1992-05-30 23:54:21 +00:00
|
|
|
|
;;; completion.el --- dynamic word-completion code
|
1996-01-14 07:34:30 +00:00
|
|
|
|
|
2020-01-01 00:19:43 +00:00
|
|
|
|
;; Copyright (C) 1990, 1993, 1995, 1997, 2001-2020 Free Software
|
2013-01-01 09:11:05 +00:00
|
|
|
|
;; Foundation, Inc.
|
1992-05-30 23:54:21 +00:00
|
|
|
|
|
2019-05-25 20:43:06 +00:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
1998-05-26 09:23:23 +00:00
|
|
|
|
;; Keywords: abbrev convenience
|
1995-11-24 22:20:07 +00:00
|
|
|
|
;; Author: Jim Salem <alem@bbnplanet.com> of Thinking Machines Inc.
|
1995-04-08 06:20:51 +00:00
|
|
|
|
;; (ideas suggested by Brewster Kahle)
|
1992-07-16 18:28:42 +00:00
|
|
|
|
|
1993-08-03 04:36:52 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
1992-07-16 18:28:42 +00:00
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1993-08-03 04:36:52 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1993-08-03 04:36:52 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1993-08-03 04:36:52 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
1996-01-14 07:34:30 +00:00
|
|
|
|
|
|
|
|
|
;; What to put in .emacs
|
|
|
|
|
;;-----------------------
|
1998-11-01 08:45:25 +00:00
|
|
|
|
;; (dynamic-completion-mode)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Documentation [Slightly out of date]
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; (also check the documentation string of the functions)
|
|
|
|
|
;;
|
|
|
|
|
;; Introduction
|
|
|
|
|
;;---------------
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;;
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; After you type a few characters, pressing the "complete" key inserts
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; the rest of the word you are likely to type.
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; This watches all the words that you type and remembers them. When
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; typing a new word, pressing "complete" (meta-return) "completes" the
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; word by inserting the most recently used word that begins with the
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; same characters. If you press meta-return repeatedly, it cycles
|
|
|
|
|
;; through all the words it knows about.
|
|
|
|
|
;;
|
|
|
|
|
;; If you like the completion then just continue typing, it is as if you
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; entered the text by hand. If you want the inserted extra characters
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; to go away, type control-w or delete. More options are described below.
|
|
|
|
|
;;
|
|
|
|
|
;; The guesses are made in the order of the most recently "used". Typing
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; in a word and then typing a separator character (such as a space) "uses"
|
|
|
|
|
;; the word. So does moving a cursor over the word. If no words are found,
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; it uses an extended version of the dabbrev style completion.
|
|
|
|
|
;;
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; You automatically save the completions you use to a file between
|
|
|
|
|
;; sessions.
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; Completion enables programmers to enter longer, more descriptive
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; variable names while typing fewer keystrokes than they normally would.
|
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
;; Full documentation
|
|
|
|
|
;;---------------------
|
|
|
|
|
;;
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; A "word" is any string containing characters with either word or symbol
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; syntax. [E.G. Any alphanumeric string with hyphens, underscores, etc.]
|
|
|
|
|
;; Unless you change the constants, you must type at least three characters
|
|
|
|
|
;; for the word to be recognized. Only words longer than 6 characters are
|
|
|
|
|
;; saved.
|
|
|
|
|
;;
|
|
|
|
|
;; When you load this file, completion will be on. I suggest you use the
|
|
|
|
|
;; compiled version (because it is noticeably faster).
|
|
|
|
|
;;
|
2003-02-05 19:09:34 +00:00
|
|
|
|
;; M-x completion-mode toggles whether or not new words are added to the
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; database by changing the value of enable-completion.
|
|
|
|
|
;;
|
|
|
|
|
;; SAVING/LOADING COMPLETIONS
|
|
|
|
|
;; Completions are automatically saved from one session to another
|
|
|
|
|
;; (unless save-completions-flag or enable-completion is nil).
|
2006-01-25 04:11:05 +00:00
|
|
|
|
;; Activating this minor-mode (calling completion-initialize) loads
|
|
|
|
|
;; a completions database for a saved completions file
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; (default: ~/.completions). When you exit, Emacs saves a copy of the
|
2006-01-25 04:11:05 +00:00
|
|
|
|
;; completions that you often use. When you next start, Emacs loads in
|
|
|
|
|
;; the saved completion file.
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; The number of completions saved depends loosely on
|
|
|
|
|
;; *saved-completions-decay-factor*. Completions that have never been
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; inserted via "complete" are not saved. You are encouraged to experiment
|
|
|
|
|
;; with different functions (see compute-completion-min-num-uses).
|
|
|
|
|
;;
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; Some completions are permanent and are always saved out. These
|
|
|
|
|
;; completions have their num-uses slot set to T. Use
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; add-permanent-completion to do this
|
|
|
|
|
;;
|
|
|
|
|
;; Completions are saved only if enable-completion is T. The number of old
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; versions kept of the saved completions file is controlled by
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; completions-file-versions-kept.
|
|
|
|
|
;;
|
|
|
|
|
;; COMPLETE KEY OPTIONS
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; The complete function takes a numeric arguments.
|
|
|
|
|
;; control-u :: leave the point at the beginning of the completion rather
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; than the middle.
|
|
|
|
|
;; a number :: rotate through the possible completions by that amount
|
|
|
|
|
;; `-' :: same as -1 (insert previous completion)
|
|
|
|
|
;;
|
|
|
|
|
;; HOW THE DATABASE IS MAINTAINED
|
|
|
|
|
;; <write>
|
|
|
|
|
;;
|
|
|
|
|
;; UPDATING THE DATABASE MANUALLY
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; m-x kill-completion
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; kills the completion at point.
|
|
|
|
|
;; m-x add-completion
|
|
|
|
|
;; m-x add-permanent-completion
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;;
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; UPDATING THE DATABASE FROM A SOURCE CODE FILE
|
|
|
|
|
;; m-x add-completions-from-buffer
|
|
|
|
|
;; Parses all the definition names from a C or LISP mode buffer and
|
|
|
|
|
;; adds them to the completion database.
|
|
|
|
|
;;
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; m-x add-completions-from-lisp-file
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Parses all the definition names from a C or Lisp mode file and
|
|
|
|
|
;; adds them to the completion database.
|
|
|
|
|
;;
|
|
|
|
|
;; UPDATING THE DATABASE FROM A TAGS TABLE
|
|
|
|
|
;; m-x add-completions-from-tags-table
|
|
|
|
|
;; Adds completions from the current tags-table-buffer.
|
|
|
|
|
;;
|
|
|
|
|
;; HOW A COMPLETION IS FOUND
|
|
|
|
|
;; <write>
|
|
|
|
|
;;
|
|
|
|
|
;; STRING CASING
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; Completion is string case independent if case-fold-search has its
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; normal default of T. Also when the completion is inserted the case of the
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; entry is coerced appropriately.
|
|
|
|
|
;; [E.G. APP --> APPROPRIATELY app --> appropriately
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; App --> Appropriately]
|
|
|
|
|
;;
|
|
|
|
|
;; INITIALIZATION
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; The form `(completion-initialize)' initializes the completion system by
|
|
|
|
|
;; trying to load in the user's completions. After the first call, further
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; calls have no effect so one should be careful not to put the form in a
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; site's standard site-init file.
|
|
|
|
|
;;
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;;
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Functions you might like to call
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;; add-completion string &optional num-uses
|
|
|
|
|
;; Adds a new string to the database
|
|
|
|
|
;;
|
|
|
|
|
;; add-permanent-completion string
|
|
|
|
|
;; Adds a new string to the database with num-uses = T
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
;; kill-completion string
|
|
|
|
|
;; Kills the completion from the database.
|
|
|
|
|
;;
|
|
|
|
|
;; clear-all-completions
|
|
|
|
|
;; Clears the database
|
|
|
|
|
;;
|
|
|
|
|
;; list-all-completions
|
|
|
|
|
;; Returns a list of all completions.
|
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
;; next-completion string &optional index
|
|
|
|
|
;; Returns a completion entry that starts with string.
|
|
|
|
|
;;
|
|
|
|
|
;; find-exact-completion string
|
|
|
|
|
;; Returns a completion entry that exactly matches string.
|
|
|
|
|
;;
|
|
|
|
|
;; complete
|
|
|
|
|
;; Inserts a completion at point
|
|
|
|
|
;;
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; completion-initialize
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; Loads the completions file and sets up so that exiting emacs will
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; save them.
|
|
|
|
|
;;
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; save-completions-to-file &optional filename
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; load-completions-from-file &optional filename
|
|
|
|
|
;;
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Other functions
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;; get-completion-list string
|
|
|
|
|
;;
|
|
|
|
|
;; These things are for manipulating the structure
|
|
|
|
|
;; make-completion string num-uses
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; completion-num-uses completion
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; completion-string completion
|
|
|
|
|
;; set-completion-num-uses completion num-uses
|
|
|
|
|
;; set-completion-string completion string
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;;
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; To Do :: (anybody ?)
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;; Implement Lookup and keyboard interface in C
|
|
|
|
|
;; Add package prefix smarts (for Common Lisp)
|
|
|
|
|
;; Add autoprompting of possible completions after every keystroke (fast
|
|
|
|
|
;; terminals only !)
|
|
|
|
|
;; Add doc. to texinfo
|
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
;;-----------------------------------------------
|
1996-01-20 02:50:09 +00:00
|
|
|
|
;;; Change Log:
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; Sometime in '84 Brewster implemented a somewhat buggy version for
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Symbolics LISPMs.
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; Jan. '85 Jim became enamored of the idea and implemented a faster,
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; more robust version.
|
|
|
|
|
;; With input from many users at TMC, (rose, craig, and gls come to mind),
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; the current style of interface was developed.
|
|
|
|
|
;; 9/87, Jim and Brewster took terminals home. Yuck. After
|
|
|
|
|
;; complaining for a while Brewster implemented a subset of the current
|
|
|
|
|
;; LISPM version for GNU Emacs.
|
|
|
|
|
;; 8/88 After complaining for a while (and with sufficient
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; promised rewards), Jim reimplemented a version of GNU completion
|
|
|
|
|
;; superior to that of the LISPM version.
|
|
|
|
|
;;
|
|
|
|
|
;;-----------------------------------------------
|
2012-07-25 05:48:19 +00:00
|
|
|
|
;; Acknowledgments
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Cliff Lasser (cal@think.com), Kevin Herbert (kph@cisco.com),
|
|
|
|
|
;; eero@media-lab, kgk@cs.brown.edu, jla@ai.mit.edu,
|
|
|
|
|
;;
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Change Log
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; From version 9 to 10
|
|
|
|
|
;; - Allowance for non-integral *completion-version* nos.
|
|
|
|
|
;; - Fix cmpl-apply-as-top-level for keyboard macros
|
|
|
|
|
;; - Fix broken completion merging (in save-completions-to-file)
|
|
|
|
|
;; - More misc. fixes for version 19.0 of emacs
|
|
|
|
|
;;
|
|
|
|
|
;; From Version 8 to 9
|
|
|
|
|
;; - Ported to version 19.0 of emacs (backcompatible with version 18)
|
|
|
|
|
;; - Added add-completions-from-tags-table (with thanks to eero@media-lab)
|
|
|
|
|
;;
|
|
|
|
|
;; From Version 7 to 8
|
|
|
|
|
;; - Misc. changes to comments
|
|
|
|
|
;; - new completion key bindings: c-x o, M->, M-<, c-a, c-e
|
|
|
|
|
;; - cdabbrev now checks all the visible window buffers and the "other buffer"
|
|
|
|
|
;; - `%' is now a symbol character rather than a separator (except in C mode)
|
|
|
|
|
;;
|
|
|
|
|
;; From Version 6 to 7
|
|
|
|
|
;; - Fixed bug with saving out .completion file the first time
|
|
|
|
|
;;
|
|
|
|
|
;; From Version 5 to 6
|
|
|
|
|
;; - removed statistics recording
|
|
|
|
|
;; - reworked advise to handle autoloads
|
|
|
|
|
;; - Fixed fortran mode support
|
|
|
|
|
;; - Added new cursor motion triggers
|
|
|
|
|
;;
|
|
|
|
|
;; From Version 4 to 5
|
|
|
|
|
;; - doesn't bother saving if nothing has changed
|
|
|
|
|
;; - auto-save if haven't used for a 1/2 hour
|
|
|
|
|
;; - save period extended to two weeks
|
|
|
|
|
;; - minor fix to capitalization code
|
|
|
|
|
;; - added *completion-auto-save-period* to variables recorded.
|
|
|
|
|
;; - added reenter protection to cmpl-record-statistics-filter
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; - added backup protection to save-completions-to-file (prevents
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; problems with disk full errors)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1992-07-16 18:28:42 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; User changeable parameters
|
|
|
|
|
;;---------------------------------------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1997-04-13 07:51:54 +00:00
|
|
|
|
(defgroup completion nil
|
|
|
|
|
"Dynamic word-completion code."
|
1998-05-26 09:23:23 +00:00
|
|
|
|
:group 'matching
|
|
|
|
|
:group 'convenience)
|
1997-04-13 07:51:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defcustom enable-completion t
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"Non-nil means enable recording and saving of completions.
|
2000-05-22 17:53:15 +00:00
|
|
|
|
If nil, no new words are added to the database or saved to the init file."
|
1997-04-13 07:51:54 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'completion)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1997-04-13 07:51:54 +00:00
|
|
|
|
(defcustom save-completions-flag t
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"Non-nil means save most-used completions when exiting Emacs.
|
1997-09-12 22:34:14 +00:00
|
|
|
|
See also `save-completions-retention-time'."
|
1997-04-13 07:51:54 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'completion)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defcustom save-completions-file-name
|
2008-10-24 09:39:27 +00:00
|
|
|
|
(locate-user-emacs-file "completions" ".completions")
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"The filename to save completions to."
|
1997-04-13 07:51:54 +00:00
|
|
|
|
:type 'file
|
|
|
|
|
:group 'completion)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1997-04-13 07:51:54 +00:00
|
|
|
|
(defcustom save-completions-retention-time 336
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"Discard a completion if unused for this many hours.
|
1993-05-27 12:44:54 +00:00
|
|
|
|
\(1 day = 24, 1 week = 168). If this is 0, non-permanent completions
|
1997-04-13 07:51:54 +00:00
|
|
|
|
will not be saved unless these are used. Default is two weeks."
|
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'completion)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1997-04-13 07:51:54 +00:00
|
|
|
|
(defcustom completion-on-separator-character nil
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"Non-nil means separator characters mark previous word as used.
|
1997-04-13 07:51:54 +00:00
|
|
|
|
This means the word will be saved as a completion."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'completion)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1997-04-13 07:51:54 +00:00
|
|
|
|
(defcustom completions-file-versions-kept kept-new-versions
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"Number of versions to keep for the saved completions file."
|
1997-04-13 07:51:54 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'completion)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1997-04-13 07:51:54 +00:00
|
|
|
|
(defcustom completion-prompt-speed-threshold 4800
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"Minimum output speed at which to display next potential completion."
|
1997-04-13 07:51:54 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'completion)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1997-04-13 07:51:54 +00:00
|
|
|
|
(defcustom completion-cdabbrev-prompt-flag nil
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"If non-nil, the next completion prompt does a cdabbrev search.
|
1997-04-13 07:51:54 +00:00
|
|
|
|
This can be time consuming."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'completion)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1997-04-13 07:51:54 +00:00
|
|
|
|
(defcustom completion-search-distance 15000
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"How far to search in the buffer when looking for completions.
|
1997-04-13 07:51:54 +00:00
|
|
|
|
In number of characters. If nil, search the whole buffer."
|
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'completion)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1997-04-13 07:51:54 +00:00
|
|
|
|
(defcustom completions-merging-modes '(lisp c)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"List of modes {`c' or `lisp'} for automatic completions merging.
|
1993-05-27 12:44:54 +00:00
|
|
|
|
Definitions from visited files which have these modes
|
1997-04-13 07:51:54 +00:00
|
|
|
|
are automatically added to the completion database."
|
|
|
|
|
:type '(set (const lisp) (const c))
|
|
|
|
|
:group 'completion)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;(defvar *completion-auto-save-period* 1800
|
2012-04-09 13:05:48 +00:00
|
|
|
|
;; "The period in seconds to wait for emacs to be idle before autosaving
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;the completions. Default is a 1/2 hour.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2003-02-05 19:09:34 +00:00
|
|
|
|
(defvar completion-min-length 6
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"The minimum length of a stored completion.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
DON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.")
|
|
|
|
|
|
2003-02-05 19:09:34 +00:00
|
|
|
|
(defvar completion-max-length 200
|
2012-04-09 13:05:48 +00:00
|
|
|
|
"The maximum length of a stored completion.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
DON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.")
|
|
|
|
|
|
2003-02-05 19:09:34 +00:00
|
|
|
|
(defvar completion-prefix-min-length 3
|
1990-04-05 21:41:26 +00:00
|
|
|
|
"The minimum length of a completion search string.
|
|
|
|
|
DON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.")
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Internal Variables
|
|
|
|
|
;;---------------------------------------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defvar cmpl-initialized-p nil
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Set to t when the completion system is initialized.
|
|
|
|
|
Indicates that the old completion file has been read in.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defvar cmpl-completions-accepted-p nil
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Set to t as soon as the first completion has been accepted.
|
|
|
|
|
Used to decide whether to save completions.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(defvar cmpl-preceding-syntax)
|
1995-02-02 23:07:44 +00:00
|
|
|
|
|
2014-12-22 17:35:29 +00:00
|
|
|
|
(defvar cmpl--completion-string)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Low level tools
|
|
|
|
|
;;---------------------------------------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; String case coercion
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun cmpl-string-case-type (string)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"Return :capitalized, :up, :down, :mixed, or :neither for case of STRING."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(let ((case-fold-search nil))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(cond ((string-match "[[:lower:]]" string)
|
|
|
|
|
(cond ((string-match "[[:upper:]]" string)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cond ((and (> (length string) 1)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(null (string-match "[[:upper:]]" string 1)))
|
|
|
|
|
:capitalized)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(t
|
2000-05-22 17:53:15 +00:00
|
|
|
|
:mixed)))
|
|
|
|
|
(t :down)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(t
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(cond ((string-match "[[:upper:]]" string)
|
|
|
|
|
:up)
|
|
|
|
|
(t :neither))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun cmpl-coerce-string-case (string case-type)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(cond ((eq case-type :down) (downcase string))
|
|
|
|
|
((eq case-type :up) (upcase string))
|
2019-02-20 14:15:35 +00:00
|
|
|
|
((eq case-type :capitalized) (capitalize string))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(t string)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun cmpl-merge-string-cases (string-to-coerce given-string)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(let ((string-case-type (cmpl-string-case-type string-to-coerce)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cond ((memq string-case-type '(:down :up :capitalized))
|
|
|
|
|
;; Found string is in a standard case. Coerce to a type based on
|
|
|
|
|
;; the given string
|
|
|
|
|
(cmpl-coerce-string-case string-to-coerce
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(cmpl-string-case-type given-string)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(t
|
|
|
|
|
;; If the found string is in some unusual case, just insert it
|
|
|
|
|
;; as is
|
2000-05-22 17:53:15 +00:00
|
|
|
|
string-to-coerce))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(defun cmpl-hours-since-origin ()
|
New function time-convert
This replaces the awkward reuse of encode-time to both convert
calendrical timestamps to Lisp timestamps, and to convert Lisp
timestamps to other forms. Now, encode-time does just the
former and the new function does just the latter.
The new function builds on a suggestion by Lars Ingebrigtsen in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00801.html
and refined by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00803.html
* doc/lispref/os.texi (Time of Day, Time Conversion):
* doc/misc/emacs-mime.texi (time-date):
* etc/NEWS: Update documentation.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-add-item):
* lisp/emacs-lisp/cl-extra.el (cl--random-time):
* lisp/emacs-lisp/timer.el (timer--time-setter)
(timer-next-integral-multiple-of-time):
* lisp/find-lisp.el (find-lisp-format-time):
* lisp/gnus/gnus-diary.el (gnus-user-format-function-d):
* lisp/gnus/gnus-group.el (gnus-group-set-timestamp):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-show-org-agenda):
* lisp/gnus/nnrss.el (nnrss-normalize-date):
* lisp/gnus/nnspool.el (nnspool-request-newgroups):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/net/pop3.el (pop3-uidl-dele):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-clock-in)
(org-clock-out, org-clock-sum):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cc-cmds.el (c-progress-init)
(c-progress-update):
* lisp/progmodes/cperl-mode.el (cperl-time-fontification):
* lisp/progmodes/flymake.el (flymake--schedule-timer-maybe):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
* lisp/tar-mode.el (tar-octal-time):
* lisp/time.el (emacs-uptime):
* lisp/url/url-auth.el (url-digest-auth-make-cnonce):
* lisp/url/url-util.el (url-lazy-message):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg-state-fast):
* lisp/xt-mouse.el (xterm-mouse-event):
* test/lisp/emacs-lisp/timer-tests.el:
(timer-next-integral-multiple-of-time-2):
Use time-convert, not encode-time.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
Don’t use now-removed FORM argument for encode-time.
It wasn’t crucial anyway.
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add time-convert.
* lisp/emacs-lisp/elint.el (elint-unknown-builtin-args):
Update encode-time signature to match current arg set.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Use timer-convert with t rather than doing it by hand.
* src/timefns.c (time_hz_ticks, time_form_stamp, lisp_time_form_stamp):
Remove; no longer needed.
(decode_lisp_time): Rturn the form instead of having a *PFORM arg.
All uses changed.
(time_arith): Just return TICKS if HZ is 1.
(Fencode_time): Remove argument FORM. All callers changed.
Do not attempt to encode time values; just encode
decoded (calendrical) times.
Unless CURRENT_TIME_LIST, just return VALUE since HZ is 1.
(Ftime_convert): New function, which does the time value
conversion that bleeding-edge encode-time formerly did.
Return TIME if it is easy to see that it is already
of the correct form.
(Fcurrent_time): Mention in doc that the form is planned to change.
* test/src/timefns-tests.el (decode-then-encode-time):
Don’t use (encode-time nil).
2019-08-06 00:38:52 +00:00
|
|
|
|
(floor (time-convert nil 'integer) 3600))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; "Symbol" parsing functions
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; The functions symbol-before-point, symbol-under-point, etc. quickly return
|
|
|
|
|
;; an appropriate symbol string. The strategy is to temporarily change
|
|
|
|
|
;; the syntax table to enable fast symbol searching. There are three classes
|
|
|
|
|
;; of syntax in these "symbol" syntax tables ::
|
|
|
|
|
;;
|
|
|
|
|
;; syntax (?_) - "symbol" chars (e.g. alphanumerics)
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; syntax (?w) - symbol chars to ignore at end of words (e.g. period).
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; syntax (? ) - everything else
|
|
|
|
|
;;
|
|
|
|
|
;; Thus by judicious use of scan-sexps and forward-word, we can get
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; the word we want relatively fast and without consing.
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Why do we need a separate category for "symbol chars to ignore at ends" ?
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; For example, in LISP we want starting :'s trimmed
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; so keyword argument specifiers also define the keyword completion. And,
|
|
|
|
|
;; for example, in C we want `.' appearing in a structure ref. to
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; be kept intact in order to store the whole structure ref.; however, if
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; it appears at the end of a symbol it should be discarded because it is
|
|
|
|
|
;; probably used as a period.
|
|
|
|
|
|
|
|
|
|
;; Here is the default completion syntax ::
|
|
|
|
|
;; Symbol chars :: A-Z a-z 0-9 @ / \ * + ~ $ < > %
|
|
|
|
|
;; Symbol chars to ignore at ends :: _ : . -
|
|
|
|
|
;; Separator chars. :: <tab> <space> ! ^ & ( ) = ` | { } [ ] ; " ' #
|
|
|
|
|
;; , ? <Everything else>
|
|
|
|
|
|
|
|
|
|
;; Mode specific differences and notes ::
|
|
|
|
|
;; LISP diffs ->
|
|
|
|
|
;; Symbol chars :: ! & ? = ^
|
|
|
|
|
;;
|
|
|
|
|
;; C diffs ->
|
|
|
|
|
;; Separator chars :: + * / : %
|
|
|
|
|
;; A note on the hyphen (`-'). Perhaps the hyphen should also be a separator
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; char., however, we wanted to have completion symbols include pointer
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; references. For example, "foo->bar" is a symbol as far as completion is
|
|
|
|
|
;; concerned.
|
|
|
|
|
;;
|
|
|
|
|
;; FORTRAN diffs ->
|
|
|
|
|
;; Separator chars :: + - * / :
|
|
|
|
|
;;
|
|
|
|
|
;; Pathname diffs ->
|
|
|
|
|
;; Symbol chars :: .
|
|
|
|
|
;; Of course there is no pathname "mode" and in fact we have not implemented
|
|
|
|
|
;; this table. However, if there was such a mode, this is what it would look
|
|
|
|
|
;; like.
|
|
|
|
|
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Table definitions
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defconst completion-standard-syntax-table
|
1996-04-16 16:04:01 +00:00
|
|
|
|
(let ((table (make-syntax-table))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
i)
|
1996-04-16 16:04:01 +00:00
|
|
|
|
;; Default syntax is whitespace.
|
|
|
|
|
(setq i 0)
|
|
|
|
|
(while (< i 256)
|
|
|
|
|
(modify-syntax-entry i " " table)
|
|
|
|
|
(setq i (1+ i)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; alpha chars
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(setq i 0)
|
|
|
|
|
(while (< i 26)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(modify-syntax-entry (+ ?a i) "_" table)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(modify-syntax-entry (+ ?A i) "_" table)
|
|
|
|
|
(setq i (1+ i)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; digit chars.
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(setq i 0)
|
|
|
|
|
(while (< i 10)
|
|
|
|
|
(modify-syntax-entry (+ ?0 i) "_" table)
|
|
|
|
|
(setq i (1+ i)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; Other ones
|
|
|
|
|
(let ((symbol-chars '(?@ ?/ ?\\ ?* ?+ ?~ ?$ ?< ?> ?%))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(symbol-chars-ignore '(?_ ?- ?: ?.)))
|
2000-02-03 15:45:10 +00:00
|
|
|
|
(dolist (char symbol-chars)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(modify-syntax-entry char "_" table))
|
2000-02-03 15:45:10 +00:00
|
|
|
|
(dolist (char symbol-chars-ignore)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(modify-syntax-entry char "w" table)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
table))
|
|
|
|
|
|
2018-04-20 22:55:04 +00:00
|
|
|
|
;; Old name, non-namespace-clean.
|
|
|
|
|
(defvaralias 'cmpl-syntax-table 'completion-syntax-table)
|
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defvar completion-syntax-table completion-standard-syntax-table
|
1990-04-05 21:41:26 +00:00
|
|
|
|
"This variable holds the current completion syntax table.")
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(make-variable-buffer-local 'completion-syntax-table)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Symbol functions
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defvar cmpl-symbol-start nil
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Holds first character of symbol, after any completion symbol function.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defvar cmpl-symbol-end nil
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Holds last character of symbol, after any completion symbol function.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun symbol-under-point ()
|
2003-02-05 19:09:34 +00:00
|
|
|
|
"Return the symbol that the point is currently on.
|
1993-05-27 12:44:54 +00:00
|
|
|
|
But only if it is longer than `completion-min-length'."
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(with-syntax-table completion-syntax-table
|
|
|
|
|
(when (memq (char-syntax (following-char)) '(?w ?_))
|
|
|
|
|
;; Cursor is on following-char and after preceding-char
|
|
|
|
|
(let ((saved-point (point)))
|
|
|
|
|
(setq cmpl-symbol-start (scan-sexps (1+ saved-point) -1)
|
|
|
|
|
cmpl-symbol-end (scan-sexps saved-point 1))
|
|
|
|
|
;; Remove chars to ignore at the start.
|
|
|
|
|
(cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
|
|
|
|
|
(goto-char cmpl-symbol-start)
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 21:54:21 +00:00
|
|
|
|
(forward-word-strictly 1)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq cmpl-symbol-start (point))
|
|
|
|
|
(goto-char saved-point)))
|
|
|
|
|
;; Remove chars to ignore at the end.
|
|
|
|
|
(cond ((= (char-syntax (char-after (1- cmpl-symbol-end))) ?w)
|
|
|
|
|
(goto-char cmpl-symbol-end)
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 21:54:21 +00:00
|
|
|
|
(forward-word-strictly -1)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq cmpl-symbol-end (point))
|
|
|
|
|
(goto-char saved-point)))
|
|
|
|
|
;; Return completion if the length is reasonable.
|
|
|
|
|
(if (and (<= completion-min-length
|
|
|
|
|
(- cmpl-symbol-end cmpl-symbol-start))
|
|
|
|
|
(<= (- cmpl-symbol-end cmpl-symbol-start)
|
|
|
|
|
completion-max-length))
|
2007-08-17 07:31:52 +00:00
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
cmpl-symbol-start cmpl-symbol-end))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; tests for symbol-under-point
|
|
|
|
|
;; `^' indicates cursor pos. where value is returned
|
|
|
|
|
;; simple-word-test
|
|
|
|
|
;; ^^^^^^^^^^^^^^^^ --> simple-word-test
|
|
|
|
|
;; _harder_word_test_
|
|
|
|
|
;; ^^^^^^^^^^^^^^^^^^ --> harder_word_test
|
|
|
|
|
;; .___.______.
|
|
|
|
|
;; --> nil
|
|
|
|
|
;; /foo/bar/quux.hello
|
|
|
|
|
;; ^^^^^^^^^^^^^^^^^^^ --> /foo/bar/quux.hello
|
|
|
|
|
;;
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun symbol-before-point ()
|
2003-02-05 19:09:34 +00:00
|
|
|
|
"Return a string of the symbol immediately before point.
|
2003-02-04 11:26:42 +00:00
|
|
|
|
Returns nil if there isn't one longer than `completion-min-length'."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; This is called when a word separator is typed so it must be FAST !
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(with-syntax-table completion-syntax-table
|
|
|
|
|
;; Cursor is on following-char and after preceding-char
|
|
|
|
|
(cond ((= (setq cmpl-preceding-syntax (char-syntax (preceding-char))) ?_)
|
|
|
|
|
;; Number of chars to ignore at end.
|
|
|
|
|
(setq cmpl-symbol-end (point)
|
|
|
|
|
cmpl-symbol-start (scan-sexps cmpl-symbol-end -1))
|
|
|
|
|
;; Remove chars to ignore at the start.
|
|
|
|
|
(cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
|
|
|
|
|
(goto-char cmpl-symbol-start)
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 21:54:21 +00:00
|
|
|
|
(forward-word-strictly 1)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq cmpl-symbol-start (point))
|
|
|
|
|
(goto-char cmpl-symbol-end)))
|
|
|
|
|
;; Return value if long enough.
|
|
|
|
|
(if (>= cmpl-symbol-end
|
|
|
|
|
(+ cmpl-symbol-start completion-min-length))
|
2007-08-17 07:31:52 +00:00
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
cmpl-symbol-start cmpl-symbol-end)))
|
2005-11-28 01:43:28 +00:00
|
|
|
|
((= cmpl-preceding-syntax ?w)
|
|
|
|
|
;; chars to ignore at end
|
|
|
|
|
(let ((saved-point (point)))
|
|
|
|
|
(setq cmpl-symbol-start (scan-sexps saved-point -1))
|
|
|
|
|
;; take off chars. from end
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 21:54:21 +00:00
|
|
|
|
(forward-word-strictly -1)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq cmpl-symbol-end (point))
|
|
|
|
|
;; remove chars to ignore at the start
|
|
|
|
|
(cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
|
|
|
|
|
(goto-char cmpl-symbol-start)
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 21:54:21 +00:00
|
|
|
|
(forward-word-strictly 1)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq cmpl-symbol-start (point))))
|
|
|
|
|
;; Restore state.
|
|
|
|
|
(goto-char saved-point)
|
|
|
|
|
;; Return completion if the length is reasonable
|
|
|
|
|
(if (and (<= completion-min-length
|
|
|
|
|
(- cmpl-symbol-end cmpl-symbol-start))
|
|
|
|
|
(<= (- cmpl-symbol-end cmpl-symbol-start)
|
|
|
|
|
completion-max-length))
|
2007-08-17 07:31:52 +00:00
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
cmpl-symbol-start cmpl-symbol-end)))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; tests for symbol-before-point
|
|
|
|
|
;; `^' indicates cursor pos. where value is returned
|
|
|
|
|
;; simple-word-test
|
|
|
|
|
;; ^ --> nil
|
|
|
|
|
;; ^ --> nil
|
|
|
|
|
;; ^ --> simple-w
|
|
|
|
|
;; ^ --> simple-word-test
|
|
|
|
|
;; _harder_word_test_
|
|
|
|
|
;; ^ --> harder_word_test
|
|
|
|
|
;; ^ --> harder_word_test
|
|
|
|
|
;; ^ --> harder
|
|
|
|
|
;; .___....
|
|
|
|
|
;; --> nil
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun symbol-under-or-before-point ()
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; This could be made slightly faster but it is better to avoid
|
|
|
|
|
;; copying all the code.
|
|
|
|
|
;; However, it is only used by the completion string prompter.
|
|
|
|
|
;; If it comes into common use, it could be rewritten.
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(if (memq (with-syntax-table completion-syntax-table
|
|
|
|
|
(char-syntax (following-char)))
|
|
|
|
|
'(?w ?_))
|
|
|
|
|
(symbol-under-point)
|
|
|
|
|
(symbol-before-point)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun symbol-before-point-for-complete ()
|
|
|
|
|
;; "Returns a string of the symbol immediately before point
|
|
|
|
|
;; or nil if there isn't one. Like symbol-before-point but doesn't trim the
|
|
|
|
|
;; end chars."
|
|
|
|
|
;; Cursor is on following-char and after preceding-char
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(with-syntax-table completion-syntax-table
|
|
|
|
|
(cond ((memq (setq cmpl-preceding-syntax (char-syntax (preceding-char)))
|
|
|
|
|
'(?_ ?w))
|
|
|
|
|
(setq cmpl-symbol-end (point)
|
|
|
|
|
cmpl-symbol-start (scan-sexps cmpl-symbol-end -1))
|
|
|
|
|
;; Remove chars to ignore at the start.
|
|
|
|
|
(cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
|
|
|
|
|
(goto-char cmpl-symbol-start)
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 21:54:21 +00:00
|
|
|
|
(forward-word-strictly 1)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq cmpl-symbol-start (point))
|
|
|
|
|
(goto-char cmpl-symbol-end)))
|
|
|
|
|
;; Return completion if the length is reasonable.
|
|
|
|
|
(if (and (<= completion-prefix-min-length
|
|
|
|
|
(- cmpl-symbol-end cmpl-symbol-start))
|
|
|
|
|
(<= (- cmpl-symbol-end cmpl-symbol-start)
|
|
|
|
|
completion-max-length))
|
2007-08-17 07:31:52 +00:00
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
cmpl-symbol-start cmpl-symbol-end))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; tests for symbol-before-point-for-complete
|
|
|
|
|
;; `^' indicates cursor pos. where value is returned
|
|
|
|
|
;; simple-word-test
|
|
|
|
|
;; ^ --> nil
|
|
|
|
|
;; ^ --> nil
|
|
|
|
|
;; ^ --> simple-w
|
|
|
|
|
;; ^ --> simple-word-test
|
|
|
|
|
;; _harder_word_test_
|
|
|
|
|
;; ^ --> harder_word_test
|
|
|
|
|
;; ^ --> harder_word_test_
|
|
|
|
|
;; ^ --> harder_
|
|
|
|
|
;; .___....
|
|
|
|
|
;; --> nil
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Statistics Recording
|
|
|
|
|
;;---------------------------------------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Note that the guts of this has been turned off. The guts
|
|
|
|
|
;; are in completion-stats.el.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Completion Sources
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
;; ID numbers
|
|
|
|
|
(defconst cmpl-source-unknown 0)
|
|
|
|
|
(defconst cmpl-source-init-file 1)
|
|
|
|
|
(defconst cmpl-source-file-parsing 2)
|
|
|
|
|
(defconst cmpl-source-separator 3)
|
|
|
|
|
(defconst cmpl-source-cursor-moves 4)
|
|
|
|
|
(defconst cmpl-source-interactive 5)
|
|
|
|
|
(defconst cmpl-source-cdabbrev 6)
|
|
|
|
|
(defconst num-cmpl-sources 7)
|
|
|
|
|
(defvar current-completion-source cmpl-source-unknown)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Completion Method #2: dabbrev-expand style
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;;
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; This method is used if there are no useful stored completions. It is
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; based on dabbrev-expand with these differences :
|
|
|
|
|
;; 1) Faster (we don't use regexps)
|
|
|
|
|
;; 2) case coercion handled correctly
|
|
|
|
|
;; This is called cdabbrev to differentiate it.
|
|
|
|
|
;; We simply search backwards through the file looking for words which
|
|
|
|
|
;; start with the same letters we are trying to complete.
|
|
|
|
|
;;
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defvar cdabbrev-completions-tried nil)
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; "A list of all the cdabbrev completions since the last reset.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defvar cdabbrev-current-point 0)
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; "The current point position the cdabbrev search is at.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defvar cdabbrev-current-window nil)
|
1998-11-01 08:45:25 +00:00
|
|
|
|
;; "The current window we are looking for cdabbrevs in.
|
|
|
|
|
;; Return t if looking in (other-buffer), nil if no more cdabbrevs.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defvar cdabbrev-wrapped-p nil)
|
1998-11-01 08:45:25 +00:00
|
|
|
|
;; "Return t if the cdabbrev search has wrapped around the file.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defvar cdabbrev-abbrev-string "")
|
|
|
|
|
(defvar cdabbrev-start-point 0)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(defvar cdabbrev-stop-point)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Test strings for cdabbrev
|
|
|
|
|
;; cdat-upcase ;;same namestring
|
|
|
|
|
;; CDAT-UPCASE ;;ok
|
|
|
|
|
;; cdat2 ;;too short
|
|
|
|
|
;; cdat-1-2-3-4 ;;ok
|
|
|
|
|
;; a-cdat-1 ;;doesn't start correctly
|
|
|
|
|
;; cdat-simple ;;ok
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun reset-cdabbrev (abbrev-string &optional initial-completions-tried)
|
2003-02-05 19:09:34 +00:00
|
|
|
|
"Reset the cdabbrev search to search for ABBREV-STRING.
|
1993-05-27 12:44:54 +00:00
|
|
|
|
INITIAL-COMPLETIONS-TRIED is a list of downcased strings to ignore
|
1990-04-05 21:41:26 +00:00
|
|
|
|
during the search."
|
|
|
|
|
(setq cdabbrev-abbrev-string abbrev-string
|
|
|
|
|
cdabbrev-completions-tried
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(cons (downcase abbrev-string) initial-completions-tried))
|
|
|
|
|
(reset-cdabbrev-window t))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun set-cdabbrev-buffer ()
|
2001-12-20 18:59:32 +00:00
|
|
|
|
;; cdabbrev-current-window must not be nil
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(set-buffer (if (eq cdabbrev-current-window t)
|
|
|
|
|
(other-buffer)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(window-buffer cdabbrev-current-window))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun reset-cdabbrev-window (&optional initializep)
|
2003-02-05 19:09:34 +00:00
|
|
|
|
"Reset the cdabbrev search to search for abbrev-string."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; Set the window
|
|
|
|
|
(cond (initializep
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cdabbrev-current-window (selected-window)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
((eq cdabbrev-current-window t)
|
|
|
|
|
;; Everything has failed
|
|
|
|
|
(setq cdabbrev-current-window nil))
|
|
|
|
|
(cdabbrev-current-window
|
|
|
|
|
(setq cdabbrev-current-window (next-window cdabbrev-current-window))
|
|
|
|
|
(if (eq cdabbrev-current-window (selected-window))
|
|
|
|
|
;; No more windows, try other buffer.
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cdabbrev-current-window t))))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(if cdabbrev-current-window
|
|
|
|
|
(save-excursion
|
|
|
|
|
(set-cdabbrev-buffer)
|
|
|
|
|
(setq cdabbrev-current-point (point)
|
|
|
|
|
cdabbrev-start-point cdabbrev-current-point
|
|
|
|
|
cdabbrev-stop-point
|
|
|
|
|
(if completion-search-distance
|
|
|
|
|
(max (point-min)
|
|
|
|
|
(- cdabbrev-start-point completion-search-distance))
|
|
|
|
|
(point-min))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
cdabbrev-wrapped-p nil))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun next-cdabbrev ()
|
|
|
|
|
"Return the next possible cdabbrev expansion or nil if there isn't one.
|
1993-05-27 12:44:54 +00:00
|
|
|
|
`reset-cdabbrev' must've been called already.
|
|
|
|
|
This is sensitive to `case-fold-search'."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; note that case-fold-search affects the behavior of this function
|
|
|
|
|
;; Bug: won't pick up an expansion that starts at the top of buffer
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(if cdabbrev-current-window
|
2003-02-04 11:26:42 +00:00
|
|
|
|
(let (saved-point
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
saved-syntax
|
|
|
|
|
(expansion nil)
|
|
|
|
|
downcase-expansion tried-list syntax saved-point-2)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
;; Switch to current completion buffer
|
|
|
|
|
(set-cdabbrev-buffer)
|
|
|
|
|
;; Save current buffer state
|
|
|
|
|
(setq saved-point (point)
|
|
|
|
|
saved-syntax (syntax-table))
|
|
|
|
|
;; Restore completion state
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(set-syntax-table completion-syntax-table)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(goto-char cdabbrev-current-point)
|
|
|
|
|
;; Loop looking for completions
|
|
|
|
|
(while
|
|
|
|
|
;; This code returns t if it should loop again
|
|
|
|
|
(cond
|
|
|
|
|
(;; search for the string
|
|
|
|
|
(search-backward cdabbrev-abbrev-string cdabbrev-stop-point t)
|
|
|
|
|
;; return nil if the completion is valid
|
|
|
|
|
(not
|
|
|
|
|
(and
|
|
|
|
|
;; does it start with a separator char ?
|
|
|
|
|
(or (= (setq syntax (char-syntax (preceding-char))) ? )
|
|
|
|
|
(and (= syntax ?w)
|
|
|
|
|
;; symbol char to ignore at end. Are we at end ?
|
|
|
|
|
(progn
|
|
|
|
|
(setq saved-point-2 (point))
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 21:54:21 +00:00
|
|
|
|
(forward-word-strictly -1)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(prog1
|
|
|
|
|
(= (char-syntax (preceding-char)) ? )
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(goto-char saved-point-2)))))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; is the symbol long enough ?
|
|
|
|
|
(setq expansion (symbol-under-point))
|
|
|
|
|
;; have we not tried this one before
|
|
|
|
|
(progn
|
|
|
|
|
;; See if we've already used it
|
|
|
|
|
(setq tried-list cdabbrev-completions-tried
|
|
|
|
|
downcase-expansion (downcase expansion))
|
|
|
|
|
(while (and tried-list
|
|
|
|
|
(not (string-equal downcase-expansion
|
|
|
|
|
(car tried-list))))
|
|
|
|
|
;; Already tried, don't choose this one
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq tried-list (cdr tried-list)))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; at this point tried-list will be nil if this
|
|
|
|
|
;; expansion has not yet been tried
|
|
|
|
|
(if tried-list
|
|
|
|
|
(setq expansion nil)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
t)))))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; search failed
|
|
|
|
|
(cdabbrev-wrapped-p
|
|
|
|
|
;; If already wrapped, then we've failed completely
|
|
|
|
|
nil)
|
|
|
|
|
(t
|
|
|
|
|
;; need to wrap
|
|
|
|
|
(goto-char (setq cdabbrev-current-point
|
|
|
|
|
(if completion-search-distance
|
|
|
|
|
(min (point-max) (+ cdabbrev-start-point completion-search-distance))
|
|
|
|
|
(point-max))))
|
|
|
|
|
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cdabbrev-wrapped-p t))))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; end of while loop
|
|
|
|
|
(cond (expansion
|
|
|
|
|
;; successful
|
|
|
|
|
(setq cdabbrev-completions-tried
|
|
|
|
|
(cons downcase-expansion cdabbrev-completions-tried)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
cdabbrev-current-point (point)))))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(set-syntax-table saved-syntax)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(goto-char saved-point)))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; If no expansion, go to next window
|
|
|
|
|
(cond (expansion)
|
|
|
|
|
(t (reset-cdabbrev-window)
|
|
|
|
|
(next-cdabbrev))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; The following must be eval'd in the minibuffer ::
|
|
|
|
|
;; (reset-cdabbrev "cdat")
|
|
|
|
|
;; (next-cdabbrev) --> "cdat-simple"
|
|
|
|
|
;; (next-cdabbrev) --> "cdat-1-2-3-4"
|
|
|
|
|
;; (next-cdabbrev) --> "CDAT-UPCASE"
|
|
|
|
|
;; (next-cdabbrev) --> "cdat-wrapping"
|
|
|
|
|
;; (next-cdabbrev) --> "cdat_start_sym"
|
|
|
|
|
;; (next-cdabbrev) --> nil
|
|
|
|
|
;; (next-cdabbrev) --> nil
|
|
|
|
|
;; (next-cdabbrev) --> nil
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; _cdat_start_sym
|
|
|
|
|
;; cdat-wrapping
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Completion Database
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
;; We use two storage modes for the two search types ::
|
|
|
|
|
;; 1) Prefix {cmpl-prefix-obarray} for looking up possible completions
|
|
|
|
|
;; Used by search-completion-next
|
|
|
|
|
;; the value of the symbol is nil or a cons of head and tail pointers
|
|
|
|
|
;; 2) Interning {cmpl-obarray} to see if it's in the database
|
|
|
|
|
;; Used by find-exact-completion, completion-in-database-p
|
|
|
|
|
;; The value of the symbol is the completion entry
|
|
|
|
|
|
|
|
|
|
;; bad things may happen if this length is changed due to the way
|
|
|
|
|
;; GNU implements obarrays
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defconst cmpl-obarray-length 511)
|
|
|
|
|
|
|
|
|
|
(defvar cmpl-prefix-obarray (make-vector cmpl-obarray-length 0)
|
1993-06-09 11:59:12 +00:00
|
|
|
|
"An obarray used to store the downcased completion prefixes.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
Each symbol is bound to a list of completion entries.")
|
|
|
|
|
|
|
|
|
|
(defvar cmpl-obarray (make-vector cmpl-obarray-length 0)
|
|
|
|
|
"An obarray used to store the downcased completions.
|
|
|
|
|
Each symbol is bound to a single completion entry.")
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Completion Entry Structure Definition
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; A completion entry is a LIST of string, prefix-symbol num-uses, and
|
|
|
|
|
;; last-use-time (the time the completion was last used)
|
2001-12-20 18:59:32 +00:00
|
|
|
|
;; last-use-time is t if the string should be kept permanently
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; num-uses is incremented every time the completion is used.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; We chose lists because (car foo) is faster than (aref foo 0) and the
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; creation time is about the same.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; READER MACROS
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defmacro completion-string (completion-entry)
|
|
|
|
|
(list 'car completion-entry))
|
|
|
|
|
|
|
|
|
|
(defmacro completion-num-uses (completion-entry)
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; "The number of times it has used. Used to decide whether to save
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; it."
|
|
|
|
|
(list 'car (list 'cdr completion-entry)))
|
|
|
|
|
|
|
|
|
|
(defmacro completion-last-use-time (completion-entry)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
;; "The time it was last used. In hours since origin. Used to decide
|
2001-12-20 18:59:32 +00:00
|
|
|
|
;; whether to save it. t if one should always save it."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(list 'nth 2 completion-entry))
|
|
|
|
|
|
|
|
|
|
(defmacro completion-source (completion-entry)
|
|
|
|
|
(list 'nth 3 completion-entry))
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; WRITER MACROS
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defmacro set-completion-string (completion-entry string)
|
|
|
|
|
(list 'setcar completion-entry string))
|
|
|
|
|
|
|
|
|
|
(defmacro set-completion-num-uses (completion-entry num-uses)
|
|
|
|
|
(list 'setcar (list 'cdr completion-entry) num-uses))
|
|
|
|
|
|
|
|
|
|
(defmacro set-completion-last-use-time (completion-entry last-use-time)
|
|
|
|
|
(list 'setcar (list 'cdr (list 'cdr completion-entry)) last-use-time))
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; CONSTRUCTOR
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defun make-completion (string)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
"Return a completion entry."
|
|
|
|
|
(list string 0 nil current-completion-source))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
;; Obsolete
|
|
|
|
|
;;(defmacro cmpl-prefix-entry-symbol (completion-entry)
|
|
|
|
|
;; (list 'car (list 'cdr completion-entry)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Prefix symbol entry definition
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; A cons of (head . tail)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; READER Macros
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defalias 'cmpl-prefix-entry-head 'car)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defalias 'cmpl-prefix-entry-tail 'cdr)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; WRITER Macros
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defmacro set-cmpl-prefix-entry-head (prefix-entry new-head)
|
|
|
|
|
(list 'setcar prefix-entry new-head))
|
|
|
|
|
|
|
|
|
|
(defmacro set-cmpl-prefix-entry-tail (prefix-entry new-tail)
|
|
|
|
|
(list 'setcdr prefix-entry new-tail))
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Constructor
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun make-cmpl-prefix-entry (completion-entry-list)
|
2003-02-05 19:09:34 +00:00
|
|
|
|
"Make a new prefix entry containing only completion-entry."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cons completion-entry-list completion-entry-list))
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Completion Database - Utilities
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun clear-all-completions ()
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"Initialize the completion storage. All existing completions are lost."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(setq cmpl-prefix-obarray (make-vector cmpl-obarray-length 0))
|
2013-08-10 12:00:19 +00:00
|
|
|
|
(setq cmpl-obarray (make-vector cmpl-obarray-length 0)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(defvar completions-list-return-value)
|
|
|
|
|
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defun list-all-completions ()
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"Return a list of all the known completion entries."
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(let ((completions-list-return-value nil))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(mapatoms 'list-all-completions-1 cmpl-prefix-obarray)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
completions-list-return-value))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun list-all-completions-1 (prefix-symbol)
|
|
|
|
|
(if (boundp prefix-symbol)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(setq completions-list-return-value
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(append (cmpl-prefix-entry-head (symbol-value prefix-symbol))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
completions-list-return-value))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun list-all-completions-by-hash-bucket ()
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Return list of lists of known completion entries, organized by hash bucket."
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(let ((completions-list-return-value nil))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(mapatoms 'list-all-completions-by-hash-bucket-1 cmpl-prefix-obarray)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
completions-list-return-value))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun list-all-completions-by-hash-bucket-1 (prefix-symbol)
|
|
|
|
|
(if (boundp prefix-symbol)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(setq completions-list-return-value
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cons (cmpl-prefix-entry-head (symbol-value prefix-symbol))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
completions-list-return-value))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Updating the database
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;; These are the internal functions used to update the datebase
|
|
|
|
|
;;
|
|
|
|
|
;;
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defvar completion-to-accept nil
|
|
|
|
|
"Set to a string that is pending its acceptance.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; this checked by the top level reading functions
|
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defvar cmpl-db-downcase-string nil
|
|
|
|
|
"Setup by `find-exact-completion', etc. The given string, downcased.")
|
|
|
|
|
(defvar cmpl-db-symbol nil
|
|
|
|
|
"The interned symbol corresponding to `cmpl-db-downcase-string'.
|
|
|
|
|
Set up by `cmpl-db-symbol'.")
|
|
|
|
|
(defvar cmpl-db-prefix-symbol nil
|
|
|
|
|
"The interned prefix symbol corresponding to `cmpl-db-downcase-string'.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defvar cmpl-db-entry nil)
|
|
|
|
|
(defvar cmpl-db-debug-p nil
|
2001-12-20 18:59:32 +00:00
|
|
|
|
"Set to t if you want to debug the database.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; READS
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defun find-exact-completion (string)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"Return the completion entry for STRING or nil.
|
1993-05-27 12:44:54 +00:00
|
|
|
|
Sets up `cmpl-db-downcase-string' and `cmpl-db-symbol'."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(and (boundp (setq cmpl-db-symbol
|
|
|
|
|
(intern (setq cmpl-db-downcase-string (downcase string))
|
|
|
|
|
cmpl-obarray)))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(symbol-value cmpl-db-symbol)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun find-cmpl-prefix-entry (prefix-string)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"Return the prefix entry for string.
|
1993-05-27 12:44:54 +00:00
|
|
|
|
Sets `cmpl-db-prefix-symbol'.
|
|
|
|
|
Prefix-string must be exactly `completion-prefix-min-length' long
|
|
|
|
|
and downcased. Sets up `cmpl-db-prefix-symbol'."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(and (boundp (setq cmpl-db-prefix-symbol
|
|
|
|
|
(intern prefix-string cmpl-prefix-obarray)))
|
|
|
|
|
(symbol-value cmpl-db-prefix-symbol)))
|
|
|
|
|
|
|
|
|
|
(defvar inside-locate-completion-entry nil)
|
|
|
|
|
;; used to trap lossage in silent error correction
|
|
|
|
|
|
2019-06-19 14:03:57 +00:00
|
|
|
|
(define-obsolete-function-alias 'locate-completion-entry
|
|
|
|
|
#'completion-locate-entry "27.1")
|
|
|
|
|
(defun completion-locate-entry (completion-entry prefix-entry)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"Locate the completion entry.
|
1992-10-06 21:01:11 +00:00
|
|
|
|
Returns a pointer to the element before the completion entry or nil if
|
|
|
|
|
the completion entry is at the head.
|
1993-05-27 12:44:54 +00:00
|
|
|
|
Must be called after `find-exact-completion'."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(let ((prefix-list (cmpl-prefix-entry-head prefix-entry))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
next-prefix-list)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cond
|
|
|
|
|
((not (eq (car prefix-list) completion-entry))
|
|
|
|
|
;; not already at head
|
|
|
|
|
(while (and prefix-list
|
|
|
|
|
(not (eq completion-entry
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(car (setq next-prefix-list (cdr prefix-list))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(setq prefix-list next-prefix-list))
|
|
|
|
|
(cond (;; found
|
|
|
|
|
prefix-list)
|
|
|
|
|
;; Didn't find it. Database is messed up.
|
|
|
|
|
(cmpl-db-debug-p
|
|
|
|
|
;; not found, error if debug mode
|
|
|
|
|
(error "Completion entry exists but not on prefix list - %s"
|
2014-12-22 17:35:29 +00:00
|
|
|
|
cmpl--completion-string))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(inside-locate-completion-entry
|
|
|
|
|
;; recursive error: really scrod
|
2019-06-19 14:03:57 +00:00
|
|
|
|
(completion-locate-db-error))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(t
|
|
|
|
|
;; Patch out
|
|
|
|
|
(set cmpl-db-symbol nil)
|
|
|
|
|
;; Retry
|
2019-06-19 14:03:57 +00:00
|
|
|
|
(completion-locate-entry-retry completion-entry)))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2019-06-19 14:03:57 +00:00
|
|
|
|
(define-obsolete-function-alias 'locate-completion-entry-retry
|
|
|
|
|
#'completion-locate-entry-retry "27.1")
|
|
|
|
|
(defun completion-locate-entry-retry (old-entry)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(let ((inside-locate-completion-entry t))
|
|
|
|
|
(add-completion (completion-string old-entry)
|
|
|
|
|
(completion-num-uses old-entry)
|
|
|
|
|
(completion-last-use-time old-entry))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(let* ((cmpl-entry (find-exact-completion (completion-string old-entry)))
|
|
|
|
|
(pref-entry
|
|
|
|
|
(if cmpl-entry
|
|
|
|
|
(find-cmpl-prefix-entry
|
|
|
|
|
(substring cmpl-db-downcase-string
|
2000-05-22 17:53:15 +00:00
|
|
|
|
0 completion-prefix-min-length)))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(if (and cmpl-entry pref-entry)
|
|
|
|
|
;; try again
|
2019-06-19 14:03:57 +00:00
|
|
|
|
(completion-locate-entry cmpl-entry pref-entry)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; still losing
|
2019-06-19 14:03:57 +00:00
|
|
|
|
(completion-locate-db-error)))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2019-06-19 14:03:57 +00:00
|
|
|
|
(define-obsolete-function-alias 'locate-completion-db-error
|
|
|
|
|
#'completion-locate-db-error "27.1")
|
|
|
|
|
(defun completion-locate-db-error ()
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; recursive error: really scrod
|
2001-07-15 16:15:35 +00:00
|
|
|
|
(error "Completion database corrupted. Try M-x clear-all-completions. Send bug report"))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; WRITES
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defun add-completion-to-tail-if-new (string)
|
1992-10-06 21:01:11 +00:00
|
|
|
|
"If STRING is not in the database add it to appropriate prefix list.
|
1993-06-09 11:59:12 +00:00
|
|
|
|
STRING is added to the end of the appropriate prefix list with
|
1992-10-06 21:01:11 +00:00
|
|
|
|
num-uses = 0. The database is unchanged if it is there. STRING must be
|
1993-05-27 12:44:54 +00:00
|
|
|
|
longer than `completion-prefix-min-length'.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
This must be very fast.
|
|
|
|
|
Returns the completion entry."
|
|
|
|
|
(or (find-exact-completion string)
|
|
|
|
|
;; not there
|
|
|
|
|
(let (;; create an entry
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(entry (list (make-completion string)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; setup the prefix
|
|
|
|
|
(prefix-entry (find-cmpl-prefix-entry
|
|
|
|
|
(substring cmpl-db-downcase-string 0
|
2003-02-05 19:09:34 +00:00
|
|
|
|
completion-prefix-min-length))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; The next two forms should happen as a unit (atomically) but
|
|
|
|
|
;; no fatal errors should result if that is not the case.
|
|
|
|
|
(cond (prefix-entry
|
|
|
|
|
;; These two should be atomic, but nothing fatal will happen
|
|
|
|
|
;; if they're not.
|
|
|
|
|
(setcdr (cmpl-prefix-entry-tail prefix-entry) entry)
|
|
|
|
|
(set-cmpl-prefix-entry-tail prefix-entry entry))
|
|
|
|
|
(t
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(set cmpl-db-prefix-symbol (make-cmpl-prefix-entry entry))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; set symbol
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(set cmpl-db-symbol (car entry)))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(defun add-completion-to-head (completion-string)
|
|
|
|
|
"If COMPLETION-STRING is not in the database, add it to prefix list.
|
|
|
|
|
We add COMPLETION-STRING to the head of the appropriate prefix list,
|
* completion.el (add-completion-to-head, add-completion): Doc fixes.
(completion-search-next, add-completions-from-file):
Fix typos in docstrings.
* filesets.el (filesets-menu-ensure-use-cached)
(filesets-ingroup-patterns, filesets-filetype-property):
* tutorial.el (get-lang-string):
* play/gamegrid.el (gamegrid-score-file-length, gamegrid-add-score):
Fix typos in docstrings.
* image-dired.el (image-dired-dired-after-readin-hook): Doc fix.
(image-dired-line-up-method, image-dired-thumb-size)
(image-dired-cmd-write-exif-data-options, image-dired-write-tags)
(image-dired-track-original-file, image-dired-track-thumbnail)
(image-dired-dired-next-line, image-dired-dired-previous-line)
(image-dired-write-comments): Reflow docstrings.
(image-dired-show-all-from-dir-max-files)
(image-dired-format-properties-string, image-dired-create-thumbs)
(image-dired-mark-tagged-files, image-dired-gallery-generate):
Fix typos in docstrings.
* savehist.el (savehist-save-minibuffer-history, savehist-file)
(savehist-additional-variables, savehist-ignored-variables)
(savehist-file-modes, savehist-autosave-interval):
* startup.el (inhibit-startup-echo-area-message, inhibit-default-init)
(inhibit-startup-buffer-menu, mail-host-address, user-mail-address)
(fancy-splash-image):
* thumbs.el (thumbs-thumbsdir, thumbs-geometry, thumbs-relief)
(thumbs-conversion-program, thumbs-margin):
Remove spurious * in docstrings.
2008-10-25 00:46:25 +00:00
|
|
|
|
or to the head of the list.
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
COMPLETION-STRING must be longer than `completion-prefix-min-length'.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
Updates the saved string with the supplied string.
|
|
|
|
|
This must be very fast.
|
|
|
|
|
Returns the completion entry."
|
2014-12-22 17:35:29 +00:00
|
|
|
|
(let ((cmpl--completion-string completion-string))
|
|
|
|
|
;; Handle pending acceptance
|
|
|
|
|
(if completion-to-accept (accept-completion))
|
|
|
|
|
;; test if already in database
|
|
|
|
|
(if (setq cmpl-db-entry (find-exact-completion completion-string))
|
|
|
|
|
;; found
|
|
|
|
|
(let* ((prefix-entry (find-cmpl-prefix-entry
|
|
|
|
|
(substring cmpl-db-downcase-string 0
|
|
|
|
|
completion-prefix-min-length)))
|
2019-06-19 14:03:57 +00:00
|
|
|
|
(splice-ptr (completion-locate-entry cmpl-db-entry prefix-entry))
|
2014-12-22 17:35:29 +00:00
|
|
|
|
(cmpl-ptr (cdr splice-ptr)))
|
|
|
|
|
;; update entry
|
|
|
|
|
(set-completion-string cmpl-db-entry completion-string)
|
|
|
|
|
;; move to head (if necessary)
|
|
|
|
|
(cond (splice-ptr
|
|
|
|
|
;; These should all execute atomically but it is not fatal if
|
|
|
|
|
;; they don't.
|
|
|
|
|
;; splice it out
|
|
|
|
|
(or (setcdr splice-ptr (cdr cmpl-ptr))
|
|
|
|
|
;; fix up tail if necessary
|
|
|
|
|
(set-cmpl-prefix-entry-tail prefix-entry splice-ptr))
|
|
|
|
|
;; splice in at head
|
|
|
|
|
(setcdr cmpl-ptr (cmpl-prefix-entry-head prefix-entry))
|
|
|
|
|
(set-cmpl-prefix-entry-head prefix-entry cmpl-ptr)))
|
|
|
|
|
cmpl-db-entry)
|
|
|
|
|
;; not there
|
|
|
|
|
(let ( ;; create an entry
|
|
|
|
|
(entry (list (make-completion completion-string)))
|
|
|
|
|
;; setup the prefix
|
|
|
|
|
(prefix-entry (find-cmpl-prefix-entry
|
|
|
|
|
(substring cmpl-db-downcase-string 0
|
|
|
|
|
completion-prefix-min-length))))
|
|
|
|
|
(cond (prefix-entry
|
|
|
|
|
;; Splice in at head
|
|
|
|
|
(setcdr entry (cmpl-prefix-entry-head prefix-entry))
|
|
|
|
|
(set-cmpl-prefix-entry-head prefix-entry entry))
|
|
|
|
|
(t
|
|
|
|
|
;; Start new prefix entry
|
|
|
|
|
(set cmpl-db-prefix-symbol (make-cmpl-prefix-entry entry))))
|
|
|
|
|
;; Add it to the symbol
|
|
|
|
|
(set cmpl-db-symbol (car entry))))))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(defun delete-completion (completion-string)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"Delete the completion from the database.
|
1993-05-27 12:44:54 +00:00
|
|
|
|
String must be longer than `completion-prefix-min-length'."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; Handle pending acceptance
|
2014-12-22 17:35:29 +00:00
|
|
|
|
(let ((cmpl--completion-string completion-string))
|
|
|
|
|
(if completion-to-accept (accept-completion))
|
|
|
|
|
(if (setq cmpl-db-entry (find-exact-completion completion-string))
|
|
|
|
|
;; found
|
|
|
|
|
(let* ((prefix-entry (find-cmpl-prefix-entry
|
|
|
|
|
(substring cmpl-db-downcase-string 0
|
|
|
|
|
completion-prefix-min-length)))
|
2019-06-19 14:03:57 +00:00
|
|
|
|
(splice-ptr (completion-locate-entry
|
|
|
|
|
cmpl-db-entry prefix-entry)))
|
2014-12-22 17:35:29 +00:00
|
|
|
|
;; delete symbol reference
|
|
|
|
|
(set cmpl-db-symbol nil)
|
|
|
|
|
;; remove from prefix list
|
|
|
|
|
(cond (splice-ptr
|
|
|
|
|
;; not at head
|
|
|
|
|
(or (setcdr splice-ptr (cdr (cdr splice-ptr)))
|
|
|
|
|
;; fix up tail if necessary
|
|
|
|
|
(set-cmpl-prefix-entry-tail prefix-entry splice-ptr)))
|
|
|
|
|
(t
|
|
|
|
|
;; at head
|
|
|
|
|
(or (set-cmpl-prefix-entry-head
|
1990-04-05 21:41:26 +00:00
|
|
|
|
prefix-entry (cdr (cmpl-prefix-entry-head prefix-entry)))
|
2014-12-22 17:35:29 +00:00
|
|
|
|
;; List is now empty
|
|
|
|
|
(set cmpl-db-prefix-symbol nil)))))
|
|
|
|
|
(error "Unknown completion `%s'" completion-string))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Database Update :: Interface level routines
|
|
|
|
|
;;---------------------------------------------------------------------------
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;;
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; These lie on top of the database ref. functions but below the standard
|
|
|
|
|
;; user interface level
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun interactive-completion-string-reader (prompt)
|
|
|
|
|
(let* ((default (symbol-under-or-before-point))
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 14:56:44 +00:00
|
|
|
|
(read (completing-read (format-prompt prompt default) cmpl-obarray)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(if (zerop (length read)) (setq read (or default "")))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(list read)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun check-completion-length (string)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(if (< (length string) completion-min-length)
|
Add new error and function `user-error'.
* lisp/subr.el (user-error): New function.
* lisp/window.el (switch-to-buffer):
* lisp/vc/smerge-mode.el (smerge-resolve-function, smerge-resolve)
(smerge-match-conflict):
* lisp/simple.el (previous-matching-history-element)
(next-matching-history-element, goto-history-element, undo-more)
(undo-start):
* lisp/progmodes/etags.el (visit-tags-table-buffer, find-tag-tag)
(find-tag-noselect, find-tag-in-order, etags-goto-tag-location)
(next-file, tags-loop-scan, list-tags, complete-tag):
* lisp/progmodes/compile.el (compilation-loop):
* lisp/mouse.el (mouse-minibuffer-check):
* lisp/man.el (Man-bgproc-sentinel, Man-goto-page):
* lisp/info.el (Info-find-node-2, Info-extract-pointer, Info-history-back)
(Info-history-forward, Info-follow-reference, Info-menu)
(Info-extract-menu-item, Info-extract-menu-counting)
(Info-forward-node, Info-backward-node, Info-next-menu-item)
(Info-last-menu-item, Info-next-preorder, Info-last-preorder)
(Info-next-reference, Info-prev-reference, Info-index)
(Info-index-next, Info-follow-nearest-node)
(Info-copy-current-node-name):
* lisp/imenu.el (imenu--make-index-alist)
(imenu-default-create-index-function, imenu-add-to-menubar):
* lisp/files.el (basic-save-buffer, recover-file):
* lisp/emacs-lisp/easy-mmode.el (easy-mmode-define-navigation):
* lisp/emacs-lisp/checkdoc.el (checkdoc-continue, checkdoc-comments)
(checkdoc-message-text, checkdoc-defun):
* lisp/dabbrev.el (dabbrev-completion, dabbrev--abbrev-at-point):
* lisp/cus-edit.el (customize-changed-options, customize-rogue)
(customize-saved, custom-variable-set, custom-variable-mark-to-save)
(custom-variable-mark-to-reset-standard)
(custom-variable-reset-backup, custom-face-mark-to-reset-standard)
(custom-file):
* lisp/completion.el (check-completion-length):
* lisp/comint.el (comint-search-arg)
(comint-previous-matching-input-string-position)
(comint-previous-matching-input)
(comint-replace-by-expanded-history-before-point, comint-send-input)
(comint-copy-old-input, comint-backward-matching-input)
(comint-goto-process-mark, comint-set-process-mark):
* lisp/calendar/calendar.el (calendar-cursor-to-date): Use it.
* lisp/bindings.el (debug-ignored-errors): Remove regexps, add `user-error'.
* src/data.c (PUT_ERROR): New macro.
(syms_of_data): Use it. Add new error type `user-error'.
* src/undo.c (user_error): New function.
(Fprimitive_undo): Use it.
* src/print.c (print_error_message): Adjust print style for `user-error'.
* src/keyboard.c (user_error): New function.
(Fexit_recursive_edit, Fabort_recursive_edit): Use it.
2012-05-04 23:16:47 +00:00
|
|
|
|
(user-error "The string `%s' is too short to be saved as a completion"
|
|
|
|
|
string)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(list string)))
|
|
|
|
|
|
|
|
|
|
(defun add-completion (string &optional num-uses last-use-time)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Add STRING to completion list, or move it to head of list.
|
* completion.el (add-completion-to-head, add-completion): Doc fixes.
(completion-search-next, add-completions-from-file):
Fix typos in docstrings.
* filesets.el (filesets-menu-ensure-use-cached)
(filesets-ingroup-patterns, filesets-filetype-property):
* tutorial.el (get-lang-string):
* play/gamegrid.el (gamegrid-score-file-length, gamegrid-add-score):
Fix typos in docstrings.
* image-dired.el (image-dired-dired-after-readin-hook): Doc fix.
(image-dired-line-up-method, image-dired-thumb-size)
(image-dired-cmd-write-exif-data-options, image-dired-write-tags)
(image-dired-track-original-file, image-dired-track-thumbnail)
(image-dired-dired-next-line, image-dired-dired-previous-line)
(image-dired-write-comments): Reflow docstrings.
(image-dired-show-all-from-dir-max-files)
(image-dired-format-properties-string, image-dired-create-thumbs)
(image-dired-mark-tagged-files, image-dired-gallery-generate):
Fix typos in docstrings.
* savehist.el (savehist-save-minibuffer-history, savehist-file)
(savehist-additional-variables, savehist-ignored-variables)
(savehist-file-modes, savehist-autosave-interval):
* startup.el (inhibit-startup-echo-area-message, inhibit-default-init)
(inhibit-startup-buffer-menu, mail-host-address, user-mail-address)
(fancy-splash-image):
* thumbs.el (thumbs-thumbsdir, thumbs-geometry, thumbs-relief)
(thumbs-conversion-program, thumbs-margin):
Remove spurious * in docstrings.
2008-10-25 00:46:25 +00:00
|
|
|
|
The completion is altered appropriately if NUM-USES and/or LAST-USE-TIME
|
|
|
|
|
are specified."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(interactive (interactive-completion-string-reader "Completion to add"))
|
|
|
|
|
(check-completion-length string)
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(let* ((current-completion-source (if (called-interactively-p 'interactive)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
cmpl-source-interactive
|
|
|
|
|
current-completion-source))
|
|
|
|
|
(entry (add-completion-to-head string)))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(if num-uses (set-completion-num-uses entry num-uses))
|
|
|
|
|
(if last-use-time
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(set-completion-last-use-time entry last-use-time))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun add-permanent-completion (string)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Add STRING if it isn't already listed, and mark it permanent."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(interactive-completion-string-reader "Completion to add permanently"))
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(let ((current-completion-source (if (called-interactively-p 'interactive)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
cmpl-source-interactive
|
2000-05-22 17:53:15 +00:00
|
|
|
|
current-completion-source)))
|
|
|
|
|
(add-completion string nil t)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun kill-completion (string)
|
|
|
|
|
(interactive (interactive-completion-string-reader "Completion to kill"))
|
|
|
|
|
(check-completion-length string)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(delete-completion string))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun accept-completion ()
|
2014-12-22 17:35:29 +00:00
|
|
|
|
"Accept the pending completion in `completion-to-accept'.
|
2003-02-04 11:26:42 +00:00
|
|
|
|
This bumps num-uses. Called by `add-completion-to-head' and
|
1993-05-27 12:44:54 +00:00
|
|
|
|
`completion-search-reset'."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(let ((string completion-to-accept)
|
|
|
|
|
;; if this is added afresh here, then it must be a cdabbrev
|
|
|
|
|
(current-completion-source cmpl-source-cdabbrev)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
entry)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(setq completion-to-accept nil)
|
|
|
|
|
(setq entry (add-completion-to-head string))
|
|
|
|
|
(set-completion-num-uses entry (1+ (completion-num-uses entry)))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-completions-accepted-p t)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun use-completion-under-point ()
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Add the completion symbol underneath the point into the completion buffer."
|
|
|
|
|
(let ((string (and enable-completion (symbol-under-point)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(current-completion-source cmpl-source-cursor-moves))
|
|
|
|
|
(if string (add-completion-to-head string))))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defun use-completion-before-point ()
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Add the completion symbol before point into the completion buffer."
|
|
|
|
|
(let ((string (and enable-completion (symbol-before-point)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(current-completion-source cmpl-source-cursor-moves))
|
|
|
|
|
(if string (add-completion-to-head string))))
|
|
|
|
|
|
|
|
|
|
(defun use-completion-under-or-before-point ()
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Add the completion symbol before point into the completion buffer."
|
|
|
|
|
(let ((string (and enable-completion (symbol-under-or-before-point)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(current-completion-source cmpl-source-cursor-moves))
|
|
|
|
|
(if string (add-completion-to-head string))))
|
|
|
|
|
|
|
|
|
|
(defun use-completion-before-separator ()
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Add the completion symbol before point into the completion buffer.
|
1992-10-06 21:01:11 +00:00
|
|
|
|
Completions added this way will automatically be saved if
|
1993-05-27 12:44:54 +00:00
|
|
|
|
`completion-on-separator-character' is non-nil."
|
|
|
|
|
(let ((string (and enable-completion (symbol-before-point)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(current-completion-source cmpl-source-separator)
|
|
|
|
|
entry)
|
|
|
|
|
(cond (string
|
|
|
|
|
(setq entry (add-completion-to-head string))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(if (and completion-on-separator-character
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(zerop (completion-num-uses entry)))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(progn
|
|
|
|
|
(set-completion-num-uses entry 1)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-completions-accepted-p t)))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Searching the database
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Functions outside this block must call completion-search-reset followed
|
|
|
|
|
;; by calls to completion-search-next or completion-search-peek
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
;; Status variables
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; Commented out to improve loading speed
|
|
|
|
|
(defvar cmpl-test-string "")
|
|
|
|
|
;; "The current string used by completion-search-next."
|
|
|
|
|
(defvar cmpl-test-regexp "")
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; "The current regexp used by completion-search-next.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; (derived from cmpl-test-string)"
|
|
|
|
|
(defvar cmpl-last-index 0)
|
|
|
|
|
;; "The last index that completion-search-next was called with."
|
|
|
|
|
(defvar cmpl-cdabbrev-reset-p nil)
|
|
|
|
|
;; "Set to t when cdabbrevs have been reset."
|
|
|
|
|
(defvar cmpl-next-possibilities nil)
|
|
|
|
|
;; "A pointer to the element BEFORE the next set of possible completions.
|
|
|
|
|
;; cadr of this is the cmpl-next-possibility"
|
|
|
|
|
(defvar cmpl-starting-possibilities nil)
|
|
|
|
|
;; "The initial list of starting possibilities."
|
|
|
|
|
(defvar cmpl-next-possibility nil)
|
|
|
|
|
;; "The cached next possibility."
|
|
|
|
|
(defvar cmpl-tried-list nil)
|
|
|
|
|
;; "A downcased list of all the completions we have tried."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun completion-search-reset (string)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Set up the for completion searching for STRING.
|
|
|
|
|
STRING must be longer than `completion-prefix-min-length'."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(if completion-to-accept (accept-completion))
|
|
|
|
|
(setq cmpl-starting-possibilities
|
|
|
|
|
(cmpl-prefix-entry-head
|
1993-08-03 05:46:33 +00:00
|
|
|
|
(find-cmpl-prefix-entry
|
|
|
|
|
(downcase (substring string 0 completion-prefix-min-length))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
cmpl-test-string string
|
|
|
|
|
cmpl-test-regexp (concat (regexp-quote string) "."))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(completion-search-reset-1))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun completion-search-reset-1 ()
|
|
|
|
|
(setq cmpl-next-possibilities cmpl-starting-possibilities
|
|
|
|
|
cmpl-next-possibility nil
|
|
|
|
|
cmpl-cdabbrev-reset-p nil
|
|
|
|
|
cmpl-last-index -1
|
2000-05-22 17:53:15 +00:00
|
|
|
|
cmpl-tried-list nil))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun completion-search-next (index)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Return the next completion entry.
|
|
|
|
|
If INDEX is out of sequence, reset and start from the top.
|
* completion.el (add-completion-to-head, add-completion): Doc fixes.
(completion-search-next, add-completions-from-file):
Fix typos in docstrings.
* filesets.el (filesets-menu-ensure-use-cached)
(filesets-ingroup-patterns, filesets-filetype-property):
* tutorial.el (get-lang-string):
* play/gamegrid.el (gamegrid-score-file-length, gamegrid-add-score):
Fix typos in docstrings.
* image-dired.el (image-dired-dired-after-readin-hook): Doc fix.
(image-dired-line-up-method, image-dired-thumb-size)
(image-dired-cmd-write-exif-data-options, image-dired-write-tags)
(image-dired-track-original-file, image-dired-track-thumbnail)
(image-dired-dired-next-line, image-dired-dired-previous-line)
(image-dired-write-comments): Reflow docstrings.
(image-dired-show-all-from-dir-max-files)
(image-dired-format-properties-string, image-dired-create-thumbs)
(image-dired-mark-tagged-files, image-dired-gallery-generate):
Fix typos in docstrings.
* savehist.el (savehist-save-minibuffer-history, savehist-file)
(savehist-additional-variables, savehist-ignored-variables)
(savehist-file-modes, savehist-autosave-interval):
* startup.el (inhibit-startup-echo-area-message, inhibit-default-init)
(inhibit-startup-buffer-menu, mail-host-address, user-mail-address)
(fancy-splash-image):
* thumbs.el (thumbs-thumbsdir, thumbs-geometry, thumbs-relief)
(thumbs-conversion-program, thumbs-margin):
Remove spurious * in docstrings.
2008-10-25 00:46:25 +00:00
|
|
|
|
If there are no more entries, try cdabbrev and return only a string."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cond
|
|
|
|
|
((= index (setq cmpl-last-index (1+ cmpl-last-index)))
|
|
|
|
|
(completion-search-peek t))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
((< index 0)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(completion-search-reset-1)
|
|
|
|
|
(setq cmpl-last-index index)
|
|
|
|
|
;; reverse the possibilities list
|
|
|
|
|
(setq cmpl-next-possibilities (reverse cmpl-starting-possibilities))
|
|
|
|
|
;; do a "normal" search
|
|
|
|
|
(while (and (completion-search-peek nil)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(< (setq index (1+ index)) 0))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-next-possibility nil))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cond ((not cmpl-next-possibilities))
|
|
|
|
|
;; If no more possibilities, leave it that way
|
|
|
|
|
((= -1 cmpl-last-index)
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; next completion is at index 0. reset next-possibility list
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; to start at beginning
|
|
|
|
|
(setq cmpl-next-possibilities cmpl-starting-possibilities))
|
|
|
|
|
(t
|
|
|
|
|
;; otherwise point to one before current
|
|
|
|
|
(setq cmpl-next-possibilities
|
|
|
|
|
(nthcdr (- (length cmpl-starting-possibilities)
|
|
|
|
|
(length cmpl-next-possibilities))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
cmpl-starting-possibilities)))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(t
|
|
|
|
|
;; non-negative index, reset and search
|
|
|
|
|
;;(prin1 'reset)
|
|
|
|
|
(completion-search-reset-1)
|
|
|
|
|
(setq cmpl-last-index index)
|
|
|
|
|
(while (and (completion-search-peek t)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(not (< (setq index (1- index)) 0)))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-next-possibility nil))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(prog1
|
|
|
|
|
cmpl-next-possibility
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-next-possibility nil)))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun completion-search-peek (use-cdabbrev)
|
2003-02-05 19:09:34 +00:00
|
|
|
|
"Return the next completion entry without actually moving the pointers.
|
2003-02-04 11:26:42 +00:00
|
|
|
|
Calling this again or calling `completion-search-next' results in the same
|
1993-05-27 12:44:54 +00:00
|
|
|
|
string being returned. Depends on `case-fold-search'.
|
|
|
|
|
If there are no more entries, try cdabbrev and then return only a string."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cond
|
|
|
|
|
;; return the cached value if we have it
|
|
|
|
|
(cmpl-next-possibility)
|
|
|
|
|
((and cmpl-next-possibilities
|
|
|
|
|
;; still a few possibilities left
|
|
|
|
|
(progn
|
|
|
|
|
(while
|
|
|
|
|
(and (not (eq 0 (string-match cmpl-test-regexp
|
|
|
|
|
(completion-string (car cmpl-next-possibilities)))))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-next-possibilities (cdr cmpl-next-possibilities))))
|
|
|
|
|
cmpl-next-possibilities))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; successful match
|
|
|
|
|
(setq cmpl-next-possibility (car cmpl-next-possibilities)
|
|
|
|
|
cmpl-tried-list (cons (downcase (completion-string cmpl-next-possibility))
|
|
|
|
|
cmpl-tried-list)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
cmpl-next-possibilities (cdr cmpl-next-possibilities))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
cmpl-next-possibility)
|
|
|
|
|
(use-cdabbrev
|
|
|
|
|
;; unsuccessful, use cdabbrev
|
|
|
|
|
(cond ((not cmpl-cdabbrev-reset-p)
|
|
|
|
|
(reset-cdabbrev cmpl-test-string cmpl-tried-list)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-cdabbrev-reset-p t)))
|
|
|
|
|
(setq cmpl-next-possibility (next-cdabbrev)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; Completely unsuccessful, return nil
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; COMPLETE
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun completion-mode ()
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"Toggle whether or not to add new words to the completion database."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(interactive)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(setq enable-completion (not enable-completion))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(message "Completion mode is now %s." (if enable-completion "ON" "OFF")))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defvar cmpl-current-index 0)
|
|
|
|
|
(defvar cmpl-original-string nil)
|
|
|
|
|
(defvar cmpl-last-insert-location -1)
|
|
|
|
|
(defvar cmpl-leave-point-at-start nil)
|
|
|
|
|
|
|
|
|
|
(defun complete (&optional arg)
|
2003-02-04 11:26:42 +00:00
|
|
|
|
"Fill out a completion of the word before point.
|
1993-06-09 11:59:12 +00:00
|
|
|
|
Point is left at end. Consecutive calls rotate through all possibilities.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
Prefix args ::
|
2003-02-04 11:26:42 +00:00
|
|
|
|
control-u :: leave the point at the beginning of the completion rather
|
1990-04-05 21:41:26 +00:00
|
|
|
|
than at the end.
|
|
|
|
|
a number :: rotate through the possible completions by that amount
|
|
|
|
|
`-' :: same as -1 (insert previous completion)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
{See the comments at the top of `completion.el' for more info.}"
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(interactive "*p")
|
|
|
|
|
;;; Set up variables
|
|
|
|
|
(cond ((eq last-command this-command)
|
|
|
|
|
;; Undo last one
|
|
|
|
|
(delete-region cmpl-last-insert-location (point))
|
|
|
|
|
;; get next completion
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-current-index (+ cmpl-current-index (or arg 1))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(t
|
|
|
|
|
(if (not cmpl-initialized-p)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(completion-initialize)) ;; make sure everything's loaded
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cond ((consp current-prefix-arg) ;; control-u
|
|
|
|
|
(setq arg 0)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-leave-point-at-start t))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(t
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-leave-point-at-start nil)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; get string
|
|
|
|
|
(setq cmpl-original-string (symbol-before-point-for-complete))
|
|
|
|
|
(cond ((not cmpl-original-string)
|
|
|
|
|
(setq this-command 'failed-complete)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(error "To complete, point must be after a symbol at least %d character long"
|
1993-05-27 12:44:54 +00:00
|
|
|
|
completion-prefix-min-length)))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; get index
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(setq cmpl-current-index (if current-prefix-arg arg 0))
|
|
|
|
|
;; reset database
|
|
|
|
|
(completion-search-reset cmpl-original-string)
|
|
|
|
|
;; erase what we've got
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(delete-region cmpl-symbol-start cmpl-symbol-end)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
;; point is at the point to insert the new symbol
|
|
|
|
|
;; Get the next completion
|
|
|
|
|
(let* ((print-status-p
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(and (>= baud-rate completion-prompt-speed-threshold)
|
Do not call to `selected-window' where it is assumed by default.
Affected functions are `window-minibuffer-p', `window-dedicated-p',
`window-hscroll', `window-width', `window-height', `window-buffer',
`window-frame', `window-start', `window-point', `next-window'
and `window-display-table'.
* abbrev.el (abbrev--default-expand):
* bs.el (bs--show-with-configuration):
* buff-menu.el (Buffer-menu-mouse-select):
* calc/calc.el (calc):
* calendar/calendar.el (calendar-generate-window):
* calendar/diary-lib.el (diary-simple-display, diary-show-all-entries)
(diary-make-entry):
* comint.el (send-invisible, comint-dynamic-complete-filename)
(comint-dynamic-simple-complete, comint-dynamic-list-completions):
* completion.el (complete):
* dabbrev.el (dabbrev-expand, dabbrev--make-friend-buffer-list):
* disp-table.el (describe-current-display-table):
* doc-view.el (doc-view-insert-image):
* ebuff-menu.el (Electric-buffer-menu-mouse-select):
* ehelp.el (with-electric-help):
* emacs-lisp/easy-mmode.el (easy-mmode-define-navigation):
* emacs-lisp/edebug.el (edebug-two-window-p, edebug-pop-to-buffer):
* emacs-lisp/helper.el (Helper-help-scroller):
* emulation/cua-base.el (cua--post-command-handler-1):
* eshell/esh-mode.el (eshell-output-filter):
* ffap.el (ffap-gnus-wrapper):
* help-macro.el (make-help-screen):
* hilit-chg.el (highlight-compare-buffers):
* hippie-exp.el (hippie-expand, try-expand-dabbrev-visible):
* hl-line.el (global-hl-line-highlight):
* icomplete.el (icomplete-simple-completing-p):
* isearch.el (isearch-done):
* jit-lock.el (jit-lock-stealth-fontify):
* mail/rmailsum.el (rmail-summary-scroll-msg-up):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* mpc.el (mpc-tagbrowser, mpc):
* net/rcirc.el (rcirc-any-buffer):
* play/gomoku.el (gomoku-max-width, gomoku-max-height):
* play/landmark.el (landmark-max-width, landmark-max-height):
* play/zone.el (zone):
* progmodes/compile.el (compilation-goto-locus):
* progmodes/ebrowse.el (ebrowse-view/find-file-and-search-pattern):
* progmodes/etags.el (find-tag-other-window):
* progmodes/fortran.el (fortran-column-ruler):
* progmodes/gdb-mi.el (gdb-mouse-toggle-breakpoint-fringe):
* progmodes/verilog-mode.el (verilog-point-text):
* reposition.el (reposition-window):
* rot13.el (toggle-rot13-mode):
* server.el (server-switch-buffer):
* shell.el (shell-dynamic-complete-command)
(shell-dynamic-complete-environment-variable):
* simple.el (insert-buffer, set-selective-display)
(delete-completion-window):
* speedbar.el (speedbar-timer-fn, speedbar-center-buffer-smartly)
(speedbar-recenter):
* startup.el (fancy-splash-head):
* textmodes/ispell.el (ispell-command-loop):
* textmodes/makeinfo.el (makeinfo-compilation-sentinel-region):
* tutorial.el (help-with-tutorial):
* vc/add-log.el (add-change-log-entry):
* vc/compare-w.el (compare-windows):
* vc/ediff-help.el (ediff-indent-help-message):
* vc/ediff-util.el (ediff-setup-control-buffer, ediff-position-region):
* vc/ediff-wind.el (ediff-skip-unsuitable-frames)
(ediff-setup-control-frame):
* vc/emerge.el (emerge-position-region):
* vc/pcvs-util.el (cvs-bury-buffer):
* window.el (walk-windows, mouse-autoselect-window-select):
* winner.el (winner-set-conf, winner-undo): Related users changed.
2013-08-05 14:26:57 +00:00
|
|
|
|
(not (window-minibuffer-p))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(insert-point (point))
|
|
|
|
|
(entry (completion-search-next cmpl-current-index))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
string)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; entry is either a completion entry or a string (if cdabbrev)
|
|
|
|
|
|
|
|
|
|
;; If found, insert
|
|
|
|
|
(cond (entry
|
|
|
|
|
;; Setup for proper case
|
|
|
|
|
(setq string (if (stringp entry)
|
|
|
|
|
entry (completion-string entry)))
|
|
|
|
|
(setq string (cmpl-merge-string-cases
|
|
|
|
|
string cmpl-original-string))
|
|
|
|
|
;; insert
|
|
|
|
|
(insert string)
|
|
|
|
|
;; accept it
|
|
|
|
|
(setq completion-to-accept string)
|
|
|
|
|
;; fixup and cache point
|
|
|
|
|
(cond (cmpl-leave-point-at-start
|
|
|
|
|
(setq cmpl-last-insert-location (point))
|
|
|
|
|
(goto-char insert-point))
|
|
|
|
|
(t;; point at end,
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq cmpl-last-insert-location insert-point)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; Done ! cmpl-stat-complete-successful
|
|
|
|
|
;;display the next completion
|
|
|
|
|
(cond
|
|
|
|
|
((and print-status-p
|
|
|
|
|
;; This updates the display and only prints if there
|
|
|
|
|
;; is no typeahead
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(sit-for 0)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(setq entry
|
|
|
|
|
(completion-search-peek
|
1993-05-27 12:44:54 +00:00
|
|
|
|
completion-cdabbrev-prompt-flag)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(setq string (if (stringp entry)
|
|
|
|
|
entry (completion-string entry)))
|
|
|
|
|
(setq string (cmpl-merge-string-cases
|
|
|
|
|
string cmpl-original-string))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(message "Next completion: %s" string))))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
(t;; none found, insert old
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(insert cmpl-original-string)
|
|
|
|
|
;; Don't accept completions
|
|
|
|
|
(setq completion-to-accept nil)
|
|
|
|
|
;; print message
|
1993-07-22 05:49:37 +00:00
|
|
|
|
;; This used to call cmpl19-sit-for, an undefined function.
|
|
|
|
|
;; I hope that sit-for does the right thing; I don't know -- rms.
|
|
|
|
|
(if (and print-status-p (sit-for 0))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(message "No %scompletions."
|
|
|
|
|
(if (eq this-command last-command) "more " "")))
|
|
|
|
|
;; Pretend that we were never here
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(setq this-command 'failed-complete)))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Parsing definitions from files into the database
|
|
|
|
|
;;---------------------------------------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Top Level functions ::
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; User interface
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defun add-completions-from-file (file)
|
* completion.el (add-completion-to-head, add-completion): Doc fixes.
(completion-search-next, add-completions-from-file):
Fix typos in docstrings.
* filesets.el (filesets-menu-ensure-use-cached)
(filesets-ingroup-patterns, filesets-filetype-property):
* tutorial.el (get-lang-string):
* play/gamegrid.el (gamegrid-score-file-length, gamegrid-add-score):
Fix typos in docstrings.
* image-dired.el (image-dired-dired-after-readin-hook): Doc fix.
(image-dired-line-up-method, image-dired-thumb-size)
(image-dired-cmd-write-exif-data-options, image-dired-write-tags)
(image-dired-track-original-file, image-dired-track-thumbnail)
(image-dired-dired-next-line, image-dired-dired-previous-line)
(image-dired-write-comments): Reflow docstrings.
(image-dired-show-all-from-dir-max-files)
(image-dired-format-properties-string, image-dired-create-thumbs)
(image-dired-mark-tagged-files, image-dired-gallery-generate):
Fix typos in docstrings.
* savehist.el (savehist-save-minibuffer-history, savehist-file)
(savehist-additional-variables, savehist-ignored-variables)
(savehist-file-modes, savehist-autosave-interval):
* startup.el (inhibit-startup-echo-area-message, inhibit-default-init)
(inhibit-startup-buffer-menu, mail-host-address, user-mail-address)
(fancy-splash-image):
* thumbs.el (thumbs-thumbsdir, thumbs-geometry, thumbs-relief)
(thumbs-conversion-program, thumbs-margin):
Remove spurious * in docstrings.
2008-10-25 00:46:25 +00:00
|
|
|
|
"Parse possible completions from a FILE and add them to database."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(interactive "fFile: ")
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(setq file (expand-file-name file))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(let* ((buffer (get-file-buffer file))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(buffer-already-there-p buffer))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(if (not buffer-already-there-p)
|
|
|
|
|
(let ((completions-merging-modes nil))
|
|
|
|
|
(setq buffer (find-file-noselect file))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(unwind-protect
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(add-completions-from-buffer))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(if (not buffer-already-there-p)
|
|
|
|
|
(kill-buffer buffer)))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun add-completions-from-buffer ()
|
|
|
|
|
(interactive)
|
2013-08-10 12:00:19 +00:00
|
|
|
|
(let ((current-completion-source cmpl-source-file-parsing))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cond ((memq major-mode '(emacs-lisp-mode lisp-mode))
|
2013-08-10 12:00:19 +00:00
|
|
|
|
(add-completions-from-lisp-buffer))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
((memq major-mode '(c-mode))
|
2013-08-10 12:00:19 +00:00
|
|
|
|
(add-completions-from-c-buffer))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(t
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(error "Cannot parse completions in %s buffers"
|
2013-08-10 12:00:19 +00:00
|
|
|
|
major-mode)))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Find file hook
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defun completion-find-file-hook ()
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(cond (enable-completion
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(cond ((and (memq major-mode '(emacs-lisp-mode lisp-mode))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(memq 'lisp completions-merging-modes))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(add-completions-from-buffer))
|
|
|
|
|
((and (memq major-mode '(c-mode))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(memq 'c completions-merging-modes))
|
|
|
|
|
(add-completions-from-buffer))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Tags Table Completions
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun add-completions-from-tags-table ()
|
|
|
|
|
;; Inspired by eero@media-lab.media.mit.edu
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Add completions from the current tags table."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(visit-tags-table-buffer) ;this will prompt if no tags-table
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let (string)
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(condition-case nil
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(while t
|
|
|
|
|
(search-forward "\177")
|
|
|
|
|
(backward-char 3)
|
|
|
|
|
(and (setq string (symbol-under-point))
|
|
|
|
|
(add-completion-to-tail-if-new string))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(forward-char 3))
|
|
|
|
|
(search-failed)))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Lisp File completion parsing
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; This merely looks for phrases beginning with (def.... or
|
|
|
|
|
;; (package:def ... and takes the next word.
|
|
|
|
|
;;
|
|
|
|
|
;; We tried using forward-lines and explicit searches but the regexp technique
|
|
|
|
|
;; was faster. (About 100K characters per second)
|
|
|
|
|
;;
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defconst *lisp-def-regexp*
|
|
|
|
|
"\n(\\(\\w*:\\)?def\\(\\w\\|\\s_\\)*\\s +(*"
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"A regexp that searches for Lisp definition form.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; Parses all the definition names from a Lisp mode buffer and adds them to
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; the completion database.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defun add-completions-from-lisp-buffer ()
|
|
|
|
|
;;; Benchmarks
|
|
|
|
|
;;; Sun-3/280 - 1500 to 3000 lines of lisp code per second
|
|
|
|
|
(let (string)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(condition-case nil
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(while t
|
|
|
|
|
(re-search-forward *lisp-def-regexp*)
|
|
|
|
|
(and (setq string (symbol-under-point))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(add-completion-to-tail-if-new string)))
|
|
|
|
|
(search-failed)))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; C file completion parsing
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; C :
|
|
|
|
|
;; Looks for #define or [<storage class>] [<type>] <name>{,<name>}
|
|
|
|
|
;; or structure, array or pointer defs.
|
|
|
|
|
;; It gets most of the definition names.
|
|
|
|
|
;;
|
|
|
|
|
;; As you might suspect by now, we use some symbol table hackery
|
|
|
|
|
;;
|
|
|
|
|
;; Symbol separator chars (have whitespace syntax) --> , ; * = (
|
|
|
|
|
;; Opening char --> [ {
|
|
|
|
|
;; Closing char --> ] }
|
|
|
|
|
;; opening and closing must be skipped over
|
|
|
|
|
;; Whitespace chars (have symbol syntax)
|
|
|
|
|
;; Everything else has word syntax
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defconst completion-c-def-syntax-table
|
1995-11-24 22:20:07 +00:00
|
|
|
|
(let ((table (make-syntax-table))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(whitespace-chars '(? ?\n ?\t ?\f ?\v ?\r))
|
1993-06-09 11:59:12 +00:00
|
|
|
|
;; unfortunately the ?( causes the parens to appear unbalanced
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(separator-chars '(?, ?* ?= ?\( ?\;))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
i)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;; default syntax is whitespace
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(setq i 0)
|
|
|
|
|
(while (< i 256)
|
|
|
|
|
(modify-syntax-entry i "w" table)
|
|
|
|
|
(setq i (1+ i)))
|
2000-02-03 15:45:10 +00:00
|
|
|
|
(dolist (char whitespace-chars)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(modify-syntax-entry char "_" table))
|
2000-02-03 15:45:10 +00:00
|
|
|
|
(dolist (char separator-chars)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(modify-syntax-entry char " " table))
|
|
|
|
|
(modify-syntax-entry ?\[ "(]" table)
|
|
|
|
|
(modify-syntax-entry ?\{ "(}" table)
|
|
|
|
|
(modify-syntax-entry ?\] ")[" table)
|
|
|
|
|
(modify-syntax-entry ?\} "){" table)
|
|
|
|
|
table))
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Regexps
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defconst *c-def-regexp*
|
|
|
|
|
;; This stops on lines with possible definitions
|
|
|
|
|
"\n[_a-zA-Z#]"
|
|
|
|
|
;; This stops after the symbol to add.
|
|
|
|
|
;;"\n\\(#define\\s +.\\|\\(\\(\\w\\|\\s_\\)+\\b\\s *\\)+[(;,[*{=]\\)"
|
|
|
|
|
;; This stops before the symbol to add. {Test cases in parens. below}
|
|
|
|
|
;;"\n\\(\\(\\w\\|\\s_\\)+\\s *(\\|\\(\\(#define\\|auto\\|extern\\|register\\|static\\|int\\|long\\|short\\|unsigned\\|char\\|void\\|float\\|double\\|enum\\|struct\\|union\\|typedef\\)\\s +\\)+\\)"
|
|
|
|
|
;; this simple version picks up too much extraneous stuff
|
|
|
|
|
;; "\n\\(\\w\\|\\s_\\|#\\)\\B"
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"A regexp that searches for a definition form.")
|
1990-04-05 21:41:26 +00:00
|
|
|
|
;
|
|
|
|
|
;(defconst *c-cont-regexp*
|
|
|
|
|
; "\\(\\w\\|\\s_\\)+\\b\\s *\\({\\|\\(\\[[0-9\t ]*\\]\\s *\\)*,\\(*\\|\\s \\)*\\b\\)"
|
|
|
|
|
; "This regexp should be used in a looking-at to parse for lists of variables.")
|
|
|
|
|
;
|
|
|
|
|
;(defconst *c-struct-regexp*
|
|
|
|
|
; "\\(*\\|\\s \\)*\\b"
|
|
|
|
|
; "This regexp should be used to test whether a symbol follows a structure definition.")
|
|
|
|
|
|
|
|
|
|
;(defun test-c-def-regexp (regexp string)
|
|
|
|
|
; (and (eq 0 (string-match regexp string)) (match-end 0))
|
|
|
|
|
; )
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Tests -
|
|
|
|
|
;; (test-c-def-regexp *c-def-regexp* "\n#define foo") -> 10 (9)
|
|
|
|
|
;; (test-c-def-regexp *c-def-regexp* "\nfoo (x, y) {") -> 6 (6)
|
|
|
|
|
;; (test-c-def-regexp *c-def-regexp* "\nint foo (x, y)") -> 10 (5)
|
|
|
|
|
;; (test-c-def-regexp *c-def-regexp* "\n int foo (x, y)") -> nil
|
|
|
|
|
;; (test-c-def-regexp *c-cont-regexp* "oo, bar") -> 4
|
|
|
|
|
;; (test-c-def-regexp *c-cont-regexp* "oo, *bar") -> 5
|
|
|
|
|
;; (test-c-def-regexp *c-cont-regexp* "a [5][6], bar") -> 10
|
|
|
|
|
;; (test-c-def-regexp *c-cont-regexp* "oo(x,y)") -> nil
|
|
|
|
|
;; (test-c-def-regexp *c-cont-regexp* "a [6] ,\t bar") -> 9
|
|
|
|
|
;; (test-c-def-regexp *c-cont-regexp* "oo {trout =1} my_carp;") -> 14
|
|
|
|
|
;; (test-c-def-regexp *c-cont-regexp* "truct_p complex foon") -> nil
|
|
|
|
|
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; Parses all the definition names from a C mode buffer and adds them to the
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; completion database.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defun add-completions-from-c-buffer ()
|
|
|
|
|
;; Benchmark --
|
|
|
|
|
;; Sun 3/280-- 1250 lines/sec.
|
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(let (string next-point char)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(catch 'finish-add-completions
|
2006-10-07 15:57:36 +00:00
|
|
|
|
(with-syntax-table completion-c-def-syntax-table
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(while t
|
|
|
|
|
;; we loop here only when scan-sexps fails
|
|
|
|
|
;; (i.e. unbalance exps.)
|
|
|
|
|
(condition-case e
|
|
|
|
|
(while t
|
|
|
|
|
(re-search-forward *c-def-regexp*)
|
|
|
|
|
(cond
|
|
|
|
|
((= (preceding-char) ?#)
|
|
|
|
|
;; preprocessor macro, see if it's one we handle
|
2006-10-07 15:57:36 +00:00
|
|
|
|
(cond ((looking-at "\\(define\\|ifdef\\)\\>")
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; skip forward over definition symbol
|
|
|
|
|
;; and add it to database
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 21:54:21 +00:00
|
|
|
|
(and (forward-word-strictly 2)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq string (symbol-before-point))
|
|
|
|
|
;;(push string foo)
|
|
|
|
|
(add-completion-to-tail-if-new string)))))
|
|
|
|
|
(t
|
|
|
|
|
;; C definition
|
|
|
|
|
(setq next-point (point))
|
|
|
|
|
(while (and
|
|
|
|
|
next-point
|
|
|
|
|
;; scan to next separator char.
|
|
|
|
|
(setq next-point (scan-sexps next-point 1)))
|
|
|
|
|
;; position the point on the word we want to add
|
|
|
|
|
(goto-char next-point)
|
|
|
|
|
(while (= (setq char (following-char)) ?*)
|
|
|
|
|
;; handle pointer ref
|
|
|
|
|
;; move to next separator char.
|
|
|
|
|
(goto-char
|
|
|
|
|
(setq next-point (scan-sexps (point) 1))))
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 21:54:21 +00:00
|
|
|
|
(forward-word-strictly -1)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; add to database
|
|
|
|
|
(if (setq string (symbol-under-point))
|
|
|
|
|
;; (push string foo)
|
|
|
|
|
(add-completion-to-tail-if-new string)
|
|
|
|
|
;; Local TMC hack (useful for parsing paris.h)
|
|
|
|
|
(if (and (looking-at "_AP") ;; "ansi prototype"
|
|
|
|
|
(progn
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 21:54:21 +00:00
|
|
|
|
(forward-word-strictly -1)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq string
|
|
|
|
|
(symbol-under-point))))
|
|
|
|
|
(add-completion-to-tail-if-new string)))
|
|
|
|
|
;; go to next
|
|
|
|
|
(goto-char next-point)
|
|
|
|
|
;; (push (format "%c" (following-char)) foo)
|
|
|
|
|
(if (= (char-syntax char) ?\()
|
|
|
|
|
;; if on an opening delimiter, go to end
|
|
|
|
|
(while (= (char-syntax char) ?\()
|
|
|
|
|
(setq next-point (scan-sexps next-point 1)
|
|
|
|
|
char (char-after next-point)))
|
|
|
|
|
(or (= char ?,)
|
|
|
|
|
;; Current char is an end char.
|
|
|
|
|
(setq next-point nil)))))))
|
|
|
|
|
(search-failed ;;done
|
|
|
|
|
(throw 'finish-add-completions t))
|
|
|
|
|
(error
|
|
|
|
|
;; Check for failure in scan-sexps
|
2006-10-07 15:57:36 +00:00
|
|
|
|
(if (member (nth 1 e)
|
|
|
|
|
'("Containing expression ends prematurely"
|
|
|
|
|
"Unbalanced parentheses"))
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; unbalanced paren., keep going
|
|
|
|
|
;;(ding)
|
|
|
|
|
(forward-line 1)
|
|
|
|
|
(message "Error parsing C buffer for completions--please send bug report")
|
|
|
|
|
(throw 'finish-add-completions t))))))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
|
;; Init files
|
|
|
|
|
;;---------------------------------------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; The version of save-completions-to-file called at kill-emacs time.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defun kill-emacs-save-completions ()
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(if (and save-completions-flag enable-completion cmpl-initialized-p)
|
|
|
|
|
(cond
|
|
|
|
|
((not cmpl-completions-accepted-p)
|
|
|
|
|
(message "Completions database has not changed - not writing."))
|
|
|
|
|
(t
|
2013-08-10 12:00:19 +00:00
|
|
|
|
(save-completions-to-file)))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1993-08-03 04:36:52 +00:00
|
|
|
|
;; There is no point bothering to change this again
|
|
|
|
|
;; unless the package changes so much that it matters
|
|
|
|
|
;; for people that have saved completions.
|
|
|
|
|
(defconst completion-version "11")
|
|
|
|
|
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defconst saved-cmpl-file-header
|
|
|
|
|
";;; Completion Initialization file.
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Version = %s
|
|
|
|
|
;; Format is (<string> . <last-use-time>)
|
|
|
|
|
;; <string> is the completion
|
|
|
|
|
;; <last-use-time> is the time the completion was last used
|
|
|
|
|
;; If it is t, the completion will never be pruned from the file.
|
|
|
|
|
;; Otherwise it is in hours since origin.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
\n")
|
|
|
|
|
|
|
|
|
|
(defun completion-backup-filename (filename)
|
|
|
|
|
(concat filename ".BAK"))
|
|
|
|
|
|
|
|
|
|
(defun save-completions-to-file (&optional filename)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Save completions in init file FILENAME.
|
|
|
|
|
If file name is not specified, use `save-completions-file-name'."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(interactive)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(setq filename (expand-file-name (or filename save-completions-file-name)))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(if (file-writable-p filename)
|
|
|
|
|
(progn
|
|
|
|
|
(if (not cmpl-initialized-p)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(completion-initialize)) ;; make sure everything's loaded
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(message "Saving completions to file %s" filename)
|
|
|
|
|
|
|
|
|
|
(let* ((delete-old-versions t)
|
|
|
|
|
(kept-old-versions 0)
|
|
|
|
|
(kept-new-versions completions-file-versions-kept)
|
|
|
|
|
last-use-time
|
Simplify use of current-time and friends.
* doc/misc/org.texi (Dynamic blocks):
* lisp/allout-widgets.el (allout-widgets-hook-error-handler):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/icalendar.el (icalendar--convert-float-to-ical):
* lisp/calendar/timeclock.el (timeclock-in, timeclock-when-to-leave)
(timeclock-last-period, timeclock-day-base):
* lisp/eshell/em-ls.el (eshell-ls-file):
* lisp/eshell/esh-util.el (eshell-parse-ange-ls):
* lisp/generic-x.el (named-database-print-serial):
* lisp/net/newst-backend.el (newsticker--get-news-by-url-callback)
(newsticker-get-news, newsticker--sentinel-work)
(newsticker--image-get, newsticker--image-sentinel):
* lisp/net/tramp-sh.el (tramp-get-remote-touch):
* lisp/progmodes/opascal.el (opascal-debug-log):
* lisp/textmodes/remember.el (remember-mail-date)
(remember-store-in-files):
* lisp/vc/vc-annotate.el (vc-annotate-display-autoscale)
(vc-default-annotate-current-time):
* lisp/vc/vc-bzr.el (vc-bzr-shelve-snapshot):
* lisp/vc/vc-cvs.el (vc-cvs-annotate-current-time):
* lisp/vc/vc-rcs.el (vc-rcs-annotate-current-time):
* lisp/url/url-util.el (url-get-normalized-date):
* lisp/erc/erc-backend.el (TOPIC):
* lisp/gnus/gnus-delay.el (gnus-delay-article):
* lisp/gnus/gnus-sum.el (gnus-summary-read-document):
* lisp/gnus/gnus-util.el (gnus-seconds-today, gnus-seconds-month):
* lisp/gnus/message.el (message-make-expires-date):
* lisp/org/org-archive.el (org-archive-subtree)
(org-archive-to-archive-sibling):
* lisp/org/org-clock.el (org-resolve-clocks, org-clock-get-sum-start)
(org-clock-special-range):
* lisp/org/org-timer.el (org-timer-seconds):
* lisp/org/org.el (org-read-date-analyze, org-get-cursor-date):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-icalendar.el (org-icalendar--vtodo):
Omit unnecessary call to current-time.
* lisp/calendar/time-date.el (time-to-seconds) [!float-time]:
* lisp/calendar/timeclock.el (timeclock-time-to-date):
* lisp/vc/vc-annotate.el (vc-annotate-convert-time):
Use current time if arg is nil, to be compatible with float-time.
(time-date--day-in-year): New function, with most of the guts of
the old time-to-day-in-year.
(time-to-day-in-year): Use it.
(time-to-days): Use it, to avoid decoding the same time stamp twice.
* lisp/calendar/timeclock.el (timeclock-update-mode-line):
* lisp/cedet/srecode/args.el (srecode-semantic-handle-:time):
* lisp/gnus/gnus-util.el (gnus-seconds-year):
* lisp/org/org.el (org-get-cursor-date):
Don't call current-time twice to get the current time stamp,
as this can lead to inconsistent results.
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/erc/erc.el (erc-emacs-time-to-erc-time):
* lisp/ido.el (ido-time-stamp):
* lisp/vc/vc-annotate.el (vc-annotate-convert-time):
Simplify by using float-time.
* lisp/completion.el (save-completions-to-file):
* lisp/url/url-cache.el (url-cache-prune-cache):
Rename local var to avoid confusion.
* lisp/gnus/gnus-util.el (gnus-float-time):
* lisp/net/rcirc.el (rcirc-float-time):
* lisp/org/org-compat.el (org-float-time):
Simplify to an alias because time-to-seconds now behaves like float-time
with respect to nil arg.
* lisp/subr.el (progress-reporter-do-update):
Don't call float-time unless needed.
* lisp/erc/erc.el (erc-current-time): Simplify by using erc-emacs-time-to-erc-time.
* lisp/org/org-clock.el (org-clock-get-table-data): Omit unnecessary, lossy
conversion from floating point to Emacs time and back.
(org-resolve-clocks): Prefer two-argument floor.
2014-10-29 01:42:51 +00:00
|
|
|
|
(this-use-time (cmpl-hours-since-origin))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(total-in-db 0)
|
|
|
|
|
(total-perm 0)
|
|
|
|
|
(total-saved 0)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(backup-filename (completion-backup-filename filename)))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create " *completion-save-buffer*")
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(setq buffer-file-name filename)
|
|
|
|
|
|
|
|
|
|
(if (not (verify-visited-file-modtime (current-buffer)))
|
|
|
|
|
(progn
|
|
|
|
|
;; file has changed on disk. Bring us up-to-date
|
|
|
|
|
(message "Completion file has changed. Merging. . .")
|
|
|
|
|
(load-completions-from-file filename t)
|
|
|
|
|
(message "Merging finished. Saving completions to file %s" filename)))
|
|
|
|
|
|
|
|
|
|
;; prepare the buffer to be modified
|
|
|
|
|
(clear-visited-file-modtime)
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
;; (/ 1 0)
|
|
|
|
|
(insert (format saved-cmpl-file-header completion-version))
|
2000-02-03 15:45:10 +00:00
|
|
|
|
(dolist (completion (list-all-completions))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(setq total-in-db (1+ total-in-db))
|
|
|
|
|
(setq last-use-time (completion-last-use-time completion))
|
|
|
|
|
;; Update num uses and maybe write completion to a file
|
|
|
|
|
(cond ((or;; Write to file if
|
|
|
|
|
;; permanent
|
|
|
|
|
(and (eq last-use-time t)
|
|
|
|
|
(setq total-perm (1+ total-perm)))
|
|
|
|
|
;; or if
|
|
|
|
|
(if (> (completion-num-uses completion) 0)
|
|
|
|
|
;; it's been used
|
Simplify use of current-time and friends.
* doc/misc/org.texi (Dynamic blocks):
* lisp/allout-widgets.el (allout-widgets-hook-error-handler):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/icalendar.el (icalendar--convert-float-to-ical):
* lisp/calendar/timeclock.el (timeclock-in, timeclock-when-to-leave)
(timeclock-last-period, timeclock-day-base):
* lisp/eshell/em-ls.el (eshell-ls-file):
* lisp/eshell/esh-util.el (eshell-parse-ange-ls):
* lisp/generic-x.el (named-database-print-serial):
* lisp/net/newst-backend.el (newsticker--get-news-by-url-callback)
(newsticker-get-news, newsticker--sentinel-work)
(newsticker--image-get, newsticker--image-sentinel):
* lisp/net/tramp-sh.el (tramp-get-remote-touch):
* lisp/progmodes/opascal.el (opascal-debug-log):
* lisp/textmodes/remember.el (remember-mail-date)
(remember-store-in-files):
* lisp/vc/vc-annotate.el (vc-annotate-display-autoscale)
(vc-default-annotate-current-time):
* lisp/vc/vc-bzr.el (vc-bzr-shelve-snapshot):
* lisp/vc/vc-cvs.el (vc-cvs-annotate-current-time):
* lisp/vc/vc-rcs.el (vc-rcs-annotate-current-time):
* lisp/url/url-util.el (url-get-normalized-date):
* lisp/erc/erc-backend.el (TOPIC):
* lisp/gnus/gnus-delay.el (gnus-delay-article):
* lisp/gnus/gnus-sum.el (gnus-summary-read-document):
* lisp/gnus/gnus-util.el (gnus-seconds-today, gnus-seconds-month):
* lisp/gnus/message.el (message-make-expires-date):
* lisp/org/org-archive.el (org-archive-subtree)
(org-archive-to-archive-sibling):
* lisp/org/org-clock.el (org-resolve-clocks, org-clock-get-sum-start)
(org-clock-special-range):
* lisp/org/org-timer.el (org-timer-seconds):
* lisp/org/org.el (org-read-date-analyze, org-get-cursor-date):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-icalendar.el (org-icalendar--vtodo):
Omit unnecessary call to current-time.
* lisp/calendar/time-date.el (time-to-seconds) [!float-time]:
* lisp/calendar/timeclock.el (timeclock-time-to-date):
* lisp/vc/vc-annotate.el (vc-annotate-convert-time):
Use current time if arg is nil, to be compatible with float-time.
(time-date--day-in-year): New function, with most of the guts of
the old time-to-day-in-year.
(time-to-day-in-year): Use it.
(time-to-days): Use it, to avoid decoding the same time stamp twice.
* lisp/calendar/timeclock.el (timeclock-update-mode-line):
* lisp/cedet/srecode/args.el (srecode-semantic-handle-:time):
* lisp/gnus/gnus-util.el (gnus-seconds-year):
* lisp/org/org.el (org-get-cursor-date):
Don't call current-time twice to get the current time stamp,
as this can lead to inconsistent results.
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/erc/erc.el (erc-emacs-time-to-erc-time):
* lisp/ido.el (ido-time-stamp):
* lisp/vc/vc-annotate.el (vc-annotate-convert-time):
Simplify by using float-time.
* lisp/completion.el (save-completions-to-file):
* lisp/url/url-cache.el (url-cache-prune-cache):
Rename local var to avoid confusion.
* lisp/gnus/gnus-util.el (gnus-float-time):
* lisp/net/rcirc.el (rcirc-float-time):
* lisp/org/org-compat.el (org-float-time):
Simplify to an alias because time-to-seconds now behaves like float-time
with respect to nil arg.
* lisp/subr.el (progress-reporter-do-update):
Don't call float-time unless needed.
* lisp/erc/erc.el (erc-current-time): Simplify by using erc-emacs-time-to-erc-time.
* lisp/org/org-clock.el (org-clock-get-table-data): Omit unnecessary, lossy
conversion from floating point to Emacs time and back.
(org-resolve-clocks): Prefer two-argument floor.
2014-10-29 01:42:51 +00:00
|
|
|
|
(setq last-use-time this-use-time)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; or it was saved before and
|
|
|
|
|
(and last-use-time
|
|
|
|
|
;; save-completions-retention-time is nil
|
|
|
|
|
(or (not save-completions-retention-time)
|
|
|
|
|
;; or time since last use is < ...retention-time*
|
Simplify use of current-time and friends.
* doc/misc/org.texi (Dynamic blocks):
* lisp/allout-widgets.el (allout-widgets-hook-error-handler):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/icalendar.el (icalendar--convert-float-to-ical):
* lisp/calendar/timeclock.el (timeclock-in, timeclock-when-to-leave)
(timeclock-last-period, timeclock-day-base):
* lisp/eshell/em-ls.el (eshell-ls-file):
* lisp/eshell/esh-util.el (eshell-parse-ange-ls):
* lisp/generic-x.el (named-database-print-serial):
* lisp/net/newst-backend.el (newsticker--get-news-by-url-callback)
(newsticker-get-news, newsticker--sentinel-work)
(newsticker--image-get, newsticker--image-sentinel):
* lisp/net/tramp-sh.el (tramp-get-remote-touch):
* lisp/progmodes/opascal.el (opascal-debug-log):
* lisp/textmodes/remember.el (remember-mail-date)
(remember-store-in-files):
* lisp/vc/vc-annotate.el (vc-annotate-display-autoscale)
(vc-default-annotate-current-time):
* lisp/vc/vc-bzr.el (vc-bzr-shelve-snapshot):
* lisp/vc/vc-cvs.el (vc-cvs-annotate-current-time):
* lisp/vc/vc-rcs.el (vc-rcs-annotate-current-time):
* lisp/url/url-util.el (url-get-normalized-date):
* lisp/erc/erc-backend.el (TOPIC):
* lisp/gnus/gnus-delay.el (gnus-delay-article):
* lisp/gnus/gnus-sum.el (gnus-summary-read-document):
* lisp/gnus/gnus-util.el (gnus-seconds-today, gnus-seconds-month):
* lisp/gnus/message.el (message-make-expires-date):
* lisp/org/org-archive.el (org-archive-subtree)
(org-archive-to-archive-sibling):
* lisp/org/org-clock.el (org-resolve-clocks, org-clock-get-sum-start)
(org-clock-special-range):
* lisp/org/org-timer.el (org-timer-seconds):
* lisp/org/org.el (org-read-date-analyze, org-get-cursor-date):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-icalendar.el (org-icalendar--vtodo):
Omit unnecessary call to current-time.
* lisp/calendar/time-date.el (time-to-seconds) [!float-time]:
* lisp/calendar/timeclock.el (timeclock-time-to-date):
* lisp/vc/vc-annotate.el (vc-annotate-convert-time):
Use current time if arg is nil, to be compatible with float-time.
(time-date--day-in-year): New function, with most of the guts of
the old time-to-day-in-year.
(time-to-day-in-year): Use it.
(time-to-days): Use it, to avoid decoding the same time stamp twice.
* lisp/calendar/timeclock.el (timeclock-update-mode-line):
* lisp/cedet/srecode/args.el (srecode-semantic-handle-:time):
* lisp/gnus/gnus-util.el (gnus-seconds-year):
* lisp/org/org.el (org-get-cursor-date):
Don't call current-time twice to get the current time stamp,
as this can lead to inconsistent results.
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/erc/erc.el (erc-emacs-time-to-erc-time):
* lisp/ido.el (ido-time-stamp):
* lisp/vc/vc-annotate.el (vc-annotate-convert-time):
Simplify by using float-time.
* lisp/completion.el (save-completions-to-file):
* lisp/url/url-cache.el (url-cache-prune-cache):
Rename local var to avoid confusion.
* lisp/gnus/gnus-util.el (gnus-float-time):
* lisp/net/rcirc.el (rcirc-float-time):
* lisp/org/org-compat.el (org-float-time):
Simplify to an alias because time-to-seconds now behaves like float-time
with respect to nil arg.
* lisp/subr.el (progress-reporter-do-update):
Don't call float-time unless needed.
* lisp/erc/erc.el (erc-current-time): Simplify by using erc-emacs-time-to-erc-time.
* lisp/org/org-clock.el (org-clock-get-table-data): Omit unnecessary, lossy
conversion from floating point to Emacs time and back.
(org-resolve-clocks): Prefer two-argument floor.
2014-10-29 01:42:51 +00:00
|
|
|
|
(< (- this-use-time last-use-time)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
save-completions-retention-time)))))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; write to file
|
|
|
|
|
(setq total-saved (1+ total-saved))
|
|
|
|
|
(insert (prin1-to-string (cons (completion-string completion)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
last-use-time)) "\n"))))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; write the buffer
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(condition-case nil
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(let ((file-exists-p (file-exists-p filename)))
|
|
|
|
|
(if file-exists-p
|
|
|
|
|
(progn
|
|
|
|
|
;; If file exists . . .
|
|
|
|
|
;; Save a backup(so GNU doesn't screw us when we're out of disk)
|
|
|
|
|
;; (GNU leaves a 0 length file if it gets a disk full error!)
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; If backup doesn't exit, Rename current to backup
|
|
|
|
|
;; {If backup exists the primary file is probably messed up}
|
|
|
|
|
(or (file-exists-p backup-filename)
|
|
|
|
|
(rename-file filename backup-filename))
|
|
|
|
|
;; Copy the backup back to the current name
|
|
|
|
|
;; (so versioning works)
|
|
|
|
|
(copy-file backup-filename filename t)))
|
|
|
|
|
;; Save it
|
|
|
|
|
(save-buffer)
|
|
|
|
|
(if file-exists-p
|
|
|
|
|
;; If successful, remove backup
|
|
|
|
|
(delete-file backup-filename)))
|
|
|
|
|
(error
|
|
|
|
|
(set-buffer-modified-p nil)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(message "Couldn't save completion file `%s'" filename)))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; Reset accepted-p flag
|
2013-08-10 12:00:19 +00:00
|
|
|
|
(setq cmpl-completions-accepted-p nil) )))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1998-10-06 23:22:48 +00:00
|
|
|
|
;;(defun auto-save-completions ()
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; (if (and save-completions-flag enable-completion cmpl-initialized-p
|
|
|
|
|
;; *completion-auto-save-period*
|
|
|
|
|
;; (> cmpl-emacs-idle-time *completion-auto-save-period*)
|
|
|
|
|
;; cmpl-completions-accepted-p)
|
|
|
|
|
;; (save-completions-to-file)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1998-10-06 23:22:48 +00:00
|
|
|
|
;;(add-hook 'cmpl-emacs-idle-time-hooks 'auto-save-completions)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
(defun load-completions-from-file (&optional filename no-message-p)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
"Load a completion init file FILENAME.
|
1993-05-27 12:44:54 +00:00
|
|
|
|
If file is not specified, then use `save-completions-file-name'."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(interactive)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(setq filename (expand-file-name (or filename save-completions-file-name)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(let* ((backup-filename (completion-backup-filename filename))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(backup-readable-p (file-readable-p backup-filename)))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(if backup-readable-p (setq filename backup-filename))
|
|
|
|
|
(if (file-readable-p filename)
|
|
|
|
|
(progn
|
|
|
|
|
(if (not no-message-p)
|
|
|
|
|
(message "Loading completions from %sfile %s . . ."
|
|
|
|
|
(if backup-readable-p "backup " "") filename))
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create " *completion-save-buffer*")
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(setq buffer-file-name filename)
|
|
|
|
|
;; prepare the buffer to be modified
|
|
|
|
|
(clear-visited-file-modtime)
|
|
|
|
|
(erase-buffer)
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(let ((insert-okay-p nil)
|
|
|
|
|
(buffer (current-buffer))
|
2005-11-28 01:43:28 +00:00
|
|
|
|
string entry last-use-time
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
cmpl-entry cmpl-last-use-time
|
|
|
|
|
(current-completion-source cmpl-source-init-file)
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(total-in-file 0) (total-perm 0))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; insert the file into a buffer
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(condition-case nil
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(progn (insert-file-contents filename t)
|
|
|
|
|
(setq insert-okay-p t))
|
|
|
|
|
|
2003-02-04 11:26:42 +00:00
|
|
|
|
(file-error
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(message "File error trying to load completion file %s."
|
|
|
|
|
filename)))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; parse it
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(if insert-okay-p
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(condition-case nil
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(while t
|
|
|
|
|
(setq entry (read buffer))
|
|
|
|
|
(setq total-in-file (1+ total-in-file))
|
|
|
|
|
(cond
|
|
|
|
|
((and (consp entry)
|
|
|
|
|
(stringp (setq string (car entry)))
|
|
|
|
|
(cond
|
|
|
|
|
((eq (setq last-use-time (cdr entry)) 'T)
|
|
|
|
|
;; handle case sensitivity
|
|
|
|
|
(setq total-perm (1+ total-perm))
|
|
|
|
|
(setq last-use-time t))
|
|
|
|
|
((eq last-use-time t)
|
|
|
|
|
(setq total-perm (1+ total-perm)))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
((integerp last-use-time))))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; Valid entry
|
|
|
|
|
;; add it in
|
|
|
|
|
(setq cmpl-last-use-time
|
|
|
|
|
(completion-last-use-time
|
|
|
|
|
(setq cmpl-entry
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(add-completion-to-tail-if-new string))))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
(if (or (eq last-use-time t)
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(and (> last-use-time 1000);;backcompatibility
|
|
|
|
|
(not (eq cmpl-last-use-time t))
|
|
|
|
|
(or (not cmpl-last-use-time)
|
|
|
|
|
;; more recent
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(> last-use-time cmpl-last-use-time))))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
;; update last-use-time
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(set-completion-last-use-time cmpl-entry last-use-time)))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(t
|
|
|
|
|
;; Bad format
|
|
|
|
|
(message "Error: invalid saved completion - %s"
|
|
|
|
|
(prin1-to-string entry))
|
|
|
|
|
;; try to get back in sync
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(search-forward "\n("))))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(search-failed
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(message "End of file while reading completions."))
|
Don't use cl. Eliminate use of when, unless,
dotimes, plusp, minusp, pusnhew, second.
(completion-dolist): New macro. Use instead of dolist.
(completion-gensym-counter, completion-gensym): New variable and fn.
(locate-completion-entry-retry): Bind cmpl-entry, then use it.
(locate-completion-entry): Use completion-string, not string.
(add-completion-to-head, delete-completion):
Rename arg to completion-string.
(completions-list-return-value): Defvar'd and renamed
from return-completions.
(cmpl-preceding-syntax, cdabbrev-stop-point): Add defvars.
(delete-completion, check-completion-length): Fix message format.
(complete, add-completions-from-buffer, add-completions-from-c-buffer)
(save-completions-to-file): Likewise.
1995-02-02 23:04:54 +00:00
|
|
|
|
(end-of-file
|
|
|
|
|
(if (= (point) (point-max))
|
|
|
|
|
(if (not no-message-p)
|
|
|
|
|
(message "Loading completions from file %s . . . Done."
|
|
|
|
|
filename))
|
2000-05-22 17:53:15 +00:00
|
|
|
|
(message "End of file while reading completions."))))))
|
|
|
|
|
))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defun completion-initialize ()
|
1993-05-27 12:44:54 +00:00
|
|
|
|
"Load the default completions file.
|
2003-02-05 19:09:34 +00:00
|
|
|
|
Also sets up so that exiting Emacs will automatically save the file."
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(interactive)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(unless cmpl-initialized-p
|
|
|
|
|
(load-completions-from-file)
|
|
|
|
|
(setq cmpl-initialized-p t)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Kill region patch
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(defun completion-kill-region (&optional beg end)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
"Kill between point and mark.
|
|
|
|
|
The text is deleted but saved in the kill ring.
|
|
|
|
|
The command \\[yank] can retrieve it from there.
|
2019-09-21 07:05:20 +00:00
|
|
|
|
\(If you want to kill and then yank immediately, use \\[copy-region-as-kill].)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
|
|
|
|
This is the primitive for programs to kill text (as opposed to deleting it).
|
2004-06-07 20:44:24 +00:00
|
|
|
|
Supply two arguments, character positions indicating the stretch of text
|
1990-04-05 21:41:26 +00:00
|
|
|
|
to be killed.
|
|
|
|
|
Any command that calls this function is a \"kill command\".
|
|
|
|
|
If the previous command was also a kill command,
|
|
|
|
|
the text killed this time appends to the text killed last time
|
|
|
|
|
to make one entry in the kill ring.
|
|
|
|
|
Patched to remove the most recent completion."
|
2003-02-04 11:26:42 +00:00
|
|
|
|
(interactive "r")
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(cond ((eq last-command 'complete)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(delete-region (point) cmpl-last-insert-location)
|
|
|
|
|
(insert cmpl-original-string)
|
2013-08-10 12:00:19 +00:00
|
|
|
|
(setq completion-to-accept nil))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(t
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(kill-region beg end))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1993-05-27 12:44:54 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Patches to self-insert-command.
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Need 2 versions: generic separator chars. and space (to get auto fill
|
|
|
|
|
;; to work)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; All common separators (eg. space "(" ")" """) characters go through a
|
2014-12-22 17:35:29 +00:00
|
|
|
|
;; function to add new words to the list of words to complete from.
|
2020-10-02 16:02:51 +00:00
|
|
|
|
;; If the character before this was an alphanumeric then this adds the
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; symbol before point to the completion list (using ADD-COMPLETION).
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2014-12-22 17:35:29 +00:00
|
|
|
|
(defvar completion-separator-chars
|
|
|
|
|
(append " !%^&()=`|{}[];\\'#,?"
|
|
|
|
|
;; We include period and colon even though they are symbol
|
|
|
|
|
;; chars because :
|
|
|
|
|
;; - in text we want to pick up the last word in a sentence.
|
|
|
|
|
;; - in C pointer refs. we want to pick up the first symbol
|
|
|
|
|
;; - it won't make a difference for lisp mode (package names
|
|
|
|
|
;; are short)
|
|
|
|
|
".:" nil))
|
|
|
|
|
|
|
|
|
|
(defun completion--post-self-insert ()
|
|
|
|
|
(when (memq last-command-event completion-separator-chars)
|
|
|
|
|
(let ((after-pos (electric--after-char-pos)))
|
|
|
|
|
(when after-pos
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (1- after-pos))
|
|
|
|
|
(use-completion-before-separator))))))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Wrapping Macro
|
|
|
|
|
;;-----------------------------------------------
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; Note that because of the way byte compiling works, none of
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; the functions defined with this macro get byte compiled.
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defun completion-def-wrapper (function-name type)
|
1992-10-06 21:01:11 +00:00
|
|
|
|
"Add a call to update the completion database before function execution.
|
|
|
|
|
TYPE is the type of the wrapper to be added. Can be :before or :under."
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(put function-name 'completion-function
|
|
|
|
|
(cdr (assq type
|
2006-01-25 04:11:05 +00:00
|
|
|
|
'((:separator . use-completion-before-separator)
|
|
|
|
|
(:before . use-completion-before-point)
|
|
|
|
|
(:backward-under . use-completion-backward-under)
|
|
|
|
|
(:backward . use-completion-backward)
|
|
|
|
|
(:under . use-completion-under-point)
|
|
|
|
|
(:under-or-before . use-completion-under-or-before-point)
|
|
|
|
|
(:minibuffer-separator
|
|
|
|
|
. use-completion-minibuffer-separator))))))
|
1993-05-27 12:44:54 +00:00
|
|
|
|
|
|
|
|
|
(defun use-completion-minibuffer-separator ()
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(let ((completion-syntax-table completion-standard-syntax-table))
|
1993-05-27 12:44:54 +00:00
|
|
|
|
(use-completion-before-separator)))
|
|
|
|
|
|
|
|
|
|
(defun use-completion-backward-under ()
|
2013-08-10 12:00:19 +00:00
|
|
|
|
(use-completion-under-point))
|
1993-05-27 12:44:54 +00:00
|
|
|
|
|
|
|
|
|
(defun use-completion-backward ()
|
2013-08-10 12:00:19 +00:00
|
|
|
|
nil)
|
1993-05-27 12:44:54 +00:00
|
|
|
|
|
|
|
|
|
(defun completion-before-command ()
|
1994-09-01 06:12:38 +00:00
|
|
|
|
(funcall (or (and (symbolp this-command)
|
|
|
|
|
(get this-command 'completion-function))
|
2019-06-26 14:24:59 +00:00
|
|
|
|
'use-completion-under-or-before-point)))
|
1998-11-01 08:45:25 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; Lisp mode diffs.
|
|
|
|
|
|
|
|
|
|
(defconst completion-lisp-syntax-table
|
|
|
|
|
(let ((table (copy-syntax-table completion-standard-syntax-table))
|
|
|
|
|
(symbol-chars '(?! ?& ?? ?= ?^)))
|
|
|
|
|
(dolist (char symbol-chars)
|
|
|
|
|
(modify-syntax-entry char "_" table))
|
|
|
|
|
table))
|
|
|
|
|
|
2018-03-23 04:40:24 +00:00
|
|
|
|
(declare-function cl-set-difference "cl-seq" (cl-list1 cl-list2 &rest cl-keys))
|
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defun completion-lisp-mode-hook ()
|
Explicitly require cl-lib where needed
Rather than relying on the byte-compiler happening to use it.
* lisp/completion.el, lisp/ffap.el, lisp/loadhist.el:
* lisp/userlock.el, lisp/emacs-lisp/debug.el, lisp/emacs-lisp/rx.el:
* lisp/emacs-lisp/testcover.el, lisp/mail/rfc2231.el:
* lisp/net/newst-treeview.el, lisp/net/puny.el:
* lisp/net/tramp-archive.el, lisp/net/tramp-gvfs.el:
* lisp/net/tramp-sh.el, lisp/net/tramp-smb.el, lisp/org/org-ctags.el:
* lisp/org/org-macs.el, lisp/progmodes/grep.el:
* lisp/progmodes/perl-mode.el, lisp/progmodes/ruby-mode.el:
* lisp/textmodes/dns-mode.el, lisp/textmodes/mhtml-mode.el:
* lisp/vc/pcvs-parse.el: Explicitly require cl-lib as needed.
2018-03-17 00:41:17 +00:00
|
|
|
|
(require 'cl-lib)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq completion-syntax-table completion-lisp-syntax-table)
|
|
|
|
|
;; Lisp Mode diffs
|
2015-04-13 14:35:15 +00:00
|
|
|
|
(setq-local completion-separator-chars
|
|
|
|
|
(cl-set-difference completion-separator-chars
|
|
|
|
|
(append "!&%?=^" nil))))
|
2005-11-28 01:43:28 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; C mode diffs.
|
2005-08-09 02:53:54 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defconst completion-c-syntax-table
|
|
|
|
|
(let ((table (copy-syntax-table completion-standard-syntax-table))
|
|
|
|
|
(separator-chars '(?+ ?* ?/ ?: ?%)))
|
|
|
|
|
(dolist (char separator-chars)
|
|
|
|
|
(modify-syntax-entry char " " table))
|
|
|
|
|
table))
|
2005-08-09 02:53:54 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(completion-def-wrapper 'electric-c-semi :separator)
|
1995-11-24 22:20:07 +00:00
|
|
|
|
(defun completion-c-mode-hook ()
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq completion-syntax-table completion-c-syntax-table)
|
2014-12-22 17:35:29 +00:00
|
|
|
|
(setq-local completion-separator-chars
|
|
|
|
|
(append "+*/" completion-separator-chars)))
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; FORTRAN mode diffs. (these are defined when fortran is called)
|
2005-08-09 02:53:54 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defconst completion-fortran-syntax-table
|
|
|
|
|
(let ((table (copy-syntax-table completion-standard-syntax-table))
|
|
|
|
|
(separator-chars '(?+ ?- ?* ?/ ?:)))
|
|
|
|
|
(dolist (char separator-chars)
|
|
|
|
|
(modify-syntax-entry char " " table))
|
|
|
|
|
table))
|
2005-08-09 02:53:54 +00:00
|
|
|
|
|
1990-04-05 21:41:26 +00:00
|
|
|
|
(defun completion-setup-fortran-mode ()
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(setq completion-syntax-table completion-fortran-syntax-table)
|
2014-12-22 17:35:29 +00:00
|
|
|
|
(setq-local completion-separator-chars
|
|
|
|
|
(append "+-*/" completion-separator-chars)))
|
1998-11-01 08:45:25 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; Enable completion mode.
|
|
|
|
|
|
|
|
|
|
(defvar fortran-mode-hook)
|
|
|
|
|
|
|
|
|
|
(defvar completion-saved-bindings nil)
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
1998-11-01 08:45:25 +00:00
|
|
|
|
;;;###autoload
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(define-minor-mode dynamic-completion-mode
|
2018-07-02 03:34:53 +00:00
|
|
|
|
"Toggle dynamic word-completion on or off."
|
2005-11-28 01:43:28 +00:00
|
|
|
|
:global t
|
2013-05-15 23:55:41 +00:00
|
|
|
|
:group 'completion
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; This is always good, not specific to dynamic-completion-mode.
|
1998-11-01 08:45:25 +00:00
|
|
|
|
(define-key function-key-map [C-return] [?\C-\r])
|
|
|
|
|
|
2014-12-22 17:35:29 +00:00
|
|
|
|
(dolist (x `((find-file-hook . ,#'completion-find-file-hook)
|
|
|
|
|
(pre-command-hook . ,#'completion-before-command)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; Save completions when killing Emacs.
|
2014-12-22 17:35:29 +00:00
|
|
|
|
(kill-emacs-hook . ,#'kill-emacs-save-completions)
|
|
|
|
|
(post-self-insert-hook . ,#'completion--post-self-insert)
|
2005-11-28 01:43:28 +00:00
|
|
|
|
|
|
|
|
|
;; Install the appropriate mode tables.
|
2014-12-22 17:35:29 +00:00
|
|
|
|
(lisp-mode-hook . ,#'completion-lisp-mode-hook)
|
|
|
|
|
(c-mode-hook . ,#'completion-c-mode-hook)
|
|
|
|
|
(fortran-mode-hook . ,#'completion-setup-fortran-mode)))
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(if dynamic-completion-mode
|
|
|
|
|
(add-hook (car x) (cdr x))
|
|
|
|
|
(remove-hook (car x) (cdr x))))
|
2006-01-25 04:11:05 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;; "Complete" Key Keybindings. We don't want to use a minor-mode
|
|
|
|
|
;; map because these have too high a priority. We could/should
|
|
|
|
|
;; probably change the interpretation of minor-mode-map-alist such
|
|
|
|
|
;; that a map has lower precedence if the symbol is not buffer-local.
|
|
|
|
|
(while completion-saved-bindings
|
|
|
|
|
(let ((binding (pop completion-saved-bindings)))
|
|
|
|
|
(global-set-key (car binding) (cdr binding))))
|
|
|
|
|
(when dynamic-completion-mode
|
|
|
|
|
(dolist (binding
|
|
|
|
|
'(("\M-\r" . complete)
|
|
|
|
|
([?\C-\r] . complete)
|
|
|
|
|
|
|
|
|
|
;; Tests -
|
|
|
|
|
;; (add-completion "cumberland")
|
|
|
|
|
;; (add-completion "cumberbund")
|
|
|
|
|
;; cum
|
|
|
|
|
;; Cumber
|
|
|
|
|
;; cumbering
|
|
|
|
|
;; cumb
|
|
|
|
|
|
|
|
|
|
;; Patches to standard keymaps insert completions
|
2014-12-22 17:35:29 +00:00
|
|
|
|
([remap kill-region] . completion-kill-region)))
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(push (cons (car binding) (lookup-key global-map (car binding)))
|
|
|
|
|
completion-saved-bindings)
|
|
|
|
|
(global-set-key (car binding) (cdr binding)))
|
|
|
|
|
|
|
|
|
|
;; Tests --
|
|
|
|
|
;; foobarbiz
|
|
|
|
|
;; foobar
|
|
|
|
|
;; fooquux
|
|
|
|
|
;; fooper
|
1998-11-01 08:45:25 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(completion-initialize)))
|
|
|
|
|
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; End of line chars.
|
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
(completion-def-wrapper 'newline :separator)
|
|
|
|
|
(completion-def-wrapper 'newline-and-indent :separator)
|
|
|
|
|
(completion-def-wrapper 'comint-send-input :separator)
|
|
|
|
|
(completion-def-wrapper 'exit-minibuffer :minibuffer-separator)
|
|
|
|
|
(completion-def-wrapper 'eval-print-last-sexp :separator)
|
|
|
|
|
(completion-def-wrapper 'eval-last-sexp :separator)
|
|
|
|
|
;;(completion-def-wrapper 'minibuffer-complete-and-exit :minibuffer)
|
1990-04-05 21:41:26 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
;;-----------------------------------------------
|
|
|
|
|
;; Cursor movement
|
|
|
|
|
;;-----------------------------------------------
|
1992-05-30 23:54:21 +00:00
|
|
|
|
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(completion-def-wrapper 'next-line :under-or-before)
|
|
|
|
|
(completion-def-wrapper 'previous-line :under-or-before)
|
|
|
|
|
(completion-def-wrapper 'beginning-of-buffer :under-or-before)
|
|
|
|
|
(completion-def-wrapper 'end-of-buffer :under-or-before)
|
|
|
|
|
(completion-def-wrapper 'beginning-of-line :under-or-before)
|
|
|
|
|
(completion-def-wrapper 'end-of-line :under-or-before)
|
|
|
|
|
(completion-def-wrapper 'forward-char :under-or-before)
|
|
|
|
|
(completion-def-wrapper 'forward-word :under-or-before)
|
|
|
|
|
(completion-def-wrapper 'forward-sexp :under-or-before)
|
|
|
|
|
(completion-def-wrapper 'backward-char :backward-under)
|
|
|
|
|
(completion-def-wrapper 'backward-word :backward-under)
|
|
|
|
|
(completion-def-wrapper 'backward-sexp :backward-under)
|
|
|
|
|
|
|
|
|
|
(completion-def-wrapper 'delete-backward-char :backward)
|
|
|
|
|
(completion-def-wrapper 'delete-backward-char-untabify :backward)
|
|
|
|
|
|
2018-04-20 22:55:04 +00:00
|
|
|
|
;; Old name, non-namespace-clean.
|
2005-11-28 01:43:28 +00:00
|
|
|
|
(defalias 'initialize-completions 'completion-initialize)
|
|
|
|
|
|
1996-04-16 16:04:01 +00:00
|
|
|
|
(provide 'completion)
|
|
|
|
|
|
1992-05-30 23:54:21 +00:00
|
|
|
|
;;; completion.el ends here
|