feat: add gpgconfig.el
Signed-off-by: Lucas Sta Maria <lucas@priime.dev>
This commit is contained in:
parent
8a25d392b3
commit
feb6e8eea2
3 changed files with 56 additions and 0 deletions
|
@ -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,
|
||||||
|
|
54
.emacs.d/include/gpgconfig.el
Normal file
54
.emacs.d/include/gpgconfig.el
Normal 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
|
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue