Mercurial > hg > xemacs-beta
annotate lisp/lisp.el @ 4697:0d6d0edf1253
lisp beginning-end-of-defun-function Changelog entry
hg diff
diff -r ecc468b62551 lisp/ChangeLog
--- a/lisp/ChangeLog Mon Sep 21 21:40:35 2009 +0200
+++ b/lisp/ChangeLog Tue Sep 22 21:11:51 2009 +0200
@@ -1,3 +1,12 @@ 2009-09-20 Aidan Kehoe <kehoea@parhasa
+2009-09-22 Andreas Roehler <andreas.roehler@online.de>
+
+ * lisp.el (beginning-of-defun-raw):
+ new variable: beginning-of-defun-function,
+ beginning-of-defun may call FUNCTION determining start position
+ * lisp.el (end-of-defun):
+ new variable: end-of-defun-function,
+ end-of-defun may call FUNCTION determining the end position
+
;;;;;;;;;;;;;;;;;;;;;;;;
hg diff -p -r 4695 -r 4696
diff -r fee33ab25966 -r ecc468b62551 lisp/lisp.el
--- a/lisp/lisp.el Sun Sep 20 23:50:05 2009 +0100
+++ b/lisp/lisp.el Mon Sep 21 21:40:35 2009 +0200
@@ -155,6 +155,21 @@ Negative arg -N means kill N sexps after
(interactive "p")
(kill-sexp (- (or arg 1))))
+
+;; derived stuff from GNU Emacs
+(defvar beginning-of-defun-function nil
+ "If non-nil, function for `beginning-of-defun-raw' to call.
+This is used to find the beginning of the defun instead of using the
+normal recipe (see `beginning-of-defun'). Modes can define this
+if defining `defun-prompt-regexp' is not sufficient to handle the mode's
+needs.")
+
+(defvar end-of-defun-function nil
+ "If non-nil, function for `end-of-defun' to call.
+This is used to find the end of the defun instead of using the normal
+recipe (see `end-of-defun'). Modes can define this if the
+normal method is not appropriate.")
+
(defun beginning-of-defun (&optional arg)
"Move backward to the beginning of a defun.
With argument, do it that many times. Negative arg -N
@@ -175,13 +190,17 @@ This is identical to beginning-of-defun,
This is identical to beginning-of-defun, except that point does not move
to the beginning of the line when `defun-prompt-regexp' is non-nil."
(interactive "p")
- (and arg (< arg 0) (not (eobp)) (forward-char 1))
- (and (re-search-backward (if defun-prompt-regexp
- (concat "^\\s(\\|"
- "\\(" defun-prompt-regexp "\\)\\s(")
- "^\\s(")
- nil 'move (or arg 1))
- (progn (goto-char (1- (match-end 0)))) t))
+ ;; (and arg (< arg 0) (not (eobp)) (forward-char 1))
+ (unless arg (setq arg 1))
+ (cond
+ (beginning-of-defun-function
+ (funcall beginning-of-defun-function arg))
+ (t (re-search-backward (if defun-prompt-regexp
+ (concat "^\\s(\\|"
+ "\\(" defun-prompt-regexp "\\)\\s(")
+ "^\\s(")
+ nil 'move (or arg 1))
+ (progn (goto-char (1- (match-end 0)))) t)))
;; XEmacs change (optional buffer parameter)
(defun buffer-end (arg &optional buffer)
@@ -198,6 +217,10 @@ the open-parenthesis that starts a defun
;; XEmacs change (for zmacs regions)
(interactive "_p")
(if (or (null arg) (= arg 0)) (setq arg 1))
+ (if end-of-defun-function
+ (if (> arg 0)
+ (dotimes (i arg)
+ (funcall end-of-defun-function)))
(let ((first t))
(while (and (> arg 0) (< (point) (point-max)))
(let ((pos (point))) ; XEmacs -- remove unused npos.
@@ -229,7 +252,7 @@ the open-parenthesis that starts a defun
(if (looking-at "\\s<\\|\n")
(forward-line 1)))
(goto-char (point-min)))))
- (setq arg (1+ arg)))))
+ (setq arg (1+ arg))))))
(defun mark-defun ()
"Put mark at end of this defun, point at beginning.
| author | Andreas Roehler <andreas.roehler@online.de> |
|---|---|
| date | Tue, 22 Sep 2009 21:14:03 +0200 |
| parents | ecc468b62551 |
| children | 7b90173970ad |
| 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 |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
161 "If non-nil, function for `beginning-of-defun-raw' to call. |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
162 This is used to find the beginning of the defun instead of using the |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
163 normal recipe (see `beginning-of-defun'). Modes can define this |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
164 if defining `defun-prompt-regexp' is not sufficient to handle the mode's |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
165 needs.") |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
166 |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
167 (defvar end-of-defun-function nil |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
168 "If non-nil, function for `end-of-defun' to call. |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
169 This is used to find the end of the defun instead of using the normal |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
170 recipe (see `end-of-defun'). Modes can define this if the |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
171 normal method is not appropriate.") |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
172 |
| 428 | 173 (defun beginning-of-defun (&optional arg) |
| 174 "Move backward to the beginning of a defun. | |
| 175 With argument, do it that many times. Negative arg -N | |
| 176 means move forward to Nth following beginning of defun. | |
| 177 Returns t unless search stops due to beginning or end of buffer. | |
| 178 | |
| 179 Normally a defun starts when there is an char with open-parenthesis | |
| 180 syntax at the beginning of a line. If `defun-prompt-regexp' is | |
| 181 non-nil, then a string which matches that regexp may precede the | |
| 182 open-parenthesis, and point ends up at the beginning of the line." | |
| 183 ;; XEmacs change (for zmacs regions) | |
| 184 (interactive "_p") | |
| 185 (and (beginning-of-defun-raw arg) | |
| 186 (progn (beginning-of-line) t))) | |
| 187 | |
| 188 (defun beginning-of-defun-raw (&optional arg) | |
| 189 "Move point to the character that starts a defun. | |
| 190 This is identical to beginning-of-defun, except that point does not move | |
| 191 to the beginning of the line when `defun-prompt-regexp' is non-nil." | |
| 192 (interactive "p") | |
|
4696
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
193 ;; (and arg (< arg 0) (not (eobp)) (forward-char 1)) |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
194 (unless arg (setq arg 1)) |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
195 (cond |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
196 (beginning-of-defun-function |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
197 (funcall beginning-of-defun-function arg)) |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
198 (t (re-search-backward (if defun-prompt-regexp |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
199 (concat "^\\s(\\|" |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
200 "\\(" defun-prompt-regexp "\\)\\s(") |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
201 "^\\s(") |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
202 nil 'move (or arg 1)) |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
203 (progn (goto-char (1- (match-end 0)))) t))) |
| 428 | 204 |
| 205 ;; XEmacs change (optional buffer parameter) | |
| 206 (defun buffer-end (arg &optional buffer) | |
| 207 "Return `point-max' of BUFFER if ARG is > 0; return `point-min' otherwise. | |
| 208 BUFFER defaults to the current buffer if omitted." | |
| 209 (if (> arg 0) (point-max buffer) (point-min buffer))) | |
| 210 | |
| 211 (defun end-of-defun (&optional arg) | |
| 212 "Move forward to next end of defun. With argument, do it that many times. | |
| 213 Negative argument -N means move back to Nth preceding end of defun. | |
| 214 | |
| 215 An end of a defun occurs right after the close-parenthesis that matches | |
| 216 the open-parenthesis that starts a defun; see `beginning-of-defun'." | |
| 217 ;; XEmacs change (for zmacs regions) | |
| 218 (interactive "_p") | |
| 219 (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
|
220 (if end-of-defun-function |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
221 (if (> arg 0) |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
222 (dotimes (i arg) |
|
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
223 (funcall end-of-defun-function))) |
| 428 | 224 (let ((first t)) |
| 225 (while (and (> arg 0) (< (point) (point-max))) | |
| 226 (let ((pos (point))) ; XEmacs -- remove unused npos. | |
| 227 (while (progn | |
| 228 (if (and first | |
| 229 (progn | |
| 230 (end-of-line 1) | |
| 231 (beginning-of-defun-raw 1))) | |
| 232 nil | |
| 446 | 233 (or (bobp) (backward-char 1)) |
| 428 | 234 (beginning-of-defun-raw -1)) |
| 235 (setq first nil) | |
| 236 (forward-list 1) | |
| 237 (skip-chars-forward " \t") | |
| 238 (if (looking-at "\\s<\\|\n") | |
| 239 (forward-line 1)) | |
| 240 (<= (point) pos)))) | |
| 241 (setq arg (1- arg))) | |
| 242 (while (< arg 0) | |
| 243 (let ((pos (point))) | |
| 244 (beginning-of-defun-raw 1) | |
| 245 (forward-sexp 1) | |
| 246 (forward-line 1) | |
| 247 (if (>= (point) pos) | |
| 248 (if (beginning-of-defun-raw 2) | |
| 249 (progn | |
| 250 (forward-list 1) | |
| 251 (skip-chars-forward " \t") | |
| 252 (if (looking-at "\\s<\\|\n") | |
| 253 (forward-line 1))) | |
| 254 (goto-char (point-min))))) | |
|
4696
ecc468b62551
funcall beginning-of-defun-function arg
andreas.roehler@online.de
parents:
3543
diff
changeset
|
255 (setq arg (1+ arg)))))) |
| 428 | 256 |
| 257 (defun mark-defun () | |
| 258 "Put mark at end of this defun, point at beginning. | |
| 259 The defun marked is the one that contains point or follows point." | |
| 260 (interactive) | |
| 261 (push-mark (point)) | |
| 262 (end-of-defun) | |
| 263 (push-mark (point) nil t) | |
| 264 (beginning-of-defun) | |
| 265 (re-search-backward "^\n" (- (point) 1) t)) | |
| 266 | |
| 267 (defun narrow-to-defun (&optional arg) | |
| 268 "Make text outside current defun invisible. | |
| 269 The defun visible is the one that contains point or follows point." | |
| 270 (interactive) | |
| 271 (save-excursion | |
| 272 (widen) | |
| 273 (end-of-defun) | |
| 274 (let ((end (point))) | |
| 275 (beginning-of-defun) | |
| 276 (narrow-to-region (point) end)))) | |
| 277 | |
| 278 (defun insert-parentheses (arg) | |
| 279 "Enclose following ARG sexps in parentheses. Leave point after open-paren. | |
| 280 A negative ARG encloses the preceding ARG sexps instead. | |
| 281 No argument is equivalent to zero: just insert `()' and leave point between. | |
| 282 If `parens-require-spaces' is non-nil, this command also inserts a space | |
| 283 before and after, depending on the surrounding characters." | |
| 284 (interactive "P") | |
| 285 (if arg (setq arg (prefix-numeric-value arg)) | |
| 286 (setq arg 0)) | |
| 287 (cond ((> arg 0) (skip-chars-forward " \t")) | |
| 288 ((< arg 0) (forward-sexp arg) (setq arg (- arg)))) | |
| 289 (and parens-require-spaces | |
| 290 (not (bobp)) | |
| 291 (memq (char-syntax (char-before (point))) '(?w ?_ ?\) )) | |
| 292 (insert " ")) | |
| 293 (insert ?\() | |
| 294 (save-excursion | |
| 295 (or (eq arg 0) (forward-sexp arg)) | |
| 296 (insert ?\)) | |
| 297 (and parens-require-spaces | |
| 298 (not (eobp)) | |
| 299 (memq (char-syntax (char-after (point))) '(?w ?_ ?\( )) | |
| 300 (insert " ")))) | |
| 301 | |
| 302 (defun move-past-close-and-reindent () | |
| 303 "Move past next `)', delete indentation before it, then indent after it." | |
| 304 (interactive) | |
| 305 (up-list 1) | |
| 446 | 306 (backward-char 1) |
| 428 | 307 (while (save-excursion ; this is my contribution |
| 308 (let ((before-paren (point))) | |
| 309 (back-to-indentation) | |
| 310 (= (point) before-paren))) | |
| 311 (delete-indentation)) | |
| 312 (forward-char 1) | |
| 313 (newline-and-indent)) | |
| 314 | |
| 315 (defun lisp-complete-symbol () | |
| 316 "Perform completion on Lisp symbol preceding point. | |
| 317 Compare that symbol against the known Lisp symbols. | |
| 318 | |
| 319 The context determines which symbols are considered. | |
| 320 If the symbol starts just after an open-parenthesis, only symbols | |
| 321 with function definitions are considered. Otherwise, all symbols with | |
| 322 function definitions, values or properties are considered." | |
| 323 (interactive) | |
| 324 (let* ((end (point)) | |
| 325 (buffer-syntax (syntax-table)) | |
| 326 (beg (unwind-protect | |
| 327 (save-excursion | |
| 328 ;; XEmacs change | |
| 329 (if emacs-lisp-mode-syntax-table | |
| 330 (set-syntax-table emacs-lisp-mode-syntax-table)) | |
| 331 (backward-sexp 1) | |
| 332 (while (eq (char-syntax (char-after (point))) ?\') | |
| 333 (forward-char 1)) | |
| 334 (point)) | |
| 335 (set-syntax-table buffer-syntax))) | |
| 336 (pattern (buffer-substring beg end)) | |
| 337 (predicate | |
| 338 (if (eq (char-after (1- beg)) ?\() | |
| 339 'fboundp | |
| 340 ;; XEmacs change | |
| 341 #'(lambda (sym) | |
| 342 (or (boundp sym) (fboundp sym) | |
| 343 (symbol-plist sym))))) | |
| 344 (completion (try-completion pattern obarray predicate))) | |
| 345 (cond ((eq completion t)) | |
| 346 ((null completion) | |
| 347 (message "Can't find completion for \"%s\"" pattern) | |
| 348 (ding)) | |
| 349 ((not (string= pattern completion)) | |
| 350 (delete-region beg end) | |
| 351 (insert completion)) | |
| 352 (t | |
| 353 (message "Making completion list...") | |
| 354 (let ((list (all-completions pattern obarray predicate)) | |
| 355 ;FSFmacs crock unnecessary in XEmacs | |
| 356 ;see minibuf.el | |
| 357 ;(completion-fixup-function | |
| 358 ; (function (lambda () (if (save-excursion | |
| 359 ; (goto-char (max (point-min) | |
| 360 ; (- (point) 4))) | |
| 361 ; (looking-at " <f>")) | |
| 362 ; (forward-char -4)))) | |
| 363 ) | |
| 364 (or (eq predicate 'fboundp) | |
| 365 (let (new) | |
| 366 (while list | |
| 367 (setq new (cons (if (fboundp (intern (car list))) | |
| 368 (list (car list) " <f>") | |
| 369 (car list)) | |
| 370 new)) | |
| 371 (setq list (cdr list))) | |
| 372 (setq list (nreverse new)))) | |
| 373 (with-output-to-temp-buffer "*Completions*" | |
| 374 (display-completion-list list))) | |
| 375 (message "Making completion list...%s" "done"))))) | |
| 376 | |
| 377 ;;; lisp.el ends here |
