* Documentation suggestion re: buffers containing crypted entries
@ 2011-04-30 21:34 Bill Day
2011-05-02 3:42 ` Darlan Cavalcante Moreira
2011-06-27 16:55 ` Bastien
0 siblings, 2 replies; 19+ messages in thread
From: Bill Day @ 2011-04-30 21:34 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 915 bytes --]
I appreciate the warning about encrypted entries, and, I would like to add,
all the hard work and careful thought that has gone into making org-mode
such an incredible piece of software.
I checked the documentation regarding turning off auto-save on pages
containing encrypted entries and saw that the warning was repeated but there
was no advice on how to implement it. See
http://orgmode.org/worg/org-tutorials/encrypting-files.html
My eventual solution (there may be better ones) was to add a line at the top
of my encrypted page as follows:
# -*- buffer-auto-save-file-name: nil; -*-
This itself generates a warning every time I go to that page, but it seems
to inhibit auto-save. I would like to suggest that a little bit of
explanation of how to turn auto-save on and off be added to the
documentation on encryption with org-mode.
Thank you.
Sincerely,
Bill Day
--
Bill Day
williamson.day@gmail.com
[-- Attachment #2: Type: text/html, Size: 1110 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Documentation suggestion re: buffers containing crypted entries
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-27 16:55 ` Bastien
1 sibling, 1 reply; 19+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-05-02 3:42 UTC (permalink / raw)
To: Bill Day; +Cc: emacs-orgmode
I was hit by this last week when I was investigating why my emacs
initialization was taking so long. Later I found out that org-crypt was the
culprit, since it added a "sit for 5s" in order for the user to actually
see this warning.
The problem is that org-crypt tests the value of the auto-save-default
variable during loading time. This reflects the default behavior and not
the actual auto-save status of the current buffer.
Maybe a variable to disable this warning could be introduced so that the
user could disable it after understanding the problem.
--
Darlan
At Sat, 30 Apr 2011 17:34:06 -0400,
Bill Day <williamson.day@gmail.com> wrote:
>
> [1 <text/plain; ISO-8859-1 (7bit)>]
> I appreciate the warning about encrypted entries, and, I would like to add,
> all the hard work and careful thought that has gone into making org-mode
> such an incredible piece of software.
>
> I checked the documentation regarding turning off auto-save on pages
> containing encrypted entries and saw that the warning was repeated but there
> was no advice on how to implement it. See
> http://orgmode.org/worg/org-tutorials/encrypting-files.html
>
> My eventual solution (there may be better ones) was to add a line at the top
> of my encrypted page as follows:
>
> # -*- buffer-auto-save-file-name: nil; -*-
>
> This itself generates a warning every time I go to that page, but it seems
> to inhibit auto-save. I would like to suggest that a little bit of
> explanation of how to turn auto-save on and off be added to the
> documentation on encryption with org-mode.
>
> Thank you.
>
> Sincerely,
>
> Bill Day
>
> --
> Bill Day
> williamson.day@gmail.com
> [2 <text/html; ISO-8859-1 (quoted-printable)>]
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Documentation suggestion re: buffers containing crypted entries
2011-05-02 3:42 ` Darlan Cavalcante Moreira
@ 2011-06-12 20:41 ` Dave Abrahams
2011-06-24 10:04 ` Eric S Fraga
0 siblings, 1 reply; 19+ messages in thread
From: Dave Abrahams @ 2011-06-12 20:41 UTC (permalink / raw)
To: emacs-orgmode
> I was hit by this last week when I was investigating why my emacs
> initialization was taking so long. Later I found out that org-crypt was the
> culprit, since it added a "sit for 5s" in order for the user to actually
> see this warning.
>
> The problem is that org-crypt tests the value of the auto-save-default
> variable during loading time. This reflects the default behavior and not
> the actual auto-save status of the current buffer.
>
> Maybe a variable to disable this warning could be introduced so that the
> user could disable it after understanding the problem.
Oh, yes please! I'm finding the delays introduced by this problem
almost intolerable. Call me picky but I've gone to great lengths to
make emacs very responsive and this sit-for really interferes!
--
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Documentation suggestion re: buffers containing crypted entries
2011-06-12 20:41 ` Dave Abrahams
@ 2011-06-24 10:04 ` Eric S Fraga
2011-06-24 10:53 ` Bastien
2011-06-24 11:57 ` Documentation suggestion re: buffers containing crypted entries Bernt Hansen
0 siblings, 2 replies; 19+ messages in thread
From: Eric S Fraga @ 2011-06-24 10:04 UTC (permalink / raw)
To: Dave Abrahams; +Cc: emacs-orgmode
Dave Abrahams <dave@boostpro.com> writes:
>> I was hit by this last week when I was investigating why my emacs
>> initialization was taking so long. Later I found out that org-crypt was the
>
>> culprit, since it added a "sit for 5s" in order for the user to actually
>> see this warning.
>>
>> The problem is that org-crypt tests the value of the auto-save-default
>> variable during loading time. This reflects the default behavior and not
>> the actual auto-save status of the current buffer.
>>
>> Maybe a variable to disable this warning could be introduced so that the
>> user could disable it after understanding the problem.
>
> Oh, yes please! I'm finding the delays introduced by this problem
> almost intolerable. Call me picky but I've gone to great lengths to
> make emacs very responsive and this sit-for really interferes!
+1
I have found this (sit-for 5) annoying enough that I have deleted it
from my copy of org. 5 seconds is a large percentage of my emacs start
up time!
thanks,
eric
--
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.430.g95fa2.dirty)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Documentation suggestion re: buffers containing crypted entries
2011-06-24 10:04 ` Eric S Fraga
@ 2011-06-24 10:53 ` Bastien
2011-06-24 13:42 ` Eric S Fraga
2011-06-24 21:03 ` [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt Pieter Praet
2011-06-24 11:57 ` Documentation suggestion re: buffers containing crypted entries Bernt Hansen
1 sibling, 2 replies; 19+ messages in thread
From: Bastien @ 2011-06-24 10:53 UTC (permalink / raw)
To: Dave Abrahams; +Cc: emacs-orgmode
Eric S Fraga <e.fraga@ucl.ac.uk> writes:
> I have found this (sit-for 5) annoying enough that I have deleted it
> from my copy of org. 5 seconds is a large percentage of my emacs start
> up time!
I just reduced it to one second. Still, the message needs some time to
appear to the user.
--
Bastien
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Documentation suggestion re: buffers containing crypted entries
2011-06-24 10:04 ` Eric S Fraga
2011-06-24 10:53 ` Bastien
@ 2011-06-24 11:57 ` Bernt Hansen
1 sibling, 0 replies; 19+ messages in thread
From: Bernt Hansen @ 2011-06-24 11:57 UTC (permalink / raw)
To: Eric S Fraga; +Cc: Dave Abrahams, emacs-orgmode
Eric S Fraga <e.fraga@ucl.ac.uk> writes:
> Dave Abrahams <dave@boostpro.com> writes:
>
>>> I was hit by this last week when I was investigating why my emacs
>>> initialization was taking so long. Later I found out that org-crypt was the
>>
>>> culprit, since it added a "sit for 5s" in order for the user to actually
>>> see this warning.
>>>
>>> The problem is that org-crypt tests the value of the auto-save-default
>>> variable during loading time. This reflects the default behavior and not
>>> the actual auto-save status of the current buffer.
>>>
>>> Maybe a variable to disable this warning could be introduced so that the
>>> user could disable it after understanding the problem.
>>
>> Oh, yes please! I'm finding the delays introduced by this problem
>> almost intolerable. Call me picky but I've gone to great lengths to
>> make emacs very responsive and this sit-for really interferes!
>
> +1
>
> I have found this (sit-for 5) annoying enough that I have deleted it
> from my copy of org. 5 seconds is a large percentage of my emacs start
> up time!
I also have removed this wait in my local copy of org-mode. I use
org-crypt for one subtree in each of my org files which contains
passwords and other sensitive data. I rarely decrypt these entries so
leaving auto save on for my use case isn't much of a security issue for
me. I tend to decrypt the entry, look up the detail I need, and then
resave the file which reencrypts the entry immediately.
Just my 2 cents :)
--
Bernt
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Documentation suggestion re: buffers containing crypted entries
2011-06-24 10:53 ` Bastien
@ 2011-06-24 13:42 ` Eric S Fraga
2011-06-27 16:56 ` Bastien
2011-06-24 21:03 ` [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt Pieter Praet
1 sibling, 1 reply; 19+ messages in thread
From: Eric S Fraga @ 2011-06-24 13:42 UTC (permalink / raw)
To: Bastien; +Cc: Dave Abrahams, emacs-orgmode
Bastien <bzg@altern.org> writes:
> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
>> I have found this (sit-for 5) annoying enough that I have deleted it
>> from my copy of org. 5 seconds is a large percentage of my emacs start
>> up time!
>
> I just reduced it to one second. Still, the message needs some time to
> appear to the user.
The question is where should this information be most appropriate to
appear. In my view, this should be in the documentation (highlighted
etc), not in the Emacs mini-buffer! I don't know enough texi (any at
all, actually) so cannot suggest a patch. However, I would suggest that
the warning that is in the code be moved into the entry for org-crypt.el
in the info manual. Or, as originally proposed, the warning in the code
could be wrapped in a customisable variable but this seems like overkill
to me.
One quickly becomes inured to messages that appear every time you use a
tool. At best, they are simply ignored; at worst, they become annoying,
such as in this case. I'm not complaining critically as it is trivial
to fix for my own use.
Just my 2¢!
--
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.430.g95fa2.dirty)
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt
2011-06-24 10:53 ` Bastien
2011-06-24 13:42 ` Eric S Fraga
@ 2011-06-24 21:03 ` Pieter Praet
2011-06-24 21:50 ` Nick Dokos
1 sibling, 1 reply; 19+ messages in thread
From: Pieter Praet @ 2011-06-24 21:03 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Dave Abrahams, Bastien
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'.
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
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt
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
0 siblings, 1 reply; 19+ messages in thread
From: Nick Dokos @ 2011-06-24 21:50 UTC (permalink / raw)
To: Pieter Praet; +Cc: Dave Abrahams, Bastien, nicholas.dokos, emacs-orgmode
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.
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
>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt
2011-06-24 21:50 ` Nick Dokos
@ 2011-06-26 6:38 ` Pieter Praet
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
0 siblings, 2 replies; 19+ messages in thread
From: Pieter Praet @ 2011-06-26 6:38 UTC (permalink / raw)
Cc: Dave Abrahams, Bastien, nicholas.dokos, emacs-orgmode
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH] org-crypt: make org-decrypt disable auto-save-mode (configurable)
2011-06-26 6:38 ` Pieter Praet
@ 2011-06-26 8:38 ` Pieter Praet
2011-06-27 16:31 ` [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt Bastien
1 sibling, 0 replies; 19+ messages in thread
From: Pieter Praet @ 2011-06-26 8:38 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Dave Abrahams, Bastien, Nick Dokos
Signed-off-by: Pieter Praet <pieter@praet.org>
---
This is appears to be the only solution that doesn't cause
the production of inordinate amounts of cortisol.
I've also added a warning re the broken state of `auto-save-hook'.
lisp/org-crypt.el | 36 ++++++++++++++++++++++++++++++++----
1 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el
index 4bff7a1..0a0ce96 100644
--- a/lisp/org-crypt.el
+++ b/lisp/org-crypt.el
@@ -94,6 +94,15 @@ This setting can also be overridden in the CRYPTKEY property."
:type 'string
:group 'org-crypt)
+(defcustom org-crypt-disable-auto-save t
+ "What org-decrypt should do if `auto-save-default' is enabled.
+
+t : Disable it for the current buffer prior to decrypting an entry.
+nil : Leave it enabled."
+ :group 'org-crypt
+ :type '(choice (const :tag "Always" t)
+ (const :tag "Never" nil)))
+
(defun org-crypt-key-for-heading ()
"Return the encryption key for the current heading."
(save-excursion
@@ -142,6 +151,24 @@ This setting can also be overridden in the CRYPTKEY property."
(defun org-decrypt-entry ()
"Decrypt the content of the current headline."
(interactive)
+
+ ; auto-save-mode causes leakage, so check whether it's enabled.
+ (when auto-save-default
+ ; Ideally, we'd check whether it's enabled for the current buffer,
+ ; using the buffer-local variable `auto-save-mode', but the
+ ; `auto-save-mode' function doesn't set this, so we have to check
+ ; the global variable `auto-save-default' instead.
+ ; Consequently, the following will run regardless of whether
+ ; `auto-save-mode' is enabled for the current buffer, spamming the
+ ; *Messages* buffer.
+ (if (eq org-crypt-disable-auto-save t)
+ (progn
+ (message "org-decrypt: Disabling auto-save-mode for current buffer to prevent leakage.")
+ ; The argument to auto-save-mode has to be "-1", since
+ ; giving a "nil" argument toggles instead of disabling.
+ (auto-save-mode -1))
+ (message "org-decrypt: WARNING! auto-save-mode is enabled globally. This may cause leakage.")))
+
(require 'epg)
(unless (org-before-first-heading-p)
(save-excursion
@@ -204,15 +231,16 @@ This setting can also be overridden in the CRYPTKEY property."
;; FIXME Find a better way to encrypt Org auto-saved buffers?
;; When `auto-save-default' is non-nil, make sure entries are
;; encrypted before auto-saving
+;; NOTE: auto-save-hook does NOT work, so don't rely on it!
;; (when auto-save-default
;; (add-hook
;; '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
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt
2011-06-26 6:38 ` Pieter Praet
2011-06-26 8:38 ` [PATCH] org-crypt: make org-decrypt disable auto-save-mode (configurable) Pieter Praet
@ 2011-06-27 16:31 ` Bastien
2011-06-28 6:55 ` Pieter Praet
1 sibling, 1 reply; 19+ messages in thread
From: Bastien @ 2011-06-27 16:31 UTC (permalink / raw)
To: Pieter Praet; +Cc: Dave Abrahams, Nick Dokos, emacs-orgmode
Hi Pieter,
Thanks for the patch at the end of this thread.
Pieter Praet <pieter@praet.org> writes:
> 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'.
I think we should first ask emacs-devel to fix this, then implement your
clean solution. Would you like to report this problem?
I'm not confident in disabling auto-save-mode globally by default, this
would surprise users -- even with a **BiG WaRnInG** message.
What do you think?
--
Bastien
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Documentation suggestion re: buffers containing crypted entries
2011-04-30 21:34 Documentation suggestion re: buffers containing crypted entries Bill Day
2011-05-02 3:42 ` Darlan Cavalcante Moreira
@ 2011-06-27 16:55 ` Bastien
1 sibling, 0 replies; 19+ messages in thread
From: Bastien @ 2011-06-27 16:55 UTC (permalink / raw)
To: Bill Day; +Cc: emacs-orgmode
Hi Bill,
Bill Day <williamson.day@gmail.com> writes:
> # -*- buffer-auto-save-file-name: nil; -*-
Do you know if this hack works for recent Emacsen without side-effects?
--
Bastien
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Documentation suggestion re: buffers containing crypted entries
2011-06-24 13:42 ` Eric S Fraga
@ 2011-06-27 16:56 ` Bastien
2011-06-28 13:29 ` Darlan Cavalcante Moreira
0 siblings, 1 reply; 19+ messages in thread
From: Bastien @ 2011-06-27 16:56 UTC (permalink / raw)
To: Dave Abrahams; +Cc: emacs-orgmode
Hi Eric,
Eric S Fraga <e.fraga@ucl.ac.uk> writes:
> The question is where should this information be most appropriate to
> appear. In my view, this should be in the documentation (highlighted
> etc), not in the Emacs mini-buffer! I don't know enough texi (any at
> all, actually) so cannot suggest a patch. However, I would suggest that
> the warning that is in the code be moved into the entry for org-crypt.el
> in the info manual.
I did so -- I added this to the config example in org.texi:
,----
| (setq auto-save-default nil)
| ;; Auto-saving does not cooperate with org-crypt.el: so you need
| ;; to turn it off if you plan to use org-crypt.el quite often.
| ;; Otherwise, you'll get an (annoying) message each time you
| ;; start Org.
|
| ;; To turn it off only locally, you can insert this:
| ;;
| ;; # -*- buffer-auto-save-file-name: nil; -*-
`----
> Or, as originally proposed, the warning in the code
> could be wrapped in a customisable variable but this seems like overkill
> to me.
To me too, unless we have a clean way to disable auto-save-mode locally.
> Just my 2¢!
2thx!
--
Bastien
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt
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:05 ` [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt Bastien
0 siblings, 2 replies; 19+ messages in thread
From: Pieter Praet @ 2011-06-28 6:55 UTC (permalink / raw)
To: Bastien; +Cc: Dave Abrahams, Nick Dokos, emacs-orgmode
On Mon, 27 Jun 2011 18:31:58 +0200, Bastien <bzg@altern.org> wrote:
> Hi Pieter,
>
> Thanks for the patch at the end of this thread.
>
> Pieter Praet <pieter@praet.org> writes:
>
> > 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'.
>
> I think we should first ask emacs-devel to fix this, then implement your
> clean solution. Would you like to report this problem?
No need. It appears I'm a veritable moron, with apologies to the Emacs folks.
2 lessons I've learned today:
- DON'T test this stuff in a *scratch* buffer (seriously...)
- DO consume sufficient quantities of coffee (IOW, org-encrypt-entries
doesn't encrypt entries unless they're *tagged* to be)
> I'm not confident in disabling auto-save-mode globally by default, this
> would surprise users -- even with a **BiG WaRnInG** message.
No worries, it's buffer-local.
And I've now changed the default to "ask first, shoot in the foot later".
> What do you think?
"I should send my patch" comes to mind :)
Traffic allowing (lots of sweaty tourists on the road),
it should be there in T-10sec.
> --
> Bastien
Peace
--
Pieter
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH] org-crypt: make org-decrypt disable auto-save-mode (configurable)
2011-06-28 6:55 ` Pieter Praet
@ 2011-06-28 6:57 ` 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
1 sibling, 1 reply; 19+ messages in thread
From: Pieter Praet @ 2011-06-28 6:57 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Dave Abrahams, Bastien, Nick Dokos
As auto-save-mode can only cause leakage when there's actual decrypted
data lying around, don't check for it (and potentially cause annoyance)
on init, but only when org-decrypt-entry is called.
* lisp/org-crypt.el:
- add defcustom `org-crypt-disable-auto-save'
- `org-decrypt-entry': before decrypting, check whether
`auto-save-mode' is enabled for the current buffer, and act
on it according to how `org-crypt-disable-auto-save' is set.
- remove comment re "encrypt[ing] Org auto-saved buffers"
- remove on-init check for `auto-save-default'
Signed-off-by: Pieter Praet <pieter@praet.org>
---
lisp/org-crypt.el | 60 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 47 insertions(+), 13 deletions(-)
diff --git a/lisp/org-crypt.el b/lisp/org-crypt.el
index 4bff7a1..1ff24b9 100644
--- a/lisp/org-crypt.el
+++ b/lisp/org-crypt.el
@@ -94,6 +94,29 @@ This setting can also be overridden in the CRYPTKEY property."
:type 'string
:group 'org-crypt)
+(defcustom org-crypt-disable-auto-save 'ask
+ "What org-decrypt should do if `auto-save-mode' is enabled.
+
+t : Disable auto-save-mode for the current buffer
+ prior to decrypting an entry.
+
+nil : Leave auto-save-mode enabled.
+ This may cause data to be written to disk unencrypted!
+
+'ask : Ask user whether or not to disable auto-save-mode
+ for the current buffer.
+
+'encrypt : Leave auto-save-mode enabled for the current buffer,
+ but automatically re-encrypt all decrypted entries
+ *before* auto-saving.
+ NOTE: This only works for entries which have a tag
+ that matches `org-crypt-tag-matcher'."
+ :group 'org-crypt
+ :type '(choice (const :tag "Always" t)
+ (const :tag "Never" nil)
+ (const :tag "Ask" ask)
+ (const :tag "Encrypt" encrypt)))
+
(defun org-crypt-key-for-heading ()
"Return the encryption key for the current heading."
(save-excursion
@@ -142,6 +165,30 @@ This setting can also be overridden in the CRYPTKEY property."
(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
@@ -201,19 +248,6 @@ This setting can also be overridden in the CRYPTKEY property."
'org-mode-hook
(lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t))))
-;; FIXME Find a better way to encrypt Org auto-saved buffers?
-;; When `auto-save-default' is non-nil, make sure entries are
-;; encrypted before auto-saving
-;; (when auto-save-default
-;; (add-hook
-;; '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))
-
(add-hook 'org-reveal-start-hook 'org-decrypt-entry)
(provide 'org-crypt)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] org-crypt: make org-decrypt disable auto-save-mode (configurable)
2011-06-28 6:57 ` [PATCH] org-crypt: make org-decrypt disable auto-save-mode (configurable) Pieter Praet
@ 2011-06-28 10:04 ` Bastien
0 siblings, 0 replies; 19+ messages in thread
From: Bastien @ 2011-06-28 10:04 UTC (permalink / raw)
To: Pieter Praet; +Cc: Dave Abrahams, Nick Dokos, emacs-orgmode
Hi Pieter,
Pieter Praet <pieter@praet.org> writes:
> As auto-save-mode can only cause leakage when there's actual decrypted
> data lying around, don't check for it (and potentially cause annoyance)
> on init, but only when org-decrypt-entry is called.
Applied, thanks for this!
--
Bastien
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] org-crypt: only warn about auto-save-mode when running org-decrypt
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:05 ` Bastien
1 sibling, 0 replies; 19+ messages in thread
From: Bastien @ 2011-06-28 10:05 UTC (permalink / raw)
To: Pieter Praet; +Cc: Dave Abrahams, Nick Dokos, emacs-orgmode
Hi Pieter,
Pieter Praet <pieter@praet.org> writes:
> 2 lessons I've learned today:
> - DON'T test this stuff in a *scratch* buffer (seriously...)
> - DO consume sufficient quantities of coffee (IOW, org-encrypt-entries
> doesn't encrypt entries unless they're *tagged* to be)
:)
>> I'm not confident in disabling auto-save-mode globally by default, this
>> would surprise users -- even with a **BiG WaRnInG** message.
>
> No worries, it's buffer-local.
>
> And I've now changed the default to "ask first, shoot in the foot
> later".
This is good.
Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Documentation suggestion re: buffers containing crypted entries
2011-06-27 16:56 ` Bastien
@ 2011-06-28 13:29 ` Darlan Cavalcante Moreira
0 siblings, 0 replies; 19+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-06-28 13:29 UTC (permalink / raw)
To: Bastien; +Cc: Dave Abrahams, emacs-orgmode
I think we can disable auto-save locally using file variables, but what
org-crypt seem to check is auto-save-default and its value probably won't
change when auto-save is disabled locally.
--
Darlan Cavalcante
At Mon, 27 Jun 2011 18:56:54 +0200,
Bastien <bzg@altern.org> wrote:
>
> Hi Eric,
>
> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
> > The question is where should this information be most appropriate to
> > appear. In my view, this should be in the documentation (highlighted
> > etc), not in the Emacs mini-buffer! I don't know enough texi (any at
> > all, actually) so cannot suggest a patch. However, I would suggest that
> > the warning that is in the code be moved into the entry for org-crypt.el
> > in the info manual.
>
> I did so -- I added this to the config example in org.texi:
>
> ,----
> | (setq auto-save-default nil)
> | ;; Auto-saving does not cooperate with org-crypt.el: so you need
> | ;; to turn it off if you plan to use org-crypt.el quite often.
> | ;; Otherwise, you'll get an (annoying) message each time you
> | ;; start Org.
> |
> | ;; To turn it off only locally, you can insert this:
> | ;;
> | ;; # -*- buffer-auto-save-file-name: nil; -*-
> `----
>
> > Or, as originally proposed, the warning in the code
> > could be wrapped in a customisable variable but this seems like overkill
> > to me.
>
> To me too, unless we have a clean way to disable auto-save-mode locally.
>
> > Just my 2¢!
>
> 2thx!
>
> --
> Bastien
>
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2011-06-28 13:29 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).