Foren: Hilfe (Thread #21732)

a before-save hook in easypg? (2009-02-18 20:14 by melagin #41966)

Dear developers,

I am using easypg to encrypt my diary. I edit the diary in the longlines-mode so no hard newlines are inserted. However, after saving the file and loading it back hard newlines appear where they are not supposed to.

I think the way to go is to disable line wrapping by the longlines mode just before saving and reenable it back afterwards. However, I failed to find a suitable hook in easypg. Is there one?

If not, I think it would be great to have one in the next version :)

Thanks in advance

RE: a before-save hook in easypg? (2009-02-18 21:53 by melagin #41970)

well, I decided to scratch my own itch. Here is the patch against epg 0.0.16

< (defcustom epa-save-before-hook nil ""
< :group 'epa-file :type 'hook)
< (defcustom epa-save-after-hook nil ""
< :group 'epa-file :type 'hook)
< (run-hooks 'epa-save-before-hook)
< (message "Wrote %s" buffer-file-name)))
< (run-hooks 'epa-save-after-hook))
> (message "Wrote %s" buffer-file-name))))

This is necessary, since epg uses write-region and not save-buffer, thus circumventing standard hooks.

Reply to #41966