mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
* lisp/dabbrev.el: Fix cycle completion order.
(dabbrev--last-obarray, dabbrev--last-completion-buffer): Remove. (dabbrev-completion): Don't use an obarray; provide a cycle-sort-function. Fixes: debbugs:10963
This commit is contained in:
parent
e2f1fdab91
commit
225979daf9
2 changed files with 39 additions and 48 deletions
|
|
@ -1,3 +1,10 @@
|
|||
2012-03-12 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* dabbrev.el: Fix cycle completion order (bug#10963).
|
||||
(dabbrev--last-obarray, dabbrev--last-completion-buffer): Remove.
|
||||
(dabbrev-completion): Don't use an obarray; provide
|
||||
a cycle-sort-function.
|
||||
|
||||
2012-03-12 Leo Liu <sdl.web@gmail.com>
|
||||
|
||||
* simple.el (kill-new): Use equal-including-properties for
|
||||
|
|
|
|||
|
|
@ -291,9 +291,6 @@ this list."
|
|||
;; Internal variables
|
||||
;;----------------------------------------------------------------
|
||||
|
||||
;; Last obarray of completions in `dabbrev-completion'
|
||||
(defvar dabbrev--last-obarray nil)
|
||||
|
||||
;; Table of expansions seen so far
|
||||
(defvar dabbrev--last-table nil)
|
||||
|
||||
|
|
@ -321,9 +318,6 @@ this list."
|
|||
;; The buffer we found the expansion last time.
|
||||
(defvar dabbrev--last-buffer-found nil)
|
||||
|
||||
;; The buffer we last did a completion in.
|
||||
(defvar dabbrev--last-completion-buffer nil)
|
||||
|
||||
;; If non-nil, a function to use when copying successive words.
|
||||
;; It should be `upcase' or `downcase'.
|
||||
(defvar dabbrev--last-case-pattern nil)
|
||||
|
|
@ -393,47 +387,39 @@ then it searches *all* buffers."
|
|||
dabbrev-case-fold-search)
|
||||
(or (not dabbrev-upcase-means-case-search)
|
||||
(string= abbrev (downcase abbrev)))))
|
||||
(my-obarray dabbrev--last-obarray)
|
||||
(list 'uninitialized)
|
||||
(table
|
||||
(completion-table-dynamic
|
||||
(let ((initialized nil))
|
||||
(lambda (abbrev)
|
||||
(unless initialized
|
||||
(setq initialized t)
|
||||
(save-excursion
|
||||
;;--------------------------------
|
||||
;; New abbreviation to expand.
|
||||
;;--------------------------------
|
||||
(setq dabbrev--last-abbreviation abbrev)
|
||||
;; Find all expansion
|
||||
(let ((completion-list
|
||||
(dabbrev--find-all-expansions abbrev ignore-case-p))
|
||||
(completion-ignore-case ignore-case-p))
|
||||
;; Make an obarray with all expansions
|
||||
(setq my-obarray (make-vector (length completion-list) 0))
|
||||
(or (> (length my-obarray) 0)
|
||||
(error "No dynamic expansion for \"%s\" found%s"
|
||||
abbrev
|
||||
(if dabbrev--check-other-buffers
|
||||
"" " in this-buffer")))
|
||||
(cond
|
||||
((not (and ignore-case-p
|
||||
dabbrev-case-replace))
|
||||
(dolist (string completion-list)
|
||||
(intern string my-obarray)))
|
||||
((string= abbrev (upcase abbrev))
|
||||
(dolist (string completion-list)
|
||||
(intern (upcase string) my-obarray)))
|
||||
((string= (substring abbrev 0 1)
|
||||
(upcase (substring abbrev 0 1)))
|
||||
(dolist (string completion-list)
|
||||
(intern (capitalize string) my-obarray)))
|
||||
(t
|
||||
(dolist (string completion-list)
|
||||
(intern (downcase string) my-obarray))))
|
||||
(setq dabbrev--last-obarray my-obarray)
|
||||
(setq dabbrev--last-completion-buffer (current-buffer)))))
|
||||
my-obarray)))))
|
||||
(lambda (s p a)
|
||||
(if (eq a 'metadata)
|
||||
`(metadata (cycle-sort-function . ,#'identity)
|
||||
(category . dabbrev))
|
||||
(when (eq list 'uninitialized)
|
||||
(save-excursion
|
||||
;;--------------------------------
|
||||
;; New abbreviation to expand.
|
||||
;;--------------------------------
|
||||
(setq dabbrev--last-abbreviation abbrev)
|
||||
;; Find all expansion
|
||||
(let ((completion-list
|
||||
(dabbrev--find-all-expansions abbrev ignore-case-p))
|
||||
(completion-ignore-case ignore-case-p))
|
||||
(or (consp completion-list)
|
||||
(error "No dynamic expansion for \"%s\" found%s"
|
||||
abbrev
|
||||
(if dabbrev--check-other-buffers
|
||||
"" " in this-buffer")))
|
||||
(setq list
|
||||
(cond
|
||||
((not (and ignore-case-p dabbrev-case-replace))
|
||||
completion-list)
|
||||
((string= abbrev (upcase abbrev))
|
||||
(mapcar #'upcase completion-list))
|
||||
((string= (substring abbrev 0 1)
|
||||
(upcase (substring abbrev 0 1)))
|
||||
(mapcar #'capitalize completion-list))
|
||||
(t
|
||||
(mapcar #'downcase completion-list)))))))
|
||||
(complete-with-action a list s p)))))
|
||||
(completion-in-region beg end table)))
|
||||
|
||||
;;;###autoload
|
||||
|
|
@ -627,8 +613,6 @@ all skip characters."
|
|||
|
||||
(defun dabbrev--reset-global-variables ()
|
||||
"Initialize all global variables."
|
||||
;; dabbrev--last-obarray and dabbrev--last-completion-buffer
|
||||
;; must not be reset here.
|
||||
(setq dabbrev--last-table nil
|
||||
dabbrev--last-abbreviation nil
|
||||
dabbrev--last-abbrev-location nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue