diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-01-09 15:17:31 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-01-09 15:17:31 +0100 |
| commit | 0f5b2e48def25e31b19105a2612b08c3d6748def (patch) | |
| tree | 16b2c776e717ab530244e01df4043312f8924966 | |
| parent | b35cd48cd4051a0d7f41aaae15b53208a8caf66a (diff) | |
| download | dotfiles-0f5b2e48def25e31b19105a2612b08c3d6748def.tar.xz | |
Allow user to specify revision to consider for action stamps
| -rw-r--r-- | .emacs | 42 |
1 files changed, 24 insertions, 18 deletions
@@ -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. |
