Mercurial > emacs
annotate lisp/subr.el @ 27125:4b3c83c489cf
(elide-head): Add :version.
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 04 Jan 2000 00:09:35 +0000 |
parents | 804cba424b64 |
children | f5713c397636 |
rev | line source |
---|---|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
648
diff
changeset
|
1 ;;; subr.el --- basic lisp subroutines for Emacs |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
2 |
26084
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
3 ;; Copyright (C) 1985, 86, 92, 94, 95, 1999 Free Software Foundation, Inc. |
114 | 4 |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
707 | 9 ;; the Free Software Foundation; either version 2, or (at your option) |
114 | 10 ;; any later version. |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
14169 | 18 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 ;; Boston, MA 02111-1307, USA. | |
114 | 21 |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
22 ;;; Code: |
18880
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
23 (defvar custom-declare-variable-list nil |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
24 "Record `defcustom' calls made before `custom.el' is loaded to handle them. |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
25 Each element of this list holds the arguments to one call to `defcustom'.") |
114 | 26 |
19662 | 27 ;; Use this, rather than defcustom, in subr.el and other files loaded |
18880
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
28 ;; before custom.el. |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
29 (defun custom-declare-variable-early (&rest arguments) |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
30 (setq custom-declare-variable-list |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
31 (cons arguments custom-declare-variable-list))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
32 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
33 ;;;; Lisp language features. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
34 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
35 (defmacro lambda (&rest cdr) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
36 "Return a lambda expression. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
37 A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
38 self-quoting; the result of evaluating the lambda expression is the |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
39 expression itself. The lambda expression may then be treated as a |
10178 | 40 function, i.e., stored as the function value of a symbol, passed to |
41 funcall or mapcar, etc. | |
42 | |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
43 ARGS should take the same form as an argument list for a `defun'. |
12395 | 44 DOCSTRING is an optional documentation string. |
45 If present, it should describe how to call the function. | |
46 But documentation strings are usually not useful in nameless functions. | |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
47 INTERACTIVE should be a call to the function `interactive', which see. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
48 It may also be omitted. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
49 BODY should be a list of lisp expressions." |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
50 ;; Note that this definition should not use backquotes; subr.el should not |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
51 ;; depend on backquote.el. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
52 (list 'function (cons 'lambda cdr))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
53 |
25437 | 54 (defmacro push (newelt listname) |
25580 | 55 "Add NEWELT to the list stored in the symbol LISTNAME. |
25437 | 56 This is equivalent to (setq LISTNAME (cons NEWELT LISTNAME)). |
25436
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
57 LISTNAME must be a symbol." |
25469 | 58 (list 'setq listname |
59 (list 'cons newelt listname))) | |
25436
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
60 |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
61 (defmacro pop (listname) |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
62 "Return the first element of LISTNAME's value, and remove it from the list. |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
63 LISTNAME must be a symbol whose value is a list. |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
64 If the value is nil, `pop' returns nil but does not actually |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
65 change the list." |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
66 (list 'prog1 (list 'car listname) |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
67 (list 'setq listname (list 'cdr listname)))) |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
68 |
16845
adc714dc8e3c
(when, unless): Definitions moved from cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
16556
diff
changeset
|
69 (defmacro when (cond &rest body) |
adc714dc8e3c
(when, unless): Definitions moved from cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
16556
diff
changeset
|
70 "(when COND BODY...): if COND yields non-nil, do BODY, else return nil." |
adc714dc8e3c
(when, unless): Definitions moved from cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
16556
diff
changeset
|
71 (list 'if cond (cons 'progn body))) |
17158
f181580c182c
(when, unless): Symbol props moved from cl.el.
Karl Heuer <kwzh@gnu.org>
parents:
17152
diff
changeset
|
72 (put 'when 'lisp-indent-function 1) |
f181580c182c
(when, unless): Symbol props moved from cl.el.
Karl Heuer <kwzh@gnu.org>
parents:
17152
diff
changeset
|
73 (put 'when 'edebug-form-spec '(&rest form)) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
74 |
16845
adc714dc8e3c
(when, unless): Definitions moved from cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
16556
diff
changeset
|
75 (defmacro unless (cond &rest body) |
adc714dc8e3c
(when, unless): Definitions moved from cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
16556
diff
changeset
|
76 "(unless COND BODY...): if COND yields nil, do BODY, else return nil." |
adc714dc8e3c
(when, unless): Definitions moved from cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
16556
diff
changeset
|
77 (cons 'if (cons cond (cons nil body)))) |
17158
f181580c182c
(when, unless): Symbol props moved from cl.el.
Karl Heuer <kwzh@gnu.org>
parents:
17152
diff
changeset
|
78 (put 'unless 'lisp-indent-function 1) |
f181580c182c
(when, unless): Symbol props moved from cl.el.
Karl Heuer <kwzh@gnu.org>
parents:
17152
diff
changeset
|
79 (put 'unless 'edebug-form-spec '(&rest form)) |
19491
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
80 |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
81 (defsubst caar (x) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
82 "Return the car of the car of X." |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
83 (car (car x))) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
84 |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
85 (defsubst cadr (x) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
86 "Return the car of the cdr of X." |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
87 (car (cdr x))) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
88 |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
89 (defsubst cdar (x) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
90 "Return the cdr of the car of X." |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
91 (cdr (car x))) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
92 |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
93 (defsubst cddr (x) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
94 "Return the cdr of the cdr of X." |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
95 (cdr (cdr x))) |
19492 | 96 |
19584
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
97 (defun last (x &optional n) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
98 "Return the last link of the list X. Its car is the last element. |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
99 If X is nil, return nil. |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
100 If N is non-nil, return the Nth-to-last link of X. |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
101 If N is bigger than the length of X, return X." |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
102 (if n |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
103 (let ((m 0) (p x)) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
104 (while (consp p) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
105 (setq m (1+ m) p (cdr p))) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
106 (if (<= n 0) p |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
107 (if (< n m) (nthcdr (- m n) x) x))) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
108 (while (cdr x) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
109 (setq x (cdr x))) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
110 x)) |
22860
349fa4ee1f27
(assoc-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22755
diff
changeset
|
111 |
22959
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
112 (defun assoc-default (key alist &optional test default) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
113 "Find object KEY in a pseudo-alist ALIST. |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
114 ALIST is a list of conses or objects. Each element (or the element's car, |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
115 if it is a cons) is compared with KEY by evaluating (TEST (car elt) KEY). |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
116 If that is non-nil, the element matches; |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
117 then `assoc-default' returns the element's cdr, if it is a cons, |
22860
349fa4ee1f27
(assoc-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22755
diff
changeset
|
118 or DEFAULT if the element is not a cons. |
22959
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
119 |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
120 If no element matches, the value is nil. |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
121 If TEST is omitted or nil, `equal' is used." |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
122 (let (found (tail alist) value) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
123 (while (and tail (not found)) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
124 (let ((elt (car tail))) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
125 (when (funcall (or test 'equal) (if (consp elt) (car elt) elt) key) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
126 (setq found t value (if (consp elt) (cdr elt) default)))) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
127 (setq tail (cdr tail))) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
128 value)) |
25295
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
129 |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
130 (defun assoc-ignore-case (key alist) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
131 "Like `assoc', but ignores differences in case and text representation. |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
132 KEY must be a string. Upper-case and lower-case letters are treated as equal. |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
133 Unibyte strings are converted to multibyte for comparison." |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
134 (let (element) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
135 (while (and alist (not element)) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
136 (if (eq t (compare-strings key 0 nil (car (car alist)) 0 nil t)) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
137 (setq element (car alist))) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
138 (setq alist (cdr alist))) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
139 element)) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
140 |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
141 (defun assoc-ignore-representation (key alist) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
142 "Like `assoc', but ignores differences in text representation. |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
143 KEY must be a string. |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
144 Unibyte strings are converted to multibyte for comparison." |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
145 (let (element) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
146 (while (and alist (not element)) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
147 (if (eq t (compare-strings key 0 nil (car (car alist)) 0 nil)) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
148 (setq element (car alist))) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
149 (setq alist (cdr alist))) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
150 element)) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
151 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
152 ;;;; Keymap support. |
114 | 153 |
154 (defun undefined () | |
155 (interactive) | |
156 (ding)) | |
157 | |
158 ;Prevent the \{...} documentation construct | |
159 ;from mentioning keys that run this command. | |
160 (put 'undefined 'suppress-keymap t) | |
161 | |
162 (defun suppress-keymap (map &optional nodigits) | |
163 "Make MAP override all normally self-inserting keys to be undefined. | |
164 Normally, as an exception, digits and minus-sign are set to make prefix args, | |
165 but optional second arg NODIGITS non-nil treats them like other chars." | |
4767
12ff77449baa
(suppress-keymap): Use substitute-key-definition instead of manually
Brian Fox <bfox@gnu.org>
parents:
4620
diff
changeset
|
166 (substitute-key-definition 'self-insert-command 'undefined map global-map) |
114 | 167 (or nodigits |
168 (let (loop) | |
169 (define-key map "-" 'negative-argument) | |
170 ;; Make plain numbers do numeric args. | |
171 (setq loop ?0) | |
172 (while (<= loop ?9) | |
173 (define-key map (char-to-string loop) 'digit-argument) | |
174 (setq loop (1+ loop)))))) | |
175 | |
176 ;Moved to keymap.c | |
177 ;(defun copy-keymap (keymap) | |
178 ; "Return a copy of KEYMAP" | |
179 ; (while (not (keymapp keymap)) | |
180 ; (setq keymap (signal 'wrong-type-argument (list 'keymapp keymap)))) | |
181 ; (if (vectorp keymap) | |
182 ; (copy-sequence keymap) | |
183 ; (copy-alist keymap))) | |
184 | |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
185 (defvar key-substitution-in-progress nil |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
186 "Used internally by substitute-key-definition.") |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
187 |
1176 | 188 (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix) |
114 | 189 "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF. |
190 In other words, OLDDEF is replaced with NEWDEF where ever it appears. | |
1176 | 191 If optional fourth argument OLDMAP is specified, we redefine |
192 in KEYMAP as NEWDEF those chars which are defined as OLDDEF in OLDMAP." | |
193 (or prefix (setq prefix "")) | |
194 (let* ((scan (or oldmap keymap)) | |
195 (vec1 (vector nil)) | |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
196 (prefix1 (vconcat prefix vec1)) |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
197 (key-substitution-in-progress |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
198 (cons scan key-substitution-in-progress))) |
1176 | 199 ;; Scan OLDMAP, finding each char or event-symbol that |
200 ;; has any definition, and act on it with hack-key. | |
201 (while (consp scan) | |
202 (if (consp (car scan)) | |
203 (let ((char (car (car scan))) | |
204 (defn (cdr (car scan)))) | |
205 ;; The inside of this let duplicates exactly | |
206 ;; the inside of the following let that handles array elements. | |
207 (aset vec1 0 char) | |
208 (aset prefix1 (length prefix) char) | |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
209 (let (inner-def skipped) |
1176 | 210 ;; Skip past menu-prompt. |
211 (while (stringp (car-safe defn)) | |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
212 (setq skipped (cons (car defn) skipped)) |
1176 | 213 (setq defn (cdr defn))) |
7615
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
214 ;; Skip past cached key-equivalence data for menu items. |
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
215 (and (consp defn) (consp (car defn)) |
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
216 (setq defn (cdr defn))) |
1176 | 217 (setq inner-def defn) |
7615
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
218 ;; Look past a symbol that names a keymap. |
1176 | 219 (while (and (symbolp inner-def) |
220 (fboundp inner-def)) | |
221 (setq inner-def (symbol-function inner-def))) | |
17215
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
222 (if (or (eq defn olddef) |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
223 ;; Compare with equal if definition is a key sequence. |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
224 ;; That is useful for operating on function-key-map. |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
225 (and (or (stringp defn) (vectorp defn)) |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
226 (equal defn olddef))) |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
227 (define-key keymap prefix1 (nconc (nreverse skipped) newdef)) |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
228 (if (and (keymapp defn) |
9986
df605fcd1e75
(substitute-key-definition): Don't recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
9822
diff
changeset
|
229 ;; Avoid recursively scanning |
df605fcd1e75
(substitute-key-definition): Don't recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
9822
diff
changeset
|
230 ;; where KEYMAP does not have a submap. |
13039
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
231 (let ((elt (lookup-key keymap prefix1))) |
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
232 (or (null elt) |
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
233 (keymapp elt))) |
9986
df605fcd1e75
(substitute-key-definition): Don't recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
9822
diff
changeset
|
234 ;; Avoid recursively rescanning keymap being scanned. |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
235 (not (memq inner-def |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
236 key-substitution-in-progress))) |
7615
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
237 ;; If this one isn't being scanned already, |
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
238 ;; scan it now. |
1176 | 239 (substitute-key-definition olddef newdef keymap |
240 inner-def | |
241 prefix1))))) | |
18044
3e4924d01221
(substitute-key-definition): Check vectorp, not arrayp.
Richard M. Stallman <rms@gnu.org>
parents:
17943
diff
changeset
|
242 (if (vectorp (car scan)) |
1176 | 243 (let* ((array (car scan)) |
244 (len (length array)) | |
245 (i 0)) | |
246 (while (< i len) | |
247 (let ((char i) (defn (aref array i))) | |
248 ;; The inside of this let duplicates exactly | |
249 ;; the inside of the previous let. | |
250 (aset vec1 0 char) | |
251 (aset prefix1 (length prefix) char) | |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
252 (let (inner-def skipped) |
1176 | 253 ;; Skip past menu-prompt. |
254 (while (stringp (car-safe defn)) | |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
255 (setq skipped (cons (car defn) skipped)) |
1176 | 256 (setq defn (cdr defn))) |
7615
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
257 (and (consp defn) (consp (car defn)) |
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
258 (setq defn (cdr defn))) |
1176 | 259 (setq inner-def defn) |
260 (while (and (symbolp inner-def) | |
261 (fboundp inner-def)) | |
262 (setq inner-def (symbol-function inner-def))) | |
17215
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
263 (if (or (eq defn olddef) |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
264 (and (or (stringp defn) (vectorp defn)) |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
265 (equal defn olddef))) |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
266 (define-key keymap prefix1 |
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
267 (nconc (nreverse skipped) newdef)) |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
268 (if (and (keymapp defn) |
13039
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
269 (let ((elt (lookup-key keymap prefix1))) |
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
270 (or (null elt) |
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
271 (keymapp elt))) |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
272 (not (memq inner-def |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
273 key-substitution-in-progress))) |
1176 | 274 (substitute-key-definition olddef newdef keymap |
275 inner-def | |
276 prefix1))))) | |
17922
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
277 (setq i (1+ i)))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
278 (if (char-table-p (car scan)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
279 (map-char-table |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
280 (function (lambda (char defn) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
281 (let () |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
282 ;; The inside of this let duplicates exactly |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
283 ;; the inside of the previous let, |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
284 ;; except that it uses set-char-table-range |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
285 ;; instead of define-key. |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
286 (aset vec1 0 char) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
287 (aset prefix1 (length prefix) char) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
288 (let (inner-def skipped) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
289 ;; Skip past menu-prompt. |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
290 (while (stringp (car-safe defn)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
291 (setq skipped (cons (car defn) skipped)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
292 (setq defn (cdr defn))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
293 (and (consp defn) (consp (car defn)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
294 (setq defn (cdr defn))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
295 (setq inner-def defn) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
296 (while (and (symbolp inner-def) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
297 (fboundp inner-def)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
298 (setq inner-def (symbol-function inner-def))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
299 (if (or (eq defn olddef) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
300 (and (or (stringp defn) (vectorp defn)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
301 (equal defn olddef))) |
17943
15dc805eadee
(substitute-key-definition): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
17922
diff
changeset
|
302 (define-key keymap prefix1 |
15dc805eadee
(substitute-key-definition): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
17922
diff
changeset
|
303 (nconc (nreverse skipped) newdef)) |
17922
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
304 (if (and (keymapp defn) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
305 (let ((elt (lookup-key keymap prefix1))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
306 (or (null elt) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
307 (keymapp elt))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
308 (not (memq inner-def |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
309 key-substitution-in-progress))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
310 (substitute-key-definition olddef newdef keymap |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
311 inner-def |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
312 prefix1))))))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
313 (car scan))))) |
1176 | 314 (setq scan (cdr scan))))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
315 |
3902
717f2e24975e
(define-key-after): Renamed from define-key-in-sequence.
Richard M. Stallman <rms@gnu.org>
parents:
3901
diff
changeset
|
316 (defun define-key-after (keymap key definition after) |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
317 "Add binding in KEYMAP for KEY => DEFINITION, right after AFTER's binding. |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
318 This is like `define-key' except that the binding for KEY is placed |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
319 just after the binding for the event AFTER, instead of at the beginning |
16556
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
320 of the map. Note that AFTER must be an event type (like KEY), NOT a command |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
321 \(like DEFINITION). |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
322 |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
323 If AFTER is t, the new binding goes at the end of the keymap. |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
324 |
6725
e044bd05a1da
(define-key-after): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6553
diff
changeset
|
325 KEY must contain just one event type--that is to say, it must be |
16556
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
326 a string or vector of length 1. |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
327 |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
328 The order of bindings in a keymap matters when it is used as a menu." |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
329 |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
330 (or (keymapp keymap) |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
331 (signal 'wrong-type-argument (list 'keymapp keymap))) |
4188
10fd517cb2e9
(define-key-after): Fix typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
4070
diff
changeset
|
332 (if (> (length key) 1) |
4070
5a97f81baf65
(define-key-after): Error if KEY has two elements.
Richard M. Stallman <rms@gnu.org>
parents:
3991
diff
changeset
|
333 (error "multi-event key specified in `define-key-after'")) |
3927
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
334 (let ((tail keymap) done inserted |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
335 (first (aref key 0))) |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
336 (while (and (not done) tail) |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
337 ;; Delete any earlier bindings for the same key. |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
338 (if (eq (car-safe (car (cdr tail))) first) |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
339 (setcdr tail (cdr (cdr tail)))) |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
340 ;; When we reach AFTER's binding, insert the new binding after. |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
341 ;; If we reach an inherited keymap, insert just before that. |
3927
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
342 ;; If we reach the end of this keymap, insert at the end. |
16556
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
343 (if (or (and (eq (car-safe (car tail)) after) |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
344 (not (eq after t))) |
3927
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
345 (eq (car (cdr tail)) 'keymap) |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
346 (null (cdr tail))) |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
347 (progn |
3927
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
348 ;; Stop the scan only if we find a parent keymap. |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
349 ;; Keep going past the inserted element |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
350 ;; so we can delete any duplications that come later. |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
351 (if (eq (car (cdr tail)) 'keymap) |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
352 (setq done t)) |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
353 ;; Don't insert more than once. |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
354 (or inserted |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
355 (setcdr tail (cons (cons (aref key 0) definition) (cdr tail)))) |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
356 (setq inserted t))) |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
357 (setq tail (cdr tail))))) |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
358 |
17437 | 359 (defmacro kbd (keys) |
360 "Convert KEYS to the internal Emacs key representation. | |
361 KEYS should be a string constant in the format used for | |
362 saving keyboard macros (see `insert-kbd-macro')." | |
363 (read-kbd-macro keys)) | |
364 | |
15894
efd2835a7c96
(keyboard-translate): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
15599
diff
changeset
|
365 (put 'keyboard-translate-table 'char-table-extra-slots 0) |
efd2835a7c96
(keyboard-translate): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
15599
diff
changeset
|
366 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
367 (defun keyboard-translate (from to) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
368 "Translate character FROM to TO at a low level. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
369 This function creates a `keyboard-translate-table' if necessary |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
370 and then modifies one entry in it." |
15894
efd2835a7c96
(keyboard-translate): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
15599
diff
changeset
|
371 (or (char-table-p keyboard-translate-table) |
efd2835a7c96
(keyboard-translate): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
15599
diff
changeset
|
372 (setq keyboard-translate-table |
efd2835a7c96
(keyboard-translate): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
15599
diff
changeset
|
373 (make-char-table 'keyboard-translate-table nil))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
374 (aset keyboard-translate-table from to)) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
375 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
376 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
377 ;;;; The global keymap tree. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
378 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
379 ;;; global-map, esc-map, and ctl-x-map have their values set up in |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
380 ;;; keymap.c; we just give them docstrings here. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
381 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
382 (defvar global-map nil |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
383 "Default global keymap mapping Emacs keyboard input into commands. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
384 The value is a keymap which is usually (but not necessarily) Emacs's |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
385 global map.") |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
386 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
387 (defvar esc-map nil |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
388 "Default keymap for ESC (meta) commands. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
389 The normal global definition of the character ESC indirects to this keymap.") |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
390 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
391 (defvar ctl-x-map nil |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
392 "Default keymap for C-x commands. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
393 The normal global definition of the character C-x indirects to this keymap.") |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
394 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
395 (defvar ctl-x-4-map (make-sparse-keymap) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
396 "Keymap for subcommands of C-x 4") |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
397 (defalias 'ctl-x-4-prefix ctl-x-4-map) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
398 (define-key ctl-x-map "4" 'ctl-x-4-prefix) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
399 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
400 (defvar ctl-x-5-map (make-sparse-keymap) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
401 "Keymap for frame commands.") |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
402 (defalias 'ctl-x-5-prefix ctl-x-5-map) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
403 (define-key ctl-x-map "5" 'ctl-x-5-prefix) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
404 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
405 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
406 ;;;; Event manipulation functions. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
407 |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
408 ;; The call to `read' is to ensure that the value is computed at load time |
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
409 ;; and not compiled into the .elc file. The value is negative on most |
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
410 ;; machines, but not on all! |
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
411 (defconst listify-key-sequence-1 (logior 128 (read "?\\M-\\^@"))) |
3153
4c94c9faf1af
(listify-key-sequence): Avoid the constant ?\M-\200.
Richard M. Stallman <rms@gnu.org>
parents:
2963
diff
changeset
|
412 |
2021
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
413 (defun listify-key-sequence (key) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
414 "Convert a key sequence to a list of events." |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
415 (if (vectorp key) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
416 (append key nil) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
417 (mapcar (function (lambda (c) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
418 (if (> c 127) |
3153
4c94c9faf1af
(listify-key-sequence): Avoid the constant ?\M-\200.
Richard M. Stallman <rms@gnu.org>
parents:
2963
diff
changeset
|
419 (logxor c listify-key-sequence-1) |
2021
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
420 c))) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
421 (append key nil)))) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
422 |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
423 (defsubst eventp (obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
424 "True if the argument is an event object." |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
425 (or (integerp obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
426 (and (symbolp obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
427 (get obj 'event-symbol-elements)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
428 (and (consp obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
429 (symbolp (car obj)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
430 (get (car obj) 'event-symbol-elements)))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
431 |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
432 (defun event-modifiers (event) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
433 "Returns a list of symbols representing the modifier keys in event EVENT. |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
434 The elements of the list may include `meta', `control', |
4414
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
435 `shift', `hyper', `super', `alt', `click', `double', `triple', `drag', |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
436 and `down'." |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
437 (let ((type event)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
438 (if (listp type) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
439 (setq type (car type))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
440 (if (symbolp type) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
441 (cdr (get type 'event-symbol-elements)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
442 (let ((list nil)) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
443 (or (zerop (logand type ?\M-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
444 (setq list (cons 'meta list))) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
445 (or (and (zerop (logand type ?\C-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
446 (>= (logand type 127) 32)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
447 (setq list (cons 'control list))) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
448 (or (and (zerop (logand type ?\S-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
449 (= (logand type 255) (downcase (logand type 255)))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
450 (setq list (cons 'shift list))) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
451 (or (zerop (logand type ?\H-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
452 (setq list (cons 'hyper list))) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
453 (or (zerop (logand type ?\s-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
454 (setq list (cons 'super list))) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
455 (or (zerop (logand type ?\A-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
456 (setq list (cons 'alt list))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
457 list)))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
458 |
2063
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
459 (defun event-basic-type (event) |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
460 "Returns the basic type of the given event (all modifiers removed). |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
461 The value is an ASCII printing character (not upper case) or a symbol." |
3784
d2df5ca46b39
* subr.el (event-basic-type): Deal with listy events properly.
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
462 (if (consp event) |
d2df5ca46b39
* subr.el (event-basic-type): Deal with listy events properly.
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
463 (setq event (car event))) |
2063
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
464 (if (symbolp event) |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
465 (car (get event 'event-symbol-elements)) |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
466 (let ((base (logand event (1- (lsh 1 18))))) |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
467 (downcase (if (< base 32) (logior base 64) base))))) |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
468 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
469 (defsubst mouse-movement-p (object) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
470 "Return non-nil if OBJECT is a mouse movement event." |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
471 (and (consp object) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
472 (eq (car object) 'mouse-movement))) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
473 |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
474 (defsubst event-start (event) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
475 "Return the starting position of EVENT. |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
476 If EVENT is a mouse press or a mouse click, this returns the location |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
477 of the event. |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
478 If EVENT is a drag, this returns the drag's starting position. |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
479 The return value is of the form |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
480 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
481 The `posn-' functions access elements of such lists." |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
482 (nth 1 event)) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
483 |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
484 (defsubst event-end (event) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
485 "Return the ending location of EVENT. EVENT should be a click or drag event. |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
486 If EVENT is a click event, this function is the same as `event-start'. |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
487 The return value is of the form |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
488 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
489 The `posn-' functions access elements of such lists." |
3860
70bdc91ef161
* subr.el (event-end): Modified to account for multi-click events.
Jim Blandy <jimb@redhat.com>
parents:
3784
diff
changeset
|
490 (nth (if (consp (nth 2 event)) 2 1) event)) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
491 |
4414
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
492 (defsubst event-click-count (event) |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
493 "Return the multi-click count of EVENT, a click or drag event. |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
494 The return value is a positive integer." |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
495 (if (integerp (nth 2 event)) (nth 2 event) 1)) |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
496 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
497 (defsubst posn-window (position) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
498 "Return the window in POSITION. |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
499 POSITION should be a list of the form |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
500 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
501 as returned by the `event-start' and `event-end' functions." |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
502 (nth 0 position)) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
503 |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
504 (defsubst posn-point (position) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
505 "Return the buffer location in POSITION. |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
506 POSITION should be a list of the form |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
507 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
508 as returned by the `event-start' and `event-end' functions." |
3991
ad2bd545983e
* subr.el (posn-point): Properly extract the BUFFER-POSITION field
Jim Blandy <jimb@redhat.com>
parents:
3927
diff
changeset
|
509 (if (consp (nth 1 position)) |
ad2bd545983e
* subr.el (posn-point): Properly extract the BUFFER-POSITION field
Jim Blandy <jimb@redhat.com>
parents:
3927
diff
changeset
|
510 (car (nth 1 position)) |
ad2bd545983e
* subr.el (posn-point): Properly extract the BUFFER-POSITION field
Jim Blandy <jimb@redhat.com>
parents:
3927
diff
changeset
|
511 (nth 1 position))) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
512 |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
513 (defsubst posn-x-y (position) |
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
514 "Return the x and y coordinates in POSITION. |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
515 POSITION should be a list of the form |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
516 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
517 as returned by the `event-start' and `event-end' functions." |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
518 (nth 2 position)) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
519 |
7636
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
520 (defun posn-col-row (position) |
7693
5fcf0620b8d3
(posn-col-row): Test for consp, not symbolp.
Karl Heuer <kwzh@gnu.org>
parents:
7640
diff
changeset
|
521 "Return the column and row in POSITION, measured in characters. |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
522 POSITION should be a list of the form |
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
523 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
7636
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
524 as returned by the `event-start' and `event-end' functions. |
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
525 For a scroll-bar event, the result column is 0, and the row |
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
526 corresponds to the vertical position of the click in the scroll bar." |
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
527 (let ((pair (nth 2 position)) |
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
528 (window (posn-window position))) |
7693
5fcf0620b8d3
(posn-col-row): Test for consp, not symbolp.
Karl Heuer <kwzh@gnu.org>
parents:
7640
diff
changeset
|
529 (if (eq (if (consp (nth 1 position)) |
5fcf0620b8d3
(posn-col-row): Test for consp, not symbolp.
Karl Heuer <kwzh@gnu.org>
parents:
7640
diff
changeset
|
530 (car (nth 1 position)) |
5fcf0620b8d3
(posn-col-row): Test for consp, not symbolp.
Karl Heuer <kwzh@gnu.org>
parents:
7640
diff
changeset
|
531 (nth 1 position)) |
7636
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
532 'vertical-scroll-bar) |
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
533 (cons 0 (scroll-bar-scale pair (1- (window-height window)))) |
7693
5fcf0620b8d3
(posn-col-row): Test for consp, not symbolp.
Karl Heuer <kwzh@gnu.org>
parents:
7640
diff
changeset
|
534 (if (eq (if (consp (nth 1 position)) |
5fcf0620b8d3
(posn-col-row): Test for consp, not symbolp.
Karl Heuer <kwzh@gnu.org>
parents:
7640
diff
changeset
|
535 (car (nth 1 position)) |
5fcf0620b8d3
(posn-col-row): Test for consp, not symbolp.
Karl Heuer <kwzh@gnu.org>
parents:
7640
diff
changeset
|
536 (nth 1 position)) |
7636
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
537 'horizontal-scroll-bar) |
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
538 (cons (scroll-bar-scale pair (window-width window)) 0) |
7640
9b1194796ef5
(posn-col-row): Use let*.
Richard M. Stallman <rms@gnu.org>
parents:
7636
diff
changeset
|
539 (let* ((frame (if (framep window) window (window-frame window))) |
9b1194796ef5
(posn-col-row): Use let*.
Richard M. Stallman <rms@gnu.org>
parents:
7636
diff
changeset
|
540 (x (/ (car pair) (frame-char-width frame))) |
9b1194796ef5
(posn-col-row): Use let*.
Richard M. Stallman <rms@gnu.org>
parents:
7636
diff
changeset
|
541 (y (/ (cdr pair) (frame-char-height frame)))) |
7636
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
542 (cons x y)))))) |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
543 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
544 (defsubst posn-timestamp (position) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
545 "Return the timestamp of POSITION. |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
546 POSITION should be a list of the form |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
547 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
3411
d91b3097bb76
(posn-timestamp): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
3210
diff
changeset
|
548 as returned by the `event-start' and `event-end' functions." |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
549 (nth 3 position)) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
550 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
551 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
552 ;;;; Obsolescent names for functions. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
553 |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
554 (defalias 'dot 'point) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
555 (defalias 'dot-marker 'point-marker) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
556 (defalias 'dot-min 'point-min) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
557 (defalias 'dot-max 'point-max) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
558 (defalias 'window-dot 'window-point) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
559 (defalias 'set-window-dot 'set-window-point) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
560 (defalias 'read-input 'read-string) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
561 (defalias 'send-string 'process-send-string) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
562 (defalias 'send-region 'process-send-region) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
563 (defalias 'show-buffer 'set-window-buffer) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
564 (defalias 'buffer-flush-undo 'buffer-disable-undo) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
565 (defalias 'eval-current-buffer 'eval-buffer) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
566 (defalias 'compiled-function-p 'byte-code-function-p) |
16437
0626ef653e3e
(define-function): Define as alias for defalias.
Richard M. Stallman <rms@gnu.org>
parents:
16379
diff
changeset
|
567 (defalias 'define-function 'defalias) |
114 | 568 |
23134
173e15236628
(sref): Make it an alias of aref. Make the
Kenichi Handa <handa@m17n.org>
parents:
23058
diff
changeset
|
569 (defalias 'sref 'aref) |
173e15236628
(sref): Make it an alias of aref. Make the
Kenichi Handa <handa@m17n.org>
parents:
23058
diff
changeset
|
570 (make-obsolete 'sref 'aref) |
173e15236628
(sref): Make it an alias of aref. Make the
Kenichi Handa <handa@m17n.org>
parents:
23058
diff
changeset
|
571 (make-obsolete 'char-bytes "Now this function always returns 1") |
20605 | 572 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
573 ;; Some programs still use this as a function. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
574 (defun baud-rate () |
3210 | 575 "Obsolete function returning the value of the `baud-rate' variable. |
576 Please convert your programs to use the variable `baud-rate' directly." | |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
577 baud-rate) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
578 |
15599
7d3af2dcd864
(unfocus-frame, focus-frame): Define as no-ops.
Miles Bader <miles@gnu.org>
parents:
14707
diff
changeset
|
579 (defalias 'focus-frame 'ignore) |
7d3af2dcd864
(unfocus-frame, focus-frame): Define as no-ops.
Miles Bader <miles@gnu.org>
parents:
14707
diff
changeset
|
580 (defalias 'unfocus-frame 'ignore) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
581 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
582 ;;;; Alternate names for functions - these are not being phased out. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
583 |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
584 (defalias 'string= 'string-equal) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
585 (defalias 'string< 'string-lessp) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
586 (defalias 'move-marker 'set-marker) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
587 (defalias 'not 'null) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
588 (defalias 'rplaca 'setcar) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
589 (defalias 'rplacd 'setcdr) |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3411
diff
changeset
|
590 (defalias 'beep 'ding) ;preserve lingual purity |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
591 (defalias 'indent-to-column 'indent-to) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
592 (defalias 'backward-delete-char 'delete-backward-char) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
593 (defalias 'search-forward-regexp (symbol-function 're-search-forward)) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
594 (defalias 'search-backward-regexp (symbol-function 're-search-backward)) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
595 (defalias 'int-to-string 'number-to-string) |
21173
e917eb0d4e01
(save-match-data): store-match-data => set-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
21092
diff
changeset
|
596 (defalias 'store-match-data 'set-match-data) |
25293
fd43e1a99384
(point-at-eol, point-at-bol): New aliases.
Karl Heuer <kwzh@gnu.org>
parents:
25140
diff
changeset
|
597 (defalias 'point-at-eol 'line-end-position) |
fd43e1a99384
(point-at-eol, point-at-bol): New aliases.
Karl Heuer <kwzh@gnu.org>
parents:
25140
diff
changeset
|
598 (defalias 'point-at-bol 'line-beginning-position) |
1903
87f63305319f
* subr.el (string-to-int): Make this an alias for
Jim Blandy <jimb@redhat.com>
parents:
1867
diff
changeset
|
599 |
87f63305319f
* subr.el (string-to-int): Make this an alias for
Jim Blandy <jimb@redhat.com>
parents:
1867
diff
changeset
|
600 ;;; Should this be an obsolete name? If you decide it should, you get |
87f63305319f
* subr.el (string-to-int): Make this an alias for
Jim Blandy <jimb@redhat.com>
parents:
1867
diff
changeset
|
601 ;;; to go through all the sources and change them. |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
602 (defalias 'string-to-int 'string-to-number) |
114 | 603 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
604 ;;;; Hook manipulation functions. |
388 | 605 |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
606 (defun make-local-hook (hook) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
607 "Make the hook HOOK local to the current buffer. |
23786
673204d56938
(make-local-hook): Return the hook variable.
Richard M. Stallman <rms@gnu.org>
parents:
23736
diff
changeset
|
608 The return value is HOOK. |
673204d56938
(make-local-hook): Return the hook variable.
Richard M. Stallman <rms@gnu.org>
parents:
23736
diff
changeset
|
609 |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
610 When a hook is local, its local and global values |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
611 work in concert: running the hook actually runs all the hook |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
612 functions listed in *either* the local value *or* the global value |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
613 of the hook variable. |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
614 |
12258
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
615 This function works by making `t' a member of the buffer-local value, |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
616 which acts as a flag to run the hook functions in the default value as |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
617 well. This works for all normal hooks, but does not work for most |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
618 non-normal hooks yet. We will be changing the callers of non-normal |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
619 hooks so that they can handle localness; this has to be done one by |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
620 one. |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
621 |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
622 This function does nothing if HOOK is already local in the current |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
623 buffer. |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
624 |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
625 Do not use `make-local-variable' to make a hook variable buffer-local." |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
626 (if (local-variable-p hook) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
627 nil |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
628 (or (boundp hook) (set hook nil)) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
629 (make-local-variable hook) |
23786
673204d56938
(make-local-hook): Return the hook variable.
Richard M. Stallman <rms@gnu.org>
parents:
23736
diff
changeset
|
630 (set hook (list t))) |
673204d56938
(make-local-hook): Return the hook variable.
Richard M. Stallman <rms@gnu.org>
parents:
23736
diff
changeset
|
631 hook) |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
632 |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
633 (defun add-hook (hook function &optional append local) |
4414
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
634 "Add to the value of HOOK the function FUNCTION. |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
635 FUNCTION is not added if already present. |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
636 FUNCTION is added (if necessary) at the beginning of the hook list |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
637 unless the optional argument APPEND is non-nil, in which case |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
638 FUNCTION is added at the end. |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
639 |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
640 The optional fourth argument, LOCAL, if non-nil, says to modify |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
641 the hook's buffer-local value rather than its default value. |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
642 This makes no difference if the hook is not buffer-local. |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
643 To make a hook variable buffer-local, always use |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
644 `make-local-hook', not `make-local-variable'. |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
645 |
4414
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
646 HOOK should be a symbol, and FUNCTION may be any valid function. If |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
647 HOOK is void, it is first set to nil. If HOOK's value is a single |
8959
d33302427a47
(remove-hook, add-hook): Copy existing list before modifying.
Richard M. Stallman <rms@gnu.org>
parents:
8928
diff
changeset
|
648 function, it is changed to a list of functions." |
114 | 649 (or (boundp hook) (set hook nil)) |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
650 (or (default-boundp hook) (set-default hook nil)) |
4414
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
651 ;; If the hook value is a single function, turn it into a list. |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
652 (let ((old (symbol-value hook))) |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
653 (if (or (not (listp old)) (eq (car old) 'lambda)) |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
654 (set hook (list old)))) |
9202
92d6de82426a
(add-hook, remove-hook): If the hook was made local
Richard M. Stallman <rms@gnu.org>
parents:
9195
diff
changeset
|
655 (if (or local |
92d6de82426a
(add-hook, remove-hook): If the hook was made local
Richard M. Stallman <rms@gnu.org>
parents:
9195
diff
changeset
|
656 ;; Detect the case where make-local-variable was used on a hook |
92d6de82426a
(add-hook, remove-hook): If the hook was made local
Richard M. Stallman <rms@gnu.org>
parents:
9195
diff
changeset
|
657 ;; and do what we used to do. |
12296
005a5b596618
(add-hook): Use local local-variable-if-set-p.
Richard M. Stallman <rms@gnu.org>
parents:
12258
diff
changeset
|
658 (and (local-variable-if-set-p hook) |
9202
92d6de82426a
(add-hook, remove-hook): If the hook was made local
Richard M. Stallman <rms@gnu.org>
parents:
9195
diff
changeset
|
659 (not (memq t (symbol-value hook))))) |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
660 ;; Alter the local value only. |
22960
d29091c19e81
(add-hook): Use byte-code-function-p, not compiled-function-p.
Richard M. Stallman <rms@gnu.org>
parents:
22959
diff
changeset
|
661 (or (if (or (consp function) (byte-code-function-p function)) |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
662 (member function (symbol-value hook)) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
663 (memq function (symbol-value hook))) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
664 (set hook |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
665 (if append |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
666 (append (symbol-value hook) (list function)) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
667 (cons function (symbol-value hook))))) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
668 ;; Alter the global value (which is also the only value, |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
669 ;; if the hook doesn't have a local value). |
22960
d29091c19e81
(add-hook): Use byte-code-function-p, not compiled-function-p.
Richard M. Stallman <rms@gnu.org>
parents:
22959
diff
changeset
|
670 (or (if (or (consp function) (byte-code-function-p function)) |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
671 (member function (default-value hook)) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
672 (memq function (default-value hook))) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
673 (set-default hook |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
674 (if append |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
675 (append (default-value hook) (list function)) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
676 (cons function (default-value hook))))))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
677 |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
678 (defun remove-hook (hook function &optional local) |
4964
78c13f3054e5
(remove-hook): New function, analogous to add-hook. This
Richard M. Stallman <rms@gnu.org>
parents:
4767
diff
changeset
|
679 "Remove from the value of HOOK the function FUNCTION. |
78c13f3054e5
(remove-hook): New function, analogous to add-hook. This
Richard M. Stallman <rms@gnu.org>
parents:
4767
diff
changeset
|
680 HOOK should be a symbol, and FUNCTION may be any valid function. If |
78c13f3054e5
(remove-hook): New function, analogous to add-hook. This
Richard M. Stallman <rms@gnu.org>
parents:
4767
diff
changeset
|
681 FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
682 list of hooks to run in HOOK, then nothing is done. See `add-hook'. |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
683 |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
684 The optional third argument, LOCAL, if non-nil, says to modify |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
685 the hook's buffer-local value rather than its default value. |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
686 This makes no difference if the hook is not buffer-local. |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
687 To make a hook variable buffer-local, always use |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
688 `make-local-hook', not `make-local-variable'." |
4964
78c13f3054e5
(remove-hook): New function, analogous to add-hook. This
Richard M. Stallman <rms@gnu.org>
parents:
4767
diff
changeset
|
689 (if (or (not (boundp hook)) ;unbound symbol, or |
21696
2f8ab139c8f1
(remove-hook): Fix spurious quote.
Dave Love <fx@gnu.org>
parents:
21578
diff
changeset
|
690 (not (default-boundp hook)) |
4964
78c13f3054e5
(remove-hook): New function, analogous to add-hook. This
Richard M. Stallman <rms@gnu.org>
parents:
4767
diff
changeset
|
691 (null (symbol-value hook)) ;value is nil, or |
78c13f3054e5
(remove-hook): New function, analogous to add-hook. This
Richard M. Stallman <rms@gnu.org>
parents:
4767
diff
changeset
|
692 (null function)) ;function is nil, then |
78c13f3054e5
(remove-hook): New function, analogous to add-hook. This
Richard M. Stallman <rms@gnu.org>
parents:
4767
diff
changeset
|
693 nil ;Do nothing. |
9202
92d6de82426a
(add-hook, remove-hook): If the hook was made local
Richard M. Stallman <rms@gnu.org>
parents:
9195
diff
changeset
|
694 (if (or local |
92d6de82426a
(add-hook, remove-hook): If the hook was made local
Richard M. Stallman <rms@gnu.org>
parents:
9195
diff
changeset
|
695 ;; Detect the case where make-local-variable was used on a hook |
92d6de82426a
(add-hook, remove-hook): If the hook was made local
Richard M. Stallman <rms@gnu.org>
parents:
9195
diff
changeset
|
696 ;; and do what we used to do. |
92d6de82426a
(add-hook, remove-hook): If the hook was made local
Richard M. Stallman <rms@gnu.org>
parents:
9195
diff
changeset
|
697 (and (local-variable-p hook) |
23294
ce2cac0f1682
(remove-hook): Check list values to avoid errors.
Dave Love <fx@gnu.org>
parents:
23134
diff
changeset
|
698 (consp (symbol-value hook)) |
ce2cac0f1682
(remove-hook): Check list values to avoid errors.
Dave Love <fx@gnu.org>
parents:
23134
diff
changeset
|
699 (not (memq t (symbol-value hook))))) |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
700 (let ((hook-value (symbol-value hook))) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
701 (if (consp hook-value) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
702 (if (member function hook-value) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
703 (setq hook-value (delete function (copy-sequence hook-value)))) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
704 (if (equal hook-value function) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
705 (setq hook-value nil))) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
706 (set hook hook-value)) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
707 (let ((hook-value (default-value hook))) |
23294
ce2cac0f1682
(remove-hook): Check list values to avoid errors.
Dave Love <fx@gnu.org>
parents:
23134
diff
changeset
|
708 (if (and (consp hook-value) (not (functionp hook-value))) |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
709 (if (member function hook-value) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
710 (setq hook-value (delete function (copy-sequence hook-value)))) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
711 (if (equal hook-value function) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
712 (setq hook-value nil))) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
713 (set-default hook hook-value))))) |
9510
f03544494d1c
(add-to-list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9202
diff
changeset
|
714 |
f03544494d1c
(add-to-list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9202
diff
changeset
|
715 (defun add-to-list (list-var element) |
9535 | 716 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. |
13812 | 717 The test for presence of ELEMENT is done with `equal'. |
24757
f4127409d184
(add-to-list): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24699
diff
changeset
|
718 If ELEMENT is added, it is added at the beginning of the list. |
f4127409d184
(add-to-list): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24699
diff
changeset
|
719 |
9535 | 720 If you want to use `add-to-list' on a variable that is not defined |
721 until a certain package is loaded, you should put the call to `add-to-list' | |
722 into a hook function that will be run only after loading the package. | |
723 `eval-after-load' provides one way to do this. In some cases | |
724 other hooks, such as major mode hooks, can do the job." | |
21409
3e8b7782f4f5
(add-to-list): Always return updated value of LIST-VAR.
Karl Heuer <kwzh@gnu.org>
parents:
21173
diff
changeset
|
725 (if (member element (symbol-value list-var)) |
3e8b7782f4f5
(add-to-list): Always return updated value of LIST-VAR.
Karl Heuer <kwzh@gnu.org>
parents:
21173
diff
changeset
|
726 (symbol-value list-var) |
3e8b7782f4f5
(add-to-list): Always return updated value of LIST-VAR.
Karl Heuer <kwzh@gnu.org>
parents:
21173
diff
changeset
|
727 (set list-var (cons element (symbol-value list-var))))) |
114 | 728 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
729 ;;;; Specifying things to do after certain files are loaded. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
730 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
731 (defun eval-after-load (file form) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
732 "Arrange that, if FILE is ever loaded, FORM will be run at that time. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
733 This makes or adds to an entry on `after-load-alist'. |
10794
4443f78a2117
(eval-after-load): Run FORM now if FILE's already loaded.
Richard M. Stallman <rms@gnu.org>
parents:
10693
diff
changeset
|
734 If FILE is already loaded, evaluate FORM right now. |
5440
856ecdc5228a
(eval-after-load): Do nothing if FORM is already on the list.
Richard M. Stallman <rms@gnu.org>
parents:
5421
diff
changeset
|
735 It does nothing if FORM is already on the list for FILE. |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
736 FILE should be the name of a library, with no directory name." |
10794
4443f78a2117
(eval-after-load): Run FORM now if FILE's already loaded.
Richard M. Stallman <rms@gnu.org>
parents:
10693
diff
changeset
|
737 ;; Make sure there is an element for FILE. |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
738 (or (assoc file after-load-alist) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
739 (setq after-load-alist (cons (list file) after-load-alist))) |
10794
4443f78a2117
(eval-after-load): Run FORM now if FILE's already loaded.
Richard M. Stallman <rms@gnu.org>
parents:
10693
diff
changeset
|
740 ;; Add FORM to the element if it isn't there. |
5440
856ecdc5228a
(eval-after-load): Do nothing if FORM is already on the list.
Richard M. Stallman <rms@gnu.org>
parents:
5421
diff
changeset
|
741 (let ((elt (assoc file after-load-alist))) |
856ecdc5228a
(eval-after-load): Do nothing if FORM is already on the list.
Richard M. Stallman <rms@gnu.org>
parents:
5421
diff
changeset
|
742 (or (member form (cdr elt)) |
10794
4443f78a2117
(eval-after-load): Run FORM now if FILE's already loaded.
Richard M. Stallman <rms@gnu.org>
parents:
10693
diff
changeset
|
743 (progn |
4443f78a2117
(eval-after-load): Run FORM now if FILE's already loaded.
Richard M. Stallman <rms@gnu.org>
parents:
10693
diff
changeset
|
744 (nconc elt (list form)) |
4443f78a2117
(eval-after-load): Run FORM now if FILE's already loaded.
Richard M. Stallman <rms@gnu.org>
parents:
10693
diff
changeset
|
745 ;; If the file has been loaded already, run FORM right away. |
4443f78a2117
(eval-after-load): Run FORM now if FILE's already loaded.
Richard M. Stallman <rms@gnu.org>
parents:
10693
diff
changeset
|
746 (and (assoc file load-history) |
4443f78a2117
(eval-after-load): Run FORM now if FILE's already loaded.
Richard M. Stallman <rms@gnu.org>
parents:
10693
diff
changeset
|
747 (eval form))))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
748 form) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
749 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
750 (defun eval-next-after-load (file) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
751 "Read the following input sexp, and run it whenever FILE is loaded. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
752 This makes or adds to an entry on `after-load-alist'. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
753 FILE should be the name of a library, with no directory name." |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
754 (eval-after-load file (read))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
755 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
756 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
757 ;;;; Input and display facilities. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
758 |
18880
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
759 (defvar read-quoted-char-radix 8 |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
760 "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'. |
18880
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
761 Legitimate radix values are 8, 10 and 16.") |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
762 |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
763 (custom-declare-variable-early |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
764 'read-quoted-char-radix 8 |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
765 "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'. |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
766 Legitimate radix values are 8, 10 and 16." |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
767 :type '(choice (const 8) (const 10) (const 16)) |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
768 :group 'editing-basics) |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
769 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
770 (defun read-quoted-char (&optional prompt) |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
771 "Like `read-char', but do not allow quitting. |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
772 Also, if the first character read is an octal digit, |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
773 we read any number of octal digits and return the |
21008
7111f9cf9392
(read-quoted-char): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20939
diff
changeset
|
774 specified character code. Any nondigit terminates the sequence. |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
775 If the terminator is RET, it is discarded; |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
776 any other terminator is used itself as input. |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
777 |
21008
7111f9cf9392
(read-quoted-char): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20939
diff
changeset
|
778 The optional argument PROMPT specifies a string to use to prompt the user. |
7111f9cf9392
(read-quoted-char): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20939
diff
changeset
|
779 The variable `read-quoted-char-radix' controls which radix to use |
7111f9cf9392
(read-quoted-char): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20939
diff
changeset
|
780 for numeric input." |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
781 (let ((message-log-max nil) done (first t) (code 0) char) |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
782 (while (not done) |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
783 (let ((inhibit-quit first) |
12108
f75e47f673f4
(read-quoted-char): Turn on help-form and turn off help-char.
Karl Heuer <kwzh@gnu.org>
parents:
12016
diff
changeset
|
784 ;; Don't let C-h get the help message--only help function keys. |
f75e47f673f4
(read-quoted-char): Turn on help-form and turn off help-char.
Karl Heuer <kwzh@gnu.org>
parents:
12016
diff
changeset
|
785 (help-char nil) |
f75e47f673f4
(read-quoted-char): Turn on help-form and turn off help-char.
Karl Heuer <kwzh@gnu.org>
parents:
12016
diff
changeset
|
786 (help-form |
f75e47f673f4
(read-quoted-char): Turn on help-form and turn off help-char.
Karl Heuer <kwzh@gnu.org>
parents:
12016
diff
changeset
|
787 "Type the special character you want to use, |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
788 or the octal character code. |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
789 RET terminates the character code and is discarded; |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
790 any other non-digit terminates the character code and is then used as input.")) |
23058
4d7992b69c29
(read-quoted-char): Don't bind input-method-function;
Richard M. Stallman <rms@gnu.org>
parents:
22960
diff
changeset
|
791 (setq char (read-event (and prompt (format "%s-" prompt)) t)) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
792 (if inhibit-quit (setq quit-flag nil))) |
18948
faab6e4baa7d
(read-quoted-char): Convert function keys like Return
Richard M. Stallman <rms@gnu.org>
parents:
18880
diff
changeset
|
793 ;; Translate TAB key into control-I ASCII character, and so on. |
faab6e4baa7d
(read-quoted-char): Convert function keys like Return
Richard M. Stallman <rms@gnu.org>
parents:
18880
diff
changeset
|
794 (and char |
faab6e4baa7d
(read-quoted-char): Convert function keys like Return
Richard M. Stallman <rms@gnu.org>
parents:
18880
diff
changeset
|
795 (let ((translated (lookup-key function-key-map (vector char)))) |
19175
3d80c899a15d
(read-quoted-char): Fix handling of meta-chars.
Richard M. Stallman <rms@gnu.org>
parents:
19002
diff
changeset
|
796 (if (arrayp translated) |
18948
faab6e4baa7d
(read-quoted-char): Convert function keys like Return
Richard M. Stallman <rms@gnu.org>
parents:
18880
diff
changeset
|
797 (setq char (aref translated 0))))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
798 (cond ((null char)) |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
799 ((not (integerp char)) |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
800 (setq unread-command-events (list char) |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
801 done t)) |
19175
3d80c899a15d
(read-quoted-char): Fix handling of meta-chars.
Richard M. Stallman <rms@gnu.org>
parents:
19002
diff
changeset
|
802 ((/= (logand char ?\M-\^@) 0) |
3d80c899a15d
(read-quoted-char): Fix handling of meta-chars.
Richard M. Stallman <rms@gnu.org>
parents:
19002
diff
changeset
|
803 ;; Turn a meta-character into a character with the 0200 bit set. |
3d80c899a15d
(read-quoted-char): Fix handling of meta-chars.
Richard M. Stallman <rms@gnu.org>
parents:
19002
diff
changeset
|
804 (setq code (logior (logand char (lognot ?\M-\^@)) 128) |
3d80c899a15d
(read-quoted-char): Fix handling of meta-chars.
Richard M. Stallman <rms@gnu.org>
parents:
19002
diff
changeset
|
805 done t)) |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
806 ((and (<= ?0 char) (< char (+ ?0 (min 10 read-quoted-char-radix)))) |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
807 (setq code (+ (* code read-quoted-char-radix) (- char ?0))) |
14343
ab021899d604
(read-quoted-char): Delete format call inside message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
808 (and prompt (setq prompt (message "%s %c" prompt char)))) |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
809 ((and (<= ?a (downcase char)) |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
810 (< (downcase char) (+ ?a -10 (min 26 read-quoted-char-radix)))) |
19002
f21881dcd27b
(read-quoted-char): Consistently downcase letter "digits".
Richard M. Stallman <rms@gnu.org>
parents:
18948
diff
changeset
|
811 (setq code (+ (* code read-quoted-char-radix) |
f21881dcd27b
(read-quoted-char): Consistently downcase letter "digits".
Richard M. Stallman <rms@gnu.org>
parents:
18948
diff
changeset
|
812 (+ 10 (- (downcase char) ?a)))) |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
813 (and prompt (setq prompt (message "%s %c" prompt char)))) |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
814 ((and (not first) (eq char ?\C-m)) |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
815 (setq done t)) |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
816 ((not first) |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
817 (setq unread-command-events (list char) |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
818 done t)) |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
819 (t (setq code char |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
820 done t))) |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
821 (setq first nil)) |
19175
3d80c899a15d
(read-quoted-char): Fix handling of meta-chars.
Richard M. Stallman <rms@gnu.org>
parents:
19002
diff
changeset
|
822 code)) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
823 |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
824 (defun read-passwd (prompt &optional confirm default) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
825 "Read a password, prompting with PROMPT. Echo `.' for each character typed. |
20472
79ea90039b23
(read-password): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20410
diff
changeset
|
826 End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
827 Optional argument CONFIRM, if non-nil, then read it twice to make sure. |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
828 Optional DEFAULT is a default password to use instead of empty input." |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
829 (if confirm |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
830 (let (success) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
831 (while (not success) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
832 (let ((first (read-passwd prompt nil default)) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
833 (second (read-passwd "Confirm password: " nil default))) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
834 (if (equal first second) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
835 (setq success first) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
836 (message "Password not repeated accurately; please start over") |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
837 (sit-for 1)))) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
838 success) |
23437
62f74712cbd6
(read-passwd): Use clear-this-command-keys.
Richard M. Stallman <rms@gnu.org>
parents:
23294
diff
changeset
|
839 (clear-this-command-keys) |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
840 (let ((pass nil) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
841 (c 0) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
842 (echo-keystrokes 0) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
843 (cursor-in-echo-area t)) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
844 (while (progn (message "%s%s" |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
845 prompt |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
846 (make-string (length pass) ?.)) |
23907
2cd294915abd
(read-passwd): Ignore input methods.
Karl Heuer <kwzh@gnu.org>
parents:
23786
diff
changeset
|
847 (setq c (read-char nil t)) |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
848 (and (/= c ?\r) (/= c ?\n) (/= c ?\e))) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
849 (if (= c ?\C-u) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
850 (setq pass "") |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
851 (if (and (/= c ?\b) (/= c ?\177)) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
852 (setq pass (concat pass (char-to-string c))) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
853 (if (> (length pass) 0) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
854 (setq pass (substring pass 0 -1)))))) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
855 (message nil) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
856 (or pass default "")))) |
20472
79ea90039b23
(read-password): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20410
diff
changeset
|
857 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
858 (defun force-mode-line-update (&optional all) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
859 "Force the mode-line of the current buffer to be redisplayed. |
6795
a379e974be7c
(force-mode-line-update): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6725
diff
changeset
|
860 With optional non-nil ALL, force redisplay of all mode-lines." |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
861 (if all (save-excursion (set-buffer (other-buffer)))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
862 (set-buffer-modified-p (buffer-modified-p))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
863 |
114 | 864 (defun momentary-string-display (string pos &optional exit-char message) |
865 "Momentarily display STRING in the buffer at POS. | |
866 Display remains until next character is typed. | |
867 If the char is EXIT-CHAR (optional third arg, default is SPC) it is swallowed; | |
868 otherwise it is then available as input (as a command if nothing else). | |
869 Display MESSAGE (optional fourth arg) in the echo area. | |
870 If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there." | |
871 (or exit-char (setq exit-char ?\ )) | |
24322
ca77d79a0c21
(momentary-string-display): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
24245
diff
changeset
|
872 (let ((inhibit-read-only t) |
6553
fca6271b0983
(momentary-string-display): Avoid modifying the undo list.
Richard M. Stallman <rms@gnu.org>
parents:
6551
diff
changeset
|
873 ;; Don't modify the undo list at all. |
fca6271b0983
(momentary-string-display): Avoid modifying the undo list.
Richard M. Stallman <rms@gnu.org>
parents:
6551
diff
changeset
|
874 (buffer-undo-list t) |
114 | 875 (modified (buffer-modified-p)) |
876 (name buffer-file-name) | |
877 insert-end) | |
878 (unwind-protect | |
879 (progn | |
880 (save-excursion | |
881 (goto-char pos) | |
882 ;; defeat file locking... don't try this at home, kids! | |
883 (setq buffer-file-name nil) | |
884 (insert-before-markers string) | |
4620
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
885 (setq insert-end (point)) |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
886 ;; If the message end is off screen, recenter now. |
21173
e917eb0d4e01
(save-match-data): store-match-data => set-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
21092
diff
changeset
|
887 (if (< (window-end nil t) insert-end) |
4620
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
888 (recenter (/ (window-height) 2))) |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
889 ;; If that pushed message start off the screen, |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
890 ;; scroll to start it at the top of the screen. |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
891 (move-to-window-line 0) |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
892 (if (> (point) pos) |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
893 (progn |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
894 (goto-char pos) |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
895 (recenter 0)))) |
114 | 896 (message (or message "Type %s to continue editing.") |
897 (single-key-description exit-char)) | |
2033
10cdd2928c7d
(momentary-string-display): Handle any event when flushing the display.
Richard M. Stallman <rms@gnu.org>
parents:
2021
diff
changeset
|
898 (let ((char (read-event))) |
114 | 899 (or (eq char exit-char) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1695
diff
changeset
|
900 (setq unread-command-events (list char))))) |
114 | 901 (if insert-end |
902 (save-excursion | |
903 (delete-region pos insert-end))) | |
904 (setq buffer-file-name name) | |
905 (set-buffer-modified-p modified)))) | |
906 | |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
907 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
908 ;;;; Miscellanea. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
909 |
10254
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
910 ;; A number of major modes set this locally. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
911 ;; Give it a global value to avoid compiler warnings. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
912 (defvar font-lock-defaults nil) |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
913 |
20846
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
914 (defvar suspend-hook nil |
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
915 "Normal hook run by `suspend-emacs', before suspending.") |
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
916 |
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
917 (defvar suspend-resume-hook nil |
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
918 "Normal hook run by `suspend-emacs', after Emacs is continued.") |
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
919 |
10254
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
920 ;; Avoid compiler warnings about this variable, |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
921 ;; which has a special meaning on certain system types. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
922 (defvar buffer-file-type nil |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
923 "Non-nil if the visited file is a binary file. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
924 This variable is meaningful on MS-DOG and Windows NT. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
925 On those systems, it is automatically local in every buffer. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
926 On other systems, this variable is normally always nil.") |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
927 |
14515
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
928 ;; This should probably be written in C (i.e., without using `walk-windows'). |
14707
ddcae263bb18
Make get-buffer-window-list take MINIBUF arg.
Simon Marshall <simon@gnu.org>
parents:
14517
diff
changeset
|
929 (defun get-buffer-window-list (buffer &optional minibuf frame) |
14515
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
930 "Return windows currently displaying BUFFER, or nil if none. |
14707
ddcae263bb18
Make get-buffer-window-list take MINIBUF arg.
Simon Marshall <simon@gnu.org>
parents:
14517
diff
changeset
|
931 See `walk-windows' for the meaning of MINIBUF and FRAME." |
14517
8b88e5c2a6d5
Cope if get-buffer-window-list is given a buffer name (like get-buffer-window does).
Simon Marshall <simon@gnu.org>
parents:
14515
diff
changeset
|
932 (let ((buffer (if (bufferp buffer) buffer (get-buffer buffer))) windows) |
14515
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
933 (walk-windows (function (lambda (window) |
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
934 (if (eq (window-buffer window) buffer) |
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
935 (setq windows (cons window windows))))) |
14707
ddcae263bb18
Make get-buffer-window-list take MINIBUF arg.
Simon Marshall <simon@gnu.org>
parents:
14517
diff
changeset
|
936 minibuf frame) |
14515
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
937 windows)) |
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
938 |
8211
08fb5e917205
(ignore): Put doc string in right place.
Richard M. Stallman <rms@gnu.org>
parents:
7693
diff
changeset
|
939 (defun ignore (&rest ignore) |
08fb5e917205
(ignore): Put doc string in right place.
Richard M. Stallman <rms@gnu.org>
parents:
7693
diff
changeset
|
940 "Do nothing and return nil. |
08fb5e917205
(ignore): Put doc string in right place.
Richard M. Stallman <rms@gnu.org>
parents:
7693
diff
changeset
|
941 This function accepts any number of arguments, but ignores them." |
7400
c415ff549eed
(ignore): Allow interactive call.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
942 (interactive) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
943 nil) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
944 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
945 (defun error (&rest args) |
13936 | 946 "Signal an error, making error message by passing all args to `format'. |
947 In Emacs, the convention is that error messages start with a capital | |
948 letter but *do not* end with a period. Please follow this convention | |
949 for the sake of consistency." | |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
950 (while t |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
951 (signal 'error (list (apply 'format args))))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
952 |
5912
909b94d547c4
(user-original-login-name): Reduce to a defalias, since it's redundant with
Karl Heuer <kwzh@gnu.org>
parents:
5844
diff
changeset
|
953 (defalias 'user-original-login-name 'user-login-name) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
954 |
114 | 955 (defun start-process-shell-command (name buffer &rest args) |
956 "Start a program in a subprocess. Return the process object for it. | |
957 Args are NAME BUFFER COMMAND &rest COMMAND-ARGS. | |
958 NAME is name for process. It is modified if necessary to make it unique. | |
959 BUFFER is the buffer or (buffer-name) to associate with the process. | |
960 Process output goes at end of that buffer, unless you specify | |
961 an output stream or filter function to handle the output. | |
962 BUFFER may be also nil, meaning that this process is not associated | |
963 with any buffer | |
964 Third arg is command name, the name of a shell command. | |
965 Remaining arguments are the arguments for the command. | |
5460
3bd42ee22d1f
(start-process-shell-command): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5440
diff
changeset
|
966 Wildcards and redirection are handled as usual in the shell." |
9822
248462096d25
(start-process-shell-command): Don't use exec on windows-nt.
Karl Heuer <kwzh@gnu.org>
parents:
9535
diff
changeset
|
967 (cond |
248462096d25
(start-process-shell-command): Don't use exec on windows-nt.
Karl Heuer <kwzh@gnu.org>
parents:
9535
diff
changeset
|
968 ((eq system-type 'vax-vms) |
248462096d25
(start-process-shell-command): Don't use exec on windows-nt.
Karl Heuer <kwzh@gnu.org>
parents:
9535
diff
changeset
|
969 (apply 'start-process name buffer args)) |
10025
3b058e13d177
(start-process-shell-command): Don't use `exec'--
Richard M. Stallman <rms@gnu.org>
parents:
9986
diff
changeset
|
970 ;; We used to use `exec' to replace the shell with the command, |
3b058e13d177
(start-process-shell-command): Don't use `exec'--
Richard M. Stallman <rms@gnu.org>
parents:
9986
diff
changeset
|
971 ;; but that failed to handle (...) and semicolon, etc. |
9822
248462096d25
(start-process-shell-command): Don't use exec on windows-nt.
Karl Heuer <kwzh@gnu.org>
parents:
9535
diff
changeset
|
972 (t |
248462096d25
(start-process-shell-command): Don't use exec on windows-nt.
Karl Heuer <kwzh@gnu.org>
parents:
9535
diff
changeset
|
973 (start-process name buffer shell-file-name shell-command-switch |
10025
3b058e13d177
(start-process-shell-command): Don't use `exec'--
Richard M. Stallman <rms@gnu.org>
parents:
9986
diff
changeset
|
974 (mapconcat 'identity args " "))))) |
16359
18cc78dc8b18
(with-temp-file): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16333
diff
changeset
|
975 |
16277
bbddbc86b82b
(with-current-buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
15983
diff
changeset
|
976 (defmacro with-current-buffer (buffer &rest body) |
bbddbc86b82b
(with-current-buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
15983
diff
changeset
|
977 "Execute the forms in BODY with BUFFER as the current buffer. |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
978 The value returned is the value of the last form in BODY. |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
979 See also `with-temp-buffer'." |
26002
4f46db3c9d7d
* subr.el (with-current-buffer): don't use backquotes to avoid
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
25706
diff
changeset
|
980 (cons 'save-current-buffer |
4f46db3c9d7d
* subr.el (with-current-buffer): don't use backquotes to avoid
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
25706
diff
changeset
|
981 (cons (list 'set-buffer buffer) |
4f46db3c9d7d
* subr.el (with-current-buffer): don't use backquotes to avoid
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
25706
diff
changeset
|
982 body))) |
16277
bbddbc86b82b
(with-current-buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
15983
diff
changeset
|
983 |
23736 | 984 (defmacro with-temp-file (file &rest body) |
985 "Create a new buffer, evaluate BODY there, and write the buffer to FILE. | |
986 The value returned is the value of the last form in BODY. | |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
987 See also `with-temp-buffer'." |
16359
18cc78dc8b18
(with-temp-file): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16333
diff
changeset
|
988 (let ((temp-file (make-symbol "temp-file")) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
989 (temp-buffer (make-symbol "temp-buffer"))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
990 `(let ((,temp-file ,file) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
991 (,temp-buffer |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
992 (get-buffer-create (generate-new-buffer-name " *temp file*")))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
993 (unwind-protect |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
994 (prog1 |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
995 (with-current-buffer ,temp-buffer |
23736 | 996 ,@body) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
997 (with-current-buffer ,temp-buffer |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
998 (widen) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
999 (write-region (point-min) (point-max) ,temp-file nil 0))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1000 (and (buffer-name ,temp-buffer) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1001 (kill-buffer ,temp-buffer)))))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1002 |
23736 | 1003 (defmacro with-temp-message (message &rest body) |
24011 | 1004 "Display MESSAGE temporarily if non-nil while BODY is evaluated. |
23736 | 1005 The original message is restored to the echo area after BODY has finished. |
1006 The value returned is the value of the last form in BODY. | |
24011 | 1007 MESSAGE is written to the message log buffer if `message-log-max' is non-nil. |
1008 If MESSAGE is nil, the echo area and message log buffer are unchanged. | |
1009 Use a MESSAGE of \"\" to temporarily clear the echo area." | |
24000
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1010 (let ((current-message (make-symbol "current-message")) |
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1011 (temp-message (make-symbol "with-temp-message"))) |
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1012 `(let ((,temp-message ,message) |
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1013 (,current-message)) |
23736 | 1014 (unwind-protect |
1015 (progn | |
24000
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1016 (when ,temp-message |
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1017 (setq ,current-message (current-message)) |
24699
1ce8c890309e
(with-temp-message): Fix the other call to message to use %s.
Karl Heuer <kwzh@gnu.org>
parents:
24385
diff
changeset
|
1018 (message "%s" ,temp-message)) |
23736 | 1019 ,@body) |
24385
92817fedff02
(with-temp-message): Use %s so % in old msg won't fool us.
Karl Heuer <kwzh@gnu.org>
parents:
24322
diff
changeset
|
1020 (and ,temp-message ,current-message |
92817fedff02
(with-temp-message): Use %s so % in old msg won't fool us.
Karl Heuer <kwzh@gnu.org>
parents:
24322
diff
changeset
|
1021 (message "%s" ,current-message)))))) |
23736 | 1022 |
1023 (defmacro with-temp-buffer (&rest body) | |
1024 "Create a temporary buffer, and evaluate BODY there like `progn'. | |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1025 See also `with-temp-file' and `with-output-to-string'." |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1026 (let ((temp-buffer (make-symbol "temp-buffer"))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1027 `(let ((,temp-buffer |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1028 (get-buffer-create (generate-new-buffer-name " *temp*")))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1029 (unwind-protect |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1030 (with-current-buffer ,temp-buffer |
23736 | 1031 ,@body) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1032 (and (buffer-name ,temp-buffer) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1033 (kill-buffer ,temp-buffer)))))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1034 |
16311
a56a8c6f2d8f
(with-output-to-string): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16294
diff
changeset
|
1035 (defmacro with-output-to-string (&rest body) |
a56a8c6f2d8f
(with-output-to-string): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16294
diff
changeset
|
1036 "Execute BODY, return the text it sent to `standard-output', as a string." |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1037 `(let ((standard-output |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1038 (get-buffer-create (generate-new-buffer-name " *string-output*")))) |
16311
a56a8c6f2d8f
(with-output-to-string): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16294
diff
changeset
|
1039 (let ((standard-output standard-output)) |
a56a8c6f2d8f
(with-output-to-string): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16294
diff
changeset
|
1040 ,@body) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1041 (with-current-buffer standard-output |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1042 (prog1 |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1043 (buffer-string) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1044 (kill-buffer nil))))) |
16549
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1045 |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1046 (defmacro combine-after-change-calls (&rest body) |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1047 "Execute BODY, but don't call the after-change functions till the end. |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1048 If BODY makes changes in the buffer, they are recorded |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1049 and the functions on `after-change-functions' are called several times |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1050 when BODY is finished. |
17146
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1051 The return value is the value of the last form in BODY. |
16549
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1052 |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1053 If `before-change-functions' is non-nil, then calls to the after-change |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1054 functions can't be deferred, so in that case this macro has no effect. |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1055 |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1056 Do not alter `after-change-functions' or `before-change-functions' |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1057 in BODY." |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1058 `(unwind-protect |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1059 (let ((combine-after-change-calls t)) |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1060 . ,body) |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1061 (combine-after-change-execute))) |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1062 |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1063 |
15955
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1064 (defvar save-match-data-internal) |
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1065 |
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1066 ;; We use save-match-data-internal as the local variable because |
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1067 ;; that works ok in practice (people should not use that variable elsewhere). |
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1068 ;; We used to use an uninterned symbol; the compiler handles that properly |
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1069 ;; now, but it generates slower code. |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1070 (defmacro save-match-data (&rest body) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1071 "Execute the BODY forms, restoring the global value of the match data." |
26084
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1072 ;; It is better not to use backquote here, |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1073 ;; because that makes a bootstrapping problem |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1074 ;; if you need to recompile all the Lisp files using interpreted code. |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1075 (list 'let |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1076 '((save-match-data-internal (match-data))) |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1077 (list 'unwind-protect |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1078 (cons 'progn body) |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1079 '(set-match-data save-match-data-internal)))) |
144
535ec1aa78ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
114
diff
changeset
|
1080 |
11115
9414f249cd8b
Changed match-string to defun, but still return nil (no error) if no match.
Simon Marshall <simon@gnu.org>
parents:
11101
diff
changeset
|
1081 (defun match-string (num &optional string) |
11101
67231dca5f32
Change to macro, and return nil if there was no match at the specified depth.
Simon Marshall <simon@gnu.org>
parents:
11087
diff
changeset
|
1082 "Return string of text matched by last search. |
67231dca5f32
Change to macro, and return nil if there was no match at the specified depth.
Simon Marshall <simon@gnu.org>
parents:
11087
diff
changeset
|
1083 NUM specifies which parenthesized expression in the last regexp. |
67231dca5f32
Change to macro, and return nil if there was no match at the specified depth.
Simon Marshall <simon@gnu.org>
parents:
11087
diff
changeset
|
1084 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. |
67231dca5f32
Change to macro, and return nil if there was no match at the specified depth.
Simon Marshall <simon@gnu.org>
parents:
11087
diff
changeset
|
1085 Zero means the entire text matched by the whole regexp or whole string. |
67231dca5f32
Change to macro, and return nil if there was no match at the specified depth.
Simon Marshall <simon@gnu.org>
parents:
11087
diff
changeset
|
1086 STRING should be given if the last search was by `string-match' on STRING." |
11115
9414f249cd8b
Changed match-string to defun, but still return nil (no error) if no match.
Simon Marshall <simon@gnu.org>
parents:
11101
diff
changeset
|
1087 (if (match-beginning num) |
9414f249cd8b
Changed match-string to defun, but still return nil (no error) if no match.
Simon Marshall <simon@gnu.org>
parents:
11101
diff
changeset
|
1088 (if string |
9414f249cd8b
Changed match-string to defun, but still return nil (no error) if no match.
Simon Marshall <simon@gnu.org>
parents:
11101
diff
changeset
|
1089 (substring string (match-beginning num) (match-end num)) |
9414f249cd8b
Changed match-string to defun, but still return nil (no error) if no match.
Simon Marshall <simon@gnu.org>
parents:
11101
diff
changeset
|
1090 (buffer-substring (match-beginning num) (match-end num))))) |
10560
fd09d51dfd77
(match-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10368
diff
changeset
|
1091 |
20491
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1092 (defun match-string-no-properties (num &optional string) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1093 "Return string of text matched by last search, without text properties. |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1094 NUM specifies which parenthesized expression in the last regexp. |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1095 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1096 Zero means the entire text matched by the whole regexp or whole string. |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1097 STRING should be given if the last search was by `string-match' on STRING." |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1098 (if (match-beginning num) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1099 (if string |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1100 (let ((result |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1101 (substring string (match-beginning num) (match-end num)))) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1102 (set-text-properties 0 (length result) nil result) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1103 result) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1104 (buffer-substring-no-properties (match-beginning num) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1105 (match-end num))))) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1106 |
16314
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1107 (defun split-string (string &optional separators) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1108 "Splits STRING into substrings where there are matches for SEPARATORS. |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1109 Each match for SEPARATORS is a splitting point. |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1110 The substrings between the splitting points are made into a list |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1111 which is returned. |
20476
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1112 If SEPARATORS is absent, it defaults to \"[ \\f\\t\\n\\r\\v]+\". |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1113 |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1114 If there is match for SEPARATORS at the beginning of STRING, we do not |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1115 include a null substring for that. Likewise, if there is a match |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1116 at the end of STRING, we don't include a null substring for that." |
16314
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1117 (let ((rexp (or separators "[ \f\t\n\r\v]+")) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1118 (start 0) |
20476
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1119 notfirst |
16314
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1120 (list nil)) |
20476
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1121 (while (and (string-match rexp string |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1122 (if (and notfirst |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1123 (= start (match-beginning 0)) |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1124 (< start (length string))) |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1125 (1+ start) start)) |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1126 (< (match-beginning 0) (length string))) |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1127 (setq notfirst t) |
16333
585956e62c87
(split-string): Fix minor bug.
Richard M. Stallman <rms@gnu.org>
parents:
16314
diff
changeset
|
1128 (or (eq (match-beginning 0) 0) |
20476
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1129 (and (eq (match-beginning 0) (match-end 0)) |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
1130 (eq (match-beginning 0) start)) |
16314
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1131 (setq list |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1132 (cons (substring string start (match-beginning 0)) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1133 list))) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1134 (setq start (match-end 0))) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1135 (or (eq start (length string)) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1136 (setq list |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1137 (cons (substring string start) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1138 list))) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
1139 (nreverse list))) |
24089
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1140 |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1141 (defun subst-char-in-string (fromchar tochar string &optional inplace) |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1142 "Replace FROMCHAR with TOCHAR in STRING each time it occurs. |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1143 Unless optional argument INPLACE is non-nil, return a new string." |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1144 (let ((i (length string)) |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1145 (newstr (if inplace string (copy-sequence string)))) |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1146 (while (> i 0) |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1147 (setq i (1- i)) |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1148 (if (eq (aref newstr i) fromchar) |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1149 (aset newstr i tochar))) |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
1150 newstr)) |
16359
18cc78dc8b18
(with-temp-file): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16333
diff
changeset
|
1151 |
5385
53077bf7c718
(shell-quote-argument): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5302
diff
changeset
|
1152 (defun shell-quote-argument (argument) |
53077bf7c718
(shell-quote-argument): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5302
diff
changeset
|
1153 "Quote an argument for passing as argument to an inferior shell." |
12465
0d404ef125ea
(shell-quote-argument): Don't do anything, on MS-DOS.
Richard M. Stallman <rms@gnu.org>
parents:
12395
diff
changeset
|
1154 (if (eq system-type 'ms-dos) |
25706
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1155 ;; Quote using double quotes, but escape any existing quotes in |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1156 ;; the argument with backslashes. |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1157 (let ((result "") |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1158 (start 0) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1159 end) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1160 (if (or (null (string-match "[^\"]" argument)) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1161 (< (match-end 0) (length argument))) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1162 (while (string-match "[\"]" argument start) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1163 (setq end (match-beginning 0) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1164 result (concat result (substring argument start end) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1165 "\\" (substring argument end (1+ end))) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1166 start (1+ end)))) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
1167 (concat "\"" result (substring argument start) "\"")) |
12465
0d404ef125ea
(shell-quote-argument): Don't do anything, on MS-DOS.
Richard M. Stallman <rms@gnu.org>
parents:
12395
diff
changeset
|
1168 (if (eq system-type 'windows-nt) |
0d404ef125ea
(shell-quote-argument): Don't do anything, on MS-DOS.
Richard M. Stallman <rms@gnu.org>
parents:
12395
diff
changeset
|
1169 (concat "\"" argument "\"") |
17610
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1170 (if (equal argument "") |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1171 "''" |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1172 ;; Quote everything except POSIX filename characters. |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1173 ;; This should be safe enough even for really weird shells. |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1174 (let ((result "") (start 0) end) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1175 (while (string-match "[^-0-9a-zA-Z_./]" argument start) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1176 (setq end (match-beginning 0) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1177 result (concat result (substring argument start end) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1178 "\\" (substring argument end (1+ end))) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1179 start (1+ end))) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
1180 (concat result (substring argument start))))))) |
5385
53077bf7c718
(shell-quote-argument): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5302
diff
changeset
|
1181 |
5844
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1182 (defun make-syntax-table (&optional oldtable) |
5421
a248a39fa4b8
(make-syntax-table): New function; no longer an alias
Richard M. Stallman <rms@gnu.org>
parents:
5385
diff
changeset
|
1183 "Return a new syntax table. |
17612
beaac591604a
(make-syntax-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17610
diff
changeset
|
1184 If OLDTABLE is non-nil, copy OLDTABLE. |
beaac591604a
(make-syntax-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17610
diff
changeset
|
1185 Otherwise, create a syntax table which inherits |
beaac591604a
(make-syntax-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17610
diff
changeset
|
1186 all letters and control characters from the standard syntax table; |
beaac591604a
(make-syntax-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17610
diff
changeset
|
1187 other characters are copied from the standard syntax table." |
5844
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1188 (if oldtable |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1189 (copy-syntax-table oldtable) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1190 (let ((table (copy-syntax-table)) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1191 i) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1192 (setq i 0) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1193 (while (<= i 31) |
13186
6d3d7b32c519
(make-syntax-table): Use nil for "inherit".
Richard M. Stallman <rms@gnu.org>
parents:
13039
diff
changeset
|
1194 (aset table i nil) |
5844
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1195 (setq i (1+ i))) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1196 (setq i ?A) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1197 (while (<= i ?Z) |
13186
6d3d7b32c519
(make-syntax-table): Use nil for "inherit".
Richard M. Stallman <rms@gnu.org>
parents:
13039
diff
changeset
|
1198 (aset table i nil) |
5844
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1199 (setq i (1+ i))) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1200 (setq i ?a) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1201 (while (<= i ?z) |
13186
6d3d7b32c519
(make-syntax-table): Use nil for "inherit".
Richard M. Stallman <rms@gnu.org>
parents:
13039
diff
changeset
|
1202 (aset table i nil) |
5844
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1203 (setq i (1+ i))) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1204 (setq i 128) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1205 (while (<= i 255) |
13186
6d3d7b32c519
(make-syntax-table): Use nil for "inherit".
Richard M. Stallman <rms@gnu.org>
parents:
13039
diff
changeset
|
1206 (aset table i nil) |
5844
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1207 (setq i (1+ i))) |
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
1208 table))) |
17146
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1209 |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1210 (defun add-to-invisibility-spec (arg) |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1211 "Add elements to `buffer-invisibility-spec'. |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1212 See documentation for `buffer-invisibility-spec' for the kind of elements |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1213 that can be added." |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1214 (cond |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1215 ((or (null buffer-invisibility-spec) (eq buffer-invisibility-spec t)) |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1216 (setq buffer-invisibility-spec (list arg))) |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1217 (t |
17158
f181580c182c
(when, unless): Symbol props moved from cl.el.
Karl Heuer <kwzh@gnu.org>
parents:
17152
diff
changeset
|
1218 (setq buffer-invisibility-spec |
f181580c182c
(when, unless): Symbol props moved from cl.el.
Karl Heuer <kwzh@gnu.org>
parents:
17152
diff
changeset
|
1219 (cons arg buffer-invisibility-spec))))) |
17146
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1220 |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1221 (defun remove-from-invisibility-spec (arg) |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1222 "Remove elements from `buffer-invisibility-spec'." |
24245
418feab1639c
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
24089
diff
changeset
|
1223 (if (consp buffer-invisibility-spec) |
17152 | 1224 (setq buffer-invisibility-spec (delete arg buffer-invisibility-spec)))) |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1225 |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1226 (defun global-set-key (key command) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1227 "Give KEY a global binding as COMMAND. |
20410
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1228 COMMAND is the command definition to use; usually it is |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1229 a symbol naming an interactively-callable function. |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1230 KEY is a key sequence; noninteractively, it is a string or vector |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1231 of characters or event types, and non-ASCII characters with codes |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1232 above 127 (such as ISO Latin-1) can be included if you use a vector. |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1233 |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1234 Note that if KEY has a local binding in the current buffer, |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1235 that local binding will continue to shadow any global binding |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1236 that you make with this function." |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1237 (interactive "KSet key globally: \nCSet key %s to command: ") |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1238 (or (vectorp key) (stringp key) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1239 (signal 'wrong-type-argument (list 'arrayp key))) |
21578
6175866e1b71
(local-set-key, global-set-key): Return what define-key returns.
Richard M. Stallman <rms@gnu.org>
parents:
21409
diff
changeset
|
1240 (define-key (current-global-map) key command)) |
5421
a248a39fa4b8
(make-syntax-table): New function; no longer an alias
Richard M. Stallman <rms@gnu.org>
parents:
5385
diff
changeset
|
1241 |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1242 (defun local-set-key (key command) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1243 "Give KEY a local binding as COMMAND. |
20410
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1244 COMMAND is the command definition to use; usually it is |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1245 a symbol naming an interactively-callable function. |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1246 KEY is a key sequence; noninteractively, it is a string or vector |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1247 of characters or event types, and non-ASCII characters with codes |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1248 above 127 (such as ISO Latin-1) can be included if you use a vector. |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
1249 |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1250 The binding goes in the current buffer's local map, |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1251 which in most cases is shared with all other buffers in the same major mode." |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1252 (interactive "KSet key locally: \nCSet key %s locally to command: ") |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1253 (let ((map (current-local-map))) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1254 (or map |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1255 (use-local-map (setq map (make-sparse-keymap)))) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1256 (or (vectorp key) (stringp key) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1257 (signal 'wrong-type-argument (list 'arrayp key))) |
21578
6175866e1b71
(local-set-key, global-set-key): Return what define-key returns.
Richard M. Stallman <rms@gnu.org>
parents:
21409
diff
changeset
|
1258 (define-key map key command))) |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1259 |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1260 (defun global-unset-key (key) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1261 "Remove global binding of KEY. |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1262 KEY is a string representing a sequence of keystrokes." |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1263 (interactive "kUnset key globally: ") |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1264 (global-set-key key nil)) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1265 |
10826
bd0ab0601489
(local-unset-key): Fix args in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
10825
diff
changeset
|
1266 (defun local-unset-key (key) |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1267 "Remove local binding of KEY. |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1268 KEY is a string representing a sequence of keystrokes." |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1269 (interactive "kUnset key locally: ") |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1270 (if (current-local-map) |
10826
bd0ab0601489
(local-unset-key): Fix args in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
10825
diff
changeset
|
1271 (local-set-key key nil)) |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1272 nil) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
1273 |
12016
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
1274 ;; We put this here instead of in frame.el so that it's defined even on |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
1275 ;; systems where frame.el isn't loaded. |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
1276 (defun frame-configuration-p (object) |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
1277 "Return non-nil if OBJECT seems to be a frame configuration. |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
1278 Any list whose car is `frame-configuration' is assumed to be a frame |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
1279 configuration." |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
1280 (and (consp object) |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
1281 (eq (car object) 'frame-configuration))) |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
1282 |
17418
726a87ac1486
(functionp): New function.
Richard M. Stallman <rms@gnu.org>
parents:
17215
diff
changeset
|
1283 (defun functionp (object) |
18880
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
1284 "Non-nil if OBJECT is a type of object that can be called as a function." |
19176
d8eb24685152
(functionp): Use byte-code-function-p, not compiled-function-p.
Richard M. Stallman <rms@gnu.org>
parents:
19175
diff
changeset
|
1285 (or (subrp object) (byte-code-function-p object) |
17418
726a87ac1486
(functionp): New function.
Richard M. Stallman <rms@gnu.org>
parents:
17215
diff
changeset
|
1286 (eq (car-safe object) 'lambda) |
726a87ac1486
(functionp): New function.
Richard M. Stallman <rms@gnu.org>
parents:
17215
diff
changeset
|
1287 (and (symbolp object) (fboundp object)))) |
726a87ac1486
(functionp): New function.
Richard M. Stallman <rms@gnu.org>
parents:
17215
diff
changeset
|
1288 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1289 ;; now in fns.c |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1290 ;(defun nth (n list) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1291 ; "Returns the Nth element of LIST. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1292 ;N counts from zero. If LIST is not that long, nil is returned." |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1293 ; (car (nthcdr n list))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1294 ; |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1295 ;(defun copy-alist (alist) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1296 ; "Return a copy of ALIST. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1297 ;This is a new alist which represents the same mapping |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1298 ;from objects to objects, but does not share the alist structure with ALIST. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1299 ;The objects mapped (cars and cdrs of elements of the alist) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1300 ;are shared, however." |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1301 ; (setq alist (copy-sequence alist)) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1302 ; (let ((tail alist)) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1303 ; (while tail |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1304 ; (if (consp (car tail)) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1305 ; (setcar tail (cons (car (car tail)) (cdr (car tail))))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1306 ; (setq tail (cdr tail)))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1307 ; alist) |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
1308 |
25140
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1309 (defun assoc-delete-all (key alist) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1310 "Delete from ALIST all elements whose car is KEY. |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1311 Return the modified alist." |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1312 (setq alist (copy-sequence alist)) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1313 (let ((tail alist)) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1314 (while tail |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1315 (if (eq (car (car tail)) key) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1316 (setq alist (delq (car tail) alist))) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1317 (setq tail (cdr tail))) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1318 alist)) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
1319 |
25631
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1320 (defun make-temp-file (prefix &optional dir-flag) |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1321 "Create a temporary file. |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1322 The returned file name (created by appending some random characters at the end |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1323 of PREFIX, and expanding against `temporary-file-directory' if necessary, |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1324 is guaranteed to point to a newly created empty file. |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1325 You can then use `write-region' to write new data into the file. |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1326 |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1327 If DIR-FLAG is non-nil, create a new empty directory instead of a file." |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1328 (let (file) |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1329 (while (condition-case () |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1330 (progn |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1331 (setq file |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1332 (make-temp-name |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1333 (expand-file-name prefix temporary-file-directory))) |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1334 (if dir-flag |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1335 (make-directory file) |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1336 (write-region "" nil file nil 'silent nil 'excl)) |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1337 nil) |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1338 (file-already-exists t)) |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1339 ;; the file was somehow created by someone else between |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1340 ;; `make-temp-name' and `write-region', let's try again. |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1341 nil) |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1342 file)) |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
1343 |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
1344 ;;; subr.el ends here |