annotate lisp/loadhist.el @ 58195:c12b583f54b9

Fixed these problems: ** Clicking on partially visible lines fails From: David Kastrup <dak@gnu.org> Date: 27 Apr 2004 16:42:58 +0200 I had gnus display a mouse-highlighted line (a URL from browse-url) partially at the bottom of its window. If I click with middle mouse key on it, the window gets recentered while I hold the mouse key pressed. If I release it, the window returns into its old position (cursor in top row) and nothing happens, presumably because the click was not registered on the line itself, but on the magically recentered version. That is a nuisance. Recentering of even partially visible click targets should only happen if window-point moves there, but not at the time of the click. From the moment I hold down a key until it gets released, the displayed window portion should not change, with the sole exception of scrolling when dragging at the edge of the screen. (progn (setq line-spacing 4) (dotimes (i (window-height)) (insert "\n" (int-to-string i))) (forward-line -2) (recenter -1)) ** Can't drag modeline when mouse-autoselect-window is set From: Klaus Zeitler <kzeitler@lucent.com> Date: Mon, 11 Oct 2004 11:14:49 +0200 1. start emacs -q --no-site-file 2. set variable mouse-autoselect-window to t 3. split-window-vertically now I can drag the modeline only upwards but not downwards
author Kim F. Storm <storm@cua.dk>
date Sat, 13 Nov 2004 01:40:36 +0000
parents 8d106818ca97
children 55722dde9e0a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; loadhist.el --- lisp functions for working with feature groups
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12751
diff changeset
2
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
3 ;; Copyright (C) 1995, 1998, 2000 Free Software Foundation, Inc.
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
6 ;; Maintainer: FSF
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: internal
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
11289
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
9 ;; This file is part of GNU Emacs.
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
10
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
14 ;; any later version.
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
15
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
19 ;; GNU General Public License for more details.
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
20
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12751
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12751
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12751
diff changeset
24 ;; Boston, MA 02111-1307, USA.
11289
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
25
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; These functions exploit the load-history system variable.
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
29 ;; Entry points include `unload-feature', `symbol-file', and
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
30 ;; `feature-file', documented in the Emacs Lisp manual.
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;; Code:
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 (defun feature-symbols (feature)
47017
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
35 "Return the file and list of definitions associated with FEATURE.
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
36 The value is actually the element of `load-history'
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
37 for the file that did (provide FEATURE)."
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 (catch 'foundit
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
39 (mapc (lambda (x)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
40 (if (member (cons 'provide feature) (cdr x))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
41 (throw 'foundit x)))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
42 load-history)
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (defun feature-file (feature)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 "Return the file name from which a given FEATURE was loaded.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 Actually, return the load argument, if any; this is sometimes the name of a
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
48 Lisp file without an extension. If the feature came from an `eval-buffer' on
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
49 a buffer with no associated file, or an `eval-region', return nil."
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (if (not (featurep feature))
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
51 (error "%S is not a currently loaded feature" feature)
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 (car (feature-symbols feature))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (defun file-provides (file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 "Return the list of features provided by FILE."
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
56 (let ((symbols (cdr (assoc file load-history)))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
57 provides)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
58 (mapc (lambda (x)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
59 (if (and (consp x) (eq (car x) 'provide))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
60 (setq provides (cons (cdr x) provides))))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
61 symbols)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
62 provides))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (defun file-requires (file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 "Return the list of features required by FILE."
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
66 (let ((symbols (cdr (assoc file load-history)))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
67 requires)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
68 (mapc (lambda (x)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
69 (if (and (consp x) (eq (car x) 'require))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
70 (setq requires (cons (cdr x) requires))))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
71 symbols)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
72 requires))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
74 (defsubst file-set-intersect (p q)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
75 "Return the set intersection of two lists."
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (let ((ret nil))
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
77 (dolist (x p ret)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
78 (if (memq x q) (setq ret (cons x ret))))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
79 ret))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (defun file-dependents (file)
10498
8fb25f247533 (unload-feature): Don't care if FILE is a dependency of itself.
Richard M. Stallman <rms@gnu.org>
parents: 8108
diff changeset
82 "Return the list of loaded libraries that depend on FILE.
8fb25f247533 (unload-feature): Don't care if FILE is a dependency of itself.
Richard M. Stallman <rms@gnu.org>
parents: 8108
diff changeset
83 This can include FILE itself."
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
84 (let ((provides (file-provides file))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
85 (dependents nil))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
86 (dolist (x load-history dependents)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
87 (if (file-set-intersect provides (file-requires (car x)))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
88 (setq dependents (cons (car x) dependents))))
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
89 dependents))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90
16173
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
91 (defun read-feature (prompt)
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
92 "Read a feature name \(string\) from the minibuffer.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
93 Prompt with PROMPT and completing from `features', and
16173
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
94 return the feature \(symbol\)."
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
95 (intern (completing-read prompt
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
96 (mapcar (lambda (feature)
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
97 (list (symbol-name feature)))
16173
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
98 features)
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
99 nil t)))
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
100
52755
6c7cae7ce71a (unload-feature-special-hooks):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
101 (defvaralias 'loadhist-hook-functions 'unload-feature-special-hooks)
6c7cae7ce71a (unload-feature-special-hooks):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
102 (defvar unload-feature-special-hooks
29346
7ac9c66520d4 (loadhist-hook-functions): Remove before-change-function,
Dave Love <fx@gnu.org>
parents: 29241
diff changeset
103 '(after-change-functions
47017
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
104 after-insert-file-functions auto-fill-function
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
105 before-change-functions blink-paren-function
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
106 buffer-access-fontify-functions command-line-functions
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
107 comment-indent-function kill-buffer-query-functions
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
108 kill-emacs-query-functions lisp-indent-function
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
109 mouse-position-function
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
110 redisplay-end-trigger-functions temp-buffer-show-function
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
111 window-scroll-functions window-size-change-functions
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
112 write-region-annotate-functions)
33094
51c874361c84 (unload-feature): Call elp-restore-function,
Dave Love <fx@gnu.org>
parents: 31674
diff changeset
113 "A list of special hooks from Info node `(elisp)Standard Hooks'.
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
114
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
115 These are symbols with hook-type values whose names don't end in
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
116 `-hook' or `-hooks', from which `unload-feature' tries to remove
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
117 pertinent symbols.")
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
118
54000
8d106818ca97 (unload-hook-features-list): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53998
diff changeset
119 (defvar unload-hook-features-list nil
8d106818ca97 (unload-hook-features-list): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53998
diff changeset
120 "List of features of the package being unloaded.
8d106818ca97 (unload-hook-features-list): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53998
diff changeset
121
8d106818ca97 (unload-hook-features-list): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53998
diff changeset
122 This is meant to be used by FEATURE-unload-hook hooks, see the
8d106818ca97 (unload-hook-features-list): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53998
diff changeset
123 documentation of `unload-feature' for details.")
8d106818ca97 (unload-hook-features-list): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53998
diff changeset
124
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;;;###autoload
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (defun unload-feature (feature &optional force)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 "Unload the library that provided FEATURE, restoring all its autoloads.
29241
a243b2d9c015 (unload-feature): Fix interactive spec [from
Dave Love <fx@gnu.org>
parents: 29090
diff changeset
128 If the feature is required by any other loaded code, and prefix arg FORCE
53998
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
129 is nil, raise an error.
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
130
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
131 This function tries to undo modifications made by the package to
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
132 hooks. Packages may define a hook FEATURE-unload-hook that is called
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
133 instead of the normal heuristics for doing this. Such a hook should
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
134 undo all the relevant global state changes that may have been made by
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
135 loading the package or executing functions in it. It has access to
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
136 the package's feature list (before anything is unbound) in the
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
137 variable `unload-hook-features-list' and could remove features from it
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
138 in the event that the package has done something normally-ill-advised,
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
139 such as redefining an Emacs function."
29241
a243b2d9c015 (unload-feature): Fix interactive spec [from
Dave Love <fx@gnu.org>
parents: 29090
diff changeset
140 (interactive (list (read-feature "Feature: ") current-prefix-arg))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (if (not (featurep feature))
12751
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
142 (error "%s is not a currently loaded feature" (symbol-name feature)))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (if (not force)
10498
8fb25f247533 (unload-feature): Don't care if FILE is a dependency of itself.
Richard M. Stallman <rms@gnu.org>
parents: 8108
diff changeset
144 (let* ((file (feature-file feature))
8fb25f247533 (unload-feature): Don't care if FILE is a dependency of itself.
Richard M. Stallman <rms@gnu.org>
parents: 8108
diff changeset
145 (dependents (delete file (copy-sequence (file-dependents file)))))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (if dependents
12751
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
147 (error "Loaded libraries %s depend on %s"
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
148 (prin1-to-string dependents) file))))
53998
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
149 (let* ((unload-hook-features-list (feature-symbols feature))
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
150 (file (car unload-hook-features-list))
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
151 (unload-hook (intern-soft (concat (symbol-name feature)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
152 "-unload-hook"))))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
153 ;; Try to avoid losing badly when hooks installed in critical
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
154 ;; places go away. (Some packages install things on
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
155 ;; `kill-buffer-hook', `activate-menubar-hook' and the like.)
53599
aa04e56e2a40 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 52755
diff changeset
156 ;; First off, provide a clean way for package FOO to arrange
aa04e56e2a40 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 52755
diff changeset
157 ;; this by adding hooks on the variable `FOO-unload-hook'.
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
158 (if unload-hook
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
159 (run-hooks unload-hook)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
160 ;; Otherwise, do our best. Look through the obarray for symbols
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
161 ;; which seem to be hook variables or special hook functions and
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
162 ;; remove anything from them which matches the feature-symbols
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
163 ;; about to get zapped. Obviously this won't get anonymous
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
164 ;; functions which the package might just have installed, and
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
165 ;; there might be other important state, but this tactic
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
166 ;; normally works.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
167 (mapatoms
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
168 (lambda (x)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
169 (if (or (and (boundp x) ; Random hooks.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
170 (consp (symbol-value x))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
171 (string-match "-hooks?\\'" (symbol-name x)))
30885
14607109ea46 (unload-feature): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29346
diff changeset
172 (and (boundp x) ; Known abnormal hooks etc.
52755
6c7cae7ce71a (unload-feature-special-hooks):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
173 (memq x unload-feature-special-hooks)))
53998
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
174 (dolist (y (cdr unload-hook-features-list))
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
175 (remove-hook x y))))))
33094
51c874361c84 (unload-feature): Call elp-restore-function,
Dave Love <fx@gnu.org>
parents: 31674
diff changeset
176 (if (fboundp 'elp-restore-function) ; remove ELP stuff first
53998
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
177 (dolist (elt (cdr unload-hook-features-list))
33094
51c874361c84 (unload-feature): Call elp-restore-function,
Dave Love <fx@gnu.org>
parents: 31674
diff changeset
178 (if (symbolp elt)
51c874361c84 (unload-feature): Call elp-restore-function,
Dave Love <fx@gnu.org>
parents: 31674
diff changeset
179 (elp-restore-function elt))))
29090
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
180 (mapc
86d462e378ce (feature-symbols, file-provides, file-requires): Use mapc.
Dave Love <fx@gnu.org>
parents: 23852
diff changeset
181 (lambda (x)
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
182 (cond ((stringp x) nil)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
183 ((consp x)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
184 ;; Remove any feature names that this file provided.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
185 (if (eq (car x) 'provide)
47017
0ba62d75345e (unload-feature): Distinguish functions from variables in load-history.
Richard M. Stallman <rms@gnu.org>
parents: 33094
diff changeset
186 (setq features (delq (cdr x) features)))
47676
fadbf61035e1 (unload-feature): When undefining a variable, delete its buffer-local bindings.
Richard M. Stallman <rms@gnu.org>
parents: 47017
diff changeset
187 (when (eq (car x) 'defvar)
fadbf61035e1 (unload-feature): When undefining a variable, delete its buffer-local bindings.
Richard M. Stallman <rms@gnu.org>
parents: 47017
diff changeset
188 ;; Kill local values as much as possible.
fadbf61035e1 (unload-feature): When undefining a variable, delete its buffer-local bindings.
Richard M. Stallman <rms@gnu.org>
parents: 47017
diff changeset
189 (dolist (buf (buffer-list))
fadbf61035e1 (unload-feature): When undefining a variable, delete its buffer-local bindings.
Richard M. Stallman <rms@gnu.org>
parents: 47017
diff changeset
190 (with-current-buffer buf
fadbf61035e1 (unload-feature): When undefining a variable, delete its buffer-local bindings.
Richard M. Stallman <rms@gnu.org>
parents: 47017
diff changeset
191 (kill-local-variable (cdr x))))
fadbf61035e1 (unload-feature): When undefining a variable, delete its buffer-local bindings.
Richard M. Stallman <rms@gnu.org>
parents: 47017
diff changeset
192 ;; Get rid of the default binding if we can.
fadbf61035e1 (unload-feature): When undefining a variable, delete its buffer-local bindings.
Richard M. Stallman <rms@gnu.org>
parents: 47017
diff changeset
193 (unless (local-variable-if-set-p (cdr x))
fadbf61035e1 (unload-feature): When undefining a variable, delete its buffer-local bindings.
Richard M. Stallman <rms@gnu.org>
parents: 47017
diff changeset
194 (makunbound (cdr x)))))
29346
7ac9c66520d4 (loadhist-hook-functions): Remove before-change-function,
Dave Love <fx@gnu.org>
parents: 29241
diff changeset
195 (t
7ac9c66520d4 (loadhist-hook-functions): Remove before-change-function,
Dave Love <fx@gnu.org>
parents: 29241
diff changeset
196 (when (fboundp x)
31674
7661306a5b4e (unload-feature): Maybe call elp-restore-list and
Dave Love <fx@gnu.org>
parents: 30885
diff changeset
197 (if (fboundp 'ad-unadvise)
7661306a5b4e (unload-feature): Maybe call elp-restore-list and
Dave Love <fx@gnu.org>
parents: 30885
diff changeset
198 (ad-unadvise x))
29346
7ac9c66520d4 (loadhist-hook-functions): Remove before-change-function,
Dave Love <fx@gnu.org>
parents: 29241
diff changeset
199 (fmakunbound x)
7ac9c66520d4 (loadhist-hook-functions): Remove before-change-function,
Dave Love <fx@gnu.org>
parents: 29241
diff changeset
200 (let ((aload (get x 'autoload)))
7ac9c66520d4 (loadhist-hook-functions): Remove before-change-function,
Dave Love <fx@gnu.org>
parents: 29241
diff changeset
201 (if aload (fset x (cons 'autoload aload))))))))
53998
2e361a295c26 (unload-feature): Doc fix. Rename flist to unload-hook-features-list.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53599
diff changeset
202 (cdr unload-hook-features-list))
12751
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
203 ;; Delete the load-history element for this file.
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
204 (let ((elt (assoc file load-history)))
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
205 (setq load-history (delq elt load-history)))))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (provide 'loadhist)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 47676
diff changeset
209 ;;; arch-tag: 70bb846a-c413-4f01-bf88-78dba4ac0798
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 ;;; loadhist.el ends here