Mercurial > emacs
annotate lisp/hippie-exp.el @ 20687:cd31a4ab72de
(momentary-string-display): Fix backward test
for whether end of message is off the screen.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 20 Jan 1998 04:56:52 +0000 |
parents | aea386116817 |
children | e4acb217b4af |
rev | line source |
---|---|
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
1 ;;; hippie-exp.el --- expand text trying various ways to find its expansion. |
2230
6314334d7c2b
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1737
diff
changeset
|
2 |
14169 | 3 ;; Copyright (C) 1992 Free Software Foundation, Inc. |
4 | |
2230
6314334d7c2b
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1737
diff
changeset
|
5 ;; Author: Anders Holst <aho@sans.kth.se> |
18030
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
6 ;; Last change: 28 May 1997 |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
7 ;; Version: 1.5 |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
8 ;; Keywords: abbrev |
2230
6314334d7c2b
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1737
diff
changeset
|
9 |
1737 | 10 ;; This file is part of GNU Emacs. |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
1737 | 26 |
2233
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2230
diff
changeset
|
27 ;;; Commentary: |
14169 | 28 |
1737 | 29 ;; `hippie-expand' is a single function for a lot of different kinds |
30 ;; of completions and expansions. Called repeatedly it tries all | |
31 ;; possible completions in succession. | |
32 ;; Which kinds of completions to try, and in which order, is | |
33 ;; determined by the contents of `hippie-expand-try-functions-list'. | |
34 ;; Much customization of `hippie-expand' can be made by changing the | |
35 ;; order of, removing, or inserting new functions in this list. | |
36 ;; Given a positive numeric argument, `hippie-expand' jumps directly | |
37 ;; ARG functions forward in this list. Given some other argument | |
38 ;; (a negative argument or just Ctrl-U) it undoes the tried | |
39 ;; completion. | |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
40 ;; |
1737 | 41 ;; If the variable `hippie-expand-verbose' is non-nil, `hippie-expand' |
42 ;; outputs in a message which try-function in the list that is used | |
43 ;; currently (ie. was used currently and will be tried first the next | |
44 ;; time). | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
45 ;; The variable `hippie-expand-max-buffers' determines in how many |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
46 ;; buffers, apart from the current, to search for expansions in. It |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
47 ;; is used by the try-functions named "-all-buffers". |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
48 ;; The variable `hippie-expand-ignore-buffers' is a list of regexps |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
49 ;; matching buffer names (as strings) or major modes (as atoms) of |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
50 ;; buffers that should not be searched by the try-functions named |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
51 ;; "-all-buffers". |
1737 | 52 ;; See also the macro `make-hippie-expand-function' below. |
53 ;; | |
54 ;; A short description of the current try-functions in this file: | |
55 ;; `try-complete-file-name' : very convenient to have in any buffer, | |
56 ;; and not just in the minibuffer or (some) shell-mode. It goes | |
57 ;; through all possible completions instead of just completing as | |
58 ;; much as is unique. | |
59 ;; `try-complete-file-name-partially' : To insert in the list just | |
60 ;; before `try-complete-file-name' for those who want first to get | |
61 ;; a file name completed only as many characters as is unique. | |
62 ;; `try-expand-all-abbrevs' : can be removed if you don't use abbrevs. | |
63 ;; Otherwise it looks through all abbrev-tables, starting with | |
64 ;; the local followed by the global. | |
65 ;; `try-expand-line' : Searches the buffer for an entire line that | |
66 ;; begins exactly as the current line. Convenient sometimes, for | |
67 ;; example as a substitute for (or complement to) the history | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
68 ;; list in shell-like buffers. At other times, only confusing. |
1737 | 69 ;; `try-expand-line-all-buffers' : Like `try-expand-line' but searches |
70 ;; in all buffers (except the current). (This may be a little | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
71 ;; slow, don't use it unless you are really fond of `hippie-expand'.) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
72 ;; `try-expand-list' : Tries to expand the text back to the nearest |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
73 ;; open delimiter, to a whole list from the buffer. Convenient for |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
74 ;; example when writing lisp or TeX. |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
75 ;; `try-expand-list-all-buffers' : Like `try-expand-list' but searches |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
76 ;; in all buffers (except the current). |
1737 | 77 ;; `try-expand-dabbrev' : works exactly as dabbrev-expand (but of |
78 ;; course in a way compatible with the other try-functions). | |
79 ;; `try-expand-dabbrev-all-buffers' : perhaps the most useful of them, | |
80 ;; like `dabbrev-expand' but searches all Emacs buffers (except the | |
81 ;; current) for matching words. (No, I don't find this one | |
82 ;; particularly slow.) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
83 ;; `try-expand-dabbrev-visible': Searches the currently visible parts of |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
84 ;; all windows. Can be put before `try-expand-dabbrev-all-buffers' to |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
85 ;; first try the expansions you can see. |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
86 ;; `try-expand-dabbrev-from-kill': Searches the kill ring for a suitable |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
87 ;; completion of the word. Good to have, just in case the word was not |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
88 ;; found elsewhere. |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
89 ;; `try-expand-whole-kill' : Tries to complete text with a whole entry |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
90 ;; from the kill ring. May be good if you don't know how far up in |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
91 ;; the kill-ring the required entry is, and don't want to mess with |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
92 ;; "Choose Next Paste". |
1737 | 93 ;; `try-complete-lisp-symbol' : like `lisp-complete-symbol', but goes |
94 ;; through all possibilities instead of completing what is unique. | |
95 ;; Might be tedious (usually a lot of possible completions) and | |
96 ;; since its function is much like `lisp-complete-symbol', which | |
97 ;; already has a key of its own, you might want to remove this. | |
98 ;; `try-complete-lisp-symbol-partially' : To insert in the list just | |
99 ;; before `try-complete-lisp-symbol' for those who first want to get | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
100 ;; completion of what is unique in the name. |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
101 ;; |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
102 ;; Not all of the above functions are by default in |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
103 ;; `hippie-expand-try-functions-list'. This variable is better set |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
104 ;; in ".emacs" to make `hippie-expand' behave maximally convenient |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
105 ;; according to personal taste. Also, instead of loading the |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
106 ;; variable with all kinds of try-functions above, it might be an |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
107 ;; idea to use `make-hippie-expand-function' to construct different |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
108 ;; `hippie-expand'-like functions, with different try-lists and bound |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
109 ;; to different keys. It is also possible to make |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
110 ;; `hippie-expand-try-functions-list' a buffer local variable, and |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
111 ;; let it depend on the mode (by setting it in the mode-hooks). |
1737 | 112 ;; |
113 ;; To write new try-functions, consider the following: | |
114 ;; Each try-function takes one argument OLD which is nil the first | |
115 ;; time the function is called and true in succeeding calls for the | |
116 ;; same string to complete. The first time the function has to | |
117 ;; extract the string before point to complete, and substitute the | |
118 ;; first completion alternative for it. On following calls it has to | |
119 ;; substitute the next possible completion for the last tried string. | |
120 ;; The try-function is to return t as long as it finds new | |
121 ;; possible completions. When there are no more alternatives it has | |
122 ;; to restore the text before point to its original contents, and | |
123 ;; return nil (don't beep or message or anything). | |
124 ;; The try-function can (should) use the following functions: | |
125 ;; `he-init-string' : Initializes the text to substitute to the | |
126 ;; contents of the region BEGIN to END. Also sets the variable | |
127 ;; `he-search-string' to the text to expand. | |
128 ;; `he-substitute-string' : substitutes STR into the region | |
129 ;; initialized with `he-init-string'. (An optional second argument | |
130 ;; TRANS-CASE non-nil, means transfer of case from the abbreviation | |
131 ;; to the expansion is ok if that is enabled in the buffer.) | |
132 ;; `he-reset-string' : Resets the initialized region to its original | |
133 ;; contents. | |
134 ;; There is also a variable: `he-tried-table' which is meant to contain | |
135 ;; all tried expansions so far. The try-function can check this | |
136 ;; variable to see whether an expansion has already been tried | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
137 ;; (hint: `he-string-member'). |
1737 | 138 ;; |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
139 ;; Known bugs |
1737 | 140 ;; |
141 ;; It may happen that some completion suggestion occurs twice, in | |
142 ;; spite of the use of `he-tried-table' to prevent that. This is | |
143 ;; because different try-functions may try to complete different | |
144 ;; lengths of text, and thus put different amounts of the | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
145 ;; text in `he-tried-table'. Anyway this seems to occur seldom enough |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
146 ;; not to be too disturbing. Also it should NOT be possible for the |
1737 | 147 ;; opposite situation to occur, that `hippie-expand' misses some |
148 ;; suggestion because it thinks it has already tried it. | |
149 ;; | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
150 ;; Acknowledgement |
1737 | 151 ;; |
152 ;; I want to thank Mikael Djurfeldt in discussions with whom the idea | |
153 ;; of this function took form. | |
154 ;; I am also grateful to all those who have given me suggestions on | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
155 ;; how to improve it, and all those who helped to find and remove bugs. |
1737 | 156 ;; |
157 | |
2233
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2230
diff
changeset
|
158 ;;; Code: |
1737 | 159 |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
160 (defgroup hippie-expand nil |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
161 "Expand text trying various ways to find its expansion." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
162 :group 'abbrev) |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
163 |
18038
1a3d130e356b
(he-dabbrev-skip-space, he-dabbrev-as-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
18030
diff
changeset
|
164 (defcustom he-dabbrev-skip-space nil |
1a3d130e356b
(he-dabbrev-skip-space, he-dabbrev-as-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
18030
diff
changeset
|
165 "Non-nil means tolerate trailing spaces in the abbreviation to expand." |
18584
aea386116817
(he-dabbrev-skip-space): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
18038
diff
changeset
|
166 :group 'hippie-expand |
18038
1a3d130e356b
(he-dabbrev-skip-space, he-dabbrev-as-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
18030
diff
changeset
|
167 :type 'boolean) |
1a3d130e356b
(he-dabbrev-skip-space, he-dabbrev-as-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
18030
diff
changeset
|
168 |
1a3d130e356b
(he-dabbrev-skip-space, he-dabbrev-as-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
18030
diff
changeset
|
169 (defcustom he-dabbrev-as-symbol t |
1a3d130e356b
(he-dabbrev-skip-space, he-dabbrev-as-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
18030
diff
changeset
|
170 "Non-nil means expand as symbols, i.e. syntax `_' is considered a letter." |
18584
aea386116817
(he-dabbrev-skip-space): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
18038
diff
changeset
|
171 :group 'hippie-expand |
18038
1a3d130e356b
(he-dabbrev-skip-space, he-dabbrev-as-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
18030
diff
changeset
|
172 :type 'boolean) |
1a3d130e356b
(he-dabbrev-skip-space, he-dabbrev-as-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
18030
diff
changeset
|
173 |
1737 | 174 (defvar he-num -1) |
175 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
176 (defvar he-string-beg (make-marker)) |
1737 | 177 |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
178 (defvar he-string-end (make-marker)) |
1737 | 179 |
180 (defvar he-search-string ()) | |
181 | |
182 (defvar he-expand-list ()) | |
183 | |
184 (defvar he-tried-table ()) | |
185 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
186 (defvar he-search-loc (make-marker)) |
1737 | 187 |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
188 (defvar he-search-loc2 ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
189 |
1737 | 190 (defvar he-search-bw ()) |
191 | |
192 (defvar he-search-bufs ()) | |
193 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
194 (defvar he-searched-n-bufs ()) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
195 |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
196 (defvar he-search-window ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
197 |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
198 ;;;###autoload |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
199 (defvar hippie-expand-try-functions-list '(try-complete-file-name-partially |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
200 try-complete-file-name |
1737 | 201 try-expand-all-abbrevs |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
202 try-expand-list |
1737 | 203 try-expand-line |
204 try-expand-dabbrev | |
205 try-expand-dabbrev-all-buffers | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
206 try-expand-dabbrev-from-kill |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
207 try-complete-lisp-symbol-partially |
1737 | 208 try-complete-lisp-symbol) |
209 "The list of expansion functions tried in order by `hippie-expand'. | |
210 To change the behavior of `hippie-expand', remove, change the order of, | |
211 or insert functions in this list.") | |
212 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
213 ;;;###autoload |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
214 (defcustom hippie-expand-verbose t |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
215 "*Non-nil makes `hippie-expand' output which function it is trying." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
216 :type 'boolean |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
217 :group 'hippie-expand) |
1737 | 218 |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
219 ;;;###autoload |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
220 (defcustom hippie-expand-max-buffers () |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
221 "*The maximum number of buffers (apart from the current) searched. |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
222 If nil, all buffers are searched." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
223 :type '(choice (const :tag "All" nil) |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
224 integer) |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
225 :group 'hippie-expand) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
226 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
227 ;;;###autoload |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
228 (defcustom hippie-expand-ignore-buffers '("^ \\*.*\\*$" dired-mode) |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
229 "*A list specifying which buffers not to search (if not current). |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
230 Can contain both regexps matching buffer names (as strings) and major modes |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
231 \(as atoms)" |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
232 :type '(repeat (choice regexp (symbol :tag "Major Mode"))) |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16590
diff
changeset
|
233 :group 'hippie-expand) |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
234 |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
235 ;;;###autoload |
1737 | 236 (defun hippie-expand (arg) |
237 "Try to expand text before point, using multiple methods. | |
238 The expansion functions in `hippie-expand-try-functions-list' are | |
239 tried in order, until a possible expansion is found. Repeated | |
240 application of `hippie-expand' inserts successively possible | |
241 expansions. | |
242 With a positive numeric argument, jumps directly to the ARG next | |
243 function in this list. With a negative argument or just \\[universal-argument], | |
244 undoes the expansion." | |
245 (interactive "P") | |
246 (if (or (not arg) | |
247 (and (integerp arg) (> arg 0))) | |
248 (let ((first (or (= he-num -1) | |
249 (not (equal this-command last-command))))) | |
250 (if first | |
251 (progn | |
252 (setq he-num -1) | |
253 (setq he-tried-table nil))) | |
254 (if arg | |
255 (if (not first) (he-reset-string)) | |
256 (setq arg 0)) | |
257 (let ((i (max (+ he-num arg) 0))) | |
258 (while (not (or (>= i (length hippie-expand-try-functions-list)) | |
259 (apply (nth i hippie-expand-try-functions-list) | |
260 (list (= he-num i))))) | |
261 (setq i (1+ i))) | |
262 (setq he-num i)) | |
263 (if (>= he-num (length hippie-expand-try-functions-list)) | |
264 (progn | |
265 (setq he-num -1) | |
266 (if first | |
267 (message "No expansion found") | |
268 (message "No further expansions found")) | |
269 (ding)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
270 (if (and hippie-expand-verbose |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
271 (not (window-minibuffer-p (selected-window)))) |
14317
594c4676b8c6
(hippie-expand): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
272 (message "Using %s" |
18030
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
273 (nth he-num hippie-expand-try-functions-list))))) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
274 (if (and (>= he-num 0) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
275 (eq (marker-buffer he-string-beg) (current-buffer))) |
1737 | 276 (progn |
277 (setq he-num -1) | |
278 (he-reset-string) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
279 (if (and hippie-expand-verbose |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
280 (not (window-minibuffer-p (selected-window)))) |
1737 | 281 (message "Undoing expansions")))))) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
282 |
1737 | 283 ;; Initializes the region to expand (to between BEG and END). |
284 (defun he-init-string (beg end) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
285 (set-marker he-string-beg beg) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
286 (set-marker he-string-end end) |
1737 | 287 (setq he-search-string (buffer-substring beg end))) |
288 | |
289 ;; Resets the expanded region to its original contents. | |
290 (defun he-reset-string () | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
291 (let ((newpos (point-marker))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
292 (goto-char he-string-beg) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
293 (insert he-search-string) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
294 (delete-region (point) he-string-end) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
295 (goto-char newpos))) |
1737 | 296 |
297 ;; Substitutes an expansion STR into the correct region (the region | |
298 ;; initialized with `he-init-string'). | |
299 ;; An optional argument TRANS-CASE means that it is ok to transfer case | |
300 ;; from the abbreviation to the expansion if that is possible, and is | |
301 ;; enabled in the buffer. | |
302 (defun he-substitute-string (str &optional trans-case) | |
303 (let ((trans-case (and trans-case | |
304 case-replace | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
305 case-fold-search)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
306 (newpos (point-marker)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
307 (subst ())) |
1737 | 308 (goto-char he-string-beg) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
309 (setq subst (if trans-case (he-transfer-case he-search-string str) str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
310 (setq he-tried-table (cons subst he-tried-table)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
311 (insert subst) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
312 (delete-region (point) he-string-end) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
313 (goto-char newpos))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
314 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
315 (defun he-capitalize-first (str) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
316 (save-match-data |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
317 (if (string-match "\\Sw*\\(\\sw\\).*" str) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
318 (let ((res (downcase str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
319 (no (match-beginning 1))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
320 (aset res no (upcase (aref str no))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
321 res) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
322 str))) |
1737 | 323 |
324 (defun he-ordinary-case-p (str) | |
325 (or (string= str (downcase str)) | |
326 (string= str (upcase str)) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
327 (string= str (capitalize str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
328 (string= str (he-capitalize-first str)))) |
1737 | 329 |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
330 (defun he-transfer-case (from-str to-str) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
331 (cond ((string= from-str (substring to-str 0 (min (length from-str) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
332 (length to-str)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
333 to-str) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
334 ((not (he-ordinary-case-p to-str)) |
13225
76ce98050470
(he-transfer-case): Fix typo in prev change.
Richard M. Stallman <rms@gnu.org>
parents:
13207
diff
changeset
|
335 to-str) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
336 ((string= from-str (downcase from-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
337 (downcase to-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
338 ((string= from-str (upcase from-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
339 (upcase to-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
340 ((string= from-str (he-capitalize-first from-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
341 (he-capitalize-first to-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
342 ((string= from-str (capitalize from-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
343 (capitalize to-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
344 (t |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
345 to-str))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
346 |
1737 | 347 |
348 ;; Check if STR is a member of LST. | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
349 ;; Transform to the final case if optional TRANS-CASE is non-NIL. |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
350 (defun he-string-member (str lst &optional trans-case) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
351 (if str |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
352 (member (if (and trans-case |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
353 case-replace |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
354 case-fold-search) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
355 (he-transfer-case he-search-string str) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
356 str) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
357 lst))) |
1737 | 358 |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
359 ;; Check if STR matches any regexp in LST. |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
360 ;; Ignore possible non-strings in LST. |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
361 (defun he-regexp-member (str lst) |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
362 (while (and lst |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
363 (or (not (stringp (car lst))) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
364 (not (string-match (car lst) str)))) |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
365 (setq lst (cdr lst))) |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
366 lst) |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
367 |
1737 | 368 ;; For the real hippie-expand enthusiast: A macro that makes it |
369 ;; possible to use many functions like hippie-expand, but with | |
370 ;; different try-functions-lists. | |
371 ;; Usage is for example: | |
372 ;; (fset 'my-complete-file (make-hippie-expand-function | |
373 ;; '(try-complete-file-name-partially | |
374 ;; try-complete-file-name))) | |
375 ;; (fset 'my-complete-line (make-hippie-expand-function | |
376 ;; '(try-expand-line | |
377 ;; try-expand-line-all-buffers))) | |
378 ;; | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
379 ;;;###autoload |
1737 | 380 (defmacro make-hippie-expand-function (try-list &optional verbose) |
381 "Construct a function similar to `hippie-expand'. | |
382 Make it use the expansion functions in TRY-LIST. An optional second | |
383 argument VERBOSE non-nil makes the function verbose." | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
384 (` (function (lambda (arg) |
1737 | 385 (, (concat |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
386 "Try to expand text before point, using the following functions: \n" |
1737 | 387 (mapconcat 'prin1-to-string (eval try-list) ", "))) |
388 (interactive "P") | |
389 (let ((hippie-expand-try-functions-list (, try-list)) | |
390 (hippie-expand-verbose (, verbose))) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
391 (hippie-expand arg)))))) |
1737 | 392 |
393 | |
394 ;;; Here follows the try-functions and their requisites: | |
395 | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
396 |
1737 | 397 (defun try-complete-file-name (old) |
398 "Try to complete text as a file name. | |
399 The argument OLD has to be nil the first call of this function, and t | |
400 for subsequent calls (for further possible completions of the same | |
401 string). It returns t if a new completion is found, nil otherwise." | |
402 (if (not old) | |
403 (progn | |
404 (he-init-string (he-file-name-beg) (point)) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
405 (let ((name-part (he-file-name-nondirectory he-search-string)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
406 (dir-part (expand-file-name (or (he-file-name-directory |
1737 | 407 he-search-string) "")))) |
408 (if (not (he-string-member name-part he-tried-table)) | |
409 (setq he-tried-table (cons name-part he-tried-table))) | |
410 (if (and (not (equal he-search-string "")) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
411 (he-file-directory-p dir-part)) |
1737 | 412 (setq he-expand-list (sort (file-name-all-completions |
413 name-part | |
414 dir-part) | |
415 'string-lessp)) | |
416 (setq he-expand-list ()))))) | |
417 | |
418 (while (and he-expand-list | |
419 (he-string-member (car he-expand-list) he-tried-table)) | |
420 (setq he-expand-list (cdr he-expand-list))) | |
421 (if (null he-expand-list) | |
422 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
423 (if old (he-reset-string)) |
1737 | 424 ()) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
425 (let ((filename (he-concat-directory-file-name |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
426 (he-file-name-directory he-search-string) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
427 (car he-expand-list)))) |
1737 | 428 (he-substitute-string filename) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
429 (setq he-tried-table (cons (car he-expand-list) (cdr he-tried-table))) |
1737 | 430 (setq he-expand-list (cdr he-expand-list)) |
431 t))) | |
432 | |
433 (defun try-complete-file-name-partially (old) | |
434 "Try to complete text as a file name, as many characters as unique. | |
435 The argument OLD has to be nil the first call of this function. It | |
436 returns t if a unique, possibly partial, completion is found, nil | |
437 otherwise." | |
438 (let ((expansion ())) | |
439 (if (not old) | |
440 (progn | |
441 (he-init-string (he-file-name-beg) (point)) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
442 (let ((name-part (he-file-name-nondirectory he-search-string)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
443 (dir-part (expand-file-name (or (he-file-name-directory |
1737 | 444 he-search-string) "")))) |
445 (if (and (not (equal he-search-string "")) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
446 (he-file-directory-p dir-part)) |
1737 | 447 (setq expansion (file-name-completion name-part |
448 dir-part))) | |
449 (if (or (eq expansion t) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
450 (string= expansion name-part) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
451 (he-string-member expansion he-tried-table)) |
1737 | 452 (setq expansion ()))))) |
453 | |
454 (if (not expansion) | |
455 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
456 (if old (he-reset-string)) |
1737 | 457 ()) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
458 (let ((filename (he-concat-directory-file-name |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
459 (he-file-name-directory he-search-string) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
460 expansion))) |
1737 | 461 (he-substitute-string filename) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
462 (setq he-tried-table (cons expansion (cdr he-tried-table))) |
1737 | 463 t)))) |
464 | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
465 (defvar he-file-name-chars |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
466 (cond ((memq system-type '(vax-vms axp-vms)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
467 "-a-zA-Z0-9_/.,~^#$+=:\\[\\]") |
15330
770c11688d0f
(he-file-name-chars): Check windows-nt, not ms-windows.
Richard M. Stallman <rms@gnu.org>
parents:
14317
diff
changeset
|
468 ((memq system-type '(ms-dos windows-nt)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
469 "-a-zA-Z0-9_/.,~^#$+=:\\\\") |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
470 (t ;; More strange file formats ? |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
471 "-a-zA-Z0-9_/.,~^#$+=")) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
472 "Characters that are considered part of the file name to expand.") |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
473 |
1737 | 474 (defun he-file-name-beg () |
18030
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
475 (let ((op (point))) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
476 (save-excursion |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
477 (skip-chars-backward he-file-name-chars) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
478 (if (> (skip-syntax-backward "w") 0) ;; No words with non-file chars |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
479 op |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
480 (point))))) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
481 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
482 ;; Thanks go to Richard Levitte <levitte@e.kth.se> who helped to make these |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
483 ;; work under VMS, and to David Hughes <ukchugd@ukpmr.cs.philips.nl> who |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
484 ;; helped to make it work on PC. |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
485 (defun he-file-name-nondirectory (file) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
486 "Fix to make `file-name-nondirectory' work for hippie-expand under VMS." |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
487 (if (memq system-type '(axp-vms vax-vms)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
488 (let ((n (file-name-nondirectory file))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
489 (if (string-match "^\\(\\[.*\\)\\.\\([^\\.]*\\)$" n) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
490 (concat "[." (substring n (match-beginning 2) (match-end 2))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
491 n)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
492 (file-name-nondirectory file))) |
1737 | 493 |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
494 (defun he-file-name-directory (file) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
495 "Fix to make `file-name-directory' work for hippie-expand under VMS." |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
496 (if (memq system-type '(axp-vms vax-vms)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
497 (let ((n (file-name-nondirectory file)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
498 (d (file-name-directory file))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
499 (if (string-match "^\\(\\[.*\\)\\.\\([^\\.]*\\)$" n) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
500 (concat d (substring n (match-beginning 1) (match-end 1)) "]") |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
501 d)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
502 (file-name-directory file))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
503 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
504 (defun he-file-directory-p (file) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
505 "Fix to make `file-directory-p' work for hippie-expand under VMS." |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
506 (if (memq system-type '(vax-vms axp-vms)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
507 (or (file-directory-p file) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
508 (file-directory-p (concat file "[000000]"))) |
15447
41bce2c4b1b8
(he-concat-directory-file-name): Directory part may be nil.
Richard M. Stallman <rms@gnu.org>
parents:
15330
diff
changeset
|
509 (file-directory-p file))) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
510 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
511 (defun he-concat-directory-file-name (dir-part name-part) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
512 "Try to slam together two parts of a file specification, system dependently." |
15447
41bce2c4b1b8
(he-concat-directory-file-name): Directory part may be nil.
Richard M. Stallman <rms@gnu.org>
parents:
15330
diff
changeset
|
513 (cond ((null dir-part) name-part) |
41bce2c4b1b8
(he-concat-directory-file-name): Directory part may be nil.
Richard M. Stallman <rms@gnu.org>
parents:
15330
diff
changeset
|
514 ((memq system-type '(axp-vms vax-vms)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
515 (if (and (string= (substring dir-part -1) "]") |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
516 (string= (substring name-part 0 2) "[.")) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
517 (concat (substring dir-part 0 -1) (substring name-part 1)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
518 (concat dir-part name-part))) |
16590
a0cfcb9f8033
Use w32 instead of ms-windows for window-system symbol
Geoff Voelker <voelker@cs.washington.edu>
parents:
15447
diff
changeset
|
519 ((memq system-type '(ms-dos w32)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
520 (if (and (string-match "\\\\" dir-part) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
521 (not (string-match "/" dir-part)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
522 (= (aref name-part (1- (length name-part))) ?/)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
523 (aset name-part (1- (length name-part)) ?\\)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
524 (concat dir-part name-part)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
525 (t |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
526 (concat dir-part name-part)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
527 |
1737 | 528 (defun try-complete-lisp-symbol (old) |
529 "Try to complete word as an Emacs Lisp symbol. | |
530 The argument OLD has to be nil the first call of this function, and t | |
531 for subsequent calls (for further possible completions of the same | |
532 string). It returns t if a new completion is found, nil otherwise." | |
533 (if (not old) | |
534 (progn | |
535 (he-init-string (he-lisp-symbol-beg) (point)) | |
536 (if (not (he-string-member he-search-string he-tried-table)) | |
537 (setq he-tried-table (cons he-search-string he-tried-table))) | |
538 (setq he-expand-list | |
539 (and (not (equal he-search-string "")) | |
540 (sort (all-completions he-search-string obarray | |
541 (function (lambda (sym) | |
542 (or (boundp sym) | |
543 (fboundp sym) | |
544 (symbol-plist sym))))) | |
545 'string-lessp))))) | |
546 (while (and he-expand-list | |
547 (he-string-member (car he-expand-list) he-tried-table)) | |
548 (setq he-expand-list (cdr he-expand-list))) | |
549 (if (null he-expand-list) | |
550 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
551 (if old (he-reset-string)) |
1737 | 552 ()) |
553 (progn | |
554 (he-substitute-string (car he-expand-list)) | |
555 (setq he-expand-list (cdr he-expand-list)) | |
556 t))) | |
557 | |
558 (defun try-complete-lisp-symbol-partially (old) | |
559 "Try to complete as an Emacs Lisp symbol, as many characters as unique. | |
560 The argument OLD has to be nil the first call of this function. It | |
561 returns t if a unique, possibly partial, completion is found, nil | |
562 otherwise." | |
563 (let ((expansion ())) | |
564 (if (not old) | |
565 (progn | |
566 (he-init-string (he-lisp-symbol-beg) (point)) | |
567 (if (not (string= he-search-string "")) | |
568 (setq expansion | |
569 (try-completion he-search-string obarray | |
570 (function (lambda (sym) | |
571 (or (boundp sym) | |
572 (fboundp sym) | |
573 (symbol-plist sym))))))) | |
574 (if (or (eq expansion t) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
575 (string= expansion he-search-string) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
576 (he-string-member expansion he-tried-table)) |
1737 | 577 (setq expansion ())))) |
578 | |
579 (if (not expansion) | |
580 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
581 (if old (he-reset-string)) |
1737 | 582 ()) |
583 (progn | |
584 (he-substitute-string expansion) | |
585 t)))) | |
586 | |
587 (defun he-lisp-symbol-beg () | |
18030
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
588 (save-excursion |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
589 (skip-syntax-backward "w_") |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
590 (point))) |
1737 | 591 |
592 (defun try-expand-line (old) | |
593 "Try to complete the current line to an entire line in the buffer. | |
594 The argument OLD has to be nil the first call of this function, and t | |
595 for subsequent calls (for further possible completions of the same | |
596 string). It returns t if a new completion is found, nil otherwise." | |
597 (let ((expansion ()) | |
598 (strip-prompt (and (get-buffer-process (current-buffer)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
599 comint-prompt-regexp))) |
1737 | 600 (if (not old) |
601 (progn | |
602 (he-init-string (he-line-beg strip-prompt) (point)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
603 (set-marker he-search-loc he-string-beg) |
1737 | 604 (setq he-search-bw t))) |
605 | |
606 (if (not (equal he-search-string "")) | |
607 (save-excursion | |
608 ;; Try looking backward unless inhibited. | |
609 (if he-search-bw | |
610 (progn | |
611 (goto-char he-search-loc) | |
612 (setq expansion (he-line-search he-search-string | |
613 strip-prompt t)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
614 (set-marker he-search-loc (point)) |
1737 | 615 (if (not expansion) |
616 (progn | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
617 (set-marker he-search-loc he-string-end) |
1737 | 618 (setq he-search-bw ()))))) |
619 | |
620 (if (not expansion) ; Then look forward. | |
621 (progn | |
622 (goto-char he-search-loc) | |
623 (setq expansion (he-line-search he-search-string | |
624 strip-prompt nil)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
625 (set-marker he-search-loc (point)))))) |
1737 | 626 |
627 (if (not expansion) | |
628 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
629 (if old (he-reset-string)) |
1737 | 630 ()) |
631 (progn | |
632 (he-substitute-string expansion t) | |
633 t)))) | |
634 | |
635 (defun try-expand-line-all-buffers (old) | |
636 "Try to complete the current line, searching all other buffers. | |
637 The argument OLD has to be nil the first call of this function, and t | |
638 for subsequent calls (for further possible completions of the same | |
639 string). It returns t if a new completion is found, nil otherwise." | |
640 (let ((expansion ()) | |
641 (strip-prompt (and (get-buffer-process (current-buffer)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
642 comint-prompt-regexp)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
643 (buf (current-buffer)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
644 (orig-case-fold-search case-fold-search)) |
1737 | 645 (if (not old) |
646 (progn | |
647 (he-init-string (he-line-beg strip-prompt) (point)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
648 (setq he-search-bufs (buffer-list)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
649 (setq he-searched-n-bufs 0) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
650 (set-marker he-search-loc 1 (car he-search-bufs)))) |
1737 | 651 |
652 (if (not (equal he-search-string "")) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
653 (while (and he-search-bufs |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
654 (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
655 (or (not hippie-expand-max-buffers) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
656 (< he-searched-n-bufs hippie-expand-max-buffers))) |
1737 | 657 (set-buffer (car he-search-bufs)) |
658 (if (and (not (eq (current-buffer) buf)) | |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
659 (not (memq major-mode hippie-expand-ignore-buffers)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
660 (not (he-regexp-member (buffer-name) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
661 hippie-expand-ignore-buffers))) |
1737 | 662 (save-excursion |
663 (goto-char he-search-loc) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
664 (setq strip-prompt (and (get-buffer-process (current-buffer)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
665 comint-prompt-regexp)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
666 (setq expansion (let ((case-fold-search orig-case-fold-search)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
667 (he-line-search he-search-string |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
668 strip-prompt nil))) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
669 (set-marker he-search-loc (point)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
670 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
671 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
672 (setq he-search-bufs (cdr he-search-bufs)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
673 (setq he-searched-n-bufs (1+ he-searched-n-bufs)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
674 (set-marker he-search-loc 1 (car he-search-bufs))))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
675 (setq he-search-bufs (cdr he-search-bufs)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
676 (set-marker he-search-loc 1 (car he-search-bufs))))) |
1737 | 677 |
678 (set-buffer buf) | |
679 (if (not expansion) | |
680 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
681 (if old (he-reset-string)) |
1737 | 682 ()) |
683 (progn | |
684 (he-substitute-string expansion t) | |
685 t)))) | |
686 | |
687 (defun he-line-search (str strip-prompt reverse) | |
688 (let ((result ())) | |
689 (while (and (not result) | |
690 (if reverse | |
691 (re-search-backward | |
692 (he-line-search-regexp str strip-prompt) | |
693 nil t) | |
694 (re-search-forward | |
695 (he-line-search-regexp str strip-prompt) | |
696 nil t))) | |
697 (setq result (buffer-substring (match-beginning 2) (match-end 2))) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
698 (if (he-string-member result he-tried-table t) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
699 (setq result nil))) ; if already in table, ignore |
1737 | 700 result)) |
701 | |
702 (defun he-line-beg (strip-prompt) | |
703 (save-excursion | |
704 (if (re-search-backward (he-line-search-regexp "" strip-prompt) | |
705 (save-excursion (beginning-of-line) | |
706 (point)) t) | |
707 (match-beginning 2) | |
708 (point)))) | |
709 | |
710 (defun he-line-search-regexp (pat strip-prompt) | |
711 (if strip-prompt | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
712 (concat "\\(" comint-prompt-regexp "\\|^\\s-*\\)\\(" |
1737 | 713 (regexp-quote pat) |
714 "[^\n]*[^ \t\n]\\)") | |
715 (concat "^\\(\\s-*\\)\\(" | |
716 (regexp-quote pat) | |
717 "[^\n]*[^ \t\n]\\)"))) | |
718 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
719 (defun try-expand-list (old) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
720 "Try to complete the current beginning of a list. |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
721 The argument OLD has to be nil the first call of this function, and t |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
722 for subsequent calls (for further possible completions of the same |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
723 string). It returns t if a new completion is found, nil otherwise." |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
724 (let ((expansion ())) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
725 (if (not old) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
726 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
727 (he-init-string (he-list-beg) (point)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
728 (set-marker he-search-loc he-string-beg) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
729 (setq he-search-bw t))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
730 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
731 (if (not (equal he-search-string "")) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
732 (save-excursion |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
733 ;; Try looking backward unless inhibited. |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
734 (if he-search-bw |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
735 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
736 (goto-char he-search-loc) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
737 (setq expansion (he-list-search he-search-string t)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
738 (set-marker he-search-loc (point)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
739 (if (not expansion) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
740 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
741 (set-marker he-search-loc he-string-end) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
742 (setq he-search-bw ()))))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
743 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
744 (if (not expansion) ; Then look forward. |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
745 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
746 (goto-char he-search-loc) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
747 (setq expansion (he-list-search he-search-string nil)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
748 (set-marker he-search-loc (point)))))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
749 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
750 (if (not expansion) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
751 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
752 (if old (he-reset-string)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
753 ()) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
754 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
755 (he-substitute-string expansion t) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
756 t)))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
757 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
758 (defun try-expand-list-all-buffers (old) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
759 "Try to complete the current list, searching all other buffers. |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
760 The argument OLD has to be nil the first call of this function, and t |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
761 for subsequent calls (for further possible completions of the same |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
762 string). It returns t if a new completion is found, nil otherwise." |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
763 (let ((expansion ()) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
764 (buf (current-buffer)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
765 (orig-case-fold-search case-fold-search)) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
766 (if (not old) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
767 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
768 (he-init-string (he-list-beg) (point)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
769 (setq he-search-bufs (buffer-list)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
770 (setq he-searched-n-bufs 0) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
771 (set-marker he-search-loc 1 (car he-search-bufs)))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
772 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
773 (if (not (equal he-search-string "")) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
774 (while (and he-search-bufs |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
775 (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
776 (or (not hippie-expand-max-buffers) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
777 (< he-searched-n-bufs hippie-expand-max-buffers))) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
778 (set-buffer (car he-search-bufs)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
779 (if (and (not (eq (current-buffer) buf)) |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
780 (not (memq major-mode hippie-expand-ignore-buffers)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
781 (not (he-regexp-member (buffer-name) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
782 hippie-expand-ignore-buffers))) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
783 (save-excursion |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
784 (goto-char he-search-loc) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
785 (setq expansion (let ((case-fold-search orig-case-fold-search)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
786 (he-list-search he-search-string nil))) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
787 (set-marker he-search-loc (point)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
788 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
789 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
790 (setq he-search-bufs (cdr he-search-bufs)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
791 (setq he-searched-n-bufs (1+ he-searched-n-bufs)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
792 (set-marker he-search-loc 1 (car he-search-bufs))))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
793 (setq he-search-bufs (cdr he-search-bufs)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
794 (set-marker he-search-loc 1 (car he-search-bufs))))) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
795 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
796 (set-buffer buf) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
797 (if (not expansion) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
798 (progn |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
799 (if old (he-reset-string)) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
800 ()) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
801 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
802 (he-substitute-string expansion t) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
803 t)))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
804 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
805 (defun he-list-search (str reverse) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
806 (let ((result ()) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
807 beg pos err) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
808 (while (and (not result) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
809 (if reverse |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
810 (search-backward str nil t) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
811 (search-forward str nil t))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
812 (setq pos (point)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
813 (setq beg (match-beginning 0)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
814 (goto-char beg) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
815 (setq err ()) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
816 (condition-case () |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
817 (forward-list 1) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
818 (error (setq err t))) |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
819 (if (and reverse |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
820 (> (point) he-string-beg)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
821 (setq err t)) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
822 (if (not err) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
823 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
824 (setq result (buffer-substring beg (point))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
825 (if (he-string-member result he-tried-table t) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
826 (setq result nil)))) ; if already in table, ignore |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
827 (goto-char pos)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
828 result)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
829 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
830 (defun he-list-beg () |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
831 (save-excursion |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
832 (condition-case () |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
833 (backward-up-list 1) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
834 (error ())) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
835 (point))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
836 |
1737 | 837 (defun try-expand-all-abbrevs (old) |
838 "Try to expand word before point according to all abbrev tables. | |
839 The argument OLD has to be nil the first call of this function, and t | |
840 for subsequent calls (for further possible expansions of the same | |
841 string). It returns t if a new expansion is found, nil otherwise." | |
842 (if (not old) | |
843 (progn | |
844 (he-init-string (he-dabbrev-beg) (point)) | |
845 (setq he-expand-list | |
846 (and (not (equal he-search-string "")) | |
847 (mapcar (function (lambda (sym) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
848 (if (and (boundp sym) (vectorp (eval sym))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
849 (abbrev-expansion (downcase he-search-string) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
850 (eval sym))))) |
1737 | 851 (append '(local-abbrev-table |
852 global-abbrev-table) | |
853 abbrev-table-name-list)))))) | |
854 (while (and he-expand-list | |
855 (or (not (car he-expand-list)) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
856 (he-string-member (car he-expand-list) he-tried-table t))) |
1737 | 857 (setq he-expand-list (cdr he-expand-list))) |
858 (if (null he-expand-list) | |
859 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
860 (if old (he-reset-string)) |
1737 | 861 ()) |
862 (progn | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
863 (he-substitute-string (car he-expand-list) t) |
1737 | 864 (setq he-expand-list (cdr he-expand-list)) |
865 t))) | |
866 | |
867 (defun try-expand-dabbrev (old) | |
868 "Try to expand word \"dynamically\", searching the current buffer. | |
869 The argument OLD has to be nil the first call of this function, and t | |
870 for subsequent calls (for further possible expansions of the same | |
871 string). It returns t if a new expansion is found, nil otherwise." | |
872 (let ((expansion ())) | |
873 (if (not old) | |
874 (progn | |
875 (he-init-string (he-dabbrev-beg) (point)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
876 (set-marker he-search-loc he-string-beg) |
1737 | 877 (setq he-search-bw t))) |
878 | |
879 (if (not (equal he-search-string "")) | |
880 (save-excursion | |
881 ;; Try looking backward unless inhibited. | |
882 (if he-search-bw | |
883 (progn | |
884 (goto-char he-search-loc) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
885 (setq expansion (he-dabbrev-search he-search-string t)) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
886 (set-marker he-search-loc (point)) |
1737 | 887 (if (not expansion) |
888 (progn | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
889 (set-marker he-search-loc he-string-end) |
1737 | 890 (setq he-search-bw ()))))) |
891 | |
892 (if (not expansion) ; Then look forward. | |
893 (progn | |
894 (goto-char he-search-loc) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
895 (setq expansion (he-dabbrev-search he-search-string nil)) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
896 (set-marker he-search-loc (point)))))) |
1737 | 897 |
898 (if (not expansion) | |
899 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
900 (if old (he-reset-string)) |
1737 | 901 ()) |
902 (progn | |
903 (he-substitute-string expansion t) | |
904 t)))) | |
905 | |
906 (defun try-expand-dabbrev-all-buffers (old) | |
907 "Tries to expand word \"dynamically\", searching all other buffers. | |
908 The argument OLD has to be nil the first call of this function, and t | |
909 for subsequent calls (for further possible expansions of the same | |
910 string). It returns t if a new expansion is found, nil otherwise." | |
911 (let ((expansion ()) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
912 (buf (current-buffer)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
913 (orig-case-fold-search case-fold-search)) |
1737 | 914 (if (not old) |
915 (progn | |
916 (he-init-string (he-dabbrev-beg) (point)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
917 (setq he-search-bufs (buffer-list)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
918 (setq he-searched-n-bufs 0) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
919 (set-marker he-search-loc 1 (car he-search-bufs)))) |
1737 | 920 |
921 (if (not (equal he-search-string "")) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
922 (while (and he-search-bufs |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
923 (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
924 (or (not hippie-expand-max-buffers) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
925 (< he-searched-n-bufs hippie-expand-max-buffers))) |
1737 | 926 (set-buffer (car he-search-bufs)) |
927 (if (and (not (eq (current-buffer) buf)) | |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
928 (not (memq major-mode hippie-expand-ignore-buffers)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
929 (not (he-regexp-member (buffer-name) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
930 hippie-expand-ignore-buffers))) |
1737 | 931 (save-excursion |
932 (goto-char he-search-loc) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
933 (setq expansion (let ((case-fold-search orig-case-fold-search)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
934 (he-dabbrev-search he-search-string nil))) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
935 (set-marker he-search-loc (point)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
936 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
937 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
938 (setq he-search-bufs (cdr he-search-bufs)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
939 (setq he-searched-n-bufs (1+ he-searched-n-bufs)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
940 (set-marker he-search-loc 1 (car he-search-bufs))))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
941 (setq he-search-bufs (cdr he-search-bufs)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
942 (set-marker he-search-loc 1 (car he-search-bufs))))) |
1737 | 943 |
944 (set-buffer buf) | |
945 (if (not expansion) | |
946 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
947 (if old (he-reset-string)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
948 ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
949 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
950 (he-substitute-string expansion t) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
951 t)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
952 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
953 ;; Thanks go to Jeff Dairiki <dairiki@faraday.apl.washington.edu> who |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
954 ;; suggested this one. |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
955 (defun try-expand-dabbrev-visible (old) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
956 "Try to expand word \"dynamically\", searching visible window parts. |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
957 The argument OLD has to be nil the first call of this function, and t |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
958 for subsequent calls (for further possible expansions of the same |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
959 string). It returns t if a new expansion is found, nil otherwise." |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
960 (let ((expansion ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
961 (buf (current-buffer)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
962 (flag (if (frame-visible-p (window-frame (selected-window))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
963 'visible t))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
964 (if (not old) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
965 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
966 (he-init-string (he-dabbrev-beg) (point)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
967 (setq he-search-window (selected-window)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
968 (set-marker he-search-loc |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
969 (window-start he-search-window) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
970 (window-buffer he-search-window)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
971 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
972 (while (and (not (equal he-search-string "")) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
973 (marker-position he-search-loc) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
974 (not expansion)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
975 (save-excursion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
976 (set-buffer (marker-buffer he-search-loc)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
977 (goto-char he-search-loc) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
978 (setq expansion (he-dabbrev-search he-search-string () |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
979 (window-end he-search-window))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
980 (if (and expansion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
981 (eq (marker-buffer he-string-beg) (current-buffer)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
982 (eq (marker-position he-string-beg) (match-beginning 0))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
983 (setq expansion (he-dabbrev-search he-search-string () |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
984 (window-end he-search-window)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
985 (set-marker he-search-loc (point) (current-buffer))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
986 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
987 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
988 (setq he-search-window (next-window he-search-window nil flag)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
989 (if (eq he-search-window (selected-window)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
990 (set-marker he-search-loc nil) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
991 (set-marker he-search-loc (window-start he-search-window) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
992 (window-buffer he-search-window)))))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
993 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
994 (set-buffer buf) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
995 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
996 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
997 (if old (he-reset-string)) |
1737 | 998 ()) |
999 (progn | |
1000 (he-substitute-string expansion t) | |
1001 t)))) | |
1002 | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1003 (defun he-dabbrev-search (pattern &optional reverse limit) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1004 (let ((result ()) |
18030
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1005 (regpat (cond ((not he-dabbrev-as-symbol) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1006 (concat "\\<" (regexp-quote pattern) "\\sw+")) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1007 ((eq (char-syntax (aref pattern 0)) ?_) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1008 (concat (regexp-quote pattern) "\\(\\sw\\|\\s_\\)+")) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1009 (t |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1010 (concat "\\<" (regexp-quote pattern) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1011 "\\(\\sw\\|\\s_\\)+"))))) |
1737 | 1012 (while (and (not result) |
1013 (if reverse | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1014 (re-search-backward regpat limit t) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1015 (re-search-forward regpat limit t))) |
1737 | 1016 (setq result (buffer-substring (match-beginning 0) (match-end 0))) |
18030
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1017 (if (or (and he-dabbrev-as-symbol |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1018 (> (match-beginning 0) (point-min)) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1019 (memq (char-syntax (char-after (1- (match-beginning 0)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1020 '(?_ ?w))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1021 (he-string-member result he-tried-table t)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1022 (setq result nil))) ; ignore if bad prefix or already in table |
1737 | 1023 result)) |
1024 | |
1025 (defun he-dabbrev-beg () | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1026 (let ((op (point))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1027 (save-excursion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1028 (if he-dabbrev-skip-space |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1029 (skip-syntax-backward ". ")) |
18030
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1030 (if (= (skip-syntax-backward (if he-dabbrev-as-symbol "w_" "w")) 0) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1031 op |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1032 (point))))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1033 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1034 (defun try-expand-dabbrev-from-kill (old) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1035 "Try to expand word \"dynamically\", searching the kill ring. |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1036 The argument OLD has to be nil the first call of this function, and t |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1037 for subsequent calls (for further possible completions of the same |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1038 string). It returns t if a new completion is found, nil otherwise." |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1039 (let ((expansion ())) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1040 (if (not old) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1041 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1042 (he-init-string (he-dabbrev-beg) (point)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1043 (setq he-expand-list |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1044 (if (not (equal he-search-string "")) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1045 kill-ring)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1046 (setq he-search-loc2 0))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1047 (if (not (equal he-search-string "")) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1048 (setq expansion (he-dabbrev-kill-search he-search-string))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1049 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1050 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1051 (if old (he-reset-string)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1052 ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1053 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1054 (he-substitute-string expansion t) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1055 t)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1056 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1057 (defun he-dabbrev-kill-search (pattern) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1058 (let ((result ()) |
18030
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1059 (regpat (cond ((not he-dabbrev-as-symbol) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1060 (concat "\\<" (regexp-quote pattern) "\\sw+")) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1061 ((eq (char-syntax (aref pattern 0)) ?_) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1062 (concat (regexp-quote pattern) "\\(\\sw\\|\\s_\\)+")) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1063 (t |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1064 (concat "\\<" (regexp-quote pattern) |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1065 "\\(\\sw\\|\\s_\\)+")))) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1066 (killstr (car he-expand-list))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1067 (while (and (not result) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1068 he-expand-list) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1069 (while (and (not result) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1070 (string-match regpat killstr he-search-loc2)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1071 (setq result (substring killstr (match-beginning 0) (match-end 0))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1072 (setq he-search-loc2 (1+ (match-beginning 0))) |
18030
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1073 (if (or (and he-dabbrev-as-symbol |
d3cc9cf799f8
(he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents:
17634
diff
changeset
|
1074 (> (match-beginning 0) 0) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1075 (memq (char-syntax (aref killstr (1- (match-beginning 0)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1076 '(?_ ?w))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1077 (he-string-member result he-tried-table t)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1078 (setq result nil))) ; ignore if bad prefix or already in table |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1079 (if (and (not result) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1080 he-expand-list) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1081 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1082 (setq he-expand-list (cdr he-expand-list)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1083 (setq killstr (car he-expand-list)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1084 (setq he-search-loc2 0)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1085 result)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1086 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1087 (defun try-expand-whole-kill (old) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1088 "Try to complete text with something from the kill ring. |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1089 The argument OLD has to be nil the first call of this function, and t |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1090 for subsequent calls (for further possible completions of the same |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1091 string). It returns t if a new completion is found, nil otherwise." |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1092 (let ((expansion ())) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1093 (if (not old) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1094 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1095 (he-init-string (he-kill-beg) (point)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1096 (if (not (he-string-member he-search-string he-tried-table)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1097 (setq he-tried-table (cons he-search-string he-tried-table))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1098 (setq he-expand-list |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1099 (if (not (equal he-search-string "")) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1100 kill-ring)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1101 (setq he-search-loc2 ()))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1102 (if (not (equal he-search-string "")) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1103 (setq expansion (he-whole-kill-search he-search-string))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1104 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1105 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1106 (if old (he-reset-string)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1107 ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1108 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1109 (he-substitute-string expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1110 t)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1111 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1112 (defun he-whole-kill-search (str) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1113 (let ((case-fold-search ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1114 (result ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1115 (str (regexp-quote str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1116 (killstr (car he-expand-list)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1117 (pos -1)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1118 (while (and (not result) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1119 he-expand-list) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1120 (if (not he-search-loc2) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1121 (while (setq pos (string-match str killstr (1+ pos))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1122 (setq he-search-loc2 (cons pos he-search-loc2)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1123 (while (and (not result) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1124 he-search-loc2) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1125 (setq pos (car he-search-loc2)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1126 (setq he-search-loc2 (cdr he-search-loc2)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1127 (save-excursion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1128 (goto-char he-string-beg) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1129 (if (and (>= (- (point) pos) (point-min)) ; avoid some string GC |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1130 (eq (char-after (- (point) pos)) (aref killstr 0)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1131 (search-backward (substring killstr 0 pos) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1132 (- (point) pos) t)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1133 (setq result (substring killstr pos)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1134 (if (and result |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1135 (he-string-member result he-tried-table)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1136 (setq result nil))) ; ignore if already in table |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1137 (if (and (not result) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1138 he-expand-list) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1139 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1140 (setq he-expand-list (cdr he-expand-list)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1141 (setq killstr (car he-expand-list)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1142 (setq pos -1)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1143 result)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1144 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1145 (defun he-kill-beg () |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1146 (let ((op (point))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1147 (save-excursion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1148 (skip-syntax-backward "^w_") |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1149 (if (= (skip-syntax-backward "w_") 0) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1150 op |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1151 (point))))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1152 |
1737 | 1153 |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
1154 (provide 'hippie-exp) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
1155 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
1156 ;;; hippie-exp.el ends here |