Mercurial > emacs
annotate lisp/hippie-exp.el @ 17286:4ee0f02eff87
(Finsert_file_contents): Handle non-regular files.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 02 Apr 1997 06:12:48 +0000 |
parents | a0cfcb9f8033 |
children | 247c2a11843d |
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> |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
6 ;; Last change: 6 August 1995 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
7 ;; Version: 1.4 |
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 |
160 (defvar he-num -1) | |
161 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
162 (defvar he-string-beg (make-marker)) |
1737 | 163 |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
164 (defvar he-string-end (make-marker)) |
1737 | 165 |
166 (defvar he-search-string ()) | |
167 | |
168 (defvar he-expand-list ()) | |
169 | |
170 (defvar he-tried-table ()) | |
171 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
172 (defvar he-search-loc (make-marker)) |
1737 | 173 |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
174 (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
|
175 |
1737 | 176 (defvar he-search-bw ()) |
177 | |
178 (defvar he-search-bufs ()) | |
179 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
180 (defvar he-searched-n-bufs ()) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
181 |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
182 (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
|
183 |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
184 ;;;###autoload |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
185 (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
|
186 try-complete-file-name |
1737 | 187 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
|
188 try-expand-list |
1737 | 189 try-expand-line |
190 try-expand-dabbrev | |
191 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
|
192 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
|
193 try-complete-lisp-symbol-partially |
1737 | 194 try-complete-lisp-symbol) |
195 "The list of expansion functions tried in order by `hippie-expand'. | |
196 To change the behavior of `hippie-expand', remove, change the order of, | |
197 or insert functions in this list.") | |
198 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
199 ;;;###autoload |
1737 | 200 (defvar hippie-expand-verbose t |
201 "*Non-nil makes `hippie-expand' output which function it is trying.") | |
202 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
203 ;;;###autoload |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
204 (defvar hippie-expand-max-buffers () |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
205 "*The maximum number of buffers (apart from the current) searched. |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
206 If nil, all buffers are searched.") |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
207 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
208 ;;;###autoload |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
209 (defvar hippie-expand-ignore-buffers '("^ \\*.*\\*$" dired-mode) |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
210 "*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
|
211 Can contain both regexps matching buffer names (as strings) and major modes |
7639 | 212 \(as atoms)") |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
213 |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
214 ;;;###autoload |
1737 | 215 (defun hippie-expand (arg) |
216 "Try to expand text before point, using multiple methods. | |
217 The expansion functions in `hippie-expand-try-functions-list' are | |
218 tried in order, until a possible expansion is found. Repeated | |
219 application of `hippie-expand' inserts successively possible | |
220 expansions. | |
221 With a positive numeric argument, jumps directly to the ARG next | |
222 function in this list. With a negative argument or just \\[universal-argument], | |
223 undoes the expansion." | |
224 (interactive "P") | |
225 (if (or (not arg) | |
226 (and (integerp arg) (> arg 0))) | |
227 (let ((first (or (= he-num -1) | |
228 (not (equal this-command last-command))))) | |
229 (if first | |
230 (progn | |
231 (setq he-num -1) | |
232 (setq he-tried-table nil))) | |
233 (if arg | |
234 (if (not first) (he-reset-string)) | |
235 (setq arg 0)) | |
236 (let ((i (max (+ he-num arg) 0))) | |
237 (while (not (or (>= i (length hippie-expand-try-functions-list)) | |
238 (apply (nth i hippie-expand-try-functions-list) | |
239 (list (= he-num i))))) | |
240 (setq i (1+ i))) | |
241 (setq he-num i)) | |
242 (if (>= he-num (length hippie-expand-try-functions-list)) | |
243 (progn | |
244 (setq he-num -1) | |
245 (if first | |
246 (message "No expansion found") | |
247 (message "No further expansions found")) | |
248 (ding)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
249 (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
|
250 (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
|
251 (message "Using %s" |
594c4676b8c6
(hippie-expand): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
252 (prin1-to-string (nth he-num |
594c4676b8c6
(hippie-expand): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
253 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
|
254 (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
|
255 (eq (marker-buffer he-string-beg) (current-buffer))) |
1737 | 256 (progn |
257 (setq he-num -1) | |
258 (he-reset-string) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
259 (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
|
260 (not (window-minibuffer-p (selected-window)))) |
1737 | 261 (message "Undoing expansions")))))) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
262 |
1737 | 263 ;; Initializes the region to expand (to between BEG and END). |
264 (defun he-init-string (beg end) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
265 (set-marker he-string-beg beg) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
266 (set-marker he-string-end end) |
1737 | 267 (setq he-search-string (buffer-substring beg end))) |
268 | |
269 ;; Resets the expanded region to its original contents. | |
270 (defun he-reset-string () | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
271 (let ((newpos (point-marker))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
272 (goto-char he-string-beg) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
273 (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
|
274 (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
|
275 (goto-char newpos))) |
1737 | 276 |
277 ;; Substitutes an expansion STR into the correct region (the region | |
278 ;; initialized with `he-init-string'). | |
279 ;; An optional argument TRANS-CASE means that it is ok to transfer case | |
280 ;; from the abbreviation to the expansion if that is possible, and is | |
281 ;; enabled in the buffer. | |
282 (defun he-substitute-string (str &optional trans-case) | |
283 (let ((trans-case (and trans-case | |
284 case-replace | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
285 case-fold-search)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
286 (newpos (point-marker)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
287 (subst ())) |
1737 | 288 (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
|
289 (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
|
290 (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
|
291 (insert subst) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
292 (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
|
293 (goto-char newpos))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
294 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
295 (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
|
296 (save-match-data |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
297 (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
|
298 (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
|
299 (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
|
300 (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
|
301 res) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
302 str))) |
1737 | 303 |
304 (defun he-ordinary-case-p (str) | |
305 (or (string= str (downcase str)) | |
306 (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
|
307 (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
|
308 (string= str (he-capitalize-first str)))) |
1737 | 309 |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
310 (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
|
311 (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
|
312 (length to-str)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
313 to-str) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
314 ((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
|
315 to-str) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
316 ((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
|
317 (downcase to-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
318 ((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
|
319 (upcase to-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
320 ((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
|
321 (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
|
322 ((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
|
323 (capitalize to-str)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
324 (t |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
325 to-str))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
326 |
1737 | 327 |
328 ;; 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
|
329 ;; 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
|
330 (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
|
331 (if str |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
332 (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
|
333 case-replace |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
334 case-fold-search) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
335 (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
|
336 str) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
337 lst))) |
1737 | 338 |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
339 ;; Check if STR matches any regexp in LST. |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
340 ;; Ignore possible non-strings in LST. |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
341 (defun he-regexp-member (str lst) |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
342 (while (and lst |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
343 (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
|
344 (not (string-match (car lst) str)))) |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
345 (setq lst (cdr lst))) |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
346 lst) |
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
347 |
1737 | 348 ;; For the real hippie-expand enthusiast: A macro that makes it |
349 ;; possible to use many functions like hippie-expand, but with | |
350 ;; different try-functions-lists. | |
351 ;; Usage is for example: | |
352 ;; (fset 'my-complete-file (make-hippie-expand-function | |
353 ;; '(try-complete-file-name-partially | |
354 ;; try-complete-file-name))) | |
355 ;; (fset 'my-complete-line (make-hippie-expand-function | |
356 ;; '(try-expand-line | |
357 ;; try-expand-line-all-buffers))) | |
358 ;; | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
359 ;;;###autoload |
1737 | 360 (defmacro make-hippie-expand-function (try-list &optional verbose) |
361 "Construct a function similar to `hippie-expand'. | |
362 Make it use the expansion functions in TRY-LIST. An optional second | |
363 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
|
364 (` (function (lambda (arg) |
1737 | 365 (, (concat |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
366 "Try to expand text before point, using the following functions: \n" |
1737 | 367 (mapconcat 'prin1-to-string (eval try-list) ", "))) |
368 (interactive "P") | |
369 (let ((hippie-expand-try-functions-list (, try-list)) | |
370 (hippie-expand-verbose (, verbose))) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
371 (hippie-expand arg)))))) |
1737 | 372 |
373 | |
374 ;;; Here follows the try-functions and their requisites: | |
375 | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
376 |
1737 | 377 (defun try-complete-file-name (old) |
378 "Try to complete text as a file name. | |
379 The argument OLD has to be nil the first call of this function, and t | |
380 for subsequent calls (for further possible completions of the same | |
381 string). It returns t if a new completion is found, nil otherwise." | |
382 (if (not old) | |
383 (progn | |
384 (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
|
385 (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
|
386 (dir-part (expand-file-name (or (he-file-name-directory |
1737 | 387 he-search-string) "")))) |
388 (if (not (he-string-member name-part he-tried-table)) | |
389 (setq he-tried-table (cons name-part he-tried-table))) | |
390 (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
|
391 (he-file-directory-p dir-part)) |
1737 | 392 (setq he-expand-list (sort (file-name-all-completions |
393 name-part | |
394 dir-part) | |
395 'string-lessp)) | |
396 (setq he-expand-list ()))))) | |
397 | |
398 (while (and he-expand-list | |
399 (he-string-member (car he-expand-list) he-tried-table)) | |
400 (setq he-expand-list (cdr he-expand-list))) | |
401 (if (null he-expand-list) | |
402 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
403 (if old (he-reset-string)) |
1737 | 404 ()) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
405 (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
|
406 (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
|
407 (car he-expand-list)))) |
1737 | 408 (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
|
409 (setq he-tried-table (cons (car he-expand-list) (cdr he-tried-table))) |
1737 | 410 (setq he-expand-list (cdr he-expand-list)) |
411 t))) | |
412 | |
413 (defun try-complete-file-name-partially (old) | |
414 "Try to complete text as a file name, as many characters as unique. | |
415 The argument OLD has to be nil the first call of this function. It | |
416 returns t if a unique, possibly partial, completion is found, nil | |
417 otherwise." | |
418 (let ((expansion ())) | |
419 (if (not old) | |
420 (progn | |
421 (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
|
422 (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
|
423 (dir-part (expand-file-name (or (he-file-name-directory |
1737 | 424 he-search-string) "")))) |
425 (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
|
426 (he-file-directory-p dir-part)) |
1737 | 427 (setq expansion (file-name-completion name-part |
428 dir-part))) | |
429 (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
|
430 (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
|
431 (he-string-member expansion he-tried-table)) |
1737 | 432 (setq expansion ()))))) |
433 | |
434 (if (not expansion) | |
435 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
436 (if old (he-reset-string)) |
1737 | 437 ()) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
438 (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
|
439 (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
|
440 expansion))) |
1737 | 441 (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
|
442 (setq he-tried-table (cons expansion (cdr he-tried-table))) |
1737 | 443 t)))) |
444 | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
445 (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
|
446 (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
|
447 "-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
|
448 ((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
|
449 "-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
|
450 (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
|
451 "-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
|
452 "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
|
453 |
1737 | 454 (defun he-file-name-beg () |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
455 (save-excursion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
456 (skip-chars-backward 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
|
457 (point))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
458 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
459 ;; 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
|
460 ;; 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
|
461 ;; 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
|
462 (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
|
463 "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
|
464 (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
|
465 (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
|
466 (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
|
467 (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
|
468 n)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
469 (file-name-nondirectory file))) |
1737 | 470 |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
471 (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
|
472 "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
|
473 (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
|
474 (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
|
475 (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
|
476 (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
|
477 (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
|
478 d)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
479 (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
|
480 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
481 (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
|
482 "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
|
483 (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
|
484 (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
|
485 (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
|
486 (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
|
487 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
488 (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
|
489 "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
|
490 (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
|
491 ((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
|
492 (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
|
493 (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
|
494 (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
|
495 (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
|
496 ((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
|
497 (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
|
498 (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
|
499 (= (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
|
500 (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
|
501 (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
|
502 (t |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
503 (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
|
504 |
1737 | 505 (defun try-complete-lisp-symbol (old) |
506 "Try to complete word as an Emacs Lisp symbol. | |
507 The argument OLD has to be nil the first call of this function, and t | |
508 for subsequent calls (for further possible completions of the same | |
509 string). It returns t if a new completion is found, nil otherwise." | |
510 (if (not old) | |
511 (progn | |
512 (he-init-string (he-lisp-symbol-beg) (point)) | |
513 (if (not (he-string-member he-search-string he-tried-table)) | |
514 (setq he-tried-table (cons he-search-string he-tried-table))) | |
515 (setq he-expand-list | |
516 (and (not (equal he-search-string "")) | |
517 (sort (all-completions he-search-string obarray | |
518 (function (lambda (sym) | |
519 (or (boundp sym) | |
520 (fboundp sym) | |
521 (symbol-plist sym))))) | |
522 'string-lessp))))) | |
523 (while (and he-expand-list | |
524 (he-string-member (car he-expand-list) he-tried-table)) | |
525 (setq he-expand-list (cdr he-expand-list))) | |
526 (if (null he-expand-list) | |
527 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
528 (if old (he-reset-string)) |
1737 | 529 ()) |
530 (progn | |
531 (he-substitute-string (car he-expand-list)) | |
532 (setq he-expand-list (cdr he-expand-list)) | |
533 t))) | |
534 | |
535 (defun try-complete-lisp-symbol-partially (old) | |
536 "Try to complete as an Emacs Lisp symbol, as many characters as unique. | |
537 The argument OLD has to be nil the first call of this function. It | |
538 returns t if a unique, possibly partial, completion is found, nil | |
539 otherwise." | |
540 (let ((expansion ())) | |
541 (if (not old) | |
542 (progn | |
543 (he-init-string (he-lisp-symbol-beg) (point)) | |
544 (if (not (string= he-search-string "")) | |
545 (setq expansion | |
546 (try-completion he-search-string obarray | |
547 (function (lambda (sym) | |
548 (or (boundp sym) | |
549 (fboundp sym) | |
550 (symbol-plist sym))))))) | |
551 (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
|
552 (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
|
553 (he-string-member expansion he-tried-table)) |
1737 | 554 (setq expansion ())))) |
555 | |
556 (if (not expansion) | |
557 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
558 (if old (he-reset-string)) |
1737 | 559 ()) |
560 (progn | |
561 (he-substitute-string expansion) | |
562 t)))) | |
563 | |
564 (defun he-lisp-symbol-beg () | |
565 (let ((skips "-a-zA-Z0-9_.")) | |
566 (save-excursion | |
567 (skip-chars-backward skips) | |
568 (point)))) | |
569 | |
570 (defun try-expand-line (old) | |
571 "Try to complete the current line to an entire line in the buffer. | |
572 The argument OLD has to be nil the first call of this function, and t | |
573 for subsequent calls (for further possible completions of the same | |
574 string). It returns t if a new completion is found, nil otherwise." | |
575 (let ((expansion ()) | |
576 (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
|
577 comint-prompt-regexp))) |
1737 | 578 (if (not old) |
579 (progn | |
580 (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
|
581 (set-marker he-search-loc he-string-beg) |
1737 | 582 (setq he-search-bw t))) |
583 | |
584 (if (not (equal he-search-string "")) | |
585 (save-excursion | |
586 ;; Try looking backward unless inhibited. | |
587 (if he-search-bw | |
588 (progn | |
589 (goto-char he-search-loc) | |
590 (setq expansion (he-line-search he-search-string | |
591 strip-prompt t)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
592 (set-marker he-search-loc (point)) |
1737 | 593 (if (not expansion) |
594 (progn | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
595 (set-marker he-search-loc he-string-end) |
1737 | 596 (setq he-search-bw ()))))) |
597 | |
598 (if (not expansion) ; Then look forward. | |
599 (progn | |
600 (goto-char he-search-loc) | |
601 (setq expansion (he-line-search he-search-string | |
602 strip-prompt nil)) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
603 (set-marker he-search-loc (point)))))) |
1737 | 604 |
605 (if (not expansion) | |
606 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
607 (if old (he-reset-string)) |
1737 | 608 ()) |
609 (progn | |
610 (he-substitute-string expansion t) | |
611 t)))) | |
612 | |
613 (defun try-expand-line-all-buffers (old) | |
614 "Try to complete the current line, searching all other buffers. | |
615 The argument OLD has to be nil the first call of this function, and t | |
616 for subsequent calls (for further possible completions of the same | |
617 string). It returns t if a new completion is found, nil otherwise." | |
618 (let ((expansion ()) | |
619 (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
|
620 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
|
621 (buf (current-buffer)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
622 (orig-case-fold-search case-fold-search)) |
1737 | 623 (if (not old) |
624 (progn | |
625 (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
|
626 (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
|
627 (setq he-searched-n-bufs 0) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
628 (set-marker he-search-loc 1 (car he-search-bufs)))) |
1737 | 629 |
630 (if (not (equal he-search-string "")) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
631 (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
|
632 (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
633 (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
|
634 (< he-searched-n-bufs hippie-expand-max-buffers))) |
1737 | 635 (set-buffer (car he-search-bufs)) |
636 (if (and (not (eq (current-buffer) buf)) | |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
637 (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
|
638 (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
|
639 hippie-expand-ignore-buffers))) |
1737 | 640 (save-excursion |
641 (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
|
642 (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
|
643 comint-prompt-regexp)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
644 (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
|
645 (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
|
646 strip-prompt nil))) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
647 (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
|
648 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
649 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
650 (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
|
651 (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
|
652 (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
|
653 (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
|
654 (set-marker he-search-loc 1 (car he-search-bufs))))) |
1737 | 655 |
656 (set-buffer buf) | |
657 (if (not expansion) | |
658 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
659 (if old (he-reset-string)) |
1737 | 660 ()) |
661 (progn | |
662 (he-substitute-string expansion t) | |
663 t)))) | |
664 | |
665 (defun he-line-search (str strip-prompt reverse) | |
666 (let ((result ())) | |
667 (while (and (not result) | |
668 (if reverse | |
669 (re-search-backward | |
670 (he-line-search-regexp str strip-prompt) | |
671 nil t) | |
672 (re-search-forward | |
673 (he-line-search-regexp str strip-prompt) | |
674 nil t))) | |
675 (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
|
676 (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
|
677 (setq result nil))) ; if already in table, ignore |
1737 | 678 result)) |
679 | |
680 (defun he-line-beg (strip-prompt) | |
681 (save-excursion | |
682 (if (re-search-backward (he-line-search-regexp "" strip-prompt) | |
683 (save-excursion (beginning-of-line) | |
684 (point)) t) | |
685 (match-beginning 2) | |
686 (point)))) | |
687 | |
688 (defun he-line-search-regexp (pat strip-prompt) | |
689 (if strip-prompt | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
690 (concat "\\(" comint-prompt-regexp "\\|^\\s-*\\)\\(" |
1737 | 691 (regexp-quote pat) |
692 "[^\n]*[^ \t\n]\\)") | |
693 (concat "^\\(\\s-*\\)\\(" | |
694 (regexp-quote pat) | |
695 "[^\n]*[^ \t\n]\\)"))) | |
696 | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
697 (defun try-expand-list (old) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
698 "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
|
699 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
|
700 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
|
701 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
|
702 (let ((expansion ())) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
703 (if (not old) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
704 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
705 (he-init-string (he-list-beg) (point)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
706 (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
|
707 (setq he-search-bw t))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
708 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
709 (if (not (equal he-search-string "")) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
710 (save-excursion |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
711 ;; Try looking backward unless inhibited. |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
712 (if he-search-bw |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
713 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
714 (goto-char he-search-loc) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
715 (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
|
716 (set-marker he-search-loc (point)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
717 (if (not expansion) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
718 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
719 (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
|
720 (setq he-search-bw ()))))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
721 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
722 (if (not expansion) ; Then look forward. |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
723 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
724 (goto-char he-search-loc) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
725 (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
|
726 (set-marker he-search-loc (point)))))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
727 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
728 (if (not expansion) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
729 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
730 (if old (he-reset-string)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
731 ()) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
732 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
733 (he-substitute-string expansion t) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
734 t)))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
735 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
736 (defun try-expand-list-all-buffers (old) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
737 "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
|
738 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
|
739 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
|
740 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
|
741 (let ((expansion ()) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
742 (buf (current-buffer)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
743 (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
|
744 (if (not old) |
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 (he-init-string (he-list-beg) (point)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
747 (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
|
748 (setq he-searched-n-bufs 0) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
749 (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
|
750 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
751 (if (not (equal he-search-string "")) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
752 (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
|
753 (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
754 (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
|
755 (< 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
|
756 (set-buffer (car he-search-bufs)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
757 (if (and (not (eq (current-buffer) buf)) |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
758 (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
|
759 (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
|
760 hippie-expand-ignore-buffers))) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
761 (save-excursion |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
762 (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
|
763 (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
|
764 (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
|
765 (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
|
766 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
767 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
768 (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
|
769 (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
|
770 (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
|
771 (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
|
772 (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
|
773 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
774 (set-buffer buf) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
775 (if (not expansion) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
776 (progn |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
777 (if old (he-reset-string)) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
778 ()) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
779 (progn |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
780 (he-substitute-string expansion t) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
781 t)))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
782 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
783 (defun he-list-search (str reverse) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
784 (let ((result ()) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
785 beg pos err) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
786 (while (and (not result) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
787 (if reverse |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
788 (search-backward str nil t) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
789 (search-forward str nil t))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
790 (setq pos (point)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
791 (setq beg (match-beginning 0)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
792 (goto-char beg) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
793 (setq err ()) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
794 (condition-case () |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
795 (forward-list 1) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
796 (error (setq err t))) |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
797 (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
|
798 (> (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
|
799 (setq err t)) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
800 (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
|
801 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
802 (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
|
803 (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
|
804 (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
|
805 (goto-char pos)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
806 result)) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
807 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
808 (defun he-list-beg () |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
809 (save-excursion |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
810 (condition-case () |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
811 (backward-up-list 1) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
812 (error ())) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
813 (point))) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
814 |
1737 | 815 (defun try-expand-all-abbrevs (old) |
816 "Try to expand word before point according to all abbrev tables. | |
817 The argument OLD has to be nil the first call of this function, and t | |
818 for subsequent calls (for further possible expansions of the same | |
819 string). It returns t if a new expansion is found, nil otherwise." | |
820 (if (not old) | |
821 (progn | |
822 (he-init-string (he-dabbrev-beg) (point)) | |
823 (setq he-expand-list | |
824 (and (not (equal he-search-string "")) | |
825 (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
|
826 (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
|
827 (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
|
828 (eval sym))))) |
1737 | 829 (append '(local-abbrev-table |
830 global-abbrev-table) | |
831 abbrev-table-name-list)))))) | |
832 (while (and he-expand-list | |
833 (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
|
834 (he-string-member (car he-expand-list) he-tried-table t))) |
1737 | 835 (setq he-expand-list (cdr he-expand-list))) |
836 (if (null he-expand-list) | |
837 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
838 (if old (he-reset-string)) |
1737 | 839 ()) |
840 (progn | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
841 (he-substitute-string (car he-expand-list) t) |
1737 | 842 (setq he-expand-list (cdr he-expand-list)) |
843 t))) | |
844 | |
845 (defun try-expand-dabbrev (old) | |
846 "Try to expand word \"dynamically\", searching the current buffer. | |
847 The argument OLD has to be nil the first call of this function, and t | |
848 for subsequent calls (for further possible expansions of the same | |
849 string). It returns t if a new expansion is found, nil otherwise." | |
850 (let ((expansion ())) | |
851 (if (not old) | |
852 (progn | |
853 (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
|
854 (set-marker he-search-loc he-string-beg) |
1737 | 855 (setq he-search-bw t))) |
856 | |
857 (if (not (equal he-search-string "")) | |
858 (save-excursion | |
859 ;; Try looking backward unless inhibited. | |
860 (if he-search-bw | |
861 (progn | |
862 (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
|
863 (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
|
864 (set-marker he-search-loc (point)) |
1737 | 865 (if (not expansion) |
866 (progn | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
867 (set-marker he-search-loc he-string-end) |
1737 | 868 (setq he-search-bw ()))))) |
869 | |
870 (if (not expansion) ; Then look forward. | |
871 (progn | |
872 (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
|
873 (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
|
874 (set-marker he-search-loc (point)))))) |
1737 | 875 |
876 (if (not expansion) | |
877 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
878 (if old (he-reset-string)) |
1737 | 879 ()) |
880 (progn | |
881 (he-substitute-string expansion t) | |
882 t)))) | |
883 | |
884 (defun try-expand-dabbrev-all-buffers (old) | |
885 "Tries to expand word \"dynamically\", searching all other buffers. | |
886 The argument OLD has to be nil the first call of this function, and t | |
887 for subsequent calls (for further possible expansions of the same | |
888 string). It returns t if a new expansion is found, nil otherwise." | |
889 (let ((expansion ()) | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
890 (buf (current-buffer)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
891 (orig-case-fold-search case-fold-search)) |
1737 | 892 (if (not old) |
893 (progn | |
894 (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
|
895 (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
|
896 (setq he-searched-n-bufs 0) |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
897 (set-marker he-search-loc 1 (car he-search-bufs)))) |
1737 | 898 |
899 (if (not (equal he-search-string "")) | |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
900 (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
|
901 (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
902 (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
|
903 (< he-searched-n-bufs hippie-expand-max-buffers))) |
1737 | 904 (set-buffer (car he-search-bufs)) |
905 (if (and (not (eq (current-buffer) buf)) | |
5296
81b21ef5290d
(;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents:
4130
diff
changeset
|
906 (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
|
907 (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
|
908 hippie-expand-ignore-buffers))) |
1737 | 909 (save-excursion |
910 (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
|
911 (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
|
912 (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
|
913 (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
|
914 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
915 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
916 (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
|
917 (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
|
918 (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
|
919 (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
|
920 (set-marker he-search-loc 1 (car he-search-bufs))))) |
1737 | 921 |
922 (set-buffer buf) | |
923 (if (not expansion) | |
924 (progn | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
925 (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
|
926 ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
927 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
928 (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
|
929 t)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
930 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
931 ;; 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
|
932 ;; suggested this one. |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
933 (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
|
934 "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
|
935 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
|
936 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
|
937 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
|
938 (let ((expansion ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
939 (buf (current-buffer)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
940 (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
|
941 'visible t))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
942 (if (not old) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
943 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
944 (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
|
945 (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
|
946 (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
|
947 (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
|
948 (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
|
949 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
950 (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
|
951 (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
|
952 (not expansion)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
953 (save-excursion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
954 (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
|
955 (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
|
956 (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
|
957 (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
|
958 (if (and expansion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
959 (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
|
960 (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
|
961 (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
|
962 (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
|
963 (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
|
964 (if (not expansion) |
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 (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
|
967 (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
|
968 (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
|
969 (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
|
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 (set-buffer buf) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
973 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
974 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
975 (if old (he-reset-string)) |
1737 | 976 ()) |
977 (progn | |
978 (he-substitute-string expansion t) | |
979 t)))) | |
980 | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
981 (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
|
982 (let ((result ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
983 (regpat (if (eq (char-syntax (aref pattern 0)) ?_) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
984 (concat (regexp-quote pattern) "\\(\\sw\\|\\s_\\)+") |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
985 (concat "\\<" (regexp-quote pattern) "\\(\\sw\\|\\s_\\)+")))) |
1737 | 986 (while (and (not result) |
987 (if reverse | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
988 (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
|
989 (re-search-forward regpat limit t))) |
1737 | 990 (setq result (buffer-substring (match-beginning 0) (match-end 0))) |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
991 (if (or (and (> (match-beginning 0) (point-min)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
992 (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
|
993 '(?_ ?w))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
994 (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
|
995 (setq result nil))) ; ignore if bad prefix or already in table |
1737 | 996 result)) |
997 | |
13207
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
998 (defvar 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
|
999 "Non-NIL means tolerate trailing spaces in the abbreviation to expand.") |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1000 |
1737 | 1001 (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
|
1002 (let ((op (point))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1003 (save-excursion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1004 (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
|
1005 (skip-syntax-backward ". ")) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1006 (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
|
1007 op |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1008 (point))))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1009 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1010 (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
|
1011 "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
|
1012 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
|
1013 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
|
1014 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
|
1015 (let ((expansion ())) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1016 (if (not old) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1017 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1018 (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
|
1019 (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
|
1020 (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
|
1021 kill-ring)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1022 (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
|
1023 (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
|
1024 (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
|
1025 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1026 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1027 (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
|
1028 ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1029 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1030 (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
|
1031 t)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1032 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1033 (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
|
1034 (let ((result ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1035 (regpat (if (eq (char-syntax (aref pattern 0)) ?_) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1036 (concat (regexp-quote pattern) "\\(\\sw\\|\\s_\\)+") |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1037 (concat "\\<" (regexp-quote pattern) "\\(\\sw\\|\\s_\\)+"))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1038 (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
|
1039 (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
|
1040 he-expand-list) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1041 (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
|
1042 (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
|
1043 (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
|
1044 (setq he-search-loc2 (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
|
1045 (if (or (and (> (match-beginning 0) 0) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1046 (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
|
1047 '(?_ ?w))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1048 (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
|
1049 (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
|
1050 (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
|
1051 he-expand-list) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1052 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1053 (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
|
1054 (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
|
1055 (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
|
1056 result)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1057 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1058 (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
|
1059 "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
|
1060 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
|
1061 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
|
1062 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
|
1063 (let ((expansion ())) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1064 (if (not old) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1065 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1066 (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
|
1067 (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
|
1068 (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
|
1069 (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
|
1070 (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
|
1071 kill-ring)) |
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 ()))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1073 (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
|
1074 (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
|
1075 (if (not expansion) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1076 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1077 (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
|
1078 ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1079 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1080 (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
|
1081 t)))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1082 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1083 (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
|
1084 (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
|
1085 (result ()) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1086 (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
|
1087 (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
|
1088 (pos -1)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1089 (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
|
1090 he-expand-list) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1091 (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
|
1092 (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
|
1093 (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
|
1094 (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
|
1095 he-search-loc2) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1096 (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
|
1097 (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
|
1098 (save-excursion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1099 (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
|
1100 (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
|
1101 (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
|
1102 (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
|
1103 (- (point) pos) t)) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1104 (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
|
1105 (if (and result |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1106 (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
|
1107 (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
|
1108 (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
|
1109 he-expand-list) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1110 (progn |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1111 (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
|
1112 (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
|
1113 (setq pos -1)))) |
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 |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1116 (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
|
1117 (let ((op (point))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1118 (save-excursion |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1119 (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
|
1120 (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
|
1121 op |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1122 (point))))) |
2b541cc4cd97
(hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
1123 |
1737 | 1124 |
4130
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
1125 (provide 'hippie-exp) |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
1126 |
e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents:
2233
diff
changeset
|
1127 ;;; hippie-exp.el ends here |