* bug#21252: 25.0.50; `describe-variable': use current buffer, not minibuffer, in `completing-read' PREDICATE
@ 2015-08-13 15:44 Drew Adams
2016-04-30 22:09 ` Lars Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: Drew Adams @ 2015-08-13 15:44 UTC (permalink / raw)
To: 21252
This bug is at least as old as Emacs 20! Never noticed it before.
1. emacs -Q
2. Type this in *scratch* and evaluate it using `C-x C-e':
(set (make-local-variable 'toto) 42)
3. C-h v tot TAB
There is no completion for variable `toto'.
The reason is that the PREDICATE arg passed to `completing-read' gets
evaluated with the minibuffer as the current buffer, and `toto' is not
bound in the minibuffer.
The predicate should use `with-current-buffer' to make the originally
current buffer current for the test.
For example, instead of this:
(interactive
(let ((v (variable-at-point))
(enable-recursive-minibuffers t)
val)
(setq val (completing-read (if (symbolp v)
(format
"Describe variable (default %s): " v)
"Describe variable: ")
obarray
(lambda (vv)
(or (get vv 'variable-documentation)
(and (boundp vv) (not (keywordp vv)))))
t nil nil
(if (symbolp v) (symbol-name v))))
(list (if (equal val "")
v (intern val)))))
Use this (or similar - since the file now binds `lexical-binding to t,
you need not resort to backquote+comma for CURBUF):
(interactive
(let ((v (variable-at-point))
(enable-recursive-minibuffers t)
(curbuf (current-buffer))
val)
(setq val (completing-read (if (symbolp v)
(format
"Describe variable (default %s): " v)
"Describe variable: ")
obarray
`(lambda (vv)
(with-current-buffer ',curbuf
(or (get vv 'variable-documentation)
(and (boundp vv) (not (keywordp vv))))))
t nil nil
(if (symbolp v) (symbol-name v))))
(list (if (equal val "")
v (intern val)))))
In GNU Emacs 25.0.50.1 (i686-pc-mingw32)
of 2014-10-20 on LEG570
Bzr revision: 118168 rgm@gnu.org-20141020195941-icp42t8ttcnud09g
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
`configure --enable-checking=yes,glyphs CPPFLAGS=-DGLYPH_DEBUG=1'
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#21252: 25.0.50; `describe-variable': use current buffer, not minibuffer, in `completing-read' PREDICATE
2015-08-13 15:44 bug#21252: 25.0.50; `describe-variable': use current buffer, not minibuffer, in `completing-read' PREDICATE Drew Adams
@ 2016-04-30 22:09 ` Lars Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2016-04-30 22:09 UTC (permalink / raw)
To: Drew Adams; +Cc: 21252
Drew Adams <drew.adams@oracle.com> writes:
> This bug is at least as old as Emacs 20! Never noticed it before.
>
> 1. emacs -Q
> 2. Type this in *scratch* and evaluate it using `C-x C-e':
>
> (set (make-local-variable 'toto) 42)
>
> 3. C-h v tot TAB
>
> There is no completion for variable `toto'.
>
> The reason is that the PREDICATE arg passed to `completing-read' gets
> evaluated with the minibuffer as the current buffer, and `toto' is not
> bound in the minibuffer.
>
> The predicate should use `with-current-buffer' to make the originally
> current buffer current for the test.
Makes sense. I applied your changes, slightly changed.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-30 22:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-13 15:44 bug#21252: 25.0.50; `describe-variable': use current buffer, not minibuffer, in `completing-read' PREDICATE Drew Adams
2016-04-30 22:09 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).