Cleanup emacs-lisp-mode's use of Flymake
* lisp/progmodes/elisp-mode.el (elisp-flymake--checkdoc-1): Delete. (elisp-flymake-checkdoc): Incorporate old elisp-flymake--checkdoc-1. (elisp-flymake--byte-compile-done): Simplify. Don't cleanup here. (elisp-flymake-byte-compile): Remove spurious interactive spec. Simplify. Cleanup on every possible exit.
This commit is contained in:
parent
0d0265bf50
commit
fa92f0c447
1 changed files with 54 additions and 66 deletions
|
@ -1599,8 +1599,11 @@ ARGLIST is either a string, or a list of strings or symbols."
|
||||||
(defvar checkdoc-autofix-flag)
|
(defvar checkdoc-autofix-flag)
|
||||||
(defvar checkdoc-generate-compile-warnings-flag)
|
(defvar checkdoc-generate-compile-warnings-flag)
|
||||||
(defvar checkdoc-diagnostic-buffer)
|
(defvar checkdoc-diagnostic-buffer)
|
||||||
(defun elisp-flymake--checkdoc-1 ()
|
|
||||||
"Do actual work for `elisp-flymake-checkdoc'."
|
;;;###autoload
|
||||||
|
(defun elisp-flymake-checkdoc (report-fn &rest _args)
|
||||||
|
"A Flymake backend for `checkdoc'.
|
||||||
|
Calls REPORT-FN directly."
|
||||||
(let (collected)
|
(let (collected)
|
||||||
(let* ((checkdoc-create-error-function
|
(let* ((checkdoc-create-error-function
|
||||||
(lambda (text start end &optional unfixable)
|
(lambda (text start end &optional unfixable)
|
||||||
|
@ -1608,35 +1611,26 @@ ARGLIST is either a string, or a list of strings or symbols."
|
||||||
nil))
|
nil))
|
||||||
(checkdoc-autofix-flag nil)
|
(checkdoc-autofix-flag nil)
|
||||||
(checkdoc-generate-compile-warnings-flag nil)
|
(checkdoc-generate-compile-warnings-flag nil)
|
||||||
(buf (generate-new-buffer " *checkdoc-temp*"))
|
(checkdoc-diagnostic-buffer
|
||||||
(checkdoc-diagnostic-buffer buf))
|
(generate-new-buffer " *checkdoc-temp*")))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(checkdoc-current-buffer t))
|
(checkdoc-current-buffer t))
|
||||||
(kill-buffer buf)))
|
(kill-buffer checkdoc-diagnostic-buffer)))
|
||||||
collected))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun elisp-flymake-checkdoc (report-fn &rest _args)
|
|
||||||
"A Flymake backend for `checkdoc'.
|
|
||||||
Calls REPORT-FN directly."
|
|
||||||
(unless (derived-mode-p 'emacs-lisp-mode)
|
|
||||||
(error "Can only work on `emacs-lisp-mode' buffers"))
|
|
||||||
(funcall report-fn
|
(funcall report-fn
|
||||||
(cl-loop for (text start end _unfixable) in
|
(cl-loop for (text start end _unfixable) in
|
||||||
(elisp-flymake--checkdoc-1)
|
collected
|
||||||
collect
|
collect
|
||||||
(flymake-make-diagnostic
|
(flymake-make-diagnostic
|
||||||
(current-buffer)
|
(current-buffer)
|
||||||
start end :note text))))
|
start end :note text)))
|
||||||
|
collected))
|
||||||
|
|
||||||
(defun elisp-flymake--byte-compile-done (report-fn
|
(defun elisp-flymake--byte-compile-done (report-fn
|
||||||
origin-buffer
|
source-buffer
|
||||||
output-buffer
|
output-buffer)
|
||||||
temp-file)
|
|
||||||
(unwind-protect
|
|
||||||
(with-current-buffer
|
(with-current-buffer
|
||||||
origin-buffer
|
source-buffer
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
|
@ -1662,9 +1656,7 @@ Calls REPORT-FN directly."
|
||||||
(if (= beg end) (1- beg) beg)
|
(if (= beg end) (1- beg) beg)
|
||||||
end
|
end
|
||||||
level
|
level
|
||||||
string))))))
|
string)))))))
|
||||||
(kill-buffer output-buffer)
|
|
||||||
(ignore-errors (delete-file temp-file))))
|
|
||||||
|
|
||||||
(defvar-local elisp-flymake--byte-compile-process nil
|
(defvar-local elisp-flymake--byte-compile-process nil
|
||||||
"Buffer-local process started for byte-compiling the buffer.")
|
"Buffer-local process started for byte-compiling the buffer.")
|
||||||
|
@ -1674,16 +1666,11 @@ Calls REPORT-FN directly."
|
||||||
"A Flymake backend for elisp byte compilation.
|
"A Flymake backend for elisp byte compilation.
|
||||||
Spawn an Emacs process that byte-compiles a file representing the
|
Spawn an Emacs process that byte-compiles a file representing the
|
||||||
current buffer state and calls REPORT-FN when done."
|
current buffer state and calls REPORT-FN when done."
|
||||||
(interactive (list (lambda (stuff)
|
|
||||||
(message "aha %s" stuff))))
|
|
||||||
(unless (derived-mode-p 'emacs-lisp-mode)
|
|
||||||
(error "Can only work on `emacs-lisp-mode' buffers"))
|
|
||||||
(when elisp-flymake--byte-compile-process
|
(when elisp-flymake--byte-compile-process
|
||||||
(process-put elisp-flymake--byte-compile-process 'elisp-flymake--obsolete t)
|
|
||||||
(when (process-live-p elisp-flymake--byte-compile-process)
|
(when (process-live-p elisp-flymake--byte-compile-process)
|
||||||
(kill-process elisp-flymake--byte-compile-process)))
|
(kill-process elisp-flymake--byte-compile-process)))
|
||||||
(let ((temp-file (make-temp-file "elisp-flymake-byte-compile"))
|
(let ((temp-file (make-temp-file "elisp-flymake-byte-compile"))
|
||||||
(origin-buffer (current-buffer)))
|
(source-buffer (current-buffer)))
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
(write-region (point-min) (point-max) temp-file nil 'nomessage))
|
(write-region (point-min) (point-max) temp-file nil 'nomessage))
|
||||||
|
@ -1703,21 +1690,22 @@ current buffer state and calls REPORT-FN when done."
|
||||||
:connection-type 'pipe
|
:connection-type 'pipe
|
||||||
:sentinel
|
:sentinel
|
||||||
(lambda (proc _event)
|
(lambda (proc _event)
|
||||||
(unless (process-live-p proc)
|
(when (eq (process-status proc) 'exit)
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(cond
|
(cond
|
||||||
|
((not (eq proc elisp-flymake--byte-compile-process))
|
||||||
|
(flymake-log :warning "byte-compile process %s obsolete" proc))
|
||||||
((zerop (process-exit-status proc))
|
((zerop (process-exit-status proc))
|
||||||
(elisp-flymake--byte-compile-done report-fn
|
(elisp-flymake--byte-compile-done report-fn
|
||||||
origin-buffer
|
source-buffer
|
||||||
output-buffer
|
output-buffer))
|
||||||
temp-file))
|
|
||||||
((process-get proc 'elisp-flymake--obsolete)
|
|
||||||
(flymake-log :warning "byte-compile process %s obsolete" proc))
|
|
||||||
(t
|
(t
|
||||||
(funcall report-fn
|
(funcall report-fn
|
||||||
:panic
|
:panic
|
||||||
:explanation
|
:explanation
|
||||||
(format "byte-compile process %s died" proc)))))))))
|
(format "byte-compile process %s died" proc))))
|
||||||
|
(ignore-errors (delete-file temp-file))
|
||||||
|
(kill-buffer output-buffer))))))
|
||||||
:stderr null-device
|
:stderr null-device
|
||||||
:noquery t)))
|
:noquery t)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue