From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Hong Xu Newsgroups: gmane.emacs.bugs Subject: bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode Date: Fri, 18 Nov 2016 11:55:28 -0800 Message-ID: References: <87r36tn2ka.fsf@topbug.net> <87oa1xmyok.fsf@topbug.net> <83d1idmy3c.fsf@gnu.org> <87pomdihhd.fsf@topbug.net> <831sysmnvc.fsf@gnu.org> <87a8dgo13q.fsf@topbug.net> <877f84mgu0.fsf@topbug.net> <83zikxcejl.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="67DCT1hO27duOB8Den1nJqJTfQo6W3k8c" X-Trace: blaine.gmane.org 1479498983 5664 195.159.176.226 (18 Nov 2016 19:56:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 18 Nov 2016 19:56:23 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 Cc: 24861@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 18 20:56:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7pGd-0008Kn-EI for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 Nov 2016 20:56:11 +0100 Original-Received: from localhost ([::1]:38665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7pGg-0006T9-Pv for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 Nov 2016 14:56:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7pGa-0006T4-CP for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2016 14:56:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7pGZ-0005w9-4b for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2016 14:56:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47052) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c7pGV-0005v3-BD; Fri, 18 Nov 2016 14:56:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c7pGU-0004GY-Bn; Fri, 18 Nov 2016 14:56:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Hong Xu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 18 Nov 2016 19:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24861 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: patch Original-Received: via spool by 24861-submit@debbugs.gnu.org id=B24861.147949894216373 (code B ref 24861); Fri, 18 Nov 2016 19:56:02 +0000 Original-Received: (at 24861) by debbugs.gnu.org; 18 Nov 2016 19:55:42 +0000 Original-Received: from localhost ([127.0.0.1]:34218 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7pGA-0004G1-2h for submit@debbugs.gnu.org; Fri, 18 Nov 2016 14:55:42 -0500 Original-Received: from sender163-mail.zoho.com ([74.201.84.163]:21365) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7pG8-0004Fs-7c for 24861@debbugs.gnu.org; Fri, 18 Nov 2016 14:55:40 -0500 Original-Received: from [10.123.31.61] (usc-secure-wireless-088-061.usc.edu [68.181.88.61]) by mx.zohomail.com with SMTPS id 1479498933915936.3908448330425; Fri, 18 Nov 2016 11:55:33 -0800 (PST) In-Reply-To: <83zikxcejl.fsf@gnu.org> X-Zoho-Virus-Status: 1 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:125845 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --67DCT1hO27duOB8Den1nJqJTfQo6W3k8c Content-Type: multipart/mixed; boundary="d9unRrHr8huwC3f8Gjj1GwbmWNrCqCnUr"; protected-headers="v1" From: Hong Xu To: Eli Zaretskii Cc: 24861@debbugs.gnu.org Message-ID: Subject: Re: bug#24861: [PATCH] Fix annoying "Parsing...done" message in c++-mode References: <87r36tn2ka.fsf@topbug.net> <87oa1xmyok.fsf@topbug.net> <83d1idmy3c.fsf@gnu.org> <87pomdihhd.fsf@topbug.net> <831sysmnvc.fsf@gnu.org> <87a8dgo13q.fsf@topbug.net> <877f84mgu0.fsf@topbug.net> <83zikxcejl.fsf@gnu.org> In-Reply-To: <83zikxcejl.fsf@gnu.org> --d9unRrHr8huwC3f8Gjj1GwbmWNrCqCnUr Content-Type: multipart/mixed; boundary="------------6EFDCD1D6731E0436FB8BC54" This is a multi-part message in MIME format. --------------6EFDCD1D6731E0436FB8BC54 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/18/2016 01:39 AM, Eli Zaretskii wrote: >> From: Hong Xu >> Cc: 24861@debbugs.gnu.org >> Date: Tue, 15 Nov 2016 16:03:19 -0800 >> >> Can you still consider this patch? >=20 > I'm okay with accepting this for the master branch, but the patch > needs some more work to fix the following issues: >=20 > . 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. >=20 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. --------------6EFDCD1D6731E0436FB8BC54 Content-Type: text/x-patch; name="cpp-message.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="cpp-message.patch" 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) =20 +(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 =20 ;;; Utilities: =20 -(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.") =20 (defun cpp-progress-message (&rest args) - ;; Report progress at most once a second. Take same ARGS as `message'= =2E - (let ((time (nth 1 (current-time)))) - (if (=3D 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 (>=3D (float-time (time-subtract time cpp-progress-time)) + cpp-message-min-time-interval) + (setq cpp-progress-time time) + (apply 'message args))))) =20 (provide 'cpp) =20 --------------6EFDCD1D6731E0436FB8BC54-- --d9unRrHr8huwC3f8Gjj1GwbmWNrCqCnUr-- --67DCT1hO27duOB8Den1nJqJTfQo6W3k8c Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYL1y1AAoJECZsfTOCL4R4BnMP/3LRshISTbTN4DxrfeWsq+xi IdQpdDOxzRBeqn3tDDmlMTQtZ8DBEvri8+zdQrFGsn03ftfCM+uMHl5oFeL+I/Xi UE+HPYBqPfrXjDZ9EukeUlscevzJg4GnbME+Vu9W+AEQCIwCule6f8RZpOlk7gWd Nx5JJCysDly2AHoprKfc36ShxdypzHO6Th1n+2bkV7MFT4rHkRoeI5cjaWGkj8rS zaxHCPRT8LX+lvMClY0nEvSr5IOoJl4hODJ0LhTNAO56yYAWXjSGY/IigKtkcveq AZbKVLcTN31/MVXI8iMLU1HYNnQICGxkigh9mzCVQTKuAeYnNFMxSbjLIpeRFjuX VlH1nVkDfWtXH1AgGkaL/+xych42DkydzSTs2mFZz8ofv7QAi3x6r0ufaubqCl9C 2QfUr8GijGFIazfA5Ym9Flb35zy3rFwhNnyoyycscBdlGecLMF08dOgX47bGIuxV FhlsQJtkKNpu/cNEiawuyHSfCP+yFvrOLaaD7+5o8TC6WGhIrBcU9wc8n1zUBTxB NJLowA7BhK3aTPNxe9Hf/pq+t8cneUhdAAWwKoFvGBAIewYYOV0Z38F2VcqWVyxl V7u6zga6jv1tF0vIzuj1dBrnlI3QWo0ELfn/15M+I5ln3vuHekA3Xis0jKpOkuoV T2JkqtVpPGOVglBMIauR =i/Rn -----END PGP SIGNATURE----- --67DCT1hO27duOB8Den1nJqJTfQo6W3k8c--