about summary refs log tree commit diff
path: root/users
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-12-11T21·33-0800
committerwpcarro <wpcarro@gmail.com>2022-12-12T18·38+0000
commit133a38e8f6af6f90d536383fc8ea5d6283e8c246 (patch)
tree5eb4e12d3eb123fce4e03b90b0b823f9bb90d5f6 /users
parent36d4a7c2fa30431aa54f301b1b7765bcf4ecbe88 (diff)
feat(wpcarro/emacs): Support passage.el r/5408
Intentionally-feature-incomplete Elisp integration with `passage`.

Change-Id: Ia46ddb93ac7df1f91b9d9221ac8fbe5f11010f97
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7559
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
Diffstat (limited to 'users')
-rw-r--r--users/wpcarro/emacs/.emacs.d/wpc/keybindings.el3
-rw-r--r--users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el2
-rw-r--r--users/wpcarro/emacs/default.nix2
-rw-r--r--users/wpcarro/emacs/pkgs/passage/README.md12
-rw-r--r--users/wpcarro/emacs/pkgs/passage/default.nix12
-rw-r--r--users/wpcarro/emacs/pkgs/passage/passage.el65
6 files changed, 92 insertions, 4 deletions
diff --git a/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el b/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el
index e9d4bdd5e4de..1c853ea6cd3d 100644
--- a/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el
+++ b/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el
@@ -47,6 +47,7 @@
 (require 'key-chord)
 (require 'edebug)
 (require 'avy)
+(require 'passage)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Helper Functions
@@ -207,7 +208,7 @@
 (keybindings-exwm "<M-tab>" #'window-manager-next-workspace)
 (keybindings-exwm "<M-S-iso-lefttab>" #'window-manager-prev-workspace)
 (keybindings-exwm "C-S-f" #'window-manager-toggle-previous)
-(keybindings-exwm "C-M-\\" #'ivy-pass)
+(keybindings-exwm "C-M-\\" #'passage-select)
 
 (defun keybindings-copy-emoji ()
   "Select an emoji from the completing-read menu."
diff --git a/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el b/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el
index fced698b433a..7a5605cdcad5 100644
--- a/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el
+++ b/users/wpcarro/emacs/.emacs.d/wpc/wpc-ui.el
@@ -109,8 +109,6 @@
   (unless constants-ci?
     (prescient-persist-mode 1)))
 
-(use-package ivy-pass)
-
 ;; all-the-icons
 (use-package all-the-icons
   :config
diff --git a/users/wpcarro/emacs/default.nix b/users/wpcarro/emacs/default.nix
index 3af7d2648cc8..eb6fd8e5a0f3 100644
--- a/users/wpcarro/emacs/default.nix
+++ b/users/wpcarro/emacs/default.nix
@@ -49,6 +49,7 @@ let
       list
       macros
       maybe
+      passage
       set
       string
       struct
@@ -107,7 +108,6 @@ let
       helpful
       ivy
       ivy-clipmenu
-      ivy-pass
       ivy-prescient
       key-chord
       lispyville
diff --git a/users/wpcarro/emacs/pkgs/passage/README.md b/users/wpcarro/emacs/pkgs/passage/README.md
new file mode 100644
index 000000000000..51f7bd6efda4
--- /dev/null
+++ b/users/wpcarro/emacs/pkgs/passage/README.md
@@ -0,0 +1,12 @@
+# passage.el
+
+Emacs support for `passage`.
+
+## Alternative Packages
+
+If you're looking for more feature-complete, configurable alternatives,
+check-out the following packages:
+
+- `ivy-pass.el`
+- `password-store.el`
+- `pass.el`
diff --git a/users/wpcarro/emacs/pkgs/passage/default.nix b/users/wpcarro/emacs/pkgs/passage/default.nix
new file mode 100644
index 000000000000..ac87f193b4e2
--- /dev/null
+++ b/users/wpcarro/emacs/pkgs/passage/default.nix
@@ -0,0 +1,12 @@
+{ pkgs, depot, ... }:
+
+pkgs.callPackage
+  ({ emacsPackages }:
+  emacsPackages.trivialBuild {
+    pname = "passage";
+    version = "1.0.0";
+    src = ./passage.el;
+    packageRequires = (with emacsPackages; [ dash f s ]);
+  }
+  )
+{ }
diff --git a/users/wpcarro/emacs/pkgs/passage/passage.el b/users/wpcarro/emacs/pkgs/passage/passage.el
new file mode 100644
index 000000000000..4a43920e0bed
--- /dev/null
+++ b/users/wpcarro/emacs/pkgs/passage/passage.el
@@ -0,0 +1,65 @@
+;;; passage.el --- Emacs passage support -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2022-2023 William Carroll <wpcarro@gmail.com>
+
+;; Author: William Carroll <wpcarro@gmail.com>
+;; Version: 1.0.0
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This package provides functions for working with passage.
+
+;;; Code:
+
+(require 'dash)
+(require 'f)
+(require 's)
+
+(defgroup passage nil
+  "Customization options for `passage'."
+  :prefix "passage-"
+  :group 'vterm)
+
+(defcustom passage-store
+  "~/.passage/store"
+  "Path to the passage store directory."
+  :type 'string
+  :group 'passage)
+
+(defcustom passage-executable
+  (or (executable-find "passage")
+      "/nix/store/jgffkfdiiwiqa4zqpxn3691mx9xc6axa-passage-unstable-2022-05-01/bin/passage")
+  "Path to passage executable."
+  :type 'string
+  :group 'passage)
+
+(defun passage-select ()
+  "Select an entry and copy its password to the kill ring."
+  (interactive)
+  (let ((key (completing-read "Copy password of entry: "
+                              (-map (lambda (x)
+                                      (f-no-ext (f-relative x passage-store)))
+                                    (f-files passage-store nil t)))))
+    (kill-new
+     (s-trim-right
+      (shell-command-to-string
+       (format "%s show %s | head -1" passage-executable key))))
+    (message "[passage.el] Copied \"%s\"!" key)))
+
+(provide 'passage)
+;;; passage.el ends here