unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38317: Buffer-local variables don't work as history for read-from-minibuffer
@ 2019-11-21 21:30 Federico Tedin
  2019-11-22 13:33 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 22+ messages in thread
From: Federico Tedin @ 2019-11-21 21:30 UTC (permalink / raw)
  To: 38317

I was recently trying to modify `goto-line' so that it uses a
buffer-local variable as input history for the minibuffer (so that line
numbers don't get mixed up with other inputted values, and each buffer
has its own input history) (see: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38282).

First, I modified `read-number' and added a new HIST parameter. Then I
just forwarded that value to `read-from-minibuffer'.

Then, in simple.el, I added a new buffer-local variable
`goto-line--hist' and passed it to `read-number' in `goto-line'. I also
added I call to `add-to-history` to record the value read. All of this
did not work as expected: the input history for all buffers was shared
for all uses of `goto-line'. Inspecting `goto-line--hist' with M-:
showed the correct list of values, however.

The shortest way I've found of reproducing the problem is:

(defvar-local local-hist nil)

(defun my-command ()
  (interactive)
  (add-to-history 'local-hist (read-from-minibuffer "> " nil nil nil 'local-hist)))

In this case, the variable `local-hist' will end up containing all the
inputted values (per buffer), but trying to use M-p or M-n to step
through the input history after invoking `my-command' will not work ("no
preceding item"). So to summarize, `read-from-minibuffer' doesn't seem
to work correctly when HIST is buffer-local.

Related: https://emacs.stackexchange.com/questions/53892/buffer-local-input-history-for-read-from-minibuffer/53898#53898






^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-12-05  9:31 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-21 21:30 bug#38317: Buffer-local variables don't work as history for read-from-minibuffer Federico Tedin
2019-11-22 13:33 ` Lars Ingebrigtsen
2019-11-22 15:23   ` Michael Heerdegen
2019-11-22 16:24   ` martin rudalics
2019-11-23 11:54     ` Lars Ingebrigtsen
2019-11-23 20:36       ` Federico Tedin
2019-11-23 23:12         ` Federico Tedin
2019-11-26 21:54           ` Federico Tedin
2019-11-27  8:14             ` Robert Pluim
2019-11-27 15:24               ` Drew Adams
2019-11-27 15:28                 ` Robert Pluim
2019-11-27 11:53             ` Lars Ingebrigtsen
2019-11-27 18:50               ` Federico Tedin
2019-11-27 19:25                 ` Eli Zaretskii
2019-11-27 21:04                   ` Federico Tedin
2019-11-28 12:05                     ` Federico Tedin
2019-12-05  9:31                       ` Lars Ingebrigtsen
2019-11-29  5:22                     ` Richard Stallman
2019-11-29 10:21                       ` Eli Zaretskii
2019-11-29 17:02                         ` Federico Tedin
2019-12-01  5:59                       ` Richard Stallman
2019-11-27 21:19             ` Juri Linkov

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).