emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Partial completion


From: Glenn Morris
Subject: Re: Partial completion
Date: Mon, 05 Mar 2007 16:09:35 -0500
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

Here's a somewhat more tested patch. The problem in question is caused
by a change in the behaviour of try-completion between 21 and 22.

(try-completion "foo" '(("foo") ("foo")))

returns "foo" in 21, but t in 22. I don't know if this is a correct
interpretation of the doc-string's "unique match which is exact" or
not.

The (1- beg) part of the patch prevents PC-lisp-complete-symbol
erasing the whole buffer, which it seems to do in 21.4 as well...

Could someone familiar with complete.el comment on this?


Index: complete.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/complete.el,v
retrieving revision 1.60
diff -c -c -w -r1.60 complete.el
*** complete.el 5 Mar 2007 14:55:05 -0000       1.60
--- complete.el 5 Mar 2007 21:07:43 -0000
***************
*** 624,630 ****
  
          ;; If ambiguous, try for a partial completion
          (let ((improved nil)
!               prefix
                (pt nil)
                (skip "\\`"))
  
--- 624,630 ----
  
          ;; If ambiguous, try for a partial completion
          (let ((improved nil)
!               prefix chunk
                (pt nil)
                (skip "\\`"))
  
***************
*** 669,686 ****
                              (setq skip (concat skip
                                                 (regexp-quote prefix)
                                                 PC-ndelims-regex)
!                                   prefix (try-completion
!                                           (PC-chunk-after
                                             ;; not basestr, because that does
                                             ;; not reflect insertions
                                             (buffer-substring
                                              (+ beg (length dirname)) end)
                                             skip)
                                            (mapcar
                                               (lambda (x)
                                                 (when (string-match skip x)
                                                   (substring x (match-end 0))))
                                             poss)))
                              (or (> i 0) (> (length prefix) 0))
                              (or (not (eq mode 'word))
                                  (and first (> (length prefix) 0)
--- 669,690 ----
                              (setq skip (concat skip
                                                 (regexp-quote prefix)
                                                 PC-ndelims-regex)
!                                     chunk (PC-chunk-after
                                             ;; not basestr, because that does
                                             ;; not reflect insertions
                                             (buffer-substring
                                              (+ beg (length dirname)) end)
                                             skip)
+                                   prefix (try-completion
+                                             chunk
                                            (mapcar
                                               (lambda (x)
                                                 (when (string-match skip x)
                                                   (substring x (match-end 0))))
                                             poss)))
+                               ;; try-completion returns t if chunk is
+                               ;; an exact match.
+                               (if (eq prefix t) (setq prefix chunk))
                              (or (> i 0) (> (length prefix) 0))
                              (or (not (eq mode 'word))
                                  (and first (> (length prefix) 0)
***************
*** 716,722 ****
                        ;; Record which part of the buffer we are completing
                        ;; so that choosing a completion from the list
                        ;; knows how much old text to replace.
!                       (setq completion-base-size dirlength)))
                  (PC-temp-minibuffer-message " [Next char not unique]"))
                nil)))))
  
--- 720,728 ----
                        ;; Record which part of the buffer we are completing
                        ;; so that choosing a completion from the list
                        ;; knows how much old text to replace.
!                       (setq completion-base-size (if dirname
!                                                        dirlength
!                                                      (1- beg)))))
                  (PC-temp-minibuffer-message " [Next char not unique]"))
                nil)))))
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]