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