Mercurial > hg > xemacs-beta
annotate lisp/lisp.el @ 4724:7eef89a3d41f
Improve docstrings of defun movement functions.
author | Stephen J. Turnbull <stephen@xemacs.org> |
---|---|
date | Fri, 09 Oct 2009 05:10:03 +0900 |
parents | a46d7513a364 |
children | 4bbda1c11a7b |
rev | line source |
---|---|
428 | 1 ;;; lisp.el --- Lisp editing commands for XEmacs |
2 | |
3 ;; Copyright (C) 1985, 1986, 1994, 1997 Free Software Foundation, Inc. | |
4 | |
5 ;; Maintainer: FSF | |
6 ;; Keywords: lisp, languages, dumped | |
7 | |
8 ;; This file is part of XEmacs. | |
9 | |
10 ;; XEmacs is free software; you can redistribute it and/or modify it | |
11 ;; under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; XEmacs is distributed in the hope that it will be useful, but | |
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 ;; General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
23 ;; 02111-1307, USA. | |
24 | |
25 ;;; Synched up with: Emacs/Mule zeta. | |
26 | |
27 ;;; Commentary: | |
28 | |
29 ;; This file is dumped with XEmacs. | |
30 | |
31 ;; Lisp editing commands to go with Lisp major mode. | |
32 | |
33 ;; 06/11/1997 - Use char-(after|before) instead of | |
34 ;; (following|preceding)-char. -slb | |
35 | |
36 ;;; Code: | |
37 | |
38 ;; Note that this variable is used by non-lisp modes too. | |
39 (defcustom defun-prompt-regexp nil | |
40 "*Non-nil => regexp to ignore, before the character that starts a defun. | |
41 This is only necessary if the opening paren or brace is not in column 0. | |
42 See `beginning-of-defun'." | |
43 :type '(choice (const :tag "none" nil) | |
44 regexp) | |
45 :group 'lisp) | |
46 | |
47 (make-variable-buffer-local 'defun-prompt-regexp) | |
48 | |
49 (defcustom parens-require-spaces t | |
50 "Non-nil => `insert-parentheses' should insert whitespace as needed." | |
51 :type 'boolean | |
52 :group 'editing-basics | |
53 :group 'lisp) | |
54 | |
55 (defun forward-sexp (&optional arg) | |
56 "Move forward across one balanced expression (sexp). | |
57 With argument, do it that many times. Negative arg -N means | |
58 move backward across N balanced expressions." | |
59 ;; XEmacs change (for zmacs regions) | |
60 (interactive "_p") | |
61 (or arg (setq arg 1)) | |
62 ;; XEmacs: evil hack! The other half of the evil hack below. | |
3543 | 63 (if (and (> arg 0) (looking-at "#s(\\|#r[uU]\\{0,1\\}\"")) |
64 (goto-char (1+ (- (point) (- (match-end 0) (match-beginning 0)))))) | |
428 | 65 (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) |
3543 | 66 (when (< arg 0) |
67 (backward-prefix-chars) | |
68 ;; XEmacs: evil hack! Skip back over #[sr] so that structures and raw | |
69 ;; strings are read properly. the current cheesified syntax tables just | |
70 ;; aren't up to this. | |
71 (let* ((diff (- (point) (point-min))) | |
72 (subject (buffer-substring (- (point) (min diff 3)) | |
73 (1+ (point)))) | |
74 (matched (string-match "#s(\\|#r[uU]\\{0,1\\}\"" subject))) | |
75 (if matched | |
76 (goto-char (1+ (- (point) (- (length subject) matched)))))))) | |
428 | 77 |
78 (defun backward-sexp (&optional arg) | |
79 "Move backward across one balanced expression (sexp). | |
80 With argument, do it that many times. Negative arg -N means | |
81 move forward across N balanced expressions." | |
82 ;; XEmacs change (for zmacs regions) | |
83 (interactive "_p") | |
444 | 84 (forward-sexp (- (or arg 1)))) |
428 | 85 |
444 | 86 (defun mark-sexp (&optional arg) |
428 | 87 "Set mark ARG sexps from point. |
88 The place mark goes is the same place \\[forward-sexp] would | |
89 move to with the same argument. | |
90 Repeat this command to mark more sexps in the same direction." | |
91 (interactive "p") | |
444 | 92 (mark-something 'mark-sexp 'forward-sexp (or arg 1))) |
428 | 93 |
94 (defun forward-list (&optional arg) | |
95 "Move forward across one balanced group of parentheses. | |
96 With argument, do it that many times. | |
97 Negative arg -N means move backward across N groups of parentheses." | |
98 ;; XEmacs change | |
99 (interactive "_p") | |
444 | 100 (goto-char (or (scan-lists (point) (or arg 1) 0) (buffer-end (or arg 1))))) |
428 | 101 |
102 (defun backward-list (&optional arg) | |
103 "Move backward across one balanced group of parentheses. | |
104 With argument, do it that many times. | |
105 Negative arg -N means move forward across N groups of parentheses." | |
106 ;; XEmacs change (for zmacs regions) | |
107 (interactive "_p") | |
444 | 108 (forward-list (- (or arg 1)))) |
428 | 109 |
444 | 110 (defun down-list (&optional arg) |
428 | 111 "Move forward down one level of parentheses. |
112 With argument, do this that many times. | |
444 | 113 A negative argument means move backward but still go down a level." |
428 | 114 ;; XEmacs change (for zmacs regions) |
115 (interactive "_p") | |
444 | 116 (or arg (setq arg 1)) |
428 | 117 (let ((inc (if (> arg 0) 1 -1))) |
118 (while (/= arg 0) | |
119 (goto-char (or (scan-lists (point) inc -1) (buffer-end arg))) | |
120 (setq arg (- arg inc))))) | |
121 | |
444 | 122 (defun backward-up-list (&optional arg) |
428 | 123 "Move backward out of one level of parentheses. |
124 With argument, do this that many times. | |
444 | 125 A negative argument means move forward but still to a less deep spot." |
428 | 126 (interactive "_p") |
444 | 127 (up-list (- (or arg 1)))) |
428 | 128 |
444 | 129 (defun up-list (&optional arg) |
428 | 130 "Move forward out of one level of parentheses. |
131 With argument, do this that many times. | |
132 A negative argument means move backward but still to a less deep spot. | |
133 In Lisp programs, an argument is required." | |
134 ;; XEmacs change (for zmacs regions) | |
135 (interactive "_p") | |
444 | 136 (or arg (setq arg 1)) |
428 | 137 (let ((inc (if (> arg 0) 1 -1))) |
138 (while (/= arg 0) | |
139 (goto-char (or (scan-lists (point) inc 1) (buffer-end arg))) | |
140 (setq arg (- arg inc))))) | |
141 | |
444 | 142 (defun kill-sexp (&optional arg) |
428 | 143 "Kill the sexp (balanced expression) following the cursor. |
144 With argument, kill that many sexps after the cursor. | |
145 Negative arg -N means kill N sexps before the cursor." | |
146 (interactive "p") | |
147 (let ((opoint (point))) | |
444 | 148 (forward-sexp (or arg 1)) |
428 | 149 (kill-region opoint (point)))) |
150 | |
444 | 151 (defun backward-kill-sexp (&optional arg) |
428 | 152 "Kill the sexp (balanced expression) preceding the cursor. |
153 With argument, kill that many sexps before the cursor. | |
154 Negative arg -N means kill N sexps after the cursor." | |
155 (interactive "p") | |
444 | 156 (kill-sexp (- (or arg 1)))) |
428 | 157 |
4696
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
158 |
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
159 ;; derived stuff from GNU Emacs |
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
160 (defvar beginning-of-defun-function nil |
4724
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
161 "If non-nil, this function will be called by `beginning-of-defun-raw'. |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
162 It will be called with one argument, which is a repetition count. |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
163 It provides an alternative algorithm to find the beginning of the current |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
164 defun instead of using the standard one implemented by `beginning-of-defun'. |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
165 See also `defun-prompt-regexp' for minor tweaks.") |
4712
a46d7513a364
`beginning-of-defun-function', `end-of-defun-function'
Andreas Roehler <andreas.roehler@online.de>
parents:
4705
diff
changeset
|
166 (make-variable-buffer-local 'beginning-of-defun-function) |
4696
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
167 |
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
168 (defvar end-of-defun-function nil |
4724
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
169 "If non-nil, this function will be called by `end-of-defun'. |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
170 It will be called with no arguments. \(Repetition is implemented in |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
171 `end-of-defun' by calling this function that many times.) |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
172 This function provides an alternative algorithm to find the end |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
173 of the current defun instead of using the standard one implemented by |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
174 `end-of-defun'. |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
175 ") |
4712
a46d7513a364
`beginning-of-defun-function', `end-of-defun-function'
Andreas Roehler <andreas.roehler@online.de>
parents:
4705
diff
changeset
|
176 (make-variable-buffer-local 'end-of-defun-function) |
4696
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
177 |
428 | 178 (defun beginning-of-defun (&optional arg) |
4724
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
179 "Move backward to the beginning of the current defun. |
428 | 180 With argument, do it that many times. Negative arg -N |
181 means move forward to Nth following beginning of defun. | |
182 Returns t unless search stops due to beginning or end of buffer. | |
183 | |
4724
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
184 In the default implementation provided by `beginning-of-defun-raw', |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
185 a defun starts at a char with open-parenthesis syntax at the beginning |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
186 of a line. If `defun-prompt-regexp' is non-nil, then a string which |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
187 matches that regexp may precede the open-parenthesis. Alternatively, |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
188 if `beginning-of-defun-function' is non-nil, that function is called, |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
189 and none of the default processing is done. |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
190 |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
191 If the beginning of defun function returns t, point moves to the |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
192 beginning of the line containing the beginning of defun." |
428 | 193 ;; XEmacs change (for zmacs regions) |
194 (interactive "_p") | |
195 (and (beginning-of-defun-raw arg) | |
196 (progn (beginning-of-line) t))) | |
197 | |
198 (defun beginning-of-defun-raw (&optional arg) | |
199 "Move point to the character that starts a defun. | |
200 This is identical to beginning-of-defun, except that point does not move | |
201 to the beginning of the line when `defun-prompt-regexp' is non-nil." | |
202 (interactive "p") | |
4696
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
203 (unless arg (setq arg 1)) |
4705
7b90173970ad
Unbreak `beginning-of-defun'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4696
diff
changeset
|
204 (if beginning-of-defun-function |
7b90173970ad
Unbreak `beginning-of-defun'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4696
diff
changeset
|
205 (funcall beginning-of-defun-function arg) |
7b90173970ad
Unbreak `beginning-of-defun'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4696
diff
changeset
|
206 (and (< arg 0) (not (eobp)) (forward-char 1)) |
7b90173970ad
Unbreak `beginning-of-defun'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4696
diff
changeset
|
207 (and |
7b90173970ad
Unbreak `beginning-of-defun'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4696
diff
changeset
|
208 (re-search-backward (if defun-prompt-regexp |
7b90173970ad
Unbreak `beginning-of-defun'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4696
diff
changeset
|
209 (concat "^\\s(\\|" |
7b90173970ad
Unbreak `beginning-of-defun'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4696
diff
changeset
|
210 "\\(" defun-prompt-regexp "\\)\\s(") |
7b90173970ad
Unbreak `beginning-of-defun'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4696
diff
changeset
|
211 "^\\s(") |
7b90173970ad
Unbreak `beginning-of-defun'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4696
diff
changeset
|
212 nil 'move arg) |
7b90173970ad
Unbreak `beginning-of-defun'.
Mike Sperber <sperber@deinprogramm.de>
parents:
4696
diff
changeset
|
213 (progn (goto-char (1- (match-end 0)))) t))) |
428 | 214 |
215 ;; XEmacs change (optional buffer parameter) | |
216 (defun buffer-end (arg &optional buffer) | |
217 "Return `point-max' of BUFFER if ARG is > 0; return `point-min' otherwise. | |
218 BUFFER defaults to the current buffer if omitted." | |
219 (if (> arg 0) (point-max buffer) (point-min buffer))) | |
220 | |
221 (defun end-of-defun (&optional arg) | |
222 "Move forward to next end of defun. With argument, do it that many times. | |
223 Negative argument -N means move back to Nth preceding end of defun. | |
224 | |
4724
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
225 In the default implementation, the end of a defun is the end of the |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
226 s-expression started at the character identified by `beginning-of-defun'. |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
227 |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
228 If `end-of-defun-function' is non-nil, none of the default processing is |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
229 done. For a repetition count greater than 1, `end-of-defun-function' is |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
230 called that many times. If the repetition count is less than 1, nothing |
7eef89a3d41f
Improve docstrings of defun movement functions.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4712
diff
changeset
|
231 is done. \(This is a bug.)" |
428 | 232 ;; XEmacs change (for zmacs regions) |
233 (interactive "_p") | |
234 (if (or (null arg) (= arg 0)) (setq arg 1)) | |
4696
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
235 (if end-of-defun-function |
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
236 (if (> arg 0) |
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
237 (dotimes (i arg) |
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
238 (funcall end-of-defun-function))) |
428 | 239 (let ((first t)) |
240 (while (and (> arg 0) (< (point) (point-max))) | |
241 (let ((pos (point))) ; XEmacs -- remove unused npos. | |
242 (while (progn | |
243 (if (and first | |
244 (progn | |
245 (end-of-line 1) | |
246 (beginning-of-defun-raw 1))) | |
247 nil | |
446 | 248 (or (bobp) (backward-char 1)) |
428 | 249 (beginning-of-defun-raw -1)) |
250 (setq first nil) | |
251 (forward-list 1) | |
252 (skip-chars-forward " \t") | |
253 (if (looking-at "\\s<\\|\n") | |
254 (forward-line 1)) | |
255 (<= (point) pos)))) | |
256 (setq arg (1- arg))) | |
257 (while (< arg 0) | |
258 (let ((pos (point))) | |
259 (beginning-of-defun-raw 1) | |
260 (forward-sexp 1) | |
261 (forward-line 1) | |
262 (if (>= (point) pos) | |
263 (if (beginning-of-defun-raw 2) | |
264 (progn | |
265 (forward-list 1) | |
266 (skip-chars-forward " \t") | |
267 (if (looking-at "\\s<\\|\n") | |
268 (forward-line 1))) | |
269 (goto-char (point-min))))) | |
4696
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
270 (setq arg (1+ arg)))))) |
428 | 271 |
272 (defun mark-defun () | |
273 "Put mark at end of this defun, point at beginning. | |
274 The defun marked is the one that contains point or follows point." | |
275 (interactive) | |
276 (push-mark (point)) | |
277 (end-of-defun) | |
278 (push-mark (point) nil t) | |
279 (beginning-of-defun) | |
280 (re-search-backward "^\n" (- (point) 1) t)) | |
281 | |
282 (defun narrow-to-defun (&optional arg) | |
283 "Make text outside current defun invisible. | |
284 The defun visible is the one that contains point or follows point." | |
285 (interactive) | |
286 (save-excursion | |
287 (widen) | |
288 (end-of-defun) | |
289 (let ((end (point))) | |
290 (beginning-of-defun) | |
291 (narrow-to-region (point) end)))) | |
292 | |
293 (defun insert-parentheses (arg) | |
294 "Enclose following ARG sexps in parentheses. Leave point after open-paren. | |
295 A negative ARG encloses the preceding ARG sexps instead. | |
296 No argument is equivalent to zero: just insert `()' and leave point between. | |
297 If `parens-require-spaces' is non-nil, this command also inserts a space | |
298 before and after, depending on the surrounding characters." | |
299 (interactive "P") | |
300 (if arg (setq arg (prefix-numeric-value arg)) | |
301 (setq arg 0)) | |
302 (cond ((> arg 0) (skip-chars-forward " \t")) | |
303 ((< arg 0) (forward-sexp arg) (setq arg (- arg)))) | |
304 (and parens-require-spaces | |
305 (not (bobp)) | |
306 (memq (char-syntax (char-before (point))) '(?w ?_ ?\) )) | |
307 (insert " ")) | |
308 (insert ?\() | |
309 (save-excursion | |
310 (or (eq arg 0) (forward-sexp arg)) | |
311 (insert ?\)) | |
312 (and parens-require-spaces | |
313 (not (eobp)) | |
314 (memq (char-syntax (char-after (point))) '(?w ?_ ?\( )) | |
315 (insert " ")))) | |
316 | |
317 (defun move-past-close-and-reindent () | |
318 "Move past next `)', delete indentation before it, then indent after it." | |
319 (interactive) | |
320 (up-list 1) | |
446 | 321 (backward-char 1) |
428 | 322 (while (save-excursion ; this is my contribution |
323 (let ((before-paren (point))) | |
324 (back-to-indentation) | |
325 (= (point) before-paren))) | |
326 (delete-indentation)) | |
327 (forward-char 1) | |
328 (newline-and-indent)) | |
329 | |
330 (defun lisp-complete-symbol () | |
331 "Perform completion on Lisp symbol preceding point. | |
332 Compare that symbol against the known Lisp symbols. | |
333 | |
334 The context determines which symbols are considered. | |
335 If the symbol starts just after an open-parenthesis, only symbols | |
336 with function definitions are considered. Otherwise, all symbols with | |
337 function definitions, values or properties are considered." | |
338 (interactive) | |
339 (let* ((end (point)) | |
340 (buffer-syntax (syntax-table)) | |
341 (beg (unwind-protect | |
342 (save-excursion | |
343 ;; XEmacs change | |
344 (if emacs-lisp-mode-syntax-table | |
345 (set-syntax-table emacs-lisp-mode-syntax-table)) | |
346 (backward-sexp 1) | |
347 (while (eq (char-syntax (char-after (point))) ?\') | |
348 (forward-char 1)) | |
349 (point)) | |
350 (set-syntax-table buffer-syntax))) | |
351 (pattern (buffer-substring beg end)) | |
352 (predicate | |
353 (if (eq (char-after (1- beg)) ?\() | |
354 'fboundp | |
355 ;; XEmacs change | |
356 #'(lambda (sym) | |
357 (or (boundp sym) (fboundp sym) | |
358 (symbol-plist sym))))) | |
359 (completion (try-completion pattern obarray predicate))) | |
360 (cond ((eq completion t)) | |
361 ((null completion) | |
362 (message "Can't find completion for \"%s\"" pattern) | |
363 (ding)) | |
364 ((not (string= pattern completion)) | |
365 (delete-region beg end) | |
366 (insert completion)) | |
367 (t | |
368 (message "Making completion list...") | |
369 (let ((list (all-completions pattern obarray predicate)) | |
370 ;FSFmacs crock unnecessary in XEmacs | |
371 ;see minibuf.el | |
372 ;(completion-fixup-function | |
373 ; (function (lambda () (if (save-excursion | |
374 ; (goto-char (max (point-min) | |
375 ; (- (point) 4))) | |
376 ; (looking-at " <f>")) | |
377 ; (forward-char -4)))) | |
378 ) | |
379 (or (eq predicate 'fboundp) | |
380 (let (new) | |
381 (while list | |
382 (setq new (cons (if (fboundp (intern (car list))) | |
383 (list (car list) " <f>") | |
384 (car list)) | |
385 new)) | |
386 (setq list (cdr list))) | |
387 (setq list (nreverse new)))) | |
388 (with-output-to-temp-buffer "*Completions*" | |
389 (display-completion-list list))) | |
390 (message "Making completion list...%s" "done"))))) | |
391 | |
392 ;;; lisp.el ends here |