annotate lisp/hippie-exp.el @ 112451:98ad7c9e56a3

gnus-html.el (gnus-html-image-fetched): Don't kill the temporary buffer after being called. It's apparently being killed by url.el, and killing it made point move to end-of-buffer in a random buffer. shr.el (shr-image-fetched): Ditto. shr.el (shr-image-fetched): Avoid having point move in the article buffer. gnus-html.el (gnus-html-image-fetched): Kill the buffer anyway, and fix the bug in url-http.el instead. shr.el (shr-image-fetched): Ditto. gravatar.el (gravatar-retrieve): Be silent when retrieving. gnus-gravatar.el (gnus-gravatar-insert): Don't move point around in the article buffer. (gnus-gravatar-insert): Use blank space from the current buffer to avoid breaking text properties. This makes X-Sent updating work again. gnus-art.el (gnus-article-read-summary-keys): Don't call disabled commands.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Mon, 24 Jan 2011 04:10:19 +0000
parents 417b1e4d63cd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
104552
10c38084881d Remove code for defunct system-types emx, macos, mswindows,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
3 ;; Copyright (C) 1992, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
4 ;; 2009, 2010, 2011 Free Software Foundation, Inc.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13225
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2230
diff changeset
26 ;;; Commentary:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13225
diff changeset
27
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; `hippie-expand' is a single function for a lot of different kinds
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; Which kinds of completions to try, and in which order, is
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; determined by the contents of `hippie-expand-try-functions-list'.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; Much customization of `hippie-expand' can be made by changing the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; order of, removing, or inserting new functions in this list.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; Given a positive numeric argument, `hippie-expand' jumps directly
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; ARG functions forward in this list. Given some other argument
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; (a negative argument or just Ctrl-U) it undoes the tried
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; completion.
5296
81b21ef5290d (;; Keywords:): Changed to "abbrev".
Richard M. Stallman <rms@gnu.org>
parents: 4130
diff changeset
39 ;;
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; If the variable `hippie-expand-verbose' is non-nil, `hippie-expand'
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; outputs in a message which try-function in the list that is used
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; currently (ie. was used currently and will be tried first the next
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; A short description of the current try-functions in this file:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; `try-complete-file-name' : very convenient to have in any buffer,
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; and not just in the minibuffer or (some) shell-mode. It goes
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; through all possible completions instead of just completing as
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; much as is unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; `try-complete-file-name-partially' : To insert in the list just
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; before `try-complete-file-name' for those who want first to get
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; a file name completed only as many characters as is unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; `try-expand-all-abbrevs' : can be removed if you don't use abbrevs.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;; `try-expand-line-all-buffers' : Like `try-expand-line' but searches
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
106377
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
83 ;; open delimiter, to a whole list from the buffer. Convenient for
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;; `try-expand-dabbrev' : works exactly as dabbrev-expand (but of
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; course in a way compatible with the other try-functions).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;; `try-expand-dabbrev-all-buffers' : perhaps the most useful of them,
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;; like `dabbrev-expand' but searches all Emacs buffers (except the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;; `try-complete-lisp-symbol' : like `lisp-complete-symbol', but goes
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; through all possibilities instead of completing what is unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;; Might be tedious (usually a lot of possible completions) and
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; since its function is much like `lisp-complete-symbol', which
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; already has a key of its own, you might want to remove this.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;; `try-complete-lisp-symbol-partially' : To insert in the list just
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
106377
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
119 ;; to different keys. It is also possible to make
4130
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;; To write new try-functions, consider the following:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; Each try-function takes one argument OLD which is nil the first
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; time the function is called and true in succeeding calls for the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;; same string to complete. The first time the function has to
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; extract the string before point to complete, and substitute the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;; first completion alternative for it. On following calls it has to
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;; substitute the next possible completion for the last tried string.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;; The try-function is to return t as long as it finds new
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ;; possible completions. When there are no more alternatives it has
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;; to restore the text before point to its original contents, and
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;; return nil (don't beep or message or anything).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ;; The try-function can (should) use the following functions:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 ;; `he-init-string' : Initializes the text to substitute to the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;; contents of the region BEGIN to END. Also sets the variable
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; `he-search-string' to the text to expand.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;; `he-substitute-string' : substitutes STR into the region
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; initialized with `he-init-string'. (An optional second argument
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;; TRANS-CASE non-nil, means transfer of case from the abbreviation
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;; to the expansion is ok if that is enabled in the buffer.)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;; `he-reset-string' : Resets the initialized region to its original
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;; contents.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;;
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
149 ;; Known bugs
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ;; because different try-functions may try to complete different
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;; opposite situation to occur, that `hippie-expand' misses some
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 ;; suggestion because it thinks it has already tried it.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ;;
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
160 ;; Acknowledgement
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 ;; I want to thank Mikael Djurfeldt in discussions with whom the idea
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 ;; of this function took form.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2230
diff changeset
168 ;;; Code:
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169
100808
550d3029fe3b Require comint.
Chong Yidong <cyd@stupidchicken.com>
parents: 100171
diff changeset
170 (require 'comint)
26599
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
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
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
174 :link '(custom-manual "(autotype)Hippie Expand")
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (defvar he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (defvar he-search-string ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (defvar he-expand-list ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (defvar he-tried-table ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (defvar he-search-bw ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (defvar he-search-bufs ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
204 (defcustom hippie-expand-try-functions-list
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
205 '(try-complete-file-name-partially
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
206 try-complete-file-name
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
207 try-expand-all-abbrevs
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
208 try-expand-list
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
209 try-expand-line
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
210 try-expand-dabbrev
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
211 try-expand-dabbrev-all-buffers
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
212 try-expand-dabbrev-from-kill
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
213 try-complete-lisp-symbol-partially
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
214 try-complete-lisp-symbol)
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 "The list of expansion functions tried in order by `hippie-expand'.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 To change the behavior of `hippie-expand', remove, change the order of,
26599
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
217 or insert functions in this list."
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
218 :type '(repeat function)
e10a1d0deb4b Require comint when compiling.
Dave Love <fx@gnu.org>
parents: 26449
diff changeset
219 :group 'hippie-expand)
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 97142
diff changeset
223 "Non-nil makes `hippie-expand' output which function it is trying."
17634
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 97142
diff changeset
229 "Non-nil means tolerate trailing spaces in the abbreviation to expand."
21131
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
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 97142
diff changeset
235 "Non-nil means expand as symbols, i.e. syntax `_' is considered a letter."
21131
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
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 97142
diff changeset
241 "Non-nil means that narrowed buffers are widened during search."
21131
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 ()
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 97142
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
105939
a0f778f4a995 * term/x-win.el (x-gtk-stock-map):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 104552
diff changeset
254 (defcustom hippie-expand-ignore-buffers (list (purecopy "^ \\*.*\\*$") 'dired-mode)
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 97142
diff changeset
255 "A list specifying which buffers not to search (if not current).
5296
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 ()
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 97142
diff changeset
263 "A list specifying the only buffers to search (in addition to current).
21131
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
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 38436
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (defun hippie-expand (arg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 "Try to expand text before point, using multiple methods.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 The expansion functions in `hippie-expand-try-functions-list' are
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 tried in order, until a possible expansion is found. Repeated
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (interactive "P")
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
281 (if (or (not arg)
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (and (integerp arg) (> arg 0)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (let ((first (or (= he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (not (equal this-command last-command)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (if first
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (setq he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (setq he-tried-table nil)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (if arg
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (if (not first) (he-reset-string))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (setq arg 0))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (let ((i (max (+ he-num arg) 0)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (list (= he-num i)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (setq i (1+ i)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (setq he-num i))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (if (>= he-num (length hippie-expand-try-functions-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (setq he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (if first
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (message "No expansion found")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (message "No further expansions found"))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (setq he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (message "Undoing expansions"))))))
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
317
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 ;; Initializes the region to expand (to between BEG and END).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 ;; Resets the expanded region to its original contents.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 ;; An optional argument TRANS-CASE means that it is ok to transfer case
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 ;; from the abbreviation to the expansion if that is possible, and is
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 ;; enabled in the buffer.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (defun he-substitute-string (str &optional trans-case)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (let ((trans-case (and trans-case
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 (defun he-ordinary-case-p (str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (or (string= str (downcase str))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 ;; Check if STR is a member of LST.
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 38436
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ;; For the real hippie-expand enthusiast: A macro that makes it
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 ;; possible to use many functions like hippie-expand, but with
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 ;; different try-functions-lists.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 ;; Usage is for example:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 ;; (fset 'my-complete-file (make-hippie-expand-function
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 ;; '(try-complete-file-name-partially
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 ;; try-complete-file-name)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 ;; (fset 'my-complete-line (make-hippie-expand-function
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 ;; '(try-expand-line
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (defmacro make-hippie-expand-function (try-list &optional verbose)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 "Construct a function similar to `hippie-expand'.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 Make it use the expansion functions in TRY-LIST. An optional second
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 argument VERBOSE non-nil makes the function verbose."
26449
725d46ec6403 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 22250
diff changeset
421 `(function (lambda (arg)
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
422 ,(concat
26449
725d46ec6403 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 22250
diff changeset
423 "Try to expand text before point, using the following functions: \n"
725d46ec6403 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 22250
diff changeset
424 (mapconcat 'prin1-to-string (eval try-list) ", "))
725d46ec6403 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 22250
diff changeset
425 (interactive "P")
725d46ec6403 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 22250
diff changeset
426 (let ((hippie-expand-try-functions-list ,try-list)
725d46ec6403 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 22250
diff changeset
427 (hippie-expand-verbose ,verbose))
725d46ec6403 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 22250
diff changeset
428 (hippie-expand arg)))))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 ;;; Here follows the try-functions and their requisites:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (defun try-complete-file-name (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 "Try to complete text as a file name.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 string). It returns t if a new completion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (if (not old)
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
440 (progn
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (he-init-string (he-file-name-beg) (point))
97142
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94678
diff changeset
442 (let ((name-part (file-name-nondirectory he-search-string))
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94678
diff changeset
443 (dir-part (expand-file-name (or (file-name-directory
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 he-search-string) ""))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (if (not (he-string-member name-part he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (setq he-tried-table (cons name-part he-tried-table)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (if (and (not (equal he-search-string ""))
97142
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94678
diff changeset
448 (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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 name-part
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 dir-part)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 'string-lessp))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 (setq he-expand-list ())))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 (while (and he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (he-string-member (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (setq he-expand-list (cdr he-expand-list)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (if (null he-expand-list)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
97142
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94678
diff changeset
463 (file-name-directory 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
464 (car he-expand-list))))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (setq he-expand-list (cdr he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (defun try-complete-file-name-partially (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 "Try to complete text as a file name, as many characters as unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (let ((expansion ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (if (not old)
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
477 (progn
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (he-init-string (he-file-name-beg) (point))
97142
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94678
diff changeset
479 (let ((name-part (file-name-nondirectory he-search-string))
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94678
diff changeset
480 (dir-part (expand-file-name (or (file-name-directory
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 he-search-string) ""))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (if (and (not (equal he-search-string ""))
97142
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94678
diff changeset
483 (file-directory-p dir-part))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (setq expansion (file-name-completion name-part
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 dir-part)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (setq expansion ())))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
97142
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94678
diff changeset
496 (file-name-directory 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
497 expansion)))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
97142
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94678
diff changeset
503 (cond ((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
504 "-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
505 (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
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 "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
508
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (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
510 (let ((op (point)))
d3cc9cf799f8 (he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents: 17634
diff changeset
511 (save-excursion
d3cc9cf799f8 (he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents: 17634
diff changeset
512 (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
513 (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
514 op
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
515 (point)))))
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
516
97142
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94678
diff changeset
517 ;; Thanks go 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
518 ;; 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
519 (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
520 "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
521 (cond ((null dir-part) name-part)
104552
10c38084881d Remove code for defunct system-types emx, macos, mswindows,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
522 ((eq system-type 'ms-dos)
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
523 (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
524 (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
525 (= (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
526 (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
527 (concat dir-part name-part))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
528 (t
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
529 (concat dir-part name-part))))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
530
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (defun try-complete-lisp-symbol (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 "Try to complete word as an Emacs Lisp symbol.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 string). It returns t if a new completion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (if (not old)
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
537 (progn
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (he-init-string (he-lisp-symbol-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (if (not (he-string-member he-search-string he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (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
541 (setq he-expand-list
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 (and (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 (sort (all-completions he-search-string obarray
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 (function (lambda (sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (or (boundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (fboundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 (symbol-plist sym)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 'string-lessp)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (while (and he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (he-string-member (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (setq he-expand-list (cdr he-expand-list)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (if (null he-expand-list)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (progn
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
554 (if old (he-reset-string))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (he-substitute-string (car he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 (setq he-expand-list (cdr he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (defun try-complete-lisp-symbol-partially (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 "Try to complete as an Emacs Lisp symbol, as many characters as unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 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
564 returns t if a unique, possibly partial, completion is found, nil
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (let ((expansion ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (if (not old)
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
568 (progn
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (he-init-string (he-lisp-symbol-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (if (not (string= he-search-string ""))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
571 (setq expansion
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (try-completion he-search-string obarray
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (function (lambda (sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 (or (boundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 (fboundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 (symbol-plist sym)))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (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
578 (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
579 (he-string-member expansion he-tried-table))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (setq expansion ()))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (progn
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
584 (if old (he-reset-string))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (he-substitute-string expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 (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
591 (save-excursion
d3cc9cf799f8 (he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents: 17634
diff changeset
592 (skip-syntax-backward "w_")
d3cc9cf799f8 (he-file-name-beg): Don't trigger on parts of
Karl Heuer <kwzh@gnu.org>
parents: 17634
diff changeset
593 (point)))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 (defun try-expand-line (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 "Try to complete the current line to an entire line in the buffer.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 string). It returns t if a new completion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (let ((expansion ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (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
602 comint-use-prompt-regexp
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
603 comint-prompt-regexp)))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (he-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
607 (set-marker he-search-loc he-string-beg)
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (setq he-search-bw t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (if (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (save-excursion
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
612 (save-restriction
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
613 (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
614 (widen))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
615 ;; 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
616 (if he-search-bw
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
617 (progn
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
618 (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
619 (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
620 strip-prompt t))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
621 (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
622 (if (not expansion)
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
623 (progn
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
624 (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
625 (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
626
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
627 (if (not expansion) ; Then look forward.
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
628 (progn
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
629 (goto-char he-search-loc)
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
630 (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
631 strip-prompt nil))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
632 (set-marker he-search-loc (point)))))))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (progn
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
636 (if old (he-reset-string))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (defun try-expand-line-all-buffers (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 "Try to complete the current line, searching all other buffers.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 string). It returns t if a new completion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (let ((expansion ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (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
649 comint-use-prompt-regexp
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
650 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
651 (buf (current-buffer))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
652 (orig-case-fold-search case-fold-search))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (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
656 (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
657 (setq he-searched-n-bufs 0)
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
658 (set-marker he-search-loc 1 (car he-search-bufs))))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 (if (not (equal he-search-string ""))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
661 (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
662 (not expansion)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
663 (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
664 (< he-searched-n-bufs hippie-expand-max-buffers)))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (set-buffer (car he-search-bufs))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (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
667 (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
668 (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
669 (not (he-buffer-member hippie-expand-ignore-buffers))))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (save-excursion
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
671 (save-restriction
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
672 (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
673 (widen))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
674 (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
675 (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
676 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
677 comint-prompt-regexp))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
678 (setq expansion
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
679 (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
680 (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
681 strip-prompt nil)))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
682 (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
683 (if (not expansion)
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
684 (progn
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
685 (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
686 (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
687 (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
688 (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
689 (set-marker he-search-loc 1 (car he-search-bufs)))))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 (set-buffer buf)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 (progn
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
694 (if old (he-reset-string))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
700 (defun he-line-search (str strip-prompt reverse)
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (let ((result ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (while (and (not result)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (if reverse
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
704 (re-search-backward
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (he-line-search-regexp str strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 nil t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (re-search-forward
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (he-line-search-regexp str strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 nil t)))
26449
725d46ec6403 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 22250
diff changeset
710 (setq result (buffer-substring-no-properties (match-end 1)
725d46ec6403 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 22250
diff changeset
711 (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
712 (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
713 (setq result nil))) ; if already in table, ignore
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 result))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 (defun he-line-beg (strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (save-excursion
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
718 (if (re-search-backward (he-line-search-regexp "" strip-prompt)
111445
56b71cddc9c5 Replace still more end-of-line etc with line-end-position, etc.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
719 (line-beginning-position) t)
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (match-beginning 2)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 (defun he-line-search-regexp (pat strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 (if strip-prompt
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
725 (concat "\\(" comint-prompt-regexp "\\|^\\s-*\\)\\("
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (regexp-quote pat)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 "[^\n]*[^ \t\n]\\)")
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
728 (concat "^\\(\\s-*\\)\\("
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 (regexp-quote pat)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 "[^\n]*[^ \t\n]\\)")))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
732 (defun try-expand-list (old)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
733 "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
734 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
735 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
736 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
737 (let ((expansion ()))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
738 (if (not old)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
739 (progn
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
740 (he-init-string (he-list-beg) (point))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
741 (set-marker he-search-loc he-string-beg)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
742 (setq he-search-bw t)))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
743
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
744 (if (not (equal he-search-string ""))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
745 (save-excursion
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
746 (save-restriction
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
747 (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
748 (widen))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
749 ;; 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
750 (if he-search-bw
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
751 (progn
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
752 (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
753 (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
754 (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
755 (if (not expansion)
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
756 (progn
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
757 (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
758 (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
759
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
760 (if (not expansion) ; Then look forward.
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
761 (progn
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
762 (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
763 (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
764 (set-marker he-search-loc (point)))))))
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
765
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
766 (if (not expansion)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
767 (progn
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
768 (if old (he-reset-string))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
769 ())
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
770 (progn
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
771 (he-substitute-string expansion t)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
772 t))))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
773
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
774 (defun try-expand-list-all-buffers (old)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
775 "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
776 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
777 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
778 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
779 (let ((expansion ())
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
780 (buf (current-buffer))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
781 (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
782 (if (not old)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
783 (progn
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
784 (he-init-string (he-list-beg) (point))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
785 (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
786 (setq he-searched-n-bufs 0)
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
787 (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
788
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
789 (if (not (equal he-search-string ""))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
790 (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
791 (not expansion)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
792 (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
793 (< 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
794 (set-buffer (car he-search-bufs))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
795 (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
796 (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
797 (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
798 (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
799 (save-excursion
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
800 (save-restriction
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
801 (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
802 (widen))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
803 (goto-char he-search-loc)
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
804 (setq expansion
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
805 (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
806 (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
807 (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
808 (if (not expansion)
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
809 (progn
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
810 (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
811 (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
812 (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
813 (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
814 (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
815
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
816 (set-buffer buf)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
817 (if (not expansion)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
818 (progn
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
819 (if old (he-reset-string))
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
820 ())
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
821 (progn
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
822 (he-substitute-string expansion t)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
823 t))))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
824
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
825 (defun he-list-search (str reverse)
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
826 (let ((result ())
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
827 beg pos err)
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
828 (while (and (not result)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
829 (if reverse
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
830 (search-backward str nil t)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
831 (search-forward str nil t)))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
832 (setq pos (point))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
833 (setq beg (match-beginning 0))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
834 (goto-char beg)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
835 (setq err ())
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
836 (condition-case ()
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
837 (forward-list 1)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
838 (error (setq err t)))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
839 (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
840 (> (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
841 (setq err t))
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
842 (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
843 (progn
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
844 (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
845 (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
846 (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
847 (goto-char pos))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
848 result))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
849
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
850 (defun he-list-beg ()
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
851 (save-excursion
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
852 (condition-case ()
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
853 (backward-up-list 1)
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
854 (error ()))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
855 (point)))
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
856
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 (defun try-expand-all-abbrevs (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 "Try to expand word before point according to all abbrev tables.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 for subsequent calls (for further possible expansions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 string). It returns t if a new expansion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 (he-init-string (he-dabbrev-beg) (point))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
865 (setq he-expand-list
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 (and (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 (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
868 (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
869 (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
870 (eval sym)))))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
871 (append '(local-abbrev-table
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 global-abbrev-table)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 abbrev-table-name-list))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 (while (and he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 (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
876 (he-string-member (car he-expand-list) he-tried-table t)))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 (setq he-expand-list (cdr he-expand-list)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (if (null he-expand-list)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 (progn
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
880 (if old (he-reset-string))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (progn
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
883 (he-substitute-string (car he-expand-list) t)
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 (setq he-expand-list (cdr he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 (defun try-expand-dabbrev (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 "Try to expand word \"dynamically\", searching the current buffer.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 for subsequent calls (for further possible expansions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 string). It returns t if a new expansion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 (let ((expansion ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 (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
896 (set-marker he-search-loc he-string-beg)
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 (setq he-search-bw t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 (if (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 (save-excursion
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
901 (save-restriction
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
902 (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
903 (widen))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
904 ;; 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
905 (if he-search-bw
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
906 (progn
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
907 (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
908 (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
909 (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
910 (if (not expansion)
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
911 (progn
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
912 (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
913 (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
914
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
915 (if (not expansion) ; Then look forward.
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
916 (progn
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
917 (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
918 (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
919 (set-marker he-search-loc (point)))))))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
920
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 (progn
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
923 (if old (he-reset-string))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 (defun try-expand-dabbrev-all-buffers (old)
106377
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
930 "Try to expand word \"dynamically\", searching all other buffers.
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 for subsequent calls (for further possible expansions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 string). It returns t if a new expansion is found, nil otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 (let ((expansion ())
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
935 (buf (current-buffer))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
936 (orig-case-fold-search case-fold-search))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 (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
940 (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
941 (setq he-searched-n-bufs 0)
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
942 (set-marker he-search-loc 1 (car he-search-bufs))))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 (if (not (equal he-search-string ""))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
945 (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
946 (not expansion)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
947 (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
948 (< he-searched-n-bufs hippie-expand-max-buffers)))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (set-buffer (car he-search-bufs))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 (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
951 (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
952 (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
953 (not (he-buffer-member hippie-expand-ignore-buffers))))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 (save-excursion
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
955 (save-restriction
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
956 (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
957 (widen))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
958 (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
959 (setq expansion
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
960 (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
961 (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
962 (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
963 (if (not expansion)
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
964 (progn
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
965 (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
966 (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
967 (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
968 (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
969 (set-marker he-search-loc 1 (car he-search-bufs)))))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971 (set-buffer buf)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 (progn
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
974 (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
975 ())
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
976 (progn
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
977 (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
978 t))))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
979
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
980 ;; 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
981 ;; suggested this one.
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
982 (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
983 "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
984 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
985 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
986 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
987 (let ((expansion ())
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
988 (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
989 'visible t)))
106377
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
990 (unless old
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
991 (he-init-string (he-dabbrev-beg) (point))
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
992 (setq he-search-window (selected-window))
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
993 (set-marker he-search-loc
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
994 (window-start he-search-window)
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
995 (window-buffer he-search-window)))
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
996
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
997 (while (and (not (equal he-search-string ""))
106377
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
998 (marker-position he-search-loc)
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
999 (not expansion))
105994
009383a57ce8 * x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105939
diff changeset
1000 (with-current-buffer (marker-buffer he-search-loc)
106377
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1001 (save-excursion
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1002 (goto-char he-search-loc)
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1003 (setq expansion (he-dabbrev-search he-search-string ()
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1004 (window-end he-search-window)))
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1005 (if (and expansion
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1006 (eq (marker-buffer he-string-beg) (current-buffer))
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1007 (eq (marker-position he-string-beg) (match-beginning 0)))
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1008 (setq expansion
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1009 (he-dabbrev-search he-search-string ()
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1010 (window-end he-search-window))))
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1011 (set-marker he-search-loc (point) (current-buffer))))
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1012 (unless expansion
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1013 (setq he-search-window (next-window he-search-window nil flag))
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1014 (if (eq he-search-window (selected-window))
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1015 (set-marker he-search-loc nil)
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1016 (set-marker he-search-loc (window-start he-search-window)
10ceddf3698e (try-expand-dabbrev-visible): Preserve point in the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105994
diff changeset
1017 (window-buffer he-search-window)))))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
1018
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1019 (if (not expansion)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1020 (progn
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1021 (if old (he-reset-string))
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1027 (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
1028 (let ((result ())
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
1029 (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
1030 (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
1031 ((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
1032 (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
1033 (t
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
1034 (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
1035 "\\(\\sw\\|\\s_\\)+")))))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
1036 (while (and (not result)
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 (if reverse
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1038 (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
1039 (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
1040 (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
1041 (match-end 0)))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
1042 (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
1043 (> (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
1044 (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
1045 '(?_ ?w)))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1046 (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
1047 (setq result nil))) ; ignore if bad prefix or already in table
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 result))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 (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
1051 (let ((op (point)))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1052 (save-excursion
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
1053 (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
1054 (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
1055 (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
1056 "w_" "w"))
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
1057 0)
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1058 op
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1059 (point)))))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1060
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1061 (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
1062 "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
1063 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
1064 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
1065 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
1066 (let ((expansion ()))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1067 (if (not old)
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
1068 (progn
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1069 (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
1070 (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
1071 (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
1072 kill-ring))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1073 (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
1074 (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
1075 (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
1076 (if (not expansion)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1077 (progn
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1078 (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
1079 ())
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1080 (progn
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1081 (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
1082 t))))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1083
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1084 (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
1085 (let ((result ())
21131
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
1086 (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
1087 (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
1088 ((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
1089 (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
1090 (t
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
1091 (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
1092 "\\(\\sw\\|\\s_\\)+"))))
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1093 (killstr (car he-expand-list)))
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
1094 (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
1095 he-expand-list)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1096 (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
1097 (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
1098 (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
1099 (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
1100 (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
1101 (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
1102 (> (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
1103 (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
1104 '(?_ ?w)))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1105 (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
1106 (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
1107 (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
1108 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 (progn
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
1110 (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
1111 (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
1112 (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
1113 result))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1114
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1115 (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
1116 "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
1117 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
1118 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
1119 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
1120 (let ((expansion ()))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1121 (if (not old)
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
1122 (progn
13207
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1123 (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
1124 (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
1125 (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
1126 (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
1127 (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
1128 kill-ring))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1129 (setq he-search-loc2 ())))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1130 (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
1131 (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
1132 (if (not expansion)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1133 (progn
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1134 (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
1135 ())
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1136 (progn
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1137 (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
1138 t))))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1139
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1140 (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
1141 (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
1142 (result ())
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1143 (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
1144 (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
1145 (pos -1))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1146 (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
1147 he-expand-list)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1148 (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
1149 (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
1150 (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
1151 (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
1152 he-search-loc2)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1153 (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
1154 (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
1155 (save-excursion
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1156 (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
1157 (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
1158 (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
1159 (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
1160 (- (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
1161 (progn
e4acb217b4af (hippie-expand-dabbrev-skip-space): Renamed `he-dabbrev-skip-space'.
Richard M. Stallman <rms@gnu.org>
parents: 18584
diff changeset
1162 (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
1163 (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
1164 (if (and result
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1165 (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
1166 (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
1167 (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
1168 he-expand-list)
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1169 (progn
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 42205
diff changeset
1170 (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
1171 (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
1172 (setq pos -1))))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1173 result))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1174
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1175 (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
1176 (let ((op (point)))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1177 (save-excursion
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1178 (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
1179 (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
1180 op
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1181 (point)))))
2b541cc4cd97 (hippie-expand): Removed bug - don't undo from another buffer.
Richard M. Stallman <rms@gnu.org>
parents: 7639
diff changeset
1182
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183
4130
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
1184 (provide 'hippie-exp)
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
1185
e5aee6a3bb75 * hippie-exp.el: Renamed from hippie.el.
Jim Blandy <jimb@redhat.com>
parents: 2233
diff changeset
1186 ;;; hippie-exp.el ends here