[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/completion.el
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/completion.el |
Date: |
Wed, 05 Feb 2003 14:09:34 -0500 |
Index: emacs/lisp/completion.el
diff -c emacs/lisp/completion.el:1.46 emacs/lisp/completion.el:1.47
*** emacs/lisp/completion.el:1.46 Tue Feb 4 06:05:54 2003
--- emacs/lisp/completion.el Wed Feb 5 14:09:34 2003
***************
*** 75,81 ****
;; When you load this file, completion will be on. I suggest you use the
;; compiled version (because it is noticeably faster).
;;
! ;; M-X completion-mode toggles whether or not new words are added to the
;; database by changing the value of enable-completion.
;;
;; SAVING/LOADING COMPLETIONS
--- 75,81 ----
;; When you load this file, completion will be on. I suggest you use the
;; compiled version (because it is noticeably faster).
;;
! ;; M-x completion-mode toggles whether or not new words are added to the
;; database by changing the value of enable-completion.
;;
;; SAVING/LOADING COMPLETIONS
***************
*** 350,381 ****
;; "*The period in seconds to wait for emacs to be idle before autosaving
;;the completions. Default is a 1/2 hour.")
! (defconst completion-min-length nil ;; defined below in eval-when
"*The minimum length of a stored completion.
DON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.")
! (defconst completion-max-length nil ;; defined below in eval-when
"*The maximum length of a stored completion.
DON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.")
! (defconst completion-prefix-min-length nil ;; defined below in eval-when
"The minimum length of a completion search string.
DON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.")
- (defmacro eval-when-compile-load-eval (&rest body)
- ;; eval everything before expanding
- (mapcar 'eval body)
- (cons 'progn body))
-
- (defun completion-eval-when ()
- (eval-when-compile-load-eval
- ;; These vars. are defined at both compile and load time.
- (setq completion-min-length 6)
- (setq completion-max-length 200)
- (setq completion-prefix-min-length 3)))
-
- (completion-eval-when)
-
;;---------------------------------------------------------------------------
;; Internal Variables
;;---------------------------------------------------------------------------
--- 350,367 ----
;; "*The period in seconds to wait for emacs to be idle before autosaving
;;the completions. Default is a 1/2 hour.")
! (defvar completion-min-length 6
"*The minimum length of a stored completion.
DON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.")
! (defvar completion-max-length 200
"*The maximum length of a stored completion.
DON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.")
! (defvar completion-prefix-min-length 3
"The minimum length of a completion search string.
DON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.")
;;---------------------------------------------------------------------------
;; Internal Variables
;;---------------------------------------------------------------------------
***************
*** 397,414 ****
;;---------------------------------------------------------------------------
;;-----------------------------------------------
- ;; Misc.
- ;;-----------------------------------------------
-
- (defun minibuffer-window-selected-p ()
- "True iff the current window is the minibuffer."
- (window-minibuffer-p (selected-window)))
-
- ;; This used to be `(eval form)'. Eval FORM at run time now.
- (defmacro cmpl-read-time-eval (form)
- form)
-
- ;;-----------------------------------------------
;; String case coercion
;;-----------------------------------------------
--- 383,388 ----
***************
*** 592,598 ****
(defvar cmpl-saved-point nil)
(defun symbol-under-point ()
! "Returns the symbol that the point is currently on.
But only if it is longer than `completion-min-length'."
(setq cmpl-saved-syntax (syntax-table))
(unwind-protect
--- 566,572 ----
(defvar cmpl-saved-point nil)
(defun symbol-under-point ()
! "Return the symbol that the point is currently on.
But only if it is longer than `completion-min-length'."
(setq cmpl-saved-syntax (syntax-table))
(unwind-protect
***************
*** 617,626 ****
(setq cmpl-symbol-end (point))
(goto-char cmpl-saved-point)))
;; Return completion if the length is reasonable.
! (if (and (<= (cmpl-read-time-eval completion-min-length)
(- cmpl-symbol-end cmpl-symbol-start))
(<= (- cmpl-symbol-end cmpl-symbol-start)
! (cmpl-read-time-eval completion-max-length)))
(buffer-substring cmpl-symbol-start cmpl-symbol-end)))))
(set-syntax-table cmpl-saved-syntax)))
--- 591,600 ----
(setq cmpl-symbol-end (point))
(goto-char cmpl-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))
(buffer-substring cmpl-symbol-start cmpl-symbol-end)))))
(set-syntax-table cmpl-saved-syntax)))
***************
*** 637,643 ****
;;
(defun symbol-before-point ()
! "Returns a string of the symbol immediately before point.
Returns nil if there isn't one longer than `completion-min-length'."
;; This is called when a word separator is typed so it must be FAST !
(setq cmpl-saved-syntax (syntax-table))
--- 611,617 ----
;;
(defun symbol-before-point ()
! "Return a string of the symbol immediately before point.
Returns nil if there isn't one longer than `completion-min-length'."
;; This is called when a word separator is typed so it must be FAST !
(setq cmpl-saved-syntax (syntax-table))
***************
*** 657,664 ****
(goto-char cmpl-symbol-end)))
;; Return value if long enough.
(if (>= cmpl-symbol-end
! (+ cmpl-symbol-start
! (cmpl-read-time-eval completion-min-length)))
(buffer-substring cmpl-symbol-start cmpl-symbol-end)))
((= cmpl-preceding-syntax ?w)
;; chars to ignore at end
--- 631,637 ----
(goto-char cmpl-symbol-end)))
;; Return value if long enough.
(if (>= cmpl-symbol-end
! (+ cmpl-symbol-start completion-min-length))
(buffer-substring cmpl-symbol-start cmpl-symbol-end)))
((= cmpl-preceding-syntax ?w)
;; chars to ignore at end
***************
*** 675,684 ****
;; Restore state.
(goto-char cmpl-saved-point)
;; Return completion if the length is reasonable
! (if (and (<= (cmpl-read-time-eval completion-min-length)
(- cmpl-symbol-end cmpl-symbol-start))
(<= (- cmpl-symbol-end cmpl-symbol-start)
! (cmpl-read-time-eval completion-max-length)))
(buffer-substring cmpl-symbol-start cmpl-symbol-end)))))
(set-syntax-table cmpl-saved-syntax)))
--- 648,657 ----
;; Restore state.
(goto-char cmpl-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))
(buffer-substring cmpl-symbol-start cmpl-symbol-end)))))
(set-syntax-table cmpl-saved-syntax)))
***************
*** 734,744 ****
(setq cmpl-symbol-start (point))
(goto-char cmpl-symbol-end)))
;; Return completion if the length is reasonable.
! (if (and (<= (cmpl-read-time-eval
! completion-prefix-min-length)
(- cmpl-symbol-end cmpl-symbol-start))
(<= (- cmpl-symbol-end cmpl-symbol-start)
! (cmpl-read-time-eval completion-max-length)))
(buffer-substring cmpl-symbol-start cmpl-symbol-end)))))
;; Restore syntax table.
(set-syntax-table cmpl-saved-syntax)))
--- 707,716 ----
(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))
(buffer-substring cmpl-symbol-start cmpl-symbol-end)))))
;; Restore syntax table.
(set-syntax-table cmpl-saved-syntax)))
***************
*** 833,839 ****
(defun reset-cdabbrev (abbrev-string &optional initial-completions-tried)
! "Resets the cdabbrev search to search for abbrev-string.
INITIAL-COMPLETIONS-TRIED is a list of downcased strings to ignore
during the search."
(setq cdabbrev-abbrev-string abbrev-string
--- 805,811 ----
(defun reset-cdabbrev (abbrev-string &optional initial-completions-tried)
! "Reset the cdabbrev search to search for ABBREV-STRING.
INITIAL-COMPLETIONS-TRIED is a list of downcased strings to ignore
during the search."
(setq cdabbrev-abbrev-string abbrev-string
***************
*** 849,855 ****
(defun reset-cdabbrev-window (&optional initializep)
! "Resets the cdabbrev search to search for abbrev-string."
;; Set the window
(cond (initializep
(setq cdabbrev-current-window (selected-window)))
--- 821,827 ----
(defun reset-cdabbrev-window (&optional initializep)
! "Reset the cdabbrev search to search for abbrev-string."
;; Set the window
(cond (initializep
(setq cdabbrev-current-window (selected-window)))
***************
*** 1037,1043 ****
;; CONSTRUCTOR
(defun make-completion (string)
! "Returns a list of a completion entry."
(list (list string 0 nil current-completion-source)))
;; Obsolete
--- 1009,1015 ----
;; CONSTRUCTOR
(defun make-completion (string)
! "Return a list of a completion entry."
(list (list string 0 nil current-completion-source)))
;; Obsolete
***************
*** 1070,1076 ****
;; Constructor
(defun make-cmpl-prefix-entry (completion-entry-list)
! "Makes a new prefix entry containing only completion-entry."
(cons completion-entry-list completion-entry-list))
;;-----------------------------------------------
--- 1042,1048 ----
;; Constructor
(defun make-cmpl-prefix-entry (completion-entry-list)
! "Make a new prefix entry containing only completion-entry."
(cons completion-entry-list completion-entry-list))
;;-----------------------------------------------
***************
*** 1221,1228 ****
;; setup the prefix
(prefix-entry (find-cmpl-prefix-entry
(substring cmpl-db-downcase-string 0
! (cmpl-read-time-eval
! completion-prefix-min-length)))))
;; 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
--- 1193,1199 ----
;; setup the prefix
(prefix-entry (find-cmpl-prefix-entry
(substring cmpl-db-downcase-string 0
! completion-prefix-min-length))))
;; 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
***************
*** 1253,1260 ****
;; found
(let* ((prefix-entry (find-cmpl-prefix-entry
(substring cmpl-db-downcase-string 0
! (cmpl-read-time-eval
! completion-prefix-min-length))))
(splice-ptr (locate-completion-entry cmpl-db-entry prefix-entry))
(cmpl-ptr (cdr splice-ptr)))
;; update entry
--- 1224,1230 ----
;; found
(let* ((prefix-entry (find-cmpl-prefix-entry
(substring cmpl-db-downcase-string 0
! completion-prefix-min-length)))
(splice-ptr (locate-completion-entry cmpl-db-entry prefix-entry))
(cmpl-ptr (cdr splice-ptr)))
;; update entry
***************
*** 1277,1284 ****
;; setup the prefix
(prefix-entry (find-cmpl-prefix-entry
(substring cmpl-db-downcase-string 0
! (cmpl-read-time-eval
! completion-prefix-min-length)))))
(cond (prefix-entry
;; Splice in at head
(setcdr entry (cmpl-prefix-entry-head prefix-entry))
--- 1247,1253 ----
;; 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))
***************
*** 1301,1308 ****
;; found
(let* ((prefix-entry (find-cmpl-prefix-entry
(substring cmpl-db-downcase-string 0
! (cmpl-read-time-eval
! completion-prefix-min-length))))
(splice-ptr (locate-completion-entry cmpl-db-entry prefix-entry)))
;; delete symbol reference
(set cmpl-db-symbol nil)
--- 1270,1276 ----
;; found
(let* ((prefix-entry (find-cmpl-prefix-entry
(substring cmpl-db-downcase-string 0
! completion-prefix-min-length)))
(splice-ptr (locate-completion-entry cmpl-db-entry prefix-entry)))
;; delete symbol reference
(set cmpl-db-symbol nil)
***************
*** 1577,1583 ****
(defun completion-search-peek (use-cdabbrev)
! "Returns the next completion entry without actually moving the pointers.
Calling this again or calling `completion-search-next' results in the same
string being returned. Depends on `case-fold-search'.
If there are no more entries, try cdabbrev and then return only a string."
--- 1545,1551 ----
(defun completion-search-peek (use-cdabbrev)
! "Return the next completion entry without actually moving the pointers.
Calling this again or calling `completion-search-next' results in the same
string being returned. Depends on `case-fold-search'.
If there are no more entries, try cdabbrev and then return only a string."
***************
*** 1707,1713 ****
;; Get the next completion
(let* ((print-status-p
(and (>= baud-rate completion-prompt-speed-threshold)
! (not (minibuffer-window-selected-p))))
(insert-point (point))
(entry (completion-search-next cmpl-current-index))
string)
--- 1675,1681 ----
;; Get the next completion
(let* ((print-status-p
(and (>= baud-rate completion-prompt-speed-threshold)
! (not (window-minibuffer-p (selected-window)))))
(insert-point (point))
(entry (completion-search-next cmpl-current-index))
string)
***************
*** 2266,2272 ****
(defun initialize-completions ()
"Load the default completions file.
! Also sets up so that exiting emacs will automatically save the file."
(interactive)
(cond ((not cmpl-initialized-p)
(load-completions-from-file)))
--- 2234,2240 ----
(defun initialize-completions ()
"Load the default completions file.
! Also sets up so that exiting Emacs will automatically save the file."
(interactive)
(cond ((not cmpl-initialized-p)
(load-completions-from-file)))
***************
*** 2531,2538 ****
(initialize-completions))
! (mapc (lambda (x)
! (add-to-list 'debug-ignored-errors x))
'("^To complete, the point must be after a symbol at least [0-9]*
character long\\.$"
"^The string \".*\" is too short to be saved as a completion\\.$"))
--- 2499,2505 ----
(initialize-completions))
! (mapc (lambda (x) (add-to-list 'debug-ignored-errors x))
'("^To complete, the point must be after a symbol at least [0-9]*
character long\\.$"
"^The string \".*\" is too short to be saved as a completion\\.$"))