all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* isolating history with buffer-local variables
@ 2015-05-13  2:10 Nick Helm
  2015-05-13 21:39 ` Stefan Monnier
  0 siblings, 1 reply; 11+ messages in thread
From: Nick Helm @ 2015-05-13  2:10 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

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





^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <mailman.2920.1431489112.904.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2015-05-25  3:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-13  2:10 isolating history with buffer-local variables Nick Helm
2015-05-13 21:39 ` 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

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.