From 2e84179a291c6fce57d5e6c44121d77160487615 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 1 Oct 2017 01:24:31 +0100 Subject: [PATCH] Tweak Flymake autoloads and dependencies * lisp/progmodes/elisp-mode.el (emacs-lisp-mode): Add to flymake-diagnostic-functions here. * lisp/progmodes/flymake-elisp.el[top]: Don't add to emacs-lisp-mode-hook. Don't call flymake-elisp-setup-backends in every buffer. (flymake-elisp-checkdoc) (flymake-elisp-byte-compile): Autoload. (flymake-elisp-setup-backends): Remove. * lisp/progmodes/flymake.el: Add some top-level comments. (flymake-make-diagnostic) (flymake-mode, flymake-mode-on, flymake-mode-off): Add autoloads Where to fixup this shit? --- lisp/progmodes/elisp-mode.el | 4 +++- lisp/progmodes/flymake-elisp.el | 18 ++++-------------- lisp/progmodes/flymake.el | 28 ++++++++++++++++++---------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 2f8e081a295..cace2bd7497 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -243,7 +243,9 @@ Blank lines separate paragraphs. Semicolons start comments. (add-hook 'xref-backend-functions #'elisp--xref-backend nil t) (setq-local project-vc-external-roots-function #'elisp-load-path-roots) (add-hook 'completion-at-point-functions - #'elisp-completion-at-point nil 'local)) + #'elisp-completion-at-point nil 'local) + (add-hook 'flymake-diagnostic-functions #'flymake-elisp-checkdoc nil t) + (add-hook 'flymake-diagnostic-functions #'flymake-elisp-byte-compile nil t)) ;; Font-locking support. diff --git a/lisp/progmodes/flymake-elisp.el b/lisp/progmodes/flymake-elisp.el index 94907e66cc5..b42767c3fac 100644 --- a/lisp/progmodes/flymake-elisp.el +++ b/lisp/progmodes/flymake-elisp.el @@ -20,7 +20,8 @@ ;;; Commentary: -;; Flymake backends for elisp work. +;; Flymake backends for elisp work, `flymake-elisp-checkdoc' and +;; `flymake-elisp-byte-compile'. ;;; Code: (require 'flymake) @@ -45,6 +46,7 @@ (kill-buffer buf)))) collected)) +;;;###autoload (defun flymake-elisp-checkdoc (report-fn) "A Flymake backend for `checkdoc'. Calls REPORT-FN directly." @@ -98,6 +100,7 @@ Calls REPORT-FN directly." (defvar-local flymake-elisp--byte-compile-process nil "Buffer-local process started for byte-compiling the buffer.") +;;;###autoload (defun flymake-elisp-byte-compile (report-fn) "A Flymake backend for elisp byte compilation. Spawn an Emacs process that byte-compiles a file representing the @@ -177,18 +180,5 @@ Runs in a batch-mode Emacs. Interactively use variable (terpri) (pp collected))) -(defun flymake-elisp-setup-backends () - "Setup Flymake for elisp work." - (add-hook 'flymake-diagnostic-functions 'flymake-elisp-checkdoc t t) - (add-hook 'flymake-diagnostic-functions 'flymake-elisp-byte-compile t t)) - -(add-hook 'emacs-lisp-mode-hook - 'flymake-elisp-setup-backends) - -(dolist (buffer (buffer-list)) - (with-current-buffer buffer - (when (derived-mode-p 'emacs-lisp-mode) - (flymake-elisp-setup-backends)))) - (provide 'flymake-elisp) ;;; flymake-elisp.el ends here diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 060f164b794..48ec361600a 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -26,9 +26,21 @@ ;; ;; Flymake is a minor Emacs mode performing on-the-fly syntax checks. ;; +;; Flymake collects diagnostic information for multiple sources, +;; called backends, and visually annotates the relevant portions in +;; the buffer. +;; ;; This file contains the UI for displaying and interacting with the -;; results of such checks, as well as entry points for backends to -;; hook on to. Backends are sources of diagnostic info. +;; results produced by these backends, as well as entry points for +;; backends to hook on to. +;; +;; The main entry points are `flymake-mode' and `flymake-start' +;; +;; The docstrings of these variabless are relevant to understanding how +;; Flymake works for both the user and the backend programmer: +;; +;; * `flymake-diagnostic-functions' +;; * `flymake-diagnostic-types-alist' ;; ;;; Code: @@ -195,6 +207,7 @@ generated it." (:constructor flymake--diag-make)) buffer beg end type text backend) +;;;###autoload (defun flymake-make-diagnostic (buffer beg end @@ -681,9 +694,8 @@ Interactively, with a prefix arg, FORCE is t." (start)))) (defvar flymake-mode-map - (let ((map (make-sparse-keymap))) - map) - "Keymap for `flymake-mode'.") + (let ((map (make-sparse-keymap))) map) + "Keymap for `flymake-mode'") ;;;###autoload (define-minor-mode flymake-mode nil @@ -770,7 +782,6 @@ Do it only if `flymake-no-changes-timeout' is non-nil." (cancel-timer flymake-timer) (setq flymake-timer nil))) -;;;###autoload (defun flymake-find-file-hook () (unless (or flymake-mode (null flymake-diagnostic-functions)) @@ -956,11 +967,8 @@ applied." '(:propertize " ")) (:propertize "]"))))))) - - - (provide 'flymake) (require 'flymake-proc) -(require 'flymake-elisp) + ;;; flymake.el ends here -- 2.39.2