annotate lisp/hippie-exp.el @ 13449:2e9306561b80

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