From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: unload-feature questions and thoughts Date: Thu, 25 Oct 2007 23:24:07 +0200 Message-ID: <858x5q51mw.fsf@lola.goethe.zz> References: <86r6t5qdbo.fsf@lola.quinscape.zz> <861wl5q7al.fsf@lola.quinscape.zz> <54853.128.165.123.18.1192027947.squirrel@webmail.lanl.gov> <55463.128.165.123.18.1192035787.squirrel@webmail.lanl.gov> <55585.128.165.123.18.1192038971.squirrel@webmail.lanl.gov> <858x6atas5.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1193348175 8976 80.91.229.12 (25 Oct 2007 21:36:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 25 Oct 2007 21:36:15 +0000 (UTC) Cc: lekktu@gmail.com, emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 25 23:36:17 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IlANE-0004WU-2X for ged-emacs-devel@m.gmane.org; Thu, 25 Oct 2007 23:36:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IlAN5-0007ZA-OK for ged-emacs-devel@m.gmane.org; Thu, 25 Oct 2007 17:36:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IlAME-0007Jp-ED for emacs-devel@gnu.org; Thu, 25 Oct 2007 17:35:14 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IlAMD-0007Jd-Ot for emacs-devel@gnu.org; Thu, 25 Oct 2007 17:35:14 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IlAMD-0007Ja-Gq for emacs-devel@gnu.org; Thu, 25 Oct 2007 17:35:13 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IlAMD-0005a5-53 for emacs-devel@gnu.org; Thu, 25 Oct 2007 17:35:13 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IlAM6-0000ZK-P0; Thu, 25 Oct 2007 17:35:07 -0400 Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id 3349D1C3ACD0; Thu, 25 Oct 2007 23:24:07 +0200 (CEST) In-Reply-To: (Richard Stallman's message of "Thu\, 11 Oct 2007 22\:46\:32 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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 Xref: news.gmane.org gmane.emacs.devel:81716 Archived-At: Richard Stallman writes: > Have you checked AUCTeX's loadup/startup sequence? It uses the > unload hooks in order to offer a way of selectively disabling > autoloaded parts. > > Could you tell us how AUCTeX's hooks would be affected by the > various proposed changes? Actually, I don't really have time in the next few days to do the proper research. One somewhat surprising thing I remembered is that it was necessary to call an autoloaded (dummy in this case) function instead of straightforwardly using require. The latter did not register the necessary information for unloading the feature again (unloading the feature needs to restore autoloads for the default TeX modes). To wit, we have ;;; auctex.el ;; ;; This can be used for starting up AUCTeX. The following somewhat ;; strange trick causes tex-site.el to be loaded in a way that can be ;; safely undone using (unload-feature 'tex-site). ;; (autoload 'TeX-load-hack @lisptexsite@) (TeX-load-hack) Where @lisptexsite@ resolves to the full path of the actual startup file tex-site.el. This file contains the following relevant stuff: (defalias 'TeX-load-hack 'ignore) (add-hook 'tex-site-unload-hook (lambda () (let ((list after-load-alist)) (while list ;; Adapted copy of the definition of `assq-delete-all' ;; from Emacs 21 as substitute for ;; `(assq-delete-all'TeX-modes-set (car list))' which ;; fails on non-list elements in Emacs 21. (let* ((alist (car list)) (tail alist) (key 'TeX-modes-set)) (while tail (if (and (consp (car tail)) (eq (car (car tail)) key)) (setq alist (delq (car tail) alist))) (setq tail (cdr tail)))) (setq list (cdr list)))) (setq load-path (delq TeX-lisp-directory load-path)))) (defun TeX-modes-set (var value &optional update) "Set VAR (which should be `TeX-modes') to VALUE. This places either the standard or the AUCTeX versions of functions into the respective function cell of the mode. If UPDATE is set, a previously saved value for the non-AUCTeX function gets overwritten with the current definition." (custom-set-default var value) (let ((list TeX-mode-alist) elt) (while list (setq elt (car (pop list))) (when (or update (null (get elt 'tex-saved))) (when (fboundp elt) (put elt 'tex-saved (symbol-function elt)))) (defalias elt (if (memq elt value) (intern (concat "TeX-" (symbol-name elt))) (get elt 'tex-saved)))))) (defcustom TeX-modes (mapcar 'car TeX-mode-alist) "List of modes provided by AUCTeX. This variable can't be set normally; use customize for that, or set it with `TeX-modes-set'." :type (cons 'set (mapcar (lambda(x) (list 'const (car x))) TeX-mode-alist)) :set 'TeX-modes-set :group 'AUCTeX :initialize (lambda (var value) (custom-initialize-reset var value) (let ((list TeX-mode-alist)) (while list (eval-after-load (cdar list) `(TeX-modes-set ',var ,var t)) (setq list (cdr list)))))) This is all rather messy and I don't remember all too well what all of this does for which exact reason, but the key point is that the variable TeX-modes can be set to overwrite a selected subset of mode definition autoloads with autoloads for the respective AUCTeX version of the mode, and (unload-feature 'tex-site) will pretty much undo (load-file "auctex.el") as long as none of the autoloads overwritten in tex-site.el have yet been triggered. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum