emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Darlan Cavalcante Moreira <darcamo@gmail.com>
To: "Rémi Letot" <hobbes@poukram.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-crypt doesn't automatically encrypt on save
Date: Fri, 12 Sep 2014 11:23:10 -0300	[thread overview]
Message-ID: <877g18291x.fsf@gmail.com> (raw)
In-Reply-To: <87r3zhktm2.fsf@poukram.net>


One note first, if you change org-modules manually like that you must
make sure this change is done before org-mode is loaded. I prefer to use
the customize interface just for org-modules for that reason.

I also add org-crypt to org-modules like you do. If I open my
password.org file and open it directly I will have the same behaviour
you get. Maybe the save magic does not work reliable when org-crypt is
loaded through org-modules, I'm not sure.

When I call my function that requires org-crypt and calls
org-crypt-use-before-save-magic before opening my password file
everything works. But I only do it like this because I have a single
file with encrypted entries and I prefer to delay loading org-crypt
initialization. I profiled my configuration some time ago and decided to
do that to reduce i little bit the initialization time.


Since you already require org-crypt, just add
"(org-crypt-use-before-save-magic)" after the require and see if that
solves your problem. 


Rémi Letot writes:

> Darlan Cavalcante Moreira <darcamo@gmail.com> writes:
>
>> You need to load org-crypt and call org-crypt-use-before-save-magic
>> before you open the org file.
>
> I have this in my config:
>
>   (add-to-list 'org-modules 'org-crypt)
>   (require 'org-crypt)
>
> So I think that's what is done. I also checked org-mode-hook on a fresh
> start of emacs, and it does include a stanza for
> org-encrypt-entries. C-h v org-mode-hook begins with this:
>
> -----
> Value: (#[nil "\300\301\302\303\304$\207"
>        [org-add-hook before-save-hook org-encrypt-entries nil t]
>        5]
> -----
>
> So I think that part is ok.
>
> Now I visit a new file, say test.org, which doesn't exist yet. I create
> one heading with a bit of content, tag it as :crypt:, and save the
> file. Bam, it's not encrypted.
>
> Now I call M-x org-encrypt-entries, and the heading is encrypted. So
> org-crypt does work, I can decrypt and encrypt headings manually, but it
> won't do it automatically. And indeed, before-save-hook is nil in a
> fresh org file and stays so when I visit an org file.
>
>
> Now I call M-x org-mode on that file, add a space so it is modified and
> I can save it, call C-x C-s, and it is encrypted as it should. org-mode
> set before-save-hook to (org-encrypt-entries t) as it should. Only I
> have to manually call org-mode once the file is open, it won't do it
> automatically.
>
> I C-x k the file, re-visit it, and I have to call M-x org-mode on it
> again before it will automatically encrypt the headings. All other
> org-mode functionnality seems to work fine.
>
> Any idea ?
>
> Thanks,

  reply	other threads:[~2014-09-12 14:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 19:44 org-crypt doesn't automatically encrypt on save Rémi Letot
2014-09-11 23:03 ` Darlan Cavalcante Moreira
2014-09-12 10:42   ` Rémi Letot
2014-09-12 14:23     ` Darlan Cavalcante Moreira [this message]
2014-09-12 16:44       ` org-mode-hook not called when entering org files (Was: Re: org-crypt doesn't automatically encrypt on save) Rémi Letot
2014-09-12 18:15         ` org-mode-hook not called when entering org files Nick Dokos
2014-09-13 19:24           ` Rémi Letot
2014-09-15 21:33             ` Nick Dokos
2014-09-16  8:27               ` Rémi Letot
2014-09-16 14:27                 ` Nick Dokos
2014-09-15 21:45             ` Nick Dokos
2014-09-12 14:42   ` org-crypt doesn't automatically encrypt on save Jorge A. Alfaro-Murillo

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=877g18291x.fsf@gmail.com \
    --to=darcamo@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=hobbes@poukram.net \
    /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).