From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darlan Cavalcante Moreira Subject: Re: org-crypt doesn't automatically encrypt on save Date: Fri, 12 Sep 2014 11:23:10 -0300 Message-ID: <877g18291x.fsf@gmail.com> References: <87y4tqkkmv.fsf@poukram.net> <87egvh4v54.fsf@gmail.com> <87r3zhktm2.fsf@poukram.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSS55-0001gS-6h for emacs-orgmode@gnu.org; Fri, 12 Sep 2014 10:44:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XSS4w-0008R5-Or for emacs-orgmode@gnu.org; Fri, 12 Sep 2014 10:44:11 -0400 Received: from mail-qg0-x232.google.com ([2607:f8b0:400d:c04::232]:48030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSS4w-0008Ql-LZ for emacs-orgmode@gnu.org; Fri, 12 Sep 2014 10:44:02 -0400 Received: by mail-qg0-f50.google.com with SMTP id z60so845384qgd.9 for ; Fri, 12 Sep 2014 07:43:59 -0700 (PDT) In-reply-to: <87r3zhktm2.fsf@poukram.net> 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: =?utf-8?Q?R=C3=A9mi?= Letot Cc: emacs-orgmode@gnu.org 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 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,