annotate lisp/dabbrev.el @ 32917:0d78af57cddd

Various updates.
author Dave Love <fx@gnu.org>
date Thu, 26 Oct 2000 15:59:48 +0000
parents edb654a13bf1
children 51c08e149a23
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
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
2
28486
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
3 ;; Copyright (C) 1985, 86, 92, 94, 96, 1997, 2000
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
4 ;; Free Software Foundation, Inc.
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
5
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
6 ;; Author: Don Morrison
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
7 ;; 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
8 ;; Created: 16 Mars 1992
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
9 ;; Lindberg's last update version: 5.7
22250
a77d473867b8 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21669
diff changeset
10 ;; Keywords: abbrev expand completion convenience
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
12 ;; This file is part of GNU Emacs.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
13
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
17 ;; any later version.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
18
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; GNU General Public License for more details.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
23
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
27 ;; Boston, MA 02111-1307, USA.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
29 ;;; Commentary:
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
31 ;; 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
32 ;; 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
33 ;; them.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
34 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
35 ;; 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
36 ;; 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
37 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
38 ;; 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
39 ;; features of this package.
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 ;;; 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
42
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
43 ;; 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
44 ;; 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
45 ;; dabbrev-case-replace nil t
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
46 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
47 ;; 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
48 ;; (set (make-local-variable 'dabbrev-case-replace) nil)
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13501
diff changeset
49 ;; Then you don't interfere with other modes.
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
50 ;;
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
51 ;; 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
52 ;; (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
53 ;; `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
54 ;; 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
55
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
56 ;; 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
57 ;; 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
58 ;; 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
59
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
60 ;; 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
61 ;; the article for expansion):
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
62 ;; (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
63 ;; (lambda (buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
64 ;; (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
65 ;; (set-buffer buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
66 ;; (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
67
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
68
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
69 ;; Known bugs and limitations.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
70 ;; - 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
71 ;; minibuffer.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
72 ;; - 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
73 ;; 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
74
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
75 ;; Future enhancements
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
76 ;; - 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
77 ;; - 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
78 ;; the nearest expansion.
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
79 ;; - 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
80 ;; 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
81
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
82 ;;; These people gave suggestions:
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
83 ;; [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
84 ;; [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
85 ;; [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
86 ;; [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
87 ;; [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
88 ;; [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
89 ;; [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
90 ;; [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
91 ;; [Petri] Petri Raitio <per@tekla.fi>
20604
cb1af13d913c (dabbrev-ignored-buffer-names): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19827
diff changeset
92 ;; [ejb] Jay Berkenbilt <ejb@ql.org>
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
93 ;; [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
94 ;; ... and to all the people who have participated in the beta tests.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
96 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 793
diff changeset
97
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
98 ;;----------------------------------------------------------------
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
99 ;; Customization variables
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
100 ;;----------------------------------------------------------------
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
101
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
102 (defgroup dabbrev nil
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
103 "Dynamic Abbreviations"
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
104 :tag "Dynamic Abbreviations"
22250
a77d473867b8 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21669
diff changeset
105 :group 'abbrev
a77d473867b8 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21669
diff changeset
106 :group 'convenience)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
107
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
108 (defcustom dabbrev-backward-only nil
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
109 "*If non-nil, `dabbrev-expand' only looks backwards."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
110 :type 'boolean
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
111 :group 'dabbrev)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
112
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
113 (defcustom dabbrev-limit nil
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
114 "*Limits region searched by `dabbrev-expand' to this many chars away."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
115 :type '(choice (const :tag "off" nil)
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
116 integer)
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
117 :group 'dabbrev)
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
118
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
119 (defcustom dabbrev-abbrev-skip-leading-regexp nil
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
120 "*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
121
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
122 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
123 in which variable names may appear with or without a leading `$'.
19308
f7a109d11c10 (dabbrev-abbrev-skip-leading-regexp): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17864
diff changeset
124 \(For example, in Makefiles.\)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
125
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
126 Set this to nil if no characters should be skipped."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
127 :type '(choice regexp
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
128 (const :tag "off" nil))
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
129 :group 'dabbrev)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
130
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
131 (defcustom dabbrev-case-fold-search 'case-fold-search
17711
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
132 "*Control whether dabbrev searches should ignore case.
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
133 A value of nil means case is significant.
17711
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
134 A value of `case-fold-search' means case is significant
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
135 if `case-fold-search' is nil.
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
136 Any other non-nil version means case is not significant."
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
137 :type '(choice (const :tag "off" nil)
22572
b1cba467a906 (dabbrev-case-fold-search, dabbrev-case-replace,
Andreas Schwab <schwab@suse.de>
parents: 22250
diff changeset
138 (const :tag "like search" case-fold-search)
b1cba467a906 (dabbrev-case-fold-search, dabbrev-case-replace,
Andreas Schwab <schwab@suse.de>
parents: 22250
diff changeset
139 (other :tag "on" t))
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
140 :group 'dabbrev)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
141
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
142 (defcustom dabbrev-upcase-means-case-search nil
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
143 "*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
144 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
145
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
146 This variable has an effect only when the value of
17711
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
147 `dabbrev-case-fold-search' says to ignore case."
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
148 :type 'boolean
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
149 :group 'dabbrev)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
150
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
151 (defcustom dabbrev-case-replace 'case-replace
17711
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
152 "*Controls whether dabbrev preserves case when expanding the abbreviation.
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
153 A value of nil means preserve case.
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
154 A value of `case-replace' means preserve case if `case-replace' is nil.
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
155 Any other non-nil version means do not preserve case.
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
156
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
157 This variable has an effect only when the value of
17711
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
158 `dabbrev-case-fold-search' specifies to ignore case."
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
159 :type '(choice (const :tag "off" nil)
22572
b1cba467a906 (dabbrev-case-fold-search, dabbrev-case-replace,
Andreas Schwab <schwab@suse.de>
parents: 22250
diff changeset
160 (const :tag "like M-x query-replace" case-replace)
b1cba467a906 (dabbrev-case-fold-search, dabbrev-case-replace,
Andreas Schwab <schwab@suse.de>
parents: 22250
diff changeset
161 (other :tag "on" t))
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
162 :group 'dabbrev)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
163
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
164 (defcustom dabbrev-abbrev-char-regexp nil
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
165 "*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
166 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
167
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
168 Set this variable to \"\\\\sw\" if you want ordinary words or
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
169 \"\\\\sw\\\\|\\\\s_\" if you want symbols (including characters whose
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
170 syntax is \"symbol\" as well as those whose syntax is \"word\".
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
171
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
172 The value nil has a special meaning: the abbreviation is from point to
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
173 previous word-start, but the search is for symbols.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
175 For instance, if you are programming in Lisp, `yes-or-no-p' is a symbol,
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
176 while `yes', `or', `no' and `p' are considered words. If this
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
177 variable is nil, then expanding `yes-or-no-' looks for a symbol
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
178 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
179 \"\\\\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
180 `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
181 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
182 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
183
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
184 The recommended value is \"\\\\sw\\\\|\\\\s_\"."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
185 :type '(choice (const nil)
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
186 regexp)
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
187 :group 'dabbrev)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
188
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
189 (defcustom dabbrev-check-all-buffers t
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
190 "*Non-nil means dabbrev package should search *all* buffers.
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
191
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
192 Dabbrev always searches the current buffer first. Then, if
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
193 `dabbrev-check-other-buffers' says so, it searches the buffers
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
194 designated by `dabbrev-select-buffers-function'.
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
195
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
196 Then, if `dabbrev-check-all-buffers' is non-nil, dabbrev searches
28486
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
197 all the other buffers, except those named in `dabbrev-ignored-buffer-names',
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
198 or matched by `dabbrev-ignored-regexps'."
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
199 :type 'boolean
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
200 :group 'dabbrev)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
201
22608
e1e08f5e0662 (dabbrev-ignored-buffer-names): Fix typo. Add *Buffer List*.
Richard M. Stallman <rms@gnu.org>
parents: 22572
diff changeset
202 (defcustom dabbrev-ignored-buffer-names '("*Messages*" "*Buffer List*")
28486
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
203 "*List of buffer names that dabbrev should not check.
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
204 See also `dabbrev-ignored-regexps'."
20604
cb1af13d913c (dabbrev-ignored-buffer-names): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19827
diff changeset
205 :type '(repeat (string :tag "Buffer name"))
21669
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21153
diff changeset
206 :group 'dabbrev
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21153
diff changeset
207 :version "20.3")
20604
cb1af13d913c (dabbrev-ignored-buffer-names): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19827
diff changeset
208
28486
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
209 (defcustom dabbrev-ignored-regexps nil
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
210 "*List of regexps matching names of buffers that dabbrev should not check.
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
211 See also `dabbrev-ignored-buffer-names'."
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
212 :type '(repeat regexp)
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
213 :group 'dabbrev
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
214 :version "21.1")
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
215
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
216 (defcustom dabbrev-check-other-buffers t
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
217 "*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
218
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
219 nil: Don't look in other buffers.
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
220 t: Also look for expansions in the buffers pointed out by
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
221 `dabbrev-select-buffers-function'.
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
222 Anything else: When we can't find any more expansions in
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
223 the current buffer, then ask the user whether to look in other
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
224 buffers too.
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
225
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
226 The default value is t."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
227 :type '(choice (const :tag "off" nil)
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
228 (const :tag "on" t)
22572
b1cba467a906 (dabbrev-case-fold-search, dabbrev-case-replace,
Andreas Schwab <schwab@suse.de>
parents: 22250
diff changeset
229 (other :tag "ask" other))
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
230 :group 'dabbrev)
10230
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 ;; 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
233 ;; 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
234 ;; 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
235 (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
236 "A function that selects buffers that should be searched by dabbrev.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
237 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
238 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
239 an example.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
240
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
241 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
242
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
243 (defcustom dabbrev-friend-buffer-function 'dabbrev--same-major-mode-p
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
244 "*A function to decide whether dabbrev should search OTHER-BUFFER.
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
245 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
246 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
247 `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
248
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
249 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
250 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
251 `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
252
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
253 A mode setting this variable should make it buffer local."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
254 :type 'function
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
255 :group 'dabbrev)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
256
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17263
diff changeset
257 (defcustom 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
258 "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
259 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
260 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
261 this list.")
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
262
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
263 ;;----------------------------------------------------------------
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
264 ;; Internal variables
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
265 ;;----------------------------------------------------------------
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
266
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
267 ;; 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
268 (defvar dabbrev--last-obarray nil)
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 ;; 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
271 (defvar dabbrev--last-table nil)
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 ;; 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
274 (defvar dabbrev--last-abbreviation nil)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
275
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
276 ;; Location last abbreviation began
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
277 (defvar dabbrev--last-abbrev-location nil)
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
279 ;; Direction of last dabbrevs search
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
280 (defvar dabbrev--last-direction 0)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
281
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
282 ;; Last expansion of an abbreviation.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
283 (defvar dabbrev--last-expansion nil)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
284
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
285 ;; 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
286 (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
287
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
288 ;; 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
289 (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
290
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
291 ;; 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
292 (defvar dabbrev--last-buffer nil)
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 ;; 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
295 (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
296
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
297 ;; 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
298 (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
299
15834
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
300 ;; Non-nil means we should upcase
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
301 ;; when copying successive words.
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
302 (defvar dabbrev--last-case-pattern nil)
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
303
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
304 ;; Same as dabbrev-check-other-buffers, but is set for every expand.
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
305 (defvar dabbrev--check-other-buffers dabbrev-check-other-buffers)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
306
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
307 ;; 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
308 (defvar dabbrev--abbrev-char-regexp nil)
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
310 ;;----------------------------------------------------------------
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
311 ;; Macros
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
312 ;;----------------------------------------------------------------
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
313
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
314 ;;; 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
315 (defsubst dabbrev--minibuffer-origin ()
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
316 (car (cdr (buffer-list))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
317
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
318 ;; 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
319 ;; 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
320 ;; 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
321 ;; if CONDITION evaluates non-nil.
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
322 (defmacro dabbrev-filter-elements (element list condition)
26459
1ef9d70dfb0f * dabbrev.el (dabbrev-filter-elements): Use the new backquote syntax.
Sam Steingold <sds@gnu.org>
parents: 23306
diff changeset
323 `(let (dabbrev-result dabbrev-tail ,element)
1ef9d70dfb0f * dabbrev.el (dabbrev-filter-elements): Use the new backquote syntax.
Sam Steingold <sds@gnu.org>
parents: 23306
diff changeset
324 (setq dabbrev-tail ,list)
1ef9d70dfb0f * dabbrev.el (dabbrev-filter-elements): Use the new backquote syntax.
Sam Steingold <sds@gnu.org>
parents: 23306
diff changeset
325 (while dabbrev-tail
1ef9d70dfb0f * dabbrev.el (dabbrev-filter-elements): Use the new backquote syntax.
Sam Steingold <sds@gnu.org>
parents: 23306
diff changeset
326 (setq ,element (car dabbrev-tail))
1ef9d70dfb0f * dabbrev.el (dabbrev-filter-elements): Use the new backquote syntax.
Sam Steingold <sds@gnu.org>
parents: 23306
diff changeset
327 (if ,condition
1ef9d70dfb0f * dabbrev.el (dabbrev-filter-elements): Use the new backquote syntax.
Sam Steingold <sds@gnu.org>
parents: 23306
diff changeset
328 (setq dabbrev-result (cons ,element dabbrev-result)))
1ef9d70dfb0f * dabbrev.el (dabbrev-filter-elements): Use the new backquote syntax.
Sam Steingold <sds@gnu.org>
parents: 23306
diff changeset
329 (setq dabbrev-tail (cdr dabbrev-tail)))
1ef9d70dfb0f * dabbrev.el (dabbrev-filter-elements): Use the new backquote syntax.
Sam Steingold <sds@gnu.org>
parents: 23306
diff changeset
330 (nreverse dabbrev-result)))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
331
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
332 ;;----------------------------------------------------------------
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
333 ;; Exported functions
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
334 ;;----------------------------------------------------------------
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
335
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
336 ;;;###autoload
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
337 (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
338 ;;;??? Do we want this?
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
339 ;;;###autoload
10251
bf1c7dcc69db (esc-map): Delete excess closeparen.
Richard M. Stallman <rms@gnu.org>
parents: 10241
diff changeset
340 (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
341
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
342 ;;;###autoload
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
343 (defun dabbrev-completion (&optional arg)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
344 "Completion on current word.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
345 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
346 and presents suggestions for completion.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
347
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
348 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
349 function pointed out by `dabbrev-friend-buffer-function' to find the
10232
ace1fffa8d96 (dabbrev-completion): Now searches all buffers when given prefix arg 16.
Richard M. Stallman <rms@gnu.org>
parents: 10231
diff changeset
350 completions.
ace1fffa8d96 (dabbrev-completion): Now searches all buffers when given prefix arg 16.
Richard M. Stallman <rms@gnu.org>
parents: 10231
diff changeset
351
ace1fffa8d96 (dabbrev-completion): Now searches all buffers when given prefix arg 16.
Richard M. Stallman <rms@gnu.org>
parents: 10231
diff changeset
352 If the prefix argument is 16 (which comes from C-u C-u),
ace1fffa8d96 (dabbrev-completion): Now searches all buffers when given prefix arg 16.
Richard M. Stallman <rms@gnu.org>
parents: 10231
diff changeset
353 then it searches *all* buffers.
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
354
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
355 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
356 if there is a suitable one already."
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
358 (interactive "*P")
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
359 (dabbrev--reset-global-variables)
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
360 (let* ((dabbrev-check-other-buffers (and arg t))
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
361 (dabbrev-check-all-buffers
10232
ace1fffa8d96 (dabbrev-completion): Now searches all buffers when given prefix arg 16.
Richard M. Stallman <rms@gnu.org>
parents: 10231
diff changeset
362 (and arg (= (prefix-numeric-value arg) 16)))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
363 (abbrev (dabbrev--abbrev-at-point))
17711
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
364 (ignore-case-p (and (if (eq dabbrev-case-fold-search 'case-fold-search)
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
365 case-fold-search
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
366 dabbrev-case-fold-search)
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
367 (or (not dabbrev-upcase-means-case-search)
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
368 (string= abbrev (downcase abbrev)))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
369 (my-obarray dabbrev--last-obarray)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
370 init)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
371 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
372 (if (and (null arg)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
373 my-obarray
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
374 (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
375 (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
376 (eq dabbrev--last-completion-buffer
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
377 (dabbrev--minibuffer-origin))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
378 dabbrev--last-abbreviation
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
379 (>= (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
380 (string= dabbrev--last-abbreviation
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
381 (substring abbrev 0
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
382 (length dabbrev--last-abbreviation)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
383 (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
384 ;; 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
385 nil
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
386 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
387 ;; New abbreviation to expand.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
388 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
389 (setq dabbrev--last-abbreviation abbrev)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
390 ;; Find all expansion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
391 (let ((completion-list
15751
022815791330 (dabbrev--search): Don't downcase the result here.
Richard M. Stallman <rms@gnu.org>
parents: 15652
diff changeset
392 (dabbrev--find-all-expansions abbrev ignore-case-p))
022815791330 (dabbrev--search): Don't downcase the result here.
Richard M. Stallman <rms@gnu.org>
parents: 15652
diff changeset
393 (completion-ignore-case ignore-case-p))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
394 ;; 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
395 (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
396 (or (> (length my-obarray) 0)
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
397 (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
398 abbrev
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
399 (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
400 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
401 ((or (not ignore-case-p)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
402 (not dabbrev-case-replace))
29077
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
403 (mapc (function (lambda (string)
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
404 (intern string my-obarray)))
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
405 completion-list))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
406 ((string= abbrev (upcase abbrev))
29077
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
407 (mapc (function (lambda (string)
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
408 (intern (upcase string) my-obarray)))
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
409 completion-list))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
410 ((string= (substring abbrev 0 1)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
411 (upcase (substring abbrev 0 1)))
29077
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
412 (mapc (function (lambda (string)
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
413 (intern (capitalize string) my-obarray)))
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
414 completion-list))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
415 (t
29077
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
416 (mapc (function (lambda (string)
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
417 (intern (downcase string) my-obarray)))
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
418 completion-list)))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
419 (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
420 (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
421 ;; Find the longest common string.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
422 (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
423 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
424 ;; 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
425 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
426 (or (stringp init)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
427 (setq init abbrev))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
428 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
429 ;; * 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
430 ((and (not (string-equal init ""))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
431 (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
432 (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
433 (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
434 (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
435 (message "The only possible completion"))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
436 (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
437 (t
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
438 ;; * 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
439 (message "Making completion list...")
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
440 (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
441 (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
442 (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
443 (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
444 (message nil))))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 ;;;###autoload
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (defun dabbrev-expand (arg)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 "Expand previous word \"dynamically\".
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
450 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
451 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
452 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
453 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
454 `dabbrev-friend-buffer-function'.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
456 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
457 possibility. A negative argument says search forward.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 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
460 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
461 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
462
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
463 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
464 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
465
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
466 See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 (interactive "*P")
15834
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
468 (let (abbrev record-case-pattern
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
469 expansion old direction (orig-point (point)))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 ;; abbrev -- the abbrev to expand
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 ;; expansion -- the expansion found (eventually) or nil until then
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 ;; old -- the text currently in the buffer
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 ;; (the abbrev, or the previously-made expansion)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 (save-excursion
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (if (and (null arg)
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
476 (markerp dabbrev--last-abbrev-location)
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
477 (marker-position dabbrev--last-abbrev-location)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
478 (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
479 (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
480 (= dabbrev--last-abbrev-location
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
481 (point)))))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
482 ;; Find a different expansion for the same abbrev as last time.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 (progn
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
484 (setq abbrev dabbrev--last-abbreviation)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
485 (setq old dabbrev--last-expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
486 (setq direction dabbrev--last-direction))
11976
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
487 ;; If the user inserts a space after expanding
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
488 ;; and then asks to expand again, always fetch the next word.
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
489 (if (and (eq (preceding-char) ?\ )
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
490 (markerp dabbrev--last-abbrev-location)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
491 (marker-position dabbrev--last-abbrev-location)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
492 (= (point) (1+ dabbrev--last-abbrev-location)))
15834
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
493 (progn
11976
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
494 ;; The "abbrev" to expand is just the space.
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
495 (setq abbrev " ")
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
496 (save-excursion
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
497 (if dabbrev--last-buffer
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
498 (set-buffer dabbrev--last-buffer))
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
499 ;; Find the end of the last "expansion" word.
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
500 (if (or (eq dabbrev--last-direction 1)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
501 (and (eq dabbrev--last-direction 0)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
502 (< dabbrev--last-expansion-location (point))))
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
503 (setq dabbrev--last-expansion-location
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
504 (+ dabbrev--last-expansion-location
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
505 (length dabbrev--last-expansion))))
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
506 (goto-char dabbrev--last-expansion-location)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
507 ;; Take the following word, with intermediate separators,
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
508 ;; as our expansion this time.
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
509 (re-search-forward
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
510 (concat "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)"))
17864
c662a8633943 (dabbrev-expand, dabbrev--abbrev-at-point)
Richard M. Stallman <rms@gnu.org>
parents: 17711
diff changeset
511 (setq expansion (buffer-substring-no-properties
c662a8633943 (dabbrev-expand, dabbrev--abbrev-at-point)
Richard M. Stallman <rms@gnu.org>
parents: 17711
diff changeset
512 dabbrev--last-expansion-location (point)))
15834
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
513 (if dabbrev--last-case-pattern
15812
63076f19cbc5 (dabbrev-expand): When snarfing consecutive words,
Richard M. Stallman <rms@gnu.org>
parents: 15789
diff changeset
514 (setq expansion (upcase expansion)))
11976
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
515
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
516 ;; Record the end of this expansion, in case we repeat this.
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
517 (setq dabbrev--last-expansion-location (point)))
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
518 ;; Indicate that dabbrev--last-expansion-location is
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
519 ;; at the end of the expansion.
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
520 (setq dabbrev--last-direction -1))
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
521
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
522 ;; We have a different abbrev to expand.
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
523 (dabbrev--reset-global-variables)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
524 (setq direction (if (null arg)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
525 (if dabbrev-backward-only 1 0)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
526 (prefix-numeric-value arg)))
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
527 (setq abbrev (dabbrev--abbrev-at-point))
15834
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
528 (setq record-case-pattern t)
11976
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
529 (setq old nil)))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
530
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
531 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
532 ;; Find the expansion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
533 ;;--------------------------------
11976
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
534 (or expansion
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
535 (setq expansion
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
536 (dabbrev--find-expansion abbrev direction
17711
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
537 (and (if (eq dabbrev-case-fold-search 'case-fold-search)
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
538 case-fold-search
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
539 dabbrev-case-fold-search)
11976
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
540 (or (not dabbrev-upcase-means-case-search)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
541 (string= abbrev (downcase abbrev))))))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
542 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
543 ((not expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
544 (dabbrev--reset-global-variables)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
545 (if old
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
546 (save-excursion
12724
c3cb2b06e05f (dabbrev-expand): Save previous point for undo.
Richard M. Stallman <rms@gnu.org>
parents: 12555
diff changeset
547 (setq buffer-undo-list (cons orig-point buffer-undo-list))
13256
d9c469af1ee0 (dabbrev-expand): When no more expansions,
Richard M. Stallman <rms@gnu.org>
parents: 12724
diff changeset
548 ;; Put back the original abbrev with its original case pattern.
d9c469af1ee0 (dabbrev-expand): When no more expansions,
Richard M. Stallman <rms@gnu.org>
parents: 12724
diff changeset
549 (search-backward old)
d9c469af1ee0 (dabbrev-expand): When no more expansions,
Richard M. Stallman <rms@gnu.org>
parents: 12724
diff changeset
550 (insert abbrev)
d9c469af1ee0 (dabbrev-expand): When no more expansions,
Richard M. Stallman <rms@gnu.org>
parents: 12724
diff changeset
551 (delete-region (point) (+ (point) (length old)))))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
552 (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
553 (if old " further" "") abbrev))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
554 (t
29294
5784ff2ff5df (dabbrev-expand): Don't display messages in the
Gerd Moellmann <gerd@gnu.org>
parents: 29077
diff changeset
555 (if (not (or (eq dabbrev--last-buffer dabbrev--last-buffer-found)
5784ff2ff5df (dabbrev-expand): Don't display messages in the
Gerd Moellmann <gerd@gnu.org>
parents: 29077
diff changeset
556 (minibuffer-window-active-p (selected-window))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
557 (progn
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
558 (message "Expansion found in '%s'"
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
559 (buffer-name dabbrev--last-buffer))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
560 (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
561 (message nil))
11976
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
562 (if (and (or (eq (current-buffer) dabbrev--last-buffer)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
563 (null dabbrev--last-buffer))
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
564 (numberp dabbrev--last-expansion-location)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
565 (and (> dabbrev--last-expansion-location (point))))
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
566 (setq dabbrev--last-expansion-location
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
567 (copy-marker dabbrev--last-expansion-location)))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
568 ;; Success: stick it in and return.
12724
c3cb2b06e05f (dabbrev-expand): Save previous point for undo.
Richard M. Stallman <rms@gnu.org>
parents: 12555
diff changeset
569 (setq buffer-undo-list (cons orig-point buffer-undo-list))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
570 (dabbrev--substitute-expansion old abbrev expansion)
15834
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
571
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
572 ;; If we are not copying successive words now,
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
573 ;; set dabbrev--last-case-pattern.
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
574 (and record-case-pattern
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
575 (setq dabbrev--last-case-pattern
17711
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
576 (and (if (eq dabbrev-case-fold-search 'case-fold-search)
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
577 case-fold-search
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
578 dabbrev-case-fold-search)
15834
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
579 (not dabbrev-upcase-means-case-search)
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
580 (equal abbrev (upcase abbrev)))))
71ede15e1ca3 (dabbrev--last-case-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15812
diff changeset
581
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
582 ;; Save state for re-expand.
26459
1ef9d70dfb0f * dabbrev.el (dabbrev-filter-elements): Use the new backquote syntax.
Sam Steingold <sds@gnu.org>
parents: 23306
diff changeset
583 (setq dabbrev--last-expansion expansion)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
584 (setq dabbrev--last-abbreviation abbrev)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
585 (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
586
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
587 ;;----------------------------------------------------------------
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
588 ;; Local functions
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
589 ;;----------------------------------------------------------------
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
590
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
591 ;;; 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
592 (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
593 (eq major-mode
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
594 (save-excursion
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
595 (set-buffer other-buffer)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
596 major-mode)))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
598 ;;; 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
599 ;;; all skip characters.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
600 (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
601 ;; Move backwards over abbrev chars
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
602 (save-match-data
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
603 (if (not (bobp))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
604 (progn
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
605 (forward-char -1)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
606 (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
607 (not (bobp)))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
608 (forward-char -1))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
609 (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
610 (forward-char 1))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
611 (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
612 (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
613 (forward-char 1)))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
614
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
615 ;;; 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
616 (defun dabbrev--abbrev-at-point ()
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
617 ;; Check for error
11976
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
618 (if (bobp)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
619 (error "No possible abbreviation preceding point"))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
620 ;; Return abbrev at point
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
621 (save-excursion
11976
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
622 ;; Record the end of the abbreviation.
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
623 (setq dabbrev--last-abbrev-location (point))
11976
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
624 ;; If we aren't right after an abbreviation,
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
625 ;; move point back to just after one.
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
626 ;; This is so the user can get successive words
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
627 ;; by typing the punctuation followed by M-/.
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
628 (save-match-data
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
629 (if (save-excursion
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
630 (forward-char -1)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
631 (not (looking-at (concat "\\("
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
632 (or dabbrev-abbrev-char-regexp
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
633 "\\sw\\|\\s_")
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
634 "\\)+"))))
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
635 (if (re-search-backward (or dabbrev-abbrev-char-regexp
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
636 "\\sw\\|\\s_")
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
637 nil t)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
638 (forward-char 1)
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
639 (error "No possible abbreviation preceding point"))))
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
640 ;; Now find the beginning of that one.
e862c6697f39 (dabbrev--abbrev-at-point): If point is after
Karl Heuer <kwzh@gnu.org>
parents: 11820
diff changeset
641 (dabbrev--goto-start-of-abbrev)
17864
c662a8633943 (dabbrev-expand, dabbrev--abbrev-at-point)
Richard M. Stallman <rms@gnu.org>
parents: 17711
diff changeset
642 (buffer-substring-no-properties
c662a8633943 (dabbrev-expand, dabbrev--abbrev-at-point)
Richard M. Stallman <rms@gnu.org>
parents: 17711
diff changeset
643 dabbrev--last-abbrev-location (point))))
26459
1ef9d70dfb0f * dabbrev.el (dabbrev-filter-elements): Use the new backquote syntax.
Sam Steingold <sds@gnu.org>
parents: 23306
diff changeset
644
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
645 ;;; Initializes all global variables
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
646 (defun dabbrev--reset-global-variables ()
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
647 ;; 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
648 ;; must not be reset here.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
649 (setq dabbrev--last-table nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
650 dabbrev--last-abbreviation nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
651 dabbrev--last-abbrev-location nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
652 dabbrev--last-direction nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
653 dabbrev--last-expansion nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
654 dabbrev--last-expansion-location nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
655 dabbrev--friend-buffer-list nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
656 dabbrev--last-buffer nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
657 dabbrev--last-buffer-found nil
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
658 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
659 "\\sw\\|\\s_")
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
660 dabbrev--check-other-buffers dabbrev-check-other-buffers))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
662 ;;; 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
663 ;;; 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
664 (defun dabbrev--select-buffers ()
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
665 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
666 (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
667 (set-buffer (dabbrev--minibuffer-origin)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
668 (let ((orig-buffer (current-buffer)))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
669 (dabbrev-filter-elements
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
670 buffer (buffer-list)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
671 (and (not (eq orig-buffer buffer))
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
672 (boundp 'dabbrev-friend-buffer-function)
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
673 (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
674
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
675 ;;; 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
676 ;;; 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
677 (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
678 (save-excursion
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
679 (save-restriction
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
680 (widen)
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
681 (let ((expansion nil))
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
682 (and dabbrev--last-expansion-location
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
683 (goto-char dabbrev--last-expansion-location))
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
684 (let ((case-fold-search ignore-case)
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
685 (count n))
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
686 (while (and (> count 0)
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
687 (setq expansion (dabbrev--search abbrev
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
688 reverse
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
689 ignore-case)))
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
690 (setq count (1- count))))
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
691 (and expansion
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
692 (setq dabbrev--last-expansion-location (point)))
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
693 expansion))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
694
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
695 ;;; Find all expansions of ABBREV
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
696 (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
697 (let ((all-expansions nil)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
698 expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
699 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
700 (goto-char (point-min))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
701 (while (setq expansion (dabbrev--find-expansion abbrev -1 ignore-case))
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
702 (setq all-expansions (cons expansion all-expansions))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
703 all-expansions))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
704
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
705 (defun dabbrev--scanning-message ()
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
706 (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
707
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
708 ;;; Find one occasion of ABBREV.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
709 ;;; 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
710 ;;; 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
711 ;;; 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
712 ;;; 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
713 (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
714 (let (expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
715 (save-excursion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
716 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
717 (dabbrev--last-buffer
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
718 (set-buffer dabbrev--last-buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
719 (dabbrev--scanning-message))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
720 ((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
721 (window-minibuffer-p (selected-window)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
722 (set-buffer (dabbrev--minibuffer-origin))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
723 ;; 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
724 ;; the top and down.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
725 (goto-char (point-min))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
726 (setq direction -1)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
727 (dabbrev--scanning-message)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
728 (cond
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
729 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
730 ;; Look backwards
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
731 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
732 ((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
733 (>= direction 0)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
734 (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
735 (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
736 (max 1 direction)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
737 ignore-case)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
738 expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
739 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
740 ;; Look forward
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
741 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
742 ((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
743 dabbrev--last-buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
744 (<= direction 0)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
745 (setq dabbrev--last-direction -1)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
746 (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
747 (max 1 (- direction))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
748 ignore-case)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
749 expansion)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
750 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
751 ;; Look in other buffers.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
752 ;; 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
753 ;; ------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
754 (t
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
755 (setq dabbrev--last-direction -1)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
756 ;; 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
757 (or dabbrev--friend-buffer-list
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
758 dabbrev--last-buffer
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
759 (setq dabbrev--friend-buffer-list
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
760 (mapcar (function get-buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
761 dabbrev-search-these-buffers-only))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
762 (not dabbrev--check-other-buffers)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
763 (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
764 (progn
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
765 (setq dabbrev--check-other-buffers
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
766 (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
767 (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
768 (setq dabbrev--friend-buffer-list
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
769 (funcall dabbrev-select-buffers-function))
11820
362251066737 (dabbrev-completion): Use mapcar, not mapc.
Richard M. Stallman <rms@gnu.org>
parents: 10251
diff changeset
770 (if dabbrev-check-all-buffers
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
771 (setq non-friend-buffer-list
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
772 (nreverse
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
773 (dabbrev-filter-elements
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
774 buffer (buffer-list)
28486
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
775 (let ((bn (buffer-name buffer)))
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
776 (and (not (member bn dabbrev-ignored-buffer-names))
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
777 (not (memq buffer dabbrev--friend-buffer-list))
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
778 (not
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
779 (let ((tail dabbrev-ignored-regexps)
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
780 (match nil))
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
781 (while (and tail (not match))
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
782 (setq match (string-match (car tail) bn)
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
783 tail (cdr tail)))
7b327ea7706b (dabbrev-ignored-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 26459
diff changeset
784 match))))))
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
785 dabbrev--friend-buffer-list
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
786 (append dabbrev--friend-buffer-list
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
787 non-friend-buffer-list)))))
13257
679fc0917c11 (dabbrev--find-expansion): Move buffers that are visible on the screen
Richard M. Stallman <rms@gnu.org>
parents: 13256
diff changeset
788 ;; Move buffers that are visible on the screen
23306
4beab023a902 (dabbrev--find-expansion): Don't scan the current buffer
Karl Heuer <kwzh@gnu.org>
parents: 22608
diff changeset
789 ;; to the front of the list. Remove the current buffer.
4beab023a902 (dabbrev--find-expansion): Don't scan the current buffer
Karl Heuer <kwzh@gnu.org>
parents: 22608
diff changeset
790 (when dabbrev--friend-buffer-list
30002
edb654a13bf1 (dabbrev--find-expansion): Use walk-windows instead
Gerd Moellmann <gerd@gnu.org>
parents: 29294
diff changeset
791 (walk-windows (lambda (w)
edb654a13bf1 (dabbrev--find-expansion): Use walk-windows instead
Gerd Moellmann <gerd@gnu.org>
parents: 29294
diff changeset
792 (unless (eq w (selected-window))
edb654a13bf1 (dabbrev--find-expansion): Use walk-windows instead
Gerd Moellmann <gerd@gnu.org>
parents: 29294
diff changeset
793 (setq dabbrev--friend-buffer-list
edb654a13bf1 (dabbrev--find-expansion): Use walk-windows instead
Gerd Moellmann <gerd@gnu.org>
parents: 29294
diff changeset
794 (cons (window-buffer w)
edb654a13bf1 (dabbrev--find-expansion): Use walk-windows instead
Gerd Moellmann <gerd@gnu.org>
parents: 29294
diff changeset
795 (delq (window-buffer w)
edb654a13bf1 (dabbrev--find-expansion): Use walk-windows instead
Gerd Moellmann <gerd@gnu.org>
parents: 29294
diff changeset
796 dabbrev--friend-buffer-list))))))
23306
4beab023a902 (dabbrev--find-expansion): Don't scan the current buffer
Karl Heuer <kwzh@gnu.org>
parents: 22608
diff changeset
797 (setq dabbrev--friend-buffer-list
4beab023a902 (dabbrev--find-expansion): Don't scan the current buffer
Karl Heuer <kwzh@gnu.org>
parents: 22608
diff changeset
798 (delq (current-buffer) dabbrev--friend-buffer-list)))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
799 ;; Walk through the buffers
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
800 (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
801 (setq dabbrev--last-buffer
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
802 (car dabbrev--friend-buffer-list))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
803 (setq dabbrev--friend-buffer-list
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
804 (cdr dabbrev--friend-buffer-list))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
805 (set-buffer dabbrev--last-buffer)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
806 (dabbrev--scanning-message)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
807 (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
808 (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
809 expansion)))))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
810
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
811 (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
812 (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
813 (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
814 (replace-match string fixedcase literal)))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
815
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
816 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
817 ;;; 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
818 ;;; 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
819 ;;; 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
820 ;;; EXPANSION is the expansion substring.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
821 (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
822 ;;(undo-boundary)
17711
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
823 (let ((use-case-replace (and (if (eq dabbrev-case-fold-search 'case-fold-search)
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
824 case-fold-search
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
825 dabbrev-case-fold-search)
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
826 (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
827 (string= abbrev (downcase abbrev)))
17711
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
828 (if (eq dabbrev-case-replace 'case-replace)
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
829 case-replace
3484851d83b9 (dabbrev-case-replace, dabbrev-case-fold-search):
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
830 dabbrev-case-replace))))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
831 (and nil use-case-replace
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
832 (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
833 (setq expansion (concat abbrev expansion)))
17263
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
834 ;; If the expansion has mixed case
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
835 ;; and it is not simply a capitalized word,
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
836 ;; or if the abbrev has mixed case,
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
837 ;; and if the given abbrev's case pattern
15751
022815791330 (dabbrev--search): Don't downcase the result here.
Richard M. Stallman <rms@gnu.org>
parents: 15652
diff changeset
838 ;; matches the start of the expansion,
022815791330 (dabbrev--search): Don't downcase the result here.
Richard M. Stallman <rms@gnu.org>
parents: 15652
diff changeset
839 ;; copy the expansion's case
022815791330 (dabbrev--search): Don't downcase the result here.
Richard M. Stallman <rms@gnu.org>
parents: 15652
diff changeset
840 ;; instead of downcasing all the rest.
17263
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
841 (let ((expansion-rest (substring expansion 1)))
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
842 (if (and (not (and (or (string= expansion-rest (downcase expansion-rest))
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
843 (string= expansion-rest (upcase expansion-rest)))
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
844 (or (string= abbrev (downcase abbrev))
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
845 (string= abbrev (upcase abbrev)))))
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
846 (string= abbrev
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
847 (substring expansion 0 (length abbrev))))
b712c50d2c84 (dabbrev--substitute-expansion):
Richard M. Stallman <rms@gnu.org>
parents: 15834
diff changeset
848 (setq use-case-replace nil)))
15812
63076f19cbc5 (dabbrev-expand): When snarfing consecutive words,
Richard M. Stallman <rms@gnu.org>
parents: 15789
diff changeset
849 (if (equal abbrev " ")
63076f19cbc5 (dabbrev-expand): When snarfing consecutive words,
Richard M. Stallman <rms@gnu.org>
parents: 15789
diff changeset
850 (setq use-case-replace nil))
63076f19cbc5 (dabbrev-expand): When snarfing consecutive words,
Richard M. Stallman <rms@gnu.org>
parents: 15789
diff changeset
851 (if use-case-replace
63076f19cbc5 (dabbrev-expand): When snarfing consecutive words,
Richard M. Stallman <rms@gnu.org>
parents: 15789
diff changeset
852 (setq expansion (downcase expansion)))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
853 (if old
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
854 (save-excursion
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
855 (search-backward old))
21153
183817081a96 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 20604
diff changeset
856 ;;(set-match-data (list (point-marker) (point-marker)))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
857 (search-backward abbrev))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
858 ;; 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
859 ;; 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
860 ;; 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
861 (dabbrev--safe-replace-match expansion
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
862 (not use-case-replace)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
863 t)))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
864
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
865
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
866 ;;;----------------------------------------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
867 ;;; Search function used by dabbrevs library.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
868
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
869 ;;; 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
870 ;;; is t for reverse search, nil for forward. Variable dabbrev-limit
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13501
diff changeset
871 ;;; controls the maximum search region size. Third argument IGNORE-CASE
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
872 ;;; 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
873 ;;; 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
874 ;;; 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
875 ;;; 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
876 ;;; case for return.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
877
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
878 ;;; 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
879 ;;; `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
880 ;;; by dabbrev-re-expand.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
881
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
882 ;;; Value is the expansion, or nil if not found.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
884 (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
885 (save-match-data
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
886 (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
887 "\\(" dabbrev--abbrev-char-regexp "\\)"))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
888 (pattern2 (concat (regexp-quote abbrev)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
889 "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)"))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
890 (found-string nil))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
891 ;; Limited search.
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
892 (save-restriction
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
893 (and dabbrev-limit
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
894 (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
895 (+ (point)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
896 (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
897 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
898 ;; 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
899 ;;--------------------------------
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
900 (while (and (not found-string)
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
901 (if reverse
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
902 (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
903 (re-search-forward pattern1 nil t)))
12555
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
904 (goto-char (match-beginning 0))
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
905 ;; In case we matched in the middle of a word,
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
906 ;; back up to start of word and verify we still match.
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
907 (dabbrev--goto-start-of-abbrev)
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
908
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
909 (if (not (looking-at pattern1))
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
910 nil
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
911 ;; We have a truly valid match. Find the end.
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
912 (re-search-forward pattern2)
17864
c662a8633943 (dabbrev-expand, dabbrev--abbrev-at-point)
Richard M. Stallman <rms@gnu.org>
parents: 17711
diff changeset
913 (setq found-string (buffer-substring-no-properties
c662a8633943 (dabbrev-expand, dabbrev--abbrev-at-point)
Richard M. Stallman <rms@gnu.org>
parents: 17711
diff changeset
914 (match-beginning 1) (match-end 1)))
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
915 (and ignore-case (setq found-string (downcase found-string)))
12555
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
916 ;; Ignore this match if it's already in the table.
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
917 (if (dabbrev-filter-elements
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
918 table-string dabbrev--last-table
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
919 (string= found-string table-string))
12555
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
920 (setq found-string nil)))
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
921 ;; Prepare to continue searching.
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
922 (if reverse
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
923 (goto-char (match-beginning 0))
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
924 (goto-char (match-end 0))))
12555
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
925 ;; If we found something, use it.
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
926 (if found-string
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
927 ;; Put it into `dabbrev--last-table'
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
928 ;; and return it (either downcased, or as is).
17864
c662a8633943 (dabbrev-expand, dabbrev--abbrev-at-point)
Richard M. Stallman <rms@gnu.org>
parents: 17711
diff changeset
929 (let ((result (buffer-substring-no-properties
c662a8633943 (dabbrev-expand, dabbrev--abbrev-at-point)
Richard M. Stallman <rms@gnu.org>
parents: 17711
diff changeset
930 (match-beginning 0) (match-end 0))))
12555
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
931 (setq dabbrev--last-table
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
932 (cons found-string dabbrev--last-table))
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
933 (if (and ignore-case (eval dabbrev-case-replace))
15751
022815791330 (dabbrev--search): Don't downcase the result here.
Richard M. Stallman <rms@gnu.org>
parents: 15652
diff changeset
934 result
12555
a2a2aa391773 (dabbrev--search): Don't let spurious match in middle
Karl Heuer <kwzh@gnu.org>
parents: 11976
diff changeset
935 result)))))))
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936
29077
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
937 (dolist (mess '("^No dynamic expansion for .* found$"
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
938 "^No further dynamic expansion for .* found$"
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
939 "^No possible abbreviation preceding point$"))
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
940 (add-to-list 'debug-ignored-errors mess))
07f205e3af83 Add debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28486
diff changeset
941
10230
7396503653cf Complete rewrite by Lars.Lindberg@sypro.cap.se.
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
942 (provide 'dabbrev)
10231
e88ff4b30786 Don't require cl, picture, or reporter.
Richard M. Stallman <rms@gnu.org>
parents: 10230
diff changeset
943
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
944 ;;; dabbrev.el ends here