emacs-devel
[Top][All Lists]
Advanced

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

Re: completing-read case problem


From: Stefan Monnier
Subject: Re: completing-read case problem
Date: Mon, 15 Nov 2004 17:06:34 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

How 'bout the patch below, which is a free adaptation from my elisp code

  ...
  (cond
   ((or (= (field-beginning) (field-end))
        (test-completion (field-string)
                         minibuffer-completion-table
                         minibuffer-completion-predicate))
    (when completion-ignore-case
      ;; Fixup case of the field, if necessary.
      (let* ((string (field-string))
             (compl (try-completion string
                                    minibuffer-completion-table
                                    minibuffer-completion-predicate)))
        (if (and (stringp string)
                 ;; If it weren't for this piece of paranoia, I'd replace
                 ;; the whole thing with a call to complete-do-completion.
                 (= (length string) (length compl)))
            (let ((beg (field-beginning))
                  (end (field-end)))
              (goto-char end)
              (insert compl)
              (delete-region beg end)))))
    (exit-minibuffer))
   ...


        Stefan


--- minibuf.c   15 nov 2004 10:41:18 -0500      1.273
+++ minibuf.c   15 nov 2004 16:57:59 -0500      
@@ -2076,10 +2076,27 @@
   if (XINT (Fminibuffer_prompt_end ()) == ZV)
     goto exit;
 
-  if (!NILP (Ftest_completion (Fminibuffer_contents (),
+  if (!NILP (Ftest_completion (val = Fminibuffer_contents (),
                               Vminibuffer_completion_table,
                               Vminibuffer_completion_predicate)))
+    {
+      if (completion_ignore_case)
+       { /* Fixup case of the field, if necessary. */
+         Lisp_Object compl
+           = Ftry_completion (val,
+                              Vminibuffer_completion_table,
+                              Vminibuffer_completion_predicate);
+         if (STRINGP (compl)
+             /* If it weren't for this piece of paranoia, I'd replace
+                the whole thing with a call to do_completion. */
+             && EQ (Flength (val), Flength (compl)))
+           {
+             del_range (XINT (Fminibuffer_prompt_end ()), ZV);
+             Finsert (1, &compl);
+           }
+       }
     goto exit;
+    }
 
   /* Call do_completion, but ignore errors.  */
   SET_PT (ZV);




reply via email to

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