On 2009-05-20 00:41 +0200, Zed Pobre wrote:

> I'm scratching my head over this one.  On the same system, with
> identical .emacs files in /root and in /home/zed, if I edit a file in a
> mercurial directory as user zed, I'm fine.  If I become root and then
> run, or even sudo, emacs on a file in a version-controlled directory, it
> breaks with the following backtrace:
>
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>   logand(nil 128)
>   vc-mode-line("/root/test.txt")
>   vc-find-file-hook()
>   run-hooks(find-file-hook)
>   after-find-file(t t)
>   find-file-noselect-1(#<buffer test.txt> "~/test.txt" nil nil "~/test.txt" 
> nil)
>   find-file-noselect("~/test.txt" nil nil t)
>   find-file("~/test.txt" t)
>   call-interactively(find-file)

I cannot really reproduce this, although I have a partial explanation.

The relevant code in the vc-mode-line function is this:

--8<---------------cut here---------------start------------->8---
      ;; 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 (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)))
--8<---------------cut here---------------end--------------->8---

Here (file-modes buffer-file-name) returns nil, which means Emacs could
not stat(2) the file, e.g. because it does not exist.  This would
explain the error (and also that you only get it as root and for new
files), except that vc-mode-line should not even be run for unregistered
files.  And it isn't for me.

What VC information do you get in the modeline when you visit a new file
as an ordinary user?

Sven



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to