unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Option for updating modeline VC state.
@ 2009-09-26  3:10 Óscar Fuentes
  2009-09-28  0:57 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Óscar Fuentes @ 2009-09-26  3:10 UTC (permalink / raw)
  To: emacs-devel

This comes from
http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=4515

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.


2009-09-24  Oscar Fuentes  <ofv@wanadoo.es>

	* 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.





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

* Re: [PATCH] Option for updating modeline VC state.
  2009-09-26  3:10 [PATCH] Option for updating modeline VC state Óscar Fuentes
@ 2009-09-28  0:57 ` Stefan Monnier
  2009-09-28  1:30   ` Óscar Fuentes
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2009-09-28  0:57 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-devel

> 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  <ofv@wanadoo.es>

> 	* 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.






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

* Re: [PATCH] Option for updating modeline VC state.
  2009-09-28  0:57 ` Stefan Monnier
@ 2009-09-28  1:30   ` Óscar Fuentes
  0 siblings, 0 replies; 3+ messages in thread
From: Óscar Fuentes @ 2009-09-28  1:30 UTC (permalink / raw)
  To: emacs-devel; +Cc: Stefan Monnier

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 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.

Just to clarify: the default value for the option corresponds to the
current behaviour, which is the lazy one. This masks performance
problems (and gives inaccurate results). My understanding of your words
indicates that you want to remove the lazy check and always do the full
check. Is this correct?

> 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?

That is already done, as per the comment at the end of vc-after-save,
although I don't know Elisp enough to understand how it works.

>
>         Stefan
>
>
>> 2009-09-24  Oscar Fuentes  <ofv@wanadoo.es>
>
>> 	* 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.
>
>
>
>
>

-- 
Óscar Fuentes
Desarrollo de Software





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

end of thread, other threads:[~2009-09-28  1:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-26  3:10 [PATCH] Option for updating modeline VC state Óscar Fuentes
2009-09-28  0:57 ` Stefan Monnier
2009-09-28  1:30   ` Óscar Fuentes

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).