[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f560e759338: ruby-rubocop-use-bundler: New user option
From: |
Dmitry Gutov |
Subject: |
master f560e759338: ruby-rubocop-use-bundler: New user option |
Date: |
Sun, 12 May 2024 22:38:03 -0400 (EDT) |
branch: master
commit f560e759338e4cd43113fef39bb6e35c9e8a5893
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>
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.
---
etc/NEWS | 5 +++++
lisp/progmodes/ruby-mode.el | 26 +++++++++++++++++++++-----
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 846bf759995..8a2c8950fd8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1706,6 +1706,11 @@ options of GNU 'ls'.
If non-nil, moving point forward or backward between widgets by typing
'TAB' or 'S-TAB' skips over inactive widgets. The default value is nil.
+** Ruby mode
+New user option 'ruby-rubocop-use-bundler'. By default it retains the
+previous behavior: read the contens of Gemfile and act accordingly. But
+you can also set it to t or nil to skip the check.
+
** Miscellaneous
---
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
:type 'string
:safe 'stringp)
+(defcustom ruby-rubocop-use-bundler 'check
+ "Non-nil with allow `ruby-flymake-rubocop' to use `bundle exec'.
+When the value is `check', it will first see whether Gemfile exists in
+the same directory as the configuration file, and whether it mentions
+the gem \"rubocop\". When t, it's used unconditionally. "
+ :type '(choice (const :tag "Always" t)
+ (const :tag "No" nil)
+ (const :tag "If rubocop is in Gemfile" check))
+ :safe 'booleanp)
+
(defun ruby-flymake-rubocop (report-fn &rest _args)
"RuboCop backend for Flymake."
(unless (executable-find "rubocop")
@@ -2614,11 +2624,17 @@ If there is no Rubocop config file, Rubocop will be
passed a flag
finally (funcall report-fn diags)))))))
(defun ruby-flymake-rubocop--use-bundler-p (dir)
- (let ((file (expand-file-name "Gemfile" dir)))
- (and (file-exists-p file)
- (with-temp-buffer
- (insert-file-contents file)
- (re-search-forward "^ *gem ['\"]rubocop['\"]" nil t)))))
+ (cond
+ ((eq t ruby-rubocop-use-bundler)
+ t)
+ ((null ruby-rubocop-use-bundler)
+ nil)
+ (t
+ (let ((file (expand-file-name "Gemfile" dir)))
+ (and (file-exists-p file)
+ (with-temp-buffer
+ (insert-file-contents file)
+ (re-search-forward "^ *gem ['\"]rubocop['\"]" nil t)))))))
(defun ruby-flymake-auto (report-fn &rest args)
(apply
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master f560e759338: ruby-rubocop-use-bundler: New user option,
Dmitry Gutov <=