From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Re: Suggestion for autorevert.el Date: Thu, 1 Apr 2004 22:09:31 -0600 (CST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200404020409.i3249Vw24362@raven.dms.auburn.edu> References: <87zna6l1kn.fsf@offby1.atm01.sea.blarg.net> <200404010330.i313Ug621242@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1080879294 7271 80.91.224.253 (2 Apr 2004 04:14:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 2 Apr 2004 04:14:54 +0000 (UTC) Cc: offby1@blarg.net, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Apr 02 06:14:44 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1B9G4q-0007GY-00 for ; Fri, 02 Apr 2004 06:14:44 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1B9G4q-00018B-00 for ; Fri, 02 Apr 2004 06:14:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B9G4n-0007q6-NI for emacs-devel@quimby.gnus.org; Thu, 01 Apr 2004 23:14:41 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1B9G4U-0007fJ-AG for emacs-devel@gnu.org; Thu, 01 Apr 2004 23:14:22 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1B9G2l-0005jH-Ns for emacs-devel@gnu.org; Thu, 01 Apr 2004 23:13:07 -0500 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B9G25-0004VB-Hm; Thu, 01 Apr 2004 23:11:53 -0500 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id i324BiKt005636; Thu, 1 Apr 2004 22:11:44 -0600 (CST) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.6+Sun/8.11.6) id i3249Vw24362; Thu, 1 Apr 2004 22:09:31 -0600 (CST) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: rms@gnu.org In-reply-to: (message from Richard Stallman on Thu, 01 Apr 2004 12:34:15 -0500) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:21184 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:21184 Adapting auto-revert for tailing turned out to be somewhat more complex than may have seemed at first. Indeed, when tailing a file in a window, I definitely do not want to keep that window permanently selected for tailing to work correctly. But then just worrying about the buffer value of point is not good enough, we have to worry about the _window_ values of point. The added code, which calls the non-primitive and non-optimized `get-buffer-window-list' and does some consing, only gets called when one needs to revert a _file buffer_. In my usage, this happens very infrequently. If a huge amount of files are continuously reverting, then maybe there could be a problem. One could leave the patch as is, or make it dependent on a user option `auto-revert-tail', as Eric originally suggested. If the latter, one could make the default value `t', since I believe that a huge amount of continuously reverting files would be an extremely rare occurrence. But the option would allow people to (maybe temporarily) disable the feature if excessive CPU usage or consing became a problem. As a side remark: is there ever any reason to use (buffer-file-name) instead of just buffer-file-name? I used the latter, which produces stylistic inconsistency with prior code in autorevert.el. If there are no objections, I would change the prior code. (The patch below does not yet do that.) ===File ~/autorevert-tail-diff============================== *** autorevert.el 31 Mar 2004 10:03:44 -0600 1.28 --- autorevert.el 01 Apr 2004 21:27:48 -0600 *************** *** 44,49 **** --- 44,60 ---- ;; seconds. The check is aborted whenever the user actually uses ;; Emacs. You should never even notice that this package is active ;; (except that your buffers will be reverted, of course). + ;; + ;; After reverting a file buffer, Auto Revert Mode normally puts point + ;; at the same position that a regular manual revert would. However, + ;; there is one exception to this rule. If point is at the end of the + ;; buffer before reverting, it stays at the end. Similarly if point + ;; is displayed at the end of a file buffer in any window, it will stay + ;; at the end of the buffer in that window, even if the window is not + ;; selected. This way, you can use Auto Revert Mode to `tail' a file. + ;; Just put point at the end of the buffer and it will stay there. + ;; These rules apply to file buffers. For non-file buffers, the + ;; behavior may be mode dependent. ;; Usage: ;; *************** *** 298,306 **** "Revert current buffer, if appropriate. 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) --- 309,317 ---- "Revert current buffer, if appropriate. This is an internal function used by Auto-Revert Mode." (unless (buffer-modified-p) ! (let (revert eob winlist eoblist) ! (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) *************** *** 312,318 **** (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 ;; do want to reset the mode for VC, so we do it manually. (when (or revert auto-revert-check-vc-info) --- 323,340 ---- (when (and auto-revert-verbose (not (eq revert 'fast))) (message "Reverting buffer `%s'." (buffer-name))) ! (when buffer-file-name ! (setq eob (eobp)) ! (setq winlist (get-buffer-window-list (current-buffer) 'no-mini t)) ! (setq eoblist ()) ! (dolist (window winlist) ! (push (cons (= (window-point window) (point-max)) window) ! eoblist))) ! (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes) ! (when buffer-file-name ! (when eob (goto-char (point-max))) ! (dolist (pair eoblist) ! (when (car pair) (set-window-point (cdr pair) (point-max)))))) ;; `preserve-modes' avoids changing the (minor) modes. But we ;; do want to reset the mode for VC, so we do it manually. (when (or revert auto-revert-check-vc-info) ============================================================