help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: isolating history with buffer-local variables


From: Stefan Monnier
Subject: Re: isolating history with buffer-local variables
Date: Wed, 13 May 2015 17:39:24 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Thanks.  I think this functionality is important and should largely be
activated automatically when visiting encrypted files (not sure which
other files/buffers would warrant such behavior).

So I'm happy to see you work on this, and I encourage you try and make
it work well, and contribute your code so we can include it directly
in Emacs.

>    (if (symbol-value private-mode)

`private-mode' will normally have value either t or nil, and the
symbol-value of nil is nil and the symbol-value of t is t, so the above
is better written as "(if private-mode".

>       (setq private-variables '( ;; data to isolate
>          minibuffer-history         ;; <-- not working
>          command-history            ;; ok
>          extended-command-history   ;; <-- not working
>          string-rectangle-history   ;; <-- not working
>          query-replace-history      ;; ok
>          search-ring                ;; ok
>          regexp-search-ring         ;; ok
>          kill-ring                  ;; ok
>          backup-inhibited           ;; ok
>          auto-save-timeout))        ;; ok 

This should probably be moved out to a defvar.

>       (setq backup-inhibited t) ;; locally disable backups
>       (setq auto-save-timeout 0)) ;; locally idle auto-saves

For encrypted files (accessed via EPA), the above should be correctly
handled already (either by preventing autosave/backups or by keeping
those files encrypted just like the main file).  If you find they're
not, please file it as a bug.

> All the local auto-save/backup vars, local ring vars, and local
> query-replace-history and command-history vars work as intended. But
> minibuffer-history, extended-command-history and
> string-rectangle-history do not. The buffer-local vars for these are
> made as expected, but they are ignored and histories continue to
> accumulate in the global variables.

I think Pascal has the right explanation for that.

> Any idea why? Anyone have suggestions for a different approach or
> a way around the problem?

You'll probably need to hack read-from-minibuffer (e.g. with an advice)
so as to redirect the history variable to another variable, or to
cleanup the variable after the fact.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]