From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Option for updating modeline VC state. Date: Sun, 27 Sep 2009 20:57:21 -0400 Message-ID: References: <87vdj6ieos.fsf@telefonica.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1254099463 2251 80.91.229.12 (28 Sep 2009 00:57:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Sep 2009 00:57:43 +0000 (UTC) Cc: emacs-devel@gnu.org To: =?iso-8859-1?Q?=D3scar?= Fuentes Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 28 02:57:36 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ms4YZ-00045V-2f for ged-emacs-devel@m.gmane.org; Mon, 28 Sep 2009 02:57:35 +0200 Original-Received: from localhost ([127.0.0.1]:37896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ms4YY-0008Nd-Di for ged-emacs-devel@m.gmane.org; Sun, 27 Sep 2009 20:57:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ms4YS-0008NO-QM for emacs-devel@gnu.org; Sun, 27 Sep 2009 20:57:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ms4YO-0008KN-Ae for emacs-devel@gnu.org; Sun, 27 Sep 2009 20:57:28 -0400 Original-Received: from [199.232.76.173] (port=32884 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ms4YO-0008KH-5v for emacs-devel@gnu.org; Sun, 27 Sep 2009 20:57:24 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:40473 helo=ironport2-out.pppoe.ca) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ms4YN-0006HY-Nt for emacs-devel@gnu.org; Sun, 27 Sep 2009 20:57:23 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvIEAEKmv0pFxIo//2dsb2JhbACBUNBuhB4Fh30 X-IronPort-AV: E=Sophos;i="4.44,462,1249272000"; d="scan'208";a="46681650" Original-Received: from 69-196-138-63.dsl.teksavvy.com (HELO pastel.home) ([69.196.138.63]) by ironport2-out.pppoe.ca with ESMTP; 27 Sep 2009 20:57:22 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id B86D480C4; Sun, 27 Sep 2009 20:57:21 -0400 (EDT) In-Reply-To: <87vdj6ieos.fsf@telefonica.net> (=?iso-8859-1?Q?=22=D3scar?= Fuentes"'s message of "Sat, 26 Sep 2009 05:10:27 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115703 Archived-At: > In short, the VC state modeline is changed to signal `edited' the first > time the file is saved. Even if subsequent editions revert the file to > its pristine state, the VC state modeline will keep showing the `edited' > flag. As Dan is concerned about performance issues if VC asks the > backend for the state of the file, this is implemented as an option > disabled by default. Maybe there are backends where this option might be "necessary", but until this is proved to be the case, I'd rather not have any option and instead consider any performance problem as a bug. One more thing, tho: I'd really like it if this state-recomputation could be done once for all the affected nuffers (i.e. for the buffer currently visiting the file as well as all the vc-dir buffers that include the file). Could someone refactor the code accordingly? Stefan > 2009-09-24 Oscar Fuentes > * lisp/vc-hooks.el (vc-always-update-modeline-after-save): > new defcustom. > (vc-after-save): Use it and when non-nil check the vc file state > so the modeline reflects its actual state. > diff -cp "c:/apps/emacs/lisp/vc-hooks.el" "d:/vc-hooks.el" > *** c:/apps/emacs/lisp/vc-hooks.el 2009-09-24 07:25:53.000000000 +0200 > --- d:/vc-hooks.el 2009-09-24 08:10:01.062500000 +0200 > *************** If nil (the default), files covered by v > *** 96,101 **** > --- 96,110 ---- > :group 'vc > :group 'backup) > + (defcustom vc-always-update-modeline-after-save nil > + "If non-nil, always update the state shown in the modeline > + after saving the file. This may be time-consuming for some > + backends. If nil, the modeline changes to `edited' when the file > + is saved for the first time and it is not updated on subsequent > + saves." > + :type 'boolean > + :group 'vc) > + > (defcustom vc-follow-symlinks 'ask > "What to do if visiting a symbolic link to a file under version control. > Editing such a file through the link bypasses the version control system, > *************** Before doing that, check if there are an > *** 743,751 **** > ;; to avoid confusion. > (vc-file-setprop file 'vc-checkout-time nil)) > t) > - (vc-up-to-date-p file) > (eq (vc-checkout-model backend (list file)) 'implicit) > ! (vc-file-setprop file 'vc-state 'edited) > (vc-mode-line file backend) > ;; Try to avoid unnecessary work, a *vc-dir* buffer is > ;; present if and only if this is true. > --- 752,766 ---- > ;; to avoid confusion. > (vc-file-setprop file 'vc-checkout-time nil)) > t) > (eq (vc-checkout-model backend (list file)) 'implicit) > ! (if vc-always-update-modeline-after-save > ! (progn > ! ;; Avoid using cached value on `vc-state': > ! (vc-file-setprop file 'vc-state 'nil) > ! (vc-file-setprop file 'vc-state (vc-state file backend))) > ! (and > ! (vc-up-to-date-p file) > ! (vc-file-setprop file 'vc-state 'edited))) > (vc-mode-line file backend) > ;; Try to avoid unnecessary work, a *vc-dir* buffer is > ;; present if and only if this is true.