emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 7cf59c6 1/2: Revert "Add flymake-backends defcust


From: João Távora
Subject: [Emacs-diffs] emacs-26 7cf59c6 1/2: Revert "Add flymake-backends defcustom"
Date: Thu, 28 Sep 2017 03:10:47 -0400 (EDT)

branch: emacs-26
commit 7cf59c6635f747fe2d974b92be1fd937d3821681
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Revert "Add flymake-backends defcustom"
    
    This reverts Git commit 13993c46a21495167517f76d2e36b6c09ac5e89e.
    
    Don't merge this back to master as development happening there builds
    upon this work. See also
    https://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00932.html
---
 lisp/progmodes/flymake-proc.el | 23 ++++--------
 lisp/progmodes/flymake-ui.el   | 84 ++++++++++++++----------------------------
 2 files changed, 34 insertions(+), 73 deletions(-)

diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index df1a075..0cbf3e1 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -123,12 +123,10 @@ NAME is the file name function to use, default 
`flymake-get-real-file-name'."
     (flymake-log 3 "file %s, init=%s" file-name (car mode-and-masks))
     mode-and-masks))
 
-(defun flymake-proc-can-syntax-check-buffer ()
-  "Determine whether we can syntax check current buffer.
-Return nil if we cannot, non-nil if
-we can."
-  (and buffer-file-name
-       (if (flymake-get-init-function buffer-file-name) t nil)))
+(defun flymake-can-syntax-check-file (file-name)
+  "Determine whether we can syntax check FILE-NAME.
+Return nil if we cannot, non-nil if we can."
+  (if (flymake-get-init-function file-name) t nil))
 
 (defun flymake-get-init-function (file-name)
   "Return init function to be used for the file."
@@ -719,11 +717,12 @@ Return its components if so, nil otherwise."
     (error
      (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name))))
 
-(defun flymake-proc-start-syntax-check ()
+(defun flymake-start-syntax-check ()
   "Start syntax checking for current buffer."
   (interactive)
   (flymake-log 3 "flymake is running: %s" flymake-is-running)
-  (when (not flymake-is-running)
+  (when (and (not flymake-is-running)
+             (flymake-can-syntax-check-file buffer-file-name))
     (when (or (not flymake-compilation-prevents-syntax-check)
               (not (flymake-compilation-is-running))) ;+ 
(flymake-rep-ort-status buffer "COMP")
       (flymake-clear-buildfile-cache)
@@ -1088,13 +1087,5 @@ Use CREATE-TEMP-F for creating temp copy."
         (list "val" (flymake-init-create-temp-buffer-copy
                      'flymake-create-temp-inplace))))
 
-
-;;;; Hook onto flymake-ui
-
-(add-to-list 'flymake-backends
-             `(flymake-proc-can-syntax-check-buffer
-               .
-               flymake-proc-start-syntax-check))
-
 (provide 'flymake-proc)
 ;;; flymake-proc.el ends here
diff --git a/lisp/progmodes/flymake-ui.el b/lisp/progmodes/flymake-ui.el
index bf5218c..2a15a49 100644
--- a/lisp/progmodes/flymake-ui.el
+++ b/lisp/progmodes/flymake-ui.el
@@ -108,17 +108,6 @@ See `flymake-error-bitmap' and `flymake-warning-bitmap'."
   :group 'flymake
   :type 'integer)
 
-(defcustom flymake-backends '()
-  "Ordered list of backends providing syntax check information for a buffer.
-Value is an alist of conses (PREDICATE . CHECKER). Both PREDICATE
-and CHECKER are functions called with a single argument, the
-buffer in which `flymake-mode' was enabled. PREDICATE is expected
-to (quickly) return t or nil if the buffer can be syntax checked
-by CHECKER, which in can performs more morose operations,
-possibly asynchronously."
-  :group 'flymake
-  :type 'alist)
-
 (defvar-local flymake-timer nil
   "Timer for starting syntax check.")
 
@@ -379,7 +368,7 @@ For the format of LINE-ERR-INFO, see 
`flymake-ler-make-ler'."
 
        (setq flymake-last-change-time nil)
        (flymake-log 3 "starting syntax check as more than 1 second passed 
since last change")
-       (flymake--start-syntax-check)))))
+       (flymake-start-syntax-check)))))
 
 (define-obsolete-function-alias 'flymake-display-err-menu-for-current-line
   'flymake-popup-current-error-menu "24.4")
@@ -453,20 +442,6 @@ For the format of LINE-ERR-INFO, see 
`flymake-ler-make-ler'."
   (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status 
%s, warning %s"
                (buffer-name) status warning))
 
-(defvar-local flymake--backend nil
-  "The currently active backend selected by `flymake-mode'")
-
-(defun flymake--can-syntax-check-buffer (buffer)
-  (let ((all flymake-backends)
-        (candidate))
-    (catch 'done
-      (while (setq candidate (pop all))
-        (when (with-current-buffer buffer (funcall (car candidate)))
-          (throw 'done (cdr candidate)))))))
-
-(defun flymake--start-syntax-check ()
-  (funcall flymake--backend))
-
 ;;;###autoload
 (define-minor-mode flymake-mode nil
   :group 'flymake :lighter flymake-mode-line
@@ -474,36 +449,31 @@ For the format of LINE-ERR-INFO, see 
`flymake-ler-make-ler'."
 
    ;; Turning the mode ON.
    (flymake-mode
-    (let* ((backend (flymake--can-syntax-check-buffer (current-buffer))))
-      (cond
-       ((not backend)
-        (flymake-log 2 "flymake cannot check syntax in buffer %s" 
(buffer-name)))
-       (t
-        (setq flymake--backend backend)
-
-        (add-hook 'after-change-functions 'flymake-after-change-function nil t)
-        (add-hook 'after-save-hook 'flymake-after-save-hook nil t)
-        (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
-        ;;+(add-hook 'find-file-hook 'flymake-find-file-hook)
-
-        (flymake-report-status "" "")
-
-        (setq flymake-timer
-              (run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
-
-        (when (and flymake-start-syntax-check-on-find-file
-                   ;; Since we write temp files in current dir, there's no 
point
-                   ;; trying if the directory is read-only (bug#8954).
-                   (file-writable-p (file-name-directory buffer-file-name)))
-          (with-demoted-errors
-              (flymake--start-syntax-check)))))
-      )
-    )
+    (cond
+     ((not buffer-file-name)
+      (message "Flymake unable to run without a buffer file name"))
+     ((not (flymake-can-syntax-check-file buffer-file-name))
+      (flymake-log 2 "flymake cannot check syntax in buffer %s" (buffer-name)))
+     (t
+      (add-hook 'after-change-functions 'flymake-after-change-function nil t)
+      (add-hook 'after-save-hook 'flymake-after-save-hook nil t)
+      (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
+      ;;+(add-hook 'find-file-hook 'flymake-find-file-hook)
+
+      (flymake-report-status "" "")
+
+      (setq flymake-timer
+            (run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
+
+      (when (and flymake-start-syntax-check-on-find-file
+                 ;; Since we write temp files in current dir, there's no point
+                 ;; trying if the directory is read-only (bug#8954).
+                 (file-writable-p (file-name-directory buffer-file-name)))
+        (with-demoted-errors
+          (flymake-start-syntax-check))))))
 
    ;; Turning the mode OFF.
    (t
-    (setq flymake--backend nil)
-
     (remove-hook 'after-change-functions 'flymake-after-change-function t)
     (remove-hook 'after-save-hook 'flymake-after-save-hook t)
     (remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t)
@@ -538,14 +508,14 @@ For the format of LINE-ERR-INFO, see 
`flymake-ler-make-ler'."
   (let((new-text (buffer-substring start stop)))
     (when (and flymake-start-syntax-check-on-newline (equal new-text "\n"))
       (flymake-log 3 "starting syntax check as new-line has been seen")
-      (flymake--start-syntax-check))
+      (flymake-start-syntax-check))
     (setq flymake-last-change-time (float-time))))
 
 (defun flymake-after-save-hook ()
   (if (local-variable-p 'flymake-mode (current-buffer))        ; (???) other 
way to determine whether flymake is active in buffer being saved?
       (progn
        (flymake-log 3 "starting syntax check as buffer was saved")
-       (flymake--start-syntax-check)))) ; no more mode 3. cannot start check 
if mode 3 (to temp copies) is active - (???)
+       (flymake-start-syntax-check)))) ; no more mode 3. cannot start check if 
mode 3 (to temp copies) is active - (???)
 
 (defun flymake-kill-buffer-hook ()
   (when flymake-timer
@@ -556,10 +526,10 @@ For the format of LINE-ERR-INFO, see 
`flymake-ler-make-ler'."
 (defun flymake-find-file-hook ()
   ;;+(when flymake-start-syntax-check-on-find-file
   ;;+    (flymake-log 3 "starting syntax check on file open")
-  ;;+    (flymake--start-syntax-check)
+  ;;+    (flymake-start-syntax-check)
   ;;+)
   (when (and (not (local-variable-p 'flymake-mode (current-buffer)))
-            (flymake--can-syntax-check-buffer (current-buffer)))
+            (flymake-can-syntax-check-file buffer-file-name))
     (flymake-mode)
     (flymake-log 3 "automatically turned ON flymake mode")))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]