[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 c1661fc 36/3
From: |
João Távora |
Subject: |
[Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 c1661fc 36/39: Hook Flymake onto proper checkdoc and byte-compile interfaces |
Date: |
Mon, 2 Oct 2017 20:12:27 -0400 (EDT) |
branch: scratch/flymake-refactor-cleaner-for-emacs-26
commit c1661fc80c4e0a33e986ca113b0eee21bde036a3
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Hook Flymake onto proper checkdoc and byte-compile interfaces
The interfaces in bytecomp.el and checkdoc.el are mostly boilerplate,
with little knowledge of actual internals or thought given to the
usefulness of said interfaces in contexts other than Flymake's.
* lisp/emacs-lisp/bytecomp.el
(byte-compile-log-warning-function): New variable.
(byte-compile-log-warning): Use it.
(byte-compile--log-warning-for-byte-compile): New function.
* lisp/emacs-lisp/checkdoc.el
(checkdoc-create-error-function): New variable.
(checkdoc-create-error): Use it.
(checkdoc--create-error-for-checkdoc): New function.xo
* lisp/progmodes/flymake-elisp.el (flymake-elisp--checkdoc-1):
Use checkdoc-create-error-function.
(flymake-elisp--batch-byte-compile): Use
byte-compile-log-warning-function.
---
lisp/emacs-lisp/bytecomp.el | 22 ++++++++++++++++++++++
lisp/emacs-lisp/checkdoc.el | 19 ++++++++++++++++---
lisp/progmodes/flymake-elisp.el | 38 +++++++++++++++++++-------------------
3 files changed, 57 insertions(+), 22 deletions(-)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 1b42961..590db57 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1183,7 +1183,29 @@ Each function's symbol gets added to
`byte-compile-noruntime-functions'."
(compilation-forget-errors)
pt))))
+(defvar byte-compile-log-warning-function
+ #'byte-compile--log-warning-for-byte-compile
+ "Function called when encountering a warning or error.
+Called with arguments (STRING POSITION FILL LEVEL). STRING is a
+message describing the problem. POSITION is a buffer position
+where the problem was detected. FILL is a prefix as in
+`warning-fill-prefix'. LEVEL is the level of the
+problem (`:warning' or `:error'). POSITION, FILL and LEVEL may be
+nil.")
+
(defun byte-compile-log-warning (string &optional fill level)
+ "Log a byte-compilation warning.
+STRING, FILL and LEVEL are as described in
+`byte-compile-log-warning-function', which see."
+ (funcall byte-compile-log-warning-function
+ string byte-compile-last-position
+ fill
+ level))
+
+(defun byte-compile--log-warning-for-byte-compile (string &optional
+ _position
+ fill
+ level)
"Log a message STRING in `byte-compile-log-buffer'.
Also log the current function and file if not already done. If
FILL is non-nil, set `warning-fill-prefix' to four spaces. LEVEL
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 7997ba6..72f82f2 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -1147,14 +1147,27 @@ Prefix argument is the same as for `checkdoc-defun'"
;; features and behaviors, so we need some ways of specifying
;; them, and making them easier to use in the wacked-out interfaces
;; people are requesting
-(defun checkdoc-create-error (text start end &optional unfixable)
- "Used to create the return error text returned from all engines.
+(defvar checkdoc-create-error-function #'checkdoc--create-error-for-checkdoc
+ "Function called when Checkdoc encounters an error.
+Should accept as arguments (TEXT START END &optional UNFIXABLE).
+
TEXT is the descriptive text of the error. START and END define the region
it is sensible to highlight when describing the problem.
Optional argument UNFIXABLE means that the error has no auto-fix available.
A list of the form (TEXT START END UNFIXABLE) is returned if we are not
-generating a buffered list of errors."
+generating a buffered list of errors.")
+
+(defun checkdoc-create-error (text start end &optional unfixable)
+ "Used to create the return error text returned from all engines.
+TEXT, START, END and UNFIXABLE conform to
+`checkdoc-create-error-function', which see."
+ (funcall checkdoc-create-error-function text start end unfixable))
+
+(defun checkdoc--create-error-for-checkdoc (text start end &optional unfixable)
+ "Create an error for Checkdoc.
+TEXT, START, END and UNFIXABLE conform to
+`checkdoc-create-error-function', which see."
(if checkdoc-generate-compile-warnings-flag
(progn (checkdoc-error start text)
nil)
diff --git a/lisp/progmodes/flymake-elisp.el b/lisp/progmodes/flymake-elisp.el
index b42767c..b433dc2 100644
--- a/lisp/progmodes/flymake-elisp.el
+++ b/lisp/progmodes/flymake-elisp.el
@@ -32,18 +32,18 @@
(defun flymake-elisp--checkdoc-1 ()
"Do actual work for `flymake-elisp-checkdoc'."
(let (collected)
- (cl-letf (((symbol-function 'checkdoc-create-error)
- (lambda (text start end &optional unfixable)
- (push (list text start end unfixable) collected)
- nil)))
- (let* ((checkdoc-autofix-flag nil)
- (checkdoc-generate-compile-warnings-flag nil)
- (buf (generate-new-buffer " *checkdoc-temp*"))
- (checkdoc-diagnostic-buffer buf))
- (unwind-protect
- (save-excursion
- (checkdoc-current-buffer t))
- (kill-buffer buf))))
+ (let* ((checkdoc-create-error-function
+ (lambda (text start end &optional unfixable)
+ (push (list text start end unfixable) collected)
+ nil))
+ (checkdoc-autofix-flag nil)
+ (checkdoc-generate-compile-warnings-flag nil)
+ (buf (generate-new-buffer " *checkdoc-temp*"))
+ (checkdoc-diagnostic-buffer buf))
+ (unwind-protect
+ (save-excursion
+ (checkdoc-current-buffer t))
+ (kill-buffer buf)))
collected))
;;;###autoload
@@ -165,14 +165,14 @@ Runs in a batch-mode Emacs. Interactively use variable
(byte-compile-dest-file-function
(lambda (source)
(setq dummy-elc-file (make-temp-file (file-name-nondirectory
source)))))
- (collected))
+ (collected)
+ (byte-compile-log-warning-function
+ (lambda (string &optional position fill level)
+ (push (list string position fill level)
+ collected)
+ t)))
(unwind-protect
- (cl-letf (((symbol-function 'byte-compile-log-warning)
- (lambda (string &optional fill level)
- (push (list string byte-compile-last-position fill level)
- collected)
- t)))
- (byte-compile-file file))
+ (byte-compile-file file)
(ignore-errors
(delete-file dummy-elc-file)
(kill-buffer byte-compile-log-buffer)))
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 0a4e420 16/39: Protect Flymake's eager checks against commands like fill-paragraph, (continued)
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 0a4e420 16/39: Protect Flymake's eager checks against commands like fill-paragraph, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 c8004c6 03/39: Completely rewrite Flymake's subprocess output processing, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2b48161 21/39: Tweak Flymake commands flymake-goto-[next/prev]-error, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2dd9e04 24/39: Add interactive flymake-start function, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 a458e1a 26/39: Treat flymake errors as just another type of diagnostic, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4ae24d7 20/39: Flymake's flymake-proc.el backend slightly easier to debug, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4d6d56d 27/39: Remove old flymake-display-err-menu-for-current-line, it's useless, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 ef67227 29/39: Explicitly add a(n empty) keymap for Flymake, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2b735b4 08/39: New Flymake variable flymake-diagnostic-types-alist and much cleanup, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2971cd0 38/39: Minimal tweak as an attempt to future-proof Flymake API, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 c1661fc 36/39: Hook Flymake onto proper checkdoc and byte-compile interfaces,
João Távora <=
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 38fdbd6 34/39: Capitalize "Flymake" in docstrings and comments, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 b80d29d 39/39: Start rewriting Flymake manual, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 b4099cb 18/39: New Flymake API variable flymake-diagnostic-functions, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 a506cc6 25/39: Fix three Flymake bugs when checking C header files, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 de4e13a 17/39: More Flymake cleanup before advancing to backend redesign, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 fd9e32c 15/39: Flymake highlights GCC info/notes as detected by flymake-proc.el, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 be9dd4c 32/39: Improve use of flymake-no-changes-timeout, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 8f0f9cc 28/39: Flymake uses some new fringe bitmaps, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 3ecfe98 35/39: Tweak Flymake autoloads and dependencies, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 26ac964 23/39: A couple of Flymake backends for emacs-lisp-mode, João Távora, 2017/10/02