annotate lisp/subr.el @ 2287:907efc217cfe

* sysdep.c (reset_sys_modes): Fix usage of EMACS_SET_TTY.
author Jim Blandy <jimb@redhat.com>
date Sat, 20 Mar 1993 22:21:12 +0000
parents 8f410f56d98f
children b7941d286c3f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
3 ;;; Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
4
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
5 ;; This file is part of GNU Emacs.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
6
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
8 ;; it under the terms of the GNU General Public License as published by
707
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
9 ;; the Free Software Foundation; either version 2, or (at your option)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
10 ;; any later version.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
11
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is distributed in the hope that it will be useful,
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
15 ;; GNU General Public License for more details.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
16
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
20
787
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
21 ;;; Code:
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
22
707
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
23 (defun one-window-p (&optional nomini)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
24 "Returns non-nil if there is only one window.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
25 Optional arg NOMINI non-nil means don't count the minibuffer
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
26 even if it is active."
707
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
27 (let ((base-window (selected-window)))
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
28 (if (and nomini (eq base-window (minibuffer-window)))
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
29 (setq base-window (next-window base-window)))
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
30 (eq base-window
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
31 (next-window base-window (if nomini 'arg)))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
32
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 707
diff changeset
33 (defun walk-windows (proc &optional minibuf all-frames)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
34 "Cycle through all visible windows, calling PROC for each one.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
35 PROC is called with a window as argument.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
36 Optional second arg MINIBUF t means count the minibuffer window
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
37 even if not active. If MINIBUF is neither t nor nil it means
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
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
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
45 (let* ((walk-windows-start (selected-window))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
46 (walk-windows-current walk-windows-start))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
47 (while (progn
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
48 (setq walk-windows-current
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 707
diff changeset
49 (next-window walk-windows-current minibuf all-frames))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
50 (funcall proc walk-windows-current)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
51 (not (eq walk-windows-current walk-windows-start))))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
52
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
53 (defun read-quoted-char (&optional prompt)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
54 "Like `read-char', except that if the first character read is an octal
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
55 digit, we read up to two more octal digits and return the character
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
56 represented by the octal number consisting of those digits.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
57 Optional argument PROMPT specifies a string to use to prompt the user."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
58 (let ((count 0) (code 0) char)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
59 (while (< count 3)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
60 (let ((inhibit-quit (zerop count))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
61 (help-form nil))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
62 (and prompt (message "%s-" prompt))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
63 (setq char (read-char))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
64 (if inhibit-quit (setq quit-flag nil)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
65 (cond ((null char))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
66 ((and (<= ?0 char) (<= char ?7))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
67 (setq code (+ (* code 8) (- char ?0))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
68 count (1+ count))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
69 (and prompt (message (setq prompt
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
70 (format "%s %c" prompt char)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
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
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
73 (t (setq code char count 259))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
74 (logand 255 code)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
75
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
76 (defun error (&rest args)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
77 "Signal an error, making error message by passing all args to `format'."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
78 (while t
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
79 (signal 'error (list (apply 'format args)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
80
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
81 (defun undefined ()
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
82 (interactive)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
83 (ding))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
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
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
90 ;Prevent the \{...} documentation construct
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
91 ;from mentioning keys that run this command.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
92 (put 'undefined 'suppress-keymap t)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
93
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
94 (defun suppress-keymap (map &optional nodigits)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
95 "Make MAP override all normally self-inserting keys to be undefined.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
96 Normally, as an exception, digits and minus-sign are set to make prefix args,
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
97 but optional second arg NODIGITS non-nil treats them like other chars."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
98 (let ((i 0))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
99 (while (<= i 127)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
100 (if (eql (lookup-key global-map (char-to-string i)) 'self-insert-command)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
101 (define-key map (char-to-string i) 'undefined))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
102 (setq i (1+ i))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
103 (or nodigits
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
104 (let (loop)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
105 (define-key map "-" 'negative-argument)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
106 ;; Make plain numbers do numeric args.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
107 (setq loop ?0)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
108 (while (<= loop ?9)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
109 (define-key map (char-to-string loop) 'digit-argument)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
110 (setq loop (1+ loop))))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
111
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
112 ;; now in fns.c
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
113 ;(defun nth (n list)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
114 ; "Returns the Nth element of LIST.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
115 ;N counts from zero. If LIST is not that long, nil is returned."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
116 ; (car (nthcdr n list)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
117 ;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
118 ;(defun copy-alist (alist)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
119 ; "Return a copy of ALIST.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
120 ;This is a new alist which represents the same mapping
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
121 ;from objects to objects, but does not share the alist structure with ALIST.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
122 ;The objects mapped (cars and cdrs of elements of the alist)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
123 ;are shared, however."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
124 ; (setq alist (copy-sequence alist))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
125 ; (let ((tail alist))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
126 ; (while tail
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
127 ; (if (consp (car tail))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
128 ; (setcar tail (cons (car (car tail)) (cdr (car tail)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
129 ; (setq tail (cdr tail))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
130 ; alist)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
131
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
132 ;Moved to keymap.c
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
133 ;(defun copy-keymap (keymap)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
134 ; "Return a copy of KEYMAP"
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
135 ; (while (not (keymapp keymap))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
136 ; (setq keymap (signal 'wrong-type-argument (list 'keymapp keymap))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
137 ; (if (vectorp keymap)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
138 ; (copy-sequence keymap)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
139 ; (copy-alist keymap)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
140
1176
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
141 (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
142 "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
143 In other words, OLDDEF is replaced with NEWDEF where ever it appears.
1176
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
144 If optional fourth argument OLDMAP is specified, we redefine
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
145 in KEYMAP as NEWDEF those chars which are defined as OLDDEF in OLDMAP."
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
146 (or prefix (setq prefix ""))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
147 (let* ((scan (or oldmap keymap))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
148 (vec1 (vector nil))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
149 (prefix1 (vconcat prefix vec1)))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
150 ;; Scan OLDMAP, finding each char or event-symbol that
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
151 ;; has any definition, and act on it with hack-key.
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
152 (while (consp scan)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
153 (if (consp (car scan))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
154 (let ((char (car (car scan)))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
155 (defn (cdr (car scan))))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
156 ;; The inside of this let duplicates exactly
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
157 ;; the inside of the following let that handles array elements.
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
158 (aset vec1 0 char)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
159 (aset prefix1 (length prefix) char)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
160 (let (inner-def)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
161 ;; Skip past menu-prompt.
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
162 (while (stringp (car-safe defn))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
163 (setq defn (cdr defn)))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
164 (setq inner-def defn)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
165 (while (and (symbolp inner-def)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
166 (fboundp inner-def))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
167 (setq inner-def (symbol-function inner-def)))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
168 (if (eq defn olddef)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
169 (define-key keymap prefix1 newdef)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
170 (if (keymapp defn)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
171 (substitute-key-definition olddef newdef keymap
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
172 inner-def
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
173 prefix1)))))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
174 (if (arrayp (car scan))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
175 (let* ((array (car scan))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
176 (len (length array))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
177 (i 0))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
178 (while (< i len)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
179 (let ((char i) (defn (aref array i)))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
180 ;; The inside of this let duplicates exactly
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
181 ;; the inside of the previous let.
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
182 (aset vec1 0 char)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
183 (aset prefix1 (length prefix) char)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
184 (let (inner-def)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
185 ;; Skip past menu-prompt.
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
186 (while (stringp (car-safe defn))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
187 (setq defn (cdr defn)))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
188 (setq inner-def defn)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
189 (while (and (symbolp inner-def)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
190 (fboundp inner-def))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
191 (setq inner-def (symbol-function inner-def)))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
192 (if (eq defn olddef)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
193 (define-key keymap prefix1 newdef)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
194 (if (keymapp defn)
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
195 (substitute-key-definition olddef newdef keymap
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
196 inner-def
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
197 prefix1)))))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
198 (setq i (1+ i))))))
60e0dc538df3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1166
diff changeset
199 (setq scan (cdr scan)))))
2071
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
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
2063
2f0555b428c4 (event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2040
diff changeset
247 (defun event-basic-type (event)
2f0555b428c4 (event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2040
diff changeset
248 "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
249 The value is an ASCII printing character (not upper case) or a symbol."
2f0555b428c4 (event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2040
diff changeset
250 (if (symbolp event)
2f0555b428c4 (event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2040
diff changeset
251 (car (get event 'event-symbol-elements))
2f0555b428c4 (event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2040
diff changeset
252 (let ((base (logand event (1- (lsh 1 18)))))
2f0555b428c4 (event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2040
diff changeset
253 (downcase (if (< base 32) (logior base 64) base)))))
2f0555b428c4 (event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2040
diff changeset
254
2071
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
255 (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
256 "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
257 (and (consp object)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
258 (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
259
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
260 (defsubst event-start (event)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
261 "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
262 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
263 of the event.
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
264 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
265 The return value is of the form
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
266 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
267 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
268 (nth 1 event))
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
269
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
270 (defsubst event-end (event)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
271 "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
272 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
273 The return value is of the form
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
274 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
275 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
276 (nth (1- (length event)) event))
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
277
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
278 (defsubst posn-window (position)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
279 "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
280 POSITION should be a list of the form
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
281 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
282 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
283 (nth 0 position))
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
284
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
285 (defsubst posn-point (position)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
286 "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
287 POSITION should be a list of the form
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
288 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
289 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
290 (nth 1 position))
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
291
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
292 (defsubst posn-col-row (position)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
293 "Return the row and column in POSITION.
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
294 POSITION should be a list of the form
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
295 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
296 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
297 (nth 2 position))
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
298
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
299 (defsubst posn-timestamp (position)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
300 "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
301 POSITION should be a list of the form
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
302 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
303 nas 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
304 (nth 3 position))
8f410f56d98f (posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents: 2063
diff changeset
305
1130
e18597ff3c95 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
306 (defmacro save-match-data (&rest body)
e18597ff3c95 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
307 "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
308 (let ((original (make-symbol "match-data")))
e18597ff3c95 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
309 (list
e18597ff3c95 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
310 'let (list (list original '(match-data)))
e18597ff3c95 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
311 (list 'unwind-protect
e18597ff3c95 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
312 (cons 'progn body)
e18597ff3c95 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
313 (list 'store-match-data original)))))
e18597ff3c95 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
314
1695
f0d8f2b34eb3 (ignore): Use defun instead of fset to define; the byte compiler is smart
Roland McGrath <roland@gnu.org>
parents: 1634
diff changeset
315 (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
316 "Do nothing.
293
7e7575d7b6d0 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 144
diff changeset
317 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
318 nil)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
319
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
320 ; old names
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
321 (fset 'make-syntax-table 'copy-syntax-table)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
322 (fset 'dot 'point)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
323 (fset 'dot-marker 'point-marker)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
324 (fset 'dot-min 'point-min)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
325 (fset 'dot-max 'point-max)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
326 (fset 'window-dot 'window-point)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
327 (fset 'set-window-dot 'set-window-point)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
328 (fset 'read-input 'read-string)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
329 (fset 'send-string 'process-send-string)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
330 (fset 'send-region 'process-send-region)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
331 (fset 'show-buffer 'set-window-buffer)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
332 (fset 'buffer-flush-undo 'buffer-disable-undo)
675
85fd29f25c75 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 668
diff changeset
333 (fset 'eval-current-buffer 'eval-buffer)
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1695
diff changeset
334 (fset 'compiled-function-p 'byte-code-function-p)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
335
1867
4262f19c6cc9 * subr.el (mod): Add back this alias for %.
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
336 ;;; 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
337 ;;; 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
338 ;;; 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
339 ;;; 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
340 ;;; `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
341 (fset 'mod '%)
4262f19c6cc9 * subr.el (mod): Add back this alias for %.
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
342
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
343 ; alternate names
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
344 (fset 'string= 'string-equal)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
345 (fset 'string< 'string-lessp)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
346 (fset 'move-marker 'set-marker)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
347 (fset 'eql 'eq)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
348 (fset 'not 'null)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
349 (fset 'rplaca 'setcar)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
350 (fset 'rplacd 'setcdr)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
351 (fset 'beep 'ding) ;preserve lingual purtity
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
352 (fset 'indent-to-column 'indent-to)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
353 (fset 'backward-delete-char 'delete-backward-char)
353
38d331b3a0b8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 293
diff changeset
354 (fset 'search-forward-regexp (symbol-function 're-search-forward))
38d331b3a0b8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 293
diff changeset
355 (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
356
87f63305319f * subr.el (string-to-int): Make this an alias for
Jim Blandy <jimb@redhat.com>
parents: 1867
diff changeset
357 ;;; 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
358 ;;; 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
359 (fset 'string-to-int 'string-to-number)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
360
388
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
361 ;;; global-map, esc-map, and ctl-x-map have their values set up
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
362 ;;; in keymap.c.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
363 (defvar global-map nil
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
364 "Default global keymap mapping Emacs keyboard input into commands.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
365 The value is a keymap which is usually (but not necessarily) Emacs's
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
366 global map.")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
367
388
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
368 (defvar esc-map nil
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
369 "Default keymap for ESC (meta) commands.
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
370 The normal global definition of the character ESC indirects to this keymap.")
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
371
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
372 (defvar ctl-x-map nil
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
373 "Default keymap for C-x commands.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
374 The normal global definition of the character C-x indirects to this keymap.")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
375
388
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
376 (defvar ctl-x-4-map (make-sparse-keymap)
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
377 "Keymap for subcommands of C-x 4")
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
378 (fset 'ctl-x-4-prefix ctl-x-4-map)
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
379 (define-key ctl-x-map "4" 'ctl-x-4-prefix)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
380
707
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
381 (defvar ctl-x-5-map (make-sparse-keymap)
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 707
diff changeset
382 "Keymap for frame commands.")
707
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
383 (fset 'ctl-x-5-prefix ctl-x-5-map)
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 675
diff changeset
384 (define-key ctl-x-map "5" 'ctl-x-5-prefix)
388
498bcec1cf3a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 384
diff changeset
385
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
386
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
387 (defun run-hooks (&rest hooklist)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
388 "Takes hook names and runs each one in turn. Major mode functions use this.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
389 Each argument should be a symbol, a hook variable.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
390 These symbols are processed in the order specified.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
391 If a hook symbol has a non-nil value, that value may be a function
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
392 or a list of functions to be called to run the hook.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
393 If the value is a function, it is called with no arguments.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
394 If it is a list, the elements are called, in order, with no arguments."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
395 (while hooklist
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
396 (let ((sym (car hooklist)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
397 (and (boundp sym)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
398 (symbol-value sym)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
399 (let ((value (symbol-value sym)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
400 (if (and (listp value) (not (eq (car value) 'lambda)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
401 (mapcar 'funcall value)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
402 (funcall value)))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
403 (setq hooklist (cdr hooklist))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
404
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
405 ;; Tell C code how to call this function.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
406 (defconst run-hooks 'run-hooks
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
407 "Variable by which C primitives find the function `run-hooks'.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
408 Don't change it.")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
409
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
410 (defun add-hook (hook function)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
411 "Add to the value of HOOK the function FUNCTION unless already present.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
412 HOOK should be a symbol, and FUNCTION may be any valid function.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
413 HOOK's value should be a list of functions, not a single function.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
414 If HOOK is void, it is first set to nil."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
415 (or (boundp hook) (set hook nil))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
416 (or (if (consp function)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
417 ;; Clever way to tell whether a given lambda-expression
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
418 ;; is equal to anything in the hook.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
419 (let ((tail (assoc (cdr function) (symbol-value hook))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
420 (equal function tail))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
421 (memq function (symbol-value hook)))
384
9dab5ca1890f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 353
diff changeset
422 (set hook (cons function (symbol-value hook)))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
423
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
424 (defun momentary-string-display (string pos &optional exit-char message)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
425 "Momentarily display STRING in the buffer at POS.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
426 Display remains until next character is typed.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
427 If the char is EXIT-CHAR (optional third arg, default is SPC) it is swallowed;
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
428 otherwise it is then available as input (as a command if nothing else).
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
429 Display MESSAGE (optional fourth arg) in the echo area.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
430 If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
431 (or exit-char (setq exit-char ?\ ))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
432 (let ((buffer-read-only nil)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
433 (modified (buffer-modified-p))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
434 (name buffer-file-name)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
435 insert-end)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
436 (unwind-protect
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
437 (progn
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
438 (save-excursion
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
439 (goto-char pos)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
440 ;; defeat file locking... don't try this at home, kids!
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
441 (setq buffer-file-name nil)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
442 (insert-before-markers string)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
443 (setq insert-end (point)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
444 (message (or message "Type %s to continue editing.")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
445 (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
446 (let ((char (read-event)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
447 (or (eq char exit-char)
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1695
diff changeset
448 (setq unread-command-events (list char)))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
449 (if insert-end
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
450 (save-excursion
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
451 (delete-region pos insert-end)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
452 (setq buffer-file-name name)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
453 (set-buffer-modified-p modified))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
454
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
455 (defun start-process-shell-command (name buffer &rest args)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
456 "Start a program in a subprocess. Return the process object for it.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
457 Args are NAME BUFFER COMMAND &rest COMMAND-ARGS.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
458 NAME is name for process. It is modified if necessary to make it unique.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
459 BUFFER is the buffer or (buffer-name) to associate with the process.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
460 Process output goes at end of that buffer, unless you specify
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
461 an output stream or filter function to handle the output.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
462 BUFFER may be also nil, meaning that this process is not associated
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
463 with any buffer
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
464 Third arg is command name, the name of a shell command.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
465 Remaining arguments are the arguments for the command.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
466 Wildcards and redirection are handle as usual in the shell."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
467 (if (eq system-type 'vax-vms)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
468 (apply 'start-process name buffer args)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
469 (start-process name buffer shell-file-name "-c"
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
470 (concat "exec " (mapconcat 'identity args " ")))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
471
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
472 (defun eval-after-load (file form)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
473 "Arrange that, if FILE is ever loaded, FORM will be run at that time.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
474 This makes or adds to an entry on `after-load-alist'.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
475 FILE should be the name of a library, with no directory name."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
476 (or (assoc file after-load-alist)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
477 (setq after-load-alist (cons (list file) after-load-alist)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
478 (nconc (assoc file after-load-alist) (list form))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
479 form)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
480
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
481 (defun eval-next-after-load (file)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
482 "Read the following input sexp, and run it whenever FILE is loaded.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
483 This makes or adds to an entry on `after-load-alist'.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
484 FILE should be the name of a library, with no directory name."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
485 (eval-after-load file (read)))
144
535ec1aa78ef *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 114
diff changeset
486
861
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 840
diff changeset
487 ;;(defmacro defun-inline (name args &rest body)
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 840
diff changeset
488 ;; "Create an \"inline defun\" (actually a macro).
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 840
diff changeset
489 ;;Use just like `defun'."
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 840
diff changeset
490 ;; (nconc (list 'defmacro name '(&rest args))
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 840
diff changeset
491 ;; (if (stringp (car body))
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 840
diff changeset
492 ;; (prog1 (list (car body))
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 840
diff changeset
493 ;; (setq body (or (cdr body) body))))
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 840
diff changeset
494 ;; (list (list 'cons (list 'quote
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 840
diff changeset
495 ;; (cons 'lambda (cons args body)))
345296f94a1e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 840
diff changeset
496 ;; 'args))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
497
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
498 (defun user-original-login-name ()
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
499 "Return user's login name from original login.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
500 This tries to remain unaffected by `su', by looking in environment variables."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
501 (or (getenv "LOGNAME") (getenv "USER") (user-login-name)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
502
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
503 (defun force-mode-line-update (&optional all)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
504 "Force the mode-line of the current buffer to be redisplayed.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
505 With optional non-nil ALL then force then force redisplay of all mode-lines."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
506 (if all (save-excursion (set-buffer (other-buffer))))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
507 (set-buffer-modified-p (buffer-modified-p)))
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
508
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
509 (defun keyboard-translate (from to)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
510 "Translate character FROM to TO at a low level.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
511 This function creates a `keyboard-translate-table' if necessary
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
512 and then modifies one entry in it."
1112
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
513 (or (arrayp keyboard-translate-table)
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
514 (setq keyboard-translate-table ""))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
515 (if (or (> from (length keyboard-translate-table))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
516 (> to (length keyboard-translate-table)))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
517 (progn
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
518 (let* ((i (length keyboard-translate-table))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
519 (table (make-string (- 256 i) 0)))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
520 (while (< i 256)
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
521 (aset table i i)
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
522 (setq i (1+ i)))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 861
diff changeset
523 (setq keyboard-translate-table table))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
524 (aset keyboard-translate-table from to))
648
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 388
diff changeset
525
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 388
diff changeset
526
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 388
diff changeset
527 (defmacro lambda (&rest cdr)
1634
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
528 "Return a lambda expression.
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
529 A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
530 self-quoting; the result of evaluating the lambda expression is the
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
531 expression itself. The lambda expression may then be treated as a
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
532 function, i. e. stored as the function value of a symbol, passed to
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
533 funcall or mapcar, etcetera.
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
534 ARGS should take the same form as an argument list for a `defun'.
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
535 DOCSTRING should be a string, as described for `defun'. It may be omitted.
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
536 INTERACTIVE should be a call to the function `interactive', which see.
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
537 It may also be omitted.
dc26bbe7cf61 * subr.el (lambda): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1622
diff changeset
538 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
539 ;; 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
540 ;; 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
541 (list 'function (cons 'lambda cdr)))
787
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
542
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
543 ;;; subr.el ends here