From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: flymake cleanups (long patch) Date: Sun, 24 Apr 2005 03:35:09 -0700 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1114338980 18584 80.91.229.2 (24 Apr 2005 10:36:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 24 Apr 2005 10:36:20 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 24 12:36:15 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DPeTC-00057T-A4 for ged-emacs-devel@m.gmane.org; Sun, 24 Apr 2005 12:36:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DPeYU-0005iH-Oi for ged-emacs-devel@m.gmane.org; Sun, 24 Apr 2005 06:41:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DPeXC-0005i9-Ux for emacs-devel@gnu.org; Sun, 24 Apr 2005 06:40:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DPeXA-0005hl-4Y for emacs-devel@gnu.org; Sun, 24 Apr 2005 06:40:18 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DPeX9-0005U8-9a for emacs-devel@gnu.org; Sun, 24 Apr 2005 06:40:15 -0400 Original-Received: from [171.67.16.123] (helo=smtp1.Stanford.EDU) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DPeVC-0006f0-91 for emacs-devel@gnu.org; Sun, 24 Apr 2005 06:38:14 -0400 Original-Received: from partenope.stanford.edu (partenope.Stanford.EDU [171.64.106.136]) by smtp1.Stanford.EDU (8.12.11/8.12.11) with ESMTP id j3OAZBEr008826 for ; Sun, 24 Apr 2005 03:35:11 -0700 Original-Received: from partenope.stanford.edu (localhost.localdomain [127.0.0.1]) by partenope.stanford.edu (8.12.8/8.12.5) with ESMTP id j3OAZA7i009801 for ; Sun, 24 Apr 2005 03:35:10 -0700 Original-Received: (from yidong@localhost) by partenope.stanford.edu (8.12.8/8.12.8/Submit) id j3OAZ9ah009799; Sun, 24 Apr 2005 03:35:09 -0700 X-Authentication-Warning: partenope.stanford.edu: yidong set sender to cyd@stupidchicken.com using -f Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:36322 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:36322 Here is a jumbo patch for the "clean up flymake.el" entry in FOR-RELEASE. It removes the `flymake-get-buffer-*' and `flymake-set-buffer-*' helper functions, a pretty strange coding convention that flymake.el uses for setting local variables. The trouble is that 99% of these functions are called inside `with-current-buffer', or with `(current-buffer)' as the argument, which means they obfuscate the code for no benefit. For example, (defun flymake-kill-buffer-hook () (when (flymake-get-buffer-timer (current-buffer)) (cancel-timer (flymake-get-buffer-timer (current-buffer))) (flymake-set-buffer-timer (current-buffer) nil))) simplifies to (defun flymake-kill-buffer-hook () (when flymake-timer (cancel-timer flymake-timer) (setq flymake-timer nil))) The patch also clarifies and adds some docstrings. Here it is: *** emacs/lisp/ChangeLog~ Sun Apr 24 18:28:30 2005 --- emacs/lisp/ChangeLog Sun Apr 24 18:27:45 2005 *************** *** 1,3 **** --- 1,15 ---- + 2005-04-24 Chong Yidong + + * progmodes/flymake.el (flymake-split-string) + (flymake-split-string, flymake-log, flymake-pid-to-names) + (flymake-reg-names, flymake-get-source-buffer-name) + (flymake-unreg-names, flymake-add-line-err-info) + (flymake-add-err-info): Clarify docstrings. + (flymake-popup-menu, flymake-make-emacs-menu) + (flymake-make-xemacs-menu): Add docstrings. + (flymake-get-buffer-*, flymake-set-buffer-*): Functions deleted. + Set variables directly throughout. + 2005-04-24 YAMAMOTO Mitsuharu * term/mac-win.el: Require select. Set selection-coding-system to *** emacs/lisp/progmodes/flymake.el~ Sun Apr 24 17:45:46 2005 --- emacs/lisp/progmodes/flymake.el Sun Apr 24 18:04:49 2005 *************** *** 62,68 **** (replace-in-string str regexp rep))) (defun flymake-split-string (str pattern) ! "Split, then remove first and/or last in case it's empty." (let* ((splitted (split-string str pattern))) (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0)))) (setq splitted (cdr splitted))) --- 62,69 ---- (replace-in-string str regexp rep))) (defun flymake-split-string (str pattern) ! "Split STR into a list of substrings bounded by PATTERN. ! Zero-length substrings at the beginning and end of the list are omitted." (let* ((splitted (split-string str pattern))) (if (and (> (length splitted) 0) (= 0 (length (elt splitted 0)))) (setq splitted (cdr splitted))) *************** *** 86,92 **** (lambda (&optional arg) (save-excursion (end-of-line arg) (point))))) (defun flymake-popup-menu (pos menu-data) ! (if (and (fboundp 'popup-menu) (fboundp 'make-event)) (let* ((x-pos (nth 0 (nth 0 pos))) (y-pos (nth 1 (nth 0 pos))) (fake-event-props '(button 1 x 1 y 1))) --- 87,98 ---- (lambda (&optional arg) (save-excursion (end-of-line arg) (point))))) (defun flymake-popup-menu (pos menu-data) ! "Pop up the flymake menu at position POS, using the data MENU-DATA. ! POS is a list of the form ((X Y) WINDOW), where X and Y are ! pixels positions from the top left corner of WINDOW's frame. ! MENU-DATA is a list of error and warning messages returned by ! `flymake-make-err-menu-data'." ! (if (featurep 'xemacs) (let* ((x-pos (nth 0 (nth 0 pos))) (y-pos (nth 1 (nth 0 pos))) (fake-event-props '(button 1 x 1 y 1))) *************** *** 96,101 **** --- 102,111 ---- (x-popup-menu pos (flymake-make-emacs-menu menu-data)))) (defun flymake-make-emacs-menu (menu-data) + "Return a menu specifier using MENU-DATA. + MENU-DATA is a list of error and warning messages returned by + `flymake-make-err-menu-data'. + See `x-popup-menu' for the menu specifier format." (let* ((menu-title (nth 0 menu-data)) (menu-items (nth 1 menu-data)) (menu-commands nil)) *************** *** 109,114 **** --- 119,125 ---- (defun flymake-nop ()) (defun flymake-make-xemacs-menu (menu-data) + "Return a menu specifier using MENU-DATA." (let* ((menu-title (nth 0 menu-data)) (menu-items (nth 1 menu-data)) (menu-commands nil)) *************** *** 152,158 **** :type 'integer) (defun flymake-log (level text &rest args) ! "Log a message with optional arguments." (if (<= level flymake-log-level) (let* ((msg (apply 'format text args))) (message msg) --- 163,173 ---- :type 'integer) (defun flymake-log (level text &rest args) ! "Log a message at level LEVEL. ! If LEVEL is higher than `flymake-log-level', the message is ! ignored. Otherwise, it is printed using `message'. ! TEXT is a format control string, and the remaining arguments ARGS ! are the string substitutions (see `format')." (if (<= level flymake-log-level) (let* ((msg (apply 'format text args))) (message msg) *************** *** 176,244 **** tmp)) (defvar flymake-pid-to-names (flymake-makehash) ! "pid -> source buffer name, output file name mapping.") (defun flymake-reg-names (pid source-buffer-name) ! "Save into in PID map." (unless (stringp source-buffer-name) (error "Invalid buffer name")) (puthash pid (list source-buffer-name) flymake-pid-to-names)) (defun flymake-get-source-buffer-name (pid) ! "Return buffer name stored in PID map." (nth 0 (gethash pid flymake-pid-to-names))) (defun flymake-unreg-names (pid) ! "Delete PID->buffer name mapping." (remhash pid flymake-pid-to-names)) - (defun flymake-get-buffer-var (buffer var-name) - "Switch to BUFFER if necessary and return local variable VAR-NAME." - (unless (bufferp buffer) - (error "Invalid buffer")) - - (if (eq buffer (current-buffer)) - (symbol-value var-name) - (with-current-buffer buffer - (symbol-value var-name)))) - - (defun flymake-set-buffer-var (buffer var-name var-value) - "Switch to BUFFER if necessary and set local variable VAR-NAME to VAR-VALUE." - (unless (bufferp buffer) - (error "Invalid buffer")) - - (if (eq buffer (current-buffer)) - (set var-name var-value) - (with-current-buffer buffer - (set var-name var-value)))) - (defvar flymake-buffer-data (flymake-makehash) "Data specific to syntax check tool, in name-value pairs.") (make-variable-buffer-local 'flymake-buffer-data) - (defun flymake-get-buffer-data (buffer) - (flymake-get-buffer-var buffer 'flymake-buffer-data)) - - (defun flymake-set-buffer-data (buffer data) - (flymake-set-buffer-var buffer 'flymake-buffer-data data)) - (defun flymake-get-buffer-value (buffer name) ! (gethash name (flymake-get-buffer-data buffer))) (defun flymake-set-buffer-value (buffer name value) ! (puthash name value (flymake-get-buffer-data buffer))) (defvar flymake-output-residual nil) (make-variable-buffer-local 'flymake-output-residual) - (defun flymake-get-buffer-output-residual (buffer) - (flymake-get-buffer-var buffer 'flymake-output-residual)) - - (defun flymake-set-buffer-output-residual (buffer residual) - (flymake-set-buffer-var buffer 'flymake-output-residual residual)) - (defcustom flymake-allowed-file-name-masks '((".+\\.c$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) (".+\\.cpp$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) --- 191,227 ---- tmp)) (defvar flymake-pid-to-names (flymake-makehash) ! "Hash table mapping PIDs to source buffer names and output files.") (defun flymake-reg-names (pid source-buffer-name) ! "Associate PID with SOURCE-BUFFER-NAME in `flymake-pid-to-names'." (unless (stringp source-buffer-name) (error "Invalid buffer name")) (puthash pid (list source-buffer-name) flymake-pid-to-names)) (defun flymake-get-source-buffer-name (pid) ! "Return buffer name associated with PID in `flymake-pid-to-names'." (nth 0 (gethash pid flymake-pid-to-names))) (defun flymake-unreg-names (pid) ! "Remove the entry associated with PID from `flymake-pid-to-names'." (remhash pid flymake-pid-to-names)) (defvar flymake-buffer-data (flymake-makehash) "Data specific to syntax check tool, in name-value pairs.") (make-variable-buffer-local 'flymake-buffer-data) (defun flymake-get-buffer-value (buffer name) ! (gethash name (with-current-buffer buffer flymake-buffer-data))) (defun flymake-set-buffer-value (buffer name value) ! (puthash name value (with-current-buffer buffer flymake-buffer-data))) (defvar flymake-output-residual nil) (make-variable-buffer-local 'flymake-output-residual) (defcustom flymake-allowed-file-name-masks '((".+\\.c$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) (".+\\.cpp$" flymake-simple-make-init flymake-simple-cleanup flymake-get-real-file-name) *************** *** 642,676 **** (flymake-parse-residual source-buffer) (flymake-post-syntax-check source-buffer exit-status command) ! (flymake-set-buffer-is-running source-buffer nil)))) (error (let ((err-str (format "Error in process sentinel for buffer %s: %s" source-buffer (error-message-string err)))) (flymake-log 0 err-str) ! (flymake-set-buffer-is-running source-buffer nil))))))) (defun flymake-post-syntax-check (source-buffer exit-status command) ! (flymake-set-buffer-err-info source-buffer (flymake-get-buffer-new-err-info source-buffer)) ! (flymake-set-buffer-new-err-info source-buffer nil) ! ! (flymake-set-buffer-err-info source-buffer (flymake-fix-line-numbers ! (flymake-get-buffer-err-info source-buffer) ! 1 ! (flymake-count-lines source-buffer))) (flymake-delete-own-overlays source-buffer) ! (flymake-highlight-err-lines source-buffer (flymake-get-buffer-err-info source-buffer)) ! ! (let ((err-count (flymake-get-err-count (flymake-get-buffer-err-info source-buffer) "e")) ! (warn-count (flymake-get-err-count (flymake-get-buffer-err-info source-buffer) "w"))) ! ! (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)" (buffer-name source-buffer) err-count warn-count ! (- (flymake-float-time) (flymake-get-buffer-check-start-time source-buffer))) ! (flymake-set-buffer-check-start-time source-buffer nil) (if (and (equal 0 err-count) (equal 0 warn-count)) (if (equal 0 exit-status) (flymake-report-status source-buffer "" "") ; PASSED ! (if (not (flymake-get-buffer-check-was-interrupted source-buffer)) (flymake-report-fatal-status (current-buffer) "CFGERR" (format "Configuration error has occured while running %s" command)) (flymake-report-status source-buffer nil ""))) ; "STOPPED" --- 625,662 ---- (flymake-parse-residual source-buffer) (flymake-post-syntax-check source-buffer exit-status command) ! (setq flymake-is-running nil)))) (error (let ((err-str (format "Error in process sentinel for buffer %s: %s" source-buffer (error-message-string err)))) (flymake-log 0 err-str) ! (with-current-buffer source-buffer ! (setq flymake-is-running nil)))))))) (defun flymake-post-syntax-check (source-buffer exit-status command) ! (with-current-buffer source-buffer ! (setq flymake-err-info flymake-new-err-info) ! (setq flymake-new-err-info nil) ! (setq flymake-err-info ! (flymake-fix-line-numbers ! flymake-err-info 1 (flymake-count-lines source-buffer)))) (flymake-delete-own-overlays source-buffer) ! (flymake-highlight-err-lines ! source-buffer (with-current-buffer source-buffer flymake-err-info)) ! (let (err-count warn-count) ! (with-current-buffer source-buffer ! (setq err-count (flymake-get-err-count flymake-err-info "e")) ! (setq warn-count (flymake-get-err-count flymake-err-info "w")) ! (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)" (buffer-name source-buffer) err-count warn-count ! (- (flymake-float-time) flymake-check-start-time)) ! (setq flymake-check-start-time nil)) ! (if (and (equal 0 err-count) (equal 0 warn-count)) (if (equal 0 exit-status) (flymake-report-status source-buffer "" "") ; PASSED ! (if (not (with-current-buffer source-buffer ! flymake-check-was-interrupted)) (flymake-report-fatal-status (current-buffer) "CFGERR" (format "Configuration error has occured while running %s" command)) (flymake-report-status source-buffer nil ""))) ; "STOPPED" *************** *** 679,716 **** (defun flymake-parse-output-and-residual (source-buffer output) "Split OUTPUT into lines, merge in residual if necessary." (with-current-buffer source-buffer ! (let* ((buffer-residual (flymake-get-buffer-output-residual source-buffer)) (total-output (if buffer-residual (concat buffer-residual output) output)) (lines-and-residual (flymake-split-output total-output)) (lines (nth 0 lines-and-residual)) (new-residual (nth 1 lines-and-residual))) ! ! (flymake-set-buffer-output-residual source-buffer new-residual) ! (flymake-set-buffer-new-err-info source-buffer (flymake-parse-err-lines ! (flymake-get-buffer-new-err-info source-buffer) ! source-buffer lines))))) (defun flymake-parse-residual (source-buffer) "Parse residual if it's non empty." (with-current-buffer source-buffer ! (when (flymake-get-buffer-output-residual source-buffer) ! (flymake-set-buffer-new-err-info source-buffer (flymake-parse-err-lines ! (flymake-get-buffer-new-err-info source-buffer) ! source-buffer ! (list (flymake-get-buffer-output-residual source-buffer)))) ! (flymake-set-buffer-output-residual source-buffer nil)))) (defvar flymake-err-info nil "Sorted list of line numbers and lists of err info in the form (file, err-text).") (make-variable-buffer-local 'flymake-err-info) - (defun flymake-get-buffer-err-info (buffer) - (flymake-get-buffer-var buffer 'flymake-err-info)) - - (defun flymake-set-buffer-err-info (buffer err-info) - (flymake-set-buffer-var buffer 'flymake-err-info err-info)) - (defun flymake-er-make-er (line-no line-err-info-list) (list line-no line-err-info-list)) --- 665,698 ---- (defun flymake-parse-output-and-residual (source-buffer output) "Split OUTPUT into lines, merge in residual if necessary." (with-current-buffer source-buffer ! (let* ((buffer-residual flymake-output-residual) (total-output (if buffer-residual (concat buffer-residual output) output)) (lines-and-residual (flymake-split-output total-output)) (lines (nth 0 lines-and-residual)) (new-residual (nth 1 lines-and-residual))) ! (with-current-buffer source-buffer ! (setq flymake-output-residual new-residual) ! (setq flymake-new-err-info ! (flymake-parse-err-lines ! flymake-new-err-info ! source-buffer lines)))))) (defun flymake-parse-residual (source-buffer) "Parse residual if it's non empty." (with-current-buffer source-buffer ! (when flymake-output-residual ! (setq flymake-new-err-info ! (flymake-parse-err-lines ! flymake-new-err-info ! source-buffer ! (list flymake-output-residual))) ! (setq flymake-output-residual nil)))) (defvar flymake-err-info nil "Sorted list of line numbers and lists of err info in the form (file, err-text).") (make-variable-buffer-local 'flymake-err-info) (defun flymake-er-make-er (line-no line-err-info-list) (list line-no line-err-info-list)) *************** *** 725,736 **** (make-variable-buffer-local 'flymake-new-err-info) - (defun flymake-get-buffer-new-err-info (buffer) - (flymake-get-buffer-var buffer 'flymake-new-err-info)) - - (defun flymake-set-buffer-new-err-info (buffer new-err-info) - (flymake-set-buffer-var buffer 'flymake-new-err-info new-err-info)) - ;; getters/setters for line-err-info: (file, line, type, text). (defun flymake-ler-make-ler (file line type text &optional full-file) (list file line type text full-file)) --- 707,712 ---- *************** *** 1067,1073 **** (and (not (flymake-ler-get-file line-one)) (not (flymake-ler-get-file line-two))))))) (defun flymake-add-line-err-info (line-err-info-list line-err-info) ! "Insert new err info favoring sorting: err-type e/w, filename nil/non-nil." (if (not line-err-info-list) (list line-err-info) (let* ((count (length line-err-info-list)) --- 1043,1053 ---- (and (not (flymake-ler-get-file line-one)) (not (flymake-ler-get-file line-two))))))) (defun flymake-add-line-err-info (line-err-info-list line-err-info) ! "Update LINE-ERR-INFO-LIST with the error LINE-ERR-INFO. ! For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'. ! The new element is inserted in the proper position, according to ! the predicate `flymake-line-err-info-is-less-or-equal'. ! The updated value of LINE-ERR-INFO-LIST is returned." (if (not line-err-info-list) (list line-err-info) (let* ((count (length line-err-info-list)) *************** *** 1079,1085 **** line-err-info-list))) (defun flymake-add-err-info (err-info-list line-err-info) ! "Add error info (file line type text) to err info list preserving sort order." (let* ((line-no (if (flymake-ler-get-file line-err-info) 1 (flymake-ler-get-line line-err-info))) (info-and-pos (flymake-find-err-info err-info-list line-no)) (exists (car info-and-pos)) --- 1059,1068 ---- line-err-info-list))) (defun flymake-add-err-info (err-info-list line-err-info) ! "Update ERR-INFO-LIST with the error LINE-ERR-INFO, preserving sort order. ! Returns the updated value of ERR-INFO-LIST. ! For the format of ERR-INFO-LIST, see `flymake-err-info'. ! For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." (let* ((line-no (if (flymake-ler-get-file line-err-info) 1 (flymake-ler-get-line line-err-info))) (info-and-pos (flymake-find-err-info err-info-list line-no)) (exists (car info-and-pos)) *************** *** 1202,1217 **** (unless (bufferp buffer) (error "Expected a buffer")) (with-current-buffer buffer ! (flymake-log 3 "flymake is running: %s" (flymake-get-buffer-is-running buffer)) ! (when (and (not (flymake-get-buffer-is-running buffer)) (flymake-can-syntax-check-file (buffer-file-name buffer))) (when (or (not flymake-compilation-prevents-syntax-check) (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP") (flymake-clear-buildfile-cache) (flymake-clear-project-include-dirs-cache) ! (flymake-set-buffer-check-was-interrupted buffer nil) ! (flymake-set-buffer-data buffer (flymake-makehash 'equal)) (let* ((source-file-name (buffer-file-name buffer)) (init-f (flymake-get-init-function source-file-name)) --- 1185,1200 ---- (unless (bufferp buffer) (error "Expected a buffer")) (with-current-buffer buffer ! (flymake-log 3 "flymake is running: %s" flymake-is-running) ! (when (and (not flymake-is-running) (flymake-can-syntax-check-file (buffer-file-name buffer))) (when (or (not flymake-compilation-prevents-syntax-check) (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP") (flymake-clear-buildfile-cache) (flymake-clear-project-include-dirs-cache) ! (setq flymake-check-was-interrupted nil) ! (setq flymake-buffer-data (flymake-makehash 'equal)) (let* ((source-file-name (buffer-file-name buffer)) (init-f (flymake-get-init-function source-file-name)) *************** *** 1225,1231 **** (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name) (funcall cleanup-f buffer)) (progn ! (flymake-set-buffer-last-change-time buffer nil) (flymake-start-syntax-check-process buffer cmd args dir)))))))) (defun flymake-start-syntax-check-process (buffer cmd args dir) --- 1208,1214 ---- (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name) (funcall cleanup-f buffer)) (progn ! (setq flymake-last-change-time nil) (flymake-start-syntax-check-process buffer cmd args dir)))))))) (defun flymake-start-syntax-check-process (buffer cmd args dir) *************** *** 1242,1250 **** (flymake-reg-names (process-id process) (buffer-name buffer)) ! (flymake-set-buffer-is-running buffer t) ! (flymake-set-buffer-last-change-time buffer nil) ! (flymake-set-buffer-check-start-time buffer (flymake-float-time)) (flymake-report-status buffer nil "*") (flymake-log 2 "started process %d, command=%s, dir=%s" --- 1225,1234 ---- (flymake-reg-names (process-id process) (buffer-name buffer)) ! (with-current-buffer buffer ! (setq flymake-is-running t) ! (setq flymake-last-change-time nil) ! (setq flymake-check-start-time (flymake-float-time))) (flymake-report-status buffer nil "*") (flymake-log 2 "started process %d, command=%s, dir=%s" *************** *** 1264,1270 **** (signal-process pid 9) (let* ((buffer-name (flymake-get-source-buffer-name pid))) (when (and buffer-name (get-buffer buffer-name)) ! (flymake-set-buffer-check-was-interrupted (get-buffer buffer-name) t))) (flymake-log 1 "killed process %d" pid)) (defun flymake-stop-all-syntax-checks () --- 1248,1255 ---- (signal-process pid 9) (let* ((buffer-name (flymake-get-source-buffer-name pid))) (when (and buffer-name (get-buffer buffer-name)) ! (with-current-buffer (get-buffer buffer-name) ! (setq flymake-check-was-interrupted t)))) (flymake-log 1 "killed process %d" pid)) (defun flymake-stop-all-syntax-checks () *************** *** 1288,1343 **** (make-variable-buffer-local 'flymake-is-running) - (defun flymake-get-buffer-is-running (buffer) - (flymake-get-buffer-var buffer 'flymake-is-running)) - - (defun flymake-set-buffer-is-running (buffer is-running) - (flymake-set-buffer-var buffer 'flymake-is-running is-running)) - (defvar flymake-timer nil "Timer for starting syntax check.") (make-variable-buffer-local 'flymake-timer) - (defun flymake-get-buffer-timer (buffer) - (flymake-get-buffer-var buffer 'flymake-timer)) - - (defun flymake-set-buffer-timer (buffer timer) - (flymake-set-buffer-var buffer 'flymake-timer timer)) - (defvar flymake-last-change-time nil "Time of last buffer change.") (make-variable-buffer-local 'flymake-last-change-time) - (defun flymake-get-buffer-last-change-time (buffer) - (flymake-get-buffer-var buffer 'flymake-last-change-time)) - - (defun flymake-set-buffer-last-change-time (buffer change-time) - (flymake-set-buffer-var buffer 'flymake-last-change-time change-time)) - (defvar flymake-check-start-time nil "Time at which syntax check was started.") (make-variable-buffer-local 'flymake-check-start-time) - (defun flymake-get-buffer-check-start-time (buffer) - (flymake-get-buffer-var buffer 'flymake-check-start-time)) - - (defun flymake-set-buffer-check-start-time (buffer check-start-time) - (flymake-set-buffer-var buffer 'flymake-check-start-time check-start-time)) - (defvar flymake-check-was-interrupted nil "Non-nil if syntax check was killed by `flymake-compile'.") (make-variable-buffer-local 'flymake-check-was-interrupted) - (defun flymake-get-buffer-check-was-interrupted (buffer) - (flymake-get-buffer-var buffer 'flymake-check-was-interrupted)) - - (defun flymake-set-buffer-check-was-interrupted (buffer interrupted) - (flymake-set-buffer-var buffer 'flymake-check-was-interrupted interrupted)) - (defcustom flymake-no-changes-timeout 0.5 "Time to wait after last change before starting compilation." :group 'flymake --- 1273,1298 ---- *************** *** 1345,1356 **** (defun flymake-on-timer-event (buffer) "Start a syntax check for buffer BUFFER if necessary." ! ;;+(flymake-log 3 "timer: running=%s, time=%s, cur-time=%s" (flymake-get-buffer-is-running buffer) (flymake-get-buffer-last-change-time buffer) (flymake-float-time)) ! (when (and (bufferp buffer) (not (flymake-get-buffer-is-running buffer))) (with-current-buffer buffer ! (when (and (flymake-get-buffer-last-change-time buffer) ! (> (flymake-float-time) (+ flymake-no-changes-timeout (flymake-get-buffer-last-change-time buffer)))) ! (flymake-set-buffer-last-change-time buffer nil) (flymake-log 3 "starting syntax check as more than 1 second passed since last change") (flymake-start-syntax-check buffer))))) --- 1300,1312 ---- (defun flymake-on-timer-event (buffer) "Start a syntax check for buffer BUFFER if necessary." ! (when (bufferp buffer) (with-current-buffer buffer ! (when (and (not flymake-is-running) ! flymake-last-change-time ! (> (flymake-float-time) (+ flymake-no-changes-timeout flymake-last-change-time))) ! ! (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 buffer))))) *************** *** 1391,1397 **** "Display a menu with errors/warnings for current line if it has errors and/or warnings." (interactive) (let* ((line-no (flymake-current-line-no)) ! (line-err-info-list (nth 0 (flymake-find-err-info (flymake-get-buffer-err-info (current-buffer)) line-no))) (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) (choice nil) (mouse-pos (flymake-get-point-pixel-pos)) --- 1347,1353 ---- "Display a menu with errors/warnings for current line if it has errors and/or warnings." (interactive) (let* ((line-no (flymake-current-line-no)) ! (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))) (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) (choice nil) (mouse-pos (flymake-get-point-pixel-pos)) *************** *** 1442,1487 **** (make-variable-buffer-local 'flymake-mode-line) - (defun flymake-get-buffer-mode-line (buffer) - (flymake-get-buffer-var buffer 'flymake-mode-line)) - - (defun flymake-set-buffer-mode-line (buffer mode-line-string) - (flymake-set-buffer-var buffer 'flymake-mode-line mode-line-string)) - (defvar flymake-mode-line-e-w nil) (make-variable-buffer-local 'flymake-mode-line-e-w) - (defun flymake-get-buffer-mode-line-e-w (buffer) - (flymake-get-buffer-var buffer 'flymake-mode-line-e-w)) - - (defun flymake-set-buffer-mode-line-e-w (buffer e-w) - (flymake-set-buffer-var buffer 'flymake-mode-line-e-w e-w)) - (defvar flymake-mode-line-status nil) (make-variable-buffer-local 'flymake-mode-line-status) - (defun flymake-get-buffer-mode-line-status (buffer) - (flymake-get-buffer-var buffer 'flymake-mode-line-status)) - - (defun flymake-set-buffer-mode-line-status (buffer status) - (flymake-set-buffer-var buffer 'flymake-mode-line-status status)) - (defun flymake-report-status (buffer e-w &optional status) "Show status in mode line." (when (bufferp buffer) (with-current-buffer buffer (when e-w ! (flymake-set-buffer-mode-line-e-w buffer e-w) ! ) (when status ! (flymake-set-buffer-mode-line-status buffer status)) (let* ((mode-line " Flymake")) ! (when (> (length (flymake-get-buffer-mode-line-e-w buffer)) 0) ! (setq mode-line (concat mode-line ":" (flymake-get-buffer-mode-line-e-w buffer)))) ! (setq mode-line (concat mode-line (flymake-get-buffer-mode-line-status buffer))) ! (flymake-set-buffer-mode-line buffer mode-line) (force-mode-line-update))))) (defun flymake-display-warning (warning) --- 1398,1424 ---- (make-variable-buffer-local 'flymake-mode-line) (defvar flymake-mode-line-e-w nil) (make-variable-buffer-local 'flymake-mode-line-e-w) (defvar flymake-mode-line-status nil) (make-variable-buffer-local 'flymake-mode-line-status) (defun flymake-report-status (buffer e-w &optional status) "Show status in mode line." (when (bufferp buffer) (with-current-buffer buffer (when e-w ! (setq flymake-mode-line-e-w e-w)) (when status ! (setq flymake-mode-line-status status)) (let* ((mode-line " Flymake")) ! (when (> (length flymake-mode-line-e-w) 0) ! (setq mode-line (concat mode-line ":" flymake-mode-line-e-w))) ! (setq mode-line (concat mode-line flymake-mode-line-status)) ! (setq flymake-mode-line mode-line) (force-mode-line-update))))) (defun flymake-display-warning (warning) *************** *** 1532,1538 **** (flymake-report-status (current-buffer) "" "") ! (flymake-set-buffer-timer (current-buffer) (run-at-time nil 1 'flymake-on-timer-event (current-buffer))) (setq flymake-mode t) (flymake-log 1 "flymake mode turned ON for buffer %s" (buffer-name (current-buffer))) --- 1469,1476 ---- (flymake-report-status (current-buffer) "" "") ! (setq flymake-timer ! (run-at-time nil 1 'flymake-on-timer-event (current-buffer))) (setq flymake-mode t) (flymake-log 1 "flymake mode turned ON for buffer %s" (buffer-name (current-buffer))) *************** *** 1550,1561 **** (flymake-delete-own-overlays (current-buffer)) ! (when (flymake-get-buffer-timer (current-buffer)) ! (cancel-timer (flymake-get-buffer-timer (current-buffer))) ! (flymake-set-buffer-timer (current-buffer) nil)) ! ! (flymake-set-buffer-is-running (current-buffer) nil) (setq flymake-mode nil) (flymake-log 1 "flymake mode turned OFF for buffer %s" (buffer-name (current-buffer))))) --- 1488,1498 ---- (flymake-delete-own-overlays (current-buffer)) ! (when flymake-timer ! (cancel-timer flymake-timer) ! (setq flymake-timer nil)) + (setq flymake-is-running nil) (setq flymake-mode nil) (flymake-log 1 "flymake mode turned OFF for buffer %s" (buffer-name (current-buffer))))) *************** *** 1571,1577 **** (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-for-current-buffer)) ! (flymake-set-buffer-last-change-time (current-buffer) (flymake-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? --- 1508,1514 ---- (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-for-current-buffer)) ! (setq flymake-last-change-time (flymake-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? *************** *** 1580,1588 **** (flymake-start-syntax-check-for-current-buffer)))) ; no more mode 3. cannot start check if mode 3 (to temp copies) is active - (???) (defun flymake-kill-buffer-hook () ! (when (flymake-get-buffer-timer (current-buffer)) ! (cancel-timer (flymake-get-buffer-timer (current-buffer))) ! (flymake-set-buffer-timer (current-buffer) nil))) (defun flymake-find-file-hook () ;;+(when flymake-start-syntax-check-on-find-file --- 1517,1525 ---- (flymake-start-syntax-check-for-current-buffer)))) ; no more mode 3. cannot start check if mode 3 (to temp copies) is active - (???) (defun flymake-kill-buffer-hook () ! (when flymake-timer ! (cancel-timer flymake-timer) ! (setq flymake-timer nil))) (defun flymake-find-file-hook () ;;+(when flymake-start-syntax-check-on-find-file *************** *** 1636,1644 **** (defun flymake-goto-next-error () "Go to next error in err ring." (interactive) ! (let ((line-no (flymake-get-next-err-line-no (flymake-get-buffer-err-info (current-buffer)) (flymake-current-line-no)))) (when (not line-no) ! (setq line-no (flymake-get-first-err-line-no (flymake-get-buffer-err-info (current-buffer)))) (flymake-log 1 "passed end of file")) (if line-no (flymake-goto-line line-no) --- 1573,1581 ---- (defun flymake-goto-next-error () "Go to next error in err ring." (interactive) ! (let ((line-no (flymake-get-next-err-line-no flymake-err-info (flymake-current-line-no)))) (when (not line-no) ! (setq line-no (flymake-get-first-err-line-no flymake-err-info)) (flymake-log 1 "passed end of file")) (if line-no (flymake-goto-line line-no) *************** *** 1647,1655 **** (defun flymake-goto-prev-error () "Go to prev error in err ring." (interactive) ! (let ((line-no (flymake-get-prev-err-line-no (flymake-get-buffer-err-info (current-buffer)) (flymake-current-line-no)))) (when (not line-no) ! (setq line-no (flymake-get-last-err-line-no (flymake-get-buffer-err-info (current-buffer)))) (flymake-log 1 "passed beginning of file")) (if line-no (flymake-goto-line line-no) --- 1584,1592 ---- (defun flymake-goto-prev-error () "Go to prev error in err ring." (interactive) ! (let ((line-no (flymake-get-prev-err-line-no flymake-err-info (flymake-current-line-no)))) (when (not line-no) ! (setq line-no (flymake-get-last-err-line-no flymake-err-info)) (flymake-log 1 "passed beginning of file")) (if line-no (flymake-goto-line line-no) *************** *** 1721,1727 **** Delete temp file." (let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name"))) (flymake-safe-delete-file temp-source-file-name) ! (flymake-set-buffer-last-change-time buffer nil))) (defun flymake-get-real-file-name (buffer file-name-from-err-msg) "Translate file name from error message to \"real\" file name. --- 1658,1665 ---- Delete temp file." (let* ((temp-source-file-name (flymake-get-buffer-value buffer "temp-source-file-name"))) (flymake-safe-delete-file temp-source-file-name) ! (with-current-buffer buffer ! (setq flymake-last-change-time nil)))) (defun flymake-get-real-file-name (buffer file-name-from-err-msg) "Translate file name from error message to \"real\" file name.