Mercurial > emacs
annotate lisp/subr.el @ 2053:8bdcc55ebd8f
(Qmodification_hooks): Renamed from Qmodification.
(syms_of_textprop): Changed accordingly.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 07 Mar 1993 09:35:31 +0000 |
parents | aa926beb4caa |
children | 2f0555b428c4 |
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 |
707 | 3 ;;; Copyright (C) 1985, 1986, 1992 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 | |
18 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
21 ;;; Code: |
114 | 22 |
707 | 23 (defun one-window-p (&optional nomini) |
114 | 24 "Returns non-nil if there is only one window. |
25 Optional arg NOMINI non-nil means don't count the minibuffer | |
26 even if it is active." | |
707 | 27 (let ((base-window (selected-window))) |
28 (if (and nomini (eq base-window (minibuffer-window))) | |
29 (setq base-window (next-window base-window))) | |
30 (eq base-window | |
31 (next-window base-window (if nomini 'arg))))) | |
114 | 32 |
779 | 33 (defun walk-windows (proc &optional minibuf all-frames) |
114 | 34 "Cycle through all visible windows, calling PROC for each one. |
35 PROC is called with a window as argument. | |
36 Optional second arg MINIBUF t means count the minibuffer window | |
37 even if not active. If MINIBUF is neither t nor nil it means | |
38 not to count the minibuffer even if it is active. | |
1959
3c827b8110db
(walk-windows): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1903
diff
changeset
|
39 |
3c827b8110db
(walk-windows): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1903
diff
changeset
|
40 Optional third arg ALL-FRAMES, if t, means include all frames. |
3c827b8110db
(walk-windows): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1903
diff
changeset
|
41 ALL-FRAMES nil or omitted means cycle within the selected frame, |
3c827b8110db
(walk-windows): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1903
diff
changeset
|
42 but include the minibuffer window (if MINIBUF says so) that that |
3c827b8110db
(walk-windows): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1903
diff
changeset
|
43 frame uses, even if it is on another frame. |
3c827b8110db
(walk-windows): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1903
diff
changeset
|
44 If ALL-FRAMES is neither nil nor t, stick strictly to the selected frame." |
114 | 45 (let* ((walk-windows-start (selected-window)) |
46 (walk-windows-current walk-windows-start)) | |
47 (while (progn | |
48 (setq walk-windows-current | |
779 | 49 (next-window walk-windows-current minibuf all-frames)) |
114 | 50 (funcall proc walk-windows-current) |
51 (not (eq walk-windows-current walk-windows-start)))))) | |
52 | |
53 (defun read-quoted-char (&optional prompt) | |
54 "Like `read-char', except that if the first character read is an octal | |
55 digit, we read up to two more octal digits and return the character | |
56 represented by the octal number consisting of those digits. | |
57 Optional argument PROMPT specifies a string to use to prompt the user." | |
58 (let ((count 0) (code 0) char) | |
59 (while (< count 3) | |
60 (let ((inhibit-quit (zerop count)) | |
61 (help-form nil)) | |
62 (and prompt (message "%s-" prompt)) | |
63 (setq char (read-char)) | |
64 (if inhibit-quit (setq quit-flag nil))) | |
65 (cond ((null char)) | |
66 ((and (<= ?0 char) (<= char ?7)) | |
67 (setq code (+ (* code 8) (- char ?0)) | |
68 count (1+ count)) | |
69 (and prompt (message (setq prompt | |
70 (format "%s %c" prompt char))))) | |
71 ((> count 0) | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1695
diff
changeset
|
72 (setq unread-command-events (list char) count 259)) |
114 | 73 (t (setq code char count 259)))) |
74 (logand 255 code))) | |
75 | |
76 (defun error (&rest args) | |
77 "Signal an error, making error message by passing all args to `format'." | |
78 (while t | |
79 (signal 'error (list (apply 'format args))))) | |
80 | |
81 (defun undefined () | |
82 (interactive) | |
83 (ding)) | |
84 | |
1166
45fbb83b8160
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1130
diff
changeset
|
85 ;; Some programs still use this as a function. |
45fbb83b8160
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1130
diff
changeset
|
86 (defun baud-rate () |
45fbb83b8160
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1130
diff
changeset
|
87 "Obsolete function returning the value of the `baud-rate' variable." |
45fbb83b8160
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1130
diff
changeset
|
88 baud-rate) |
45fbb83b8160
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1130
diff
changeset
|
89 |
114 | 90 ;Prevent the \{...} documentation construct |
91 ;from mentioning keys that run this command. | |
92 (put 'undefined 'suppress-keymap t) | |
93 | |
94 (defun suppress-keymap (map &optional nodigits) | |
95 "Make MAP override all normally self-inserting keys to be undefined. | |
96 Normally, as an exception, digits and minus-sign are set to make prefix args, | |
97 but optional second arg NODIGITS non-nil treats them like other chars." | |
98 (let ((i 0)) | |
99 (while (<= i 127) | |
100 (if (eql (lookup-key global-map (char-to-string i)) 'self-insert-command) | |
101 (define-key map (char-to-string i) 'undefined)) | |
102 (setq i (1+ i)))) | |
103 (or nodigits | |
104 (let (loop) | |
105 (define-key map "-" 'negative-argument) | |
106 ;; Make plain numbers do numeric args. | |
107 (setq loop ?0) | |
108 (while (<= loop ?9) | |
109 (define-key map (char-to-string loop) 'digit-argument) | |
110 (setq loop (1+ loop)))))) | |
111 | |
112 ;; now in fns.c | |
113 ;(defun nth (n list) | |
114 ; "Returns the Nth element of LIST. | |
115 ;N counts from zero. If LIST is not that long, nil is returned." | |
116 ; (car (nthcdr n list))) | |
117 ; | |
118 ;(defun copy-alist (alist) | |
119 ; "Return a copy of ALIST. | |
120 ;This is a new alist which represents the same mapping | |
121 ;from objects to objects, but does not share the alist structure with ALIST. | |
122 ;The objects mapped (cars and cdrs of elements of the alist) | |
123 ;are shared, however." | |
124 ; (setq alist (copy-sequence alist)) | |
125 ; (let ((tail alist)) | |
126 ; (while tail | |
127 ; (if (consp (car tail)) | |
128 ; (setcar tail (cons (car (car tail)) (cdr (car tail))))) | |
129 ; (setq tail (cdr tail)))) | |
130 ; alist) | |
131 | |
132 ;Moved to keymap.c | |
133 ;(defun copy-keymap (keymap) | |
134 ; "Return a copy of KEYMAP" | |
135 ; (while (not (keymapp keymap)) | |
136 ; (setq keymap (signal 'wrong-type-argument (list 'keymapp keymap)))) | |
137 ; (if (vectorp keymap) | |
138 ; (copy-sequence keymap) | |
139 ; (copy-alist keymap))) | |
140 | |
1176 | 141 (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix) |
114 | 142 "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF. |
143 In other words, OLDDEF is replaced with NEWDEF where ever it appears. | |
1176 | 144 If optional fourth argument OLDMAP is specified, we redefine |
145 in KEYMAP as NEWDEF those chars which are defined as OLDDEF in OLDMAP." | |
146 (or prefix (setq prefix "")) | |
147 (let* ((scan (or oldmap keymap)) | |
148 (vec1 (vector nil)) | |
149 (prefix1 (vconcat prefix vec1))) | |
150 ;; Scan OLDMAP, finding each char or event-symbol that | |
151 ;; has any definition, and act on it with hack-key. | |
152 (while (consp scan) | |
153 (if (consp (car scan)) | |
154 (let ((char (car (car scan))) | |
155 (defn (cdr (car scan)))) | |
156 ;; The inside of this let duplicates exactly | |
157 ;; the inside of the following let that handles array elements. | |
158 (aset vec1 0 char) | |
159 (aset prefix1 (length prefix) char) | |
160 (let (inner-def) | |
161 ;; Skip past menu-prompt. | |
162 (while (stringp (car-safe defn)) | |
163 (setq defn (cdr defn))) | |
164 (setq inner-def defn) | |
165 (while (and (symbolp inner-def) | |
166 (fboundp inner-def)) | |
167 (setq inner-def (symbol-function inner-def))) | |
168 (if (eq defn olddef) | |
169 (define-key keymap prefix1 newdef) | |
170 (if (keymapp defn) | |
171 (substitute-key-definition olddef newdef keymap | |
172 inner-def | |
173 prefix1))))) | |
174 (if (arrayp (car scan)) | |
175 (let* ((array (car scan)) | |
176 (len (length array)) | |
177 (i 0)) | |
178 (while (< i len) | |
179 (let ((char i) (defn (aref array i))) | |
180 ;; The inside of this let duplicates exactly | |
181 ;; the inside of the previous let. | |
182 (aset vec1 0 char) | |
183 (aset prefix1 (length prefix) char) | |
184 (let (inner-def) | |
185 ;; Skip past menu-prompt. | |
186 (while (stringp (car-safe defn)) | |
187 (setq defn (cdr defn))) | |
188 (setq inner-def defn) | |
189 (while (and (symbolp inner-def) | |
190 (fboundp inner-def)) | |
191 (setq inner-def (symbol-function inner-def))) | |
192 (if (eq defn olddef) | |
193 (define-key keymap prefix1 newdef) | |
194 (if (keymapp defn) | |
195 (substitute-key-definition olddef newdef keymap | |
196 inner-def | |
197 prefix1))))) | |
198 (setq i (1+ i)))))) | |
199 (setq scan (cdr scan))))) | |
114 | 200 |
2021
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
201 (defun listify-key-sequence (key) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
202 "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
|
203 (if (vectorp key) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
204 (append key nil) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
205 (mapcar (function (lambda (c) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
206 (if (> c 127) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
207 (logxor c 8388736) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
208 c))) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
209 (append key nil)))) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
210 |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
211 (defsubst eventp (obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
212 "True if the argument is an event object." |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
213 (or (integerp obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
214 (and (symbolp obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
215 (get obj 'event-symbol-elements)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
216 (and (consp obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
217 (symbolp (car obj)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
218 (get (car obj) 'event-symbol-elements)))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
219 |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
220 (defun event-modifiers (event) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
221 "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
|
222 The elements of the list may include `meta', `control', |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
223 `shift', `hyper', `super', `alt'. |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
224 See also the function `event-modifier-bits'." |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
225 (let ((type event)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
226 (if (listp type) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
227 (setq type (car type))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
228 (if (symbolp type) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
229 (cdr (get type 'event-symbol-elements)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
230 (let ((list nil)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
231 (or (zerop (logand type (lsh 1 23))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
232 (setq list (cons 'meta list))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
233 (or (and (zerop (logand type (lsh 1 22))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
234 (>= (logand type 127) 32)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
235 (setq list (cons 'control list))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
236 (or (and (zerop (logand type (lsh 1 21))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
237 (= (logand type 255) (downcase (logand type 255)))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
238 (setq list (cons 'shift list))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
239 (or (zerop (logand type (lsh 1 20))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
240 (setq list (cons 'hyper list))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
241 (or (zerop (logand type (lsh 1 19))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
242 (setq list (cons 'super list))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
243 (or (zerop (logand type (lsh 1 18))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
244 (setq list (cons 'alt list))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
245 list)))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
246 |
1130
e18597ff3c95
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1112
diff
changeset
|
247 (defmacro save-match-data (&rest body) |
e18597ff3c95
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1112
diff
changeset
|
248 "Execute the BODY forms, restoring the global value of the match data." |
e18597ff3c95
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1112
diff
changeset
|
249 (let ((original (make-symbol "match-data"))) |
e18597ff3c95
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1112
diff
changeset
|
250 (list |
e18597ff3c95
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1112
diff
changeset
|
251 'let (list (list original '(match-data))) |
e18597ff3c95
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1112
diff
changeset
|
252 (list 'unwind-protect |
e18597ff3c95
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1112
diff
changeset
|
253 (cons 'progn body) |
e18597ff3c95
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1112
diff
changeset
|
254 (list 'store-match-data original))))) |
e18597ff3c95
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1112
diff
changeset
|
255 |
1695
f0d8f2b34eb3
(ignore): Use defun instead of fset to define; the byte compiler is smart
Roland McGrath <roland@gnu.org>
parents:
1634
diff
changeset
|
256 (defun ignore (&rest ignore) |
f0d8f2b34eb3
(ignore): Use defun instead of fset to define; the byte compiler is smart
Roland McGrath <roland@gnu.org>
parents:
1634
diff
changeset
|
257 "Do nothing. |
293 | 258 Accept any number of arguments, but ignore them." |
1695
f0d8f2b34eb3
(ignore): Use defun instead of fset to define; the byte compiler is smart
Roland McGrath <roland@gnu.org>
parents:
1634
diff
changeset
|
259 nil) |
114 | 260 |
261 ; old names | |
262 (fset 'make-syntax-table 'copy-syntax-table) | |
263 (fset 'dot 'point) | |
264 (fset 'dot-marker 'point-marker) | |
265 (fset 'dot-min 'point-min) | |
266 (fset 'dot-max 'point-max) | |
267 (fset 'window-dot 'window-point) | |
268 (fset 'set-window-dot 'set-window-point) | |
269 (fset 'read-input 'read-string) | |
270 (fset 'send-string 'process-send-string) | |
271 (fset 'send-region 'process-send-region) | |
272 (fset 'show-buffer 'set-window-buffer) | |
273 (fset 'buffer-flush-undo 'buffer-disable-undo) | |
675
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
668
diff
changeset
|
274 (fset 'eval-current-buffer 'eval-buffer) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1695
diff
changeset
|
275 (fset 'compiled-function-p 'byte-code-function-p) |
114 | 276 |
1867
4262f19c6cc9
* subr.el (mod): Add back this alias for %.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
277 ;;; This name isn't mentioned in the manual, and we've been hoping to |
4262f19c6cc9
* subr.el (mod): Add back this alias for %.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
278 ;;; phase it out, but there's still a lot of code out there, even for |
4262f19c6cc9
* subr.el (mod): Add back this alias for %.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
279 ;;; Emacs 18.59, which uses mod. I'm going to let the byte compiler's |
4262f19c6cc9
* subr.el (mod): Add back this alias for %.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
280 ;;; make-obsolete function to poke people a little more, and leave the |
4262f19c6cc9
* subr.el (mod): Add back this alias for %.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
281 ;;; `mod' name around for a while longer. |
4262f19c6cc9
* subr.el (mod): Add back this alias for %.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
282 (fset 'mod '%) |
4262f19c6cc9
* subr.el (mod): Add back this alias for %.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
283 |
114 | 284 ; alternate names |
285 (fset 'string= 'string-equal) | |
286 (fset 'string< 'string-lessp) | |
287 (fset 'move-marker 'set-marker) | |
288 (fset 'eql 'eq) | |
289 (fset 'not 'null) | |
290 (fset 'rplaca 'setcar) | |
291 (fset 'rplacd 'setcdr) | |
292 (fset 'beep 'ding) ;preserve lingual purtity | |
293 (fset 'indent-to-column 'indent-to) | |
294 (fset 'backward-delete-char 'delete-backward-char) | |
353 | 295 (fset 'search-forward-regexp (symbol-function 're-search-forward)) |
296 (fset 'search-backward-regexp (symbol-function 're-search-backward)) | |
1903
87f63305319f
* subr.el (string-to-int): Make this an alias for
Jim Blandy <jimb@redhat.com>
parents:
1867
diff
changeset
|
297 |
87f63305319f
* subr.el (string-to-int): Make this an alias for
Jim Blandy <jimb@redhat.com>
parents:
1867
diff
changeset
|
298 ;;; 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
|
299 ;;; to go through all the sources and change them. |
87f63305319f
* subr.el (string-to-int): Make this an alias for
Jim Blandy <jimb@redhat.com>
parents:
1867
diff
changeset
|
300 (fset 'string-to-int 'string-to-number) |
114 | 301 |
388 | 302 ;;; global-map, esc-map, and ctl-x-map have their values set up |
303 ;;; in keymap.c. | |
114 | 304 (defvar global-map nil |
305 "Default global keymap mapping Emacs keyboard input into commands. | |
306 The value is a keymap which is usually (but not necessarily) Emacs's | |
307 global map.") | |
308 | |
388 | 309 (defvar esc-map nil |
310 "Default keymap for ESC (meta) commands. | |
311 The normal global definition of the character ESC indirects to this keymap.") | |
312 | |
114 | 313 (defvar ctl-x-map nil |
314 "Default keymap for C-x commands. | |
315 The normal global definition of the character C-x indirects to this keymap.") | |
316 | |
388 | 317 (defvar ctl-x-4-map (make-sparse-keymap) |
318 "Keymap for subcommands of C-x 4") | |
319 (fset 'ctl-x-4-prefix ctl-x-4-map) | |
320 (define-key ctl-x-map "4" 'ctl-x-4-prefix) | |
114 | 321 |
707 | 322 (defvar ctl-x-5-map (make-sparse-keymap) |
779 | 323 "Keymap for frame commands.") |
707 | 324 (fset 'ctl-x-5-prefix ctl-x-5-map) |
325 (define-key ctl-x-map "5" 'ctl-x-5-prefix) | |
388 | 326 |
114 | 327 |
328 (defun run-hooks (&rest hooklist) | |
329 "Takes hook names and runs each one in turn. Major mode functions use this. | |
330 Each argument should be a symbol, a hook variable. | |
331 These symbols are processed in the order specified. | |
332 If a hook symbol has a non-nil value, that value may be a function | |
333 or a list of functions to be called to run the hook. | |
334 If the value is a function, it is called with no arguments. | |
335 If it is a list, the elements are called, in order, with no arguments." | |
336 (while hooklist | |
337 (let ((sym (car hooklist))) | |
338 (and (boundp sym) | |
339 (symbol-value sym) | |
340 (let ((value (symbol-value sym))) | |
341 (if (and (listp value) (not (eq (car value) 'lambda))) | |
342 (mapcar 'funcall value) | |
343 (funcall value))))) | |
344 (setq hooklist (cdr hooklist)))) | |
345 | |
346 ;; Tell C code how to call this function. | |
347 (defconst run-hooks 'run-hooks | |
348 "Variable by which C primitives find the function `run-hooks'. | |
349 Don't change it.") | |
350 | |
351 (defun add-hook (hook function) | |
352 "Add to the value of HOOK the function FUNCTION unless already present. | |
353 HOOK should be a symbol, and FUNCTION may be any valid function. | |
354 HOOK's value should be a list of functions, not a single function. | |
355 If HOOK is void, it is first set to nil." | |
356 (or (boundp hook) (set hook nil)) | |
357 (or (if (consp function) | |
358 ;; Clever way to tell whether a given lambda-expression | |
359 ;; is equal to anything in the hook. | |
360 (let ((tail (assoc (cdr function) (symbol-value hook)))) | |
361 (equal function tail)) | |
362 (memq function (symbol-value hook))) | |
384 | 363 (set hook (cons function (symbol-value hook))))) |
114 | 364 |
365 (defun momentary-string-display (string pos &optional exit-char message) | |
366 "Momentarily display STRING in the buffer at POS. | |
367 Display remains until next character is typed. | |
368 If the char is EXIT-CHAR (optional third arg, default is SPC) it is swallowed; | |
369 otherwise it is then available as input (as a command if nothing else). | |
370 Display MESSAGE (optional fourth arg) in the echo area. | |
371 If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there." | |
372 (or exit-char (setq exit-char ?\ )) | |
373 (let ((buffer-read-only nil) | |
374 (modified (buffer-modified-p)) | |
375 (name buffer-file-name) | |
376 insert-end) | |
377 (unwind-protect | |
378 (progn | |
379 (save-excursion | |
380 (goto-char pos) | |
381 ;; defeat file locking... don't try this at home, kids! | |
382 (setq buffer-file-name nil) | |
383 (insert-before-markers string) | |
384 (setq insert-end (point))) | |
385 (message (or message "Type %s to continue editing.") | |
386 (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
|
387 (let ((char (read-event))) |
114 | 388 (or (eq char exit-char) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1695
diff
changeset
|
389 (setq unread-command-events (list char))))) |
114 | 390 (if insert-end |
391 (save-excursion | |
392 (delete-region pos insert-end))) | |
393 (setq buffer-file-name name) | |
394 (set-buffer-modified-p modified)))) | |
395 | |
396 (defun start-process-shell-command (name buffer &rest args) | |
397 "Start a program in a subprocess. Return the process object for it. | |
398 Args are NAME BUFFER COMMAND &rest COMMAND-ARGS. | |
399 NAME is name for process. It is modified if necessary to make it unique. | |
400 BUFFER is the buffer or (buffer-name) to associate with the process. | |
401 Process output goes at end of that buffer, unless you specify | |
402 an output stream or filter function to handle the output. | |
403 BUFFER may be also nil, meaning that this process is not associated | |
404 with any buffer | |
405 Third arg is command name, the name of a shell command. | |
406 Remaining arguments are the arguments for the command. | |
407 Wildcards and redirection are handle as usual in the shell." | |
408 (if (eq system-type 'vax-vms) | |
409 (apply 'start-process name buffer args) | |
410 (start-process name buffer shell-file-name "-c" | |
411 (concat "exec " (mapconcat 'identity args " "))))) | |
412 | |
413 (defun eval-after-load (file form) | |
414 "Arrange that, if FILE is ever loaded, FORM will be run at that time. | |
415 This makes or adds to an entry on `after-load-alist'. | |
416 FILE should be the name of a library, with no directory name." | |
417 (or (assoc file after-load-alist) | |
418 (setq after-load-alist (cons (list file) after-load-alist))) | |
419 (nconc (assoc file after-load-alist) (list form)) | |
420 form) | |
421 | |
422 (defun eval-next-after-load (file) | |
423 "Read the following input sexp, and run it whenever FILE is loaded. | |
424 This makes or adds to an entry on `after-load-alist'. | |
425 FILE should be the name of a library, with no directory name." | |
426 (eval-after-load file (read))) | |
144
535ec1aa78ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
114
diff
changeset
|
427 |
861
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
428 ;;(defmacro defun-inline (name args &rest body) |
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
429 ;; "Create an \"inline defun\" (actually a macro). |
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
430 ;;Use just like `defun'." |
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
431 ;; (nconc (list 'defmacro name '(&rest args)) |
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
432 ;; (if (stringp (car body)) |
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
433 ;; (prog1 (list (car body)) |
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
434 ;; (setq body (or (cdr body) body)))) |
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
435 ;; (list (list 'cons (list 'quote |
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
436 ;; (cons 'lambda (cons args body))) |
345296f94a1e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
840
diff
changeset
|
437 ;; 'args)))) |
114 | 438 |
439 (defun user-original-login-name () | |
440 "Return user's login name from original login. | |
441 This tries to remain unaffected by `su', by looking in environment variables." | |
442 (or (getenv "LOGNAME") (getenv "USER") (user-login-name))) | |
443 | |
444 (defun force-mode-line-update (&optional all) | |
445 "Force the mode-line of the current buffer to be redisplayed. | |
446 With optional non-nil ALL then force then force redisplay of all mode-lines." | |
447 (if all (save-excursion (set-buffer (other-buffer)))) | |
448 (set-buffer-modified-p (buffer-modified-p))) | |
449 | |
450 (defun keyboard-translate (from to) | |
451 "Translate character FROM to TO at a low level. | |
452 This function creates a `keyboard-translate-table' if necessary | |
453 and then modifies one entry in it." | |
1112 | 454 (or (arrayp keyboard-translate-table) |
455 (setq keyboard-translate-table "")) | |
456 (if (or (> from (length keyboard-translate-table)) | |
457 (> to (length keyboard-translate-table))) | |
458 (progn | |
459 (let* ((i (length keyboard-translate-table)) | |
460 (table (make-string (- 256 i) 0))) | |
461 (while (< i 256) | |
462 (aset table i i) | |
463 (setq i (1+ i))) | |
464 (setq keyboard-translate-table table)))) | |
114 | 465 (aset keyboard-translate-table from to)) |
648 | 466 |
467 | |
468 (defmacro lambda (&rest cdr) | |
1634 | 469 "Return a lambda expression. |
470 A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is | |
471 self-quoting; the result of evaluating the lambda expression is the | |
472 expression itself. The lambda expression may then be treated as a | |
473 function, i. e. stored as the function value of a symbol, passed to | |
474 funcall or mapcar, etcetera. | |
475 ARGS should take the same form as an argument list for a `defun'. | |
476 DOCSTRING should be a string, as described for `defun'. It may be omitted. | |
477 INTERACTIVE should be a call to the function `interactive', which see. | |
478 It may also be omitted. | |
479 BODY should be a list of lisp expressions." | |
1622
dd7b72d023ad
* subr.el (lambda): Don't use backquotes in lambda's definition.
Jim Blandy <jimb@redhat.com>
parents:
1543
diff
changeset
|
480 ;; Note that this definition should not use backquotes; subr.el should not |
dd7b72d023ad
* subr.el (lambda): Don't use backquotes in lambda's definition.
Jim Blandy <jimb@redhat.com>
parents:
1543
diff
changeset
|
481 ;; depend on backquote.el. |
dd7b72d023ad
* subr.el (lambda): Don't use backquotes in lambda's definition.
Jim Blandy <jimb@redhat.com>
parents:
1543
diff
changeset
|
482 (list 'function (cons 'lambda cdr))) |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
483 |
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
484 ;;; subr.el ends here |