GNU bug report logs -
#24861
[PATCH] Fix annoying "Parsing...done" message in c++-mode
Previous Next
Reported by: Hong Xu <hong <at> topbug.net>
Date: Wed, 2 Nov 2016 18:46:01 UTC
Severity: wishlist
Tags: patch
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On 2016-11-18 Fri 23:50 GMT-0800, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> Cc: 24861 <at> debbugs.gnu.org
>> From: Hong Xu <hong <at> topbug.net>
>> Date: Fri, 18 Nov 2016 11:55:28 -0800
>>
>> Allow users to customize the maximum frequency that
>> `cpp-progress-message' prints messages.
>>
>> * progmodes/cpp.el (cpp-message-min-time-interval)
>> (cpp-progress-message): Add variable
>> `cpp-message-min-time-interval' to indicate the minimum time
>> interval in seconds that `cpp-progress-message' prints messages.
>>
>> * progmodes/cpp.el (cpp-progress-time): Initialize to '(0 0 0 0) instead of
>> 0 and improve the documentation.
>>
>> * progmodes/cpp.el (cpp-highlight-buffer): Use
>> `cpp-progress-message' instead of `message'.
>
> Thanks, but there are still left-overs:
>
>> +(defcustom cpp-message-min-time-interval 1.0
>> + "Indicate the minimum time interval in seconds that
>> +`cpp-progress-message' should print messages.
>
> This should be one line, so the sentence should be shorter to fit. If
> you drop the redundant "Indicate the" part, it will come close.
>
>> -(defvar cpp-progress-time 0)
>> -;; Last time we issued a progress message.
>> +(defvar cpp-progress-time '(0 0 0 0)
>
> You could leave it at 0, no need to have a list here.
>
>> + "Indicate the last time `cpp-progress-message' issued a
>> + progress message.")
>
> This should be a single line. Once again, please drop the uneeded
> "Indicate" part.
>
>> (defun cpp-progress-message (&rest args)
>> - ;; Report progress at most once a second. Take same ARGS as `message'.
>> - (let ((time (nth 1 (current-time))))
>> - (if (= time cpp-progress-time)
>> - ()
>> - (setq cpp-progress-time time)
>> - (apply 'message args))))
>> + "Report progress by printing messages at most once every
>> +`cpp-message-min-time-interval' seconds for functions whose names
>> +start with \"cpp-\". If `cpp-message-min-time-interval' is nil,
>> +it prints no message. The ARGS are the same as in `message'."
>
> The first sentence of the doc string should take only one line.
Thanks, updated.
Allow users to customize the maximum frequency that `cpp-progress-message' prints messages.
* progmodes/cpp.el (cpp-message-min-time-interval)
(cpp-progress-message): Add variable
`cpp-message-min-time-interval' to indicate the minimum time
interval in seconds that `cpp-progress-message' prints messages.
* progmodes/cpp.el (cpp-progress-time): Improve the documentation.
* progmodes/cpp.el (cpp-highlight-buffer): Use
`cpp-progress-message' instead of `message' to print messages.
[cpp-message.patch (text/x-diff, inline)]
diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 7d641ab47f09..fc8c271cc5ec 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -104,6 +104,13 @@ cpp-edit-list
(const :tag "Both branches writable" both))))
:group 'cpp)
+(defcustom cpp-message-min-time-interval 1.0
+ "The minimum time interval in seconds that `cpp-progress-message' prints messages.
+If it is set to nil, `cpp-progress-message' prints no message."
+ :type 'float
+ :group 'cpp
+ :version "26.1")
+
(defvar cpp-overlay-list nil)
;; List of cpp overlays active in the current buffer.
(make-variable-buffer-local 'cpp-overlay-list)
@@ -278,7 +285,7 @@ cpp-highlight-buffer
(cpp-parse-close from to))
(t
(cpp-parse-error "Parser error"))))))))
- (message "Parsing...done"))
+ (cpp-progress-message "Parsing...done"))
(if cpp-state-stack
(save-excursion
(goto-char (nth 3 (car cpp-state-stack)))
@@ -819,16 +826,21 @@ cpp-face-name
;;; Utilities:
-(defvar cpp-progress-time 0)
-;; Last time we issued a progress message.
+(defvar cpp-progress-time 0
+ "The last time `cpp-progress-message' issued a progress message.")
(defun cpp-progress-message (&rest args)
- ;; Report progress at most once a second. Take same ARGS as `message'.
- (let ((time (nth 1 (current-time))))
- (if (= time cpp-progress-time)
- ()
- (setq cpp-progress-time time)
- (apply 'message args))))
+ "Report progress by printing messages used by \"cpp-\" functions.
+It prints messages at most once every
+`cpp-message-min-time-interval' seconds. If
+`cpp-message-min-time-interval' is nil, it prints no message.
+The ARGS are the same as in `message'."
+ (when cpp-message-min-time-interval
+ (let ((time (current-time)))
+ (when (>= (float-time (time-subtract time cpp-progress-time))
+ cpp-message-min-time-interval)
+ (setq cpp-progress-time time)
+ (apply 'message args)))))
(provide 'cpp)
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 8 years and 176 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.