unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* autorevert and excessive verbosity.
@ 2004-03-30  2:43 Luc Teirlinck
  2004-03-30 20:08 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Luc Teirlinck @ 2004-03-30  2:43 UTC (permalink / raw)


If global-auto-revert-mode _and_ global-auto-revert-non-file-buffers
are enabled, the buffer-menu updates automatically every
auto-revert-interval seconds.  A buffer-stale-function which does that
should _never_ cause auto-revert-mode to print revert messages even if
auto-revert-verbose is t.  Otherwise Emacs becomes essentially
unusable.  Hence I propose the following patches to autorevert.el,
files.el and buff-menu.el, which are essentially just changes to my
own prior changes.  They would allow for a special return value `fast'
of buffer-stale-function, indicating that the function just returned
non-nil without really checking the need for reverting, because
reverting is fast anyway.  If there are no objections, I will install
these patches.

autorevert-diff2 assumes that autorevert-diff1 has been applied.  (See
the related thread autorevert and vc.)

===File ~/autorevert-diff2==================================
diff -c /home/teirllm/emacscvsdir/emacs/lisp/autorevert.el /home/teirllm/autorevert.latest.el
*** /home/teirllm/emacscvsdir/emacs/lisp/autorevert.el	Mon Mar 29 19:39:15 2004
--- /home/teirllm/autorevert.latest.el	Mon Mar 29 19:30:48 2004
***************
*** 293,309 ****
  This is an internal function used by Auto-Revert Mode."
    (unless (buffer-modified-p)
      (let (revert)
!       (when (or (and (buffer-file-name)
! 		     (file-readable-p (buffer-file-name))
! 		     (not (verify-visited-file-modtime (current-buffer))))
! 		(and (or auto-revert-mode global-auto-revert-non-file-buffers)
! 		     revert-buffer-function
! 		     (boundp 'buffer-stale-function)
! 		     (functionp buffer-stale-function)
! 		     (funcall buffer-stale-function t)))
! 	(setq revert t))
        (when revert
! 	(when auto-revert-verbose
  	  (message "Reverting buffer `%s'." (buffer-name)))
  	(revert-buffer 'ignore-auto 'dont-ask 'preserve-modes))
        ;; `preserve-modes' avoids changing the (minor) modes.  But we
--- 293,310 ----
  This is an internal function used by Auto-Revert Mode."
    (unless (buffer-modified-p)
      (let (revert)
!       (or (and (buffer-file-name)
! 	       (file-readable-p (buffer-file-name))
! 	       (not (verify-visited-file-modtime (current-buffer)))
! 	       (setq revert t))
! 	  (and (or auto-revert-mode global-auto-revert-non-file-buffers)
! 	       revert-buffer-function
! 	       (boundp 'buffer-stale-function)
! 	       (functionp buffer-stale-function)
! 	       (setq revert (funcall buffer-stale-function t))))
        (when revert
! 	(when (and auto-revert-verbose
! 		   (not (eq revert 'fast)))
  	  (message "Reverting buffer `%s'." (buffer-name)))
  	(revert-buffer 'ignore-auto 'dont-ask 'preserve-modes))
        ;; `preserve-modes' avoids changing the (minor) modes.  But we

Diff finished.  Mon Mar 29 19:41:32 2004
============================================================

===File ~/files.el-diff=====================================
*** files.el	26 Mar 2004 21:55:58 -0600	1.686
--- files.el	29 Mar 2004 19:51:38 -0600	
***************
*** 3458,3465 ****
    "Function to check whether a non-file buffer needs reverting.
  This should be a function with one optional argument NOCONFIRM.
  Auto Revert Mode sets NOCONFIRM to t.  The function should return
! non-nil if the buffer should be reverted.  The buffer is current
! when this function is called.
  
  The idea behind the NOCONFIRM argument is that it should be
  non-nil if the buffer is going to be reverted without asking the
--- 3458,3467 ----
    "Function to check whether a non-file buffer needs reverting.
  This should be a function with one optional argument NOCONFIRM.
  Auto Revert Mode sets NOCONFIRM to t.  The function should return
! non-nil if the buffer should be reverted.  A return value of
! `fast' means that the need for reverting was not checked, but
! that reverting the buffer is fast.  The buffer is current when
! this function is called.
  
  The idea behind the NOCONFIRM argument is that it should be
  non-nil if the buffer is going to be reverted without asking the
============================================================

===File ~/buff-menu.el-diff=================================
*** buff-menu.el	26 Mar 2004 19:53:00 -0600	1.65
--- buff-menu.el	29 Mar 2004 19:48:59 -0600	
***************
*** 185,191 ****
    (set (make-local-variable 'revert-buffer-function)
         'Buffer-menu-revert-function)
    (set (make-local-variable 'buffer-stale-function)
!        #'(lambda (&optional noconfirm) t))
    (setq truncate-lines t)
    (setq buffer-read-only t)
    (run-hooks 'buffer-menu-mode-hook))
--- 185,191 ----
    (set (make-local-variable 'revert-buffer-function)
         'Buffer-menu-revert-function)
    (set (make-local-variable 'buffer-stale-function)
!        #'(lambda (&optional noconfirm) 'fast))
    (setq truncate-lines t)
    (setq buffer-read-only t)
    (run-hooks 'buffer-menu-mode-hook))
============================================================

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

* Re: autorevert and excessive verbosity.
  2004-03-30  2:43 autorevert and excessive verbosity Luc Teirlinck
@ 2004-03-30 20:08 ` Stefan Monnier
  2004-03-31  2:46   ` Luc Teirlinck
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2004-03-30 20:08 UTC (permalink / raw)
  Cc: emacs-devel

> own prior changes.  They would allow for a special return value `fast'
> of buffer-stale-function, indicating that the function just returned

Why not call it `quiet'?


        Stefan

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

* Re: autorevert and excessive verbosity.
  2004-03-30 20:08 ` Stefan Monnier
@ 2004-03-31  2:46   ` Luc Teirlinck
  0 siblings, 0 replies; 3+ messages in thread
From: Luc Teirlinck @ 2004-03-31  2:46 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier wrote:

   > own prior changes.  They would allow for a special return value `fast'
   > of buffer-stale-function, indicating that the function just returned

   Why not call it `quiet'?

That would make sense for auto-revert.  But determining the stale-ness
of the buffer potentially could be useful for other things.  It seems
to me that `fast' better describes the reason for returning non-nil,
even though no check was done.

Sincerely,

Luc.

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

end of thread, other threads:[~2004-03-31  2:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-30  2:43 autorevert and excessive verbosity Luc Teirlinck
2004-03-30 20:08 ` Stefan Monnier
2004-03-31  2:46   ` Luc Teirlinck

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