unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
@ 2016-11-02 18:45 Hong Xu
  2016-11-02 20:09 ` Hong Xu
  0 siblings, 1 reply; 15+ messages in thread
From: Hong Xu @ 2016-11-02 18:45 UTC (permalink / raw)
  To: 24861

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]


This patch adds a customizable variable cpp-message-min-time-interval to
avoid over messaging.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: cpp-message.patch --]
[-- Type: text/x-diff, Size: 1420 bytes --]

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 7d641ab47f09..1dd179d9103f 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -104,6 +104,12 @@ cpp-edit-list
 			       (const :tag "Both branches writable" both))))
   :group 'cpp)
 
+(defcustom cpp-message-min-time-interval 1
+  "The minimum time interval in seconds that cpp-mode should
+print messages.  No message will be printed if set to 0."
+  :type 'integer
+  :group 'cpp)
+
 (defvar cpp-overlay-list nil)
 ;; List of cpp overlays active in the current buffer.
 (make-variable-buffer-local 'cpp-overlay-list)
@@ -278,7 +284,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)))
@@ -823,10 +829,10 @@ cpp-progress-time
 ;; Last time we issued a progress message.
 
 (defun cpp-progress-message (&rest args)
-  ;; Report progress at most once a second.  Take same ARGS as `message'.
+  "Report progress at most once a second.  Take same ARGS as `message'."
   (let ((time (nth 1 (current-time))))
-    (if (= time cpp-progress-time)
-	()
+    (when (>= (- time cpp-progress-time)
+              cpp-message-min-time-interval)
       (setq cpp-progress-time time)
       (apply 'message args))))
 

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-02 18:45 bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode Hong Xu
@ 2016-11-02 20:09 ` Hong Xu
  2016-11-02 20:21   ` Eli Zaretskii
  2016-11-02 22:05   ` Andreas Schwab
  0 siblings, 2 replies; 15+ messages in thread
From: Hong Xu @ 2016-11-02 20:09 UTC (permalink / raw)
  To: 24861

[-- Attachment #1: Type: text/plain, Size: 53 bytes --]


The attachment is an updated version of the patch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: cpp-message.patch --]
[-- Type: text/x-diff, Size: 1442 bytes --]

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 7d641ab47f09..75ed7827adf8 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
+  "The minimum time interval in seconds that cpp-mode should
+print messages.  No message will be printed if set to
+`most-positive-fixnum'."
+  :type 'integer
+  :group 'cpp)
+
 (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)))
@@ -823,10 +830,10 @@ cpp-progress-time
 ;; Last time we issued a progress message.
 
 (defun cpp-progress-message (&rest args)
-  ;; Report progress at most once a second.  Take same ARGS as `message'.
+  "Report progress at most once a second.  Take same ARGS as `message'."
   (let ((time (nth 1 (current-time))))
-    (if (= time cpp-progress-time)
-	()
+    (when (>= (- time cpp-progress-time)
+              cpp-message-min-time-interval)
       (setq cpp-progress-time time)
       (apply 'message args))))
 

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-02 20:09 ` Hong Xu
@ 2016-11-02 20:21   ` Eli Zaretskii
  2016-11-02 23:34     ` Hong Xu
                       ` (2 more replies)
  2016-11-02 22:05   ` Andreas Schwab
  1 sibling, 3 replies; 15+ messages in thread
From: Eli Zaretskii @ 2016-11-02 20:21 UTC (permalink / raw)
  To: Hong Xu; +Cc: 24861

> From: Hong Xu <hong@topbug.net>
> Date: Wed, 02 Nov 2016 13:09:15 -0700
> 
> +(defcustom cpp-message-min-time-interval 1
> +  "The minimum time interval in seconds that cpp-mode should
> +print messages.  No message will be printed if set to
> +`most-positive-fixnum'."

Please avoid using passive tense as much as possible (in the last
sentence).

Also, I think it's accepted practice to use nil as the value which
disables a periodic feature.

(Not that I understand why this particular message needs to be
customizable.)

Thanks.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-02 20:09 ` Hong Xu
  2016-11-02 20:21   ` Eli Zaretskii
@ 2016-11-02 22:05   ` Andreas Schwab
  1 sibling, 0 replies; 15+ messages in thread
From: Andreas Schwab @ 2016-11-02 22:05 UTC (permalink / raw)
  To: Hong Xu; +Cc: 24861

On Nov 02 2016, Hong Xu <hong@topbug.net> wrote:

> diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
> index 7d641ab47f09..75ed7827adf8 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
> +  "The minimum time interval in seconds that cpp-mode should

The first line of a doc string should be a full sentence.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-02 20:21   ` Eli Zaretskii
@ 2016-11-02 23:34     ` Hong Xu
  2016-11-03 18:15       ` Eli Zaretskii
  2016-11-02 23:39     ` Hong Xu
  2016-11-03 16:39     ` Richard Stallman
  2 siblings, 1 reply; 15+ messages in thread
From: Hong Xu @ 2016-11-02 23:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 24861, Andreas Schwab


[-- Attachment #1.1: Type: text/plain, Size: 337 bytes --]


On 2016-11-02 Wed 13:21 GMT-0700, Eli Zaretskii <eliz@gnu.org> wrote:

> (Not that I understand why this particular message needs to be
> customizable.)

Because the messages by cpp.el is so frequent that it often competes
with other useful information. I've added some explanation in the
docstring.

The attachment is a new version.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: cpp-message.patch --]
[-- Type: text/x-diff, Size: 1803 bytes --]

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 7d641ab47f09..a0705023b448 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -104,6 +104,15 @@ cpp-edit-list
 			       (const :tag "Both branches writable" both))))
   :group 'cpp)
 
+(defcustom cpp-message-min-time-interval 1
+  "Indicate the minimum time interval in seconds that `cc-mode'
+should print messages.  If set to nil, `cc-mode' will print no
+message.  This may be useful to set when the message `cc-mode'
+prints too many messages that competes with other information in
+the echo area."
+  :type 'integer
+  :group 'cpp)
+
 (defvar cpp-overlay-list nil)
 ;; List of cpp overlays active in the current buffer.
 (make-variable-buffer-local 'cpp-overlay-list)
@@ -278,7 +287,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)))
@@ -823,12 +832,14 @@ cpp-progress-time
 ;; Last time we 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 at most once a second.  Take same ARGS as
+`message'."
+  (when cpp-message-min-time-interval
+    (let ((time (nth 1 (current-time))))
+      (when (>= (- time cpp-progress-time)
+                cpp-message-min-time-interval)
+        (setq cpp-progress-time time)
+        (apply 'message args)))))
 
 (provide 'cpp)
 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-02 20:21   ` Eli Zaretskii
  2016-11-02 23:34     ` Hong Xu
@ 2016-11-02 23:39     ` Hong Xu
  2016-11-03 16:39     ` Richard Stallman
  2 siblings, 0 replies; 15+ messages in thread
From: Hong Xu @ 2016-11-02 23:39 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 24861

[-- Attachment #1: Type: text/plain, Size: 297 bytes --]


On 2016-11-02 Wed 13:21 GMT-0700, Eli Zaretskii <eliz@gnu.org> wrote:

> (Not that I understand why this particular message needs to be
> customizable.)

Also note that this patch does NOT ONLY customize this particular
message: it affects all messages printed by `cpp-progress-message'.



Hong

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-02 20:21   ` Eli Zaretskii
  2016-11-02 23:34     ` Hong Xu
  2016-11-02 23:39     ` Hong Xu
@ 2016-11-03 16:39     ` Richard Stallman
  2 siblings, 0 replies; 15+ messages in thread
From: Richard Stallman @ 2016-11-03 16:39 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 24861, hong

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Please avoid using passive tense as much as possible (in the last
  > sentence).

Thank you for reminding people of this point.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-02 23:34     ` Hong Xu
@ 2016-11-03 18:15       ` Eli Zaretskii
  2016-11-03 18:43         ` Hong Xu
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2016-11-03 18:15 UTC (permalink / raw)
  To: Hong Xu; +Cc: 24861

> From: Hong Xu <hong@topbug.net>
> Cc: 24861@debbugs.gnu.org
> Cc: Andreas Schwab <schwab@linux-m68k.org>
> Date: Wed, 02 Nov 2016 16:34:22 -0700
> 
> On 2016-11-02 Wed 13:21 GMT-0700, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> > (Not that I understand why this particular message needs to be
> > customizable.)
> 
> Because the messages by cpp.el is so frequent that it often competes
> with other useful information.

Yes, but we have lots of similar messages in other places.  A search
for a call to 'message' that displays "SOMETHING...done" turns up more
than 270 hits.  Why is this particular package being singled out?

Also, what useful information does it conceal?  Can you show a use
case where this happens?

> I've added some explanation in the docstring.

That should not be necessary, such explanations should be in comments
and commit log messages.

Thanks.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-03 18:15       ` Eli Zaretskii
@ 2016-11-03 18:43         ` Hong Xu
  2016-11-16  0:03           ` Hong Xu
  0 siblings, 1 reply; 15+ messages in thread
From: Hong Xu @ 2016-11-03 18:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 24861

[-- Attachment #1: Type: text/plain, Size: 1393 bytes --]


On 2016-11-03 Thu 11:15 GMT-0700, Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Hong Xu <hong@topbug.net>
>> Cc: 24861@debbugs.gnu.org
>> Cc: Andreas Schwab <schwab@linux-m68k.org>
>> Date: Wed, 02 Nov 2016 16:34:22 -0700
>>
>> On 2016-11-02 Wed 13:21 GMT-0700, Eli Zaretskii <eliz@gnu.org> wrote:
>>
>> > (Not that I understand why this particular message needs to be
>> > customizable.)
>>
>> Because the messages by cpp.el is so frequent that it often competes
>> with other useful information.
>
> Yes, but we have lots of similar messages in other places.  A search
> for a call to 'message' that displays "SOMETHING...done" turns up more
> than 270 hits.  Why is this particular package being singled out?

It was not me who singled out this particular package; it was singled
out before, with the frequency hard coded to be 1 second. I just made it
more flexible and correct a misused plain `message'.

>
> Also, what useful information does it conceal?  Can you show a use
> case where this happens?

I've never seen how these information can be useful (ideally I would say
concealing all these cpp-progress-message unless some debug option is
turned on), but I'm probably not qualified enough to make such
assertion.

One annoying case is that I've set up to show the syntax error at point,
but the "Parsing...done" message frequently comes in the way before I
can read the message.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-03 18:43         ` Hong Xu
@ 2016-11-16  0:03           ` Hong Xu
  2016-11-18  9:39             ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Hong Xu @ 2016-11-16  0:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 24861

[-- Attachment #1: Type: text/plain, Size: 1543 bytes --]


On 2016-11-03 Thu 11:43 GMT-0800, Hong Xu <hong@topbug.net> wrote:

> On 2016-11-03 Thu 11:15 GMT-0700, Eli Zaretskii <eliz@gnu.org> wrote:
>
>>> From: Hong Xu <hong@topbug.net>
>>> Cc: 24861@debbugs.gnu.org
>>> Cc: Andreas Schwab <schwab@linux-m68k.org>
>>> Date: Wed, 02 Nov 2016 16:34:22 -0700
>>>
>>> On 2016-11-02 Wed 13:21 GMT-0700, Eli Zaretskii <eliz@gnu.org> wrote:
>>>
>>> > (Not that I understand why this particular message needs to be
>>> > customizable.)
>>>
>>> Because the messages by cpp.el is so frequent that it often competes
>>> with other useful information.
>>
>> Yes, but we have lots of similar messages in other places.  A search
>> for a call to 'message' that displays "SOMETHING...done" turns up more
>> than 270 hits.  Why is this particular package being singled out?
>
> It was not me who singled out this particular package; it was singled
> out before, with the frequency hard coded to be 1 second. I just made it
> more flexible and correct a misused plain `message'.
>
>>
>> Also, what useful information does it conceal?  Can you show a use
>> case where this happens?
>
> I've never seen how these information can be useful (ideally I would say
> concealing all these cpp-progress-message unless some debug option is
> turned on), but I'm probably not qualified enough to make such
> assertion.
>
> One annoying case is that I've set up to show the syntax error at point,
> but the "Parsing...done" message frequently comes in the way before I
> can read the message.

Can you still consider this patch?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-16  0:03           ` Hong Xu
@ 2016-11-18  9:39             ` Eli Zaretskii
  2016-11-18 19:55               ` Hong Xu
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2016-11-18  9:39 UTC (permalink / raw)
  To: Hong Xu; +Cc: 24861

> From: Hong Xu <hong@topbug.net>
> Cc: 24861@debbugs.gnu.org
> Date: Tue, 15 Nov 2016 16:03:19 -0800
> 
> Can you still consider this patch?

I'm okay with accepting this for the master branch, but the patch
needs some more work to fix the following issues:

 . The first line of each doc string should be a complete sentence.
 . The doc string of cpp-progress-message should mention
   cpp-message-min-time-interval.
 . The defcustom you are adding should have a :version tag.
 . The calculation in cpp-progress-message should be fixed to
   calculate the time difference between the current time and the time
   of the previous progress message, and compare that with the value
   of cpp-message-min-time-interval.  The old code just looked at the
   2nd member of the list returned by current-time, but that is no
   longer TRT when you need to compare the time difference, because
   that member can go back to zero.  You need to use time-subtract.
 . Last, but not least: please include ChangeLog-style commit log
   message for the changes.

Thanks.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-18  9:39             ` Eli Zaretskii
@ 2016-11-18 19:55               ` Hong Xu
  2016-11-19  7:50                 ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Hong Xu @ 2016-11-18 19:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 24861


[-- Attachment #1.1.1: Type: text/plain, Size: 1704 bytes --]

On 11/18/2016 01:39 AM, Eli Zaretskii wrote:
>> From: Hong Xu <hong@topbug.net>
>> Cc: 24861@debbugs.gnu.org
>> Date: Tue, 15 Nov 2016 16:03:19 -0800
>>
>> Can you still consider this patch?
> 
> I'm okay with accepting this for the master branch, but the patch
> needs some more work to fix the following issues:
> 
>  . The first line of each doc string should be a complete sentence.
>  . The doc string of cpp-progress-message should mention
>    cpp-message-min-time-interval.
>  . The defcustom you are adding should have a :version tag.
>  . The calculation in cpp-progress-message should be fixed to
>    calculate the time difference between the current time and the time
>    of the previous progress message, and compare that with the value
>    of cpp-message-min-time-interval.  The old code just looked at the
>    2nd member of the list returned by current-time, but that is no
>    longer TRT when you need to compare the time difference, because
>    that member can go back to zero.  You need to use time-subtract.
>  . Last, but not least: please include ChangeLog-style commit log
>    message for the changes.
> 

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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: cpp-message.patch --]
[-- Type: text/x-patch; name="cpp-message.patch", Size: 2085 bytes --]

diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 7d641ab47f09..41b7fc968a2d 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -104,6 +104,14 @@ cpp-edit-list
 			       (const :tag "Both branches writable" both))))
   :group 'cpp)
 
+(defcustom cpp-message-min-time-interval 1.0
+  "Indicate the minimum time interval in seconds that
+`cpp-progress-message' should print messages.
+`cpp-progress-message' prints no message if it is set to nil."
+  :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 +286,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 +827,21 @@ cpp-face-name
 
 ;;; Utilities:
 
-(defvar cpp-progress-time 0)
-;; Last time we issued a progress message.
+(defvar cpp-progress-time '(0 0 0 0)
+  "Indicate 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 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'."
+  (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)
 

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-18 19:55               ` Hong Xu
@ 2016-11-19  7:50                 ` Eli Zaretskii
  2016-11-20  0:20                   ` Hong Xu
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2016-11-19  7:50 UTC (permalink / raw)
  To: Hong Xu; +Cc: 24861

> Cc: 24861@debbugs.gnu.org
> From: Hong Xu <hong@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.





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-19  7:50                 ` Eli Zaretskii
@ 2016-11-20  0:20                   ` Hong Xu
  2016-11-25 10:53                     ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Hong Xu @ 2016-11-20  0:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 24861


[-- Attachment #1.1: Type: text/plain, Size: 2650 bytes --]


On 2016-11-18 Fri 23:50 GMT-0800, Eli Zaretskii <eliz@gnu.org> wrote:

>> Cc: 24861@debbugs.gnu.org
>> From: Hong Xu <hong@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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: cpp-message.patch --]
[-- Type: text/x-diff, Size: 2049 bytes --]

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)
 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode
  2016-11-20  0:20                   ` Hong Xu
@ 2016-11-25 10:53                     ` Eli Zaretskii
  0 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2016-11-25 10:53 UTC (permalink / raw)
  To: Hong Xu; +Cc: 24861-done

> From: Hong Xu <hong@topbug.net>
> Cc: 24861@debbugs.gnu.org
> Date: Sat, 19 Nov 2016 16:20:10 -0800
> 
> Thanks, updated.

Thanks, pushed to master.





^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-11-25 10:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-02 18:45 bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode Hong Xu
2016-11-02 20:09 ` Hong Xu
2016-11-02 20:21   ` Eli Zaretskii
2016-11-02 23:34     ` Hong Xu
2016-11-03 18:15       ` Eli Zaretskii
2016-11-03 18:43         ` Hong Xu
2016-11-16  0:03           ` Hong Xu
2016-11-18  9:39             ` Eli Zaretskii
2016-11-18 19:55               ` Hong Xu
2016-11-19  7:50                 ` Eli Zaretskii
2016-11-20  0:20                   ` Hong Xu
2016-11-25 10:53                     ` Eli Zaretskii
2016-11-02 23:39     ` Hong Xu
2016-11-03 16:39     ` Richard Stallman
2016-11-02 22:05   ` Andreas Schwab

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).