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

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

Re: Partial completion and completions-first-difference.


From: Stefan Monnier
Subject: Re: Partial completion and completions-first-difference.
Date: Tue, 08 Nov 2005 17:15:06 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>     An easy fix is to turn off the boldening if partial-completion-mode is ON
>     and the string starts with a - (or maybe even turn it OFF altogether
>     whenever partial-completion-mode is ON).

> A week from now, if nobody has proposed a better solution, would you
> please do that?

How 'bout the patch below?
It does the following:
- try and fix the problem with the leading -
- add a reminder about the fact that it's the wrong place to fix
  the problem.
- change handling of the completion-base-size-function property so it's also
  obeyed if minibuffer-completing-file-name.
- add a comment about the fact that completion-base-size-function receives
  very little info, making it potentially difficult for it to do its job.

Regarding this last point, we could use a convention like "all-completions
can return a list whose last cdr is not nil but an integer (the
completion-base-size)" or some other way to return that info on the side.


        Stefan


PS: guaranteed 100% untested patch:

*** simple.el   03 nov 2005 23:31:05 -0500      1.761
--- simple.el   08 nov 2005 17:10:41 -0500      
***************
*** 4908,4938 ****
          (setq default-directory (file-name-directory mbuf-contents))))
      ;; If partial-completion-mode is on, point might not be after the
      ;; last character in the minibuffer.
!     ;; FIXME: This still doesn't work if the text to be completed
!     ;; starts with a `-'.
!     (when (and partial-completion-mode (not (eobp)))
        (setq common-string-length
!             (- common-string-length (- (point) (point-max)))))
      (with-current-buffer standard-output
        (completion-list-mode)
        (set (make-local-variable 'completion-reference-buffer) mainbuf)
-       (if minibuffer-completing-file-name
-         ;; For file name completion,
-         ;; use the number of chars before the start of the
-         ;; last file name component.
          (setq completion-base-size
                (with-current-buffer mainbuf
                  (save-excursion
                    (goto-char (point-max))
                    (skip-chars-backward completion-root-regexp)
!                   (- (point) (minibuffer-prompt-end)))))
        ;; Otherwise, in minibuffer, the whole input is being completed.
!       (if (minibufferp mainbuf)
            (if (and (symbolp minibuffer-completion-table)
                     (get minibuffer-completion-table 
'completion-base-size-function))
                (setq completion-base-size
!                     (funcall (get minibuffer-completion-table 
'completion-base-size-function)))
!             (setq completion-base-size 0))))
        ;; Put faces on first uncommon characters and common parts.
        (when (or completion-common-substring completion-base-size)
          (setq common-string-length
--- 4908,4949 ----
          (setq default-directory (file-name-directory mbuf-contents))))
      ;; If partial-completion-mode is on, point might not be after the
      ;; last character in the minibuffer.
!     ;; FIXME: This hack should be moved to complete.el's where we call
!     ;; display-completion-list.
!     (when partial-completion-mode
        (setq common-string-length
!             (if (eq (char-after (field-beginning)) ?-)
!                 ;; If the text to be completed starts with a `-', there is no
!                 ;; common prefix.
!                 ;; FIXME: this probably still doesn't do the right thing
!                 ;; when completing file names.  It's not even clear what
!                 ;; is TRT.
!                 0
!               (- common-string-length (- (point) (point-max))))))
      (with-current-buffer standard-output
        (completion-list-mode)
        (set (make-local-variable 'completion-reference-buffer) mainbuf)
          (setq completion-base-size
+             (if minibuffer-completing-file-name
+                 ;; For file name completion, use the number of chars before
+                 ;; the start of the last file name component.
                (with-current-buffer mainbuf
                  (save-excursion
                    (goto-char (point-max))
                    (skip-chars-backward completion-root-regexp)
!                   (- (point) (minibuffer-prompt-end))))
        ;; Otherwise, in minibuffer, the whole input is being completed.
!               (if (minibufferp mainbuf) 0)))
            (if (and (symbolp minibuffer-completion-table)
                     (get minibuffer-completion-table 
'completion-base-size-function))
                (setq completion-base-size
!                 ;; FIXME: without any extra arg, how is this function
!                 ;; expected to return anything else than a constant ????
!                 ;; In most cases this value would better be computed and
!                 ;; returned at the same time as the list of all-completions
!                 ;; is computed.  --Stef
!                 (funcall (get minibuffer-completion-table
!                               'completion-base-size-function))))
        ;; Put faces on first uncommon characters and common parts.
        (when (or completion-common-substring completion-base-size)
          (setq common-string-length




reply via email to

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