diff options
| author | Jakob L. Kreuze | 2020-06-01 16:53:50 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze | 2020-06-01 16:53:50 -0400 |
| commit | 6c7f0b8ae2de30a808901b16b0d462fe833ea1b4 (patch) | |
| tree | 2cc0a3e9022fc43c39e5b91f4e7832b5387636e9 /lisp/jakob.el | |
| parent | 4d4f759881e310818055c31f286158da9db60d1c (diff) | |
Break config into files.
Diffstat (limited to 'lisp/jakob.el')
| -rw-r--r-- | lisp/jakob.el | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/lisp/jakob.el b/lisp/jakob.el new file mode 100644 index 0000000..f720d7e --- /dev/null +++ b/lisp/jakob.el @@ -0,0 +1,81 @@ +;;; jakob.el -*- lexical-binding: t; -*- +;;; +;;; Author: Jakob L. Kreuze <zerodaysfordays@sdf.org> +;;; URL: https://git.sr.ht/~jakob/.emacs.d/ +;;; +;;; Custom elisp written by yours truly that is independent of any particular +;;; package. +;;; + + +;;; +;;; Configuration. +;;; + +;; Bind some keys for working with this configuration file. + +(defun config-goto () + "Switch to a buffer visiting the config file." + (interactive) + (find-file "~/.emacs.d/init.el")) + +(bind-key "C-c e" #'config-goto) + + +;;; +;;; pass +;;; + +;; TODO: Replace with pass.el? + +;; Here's a snippet for interactively pulling a password from password-store, so +;; I'm not spawning a terminal every time I need to invoke my password manager. + +(defvar password-store-directory "~/.password-store" + "Directory containing passwords managed by `pass'.") + +(defun pass-password-files () + "Returns the paths of every password managed by `pass'." + (let ((prefix-length (1+ (length password-store-directory))) + (suffix-length (length ".gpg"))) + (map 'list + #'(lambda (path) (cl-subseq path prefix-length (- suffix-length))) + (directory-files-recursively password-store-directory ".gpg$")))) + +(defun pass () + "Prompt for a password and copy it to the clipboard. +Passwords are taken from `password-store-directory'." + (interactive) + (let* ((account (completing-read "Account: " (pass-password-files))) + (path (concat password-store-directory "/" account ".gpg"))) + (with-temp-buffer + (insert-file-contents path) + (clipboard-kill-ring-save 1 (1- (buffer-end 1)))) + (message "Password for %s copied to clipboard." account))) + + +;;; +;;; 8-ball +;;; + +;; A little snippet for getting an answer to a dumb question. Responses were +;; lifted from Wikipedia's page [1] about the toy. +;; +;; [1]: https://en.wikipedia.org/wiki/Magic_8-Ball + +(defun consult () + "Consult the magic 8-ball. +Interactive function to consult the magic 8-ball for answers to +very important questions." + (interactive) + (let ((responses (list "It is certain." "It is decidedly so." + "Without a doubt." "Yes - definitely." + "You may rely on it." "As I see it, yes." + "Most likely." "Outlook good." "Yes." + "Signs point to yes." "Reply hazy, try again." + "Ask again later." "Better not tell you now." + "Cannot predict now." "Concentrate and ask again." + "Don't count on it." "My reply is no." + "My sources say no." "Outlook not so good." + "Very doubtful."))) + (message (elt responses (mod (random) (length responses)))))) |