From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt Date: Fri, 24 Jun 2011 17:50:04 -0400 Message-ID: <11546.1308952204@alphaville.dokosmarshall.org> References: <87hb7febzu.fsf@gnu.org> <1308949422-30288-1-git-send-email-pieter@praet.org> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:46277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QaEGn-0000WE-8N for emacs-orgmode@gnu.org; Fri, 24 Jun 2011 17:50:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QaEGl-0000ty-HU for emacs-orgmode@gnu.org; Fri, 24 Jun 2011 17:50:32 -0400 Received: from vms173001pub.verizon.net ([206.46.173.1]:50818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QaEGl-0000tp-DL for emacs-orgmode@gnu.org; Fri, 24 Jun 2011 17:50:31 -0400 Received: from alphaville.dokosmarshall.org ([unknown] [173.76.32.106]) by vms173001.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0LNB004W4DZHTZ20@vms173001.mailsrvcs.net> for emacs-orgmode@gnu.org; Fri, 24 Jun 2011 16:50:17 -0500 (CDT) In-reply-to: Message from Pieter Praet of "Fri, 24 Jun 2011 23:03:42 +0200." <1308949422-30288-1-git-send-email-pieter@praet.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Pieter Praet Cc: Dave Abrahams , Bastien , nicholas.dokos@hp.com, emacs-orgmode@gnu.org Pieter Praet wrote: > As auto-save-mode can only cause leakage after org-decrypt has been run, > there's no need to check for it (and potentially cause annoyance) so early. > > Unfortunately, auto-save-mode doesn't set a buffer-local var to indicate > whether it's enabled for the current buffer (checking > `buffer-auto-save-file-name' has proven to be unreliable), so we can > only check whether it's enabled globally, using `auto-save-default'. > That's very nice, but I think you can go one step further: Why not turn auto-save-mode off for the buffer when org-decrypt is called? With a warning that says so and says why, of course. Nick > Signed-off-by: Pieter Praet > --- > lisp/org-crypt.el | 14 +++++++++----- > 1 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el > index 4bff7a1..f4c0b8e 100644 > --- a/lisp/org-crypt.el > +++ b/lisp/org-crypt.el > @@ -142,6 +142,10 @@ This setting can also be overridden in the CRYPTKEY property." > (defun org-decrypt-entry () > "Decrypt the content of the current headline." > (interactive) > + (when > + (or > + (not auto-save-default) > + (yes-or-no-p "WARNING: auto-save-mode is enabled globally. This may cause leakage. Continue? ")) > (require 'epg) > (unless (org-before-first-heading-p) > (save-excursion > @@ -179,7 +183,7 @@ This setting can also be overridden in the CRYPTKEY property." > (when heading-was-invisible-p > (goto-char heading-point) > (org-flag-subtree t)) > - nil)))))) > + nil))))))) > > (defun org-encrypt-entries () > "Encrypt all top-level entries in the current buffer." > @@ -209,10 +213,10 @@ This setting can also be overridden in the CRYPTKEY property." > ;; 'org-mode-hook > ;; (lambda () (add-hook 'auto-save-hook 'org-encrypt-entries nil t)))) > > -(when (and (functionp 'daemonp) > - (not (daemonp)) auto-save-default) > - (message "Warning: turn auto-save-mode off in Org buffers containing crypted entries.") > - (sit-for 1)) > +;; (when (and (functionp 'daemonp) > +;; (not (daemonp)) auto-save-default) > +;; (message "Warning: turn auto-save-mode off in Org buffers containing crypted entries.") > +;; (sit-for 1)) > > (add-hook 'org-reveal-start-hook 'org-decrypt-entry) > > -- > 1.7.4.1 > >