[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: isolating history with buffer-local variables
From: |
Pascal J. Bourguignon |
Subject: |
Re: isolating history with buffer-local variables |
Date: |
Wed, 13 May 2015 06:17:36 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Nick Helm <nick@tenpoint.co.nz> writes:
> Hello, I'm trying to teach myself some elisp, but I'm having a problem
> with some code that works with buffer-local variables. It seems to
> work as intended for some variables, but not others.
>
> My objective is to create a minor mode that makes Emacs less likely to
> leak private data.
>
> The approach I've taken is to locally turn off backups and auto-saves,
> and create buffer-local variables to isolate command histories and
> rings that may accumulate private information. My intent is for
> editing to work normally in the private buffer, with local histories
> and the local kill-ring etc all available, but without exposing them
> globally to other buffers and packages like savehist, which should
> continue uninterrupted. When the minor mode is turned off, the local
> variables are killed, reinstating the global bindings.
>
> Here's the code:
>
> (define-minor-mode private-mode
> "This mode prevents Emacs from creating backups, auto-saves and
> certain history records for the current buffer. It is useful
> when editing private data, such as password files, key-chains and
> secure notes."
> :init-value nil
> :lighter " Private"
> :keymap nil
> (if (symbol-value private-mode) (progn
> (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
> (dolist (variable private-variables) (make-local-variable variable)) ;;
> make local vars
> (setq backup-inhibited t) ;; locally disable backups
> (setq auto-save-timeout 0)) ;; locally idle auto-saves
> ;; TODO: Add idle timer to purge changes to local vars
> (dolist (variable private-variables) (kill-local-variable variable)))) ;;
> pop local vars
>
> 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.
>
> Any idea why? Anyone have suggestions for a different approach or a
> way around the problem?
>
> (There is a somewhat relevant discussion here:
> http://lists.gnu.org/archive/html/help-gnu-emacs/2011-10/msg00292.html)
minibuffer-history is used in the minibuffer. This is a different
buffer. Therefore it's a different buffer local variable.
I guess a similar problem might be the case for the other variables.
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
- isolating history with buffer-local variables, Nick Helm, 2015/05/12
- Re: isolating history with buffer-local variables, Stefan Monnier, 2015/05/13
- Re: isolating history with buffer-local variables, Nick Helm, 2015/05/14
- Re: isolating history with buffer-local variables, Stefan Monnier, 2015/05/15
- Re: isolating history with buffer-local variables, Nick Helm, 2015/05/20
- Re: isolating history with buffer-local variables, Stefan Monnier, 2015/05/20
- Re: isolating history with buffer-local variables, Stefan Monnier, 2015/05/24
- Re: isolating history with buffer-local variables, Nick Helm, 2015/05/24
- Message not available
- Re: isolating history with buffer-local variables, Pascal J. Bourguignon, 2015/05/24
- Re: isolating history with buffer-local variables, Nick Helm, 2015/05/24
- Re: isolating history with buffer-local variables,
Pascal J. Bourguignon <=