mirror of
https://github.com/jimeh/rubocopfmt.el.git
synced 2026-02-19 09:06:41 +00:00
Allow showing errors in dedicated buffer
This commit is contained in:
@@ -67,9 +67,18 @@ interactive use within a text-editor."
|
|||||||
:type '(repeat string)
|
:type '(repeat string)
|
||||||
:group 'rubocopfmt)
|
:group 'rubocopfmt)
|
||||||
|
|
||||||
(defcustom rubocopfmt-show-errors t
|
(defcustom rubocopfmt-show-errors 'buffer
|
||||||
"Display errors in echo area."
|
"Where to display rubocopfmt error output.
|
||||||
:type 'boolean
|
It can either be displayed in its own buffer, in the echo area,
|
||||||
|
or not at all.
|
||||||
|
|
||||||
|
Please note that Emacs outputs to the echo area when writing
|
||||||
|
files and will overwrite rubocopfmt's echo output if used from
|
||||||
|
inside a `before-save-hook'."
|
||||||
|
:type '(choice
|
||||||
|
(const :tag "Own buffer" buffer)
|
||||||
|
(const :tag "Echo area" echo)
|
||||||
|
(const :tag "None" nil))
|
||||||
:group 'rubocopfmt)
|
:group 'rubocopfmt)
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
@@ -144,14 +153,22 @@ interactive use within a text-editor."
|
|||||||
(when (search-forward "[Corrected]" split t)
|
(when (search-forward "[Corrected]" split t)
|
||||||
(write-region split (point-max) tmpfile)
|
(write-region split (point-max) tmpfile)
|
||||||
t))
|
t))
|
||||||
(rubocopfmt--display-error resultbuf)
|
(rubocopfmt--process-errors resultbuf)
|
||||||
nil))))
|
nil))))
|
||||||
|
|
||||||
(defun rubocopfmt--display-error (resultbuf)
|
(defun rubocopfmt--process-errors (resultbuf)
|
||||||
"Display contents of RESULTBUF if rubocop-show-errors is t."
|
"Display contents of RESULTBUF as errors."
|
||||||
(if rubocopfmt-show-errors
|
(if (eq rubocopfmt-show-errors 'echo)
|
||||||
(with-current-buffer resultbuf
|
(with-current-buffer resultbuf
|
||||||
(message (buffer-string)))))
|
(message (buffer-string))))
|
||||||
|
|
||||||
|
(if (eq rubocopfmt-show-errors 'buffer)
|
||||||
|
(let ((errbuf (get-buffer-create "*Rubocopfmt errors*")))
|
||||||
|
(with-current-buffer errbuf
|
||||||
|
(erase-buffer)
|
||||||
|
(goto-char (point-min))
|
||||||
|
(insert-buffer-substring resultbuf))
|
||||||
|
(display-buffer errbuf))))
|
||||||
|
|
||||||
(defun rubocopfmt--bundled-path-p (directory)
|
(defun rubocopfmt--bundled-path-p (directory)
|
||||||
"Check if there is a Gemfile in DIRECTORY, or any parent directory."
|
"Check if there is a Gemfile in DIRECTORY, or any parent directory."
|
||||||
|
|||||||
Reference in New Issue
Block a user