annotate lisp/dabbrev.el @ 10231:e88ff4b30786

Don't require cl, picture, or reporter. Don't provide new-dabbrev. (dabbrev--try-find): Don't use `loop'. Don't create or kill local bindings. (dabbrev-completion): Use key-description to say what to type. Fix style of "done" message. (dabbrev-submit-feedback): Function deleted. (dabbrev--same-major-mode-p): Simplify. (dabbrev-completion, dabbrev--abbrev-at-point): Fix error msg style. (dabbrev-filter-elements): New macro. (dabbrev--select-buffers, dabbrev--find-expansion): Use that. (dabbrev--search): Use that.
author Richard M. Stallman <rms@gnu.org>
date Sat, 24 Dec 1994 01:30:55 +0000
parents 7396503653cf
children ace1fffa8d96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
7 ;; Version: 4.4.2 beta
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
8 (defun dabbrev--version () "4.4.2 beta")
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
9 ;; Keywords: abbrev expand completion
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
11 ;; This program is free software; you can redistribute it and/or modify
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; 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
13 ;; 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
14 ;; (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
15 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
16 ;; This program is distributed in the hope that it will be useful,
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; 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
20 ;;
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; 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
22 ;; 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
23 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
25 ;;; Commentary:
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
27 ;; 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
28 ;; 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
29 ;; them.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
30 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
31 ;; 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
32 ;; 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
33 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
34 ;; There are powerful things in this package that aren't turned on by
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
35 ;; default. I recommend you to do the following.
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
36 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
37 ;; Put the following 2 lines in your .emacs file:
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
38 ;; (setq dabbrev-always-check-other-buffers t)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
39 ;; (setq dabbrev-abbrev-char-regexp "\\sw\\|\\s_")
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
40 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
41 ;; Dabbrev will now search in all buffers with the same major mode for
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
42 ;; your expansions. It will also search for complete symbols, the old
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
43 ;; dabbrev package only looked half-heartedly for symbols.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
44 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
45 ;; 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
46 ;; features of this package.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
47
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
48 ;;; 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
49
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
50 ;; 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
51 ;; 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
52 ;; dabbrev-case-replace nil t
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
53 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
54 ;; 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
55 ;; (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
56 ;; 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
57 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
58 ;; 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
59 ;; (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
60 ;; `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
61 ;; 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
62
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
63 ;; 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
64 ;; 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
65 ;; 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
66
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
67 ;; 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
68 ;; the article for expansion):
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
69 ;; (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
70 ;; (lambda (buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
71 ;; (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
72 ;; (set-buffer buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
73 ;; (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
74
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
75
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
76 ;; Known bugs and limitations.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
77 ;; - 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
78 ;; minibuffer.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
79 ;; - 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
80 ;; 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
81
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
82 ;; Future enhancements
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
83 ;; - 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
84 ;; - 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
85 ;; the nearest expansion.
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
86 ;; - 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
87 ;; 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
88
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
89 ;;; Thanks goes to
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
90 ;; [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
91 ;; [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
92 ;; [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
93 ;; [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
94 ;; [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
95 ;; [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
96 ;; [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
97 ;; [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
98 ;; [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
99 ;; [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
100 ;; [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
101 ;; ... and to all the people who have participated in the beta tests.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
103 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
104
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
105 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
106 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
107 ;;; Customization variables
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
108 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
109 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
110 (defvar dabbrev-backward-only nil
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
111 "*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
112
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
113 (defvar dabbrev-limit nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
114 "*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
115
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
116 (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
117 "*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
118
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
119 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
120 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
121 (For example, in Makefiles.)
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 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
124
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
125 ;; 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
126 (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
127 "*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
128 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
129
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
130 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
131 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
132 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
133 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
134
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
135 (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
136 "*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
137 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
138
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
139 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
140 `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
141
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
142 ;; 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
143 (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
144 "*Non-nil means dabbrev should preserve case when expanding the abbreviation.
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
145 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
146 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
147 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
148 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
149
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
150 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
151 `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
152
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
153 ;; I recommend that you set this to "\\sw\\|\\s_"
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
154 (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
155 "*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
156 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
157
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
158 Set this variable to \"\\\\sw\" if you want ordinary words or
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
159 \"\\\\sw\\\\|\\\\s_\" if you want symbols.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
160
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
161 You can also set it to nil if you want old-style dabbrev searching
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
162 \(the abbreviation is from point to previous word-start, the
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
163 search is for symbols).
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
165 For instance, if you are programming in Lisp, `yes-or-no-p' is a symbol,
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
166 while `yes', `or', `no' and `p' are considered words. If you set this
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
167 variable to nil, then expanding `yes-or-no-' looks for a symbol
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
168 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
169 \"\\\\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
170 `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
171 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
172 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
173
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
174 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
175
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
176 (defvar dabbrev-check-rest-of-buffers t
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
177 "*Non-nil means dabbrev package should search in all buffers.
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
178 It searches the buffers pointed out by `dabbrev-select-buffers-function'
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
179 first; afterward it looks in the rest of the buffers.")
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
180
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
181
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
182 ;; I recommend that you set this to t.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
183 (defvar dabbrev-always-check-other-buffers nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
184 "*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
185 nil = Don't look in other buffers.\n\
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
186 t = Look in other buffers.\n\
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
187 Value other than nil and t = ask the user if he want's to look in
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
188 other buffers.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
189
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
190 The recommended value is t.")
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
191
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
192 ;; 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
193 ;; 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
194 ;; 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
195 (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
196 "A function that selects buffers that should be searched by dabbrev.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
198 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
199 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
200 an example.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
201
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
202 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
203
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
204 (defvar dabbrev-friend-buffer-function 'dabbrev--same-major-mode-p
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
205 "*A function to check if OTHER-BUFFER should be searched by dabbrev.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
206
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
207 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
208 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
209 `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
210
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
211 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
212 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
213 `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
214
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
215 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
216
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
217 (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
218 "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
219 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
220 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
221 this list.")
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
222
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
223 ;;;----------------------------------------------------------------
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 ;;; Internal variables
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
226 ;;;----------------------------------------------------------------
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
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
229 ;; 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
230 (defvar dabbrev--last-obarray nil)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
231
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
232 ;; 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
233 (defvar dabbrev--last-table nil)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
234
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
235 ;; 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
236 (defvar dabbrev--last-abbreviation nil)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
237
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
238 ;; Location last abbreviation began
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
239 (defvar dabbrev--last-abbrev-location nil)
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
241 ;; Direction of last dabbrevs search
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
242 (defvar dabbrev--last-direction 0)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
243
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
244 ;; Last expansion of an abbreviation.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
245 (defvar dabbrev--last-expansion nil)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
246
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
247 ;; 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
248 (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
249
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
250 ;; 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
251 (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
252
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
253 ;; 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
254 (defvar dabbrev--last-buffer nil)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
255
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
256 ;; 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
257 (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
258
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
259 ;; 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
260 (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
261
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
262 ;; Same as dabbrev-always-check-other-buffers, but is set for every expand.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
263 (defvar dabbrev--check-other-buffers dabbrev-always-check-other-buffers)
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 ;; 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
266 (defvar dabbrev--abbrev-char-regexp nil)
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
268 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
269 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
270 ;;; Macros
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
271 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
272 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
273
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
274 ;;; 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
275 (defsubst dabbrev--minibuffer-origin ()
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
276 (car (cdr (buffer-list))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
277
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
278 ;; 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
279 ;; 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
280 ;; 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
281 ;; if CONDITION evaluates non-nil.
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
282 (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
283 (` (let (dabbrev-result dabbrev-tail (, element))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
284 (setq dabbrev-tail (, list))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
285 (while dabbrev-tail
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
286 (setq (, element) (car dabbrev-tail))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
287 (if (, condition)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
288 (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
289 (setq dabbrev-tail (cdr dabbrev-tail)))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
290 (nreverse dabbrev-result))))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
291
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
292 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
293 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
294 ;;; Exported functions
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
295 ;;;----------------------------------------------------------------
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
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
298 ;;;###autoload
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
299 (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
300 ;;;??? Do we want this?
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
301 ;;;###autoload
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
302 (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
303
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
304 ;;;###autoload
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
305 (defun dabbrev-completion (&optional arg)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
306 "Completion on current word.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
307 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
308 and presents suggestions for completion.
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 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
311 function pointed out by `dabbrev-friend-buffer-function' to find the
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
312 completions. \(The argument value does not matter.)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
313
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
314 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
315 if there is a suitable one already."
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
317 (interactive "*P")
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
318 (let* ((dabbrev-always-check-other-buffers (and arg t))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
319 (abbrev (dabbrev--abbrev-at-point))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
320 (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
321 (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
322 (string= abbrev (downcase abbrev)))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
323 (my-obarray dabbrev--last-obarray)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
324 init)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
325 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
326 (if (and (null arg)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
327 my-obarray
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
328 (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
329 (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
330 (eq dabbrev--last-completion-buffer
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
331 (dabbrev--minibuffer-origin))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
332 dabbrev--last-abbreviation
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
333 (>= (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
334 (string= dabbrev--last-abbreviation
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
335 (substring abbrev 0
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
336 (length dabbrev--last-abbreviation)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
337 (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
338 ;; 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
339 nil
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
340 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
341 ;; New abbreviation to expand.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
342 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
343 (dabbrev--reset-global-variables)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
344 (setq dabbrev--last-abbreviation abbrev)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
345 ;; Find all expansion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
346 (let ((completion-list
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
347 (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
348 ;; 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
349 (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
350 (or (> (length my-obarray) 0)
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
351 (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
352 abbrev
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
353 (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
354 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
355 ((or (not ignore-case-p)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
356 (not dabbrev-case-replace))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
357 (mapc (function (lambda (string)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
358 (intern string my-obarray)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
359 completion-list))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
360 ((string= abbrev (upcase abbrev))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
361 (mapc (function (lambda (string)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
362 (intern (upcase string) my-obarray)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
363 completion-list))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
364 ((string= (substring abbrev 0 1)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
365 (upcase (substring abbrev 0 1)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
366 (mapc (function (lambda (string)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
367 (intern (dabbrev--capitalize string) my-obarray)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
368 completion-list))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
369 (t
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
370 (mapc (function (lambda (string)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
371 (intern (downcase string) my-obarray)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
372 completion-list)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
373 (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
374 (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
375 ;; Find the longest common string.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
376 (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
377 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
378 ;; 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
379 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
380 (or (stringp init)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
381 (setq init abbrev))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
382 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
383 ;; * 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
384 ((and (not (string-equal init ""))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
385 (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
386 (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
387 (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
388 (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
389 (message "The only possible completion"))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
390 (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
391 (t
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
392 ;; * 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
393 (message "Making completion list...")
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
394 (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
395 (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
396 (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
397 (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
398 (message nil))))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 ;;;###autoload
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (defun dabbrev-expand (arg)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 "Expand previous word \"dynamically\".
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
404 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
405 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
406 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
407 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
408 `dabbrev-friend-buffer-function'.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
410 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
411 possibility. A negative argument says search forward.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 If the cursor has not moved from the end of the previous expansion and
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 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
415 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
416
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
417 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
418 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
419
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
420 ???
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
421 To make it more powerful, make sure that
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
422 `dabbrev-always-check-other-buffers' is set to t.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
423
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
424 See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 (interactive "*P")
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
426 (let (abbrev expansion old direction)
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 ;; abbrev -- the abbrev to expand
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 ;; expansion -- the expansion found (eventually) or nil until then
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 ;; old -- the text currently in the buffer
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 ;; (the abbrev, or the previously-made expansion)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (save-excursion
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (if (and (null arg)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
433 dabbrev--last-abbrev-location
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
434 (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
435 (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
436 (= dabbrev--last-abbrev-location
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
437 (point)))))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
438 ;; Find a different expansion for the same abbrev as last time.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (progn
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
440 (setq abbrev dabbrev--last-abbreviation)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
441 (setq old dabbrev--last-expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
442 (setq direction dabbrev--last-direction))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
443 ;; We have a different abbrev to expand.
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
444 (dabbrev--reset-global-variables)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
445 (setq direction (if (null arg)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
446 (if dabbrev-backward-only 1 0)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
447 (prefix-numeric-value arg)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
448 (setq abbrev (dabbrev--abbrev-at-point))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
449 (setq old nil))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
450
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
451 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
452 ;; Find the expansion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
453 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
454 (setq expansion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
455 (dabbrev--find-expansion abbrev direction
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
456 (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
457 (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
458 (string= abbrev (downcase abbrev)))))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
459 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
460 ((not expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
461 (dabbrev--reset-global-variables)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
462 (if old
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
463 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
464 (search-backward (substring old (length abbrev)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
465 (delete-region (match-beginning 0) (match-end 0))))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
466 (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
467 (if old " further" "") abbrev))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
468 (t
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
469 (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
470 (progn
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
471 (message "Expansion found in '%s'"
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
472 (buffer-name dabbrev--last-buffer))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
473 (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
474 (message nil))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
475 ;; Success: stick it in and return.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
476 (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
477 ;; Save state for re-expand.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
478 (setq dabbrev--last-expansion expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
479 (setq dabbrev--last-abbreviation abbrev)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
480 (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
481
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
482 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
483 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
484 ;;; Local functions
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
485 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
486 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
487
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
488 (defun dabbrev--capitalize (string)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
489 ;; Capitalize STRING (See capitalize-word)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
490 (let ((new-string ""))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
491 (save-match-data
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
492 (while (string-match "\\w+" string)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
493 (let* ((mb (match-beginning 0))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
494 (me (match-end 0))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
495 (ms (substring string mb me)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
496 (setq new-string
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
497 (concat new-string
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
498 (substring string 0 mb)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
499 (upcase (substring ms 0 1))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
500 (downcase (substring ms 1))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
501 (setq string (substring string me)))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
502 new-string))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
503
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
504 ;;; 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
505 (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
506 (eq major-mode
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
507 (save-excursion
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
508 (set-buffer other-buffer)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
509 major-mode)))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
511 ;;; 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
512 ;;; all skip characters.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
513 (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
514 ;; Move backwards over abbrev chars
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
515 (save-match-data
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
516 (if (not (bobp))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
517 (progn
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
518 (forward-char -1)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
519 (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
520 (not (bobp)))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
521 (forward-char -1))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
522 (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
523 (forward-char 1))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
524 (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
525 (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
526 (forward-char 1)))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
527
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
528 ;;; 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
529 (defun dabbrev--abbrev-at-point ()
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
530 ;; Check for error
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
531 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
532 (save-match-data
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
533 (if (or (bobp)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
534 (progn
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
535 (forward-char -1)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
536 (not (looking-at (concat "\\("
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
537 (or dabbrev-abbrev-char-regexp
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
538 "\\sw\\|\\s_")
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
539 "\\)+")))))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
540 (error "Not positioned immediately after an abbreviation"))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
541 ;; Return abbrev at point
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
542 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
543 (setq dabbrev--last-abbrev-location (point))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
544 (buffer-substring (point)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
545 (progn (dabbrev--goto-start-of-abbrev)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
546 (point)))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
547
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
548 ;;; Initializes all global variables
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
549 (defun dabbrev--reset-global-variables ()
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
550 ;; 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
551 ;; must not be reset here.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
552 (setq dabbrev--last-table nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
553 dabbrev--last-abbreviation nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
554 dabbrev--last-abbrev-location nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
555 dabbrev--last-direction nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
556 dabbrev--last-expansion nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
557 dabbrev--last-expansion-location nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
558 dabbrev--friend-buffer-list nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
559 dabbrev--last-buffer nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
560 dabbrev--last-buffer-found nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
561 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
562 "\\sw\\|\\s_")
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
563 dabbrev--check-other-buffers dabbrev-always-check-other-buffers))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
565 ;;; 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
566 ;;; 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
567 (defun dabbrev--select-buffers ()
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
568 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
569 (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
570 (set-buffer (dabbrev--minibuffer-origin)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
571 (let ((orig-buffer (current-buffer)))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
572 (dabbrev-filter-elements
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
573 buffer (buffer-list)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
574 (and (not (eq orig-buffer buffer))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
575 (boundp 'dabbrev-friend-buffer-function)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
576 (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
577
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
578 ;;; 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
579 ;;; 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
580 (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
581 (save-excursion
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
582 (let ((expansion nil))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
583 (and dabbrev--last-expansion-location
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
584 (goto-char dabbrev--last-expansion-location))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
585 (let ((case-fold-search ignore-case)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
586 (count n))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
587 (while (and (> count 0)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
588 (setq expansion (dabbrev--search abbrev
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
589 reverse
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
590 ignore-case)))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
591 (setq count (1- count))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
592 (and expansion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
593 (setq dabbrev--last-expansion-location (point)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
594 expansion)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
595
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
596 ;;; Find all expansions of ABBREV
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
597 (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
598 (let ((all-expansions nil)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
599 expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
600 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
601 (goto-char (point-min))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
602 (while (setq expansion (dabbrev--find-expansion abbrev -1 ignore-case))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
603 (push expansion all-expansions)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
604 all-expansions))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
605
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
606 (defun dabbrev--scanning-message ()
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
607 (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
608
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
609 ;;; Find one occasion of ABBREV.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
610 ;;; 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
611 ;;; 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
612 ;;; 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
613 ;;; 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
614 (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
615 (let (expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
616 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
617 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
618 (dabbrev--last-buffer
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
619 (set-buffer dabbrev--last-buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
620 (dabbrev--scanning-message))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
621 ((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
622 (window-minibuffer-p (selected-window)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
623 (set-buffer (dabbrev--minibuffer-origin))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
624 ;; 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
625 ;; the top and down.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
626 (goto-char (point-min))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
627 (setq direction -1)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
628 (dabbrev--scanning-message)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
629 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
630 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
631 ;; Look backwards
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
632 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
633 ((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
634 (>= direction 0)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
635 (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
636 (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
637 (max 1 direction)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
638 ignore-case)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
639 expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
640 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
641 ;; Look forward
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
642 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
643 ((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
644 dabbrev--last-buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
645 (<= direction 0)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
646 (setq dabbrev--last-direction -1)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
647 (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
648 (max 1 (- direction))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
649 ignore-case)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
650 expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
651 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
652 ;; Look in other buffers.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
653 ;; 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
654 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
655 (t
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
656 (setq dabbrev--last-direction -1)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
657 ;; 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
658 (or dabbrev--friend-buffer-list
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
659 dabbrev--last-buffer
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
660 (setq dabbrev--friend-buffer-list
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
661 (mapcar (function get-buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
662 dabbrev-search-these-buffers-only))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
663 (not dabbrev--check-other-buffers)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
664 (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
665 (progn
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
666 (setq dabbrev--check-other-buffers
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
667 (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
668 (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
669 (setq dabbrev--friend-buffer-list
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
670 (funcall dabbrev-select-buffers-function))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
671 (if dabbrev-check-rest-of-buffers
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
672 (setq non-friend-buffer-list
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
673 (nreverse
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
674 (dabbrev-filter-elements
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
675 buffer (buffer-list)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
676 (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
677 dabbrev--friend-buffer-list
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
678 (append dabbrev--friend-buffer-list
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
679 non-friend-buffer-list)))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
680 ;; Walk through the buffers
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
681 (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
682 (setq dabbrev--last-buffer
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
683 (car dabbrev--friend-buffer-list))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
684 (setq dabbrev--friend-buffer-list
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
685 (cdr dabbrev--friend-buffer-list))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
686 (set-buffer dabbrev--last-buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
687 (dabbrev--scanning-message)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
688 (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
689 (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
690 expansion)))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
691
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
692 (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
693 (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
694 (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
695 (replace-match string fixedcase literal)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
696
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
697 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
698 ;;; 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
699 ;;; 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
700 ;;; 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
701 ;;; EXPANSION is the expansion substring.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
702 (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
703 ;;(undo-boundary)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
704 (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
705 (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
706 (string= abbrev (downcase abbrev)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
707 (eval dabbrev-case-replace))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
708 (and nil use-case-replace
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
709 (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
710 (setq expansion (concat abbrev expansion)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
711 (if old
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 (save-excursion
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
713 (search-backward old))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
714 ;;(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
715 (search-backward abbrev))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
716 ;; 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
717 ;; 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
718 ;; 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
719 (dabbrev--safe-replace-match expansion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
720 (not use-case-replace)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
721 t)))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
724 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
725 ;;; Search function used by dabbrevs library.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
727 ;;; 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
728 ;;; 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
729 ;;; 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
730 ;;; 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
731 ;;; 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
732 ;;; 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
733 ;;; 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
734 ;;; case for return.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
736 ;;; 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
737 ;;; `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
738 ;;; by dabbrev-re-expand.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
740 ;;; Value is the expansion, or nil if not found.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
742 (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
743 (save-match-data
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
744 (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
745 "\\(" dabbrev--abbrev-char-regexp "\\)"))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
746 (pattern2 (concat (regexp-quote abbrev)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
747 "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)"))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
748 (found-string nil))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
749 ;; Limited search.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
750 (save-restriction
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
751 (and dabbrev-limit
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
752 (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
753 (+ (point)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
754 (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
755 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
756 ;; 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
757 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
758 (while (and (not found-string)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
759 (if reverse
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
760 (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
761 (re-search-forward pattern1 nil t)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
762 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
763 ((progn
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
764 (goto-char (match-beginning 0))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
765 (dabbrev--goto-start-of-abbrev)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
766 (/= (point) (match-beginning 0)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
767 ;; Prefix of found abbreviation not OK
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
768 nil)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
769 (t
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
770 (goto-char (match-beginning 0))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
771 (re-search-forward pattern2)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
772 (setq found-string
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
773 (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
774 (and ignore-case (setq found-string (downcase found-string)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
775 ;; Throw away if found in table
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
776 (if (dabbrev-filter-elements
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
777 table-string dabbrev--last-table
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
778 (string= found-string table-string))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
779 (setq found-string nil))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
780 (if reverse
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
781 (goto-char (match-beginning 0))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
782 (goto-char (match-end 0))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
783 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
784 (found-string
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
785 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
786 ;; Put in `dabbrev--last-table' and decide if we should return
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
787 ;; result or (downcase result)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
788 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
789 (push found-string dabbrev--last-table)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
790 (let ((result (buffer-substring (match-beginning 0) (match-end 0))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
791 (if (and ignore-case (eval dabbrev-case-replace))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
792 (downcase result)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
793 result))))))))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
795 (provide 'dabbrev)
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
796
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
797 ;; dabbrev.el ends here
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 267
diff changeset
798
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 267
diff changeset
799