diff --git a/bootstrap.org b/bootstrap.org index f8d8aaf..c8da13a 100644 --- a/bootstrap.org +++ b/bootstrap.org @@ -46,7 +46,7 @@ Helper functions to allow code for specific operating systems: With the way I start Emacs, I may not have the =PATH= I /actually/ use (from the shell) available, so we'll force it (code taken [[https://www.emacswiki.org/emacs/ExecPath][from here]]): -#+begin_src emacs-lisp :tangle no +#+begin_src emacs-lisp (defun set-exec-path-from-shell () "Set up Emacs' `exec-path' and PATH environment variable to match that used by the user's shell. @@ -81,31 +81,6 @@ Getting tired off all the packages that I load spewing a bunch of warnings that (setq native-comp-async-report-warnings-errors nil native-comp-deferred-compilation t)) #+end_src -** GNU Pretty Good Privacy -On Linux, GPG is pretty straight-forward, but on the Mac, I often have troubles doing: -#+begin_src sh - brew install gpg -#+end_src -Next, on every reboot, start the agent: -#+begin_src sh - /opt/homebrew/bin/gpg-agent --daemon -#+end_src - -Since =brew link gpg= doesn’t always work, this helper function may find the executable: -#+begin_src emacs-lisp - (defun executable (path) - "Return PATH if executable, see `file-executable-p'." - (let ((epath (first (file-expand-wildcards path)))) - (when (and epath (file-executable-p epath)) epath))) - - (use-package epa-file - :straight (:type built-in) - :custom (epg-gpg-program (or (executable "/opt/homebrew/bin/gpg") - (executable "/usr/local/bin/gpg") - (executable "/usr/local/opt/gpg") - (executable "/usr/bin/pgp"))) - :config (epa-file-enable)) -#+end_src * Basic Libraries The following packages come with Emacs, but seems like they still need loading: #+begin_src emacs-lisp @@ -120,13 +95,13 @@ Ugh. Why am I getting a missing =first= function error? I define a simple implem While most libraries will take care of their dependencies, I want to install /my dependent libraries/, e.g, [[https://github.com/magnars/.emacs.d/][Magnar Sveen]]'s Clojure-inspired [[https://github.com/magnars/dash.el][dash.el]] project: #+begin_src emacs-lisp -(use-package dash) + (use-package dash) #+end_src Sure this package is essentially syntactic sugar, and to help /share/ my configuration, I attempt to use =thread-last= instead of =->>=, but, I still like it. The [[https://github.com/magnars/s.el][s.el]] project is a simpler string manipulation library that I (and other projects) use: #+begin_src emacs-lisp -(use-package s) + (use-package s) #+end_src Manipulate file paths with the [[https://github.com/rejeep/f.el][f.el]] project: diff --git a/ha-config.org b/ha-config.org index 293e4d0..19ac844 100644 --- a/ha-config.org +++ b/ha-config.org @@ -20,7 +20,7 @@ A literate programming file for configuring Emacs. ;; ;; *NB:* Do not edit this file. Instead, edit the original literate file at: ;; ~/other/hamacs/ha-config.org - ;; Using `find-file-at-point', and tangle the file to recreate this one . + ;; Using `find-file-at-point', and tangle the file to recreate this. ;; ;;; Code: #+end_src @@ -775,63 +775,40 @@ Once we create the new perspective workspace, if it matches a particular name, I * Pretty Good Encryption For details on using GnuPG in Emacs, see Mickey Petersen’s [[https://www.masteringemacs.org/article/keeping-secrets-in-emacs-gnupg-auth-sources][GnuPG Essay]]. +On Linux, GPG is pretty straight-forward, but on the Mac, I often have troubles doing: +#+begin_src sh + brew install gpg +#+end_src +Next, on every reboot, start the agent: +#+begin_src sh + /opt/homebrew/bin/gpg-agent --daemon +#+end_src + Also, as [[https://www.bytedude.com/gpg-in-emacs/][bytedude]] mentions, I need to use the =epa-pineentry-mode= to =loopback= to actually get a prompt for the password, instead of an error. Also let's cache as much as possible, as my home machine is pretty safe, and my laptop is shutdown a lot. +#+begin_src emacs-lisp + (use-package epa-file + :straight (:type built-in) + :custom + (epg-debug t) + (auth-source-debug t) + ;; Since I normally want symmetric encryption, and don't want + ;; to use the "key selection": + (epa-file-select-keys 'symmetric-only) + ;; Make sure we prompt in the minibuffer for the password: + (epg-pinentry-mode 'loopback) + ;; I trust my Emacs session, so I don't bother expiring my pass: + (auth-source-cache-expiry nil)) +#+end_src + +Need to make sure that Emacs will handle the prompts, and turn it on: #+begin_src emacs-lisp (use-package epa-file :config - (setq epg-debug t auth-source-debug t - ;; Since I normally want symmetric encryption, and don't want - ;; to use the "key selection": - epa-file-select-keys 'symmetric-only - ;; Make sure we prompt in the minibuffer for the password: - epg-pinentry-mode 'loopback - ;; I trust my Emacs session, so I don't bother expiring my pass: - auth-source-cache-expiry nil) - ;; Make sure that for Emacs, we will handle the prompts: (setenv "GPG_AGENT_INFO" nil) (epa-file-enable)) -#+end_src - -Make sure that the following passes: -#+begin_src emacs-lisp :tangle no - (let ((macos-gpg "/opt/homebrew/bin/gpg1")) - (when (and (file-exists-p macos-gpg) - (file-executable-p macos-gpg)) - (setq epg-gpg-program macos-gpg))) -#+end_src -As well as: -#+begin_src emacs-lisp :tangle no - (let ((macos-gpg "/opt/homebrew/bin/pinentry-tty")) - (when (and (file-exists-p macos-gpg) - (file-executable-p macos-gpg)) - (setq pinentry-program macos-gpg))) #+end_src -According to [[https://emacs.stackexchange.com/questions/78140/emacs-failing-to-save-encrypted-file][this discussion]], I seem to first, downgrade the version of GPG to version 2.2: -#+begin_src sh :results replace raw :wrap example - gpg --version -#+end_src - -#+begin_example -gpg (GnuPG) 2.2.42 -libgcrypt 1.10.3 -Copyright (C) 2023 g10 Code GmbH -License GNU GPL-3.0-or-later -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law. - -Home: /Users/howard.abrams/.gnupg -Supported algorithms: -Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA -Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, - CAMELLIA128, CAMELLIA192, CAMELLIA256 -Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 -Compression: Uncompressed, ZIP, ZLIB, BZIP2 -#+end_example - -However, for Emacs 29, and even with GPG1 or GPG2.2, it still hangs when saving encrypted files. - * Technical Artifacts :noexport: Let's provide a name so we can =require= this file: #+begin_src emacs-lisp :exports none