unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1976: 23.0.50; PC-do-completion should fix case if possible
       [not found]   ` <ddae169d0710030400j4eecd40ap101edf50296971db@mail.gmail.com>
@ 2009-01-21 14:42     ` Denis Howe
  2009-01-21 22:13       ` Stefan Monnier
  2009-01-28 15:45       ` bug#1976: marked as done (23.0.50; PC-do-completion should fix case if possible) Emacs bug Tracking System
  0 siblings, 2 replies; 4+ messages in thread
From: Denis Howe @ 2009-01-21 14:42 UTC (permalink / raw)
  To: emacs-pretest-bug

[-- Attachment #1: Type: text/plain, Size: 4835 bytes --]

My 2007-10-03 attempt to get this patch applied got no further than RMS's
request for someone to DTRT.  It took several hours of my time to debug and
test, and the bug still bites me every time I re-install, so PLEASE could
someone apply it?  Thanks.
------------------------------------------------------------
In the latest complete.el from CVS (v1.94), 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:

2009-01-21  Denis Howe <denis.howe@gmail.com>

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

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

cvs diff -cw complete.el
Index: complete.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/complete.el,v
retrieving revision 1.94
diff -c -w -r1.94 complete.el
*** complete.el    9 Jan 2009 04:44:19 -0000    1.94
--- complete.el    21 Jan 2009 14:21:17 -0000
***************
*** 737,744 ****
               (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)))
--- 737,742 ----
***************
*** 746,760 ****
                  (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))))
--- 744,757 ----
                  (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))))
***************
*** 766,772 ****
                                                 (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))
--- 763,769 ----
                                                 (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))

------------------------------------------------------------
End

-- Denis Howe <denis.howe@gmail.com>

[-- Attachment #2: Type: text/html, Size: 11236 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#1976: 23.0.50; PC-do-completion should fix case if possible
  2009-01-21 14:42     ` bug#1976: 23.0.50; PC-do-completion should fix case if possible Denis Howe
@ 2009-01-21 22:13       ` Stefan Monnier
  2009-01-21 23:09         ` Denis Howe
  2009-01-28 15:45       ` bug#1976: marked as done (23.0.50; PC-do-completion should fix case if possible) Emacs bug Tracking System
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2009-01-21 22:13 UTC (permalink / raw)
  To: Denis Howe; +Cc: emacs-pretest-bug, 1976

> My 2007-10-03 attempt to get this patch applied got no further than RMS's
> request for someone to DTRT.  It took several hours of my time to debug and
> test, and the bug still bites me every time I re-install, so PLEASE could
> someone apply it?  Thanks.

BTW, the default completion in Emacs-23 is very close to
partial-completion-mode.  More to the point, if you remove `basic' from
`completion-styles', it should be pretty much identical except for the
following known differences:
- no <foo.h> style completion for file names.
- M-x lch TAB doesn't know how to expand to `list-command-history'.
And even if you don't remove `basic', the behavior is fairly close.
Also it should fix the problem you're reporting and provides
a few improvements.

Since partial-completion-mode is slated for obsolescence (tho not
marked obsolete yet), I'm interested to hear if you find some other
missing feature.


        Stefan






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#1976: 23.0.50; PC-do-completion should fix case if possible
  2009-01-21 22:13       ` Stefan Monnier
@ 2009-01-21 23:09         ` Denis Howe
  0 siblings, 0 replies; 4+ messages in thread
From: Denis Howe @ 2009-01-21 23:09 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-pretest-bug, 1976

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

2009/1/21 Stefan Monnier <monnier@iro.umontreal.ca>

> the default completion in Emacs-23 is very close to partial-completion-mode


OMG, so it is!   I've been using partial-completion-mode so long I can't
remember why I turned it on.  What's even stupider is that I've never
actually used the "partial" feature.  Thanks very much for the
enlightenment.

[-- Attachment #2: Type: text/html, Size: 676 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#1976: marked as done (23.0.50; PC-do-completion should fix  case if possible)
  2009-01-21 14:42     ` bug#1976: 23.0.50; PC-do-completion should fix case if possible Denis Howe
  2009-01-21 22:13       ` Stefan Monnier
@ 2009-01-28 15:45       ` Emacs bug Tracking System
  1 sibling, 0 replies; 4+ messages in thread
From: Emacs bug Tracking System @ 2009-01-28 15:45 UTC (permalink / raw)
  To: Chong Yidong

[-- Attachment #1: Type: text/plain, Size: 892 bytes --]


Your message dated Wed, 28 Jan 2009 10:36:04 -0500
with message-id <87bptr1lzv.fsf@cyd.mit.edu>
and subject line Re: 23.0.50; PC-do-completion should fix case if possible
has caused the Emacs bug report #1976,
regarding 23.0.50; PC-do-completion should fix case if possible
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@emacsbugs.donarmstrong.com
immediately.)


-- 
1976: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=1976
Emacs Bug Tracking System
Contact owner@emacsbugs.donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 19792 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 4835 bytes --]

My 2007-10-03 attempt to get this patch applied got no further than RMS's
request for someone to DTRT.  It took several hours of my time to debug and
test, and the bug still bites me every time I re-install, so PLEASE could
someone apply it?  Thanks.
------------------------------------------------------------
In the latest complete.el from CVS (v1.94), 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:

2009-01-21  Denis Howe <denis.howe@gmail.com>

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

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

cvs diff -cw complete.el
Index: complete.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/complete.el,v
retrieving revision 1.94
diff -c -w -r1.94 complete.el
*** complete.el    9 Jan 2009 04:44:19 -0000    1.94
--- complete.el    21 Jan 2009 14:21:17 -0000
***************
*** 737,744 ****
               (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)))
--- 737,742 ----
***************
*** 746,760 ****
                  (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))))
--- 744,757 ----
                  (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))))
***************
*** 766,772 ****
                                                 (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))
--- 763,769 ----
                                                 (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))

------------------------------------------------------------
End

-- Denis Howe <denis.howe@gmail.com>

[-- Attachment #2.1.2: Type: text/html, Size: 11236 bytes --]

[-- Attachment #3: Type: message/rfc822, Size: 1453 bytes --]

From: Chong Yidong <cyd@stupidchicken.com>
To: Denis Howe <denis.howe@gmail.com>
Cc: 1976-done@emacsbugs.donarmstrong.com
Subject: Re: 23.0.50; PC-do-completion should fix case if possible
Date: Wed, 28 Jan 2009 10:36:04 -0500
Message-ID: <87bptr1lzv.fsf@cyd.mit.edu>

> > the default completion in Emacs-23 is very close to
> > partial-completion-mode
>
> OMG, so it is!  I've been using partial-completion-mode so long I
> can't remember why I turned it on.  What's even stupider is that I've
> never actually used the "partial" feature.  Thanks very much for the
> enlightenment.

In any case, I've checked in your patch to complete.el.  Thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-28 15:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ddae169d0710020722o2efaecdfq45a98db1cd463d2d@mail.gmail.com>
     [not found] ` <E1Icplo-0008E5-OJ@fencepost.gnu.org>
     [not found]   ` <ddae169d0710030400j4eecd40ap101edf50296971db@mail.gmail.com>
2009-01-21 14:42     ` bug#1976: 23.0.50; PC-do-completion should fix case if possible Denis Howe
2009-01-21 22:13       ` Stefan Monnier
2009-01-21 23:09         ` Denis Howe
2009-01-28 15:45       ` bug#1976: marked as done (23.0.50; PC-do-completion should fix case if possible) Emacs bug Tracking System

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).