aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/completion.el
diff options
context:
space:
mode:
authorJuanma Barranquero2003-02-04 11:26:42 +0000
committerJuanma Barranquero2003-02-04 11:26:42 +0000
commit71296446d3cec5bb2a27bc5ad6da574df38d0ec8 (patch)
tree0204c3c252547a44e2404959409034406f7680cd /lisp/completion.el
parent693ff6134cb2ec65c7d188696f012662edadfbf0 (diff)
downloademacs-71296446d3cec5bb2a27bc5ad6da574df38d0ec8.tar.gz
emacs-71296446d3cec5bb2a27bc5ad6da574df38d0ec8.zip
Trailing whitespace deleted.
Diffstat (limited to 'lisp/completion.el')
-rw-r--r--lisp/completion.el206
1 files changed, 103 insertions, 103 deletions
diff --git a/lisp/completion.el b/lisp/completion.el
index 4bc34cc4ba2..2f89a68147d 100644
--- a/lisp/completion.el
+++ b/lisp/completion.el
@@ -37,36 +37,36 @@
37;; 37;;
38;; Introduction 38;; Introduction
39;;--------------- 39;;---------------
40;; 40;;
41;; After you type a few characters, pressing the "complete" key inserts 41;; After you type a few characters, pressing the "complete" key inserts
42;; the rest of the word you are likely to type. 42;; the rest of the word you are likely to type.
43;; 43;;
44;; This watches all the words that you type and remembers them. When 44;; This watches all the words that you type and remembers them. When
45;; typing a new word, pressing "complete" (meta-return) "completes" the 45;; typing a new word, pressing "complete" (meta-return) "completes" the
46;; word by inserting the most recently used word that begins with the 46;; word by inserting the most recently used word that begins with the
47;; same characters. If you press meta-return repeatedly, it cycles 47;; same characters. If you press meta-return repeatedly, it cycles
48;; through all the words it knows about. 48;; through all the words it knows about.
49;; 49;;
50;; If you like the completion then just continue typing, it is as if you 50;; If you like the completion then just continue typing, it is as if you
51;; entered the text by hand. If you want the inserted extra characters 51;; entered the text by hand. If you want the inserted extra characters
52;; to go away, type control-w or delete. More options are described below. 52;; to go away, type control-w or delete. More options are described below.
53;; 53;;
54;; The guesses are made in the order of the most recently "used". Typing 54;; The guesses are made in the order of the most recently "used". Typing
55;; in a word and then typing a separator character (such as a space) "uses" 55;; in a word and then typing a separator character (such as a space) "uses"
56;; the word. So does moving a cursor over the word. If no words are found, 56;; the word. So does moving a cursor over the word. If no words are found,
57;; it uses an extended version of the dabbrev style completion. 57;; it uses an extended version of the dabbrev style completion.
58;; 58;;
59;; You automatically save the completions you use to a file between 59;; You automatically save the completions you use to a file between
60;; sessions. 60;; sessions.
61;; 61;;
62;; Completion enables programmers to enter longer, more descriptive 62;; Completion enables programmers to enter longer, more descriptive
63;; variable names while typing fewer keystrokes than they normally would. 63;; variable names while typing fewer keystrokes than they normally would.
64;; 64;;
65;; 65;;
66;; Full documentation 66;; Full documentation
67;;--------------------- 67;;---------------------
68;; 68;;
69;; A "word" is any string containing characters with either word or symbol 69;; A "word" is any string containing characters with either word or symbol
70;; syntax. [E.G. Any alphanumeric string with hyphens, underscores, etc.] 70;; syntax. [E.G. Any alphanumeric string with hyphens, underscores, etc.]
71;; Unless you change the constants, you must type at least three characters 71;; Unless you change the constants, you must type at least three characters
72;; for the word to be recognized. Only words longer than 6 characters are 72;; for the word to be recognized. Only words longer than 6 characters are
@@ -82,27 +82,27 @@
82;; Completions are automatically saved from one session to another 82;; Completions are automatically saved from one session to another
83;; (unless save-completions-flag or enable-completion is nil). 83;; (unless save-completions-flag or enable-completion is nil).
84;; Loading this file (or calling initialize-completions) causes EMACS 84;; Loading this file (or calling initialize-completions) causes EMACS
85;; to load a completions database for a saved completions file 85;; to load a completions database for a saved completions file
86;; (default: ~/.completions). When you exit, EMACS saves a copy of the 86;; (default: ~/.completions). When you exit, EMACS saves a copy of the
87;; completions that you 87;; completions that you
88;; often use. When you next start, EMACS loads in the saved completion file. 88;; often use. When you next start, EMACS loads in the saved completion file.
89;; 89;;
90;; The number of completions saved depends loosely on 90;; The number of completions saved depends loosely on
91;; *saved-completions-decay-factor*. Completions that have never been 91;; *saved-completions-decay-factor*. Completions that have never been
92;; inserted via "complete" are not saved. You are encouraged to experiment 92;; inserted via "complete" are not saved. You are encouraged to experiment
93;; with different functions (see compute-completion-min-num-uses). 93;; with different functions (see compute-completion-min-num-uses).
94;; 94;;
95;; Some completions are permanent and are always saved out. These 95;; Some completions are permanent and are always saved out. These
96;; completions have their num-uses slot set to T. Use 96;; completions have their num-uses slot set to T. Use
97;; add-permanent-completion to do this 97;; add-permanent-completion to do this
98;; 98;;
99;; Completions are saved only if enable-completion is T. The number of old 99;; Completions are saved only if enable-completion is T. The number of old
100;; versions kept of the saved completions file is controlled by 100;; versions kept of the saved completions file is controlled by
101;; completions-file-versions-kept. 101;; completions-file-versions-kept.
102;; 102;;
103;; COMPLETE KEY OPTIONS 103;; COMPLETE KEY OPTIONS
104;; The complete function takes a numeric arguments. 104;; The complete function takes a numeric arguments.
105;; control-u :: leave the point at the beginning of the completion rather 105;; control-u :: leave the point at the beginning of the completion rather
106;; than the middle. 106;; than the middle.
107;; a number :: rotate through the possible completions by that amount 107;; a number :: rotate through the possible completions by that amount
108;; `-' :: same as -1 (insert previous completion) 108;; `-' :: same as -1 (insert previous completion)
@@ -111,17 +111,17 @@
111;; <write> 111;; <write>
112;; 112;;
113;; UPDATING THE DATABASE MANUALLY 113;; UPDATING THE DATABASE MANUALLY
114;; m-x kill-completion 114;; m-x kill-completion
115;; kills the completion at point. 115;; kills the completion at point.
116;; m-x add-completion 116;; m-x add-completion
117;; m-x add-permanent-completion 117;; m-x add-permanent-completion
118;; 118;;
119;; UPDATING THE DATABASE FROM A SOURCE CODE FILE 119;; UPDATING THE DATABASE FROM A SOURCE CODE FILE
120;; m-x add-completions-from-buffer 120;; m-x add-completions-from-buffer
121;; Parses all the definition names from a C or LISP mode buffer and 121;; Parses all the definition names from a C or LISP mode buffer and
122;; adds them to the completion database. 122;; adds them to the completion database.
123;; 123;;
124;; m-x add-completions-from-lisp-file 124;; m-x add-completions-from-lisp-file
125;; Parses all the definition names from a C or Lisp mode file and 125;; Parses all the definition names from a C or Lisp mode file and
126;; adds them to the completion database. 126;; adds them to the completion database.
127;; 127;;
@@ -133,16 +133,16 @@
133;; <write> 133;; <write>
134;; 134;;
135;; STRING CASING 135;; STRING CASING
136;; Completion is string case independent if case-fold-search has its 136;; Completion is string case independent if case-fold-search has its
137;; normal default of T. Also when the completion is inserted the case of the 137;; normal default of T. Also when the completion is inserted the case of the
138;; entry is coerced appropriately. 138;; entry is coerced appropriately.
139;; [E.G. APP --> APPROPRIATELY app --> appropriately 139;; [E.G. APP --> APPROPRIATELY app --> appropriately
140;; App --> Appropriately] 140;; App --> Appropriately]
141;; 141;;
142;; INITIALIZATION 142;; INITIALIZATION
143;; The form `(initialize-completions)' initializes the completion system by 143;; The form `(initialize-completions)' initializes the completion system by
144;; trying to load in the user's completions. After the first cal, further 144;; trying to load in the user's completions. After the first cal, further
145;; calls have no effect so one should be careful not to put the form in a 145;; calls have no effect so one should be careful not to put the form in a
146;; site's standard site-init file. 146;; site's standard site-init file.
147;; 147;;
148;;--------------------------------------------------------------------------- 148;;---------------------------------------------------------------------------
@@ -180,10 +180,10 @@
180;; Inserts a completion at point 180;; Inserts a completion at point
181;; 181;;
182;; initialize-completions 182;; initialize-completions
183;; Loads the completions file and sets up so that exiting emacs will 183;; Loads the completions file and sets up so that exiting emacs will
184;; save them. 184;; save them.
185;; 185;;
186;; save-completions-to-file &optional filename 186;; save-completions-to-file &optional filename
187;; load-completions-from-file &optional filename 187;; load-completions-from-file &optional filename
188;; 188;;
189;;----------------------------------------------- 189;;-----------------------------------------------
@@ -194,11 +194,11 @@
194;; 194;;
195;; These things are for manipulating the structure 195;; These things are for manipulating the structure
196;; make-completion string num-uses 196;; make-completion string num-uses
197;; completion-num-uses completion 197;; completion-num-uses completion
198;; completion-string completion 198;; completion-string completion
199;; set-completion-num-uses completion num-uses 199;; set-completion-num-uses completion num-uses
200;; set-completion-string completion string 200;; set-completion-string completion string
201;; 201;;
202;; 202;;
203 203
204;;----------------------------------------------- 204;;-----------------------------------------------
@@ -215,16 +215,16 @@
215;;----------------------------------------------- 215;;-----------------------------------------------
216;;; Change Log: 216;;; Change Log:
217;;----------------------------------------------- 217;;-----------------------------------------------
218;; Sometime in '84 Brewster implemented a somewhat buggy version for 218;; Sometime in '84 Brewster implemented a somewhat buggy version for
219;; Symbolics LISPMs. 219;; Symbolics LISPMs.
220;; Jan. '85 Jim became enamored of the idea and implemented a faster, 220;; Jan. '85 Jim became enamored of the idea and implemented a faster,
221;; more robust version. 221;; more robust version.
222;; With input from many users at TMC, (rose, craig, and gls come to mind), 222;; With input from many users at TMC, (rose, craig, and gls come to mind),
223;; the current style of interface was developed. 223;; the current style of interface was developed.
224;; 9/87, Jim and Brewster took terminals home. Yuck. After 224;; 9/87, Jim and Brewster took terminals home. Yuck. After
225;; complaining for a while Brewster implemented a subset of the current 225;; complaining for a while Brewster implemented a subset of the current
226;; LISPM version for GNU Emacs. 226;; LISPM version for GNU Emacs.
227;; 8/88 After complaining for a while (and with sufficient 227;; 8/88 After complaining for a while (and with sufficient
228;; promised rewards), Jim reimplemented a version of GNU completion 228;; promised rewards), Jim reimplemented a version of GNU completion
229;; superior to that of the LISPM version. 229;; superior to that of the LISPM version.
230;; 230;;
@@ -269,7 +269,7 @@
269;; - minor fix to capitalization code 269;; - minor fix to capitalization code
270;; - added *completion-auto-save-period* to variables recorded. 270;; - added *completion-auto-save-period* to variables recorded.
271;; - added reenter protection to cmpl-record-statistics-filter 271;; - added reenter protection to cmpl-record-statistics-filter
272;; - added backup protection to save-completions-to-file (prevents 272;; - added backup protection to save-completions-to-file (prevents
273;; problems with disk full errors) 273;; problems with disk full errors)
274 274
275;;; Code: 275;;; Code:
@@ -375,7 +375,7 @@ DON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.")
375 (setq completion-prefix-min-length 3))) 375 (setq completion-prefix-min-length 3)))
376 376
377(completion-eval-when) 377(completion-eval-when)
378 378
379;;--------------------------------------------------------------------------- 379;;---------------------------------------------------------------------------
380;; Internal Variables 380;; Internal Variables
381;;--------------------------------------------------------------------------- 381;;---------------------------------------------------------------------------
@@ -476,17 +476,17 @@ Used to decide whether to save completions.")
476;; of syntax in these "symbol" syntax tables :: 476;; of syntax in these "symbol" syntax tables ::
477;; 477;;
478;; syntax (?_) - "symbol" chars (e.g. alphanumerics) 478;; syntax (?_) - "symbol" chars (e.g. alphanumerics)
479;; syntax (?w) - symbol chars to ignore at end of words (e.g. period). 479;; syntax (?w) - symbol chars to ignore at end of words (e.g. period).
480;; syntax (? ) - everything else 480;; syntax (? ) - everything else
481;; 481;;
482;; Thus by judicious use of scan-sexps and forward-word, we can get 482;; Thus by judicious use of scan-sexps and forward-word, we can get
483;; the word we want relatively fast and without consing. 483;; the word we want relatively fast and without consing.
484;; 484;;
485;; Why do we need a separate category for "symbol chars to ignore at ends" ? 485;; Why do we need a separate category for "symbol chars to ignore at ends" ?
486;; For example, in LISP we want starting :'s trimmed 486;; For example, in LISP we want starting :'s trimmed
487;; so keyword argument specifiers also define the keyword completion. And, 487;; so keyword argument specifiers also define the keyword completion. And,
488;; for example, in C we want `.' appearing in a structure ref. to 488;; for example, in C we want `.' appearing in a structure ref. to
489;; be kept intact in order to store the whole structure ref.; however, if 489;; be kept intact in order to store the whole structure ref.; however, if
490;; it appears at the end of a symbol it should be discarded because it is 490;; it appears at the end of a symbol it should be discarded because it is
491;; probably used as a period. 491;; probably used as a period.
492 492
@@ -503,7 +503,7 @@ Used to decide whether to save completions.")
503;; C diffs -> 503;; C diffs ->
504;; Separator chars :: + * / : % 504;; Separator chars :: + * / : %
505;; A note on the hyphen (`-'). Perhaps the hyphen should also be a separator 505;; A note on the hyphen (`-'). Perhaps the hyphen should also be a separator
506;; char., however, we wanted to have completion symbols include pointer 506;; char., however, we wanted to have completion symbols include pointer
507;; references. For example, "foo->bar" is a symbol as far as completion is 507;; references. For example, "foo->bar" is a symbol as far as completion is
508;; concerned. 508;; concerned.
509;; 509;;
@@ -556,7 +556,7 @@ Used to decide whether to save completions.")
556 (dolist (char symbol-chars) 556 (dolist (char symbol-chars)
557 (modify-syntax-entry char "_" table)) 557 (modify-syntax-entry char "_" table))
558 table)) 558 table))
559 559
560(defun cmpl-make-c-completion-syntax-table () 560(defun cmpl-make-c-completion-syntax-table ()
561 (let ((table (copy-syntax-table cmpl-standard-syntax-table)) 561 (let ((table (copy-syntax-table cmpl-standard-syntax-table))
562 (separator-chars '(?+ ?* ?/ ?: ?%))) 562 (separator-chars '(?+ ?* ?/ ?: ?%)))
@@ -598,9 +598,9 @@ But only if it is longer than `completion-min-length'."
598 (unwind-protect 598 (unwind-protect
599 (progn 599 (progn
600 (set-syntax-table cmpl-syntax-table) 600 (set-syntax-table cmpl-syntax-table)
601 (cond 601 (cond
602 ;; Cursor is on following-char and after preceding-char 602 ;; Cursor is on following-char and after preceding-char
603 ((memq (char-syntax (following-char)) '(?w ?_)) 603 ((memq (char-syntax (following-char)) '(?w ?_))
604 (setq cmpl-saved-point (point) 604 (setq cmpl-saved-point (point)
605 cmpl-symbol-start (scan-sexps (1+ cmpl-saved-point) -1) 605 cmpl-symbol-start (scan-sexps (1+ cmpl-saved-point) -1)
606 cmpl-symbol-end (scan-sexps cmpl-saved-point 1)) 606 cmpl-symbol-end (scan-sexps cmpl-saved-point 1))
@@ -638,7 +638,7 @@ But only if it is longer than `completion-min-length'."
638 638
639(defun symbol-before-point () 639(defun symbol-before-point ()
640 "Returns a string of the symbol immediately before point. 640 "Returns a string of the symbol immediately before point.
641Returns nil if there isn't one longer than `completion-min-length'." 641Returns nil if there isn't one longer than `completion-min-length'."
642 ;; This is called when a word separator is typed so it must be FAST ! 642 ;; This is called when a word separator is typed so it must be FAST !
643 (setq cmpl-saved-syntax (syntax-table)) 643 (setq cmpl-saved-syntax (syntax-table))
644 (unwind-protect 644 (unwind-protect
@@ -774,7 +774,7 @@ Returns nil if there isn't one longer than `completion-min-length'."
774;; "Only executes body if we are recording statistics." 774;; "Only executes body if we are recording statistics."
775;; (list 'cond 775;; (list 'cond
776;; (list* '*record-cmpl-statistics-p* body) 776;; (list* '*record-cmpl-statistics-p* body)
777;; )) 777;; ))
778 778
779;;----------------------------------------------- 779;;-----------------------------------------------
780;; Completion Sources 780;; Completion Sources
@@ -797,7 +797,7 @@ Returns nil if there isn't one longer than `completion-min-length'."
797;; Completion Method #2: dabbrev-expand style 797;; Completion Method #2: dabbrev-expand style
798;;--------------------------------------------------------------------------- 798;;---------------------------------------------------------------------------
799;; 799;;
800;; This method is used if there are no useful stored completions. It is 800;; This method is used if there are no useful stored completions. It is
801;; based on dabbrev-expand with these differences : 801;; based on dabbrev-expand with these differences :
802;; 1) Faster (we don't use regexps) 802;; 1) Faster (we don't use regexps)
803;; 2) case coercion handled correctly 803;; 2) case coercion handled correctly
@@ -880,7 +880,7 @@ This is sensitive to `case-fold-search'."
880 ;; note that case-fold-search affects the behavior of this function 880 ;; note that case-fold-search affects the behavior of this function
881 ;; Bug: won't pick up an expansion that starts at the top of buffer 881 ;; Bug: won't pick up an expansion that starts at the top of buffer
882 (if cdabbrev-current-window 882 (if cdabbrev-current-window
883 (let (saved-point 883 (let (saved-point
884 saved-syntax 884 saved-syntax
885 (expansion nil) 885 (expansion nil)
886 downcase-expansion tried-list syntax saved-point-2) 886 downcase-expansion tried-list syntax saved-point-2)
@@ -1004,7 +1004,7 @@ Each symbol is bound to a single completion entry.")
1004;; last-use-time is t if the string should be kept permanently 1004;; last-use-time is t if the string should be kept permanently
1005;; num-uses is incremented every time the completion is used. 1005;; num-uses is incremented every time the completion is used.
1006 1006
1007;; We chose lists because (car foo) is faster than (aref foo 0) and the 1007;; We chose lists because (car foo) is faster than (aref foo 0) and the
1008;; creation time is about the same. 1008;; creation time is about the same.
1009 1009
1010;; READER MACROS 1010;; READER MACROS
@@ -1013,7 +1013,7 @@ Each symbol is bound to a single completion entry.")
1013 (list 'car completion-entry)) 1013 (list 'car completion-entry))
1014 1014
1015(defmacro completion-num-uses (completion-entry) 1015(defmacro completion-num-uses (completion-entry)
1016 ;; "The number of times it has used. Used to decide whether to save 1016 ;; "The number of times it has used. Used to decide whether to save
1017 ;; it." 1017 ;; it."
1018 (list 'car (list 'cdr completion-entry))) 1018 (list 'car (list 'cdr completion-entry)))
1019 1019
@@ -1291,7 +1291,7 @@ Returns the completion entry."
1291 (note-added-completion)) 1291 (note-added-completion))
1292 ;; Add it to the symbol 1292 ;; Add it to the symbol
1293 (set cmpl-db-symbol (car entry))))) 1293 (set cmpl-db-symbol (car entry)))))
1294 1294
1295(defun delete-completion (completion-string) 1295(defun delete-completion (completion-string)
1296 "Delete the completion from the database. 1296 "Delete the completion from the database.
1297String must be longer than `completion-prefix-min-length'." 1297String must be longer than `completion-prefix-min-length'."
@@ -1299,7 +1299,7 @@ String must be longer than `completion-prefix-min-length'."
1299 (if completion-to-accept (accept-completion)) 1299 (if completion-to-accept (accept-completion))
1300 (if (setq cmpl-db-entry (find-exact-completion completion-string)) 1300 (if (setq cmpl-db-entry (find-exact-completion completion-string))
1301 ;; found 1301 ;; found
1302 (let* ((prefix-entry (find-cmpl-prefix-entry 1302 (let* ((prefix-entry (find-cmpl-prefix-entry
1303 (substring cmpl-db-downcase-string 0 1303 (substring cmpl-db-downcase-string 0
1304 (cmpl-read-time-eval 1304 (cmpl-read-time-eval
1305 completion-prefix-min-length)))) 1305 completion-prefix-min-length))))
@@ -1339,16 +1339,16 @@ String must be longer than `completion-prefix-min-length'."
1339;; 1339;;
1340;; - Deleting - 1340;; - Deleting -
1341;; (add-completion-to-head "banner") --> ("banner" 0 nil 0) 1341;; (add-completion-to-head "banner") --> ("banner" 0 nil 0)
1342;; (delete-completion "banner") 1342;; (delete-completion "banner")
1343;; (find-exact-completion "banner") --> nil 1343;; (find-exact-completion "banner") --> nil
1344;; (car (find-cmpl-prefix-entry "ban")) --> (("banana" ...) ("banish" ...)) 1344;; (car (find-cmpl-prefix-entry "ban")) --> (("banana" ...) ("banish" ...))
1345;; (cdr (find-cmpl-prefix-entry "ban")) --> (("banish" ...)) 1345;; (cdr (find-cmpl-prefix-entry "ban")) --> (("banish" ...))
1346;; (add-completion-to-head "banner") --> ("banner" 0 nil 0) 1346;; (add-completion-to-head "banner") --> ("banner" 0 nil 0)
1347;; (delete-completion "banana") 1347;; (delete-completion "banana")
1348;; (car (find-cmpl-prefix-entry "ban")) --> (("banner" ...) ("banish" ...)) 1348;; (car (find-cmpl-prefix-entry "ban")) --> (("banner" ...) ("banish" ...))
1349;; (cdr (find-cmpl-prefix-entry "ban")) --> (("banish" ...)) 1349;; (cdr (find-cmpl-prefix-entry "ban")) --> (("banish" ...))
1350;; (delete-completion "banner") 1350;; (delete-completion "banner")
1351;; (delete-completion "banish") 1351;; (delete-completion "banish")
1352;; (find-cmpl-prefix-entry "ban") --> nil 1352;; (find-cmpl-prefix-entry "ban") --> nil
1353;; (delete-completion "banner") --> error 1353;; (delete-completion "banner") --> error
1354;; 1354;;
@@ -1365,7 +1365,7 @@ String must be longer than `completion-prefix-min-length'."
1365;;--------------------------------------------------------------------------- 1365;;---------------------------------------------------------------------------
1366;; Database Update :: Interface level routines 1366;; Database Update :: Interface level routines
1367;;--------------------------------------------------------------------------- 1367;;---------------------------------------------------------------------------
1368;; 1368;;
1369;; These lie on top of the database ref. functions but below the standard 1369;; These lie on top of the database ref. functions but below the standard
1370;; user interface level 1370;; user interface level
1371 1371
@@ -1388,7 +1388,7 @@ String must be longer than `completion-prefix-min-length'."
1388 1388
1389(defun add-completion (string &optional num-uses last-use-time) 1389(defun add-completion (string &optional num-uses last-use-time)
1390 "Add STRING to completion list, or move it to head of list. 1390 "Add STRING to completion list, or move it to head of list.
1391The completion is altered appropriately if num-uses and/or last-use-time is 1391The completion is altered appropriately if num-uses and/or last-use-time is
1392specified." 1392specified."
1393 (interactive (interactive-completion-string-reader "Completion to add")) 1393 (interactive (interactive-completion-string-reader "Completion to add"))
1394 (check-completion-length string) 1394 (check-completion-length string)
@@ -1396,7 +1396,7 @@ specified."
1396 cmpl-source-interactive 1396 cmpl-source-interactive
1397 current-completion-source)) 1397 current-completion-source))
1398 (entry (add-completion-to-head string))) 1398 (entry (add-completion-to-head string)))
1399 1399
1400 (if num-uses (set-completion-num-uses entry num-uses)) 1400 (if num-uses (set-completion-num-uses entry num-uses))
1401 (if last-use-time 1401 (if last-use-time
1402 (set-completion-last-use-time entry last-use-time)))) 1402 (set-completion-last-use-time entry last-use-time))))
@@ -1417,7 +1417,7 @@ specified."
1417 1417
1418(defun accept-completion () 1418(defun accept-completion ()
1419 "Accepts the pending completion in `completion-to-accept'. 1419 "Accepts the pending completion in `completion-to-accept'.
1420This bumps num-uses. Called by `add-completion-to-head' and 1420This bumps num-uses. Called by `add-completion-to-head' and
1421`completion-search-reset'." 1421`completion-search-reset'."
1422 (let ((string completion-to-accept) 1422 (let ((string completion-to-accept)
1423 ;; if this is added afresh here, then it must be a cdabbrev 1423 ;; if this is added afresh here, then it must be a cdabbrev
@@ -1433,7 +1433,7 @@ This bumps num-uses. Called by `add-completion-to-head' and
1433 (let ((string (and enable-completion (symbol-under-point))) 1433 (let ((string (and enable-completion (symbol-under-point)))
1434 (current-completion-source cmpl-source-cursor-moves)) 1434 (current-completion-source cmpl-source-cursor-moves))
1435 (if string (add-completion-to-head string)))) 1435 (if string (add-completion-to-head string))))
1436 1436
1437(defun use-completion-before-point () 1437(defun use-completion-before-point ()
1438 "Add the completion symbol before point into the completion buffer." 1438 "Add the completion symbol before point into the completion buffer."
1439 (let ((string (and enable-completion (symbol-before-point))) 1439 (let ((string (and enable-completion (symbol-before-point)))
@@ -1465,25 +1465,25 @@ Completions added this way will automatically be saved if
1465 1465
1466;; Tests -- 1466;; Tests --
1467;; - Add and Find - 1467;; - Add and Find -
1468;; (add-completion "banana" 5 10) 1468;; (add-completion "banana" 5 10)
1469;; (find-exact-completion "banana") --> ("banana" 5 10 0) 1469;; (find-exact-completion "banana") --> ("banana" 5 10 0)
1470;; (add-completion "banana" 6) 1470;; (add-completion "banana" 6)
1471;; (find-exact-completion "banana") --> ("banana" 6 10 0) 1471;; (find-exact-completion "banana") --> ("banana" 6 10 0)
1472;; (add-completion "banish") 1472;; (add-completion "banish")
1473;; (car (find-cmpl-prefix-entry "ban")) --> (("banish" ...) ("banana" ...)) 1473;; (car (find-cmpl-prefix-entry "ban")) --> (("banish" ...) ("banana" ...))
1474;; 1474;;
1475;; - Accepting - 1475;; - Accepting -
1476;; (setq completion-to-accept "banana") 1476;; (setq completion-to-accept "banana")
1477;; (accept-completion) 1477;; (accept-completion)
1478;; (find-exact-completion "banana") --> ("banana" 7 10) 1478;; (find-exact-completion "banana") --> ("banana" 7 10)
1479;; (car (find-cmpl-prefix-entry "ban")) --> (("banana" ...) ("banish" ...)) 1479;; (car (find-cmpl-prefix-entry "ban")) --> (("banana" ...) ("banish" ...))
1480;; (setq completion-to-accept "banish") 1480;; (setq completion-to-accept "banish")
1481;; (add-completion "banner") 1481;; (add-completion "banner")
1482;; (car (find-cmpl-prefix-entry "ban")) 1482;; (car (find-cmpl-prefix-entry "ban"))
1483;; --> (("banner" ...) ("banish" 1 ...) ("banana" 7 ...)) 1483;; --> (("banner" ...) ("banish" 1 ...) ("banana" 7 ...))
1484;; 1484;;
1485;; - Deleting - 1485;; - Deleting -
1486;; (kill-completion "banish") 1486;; (kill-completion "banish")
1487;; (car (find-cmpl-prefix-entry "ban")) --> (("banner" ...) ("banana" ...)) 1487;; (car (find-cmpl-prefix-entry "ban")) --> (("banner" ...) ("banana" ...))
1488 1488
1489 1489
@@ -1499,7 +1499,7 @@ Completions added this way will automatically be saved if
1499(defvar cmpl-test-string "") 1499(defvar cmpl-test-string "")
1500;; "The current string used by completion-search-next." 1500;; "The current string used by completion-search-next."
1501(defvar cmpl-test-regexp "") 1501(defvar cmpl-test-regexp "")
1502;; "The current regexp used by completion-search-next. 1502;; "The current regexp used by completion-search-next.
1503;; (derived from cmpl-test-string)" 1503;; (derived from cmpl-test-string)"
1504(defvar cmpl-last-index 0) 1504(defvar cmpl-last-index 0)
1505;; "The last index that completion-search-next was called with." 1505;; "The last index that completion-search-next was called with."
@@ -1554,7 +1554,7 @@ If there are no more entries, try cdabbrev and returns only a string."
1554 (cond ((not cmpl-next-possibilities)) 1554 (cond ((not cmpl-next-possibilities))
1555 ;; If no more possibilities, leave it that way 1555 ;; If no more possibilities, leave it that way
1556 ((= -1 cmpl-last-index) 1556 ((= -1 cmpl-last-index)
1557 ;; next completion is at index 0. reset next-possibility list 1557 ;; next completion is at index 0. reset next-possibility list
1558 ;; to start at beginning 1558 ;; to start at beginning
1559 (setq cmpl-next-possibilities cmpl-starting-possibilities)) 1559 (setq cmpl-next-possibilities cmpl-starting-possibilities))
1560 (t 1560 (t
@@ -1574,11 +1574,11 @@ If there are no more entries, try cdabbrev and returns only a string."
1574 (prog1 1574 (prog1
1575 cmpl-next-possibility 1575 cmpl-next-possibility
1576 (setq cmpl-next-possibility nil))) 1576 (setq cmpl-next-possibility nil)))
1577 1577
1578 1578
1579(defun completion-search-peek (use-cdabbrev) 1579(defun completion-search-peek (use-cdabbrev)
1580 "Returns the next completion entry without actually moving the pointers. 1580 "Returns the next completion entry without actually moving the pointers.
1581Calling this again or calling `completion-search-next' results in the same 1581Calling this again or calling `completion-search-next' results in the same
1582string being returned. Depends on `case-fold-search'. 1582string being returned. Depends on `case-fold-search'.
1583If there are no more entries, try cdabbrev and then return only a string." 1583If there are no more entries, try cdabbrev and then return only a string."
1584 (cond 1584 (cond
@@ -1609,14 +1609,14 @@ If there are no more entries, try cdabbrev and then return only a string."
1609 1609
1610;; Tests -- 1610;; Tests --
1611;; - Add and Find - 1611;; - Add and Find -
1612;; (add-completion "banana") 1612;; (add-completion "banana")
1613;; (completion-search-reset "ban") 1613;; (completion-search-reset "ban")
1614;; (completion-search-next 0) --> "banana" 1614;; (completion-search-next 0) --> "banana"
1615;; 1615;;
1616;; - Discrimination - 1616;; - Discrimination -
1617;; (add-completion "cumberland") 1617;; (add-completion "cumberland")
1618;; (add-completion "cumberbund") 1618;; (add-completion "cumberbund")
1619;; cumbering 1619;; cumbering
1620;; (completion-search-reset "cumb") 1620;; (completion-search-reset "cumb")
1621;; (completion-search-peek t) --> "cumberbund" 1621;; (completion-search-peek t) --> "cumberbund"
1622;; (completion-search-next 0) --> "cumberbund" 1622;; (completion-search-next 0) --> "cumberbund"
@@ -1637,7 +1637,7 @@ If there are no more entries, try cdabbrev and then return only a string."
1637;; 1637;;
1638;; - Deleting - 1638;; - Deleting -
1639;; (kill-completion "cumberland") 1639;; (kill-completion "cumberland")
1640;; cummings 1640;; cummings
1641;; (completion-search-reset "cum") 1641;; (completion-search-reset "cum")
1642;; (completion-search-next 0) --> "cumberbund" 1642;; (completion-search-next 0) --> "cumberbund"
1643;; (completion-search-next 1) --> "cummings" 1643;; (completion-search-next 1) --> "cummings"
@@ -1657,17 +1657,17 @@ If there are no more entries, try cdabbrev and then return only a string."
1657 (interactive) 1657 (interactive)
1658 (setq enable-completion (not enable-completion)) 1658 (setq enable-completion (not enable-completion))
1659 (message "Completion mode is now %s." (if enable-completion "ON" "OFF"))) 1659 (message "Completion mode is now %s." (if enable-completion "ON" "OFF")))
1660 1660
1661(defvar cmpl-current-index 0) 1661(defvar cmpl-current-index 0)
1662(defvar cmpl-original-string nil) 1662(defvar cmpl-original-string nil)
1663(defvar cmpl-last-insert-location -1) 1663(defvar cmpl-last-insert-location -1)
1664(defvar cmpl-leave-point-at-start nil) 1664(defvar cmpl-leave-point-at-start nil)
1665 1665
1666(defun complete (&optional arg) 1666(defun complete (&optional arg)
1667 "Fill out a completion of the word before point. 1667 "Fill out a completion of the word before point.
1668Point is left at end. Consecutive calls rotate through all possibilities. 1668Point is left at end. Consecutive calls rotate through all possibilities.
1669Prefix args :: 1669Prefix args ::
1670 control-u :: leave the point at the beginning of the completion rather 1670 control-u :: leave the point at the beginning of the completion rather
1671 than at the end. 1671 than at the end.
1672 a number :: rotate through the possible completions by that amount 1672 a number :: rotate through the possible completions by that amount
1673 `-' :: same as -1 (insert previous completion) 1673 `-' :: same as -1 (insert previous completion)
@@ -1693,7 +1693,7 @@ Prefix args ::
1693 (setq this-command 'failed-complete) 1693 (setq this-command 'failed-complete)
1694 (error "To complete, point must be after a symbol at least %d character long" 1694 (error "To complete, point must be after a symbol at least %d character long"
1695 completion-prefix-min-length))) 1695 completion-prefix-min-length)))
1696 ;; get index 1696 ;; get index
1697 (setq cmpl-current-index (if current-prefix-arg arg 0)) 1697 (setq cmpl-current-index (if current-prefix-arg arg 0))
1698 ;; statistics 1698 ;; statistics
1699 (cmpl-statistics-block 1699 (cmpl-statistics-block
@@ -1748,7 +1748,7 @@ Prefix args ::
1748 (setq string (cmpl-merge-string-cases 1748 (setq string (cmpl-merge-string-cases
1749 string cmpl-original-string)) 1749 string cmpl-original-string))
1750 (message "Next completion: %s" string)))) 1750 (message "Next completion: %s" string))))
1751 (t;; none found, insert old 1751 (t;; none found, insert old
1752 (insert cmpl-original-string) 1752 (insert cmpl-original-string)
1753 ;; Don't accept completions 1753 ;; Don't accept completions
1754 (setq completion-to-accept nil) 1754 (setq completion-to-accept nil)
@@ -1862,7 +1862,7 @@ Prefix args ::
1862;; (and (string-match *lisp-def-regexp* "\n(def-bar foo")(match-end 0)) -> 10 1862;; (and (string-match *lisp-def-regexp* "\n(def-bar foo")(match-end 0)) -> 10
1863;; (and (string-match *lisp-def-regexp* "\n(defun (foo") (match-end 0)) -> 9 1863;; (and (string-match *lisp-def-regexp* "\n(defun (foo") (match-end 0)) -> 9
1864 1864
1865;; Parses all the definition names from a Lisp mode buffer and adds them to 1865;; Parses all the definition names from a Lisp mode buffer and adds them to
1866;; the completion database. 1866;; the completion database.
1867(defun add-completions-from-lisp-buffer () 1867(defun add-completions-from-lisp-buffer ()
1868 ;;; Benchmarks 1868 ;;; Benchmarks
@@ -1955,7 +1955,7 @@ Prefix args ::
1955;; (test-c-def-regexp *c-cont-regexp* "oo {trout =1} my_carp;") -> 14 1955;; (test-c-def-regexp *c-cont-regexp* "oo {trout =1} my_carp;") -> 14
1956;; (test-c-def-regexp *c-cont-regexp* "truct_p complex foon") -> nil 1956;; (test-c-def-regexp *c-cont-regexp* "truct_p complex foon") -> nil
1957 1957
1958;; Parses all the definition names from a C mode buffer and adds them to the 1958;; Parses all the definition names from a C mode buffer and adds them to the
1959;; completion database. 1959;; completion database.
1960(defun add-completions-from-c-buffer () 1960(defun add-completions-from-c-buffer ()
1961 ;; Benchmark -- 1961 ;; Benchmark --
@@ -2089,7 +2089,7 @@ If file name is not specified, use `save-completions-file-name'."
2089 (total-perm 0) 2089 (total-perm 0)
2090 (total-saved 0) 2090 (total-saved 0)
2091 (backup-filename (completion-backup-filename filename))) 2091 (backup-filename (completion-backup-filename filename)))
2092 2092
2093 (save-excursion 2093 (save-excursion
2094 (get-buffer-create " *completion-save-buffer*") 2094 (get-buffer-create " *completion-save-buffer*")
2095 (set-buffer " *completion-save-buffer*") 2095 (set-buffer " *completion-save-buffer*")
@@ -2130,7 +2130,7 @@ If file name is not specified, use `save-completions-file-name'."
2130 (setq total-saved (1+ total-saved)) 2130 (setq total-saved (1+ total-saved))
2131 (insert (prin1-to-string (cons (completion-string completion) 2131 (insert (prin1-to-string (cons (completion-string completion)
2132 last-use-time)) "\n")))) 2132 last-use-time)) "\n"))))
2133 2133
2134 ;; write the buffer 2134 ;; write the buffer
2135 (condition-case e 2135 (condition-case e
2136 (let ((file-exists-p (file-exists-p filename))) 2136 (let ((file-exists-p (file-exists-p filename)))
@@ -2139,7 +2139,7 @@ If file name is not specified, use `save-completions-file-name'."
2139 ;; If file exists . . . 2139 ;; If file exists . . .
2140 ;; Save a backup(so GNU doesn't screw us when we're out of disk) 2140 ;; Save a backup(so GNU doesn't screw us when we're out of disk)
2141 ;; (GNU leaves a 0 length file if it gets a disk full error!) 2141 ;; (GNU leaves a 0 length file if it gets a disk full error!)
2142 2142
2143 ;; If backup doesn't exit, Rename current to backup 2143 ;; If backup doesn't exit, Rename current to backup
2144 ;; {If backup exists the primary file is probably messed up} 2144 ;; {If backup exists the primary file is probably messed up}
2145 (or (file-exists-p backup-filename) 2145 (or (file-exists-p backup-filename)
@@ -2189,7 +2189,7 @@ If file is not specified, then use `save-completions-file-name'."
2189 ;; prepare the buffer to be modified 2189 ;; prepare the buffer to be modified
2190 (clear-visited-file-modtime) 2190 (clear-visited-file-modtime)
2191 (erase-buffer) 2191 (erase-buffer)
2192 2192
2193 (let ((insert-okay-p nil) 2193 (let ((insert-okay-p nil)
2194 (buffer (current-buffer)) 2194 (buffer (current-buffer))
2195 (current-time (cmpl-hours-since-origin)) 2195 (current-time (cmpl-hours-since-origin))
@@ -2205,10 +2205,10 @@ If file is not specified, then use `save-completions-file-name'."
2205 (progn (insert-file-contents filename t) 2205 (progn (insert-file-contents filename t)
2206 (setq insert-okay-p t)) 2206 (setq insert-okay-p t))
2207 2207
2208 (file-error 2208 (file-error
2209 (message "File error trying to load completion file %s." 2209 (message "File error trying to load completion file %s."
2210 filename))) 2210 filename)))
2211 ;; parse it 2211 ;; parse it
2212 (if insert-okay-p 2212 (if insert-okay-p
2213 (progn 2213 (progn
2214 (goto-char (point-min)) 2214 (goto-char (point-min))
@@ -2234,7 +2234,7 @@ If file is not specified, then use `save-completions-file-name'."
2234 (completion-last-use-time 2234 (completion-last-use-time
2235 (setq cmpl-entry 2235 (setq cmpl-entry
2236 (add-completion-to-tail-if-new string)))) 2236 (add-completion-to-tail-if-new string))))
2237 (if (or (eq last-use-time t) 2237 (if (or (eq last-use-time t)
2238 (and (> last-use-time 1000);;backcompatibility 2238 (and (> last-use-time 1000);;backcompatibility
2239 (not (eq cmpl-last-use-time t)) 2239 (not (eq cmpl-last-use-time t))
2240 (or (not cmpl-last-use-time) 2240 (or (not cmpl-last-use-time)
@@ -2290,7 +2290,7 @@ If the previous command was also a kill command,
2290the text killed this time appends to the text killed last time 2290the text killed this time appends to the text killed last time
2291to make one entry in the kill ring. 2291to make one entry in the kill ring.
2292Patched to remove the most recent completion." 2292Patched to remove the most recent completion."
2293 (interactive "r") 2293 (interactive "r")
2294 (cond ((eq last-command 'complete) 2294 (cond ((eq last-command 'complete)
2295 (delete-region (point) cmpl-last-insert-location) 2295 (delete-region (point) cmpl-last-insert-location)
2296 (insert cmpl-original-string) 2296 (insert cmpl-original-string)
@@ -2311,7 +2311,7 @@ Patched to remove the most recent completion."
2311;; All common separators (eg. space "(" ")" """) characters go through a 2311;; All common separators (eg. space "(" ")" """) characters go through a
2312;; function to add new words to the list of words to complete from: 2312;; function to add new words to the list of words to complete from:
2313;; COMPLETION-SEPARATOR-SELF-INSERT-COMMAND (arg). 2313;; COMPLETION-SEPARATOR-SELF-INSERT-COMMAND (arg).
2314;; If the character before this was an alpha-numeric then this adds the 2314;; If the character before this was an alpha-numeric then this adds the
2315;; symbol before point to the completion list (using ADD-COMPLETION). 2315;; symbol before point to the completion list (using ADD-COMPLETION).
2316 2316
2317(defun completion-separator-self-insert-command (arg) 2317(defun completion-separator-self-insert-command (arg)
@@ -2330,7 +2330,7 @@ Patched to remove the most recent completion."
2330;; Wrapping Macro 2330;; Wrapping Macro
2331;;----------------------------------------------- 2331;;-----------------------------------------------
2332 2332
2333;; Note that because of the way byte compiling works, none of 2333;; Note that because of the way byte compiling works, none of
2334;; the functions defined with this macro get byte compiled. 2334;; the functions defined with this macro get byte compiled.
2335 2335
2336(defmacro def-completion-wrapper (function-name type &optional new-name) 2336(defmacro def-completion-wrapper (function-name type &optional new-name)
@@ -2397,7 +2397,7 @@ TYPE is the type of the wrapper to be added. Can be :before or :under."
2397 (define-key fortran-mode-map "/" 'completion-separator-self-insert-command)) 2397 (define-key fortran-mode-map "/" 'completion-separator-self-insert-command))
2398 2398
2399;;; Enable completion mode. 2399;;; Enable completion mode.
2400 2400
2401;;;###autoload 2401;;;###autoload
2402(defun dynamic-completion-mode () 2402(defun dynamic-completion-mode ()
2403 "Enable dynamic word-completion." 2403 "Enable dynamic word-completion."
@@ -2522,8 +2522,8 @@ TYPE is the type of the wrapper to be added. Can be :before or :under."
2522 2522
2523 ;; Tests -- 2523 ;; Tests --
2524 ;; foobarbiz 2524 ;; foobarbiz
2525 ;; foobar 2525 ;; foobar
2526 ;; fooquux 2526 ;; fooquux
2527 ;; fooper 2527 ;; fooper
2528 2528
2529 (cmpl-statistics-block 2529 (cmpl-statistics-block