GNU bug report logs - #1797
23.0.60; completing-read breaks backwards compatibility

Previous Next

Package: emacs;

Reported by: Ulrich Mueller <ulm <at> gentoo.org>

Date: Tue, 6 Jan 2009 00:00:02 UTC

Severity: normal

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

Full log


Message #10 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ulrich Mueller <ulm <at> gentoo.org>
Cc: 1797 <at> debbugs.gnu.org, emacs-pretest-bug <at> gnu.org
Subject: Re: bug#1797: 23.0.60; completing-read breaks backwards compatibility
Date: Mon, 05 Jan 2009 23:24:54 -0500
>> 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




This bug report was last modified 16 years and 183 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.