[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21252: 25.0.50; `describe-variable': use current buffer, not minibuf
From: |
Drew Adams |
Subject: |
bug#21252: 25.0.50; `describe-variable': use current buffer, not minibuffer, in `completing-read' PREDICATE |
Date: |
Thu, 13 Aug 2015 08:44:24 -0700 (PDT) |
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'
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#21252: 25.0.50; `describe-variable': use current buffer, not minibuffer, in `completing-read' PREDICATE,
Drew Adams <=