From f9ed422d0ad737daa7dbe466fbc6af9168613bae Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Wed, 14 Aug 2024 04:58:33 -0400 Subject: [PATCH] tweak: make `pass` buffer display more consistent --- config.org | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/config.org b/config.org index 33ec2c6..71e4fae 100644 --- a/config.org +++ b/config.org @@ -2526,6 +2526,34 @@ I use the standard Unix-style password management system, [[https://www.password (set-popup-rule! "^\\*Password-Store" :side 'right :size 0.25 :quit nil)) #+end_src +*** Tweaks + +For some unknown reason, the creators of the original =pass= package decided that when showing the pass buffer, the main dispatch function would call ~pop-to-buffer~ when it needs to be created, but ~switch-to-buffer~ when it already exists. These are different functions! Let's fix that. + +#+begin_src emacs-lisp +(defadvice! ~/pass () + "Fix inconsistent opening of `pass-mode' buffer." + :override #'pass + (if-let ((window (get-buffer-window pass-buffer-name))) + (progn + (select-window window) + (pass-update-buffer)) + (pop-to-buffer pass-buffer-name) + (pass-setup-buffer))) +#+end_src + +When visiting a password file, the file's buffer replaces the pass buffer, which isn't very good UX. To fix this, we can advise it to use ~pop-to-buffer~, folding it into the popup system. + +#+begin_src emacs-lisp +(defadvice! ~/pass-view () + "Use `find-file-other-window' instead of `find-file'." + :override #'pass-view + (pass--with-closest-entry entry + (pop-to-buffer + (find-file-noselect (concat (f-join (password-store-dir) entry) ".gpg")) + (cdr (+popup-make-rule nil '(:side bottom :size 8 :quit t :modeline t)))))) +#+end_src + * Org #+call: confpkg()