annotate lisp/lisp.el @ 4705:7b90173970ad

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