annotate lisp/hippie-exp.el @ 2566:4f201a4ab030

(define-function): Changed name back to defalisaases to get things in a known-good state.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Fri, 23 Apr 1993 03:43:33 +0000
parents fb0ed5a1d0f3
children e5aee6a3bb75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2230
6314334d7c2b Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1737
diff changeset
1 ;;; hippie.el --- expand a word trying various ways to find its expansion.
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>
6314334d7c2b Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1737
diff changeset
4 ;; Keywords: extensions
6314334d7c2b Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1737
diff changeset
5
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Copyright (C) 1992 Free Software Foundation, Inc.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
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 ;; 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
11 ;; 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
12 ;; the Free Software Foundation; either version 2, or (at your option)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; 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
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; 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
21 ;; 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
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Last change: 4 January 1993
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.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; If the variable `hippie-expand-verbose' is non-nil, `hippie-expand'
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; 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
41 ;; 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
42 ;; time).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; See also the macro `make-hippie-expand-function' below.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; A short description of the current try-functions in this file:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; `try-complete-file-name' : very convenient to have in any buffer,
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; 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
48 ;; through all possible completions instead of just completing as
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; much as is unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;; `try-complete-file-name-partially' : To insert in the list just
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; 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
52 ;; a file name completed only as many characters as is unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; (NOTE: Not by default in `hippie-expand-try-functions-list'.)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; `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
55 ;; Otherwise it looks through all abbrev-tables, starting with
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; the local followed by the global.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; `try-expand-line' : Searches the buffer for an entire line that
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; begins exactly as the current line. Convenient sometimes, for
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; example as a substitute for (or complement to) the history
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; list in shell-like buffers. Remove it if you find it confusing.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; `try-expand-line-all-buffers' : Like `try-expand-line' but searches
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; in all buffers (except the current). (This may be a little
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; slow, don't use it unless you are really fond of `hippie-expand'.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; NOTE: Not by default in hippie-expand-try-functions-list.)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; `try-expand-dabbrev' : works exactly as dabbrev-expand (but of
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; course in a way compatible with the other try-functions).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; `try-expand-dabbrev-all-buffers' : perhaps the most useful of them,
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; like `dabbrev-expand' but searches all Emacs buffers (except the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; current) for matching words. (No, I don't find this one
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; particularly slow.)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; `try-complete-lisp-symbol' : like `lisp-complete-symbol', but goes
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; through all possibilities instead of completing what is unique.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; Might be tedious (usually a lot of possible completions) and
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; since its function is much like `lisp-complete-symbol', which
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; 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
76 ;; `try-complete-lisp-symbol-partially' : To insert in the list just
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; before `try-complete-lisp-symbol' for those who first want to get
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; completion of what is unique in the name. (NOTE: Not by
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;; default in hippie-expand-try-functions-list.)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; To write new try-functions, consider the following:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; 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
83 ;; 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
84 ;; same string to complete. The first time the function has to
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; extract the string before point to complete, and substitute the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;; first completion alternative for it. On following calls it has to
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;; substitute the next possible completion for the last tried string.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; 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
89 ;; possible completions. When there are no more alternatives it has
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;; to restore the text before point to its original contents, and
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ;; return nil (don't beep or message or anything).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ;; The try-function can (should) use the following functions:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; `he-init-string' : Initializes the text to substitute to the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;; contents of the region BEGIN to END. Also sets the variable
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ;; `he-search-string' to the text to expand.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; `he-substitute-string' : substitutes STR into the region
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ;; initialized with `he-init-string'. (An optional second argument
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ;; TRANS-CASE non-nil, means transfer of case from the abbreviation
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; 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
100 ;; `he-reset-string' : Resets the initialized region to its original
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;; contents.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;; 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
103 ;; all tried expansions so far. The try-function can check this
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; variable to see whether an expansion has already been tried
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;; (hint: `he-string-member'), and add its own tried expansions to it.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;; KNOWN BUGS
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;; It may happen that some completion suggestion occurs twice, in
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ;; 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
112 ;; because different try-functions may try to complete different
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; lengths of text, and thus put different amounts of the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ;; text in `he-try-table'. Anyway this seems to occur seldom enough not
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;; to be too disturbing. Also it should NOT bee possible for the
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ;; opposite situation to occur, that `hippie-expand' misses some
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; suggestion because it thinks it has already tried it.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;; ACKNOWLEDGEMENT
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; 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
123 ;; of this function took form.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; I am also grateful to all those who have given me suggestions on
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; how to improve it.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2230
diff changeset
128 ;;; Code:
1737
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (defvar he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (defvar he-string-beg ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (defvar he-string-end ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (defvar he-search-string ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (defvar he-expand-list ())
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 (defvar he-tried-table ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (defvar he-search-loc ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (defvar he-search-bw ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (defvar he-search-bufs ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (defvar hippie-expand-try-functions-list '(try-complete-file-name
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 try-expand-all-abbrevs
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 try-expand-line
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 try-expand-dabbrev
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 try-expand-dabbrev-all-buffers
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 try-complete-lisp-symbol)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 "The list of expansion functions tried in order by `hippie-expand'.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 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
156 or insert functions in this list.")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (defvar hippie-expand-verbose t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 "*Non-nil makes `hippie-expand' output which function it is trying.")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (defun hippie-expand (arg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 "Try to expand text before point, using multiple methods.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 The expansion functions in `hippie-expand-try-functions-list' are
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 tried in order, until a possible expansion is found. Repeated
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 application of `hippie-expand' inserts successively possible
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 expansions.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 With a positive numeric argument, jumps directly to the ARG next
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 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
169 undoes the expansion."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (interactive "P")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (if (or (not arg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (and (integerp arg) (> arg 0)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (let ((first (or (= he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (not (equal this-command last-command)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (if first
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (setq he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (setq he-tried-table nil)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (if arg
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (if (not first) (he-reset-string))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (setq arg 0))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (let ((i (max (+ he-num arg) 0)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (while (not (or (>= i (length hippie-expand-try-functions-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (apply (nth i hippie-expand-try-functions-list)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (list (= he-num i)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (setq i (1+ i)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (setq he-num i))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (if (>= he-num (length hippie-expand-try-functions-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (setq he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (if first
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (message "No expansion found")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (message "No further expansions found"))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (ding))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (if hippie-expand-verbose
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (message (concat "Using "
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (prin1-to-string (nth he-num
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 hippie-expand-try-functions-list)))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (if (>= he-num 0)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (setq he-num -1)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (if hippie-expand-verbose
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (message "Undoing expansions"))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 ;; Initializes the region to expand (to between BEG and END).
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (defun he-init-string (beg end)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (setq he-string-beg beg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (setq he-string-end end)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (setq he-search-string (buffer-substring beg end)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 ;; Resets the expanded region to its original contents.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (defun he-reset-string ()
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (delete-region he-string-beg he-string-end)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (insert he-search-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (setq he-string-end (point)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 ;; Substitutes an expansion STR into the correct region (the region
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 ;; initialized with `he-init-string').
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 ;; 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
221 ;; 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
222 ;; enabled in the buffer.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (defun he-substitute-string (str &optional trans-case)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (let ((trans-case (and trans-case
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 case-replace
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 case-fold-search
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (he-transfer-case-ok str he-search-string))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (goto-char he-string-beg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (search-forward he-search-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (replace-match (if trans-case (downcase str) str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (not trans-case)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 'literal)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (setq he-string-end (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (defun he-ordinary-case-p (str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (or (string= str (downcase str))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (string= str (upcase str))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (string= str (capitalize str))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (defun he-transfer-case-ok (to-str from-str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (and (not (string= from-str (substring to-str 0 (length from-str))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 ;; otherwise transfer is not needed (and this also solves
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 ;; some obscure situations)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (he-ordinary-case-p to-str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 ;; otherwise case may be significant
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (he-ordinary-case-p from-str)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 ;; otherwise replace-match wont know what to do
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 ))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 ;; Check if STR is a member of LST.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 ;; Ignore case if `case-replace' and `case-fold-search' are both t.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (defun he-string-member (str lst)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (while (and lst
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (not
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (if (and case-fold-search case-replace)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (string= (downcase (car lst)) (downcase str))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (string= (car lst) str))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (setq lst (cdr lst)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 lst)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 ;; For the real hippie-expand enthusiast: A macro that makes it
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 ;; possible to use many functions like hippie-expand, but with
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 ;; different try-functions-lists.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 ;; Usage is for example:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 ;; (fset 'my-complete-file (make-hippie-expand-function
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 ;; '(try-complete-file-name-partially
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 ;; try-complete-file-name)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 ;; (fset 'my-complete-line (make-hippie-expand-function
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 ;; '(try-expand-line
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 ;; try-expand-line-all-buffers)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 ;;
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (defmacro make-hippie-expand-function (try-list &optional verbose)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 "Construct a function similar to `hippie-expand'.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 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
276 argument VERBOSE non-nil makes the function verbose."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (` '(lambda (arg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (, (concat
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 "Try to expand text before point, using the following functions: \n"
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (mapconcat 'prin1-to-string (eval try-list) ", ")))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (interactive "P")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (let ((hippie-expand-try-functions-list (, try-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (hippie-expand-verbose (, verbose)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (hippie-expand arg)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 ;;; Here follows the try-functions and their requisites:
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (defun try-complete-file-name (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 "Try to complete text as a file name.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 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
292 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 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
294 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (he-init-string (he-file-name-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (let ((name-part (file-name-nondirectory he-search-string))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (dir-part (expand-file-name (or (file-name-directory
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 he-search-string) ""))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (if (not (he-string-member name-part he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (setq he-tried-table (cons name-part he-tried-table)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (if (and (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (file-directory-p dir-part))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (setq he-expand-list (sort (file-name-all-completions
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 name-part
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 dir-part)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 'string-lessp))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (setq he-expand-list ())))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (while (and he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (he-string-member (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (setq he-expand-list (cdr he-expand-list)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (if (null he-expand-list)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (let ((filename (concat (file-name-directory he-search-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (car he-expand-list))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (he-substitute-string filename)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (setq he-tried-table (cons (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (setq he-expand-list (cdr he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (defun try-complete-file-name-partially (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 "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
326 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
327 returns t if a unique, possibly partial, completion is found, nil
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (let ((expansion ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (he-init-string (he-file-name-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (let ((name-part (file-name-nondirectory he-search-string))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (dir-part (expand-file-name (or (file-name-directory
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 he-search-string) ""))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (if (and (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (file-directory-p dir-part))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (setq expansion (file-name-completion name-part
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 dir-part)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (if (or (eq expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (string= expansion name-part))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (setq expansion ())))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (let ((filename (concat (file-name-directory he-search-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 expansion)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (he-substitute-string filename)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (defun he-file-name-beg ()
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (let ((skips "-a-zA-Z0-9_./~^#$"))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (skip-chars-backward skips)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (defun try-complete-lisp-symbol (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 "Try to complete word as an Emacs Lisp symbol.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 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
363 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 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
365 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (he-init-string (he-lisp-symbol-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (if (not (he-string-member he-search-string he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (setq he-tried-table (cons he-search-string he-tried-table)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (setq he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (and (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (sort (all-completions he-search-string obarray
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (function (lambda (sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (or (boundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (fboundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (symbol-plist sym)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 'string-lessp)))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (while (and he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (he-string-member (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (setq he-expand-list (cdr he-expand-list)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (if (null he-expand-list)
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-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (he-substitute-string (car he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (setq he-tried-table (cons (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (setq he-expand-list (cdr he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (defun try-complete-lisp-symbol-partially (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 "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
393 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
394 returns t if a unique, possibly partial, completion is found, nil
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 otherwise."
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (let ((expansion ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (he-init-string (he-lisp-symbol-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (if (not (string= he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (setq expansion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (try-completion he-search-string obarray
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (function (lambda (sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (or (boundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (fboundp sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (symbol-plist sym)))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (if (or (eq expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (string= expansion he-search-string))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (setq expansion ()))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (he-substitute-string expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (defun he-lisp-symbol-beg ()
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (let ((skips "-a-zA-Z0-9_."))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (skip-chars-backward skips)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (defun try-expand-line (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 "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
428 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
429 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 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
431 (let ((expansion ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (strip-prompt (and (get-buffer-process (current-buffer))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 shell-prompt-pattern)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (he-init-string (he-line-beg strip-prompt) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (setq he-search-loc he-string-beg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (setq he-search-bw t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (if (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 ;; Try looking backward unless inhibited.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (if he-search-bw
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (setq expansion (he-line-search he-search-string
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 strip-prompt t))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (setq he-search-loc (point-marker))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 (setq he-search-loc he-string-end)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 (setq he-search-bw ())))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (if (not expansion) ; Then look forward.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (setq expansion (he-line-search he-search-string
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 strip-prompt nil))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (setq he-search-loc (point-marker))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (defun try-expand-line-all-buffers (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 "Try to complete the current line, searching all other buffers.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 The argument OLD has to be nil the first call of this function, and t
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 for subsequent calls (for further possible completions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 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
475 (let ((expansion ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (strip-prompt (and (get-buffer-process (current-buffer))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 shell-prompt-pattern))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (buf (current-buffer)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (he-init-string (he-line-beg strip-prompt) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (setq he-search-loc 0)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (setq he-search-bufs (buffer-list))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (if (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (while (and he-search-bufs (not expansion))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (set-buffer (car he-search-bufs))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (if (and (not (eq (current-buffer) buf))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (not (eq major-mode 'dired-mode)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 ;; dont search dired buffers
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (setq expansion (he-line-search he-search-string
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 strip-prompt nil))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (setq he-search-loc (point-marker))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (if expansion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (setq he-search-loc 0)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (setq he-search-bufs (cdr he-search-bufs))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (set-buffer buf)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (defun he-line-search (str strip-prompt reverse)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (let ((result ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (while (and (not result)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (if reverse
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (re-search-backward
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (he-line-search-regexp str strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 nil t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 (re-search-forward
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (he-line-search-regexp str strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 nil t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (setq result (buffer-substring (match-beginning 2) (match-end 2)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 (if (he-string-member result he-tried-table)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 (setq result nil))) ; if already in table, ignore
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 result))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 (defun he-line-beg (strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (end-of-line)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 (if (re-search-backward (he-line-search-regexp "" strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 (save-excursion (beginning-of-line)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (point)) t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 (match-beginning 2)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 (beginning-of-line)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (defun he-line-search-regexp (pat strip-prompt)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 (if strip-prompt
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (concat "\\(" shell-prompt-pattern "\\|^\\s-*\\)\\("
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (regexp-quote pat)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 "[^\n]*[^ \t\n]\\)")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 (concat "^\\(\\s-*\\)\\("
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 (regexp-quote pat)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 "[^\n]*[^ \t\n]\\)")))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (defun try-expand-all-abbrevs (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 "Try to expand word before point according to all abbrev tables.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 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
548 for subsequent calls (for further possible expansions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 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
550 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (he-init-string (he-dabbrev-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (setq he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (and (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 (mapcar (function (lambda (sym)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (abbrev-expansion he-search-string
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (eval sym))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 (append '(local-abbrev-table
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 global-abbrev-table)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 abbrev-table-name-list))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (while (and he-expand-list
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (or (not (car he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (he-string-member (car he-expand-list) he-tried-table)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (setq he-expand-list (cdr he-expand-list)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (if (null he-expand-list)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (he-substitute-string (car he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 (setq he-tried-table (cons (car he-expand-list) he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (setq he-expand-list (cdr he-expand-list))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 (defun try-expand-dabbrev (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 "Try to expand word \"dynamically\", searching the current buffer.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 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
578 for subsequent calls (for further possible expansions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 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
580 (let ((expansion ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (he-init-string (he-dabbrev-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (setq he-search-loc he-string-beg)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (setq he-search-bw t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (if (not (equal he-search-string ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 ;; Try looking backward unless inhibited.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 (if he-search-bw
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (setq expansion (he-dab-search he-search-string t))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 (setq he-search-loc (point-marker))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 (setq he-search-loc he-string-end)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 (setq he-search-bw ())))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (if (not expansion) ; Then look forward.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (setq expansion (he-dab-search he-search-string nil))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (setq he-search-loc (point-marker))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (if (not expansion)
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-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 (defun try-expand-dabbrev-all-buffers (old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 "Tries to expand word \"dynamically\", searching all other buffers.
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 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
618 for subsequent calls (for further possible expansions of the same
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 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
620 (let ((expansion ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 (buf (current-buffer)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 (if (not old)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 (he-init-string (he-dabbrev-beg) (point))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 (setq he-search-loc 0)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 (setq he-search-bufs (buffer-list))))
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 ""))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (while (and he-search-bufs (not expansion))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 (set-buffer (car he-search-bufs))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (if (and (not (eq (current-buffer) buf))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 (not (eq major-mode 'dired-mode)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 ;; dont search dired buffers
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (goto-char he-search-loc)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 (setq expansion (he-dab-search he-search-string nil))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (setq he-search-loc (point-marker))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (if expansion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 (setq he-tried-table (cons expansion he-tried-table))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 (setq he-search-loc 0)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (setq he-search-bufs (cdr he-search-bufs))))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 (set-buffer buf)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 (if (not expansion)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (he-reset-string)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 ())
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 (progn
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (he-substitute-string expansion t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 t))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (defun he-dab-search-regexp (pat)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 (concat "\\b" (regexp-quote pat)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 "\\(\\sw\\|\\s_\\)+"))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (defun he-dab-search (pattern reverse)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 (let ((result ()))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 (while (and (not result)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 (if reverse
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (re-search-backward (he-dab-search-regexp pattern)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 nil t)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (re-search-forward (he-dab-search-regexp pattern)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 nil t)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (setq result (buffer-substring (match-beginning 0) (match-end 0)))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (if (he-string-member result he-tried-table)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (setq result nil))) ; if already in table, ignore
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 result))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (defun he-dabbrev-beg ()
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (let ((skips "-a-zA-Z0-9_."))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (save-excursion
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (skip-chars-backward skips)
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 (skip-chars-forward "-_.")
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 (point))))
d7e9186edefa entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676
2230
6314334d7c2b Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1737
diff changeset
677 ;;; hippie.el ends here