From: Pieter Praet <pieter@praet.org>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-crypt: when running org-decrypt-entry, only run auto-save-mode check if on an encrypted entry
Date: Thu, 27 Oct 2011 10:52:32 +0200 [thread overview]
Message-ID: <8762jazui7.fsf@praet.org> (raw)
In-Reply-To: <1E90A07C-2176-4265-934C-9159E1EEE76E@gmail.com>
On Sat, 8 Oct 2011 18:11:32 +0200, Carsten Dominik <carsten.dominik@gmail.com> wrote:
> Accepted, thanks.
Thanks Carsten!
BTW, my FSF copyright assignment is completed (assignment number
#705083) so I should probably be added to the list of signees [1].
Would you like me to provide a patch to that effect?
> - Carsten
>
> On 28.8.2011, at 15:46, Pieter Praet wrote:
>
> > * lisp/org-crypt.el (org-crypt-check-auto-save): New function, see next change.
> > * lisp/org-crypt.el (org-decrypt-entry): Break the auto-save-mode check out
> > into a separate function, and call it at a later point, to assure it only
> > runs when visiting an encrypted entry.
> >
> > Currently `org-decrypt-entry' is doing the auto-save-mode check whenever
> > it's run, regardless of context, while this only makes sense when run on
> > an entry which is actually encrypted (or looks like it, at least).
> >
> > Signed-off-by: Pieter Praet <pieter@praet.org>
> > ---
> >
> > lisp/org-crypt.el | 54 +++++++++++++++++++++++++++++-----------------------
> > 1 files changed, 30 insertions(+), 24 deletions(-)
> >
> > diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el
> > index 5991192..f764404 100644
> > --- a/lisp/org-crypt.el
> > +++ b/lisp/org-crypt.el
> > @@ -116,6 +116,35 @@ nil : Leave auto-save-mode enabled.
> > (const :tag "Ask" ask)
> > (const :tag "Encrypt" encrypt)))
> >
> > +(defun org-crypt-check-auto-save ()
> > + "Check whether auto-save-mode is enabled for the current buffer.
> > +
> > +`auto-save-mode' may cause leakage when decrypting entries, so
> > +check whether it's enabled, and decide what to do about it.
> > +
> > +See `org-crypt-disable-auto-save'."
> > + (when buffer-auto-save-file-name
> > + (cond
> > + ((or
> > + (eq org-crypt-disable-auto-save t)
> > + (and
> > + (eq org-crypt-disable-auto-save 'ask)
> > + (y-or-n-p "org-decrypt: auto-save-mode may cause leakage. Disable it for current buffer? ")))
> > + (message (concat "org-decrypt: Disabling auto-save-mode for " (or (buffer-file-name) (current-buffer))))
> > + ; The argument to auto-save-mode has to be "-1", since
> > + ; giving a "nil" argument toggles instead of disabling.
> > + (auto-save-mode -1))
> > + ((eq org-crypt-disable-auto-save nil)
> > + (message "org-decrypt: Decrypting entry with auto-save-mode enabled. This may cause leakage."))
> > + ((eq org-crypt-disable-auto-save 'encrypt)
> > + (message "org-decrypt: Enabling re-encryption on auto-save.")
> > + (add-hook 'auto-save-hook
> > + (lambda ()
> > + (message "org-crypt: Re-encrypting all decrypted entries due to auto-save.")
> > + (org-encrypt-entries))
> > + nil t))
> > + (t nil))))
> > +
> > (defun org-crypt-key-for-heading ()
> > "Return the encryption key for the current heading."
> > (save-excursion
> > @@ -164,30 +193,6 @@ nil : Leave auto-save-mode enabled.
> > (defun org-decrypt-entry ()
> > "Decrypt the content of the current headline."
> > (interactive)
> > -
> > - ; auto-save-mode may cause leakage, so check whether it's enabled.
> > - (when buffer-auto-save-file-name
> > - (cond
> > - ((or
> > - (eq org-crypt-disable-auto-save t)
> > - (and
> > - (eq org-crypt-disable-auto-save 'ask)
> > - (y-or-n-p "org-decrypt: auto-save-mode may cause leakage. Disable it for current buffer? ")))
> > - (message (concat "org-decrypt: Disabling auto-save-mode for " (or (buffer-file-name) (current-buffer))))
> > - ; The argument to auto-save-mode has to be "-1", since
> > - ; giving a "nil" argument toggles instead of disabling.
> > - (auto-save-mode -1))
> > - ((eq org-crypt-disable-auto-save nil)
> > - (message "org-decrypt: Decrypting entry with auto-save-mode enabled. This may cause leakage."))
> > - ((eq org-crypt-disable-auto-save 'encrypt)
> > - (message "org-decrypt: Enabling re-encryption on auto-save.")
> > - (add-hook 'auto-save-hook
> > - (lambda ()
> > - (message "org-crypt: Re-encrypting all decrypted entries due to auto-save.")
> > - (org-encrypt-entries))
> > - nil t))
> > - (t nil)))
> > -
> > (require 'epg)
> > (unless (org-before-first-heading-p)
> > (save-excursion
> > @@ -199,6 +204,7 @@ nil : Leave auto-save-mode enabled.
> > (outline-invisible-p))))
> > (forward-line)
> > (when (looking-at "-----BEGIN PGP MESSAGE-----")
> > + (org-crypt-check-auto-save)
> > (let* ((end (save-excursion
> > (search-forward "-----END PGP MESSAGE-----")
> > (forward-line)
> > --
> > 1.7.5.4
> >
> >
>
Peace
--
Pieter
[1] http://orgmode.org/worg/org-contribute.html#contributors_with_fsf_papers
next prev parent reply other threads:[~2011-10-27 8:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-14 12:22 disable "org-decrypt: auto-save-mode may cause leakage" Karl Voit
2011-07-14 13:14 ` Pieter Praet
2011-07-14 13:17 ` Juan Pechiar
2011-07-14 13:37 ` Sebastien Vauban
2011-07-14 14:25 ` Pieter Praet
2011-07-14 14:42 ` Sebastien Vauban
2011-07-14 15:50 ` Pieter Praet
2011-07-18 9:24 ` Sebastien Vauban
2011-07-18 23:12 ` Bastien
2011-08-27 16:22 ` Pieter Praet
2011-08-28 7:02 ` Achim Gratz
2011-08-28 11:35 ` Pieter Praet
2011-08-28 13:46 ` [PATCH] org-crypt: when running org-decrypt-entry, only run auto-save-mode check if on an encrypted entry Pieter Praet
2011-10-08 16:11 ` Carsten Dominik
2011-10-27 8:52 ` Pieter Praet [this message]
2011-10-28 15:13 ` Bastien
2011-08-29 9:09 ` disable "org-decrypt: auto-save-mode may cause leakage" Sebastien Vauban
2011-07-14 15:14 ` Karl Voit
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=8762jazui7.fsf@praet.org \
--to=pieter@praet.org \
--cc=carsten.dominik@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).