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: find-file-hook as illustration of Custom problems Date: Thu, 3 Feb 2005 18:36:55 -0600 (CST) Message-ID: <200502040036.j140atb03430@raven.dms.auburn.edu> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1107477623 1444 80.91.229.2 (4 Feb 2005 00:40:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 4 Feb 2005 00:40:23 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 04 01:40:23 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1CwrWB-0004kQ-Jq for ged-emacs-devel@m.gmane.org; Fri, 04 Feb 2005 01:40:15 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cwrjb-0001PN-RV for ged-emacs-devel@m.gmane.org; Thu, 03 Feb 2005 19:54:07 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Cwrj7-0001Hp-64 for emacs-devel@gnu.org; Thu, 03 Feb 2005 19:53:37 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Cwriu-00018b-1M for emacs-devel@gnu.org; Thu, 03 Feb 2005 19:53:26 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cwrit-00016r-3A for emacs-devel@gnu.org; Thu, 03 Feb 2005 19:53:23 -0500 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CwrUJ-0006GQ-CK for emacs-devel@gnu.org; Thu, 03 Feb 2005 19:38:19 -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 j140cC9N024727 for ; Thu, 3 Feb 2005 18:38:13 -0600 (CST) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j140atb03430; Thu, 3 Feb 2005 18:36:55 -0600 (CST) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: main.gmane.org gmane.emacs.devel:32851 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:32851 Programs adding entries to hooks or other lists or alists that are defined by defcustoms can yield _all kinds_ of problems. If you do `emacs -q' and then `M-x customize-rogue' you will see well over twenty variables that are defined with defcustoms and are then changed by code. Just experimenting a little bit with these variables in Custom buffers (_not_ in `emacs -q', because you want a regular customized Emacs for this) will reveal a wide variety of buggish behavior. I _only_ took a look at find-file-hook, because I wanted a really easy example. (Plenty of other variables, look like they might be a much bigger mess.) If you customize find-file-hook, then regret your customizations and select "Erase Customization" VC will not work any more, for newly visited files. If you use auto-revert-tail-mode, it will malfunction from that moment on, for newly visited files. Both will work again if you start a new session, but the fact that they cease to work without warning in the current session is bad enough. The problem is that vc-hooks.el contains: (add-hook 'find-file-hook 'vc-find-file-hook) and autorevert.el contains: (add-hook 'find-file-hook (lambda () (set (make-local-variable 'auto-revert-tail-pos) (save-restriction (widen) (1- (point-max)))))) Since vc-hooks.el is apparently preloaded, one could either call vc-find-file-hook directly from after-find-file or one could add it to the defcustom of find-file-hook. Since it seems to be a function that needs to run _unconditionally_, I personally would lean toward calling it from after-find-file directly. What should be done with the auto-revert-tail-mode problem is not that straightforward. I would say just ignore it for the moment. I just noticed auto-revert-tail, because I use auto-revert-mode, but looking through the code, I noticed that several other packages add stuff to find-file-hook in the same way and hence will also be disabled by "Erase Customization ". I guess that after "21.4" is released, we could split some of the most often used and most problematic hooks (like find-file-hook) into a user and a program hook, thereby solving this kind of problem. (Doing this for all defcustomed hooks would probably be unrealistic, because there are too many of them.) After that more than twenty complete different and much more complex problems with changing stuff outside Custom remain, if we just look at problems present at startup. But problems occurring _after_ startup are much more dangerous, as I pointed out and they are also apparently even way more numerous. I would say, let us tackle this seriously after 21.4 is released and let us leave Custom alone until 21.4 is released. Sincerely, Luc.