summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.emacs42
1 files changed, 24 insertions, 18 deletions
diff --git a/.emacs b/.emacs
index 35fd2e9..35ab4f8 100644
--- a/.emacs
+++ b/.emacs
@@ -195,24 +195,30 @@
;; in stone, and I would miss out on future updates by Magit.
(add-hook 'git-commit-setup-hook 'git-commit-turn-on-flyspell)
-(defun my/action-stamp-at-point ()
- (interactive)
- (when-let ((rev (cond
- ;; TODO: add vc support.
- ((derived-mode-p 'magit-mode)
- (magit-branch-or-commit-at-point)))))
- (let* ((cmd "git show --no-patch --date=unix --format='%ad!%ae'")
- (git-info (shell-command-to-string (format "%s %s" cmd rev))))
- (pcase git-info
- ((rx (let timestamp-str (+ digit))
- "!"
- (let mail (+ anychar))
- "\n")
- (let* ((timestamp (string-to-number timestamp-str))
- (date (format-time-string "%FT%TZ" timestamp t))
- (action-stamp (format "%s!%s" date mail)))
- (kill-new action-stamp)
- (message action-stamp)))))))
+(defun my/revision-at-point ()
+ (cond
+ ;; TODO: add vc support.
+ ((derived-mode-p 'magit-mode)
+ (magit-branch-or-commit-at-point))))
+
+(defun my/action-stamp-at-point (rev)
+ (interactive
+ (list
+ (let* ((rev (my/revision-at-point))
+ (prompt (if rev (format "Revision? (%s) " rev) "Revision? ")))
+ (read-string prompt nil nil rev))))
+ (let* ((cmd "git show --no-patch --date=unix --format='%ad!%ae'")
+ (git-info (shell-command-to-string (format "%s %s" cmd rev))))
+ (pcase git-info
+ ((rx (let timestamp-str (+ digit))
+ "!"
+ (let mail (+ anychar))
+ "\n")
+ (let* ((timestamp (string-to-number timestamp-str))
+ (date (format-time-string "%FT%TZ" timestamp t))
+ (action-stamp (format "%s!%s" date mail)))
+ (kill-new action-stamp)
+ (message action-stamp))))))
;; rg re-binds C-n and C-p. I loathe arrow keys for regular movement,
;; and n and p are laggy because they visit the matched files.