diff options
| author | Stefan Monnier | 2005-12-30 17:28:30 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-12-30 17:28:30 +0000 |
| commit | 4dd68f44332b1c8418d47675d2be052f3cbeff32 (patch) | |
| tree | f54e2e30f3d5aa8628c15c2114919b786611e10c | |
| parent | 5e860c2408d5ba7c81b33fba29b74cb095ec7191 (diff) | |
| download | emacs-4dd68f44332b1c8418d47675d2be052f3cbeff32.tar.gz emacs-4dd68f44332b1c8418d47675d2be052f3cbeff32.zip | |
(flymake-copy-buffer-to-temp-buffer): Simplify.
(flymake-parse-output-and-residual): Remove `source-buffer' argument.
(flymake-process-filter): Switch to buffer before calling it instead.
(flymake-post-syntax-check, flymake-highlight-err-lines)
(flymake-delete-own-overlays, flymake-parse-err-lines)
(flymake-start-syntax-check, flymake-start-syntax-check-process)
(flymake-count-lines, flymake-parse-residual): Remove constant buffer argument.
(flymake-start-syntax-check-for-current-buffer): Remove.
Update callers to use flymake-start-syntax-check instead.
(flymake-display-err-menu-for-current-line): Remove unused var `mouse-pos'.
(flymake-restore-formatting): Comment out unused function.
(flymake-report-status, flymake-report-fatal-status): Remove buffer
argument, use current-buffer instead. Update callers.
| -rw-r--r-- | lisp/ChangeLog | 21 | ||||
| -rw-r--r-- | lisp/progmodes/flymake.el | 286 |
2 files changed, 147 insertions, 160 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 96a7bc10d62..21c04a6678b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,21 @@ | |||
| 1 | 2005-12-30 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * progmodes/flymake.el (flymake-copy-buffer-to-temp-buffer): Simplify. | ||
| 4 | (flymake-parse-output-and-residual): Remove `source-buffer' argument. | ||
| 5 | (flymake-process-filter): Switch to buffer before calling it instead. | ||
| 6 | (flymake-post-syntax-check, flymake-highlight-err-lines) | ||
| 7 | (flymake-delete-own-overlays, flymake-parse-err-lines) | ||
| 8 | (flymake-start-syntax-check, flymake-start-syntax-check-process) | ||
| 9 | (flymake-count-lines, flymake-parse-residual): | ||
| 10 | Remove constant buffer argument. | ||
| 11 | (flymake-start-syntax-check-for-current-buffer): Remove. | ||
| 12 | Update callers to use flymake-start-syntax-check instead. | ||
| 13 | (flymake-display-err-menu-for-current-line): | ||
| 14 | Remove unused var `mouse-pos'. | ||
| 15 | (flymake-restore-formatting): Comment out unused function. | ||
| 16 | (flymake-report-status, flymake-report-fatal-status): Remove buffer | ||
| 17 | argument, use current-buffer instead. Update callers. | ||
| 18 | |||
| 1 | 2005-12-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> | 19 | 2005-12-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> |
| 2 | 20 | ||
| 3 | * textmodes/bibtex.el (bibtex-mode): Make completion-ignore-case | 21 | * textmodes/bibtex.el (bibtex-mode): Make completion-ignore-case |
| @@ -11,8 +29,7 @@ | |||
| 11 | 29 | ||
| 12 | 2005-12-30 Andreas Schwab <schwab@suse.de> | 30 | 2005-12-30 Andreas Schwab <schwab@suse.de> |
| 13 | 31 | ||
| 14 | * progmodes/cc-defs.el: Ignore errors from | 32 | * progmodes/cc-defs.el: Ignore errors from font-lock-compile-keywords. |
| 15 | font-lock-compile-keywords. | ||
| 16 | 33 | ||
| 17 | 2005-12-30 Eli Zaretskii <eliz@gnu.org> | 34 | 2005-12-30 Eli Zaretskii <eliz@gnu.org> |
| 18 | 35 | ||
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 9ceee6f6920..6f5d0855e19 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -516,15 +516,11 @@ instead of reading master file from disk." | |||
| 516 | 516 | ||
| 517 | (defun flymake-copy-buffer-to-temp-buffer (buffer) | 517 | (defun flymake-copy-buffer-to-temp-buffer (buffer) |
| 518 | "Copy contents of BUFFER into newly created temp buffer." | 518 | "Copy contents of BUFFER into newly created temp buffer." |
| 519 | (let ((contents nil) | 519 | (with-current-buffer |
| 520 | (temp-buffer nil)) | 520 | (get-buffer-create (generate-new-buffer-name |
| 521 | (with-current-buffer buffer | 521 | (concat "flymake:" (buffer-name buffer)))) |
| 522 | (setq contents (buffer-string)) | 522 | (insert-buffer-substring buffer) |
| 523 | 523 | (current-buffer))) | |
| 524 | (setq temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (buffer-name buffer))))) | ||
| 525 | (set-buffer temp-buffer) | ||
| 526 | (insert contents)) | ||
| 527 | temp-buffer)) | ||
| 528 | 524 | ||
| 529 | (defun flymake-check-include (source-file-name inc-path inc-name include-dirs) | 525 | (defun flymake-check-include (source-file-name inc-path inc-name include-dirs) |
| 530 | "Check if SOURCE-FILE-NAME can be found in include path. | 526 | "Check if SOURCE-FILE-NAME can be found in include path. |
| @@ -613,7 +609,8 @@ It's flymake process filter." | |||
| 613 | 609 | ||
| 614 | (flymake-log 3 "received %d byte(s) of output from process %d" (length output) pid) | 610 | (flymake-log 3 "received %d byte(s) of output from process %d" (length output) pid) |
| 615 | (when source-buffer | 611 | (when source-buffer |
| 616 | (flymake-parse-output-and-residual source-buffer output)))) | 612 | (with-current-buffer source-buffer |
| 613 | (flymake-parse-output-and-residual output))))) | ||
| 617 | 614 | ||
| 618 | (defun flymake-process-sentinel (process event) | 615 | (defun flymake-process-sentinel (process event) |
| 619 | "Sentinel for syntax check buffers." | 616 | "Sentinel for syntax check buffers." |
| @@ -636,8 +633,8 @@ It's flymake process filter." | |||
| 636 | (when source-buffer | 633 | (when source-buffer |
| 637 | (with-current-buffer source-buffer | 634 | (with-current-buffer source-buffer |
| 638 | 635 | ||
| 639 | (flymake-parse-residual source-buffer) | 636 | (flymake-parse-residual) |
| 640 | (flymake-post-syntax-check source-buffer exit-status command) | 637 | (flymake-post-syntax-check exit-status command) |
| 641 | (setq flymake-is-running nil)))) | 638 | (setq flymake-is-running nil)))) |
| 642 | (error | 639 | (error |
| 643 | (let ((err-str (format "Error in process sentinel for buffer %s: %s" | 640 | (let ((err-str (format "Error in process sentinel for buffer %s: %s" |
| @@ -646,60 +643,51 @@ It's flymake process filter." | |||
| 646 | (with-current-buffer source-buffer | 643 | (with-current-buffer source-buffer |
| 647 | (setq flymake-is-running nil)))))))) | 644 | (setq flymake-is-running nil)))))))) |
| 648 | 645 | ||
| 649 | (defun flymake-post-syntax-check (source-buffer exit-status command) | 646 | (defun flymake-post-syntax-check (exit-status command) |
| 650 | (with-current-buffer source-buffer | 647 | (setq flymake-err-info flymake-new-err-info) |
| 651 | (setq flymake-err-info flymake-new-err-info) | 648 | (setq flymake-new-err-info nil) |
| 652 | (setq flymake-new-err-info nil) | 649 | (setq flymake-err-info |
| 653 | (setq flymake-err-info | 650 | (flymake-fix-line-numbers |
| 654 | (flymake-fix-line-numbers | 651 | flymake-err-info 1 (flymake-count-lines))) |
| 655 | flymake-err-info 1 (flymake-count-lines source-buffer)))) | 652 | (flymake-delete-own-overlays) |
| 656 | (flymake-delete-own-overlays source-buffer) | 653 | (flymake-highlight-err-lines flymake-err-info) |
| 657 | (flymake-highlight-err-lines | ||
| 658 | source-buffer (with-current-buffer source-buffer flymake-err-info)) | ||
| 659 | (let (err-count warn-count) | 654 | (let (err-count warn-count) |
| 660 | (with-current-buffer source-buffer | 655 | (setq err-count (flymake-get-err-count flymake-err-info "e")) |
| 661 | (setq err-count (flymake-get-err-count flymake-err-info "e")) | 656 | (setq warn-count (flymake-get-err-count flymake-err-info "w")) |
| 662 | (setq warn-count (flymake-get-err-count flymake-err-info "w")) | 657 | (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)" |
| 663 | (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)" | 658 | (buffer-name) err-count warn-count |
| 664 | (buffer-name source-buffer) err-count warn-count | ||
| 665 | (- (flymake-float-time) flymake-check-start-time)) | 659 | (- (flymake-float-time) flymake-check-start-time)) |
| 666 | (setq flymake-check-start-time nil)) | 660 | (setq flymake-check-start-time nil) |
| 667 | 661 | ||
| 668 | (if (and (equal 0 err-count) (equal 0 warn-count)) | 662 | (if (and (equal 0 err-count) (equal 0 warn-count)) |
| 669 | (if (equal 0 exit-status) | 663 | (if (equal 0 exit-status) |
| 670 | (flymake-report-status source-buffer "" "") ; PASSED | 664 | (flymake-report-status "" "") ; PASSED |
| 671 | (if (not (with-current-buffer source-buffer | 665 | (if (not flymake-check-was-interrupted) |
| 672 | flymake-check-was-interrupted)) | 666 | (flymake-report-fatal-status "CFGERR" |
| 673 | (flymake-report-fatal-status (current-buffer) "CFGERR" | ||
| 674 | (format "Configuration error has occured while running %s" command)) | 667 | (format "Configuration error has occured while running %s" command)) |
| 675 | (flymake-report-status source-buffer nil ""))) ; "STOPPED" | 668 | (flymake-report-status nil ""))) ; "STOPPED" |
| 676 | (flymake-report-status source-buffer (format "%d/%d" err-count warn-count) "")))) | 669 | (flymake-report-status (format "%d/%d" err-count warn-count) "")))) |
| 677 | 670 | ||
| 678 | (defun flymake-parse-output-and-residual (source-buffer output) | 671 | (defun flymake-parse-output-and-residual (output) |
| 679 | "Split OUTPUT into lines, merge in residual if necessary." | 672 | "Split OUTPUT into lines, merge in residual if necessary." |
| 680 | (with-current-buffer source-buffer | 673 | (let* ((buffer-residual flymake-output-residual) |
| 681 | (let* ((buffer-residual flymake-output-residual) | 674 | (total-output (if buffer-residual (concat buffer-residual output) output)) |
| 682 | (total-output (if buffer-residual (concat buffer-residual output) output)) | 675 | (lines-and-residual (flymake-split-output total-output)) |
| 683 | (lines-and-residual (flymake-split-output total-output)) | 676 | (lines (nth 0 lines-and-residual)) |
| 684 | (lines (nth 0 lines-and-residual)) | 677 | (new-residual (nth 1 lines-and-residual))) |
| 685 | (new-residual (nth 1 lines-and-residual))) | 678 | (setq flymake-output-residual new-residual) |
| 686 | (with-current-buffer source-buffer | 679 | (setq flymake-new-err-info |
| 687 | (setq flymake-output-residual new-residual) | 680 | (flymake-parse-err-lines |
| 688 | (setq flymake-new-err-info | 681 | flymake-new-err-info lines)))) |
| 689 | (flymake-parse-err-lines | 682 | |
| 690 | flymake-new-err-info | 683 | (defun flymake-parse-residual () |
| 691 | source-buffer lines)))))) | ||
| 692 | |||
| 693 | (defun flymake-parse-residual (source-buffer) | ||
| 694 | "Parse residual if it's non empty." | 684 | "Parse residual if it's non empty." |
| 695 | (with-current-buffer source-buffer | 685 | (when flymake-output-residual |
| 696 | (when flymake-output-residual | 686 | (setq flymake-new-err-info |
| 697 | (setq flymake-new-err-info | 687 | (flymake-parse-err-lines |
| 698 | (flymake-parse-err-lines | 688 | flymake-new-err-info |
| 699 | flymake-new-err-info | 689 | (list flymake-output-residual))) |
| 700 | source-buffer | 690 | (setq flymake-output-residual nil))) |
| 701 | (list flymake-output-residual))) | ||
| 702 | (setq flymake-output-residual nil)))) | ||
| 703 | 691 | ||
| 704 | (defvar flymake-err-info nil | 692 | (defvar flymake-err-info nil |
| 705 | "Sorted list of line numbers and lists of err info in the form (file, err-text).") | 693 | "Sorted list of line numbers and lists of err info in the form (file, err-text).") |
| @@ -803,16 +791,11 @@ line number outside the file being compiled." | |||
| 803 | (setq count (1- count)))) | 791 | (setq count (1- count)))) |
| 804 | err-info-list) | 792 | err-info-list) |
| 805 | 793 | ||
| 806 | (defun flymake-highlight-err-lines (buffer err-info-list) | 794 | (defun flymake-highlight-err-lines (err-info-list) |
| 807 | "Highlight error lines in BUFFER using info from ERR-INFO-LIST." | 795 | "Highlight error lines in BUFFER using info from ERR-INFO-LIST." |
| 808 | (with-current-buffer buffer | 796 | (save-excursion |
| 809 | (save-excursion | 797 | (dolist (err err-info-list) |
| 810 | (let* ((idx 0) | 798 | (flymake-highlight-line (car err) (nth 1 err))))) |
| 811 | (count (length err-info-list))) | ||
| 812 | (while (< idx count) | ||
| 813 | (flymake-highlight-line (car (nth idx err-info-list)) | ||
| 814 | (nth 1 (nth idx err-info-list))) | ||
| 815 | (setq idx (1+ idx))))))) | ||
| 816 | 799 | ||
| 817 | (defun flymake-overlay-p (ov) | 800 | (defun flymake-overlay-p (ov) |
| 818 | "Determine whether overlay OV was created by flymake." | 801 | "Determine whether overlay OV was created by flymake." |
| @@ -831,16 +814,13 @@ line number outside the file being compiled." | |||
| 831 | ov) | 814 | ov) |
| 832 | (flymake-log 3 "created an overlay at (%d-%d)" beg end))) | 815 | (flymake-log 3 "created an overlay at (%d-%d)" beg end))) |
| 833 | 816 | ||
| 834 | (defun flymake-delete-own-overlays (buffer) | 817 | (defun flymake-delete-own-overlays () |
| 835 | "Delete all flymake overlays in BUFFER." | 818 | "Delete all flymake overlays in BUFFER." |
| 836 | (with-current-buffer buffer | 819 | (dolist (ol (overlays-in (point-min) (point-max))) |
| 837 | (let ((ov (overlays-in (point-min) (point-max)))) | 820 | (when (flymake-overlay-p ol) |
| 838 | (while (consp ov) | 821 | (delete-overlay ol) |
| 839 | (when (flymake-overlay-p (car ov)) | 822 | ;;+(flymake-log 3 "deleted overlay %s" ol) |
| 840 | (delete-overlay (car ov)) | 823 | ))) |
| 841 | ;;+(flymake-log 3 "deleted overlay %s" ov) | ||
| 842 | ) | ||
| 843 | (setq ov (cdr ov)))))) | ||
| 844 | 824 | ||
| 845 | (defun flymake-region-has-flymake-overlays (beg end) | 825 | (defun flymake-region-has-flymake-overlays (beg end) |
| 846 | "Check if region specified by BEG and END has overlay. | 826 | "Check if region specified by BEG and END has overlay. |
| @@ -905,19 +885,19 @@ Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting." | |||
| 905 | 885 | ||
| 906 | (flymake-make-overlay beg end tooltip-text face nil))) | 886 | (flymake-make-overlay beg end tooltip-text face nil))) |
| 907 | 887 | ||
| 908 | (defun flymake-parse-err-lines (err-info-list source-buffer lines) | 888 | (defun flymake-parse-err-lines (err-info-list lines) |
| 909 | "Parse err LINES, store info in ERR-INFO-LIST." | 889 | "Parse err LINES, store info in ERR-INFO-LIST." |
| 910 | (let* ((count (length lines)) | 890 | (let* ((count (length lines)) |
| 911 | (idx 0) | 891 | (idx 0) |
| 912 | (line-err-info nil) | 892 | (line-err-info nil) |
| 913 | (real-file-name nil) | 893 | (real-file-name nil) |
| 914 | (source-file-name (buffer-file-name source-buffer)) | 894 | (source-file-name buffer-file-name) |
| 915 | (get-real-file-name-f (flymake-get-real-file-name-function source-file-name))) | 895 | (get-real-file-name-f (flymake-get-real-file-name-function source-file-name))) |
| 916 | 896 | ||
| 917 | (while (< idx count) | 897 | (while (< idx count) |
| 918 | (setq line-err-info (flymake-parse-line (nth idx lines))) | 898 | (setq line-err-info (flymake-parse-line (nth idx lines))) |
| 919 | (when line-err-info | 899 | (when line-err-info |
| 920 | (setq real-file-name (funcall get-real-file-name-f source-buffer (flymake-ler-get-file line-err-info))) | 900 | (setq real-file-name (funcall get-real-file-name-f (current-buffer) (flymake-ler-get-file line-err-info))) |
| 921 | (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name)) | 901 | (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name)) |
| 922 | 902 | ||
| 923 | (if (flymake-same-files real-file-name source-file-name) | 903 | (if (flymake-same-files real-file-name source-file-name) |
| @@ -1147,9 +1127,9 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1147 | (let* ((include-dirs (append '(".") (flymake-get-project-include-dirs base-dir) (flymake-get-system-include-dirs)))) | 1127 | (let* ((include-dirs (append '(".") (flymake-get-project-include-dirs base-dir) (flymake-get-system-include-dirs)))) |
| 1148 | include-dirs)) | 1128 | include-dirs)) |
| 1149 | 1129 | ||
| 1150 | (defun flymake-restore-formatting (source-buffer) | 1130 | ;; (defun flymake-restore-formatting () |
| 1151 | "Remove any formatting made by flymake." | 1131 | ;; "Remove any formatting made by flymake." |
| 1152 | ) | 1132 | ;; ) |
| 1153 | 1133 | ||
| 1154 | (defun flymake-get-program-dir (buffer) | 1134 | (defun flymake-get-program-dir (buffer) |
| 1155 | "Get dir to start program in." | 1135 | "Get dir to start program in." |
| @@ -1176,38 +1156,36 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1176 | :group 'flymake | 1156 | :group 'flymake |
| 1177 | :type 'boolean) | 1157 | :type 'boolean) |
| 1178 | 1158 | ||
| 1179 | (defun flymake-start-syntax-check (buffer) | 1159 | (defun flymake-start-syntax-check () |
| 1180 | "Start syntax checking for buffer BUFFER." | 1160 | "Start syntax checking for current buffer." |
| 1181 | (unless (bufferp buffer) | 1161 | (interactive) |
| 1182 | (error "Expected a buffer")) | 1162 | (flymake-log 3 "flymake is running: %s" flymake-is-running) |
| 1183 | (with-current-buffer buffer | 1163 | (when (and (not flymake-is-running) |
| 1184 | (flymake-log 3 "flymake is running: %s" flymake-is-running) | 1164 | (flymake-can-syntax-check-file buffer-file-name)) |
| 1185 | (when (and (not flymake-is-running) | 1165 | (when (or (not flymake-compilation-prevents-syntax-check) |
| 1186 | (flymake-can-syntax-check-file (buffer-file-name buffer))) | 1166 | (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP") |
| 1187 | (when (or (not flymake-compilation-prevents-syntax-check) | 1167 | (flymake-clear-buildfile-cache) |
| 1188 | (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP") | 1168 | (flymake-clear-project-include-dirs-cache) |
| 1189 | (flymake-clear-buildfile-cache) | 1169 | |
| 1190 | (flymake-clear-project-include-dirs-cache) | 1170 | (setq flymake-check-was-interrupted nil) |
| 1191 | 1171 | (setq flymake-buffer-data (flymake-makehash 'equal)) | |
| 1192 | (setq flymake-check-was-interrupted nil) | 1172 | |
| 1193 | (setq flymake-buffer-data (flymake-makehash 'equal)) | 1173 | (let* ((source-file-name buffer-file-name) |
| 1194 | 1174 | (init-f (flymake-get-init-function source-file-name)) | |
| 1195 | (let* ((source-file-name (buffer-file-name buffer)) | 1175 | (cleanup-f (flymake-get-cleanup-function source-file-name)) |
| 1196 | (init-f (flymake-get-init-function source-file-name)) | 1176 | (cmd-and-args (funcall init-f (current-buffer))) |
| 1197 | (cleanup-f (flymake-get-cleanup-function source-file-name)) | 1177 | (cmd (nth 0 cmd-and-args)) |
| 1198 | (cmd-and-args (funcall init-f buffer)) | 1178 | (args (nth 1 cmd-and-args)) |
| 1199 | (cmd (nth 0 cmd-and-args)) | 1179 | (dir (nth 2 cmd-and-args))) |
| 1200 | (args (nth 1 cmd-and-args)) | 1180 | (if (not cmd-and-args) |
| 1201 | (dir (nth 2 cmd-and-args))) | 1181 | (progn |
| 1202 | (if (not cmd-and-args) | 1182 | (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name) |
| 1203 | (progn | 1183 | (funcall cleanup-f (current-buffer))) |
| 1204 | (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name) | 1184 | (progn |
| 1205 | (funcall cleanup-f buffer)) | 1185 | (setq flymake-last-change-time nil) |
| 1206 | (progn | 1186 | (flymake-start-syntax-check-process cmd args dir))))))) |
| 1207 | (setq flymake-last-change-time nil) | 1187 | |
| 1208 | (flymake-start-syntax-check-process buffer cmd args dir)))))))) | 1188 | (defun flymake-start-syntax-check-process (cmd args dir) |
| 1209 | |||
| 1210 | (defun flymake-start-syntax-check-process (buffer cmd args dir) | ||
| 1211 | "Start syntax check process." | 1189 | "Start syntax check process." |
| 1212 | (let* ((process nil)) | 1190 | (let* ((process nil)) |
| 1213 | (condition-case err | 1191 | (condition-case err |
| @@ -1219,25 +1197,24 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1219 | (set-process-sentinel process 'flymake-process-sentinel) | 1197 | (set-process-sentinel process 'flymake-process-sentinel) |
| 1220 | (set-process-filter process 'flymake-process-filter) | 1198 | (set-process-filter process 'flymake-process-filter) |
| 1221 | 1199 | ||
| 1222 | (flymake-reg-names (process-id process) (buffer-name buffer)) | 1200 | (flymake-reg-names (process-id process) (buffer-name)) |
| 1223 | 1201 | ||
| 1224 | (with-current-buffer buffer | 1202 | (setq flymake-is-running t) |
| 1225 | (setq flymake-is-running t) | 1203 | (setq flymake-last-change-time nil) |
| 1226 | (setq flymake-last-change-time nil) | 1204 | (setq flymake-check-start-time (flymake-float-time)) |
| 1227 | (setq flymake-check-start-time (flymake-float-time))) | ||
| 1228 | 1205 | ||
| 1229 | (flymake-report-status buffer nil "*") | 1206 | (flymake-report-status nil "*") |
| 1230 | (flymake-log 2 "started process %d, command=%s, dir=%s" | 1207 | (flymake-log 2 "started process %d, command=%s, dir=%s" |
| 1231 | (process-id process) (process-command process) default-directory) | 1208 | (process-id process) (process-command process) default-directory) |
| 1232 | process) | 1209 | process) |
| 1233 | (error | 1210 | (error |
| 1234 | (let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s" | 1211 | (let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s" |
| 1235 | cmd args (error-message-string err))) | 1212 | cmd args (error-message-string err))) |
| 1236 | (source-file-name (buffer-file-name buffer)) | 1213 | (source-file-name buffer-file-name) |
| 1237 | (cleanup-f (flymake-get-cleanup-function source-file-name))) | 1214 | (cleanup-f (flymake-get-cleanup-function source-file-name))) |
| 1238 | (flymake-log 0 err-str) | 1215 | (flymake-log 0 err-str) |
| 1239 | (funcall cleanup-f buffer) | 1216 | (funcall cleanup-f (current-buffer)) |
| 1240 | (flymake-report-fatal-status buffer "PROCERR" err-str)))))) | 1217 | (flymake-report-fatal-status "PROCERR" err-str)))))) |
| 1241 | 1218 | ||
| 1242 | (defun flymake-kill-process (pid &optional rest) | 1219 | (defun flymake-kill-process (pid &optional rest) |
| 1243 | "Kill process PID." | 1220 | "Kill process PID." |
| @@ -1304,12 +1281,7 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1304 | 1281 | ||
| 1305 | (setq flymake-last-change-time nil) | 1282 | (setq flymake-last-change-time nil) |
| 1306 | (flymake-log 3 "starting syntax check as more than 1 second passed since last change") | 1283 | (flymake-log 3 "starting syntax check as more than 1 second passed since last change") |
| 1307 | (flymake-start-syntax-check buffer))))) | 1284 | (flymake-start-syntax-check))))) |
| 1308 | |||
| 1309 | (defun flymake-start-syntax-check-for-current-buffer () | ||
| 1310 | "Run `flymake-start-syntax-check' for current buffer if it isn't already running." | ||
| 1311 | (interactive) | ||
| 1312 | (flymake-start-syntax-check (current-buffer))) | ||
| 1313 | 1285 | ||
| 1314 | (defun flymake-current-line-no () | 1286 | (defun flymake-current-line-no () |
| 1315 | "Return number of current line in current buffer." | 1287 | "Return number of current line in current buffer." |
| @@ -1318,10 +1290,9 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1318 | (end (if (= (point) (point-max)) (point) (1+ (point))))) | 1290 | (end (if (= (point) (point-max)) (point) (1+ (point))))) |
| 1319 | (count-lines beg end))) | 1291 | (count-lines beg end))) |
| 1320 | 1292 | ||
| 1321 | (defun flymake-count-lines (buffer) | 1293 | (defun flymake-count-lines () |
| 1322 | "Return number of lines in buffer BUFFER." | 1294 | "Return number of lines in buffer BUFFER." |
| 1323 | (with-current-buffer buffer | 1295 | (count-lines (point-min) (point-max))) |
| 1324 | (count-lines (point-min) (point-max)))) | ||
| 1325 | 1296 | ||
| 1326 | (defun flymake-get-point-pixel-pos () | 1297 | (defun flymake-get-point-pixel-pos () |
| 1327 | "Return point position in pixels: (x, y)." | 1298 | "Return point position in pixels: (x, y)." |
| @@ -1346,7 +1317,6 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1346 | (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))) | 1317 | (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))) |
| 1347 | (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) | 1318 | (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) |
| 1348 | (choice nil) | 1319 | (choice nil) |
| 1349 | (mouse-pos (flymake-get-point-pixel-pos)) | ||
| 1350 | (menu-pos (list (flymake-get-point-pixel-pos) (selected-window)))) | 1320 | (menu-pos (list (flymake-get-point-pixel-pos) (selected-window)))) |
| 1351 | (if menu-data | 1321 | (if menu-data |
| 1352 | (progn | 1322 | (progn |
| @@ -1402,20 +1372,18 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1402 | 1372 | ||
| 1403 | (make-variable-buffer-local 'flymake-mode-line-status) | 1373 | (make-variable-buffer-local 'flymake-mode-line-status) |
| 1404 | 1374 | ||
| 1405 | (defun flymake-report-status (buffer e-w &optional status) | 1375 | (defun flymake-report-status (e-w &optional status) |
| 1406 | "Show status in mode line." | 1376 | "Show status in mode line." |
| 1407 | (when (bufferp buffer) | 1377 | (when e-w |
| 1408 | (with-current-buffer buffer | 1378 | (setq flymake-mode-line-e-w e-w)) |
| 1409 | (when e-w | 1379 | (when status |
| 1410 | (setq flymake-mode-line-e-w e-w)) | 1380 | (setq flymake-mode-line-status status)) |
| 1411 | (when status | 1381 | (let* ((mode-line " Flymake")) |
| 1412 | (setq flymake-mode-line-status status)) | 1382 | (when (> (length flymake-mode-line-e-w) 0) |
| 1413 | (let* ((mode-line " Flymake")) | 1383 | (setq mode-line (concat mode-line ":" flymake-mode-line-e-w))) |
| 1414 | (when (> (length flymake-mode-line-e-w) 0) | 1384 | (setq mode-line (concat mode-line flymake-mode-line-status)) |
| 1415 | (setq mode-line (concat mode-line ":" flymake-mode-line-e-w))) | 1385 | (setq flymake-mode-line mode-line) |
| 1416 | (setq mode-line (concat mode-line flymake-mode-line-status)) | 1386 | (force-mode-line-update))) |
| 1417 | (setq flymake-mode-line mode-line) | ||
| 1418 | (force-mode-line-update))))) | ||
| 1419 | 1387 | ||
| 1420 | (defun flymake-display-warning (warning) | 1388 | (defun flymake-display-warning (warning) |
| 1421 | "Display a warning to user." | 1389 | "Display a warning to user." |
| @@ -1426,15 +1394,14 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." | |||
| 1426 | :group 'flymake | 1394 | :group 'flymake |
| 1427 | :type 'boolean) | 1395 | :type 'boolean) |
| 1428 | 1396 | ||
| 1429 | (defun flymake-report-fatal-status (buffer status warning) | 1397 | (defun flymake-report-fatal-status (status warning) |
| 1430 | "Display a warning and switch flymake mode off." | 1398 | "Display a warning and switch flymake mode off." |
| 1431 | (when flymake-gui-warnings-enabled | 1399 | (when flymake-gui-warnings-enabled |
| 1432 | (flymake-display-warning (format "Flymake: %s. Flymake will be switched OFF" warning)) | 1400 | (flymake-display-warning (format "Flymake: %s. Flymake will be switched OFF" warning)) |
| 1433 | ) | 1401 | ) |
| 1434 | (with-current-buffer buffer | 1402 | (flymake-mode 0) |
| 1435 | (flymake-mode 0) | 1403 | (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s" |
| 1436 | (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s" | 1404 | (buffer-name) status warning)) |
| 1437 | (buffer-name buffer) status warning))) | ||
| 1438 | 1405 | ||
| 1439 | (defcustom flymake-start-syntax-check-on-find-file t | 1406 | (defcustom flymake-start-syntax-check-on-find-file t |
| 1440 | "Start syntax check on find file." | 1407 | "Start syntax check on find file." |
| @@ -1458,13 +1425,13 @@ With arg, turn Flymake mode on if and only if arg is positive." | |||
| 1458 | (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t) | 1425 | (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t) |
| 1459 | ;;+(add-hook 'find-file-hook 'flymake-find-file-hook) | 1426 | ;;+(add-hook 'find-file-hook 'flymake-find-file-hook) |
| 1460 | 1427 | ||
| 1461 | (flymake-report-status (current-buffer) "" "") | 1428 | (flymake-report-status "" "") |
| 1462 | 1429 | ||
| 1463 | (setq flymake-timer | 1430 | (setq flymake-timer |
| 1464 | (run-at-time nil 1 'flymake-on-timer-event (current-buffer))) | 1431 | (run-at-time nil 1 'flymake-on-timer-event (current-buffer))) |
| 1465 | 1432 | ||
| 1466 | (when flymake-start-syntax-check-on-find-file | 1433 | (when flymake-start-syntax-check-on-find-file |
| 1467 | (flymake-start-syntax-check-for-current-buffer)))) | 1434 | (flymake-start-syntax-check)))) |
| 1468 | 1435 | ||
| 1469 | ;; Turning the mode OFF. | 1436 | ;; Turning the mode OFF. |
| 1470 | (t | 1437 | (t |
| @@ -1473,7 +1440,7 @@ With arg, turn Flymake mode on if and only if arg is positive." | |||
| 1473 | (remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t) | 1440 | (remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t) |
| 1474 | ;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t) | 1441 | ;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t) |
| 1475 | 1442 | ||
| 1476 | (flymake-delete-own-overlays (current-buffer)) | 1443 | (flymake-delete-own-overlays) |
| 1477 | 1444 | ||
| 1478 | (when flymake-timer | 1445 | (when flymake-timer |
| 1479 | (cancel-timer flymake-timer) | 1446 | (cancel-timer flymake-timer) |
| @@ -1504,14 +1471,14 @@ With arg, turn Flymake mode on if and only if arg is positive." | |||
| 1504 | (let((new-text (buffer-substring start stop))) | 1471 | (let((new-text (buffer-substring start stop))) |
| 1505 | (when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) | 1472 | (when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) |
| 1506 | (flymake-log 3 "starting syntax check as new-line has been seen") | 1473 | (flymake-log 3 "starting syntax check as new-line has been seen") |
| 1507 | (flymake-start-syntax-check-for-current-buffer)) | 1474 | (flymake-start-syntax-check)) |
| 1508 | (setq flymake-last-change-time (flymake-float-time)))) | 1475 | (setq flymake-last-change-time (flymake-float-time)))) |
| 1509 | 1476 | ||
| 1510 | (defun flymake-after-save-hook () | 1477 | (defun flymake-after-save-hook () |
| 1511 | (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved? | 1478 | (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved? |
| 1512 | (progn | 1479 | (progn |
| 1513 | (flymake-log 3 "starting syntax check as buffer was saved") | 1480 | (flymake-log 3 "starting syntax check as buffer was saved") |
| 1514 | (flymake-start-syntax-check-for-current-buffer)))) ; no more mode 3. cannot start check if mode 3 (to temp copies) is active - (???) | 1481 | (flymake-start-syntax-check)))) ; no more mode 3. cannot start check if mode 3 (to temp copies) is active - (???) |
| 1515 | 1482 | ||
| 1516 | (defun flymake-kill-buffer-hook () | 1483 | (defun flymake-kill-buffer-hook () |
| 1517 | (when flymake-timer | 1484 | (when flymake-timer |
| @@ -1521,7 +1488,7 @@ With arg, turn Flymake mode on if and only if arg is positive." | |||
| 1521 | (defun flymake-find-file-hook () | 1488 | (defun flymake-find-file-hook () |
| 1522 | ;;+(when flymake-start-syntax-check-on-find-file | 1489 | ;;+(when flymake-start-syntax-check-on-find-file |
| 1523 | ;;+ (flymake-log 3 "starting syntax check on file open") | 1490 | ;;+ (flymake-log 3 "starting syntax check on file open") |
| 1524 | ;;+ (flymake-start-syntax-check-for-current-buffer) | 1491 | ;;+ (flymake-start-syntax-check) |
| 1525 | ;;+) | 1492 | ;;+) |
| 1526 | (when (and (not (local-variable-p 'flymake-mode (current-buffer))) | 1493 | (when (and (not (local-variable-p 'flymake-mode (current-buffer))) |
| 1527 | (flymake-can-syntax-check-file buffer-file-name)) | 1494 | (flymake-can-syntax-check-file buffer-file-name)) |
| @@ -1728,7 +1695,8 @@ Return full-name. Names are real, not patched." | |||
| 1728 | (if (not buildfile-dir) | 1695 | (if (not buildfile-dir) |
| 1729 | (progn | 1696 | (progn |
| 1730 | (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name) | 1697 | (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name) |
| 1731 | (flymake-report-fatal-status buffer "NOMK" (format "No buildfile (%s) found for %s" buildfile-name source-file-name)) | 1698 | (with-current-buffer buffer |
| 1699 | (flymake-report-fatal-status "NOMK" (format "No buildfile (%s) found for %s" buildfile-name source-file-name))) | ||
| 1732 | ) | 1700 | ) |
| 1733 | (progn | 1701 | (progn |
| 1734 | (flymake-set-buffer-value buffer "base-dir" buildfile-dir))) | 1702 | (flymake-set-buffer-value buffer "base-dir" buildfile-dir))) |
| @@ -1748,7 +1716,9 @@ Return full-name. Names are real, not patched." | |||
| 1748 | (if (not master-and-temp-master) | 1716 | (if (not master-and-temp-master) |
| 1749 | (progn | 1717 | (progn |
| 1750 | (flymake-log 1 "cannot find master file for %s" source-file-name) | 1718 | (flymake-log 1 "cannot find master file for %s" source-file-name) |
| 1751 | (flymake-report-status buffer "!" "") ; NOMASTER | 1719 | (when (bufferp buffer) |
| 1720 | (with-current-buffer buffer | ||
| 1721 | (flymake-report-status "!" ""))) ; NOMASTER | ||
| 1752 | ) | 1722 | ) |
| 1753 | (progn | 1723 | (progn |
| 1754 | (setq master-file-name (nth 0 master-and-temp-master)) | 1724 | (setq master-file-name (nth 0 master-and-temp-master)) |