From: Pieter Praet <pieter@praet.org>
Cc: Dave Abrahams <dave@boostpro.com>, Bastien <bzg@altern.org>,
nicholas.dokos@hp.com, emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt
Date: Sun, 26 Jun 2011 08:38:12 +0200 [thread overview]
Message-ID: <8762ntjdwr.fsf@praet.org> (raw)
In-Reply-To: <11546.1308952204@alphaville.dokosmarshall.org>
On Fri, 24 Jun 2011 17:50:04 -0400, Nick Dokos <nicholas.dokos@hp.com> wrote:
> Pieter Praet <pieter@praet.org> 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.
Ideally, we'd have a defcustom `org-crypt-auto-save' with the following options:
- 'ask : Ask the user whether or not to decrypt the entry.
- 'disable : Disable auto-save-mode for the current buffer before decrypting.
- 'ignore : Decrypt the entry regardless.
- 'encrypt : Re-encrypt the entries before auto-save kicks in.
I've implemented this, but it fails miserably:
Since the function `auto-save-mode' doesn't set an buffer-local
var to indicate whether or not it's enabled for the current buffer, we
can only check for `auto-save-default'. This poses the following problems:
- 'ask will be a serious whiner, prompting the user for each and every
entry being decrypted, whether or not `auto-save-mode' is enabled for
the current buffer.
- 'disable will cause (perhaps minor) performance issues, since it will
try disabling `auto-save-mode' for each and every entry being decrypted,
even though it may already be disabled for the current buffer.
If (as per your suggestion) emitting a warning, this will also spam the
*Message* buffer to no end.
Also, 'encrypt will simply not work, due to `auto-save-hook' not being
called when it's supposed to.
BTW: For those of us running `org-decrypt-entry' with a wrapper function,
do remember one has to call (auto-save-mode -1) instead of (auto-save-mode nil),
since the latter will *toggle* instead of *disable* !
> Nick
>
> > Signed-off-by: Pieter Praet <pieter@praet.org>
> > ---
> > 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
> >
> >
Peace
--
Pieter
next prev parent reply other threads:[~2011-06-26 6:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-30 21:34 Documentation suggestion re: buffers containing crypted entries Bill Day
2011-05-02 3:42 ` Darlan Cavalcante Moreira
2011-06-12 20:41 ` Dave Abrahams
2011-06-24 10:04 ` Eric S Fraga
2011-06-24 10:53 ` Bastien
2011-06-24 13:42 ` Eric S Fraga
2011-06-27 16:56 ` Bastien
2011-06-28 13:29 ` Darlan Cavalcante Moreira
2011-06-24 21:03 ` [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt Pieter Praet
2011-06-24 21:50 ` Nick Dokos
2011-06-26 6:38 ` Pieter Praet [this message]
2011-06-26 8:38 ` [PATCH] org-crypt: make org-decrypt disable auto-save-mode (configurable) Pieter Praet
2011-06-27 16:31 ` [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt Bastien
2011-06-28 6:55 ` Pieter Praet
2011-06-28 6:57 ` [PATCH] org-crypt: make org-decrypt disable auto-save-mode (configurable) Pieter Praet
2011-06-28 10:04 ` Bastien
2011-06-28 10:05 ` [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt Bastien
2011-06-24 11:57 ` Documentation suggestion re: buffers containing crypted entries Bernt Hansen
2011-06-27 16:55 ` Bastien
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8762ntjdwr.fsf@praet.org \
--to=pieter@praet.org \
--cc=bzg@altern.org \
--cc=dave@boostpro.com \
--cc=emacs-orgmode@gnu.org \
--cc=nicholas.dokos@hp.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).