* bug#1797: 23.0.60; completing-read breaks backwards compatibility
@ 2009-01-05 23:53 Ulrich Mueller
2009-01-06 4:24 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Mueller @ 2009-01-05 23:53 UTC (permalink / raw)
To: emacs-pretest-bug
>>>>> On Mon, 05 Jan 2009, Stefan Monnier wrote:
>> Also, the different behaviour of `completing-read' breaks backwards
>> compatibility. In fact, I stumbled across this because of some lisp
>> code doing "programmed completion", which doesn't work properly
>> with Emacs 23 anymore (because it accounts only for nil, t, and
>> `lambda').
> 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:
(defvar my-keywords '("foo" "bar" "baz" "quux" "quuux"))
(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))))
(t 'ignore))
s2
(mapcar (lambda (x) (list (concat x " ")))
my-keywords)
pred)))
(if (stringp c2) (concat s1 c2) c2)))
(completing-read "Type some keywords: " 'my-complete)
Now type at the minibuffer prompt:
f TAB b TAB TAB
Emacs 21/22 (and XEmacs) behaviour:
Minibuffer: "Type some keywords: foo ba"
*Completions* buffer offers "bar" and "baz" as completions.
Emacs 23.0.60 behaviour:
Minibuffer: "Type some keywords: foo ba [No completions]"
(and no *Completions* buffer appears)
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#1797: 23.0.60; completing-read breaks backwards compatibility
2009-01-05 23:53 bug#1797: 23.0.60; completing-read breaks backwards compatibility Ulrich Mueller
@ 2009-01-06 4:24 ` Stefan Monnier
2009-01-06 9:34 ` Ulrich Mueller
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2009-01-06 4:24 UTC (permalink / raw)
To: Ulrich Mueller; +Cc: emacs-pretest-bug, 1797
>> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#1797: 23.0.60; completing-read breaks backwards compatibility
2009-01-06 4:24 ` Stefan Monnier
@ 2009-01-06 9:34 ` Ulrich Mueller
0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Mueller @ 2009-01-06 9:34 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-pretest-bug, 1797
>>>>> On Mon, 05 Jan 2009, Stefan Monnier wrote:
> Thanks. I installed a change which I believe should fix this bug.
I confirm that today's CVS trunk is working as expected.
> Note that your completion function is a prime example of a completion
> table that needs completion-boundaries in order to work right.
> ((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))))
Hey, I had already come to a very similar solution: ;-)
(defun my-complete (s pred mode)
(string-match "^\\(.*\\s-\\)?\\(.*\\)$" s)
+ (if (eq (car-safe mode) 'boundaries) ; GNU Emacs 23
+ (cons 'boundaries
+ (cons (match-beginning 2)
+ (string-match "\\s-" (cdr mode))))
(let* ((s1 (match-string 1 s))
(s2 (match-string 2 s))
It cost me quite some time to get this right, because of the missing
documentation.
Ulrich
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-01-06 9:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-05 23:53 bug#1797: 23.0.60; completing-read breaks backwards compatibility Ulrich Mueller
2009-01-06 4:24 ` Stefan Monnier
2009-01-06 9:34 ` Ulrich Mueller
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.