aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/dabbrev.el80
2 files changed, 39 insertions, 48 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4f883b1cf94..0032e07074c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12012-03-12 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * dabbrev.el: Fix cycle completion order (bug#10963).
4 (dabbrev--last-obarray, dabbrev--last-completion-buffer): Remove.
5 (dabbrev-completion): Don't use an obarray; provide
6 a cycle-sort-function.
7
12012-03-12 Leo Liu <sdl.web@gmail.com> 82012-03-12 Leo Liu <sdl.web@gmail.com>
2 9
3 * simple.el (kill-new): Use equal-including-properties for 10 * simple.el (kill-new): Use equal-including-properties for
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el
index 825402228e1..c5b370bfa61 100644
--- a/lisp/dabbrev.el
+++ b/lisp/dabbrev.el
@@ -291,9 +291,6 @@ this list."
291;; Internal variables 291;; Internal variables
292;;---------------------------------------------------------------- 292;;----------------------------------------------------------------
293 293
294;; Last obarray of completions in `dabbrev-completion'
295(defvar dabbrev--last-obarray nil)
296
297;; Table of expansions seen so far 294;; Table of expansions seen so far
298(defvar dabbrev--last-table nil) 295(defvar dabbrev--last-table nil)
299 296
@@ -321,9 +318,6 @@ this list."
321;; The buffer we found the expansion last time. 318;; The buffer we found the expansion last time.
322(defvar dabbrev--last-buffer-found nil) 319(defvar dabbrev--last-buffer-found nil)
323 320
324;; The buffer we last did a completion in.
325(defvar dabbrev--last-completion-buffer nil)
326
327;; If non-nil, a function to use when copying successive words. 321;; If non-nil, a function to use when copying successive words.
328;; It should be `upcase' or `downcase'. 322;; It should be `upcase' or `downcase'.
329(defvar dabbrev--last-case-pattern nil) 323(defvar dabbrev--last-case-pattern nil)
@@ -393,47 +387,39 @@ then it searches *all* buffers."
393 dabbrev-case-fold-search) 387 dabbrev-case-fold-search)
394 (or (not dabbrev-upcase-means-case-search) 388 (or (not dabbrev-upcase-means-case-search)
395 (string= abbrev (downcase abbrev))))) 389 (string= abbrev (downcase abbrev)))))
396 (my-obarray dabbrev--last-obarray) 390 (list 'uninitialized)
397 (table 391 (table
398 (completion-table-dynamic 392 (lambda (s p a)
399 (let ((initialized nil)) 393 (if (eq a 'metadata)
400 (lambda (abbrev) 394 `(metadata (cycle-sort-function . ,#'identity)
401 (unless initialized 395 (category . dabbrev))
402 (setq initialized t) 396 (when (eq list 'uninitialized)
403 (save-excursion 397 (save-excursion
404 ;;-------------------------------- 398 ;;--------------------------------
405 ;; New abbreviation to expand. 399 ;; New abbreviation to expand.
406 ;;-------------------------------- 400 ;;--------------------------------
407 (setq dabbrev--last-abbreviation abbrev) 401 (setq dabbrev--last-abbreviation abbrev)
408 ;; Find all expansion 402 ;; Find all expansion
409 (let ((completion-list 403 (let ((completion-list
410 (dabbrev--find-all-expansions abbrev ignore-case-p)) 404 (dabbrev--find-all-expansions abbrev ignore-case-p))
411 (completion-ignore-case ignore-case-p)) 405 (completion-ignore-case ignore-case-p))
412 ;; Make an obarray with all expansions 406 (or (consp completion-list)
413 (setq my-obarray (make-vector (length completion-list) 0)) 407 (error "No dynamic expansion for \"%s\" found%s"
414 (or (> (length my-obarray) 0) 408 abbrev
415 (error "No dynamic expansion for \"%s\" found%s" 409 (if dabbrev--check-other-buffers
416 abbrev 410 "" " in this-buffer")))
417 (if dabbrev--check-other-buffers 411 (setq list
418 "" " in this-buffer"))) 412 (cond
419 (cond 413 ((not (and ignore-case-p dabbrev-case-replace))
420 ((not (and ignore-case-p 414 completion-list)
421 dabbrev-case-replace)) 415 ((string= abbrev (upcase abbrev))
422 (dolist (string completion-list) 416 (mapcar #'upcase completion-list))
423 (intern string my-obarray))) 417 ((string= (substring abbrev 0 1)
424 ((string= abbrev (upcase abbrev)) 418 (upcase (substring abbrev 0 1)))
425 (dolist (string completion-list) 419 (mapcar #'capitalize completion-list))
426 (intern (upcase string) my-obarray))) 420 (t
427 ((string= (substring abbrev 0 1) 421 (mapcar #'downcase completion-list)))))))
428 (upcase (substring abbrev 0 1))) 422 (complete-with-action a list s p)))))
429 (dolist (string completion-list)
430 (intern (capitalize string) my-obarray)))
431 (t
432 (dolist (string completion-list)
433 (intern (downcase string) my-obarray))))
434 (setq dabbrev--last-obarray my-obarray)
435 (setq dabbrev--last-completion-buffer (current-buffer)))))
436 my-obarray)))))
437 (completion-in-region beg end table))) 423 (completion-in-region beg end table)))
438 424
439;;;###autoload 425;;;###autoload
@@ -627,8 +613,6 @@ all skip characters."
627 613
628(defun dabbrev--reset-global-variables () 614(defun dabbrev--reset-global-variables ()
629 "Initialize all global variables." 615 "Initialize all global variables."
630 ;; dabbrev--last-obarray and dabbrev--last-completion-buffer
631 ;; must not be reset here.
632 (setq dabbrev--last-table nil 616 (setq dabbrev--last-table nil
633 dabbrev--last-abbreviation nil 617 dabbrev--last-abbreviation nil
634 dabbrev--last-abbrev-location nil 618 dabbrev--last-abbrev-location nil