1
0
Fork 0

feat: add gpgconfig.el

Signed-off-by: Lucas Sta Maria <lucas@priime.dev>
This commit is contained in:
Lucas Sta Maria 2023-08-06 19:04:47 -07:00
parent 8a25d392b3
commit feb6e8eea2
No known key found for this signature in database
GPG key ID: F07FB16A826E3B47
3 changed files with 56 additions and 0 deletions

View file

@ -50,6 +50,7 @@
general.el, general.el,
misc.el, misc.el,
utils.el, utils.el,
gpgconfig.el,
orgconfig.el, orgconfig.el,
mu4econfig.el, mu4econfig.el,
racket.el, racket.el,

View file

@ -0,0 +1,54 @@
;;; gpg.el --- Functions for working with gpg
;;; Commentary:
;; Functions for working with gpg.
;;; Code:
(defun gpg-public-keys ()
"Produces a list of GPG public keys."
(interactive)
(let ((buf (get-buffer-create "*gpg-public-keys*"))
(info (list))
(keyid "")
(curline ""))
(with-current-buffer buf
(insert (shell-command-to-string "gpg -k"))
(goto-char (point-min))
;; Clear the prelude
(forward-line 2)
(delete-region (point-min) (point))
(goto-char (point-min))
;; Collect IDs, names, and emails
(while (not (eobp))
(setq curline (thing-at-point 'line t))
(forward-line)
(cond ((string-prefix-p " " curline)
(setq keyid (car (split-string curline))))
((string-prefix-p "uid" curline)
(let* ((original-length (length curline))
(start-raw (concat (memq (string-to-char "]")
(string-to-list curline))))
(start (+ 2 (- original-length
(length start-raw))))
(name-email (substring curline start -1))
(keyid-name-email (concat keyid " " name-email)))
(if (not (memq (string-to-char "(")
(string-to-list name-email)))
(push keyid-name-email info)
;; Remove key descriptions inside parentheses
(let* ((open-paren-start
(length (concat (memq (string-to-char "(")
(string-to-list name-email)))))
(name-part (substring name-email 0 (- open-paren-start)))
(close-paren-start
(length (concat (memq (string-to-char ")")
(string-to-list name-email)))))
(email-part (substring name-email
(+ 2 (- close-paren-start))))
(sanitized (concat keyid " " name-part email-part)))
(push sanitized info)))))))
(setq info (-filter (lambda (s) (not (string-match "image" s))) info))
info)))
(provide 'gpgconfig)
;;; gpgconfig.el ends here

View file

@ -81,6 +81,7 @@
(load-library "latexconfig") (load-library "latexconfig")
(load-library "cppconfig") (load-library "cppconfig")
(load-library "pdfconfig") (load-library "pdfconfig")
(load-library "gpgconfig")
;; ====== Hooks ============================== ;; ====== Hooks ==============================
(add-hook 'after-init-hook 'global-company-mode) (add-hook 'after-init-hook 'global-company-mode)