all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: rms@gnu.org
Cc: lekktu@gmail.com, emacs-devel@gnu.org
Subject: Re: unload-feature questions and thoughts
Date: Thu, 25 Oct 2007 23:24:07 +0200	[thread overview]
Message-ID: <858x5q51mw.fsf@lola.goethe.zz> (raw)
In-Reply-To: <E1IgAXo-0004e0-Tl@fencepost.gnu.org> (Richard Stallman's message of "Thu\, 11 Oct 2007 22\:46\:32 -0400")

Richard Stallman <rms@gnu.org> 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

  reply	other threads:[~2007-10-25 21:24 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-04 18:03 unload-feature questions and thoughts Juanma Barranquero
2007-02-04 18:32 ` David Kastrup
2007-02-04 19:07   ` Juanma Barranquero
2007-02-04 19:14     ` David Kastrup
2007-02-05  0:10       ` Juanma Barranquero
2007-02-05  7:21         ` David Kastrup
2007-02-05  9:21           ` Juanma Barranquero
2007-02-05  9:32             ` David Kastrup
2007-02-05 11:08               ` Juanma Barranquero
2007-02-05 11:16                 ` David Kastrup
2007-02-05 11:40                   ` Juanma Barranquero
2007-02-06  0:16                 ` Richard Stallman
2007-10-10 11:04                 ` Juanma Barranquero
2007-10-10 14:52                   ` Davis Herring
2007-10-10 16:08                     ` Juanma Barranquero
2007-10-10 17:03                       ` Davis Herring
2007-10-10 17:07                         ` Juanma Barranquero
2007-10-10 17:56                           ` Davis Herring
2007-10-11  5:20                             ` Richard Stallman
2007-10-11  6:39                             ` David Kastrup
2007-10-11 15:16                               ` Juanma Barranquero
2007-10-12 15:59                                 ` Richard Stallman
2007-10-12 17:01                                   ` Juanma Barranquero
2007-10-13  6:41                                     ` Richard Stallman
2007-10-13 10:03                                       ` Juanma Barranquero
2007-10-14 16:28                                         ` Richard Stallman
2007-10-14 22:34                                           ` Juanma Barranquero
2007-10-15 16:03                                             ` Richard Stallman
2007-10-15 16:22                                               ` Juanma Barranquero
2007-10-16  4:10                                                 ` Richard Stallman
2007-10-16  8:15                                                   ` Juanma Barranquero
2007-10-17  5:02                                                     ` Richard Stallman
2007-10-17 23:39                                                       ` Juanma Barranquero
2007-10-23 19:27                                           ` Davis Herring
2007-10-24  8:32                                             ` Richard Stallman
2007-10-11 16:41                               ` Davis Herring
2007-10-12  2:46                               ` Richard Stallman
2007-10-25 21:24                                 ` David Kastrup [this message]
2007-10-28 13:51                                   ` Richard Stallman
2007-10-10 21:03                   ` Richard Stallman
2007-10-10 21:42                     ` Juanma Barranquero
2007-02-05 19:10 ` Richard Stallman
2007-02-05 23:27   ` Juanma Barranquero
2007-02-06 17:09     ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=858x5q51mw.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.