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: Nick Helm
Subject: Re: isolating history with buffer-local variables
Date: Fri, 15 May 2015 02:40:26 +0000

> On 14/05/2015, at 9:39 am, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> 
> 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).

I could add to auto-mode-alist to activate private-mode for .gpg files 
(for example), but I don't know if the file extension is a reliable 
enough way to identify an encrypted file. I'll have a look at epa-hook
instead. 

I think there are other use-cases though. For instance, I use Emacs to 
edit confidential files that I don't want leaking into incremental 
backups or off-site syncing of ~/.emacs.d/ (all the usual financial,
medical, legal stuff).

> 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.

Gladly. I'll progress it as far as I can then ask for further critique
and suggestions.

>>   (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.

Yes, that's what I see here too.

>> 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.

I thought that was probably the case, but I couldn't pin down why some 
minibuffer input was prepended to the local variable 
(e.g. command-history) while other input was not 
(e.g. extended-command-history).

>> 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.

Thanks, I'll give those a try.

> 
>        Stefan
> 
> 
> 




reply via email to

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