From 30ea272fe472ed77eab40179f43bb7bee5184912 Mon Sep 17 00:00:00 2001 From: João Távora Date: Sun, 1 Oct 2017 13:30:38 +0100 Subject: 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 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lisp/emacs-lisp/bytecomp.el') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 1b42961f1a4..590db570c56 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 -- cgit v1.2.3