diff options
| author | Hong Xu | 2016-11-25 12:51:22 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-11-25 12:51:22 +0200 |
| commit | 83bf70f81ec13b1f6ba3afeba503f483bf2fcc75 (patch) | |
| tree | 16818f8a9628fc8df188d6df6a288377e53e9741 | |
| parent | 8da61f884649e1fb98fc83f9401116df8f948a31 (diff) | |
| download | emacs-83bf70f81ec13b1f6ba3afeba503f483bf2fcc75.tar.gz emacs-83bf70f81ec13b1f6ba3afeba503f483bf2fcc75.zip | |
Allow user control of progress messages in cpp.el
* progmodes/cpp.el (cpp-message-min-time-interval): New defcustom.
(cpp-progress-time): Use 'cpp-message-min-time-interval'. Improve
the doc string.
(cpp-highlight-buffer): Use 'cpp-progress-message' instead of
'message' to print messages. (Bug#24861)
Copyright-paperwork-exempt: yes
| -rw-r--r-- | lisp/progmodes/cpp.el | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el index 7d641ab47f0..18b0704d6be 100644 --- a/lisp/progmodes/cpp.el +++ b/lisp/progmodes/cpp.el | |||
| @@ -104,6 +104,13 @@ Each entry is a list with the following elements: | |||
| 104 | (const :tag "Both branches writable" both)))) | 104 | (const :tag "Both branches writable" both)))) |
| 105 | :group 'cpp) | 105 | :group 'cpp) |
| 106 | 106 | ||
| 107 | (defcustom cpp-message-min-time-interval 1.0 | ||
| 108 | "Minimum time interval in seconds for `cpp-progress-message' messages. | ||
| 109 | If nil, `cpp-progress-message' prints no progress messages." | ||
| 110 | :type 'float | ||
| 111 | :group 'cpp | ||
| 112 | :version "26.1") | ||
| 113 | |||
| 107 | (defvar cpp-overlay-list nil) | 114 | (defvar cpp-overlay-list nil) |
| 108 | ;; List of cpp overlays active in the current buffer. | 115 | ;; List of cpp overlays active in the current buffer. |
| 109 | (make-variable-buffer-local 'cpp-overlay-list) | 116 | (make-variable-buffer-local 'cpp-overlay-list) |
| @@ -278,7 +285,7 @@ A prefix arg suppresses display of that buffer." | |||
| 278 | (cpp-parse-close from to)) | 285 | (cpp-parse-close from to)) |
| 279 | (t | 286 | (t |
| 280 | (cpp-parse-error "Parser error")))))))) | 287 | (cpp-parse-error "Parser error")))))))) |
| 281 | (message "Parsing...done")) | 288 | (cpp-progress-message "Parsing...done")) |
| 282 | (if cpp-state-stack | 289 | (if cpp-state-stack |
| 283 | (save-excursion | 290 | (save-excursion |
| 284 | (goto-char (nth 3 (car cpp-state-stack))) | 291 | (goto-char (nth 3 (car cpp-state-stack))) |
| @@ -819,16 +826,21 @@ BRANCH should be either nil (false branch), t (true branch) or `both'." | |||
| 819 | 826 | ||
| 820 | ;;; Utilities: | 827 | ;;; Utilities: |
| 821 | 828 | ||
| 822 | (defvar cpp-progress-time 0) | 829 | (defvar cpp-progress-time 0 |
| 823 | ;; Last time we issued a progress message. | 830 | "Last time `cpp-progress-message' issued a progress message.") |
| 824 | 831 | ||
| 825 | (defun cpp-progress-message (&rest args) | 832 | (defun cpp-progress-message (&rest args) |
| 826 | ;; Report progress at most once a second. Take same ARGS as `message'. | 833 | "Report progress by printing messages used by \"cpp-\" functions. |
| 827 | (let ((time (nth 1 (current-time)))) | 834 | |
| 828 | (if (= time cpp-progress-time) | 835 | Print messages at most once every `cpp-message-min-time-interval' seconds. |
| 829 | () | 836 | If that option is nil, don't prints messages. |
| 830 | (setq cpp-progress-time time) | 837 | ARGS are the same as for `message'." |
| 831 | (apply 'message args)))) | 838 | (when cpp-message-min-time-interval |
| 839 | (let ((time (current-time))) | ||
| 840 | (when (>= (float-time (time-subtract time cpp-progress-time)) | ||
| 841 | cpp-message-min-time-interval) | ||
| 842 | (setq cpp-progress-time time) | ||
| 843 | (apply 'message args))))) | ||
| 832 | 844 | ||
| 833 | (provide 'cpp) | 845 | (provide 'cpp) |
| 834 | 846 | ||