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

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

bug#1797: 23.0.60; completing-read breaks backwards compatibility


From: Stefan Monnier
Subject: bug#1797: 23.0.60; completing-read breaks backwards compatibility
Date: Mon, 05 Jan 2009 23:24:54 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>> The intention is for it to 100% backwards compatible. So please
>> report this bug.

> Here we go.
> To reproduce the problem, eval the following code:

Thanks.  I installed a change which I believe should fix this bug.
Note that your completion function is a prime example of a completion
table that needs completion-boundaries in order to work right.
E.g. with the function as it is defined, the *Completions* buffer has
several bugs: clicking on "bar" will replace "foo ba" with "bar" rather
than with "foo bar", and the completions-common-part hilighting
is incorrect.

If you add the code below:

> (defun my-complete (s pred mode)
>   (string-match "^\\(.*\\s-\\)?\\(.*\\)$" s)
>   (let* ((s1 (match-string 1 s))
>        (s2 (match-string 2 s))
>        (c2 (funcall
>             (cond ((null mode) 'try-completion)
>                   ((eq mode t) 'all-completions)
>                   ((eq mode 'lambda)
>                    (if (fboundp 'test-completion)
>                        'test-completion
>                      ;; XEmacs doesn't have test-completion
>                      (lambda (&rest args)
>                        (eq (apply 'try-completion args) t))))

                    ((eq (car-safe mode) 'boundaries)
                     (lexical-let* ((suffix (cdr mode))
                                    (start (or (match-end 1) 0))
                                    (end (string-match "\\s-" suffix)))
                       (lambda (s table pred)
                         `(boundaries ,start . ,end))))

>                   (t 'ignore))
>             s2
>             (mapcar (lambda (x) (list (concat x " ")))
>                     my-keywords)
>             pred)))
>     (if (stringp c2) (concat s1 c2) c2)))

You'll see that the completions-common-part highlighting is correct, and
you can even complete "fo ba" to "foo ba" if point is after "fo" when
you hit TAB.


        Stefan






reply via email to

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