Mercurial > emacs
annotate lisp/dabbrev.el @ 13553:fb12156faaf5
(mark_object): Don't overwrite original argument value.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 15 Nov 1995 17:42:44 +0000 |
parents | 3691c5bda8d2 |
children | 187735b53d52 |
rev | line source |
---|---|
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
1 ;;; dabbrev.el --- dynamic abbreviation package |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
2 ;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
3 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
4 ;; Author: Don Morrison |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
5 ;; Maintainer: Lars Lindberg <Lars.Lindberg@sypro.cap.se> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
6 ;; Created: 16 Mars 1992 |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
7 ;; Lindberg's last update version: 5.7 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
8 ;; Keywords: abbrev expand completion |
267 | 9 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
10 ;; This program is free software; you can redistribute it and/or modify |
267 | 11 ;; it under the terms of the GNU General Public License as published by |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
12 ;; the Free Software Foundation; either version 2 of the License, or |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
13 ;; (at your option) any later version. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
14 ;; |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
15 ;; This program is distributed in the hope that it will be useful, |
267 | 16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
19 ;; |
267 | 20 ;; You should have received a copy of the GNU General Public License |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
21 ;; along with this program; if not, write to the Free Software |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
22 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
267 | 23 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
793
diff
changeset
|
24 ;;; Commentary: |
267 | 25 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
26 ;; The purpose with this package is to let you write just a few |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
27 ;; characters of words you've written earlier to be able to expand |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
28 ;; them. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
29 ;; |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
30 ;; To expand a word, just put the point right after the word and press |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
31 ;; M-/ (dabbrev-expand) or M-C-/ (dabbrev-completion). |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
32 ;; |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
33 ;; Check out the customizable variables below to learn about all the |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
34 ;; features of this package. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
35 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
36 ;;; Hints and tips for major modes writers: |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
37 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
38 ;; Recommended values C/Lisp etc text |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
39 ;; dabbrev-case-fold-search nil t |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
40 ;; dabbrev-case-replace nil t |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
41 ;; |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
42 ;; Set the variables you want special for your mode like this: |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
43 ;; (set (make-local-variable 'dabbrev-case-replace) nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
44 ;; Then you don't interfer with other modes. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
45 ;; |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
46 ;; If your mode handles buffers that refers to other buffers |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
47 ;; (i.e. compilation-mode, gud-mode), then try to set |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
48 ;; `dabbrev-select-buffers-function' or `dabbrev-friend-buffer-function' |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
49 ;; to a function that point out those buffers. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
50 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
51 ;; Same goes for major-modes that are connected to other modes. There |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
52 ;; are for instance a number of mail-modes. One for reading, one for |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
53 ;; creating a new mail etc. Maybe those should be connected. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
54 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
55 ;; Example for GNUS (when we write a reply, we want dabbrev to look in |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
56 ;; the article for expansion): |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
57 ;; (set (make-local-variable 'dabbrev-friend-buffer-function) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
58 ;; (lambda (buffer) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
59 ;; (save-excursion |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
60 ;; (set-buffer buffer) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
61 ;; (memq major-mode '(news-reply-mode gnus-article-mode))))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
62 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
63 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
64 ;; Known bugs and limitations. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
65 ;; - Possible to do several levels of `dabbrev-completion' in the |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
66 ;; minibuffer. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
67 ;; - dabbrev-completion doesn't handle resetting the globals variables |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
68 ;; right. It resets them after finding the abbrev. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
69 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
70 ;; Future enhancements |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
71 ;; - Check the tags-files? Like tags-complete? |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
72 ;; - Add the possibility of searching both forward and backward to |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
73 ;; the nearest expansion. |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
74 ;; - Check the kill-ring when everything else fails. (Maybe something |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
75 ;; for hippie-expand?). [Bng] <boris@cs.rochester.edu> |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
76 |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
77 ;;; These people gave suggestions: |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
78 ;; [hymie] Hyman Rosen <marks!hymie@jyacc.jyacc.com> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
79 ;; [burgett] Steve Burgett <burgett@bizet.eecs.berkeley.edu> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
80 ;; [jules] Julian Gosnell <jules@x.co.uk> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
81 ;; [kifer] Michael Kifer <kifer@sbcs.sunysb.edu> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
82 ;; [ake] Ake Stenhoff <extaksf@aom.ericsson.se> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
83 ;; [alon] Alon Albert <al%imercury@uunet.uu.net> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
84 ;; [tromey] Tom Tromey <tromey@busco.lanl.gov> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
85 ;; [Rolf] Rolf Schreiber <rolf@mathematik.uni-stuttgart.de> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
86 ;; [Petri] Petri Raitio <per@tekla.fi> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
87 ;; [ejb] Jay Berkenbilt <ejb@ERA.COM> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
88 ;; [hawley] Bob Hawley <rth1@quartet.mt.att.com> |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
89 ;; ... and to all the people who have participated in the beta tests. |
267 | 90 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
793
diff
changeset
|
91 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
793
diff
changeset
|
92 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
93 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
94 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
95 ;;; Customization variables |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
96 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
97 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
98 (defvar dabbrev-backward-only nil |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
99 "*If non-nil, `dabbrev-expand' only looks backwards.") |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
100 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
101 (defvar dabbrev-limit nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
102 "*Limits region searched by `dabbrev-expand' to this many chars away.") |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
103 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
104 (defvar dabbrev-abbrev-skip-leading-regexp nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
105 "*Regexp for skipping leading characters of an abbreviation. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
106 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
107 Example: Set this to \"\\\\$\" for programming languages |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
108 in which variable names may appear with or without a leading `$'. |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
109 (For example, in Makefiles.) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
110 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
111 Set this to nil if no characters should be skipped.") |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
112 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
113 ;; I recommend that you set this to nil. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
114 (defvar dabbrev-case-fold-search 'case-fold-search |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
115 "*Non-nil if dabbrev searches should ignore case. |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
116 A value of nil means case is significant. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
117 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
118 The value of this variable is an expression; it is evaluated |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
119 and the resulting value determines the decision. |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
120 For example: setting this to `case-fold-search' means evaluate that |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
121 variable to see whether its value is nil.") |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
122 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
123 (defvar dabbrev-upcase-means-case-search nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
124 "*The significance of an uppercase character in an abbreviation. |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
125 nil means case fold search, non-nil means case sensitive search. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
126 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
127 This variable has an effect only when the value of |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
128 `dabbrev-case-fold-search' evaluates to t.") |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
129 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
130 ;; I recommend that you set this to nil. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
131 (defvar dabbrev-case-replace 'case-replace |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
132 "*Non-nil means dabbrev should preserve case when expanding the abbreviation. |
13501
3691c5bda8d2
(dabbrev-case-replace): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13257
diff
changeset
|
133 More precisely, it preserves the case pattern of the abbreviation as you |
3691c5bda8d2
(dabbrev-case-replace): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13257
diff
changeset
|
134 typed it--as opposed to the case pattern of the expansion that is copied. |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
135 The value of this variable is an expression; it is evaluated |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
136 and the resulting value determines the decision. |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
137 For example, setting this to `case-replace' means evaluate that |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
138 variable to see if its value is t or nil. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
139 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
140 This variable has an effect only when the value of |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
141 `dabbrev-case-fold-search' evaluates to t.") |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
142 |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
143 (defvar dabbrev-abbrev-char-regexp nil |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
144 "*Regexp to recognize a character in an abbreviation or expansion. |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
145 This regexp will be surrounded with \\\\( ... \\\\) when actually used. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
146 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
147 Set this variable to \"\\\\sw\" if you want ordinary words or |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
148 \"\\\\sw\\\\|\\\\s_\" if you want symbols (including characters whose |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
149 syntax is \"symbol\" as well as those whose syntax is \"word\". |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
150 |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
151 The value nil has a special meaning: the abbreviation is from point to |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
152 previous word-start, but the search is for symbols. |
267 | 153 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
154 For instance, if you are programming in Lisp, `yes-or-no-p' is a symbol, |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
155 while `yes', `or', `no' and `p' are considered words. If this |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
156 variable is nil, then expanding `yes-or-no-' looks for a symbol |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
157 starting with or containing `no-'. If you set this variable to |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
158 \"\\\\sw\\\\|\\\\s_\", that expansion looks for a symbol starting with |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
159 `yes-or-no-'. Finally, if you set this variable to \"\\\\sw\", then |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
160 expanding `yes-or-no-' signals an error because `-' is not part of a word; |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
161 but expanding `yes-or-no' looks for a word starting with `no'. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
162 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
163 The recommended value is \"\\\\sw\\\\|\\\\s_\".") |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
164 |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
165 (defvar dabbrev-check-all-buffers t |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
166 "*Non-nil means dabbrev package should search *all* buffers. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
167 |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
168 Dabbrev always searches the current buffer first. Then, if |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
169 `dabbrev-check-other-buffers' says so, it searches the buffers |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
170 designated by `dabbrev-select-buffers-function'. |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
171 |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
172 Then, if `dabbrev-check-all-buffers' is non-nil, dabbrev searches |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
173 all the other buffers.") |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
174 |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
175 (defvar dabbrev-check-other-buffers t |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
176 "*Should \\[dabbrev-expand] look in other buffers?\ |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
177 |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
178 nil: Don't look in other buffers. |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
179 t: Also look for expansions in the buffers pointed out by |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
180 `dabbrev-select-buffers-function'. |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
181 Anything else: When we can't find any more expansions in |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
182 the current buffer, then ask the user whether to look in other |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
183 buffers too. |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
184 |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
185 The default value is t.") |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
186 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
187 ;; I guess setting this to a function that selects all C- or C++- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
188 ;; mode buffers would be a good choice for a debugging buffer, |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
189 ;; when debugging C- or C++-code. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
190 (defvar dabbrev-select-buffers-function 'dabbrev--select-buffers |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
191 "A function that selects buffers that should be searched by dabbrev. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
192 The function should take no arguments and return a list of buffers to |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
193 search for expansions. Have a look at `dabbrev--select-buffers' for |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
194 an example. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
195 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
196 A mode setting this variable should make it buffer local.") |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
197 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
198 (defvar dabbrev-friend-buffer-function 'dabbrev--same-major-mode-p |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
199 "*A function to decide whether dabbrev should search OTHER-BUFFER. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
200 The function should take one argument, OTHER-BUFFER, and return |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
201 non-nil if that buffer should be searched. Have a look at |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
202 `dabbrev--same-major-mode-p' for an example. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
203 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
204 The value of `dabbrev-friend-buffer-function' has an effect only if |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
205 the value of `dabbrev-select-buffers-function' uses it. The function |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
206 `dabbrev--select-buffers' is one function you can use here. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
207 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
208 A mode setting this variable should make it buffer local.") |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
209 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
210 (defvar dabbrev-search-these-buffers-only nil |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
211 "If non-nil, a list of buffers which dabbrev should search. |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
212 If this variable is non-nil, dabbrev will only look in these buffers. |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
213 It will not even look in the current buffer if it is not a member of |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
214 this list.") |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
215 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
216 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
217 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
218 ;;; Internal variables |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
219 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
220 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
221 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
222 ;; Last obarray of completions in `dabbrev-completion' |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
223 (defvar dabbrev--last-obarray nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
224 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
225 ;; Table of expansions seen so far |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
226 (defvar dabbrev--last-table nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
227 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
228 ;; Last string we tried to expand. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
229 (defvar dabbrev--last-abbreviation nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
230 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
231 ;; Location last abbreviation began |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
232 (defvar dabbrev--last-abbrev-location nil) |
267 | 233 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
234 ;; Direction of last dabbrevs search |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
235 (defvar dabbrev--last-direction 0) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
236 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
237 ;; Last expansion of an abbreviation. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
238 (defvar dabbrev--last-expansion nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
239 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
240 ;; Location the last expansion was found. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
241 (defvar dabbrev--last-expansion-location nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
242 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
243 ;; The list of remaining buffers with the same mode as current buffer. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
244 (defvar dabbrev--friend-buffer-list nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
245 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
246 ;; The buffer we looked in last. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
247 (defvar dabbrev--last-buffer nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
248 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
249 ;; The buffer we found the expansion last time. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
250 (defvar dabbrev--last-buffer-found nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
251 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
252 ;; The buffer we last did a completion in. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
253 (defvar dabbrev--last-completion-buffer nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
254 |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
255 ;; Same as dabbrev-check-other-buffers, but is set for every expand. |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
256 (defvar dabbrev--check-other-buffers dabbrev-check-other-buffers) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
257 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
258 ;; The regexp for recognizing a character in an abbreviation. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
259 (defvar dabbrev--abbrev-char-regexp nil) |
267 | 260 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
261 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
262 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
263 ;;; Macros |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
264 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
265 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
266 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
267 ;;; Get the buffer that mini-buffer was activated from |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
268 (defsubst dabbrev--minibuffer-origin () |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
269 (car (cdr (buffer-list)))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
270 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
271 ;; Make a list of some of the elements of LIST. |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
272 ;; Check each element of LIST, storing it temporarily in the |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
273 ;; variable ELEMENT, and include it in the result |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
274 ;; if CONDITION evaluates non-nil. |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
275 (defmacro dabbrev-filter-elements (element list condition) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
276 (` (let (dabbrev-result dabbrev-tail (, element)) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
277 (setq dabbrev-tail (, list)) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
278 (while dabbrev-tail |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
279 (setq (, element) (car dabbrev-tail)) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
280 (if (, condition) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
281 (setq dabbrev-result (cons (, element) dabbrev-result))) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
282 (setq dabbrev-tail (cdr dabbrev-tail))) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
283 (nreverse dabbrev-result)))) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
284 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
285 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
286 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
287 ;;; Exported functions |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
288 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
289 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
290 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
291 ;;;###autoload |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
292 (define-key esc-map "/" 'dabbrev-expand) |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
293 ;;;??? Do we want this? |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
294 ;;;###autoload |
10251
bf1c7dcc69db
(esc-map): Delete excess closeparen.
Richard M. Stallman <rms@gnu.org>
parents:
10241
diff
changeset
|
295 (define-key esc-map [?\C-/] 'dabbrev-completion) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
296 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
297 ;;;###autoload |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
298 (defun dabbrev-completion (&optional arg) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
299 "Completion on current word. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
300 Like \\[dabbrev-expand] but finds all expansions in the current buffer |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
301 and presents suggestions for completion. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
302 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
303 With a prefix argument, it searches all buffers accepted by the |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
304 function pointed out by `dabbrev-friend-buffer-function' to find the |
10232
ace1fffa8d96
(dabbrev-completion): Now searches all buffers when given prefix arg 16.
Richard M. Stallman <rms@gnu.org>
parents:
10231
diff
changeset
|
305 completions. |
ace1fffa8d96
(dabbrev-completion): Now searches all buffers when given prefix arg 16.
Richard M. Stallman <rms@gnu.org>
parents:
10231
diff
changeset
|
306 |
ace1fffa8d96
(dabbrev-completion): Now searches all buffers when given prefix arg 16.
Richard M. Stallman <rms@gnu.org>
parents:
10231
diff
changeset
|
307 If the prefix argument is 16 (which comes from C-u C-u), |
ace1fffa8d96
(dabbrev-completion): Now searches all buffers when given prefix arg 16.
Richard M. Stallman <rms@gnu.org>
parents:
10231
diff
changeset
|
308 then it searches *all* buffers. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
309 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
310 With no prefix argument, it reuses an old completion list |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
311 if there is a suitable one already." |
267 | 312 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
313 (interactive "*P") |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
314 (dabbrev--reset-global-variables) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
315 (let* ((dabbrev-check-other-buffers (and arg t)) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
316 (dabbrev-check-all-buffers |
10232
ace1fffa8d96
(dabbrev-completion): Now searches all buffers when given prefix arg 16.
Richard M. Stallman <rms@gnu.org>
parents:
10231
diff
changeset
|
317 (and arg (= (prefix-numeric-value arg) 16))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
318 (abbrev (dabbrev--abbrev-at-point)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
319 (ignore-case-p (and (eval dabbrev-case-fold-search) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
320 (or (not dabbrev-upcase-means-case-search) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
321 (string= abbrev (downcase abbrev))))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
322 (my-obarray dabbrev--last-obarray) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
323 init) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
324 (save-excursion |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
325 (if (and (null arg) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
326 my-obarray |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
327 (or (eq dabbrev--last-completion-buffer (current-buffer)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
328 (and (window-minibuffer-p (selected-window)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
329 (eq dabbrev--last-completion-buffer |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
330 (dabbrev--minibuffer-origin)))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
331 dabbrev--last-abbreviation |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
332 (>= (length abbrev) (length dabbrev--last-abbreviation)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
333 (string= dabbrev--last-abbreviation |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
334 (substring abbrev 0 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
335 (length dabbrev--last-abbreviation))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
336 (setq init (try-completion abbrev my-obarray))) |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
337 ;; We can reuse the existing completion list. |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
338 nil |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
339 ;;-------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
340 ;; New abbreviation to expand. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
341 ;;-------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
342 (setq dabbrev--last-abbreviation abbrev) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
343 ;; Find all expansion |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
344 (let ((completion-list |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
345 (dabbrev--find-all-expansions abbrev ignore-case-p))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
346 ;; Make an obarray with all expansions |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
347 (setq my-obarray (make-vector (length completion-list) 0)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
348 (or (> (length my-obarray) 0) |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
349 (error "No dynamic expansion for \"%s\" found%s" |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
350 abbrev |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
351 (if dabbrev--check-other-buffers "" " in this-buffer"))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
352 (cond |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
353 ((or (not ignore-case-p) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
354 (not dabbrev-case-replace)) |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
355 (mapcar (function (lambda (string) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
356 (intern string my-obarray))) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
357 completion-list)) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
358 ((string= abbrev (upcase abbrev)) |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
359 (mapcar (function (lambda (string) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
360 (intern (upcase string) my-obarray))) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
361 completion-list)) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
362 ((string= (substring abbrev 0 1) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
363 (upcase (substring abbrev 0 1))) |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
364 (mapcar (function (lambda (string) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
365 (intern (capitalize string) my-obarray))) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
366 completion-list)) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
367 (t |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
368 (mapcar (function (lambda (string) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
369 (intern (downcase string) my-obarray))) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
370 completion-list))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
371 (setq dabbrev--last-obarray my-obarray) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
372 (setq dabbrev--last-completion-buffer (current-buffer)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
373 ;; Find the longest common string. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
374 (setq init (try-completion abbrev my-obarray))))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
375 ;;-------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
376 ;; Let the user choose between the expansions |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
377 ;;-------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
378 (or (stringp init) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
379 (setq init abbrev)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
380 (cond |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
381 ;; * Replace string fragment with matched common substring completion. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
382 ((and (not (string-equal init "")) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
383 (not (string-equal (downcase init) (downcase abbrev)))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
384 (if (> (length (all-completions init my-obarray)) 1) |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
385 (message "Repeat `%s' to see all completions" |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
386 (key-description (this-command-keys))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
387 (message "The only possible completion")) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
388 (dabbrev--substitute-expansion nil abbrev init)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
389 (t |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
390 ;; * String is a common substring completion already. Make list. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
391 (message "Making completion list...") |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
392 (with-output-to-temp-buffer " *Completions*" |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
393 (display-completion-list (all-completions init my-obarray))) |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
394 (message "Making completion list...done"))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
395 (and (window-minibuffer-p (selected-window)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
396 (message nil)))) |
267 | 397 |
398 ;;;###autoload | |
399 (defun dabbrev-expand (arg) | |
400 "Expand previous word \"dynamically\". | |
401 | |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
402 Expands to the most recent, preceding word for which this is a prefix. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
403 If no suitable preceding word is found, words following point are |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
404 considered. If still no suitable word is found, then look in the |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
405 buffers accepted by the function pointed out by variable |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
406 `dabbrev-friend-buffer-function'. |
267 | 407 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
408 A positive prefix argument, N, says to take the Nth backward *distinct* |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
409 possibility. A negative argument says search forward. |
267 | 410 |
411 If the cursor has not moved from the end of the previous expansion and | |
412 no argument is given, replace the previously-made expansion | |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
413 with the next possible expansion not yet tried. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
414 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
415 The variable `dabbrev-backward-only' may be used to limit the |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
416 direction of search to backward if set non-nil. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
417 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
418 See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." |
267 | 419 (interactive "*P") |
12724
c3cb2b06e05f
(dabbrev-expand): Save previous point for undo.
Richard M. Stallman <rms@gnu.org>
parents:
12555
diff
changeset
|
420 (let (abbrev expansion old direction (orig-point (point))) |
267 | 421 ;; abbrev -- the abbrev to expand |
422 ;; expansion -- the expansion found (eventually) or nil until then | |
423 ;; old -- the text currently in the buffer | |
424 ;; (the abbrev, or the previously-made expansion) | |
425 (save-excursion | |
426 (if (and (null arg) | |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
427 (markerp dabbrev--last-abbrev-location) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
428 (marker-position dabbrev--last-abbrev-location) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
429 (or (eq last-command this-command) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
430 (and (window-minibuffer-p (selected-window)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
431 (= dabbrev--last-abbrev-location |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
432 (point))))) |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
433 ;; Find a different expansion for the same abbrev as last time. |
267 | 434 (progn |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
435 (setq abbrev dabbrev--last-abbreviation) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
436 (setq old dabbrev--last-expansion) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
437 (setq direction dabbrev--last-direction)) |
11976
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
438 ;; If the user inserts a space after expanding |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
439 ;; and then asks to expand again, always fetch the next word. |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
440 (if (and (eq (preceding-char) ?\ ) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
441 (markerp dabbrev--last-abbrev-location) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
442 (marker-position dabbrev--last-abbrev-location) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
443 (= (point) (1+ dabbrev--last-abbrev-location))) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
444 (progn |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
445 ;; The "abbrev" to expand is just the space. |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
446 (setq abbrev " ") |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
447 (save-excursion |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
448 (if dabbrev--last-buffer |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
449 (set-buffer dabbrev--last-buffer)) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
450 ;; Find the end of the last "expansion" word. |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
451 (if (or (eq dabbrev--last-direction 1) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
452 (and (eq dabbrev--last-direction 0) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
453 (< dabbrev--last-expansion-location (point)))) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
454 (setq dabbrev--last-expansion-location |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
455 (+ dabbrev--last-expansion-location |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
456 (length dabbrev--last-expansion)))) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
457 (goto-char dabbrev--last-expansion-location) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
458 ;; Take the following word, with intermediate separators, |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
459 ;; as our expansion this time. |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
460 (re-search-forward |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
461 (concat "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)")) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
462 (setq expansion |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
463 (buffer-substring dabbrev--last-expansion-location |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
464 (point))) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
465 |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
466 ;; Record the end of this expansion, in case we repeat this. |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
467 (setq dabbrev--last-expansion-location (point))) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
468 ;; Indicate that dabbrev--last-expansion-location is |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
469 ;; at the end of the expansion. |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
470 (setq dabbrev--last-direction -1)) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
471 |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
472 ;; We have a different abbrev to expand. |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
473 (dabbrev--reset-global-variables) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
474 (setq direction (if (null arg) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
475 (if dabbrev-backward-only 1 0) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
476 (prefix-numeric-value arg))) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
477 (setq abbrev (dabbrev--abbrev-at-point)) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
478 (setq old nil))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
479 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
480 ;;-------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
481 ;; Find the expansion |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
482 ;;-------------------------------- |
11976
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
483 (or expansion |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
484 (setq expansion |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
485 (dabbrev--find-expansion abbrev direction |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
486 (and (eval dabbrev-case-fold-search) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
487 (or (not dabbrev-upcase-means-case-search) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
488 (string= abbrev (downcase abbrev)))))))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
489 (cond |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
490 ((not expansion) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
491 (dabbrev--reset-global-variables) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
492 (if old |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
493 (save-excursion |
12724
c3cb2b06e05f
(dabbrev-expand): Save previous point for undo.
Richard M. Stallman <rms@gnu.org>
parents:
12555
diff
changeset
|
494 (setq buffer-undo-list (cons orig-point buffer-undo-list)) |
13256
d9c469af1ee0
(dabbrev-expand): When no more expansions,
Richard M. Stallman <rms@gnu.org>
parents:
12724
diff
changeset
|
495 ;; Put back the original abbrev with its original case pattern. |
d9c469af1ee0
(dabbrev-expand): When no more expansions,
Richard M. Stallman <rms@gnu.org>
parents:
12724
diff
changeset
|
496 (search-backward old) |
d9c469af1ee0
(dabbrev-expand): When no more expansions,
Richard M. Stallman <rms@gnu.org>
parents:
12724
diff
changeset
|
497 (insert abbrev) |
d9c469af1ee0
(dabbrev-expand): When no more expansions,
Richard M. Stallman <rms@gnu.org>
parents:
12724
diff
changeset
|
498 (delete-region (point) (+ (point) (length old))))) |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
499 (error "No%s dynamic expansion for `%s' found" |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
500 (if old " further" "") abbrev)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
501 (t |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
502 (if (not (eq dabbrev--last-buffer dabbrev--last-buffer-found)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
503 (progn |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
504 (message "Expansion found in '%s'" |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
505 (buffer-name dabbrev--last-buffer)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
506 (setq dabbrev--last-buffer-found dabbrev--last-buffer)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
507 (message nil)) |
11976
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
508 (if (and (or (eq (current-buffer) dabbrev--last-buffer) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
509 (null dabbrev--last-buffer)) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
510 (numberp dabbrev--last-expansion-location) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
511 (and (> dabbrev--last-expansion-location (point)))) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
512 (setq dabbrev--last-expansion-location |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
513 (copy-marker dabbrev--last-expansion-location))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
514 ;; Success: stick it in and return. |
12724
c3cb2b06e05f
(dabbrev-expand): Save previous point for undo.
Richard M. Stallman <rms@gnu.org>
parents:
12555
diff
changeset
|
515 (setq buffer-undo-list (cons orig-point buffer-undo-list)) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
516 (dabbrev--substitute-expansion old abbrev expansion) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
517 ;; Save state for re-expand. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
518 (setq dabbrev--last-expansion expansion) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
519 (setq dabbrev--last-abbreviation abbrev) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
520 (setq dabbrev--last-abbrev-location (point-marker)))))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
521 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
522 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
523 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
524 ;;; Local functions |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
525 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
526 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
527 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
528 ;;; Checks if OTHER-BUFFER has the same major mode as current buffer. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
529 (defun dabbrev--same-major-mode-p (other-buffer) |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
530 (eq major-mode |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
531 (save-excursion |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
532 (set-buffer other-buffer) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
533 major-mode))) |
267 | 534 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
535 ;;; Back over all abbrev type characters and then moves forward over |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
536 ;;; all skip characters. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
537 (defun dabbrev--goto-start-of-abbrev () |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
538 ;; Move backwards over abbrev chars |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
539 (save-match-data |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
540 (if (not (bobp)) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
541 (progn |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
542 (forward-char -1) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
543 (while (and (looking-at dabbrev--abbrev-char-regexp) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
544 (not (bobp))) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
545 (forward-char -1)) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
546 (or (looking-at dabbrev--abbrev-char-regexp) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
547 (forward-char 1)))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
548 (and dabbrev-abbrev-skip-leading-regexp |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
549 (while (looking-at dabbrev-abbrev-skip-leading-regexp) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
550 (forward-char 1))))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
551 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
552 ;;; Extract the symbol at point to serve as abbreviation. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
553 (defun dabbrev--abbrev-at-point () |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
554 ;; Check for error |
11976
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
555 (if (bobp) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
556 (error "No possible abbreviation preceding point")) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
557 ;; Return abbrev at point |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
558 (save-excursion |
11976
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
559 ;; Record the end of the abbreviation. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
560 (setq dabbrev--last-abbrev-location (point)) |
11976
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
561 ;; If we aren't right after an abbreviation, |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
562 ;; move point back to just after one. |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
563 ;; This is so the user can get successive words |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
564 ;; by typing the punctuation followed by M-/. |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
565 (save-match-data |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
566 (if (save-excursion |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
567 (forward-char -1) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
568 (not (looking-at (concat "\\(" |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
569 (or dabbrev-abbrev-char-regexp |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
570 "\\sw\\|\\s_") |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
571 "\\)+")))) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
572 (if (re-search-backward (or dabbrev-abbrev-char-regexp |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
573 "\\sw\\|\\s_") |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
574 nil t) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
575 (forward-char 1) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
576 (error "No possible abbreviation preceding point")))) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
577 ;; Now find the beginning of that one. |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
578 (dabbrev--goto-start-of-abbrev) |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
579 (buffer-substring dabbrev--last-abbrev-location |
e862c6697f39
(dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents:
11820
diff
changeset
|
580 (point)))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
581 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
582 ;;; Initializes all global variables |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
583 (defun dabbrev--reset-global-variables () |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
584 ;; dabbrev--last-obarray and dabbrev--last-completion-buffer |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
585 ;; must not be reset here. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
586 (setq dabbrev--last-table nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
587 dabbrev--last-abbreviation nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
588 dabbrev--last-abbrev-location nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
589 dabbrev--last-direction nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
590 dabbrev--last-expansion nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
591 dabbrev--last-expansion-location nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
592 dabbrev--friend-buffer-list nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
593 dabbrev--last-buffer nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
594 dabbrev--last-buffer-found nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
595 dabbrev--abbrev-char-regexp (or dabbrev-abbrev-char-regexp |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
596 "\\sw\\|\\s_") |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
597 dabbrev--check-other-buffers dabbrev-check-other-buffers)) |
267 | 598 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
599 ;;; Find all buffers that are considered "friends" according to the |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
600 ;;; function pointed out by dabbrev-friend-buffer-function. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
601 (defun dabbrev--select-buffers () |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
602 (save-excursion |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
603 (and (window-minibuffer-p (selected-window)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
604 (set-buffer (dabbrev--minibuffer-origin))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
605 (let ((orig-buffer (current-buffer))) |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
606 (dabbrev-filter-elements |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
607 buffer (buffer-list) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
608 (and (not (eq orig-buffer buffer)) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
609 (boundp 'dabbrev-friend-buffer-function) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
610 (funcall dabbrev-friend-buffer-function buffer)))))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
611 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
612 ;;; Search for ABBREV, N times, normally looking forward, |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
613 ;;; but looking in reverse instead if REVERSE is non-nil. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
614 (defun dabbrev--try-find (abbrev reverse n ignore-case) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
615 (save-excursion |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
616 (save-restriction |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
617 (widen) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
618 (let ((expansion nil)) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
619 (and dabbrev--last-expansion-location |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
620 (goto-char dabbrev--last-expansion-location)) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
621 (let ((case-fold-search ignore-case) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
622 (count n)) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
623 (while (and (> count 0) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
624 (setq expansion (dabbrev--search abbrev |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
625 reverse |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
626 ignore-case))) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
627 (setq count (1- count)))) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
628 (and expansion |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
629 (setq dabbrev--last-expansion-location (point))) |
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
630 expansion)))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
631 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
632 ;;; Find all expansions of ABBREV |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
633 (defun dabbrev--find-all-expansions (abbrev ignore-case) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
634 (let ((all-expansions nil) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
635 expansion) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
636 (save-excursion |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
637 (goto-char (point-min)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
638 (while (setq expansion (dabbrev--find-expansion abbrev -1 ignore-case)) |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
639 (setq all-expansions (cons expansion all-expansions)))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
640 all-expansions)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
641 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
642 (defun dabbrev--scanning-message () |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
643 (message "Scanning `%s'" (buffer-name (current-buffer)))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
644 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
645 ;;; Find one occasion of ABBREV. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
646 ;;; DIRECTION > 0 means look that many times backwards. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
647 ;;; DIRECTION < 0 means look that many times forward. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
648 ;;; DIRECTION = 0 means try both backward and forward. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
649 ;;; IGNORE-CASE non-nil means ignore case when searching. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
650 (defun dabbrev--find-expansion (abbrev direction ignore-case) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
651 (let (expansion) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
652 (save-excursion |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
653 (cond |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
654 (dabbrev--last-buffer |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
655 (set-buffer dabbrev--last-buffer) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
656 (dabbrev--scanning-message)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
657 ((and (not dabbrev-search-these-buffers-only) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
658 (window-minibuffer-p (selected-window))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
659 (set-buffer (dabbrev--minibuffer-origin)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
660 ;; In the minibuffer-origin buffer we will only search from |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
661 ;; the top and down. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
662 (goto-char (point-min)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
663 (setq direction -1) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
664 (dabbrev--scanning-message))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
665 (cond |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
666 ;; ------------------------------------------ |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
667 ;; Look backwards |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
668 ;; ------------------------------------------ |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
669 ((and (not dabbrev-search-these-buffers-only) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
670 (>= direction 0) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
671 (setq dabbrev--last-direction (min 1 direction)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
672 (setq expansion (dabbrev--try-find abbrev t |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
673 (max 1 direction) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
674 ignore-case))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
675 expansion) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
676 ;; ------------------------------------------ |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
677 ;; Look forward |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
678 ;; ------------------------------------------ |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
679 ((and (or (not dabbrev-search-these-buffers-only) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
680 dabbrev--last-buffer) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
681 (<= direction 0) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
682 (setq dabbrev--last-direction -1) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
683 (setq expansion (dabbrev--try-find abbrev nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
684 (max 1 (- direction)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
685 ignore-case))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
686 expansion) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
687 ;; ------------------------------------------ |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
688 ;; Look in other buffers. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
689 ;; Start at (point-min) and look forward. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
690 ;; ------------------------------------------ |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
691 (t |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
692 (setq dabbrev--last-direction -1) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
693 ;; Make sure that we should check other buffers |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
694 (or dabbrev--friend-buffer-list |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
695 dabbrev--last-buffer |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
696 (setq dabbrev--friend-buffer-list |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
697 (mapcar (function get-buffer) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
698 dabbrev-search-these-buffers-only)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
699 (not dabbrev--check-other-buffers) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
700 (not (or (eq dabbrev--check-other-buffers t) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
701 (progn |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
702 (setq dabbrev--check-other-buffers |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
703 (y-or-n-p "Scan other buffers also? "))))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
704 (let* (friend-buffer-list non-friend-buffer-list) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
705 (setq dabbrev--friend-buffer-list |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
706 (funcall dabbrev-select-buffers-function)) |
11820
362251066737
(dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents:
10251
diff
changeset
|
707 (if dabbrev-check-all-buffers |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
708 (setq non-friend-buffer-list |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
709 (nreverse |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
710 (dabbrev-filter-elements |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
711 buffer (buffer-list) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
712 (not (memq buffer dabbrev--friend-buffer-list)))) |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
713 dabbrev--friend-buffer-list |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
714 (append dabbrev--friend-buffer-list |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
715 non-friend-buffer-list))))) |
13257
679fc0917c11
(dabbrev--find-expansion): Move buffers that are visible on the screen
Richard M. Stallman <rms@gnu.org>
parents:
13256
diff
changeset
|
716 ;; Move buffers that are visible on the screen |
679fc0917c11
(dabbrev--find-expansion): Move buffers that are visible on the screen
Richard M. Stallman <rms@gnu.org>
parents:
13256
diff
changeset
|
717 ;; to the front of the list. |
679fc0917c11
(dabbrev--find-expansion): Move buffers that are visible on the screen
Richard M. Stallman <rms@gnu.org>
parents:
13256
diff
changeset
|
718 (if dabbrev--friend-buffer-list |
679fc0917c11
(dabbrev--find-expansion): Move buffers that are visible on the screen
Richard M. Stallman <rms@gnu.org>
parents:
13256
diff
changeset
|
719 (let ((w (next-window (selected-window)))) |
679fc0917c11
(dabbrev--find-expansion): Move buffers that are visible on the screen
Richard M. Stallman <rms@gnu.org>
parents:
13256
diff
changeset
|
720 (while (not (eq w (selected-window))) |
679fc0917c11
(dabbrev--find-expansion): Move buffers that are visible on the screen
Richard M. Stallman <rms@gnu.org>
parents:
13256
diff
changeset
|
721 (setq dabbrev--friend-buffer-list |
679fc0917c11
(dabbrev--find-expansion): Move buffers that are visible on the screen
Richard M. Stallman <rms@gnu.org>
parents:
13256
diff
changeset
|
722 (cons (window-buffer w) |
679fc0917c11
(dabbrev--find-expansion): Move buffers that are visible on the screen
Richard M. Stallman <rms@gnu.org>
parents:
13256
diff
changeset
|
723 (delq (window-buffer w) dabbrev--friend-buffer-list))) |
679fc0917c11
(dabbrev--find-expansion): Move buffers that are visible on the screen
Richard M. Stallman <rms@gnu.org>
parents:
13256
diff
changeset
|
724 (setq w (next-window w))))) |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
725 ;; Walk through the buffers |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
726 (while (and (not expansion) dabbrev--friend-buffer-list) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
727 (setq dabbrev--last-buffer |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
728 (car dabbrev--friend-buffer-list)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
729 (setq dabbrev--friend-buffer-list |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
730 (cdr dabbrev--friend-buffer-list)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
731 (set-buffer dabbrev--last-buffer) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
732 (dabbrev--scanning-message) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
733 (setq dabbrev--last-expansion-location (point-min)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
734 (setq expansion (dabbrev--try-find abbrev nil 1 ignore-case))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
735 expansion))))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
736 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
737 (defun dabbrev--safe-replace-match (string &optional fixedcase literal) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
738 (if (eq major-mode 'picture-mode) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
739 (picture-replace-match string fixedcase literal) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
740 (replace-match string fixedcase literal))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
741 |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
742 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
743 ;;; Substitute the current string in buffer with the expansion |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
744 ;;; OLD is nil or the last expansion substring. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
745 ;;; ABBREV is the abbreviation we are working with. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
746 ;;; EXPANSION is the expansion substring. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
747 (defun dabbrev--substitute-expansion (old abbrev expansion) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
748 ;;(undo-boundary) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
749 (let ((use-case-replace (and (eval dabbrev-case-fold-search) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
750 (or (not dabbrev-upcase-means-case-search) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
751 (string= abbrev (downcase abbrev))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
752 (eval dabbrev-case-replace)))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
753 (and nil use-case-replace |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
754 (setq old (concat abbrev (or old ""))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
755 (setq expansion (concat abbrev expansion))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
756 (if old |
267 | 757 (save-excursion |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
758 (search-backward old)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
759 ;;(store-match-data (list (point-marker) (point-marker))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
760 (search-backward abbrev)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
761 ;; Make case of replacement conform to case of abbreviation |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
762 ;; provided (1) that kind of thing is enabled in this buffer |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
763 ;; and (2) the replacement itself is all lower case. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
764 (dabbrev--safe-replace-match expansion |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
765 (not use-case-replace) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
766 t))) |
267 | 767 |
768 | |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
769 ;;;---------------------------------------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
770 ;;; Search function used by dabbrevs library. |
267 | 771 |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
772 ;;; ABBREV is string to find as prefix of word. Second arg, REVERSE, |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
773 ;;; is t for reverse search, nil for forward. Variable dabbrev-limit |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
774 ;;; controls the maximum search region size. Third argment IGNORE-CASE |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
775 ;;; non-nil means treat case as insignificant while looking for a match |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
776 ;;; and when comparing with previous matches. Also if that's non-nil |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
777 ;;; and the match is found at the beginning of a sentence and is in |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
778 ;;; lower case except for the initial then it is converted to all lower |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
779 ;;; case for return. |
267 | 780 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
781 ;;; Table of expansions already seen is examined in buffer |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
782 ;;; `dabbrev--last-table' so that only distinct possibilities are found |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
783 ;;; by dabbrev-re-expand. |
267 | 784 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
785 ;;; Value is the expansion, or nil if not found. |
267 | 786 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
787 (defun dabbrev--search (abbrev reverse ignore-case) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
788 (save-match-data |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
789 (let ((pattern1 (concat (regexp-quote abbrev) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
790 "\\(" dabbrev--abbrev-char-regexp "\\)")) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
791 (pattern2 (concat (regexp-quote abbrev) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
792 "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)")) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
793 (found-string nil)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
794 ;; Limited search. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
795 (save-restriction |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
796 (and dabbrev-limit |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
797 (narrow-to-region dabbrev--last-expansion-location |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
798 (+ (point) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
799 (if reverse (- dabbrev-limit) dabbrev-limit)))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
800 ;;-------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
801 ;; Look for a distinct expansion, using dabbrev--last-table. |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
802 ;;-------------------------------- |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
803 (while (and (not found-string) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
804 (if reverse |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
805 (re-search-backward pattern1 nil t) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
806 (re-search-forward pattern1 nil t))) |
12555
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
807 (goto-char (match-beginning 0)) |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
808 ;; In case we matched in the middle of a word, |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
809 ;; back up to start of word and verify we still match. |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
810 (dabbrev--goto-start-of-abbrev) |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
811 |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
812 (if (not (looking-at pattern1)) |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
813 nil |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
814 ;; We have a truly valid match. Find the end. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
815 (re-search-forward pattern2) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
816 (setq found-string |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
817 (buffer-substring (match-beginning 1) (match-end 1))) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
818 (and ignore-case (setq found-string (downcase found-string))) |
12555
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
819 ;; Ignore this match if it's already in the table. |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
820 (if (dabbrev-filter-elements |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
821 table-string dabbrev--last-table |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
822 (string= found-string table-string)) |
12555
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
823 (setq found-string nil))) |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
824 ;; Prepare to continue searching. |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
825 (if reverse |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
826 (goto-char (match-beginning 0)) |
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
827 (goto-char (match-end 0)))) |
12555
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
828 ;; If we found something, use it. |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
829 (if found-string |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
830 ;; Put it into `dabbrev--last-table' |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
831 ;; and return it (either downcased, or as is). |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
832 (let ((result |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
833 (buffer-substring (match-beginning 0) (match-end 0)))) |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
834 (setq dabbrev--last-table |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
835 (cons found-string dabbrev--last-table)) |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
836 (if (and ignore-case (eval dabbrev-case-replace)) |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
837 (downcase result) |
a2a2aa391773
(dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents:
11976
diff
changeset
|
838 result))))))) |
267 | 839 |
10230
7396503653cf
Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents:
5307
diff
changeset
|
840 (provide 'dabbrev) |
10231
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
841 |
e88ff4b30786
Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents:
10230
diff
changeset
|
842 ;; dabbrev.el ends here |
584 | 843 |
844 |