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: autorevert.el Date: Wed, 3 Mar 2004 23:08:33 -0600 (CST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200403040508.i2458W811551@raven.dms.auburn.edu> References: <200403022319.i22NJbG01259@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1078606772 12865 80.91.224.253 (6 Mar 2004 20:59:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 6 Mar 2004 20:59:32 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat Mar 06 21:59:18 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 1AzitC-000648-00 for ; Sat, 06 Mar 2004 21:59:18 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AzitC-0003Re-00 for ; Sat, 06 Mar 2004 21:59:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1AzisL-0002rq-AY for emacs-devel@quimby.gnus.org; Sat, 06 Mar 2004 15:58:25 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1Ayl7h-0000gN-Cn for emacs-devel@gnu.org; Thu, 04 Mar 2004 00:10:17 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1Ayl79-0000Pk-Vy for emacs-devel@gnu.org; Thu, 04 Mar 2004 00:10:15 -0500 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.30) id 1Ayl79-0000Ml-HR for emacs-devel@gnu.org; Thu, 04 Mar 2004 00:09:43 -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 i2459YKt027624; Wed, 3 Mar 2004 23:09:34 -0600 (CST) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.6+Sun/8.11.6) id i2458W811551; Wed, 3 Mar 2004 23:08:33 -0600 (CST) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: monnier@iro.umontreal.ca In-reply-to: (message from Stefan Monnier on 03 Mar 2004 08:24:58 -0500) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 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:20253 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:20253 Stefan Monnier wrote: Most of the patch looks right (the list-diff thing was just horrendous and showed a serious misunderstanding), except I'd try to merge a bit more the dired and non-dired checks since both check the modtime. Not all parts of the function check the modtime and the two parts where the modtime gets checked do it in different ways (dired can not use `verify-visited-file-modtime', because it is not visiting a file). It seems that the only thing that is done unconditionally in all cases is check (buffer-modified-p), so I changed the function to first check this before splitting into cases. Also, I'd use file-remote-p rather than (string-match "@"), especially since remote files might not include any @. You are right. I kept this from the original code. I did not check this carefully enough. Note that I neither checked the code of the vc-part of the original patch, not tested it. As for the auto-revert-flag thingy, I find it truly ugly because I don't like dired knowing about auto-revert just for the sake of verbosity control. There's got to be a better way. Like what? I need some way to tell not only dired, but other non-file buffers as well, not to display the revert messages they usually do. The only real way I see is using a flag variable and I need one variable for all non-file buffers. The only alternative I see would be a similar variable inhibiting revert messages not "overtly" tied to auto-revert.el. I do not believe that would make a lot of difference in practice, but it could be done. Note that the code in question first checks: (boundp 'auto-revert-flag), so if autoreverting is not already in use, auto-revert.el will not be loaded (that would indeed be terribly ugly). I do not know whether you question the usefulness of the verbosity control itself. I implemented this because I felt a definite need for it. Constant gratuitous echo area messages are a distracting nuisance, not to mention being overshouted by them while trying to use the minibuffer and just hesitating slightly too long. Here are the changes I propose to my original autorevert.el patch. Essentially, I replaced the three separate (buffer-modified-p) checks by one single one at the very start and used file-remote-p instead of (string-match "@"). I could change the auto-revert-flag stuff once I understand your concrete objections better. Would a not-officially-linked-to-autorevert.el flag variable disabling revert messages (when set) in various non-file buffers, including dired buffers, take care of your objections? That would be easy to do. However, I definitely want to keep the functionality as a user option, disabled by default. Diff with previous version of the patch: ===File ~/auto-revert-newdiff=============================== diff -c /home/teirllm/autorevert.prev.el /home/teirllm/emacscvsdir/emacs/lisp/autorevert.el *** /home/teirllm/autorevert.prev.el Wed Mar 3 17:38:24 2004 --- /home/teirllm/emacscvsdir/emacs/lisp/autorevert.el Wed Mar 3 17:44:23 2004 *************** *** 278,312 **** "Check if current buffer should be reverted." ;; - Always include VC buffers to list. It would be too expensive ;; to test the "revert" status here each time timer launches. ! (or (and (eq major-mode 'dired-mode) ! (or (and global-auto-revert-mode ! global-auto-revert-non-file-buffers) ! auto-revert-mode) ! (not (buffer-modified-p)) ! (stringp dired-directory) ! ;; Exclude remote buffers, would be too slow for user ! ;; modem, timeouts, network lag ... all is possible ! (not (string-match "@" dired-directory)) ! (file-directory-p dired-directory) ! (file-readable-p dired-directory) ! (not (let ((attributes (file-attributes dired-directory)) ! (modtime (visited-file-modtime))) ! (or (eq modtime 0) ! (not (eq (car attributes) t)) ! (and (= (car (nth 5 attributes)) (car modtime)) ! (= (nth 1 (nth 5 attributes)) (cdr modtime))))))) ! (and (not (eq major-mode 'dired-mode)) ! (not (buffer-modified-p)) ! (auto-revert-vc-buffer-p)) ! (and (not (eq major-mode 'dired-mode)) ! (not (buffer-modified-p)) ! (if (buffer-file-name) ! (and (file-readable-p (buffer-file-name)) ! (not (verify-visited-file-modtime (current-buffer)))) ! (and revert-buffer-function ! (or (and global-auto-revert-mode ! global-auto-revert-non-file-buffers) ! auto-revert-mode)))))) (defun auto-revert-vc-cvs-file-version (file) "Get version of FILE by reading control file on disk." --- 278,310 ---- "Check if current buffer should be reverted." ;; - Always include VC buffers to list. It would be too expensive ;; to test the "revert" status here each time timer launches. ! (unless (buffer-modified-p) ! (or (and (eq major-mode 'dired-mode) ! (or (and global-auto-revert-mode ! global-auto-revert-non-file-buffers) ! auto-revert-mode) ! (stringp dired-directory) ! ;; Exclude remote buffers, would be too slow for user ! ;; modem, timeouts, network lag ... all is possible ! (not (file-remote-p dired-directory)) ! (file-directory-p dired-directory) ! (file-readable-p dired-directory) ! (not (let ((attributes (file-attributes dired-directory)) ! (modtime (visited-file-modtime))) ! (or (eq modtime 0) ! (not (eq (car attributes) t)) ! (and (= (car (nth 5 attributes)) (car modtime)) ! (= (nth 1 (nth 5 attributes)) (cdr modtime))))))) ! (and (not (eq major-mode 'dired-mode)) ! (auto-revert-vc-buffer-p)) ! (and (not (eq major-mode 'dired-mode)) ! (if (buffer-file-name) ! (and (file-readable-p (buffer-file-name)) ! (not (verify-visited-file-modtime (current-buffer)))) ! (and revert-buffer-function ! (or (and global-auto-revert-mode ! global-auto-revert-non-file-buffers) ! auto-revert-mode))))))) (defun auto-revert-vc-cvs-file-version (file) "Get version of FILE by reading control file on disk." Diff finished. Wed Mar 3 21:57:57 2004 ============================================================