bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C-x C-q more useful as toggle-read-only


From: Klaus Berndl
Subject: Re: C-x C-q more useful as toggle-read-only
Date: 24 Oct 2000 19:24:53 +0200
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7

On 24 Oct 2000, Michael J. Downes wrote:

>  address@hidden (Klaus Berndl) writes:
>  
> > If a file is under version control IMHO toggle-read-only makes no sense,
> > in such a case your options are to check out, uncheckout or check in.
>  ..
> > I'm wondering in which respect the current behavior of
> > *vc-toggle-read-only* doesn't satisfy some people??
>  
>  Here is an example:
>  
>  On Tuesday I check out foo.bar in module A and begin making some
>  changes. On Wednesday I get called away to some other tasks. On Friday I
>  remember that I was working on something in the module A but can't
>  recall which file so I start looking at some files with
>  find-file-read-only. (It is not uncommon for me to use
>  find-file-read-only when I am not sure that I will be changing the
>  file.) When I find foo.bar I say "Aha, yes, this is where I was
>  working". The file is already checked out and writable, but the buffer
>  is read only because of the command that I used to get the file.
>  
>  Now given that I have the file in front of my eyes, what is the most
>  direct way to continue working on it? toggle-read-only. But if I do C-x
>  C-q I get instead vc-toggle-read-only whose default action in this case
>  is to *ask if I want to revert to the master version*!?!
>

,----
| (defun vc-toggle-read-only (&optional verbose)
|   "Change read-only status of current buffer, perhaps via version control.
| If the buffer is visiting a file registered with version control,
| then check the file in or out.  Otherwise, just change the read-only flag
| of the buffer.
| With prefix argument, ask for version number to check in or check out.
| Check-out of a specified version number does not lock the file;
| to do that, use this command a second time with no argument."
|   (interactive "P")
|   (cond ( ;; file is under version-control AND buffer is read only AND file
|           ;; is writeable therefore it must be checked out. Therefore the
|           ;; action should only be a toggle-read-only and not any
|           ;; version-control action!
|           ;; Does not exactly know if this works for CVS??!!
|          (and (or (and (boundp 'vc-dired-mode) vc-dired-mode)
|                   ;; use boundp because vc.el might not be loaded
|                   (vc-backend (buffer-file-name)))
|               buffer-read-only
|               (file-writable-p buffer-file-name))
|          (toggle-read-only))
|         ( ;; file is under version-control so do the next appropriate
|           ;; action in vc
|          (or (and (boundp 'vc-dired-mode) vc-dired-mode)
|              ;; use boundp because vc.el might not be loaded
|              (vc-backend (buffer-file-name)))
|          (vc-next-action verbose))
|         ( ;; file is not under version control so do only a toggle-read-only
|          t
|          (toggle-read-only))))
| (define-key global-map "\C-x\C-q" 'vc-toggle-read-only)
`----

OK, your example is plausible for me. Does this slightly modified version of
*vc-toggle-read-only* what you want (s.a.)?  I have commented the different
cases of the (cond...)-form and what should be done.

I´m not so firm with RCS, CVS and SCCS because i´m using ClearCase and with
clearcase.el the *clearcase-toggle-read-only* has exactly the behavior you
need and is bound to C-x C-q. Í have tried the scenario you described above
and it works fine. Please test the code above and tell me if works!
(the documentation-string of the new version is not adjusted)

>  [...]
>  
>  But in general it seems to me automatically doing version control
>  operations without confirmation violates the principle of least
>  surprise; therefore it should be an expert option rather than the
>  default behavior.

If an automatic does the correct thing then it is really the best for a newbie
IMHO :-)

Klaus

-- 
Klaus Berndl                    mailto: address@hidden
sd&m AG                         http://www.sdm.de
software design & management    
Thomas-Dehler-Str. 27, 81737 München, Germany
Tel +49 89 63812-392, Fax -220



reply via email to

[Prev in Thread] Current Thread [Next in Thread]