annotate lisp/hippie-exp.el @ 1737:d7e9186edefa

entered into RCS
author Richard M. Stallman <rms@gnu.org>
date Wed, 06 Jan 1993 04:35:15 +0000
parents
children 6314334d7c2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;; Expand a word trying various ways to find its expansion.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;; Copyright (C) 1992 Free Software Foundation, Inc.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; This file is part of GNU Emacs.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; GNU Emacs is free software; you can redistribute it and/or modify
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; it under the terms of the GNU General Public License as published by
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; the Free Software Foundation; either version 2, or (at your option)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; any later version.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is distributed in the hope that it will be useful,
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; GNU General Public License for more details.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; You should have received a copy of the GNU General Public License
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; along with GNU Emacs; see the file COPYING. If not, write to
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; Author: Anders Holst (aho@sans.kth.se)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; Last change: 4 January 1993
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; DESCRIPTION
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; `hippie-expand' is a single function for a lot of different kinds
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; of completions and expansions. Called repeatedly it tries all
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; possible completions in succession.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; Which kinds of completions to try, and in which order, is
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; determined by the contents of `hippie-expand-try-functions-list'.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; Much customization of `hippie-expand' can be made by changing the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; order of, removing, or inserting new functions in this list.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; Given a positive numeric argument, `hippie-expand' jumps directly
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; ARG functions forward in this list. Given some other argument
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; (a negative argument or just Ctrl-U) it undoes the tried
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; completion.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; If the variable `hippie-expand-verbose' is non-nil, `hippie-expand'
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; outputs in a message which try-function in the list that is used
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; currently (ie. was used currently and will be tried first the next
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; time).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; See also the macro `make-hippie-expand-function' below.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; A short description of the current try-functions in this file:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; `try-complete-file-name' : very convenient to have in any buffer,
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; and not just in the minibuffer or (some) shell-mode. It goes
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; through all possible completions instead of just completing as
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; much as is unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; `try-complete-file-name-partially' : To insert in the list just
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;; before `try-complete-file-name' for those who want first to get
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; a file name completed only as many characters as is unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; (NOTE: Not by default in `hippie-expand-try-functions-list'.)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; `try-expand-all-abbrevs' : can be removed if you don't use abbrevs.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; Otherwise it looks through all abbrev-tables, starting with
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; the local followed by the global.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; `try-expand-line' : Searches the buffer for an entire line that
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; begins exactly as the current line. Convenient sometimes, for
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; example as a substitute for (or complement to) the history
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; list in shell-like buffers. Remove it if you find it confusing.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; `try-expand-line-all-buffers' : Like `try-expand-line' but searches
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; in all buffers (except the current). (This may be a little
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; slow, don't use it unless you are really fond of `hippie-expand'.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; NOTE: Not by default in hippie-expand-try-functions-list.)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; `try-expand-dabbrev' : works exactly as dabbrev-expand (but of
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; course in a way compatible with the other try-functions).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; `try-expand-dabbrev-all-buffers' : perhaps the most useful of them,
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; like `dabbrev-expand' but searches all Emacs buffers (except the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; current) for matching words. (No, I don't find this one
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; particularly slow.)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; `try-complete-lisp-symbol' : like `lisp-complete-symbol', but goes
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; through all possibilities instead of completing what is unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; Might be tedious (usually a lot of possible completions) and
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; since its function is much like `lisp-complete-symbol', which
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; already has a key of its own, you might want to remove this.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; `try-complete-lisp-symbol-partially' : To insert in the list just
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; before `try-complete-lisp-symbol' for those who first want to get
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; completion of what is unique in the name. (NOTE: Not by
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; default in hippie-expand-try-functions-list.)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; To write new try-functions, consider the following:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; Each try-function takes one argument OLD which is nil the first
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; time the function is called and true in succeeding calls for the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; same string to complete. The first time the function has to
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; extract the string before point to complete, and substitute the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; first completion alternative for it. On following calls it has to
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;; substitute the next possible completion for the last tried string.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;; The try-function is to return t as long as it finds new
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; possible completions. When there are no more alternatives it has
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;; to restore the text before point to its original contents, and
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;; return nil (don't beep or message or anything).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ;; The try-function can (should) use the following functions:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ;; `he-init-string' : Initializes the text to substitute to the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; contents of the region BEGIN to END. Also sets the variable
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;; `he-search-string' to the text to expand.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ;; `he-substitute-string' : substitutes STR into the region
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; initialized with `he-init-string'. (An optional second argument
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ;; TRANS-CASE non-nil, means transfer of case from the abbreviation
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ;; to the expansion is ok if that is enabled in the buffer.)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; `he-reset-string' : Resets the initialized region to its original
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ;; contents.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;; There is also a variable: `he-tried-table' which is meant to contain
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;; all tried expansions so far. The try-function can check this
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;; variable to see whether an expansion has already been tried
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; (hint: `he-string-member'), and add its own tried expansions to it.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; KNOWN BUGS
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;; It may happen that some completion suggestion occurs twice, in
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;; spite of the use of `he-tried-table' to prevent that. This is
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ;; because different try-functions may try to complete different
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ;; lengths of text, and thus put different amounts of the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; text in `he-try-table'. Anyway this seems to occur seldom enough not
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ;; to be too disturbing. Also it should NOT bee possible for the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;; opposite situation to occur, that `hippie-expand' misses some
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ;; suggestion because it thinks it has already tried it.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;; ACKNOWLEDGEMENT
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;; I want to thank Mikael Djurfeldt in discussions with whom the idea
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; of this function took form.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;; I am also grateful to all those who have given me suggestions on
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; how to improve it.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (defvar he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (defvar he-string-beg ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (defvar he-string-end ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (defvar he-search-string ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (defvar he-expand-list ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (defvar he-tried-table ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (defvar he-search-loc ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (defvar he-search-bw ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (defvar he-search-bufs ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (defvar hippie-expand-try-functions-list '(try-complete-file-name
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 try-expand-all-abbrevs
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 try-expand-line
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 try-expand-dabbrev
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 try-expand-dabbrev-all-buffers
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 try-complete-lisp-symbol)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 "The list of expansion functions tried in order by `hippie-expand'.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 To change the behavior of `hippie-expand', remove, change the order of,
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 or insert functions in this list.")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (defvar hippie-expand-verbose t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 "*Non-nil makes `hippie-expand' output which function it is trying.")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (defun hippie-expand (arg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 "Try to expand text before point, using multiple methods.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 The expansion functions in `hippie-expand-try-functions-list' are
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 tried in order, until a possible expansion is found. Repeated
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 application of `hippie-expand' inserts successively possible
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 expansions.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 With a positive numeric argument, jumps directly to the ARG next
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 function in this list. With a negative argument or just \\[universal-argument],
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 undoes the expansion."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (interactive "P")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (if (or (not arg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (and (integerp arg) (> arg 0)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (let ((first (or (= he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (not (equal this-command last-command)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (if first
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (setq he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (setq he-tried-table nil)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (if arg
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (if (not first) (he-reset-string))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (setq arg 0))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (let ((i (max (+ he-num arg) 0)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (while (not (or (>= i (length hippie-expand-try-functions-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (apply (nth i hippie-expand-try-functions-list)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (list (= he-num i)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (setq i (1+ i)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (setq he-num i))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (if (>= he-num (length hippie-expand-try-functions-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (setq he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (if first
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (message "No expansion found")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (message "No further expansions found"))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (ding))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (if hippie-expand-verbose
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (message (concat "Using "
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (prin1-to-string (nth he-num
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 hippie-expand-try-functions-list)))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (if (>= he-num 0)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (setq he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (if hippie-expand-verbose
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (message "Undoing expansions"))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 ;; Initializes the region to expand (to between BEG and END).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (defun he-init-string (beg end)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (setq he-string-beg beg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (setq he-string-end end)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (setq he-search-string (buffer-substring beg end)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 ;; Resets the expanded region to its original contents.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (defun he-reset-string ()
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (delete-region he-string-beg he-string-end)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (insert he-search-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (setq he-string-end (point)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 ;; Substitutes an expansion STR into the correct region (the region
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 ;; initialized with `he-init-string').
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 ;; An optional argument TRANS-CASE means that it is ok to transfer case
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 ;; from the abbreviation to the expansion if that is possible, and is
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 ;; enabled in the buffer.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (defun he-substitute-string (str &optional trans-case)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (let ((trans-case (and trans-case
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 case-replace
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 case-fold-search
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (he-transfer-case-ok str he-search-string))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (goto-char he-string-beg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (search-forward he-search-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (replace-match (if trans-case (downcase str) str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (not trans-case)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 'literal)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (setq he-string-end (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (defun he-ordinary-case-p (str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (or (string= str (downcase str))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (string= str (upcase str))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (string= str (capitalize str))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (defun he-transfer-case-ok (to-str from-str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (and (not (string= from-str (substring to-str 0 (length from-str))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 ;; otherwise transfer is not needed (and this also solves
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 ;; some obscure situations)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (he-ordinary-case-p to-str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 ;; otherwise case may be significant
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (he-ordinary-case-p from-str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 ;; otherwise replace-match wont know what to do
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 ))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 ;; Check if STR is a member of LST.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 ;; Ignore case if `case-replace' and `case-fold-search' are both t.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (defun he-string-member (str lst)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (while (and lst
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (not
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (if (and case-fold-search case-replace)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (string= (downcase (car lst)) (downcase str))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (string= (car lst) str))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (setq lst (cdr lst)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 lst)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 ;; For the real hippie-expand enthusiast: A macro that makes it
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 ;; possible to use many functions like hippie-expand, but with
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 ;; different try-functions-lists.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 ;; Usage is for example:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 ;; (fset 'my-complete-file (make-hippie-expand-function
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 ;; '(try-complete-file-name-partially
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 ;; try-complete-file-name)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 ;; (fset 'my-complete-line (make-hippie-expand-function
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 ;; '(try-expand-line
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 ;; try-expand-line-all-buffers)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (defmacro make-hippie-expand-function (try-list &optional verbose)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 "Construct a function similar to `hippie-expand'.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 Make it use the expansion functions in TRY-LIST. An optional second
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 argument VERBOSE non-nil makes the function verbose."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (` '(lambda (arg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (, (concat
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 "Try to expand text before point, using the following functions: \n"
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (mapconcat 'prin1-to-string (eval try-list) ", ")))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (interactive "P")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (let ((hippie-expand-try-functions-list (, try-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (hippie-expand-verbose (, verbose)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (hippie-expand arg)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 ;;; Here follows the try-functions and their requisites:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (defun try-complete-file-name (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 "Try to complete text as a file name.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 string). It returns t if a new completion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (he-init-string (he-file-name-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (let ((name-part (file-name-nondirectory he-search-string))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (dir-part (expand-file-name (or (file-name-directory
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 he-search-string) ""))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (if (not (he-string-member name-part he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (setq he-tried-table (cons name-part he-tried-table)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (if (and (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (file-directory-p dir-part))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (setq he-expand-list (sort (file-name-all-completions
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 name-part
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 dir-part)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 'string-lessp))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (setq he-expand-list ())))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (while (and he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (he-string-member (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (setq he-expand-list (cdr he-expand-list)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (if (null he-expand-list)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (let ((filename (concat (file-name-directory he-search-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (car he-expand-list))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (he-substitute-string filename)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (setq he-tried-table (cons (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (setq he-expand-list (cdr he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (defun try-complete-file-name-partially (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 "Try to complete text as a file name, as many characters as unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 The argument OLD has to be nil the first call of this function. It
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 returns t if a unique, possibly partial, completion is found, nil
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (let ((expansion ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (he-init-string (he-file-name-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (let ((name-part (file-name-nondirectory he-search-string))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (dir-part (expand-file-name (or (file-name-directory
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 he-search-string) ""))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (if (and (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (file-directory-p dir-part))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (setq expansion (file-name-completion name-part
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 dir-part)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (if (or (eq expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (string= expansion name-part))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (setq expansion ())))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (let ((filename (concat (file-name-directory he-search-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 expansion)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (he-substitute-string filename)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (defun he-file-name-beg ()
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (let ((skips "-a-zA-Z0-9_./~^#$"))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (skip-chars-backward skips)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (defun try-complete-lisp-symbol (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 "Try to complete word as an Emacs Lisp symbol.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 string). It returns t if a new completion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (he-init-string (he-lisp-symbol-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (if (not (he-string-member he-search-string he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (setq he-tried-table (cons he-search-string he-tried-table)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (setq he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (and (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (sort (all-completions he-search-string obarray
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (function (lambda (sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (or (boundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (fboundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (symbol-plist sym)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 'string-lessp)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (while (and he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (he-string-member (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (setq he-expand-list (cdr he-expand-list)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (if (null he-expand-list)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (he-substitute-string (car he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (setq he-tried-table (cons (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (setq he-expand-list (cdr he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (defun try-complete-lisp-symbol-partially (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 "Try to complete as an Emacs Lisp symbol, as many characters as unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 The argument OLD has to be nil the first call of this function. It
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 returns t if a unique, possibly partial, completion is found, nil
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (let ((expansion ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (he-init-string (he-lisp-symbol-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (if (not (string= he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (setq expansion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (try-completion he-search-string obarray
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (function (lambda (sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (or (boundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (fboundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (symbol-plist sym)))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (if (or (eq expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (string= expansion he-search-string))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (setq expansion ()))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (he-substitute-string expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (defun he-lisp-symbol-beg ()
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (let ((skips "-a-zA-Z0-9_."))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (skip-chars-backward skips)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (defun try-expand-line (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 "Try to complete the current line to an entire line in the buffer.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 string). It returns t if a new completion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (let ((expansion ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (strip-prompt (and (get-buffer-process (current-buffer))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 shell-prompt-pattern)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (he-init-string (he-line-beg strip-prompt) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (setq he-search-loc he-string-beg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (setq he-search-bw t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (if (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 ;; Try looking backward unless inhibited.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (if he-search-bw
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (setq expansion (he-line-search he-search-string
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 strip-prompt t))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (setq he-search-loc (point-marker))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (setq he-search-loc he-string-end)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (setq he-search-bw ())))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 (if (not expansion) ; Then look forward.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 (setq expansion (he-line-search he-search-string
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 strip-prompt nil))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (setq he-search-loc (point-marker))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 (defun try-expand-line-all-buffers (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 "Try to complete the current line, searching all other buffers.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 string). It returns t if a new completion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (let ((expansion ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (strip-prompt (and (get-buffer-process (current-buffer))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 shell-prompt-pattern))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (buf (current-buffer)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (he-init-string (he-line-beg strip-prompt) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (setq he-search-loc 0)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (setq he-search-bufs (buffer-list))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (if (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (while (and he-search-bufs (not expansion))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (set-buffer (car he-search-bufs))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (if (and (not (eq (current-buffer) buf))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (not (eq major-mode 'dired-mode)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 ;; dont search dired buffers
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (setq expansion (he-line-search he-search-string
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 strip-prompt nil))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (setq he-search-loc (point-marker))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (if expansion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (setq he-search-loc 0)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (setq he-search-bufs (cdr he-search-bufs))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (set-buffer buf)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (defun he-line-search (str strip-prompt reverse)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (let ((result ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (while (and (not result)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (if reverse
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (re-search-backward
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (he-line-search-regexp str strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 nil t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (re-search-forward
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (he-line-search-regexp str strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 nil t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (setq result (buffer-substring (match-beginning 2) (match-end 2)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 (if (he-string-member result he-tried-table)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (setq result nil))) ; if already in table, ignore
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 result))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 (defun he-line-beg (strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 (end-of-line)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 (if (re-search-backward (he-line-search-regexp "" strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (save-excursion (beginning-of-line)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 (point)) t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 (match-beginning 2)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (beginning-of-line)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 (defun he-line-search-regexp (pat strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 (if strip-prompt
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (concat "\\(" shell-prompt-pattern "\\|^\\s-*\\)\\("
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 (regexp-quote pat)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 "[^\n]*[^ \t\n]\\)")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (concat "^\\(\\s-*\\)\\("
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (regexp-quote pat)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 "[^\n]*[^ \t\n]\\)")))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 (defun try-expand-all-abbrevs (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 "Try to expand word before point according to all abbrev tables.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 for subsequent calls (for further possible expansions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 string). It returns t if a new expansion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (he-init-string (he-dabbrev-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (setq he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (and (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (mapcar (function (lambda (sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (abbrev-expansion he-search-string
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 (eval sym))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (append '(local-abbrev-table
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 global-abbrev-table)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 abbrev-table-name-list))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (while (and he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (or (not (car he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (he-string-member (car he-expand-list) he-tried-table)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (setq he-expand-list (cdr he-expand-list)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (if (null he-expand-list)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 (he-substitute-string (car he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (setq he-tried-table (cons (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (setq he-expand-list (cdr he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (defun try-expand-dabbrev (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 "Try to expand word \"dynamically\", searching the current buffer.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 for subsequent calls (for further possible expansions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 string). It returns t if a new expansion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (let ((expansion ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (he-init-string (he-dabbrev-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (setq he-search-loc he-string-beg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (setq he-search-bw t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (if (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 ;; Try looking backward unless inhibited.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (if he-search-bw
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 (setq expansion (he-dab-search he-search-string t))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (setq he-search-loc (point-marker))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 (setq he-search-loc he-string-end)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 (setq he-search-bw ())))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 (if (not expansion) ; Then look forward.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (setq expansion (he-dab-search he-search-string nil))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 (setq he-search-loc (point-marker))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 (defun try-expand-dabbrev-all-buffers (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 "Tries to expand word \"dynamically\", searching all other buffers.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 for subsequent calls (for further possible expansions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 string). It returns t if a new expansion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 (let ((expansion ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 (buf (current-buffer)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 (he-init-string (he-dabbrev-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 (setq he-search-loc 0)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 (setq he-search-bufs (buffer-list))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 (if (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 (while (and he-search-bufs (not expansion))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 (set-buffer (car he-search-bufs))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (if (and (not (eq (current-buffer) buf))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 (not (eq major-mode 'dired-mode)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 ;; dont search dired buffers
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (setq expansion (he-dab-search he-search-string nil))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (setq he-search-loc (point-marker))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 (if expansion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 (setq he-search-loc 0)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 (setq he-search-bufs (cdr he-search-bufs))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (set-buffer buf)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (defun he-dab-search-regexp (pat)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 (concat "\\b" (regexp-quote pat)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 "\\(\\sw\\|\\s_\\)+"))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (defun he-dab-search (pattern reverse)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 (let ((result ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (while (and (not result)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 (if reverse
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 (re-search-backward (he-dab-search-regexp pattern)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 nil t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (re-search-forward (he-dab-search-regexp pattern)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 nil t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (setq result (buffer-substring (match-beginning 0) (match-end 0)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (if (he-string-member result he-tried-table)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (setq result nil))) ; if already in table, ignore
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 result))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (defun he-dabbrev-beg ()
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (let ((skips "-a-zA-Z0-9_."))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (skip-chars-backward skips)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (skip-chars-forward "-_.")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674