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