summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2020-01-09 15:01:13 +0100
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2020-01-09 15:01:13 +0100
commitb35cd48cd4051a0d7f41aaae15b53208a8caf66a (patch)
treebdccbfb10e5896e1f95184bc23e5c48d2e4c1225
parent92b4f8edb2e26f0e38bf664504d8ea773faffae9 (diff)
downloaddotfiles-b35cd48cd4051a0d7f41aaae15b53208a8caf66a.tar.xz
Add a function to create action stamp from Magit buffer
-rw-r--r--.emacs19
1 files changed, 19 insertions, 0 deletions
diff --git a/.emacs b/.emacs
index e813ab6..35fd2e9 100644
--- a/.emacs
+++ b/.emacs
@@ -195,6 +195,25 @@
;; 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)))))))
+
;; 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.
;; Since I can't blame anyone for telling me "It's 2019; use the arrow