emacs-devel
[Top][All Lists]
Advanced

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

Re: 23.0.50; PC-do-completion should fix case if possible


From: Denis Howe
Subject: Re: 23.0.50; PC-do-completion should fix case if possible
Date: Wed, 3 Oct 2007 12:00:09 +0100

This is an improved version of my report sent yesterday.

In the latest complete.el from CVS (v1.79),
function "PC-do-completion" fails to correct
the case of the input being completed when:

- "completion-ignore-case" is true and
- "read-file-name-completion-ignore-case" is true and
- all possible completions have the same case

Ordinary completion preserves input case only where the
potential completions differ in case.  If they agree then ordinary
completion changes the input case to that of the prefix.

For example, evaluate:

(partial-completion-mode 0)
(setq completion-ignore-case t)
(completing-read "Input: " '(("Den".1)("Denis".2)) nil t "d")

Hitting TAB runs ordinary "minibuffer-complete"
which completes "d" to "Den" (case corrected).

Enable partial completion:

(partial-completion-mode 1)

Re-evaluate the above completing-read.

Hitting TAB now runs "PC-complete" which
completes "d" to "den" (fails to correct input case).

I've tested the attached patch thoroughly.
Please contact me if you want any more background on this.

------------------------------------------------------------

ChangeLog entry:

2007-10-03  Denis Howe  <address@hidden>

        * complete.el (PC-do-completion): Correct case when unambiguous.

------------------------------------------------------------

diff -cw GNU/complete.el Fix/complete.el
*** GNU/complete.el     2007-10-03 11:33:55.000000000 +0100
--- Fix/complete.el     2007-09-19 17:15:12.000000000 +0100
***************
*** 731,738 ****
                     (setq prefix (PC-try-completion
                                   (PC-chunk-after basestr skip) poss)))
                (let ((first t) i)
-                 ;; Retain capitalization of user input even if
-                 ;; completion-ignore-case is set.
                  (if (eq mode 'word)
                      (setq prefix (PC-chop-word prefix basestr)))
                  (goto-char (+ beg (length dirname)))
--- 731,736 ----
***************
*** 740,754 ****
                                (setq i 0) ; index into prefix string
                                (while (< i (length prefix))
                                  (if (and (< (point) end)
                                           (eq (downcase (aref prefix i))
!                                              (downcase (following-char))))
!                                     ;; same char (modulo case); no action
!                                     (forward-char 1)
!                                   (if (and (< (point) end)
                                             (and (looking-at " ")
                                                    (memq (aref prefix i)
!                                                       PC-delims-list)))
                                        ;; replace " " by the actual delimiter
                                        (progn
                                          (delete-char 1)
                                          (insert (substring prefix i (1+ i))))
--- 738,751 ----
                                  (setq i 0) ; index into prefix string
                                  (while (< i (length prefix))
                                    (if (and (< (point) end)
+                                            (or
                                              (eq (downcase (aref prefix i))
!                                                 (downcase (following-char)))
                                              (and (looking-at " ")
                                                   (memq (aref prefix i)
!                                                        PC-delims-list))))
                                        ;; replace " " by the actual delimiter
+                                       ;; or input char by prefix char
                                        (progn
                                          (delete-char 1)
                                          (insert (substring prefix i (1+ i))))
***************
*** 760,766 ****
                                                 (setq end (1- end))))
                                        (setq improved t)
                                          (insert (substring prefix i (1+ i)))
!                                       (setq end (1+ end)))))
                                  (setq i (1+ i)))
                                (or pt (setq pt (point)))
                                (looking-at PC-delim-regex))
--- 757,763 ----
                                               (setq end (1- end))))
                                        (setq improved t)
                                        (insert (substring prefix i (1+ i)))
!                                       (setq end (1+ end))))
                                    (setq i (1+ i)))
                                  (or pt (setq pt (point)))
                                  (looking-at PC-delim-regex))

------------------------------------------------------------




reply via email to

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