Mercurial > emacs
annotate lisp/subr.el @ 53593:39793eabee87
(declare): New macro.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Fri, 16 Jan 2004 01:07:46 +0000 |
parents | 21599196e26a |
children | ee432d9e3bbd |
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 |
49311 | 3 ;; Copyright (C) 1985, 86, 92, 94, 95, 99, 2000, 2001, 2002, 2003 |
36094
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
114 | 5 |
45078 | 6 ;; Maintainer: FSF |
7 ;; Keywords: internal | |
8 | |
114 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
707 | 13 ;; the Free Software Foundation; either version 2, or (at your option) |
114 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
114 | 25 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37070
diff
changeset
|
26 ;;; Commentary: |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37070
diff
changeset
|
27 |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
28 ;;; Code: |
18880
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
29 (defvar custom-declare-variable-list nil |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
30 "Record `defcustom' calls made before `custom.el' is loaded to handle them. |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
31 Each element of this list holds the arguments to one call to `defcustom'.") |
114 | 32 |
19662 | 33 ;; Use this, rather than defcustom, in subr.el and other files loaded |
18880
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
34 ;; before custom.el. |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
35 (defun custom-declare-variable-early (&rest arguments) |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
36 (setq custom-declare-variable-list |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
37 (cons arguments custom-declare-variable-list))) |
44129
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
38 |
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
39 |
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
40 (defun macro-declaration-function (macro decl) |
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
41 "Process a declaration found in a macro definition. |
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
42 This is set as the value of the variable `macro-declaration-function'. |
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
43 MACRO is the name of the macro being defined. |
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
44 DECL is a list `(declare ...)' containing the declarations. |
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
45 The return value of this function is not used." |
51062
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
46 ;; We can't use `dolist' or `cadr' yet for bootstrapping reasons. |
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
47 (let (d) |
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
48 ;; Ignore the first element of `decl' (it's always `declare'). |
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
49 (while (setq decl (cdr decl)) |
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
50 (setq d (car decl)) |
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
51 (cond ((and (consp d) (eq (car d) 'indent)) |
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
52 (put macro 'lisp-indent-function (car (cdr d)))) |
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
53 ((and (consp d) (eq (car d) 'debug)) |
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
54 (put macro 'edebug-form-spec (car (cdr d)))) |
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
55 (t |
e562b94e5f9e
(macro-declaration-function): Avoid `dolist' and `cadr'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51051
diff
changeset
|
56 (message "Unknown declaration %s" d)))))) |
44129
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
57 |
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
58 (setq macro-declaration-function 'macro-declaration-function) |
444bd245e176
(macro-declaration-function): New function. Set the
Gerd Moellmann <gerd@gnu.org>
parents:
43833
diff
changeset
|
59 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
60 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
61 ;;;; Lisp language features. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
62 |
40822
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
63 (defalias 'not 'null) |
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
64 |
53197
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
65 (defmacro noreturn (form) |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
66 "Evaluates FORM, with the expectation that the evaluation will signal an error |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
67 instead of returning to its caller. If FORM does return, an error is |
53593 | 68 signalled." |
53197
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
69 `(prog1 ,form |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
70 (error "Form marked with `noreturn' did return"))) |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
71 |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
72 (defmacro 1value (form) |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
73 "Evaluates FORM, with the expectation that all the same value will be returned |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
74 from all evaluations of FORM. This is the global do-nothing |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
75 version of `1value'. There is also `testcover-1value' that |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
76 complains if FORM ever does return differing values." |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
77 form) |
61703d3393d6
Add macros `1value' and `noreturn'.
Jonathan Yavner <jyavner@member.fsf.org>
parents:
53181
diff
changeset
|
78 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
79 (defmacro lambda (&rest cdr) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
80 "Return a lambda expression. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
81 A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
82 self-quoting; the result of evaluating the lambda expression is the |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
83 expression itself. The lambda expression may then be treated as a |
10178 | 84 function, i.e., stored as the function value of a symbol, passed to |
85 funcall or mapcar, etc. | |
86 | |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
87 ARGS should take the same form as an argument list for a `defun'. |
12395 | 88 DOCSTRING is an optional documentation string. |
89 If present, it should describe how to call the function. | |
90 But documentation strings are usually not useful in nameless functions. | |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
91 INTERACTIVE should be a call to the function `interactive', which see. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
92 It may also be omitted. |
49363 | 93 BODY should be a list of Lisp expressions." |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
94 ;; Note that this definition should not use backquotes; subr.el should not |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
95 ;; depend on backquote.el. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
96 (list 'function (cons 'lambda cdr))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
97 |
25437 | 98 (defmacro push (newelt listname) |
25580 | 99 "Add NEWELT to the list stored in the symbol LISTNAME. |
25437 | 100 This is equivalent to (setq LISTNAME (cons NEWELT LISTNAME)). |
25436
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
101 LISTNAME must be a symbol." |
51611
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
102 (declare (debug (form sexp))) |
25469 | 103 (list 'setq listname |
104 (list 'cons newelt listname))) | |
25436
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
105 |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
106 (defmacro pop (listname) |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
107 "Return the first element of LISTNAME's value, and remove it from the list. |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
108 LISTNAME must be a symbol whose value is a list. |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
109 If the value is nil, `pop' returns nil but does not actually |
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
110 change the list." |
51611
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
111 (declare (debug (sexp))) |
45823
7ec7fff5e571
(pop): Move the call to `car' outside the prog1, as the compiler
Miles Bader <miles@gnu.org>
parents:
45821
diff
changeset
|
112 (list 'car |
7ec7fff5e571
(pop): Move the call to `car' outside the prog1, as the compiler
Miles Bader <miles@gnu.org>
parents:
45821
diff
changeset
|
113 (list 'prog1 listname |
7ec7fff5e571
(pop): Move the call to `car' outside the prog1, as the compiler
Miles Bader <miles@gnu.org>
parents:
45821
diff
changeset
|
114 (list 'setq listname (list 'cdr listname))))) |
25436
d24cf1a4dd34
(push, pop): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
25295
diff
changeset
|
115 |
16845
adc714dc8e3c
(when, unless): Definitions moved from cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
16556
diff
changeset
|
116 (defmacro when (cond &rest body) |
27810
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
117 "If COND yields non-nil, do BODY, else return nil." |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
118 (declare (indent 1) (debug t)) |
16845
adc714dc8e3c
(when, unless): Definitions moved from cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
16556
diff
changeset
|
119 (list 'if cond (cons 'progn body))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
120 |
16845
adc714dc8e3c
(when, unless): Definitions moved from cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
16556
diff
changeset
|
121 (defmacro unless (cond &rest body) |
27810
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
122 "If COND yields nil, do BODY, else return nil." |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
123 (declare (indent 1) (debug t)) |
16845
adc714dc8e3c
(when, unless): Definitions moved from cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
16556
diff
changeset
|
124 (cons 'if (cons cond (cons nil body)))) |
19491
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
125 |
27376
674b7f75841e
(dolist, dotimes): Moved from cl-macs.el.
Richard M. Stallman <rms@gnu.org>
parents:
27297
diff
changeset
|
126 (defmacro dolist (spec &rest body) |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
127 "Loop over a list. |
27376
674b7f75841e
(dolist, dotimes): Moved from cl-macs.el.
Richard M. Stallman <rms@gnu.org>
parents:
27297
diff
changeset
|
128 Evaluate BODY with VAR bound to each car from LIST, in turn. |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
129 Then evaluate RESULT to get return value, default nil. |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
130 |
51817
5e9d88e4fcff
(dolist, dotimes): Doc fix.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
51695
diff
changeset
|
131 \(fn (VAR LIST [RESULT]) BODY...)" |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
132 (declare (indent 1) (debug ((symbolp form &optional form) body))) |
27383
b1b3e778f7ac
Make the definitions of dolist and dotimes work
Richard M. Stallman <rms@gnu.org>
parents:
27376
diff
changeset
|
133 (let ((temp (make-symbol "--dolist-temp--"))) |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
134 `(let ((,temp ,(nth 1 spec)) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
135 ,(car spec)) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
136 (while ,temp |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
137 (setq ,(car spec) (car ,temp)) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
138 (setq ,temp (cdr ,temp)) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
139 ,@body) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
140 ,@(if (cdr (cdr spec)) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
141 `((setq ,(car spec) nil) ,@(cdr (cdr spec))))))) |
27376
674b7f75841e
(dolist, dotimes): Moved from cl-macs.el.
Richard M. Stallman <rms@gnu.org>
parents:
27297
diff
changeset
|
142 |
674b7f75841e
(dolist, dotimes): Moved from cl-macs.el.
Richard M. Stallman <rms@gnu.org>
parents:
27297
diff
changeset
|
143 (defmacro dotimes (spec &rest body) |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
144 "Loop a certain number of times. |
27376
674b7f75841e
(dolist, dotimes): Moved from cl-macs.el.
Richard M. Stallman <rms@gnu.org>
parents:
27297
diff
changeset
|
145 Evaluate BODY with VAR bound to successive integers running from 0, |
674b7f75841e
(dolist, dotimes): Moved from cl-macs.el.
Richard M. Stallman <rms@gnu.org>
parents:
27297
diff
changeset
|
146 inclusive, to COUNT, exclusive. Then evaluate RESULT to get |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
147 the return value (nil if RESULT is omitted). |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
148 |
51817
5e9d88e4fcff
(dolist, dotimes): Doc fix.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
51695
diff
changeset
|
149 \(fn (VAR COUNT [RESULT]) BODY...)" |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
150 (declare (indent 1) (debug dolist)) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
151 (let ((temp (make-symbol "--dotimes-temp--")) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
152 (start 0) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
153 (end (nth 1 spec))) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
154 `(let ((,temp ,end) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
155 (,(car spec) ,start)) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
156 (while (< ,(car spec) ,temp) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
157 ,@body |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
158 (setq ,(car spec) (1+ ,(car spec)))) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
159 ,@(cdr (cdr spec))))) |
27376
674b7f75841e
(dolist, dotimes): Moved from cl-macs.el.
Richard M. Stallman <rms@gnu.org>
parents:
27297
diff
changeset
|
160 |
53593 | 161 (defmacro declare (&rest specs) |
162 "Do not evaluate any arguments and return nil. | |
163 Treated as a declaration when used at the right place in a | |
164 `defmacro' form. \(See Info anchor `(elisp)Definition of declare'." | |
165 nil) | |
166 | |
19491
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
167 (defsubst caar (x) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
168 "Return the car of the car of X." |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
169 (car (car x))) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
170 |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
171 (defsubst cadr (x) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
172 "Return the car of the cdr of X." |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
173 (car (cdr x))) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
174 |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
175 (defsubst cdar (x) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
176 "Return the cdr of the car of X." |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
177 (cdr (car x))) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
178 |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
179 (defsubst cddr (x) |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
180 "Return the cdr of the cdr of X." |
f5fd22f3462c
(caar, cadr, cdar, cddr): Definitions moved here and changed into defsubsts.
Richard M. Stallman <rms@gnu.org>
parents:
19176
diff
changeset
|
181 (cdr (cdr x))) |
19492 | 182 |
19584
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
183 (defun last (x &optional n) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
184 "Return the last link of the list X. Its car is the last element. |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
185 If X is nil, return nil. |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
186 If N is non-nil, return the Nth-to-last link of X. |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
187 If N is bigger than the length of X, return X." |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
188 (if n |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
189 (let ((m 0) (p x)) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
190 (while (consp p) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
191 (setq m (1+ m) p (cdr p))) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
192 (if (<= n 0) p |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
193 (if (< n m) (nthcdr (- m n) x) x))) |
35281
be18bd846968
(last): Handle a list that doesn't end in nil.
Richard M. Stallman <rms@gnu.org>
parents:
35231
diff
changeset
|
194 (while (consp (cdr x)) |
19584
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
195 (setq x (cdr x))) |
17db1ee36bbb
(last): Accept optional second argument.
Richard M. Stallman <rms@gnu.org>
parents:
19492
diff
changeset
|
196 x)) |
22860
349fa4ee1f27
(assoc-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22755
diff
changeset
|
197 |
34898
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
198 (defun butlast (x &optional n) |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
199 "Returns a copy of LIST with the last N elements removed." |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
200 (if (and n (<= n 0)) x |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
201 (nbutlast (copy-sequence x) n))) |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
202 |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
203 (defun nbutlast (x &optional n) |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
204 "Modifies LIST to remove the last N elements." |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
205 (let ((m (length x))) |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
206 (or n (setq n 1)) |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
207 (and (< n m) |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
208 (progn |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
209 (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil)) |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
210 x)))) |
1486728b21f0
(butlast, nbutlast): Moved from cl.el to here.
Kenichi Handa <handa@m17n.org>
parents:
34853
diff
changeset
|
211 |
50449
f85be9da34a2
Adjust number-sequence code
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
50427
diff
changeset
|
212 (defun number-sequence (from &optional to inc) |
50415
b040b4e36f5e
(number-sequence): New function.
Kenichi Handa <handa@m17n.org>
parents:
50136
diff
changeset
|
213 "Return a sequence of numbers from FROM to TO (both inclusive) as a list. |
53174
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
214 INC is the increment used between numbers in the sequence and defaults to 1. |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
215 So, the Nth element of the list is \(+ FROM \(* N INC)) where N counts from |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
216 zero. TO is only included if there is an N for which TO = FROM + N * INC. |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
217 If TO is nil or numerically equal to FROM, return \(FROM). |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
218 If INC is positive and TO is less than FROM, or INC is negative |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
219 and TO is larger than FROM, return nil. |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
220 If INC is zero and TO is neither nil nor numerically equal to |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
221 FROM, signal an error. |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
222 |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
223 This function is primarily designed for integer arguments. |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
224 Nevertheless, FROM, TO and INC can be integer or float. However, |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
225 floating point arithmetic is inexact. For instance, depending on |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
226 the machine, it may quite well happen that |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
227 \(number-sequence 0.4 0.6 0.2) returns the one element list \(0.4), |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
228 whereas \(number-sequence 0.4 0.8 0.2) returns a list with three |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
229 elements. Thus, if some of the arguments are floats and one wants |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
230 to make sure that TO is included, one may have to explicitly write |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
231 TO as \(+ FROM \(* N INC)) or use a variable whose value was |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
232 computed with this exact expression. Alternatively, you can, |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
233 of course, also replace TO with a slightly larger value |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
234 \(or a slightly more negative value if INC is negative)." |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
235 (if (or (not to) (= from to)) |
50449
f85be9da34a2
Adjust number-sequence code
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
50427
diff
changeset
|
236 (list from) |
f85be9da34a2
Adjust number-sequence code
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
50427
diff
changeset
|
237 (or inc (setq inc 1)) |
53174
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
238 (when (zerop inc) (error "The increment can not be zero")) |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
239 (let (seq (n 0) (next from)) |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
240 (if (> inc 0) |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
241 (while (<= next to) |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
242 (setq seq (cons next seq) |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
243 n (1+ n) |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
244 next (+ from (* n inc)))) |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
245 (while (>= next to) |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
246 (setq seq (cons next seq) |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
247 n (1+ n) |
5f50db6e04c6
(number-sequence): Improve handling of floating point arguments
Luc Teirlinck <teirllm@auburn.edu>
parents:
53132
diff
changeset
|
248 next (+ from (* n inc))))) |
50449
f85be9da34a2
Adjust number-sequence code
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
50427
diff
changeset
|
249 (nreverse seq)))) |
50415
b040b4e36f5e
(number-sequence): New function.
Kenichi Handa <handa@m17n.org>
parents:
50136
diff
changeset
|
250 |
30515
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
251 (defun remove (elt seq) |
42941 | 252 "Return a copy of SEQ with all occurrences of ELT removed. |
30515
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
253 SEQ must be a list, vector, or string. The comparison is done with `equal'." |
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
254 (if (nlistp seq) |
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
255 ;; If SEQ isn't a list, there's no need to copy SEQ because |
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
256 ;; `delete' will return a new object. |
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
257 (delete elt seq) |
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
258 (delete elt (copy-sequence seq)))) |
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
259 |
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
260 (defun remq (elt list) |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
261 "Return LIST with all occurrences of ELT removed. |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
262 The comparison is done with `eq'. Contrary to `delq', this does not use |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
263 side-effects, and the argument LIST is not modified." |
30515
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
264 (if (memq elt list) |
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
265 (delq elt (copy-sequence list)) |
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
266 list)) |
6165183bc490
(remove, remq): New functions.
Gerd Moellmann <gerd@gnu.org>
parents:
29354
diff
changeset
|
267 |
45690
9d351e5869c8
(copy-list): Moved here from cl.el.
Colin Walters <walters@gnu.org>
parents:
45587
diff
changeset
|
268 (defun copy-tree (tree &optional vecp) |
9d351e5869c8
(copy-list): Moved here from cl.el.
Colin Walters <walters@gnu.org>
parents:
45587
diff
changeset
|
269 "Make a copy of TREE. |
9d351e5869c8
(copy-list): Moved here from cl.el.
Colin Walters <walters@gnu.org>
parents:
45587
diff
changeset
|
270 If TREE is a cons cell, this recursively copies both its car and its cdr. |
45740
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
271 Contrast to `copy-sequence', which copies only along the cdrs. With second |
45690
9d351e5869c8
(copy-list): Moved here from cl.el.
Colin Walters <walters@gnu.org>
parents:
45587
diff
changeset
|
272 argument VECP, this copies vectors as well as conses." |
9d351e5869c8
(copy-list): Moved here from cl.el.
Colin Walters <walters@gnu.org>
parents:
45587
diff
changeset
|
273 (if (consp tree) |
45740
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
274 (let (result) |
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
275 (while (consp tree) |
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
276 (let ((newcar (car tree))) |
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
277 (if (or (consp (car tree)) (and vecp (vectorp (car tree)))) |
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
278 (setq newcar (copy-tree (car tree) vecp))) |
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
279 (push newcar result)) |
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
280 (setq tree (cdr tree))) |
45821
41129d3d126b
(copy-tree): Use `nconc' and `nreverse' instead of `nreconc'.
Miles Bader <miles@gnu.org>
parents:
45740
diff
changeset
|
281 (nconc (nreverse result) tree)) |
45690
9d351e5869c8
(copy-list): Moved here from cl.el.
Colin Walters <walters@gnu.org>
parents:
45587
diff
changeset
|
282 (if (and vecp (vectorp tree)) |
9d351e5869c8
(copy-list): Moved here from cl.el.
Colin Walters <walters@gnu.org>
parents:
45587
diff
changeset
|
283 (let ((i (length (setq tree (copy-sequence tree))))) |
9d351e5869c8
(copy-list): Moved here from cl.el.
Colin Walters <walters@gnu.org>
parents:
45587
diff
changeset
|
284 (while (>= (setq i (1- i)) 0) |
45740
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
285 (aset tree i (copy-tree (aref tree i) vecp))) |
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
286 tree) |
4e576724db9f
(copy-list): Moved to cl.el.
Richard M. Stallman <rms@gnu.org>
parents:
45690
diff
changeset
|
287 tree))) |
45690
9d351e5869c8
(copy-list): Moved here from cl.el.
Colin Walters <walters@gnu.org>
parents:
45587
diff
changeset
|
288 |
22959
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
289 (defun assoc-default (key alist &optional test default) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
290 "Find object KEY in a pseudo-alist ALIST. |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
291 ALIST is a list of conses or objects. Each element (or the element's car, |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
292 if it is a cons) is compared with KEY by evaluating (TEST (car elt) KEY). |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
293 If that is non-nil, the element matches; |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
294 then `assoc-default' returns the element's cdr, if it is a cons, |
22860
349fa4ee1f27
(assoc-default): New function.
Richard M. Stallman <rms@gnu.org>
parents:
22755
diff
changeset
|
295 or DEFAULT if the element is not a cons. |
22959
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
296 |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
297 If no element matches, the value is nil. |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
298 If TEST is omitted or nil, `equal' is used." |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
299 (let (found (tail alist) value) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
300 (while (and tail (not found)) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
301 (let ((elt (car tail))) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
302 (when (funcall (or test 'equal) (if (consp elt) (car elt) elt) key) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
303 (setq found t value (if (consp elt) (cdr elt) default)))) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
304 (setq tail (cdr tail))) |
73a21b5f9bd8
(assoc-default): Rewrite not to use dolist.
Richard M. Stallman <rms@gnu.org>
parents:
22860
diff
changeset
|
305 value)) |
25295
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
306 |
53412
a2bba9e88b95
(assoc-ignore-case, assoc-ignore-representation):
Richard M. Stallman <rms@gnu.org>
parents:
53368
diff
changeset
|
307 (make-obsolete 'assoc-ignore-case 'assoc-string) |
25295
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
308 (defun assoc-ignore-case (key alist) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
309 "Like `assoc', but ignores differences in case and text representation. |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
310 KEY must be a string. Upper-case and lower-case letters are treated as equal. |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
311 Unibyte strings are converted to multibyte for comparison." |
53412
a2bba9e88b95
(assoc-ignore-case, assoc-ignore-representation):
Richard M. Stallman <rms@gnu.org>
parents:
53368
diff
changeset
|
312 (assoc-string key alist t)) |
25295
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
313 |
53412
a2bba9e88b95
(assoc-ignore-case, assoc-ignore-representation):
Richard M. Stallman <rms@gnu.org>
parents:
53368
diff
changeset
|
314 (make-obsolete 'assoc-ignore-representation 'assoc-string) |
25295
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
315 (defun assoc-ignore-representation (key alist) |
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
316 "Like `assoc', but ignores differences in text representation. |
47916 | 317 KEY must be a string. |
25295
737e82c21934
(assoc-ignore-case, assoc-ignore-representation): Moved here from simple.el.
Karl Heuer <kwzh@gnu.org>
parents:
25293
diff
changeset
|
318 Unibyte strings are converted to multibyte for comparison." |
53412
a2bba9e88b95
(assoc-ignore-case, assoc-ignore-representation):
Richard M. Stallman <rms@gnu.org>
parents:
53368
diff
changeset
|
319 (assoc-string key alist nil)) |
28490
9958b6d95bd6
(member-ignore-case): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28234
diff
changeset
|
320 |
9958b6d95bd6
(member-ignore-case): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28234
diff
changeset
|
321 (defun member-ignore-case (elt list) |
9958b6d95bd6
(member-ignore-case): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28234
diff
changeset
|
322 "Like `member', but ignores differences in case and text representation. |
9958b6d95bd6
(member-ignore-case): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28234
diff
changeset
|
323 ELT must be a string. Upper-case and lower-case letters are treated as equal. |
44900
e4975d9c93ff
(insert-for-yank): Replace `category' property
Richard M. Stallman <rms@gnu.org>
parents:
44723
diff
changeset
|
324 Unibyte strings are converted to multibyte for comparison. |
e4975d9c93ff
(insert-for-yank): Replace `category' property
Richard M. Stallman <rms@gnu.org>
parents:
44723
diff
changeset
|
325 Non-strings in LIST are ignored." |
e4975d9c93ff
(insert-for-yank): Replace `category' property
Richard M. Stallman <rms@gnu.org>
parents:
44723
diff
changeset
|
326 (while (and list |
e4975d9c93ff
(insert-for-yank): Replace `category' property
Richard M. Stallman <rms@gnu.org>
parents:
44723
diff
changeset
|
327 (not (and (stringp (car list)) |
e4975d9c93ff
(insert-for-yank): Replace `category' property
Richard M. Stallman <rms@gnu.org>
parents:
44723
diff
changeset
|
328 (eq t (compare-strings elt 0 nil (car list) 0 nil t))))) |
33978
9aa3fd6779f7
(member-ignore-case): Return the tail of the list who's car matches,
Miles Bader <miles@gnu.org>
parents:
33835
diff
changeset
|
329 (setq list (cdr list))) |
9aa3fd6779f7
(member-ignore-case): Return the tail of the list who's car matches,
Miles Bader <miles@gnu.org>
parents:
33835
diff
changeset
|
330 list) |
28490
9958b6d95bd6
(member-ignore-case): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28234
diff
changeset
|
331 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
332 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
333 ;;;; Keymap support. |
114 | 334 |
335 (defun undefined () | |
336 (interactive) | |
337 (ding)) | |
338 | |
339 ;Prevent the \{...} documentation construct | |
340 ;from mentioning keys that run this command. | |
341 (put 'undefined 'suppress-keymap t) | |
342 | |
343 (defun suppress-keymap (map &optional nodigits) | |
344 "Make MAP override all normally self-inserting keys to be undefined. | |
345 Normally, as an exception, digits and minus-sign are set to make prefix args, | |
346 but optional second arg NODIGITS non-nil treats them like other chars." | |
47042
74f8b41068e0
(suppress-keymap): Use command remapping instead of
Kim F. Storm <storm@cua.dk>
parents:
47025
diff
changeset
|
347 (define-key map [remap self-insert-command] 'undefined) |
114 | 348 (or nodigits |
349 (let (loop) | |
350 (define-key map "-" 'negative-argument) | |
351 ;; Make plain numbers do numeric args. | |
352 (setq loop ?0) | |
353 (while (<= loop ?9) | |
354 (define-key map (char-to-string loop) 'digit-argument) | |
355 (setq loop (1+ loop)))))) | |
356 | |
357 ;Moved to keymap.c | |
358 ;(defun copy-keymap (keymap) | |
47916 | 359 ; "Return a copy of KEYMAP" |
114 | 360 ; (while (not (keymapp keymap)) |
361 ; (setq keymap (signal 'wrong-type-argument (list 'keymapp keymap)))) | |
362 ; (if (vectorp keymap) | |
363 ; (copy-sequence keymap) | |
364 ; (copy-alist keymap))) | |
365 | |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
366 (defvar key-substitution-in-progress nil |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
367 "Used internally by substitute-key-definition.") |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
368 |
1176 | 369 (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix) |
114 | 370 "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF. |
371 In other words, OLDDEF is replaced with NEWDEF where ever it appears. | |
28811
8a7623ffeeac
(substitute-key-definition): Clarify documentation.
Gerd Moellmann <gerd@gnu.org>
parents:
28794
diff
changeset
|
372 Alternatively, if optional fourth argument OLDMAP is specified, we redefine |
32131
3a54b3a6bf40
(substitute-key-definition): Doc fix.
Dave Love <fx@gnu.org>
parents:
31979
diff
changeset
|
373 in KEYMAP as NEWDEF those keys which are defined as OLDDEF in OLDMAP." |
28868
e62636f5d724
(substitute-key-definition): Add comment describing
Gerd Moellmann <gerd@gnu.org>
parents:
28863
diff
changeset
|
374 ;; Don't document PREFIX in the doc string because we don't want to |
e62636f5d724
(substitute-key-definition): Add comment describing
Gerd Moellmann <gerd@gnu.org>
parents:
28863
diff
changeset
|
375 ;; advertise it. It's meant for recursive calls only. Here's its |
e62636f5d724
(substitute-key-definition): Add comment describing
Gerd Moellmann <gerd@gnu.org>
parents:
28863
diff
changeset
|
376 ;; meaning |
47916 | 377 |
28868
e62636f5d724
(substitute-key-definition): Add comment describing
Gerd Moellmann <gerd@gnu.org>
parents:
28863
diff
changeset
|
378 ;; If optional argument PREFIX is specified, it should be a key |
e62636f5d724
(substitute-key-definition): Add comment describing
Gerd Moellmann <gerd@gnu.org>
parents:
28863
diff
changeset
|
379 ;; prefix, a string. Redefined bindings will then be bound to the |
e62636f5d724
(substitute-key-definition): Add comment describing
Gerd Moellmann <gerd@gnu.org>
parents:
28863
diff
changeset
|
380 ;; original key, with PREFIX added at the front. |
1176 | 381 (or prefix (setq prefix "")) |
382 (let* ((scan (or oldmap keymap)) | |
383 (vec1 (vector nil)) | |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
384 (prefix1 (vconcat prefix vec1)) |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
385 (key-substitution-in-progress |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
386 (cons scan key-substitution-in-progress))) |
1176 | 387 ;; Scan OLDMAP, finding each char or event-symbol that |
388 ;; has any definition, and act on it with hack-key. | |
389 (while (consp scan) | |
390 (if (consp (car scan)) | |
391 (let ((char (car (car scan))) | |
392 (defn (cdr (car scan)))) | |
393 ;; The inside of this let duplicates exactly | |
394 ;; the inside of the following let that handles array elements. | |
395 (aset vec1 0 char) | |
396 (aset prefix1 (length prefix) char) | |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
397 (let (inner-def skipped) |
1176 | 398 ;; Skip past menu-prompt. |
399 (while (stringp (car-safe defn)) | |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
400 (setq skipped (cons (car defn) skipped)) |
1176 | 401 (setq defn (cdr defn))) |
7615
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
402 ;; Skip past cached key-equivalence data for menu items. |
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
403 (and (consp defn) (consp (car defn)) |
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
404 (setq defn (cdr defn))) |
1176 | 405 (setq inner-def defn) |
7615
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
406 ;; Look past a symbol that names a keymap. |
1176 | 407 (while (and (symbolp inner-def) |
408 (fboundp inner-def)) | |
409 (setq inner-def (symbol-function inner-def))) | |
17215
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
410 (if (or (eq defn olddef) |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
411 ;; Compare with equal if definition is a key sequence. |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
412 ;; That is useful for operating on function-key-map. |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
413 (and (or (stringp defn) (vectorp defn)) |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
414 (equal defn olddef))) |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
415 (define-key keymap prefix1 (nconc (nreverse skipped) newdef)) |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
416 (if (and (keymapp defn) |
9986
df605fcd1e75
(substitute-key-definition): Don't recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
9822
diff
changeset
|
417 ;; Avoid recursively scanning |
df605fcd1e75
(substitute-key-definition): Don't recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
9822
diff
changeset
|
418 ;; where KEYMAP does not have a submap. |
13039
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
419 (let ((elt (lookup-key keymap prefix1))) |
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
420 (or (null elt) |
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
421 (keymapp elt))) |
9986
df605fcd1e75
(substitute-key-definition): Don't recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
9822
diff
changeset
|
422 ;; Avoid recursively rescanning keymap being scanned. |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
423 (not (memq inner-def |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
424 key-substitution-in-progress))) |
7615
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
425 ;; If this one isn't being scanned already, |
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
426 ;; scan it now. |
1176 | 427 (substitute-key-definition olddef newdef keymap |
428 inner-def | |
429 prefix1))))) | |
18044
3e4924d01221
(substitute-key-definition): Check vectorp, not arrayp.
Richard M. Stallman <rms@gnu.org>
parents:
17943
diff
changeset
|
430 (if (vectorp (car scan)) |
1176 | 431 (let* ((array (car scan)) |
432 (len (length array)) | |
433 (i 0)) | |
434 (while (< i len) | |
435 (let ((char i) (defn (aref array i))) | |
436 ;; The inside of this let duplicates exactly | |
437 ;; the inside of the previous let. | |
438 (aset vec1 0 char) | |
439 (aset prefix1 (length prefix) char) | |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
440 (let (inner-def skipped) |
1176 | 441 ;; Skip past menu-prompt. |
442 (while (stringp (car-safe defn)) | |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
443 (setq skipped (cons (car defn) skipped)) |
1176 | 444 (setq defn (cdr defn))) |
7615
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
445 (and (consp defn) (consp (car defn)) |
49176059d040
(substitute-key-definition): Skip cached menu key-equivs.
Richard M. Stallman <rms@gnu.org>
parents:
7548
diff
changeset
|
446 (setq defn (cdr defn))) |
1176 | 447 (setq inner-def defn) |
448 (while (and (symbolp inner-def) | |
449 (fboundp inner-def)) | |
450 (setq inner-def (symbol-function inner-def))) | |
17215
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
451 (if (or (eq defn olddef) |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
452 (and (or (stringp defn) (vectorp defn)) |
21e3f467224e
(substitute-key-definition):
Richard M. Stallman <rms@gnu.org>
parents:
17158
diff
changeset
|
453 (equal defn olddef))) |
6005
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
454 (define-key keymap prefix1 |
bf1c9fd5669b
(substitute-key-definition): Don't discard menu strings.
Richard M. Stallman <rms@gnu.org>
parents:
5912
diff
changeset
|
455 (nconc (nreverse skipped) newdef)) |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
456 (if (and (keymapp defn) |
13039
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
457 (let ((elt (lookup-key keymap prefix1))) |
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
458 (or (null elt) |
04ffbdd37d2d
(substitute-key-definition): Do recursively scan
Richard M. Stallman <rms@gnu.org>
parents:
12730
diff
changeset
|
459 (keymapp elt))) |
6167
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
460 (not (memq inner-def |
1ad8f8ccdc2b
(substitute-key-definition): Avoid infinite recursion.
Karl Heuer <kwzh@gnu.org>
parents:
6039
diff
changeset
|
461 key-substitution-in-progress))) |
1176 | 462 (substitute-key-definition olddef newdef keymap |
463 inner-def | |
464 prefix1))))) | |
17922
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
465 (setq i (1+ i)))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
466 (if (char-table-p (car scan)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
467 (map-char-table |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
468 (function (lambda (char defn) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
469 (let () |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
470 ;; The inside of this let duplicates exactly |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
471 ;; the inside of the previous let, |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
472 ;; except that it uses set-char-table-range |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
473 ;; instead of define-key. |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
474 (aset vec1 0 char) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
475 (aset prefix1 (length prefix) char) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
476 (let (inner-def skipped) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
477 ;; Skip past menu-prompt. |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
478 (while (stringp (car-safe defn)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
479 (setq skipped (cons (car defn) skipped)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
480 (setq defn (cdr defn))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
481 (and (consp defn) (consp (car defn)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
482 (setq defn (cdr defn))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
483 (setq inner-def defn) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
484 (while (and (symbolp inner-def) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
485 (fboundp inner-def)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
486 (setq inner-def (symbol-function inner-def))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
487 (if (or (eq defn olddef) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
488 (and (or (stringp defn) (vectorp defn)) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
489 (equal defn olddef))) |
17943
15dc805eadee
(substitute-key-definition): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
17922
diff
changeset
|
490 (define-key keymap prefix1 |
15dc805eadee
(substitute-key-definition): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
17922
diff
changeset
|
491 (nconc (nreverse skipped) newdef)) |
17922
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
492 (if (and (keymapp defn) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
493 (let ((elt (lookup-key keymap prefix1))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
494 (or (null elt) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
495 (keymapp elt))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
496 (not (memq inner-def |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
497 key-substitution-in-progress))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
498 (substitute-key-definition olddef newdef keymap |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
499 inner-def |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
500 prefix1))))))) |
29d58e05d603
(substitute-key-definition): Handle chartables.
Richard M. Stallman <rms@gnu.org>
parents:
17707
diff
changeset
|
501 (car scan))))) |
1176 | 502 (setq scan (cdr scan))))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
503 |
27821
5ef5616e8304
(define-key-after): Default AFTER to t. Doc fix.
Dave Love <fx@gnu.org>
parents:
27810
diff
changeset
|
504 (defun define-key-after (keymap key definition &optional after) |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
505 "Add binding in KEYMAP for KEY => DEFINITION, right after AFTER's binding. |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
506 This is like `define-key' except that the binding for KEY is placed |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
507 just after the binding for the event AFTER, instead of at the beginning |
16556
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
508 of the map. Note that AFTER must be an event type (like KEY), NOT a command |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
509 \(like DEFINITION). |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
510 |
27821
5ef5616e8304
(define-key-after): Default AFTER to t. Doc fix.
Dave Love <fx@gnu.org>
parents:
27810
diff
changeset
|
511 If AFTER is t or omitted, the new binding goes at the end of the keymap. |
39557
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
512 AFTER should be a single event type--a symbol or a character, not a sequence. |
27821
5ef5616e8304
(define-key-after): Default AFTER to t. Doc fix.
Dave Love <fx@gnu.org>
parents:
27810
diff
changeset
|
513 |
5ef5616e8304
(define-key-after): Default AFTER to t. Doc fix.
Dave Love <fx@gnu.org>
parents:
27810
diff
changeset
|
514 Bindings are always added before any inherited map. |
16556
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
515 |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
516 The order of bindings in a keymap matters when it is used as a menu." |
27821
5ef5616e8304
(define-key-after): Default AFTER to t. Doc fix.
Dave Love <fx@gnu.org>
parents:
27810
diff
changeset
|
517 (unless after (setq after t)) |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
518 (or (keymapp keymap) |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
519 (signal 'wrong-type-argument (list 'keymapp keymap))) |
39557
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
520 (setq key |
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
521 (if (<= (length key) 1) (aref key 0) |
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
522 (setq keymap (lookup-key keymap |
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
523 (apply 'vector |
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
524 (butlast (mapcar 'identity key))))) |
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
525 (aref key (1- (length key))))) |
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
526 (let ((tail keymap) done inserted) |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
527 (while (and (not done) tail) |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
528 ;; Delete any earlier bindings for the same key. |
39557
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
529 (if (eq (car-safe (car (cdr tail))) key) |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
530 (setcdr tail (cdr (cdr tail)))) |
39557
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
531 ;; If we hit an included map, go down that one. |
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
532 (if (keymapp (car tail)) (setq tail (car tail))) |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
533 ;; When we reach AFTER's binding, insert the new binding after. |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
534 ;; If we reach an inherited keymap, insert just before that. |
3927
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
535 ;; If we reach the end of this keymap, insert at the end. |
16556
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
536 (if (or (and (eq (car-safe (car tail)) after) |
3a1df67c6677
(define-key-after): If AFTER is t, always put new binding at the end.
Richard M. Stallman <rms@gnu.org>
parents:
16549
diff
changeset
|
537 (not (eq after t))) |
3927
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
538 (eq (car (cdr tail)) 'keymap) |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
539 (null (cdr tail))) |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
540 (progn |
3927
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
541 ;; Stop the scan only if we find a parent keymap. |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
542 ;; Keep going past the inserted element |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
543 ;; so we can delete any duplications that come later. |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
544 (if (eq (car (cdr tail)) 'keymap) |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
545 (setq done t)) |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
546 ;; Don't insert more than once. |
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
547 (or inserted |
39557
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
548 (setcdr tail (cons (cons key definition) (cdr tail)))) |
3927
1f1fefc400ed
(define-key-after): Delete duplicate bindings that come
Richard M. Stallman <rms@gnu.org>
parents:
3902
diff
changeset
|
549 (setq inserted t))) |
3901
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
550 (setq tail (cdr tail))))) |
c78753b7eea8
(define-key-in-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3860
diff
changeset
|
551 |
44251
3900f65547f0
(play-sound-file): Moved to simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
44158
diff
changeset
|
552 |
17437 | 553 (defmacro kbd (keys) |
554 "Convert KEYS to the internal Emacs key representation. | |
555 KEYS should be a string constant in the format used for | |
556 saving keyboard macros (see `insert-kbd-macro')." | |
557 (read-kbd-macro keys)) | |
558 | |
15894
efd2835a7c96
(keyboard-translate): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
15599
diff
changeset
|
559 (put 'keyboard-translate-table 'char-table-extra-slots 0) |
efd2835a7c96
(keyboard-translate): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
15599
diff
changeset
|
560 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
561 (defun keyboard-translate (from to) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
562 "Translate character FROM to TO at a low level. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
563 This function creates a `keyboard-translate-table' if necessary |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
564 and then modifies one entry in it." |
15894
efd2835a7c96
(keyboard-translate): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
15599
diff
changeset
|
565 (or (char-table-p keyboard-translate-table) |
efd2835a7c96
(keyboard-translate): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
15599
diff
changeset
|
566 (setq keyboard-translate-table |
efd2835a7c96
(keyboard-translate): Use a char-table.
Richard M. Stallman <rms@gnu.org>
parents:
15599
diff
changeset
|
567 (make-char-table 'keyboard-translate-table nil))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
568 (aset keyboard-translate-table from to)) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
569 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
570 |
47916 | 571 ;;;; The global keymap tree. |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
572 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
573 ;;; global-map, esc-map, and ctl-x-map have their values set up in |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
574 ;;; keymap.c; we just give them docstrings here. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
575 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
576 (defvar global-map nil |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
577 "Default global keymap mapping Emacs keyboard input into commands. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
578 The value is a keymap which is usually (but not necessarily) Emacs's |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
579 global map.") |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
580 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
581 (defvar esc-map nil |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
582 "Default keymap for ESC (meta) commands. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
583 The normal global definition of the character ESC indirects to this keymap.") |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
584 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
585 (defvar ctl-x-map nil |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
586 "Default keymap for C-x commands. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
587 The normal global definition of the character C-x indirects to this keymap.") |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
588 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
589 (defvar ctl-x-4-map (make-sparse-keymap) |
41955 | 590 "Keymap for subcommands of C-x 4.") |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
591 (defalias 'ctl-x-4-prefix ctl-x-4-map) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
592 (define-key ctl-x-map "4" 'ctl-x-4-prefix) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
593 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
594 (defvar ctl-x-5-map (make-sparse-keymap) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
595 "Keymap for frame commands.") |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
596 (defalias 'ctl-x-5-prefix ctl-x-5-map) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
597 (define-key ctl-x-map "5" 'ctl-x-5-prefix) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
598 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
599 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
600 ;;;; Event manipulation functions. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
601 |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
602 ;; The call to `read' is to ensure that the value is computed at load time |
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
603 ;; and not compiled into the .elc file. The value is negative on most |
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
604 ;; machines, but not on all! |
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
605 (defconst listify-key-sequence-1 (logior 128 (read "?\\M-\\^@"))) |
3153
4c94c9faf1af
(listify-key-sequence): Avoid the constant ?\M-\200.
Richard M. Stallman <rms@gnu.org>
parents:
2963
diff
changeset
|
606 |
2021
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
607 (defun listify-key-sequence (key) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
608 "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
|
609 (if (vectorp key) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
610 (append key nil) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
611 (mapcar (function (lambda (c) |
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
612 (if (> c 127) |
3153
4c94c9faf1af
(listify-key-sequence): Avoid the constant ?\M-\200.
Richard M. Stallman <rms@gnu.org>
parents:
2963
diff
changeset
|
613 (logxor c listify-key-sequence-1) |
2021
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
614 c))) |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
615 key))) |
2021
8b9286bffef8
(listify-key-sequence): New function.
Richard M. Stallman <rms@gnu.org>
parents:
1959
diff
changeset
|
616 |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
617 (defsubst eventp (obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
618 "True if the argument is an event object." |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
619 (or (integerp obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
620 (and (symbolp obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
621 (get obj 'event-symbol-elements)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
622 (and (consp obj) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
623 (symbolp (car obj)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
624 (get (car obj) 'event-symbol-elements)))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
625 |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
626 (defun event-modifiers (event) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
627 "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
|
628 The elements of the list may include `meta', `control', |
4414
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
629 `shift', `hyper', `super', `alt', `click', `double', `triple', `drag', |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
630 and `down'." |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
631 (let ((type event)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
632 (if (listp type) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
633 (setq type (car type))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
634 (if (symbolp type) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
635 (cdr (get type 'event-symbol-elements)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
636 (let ((list nil)) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
637 (or (zerop (logand type ?\M-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
638 (setq list (cons 'meta list))) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
639 (or (and (zerop (logand type ?\C-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
640 (>= (logand type 127) 32)) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
641 (setq list (cons 'control list))) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
642 (or (and (zerop (logand type ?\S-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
643 (= (logand type 255) (downcase (logand type 255)))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
644 (setq list (cons 'shift list))) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
645 (or (zerop (logand type ?\H-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
646 (setq list (cons 'hyper list))) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
647 (or (zerop (logand type ?\s-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
648 (setq list (cons 'super list))) |
10693
0875851842f0
(listify-key-sequence-1, event-modifiers): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents:
10681
diff
changeset
|
649 (or (zerop (logand type ?\A-\^@)) |
2040
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
650 (setq list (cons 'alt list))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
651 list)))) |
aa926beb4caa
(event-modifiers): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2033
diff
changeset
|
652 |
2063
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
653 (defun event-basic-type (event) |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
654 "Returns the basic type of the given event (all modifiers removed). |
36468 | 655 The value is a printing character (not upper case) or a symbol." |
3784
d2df5ca46b39
* subr.el (event-basic-type): Deal with listy events properly.
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
656 (if (consp event) |
d2df5ca46b39
* subr.el (event-basic-type): Deal with listy events properly.
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
657 (setq event (car event))) |
2063
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
658 (if (symbolp event) |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
659 (car (get event 'event-symbol-elements)) |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
660 (let ((base (logand event (1- (lsh 1 18))))) |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
661 (downcase (if (< base 32) (logior base 64) base))))) |
2f0555b428c4
(event-basic-type): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2040
diff
changeset
|
662 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
663 (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
|
664 "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
|
665 (and (consp object) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
666 (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
|
667 |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
668 (defsubst event-start (event) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
669 "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
|
670 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
|
671 of the event. |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
672 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
|
673 The return value is of the form |
53518
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
674 (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW) |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
675 IMAGE (DX . DY) (WIDTH . HEIGHT)) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
676 The `posn-' functions access elements of such lists." |
45978
a8fbafaa31ad
(event-start, event-end, event-click-count):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45823
diff
changeset
|
677 (if (consp event) (nth 1 event) |
a8fbafaa31ad
(event-start, event-end, event-click-count):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45823
diff
changeset
|
678 (list (selected-window) (point) '(0 . 0) 0))) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
679 |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
680 (defsubst event-end (event) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
681 "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
|
682 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
|
683 The return value is of the form |
53518
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
684 (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW) |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
685 IMAGE (DX . DY) (WIDTH . HEIGHT)) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
686 The `posn-' functions access elements of such lists." |
45978
a8fbafaa31ad
(event-start, event-end, event-click-count):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45823
diff
changeset
|
687 (if (consp event) (nth (if (consp (nth 2 event)) 2 1) event) |
a8fbafaa31ad
(event-start, event-end, event-click-count):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45823
diff
changeset
|
688 (list (selected-window) (point) '(0 . 0) 0))) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
689 |
4414
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
690 (defsubst event-click-count (event) |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
691 "Return the multi-click count of EVENT, a click or drag event. |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
692 The return value is a positive integer." |
45978
a8fbafaa31ad
(event-start, event-end, event-click-count):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45823
diff
changeset
|
693 (if (and (consp event) (integerp (nth 2 event))) (nth 2 event) 1)) |
4414
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
694 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
695 (defsubst posn-window (position) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
696 "Return the window in POSITION. |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
697 POSITION should be a list of the form returned by the `event-start' |
53593 | 698 and `event-end' functions." |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
699 (nth 0 position)) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
700 |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
701 (defsubst posn-area (position) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
702 "Return the window area recorded in POSITION, or nil for the text area. |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
703 POSITION should be a list of the form returned by the `event-start' |
53593 | 704 and `event-end' functions." |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
705 (let ((area (if (consp (nth 1 position)) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
706 (car (nth 1 position)) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
707 (nth 1 position)))) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
708 (and (symbolp area) area))) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
709 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
710 (defsubst posn-point (position) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
711 "Return the buffer location in POSITION. |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
712 POSITION should be a list of the form returned by the `event-start' |
53593 | 713 and `event-end' functions." |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
714 (or (nth 5 position) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
715 (if (consp (nth 1 position)) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
716 (car (nth 1 position)) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
717 (nth 1 position)))) |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
718 |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
719 (defsubst posn-x-y (position) |
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
720 "Return the x and y coordinates in POSITION. |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
721 POSITION should be a list of the form returned by the `event-start' |
53593 | 722 and `event-end' functions." |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
723 (nth 2 position)) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
724 |
7636
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
725 (defun posn-col-row (position) |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
726 "Return the nominal column and row in POSITION, measured in characters. |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
727 The column and row values are approximations calculated from the x |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
728 and y coordinates in POSITION and the frame's default character width |
53593 | 729 and height. |
7636
83dba60657ef
(posn-col-row): Do something useful for scroll bar event.
Richard M. Stallman <rms@gnu.org>
parents:
7615
diff
changeset
|
730 For a scroll-bar event, the result column is 0, and the row |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
731 corresponds to the vertical position of the click in the scroll bar. |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
732 POSITION should be a list of the form returned by the `event-start' |
53593 | 733 and `event-end' functions." |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
734 (let* ((pair (posn-x-y position)) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
735 (window (posn-window position)) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
736 (area (posn-area position))) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
737 (cond |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
738 ((null window) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
739 '(0 . 0)) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
740 ((eq area 'vertical-scroll-bar) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
741 (cons 0 (scroll-bar-scale pair (1- (window-height window))))) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
742 ((eq area 'horizontal-scroll-bar) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
743 (cons (scroll-bar-scale pair (window-width window)) 0)) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
744 (t |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
745 (let* ((frame (if (framep window) window (window-frame window))) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
746 (x (/ (car pair) (frame-char-width frame))) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
747 (y (/ (cdr pair) (+ (frame-char-height frame) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
748 (or (frame-parameter frame 'line-spacing) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
749 default-line-spacing |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
750 0))))) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
751 (cons x y)))))) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
752 |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
753 (defun posn-actual-col-row (position) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
754 "Return the actual column and row in POSITION, measured in characters. |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
755 These are the actual row number in the window and character number in that row. |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
756 Return nil if POSITION does not contain the actual position; in that case |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
757 `posn-col-row' can be used to get approximate values. |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
758 POSITION should be a list of the form returned by the `event-start' |
53593 | 759 and `event-end' functions." |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
760 (nth 6 position)) |
6039
4eb7f4633370
(posn-x-y): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6005
diff
changeset
|
761 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
762 (defsubst posn-timestamp (position) |
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
763 "Return the timestamp of POSITION. |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
764 POSITION should be a list of the form returned by the `event-start' |
53593 | 765 and `event-end' functions." |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
766 (nth 3 position)) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
767 |
53518
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
768 (defsubst posn-string (position) |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
769 "Return the string object of POSITION, or nil if a buffer position. |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
770 POSITION should be a list of the form returned by the `event-start' |
53593 | 771 and `event-end' functions." |
53132
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
772 (nth 4 position)) |
20c6299bd4df
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53063
diff
changeset
|
773 |
53518
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
774 (defsubst posn-image (position) |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
775 "Return the image object of POSITION, or nil if a not an image. |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
776 POSITION should be a list of the form returned by the `event-start' |
53593 | 777 and `event-end' functions." |
53518
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
778 (nth 7 position)) |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
779 |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
780 (defsubst posn-object (position) |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
781 "Return the object (image or string) of POSITION. |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
782 POSITION should be a list of the form returned by the `event-start' |
53593 | 783 and `event-end' functions." |
53518
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
784 (or (posn-image position) (posn-string position))) |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
785 |
53181
8337e648c2b3
(posn-object-x-y): New defun.
Kim F. Storm <storm@cua.dk>
parents:
53174
diff
changeset
|
786 (defsubst posn-object-x-y (position) |
8337e648c2b3
(posn-object-x-y): New defun.
Kim F. Storm <storm@cua.dk>
parents:
53174
diff
changeset
|
787 "Return the x and y coordinates relative to the object of POSITION. |
8337e648c2b3
(posn-object-x-y): New defun.
Kim F. Storm <storm@cua.dk>
parents:
53174
diff
changeset
|
788 POSITION should be a list of the form returned by the `event-start' |
53593 | 789 and `event-end' functions." |
53518
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
790 (nth 8 position)) |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
791 |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
792 (defsubst posn-object-width-height (position) |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
793 "Return the pixel width and height of the object of POSITION. |
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
794 POSITION should be a list of the form returned by the `event-start' |
53593 | 795 and `event-end' functions." |
53518
21599196e26a
(event-start, event-end): Doc fix.
Kim F. Storm <storm@cua.dk>
parents:
53485
diff
changeset
|
796 (nth 9 position)) |
53181
8337e648c2b3
(posn-object-x-y): New defun.
Kim F. Storm <storm@cua.dk>
parents:
53174
diff
changeset
|
797 |
2071
8f410f56d98f
(posn-timestamp, posn-col-row, posn-point, posn-window):
Richard M. Stallman <rms@gnu.org>
parents:
2063
diff
changeset
|
798 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
799 ;;;; Obsolescent names for functions. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
800 |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
801 (defalias 'dot 'point) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
802 (defalias 'dot-marker 'point-marker) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
803 (defalias 'dot-min 'point-min) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
804 (defalias 'dot-max 'point-max) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
805 (defalias 'window-dot 'window-point) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
806 (defalias 'set-window-dot 'set-window-point) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
807 (defalias 'read-input 'read-string) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
808 (defalias 'send-string 'process-send-string) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
809 (defalias 'send-region 'process-send-region) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
810 (defalias 'show-buffer 'set-window-buffer) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
811 (defalias 'buffer-flush-undo 'buffer-disable-undo) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
812 (defalias 'eval-current-buffer 'eval-buffer) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
813 (defalias 'compiled-function-p 'byte-code-function-p) |
16437
0626ef653e3e
(define-function): Define as alias for defalias.
Richard M. Stallman <rms@gnu.org>
parents:
16379
diff
changeset
|
814 (defalias 'define-function 'defalias) |
114 | 815 |
23134
173e15236628
(sref): Make it an alias of aref. Make the
Kenichi Handa <handa@m17n.org>
parents:
23058
diff
changeset
|
816 (defalias 'sref 'aref) |
29354
4ed4a700358b
Update calls to make-obsolete with a WHEN argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29062
diff
changeset
|
817 (make-obsolete 'sref 'aref "20.4") |
47652
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
818 (make-obsolete 'char-bytes "now always returns 1." "20.4") |
46148
a123dda5650e
(chars-in-region): Add obsolescence declaration for `chars-in-region'.
Juanma Barranquero <lekktu@gmail.com>
parents:
46052
diff
changeset
|
819 (make-obsolete 'chars-in-region "use (abs (- BEG END))." "20.3") |
46532
6b003ac8d860
(dot, dot-max, dot-min, dot-marker, buffer-flush-undo, baud-rate,
Juanma Barranquero <lekktu@gmail.com>
parents:
46219
diff
changeset
|
820 (make-obsolete 'dot 'point "before 19.15") |
6b003ac8d860
(dot, dot-max, dot-min, dot-marker, buffer-flush-undo, baud-rate,
Juanma Barranquero <lekktu@gmail.com>
parents:
46219
diff
changeset
|
821 (make-obsolete 'dot-max 'point-max "before 19.15") |
6b003ac8d860
(dot, dot-max, dot-min, dot-marker, buffer-flush-undo, baud-rate,
Juanma Barranquero <lekktu@gmail.com>
parents:
46219
diff
changeset
|
822 (make-obsolete 'dot-min 'point-min "before 19.15") |
6b003ac8d860
(dot, dot-max, dot-min, dot-marker, buffer-flush-undo, baud-rate,
Juanma Barranquero <lekktu@gmail.com>
parents:
46219
diff
changeset
|
823 (make-obsolete 'dot-marker 'point-marker "before 19.15") |
6b003ac8d860
(dot, dot-max, dot-min, dot-marker, buffer-flush-undo, baud-rate,
Juanma Barranquero <lekktu@gmail.com>
parents:
46219
diff
changeset
|
824 (make-obsolete 'buffer-flush-undo 'buffer-disable-undo "before 19.15") |
6b003ac8d860
(dot, dot-max, dot-min, dot-marker, buffer-flush-undo, baud-rate,
Juanma Barranquero <lekktu@gmail.com>
parents:
46219
diff
changeset
|
825 (make-obsolete 'baud-rate "use the baud-rate variable instead." "before 19.15") |
6b003ac8d860
(dot, dot-max, dot-min, dot-marker, buffer-flush-undo, baud-rate,
Juanma Barranquero <lekktu@gmail.com>
parents:
46219
diff
changeset
|
826 (make-obsolete 'compiled-function-p 'byte-code-function-p "before 19.15") |
6b003ac8d860
(dot, dot-max, dot-min, dot-marker, buffer-flush-undo, baud-rate,
Juanma Barranquero <lekktu@gmail.com>
parents:
46219
diff
changeset
|
827 (make-obsolete 'define-function 'defalias "20.1") |
20605 | 828 |
42266
75bbe9d566d9
(insert-string): Moved from mocklisp.c, reimplemented in Lisp. Obsoleted.
Pavel Janík <Pavel@Janik.cz>
parents:
42083
diff
changeset
|
829 (defun insert-string (&rest args) |
75bbe9d566d9
(insert-string): Moved from mocklisp.c, reimplemented in Lisp. Obsoleted.
Pavel Janík <Pavel@Janik.cz>
parents:
42083
diff
changeset
|
830 "Mocklisp-compatibility insert function. |
75bbe9d566d9
(insert-string): Moved from mocklisp.c, reimplemented in Lisp. Obsoleted.
Pavel Janík <Pavel@Janik.cz>
parents:
42083
diff
changeset
|
831 Like the function `insert' except that any argument that is a number |
75bbe9d566d9
(insert-string): Moved from mocklisp.c, reimplemented in Lisp. Obsoleted.
Pavel Janík <Pavel@Janik.cz>
parents:
42083
diff
changeset
|
832 is converted into a string by expressing it in decimal." |
75bbe9d566d9
(insert-string): Moved from mocklisp.c, reimplemented in Lisp. Obsoleted.
Pavel Janík <Pavel@Janik.cz>
parents:
42083
diff
changeset
|
833 (dolist (el args) |
75bbe9d566d9
(insert-string): Moved from mocklisp.c, reimplemented in Lisp. Obsoleted.
Pavel Janík <Pavel@Janik.cz>
parents:
42083
diff
changeset
|
834 (insert (if (integerp el) (number-to-string el) el)))) |
46219
56b79cbf05d2
(insert-string): Update the obsolete info.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46148
diff
changeset
|
835 (make-obsolete 'insert-string 'insert "21.4") |
56b79cbf05d2
(insert-string): Update the obsolete info.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46148
diff
changeset
|
836 (defun makehash (&optional test) (make-hash-table :test (or test 'eql))) |
56b79cbf05d2
(insert-string): Update the obsolete info.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46148
diff
changeset
|
837 (make-obsolete 'makehash 'make-hash-table "21.4") |
42266
75bbe9d566d9
(insert-string): Moved from mocklisp.c, reimplemented in Lisp. Obsoleted.
Pavel Janík <Pavel@Janik.cz>
parents:
42083
diff
changeset
|
838 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
839 ;; Some programs still use this as a function. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
840 (defun baud-rate () |
46052
4d27fe417297
(char-bytes): Fix obsolescence declaration.
Juanma Barranquero <lekktu@gmail.com>
parents:
45978
diff
changeset
|
841 "Return the value of the `baud-rate' variable." |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
842 baud-rate) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
843 |
15599
7d3af2dcd864
(unfocus-frame, focus-frame): Define as no-ops.
Miles Bader <miles@gnu.org>
parents:
14707
diff
changeset
|
844 (defalias 'focus-frame 'ignore) |
7d3af2dcd864
(unfocus-frame, focus-frame): Define as no-ops.
Miles Bader <miles@gnu.org>
parents:
14707
diff
changeset
|
845 (defalias 'unfocus-frame 'ignore) |
46537
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
846 |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
847 |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
848 ;;;; Obsolescence declarations for variables. |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
849 |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
850 (make-obsolete-variable 'directory-sep-char "do not use it." "21.1") |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
851 (make-obsolete-variable 'mode-line-inverse-video "use the appropriate faces instead." "21.1") |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
852 (make-obsolete-variable 'unread-command-char |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
853 "use `unread-command-events' instead. That variable is a list of events to reread, so it now uses nil to mean `no event', instead of -1." |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
854 "before 19.15") |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
855 (make-obsolete-variable 'executing-macro 'executing-kbd-macro "before 19.34") |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
856 (make-obsolete-variable 'post-command-idle-hook |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
857 "use timers instead, with `run-with-idle-timer'." "before 19.34") |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
858 (make-obsolete-variable 'post-command-idle-delay |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
859 "use timers instead, with `run-with-idle-timer'." "before 19.34") |
46f175ecf5d4
(unread-command-char, executing-macro, post-command-idle-hook,
Juanma Barranquero <lekktu@gmail.com>
parents:
46532
diff
changeset
|
860 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
861 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
862 ;;;; Alternate names for functions - these are not being phased out. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
863 |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
864 (defalias 'string= 'string-equal) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
865 (defalias 'string< 'string-lessp) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
866 (defalias 'move-marker 'set-marker) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
867 (defalias 'rplaca 'setcar) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
868 (defalias 'rplacd 'setcdr) |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3411
diff
changeset
|
869 (defalias 'beep 'ding) ;preserve lingual purity |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
870 (defalias 'indent-to-column 'indent-to) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
871 (defalias 'backward-delete-char 'delete-backward-char) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
872 (defalias 'search-forward-regexp (symbol-function 're-search-forward)) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
873 (defalias 'search-backward-regexp (symbol-function 're-search-backward)) |
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
874 (defalias 'int-to-string 'number-to-string) |
21173
e917eb0d4e01
(save-match-data): store-match-data => set-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
21092
diff
changeset
|
875 (defalias 'store-match-data 'set-match-data) |
47078
6e9df2174ee2
(make-variable-frame-localizable): New alias for `make-variable-frame-local'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47042
diff
changeset
|
876 (defalias 'make-variable-frame-localizable 'make-variable-frame-local) |
31563
96b9757bfd45
(add-minor-mode): Use toggle-fun arg.
Dave Love <fx@gnu.org>
parents:
30515
diff
changeset
|
877 ;; These are the XEmacs names: |
25293
fd43e1a99384
(point-at-eol, point-at-bol): New aliases.
Karl Heuer <kwzh@gnu.org>
parents:
25140
diff
changeset
|
878 (defalias 'point-at-eol 'line-end-position) |
fd43e1a99384
(point-at-eol, point-at-bol): New aliases.
Karl Heuer <kwzh@gnu.org>
parents:
25140
diff
changeset
|
879 (defalias 'point-at-bol 'line-beginning-position) |
1903
87f63305319f
* subr.el (string-to-int): Make this an alias for
Jim Blandy <jimb@redhat.com>
parents:
1867
diff
changeset
|
880 |
87f63305319f
* subr.el (string-to-int): Make this an alias for
Jim Blandy <jimb@redhat.com>
parents:
1867
diff
changeset
|
881 ;;; 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
|
882 ;;; to go through all the sources and change them. |
2569
39ad4eda7fea
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2504
diff
changeset
|
883 (defalias 'string-to-int 'string-to-number) |
114 | 884 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
885 ;;;; Hook manipulation functions. |
388 | 886 |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
887 (defun make-local-hook (hook) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
888 "Make the hook HOOK local to the current buffer. |
23786
673204d56938
(make-local-hook): Return the hook variable.
Richard M. Stallman <rms@gnu.org>
parents:
23736
diff
changeset
|
889 The return value is HOOK. |
673204d56938
(make-local-hook): Return the hook variable.
Richard M. Stallman <rms@gnu.org>
parents:
23736
diff
changeset
|
890 |
33707
2b9847c18f31
(make-local-hook): Docstring fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32355
diff
changeset
|
891 You never need to call this function now that `add-hook' does it for you |
2b9847c18f31
(make-local-hook): Docstring fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32355
diff
changeset
|
892 if its LOCAL argument is non-nil. |
2b9847c18f31
(make-local-hook): Docstring fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32355
diff
changeset
|
893 |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
894 When a hook is local, its local and global values |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
895 work in concert: running the hook actually runs all the hook |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
896 functions listed in *either* the local value *or* the global value |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
897 of the hook variable. |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
898 |
39557
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
899 This function works by making t a member of the buffer-local value, |
12258
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
900 which acts as a flag to run the hook functions in the default value as |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
901 well. This works for all normal hooks, but does not work for most |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
902 non-normal hooks yet. We will be changing the callers of non-normal |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
903 hooks so that they can handle localness; this has to be done one by |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
904 one. |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
905 |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
906 This function does nothing if HOOK is already local in the current |
95ebca0a74d8
(make-local-hook): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12108
diff
changeset
|
907 buffer. |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
908 |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
909 Do not use `make-local-variable' to make a hook variable buffer-local." |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
910 (if (local-variable-p hook) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
911 nil |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
912 (or (boundp hook) (set hook nil)) |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
913 (make-local-variable hook) |
23786
673204d56938
(make-local-hook): Return the hook variable.
Richard M. Stallman <rms@gnu.org>
parents:
23736
diff
changeset
|
914 (set hook (list t))) |
673204d56938
(make-local-hook): Return the hook variable.
Richard M. Stallman <rms@gnu.org>
parents:
23736
diff
changeset
|
915 hook) |
46052
4d27fe417297
(char-bytes): Fix obsolescence declaration.
Juanma Barranquero <lekktu@gmail.com>
parents:
45978
diff
changeset
|
916 (make-obsolete 'make-local-hook "not necessary any more." "21.1") |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
917 |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
918 (defun add-hook (hook function &optional append local) |
4414
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
919 "Add to the value of HOOK the function FUNCTION. |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
920 FUNCTION is not added if already present. |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
921 FUNCTION is added (if necessary) at the beginning of the hook list |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
922 unless the optional argument APPEND is non-nil, in which case |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
923 FUNCTION is added at the end. |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
924 |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
925 The optional fourth argument, LOCAL, if non-nil, says to modify |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
926 the hook's buffer-local value rather than its default value. |
43435 | 927 This makes the hook buffer-local if needed, and it makes t a member |
928 of the buffer-local value. That acts as a flag to run the hook | |
929 functions in the default value as well as in the local value. | |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
930 |
4414
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
931 HOOK should be a symbol, and FUNCTION may be any valid function. If |
3356419b94c1
(add-hook): Change a single function into a list.
Richard M. Stallman <rms@gnu.org>
parents:
4235
diff
changeset
|
932 HOOK is void, it is first set to nil. If HOOK's value is a single |
8959
d33302427a47
(remove-hook, add-hook): Copy existing list before modifying.
Richard M. Stallman <rms@gnu.org>
parents:
8928
diff
changeset
|
933 function, it is changed to a list of functions." |
114 | 934 (or (boundp hook) (set hook nil)) |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
935 (or (default-boundp hook) (set-default hook nil)) |
39557
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
936 (if local (unless (local-variable-if-set-p hook) |
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
937 (set (make-local-variable hook) (list t))) |
28863
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
938 ;; Detect the case where make-local-variable was used on a hook |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
939 ;; and do what we used to do. |
52987
ac21698ba968
(add-hook): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52896
diff
changeset
|
940 (unless (and (consp (symbol-value hook)) (memq t (symbol-value hook))) |
28863
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
941 (setq local t))) |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
942 (let ((hook-value (if local (symbol-value hook) (default-value hook)))) |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
943 ;; If the hook value is a single function, turn it into a list. |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
944 (when (or (not (listp hook-value)) (eq (car hook-value) 'lambda)) |
28940
2a91228f7aa3
(add-hook): setq hook-value, not set
Sam Steingold <sds@gnu.org>
parents:
28868
diff
changeset
|
945 (setq hook-value (list hook-value))) |
28863
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
946 ;; Do the actual addition if necessary |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
947 (unless (member function hook-value) |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
948 (setq hook-value |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
949 (if append |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
950 (append hook-value (list function)) |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
951 (cons function hook-value)))) |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
952 ;; Set the actual variable |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
953 (if local (set hook hook-value) (set-default hook hook-value)))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
954 |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
955 (defun remove-hook (hook function &optional local) |
4964
78c13f3054e5
(remove-hook): New function, analogous to add-hook. This
Richard M. Stallman <rms@gnu.org>
parents:
4767
diff
changeset
|
956 "Remove from the value of HOOK the function FUNCTION. |
78c13f3054e5
(remove-hook): New function, analogous to add-hook. This
Richard M. Stallman <rms@gnu.org>
parents:
4767
diff
changeset
|
957 HOOK should be a symbol, and FUNCTION may be any valid function. If |
78c13f3054e5
(remove-hook): New function, analogous to add-hook. This
Richard M. Stallman <rms@gnu.org>
parents:
4767
diff
changeset
|
958 FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the |
9195
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
959 list of hooks to run in HOOK, then nothing is done. See `add-hook'. |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
960 |
70b00615cb75
(add-hook): Initialize default value and local value.
Richard M. Stallman <rms@gnu.org>
parents:
8959
diff
changeset
|
961 The optional third argument, LOCAL, if non-nil, says to modify |
52896
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
962 the hook's buffer-local value rather than its default value." |
28863
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
963 (or (boundp hook) (set hook nil)) |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
964 (or (default-boundp hook) (set-default hook nil)) |
52896
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
965 ;; Do nothing if LOCAL is t but this hook has no local binding. |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
966 (unless (and local (not (local-variable-p hook))) |
28863
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
967 ;; Detect the case where make-local-variable was used on a hook |
6430ce03c28a
(add-hook, remove-hook): Make hook buffer-local if needed..
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28811
diff
changeset
|
968 ;; and do what we used to do. |
52896
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
969 (when (and (local-variable-p hook) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
970 (not (and (consp (symbol-value hook)) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
971 (memq t (symbol-value hook))))) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
972 (setq local t)) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
973 (let ((hook-value (if local (symbol-value hook) (default-value hook)))) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
974 ;; Remove the function, for both the list and the non-list cases. |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
975 (if (or (not (listp hook-value)) (eq (car hook-value) 'lambda)) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
976 (if (equal hook-value function) (setq hook-value nil)) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
977 (setq hook-value (delete function (copy-sequence hook-value)))) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
978 ;; If the function is on the global hook, we need to shadow it locally |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
979 ;;(when (and local (member function (default-value hook)) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
980 ;; (not (member (cons 'not function) hook-value))) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
981 ;; (push (cons 'not function) hook-value)) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
982 ;; Set the actual variable |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
983 (if (not local) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
984 (set-default hook hook-value) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
985 (if (equal hook-value '(t)) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
986 (kill-local-variable hook) |
f992824e67f0
(add-hook): Correctly detect when make-local-hook was used.
Richard M. Stallman <rms@gnu.org>
parents:
52858
diff
changeset
|
987 (set hook hook-value)))))) |
9510
f03544494d1c
(add-to-list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9202
diff
changeset
|
988 |
32355
6bf2ae19e286
(add-to-list): Add optional argument APPEND.
Miles Bader <miles@gnu.org>
parents:
32131
diff
changeset
|
989 (defun add-to-list (list-var element &optional append) |
9535 | 990 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. |
13812 | 991 The test for presence of ELEMENT is done with `equal'. |
32355
6bf2ae19e286
(add-to-list): Add optional argument APPEND.
Miles Bader <miles@gnu.org>
parents:
32131
diff
changeset
|
992 If ELEMENT is added, it is added at the beginning of the list, |
6bf2ae19e286
(add-to-list): Add optional argument APPEND.
Miles Bader <miles@gnu.org>
parents:
32131
diff
changeset
|
993 unless the optional argument APPEND is non-nil, in which case |
6bf2ae19e286
(add-to-list): Add optional argument APPEND.
Miles Bader <miles@gnu.org>
parents:
32131
diff
changeset
|
994 ELEMENT is added at the end. |
24757
f4127409d184
(add-to-list): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
24699
diff
changeset
|
995 |
43833 | 996 The return value is the new value of LIST-VAR. |
997 | |
9535 | 998 If you want to use `add-to-list' on a variable that is not defined |
999 until a certain package is loaded, you should put the call to `add-to-list' | |
1000 into a hook function that will be run only after loading the package. | |
1001 `eval-after-load' provides one way to do this. In some cases | |
1002 other hooks, such as major mode hooks, can do the job." | |
21409
3e8b7782f4f5
(add-to-list): Always return updated value of LIST-VAR.
Karl Heuer <kwzh@gnu.org>
parents:
21173
diff
changeset
|
1003 (if (member element (symbol-value list-var)) |
3e8b7782f4f5
(add-to-list): Always return updated value of LIST-VAR.
Karl Heuer <kwzh@gnu.org>
parents:
21173
diff
changeset
|
1004 (symbol-value list-var) |
32355
6bf2ae19e286
(add-to-list): Add optional argument APPEND.
Miles Bader <miles@gnu.org>
parents:
32131
diff
changeset
|
1005 (set list-var |
6bf2ae19e286
(add-to-list): Add optional argument APPEND.
Miles Bader <miles@gnu.org>
parents:
32131
diff
changeset
|
1006 (if append |
6bf2ae19e286
(add-to-list): Add optional argument APPEND.
Miles Bader <miles@gnu.org>
parents:
32131
diff
changeset
|
1007 (append (symbol-value list-var) (list element)) |
6bf2ae19e286
(add-to-list): Add optional argument APPEND.
Miles Bader <miles@gnu.org>
parents:
32131
diff
changeset
|
1008 (cons element (symbol-value list-var)))))) |
39725
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1009 |
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1010 |
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1011 ;;; Load history |
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1012 |
47015
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1013 ;;; (defvar symbol-file-load-history-loaded nil |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1014 ;;; "Non-nil means we have loaded the file `fns-VERSION.el' in `exec-directory'. |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1015 ;;; That file records the part of `load-history' for preloaded files, |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1016 ;;; which is cleared out before dumping to make Emacs smaller.") |
39725
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1017 |
47015
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1018 ;;; (defun load-symbol-file-load-history () |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1019 ;;; "Load the file `fns-VERSION.el' in `exec-directory' if not already done. |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1020 ;;; That file records the part of `load-history' for preloaded files, |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1021 ;;; which is cleared out before dumping to make Emacs smaller." |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1022 ;;; (unless symbol-file-load-history-loaded |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1023 ;;; (load (expand-file-name |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1024 ;;; ;; fns-XX.YY.ZZ.el does not work on DOS filesystem. |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1025 ;;; (if (eq system-type 'ms-dos) |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1026 ;;; "fns.el" |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1027 ;;; (format "fns-%s.el" emacs-version)) |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1028 ;;; exec-directory) |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1029 ;;; ;; The file name fns-%s.el already has a .el extension. |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1030 ;;; nil nil t) |
7faae7c35e07
(symbol-file-load-history-loaded)
Richard M. Stallman <rms@gnu.org>
parents:
46783
diff
changeset
|
1031 ;;; (setq symbol-file-load-history-loaded t))) |
39725
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1032 |
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1033 (defun symbol-file (function) |
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1034 "Return the input source from which FUNCTION was loaded. |
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1035 The value is normally a string that was passed to `load': |
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1036 either an absolute file name, or a library name |
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1037 \(with no directory name and no `.el' or `.elc' at the end). |
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1038 It can also be nil, if the definition is not associated with any file." |
47355
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
1039 (if (and (symbolp function) (fboundp function) |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
1040 (eq 'autoload (car-safe (symbol-function function)))) |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
1041 (nth 1 (symbol-function function)) |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
1042 (let ((files load-history) |
48474
33dafec6a9de
(symbol-file): Remove unused variable `functions'.
John Paul Wallington <jpw@pobox.com>
parents:
48077
diff
changeset
|
1043 file) |
47355
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
1044 (while files |
48475
4bdcb09d9f25
(symbol-file): Accept a non-atomic `function' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48474
diff
changeset
|
1045 (if (member function (cdr (car files))) |
47355
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
1046 (setq file (car (car files)) files nil)) |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
1047 (setq files (cdr files))) |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
1048 file))) |
39725
c64d3e3adf5d
(symbol-file-load-history-loaded)
Miles Bader <miles@gnu.org>
parents:
39598
diff
changeset
|
1049 |
114 | 1050 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1051 ;;;; Specifying things to do after certain files are loaded. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1052 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1053 (defun eval-after-load (file form) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1054 "Arrange that, if FILE is ever loaded, FORM will be run at that time. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1055 This makes or adds to an entry on `after-load-alist'. |
10794
4443f78a2117
(eval-after-load): Run FORM now if FILE's already loaded.
Richard M. Stallman <rms@gnu.org>
parents:
10693
diff
changeset
|
1056 If FILE is already loaded, evaluate FORM right now. |
5440
856ecdc5228a
(eval-after-load): Do nothing if FORM is already on the list.
Richard M. Stallman <rms@gnu.org>
parents:
5421
diff
changeset
|
1057 It does nothing if FORM is already on the list for FILE. |
34750 | 1058 FILE must match exactly. Normally FILE is the name of a library, |
1059 with no directory or extension specified, since that is how `load' | |
41140
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1060 is normally called. |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1061 FILE can also be a feature (i.e. a symbol), in which case FORM is |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1062 evaluated whenever that feature is `provide'd." |
5440
856ecdc5228a
(eval-after-load): Do nothing if FORM is already on the list.
Richard M. Stallman <rms@gnu.org>
parents:
5421
diff
changeset
|
1063 (let ((elt (assoc file after-load-alist))) |
41140
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1064 ;; Make sure there is an element for FILE. |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1065 (unless elt (setq elt (list file)) (push elt after-load-alist)) |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1066 ;; Add FORM to the element if it isn't there. |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1067 (unless (member form (cdr elt)) |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1068 (nconc elt (list form)) |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1069 ;; If the file has been loaded already, run FORM right away. |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1070 (if (if (symbolp file) |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1071 (featurep file) |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1072 ;; Make sure `load-history' contains the files dumped with |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1073 ;; Emacs for the case that FILE is one of them. |
47355
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
1074 ;; (load-symbol-file-load-history) |
41140
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1075 (assoc file load-history)) |
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
1076 (eval form)))) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1077 form) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1078 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1079 (defun eval-next-after-load (file) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1080 "Read the following input sexp, and run it whenever FILE is loaded. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1081 This makes or adds to an entry on `after-load-alist'. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1082 FILE should be the name of a library, with no directory name." |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1083 (eval-after-load file (read))) |
45587
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1084 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1085 ;;; make-network-process wrappers |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1086 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1087 (if (featurep 'make-network-process) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1088 (progn |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1089 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1090 (defun open-network-stream (name buffer host service) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1091 "Open a TCP connection for a service to a host. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1092 Returns a subprocess-object to represent the connection. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1093 Input and output work as for subprocesses; `delete-process' closes it. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1094 Args are NAME BUFFER HOST SERVICE. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1095 NAME is name for process. It is modified if necessary to make it unique. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1096 BUFFER is the buffer (or buffer-name) to associate with the process. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1097 Process output goes at end of that buffer, unless you specify |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1098 an output stream or filter function to handle the output. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1099 BUFFER may be also nil, meaning that this process is not associated |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1100 with any buffer |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1101 Third arg is name of the host to connect to, or its IP address. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1102 Fourth arg SERVICE is name of the service desired, or an integer |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1103 specifying a port number to connect to." |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1104 (make-network-process :name name :buffer buffer |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1105 :host host :service service)) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1106 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1107 (defun open-network-stream-nowait (name buffer host service &optional sentinel filter) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1108 "Initiate connection to a TCP connection for a service to a host. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1109 It returns nil if non-blocking connects are not supported; otherwise, |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1110 it returns a subprocess-object to represent the connection. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1111 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1112 This function is similar to `open-network-stream', except that this |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1113 function returns before the connection is established. When the |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1114 connection is completed, the sentinel function will be called with |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1115 second arg matching `open' (if successful) or `failed' (on error). |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1116 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1117 Args are NAME BUFFER HOST SERVICE SENTINEL FILTER. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1118 NAME, BUFFER, HOST, and SERVICE are as for `open-network-stream'. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1119 Optional args, SENTINEL and FILTER specifies the sentinel and filter |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1120 functions to be used for this network stream." |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1121 (if (featurep 'make-network-process '(:nowait t)) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1122 (make-network-process :name name :buffer buffer :nowait t |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1123 :host host :service service |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1124 :filter filter :sentinel sentinel))) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1125 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1126 (defun open-network-stream-server (name buffer service &optional sentinel filter) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1127 "Create a network server process for a TCP service. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1128 It returns nil if server processes are not supported; otherwise, |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1129 it returns a subprocess-object to represent the server. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1130 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1131 When a client connects to the specified service, a new subprocess |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1132 is created to handle the new connection, and the sentinel function |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1133 is called for the new process. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1134 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1135 Args are NAME BUFFER SERVICE SENTINEL FILTER. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1136 NAME is name for the server process. Client processes are named by |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1137 appending the ip-address and port number of the client to NAME. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1138 BUFFER is the buffer (or buffer-name) to associate with the server |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1139 process. Client processes will not get a buffer if a process filter |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1140 is specified or BUFFER is nil; otherwise, a new buffer is created for |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1141 the client process. The name is similar to the process name. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1142 Third arg SERVICE is name of the service desired, or an integer |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1143 specifying a port number to connect to. It may also be t to selected |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1144 an unused port number for the server. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1145 Optional args, SENTINEL and FILTER specifies the sentinel and filter |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1146 functions to be used for the client processes; the server process |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1147 does not use these function." |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1148 (if (featurep 'make-network-process '(:server t)) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1149 (make-network-process :name name :buffer buffer |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1150 :service service :server t :noquery t |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1151 :sentinel sentinel :filter filter))) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1152 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1153 )) ;; (featurep 'make-network-process) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1154 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1155 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1156 ;; compatibility |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1157 |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1158 (defun process-kill-without-query (process &optional flag) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1159 "Say no query needed if PROCESS is running when Emacs is exited. |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1160 Optional second argument if non-nil says to require a query. |
47916 | 1161 Value is t if a query was formerly required. |
45587
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1162 New code should not use this function; use `process-query-on-exit-flag' |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1163 or `set-process-query-on-exit-flag' instead." |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1164 (let ((old (process-query-on-exit-flag process))) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1165 (set-process-query-on-exit-flag process nil) |
02df8e2ff88b
(open-network-stream, open-network-stream-nowait)
Richard M. Stallman <rms@gnu.org>
parents:
45246
diff
changeset
|
1166 old)) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1167 |
49225
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1168 ;; process plist management |
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1169 |
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1170 (defun process-get (process propname) |
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1171 "Return the value of PROCESS' PROPNAME property. |
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1172 This is the last value stored with `(process-put PROCESS PROPNAME VALUE)'." |
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1173 (plist-get (process-plist process) propname)) |
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1174 |
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1175 (defun process-put (process propname value) |
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1176 "Change PROCESS' PROPNAME property to VALUE. |
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1177 It can be retrieved with `(process-get PROCESS PROPNAME)'." |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49492
diff
changeset
|
1178 (set-process-plist process |
49225
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1179 (plist-put (process-plist process) propname value))) |
50cb245b2072
(process-put, process-get): New functions.
Kim F. Storm <storm@cua.dk>
parents:
48935
diff
changeset
|
1180 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1181 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1182 ;;;; Input and display facilities. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1183 |
18880
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
1184 (defvar read-quoted-char-radix 8 |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
1185 "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'. |
18880
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
1186 Legitimate radix values are 8, 10 and 16.") |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
1187 |
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
1188 (custom-declare-variable-early |
47916 | 1189 'read-quoted-char-radix 8 |
18880
1ed40ed8e0c1
(custom-declare-variable-early): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18828
diff
changeset
|
1190 "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'. |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
1191 Legitimate radix values are 8, 10 and 16." |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
1192 :type '(choice (const 8) (const 10) (const 16)) |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
1193 :group 'editing-basics) |
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
1194 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1195 (defun read-quoted-char (&optional prompt) |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1196 "Like `read-char', but do not allow quitting. |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1197 Also, if the first character read is an octal digit, |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1198 we read any number of octal digits and return the |
21008
7111f9cf9392
(read-quoted-char): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20939
diff
changeset
|
1199 specified character code. Any nondigit terminates the sequence. |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
1200 If the terminator is RET, it is discarded; |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1201 any other terminator is used itself as input. |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1202 |
21008
7111f9cf9392
(read-quoted-char): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20939
diff
changeset
|
1203 The optional argument PROMPT specifies a string to use to prompt the user. |
7111f9cf9392
(read-quoted-char): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20939
diff
changeset
|
1204 The variable `read-quoted-char-radix' controls which radix to use |
7111f9cf9392
(read-quoted-char): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20939
diff
changeset
|
1205 for numeric input." |
50427
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1206 (let ((message-log-max nil) done (first t) (code 0) char translated) |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1207 (while (not done) |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1208 (let ((inhibit-quit first) |
12108
f75e47f673f4
(read-quoted-char): Turn on help-form and turn off help-char.
Karl Heuer <kwzh@gnu.org>
parents:
12016
diff
changeset
|
1209 ;; Don't let C-h get the help message--only help function keys. |
f75e47f673f4
(read-quoted-char): Turn on help-form and turn off help-char.
Karl Heuer <kwzh@gnu.org>
parents:
12016
diff
changeset
|
1210 (help-char nil) |
f75e47f673f4
(read-quoted-char): Turn on help-form and turn off help-char.
Karl Heuer <kwzh@gnu.org>
parents:
12016
diff
changeset
|
1211 (help-form |
f75e47f673f4
(read-quoted-char): Turn on help-form and turn off help-char.
Karl Heuer <kwzh@gnu.org>
parents:
12016
diff
changeset
|
1212 "Type the special character you want to use, |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1213 or the octal character code. |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
1214 RET terminates the character code and is discarded; |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1215 any other non-digit terminates the character code and is then used as input.")) |
47747
399628a16c0a
(read-key-auxiliary-map, read-key): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47690
diff
changeset
|
1216 (setq char (read-event (and prompt (format "%s-" prompt)) t)) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1217 (if inhibit-quit (setq quit-flag nil))) |
47747
399628a16c0a
(read-key-auxiliary-map, read-key): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47690
diff
changeset
|
1218 ;; Translate TAB key into control-I ASCII character, and so on. |
399628a16c0a
(read-key-auxiliary-map, read-key): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47690
diff
changeset
|
1219 ;; Note: `read-char' does it using the `ascii-character' property. |
399628a16c0a
(read-key-auxiliary-map, read-key): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47690
diff
changeset
|
1220 ;; We could try and use read-key-sequence instead, but then C-q ESC |
399628a16c0a
(read-key-auxiliary-map, read-key): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47690
diff
changeset
|
1221 ;; or C-q C-x might not return immediately since ESC or C-x might be |
399628a16c0a
(read-key-auxiliary-map, read-key): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47690
diff
changeset
|
1222 ;; bound to some prefix in function-key-map or key-translation-map. |
50427
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1223 (setq translated char) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1224 (let ((translation (lookup-key function-key-map (vector char)))) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1225 (if (arrayp translation) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1226 (setq translated (aref translation 0)))) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1227 (cond ((null translated)) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1228 ((not (integerp translated)) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1229 (setq unread-command-events (list char) |
18828
4837387f683c
(read-quoted-char): Handle non-character events.
Richard M. Stallman <rms@gnu.org>
parents:
18821
diff
changeset
|
1230 done t)) |
50427
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1231 ((/= (logand translated ?\M-\^@) 0) |
19175
3d80c899a15d
(read-quoted-char): Fix handling of meta-chars.
Richard M. Stallman <rms@gnu.org>
parents:
19002
diff
changeset
|
1232 ;; Turn a meta-character into a character with the 0200 bit set. |
50427
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1233 (setq code (logior (logand translated (lognot ?\M-\^@)) 128) |
19175
3d80c899a15d
(read-quoted-char): Fix handling of meta-chars.
Richard M. Stallman <rms@gnu.org>
parents:
19002
diff
changeset
|
1234 done t)) |
50427
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1235 ((and (<= ?0 translated) (< translated (+ ?0 (min 10 read-quoted-char-radix)))) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1236 (setq code (+ (* code read-quoted-char-radix) (- translated ?0))) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1237 (and prompt (setq prompt (message "%s %c" prompt translated)))) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1238 ((and (<= ?a (downcase translated)) |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1239 (< (downcase translated) (+ ?a -10 (min 36 read-quoted-char-radix)))) |
19002
f21881dcd27b
(read-quoted-char): Consistently downcase letter "digits".
Richard M. Stallman <rms@gnu.org>
parents:
18948
diff
changeset
|
1240 (setq code (+ (* code read-quoted-char-radix) |
50427
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1241 (+ 10 (- (downcase translated) ?a)))) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1242 (and prompt (setq prompt (message "%s %c" prompt translated)))) |
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1243 ((and (not first) (eq translated ?\C-m)) |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1244 (setq done t)) |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1245 ((not first) |
50427
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1246 (setq unread-command-events (list char) |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1247 done t)) |
50427
6ce9db7934cb
(read-quoted-char): Remember the input char
Richard M. Stallman <rms@gnu.org>
parents:
50417
diff
changeset
|
1248 (t (setq code translated |
18821
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1249 done t))) |
83425393d550
(read-quoted-char): Read any number of octal digits,
Richard M. Stallman <rms@gnu.org>
parents:
18044
diff
changeset
|
1250 (setq first nil)) |
19175
3d80c899a15d
(read-quoted-char): Fix handling of meta-chars.
Richard M. Stallman <rms@gnu.org>
parents:
19002
diff
changeset
|
1251 code)) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1252 |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1253 (defun read-passwd (prompt &optional confirm default) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1254 "Read a password, prompting with PROMPT. Echo `.' for each character typed. |
20472
79ea90039b23
(read-password): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20410
diff
changeset
|
1255 End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1256 Optional argument CONFIRM, if non-nil, then read it twice to make sure. |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1257 Optional DEFAULT is a default password to use instead of empty input." |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1258 (if confirm |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1259 (let (success) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1260 (while (not success) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1261 (let ((first (read-passwd prompt nil default)) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1262 (second (read-passwd "Confirm password: " nil default))) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1263 (if (equal first second) |
36094
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
1264 (progn |
52132
4127c72e350b
(read-passwd): Use clear-string instead of fillarray.
Richard M. Stallman <rms@gnu.org>
parents:
51983
diff
changeset
|
1265 (and (arrayp second) (clear-string second)) |
36094
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
1266 (setq success first)) |
52132
4127c72e350b
(read-passwd): Use clear-string instead of fillarray.
Richard M. Stallman <rms@gnu.org>
parents:
51983
diff
changeset
|
1267 (and (arrayp first) (clear-string first)) |
4127c72e350b
(read-passwd): Use clear-string instead of fillarray.
Richard M. Stallman <rms@gnu.org>
parents:
51983
diff
changeset
|
1268 (and (arrayp second) (clear-string second)) |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1269 (message "Password not repeated accurately; please start over") |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1270 (sit-for 1)))) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1271 success) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1272 (let ((pass nil) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1273 (c 0) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1274 (echo-keystrokes 0) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1275 (cursor-in-echo-area t)) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1276 (while (progn (message "%s%s" |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1277 prompt |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1278 (make-string (length pass) ?.)) |
28628
60285ddb5d02
(read-passwd): Use read-char-exclusive.
Richard M. Stallman <rms@gnu.org>
parents:
28490
diff
changeset
|
1279 (setq c (read-char-exclusive nil t)) |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1280 (and (/= c ?\r) (/= c ?\n) (/= c ?\e))) |
37028
f023c8a482ec
(read-passwd): Clear command history after each
Gerd Moellmann <gerd@gnu.org>
parents:
36468
diff
changeset
|
1281 (clear-this-command-keys) |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1282 (if (= c ?\C-u) |
36094
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
1283 (progn |
52132
4127c72e350b
(read-passwd): Use clear-string instead of fillarray.
Richard M. Stallman <rms@gnu.org>
parents:
51983
diff
changeset
|
1284 (and (arrayp pass) (clear-string pass)) |
36094
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
1285 (setq pass "")) |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1286 (if (and (/= c ?\b) (/= c ?\177)) |
36094
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
1287 (let* ((new-char (char-to-string c)) |
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
1288 (new-pass (concat pass new-char))) |
52132
4127c72e350b
(read-passwd): Use clear-string instead of fillarray.
Richard M. Stallman <rms@gnu.org>
parents:
51983
diff
changeset
|
1289 (and (arrayp pass) (clear-string pass)) |
4127c72e350b
(read-passwd): Use clear-string instead of fillarray.
Richard M. Stallman <rms@gnu.org>
parents:
51983
diff
changeset
|
1290 (clear-string new-char) |
36094
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
1291 (setq c ?\0) |
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
1292 (setq pass new-pass)) |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1293 (if (> (length pass) 0) |
36094
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
1294 (let ((new-pass (substring pass 0 -1))) |
52132
4127c72e350b
(read-passwd): Use clear-string instead of fillarray.
Richard M. Stallman <rms@gnu.org>
parents:
51983
diff
changeset
|
1295 (and (arrayp pass) (clear-string pass)) |
36094
fddc05f3f926
(read-passwd): Clear Lisp memory holding password.
Gerd Moellmann <gerd@gnu.org>
parents:
35281
diff
changeset
|
1296 (setq pass new-pass)))))) |
21092
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1297 (message nil) |
7726f8d9eff0
(read-passwd): Renamed from read-password. New second arg CONFIRM.
Richard M. Stallman <rms@gnu.org>
parents:
21066
diff
changeset
|
1298 (or pass default "")))) |
20472
79ea90039b23
(read-password): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20410
diff
changeset
|
1299 |
44668
52222efc9d4d
(insert-for-yank): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44473
diff
changeset
|
1300 ;;; Atomic change groups. |
52222efc9d4d
(insert-for-yank): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44473
diff
changeset
|
1301 |
43126
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1302 (defmacro atomic-change-group (&rest body) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1303 "Perform BODY as an atomic change group. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1304 This means that if BODY exits abnormally, |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1305 all of its changes to the current buffer are undone. |
46783
a4e9eb2530cb
(atomic-change-group): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
46537
diff
changeset
|
1306 This works regardless of whether undo is enabled in the buffer. |
43126
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1307 |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1308 This mechanism is transparent to ordinary use of undo; |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1309 if undo is enabled in the buffer and BODY succeeds, the |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1310 user can undo the change normally." |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1311 (let ((handle (make-symbol "--change-group-handle--")) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1312 (success (make-symbol "--change-group-success--"))) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1313 `(let ((,handle (prepare-change-group)) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1314 (,success nil)) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1315 (unwind-protect |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1316 (progn |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1317 ;; This is inside the unwind-protect because |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1318 ;; it enables undo if that was disabled; we need |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1319 ;; to make sure that it gets disabled again. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1320 (activate-change-group ,handle) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1321 ,@body |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1322 (setq ,success t)) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1323 ;; Either of these functions will disable undo |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1324 ;; if it was disabled before. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1325 (if ,success |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1326 (accept-change-group ,handle) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1327 (cancel-change-group ,handle)))))) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1328 |
51068
4441e202a6f4
(prepare-change-group): Reinstate BUFFER arg; make it work.
Richard M. Stallman <rms@gnu.org>
parents:
51062
diff
changeset
|
1329 (defun prepare-change-group (&optional buffer) |
43126
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1330 "Return a handle for the current buffer's state, for a change group. |
51068
4441e202a6f4
(prepare-change-group): Reinstate BUFFER arg; make it work.
Richard M. Stallman <rms@gnu.org>
parents:
51062
diff
changeset
|
1331 If you specify BUFFER, make a handle for BUFFER's state instead. |
43126
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1332 |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1333 Pass the handle to `activate-change-group' afterward to initiate |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1334 the actual changes of the change group. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1335 |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1336 To finish the change group, call either `accept-change-group' or |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1337 `cancel-change-group' passing the same handle as argument. Call |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1338 `accept-change-group' to accept the changes in the group as final; |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1339 call `cancel-change-group' to undo them all. You should use |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1340 `unwind-protect' to make sure the group is always finished. The call |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1341 to `activate-change-group' should be inside the `unwind-protect'. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1342 Once you finish the group, don't use the handle again--don't try to |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1343 finish the same group twice. For a simple example of correct use, see |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1344 the source code of `atomic-change-group'. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1345 |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1346 The handle records only the specified buffer. To make a multibuffer |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1347 change group, call this function once for each buffer you want to |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1348 cover, then use `nconc' to combine the returned values, like this: |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1349 |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1350 (nconc (prepare-change-group buffer-1) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1351 (prepare-change-group buffer-2)) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1352 |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1353 You can then activate that multibuffer change group with a single |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1354 call to `activate-change-group' and finish it with a single call |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1355 to `accept-change-group' or `cancel-change-group'." |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1356 |
51068
4441e202a6f4
(prepare-change-group): Reinstate BUFFER arg; make it work.
Richard M. Stallman <rms@gnu.org>
parents:
51062
diff
changeset
|
1357 (if buffer |
4441e202a6f4
(prepare-change-group): Reinstate BUFFER arg; make it work.
Richard M. Stallman <rms@gnu.org>
parents:
51062
diff
changeset
|
1358 (list (cons buffer (with-current-buffer buffer buffer-undo-list))) |
4441e202a6f4
(prepare-change-group): Reinstate BUFFER arg; make it work.
Richard M. Stallman <rms@gnu.org>
parents:
51062
diff
changeset
|
1359 (list (cons (current-buffer) buffer-undo-list)))) |
43126
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1360 |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1361 (defun activate-change-group (handle) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1362 "Activate a change group made with `prepare-change-group' (which see)." |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1363 (dolist (elt handle) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1364 (with-current-buffer (car elt) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1365 (if (eq buffer-undo-list t) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1366 (setq buffer-undo-list nil))))) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1367 |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1368 (defun accept-change-group (handle) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1369 "Finish a change group made with `prepare-change-group' (which see). |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1370 This finishes the change group by accepting its changes as final." |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1371 (dolist (elt handle) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1372 (with-current-buffer (car elt) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1373 (if (eq elt t) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1374 (setq buffer-undo-list t))))) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1375 |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1376 (defun cancel-change-group (handle) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1377 "Finish a change group made with `prepare-change-group' (which see). |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1378 This finishes the change group by reverting all of its changes." |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1379 (dolist (elt handle) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1380 (with-current-buffer (car elt) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1381 (setq elt (cdr elt)) |
47916 | 1382 (let ((old-car |
43126
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1383 (if (consp elt) (car elt))) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1384 (old-cdr |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1385 (if (consp elt) (cdr elt)))) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1386 ;; Temporarily truncate the undo log at ELT. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1387 (when (consp elt) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1388 (setcar elt nil) (setcdr elt nil)) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1389 (unless (eq last-command 'undo) (undo-start)) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1390 ;; Make sure there's no confusion. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1391 (when (and (consp elt) (not (eq elt (last pending-undo-list)))) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1392 (error "Undoing to some unrelated state")) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1393 ;; Undo it all. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1394 (while pending-undo-list (undo-more 1)) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1395 ;; Reset the modified cons cell ELT to its original content. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1396 (when (consp elt) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1397 (setcar elt old-car) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1398 (setcdr elt old-cdr)) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1399 ;; Revert the undo info to what it was when we grabbed the state. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1400 (setq buffer-undo-list elt))))) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
1401 |
44285
30505fab0350
(redraw-modeline): Define alias.
Richard M. Stallman <rms@gnu.org>
parents:
44251
diff
changeset
|
1402 ;; For compatibility. |
30505fab0350
(redraw-modeline): Define alias.
Richard M. Stallman <rms@gnu.org>
parents:
44251
diff
changeset
|
1403 (defalias 'redraw-modeline 'force-mode-line-update) |
30505fab0350
(redraw-modeline): Define alias.
Richard M. Stallman <rms@gnu.org>
parents:
44251
diff
changeset
|
1404 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1405 (defun force-mode-line-update (&optional all) |
52858
b4112065d679
(force-mode-line-update): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
1406 "Force redisplay of the current buffer's mode line and header line. |
b4112065d679
(force-mode-line-update): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
1407 With optional non-nil ALL, force redisplay of all mode lines and |
b4112065d679
(force-mode-line-update): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
1408 header lines. This function also forces recomputation of the |
b4112065d679
(force-mode-line-update): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
1409 menu bar menus and the frame title." |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1410 (if all (save-excursion (set-buffer (other-buffer)))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1411 (set-buffer-modified-p (buffer-modified-p))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1412 |
41618
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1413 (defun momentary-string-display (string pos &optional exit-char message) |
114 | 1414 "Momentarily display STRING in the buffer at POS. |
1415 Display remains until next character is typed. | |
1416 If the char is EXIT-CHAR (optional third arg, default is SPC) it is swallowed; | |
1417 otherwise it is then available as input (as a command if nothing else). | |
1418 Display MESSAGE (optional fourth arg) in the echo area. | |
1419 If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there." | |
1420 (or exit-char (setq exit-char ?\ )) | |
24322
ca77d79a0c21
(momentary-string-display): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
24245
diff
changeset
|
1421 (let ((inhibit-read-only t) |
6553
fca6271b0983
(momentary-string-display): Avoid modifying the undo list.
Richard M. Stallman <rms@gnu.org>
parents:
6551
diff
changeset
|
1422 ;; Don't modify the undo list at all. |
fca6271b0983
(momentary-string-display): Avoid modifying the undo list.
Richard M. Stallman <rms@gnu.org>
parents:
6551
diff
changeset
|
1423 (buffer-undo-list t) |
114 | 1424 (modified (buffer-modified-p)) |
1425 (name buffer-file-name) | |
1426 insert-end) | |
1427 (unwind-protect | |
1428 (progn | |
1429 (save-excursion | |
1430 (goto-char pos) | |
1431 ;; defeat file locking... don't try this at home, kids! | |
1432 (setq buffer-file-name nil) | |
1433 (insert-before-markers string) | |
4620
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
1434 (setq insert-end (point)) |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
1435 ;; If the message end is off screen, recenter now. |
21173
e917eb0d4e01
(save-match-data): store-match-data => set-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
21092
diff
changeset
|
1436 (if (< (window-end nil t) insert-end) |
4620
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
1437 (recenter (/ (window-height) 2))) |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
1438 ;; If that pushed message start off the screen, |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
1439 ;; scroll to start it at the top of the screen. |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
1440 (move-to-window-line 0) |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
1441 (if (> (point) pos) |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
1442 (progn |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
1443 (goto-char pos) |
5474175de175
(momentary-string-display): Scroll to keep the string on the screen.
Richard M. Stallman <rms@gnu.org>
parents:
4518
diff
changeset
|
1444 (recenter 0)))) |
114 | 1445 (message (or message "Type %s to continue editing.") |
1446 (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
|
1447 (let ((char (read-event))) |
114 | 1448 (or (eq char exit-char) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1695
diff
changeset
|
1449 (setq unread-command-events (list char))))) |
114 | 1450 (if insert-end |
1451 (save-excursion | |
1452 (delete-region pos insert-end))) | |
1453 (setq buffer-file-name name) | |
1454 (set-buffer-modified-p modified)))) | |
1455 | |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1456 |
41618
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1457 ;;;; Overlay operations |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1458 |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1459 (defun copy-overlay (o) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1460 "Return a copy of overlay O." |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1461 (let ((o1 (make-overlay (overlay-start o) (overlay-end o) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1462 ;; FIXME: there's no easy way to find the |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1463 ;; insertion-type of the two markers. |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1464 (overlay-buffer o))) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1465 (props (overlay-properties o))) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1466 (while props |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1467 (overlay-put o1 (pop props) (pop props))) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1468 o1)) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1469 |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1470 (defun remove-overlays (beg end name val) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1471 "Clear BEG and END of overlays whose property NAME has value VAL. |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1472 Overlays might be moved and or split." |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1473 (if (< end beg) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1474 (setq beg (prog1 end (setq end beg)))) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1475 (save-excursion |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1476 (dolist (o (overlays-in beg end)) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1477 (when (eq (overlay-get o name) val) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1478 ;; Either push this overlay outside beg...end |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1479 ;; or split it to exclude beg...end |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1480 ;; or delete it entirely (if it is contained in beg...end). |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1481 (if (< (overlay-start o) beg) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1482 (if (> (overlay-end o) end) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1483 (progn |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1484 (move-overlay (copy-overlay o) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1485 (overlay-start o) beg) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1486 (move-overlay o end (overlay-end o))) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1487 (move-overlay o (overlay-start o) beg)) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1488 (if (> (overlay-end o) end) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1489 (move-overlay o end (overlay-end o)) |
812e52cc5162
(copy-overlay, remove-overlays): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41187
diff
changeset
|
1490 (delete-overlay o))))))) |
42917
ec2db12c7670
(copy-without-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
42266
diff
changeset
|
1491 |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1492 ;;;; Miscellanea. |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1493 |
10254
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1494 ;; A number of major modes set this locally. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1495 ;; Give it a global value to avoid compiler warnings. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1496 (defvar font-lock-defaults nil) |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1497 |
20846
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
1498 (defvar suspend-hook nil |
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
1499 "Normal hook run by `suspend-emacs', before suspending.") |
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
1500 |
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
1501 (defvar suspend-resume-hook nil |
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
1502 "Normal hook run by `suspend-emacs', after Emacs is continued.") |
985a277c9b9a
(suspend-hook, suspend-resume-hook): New defvars.
Richard M. Stallman <rms@gnu.org>
parents:
20687
diff
changeset
|
1503 |
42083
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1504 (defvar temp-buffer-show-hook nil |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1505 "Normal hook run by `with-output-to-temp-buffer' after displaying the buffer. |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1506 When the hook runs, the temporary buffer is current, and the window it |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1507 was displayed in is selected. This hook is normally set up with a |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1508 function to make the buffer read only, and find function names and |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1509 variable names in it, provided the major mode is still Help mode.") |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1510 |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1511 (defvar temp-buffer-setup-hook nil |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1512 "Normal hook run by `with-output-to-temp-buffer' at the start. |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1513 When the hook runs, the temporary buffer is current. |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1514 This hook is normally set up with a function to put the buffer in Help |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1515 mode.") |
981f93cc55d1
(temp-buffer-show-hook, temp-buffer-setup-hook): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
42076
diff
changeset
|
1516 |
10254
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1517 ;; Avoid compiler warnings about this variable, |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1518 ;; which has a special meaning on certain system types. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1519 (defvar buffer-file-type nil |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1520 "Non-nil if the visited file is a binary file. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1521 This variable is meaningful on MS-DOG and Windows NT. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1522 On those systems, it is automatically local in every buffer. |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1523 On other systems, this variable is normally always nil.") |
1ac3c8fea14a
(font-lock-defaults): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
10178
diff
changeset
|
1524 |
14515
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
1525 ;; This should probably be written in C (i.e., without using `walk-windows'). |
14707
ddcae263bb18
Make get-buffer-window-list take MINIBUF arg.
Simon Marshall <simon@gnu.org>
parents:
14517
diff
changeset
|
1526 (defun get-buffer-window-list (buffer &optional minibuf frame) |
14515
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
1527 "Return windows currently displaying BUFFER, or nil if none. |
14707
ddcae263bb18
Make get-buffer-window-list take MINIBUF arg.
Simon Marshall <simon@gnu.org>
parents:
14517
diff
changeset
|
1528 See `walk-windows' for the meaning of MINIBUF and FRAME." |
14517
8b88e5c2a6d5
Cope if get-buffer-window-list is given a buffer name (like get-buffer-window does).
Simon Marshall <simon@gnu.org>
parents:
14515
diff
changeset
|
1529 (let ((buffer (if (bufferp buffer) buffer (get-buffer buffer))) windows) |
14515
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
1530 (walk-windows (function (lambda (window) |
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
1531 (if (eq (window-buffer window) buffer) |
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
1532 (setq windows (cons window windows))))) |
14707
ddcae263bb18
Make get-buffer-window-list take MINIBUF arg.
Simon Marshall <simon@gnu.org>
parents:
14517
diff
changeset
|
1533 minibuf frame) |
14515
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
1534 windows)) |
b35134a0e47a
Added get-buffer-window-list.
Simon Marshall <simon@gnu.org>
parents:
14343
diff
changeset
|
1535 |
8211
08fb5e917205
(ignore): Put doc string in right place.
Richard M. Stallman <rms@gnu.org>
parents:
7693
diff
changeset
|
1536 (defun ignore (&rest ignore) |
08fb5e917205
(ignore): Put doc string in right place.
Richard M. Stallman <rms@gnu.org>
parents:
7693
diff
changeset
|
1537 "Do nothing and return nil. |
08fb5e917205
(ignore): Put doc string in right place.
Richard M. Stallman <rms@gnu.org>
parents:
7693
diff
changeset
|
1538 This function accepts any number of arguments, but ignores them." |
7400
c415ff549eed
(ignore): Allow interactive call.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1539 (interactive) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1540 nil) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1541 |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1542 (defun error (&rest args) |
13936 | 1543 "Signal an error, making error message by passing all args to `format'. |
1544 In Emacs, the convention is that error messages start with a capital | |
1545 letter but *do not* end with a period. Please follow this convention | |
1546 for the sake of consistency." | |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1547 (while t |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1548 (signal 'error (list (apply 'format args))))) |
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1549 |
5912
909b94d547c4
(user-original-login-name): Reduce to a defalias, since it's redundant with
Karl Heuer <kwzh@gnu.org>
parents:
5844
diff
changeset
|
1550 (defalias 'user-original-login-name 'user-login-name) |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1551 |
44668
52222efc9d4d
(insert-for-yank): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44473
diff
changeset
|
1552 (defvar yank-excluded-properties) |
52222efc9d4d
(insert-for-yank): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44473
diff
changeset
|
1553 |
44980
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1554 (defun remove-yank-excluded-properties (start end) |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1555 "Remove `yank-excluded-properties' between START and END positions. |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1556 Replaces `category' properties with their defined properties." |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1557 (let ((inhibit-read-only t)) |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1558 ;; Replace any `category' property with the properties it stands for. |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1559 (unless (memq yank-excluded-properties '(t nil)) |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1560 (save-excursion |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1561 (goto-char start) |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1562 (while (< (point) end) |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1563 (let ((cat (get-text-property (point) 'category)) |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1564 run-end) |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1565 (setq run-end |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1566 (next-single-property-change (point) 'category nil end)) |
47675
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1567 (when cat |
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1568 (let (run-end2 original) |
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1569 (remove-list-of-text-properties (point) run-end '(category)) |
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1570 (while (< (point) run-end) |
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1571 (setq run-end2 (next-property-change (point) nil run-end)) |
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1572 (setq original (text-properties-at (point))) |
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1573 (set-text-properties (point) run-end2 (symbol-plist cat)) |
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1574 (add-text-properties (point) run-end2 original) |
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1575 (goto-char run-end2)))) |
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1576 (goto-char run-end))))) |
44980
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1577 (if (eq yank-excluded-properties t) |
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1578 (set-text-properties start end nil) |
47675
cb548fe4bcdb
(remove-yank-excluded-properties): Fix bugs in handling of category properties.
Richard M. Stallman <rms@gnu.org>
parents:
47652
diff
changeset
|
1579 (remove-list-of-text-properties start end yank-excluded-properties)))) |
44980
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1580 |
49310
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1581 (defvar yank-undo-function) |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1582 |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1583 (defun insert-for-yank (string) |
53368
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1584 "Calls `insert-for-yank-1' repetitively for each `yank-handler' segment. |
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1585 |
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1586 See `insert-for-yank-1' for more details." |
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1587 (let (to) |
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1588 (while (setq to (next-single-property-change 0 'yank-handler string)) |
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1589 (insert-for-yank-1 (substring string 0 to)) |
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1590 (setq string (substring string to)))) |
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1591 (insert-for-yank-1 string)) |
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1592 |
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1593 (defun insert-for-yank-1 (string) |
49310
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1594 "Insert STRING at point, stripping some text properties. |
53368
6dab9150c9e0
(insert-for-yank): Call insert-for-yank-1 repetitively
Eli Zaretskii <eliz@is.elta.co.il>
parents:
53197
diff
changeset
|
1595 |
49310
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1596 Strip text properties from the inserted text according to |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1597 `yank-excluded-properties'. Otherwise just like (insert STRING). |
44723
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1598 |
49363 | 1599 If STRING has a non-nil `yank-handler' property on the first character, |
49310
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1600 the normal insert behaviour is modified in various ways. The value of |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1601 the yank-handler property must be a list with one to five elements |
49492
a144c40bb984
(insert-for-yank): Remove COMMAND element from yank handler.
Kim F. Storm <storm@cua.dk>
parents:
49363
diff
changeset
|
1602 with the following format: (FUNCTION PARAM NOEXCLUDE UNDO). |
49310
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1603 When FUNCTION is present and non-nil, it is called instead of `insert' |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1604 to insert the string. FUNCTION takes one argument--the object to insert. |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1605 If PARAM is present and non-nil, it replaces STRING as the object |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1606 passed to FUNCTION (or `insert'); for example, if FUNCTION is |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1607 `yank-rectangle', PARAM may be a list of strings to insert as a |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1608 rectangle. |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1609 If NOEXCLUDE is present and non-nil, the normal removal of the |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1610 yank-excluded-properties is not performed; instead FUNCTION is |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1611 responsible for removing those properties. This may be necessary |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1612 if FUNCTION adjusts point before or after inserting the object. |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1613 If UNDO is present and non-nil, it is a function that will be called |
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1614 by `yank-pop' to undo the insertion of the current object. It is |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49492
diff
changeset
|
1615 called with two arguments, the start and end of the current region. |
49492
a144c40bb984
(insert-for-yank): Remove COMMAND element from yank handler.
Kim F. Storm <storm@cua.dk>
parents:
49363
diff
changeset
|
1616 FUNCTION may set `yank-undo-function' to override the UNDO value." |
49318
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1617 (let* ((handler (and (stringp string) |
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1618 (get-text-property 0 'yank-handler string))) |
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1619 (param (or (nth 1 handler) string)) |
49310
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1620 (opoint (point))) |
49318
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1621 (setq yank-undo-function t) |
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1622 (if (nth 0 handler) ;; FUNCTION |
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1623 (funcall (car handler) param) |
49310
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1624 (insert param)) |
49318
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1625 (unless (nth 2 handler) ;; NOEXCLUDE |
49310
32fe2d888907
(insert-for-yank): Arg list changed; now only accepts one
Kim F. Storm <storm@cua.dk>
parents:
49225
diff
changeset
|
1626 (remove-yank-excluded-properties opoint (point))) |
49318
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1627 (if (eq yank-undo-function t) ;; not set by FUNCTION |
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1628 (setq yank-undo-function (nth 3 handler))) ;; UNDO |
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1629 (if (nth 4 handler) ;; COMMAND |
63a122cc4286
(insert-for-yank): Set yank-undo-function after calling FUNCTION,
Kim F. Storm <storm@cua.dk>
parents:
49313
diff
changeset
|
1630 (setq this-command (nth 4 handler))))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49492
diff
changeset
|
1631 |
44723
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1632 (defun insert-buffer-substring-no-properties (buf &optional start end) |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1633 "Insert before point a substring of buffer BUFFER, without text properties. |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1634 BUFFER may be a buffer or a buffer name. |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1635 Arguments START and END are character numbers specifying the substring. |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1636 They default to the beginning and the end of BUFFER." |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1637 (let ((opoint (point))) |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1638 (insert-buffer-substring buf start end) |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1639 (let ((inhibit-read-only t)) |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1640 (set-text-properties opoint (point) nil)))) |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1641 |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1642 (defun insert-buffer-substring-as-yank (buf &optional start end) |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1643 "Insert before point a part of buffer BUFFER, stripping some text properties. |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1644 BUFFER may be a buffer or a buffer name. Arguments START and END are |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1645 character numbers specifying the substring. They default to the |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1646 beginning and the end of BUFFER. Strip text properties from the |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1647 inserted text according to `yank-excluded-properties'." |
52379 | 1648 ;; Since the buffer text should not normally have yank-handler properties, |
1649 ;; there is no need to handle them here. | |
44723
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1650 (let ((opoint (point))) |
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1651 (insert-buffer-substring buf start end) |
44980
5eb4aa56b278
(remove-yank-excluded-properties): New helper function.
Kim F. Storm <storm@cua.dk>
parents:
44945
diff
changeset
|
1652 (remove-yank-excluded-properties opoint (point)))) |
44723
f5b7b7055a64
(insert-buffer-substring-no-properties): New function.
Kim F. Storm <storm@cua.dk>
parents:
44668
diff
changeset
|
1653 |
44668
52222efc9d4d
(insert-for-yank): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44473
diff
changeset
|
1654 |
52222efc9d4d
(insert-for-yank): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44473
diff
changeset
|
1655 ;; Synchronous shell commands. |
52222efc9d4d
(insert-for-yank): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44473
diff
changeset
|
1656 |
114 | 1657 (defun start-process-shell-command (name buffer &rest args) |
1658 "Start a program in a subprocess. Return the process object for it. | |
1659 Args are NAME BUFFER COMMAND &rest COMMAND-ARGS. | |
1660 NAME is name for process. It is modified if necessary to make it unique. | |
1661 BUFFER is the buffer or (buffer-name) to associate with the process. | |
1662 Process output goes at end of that buffer, unless you specify | |
1663 an output stream or filter function to handle the output. | |
1664 BUFFER may be also nil, meaning that this process is not associated | |
1665 with any buffer | |
1666 Third arg is command name, the name of a shell command. | |
1667 Remaining arguments are the arguments for the command. | |
5460
3bd42ee22d1f
(start-process-shell-command): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5440
diff
changeset
|
1668 Wildcards and redirection are handled as usual in the shell." |
9822
248462096d25
(start-process-shell-command): Don't use exec on windows-nt.
Karl Heuer <kwzh@gnu.org>
parents:
9535
diff
changeset
|
1669 (cond |
248462096d25
(start-process-shell-command): Don't use exec on windows-nt.
Karl Heuer <kwzh@gnu.org>
parents:
9535
diff
changeset
|
1670 ((eq system-type 'vax-vms) |
248462096d25
(start-process-shell-command): Don't use exec on windows-nt.
Karl Heuer <kwzh@gnu.org>
parents:
9535
diff
changeset
|
1671 (apply 'start-process name buffer args)) |
10025
3b058e13d177
(start-process-shell-command): Don't use `exec'--
Richard M. Stallman <rms@gnu.org>
parents:
9986
diff
changeset
|
1672 ;; We used to use `exec' to replace the shell with the command, |
3b058e13d177
(start-process-shell-command): Don't use `exec'--
Richard M. Stallman <rms@gnu.org>
parents:
9986
diff
changeset
|
1673 ;; but that failed to handle (...) and semicolon, etc. |
9822
248462096d25
(start-process-shell-command): Don't use exec on windows-nt.
Karl Heuer <kwzh@gnu.org>
parents:
9535
diff
changeset
|
1674 (t |
248462096d25
(start-process-shell-command): Don't use exec on windows-nt.
Karl Heuer <kwzh@gnu.org>
parents:
9535
diff
changeset
|
1675 (start-process name buffer shell-file-name shell-command-switch |
10025
3b058e13d177
(start-process-shell-command): Don't use `exec'--
Richard M. Stallman <rms@gnu.org>
parents:
9986
diff
changeset
|
1676 (mapconcat 'identity args " "))))) |
39598
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1677 |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1678 (defun call-process-shell-command (command &optional infile buffer display |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1679 &rest args) |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1680 "Execute the shell command COMMAND synchronously in separate process. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1681 The remaining arguments are optional. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1682 The program's input comes from file INFILE (nil means `/dev/null'). |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1683 Insert output in BUFFER before point; t means current buffer; |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1684 nil for BUFFER means discard it; 0 means discard and don't wait. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1685 BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case, |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1686 REAL-BUFFER says what to do with standard output, as above, |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1687 while STDERR-FILE says what to do with standard error in the child. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1688 STDERR-FILE may be nil (discard standard error output), |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1689 t (mix it with ordinary output), or a file name string. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1690 |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1691 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1692 Remaining arguments are strings passed as additional arguments for COMMAND. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1693 Wildcards and redirection are handled as usual in the shell. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1694 |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1695 If BUFFER is 0, `call-process-shell-command' returns immediately with value nil. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1696 Otherwise it waits for COMMAND to terminate and returns a numeric exit |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1697 status or a signal description string. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1698 If you quit, the process is killed with SIGINT, or SIGKILL if you quit again." |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1699 (cond |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1700 ((eq system-type 'vax-vms) |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1701 (apply 'call-process command infile buffer display args)) |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1702 ;; We used to use `exec' to replace the shell with the command, |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1703 ;; but that failed to handle (...) and semicolon, etc. |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1704 (t |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1705 (call-process shell-file-name |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1706 infile buffer display |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1707 shell-command-switch |
67884544e4c8
(call-process-shell-command): New function.
Miles Bader <miles@gnu.org>
parents:
39557
diff
changeset
|
1708 (mapconcat 'identity (cons command args) " "))))) |
16359
18cc78dc8b18
(with-temp-file): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16333
diff
changeset
|
1709 |
16277
bbddbc86b82b
(with-current-buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
15983
diff
changeset
|
1710 (defmacro with-current-buffer (buffer &rest body) |
bbddbc86b82b
(with-current-buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
15983
diff
changeset
|
1711 "Execute the forms in BODY with BUFFER as the current buffer. |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1712 The value returned is the value of the last form in BODY. |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1713 See also `with-temp-buffer'." |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1714 (declare (indent 1) (debug t)) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1715 `(save-current-buffer |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1716 (set-buffer ,buffer) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1717 ,@body)) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1718 |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1719 (defmacro with-selected-window (window &rest body) |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1720 "Execute the forms in BODY with WINDOW as the selected window. |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1721 The value returned is the value of the last form in BODY. |
51980
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1722 This does not alter the buffer list ordering. |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1723 See also `with-temp-buffer'." |
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1724 (declare (indent 1) (debug t)) |
51980
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1725 ;; Most of this code is a copy of save-selected-window. |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1726 `(let ((save-selected-window-window (selected-window)) |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1727 (save-selected-window-alist |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1728 (mapcar (lambda (frame) (list frame (frame-selected-window frame))) |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1729 (frame-list)))) |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1730 (unwind-protect |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1731 (progn (select-window ,window 'norecord) |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1732 ,@body) |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1733 (dolist (elt save-selected-window-alist) |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1734 (and (frame-live-p (car elt)) |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1735 (window-live-p (cadr elt)) |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1736 (set-frame-selected-window (car elt) (cadr elt)))) |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1737 (if (window-live-p save-selected-window-window) |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1738 ;; This is where the code differs from save-selected-window. |
51983
9e88997e86c3
(with-selected-window): Add closing paren.
John Paul Wallington <jpw@pobox.com>
parents:
51980
diff
changeset
|
1739 (select-window save-selected-window-window 'norecord))))) |
16277
bbddbc86b82b
(with-current-buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
15983
diff
changeset
|
1740 |
23736 | 1741 (defmacro with-temp-file (file &rest body) |
1742 "Create a new buffer, evaluate BODY there, and write the buffer to FILE. | |
1743 The value returned is the value of the last form in BODY. | |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1744 See also `with-temp-buffer'." |
51611
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
1745 (declare (debug t)) |
16359
18cc78dc8b18
(with-temp-file): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16333
diff
changeset
|
1746 (let ((temp-file (make-symbol "temp-file")) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1747 (temp-buffer (make-symbol "temp-buffer"))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1748 `(let ((,temp-file ,file) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1749 (,temp-buffer |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1750 (get-buffer-create (generate-new-buffer-name " *temp file*")))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1751 (unwind-protect |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1752 (prog1 |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1753 (with-current-buffer ,temp-buffer |
23736 | 1754 ,@body) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1755 (with-current-buffer ,temp-buffer |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1756 (widen) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1757 (write-region (point-min) (point-max) ,temp-file nil 0))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1758 (and (buffer-name ,temp-buffer) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1759 (kill-buffer ,temp-buffer)))))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1760 |
23736 | 1761 (defmacro with-temp-message (message &rest body) |
24011 | 1762 "Display MESSAGE temporarily if non-nil while BODY is evaluated. |
23736 | 1763 The original message is restored to the echo area after BODY has finished. |
1764 The value returned is the value of the last form in BODY. | |
24011 | 1765 MESSAGE is written to the message log buffer if `message-log-max' is non-nil. |
1766 If MESSAGE is nil, the echo area and message log buffer are unchanged. | |
1767 Use a MESSAGE of \"\" to temporarily clear the echo area." | |
51611
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
1768 (declare (debug t)) |
24000
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1769 (let ((current-message (make-symbol "current-message")) |
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1770 (temp-message (make-symbol "with-temp-message"))) |
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1771 `(let ((,temp-message ,message) |
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1772 (,current-message)) |
23736 | 1773 (unwind-protect |
1774 (progn | |
24000
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1775 (when ,temp-message |
2de7db40964d
(with-temp-message): Don't display MESSAGE if nil.
Simon Marshall <simon@gnu.org>
parents:
23907
diff
changeset
|
1776 (setq ,current-message (current-message)) |
24699
1ce8c890309e
(with-temp-message): Fix the other call to message to use %s.
Karl Heuer <kwzh@gnu.org>
parents:
24385
diff
changeset
|
1777 (message "%s" ,temp-message)) |
23736 | 1778 ,@body) |
42076
d6765861f6ea
(with-temp-message): At the end, always discard
Richard M. Stallman <rms@gnu.org>
parents:
41975
diff
changeset
|
1779 (and ,temp-message |
d6765861f6ea
(with-temp-message): At the end, always discard
Richard M. Stallman <rms@gnu.org>
parents:
41975
diff
changeset
|
1780 (if ,current-message |
d6765861f6ea
(with-temp-message): At the end, always discard
Richard M. Stallman <rms@gnu.org>
parents:
41975
diff
changeset
|
1781 (message "%s" ,current-message) |
d6765861f6ea
(with-temp-message): At the end, always discard
Richard M. Stallman <rms@gnu.org>
parents:
41975
diff
changeset
|
1782 (message nil))))))) |
23736 | 1783 |
1784 (defmacro with-temp-buffer (&rest body) | |
1785 "Create a temporary buffer, and evaluate BODY there like `progn'. | |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1786 See also `with-temp-file' and `with-output-to-string'." |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1787 (declare (indent 0) (debug t)) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1788 (let ((temp-buffer (make-symbol "temp-buffer"))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1789 `(let ((,temp-buffer |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1790 (get-buffer-create (generate-new-buffer-name " *temp*")))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1791 (unwind-protect |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1792 (with-current-buffer ,temp-buffer |
23736 | 1793 ,@body) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1794 (and (buffer-name ,temp-buffer) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1795 (kill-buffer ,temp-buffer)))))) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1796 |
16311
a56a8c6f2d8f
(with-output-to-string): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16294
diff
changeset
|
1797 (defmacro with-output-to-string (&rest body) |
a56a8c6f2d8f
(with-output-to-string): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16294
diff
changeset
|
1798 "Execute BODY, return the text it sent to `standard-output', as a string." |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1799 (declare (indent 0) (debug t)) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1800 `(let ((standard-output |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1801 (get-buffer-create (generate-new-buffer-name " *string-output*")))) |
16311
a56a8c6f2d8f
(with-output-to-string): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16294
diff
changeset
|
1802 (let ((standard-output standard-output)) |
a56a8c6f2d8f
(with-output-to-string): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16294
diff
changeset
|
1803 ,@body) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1804 (with-current-buffer standard-output |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1805 (prog1 |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1806 (buffer-string) |
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1807 (kill-buffer nil))))) |
16549
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1808 |
40822
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
1809 (defmacro with-local-quit (&rest body) |
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
1810 "Execute BODY with `inhibit-quit' temporarily bound to nil." |
48475
4bdcb09d9f25
(symbol-file): Accept a non-atomic `function' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48474
diff
changeset
|
1811 (declare (debug t) (indent 0)) |
40822
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
1812 `(condition-case nil |
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
1813 (let ((inhibit-quit nil)) |
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
1814 ,@body) |
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
1815 (quit (setq quit-flag t)))) |
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
1816 |
16549
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1817 (defmacro combine-after-change-calls (&rest body) |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1818 "Execute BODY, but don't call the after-change functions till the end. |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1819 If BODY makes changes in the buffer, they are recorded |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1820 and the functions on `after-change-functions' are called several times |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1821 when BODY is finished. |
17146
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
1822 The return value is the value of the last form in BODY. |
16549
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1823 |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1824 If `before-change-functions' is non-nil, then calls to the after-change |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1825 functions can't be deferred, so in that case this macro has no effect. |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1826 |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1827 Do not alter `after-change-functions' or `before-change-functions' |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1828 in BODY." |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1829 (declare (indent 0) (debug t)) |
16549
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1830 `(unwind-protect |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1831 (let ((combine-after-change-calls t)) |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1832 . ,body) |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1833 (combine-after-change-execute))) |
30ddd0e52ace
(combine-after-change-calls): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16437
diff
changeset
|
1834 |
28234
763c6639628b
(combine-run-hooks): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28148
diff
changeset
|
1835 |
40282
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1836 (defvar delay-mode-hooks nil |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1837 "If non-nil, `run-mode-hooks' should delay running the hooks.") |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1838 (defvar delayed-mode-hooks nil |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1839 "List of delayed mode hooks waiting to be run.") |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1840 (make-variable-buffer-local 'delayed-mode-hooks) |
53412
a2bba9e88b95
(assoc-ignore-case, assoc-ignore-representation):
Richard M. Stallman <rms@gnu.org>
parents:
53368
diff
changeset
|
1841 (put 'delay-mode-hooks 'permanent-local t) |
40282
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1842 |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1843 (defun run-mode-hooks (&rest hooks) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1844 "Run mode hooks `delayed-mode-hooks' and HOOKS, or delay HOOKS. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1845 Execution is delayed if `delay-mode-hooks' is non-nil. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1846 Major mode functions should use this." |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1847 (if delay-mode-hooks |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1848 ;; Delaying case. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1849 (dolist (hook hooks) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1850 (push hook delayed-mode-hooks)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1851 ;; Normal case, just run the hook as before plus any delayed hooks. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1852 (setq hooks (nconc (nreverse delayed-mode-hooks) hooks)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1853 (setq delayed-mode-hooks nil) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1854 (apply 'run-hooks hooks))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1855 |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1856 (defmacro delay-mode-hooks (&rest body) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1857 "Execute BODY, but delay any `run-mode-hooks'. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1858 Only affects hooks run in the current buffer." |
51611
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
1859 (declare (debug t)) |
40282
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1860 `(progn |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1861 (make-local-variable 'delay-mode-hooks) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1862 (let ((delay-mode-hooks t)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1863 ,@body))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
1864 |
41975
2b1145fdbe6e
(derived-mode-p): Moved here from derived.el.
Richard M. Stallman <rms@gnu.org>
parents:
41955
diff
changeset
|
1865 ;; PUBLIC: find if the current mode derives from another. |
2b1145fdbe6e
(derived-mode-p): Moved here from derived.el.
Richard M. Stallman <rms@gnu.org>
parents:
41955
diff
changeset
|
1866 |
2b1145fdbe6e
(derived-mode-p): Moved here from derived.el.
Richard M. Stallman <rms@gnu.org>
parents:
41955
diff
changeset
|
1867 (defun derived-mode-p (&rest modes) |
2b1145fdbe6e
(derived-mode-p): Moved here from derived.el.
Richard M. Stallman <rms@gnu.org>
parents:
41955
diff
changeset
|
1868 "Non-nil if the current major mode is derived from one of MODES. |
2b1145fdbe6e
(derived-mode-p): Moved here from derived.el.
Richard M. Stallman <rms@gnu.org>
parents:
41955
diff
changeset
|
1869 Uses the `derived-mode-parent' property of the symbol to trace backwards." |
2b1145fdbe6e
(derived-mode-p): Moved here from derived.el.
Richard M. Stallman <rms@gnu.org>
parents:
41955
diff
changeset
|
1870 (let ((parent major-mode)) |
2b1145fdbe6e
(derived-mode-p): Moved here from derived.el.
Richard M. Stallman <rms@gnu.org>
parents:
41955
diff
changeset
|
1871 (while (and (not (memq parent modes)) |
2b1145fdbe6e
(derived-mode-p): Moved here from derived.el.
Richard M. Stallman <rms@gnu.org>
parents:
41955
diff
changeset
|
1872 (setq parent (get parent 'derived-mode-parent)))) |
2b1145fdbe6e
(derived-mode-p): Moved here from derived.el.
Richard M. Stallman <rms@gnu.org>
parents:
41955
diff
changeset
|
1873 parent)) |
2b1145fdbe6e
(derived-mode-p): Moved here from derived.el.
Richard M. Stallman <rms@gnu.org>
parents:
41955
diff
changeset
|
1874 |
27297
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1875 (defmacro with-syntax-table (table &rest body) |
49888
c0dd4de41e91
(with-syntax-table): Don't copy the table any more.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49597
diff
changeset
|
1876 "Evaluate BODY with syntax table of current buffer set to TABLE. |
27297
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1877 The syntax table of the current buffer is saved, BODY is evaluated, and the |
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1878 saved table is restored, even in case of an abnormal exit. |
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1879 Value is what BODY returns." |
51611
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
1880 (declare (debug t)) |
27384
a10a13dd0670
(with-syntax-table): Use make-symbol, not gensym.
Richard M. Stallman <rms@gnu.org>
parents:
27383
diff
changeset
|
1881 (let ((old-table (make-symbol "table")) |
a10a13dd0670
(with-syntax-table): Use make-symbol, not gensym.
Richard M. Stallman <rms@gnu.org>
parents:
27383
diff
changeset
|
1882 (old-buffer (make-symbol "buffer"))) |
27297
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1883 `(let ((,old-table (syntax-table)) |
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1884 (,old-buffer (current-buffer))) |
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1885 (unwind-protect |
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1886 (progn |
49888
c0dd4de41e91
(with-syntax-table): Don't copy the table any more.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49597
diff
changeset
|
1887 (set-syntax-table ,table) |
27297
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1888 ,@body) |
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1889 (save-current-buffer |
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1890 (set-buffer ,old-buffer) |
f5713c397636
(with-syntax-table): Moved from simple.el.
Richard M. Stallman <rms@gnu.org>
parents:
26084
diff
changeset
|
1891 (set-syntax-table ,old-table)))))) |
51695
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1892 |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1893 (defmacro dynamic-completion-table (fun) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1894 "Use function FUN as a dynamic completion table. |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1895 FUN is called with one argument, the string for which completion is required, |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1896 and it should return an alist containing all the intended possible |
51980
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1897 completions. This alist may be a full list of possible completions so that FUN |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1898 can ignore the value of its argument. If completion is performed in the |
51695
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1899 minibuffer, FUN will be called in the buffer from which the minibuffer was |
51980
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1900 entered. |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1901 |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1902 The result of the `dynamic-completion-table' form is a function |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1903 that can be used as the ALIST argument to `try-completion' and |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1904 `all-completion'. See Info node `(elisp)Programmed Completion'." |
51695
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1905 (let ((win (make-symbol "window")) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1906 (string (make-symbol "string")) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1907 (predicate (make-symbol "predicate")) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1908 (mode (make-symbol "mode"))) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1909 `(lambda (,string ,predicate ,mode) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1910 (with-current-buffer (let ((,win (minibuffer-selected-window))) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1911 (if (window-live-p ,win) (window-buffer ,win) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1912 (current-buffer))) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1913 (cond |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1914 ((eq ,mode t) (all-completions ,string (,fun ,string) ,predicate)) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1915 ((not ,mode) (try-completion ,string (,fun ,string) ,predicate)) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1916 (t (test-completion ,string (,fun ,string) ,predicate))))))) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1917 |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1918 (defmacro lazy-completion-table (var fun &rest args) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1919 "Initialize variable VAR as a lazy completion table. |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1920 If the completion table VAR is used for the first time (e.g., by passing VAR |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1921 as an argument to `try-completion'), the function FUN is called with arguments |
51980
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1922 ARGS. FUN must return the completion table that will be stored in VAR. |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1923 If completion is requested in the minibuffer, FUN will be called in the buffer |
b7fa62a1a49d
(with-selected-window): Copy code form save-selected-window
Richard M. Stallman <rms@gnu.org>
parents:
51817
diff
changeset
|
1924 from which the minibuffer was entered. The return value of |
51695
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1925 `lazy-completion-table' must be used to initialize the value of VAR." |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1926 (let ((str (make-symbol "string"))) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1927 `(dynamic-completion-table |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1928 (lambda (,str) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1929 (unless (listp ,var) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1930 (setq ,var (funcall ',fun ,@args))) |
3e0f0ad2d93d
(lazy-completion-table, dynamic-completion-table): New macros.
Richard M. Stallman <rms@gnu.org>
parents:
51611
diff
changeset
|
1931 ,var)))) |
16379
dcc3625f52e2
(with-current-buffer): Minor cleanup.
Erik Naggum <erik@naggum.no>
parents:
16359
diff
changeset
|
1932 |
44668
52222efc9d4d
(insert-for-yank): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44473
diff
changeset
|
1933 ;;; Matching and substitution |
52222efc9d4d
(insert-for-yank): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44473
diff
changeset
|
1934 |
15955
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1935 (defvar save-match-data-internal) |
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1936 |
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1937 ;; We use save-match-data-internal as the local variable because |
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1938 ;; that works ok in practice (people should not use that variable elsewhere). |
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1939 ;; We used to use an uninterned symbol; the compiler handles that properly |
32d772cba2c1
(save-match-data): Use save-match-data-internal
Richard M. Stallman <rms@gnu.org>
parents:
15894
diff
changeset
|
1940 ;; now, but it generates slower code. |
2504
181eef669324
* subr.el (overlay-start, overlay-end, overlay-buffer): New
Jim Blandy <jimb@redhat.com>
parents:
2428
diff
changeset
|
1941 (defmacro save-match-data (&rest body) |
43527
d51d403fd80a
(save-match-data): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
43498
diff
changeset
|
1942 "Execute the BODY forms, restoring the global value of the match data. |
d51d403fd80a
(save-match-data): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
43498
diff
changeset
|
1943 The value returned is the value of the last form in BODY." |
26084
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1944 ;; It is better not to use backquote here, |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1945 ;; because that makes a bootstrapping problem |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1946 ;; if you need to recompile all the Lisp files using interpreted code. |
51051
b39d8ed2d159
(with-selected-window): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50694
diff
changeset
|
1947 (declare (indent 0) (debug t)) |
26084
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1948 (list 'let |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1949 '((save-match-data-internal (match-data))) |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1950 (list 'unwind-protect |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1951 (cons 'progn body) |
804cba424b64
Fix bootstrapping problems.
Paul Eggert <eggert@twinsun.com>
parents:
26002
diff
changeset
|
1952 '(set-match-data save-match-data-internal)))) |
144
535ec1aa78ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
114
diff
changeset
|
1953 |
11115
9414f249cd8b
Changed match-string to defun, but still return nil (no error) if no match.
Simon Marshall <simon@gnu.org>
parents:
11101
diff
changeset
|
1954 (defun match-string (num &optional string) |
11101
67231dca5f32
Change to macro, and return nil if there was no match at the specified depth.
Simon Marshall <simon@gnu.org>
parents:
11087
diff
changeset
|
1955 "Return string of text matched by last search. |
67231dca5f32
Change to macro, and return nil if there was no match at the specified depth.
Simon Marshall <simon@gnu.org>
parents:
11087
diff
changeset
|
1956 NUM specifies which parenthesized expression in the last regexp. |
67231dca5f32
Change to macro, and return nil if there was no match at the specified depth.
Simon Marshall <simon@gnu.org>
parents:
11087
diff
changeset
|
1957 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. |
67231dca5f32
Change to macro, and return nil if there was no match at the specified depth.
Simon Marshall <simon@gnu.org>
parents:
11087
diff
changeset
|
1958 Zero means the entire text matched by the whole regexp or whole string. |
67231dca5f32
Change to macro, and return nil if there was no match at the specified depth.
Simon Marshall <simon@gnu.org>
parents:
11087
diff
changeset
|
1959 STRING should be given if the last search was by `string-match' on STRING." |
11115
9414f249cd8b
Changed match-string to defun, but still return nil (no error) if no match.
Simon Marshall <simon@gnu.org>
parents:
11101
diff
changeset
|
1960 (if (match-beginning num) |
9414f249cd8b
Changed match-string to defun, but still return nil (no error) if no match.
Simon Marshall <simon@gnu.org>
parents:
11101
diff
changeset
|
1961 (if string |
9414f249cd8b
Changed match-string to defun, but still return nil (no error) if no match.
Simon Marshall <simon@gnu.org>
parents:
11101
diff
changeset
|
1962 (substring string (match-beginning num) (match-end num)) |
9414f249cd8b
Changed match-string to defun, but still return nil (no error) if no match.
Simon Marshall <simon@gnu.org>
parents:
11101
diff
changeset
|
1963 (buffer-substring (match-beginning num) (match-end num))))) |
10560
fd09d51dfd77
(match-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10368
diff
changeset
|
1964 |
20491
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1965 (defun match-string-no-properties (num &optional string) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1966 "Return string of text matched by last search, without text properties. |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1967 NUM specifies which parenthesized expression in the last regexp. |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1968 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1969 Zero means the entire text matched by the whole regexp or whole string. |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1970 STRING should be given if the last search was by `string-match' on STRING." |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1971 (if (match-beginning num) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1972 (if string |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1973 (let ((result |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1974 (substring string (match-beginning num) (match-end num)))) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1975 (set-text-properties 0 (length result) nil result) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1976 result) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1977 (buffer-substring-no-properties (match-beginning num) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1978 (match-end num))))) |
d884af34ba47
(match-string-no-properties): New function.
Richard M. Stallman <rms@gnu.org>
parents:
20476
diff
changeset
|
1979 |
51611
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
1980 (defun looking-back (regexp &optional limit) |
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
1981 "Return non-nil if text before point matches regular expression REGEXP. |
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
1982 Like `looking-at' except backwards and slower. |
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
1983 LIMIT if non-nil speeds up the search by specifying how far back the |
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
1984 match can start." |
51339
14976a545668
(looking-back): New function to check for regular expression before point.
Juanma Barranquero <lekktu@gmail.com>
parents:
51148
diff
changeset
|
1985 (save-excursion |
51611
d201fdadadce
(looking-back): Handle the case of non-trivial regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51339
diff
changeset
|
1986 (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t))) |
51339
14976a545668
(looking-back): New function to check for regular expression before point.
Juanma Barranquero <lekktu@gmail.com>
parents:
51148
diff
changeset
|
1987 |
51148
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1988 (defconst split-string-default-separators "[ \f\t\n\r\v]+" |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1989 "The default value of separators for `split-string'. |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1990 |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1991 A regexp matching strings of whitespace. May be locale-dependent |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1992 \(as yet unimplemented). Should not match non-breaking spaces. |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1993 |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1994 Warning: binding this to a different value and using it as default is |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1995 likely to have undesired semantics.") |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1996 |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1997 ;; The specification says that if both SEPARATORS and OMIT-NULLS are |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1998 ;; defaulted, OMIT-NULLS should be treated as t. Simplifying the logical |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
1999 ;; expression leads to the equivalent implementation that if SEPARATORS |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2000 ;; is defaulted, OMIT-NULLS is treated as t. |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2001 (defun split-string (string &optional separators omit-nulls) |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2002 "Splits STRING into substrings bounded by matches for SEPARATORS. |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2003 |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2004 The beginning and end of STRING, and each match for SEPARATORS, are |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2005 splitting points. The substrings matching SEPARATORS are removed, and |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2006 the substrings between the splitting points are collected as a list, |
16314
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2007 which is returned. |
51148
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2008 |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2009 If SEPARATORS is non-nil, it should be a regular expression matching text |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2010 which separates, but is not part of, the substrings. If nil it defaults to |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2011 `split-string-default-separators', normally \"[ \\f\\t\\n\\r\\v]+\", and |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2012 OMIT-NULLS is forced to t. |
20476
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
2013 |
51148
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2014 If OMIT-NULLs is t, zero-length substrings are omitted from the list \(so |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2015 that for the default value of SEPARATORS leading and trailing whitespace |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2016 are effectively trimmed). If nil, all zero-length substrings are retained, |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2017 which correctly parses CSV format, for example. |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2018 |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2019 Note that the effect of `(split-string STRING)' is the same as |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2020 `(split-string STRING split-string-default-separators t)'). In the rare |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2021 case that you wish to retain zero-length substrings when splitting on |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2022 whitespace, use `(split-string STRING split-string-default-separators)'. |
27810
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2023 |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2024 Modifies the match data; use `save-match-data' if necessary." |
51148
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2025 (let ((keep-nulls (not (if separators omit-nulls t))) |
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2026 (rexp (or separators split-string-default-separators)) |
16314
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2027 (start 0) |
20476
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
2028 notfirst |
16314
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2029 (list nil)) |
20476
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
2030 (while (and (string-match rexp string |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
2031 (if (and notfirst |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
2032 (= start (match-beginning 0)) |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
2033 (< start (length string))) |
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
2034 (1+ start) start)) |
51148
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2035 (< start (length string))) |
20476
f213a5906ea6
(split-string): Handle empty matches reasonably.
Richard M. Stallman <rms@gnu.org>
parents:
20472
diff
changeset
|
2036 (setq notfirst t) |
51148
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2037 (if (or keep-nulls (< start (match-beginning 0))) |
16314
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2038 (setq list |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2039 (cons (substring string start (match-beginning 0)) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2040 list))) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2041 (setq start (match-end 0))) |
51148
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2042 (if (or keep-nulls (< start (length string))) |
16314
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2043 (setq list |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2044 (cons (substring string start) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2045 list))) |
c72b7ee606a3
(split-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16311
diff
changeset
|
2046 (nreverse list))) |
24089
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
2047 |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
2048 (defun subst-char-in-string (fromchar tochar string &optional inplace) |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
2049 "Replace FROMCHAR with TOCHAR in STRING each time it occurs. |
70954a8be49b
(subst-char-in-string): New function.
Andrew Innes <andrewi@gnu.org>
parents:
24011
diff
changeset
|
2050 Unless optional argument INPLACE is non-nil, return a new string." |
33835
1b1555d26963
Undoing the changes erroneously committed just before.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33833
diff
changeset
|
2051 (let ((i (length string)) |
1b1555d26963
Undoing the changes erroneously committed just before.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33833
diff
changeset
|
2052 (newstr (if inplace string (copy-sequence string)))) |
1b1555d26963
Undoing the changes erroneously committed just before.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33833
diff
changeset
|
2053 (while (> i 0) |
1b1555d26963
Undoing the changes erroneously committed just before.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33833
diff
changeset
|
2054 (setq i (1- i)) |
1b1555d26963
Undoing the changes erroneously committed just before.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33833
diff
changeset
|
2055 (if (eq (aref newstr i) fromchar) |
1b1555d26963
Undoing the changes erroneously committed just before.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33833
diff
changeset
|
2056 (aset newstr i tochar))) |
1b1555d26963
Undoing the changes erroneously committed just before.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33833
diff
changeset
|
2057 newstr)) |
27810
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2058 |
28148
0f14966fe791
(replace-regexp-in-string): Renamed from
Dave Love <fx@gnu.org>
parents:
28065
diff
changeset
|
2059 (defun replace-regexp-in-string (regexp rep string &optional |
51148
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2060 fixedcase literal subexp start) |
27810
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2061 "Replace all matches for REGEXP with REP in STRING. |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2062 |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2063 Return a new string containing the replacements. |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2064 |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2065 Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2066 arguments with the same names of function `replace-match'. If START |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2067 is non-nil, start replacements at that index in STRING. |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2068 |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2069 REP is either a string used as the NEWTEXT arg of `replace-match' or a |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2070 function. If it is a function it is applied to each match to generate |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2071 the replacement passed to `replace-match'; the match-data at this |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2072 point are such that match 0 is the function's argument. |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2073 |
28148
0f14966fe791
(replace-regexp-in-string): Renamed from
Dave Love <fx@gnu.org>
parents:
28065
diff
changeset
|
2074 To replace only the first match (if any), make REGEXP match up to \\' |
0f14966fe791
(replace-regexp-in-string): Renamed from
Dave Love <fx@gnu.org>
parents:
28065
diff
changeset
|
2075 and replace a sub-expression, e.g. |
48077
69077a78e52f
(replace-regexp-in-string): Doc fix.
Andreas Schwab <schwab@suse.de>
parents:
47916
diff
changeset
|
2076 (replace-regexp-in-string \"\\\\(foo\\\\).*\\\\'\" \"bar\" \" foo foo\" nil nil 1) |
28148
0f14966fe791
(replace-regexp-in-string): Renamed from
Dave Love <fx@gnu.org>
parents:
28065
diff
changeset
|
2077 => \" bar foo\" |
0f14966fe791
(replace-regexp-in-string): Renamed from
Dave Love <fx@gnu.org>
parents:
28065
diff
changeset
|
2078 " |
27810
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2079 |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2080 ;; To avoid excessive consing from multiple matches in long strings, |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2081 ;; don't just call `replace-match' continually. Walk down the |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2082 ;; string looking for matches of REGEXP and building up a (reversed) |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2083 ;; list MATCHES. This comprises segments of STRING which weren't |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2084 ;; matched interspersed with replacements for segments that were. |
39557
fb85410efef7
(define-key-after): Allow `key' to be longer than 1.
Gerd Moellmann <gerd@gnu.org>
parents:
38760
diff
changeset
|
2085 ;; [For a `large' number of replacements it's more efficient to |
27810
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2086 ;; operate in a temporary buffer; we can't tell from the function's |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2087 ;; args whether to choose the buffer-based implementation, though it |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2088 ;; might be reasonable to do so for long enough STRING.] |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2089 (let ((l (length string)) |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2090 (start (or start 0)) |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2091 matches str mb me) |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2092 (save-match-data |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2093 (while (and (< start l) (string-match regexp string start)) |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2094 (setq mb (match-beginning 0) |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2095 me (match-end 0)) |
28065
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2096 ;; If we matched the empty string, make sure we advance by one char |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2097 (when (= me mb) (setq me (min l (1+ mb)))) |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2098 ;; Generate a replacement for the matched substring. |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2099 ;; Operate only on the substring to minimize string consing. |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2100 ;; Set up match data for the substring for replacement; |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2101 ;; presumably this is likely to be faster than munging the |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2102 ;; match data directly in Lisp. |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2103 (string-match regexp (setq str (substring string mb me))) |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2104 (setq matches |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2105 (cons (replace-match (if (stringp rep) |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2106 rep |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2107 (funcall rep (match-string 0 str))) |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2108 fixedcase literal str subexp) |
51148
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2109 (cons (substring string start mb) ; unmatched prefix |
28065
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2110 matches))) |
093dcd5f39b2
(replace-regexps-in-string): Properly handle the case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27908
diff
changeset
|
2111 (setq start me)) |
27810
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2112 ;; Reconstruct a string from the pieces. |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2113 (setq matches (cons (substring string start l) matches)) ; leftover |
1d7650c95e0a
(when, unless, split-string): Doc fix.
Dave Love <fx@gnu.org>
parents:
27482
diff
changeset
|
2114 (apply #'concat (nreverse matches))))) |
16359
18cc78dc8b18
(with-temp-file): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16333
diff
changeset
|
2115 |
5385
53077bf7c718
(shell-quote-argument): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5302
diff
changeset
|
2116 (defun shell-quote-argument (argument) |
53077bf7c718
(shell-quote-argument): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5302
diff
changeset
|
2117 "Quote an argument for passing as argument to an inferior shell." |
12465
0d404ef125ea
(shell-quote-argument): Don't do anything, on MS-DOS.
Richard M. Stallman <rms@gnu.org>
parents:
12395
diff
changeset
|
2118 (if (eq system-type 'ms-dos) |
25706
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2119 ;; Quote using double quotes, but escape any existing quotes in |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2120 ;; the argument with backslashes. |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2121 (let ((result "") |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2122 (start 0) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2123 end) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2124 (if (or (null (string-match "[^\"]" argument)) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2125 (< (match-end 0) (length argument))) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2126 (while (string-match "[\"]" argument start) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2127 (setq end (match-beginning 0) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2128 result (concat result (substring argument start end) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2129 "\\" (substring argument end (1+ end))) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2130 start (1+ end)))) |
498eb90e1723
(shell-quote-argument): Quote argument with double
Eli Zaretskii <eliz@gnu.org>
parents:
25631
diff
changeset
|
2131 (concat "\"" result (substring argument start) "\"")) |
12465
0d404ef125ea
(shell-quote-argument): Don't do anything, on MS-DOS.
Richard M. Stallman <rms@gnu.org>
parents:
12395
diff
changeset
|
2132 (if (eq system-type 'windows-nt) |
0d404ef125ea
(shell-quote-argument): Don't do anything, on MS-DOS.
Richard M. Stallman <rms@gnu.org>
parents:
12395
diff
changeset
|
2133 (concat "\"" argument "\"") |
17610
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2134 (if (equal argument "") |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2135 "''" |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2136 ;; Quote everything except POSIX filename characters. |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2137 ;; This should be safe enough even for really weird shells. |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2138 (let ((result "") (start 0) end) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2139 (while (string-match "[^-0-9a-zA-Z_./]" argument start) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2140 (setq end (match-beginning 0) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2141 result (concat result (substring argument start end) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2142 "\\" (substring argument end (1+ end))) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2143 start (1+ end))) |
f95fbf6f1234
(shell-quote-argument): Quote null string usefully.
Richard M. Stallman <rms@gnu.org>
parents:
17437
diff
changeset
|
2144 (concat result (substring argument start))))))) |
5385
53077bf7c718
(shell-quote-argument): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5302
diff
changeset
|
2145 |
5844
445de172c217
(make-syntax-table): Behave like copy-syntax-table if an argument is given,
Karl Heuer <kwzh@gnu.org>
parents:
5460
diff
changeset
|
2146 (defun make-syntax-table (&optional oldtable) |
5421
a248a39fa4b8
(make-syntax-table): New function; no longer an alias
Richard M. Stallman <rms@gnu.org>
parents:
5385
diff
changeset
|
2147 "Return a new syntax table. |
40822
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
2148 Create a syntax table which inherits from OLDTABLE (if non-nil) or |
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
2149 from `standard-syntax-table' otherwise." |
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
2150 (let ((table (make-char-table 'syntax-table nil))) |
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
2151 (set-char-table-parent table (or oldtable (standard-syntax-table))) |
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
2152 table)) |
17146
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
2153 |
47355
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
2154 (defun syntax-after (pos) |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
2155 "Return the syntax of the char after POS." |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
2156 (unless (or (< pos (point-min)) (>= pos (point-max))) |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
2157 (let ((st (if parse-sexp-lookup-properties |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
2158 (get-char-property pos 'syntax-table)))) |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
2159 (if (consp st) st |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
2160 (aref (or st (syntax-table)) (char-after pos)))))) |
9e3ee43b5262
(symbol-file): Also work for autoloaded funcs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47305
diff
changeset
|
2161 |
17146
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
2162 (defun add-to-invisibility-spec (arg) |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
2163 "Add elements to `buffer-invisibility-spec'. |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
2164 See documentation for `buffer-invisibility-spec' for the kind of elements |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
2165 that can be added." |
48935
6047d93c991e
(add-to-invisibility-spec): If it was t, start it out at (t).
Richard M. Stallman <rms@gnu.org>
parents:
48475
diff
changeset
|
2166 (if (eq buffer-invisibility-spec t) |
6047d93c991e
(add-to-invisibility-spec): If it was t, start it out at (t).
Richard M. Stallman <rms@gnu.org>
parents:
48475
diff
changeset
|
2167 (setq buffer-invisibility-spec (list t))) |
6047d93c991e
(add-to-invisibility-spec): If it was t, start it out at (t).
Richard M. Stallman <rms@gnu.org>
parents:
48475
diff
changeset
|
2168 (setq buffer-invisibility-spec |
6047d93c991e
(add-to-invisibility-spec): If it was t, start it out at (t).
Richard M. Stallman <rms@gnu.org>
parents:
48475
diff
changeset
|
2169 (cons arg buffer-invisibility-spec))) |
17146
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
2170 |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
2171 (defun remove-from-invisibility-spec (arg) |
b8536e42d4ef
(combine-after-change-calls): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16845
diff
changeset
|
2172 "Remove elements from `buffer-invisibility-spec'." |
24245
418feab1639c
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
24089
diff
changeset
|
2173 (if (consp buffer-invisibility-spec) |
17152 | 2174 (setq buffer-invisibility-spec (delete arg buffer-invisibility-spec)))) |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2175 |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2176 (defun global-set-key (key command) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2177 "Give KEY a global binding as COMMAND. |
20410
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2178 COMMAND is the command definition to use; usually it is |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2179 a symbol naming an interactively-callable function. |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2180 KEY is a key sequence; noninteractively, it is a string or vector |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2181 of characters or event types, and non-ASCII characters with codes |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2182 above 127 (such as ISO Latin-1) can be included if you use a vector. |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2183 |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2184 Note that if KEY has a local binding in the current buffer, |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2185 that local binding will continue to shadow any global binding |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2186 that you make with this function." |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2187 (interactive "KSet key globally: \nCSet key %s to command: ") |
43498
ecd03935bb98
(global-set-key, local-set-key): Undo 2002-02-06
Kim F. Storm <storm@cua.dk>
parents:
43435
diff
changeset
|
2188 (or (vectorp key) (stringp key) |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2189 (signal 'wrong-type-argument (list 'arrayp key))) |
21578
6175866e1b71
(local-set-key, global-set-key): Return what define-key returns.
Richard M. Stallman <rms@gnu.org>
parents:
21409
diff
changeset
|
2190 (define-key (current-global-map) key command)) |
5421
a248a39fa4b8
(make-syntax-table): New function; no longer an alias
Richard M. Stallman <rms@gnu.org>
parents:
5385
diff
changeset
|
2191 |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2192 (defun local-set-key (key command) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2193 "Give KEY a local binding as COMMAND. |
20410
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2194 COMMAND is the command definition to use; usually it is |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2195 a symbol naming an interactively-callable function. |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2196 KEY is a key sequence; noninteractively, it is a string or vector |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2197 of characters or event types, and non-ASCII characters with codes |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2198 above 127 (such as ISO Latin-1) can be included if you use a vector. |
af925352116e
(global-set-key, local-set-key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
19662
diff
changeset
|
2199 |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2200 The binding goes in the current buffer's local map, |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2201 which in most cases is shared with all other buffers in the same major mode." |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2202 (interactive "KSet key locally: \nCSet key %s locally to command: ") |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2203 (let ((map (current-local-map))) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2204 (or map |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2205 (use-local-map (setq map (make-sparse-keymap)))) |
43498
ecd03935bb98
(global-set-key, local-set-key): Undo 2002-02-06
Kim F. Storm <storm@cua.dk>
parents:
43435
diff
changeset
|
2206 (or (vectorp key) (stringp key) |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2207 (signal 'wrong-type-argument (list 'arrayp key))) |
21578
6175866e1b71
(local-set-key, global-set-key): Return what define-key returns.
Richard M. Stallman <rms@gnu.org>
parents:
21409
diff
changeset
|
2208 (define-key map key command))) |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2209 |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2210 (defun global-unset-key (key) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2211 "Remove global binding of KEY. |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2212 KEY is a string representing a sequence of keystrokes." |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2213 (interactive "kUnset key globally: ") |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2214 (global-set-key key nil)) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2215 |
10826
bd0ab0601489
(local-unset-key): Fix args in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
10825
diff
changeset
|
2216 (defun local-unset-key (key) |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2217 "Remove local binding of KEY. |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2218 KEY is a string representing a sequence of keystrokes." |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2219 (interactive "kUnset key locally: ") |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2220 (if (current-local-map) |
10826
bd0ab0601489
(local-unset-key): Fix args in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
10825
diff
changeset
|
2221 (local-set-key key nil)) |
10825
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2222 nil) |
4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
Richard M. Stallman <rms@gnu.org>
parents:
10794
diff
changeset
|
2223 |
12016
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
2224 ;; We put this here instead of in frame.el so that it's defined even on |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
2225 ;; systems where frame.el isn't loaded. |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
2226 (defun frame-configuration-p (object) |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
2227 "Return non-nil if OBJECT seems to be a frame configuration. |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
2228 Any list whose car is `frame-configuration' is assumed to be a frame |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
2229 configuration." |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
2230 (and (consp object) |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
2231 (eq (car object) 'frame-configuration))) |
3fd7ef954be6
(frame-configuration-p): Moved here from frame.el.
Karl Heuer <kwzh@gnu.org>
parents:
11640
diff
changeset
|
2232 |
17418
726a87ac1486
(functionp): New function.
Richard M. Stallman <rms@gnu.org>
parents:
17215
diff
changeset
|
2233 (defun functionp (object) |
53485 | 2234 "Non-nil if OBJECT is any kind of function or a special form. |
2235 Also non-nil if OBJECT is a symbol and its function definition is | |
2236 \(recursively) a function or special form. This does not include | |
2237 macros." | |
41140
dc77550aede3
(eval-after-load): Make it work with features as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40832
diff
changeset
|
2238 (or (and (symbolp object) (fboundp object) |
45246
aec4852e765a
(functionp): Catch errors in indirect-function.
Richard M. Stallman <rms@gnu.org>
parents:
45078
diff
changeset
|
2239 (condition-case nil |
aec4852e765a
(functionp): Catch errors in indirect-function.
Richard M. Stallman <rms@gnu.org>
parents:
45078
diff
changeset
|
2240 (setq object (indirect-function object)) |
aec4852e765a
(functionp): Catch errors in indirect-function.
Richard M. Stallman <rms@gnu.org>
parents:
45078
diff
changeset
|
2241 (error nil)) |
40822
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
2242 (eq (car-safe object) 'autoload) |
41187
f3b21013637a
(functionp): Do use cdr-safe on object.
Richard M. Stallman <rms@gnu.org>
parents:
41140
diff
changeset
|
2243 (not (car-safe (cdr-safe (cdr-safe (cdr-safe (cdr-safe object))))))) |
40822
b10e7d6fb95b
(with-local-quit): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40282
diff
changeset
|
2244 (subrp object) (byte-code-function-p object) |
40832
33d8d61c63dd
(functionp): Don't consider macros as functions.
Miles Bader <miles@gnu.org>
parents:
40830
diff
changeset
|
2245 (eq (car-safe object) 'lambda))) |
17418
726a87ac1486
(functionp): New function.
Richard M. Stallman <rms@gnu.org>
parents:
17215
diff
changeset
|
2246 |
37054
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2247 (defun interactive-form (function) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2248 "Return the interactive form of FUNCTION. |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2249 If function is a command (see `commandp'), value is a list of the form |
37055 | 2250 \(interactive SPEC). If function is not a command, return nil." |
37054
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2251 (setq function (indirect-function function)) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2252 (when (commandp function) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2253 (cond ((byte-code-function-p function) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2254 (when (> (length function) 5) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2255 (let ((spec (aref function 5))) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2256 (if spec |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2257 (list 'interactive spec) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2258 (list 'interactive))))) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2259 ((subrp function) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2260 (subr-interactive-form function)) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2261 ((eq (car-safe function) 'lambda) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2262 (setq function (cddr function)) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2263 (when (stringp (car function)) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2264 (setq function (cdr function))) |
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2265 (let ((form (car function))) |
37070
838adca2d2fd
(interactive-form): Fix paren typo.
Miles Bader <miles@gnu.org>
parents:
37055
diff
changeset
|
2266 (when (eq (car-safe form) 'interactive) |
37054
dec182bcbaa4
(interactive-form): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37028
diff
changeset
|
2267 (copy-sequence form))))))) |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
2268 |
27908
1c1e1ebca7f8
(assq-delete-all): Renamed from assoc-delete-all.
Gerd Moellmann <gerd@gnu.org>
parents:
27821
diff
changeset
|
2269 (defun assq-delete-all (key alist) |
25140
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
2270 "Delete from ALIST all elements whose car is KEY. |
50694
fc93ef4196d1
(assq-delete-all): Ignore non-cons elememts.
Richard M. Stallman <rms@gnu.org>
parents:
50506
diff
changeset
|
2271 Return the modified alist. |
fc93ef4196d1
(assq-delete-all): Ignore non-cons elememts.
Richard M. Stallman <rms@gnu.org>
parents:
50506
diff
changeset
|
2272 Elements of ALIST that are not conses are ignored." |
25140
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
2273 (let ((tail alist)) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
2274 (while tail |
50694
fc93ef4196d1
(assq-delete-all): Ignore non-cons elememts.
Richard M. Stallman <rms@gnu.org>
parents:
50506
diff
changeset
|
2275 (if (and (consp (car tail)) (eq (car (car tail)) key)) |
25140
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
2276 (setq alist (delq (car tail) alist))) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
2277 (setq tail (cdr tail))) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
2278 alist)) |
e4493f0697ae
(assoc-delete-all): New function, renamed from frame-delete-all.
Dave Love <fx@gnu.org>
parents:
24757
diff
changeset
|
2279 |
44945
27acb2b2a2a9
(make-temp-file): New arg SUFFIX.
Richard M. Stallman <rms@gnu.org>
parents:
44900
diff
changeset
|
2280 (defun make-temp-file (prefix &optional dir-flag suffix) |
25631
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
2281 "Create a temporary file. |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
2282 The returned file name (created by appending some random characters at the end |
45978
a8fbafaa31ad
(event-start, event-end, event-click-count):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45823
diff
changeset
|
2283 of PREFIX, and expanding against `temporary-file-directory' if necessary), |
25631
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
2284 is guaranteed to point to a newly created empty file. |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
2285 You can then use `write-region' to write new data into the file. |
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
2286 |
44945
27acb2b2a2a9
(make-temp-file): New arg SUFFIX.
Richard M. Stallman <rms@gnu.org>
parents:
44900
diff
changeset
|
2287 If DIR-FLAG is non-nil, create a new empty directory instead of a file. |
27acb2b2a2a9
(make-temp-file): New arg SUFFIX.
Richard M. Stallman <rms@gnu.org>
parents:
44900
diff
changeset
|
2288 |
27acb2b2a2a9
(make-temp-file): New arg SUFFIX.
Richard M. Stallman <rms@gnu.org>
parents:
44900
diff
changeset
|
2289 If SUFFIX is non-nil, add that at the end of the file name." |
47652
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2290 (let ((umask (default-file-modes)) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2291 file) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2292 (unwind-protect |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2293 (progn |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2294 ;; Create temp files with strict access rights. It's easy to |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2295 ;; loosen them later, whereas it's impossible to close the |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2296 ;; time-window of loose permissions otherwise. |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2297 (set-default-file-modes ?\700) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2298 (while (condition-case () |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2299 (progn |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2300 (setq file |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2301 (make-temp-name |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2302 (expand-file-name prefix temporary-file-directory))) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2303 (if suffix |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2304 (setq file (concat file suffix))) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2305 (if dir-flag |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2306 (make-directory file) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2307 (write-region "" nil file nil 'silent nil 'excl)) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2308 nil) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2309 (file-already-exists t)) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2310 ;; the file was somehow created by someone else between |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2311 ;; `make-temp-name' and `write-region', let's try again. |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2312 nil) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2313 file) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2314 ;; Reset the umask. |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2315 (set-default-file-modes umask)))) |
25631
0987f52a0674
(make-temp-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
25580
diff
changeset
|
2316 |
28720
f8379b011476
(add-minor-mode): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28628
diff
changeset
|
2317 |
50506
6cc9a6c84a94
(minor-mode-list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50449
diff
changeset
|
2318 ;; If a minor mode is not defined with define-minor-mode, |
6cc9a6c84a94
(minor-mode-list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50449
diff
changeset
|
2319 ;; add it here explicitly. |
6cc9a6c84a94
(minor-mode-list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50449
diff
changeset
|
2320 ;; isearch-mode is deliberately excluded, since you should |
6cc9a6c84a94
(minor-mode-list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50449
diff
changeset
|
2321 ;; not call it yourself. |
6cc9a6c84a94
(minor-mode-list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50449
diff
changeset
|
2322 (defvar minor-mode-list '(auto-save-mode auto-fill-mode abbrev-mode |
53063
5ce618af4f38
(minor-mode-list): Add `hs-minor-mode'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52987
diff
changeset
|
2323 overwrite-mode view-mode |
5ce618af4f38
(minor-mode-list): Add `hs-minor-mode'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52987
diff
changeset
|
2324 hs-minor-mode) |
50506
6cc9a6c84a94
(minor-mode-list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50449
diff
changeset
|
2325 "List of all minor mode functions.") |
6cc9a6c84a94
(minor-mode-list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50449
diff
changeset
|
2326 |
28751 | 2327 (defun add-minor-mode (toggle name &optional keymap after toggle-fun) |
28720
f8379b011476
(add-minor-mode): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
28628
diff
changeset
|
2328 "Register a new minor mode. |
28751 | 2329 |
31979
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2330 This is an XEmacs-compatibility function. Use `define-minor-mode' instead. |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2331 |
28751 | 2332 TOGGLE is a symbol which is the name of a buffer-local variable that |
2333 is toggled on or off to say whether the minor mode is active or not. | |
2334 | |
2335 NAME specifies what will appear in the mode line when the minor mode | |
2336 is active. NAME should be either a string starting with a space, or a | |
2337 symbol whose value is such a string. | |
2338 | |
2339 Optional KEYMAP is the keymap for the minor mode that will be added | |
2340 to `minor-mode-map-alist'. | |
2341 | |
2342 Optional AFTER specifies that TOGGLE should be added after AFTER | |
2343 in `minor-mode-alist'. | |
2344 | |
31979
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2345 Optional TOGGLE-FUN is an interactive function to toggle the mode. |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2346 It defaults to (and should by convention be) TOGGLE. |
31563
96b9757bfd45
(add-minor-mode): Use toggle-fun arg.
Dave Love <fx@gnu.org>
parents:
30515
diff
changeset
|
2347 |
31979
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2348 If TOGGLE has a non-nil `:included' property, an entry for the mode is |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2349 included in the mode-line minor mode menu. |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2350 If TOGGLE has a `:menu-tag', that is used for the menu item's label." |
50506
6cc9a6c84a94
(minor-mode-list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50449
diff
changeset
|
2351 (unless (memq toggle minor-mode-list) |
6cc9a6c84a94
(minor-mode-list): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
50449
diff
changeset
|
2352 (push toggle minor-mode-list)) |
51148
f59aeee43725
(split-string): Implement specification that splitting on explicit separators
Juanma Barranquero <lekktu@gmail.com>
parents:
51068
diff
changeset
|
2353 |
31979
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2354 (unless toggle-fun (setq toggle-fun toggle)) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2355 ;; Add the name to the minor-mode-alist. |
28751 | 2356 (when name |
31979
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2357 (let ((existing (assq toggle minor-mode-alist))) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2358 (if existing |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2359 (setcdr existing (list name)) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2360 (let ((tail minor-mode-alist) found) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2361 (while (and tail (not found)) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2362 (if (eq after (caar tail)) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2363 (setq found tail) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2364 (setq tail (cdr tail)))) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2365 (if found |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2366 (let ((rest (cdr found))) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2367 (setcdr found nil) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2368 (nconc found (list (list toggle name)) rest)) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2369 (setq minor-mode-alist (cons (list toggle name) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2370 minor-mode-alist))))))) |
43126
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2371 ;; Add the toggle to the minor-modes menu if requested. |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2372 (when (get toggle :included) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2373 (define-key mode-line-mode-menu |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2374 (vector toggle) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2375 (list 'menu-item |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2376 (concat |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2377 (or (get toggle :menu-tag) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2378 (if (stringp name) name (symbol-name toggle))) |
47652
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2379 (let ((mode-name (if (symbolp name) (symbol-value name)))) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2380 (if (and (stringp mode-name) (string-match "[^ ]+" mode-name)) |
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2381 (concat " (" (match-string 0 mode-name) ")")))) |
43126
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2382 toggle-fun |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2383 :button (cons :toggle toggle)))) |
6f39ff1c6d8f
(atomic-change-group, prepare-change-group, activate-change-group)
Richard M. Stallman <rms@gnu.org>
parents:
42941
diff
changeset
|
2384 |
47652
a5316596929f
(read-key-auxiliary-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47406
diff
changeset
|
2385 ;; Add the map to the minor-mode-map-alist. |
28751 | 2386 (when keymap |
2387 (let ((existing (assq toggle minor-mode-map-alist))) | |
31979
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2388 (if existing |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2389 (setcdr existing keymap) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2390 (let ((tail minor-mode-map-alist) found) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2391 (while (and tail (not found)) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2392 (if (eq after (caar tail)) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2393 (setq found tail) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2394 (setq tail (cdr tail)))) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2395 (if found |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2396 (let ((rest (cdr found))) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2397 (setcdr found nil) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2398 (nconc found (list (cons toggle keymap)) rest)) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2399 (setq minor-mode-map-alist (cons (cons toggle keymap) |
6085a3297ebc
(add-minor-mode): Don't eval NAME.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31563
diff
changeset
|
2400 minor-mode-map-alist)))))))) |
44668
52222efc9d4d
(insert-for-yank): New function.
Richard M. Stallman <rms@gnu.org>
parents:
44473
diff
changeset
|
2401 |
40282
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2402 ;; Clones ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2403 |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2404 (defun text-clone-maintain (ol1 after beg end &optional len) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2405 "Propagate the changes made under the overlay OL1 to the other clones. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2406 This is used on the `modification-hooks' property of text clones." |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2407 (when (and after (not undo-in-progress) (overlay-start ol1)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2408 (let ((margin (if (overlay-get ol1 'text-clone-spreadp) 1 0))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2409 (setq beg (max beg (+ (overlay-start ol1) margin))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2410 (setq end (min end (- (overlay-end ol1) margin))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2411 (when (<= beg end) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2412 (save-excursion |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2413 (when (overlay-get ol1 'text-clone-syntax) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2414 ;; Check content of the clone's text. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2415 (let ((cbeg (+ (overlay-start ol1) margin)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2416 (cend (- (overlay-end ol1) margin))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2417 (goto-char cbeg) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2418 (save-match-data |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2419 (if (not (re-search-forward |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2420 (overlay-get ol1 'text-clone-syntax) cend t)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2421 ;; Mark the overlay for deletion. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2422 (overlay-put ol1 'text-clones nil) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2423 (when (< (match-end 0) cend) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2424 ;; Shrink the clone at its end. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2425 (setq end (min end (match-end 0))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2426 (move-overlay ol1 (overlay-start ol1) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2427 (+ (match-end 0) margin))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2428 (when (> (match-beginning 0) cbeg) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2429 ;; Shrink the clone at its beginning. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2430 (setq beg (max (match-beginning 0) beg)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2431 (move-overlay ol1 (- (match-beginning 0) margin) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2432 (overlay-end ol1))))))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2433 ;; Now go ahead and update the clones. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2434 (let ((head (- beg (overlay-start ol1))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2435 (tail (- (overlay-end ol1) end)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2436 (str (buffer-substring beg end)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2437 (nothing-left t) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2438 (inhibit-modification-hooks t)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2439 (dolist (ol2 (overlay-get ol1 'text-clones)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2440 (let ((oe (overlay-end ol2))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2441 (unless (or (eq ol1 ol2) (null oe)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2442 (setq nothing-left nil) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2443 (let ((mod-beg (+ (overlay-start ol2) head))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2444 ;;(overlay-put ol2 'modification-hooks nil) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2445 (goto-char (- (overlay-end ol2) tail)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2446 (unless (> mod-beg (point)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2447 (save-excursion (insert str)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2448 (delete-region mod-beg (point))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2449 ;;(overlay-put ol2 'modification-hooks '(text-clone-maintain)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2450 )))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2451 (if nothing-left (delete-overlay ol1)))))))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2452 |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2453 (defun text-clone-create (start end &optional spreadp syntax) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2454 "Create a text clone of START...END at point. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2455 Text clones are chunks of text that are automatically kept identical: |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2456 changes done to one of the clones will be immediately propagated to the other. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2457 |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2458 The buffer's content at point is assumed to be already identical to |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2459 the one between START and END. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2460 If SYNTAX is provided it's a regexp that describes the possible text of |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2461 the clones; the clone will be shrunk or killed if necessary to ensure that |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2462 its text matches the regexp. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2463 If SPREADP is non-nil it indicates that text inserted before/after the |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2464 clone should be incorporated in the clone." |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2465 ;; To deal with SPREADP we can either use an overlay with `nil t' along |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2466 ;; with insert-(behind|in-front-of)-hooks or use a slightly larger overlay |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2467 ;; (with a one-char margin at each end) with `t nil'. |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2468 ;; We opted for a larger overlay because it behaves better in the case |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2469 ;; where the clone is reduced to the empty string (we want the overlay to |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2470 ;; stay when the clone's content is the empty string and we want to use |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2471 ;; `evaporate' to make sure those overlays get deleted when needed). |
47916 | 2472 ;; |
40282
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2473 (let* ((pt-end (+ (point) (- end start))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2474 (start-margin (if (or (not spreadp) (bobp) (<= start (point-min))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2475 0 1)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2476 (end-margin (if (or (not spreadp) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2477 (>= pt-end (point-max)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2478 (>= start (point-max))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2479 0 1)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2480 (ol1 (make-overlay (- start start-margin) (+ end end-margin) nil t)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2481 (ol2 (make-overlay (- (point) start-margin) (+ pt-end end-margin) nil t)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2482 (dups (list ol1 ol2))) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2483 (overlay-put ol1 'modification-hooks '(text-clone-maintain)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2484 (when spreadp (overlay-put ol1 'text-clone-spreadp t)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2485 (when syntax (overlay-put ol1 'text-clone-syntax syntax)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2486 ;;(overlay-put ol1 'face 'underline) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2487 (overlay-put ol1 'evaporate t) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2488 (overlay-put ol1 'text-clones dups) |
47916 | 2489 ;; |
40282
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2490 (overlay-put ol2 'modification-hooks '(text-clone-maintain)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2491 (when spreadp (overlay-put ol2 'text-clone-spreadp t)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2492 (when syntax (overlay-put ol2 'text-clone-syntax syntax)) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2493 ;;(overlay-put ol2 'face 'underline) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2494 (overlay-put ol2 'evaporate t) |
7f05eff77ea2
(delay-mode-hooks, delayed-mode-hooks, run-mode-hooks): New vars and functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39725
diff
changeset
|
2495 (overlay-put ol2 'text-clones dups))) |
47406
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2496 |
44422
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2497 (defun play-sound (sound) |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2498 "SOUND is a list of the form `(sound KEYWORD VALUE...)'. |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2499 The following keywords are recognized: |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2500 |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2501 :file FILE - read sound data from FILE. If FILE isn't an |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2502 absolute file name, it is searched in `data-directory'. |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2503 |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2504 :data DATA - read sound data from string DATA. |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2505 |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2506 Exactly one of :file or :data must be present. |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2507 |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2508 :volume VOL - set volume to VOL. VOL must an integer in the |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2509 range 0..100 or a float in the range 0..1.0. If not specified, |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2510 don't change the volume setting of the sound device. |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2511 |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2512 :device DEVICE - play sound on DEVICE. If not specified, |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2513 a system-dependent default device name is used." |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2514 (unless (fboundp 'play-sound-internal) |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2515 (error "This Emacs binary lacks sound support")) |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2516 (play-sound-internal sound)) |
5f7f8b191a8c
(play-sound): Move here from simple.el.
Pavel Janík <Pavel@Janik.cz>
parents:
44285
diff
changeset
|
2517 |
47406
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2518 (defun define-mail-user-agent (symbol composefunc sendfunc |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2519 &optional abortfunc hookvar) |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2520 "Define a symbol to identify a mail-sending package for `mail-user-agent'. |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2521 |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2522 SYMBOL can be any Lisp symbol. Its function definition and/or |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2523 value as a variable do not matter for this usage; we use only certain |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2524 properties on its property list, to encode the rest of the arguments. |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2525 |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2526 COMPOSEFUNC is program callable function that composes an outgoing |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2527 mail message buffer. This function should set up the basics of the |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2528 buffer without requiring user interaction. It should populate the |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2529 standard mail headers, leaving the `to:' and `subject:' headers blank |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2530 by default. |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2531 |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2532 COMPOSEFUNC should accept several optional arguments--the same |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2533 arguments that `compose-mail' takes. See that function's documentation. |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2534 |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2535 SENDFUNC is the command a user would run to send the message. |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2536 |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2537 Optional ABORTFUNC is the command a user would run to abort the |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2538 message. For mail packages that don't have a separate abort function, |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2539 this can be `kill-buffer' (the equivalent of omitting this argument). |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2540 |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2541 Optional HOOKVAR is a hook variable that gets run before the message |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2542 is actually sent. Callers that use the `mail-user-agent' may |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2543 install a hook function temporarily on this hook variable. |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2544 If HOOKVAR is nil, `mail-send-hook' is used. |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2545 |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2546 The properties used on SYMBOL are `composefunc', `sendfunc', |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2547 `abortfunc', and `hookvar'." |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2548 (put symbol 'composefunc composefunc) |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2549 (put symbol 'sendfunc sendfunc) |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2550 (put symbol 'abortfunc (or abortfunc 'kill-buffer)) |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2551 (put symbol 'hookvar (or hookvar 'mail-send-hook))) |
fbd7a9a8682c
(define-mail-user-agent): Moved from simple.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47355
diff
changeset
|
2552 |
52401 | 2553 ;;; arch-tag: f7e0e6e5-70aa-4897-ae72-7a3511ec40bc |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
2554 ;;; subr.el ends here |