From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nick Helm Newsgroups: gmane.emacs.help Subject: isolating history with buffer-local variables Date: Wed, 13 May 2015 02:10:25 +0000 Message-ID: <54AE8A33-FB8D-4F63-8BC1-F84DB290EF05@tenpoint.co.nz> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1431489131 19021 80.91.229.3 (13 May 2015 03:52:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 13 May 2015 03:52:11 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 13 05:52:02 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YsNiD-0004Sd-Qs for geh-help-gnu-emacs@m.gmane.org; Wed, 13 May 2015 05:52:01 +0200 Original-Received: from localhost ([::1]:46021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsNiC-0006Vn-Td for geh-help-gnu-emacs@m.gmane.org; Tue, 12 May 2015 23:52:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsMPX-0002uW-Rc for help-gnu-emacs@gnu.org; Tue, 12 May 2015 22:28:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YsMPS-0004cE-PH for help-gnu-emacs@gnu.org; Tue, 12 May 2015 22:28:39 -0400 Original-Received: from mail.cloudless.co.nz ([202.20.2.65]:47921 helo=CL-DAG01.cloudless.local) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsMPS-0004av-EZ for help-gnu-emacs@gnu.org; Tue, 12 May 2015 22:28:34 -0400 Original-Received: from CL-DAG01.cloudless.local (10.100.10.20) by CL-DAG01.cloudless.local (10.100.10.20) with Microsoft SMTP Server (TLS) id 15.0.775.38; Wed, 13 May 2015 14:10:26 +1200 Original-Received: from CL-DAG01.cloudless.local ([fe80::c8af:a0f:50d9:c20]) by CL-DAG01.cloudless.local ([fe80::c8af:a0f:50d9:c20%13]) with mapi id 15.00.0775.031; Wed, 13 May 2015 14:10:26 +1200 Thread-Topic: isolating history with buffer-local variables Thread-Index: AQHQjSH5T5/f5vFCB0yFSm4vb9SnaA== Accept-Language: en-NZ, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [122.57.35.49] Content-ID: <10535CCF286BF3408C63BC579AD73AF3@cloudless.local> X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 202.20.2.65 X-Mailman-Approved-At: Tue, 12 May 2015 23:51:51 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104431 Archived-At: 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 inte= nded for some variables, but not others. My objective is to create a minor mode that makes Emacs less likely to leak= private data.=20 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 m= ay accumulate private information. My intent is for editing to work normall= y in the private buffer, with local histories and the local kill-ring etc a= ll available, but without exposing them globally to other buffers and packa= ges like savehist, which should continue uninterrupted. When the minor mode= is turned off, the local variables are killed, reinstating the global bind= ings. 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=20 (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-repla= ce-history and command-history vars work as intended. But minibuffer-histor= y, extended-command-history and string-rectangle-history do not. The buffer= -local vars for these are made as expected, but they are ignored and histor= ies continue to accumulate in the global variables. Any idea why? Anyone have suggestions for a different approach or a way aro= und the problem?=20 (There is a somewhat relevant discussion here: http://lists.gnu.org/archive= /html/help-gnu-emacs/2011-10/msg00292.html) Nick