emacs: Add mail encryption, fix some hooks.

Remove hard coded org-crypt key, fix dead keys input.
This commit is contained in:
Kevin Baensch 2019-12-18 09:08:23 +01:00
parent 345c054448
commit 6987397142
Signed by: derped
GPG key ID: C0F1D326C7626543
3 changed files with 49 additions and 16 deletions

View file

@ -90,6 +90,9 @@ in rec {
;; Hook for when a frame is created with emacsclient ;; Hook for when a frame is created with emacsclient
;; see https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Frames.html ;; see https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Frames.html
(add-hook 'after-make-frame-functions 'set-fonts) (add-hook 'after-make-frame-functions 'set-fonts)
;; Fix keyboard input of 'dead-keys'
(require 'iso-transl)
''; '';
}; };

View file

@ -2,17 +2,42 @@
with lib; with lib;
mkIf (elem "emacs::mu4e" config.machine.pkgs) { let
defaultEncrypt = pkgs.emacsPackages.trivialBuild rec {
pname = "defaultencrypt";
version = "ba07acc8e9fd692534c39c7cdad0a19dc0d897d9";
src = pkgs.fetchFromGitLab {
owner = "lechten";
repo = pname;
rev = version;
sha256 = "1ln7h1syx7yi7bqvirv90mk4rvwxg4zm1wvfcvhfh64s3hqrbfgl";
};
};
in mkIf (elem "emacs::mu4e" config.machine.pkgs) {
programs.emacs.init.usePackage.pinentry = {
enable = true;
command = [ "pinentry-start" ];
hook = [ "(after-init . pinentry-start)" ];
};
programs.emacs.init.usePackage.mu4e = { programs.emacs.init.usePackage.mu4e = {
enable = true; enable = true;
package = epkgs: null; package = epkgs: null;
command = [ "mu4e" ]; command = [ "mu4e" ];
diminish = [ "mu4e-mode" ]; diminish = [ "mu4e-mode" ];
hook = [ hook = [
"('mu4e-view-mode-hook #'visual-line-mode)" "(mu4e-view-mode . visual-line-mode)"
"('mu4e-compose-mode-hook 'flyspell-mode)" "(mu4e-compose-mode . flyspell-mode)"
''(message-send . (lambda ()
(unless (yes-or-no-p "Send this message?")
(signal 'quit nil))))''
]; ];
bind = { "\t" = "'company-complete-common"; }; bind = { "\t" = "'company-complete-common"; };
init = ''
(add-to-list 'load-path "${defaultEncrypt}/share/emacs/site-lisp")
(require 'jl-encrypt)
'';
config = '' config = ''
(setq mail-user-agent 'mu4e-user-agent) (setq mail-user-agent 'mu4e-user-agent)
(setq org-mu4e-link-query-in-headers-mode t) (setq org-mu4e-link-query-in-headers-mode t)
@ -46,9 +71,12 @@ mkIf (elem "emacs::mu4e" config.machine.pkgs) {
(imagemagick-register-types)) (imagemagick-register-types))
(setq message-kill-buffer-on-exit t) (setq message-kill-buffer-on-exit t)
;; Encryption Stuff
;; mailAcc config goes here (setq mml-secure-openpgp-sign-with-sender t)
;; (setq mm-sign-option guided)
(setq epa-pinentry-mode 'loopback)
;; mailAcc config goes here
(load-file "~/.emacs.d/mu4e.el")
(defun my-browse-url-firefox-privately (url &optional new-window) (defun my-browse-url-firefox-privately (url &optional new-window)
"Make firefox open URL in private-browsing window." "Make firefox open URL in private-browsing window."
@ -64,21 +92,21 @@ mkIf (elem "emacs::mu4e" config.machine.pkgs) {
'("ViewInBrowser" . mu4e-action-view-in-browser) t) '("ViewInBrowser" . mu4e-action-view-in-browser) t)
''; '';
extraConfig = '' extraConfig = ''
:load-path ${pkgs.mu4e}/share/emacs/site-lisp/mu4e :load-path "${pkgs.mu}/share/emacs/site-lisp/mu4e"
''; '';
}; };
programs.emacs.init.usePackage.mu4e-alert = { programs.emacs.init.usePackage.mu4e-alert = {
enable = true; enable = true;
hook = [ "'after-init-hook #'mu4e-alert-enable-mode-line-display" ]; # hook = [ "after-init . mu4e-alert-enable-mode-line-display" ];
}; };
programs.emacs.init.usePackage.org-mu4e = { # programs.emacs.init.usePackage.org-mu4e = {
enable = (elem "emacs::org" config.machine.pkgs); # enable = (elem "emacs::org" config.machine.pkgs);
}; # };
environment.systemPackages = [ environment.systemPackages = with pkgs; [
mu4e mu
isync isync
]; ];
} }

View file

@ -399,17 +399,19 @@ mkIf (elem "emacs::org" config.machine.pkgs) {
programs.emacs.init.usePackage.org-crypt = { programs.emacs.init.usePackage.org-crypt = {
enable = true; enable = true;
after = [ "org" ]; after = [ "org" ];
hook = [ "(org-mode . (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t)))" ];
command = [ "org-decrypt-entry" "org-encrypt-entry" ];
bindLocal = { org-mode-map = { bindLocal = { org-mode-map = {
"C-c d" = "org-decrypt-entry"; "C-c d" = "org-decrypt-entry";
"C-c e" = "org-encrypt-entry"; "C-c e" = "org-encrypt-entry";
};}; };};
config = '' config = ''
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance (quote ("crypt"))) (setq org-tags-exclude-from-inheritance (quote ("crypt")))
;; GPG key to use for encryption ;; GPG key to use for encryption
(setq org-crypt-key "BD9667B90757EAE9CDFE510A59A28744FE81FFEB") (load-file ~/.emacs.d/org-crypt-key.el)
;; don't ask to disable auto-save ;; don't ask to disable auto-save
(setq org-crypt-disable-auto-save nil) (setq org-crypt-disable-auto-save "encrypt")
''; '';
}; };