From: Nick Helm <nick@tenpoint.co.nz>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: isolating history with buffer-local variables
Date: Wed, 13 May 2015 02:10:25 +0000 [thread overview]
Message-ID: <54AE8A33-FB8D-4F63-8BC1-F84DB290EF05@tenpoint.co.nz> (raw)
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)
Nick
next reply other threads:[~2015-05-13 2:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-13 2:10 Nick Helm [this message]
2015-05-13 21:39 ` isolating history with buffer-local variables Stefan Monnier
2015-05-15 2:40 ` Nick Helm
2015-05-15 23:32 ` Stefan Monnier
2015-05-20 15:52 ` Nick Helm
2015-05-20 21:26 ` Stefan Monnier
2015-05-25 0:39 ` Stefan Monnier
2015-05-25 2:06 ` Nick Helm
[not found] ` <mailman.3589.1432519466.904.help-gnu-emacs@gnu.org>
2015-05-25 2:12 ` Pascal J. Bourguignon
2015-05-25 3:14 ` Nick Helm
[not found] <mailman.2920.1431489112.904.help-gnu-emacs@gnu.org>
2015-05-13 4:17 ` Pascal J. Bourguignon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54AE8A33-FB8D-4F63-8BC1-F84DB290EF05@tenpoint.co.nz \
--to=nick@tenpoint.co.nz \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.