[Top][All Lists]

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

vc-hooks.el vc-mode-line should not set read only for CVS

From: Jari Aalto+mail.emacs
Subject: vc-hooks.el vc-mode-line should not set read only for CVS
Date: 07 Mar 2001 18:38:38 +0200
User-agent: Gnus/5.090001 (Oort Gnus v0.01) Emacs/20.7 (i386-*-windows98.1998)

* 2001-03-07 Stefan acm <monnier+gnu.emacs.help/news/@flint.cs.yale.edu>

[Was] Re: Need help with intersection of emacs, cvs, and XP!
in newsgroup gnu.emacs.help

| >>>>> "Roy" == Roy Smith <roy@panix.com> writes:
| Actually, VC should never make the buffer read-only at all (I'm not
| 100% sure about that one, tho).  So the problem is more likely that Emacs
| thinks the file is not writable.  Could you try

It does that and it is highly annoying for CVS, this code should
be fixed.


(defun vc-mode-line (file &optional label)
  "Set `vc-mode' to display type of version control for FILE.
The value is set in the current buffer, which should be the buffer
visiting FILE.  Second optional arg LABEL is put in place of version
control system name."
  (interactive (list buffer-file-name nil))
  (let ((vc-type (vc-backend file)))
    (setq vc-mode
          (and vc-type
               (concat " " (or label (symbol-name vc-type)) 
                       (and vc-display-status (vc-status file)))))
    ;; If the file is locked by some other user, make
    ;; the buffer read-only.  Like this, even root
    ;; cannot modify a file that someone else has locked.
    (and vc-type 
         (equal file (buffer-file-name))
         (vc-locking-user file)
         (not (string= (vc-user-login-name) (vc-locking-user file)))
         (setq buffer-read-only t))
    ;; If the user is root, and the file is not owner-writable,
    ;; then pretend that we can't write it
    ;; even though we can (because root can write anything).
    ;; This way, even root cannot modify a file that isn't locked.
    (and vc-type
         (equal file (buffer-file-name))
         (not buffer-read-only)
         (zerop (user-real-uid))
         (zerop (logand (file-modes (buffer-file-name)) 128))
         (setq buffer-read-only t))
    ;;(set-buffer-modified-p (buffer-modified-p)) ;;use this if Emacs 18

reply via email to

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