annotate lisp/ilisp/completer.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; -*-Emacs-Lisp-*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;;%Header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; Rcs_Info: completer.el,v 3.23 1993/09/03 02:05:07 ivan Rel $
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; Partial completion mechanism for GNU Emacs. Version 3.03
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; Copyright (C) 1990, 1991, 1992 Chris McConnell, ccm@cs.cmu.edu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Thanks to Bjorn Victor for suggestions, testing, and patches for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; file completion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; but WITHOUT ANY WARRANTY. No author or distributor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; accepts responsibility to anyone for the consequences of using it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; or for whether it serves any particular purpose or works at all,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; unless he says so in writing. Refer to the GNU Emacs General Public
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; License for full details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; Everyone is granted permission to copy, modify and redistribute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; GNU Emacs, but only under the conditions described in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; GNU Emacs General Public License. A copy of this license is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; supposed to have been given to you along with GNU Emacs so you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; can know your rights and responsibilities. It should be in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; file named COPYING. Among other things, the copyright notice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; and this notice must be preserved on all copies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; When loaded, this file extends the standard completion mechanisms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; so that they perform pattern matching completions. There is also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; an interface that allows it to be used by other programs. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; completion rules are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; 1) If what has been typed matches any possibility, do normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; completion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; 2) Otherwise, generate a regular expression such that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; completer-words delimit words and generate all possible matches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; The variable completer-any-delimiter can be set to a character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; that matches any delimiter. If it were " ", then "by d" would be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; byte-recompile-directory. If completer-use-words is T, a match is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; unique if it is the only one with the same number of words. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; completer-use-words is NIL, a match is unique if it is the only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; possibility. If you ask the completer to use its best guess, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; will be the shortest match of the possibilities unless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; completer-exact is T.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; 3) For filenames, if completer-complete-filenames is T, each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; pathname component will be individually completed, otherwise only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; the final component will be completed. If you are using a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;; distributed file system like afs, you may want to set up a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; symbolic link in your home directory or add pathname components to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; completer-file-skip so that the pathname components that go across
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;; machines do not get expanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; SPACE, TAB, LFD, RET, and ? do normal completion if possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; otherwise they do partial completion. In addition, C-DEL will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; undo the last partial expansion or contraction. M-RET will always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; complete to the current match before returning. This is useful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; when any string is possible, but you want to complete to a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; as when calling find-file. The bindings can be changed by using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; completer-load-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; Modes that use comint-dynamic-complete (like cmushell and ilisp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; will also do partial completion as will M-tab in Emacs LISP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; Examples:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; a-f auto-fill-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; b--d *beginning-of-defun or byte-recompile-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; by d *byte-recompile-directory if completer-any-delimiter is " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; ~/i.e *~/ilisp.el or ~/il-el.el or ~/ilisp.elc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; /u/mi/ /usr/misc/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;;%Globals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;;%%Switches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defvar completer-load-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "Hook called when minibuffer partial completion is loaded.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defvar completer-disable nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 "*If T, turn off partial completion. Use the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 \\[completer-toggle] to set this.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defvar completer-complete-filenames t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 "*If T, then each component of a filename will be completed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 otherwise just the final component will be completed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defvar completer-use-words nil ; jwz: this is HATEFUL!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "*If T, then prefer completions with the same number of words as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 pattern.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (defvar completer-words "---. <"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 "*Delimiters used in partial completions. It should be a set of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 characters suitable for inclusion in a [] regular expression.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (defvar completer-any-delimiter nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 "*If a character, then a delimiter in the pattern that matches the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 character will match any delimiter in completer-words.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defvar completer-file-skip "^cs/$\\|@sys\\|.edu/$\\|.gov/$\\|.com/$\\|:/$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 "*Regular expression for pathname components to not complete.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defvar completer-exact nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "*If T, then you must have an exact match. Otherwise, the shortest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 string that matches the pattern will be used.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defvar completer-cache-size 100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "*Size of cache to use for partially completed pathnames.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defvar completer-use-cache t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "*Set to nil to disable the partially completed pathname cache.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;;%%Internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defvar completer-last-pattern ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 "The last pattern expanded.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (defvar completer-message nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 "T if temporary message was just displayed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (defvar completer-path-cache nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 "Cache of (path . choices) for completer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defvar completer-string nil "Last completer string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defvar completer-table nil "Last completer table.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defvar completer-pred nil "Last completer pred.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defvar completer-mode nil "Last completer mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defvar completer-result nil "Last completer result.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;;%Utilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defun completer-message (message &optional point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 "Display MESSAGE at optional POINT for two seconds."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (setq point (or point (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 completer-message t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (let ((end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (goto-char point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (insert message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (delete-region point end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (if (and quit-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;;(not (eq 'lucid-19 ilisp-emacs-version-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (not (string-match "Lucid" emacs-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (setq quit-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 unread-command-char 7))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defun completer-deleter (regexp choices &optional keep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 "Destructively remove strings that match REGEXP in CHOICES and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 return the modified list. If optional KEEP, then keep entries that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 match regexp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (let* ((choiceb choices)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 choicep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (if keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (while (and choiceb (not (string-match regexp (car choiceb))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq choiceb (cdr choiceb)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (setq choicep choiceb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (while (cdr choicep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (if (string-match regexp (car (cdr choicep)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (setq choicep (cdr choicep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (rplacd choicep (cdr (cdr choicep))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (while (and choiceb (string-match regexp (car choiceb)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (setq choiceb (cdr choiceb)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (setq choicep choiceb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (while (cdr choicep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (if (string-match regexp (car (cdr choicep)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (rplacd choicep (cdr (cdr choicep)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (setq choicep (cdr choicep)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 choiceb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;;%%Regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defun completer-regexp (string delimiters any)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "Convert STRING into a regexp with words delimited by characters in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 DELIMITERS. Any delimiter in STRING that is the same as ANY will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 match any delimiter."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (let* ((delimiter-reg (concat "[" delimiters "]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (limit (length string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (pos 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (regexp "^"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (while (and (< pos limit) (string-match delimiter-reg string pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (let* ((begin (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (end (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (delimiter (substring string begin end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (anyp (eq (elt string begin) any)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (setq regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (format "%s%s[^%s]*%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (regexp-quote (substring string pos begin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (if anyp delimiters delimiter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (if anyp delimiter-reg (regexp-quote delimiter)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 pos end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if (<= pos limit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (setq regexp (concat regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (regexp-quote (substring string pos limit)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (defun completer-words (regexp string &optional limit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 "Return the number of words matching REGEXP in STRING up to LIMIT."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (setq limit (or limit 1000))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (let ((count 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (pos 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (while (and (string-match regexp string pos) (<= count limit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (setq count (1+ count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 pos (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;;%Matcher
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (defun completer-matches (string choices delimiters any)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "Return STRING's matches in CHOICES using DELIMITERS and wildcard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ANY to segment the strings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (let* ((regexp (concat "[" delimiters "]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (from nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (to 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (pattern nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (len (length string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (matches nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 sub sublen choice word wordlen pat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; Segment pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (while (< (or from 0) len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (setq to (or (string-match regexp string (if from (1+ from))) len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (if (eq (elt string (or from 0)) completer-any-delimiter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (setq sub (substring string (if from (1+ from) 0) to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 sublen (- (length sub)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (setq sub (substring string (or from 0) to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 sublen (length sub)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (setq pattern (cons (cons sub sublen) pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 from to))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (setq pattern (reverse pattern))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; Find choices that match patterns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (setq regexp (concat "[" delimiters "]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (while choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (setq choice (car choices)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 word pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 from 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (while (and word from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (let* (begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (if (< (setq wordlen (cdr (setq pat (car word)))) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (setq begin (1+ from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 end (+ begin (- wordlen)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (setq begin from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 end (+ begin wordlen)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (and (<= end (length choice))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (or (zerop wordlen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (string-equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (car pat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (substring choice begin end))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (setq from (string-match regexp choice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (if (and (zerop from) (zerop wordlen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (1+ from)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 word (cdr word)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if (not word) (setq matches (cons choice matches)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (setq choices (cdr choices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 matches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defun completer-choice (string choices delimiters use-words)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 "Return the best match of STRING in CHOICES with DELIMITERS between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 words and T if it is unique. A match is unique if it is the only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 possibility or when USE-WORDS the only possibility with the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 number of words. The shortest string of multiple possiblities will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 the best match."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (or (if (null (cdr choices)) (cons (car choices) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (let* ((regexp (concat "[^" delimiters "]*[" delimiters "]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (words (if use-words (completer-words regexp string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (choice choices)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (unique-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (match nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (match-count nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (match-len 1000))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (while choice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (let* ((current (car choice))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (length (length current)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (if match-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (if (= (completer-words regexp current words) words)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (setq unique-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (if (< length match-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (setq match current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 match-len length))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (if (and use-words
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (= (completer-words regexp current words) words))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq match current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 match-len length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 match-count t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 unique-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (if (< length match-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (setq match current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 match-len length)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (setq choice (cdr choice)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (cons match unique-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;;;%Completer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;;;%%Utilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (defun completer-region (delimiters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 "Return the completion region bounded by characters in DELIMITERS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 for the current buffer assuming that point is in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (cons (save-excursion (skip-chars-backward delimiters) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (save-excursion (skip-chars-forward delimiters) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (defun completer-last-component (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 "Return the start of the last filename component in STRING."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (let ((last (1- (length string)) )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (match 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (while (and (setq match (string-match "/" string end)) (< match last))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq end (1+ match)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (defun completer-match-record (string matches delimiters any dir mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "Return (match lcs choices unique) for STRING in MATCHES with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 DELIMITERS or ANY wildcards and DIR if a filename when in MODE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (let ((pattern (if dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (substring string (completer-last-component string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (setq matches (completer-matches pattern matches delimiters any)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 match (try-completion pattern (mapcar 'list matches)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;; If try-completion produced an exact match for an element in 'matches',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;; then remove any partial matches from 'matches' and set the unique
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;; match flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (and (stringp match) (member match matches) (setq matches (list match)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (if (cdr matches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (let ((lcs (concat dir (try-completion "" (mapcar 'list matches)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (setq match (if (not completer-exact)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (completer-choice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 pattern matches delimiters completer-use-words)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (list (if match (concat dir (car match)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 lcs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (cdr match)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (if matches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (progn (setq match (concat dir (car matches)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (list match match matches t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (list nil nil nil nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;;;%%Complete file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (defun completer-extension-regexp (extensions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 "Return a regexp that matches to a string that ends with any string from EXTENSIONS list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (concat "\\(" (mapconcat 'regexp-quote extensions "\\|") "\\)\\'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (defun completer-flush ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 "Flush completer's pathname cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (setq completer-path-cache nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defun completer-cache (path pred words any mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 "Check to see if PATH is in path cache with PRED, WORDS, ANY and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 MODE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (let* ((last nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (ptr completer-path-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (size 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (result nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (if completer-use-cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (while ptr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (let ((current (car (car ptr))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (if (string-equal current path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (if last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (rplacd last (cdr ptr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (rplacd ptr completer-path-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (setq completer-path-cache ptr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (setq result (cdr (car ptr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ptr nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (if (cdr ptr) (setq last ptr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (setq size (1+ size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ptr (cdr ptr))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (or result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (let* ((choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (completer path 'read-file-name-internal pred words any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 mode t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (if (and (or (car (cdr (cdr (cdr choices))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (string= path (car choices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (eq (elt (car choices) (1- (length (car choices)))) ?/))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (if (>= size completer-cache-size) (rplacd last nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (setq completer-path-cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (cons (cons path choices) completer-path-cache))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 choices))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defun completer-file (string pred words any mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "Return (match common-substring matches unique-p) for STRING using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 read-file-name-internal for choices that pass PRED using WORDS to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 delimit words. Optional ANY is a delimiter that matches any of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 delimiters in WORD. If optional MODE is nil or 'help then possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 matches will always be returned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (let* ((case-fold-search completion-ignore-case)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (last (and (eq mode 'exit-ok) (completer-last-component string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;; Special hack for CMU RFS filenames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (if (string-match "^/\\.\\./[^/]*/" string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (string-match "[^~/]" string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (new (substring string 0 position))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (user (if (string= new "~")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (setq new (file-name-directory (expand-file-name new)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (words (concat words "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (len (length string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (choices nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (old-choices (list nil nil nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (while position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (let* ((begin (string-match "/" string position))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (exact-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (setq end (if begin (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;; Ends with a /, so check files in directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if (and (memq mode '(nil help)) (= position len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (completer-match-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;; This assumes that .. and . come at the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (let* ((choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (all-completions new 'read-file-name-internal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (choicep choices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (if (string= (car choicep) "../")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (cdr (cdr choicep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (while (cdr choicep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (if (string= (car (cdr choicep)) "../")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (rplacd choicep nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (setq choicep (cdr choicep)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 choices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 words any new mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (if (eq position last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (let ((new (concat new (substring string position))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (list new new nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let ((component (substring string position end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (if (and end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (string-match completer-file-skip component))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;; Assume component is complete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (list (concat new component)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (concat new component)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (completer-cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (concat new component)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 pred words any mode))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;; Keep going if unique or we match exactly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if (or (car (cdr (cdr (cdr choices))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (setq exact-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (string= (concat new (substring string position end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (car choices))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (setq old-choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (let* ((lcs (car (cdr choices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (matches (car (cdr (cdr choices))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (slash (and lcs (string-match "/$" lcs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if slash (substring lcs 0 slash) lcs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (if (and (cdr matches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (or (eq mode 'help) (not exact-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 matches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 new (car choices)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 position end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;; Its ok to not match user names because they may be in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ;; different root directories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (if (and (= position 1) (= (elt string 0) ?~))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (setq new (substring string 0 end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 choices (list new new (list new) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 user nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 position end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (setq position nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (if (not (car choices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (setq choices old-choices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (if (and (car choices)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (not (eq mode 'help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (not (car (cdr (cdr (cdr choices))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;; Try removing completion ignored extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (let* ((extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (completer-extension-regexp completion-ignored-extensions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (choiceb (car (cdr (cdr choices))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (choicep choiceb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (isext nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (noext nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (while choicep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (if (string-match extensions (car choicep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (setq isext t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (setq noext t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (if (and isext noext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; There are matches besides extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (setq choiceb (completer-deleter extensions choiceb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 choicep nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (setq choicep (cdr choicep))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (if (and isext noext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (setq choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (completer-match-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (if end (substring string end) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 choiceb words any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (file-name-directory (car (cdr choices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 mode)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (if user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (let ((match (car choices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (lcs (car (cdr choices)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (len (length user)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (setq choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (cons (if match (concat "~" (substring match len)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (cons (if lcs (concat "~" (substring lcs len)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (cdr (cdr choices)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 choices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ;;;%Exported program interface
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;;;%%Completer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (defun completer (string table pred words
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 &optional any mode file-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 "Return (match common-substring matches unique-p) for STRING in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 TABLE for choices that pass PRED using WORDS to delimit words. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 flag completer-complete-filenames is T and the table is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 read-file-name-internal, then filename components will be individually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 expanded. Optional ANY is a delimiter that can match any delimiter in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 WORDS. Optional MODE is nil for complete, 'help for help and 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 for exit."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (if (and (stringp completer-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (string= string completer-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (eq table completer-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (eq pred completer-pred)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (not file-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (or (eq mode completer-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (not (memq table '(read-file-name-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 read-directory-name-internal)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 completer-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 completer-string ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 completer-table table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 completer-pred pred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 completer-mode mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 completer-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (if (and completer-complete-filenames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (not file-p) (eq table 'read-file-name-internal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (completer-file string pred words any mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (let* ((file-p (or file-p (eq table 'read-file-name-internal)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (case-fold-search completion-ignore-case)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (pattern (concat "[" words "]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (component (if file-p (completer-last-component string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (dir (if component (substring string 0 component)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (string (if dir (substring string component) string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (has-words (or (string-match pattern string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (length string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (if (and file-p (string-match "^\\$" string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ;; Handle environment variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (let ((match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (getenv (substring string 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (string-match "/" string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (if match (setq match (concat match "/")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (list match match (list match) match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (let* ((choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (all-completions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (concat dir (substring string 0 has-words))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 table pred))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (regexp (completer-regexp string words any)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (if choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (completer-match-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (completer-deleter regexp choices t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 words any dir mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (list nil nil nil nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 completer-string string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 completer-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;;;%%Display choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (defun completer-display-choices (choices &optional match message end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 "Display the list of possible CHOICES with optional MATCH, MESSAGE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 END and DISPLAY. If MATCH is non-nil, it will be flagged as the best
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 guess. If there are no choices, display MESSAGE. END is where to put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 temporary messages. If DISPLAY is present then it will be called on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 each possible completion and should return a string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (if choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (with-output-to-temp-buffer "*Completions*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (if (cdr choices)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (funcall completion-display-completion-list-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (if display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (let ((old choices)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (new nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (while old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (setq new (cons (funcall display (car old)) new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 old (cdr old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (copy-sequence choices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (function (lambda (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (string-lessp (or (car-safe x) x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (or (car-safe y) y)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (if match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (set-buffer "*Completions*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (insert "Guess = " match (if (cdr choices) ", " "") "\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (completer-message (or message " (No completions)") end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;;;%%Goto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (defun completer-goto (match lcs choices unique delimiters words
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 &optional mode display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 "MATCH is the best match, LCS is the longest common substring of all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 of the matches. CHOICES is a list of the possibilities, UNIQUE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 indicates if MATCH is unique. DELIMITERS are possible bounding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 characters for the completion region. WORDS are the characters that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 delimit the words for partial matches. Replace the region bounded by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 delimiters with the match if unique and the lcs otherwise unless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 optional MODE is 'help. Then go to the part of the string that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 disambiguates choices using WORDS to separate words and display the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 possibilities if the string was not extended. If optional DISPLAY is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 present then it will be called on each possible completion and should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 return a string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (setq completer-message nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (let* ((region (completer-region delimiters))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (start (car region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (end (cdr region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (string (buffer-substring start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (file-p (string-match "[^ ]*\\(~\\|/\\|$\\)" string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (no-insert (eq mode 'help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (message t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (new (not (string= (buffer-substring start (point)) lcs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (if unique
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (if no-insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (completer-display-choices choices match nil end display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (if (string= string match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (if (not file-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (progn (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (completer-message " (Sole completion)" end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (completer-insert match delimiters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;;Not unique
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (if lcs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (let* ((regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (concat "[" words (if file-p "/") "]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (words (completer-words regexp lcs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ;; Go to where its ambiguous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (if (not no-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (insert lcs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (setq completer-last-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (list string delimiters (current-buffer) start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 start (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 end (+ end (length lcs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;; Skip to the first delimiter in the original string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;; beyond the ambiguous point and keep from there on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (if (re-search-forward regexp end 'move words)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (if (and (not no-insert) match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (let ((delimiter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (string-match (regexp-quote lcs) match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (substring match (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (1+ (match-end 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (if (string-match regexp delimiter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (insert delimiter))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (forward-char -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (if (not no-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (setq end (- end (- (point) start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (delete-region start (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (if choices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (if (or no-insert (not new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (completer-display-choices choices match nil end display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (if file-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (if (not (= (point) end)) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (if (not (save-excursion (re-search-forward "/" end t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (goto-char end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (if message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (completer-message (if no-insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 " (No completions)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 " (No match)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 end)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 ;;;%Exported buffer interface
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 ;;;%%Complete and go
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (defun completer-complete-goto (delimiters words table pred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 &optional no-insert display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 "Complete the string bound by DELIMITERS using WORDS to bound words
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 for partial matches in TABLE with PRED and then insert the longest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 common substring unless optional NO-INSERT and go to the point of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 ambiguity. If optional DISPLAY, it will be called on each match when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 possible completions are shown and should return a string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (let* ((region (completer-region delimiters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (apply 'completer-goto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (append (completer (buffer-substring (car region) (cdr region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 table pred words completer-any-delimiter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 no-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (list delimiters words no-insert display)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 ;;;%%Undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (defun completer-insert (match delimiters &optional buffer undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 "Replace the region bounded with characters in DELIMITERS by MATCH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 and save it so that it can be restored by completer-undo."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (let* ((region (completer-region delimiters))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (start (car region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (end (cdr region)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (if (and undo (or (not (= start undo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (not (eq (current-buffer) buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (error "No previous pattern")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (setq completer-last-pattern (list (buffer-substring start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 delimiters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (delete-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (insert match))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (defun completer-undo ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 "Swap the last expansion and the last match pattern."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (if completer-last-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (apply 'completer-insert completer-last-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (error "No previous pattern")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;;;%Minibuffer specific code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ;;;%%Utilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (defun completer-minibuf-string ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 "Remove dead filename specs from the minibuffer as delimited by //
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 or ~ or $ and return the resulting string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (if (and (eq minibuffer-completion-table 'read-file-name-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (re-search-backward "//\\|/~\\|.\\$" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (delete-region (point-min) (1+ (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (buffer-substring (point-min) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (defun completer-minibuf-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 "Exit the minibuffer and clear completer-last-pattern."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (setq completer-last-pattern nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (exit-minibuffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (defun completer-new-cmd (cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 "Return t if we can't execute the old minibuffer version of CMD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (if (or completer-disable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (let ((string (completer-minibuf-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (not (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (concat "[" completer-words "/~]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (let ((completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (try-completion string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 minibuffer-completion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 minibuffer-completion-predicate)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (if (eq minibuffer-completion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 'read-file-name-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 ;; Directories complete as themselves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (and completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (or (not (string= string completion))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (file-exists-p completion)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 completion))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (error nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (funcall cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (defun completer-minibuf (&optional mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 "Partial completion of minibuffer expressions. Optional MODE is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 'help for help and 'exit for exit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 If what has been typed so far matches any possibility normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 completion will be done. Otherwise, the string is considered to be a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 pattern with words delimited by the characters in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 completer-words. If completer-exact is T, the best match will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 the shortest one with the same number of words as the pattern if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 possible and otherwise the shortest matching expression. If called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 with a prefix, caching will be temporarily disabled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 Examples:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 a-f auto-fill-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 r-e rmail-expunge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 b--d *begining-of-defun or byte-recompile-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 by d *byte-recompile-directory if completer-any-delimiter is \" \"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 ~/i.e *~/ilisp.el or ~/il-el.el or ~/ilisp.elc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 /u/mi/ /usr/misc/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (let ((completer-use-cache (not (or (not completer-use-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 current-prefix-arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (completer (completer-minibuf-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 minibuffer-completion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 minibuffer-completion-predicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 completer-words
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 completer-any-delimiter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (list "^" completer-words mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 ;;;%%Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (defun completer-toggle ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 "Turn partial completion on or off."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (setq completer-disable (not completer-disable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (message (if completer-disable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 "Partial completion OFF"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 "Partial completion ON")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (defvar completer-old-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (lookup-key minibuffer-local-must-match-map "?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 "Old binding of ? in minibuffer completion map.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (defun completer-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 "Partial completion minibuffer-completion-help.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 See completer-minibuf for more information."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (if (completer-new-cmd completer-old-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (apply 'completer-goto (completer-minibuf 'help))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (defvar completer-old-completer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (lookup-key minibuffer-local-must-match-map "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 "Old binding of TAB in minibuffer completion map.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (defun completer-complete ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 "Partial completion minibuffer-complete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 See completer-minibuf for more information."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (if (completer-new-cmd completer-old-completer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (apply 'completer-goto (completer-minibuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (defvar completer-old-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (lookup-key minibuffer-local-must-match-map " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 "Old binding of SPACE in minibuffer completion map.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (defun completer-word ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 "Partial completion minibuffer-complete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 See completer-minibuf for more information."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (if (eq completer-any-delimiter ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (insert ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (if (completer-new-cmd completer-old-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (apply 'completer-goto (completer-minibuf)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (defvar completer-old-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (lookup-key minibuffer-local-must-match-map "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 "Old binding of RET in minibuffer completion map.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (defun completer-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 "Partial completion minibuffer-complete-and-exit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 See completer-minibuf for more information."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (if (completer-new-cmd completer-old-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (let* ((completions (completer-minibuf 'exit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (match (car completions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (unique-p (car (cdr (cdr (cdr completions))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (apply 'completer-goto completions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (if unique-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (completer-minibuf-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (if match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (progn (completer-insert match "^")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (if minibuffer-completion-confirm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (completer-message " (Confirm)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (completer-minibuf-exit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (if (not completer-message) (beep)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (defun completer-match-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 "Exit the minibuffer with the current best match."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (let* ((completions (completer-minibuf 'exit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (guess (car completions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (if (not guess)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 ;; OK if last filename component doesn't match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (setq completions (completer-minibuf 'exit-ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 guess (car completions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (if guess
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (insert guess)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (exit-minibuffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (apply 'completer-goto completions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 ;;;%%Keymaps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 ;this interferes with normal undo.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 ;(define-key minibuffer-local-completion-map "\C-_" 'completer-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (define-key minibuffer-local-completion-map "\t" 'completer-complete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (define-key minibuffer-local-completion-map " " 'completer-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (define-key minibuffer-local-completion-map "?" 'completer-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (define-key minibuffer-local-completion-map "\n" 'completer-minibuf-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (define-key minibuffer-local-completion-map "\r" 'completer-minibuf-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (define-key minibuffer-local-completion-map "\M-\n" 'completer-match-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (define-key minibuffer-local-completion-map "\M-\r" 'completer-match-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 ;this interferes with normal undo.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 ;(define-key minibuffer-local-must-match-map "\C-_" 'completer-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (define-key minibuffer-local-must-match-map "\t" 'completer-complete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (define-key minibuffer-local-must-match-map " " 'completer-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (define-key minibuffer-local-must-match-map "\n" 'completer-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (define-key minibuffer-local-must-match-map "\r" 'completer-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (define-key minibuffer-local-must-match-map "?" 'completer-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (define-key minibuffer-local-must-match-map "\M-\n" 'completer-match-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (define-key minibuffer-local-must-match-map "\M-\r" 'completer-match-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;;;%comint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (defun completer-comint-dynamic-list-completions (completions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 "List in help buffer sorted COMPLETIONS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 Typing SPC flushes the help buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (completer-comint-dynamic-complete-1 nil 'help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (defun completer-comint-dynamic-complete-filename ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 "Dynamically complete the filename at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (completer-comint-dynamic-complete-1 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (defun completer-comint-dynamic-complete-1 (&optional undo mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 "Complete the previous filename or display possibilities if done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 twice in a row. If called with a prefix, undo the last completion."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (if undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (completer-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 ;; added by jwz: don't cache completions in shell buffer!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (setq completer-string nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (let ((conf (current-window-configuration)));; lemacs change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (completer-complete-goto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 "^ \t\n\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 completer-words
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 'read-file-name-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ;; lemacs change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (if (eq mode 'help) (comint-restore-window-config conf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ;(fset 'comint-dynamic-complete 'completer-comint-dynamic-complete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (fset 'comint-dynamic-complete-filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 'completer-comint-dynamic-complete-filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (fset 'comint-dynamic-list-completions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 'completer-comint-dynamic-list-completions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 ;;; Set the functions again if comint is loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (setq comint-load-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (cons (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 ;; (fset 'comint-dynamic-complete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 ;; 'completer-comint-dynamic-complete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (fset 'comint-dynamic-complete-filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 'completer-comint-dynamic-complete-filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (fset 'comint-dynamic-list-completions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 'completer-comint-dynamic-list-completions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (if (and (boundp 'comint-load-hook) comint-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (if (consp comint-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (if (eq (car comint-load-hook) 'lambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (list comint-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 comint-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (list comint-load-hook)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 ;;;%lisp-complete-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (defun lisp-complete-symbol (&optional mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 "Perform partial completion on Lisp symbol preceding point. That
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 symbol is compared against the symbols that exist and any additional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 characters determined by what is there are inserted. If the symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 starts just after an open-parenthesis, only symbols with function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 definitions are considered. Otherwise, all symbols with function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 definitions, values or properties are considered. If called with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 negative prefix, the last completion will be undone."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (if (< (prefix-numeric-value mode) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (completer-undo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (let* ((end (save-excursion (skip-chars-forward "^ \t\n)]}\"") (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (beg (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (while (= (char-syntax (following-char)) ?\')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (pattern (buffer-substring beg end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (predicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (if (eq (char-after (1- beg)) ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 'fboundp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (function (lambda (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (or (boundp sym) (fboundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (symbol-plist sym))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (completion (try-completion pattern obarray predicate)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (cond ((eq completion t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ((null completion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (completer-complete-goto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 "^ \t\n\(\)[]{}'`" completer-words
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 obarray predicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (if (not (eq predicate 'fboundp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (function (lambda (choice)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (if (fboundp (intern choice))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (list choice " <f>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 choice))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 ((not (string= pattern completion))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (delete-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (insert completion))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (message "Making completion list...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (let ((list (all-completions pattern obarray predicate)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (or (eq predicate 'fboundp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (let (new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (setq new (cons (if (fboundp (intern (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (list (car list) " <f>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (setq list (nreverse new))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (with-output-to-temp-buffer "*Help*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (funcall completion-display-completion-list-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (sort list (function (lambda (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (string-lessp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (or (car-safe x) x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (or (car-safe y) y))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (message "Making completion list...%s" "done"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 ;;;%Hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (provide 'completer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (run-hooks 'completer-load-hook)