diff options
| author | Dmitry Gutov | 2024-05-13 05:36:28 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2024-05-13 05:37:05 +0300 |
| commit | f560e759338e4cd43113fef39bb6e35c9e8a5893 (patch) | |
| tree | f1ea2b04c00bed9afbb15bbb5d319764e68d4573 | |
| parent | ad588f81317db2faa2770a700f0e29a3b74ae682 (diff) | |
| download | emacs-f560e759338e4cd43113fef39bb6e35c9e8a5893.tar.gz emacs-f560e759338e4cd43113fef39bb6e35c9e8a5893.zip | |
ruby-rubocop-use-bundler: New user option
* lisp/progmodes/ruby-mode.el (ruby-rubocop-use-bundler):
New user option.
(ruby-flymake-rubocop--use-bundler-p): Use it.
* etc/NEWS: Mention it.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 26 |
2 files changed, 26 insertions, 5 deletions
| @@ -1706,6 +1706,11 @@ options of GNU 'ls'. | |||
| 1706 | If non-nil, moving point forward or backward between widgets by typing | 1706 | If non-nil, moving point forward or backward between widgets by typing |
| 1707 | 'TAB' or 'S-TAB' skips over inactive widgets. The default value is nil. | 1707 | 'TAB' or 'S-TAB' skips over inactive widgets. The default value is nil. |
| 1708 | 1708 | ||
| 1709 | ** Ruby mode | ||
| 1710 | New user option 'ruby-rubocop-use-bundler'. By default it retains the | ||
| 1711 | previous behavior: read the contens of Gemfile and act accordingly. But | ||
| 1712 | you can also set it to t or nil to skip the check. | ||
| 1713 | |||
| 1709 | ** Miscellaneous | 1714 | ** Miscellaneous |
| 1710 | 1715 | ||
| 1711 | --- | 1716 | --- |
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 999fbebfb08..f6ef175e11e 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -2553,6 +2553,16 @@ If there is no Rubocop config file, Rubocop will be passed a flag | |||
| 2553 | :type 'string | 2553 | :type 'string |
| 2554 | :safe 'stringp) | 2554 | :safe 'stringp) |
| 2555 | 2555 | ||
| 2556 | (defcustom ruby-rubocop-use-bundler 'check | ||
| 2557 | "Non-nil with allow `ruby-flymake-rubocop' to use `bundle exec'. | ||
| 2558 | When the value is `check', it will first see whether Gemfile exists in | ||
| 2559 | the same directory as the configuration file, and whether it mentions | ||
| 2560 | the gem \"rubocop\". When t, it's used unconditionally. " | ||
| 2561 | :type '(choice (const :tag "Always" t) | ||
| 2562 | (const :tag "No" nil) | ||
| 2563 | (const :tag "If rubocop is in Gemfile" check)) | ||
| 2564 | :safe 'booleanp) | ||
| 2565 | |||
| 2556 | (defun ruby-flymake-rubocop (report-fn &rest _args) | 2566 | (defun ruby-flymake-rubocop (report-fn &rest _args) |
| 2557 | "RuboCop backend for Flymake." | 2567 | "RuboCop backend for Flymake." |
| 2558 | (unless (executable-find "rubocop") | 2568 | (unless (executable-find "rubocop") |
| @@ -2614,11 +2624,17 @@ If there is no Rubocop config file, Rubocop will be passed a flag | |||
| 2614 | finally (funcall report-fn diags))))))) | 2624 | finally (funcall report-fn diags))))))) |
| 2615 | 2625 | ||
| 2616 | (defun ruby-flymake-rubocop--use-bundler-p (dir) | 2626 | (defun ruby-flymake-rubocop--use-bundler-p (dir) |
| 2617 | (let ((file (expand-file-name "Gemfile" dir))) | 2627 | (cond |
| 2618 | (and (file-exists-p file) | 2628 | ((eq t ruby-rubocop-use-bundler) |
| 2619 | (with-temp-buffer | 2629 | t) |
| 2620 | (insert-file-contents file) | 2630 | ((null ruby-rubocop-use-bundler) |
| 2621 | (re-search-forward "^ *gem ['\"]rubocop['\"]" nil t))))) | 2631 | nil) |
| 2632 | (t | ||
| 2633 | (let ((file (expand-file-name "Gemfile" dir))) | ||
| 2634 | (and (file-exists-p file) | ||
| 2635 | (with-temp-buffer | ||
| 2636 | (insert-file-contents file) | ||
| 2637 | (re-search-forward "^ *gem ['\"]rubocop['\"]" nil t))))))) | ||
| 2622 | 2638 | ||
| 2623 | (defun ruby-flymake-auto (report-fn &rest args) | 2639 | (defun ruby-flymake-auto (report-fn &rest args) |
| 2624 | (apply | 2640 | (apply |