annotate lisp/hippie-exp.el @ 21896:ff66bfc5d801

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