Subject: bug#11412: 24.0.95; auto-revert-mode doesn't revert buffer when file becomes writeable

From: Eric Hanchrow <[email-masked]>
Date: Sat, 5 May 2012 08:23:36 -0700

This is probably not an actual bug, since I think Emacs is doing what
it was designed to do.  Rather, it's more of a feature request.

Put this form in a freshly-started emacs and evaluate it:

(let ((fn (make-temp-file "frotzplotz")))
  (set-file-modes fn #o444)
  (find-file fn)
  (auto-revert-mode 1)
  (message "Note the %% in the mode line")
  (sit-for 1)
  (set-file-modes fn #o644)
  (message "It'd be nice if the %% in the mode line went away"))

When the evaluation finishes, you'll see a (empty) buffer visiting the
temp file.  The buffer will be read-only, as indicated by the %% in the
mode line.  However, this is less than ideal; the file is writeable, so
it'd be nice if the mode line so indicated.

In fact, the buffer never reverted; I assme because Emacs only looks
at the st_mtime field of the stat info, whereas when I made the file
writeable, only the st_ctime field changed.  So: perhaps
verify-visited-file-modtime could check st_ctime as well, or (probably
less disruptive) perhaps auto-revert-handler could check that.

This change would be useful in one case: when I'm using a
revision-control system that "locks" files by making them read-only,
and I then "check out" the file, it'd be nice if my read-only buffer
would automatically become writable to reflect the corresponding
change in the underlying file.

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/usr/local/src/emacs/etc/DEBUG.

In GNU Emacs 24.0.95.1 (i686-pc-linux-gnu)
 of 2012-04-04 on ip-10-171-85-229
Configured using:
 `configure '--without-x''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-ring-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-match-mode: t
  erc-netsplit-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-autojoin-mode: t
  erc-log-mode: t
  erc-services-mode: t
  erc-networks-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  shell-dirtrack-mode: t
  eldoc-mode: t
  global-auto-revert-mode: t
  recentf-mode: t
  ido-everywhere: t
  display-time-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
" p r o c e s s " SPC c a l l s SPC w i t h SPC e l
i s p SPC f u n c t i o n s SPC t h o u g h C-c C-c
q q q C-a C-u C-p C-p C-p ESC C-k C-x C-o C-x C-s C-h
i i c h m o d RET t C-s c h m o d C-s C-a i r e a d
- o TAB RET , , , , , , , , , , , , t C-s m o d e s
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-a i f
i l e SPC m o d e TAB s RET u i ESC p ESC p ESC n C-e
, SPC s e TAB RET C-x 2 C-x b RET ESC m ESC C-k ESC
( s e t - f i l e - m o d e s SPC f n SPC C-x o C-v
C-x o # o 4 4 4 C-x C-e C-n C-n C-n C-a C-n C-n ESC
m ESC C-k ESC ( s e t - f ESC / SPC f n SPC # o 6 4
4 C-x C-s ESC C-x C-x o C-x b t m p RET g C-x o C-x
o ESC ! ESC p ESC p ESC p ESC p ESC d ESC d ESC d ESC
d ESC d e c h o C-e ESC \ TAB RET C-x b s h e RET ESC
> C-x b b u RET C-x 1 C-x v v d o n e C-c C-c ESC x
r e p o r t - e m a c s TAB RET

Recent messages:
Saving file /home/erich/bug/bug.el...
Wrote /home/erich/bug/bug.el
Note: file is write protected
Note the % in the mode line
It'd be nice if the % in the mode line went away [2 times]
(Shell command succeeded with no output)
Mark set [2 times]
Press C-c C-c when you are done editing.
Enter a change comment.  Type C-c C-c when done
Checking in /home/erich/bug/bug.el...done

Load-path shadows:
~/.emacs.d/custom hides /usr/local/src/emacs/lisp/custom
/home/erich/.emacs.d/elpa/eieio-1.4/eieio-opt hides
/usr/local/src/emacs/lisp/emacs-lisp/eieio-opt
/home/erich/.emacs.d/elpa/eieio-1.4/eieio hides
/usr/local/src/emacs/lisp/emacs-lisp/eieio

Features:
(cmuscheme org-table cl-specs edebug novice wdired browse-kill-ring
erc-fill tmm electric vc-arch vc-mtn vc-hg chistory ind-util ruby-mode
find-dired vc-annotate doc-view image-mode whitespace pcmpl-gnu
make-mode log-view repeat compare-w rmailmm rmail nxml-uchnm rng-xsd
xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc rng-uri rng-parse
nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode
nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok sgml-mode
two-column skeleton cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs python-21 python scheme morse
sh-script executable cperl-mode iswitchb color descr-text shadow sort
mail-extr emacsbug message rfc822 mml mml-sec mm-decode mm-bodies
mm-encode mailabbrev gmm-utils mailheader gist gh-gist gh-oauth gh-api
gh-cache gh-auth gh-common debug apropos conf-mode timezone logito
pcache json eieio-base pcache-autoloads eieio-comp inversion speedbar
sb-image ezimage dframe eieio-autoloads tar-mode logito-autoloads
autoload epa-file epa epg epg-config mule-util parse-time url-cache
url-http mail-parse rfc2231 url-gw url-auth url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-util url-parse
url-vars mailcap finder-inf loadhist rect disp-table jka-compr tabify
sql-indent sql face-remap org-wl org-w3m org-vm org-rmail org-mhe
org-mew org-irc org-jsinfo org-infojs org-html org-exp ob-exp
org-exp-blocks org-agenda org-info org-gnus org-docview org-bibtex
bibtex org-bbdb org ob-emacs-lisp ob-tangle ob-ref ob-lob ob-table
org-footnote org-src ob-comint ob-keys ob ob-eval org-pcomplete org-list
org-faces org-compat org-entities org-macs noutline outline cal-menu
calendar cal-loaddefs dired-aux info iso-transl dabbrev log-edit
pcvs-util add-log smerge-mode newcomment diff-mode easy-mmode cus-edit
cus-start cus-load help-mode view edit-list multi-isearch ffap vc-bzr
vc-sccs vc-svn vc-cvs vc-rcs vc-dir ewoc vc ediff-merg ediff-diff
ediff-wind ediff-help ediff-util ediff-mult ediff-init ediff
vc-dispatcher pcmpl-unix network-stream tls erc-hl-nicks erc-menu
erc-ring erc-pcomplete erc-track erc-match erc-netsplit erc-button
erc-stamp erc-truncate erc-spelling flyspell ispell erc-join erc-log
erc-services erc-networks erc-goodies erc erc-backend erc-compat
format-spec thingatpt pp shell pcomplete woman man
erc-hl-nicks-autoloads package tabulated-list eldoc midnight uniquify
warnings protbuf etags vc-git derived autorevert paste-to-dropbox advice
help-fns advice-preload path server starttls smtpmail auth-source eieio
byte-opt bytecomp byte-compile cconv macroexp assoc gnus-util time-date
password-cache sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils grep compile comint ansi-color ring tool-bar cl find-func
ibuf-ext ibuf-macs ibuffer recentf tree-widget wid-edit ido dired-x
easymenu dired regexp-opt edmacro kmacro rx autoinsert time image
ediff-hook vc-hooks lisp-float-type lisp-mode register page menu-bar
rfn-eshadow timer select mouse jit-lock font-lock syntax facemenu
font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind multi-tty emacs)