diff options
| -rw-r--r-- | .emacs | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -186,6 +186,26 @@ ;; * executable: (info "(manual) Node"), "man 7 manual" ;; * <https://somewhe.re/manual.html#node> +(defun my/read (prompt default) + (read-string (format-prompt prompt default) nil nil default)) + +(defun my/run (program &rest args) + (let ((handler (lambda (status) + (unless (eq status 0) + (user-error + "%s returned %d:\n%s" + program status (buffer-string)))))) + (apply 'process-lines-handling-status program handler args))) + +(defun my/kill-date (date format) + (interactive + (if current-prefix-arg + (list (my/read "Date spec?" "today") + (my/read "Format?" "%F")) + (list "today" "%F"))) + (my/kill + (car (my/run "date" (concat "-d" date) (concat "+" format))))) + (defun my/kill-filename () (interactive) (my/kill (or (buffer-file-name) default-directory))) @@ -276,7 +296,8 @@ (my/define-prefix-command my/kill-map "Keymap for adding things to the kill ring." - '(("f" my/kill-filename) + '(("d" my/kill-date) + ("f" my/kill-filename) ("|" my/kill-pipe-region) ("!" my/kill-shell))) |
