Add function to generate a date ranged diff for the current buffer
This commit is contained in:
parent
aab960a989
commit
cb4c371e5c
12
gists.org
12
gists.org
|
@ -701,6 +701,18 @@ Based on an answer at the [[https://emacs.stackexchange.com/a/77480/34645][Emacs
|
||||||
(apply-partially #'my/buffer-has-major-mode-p mode))))
|
(apply-partially #'my/buffer-has-major-mode-p mode))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
* Magit: show diff of current buffer since a given date/time :emacs:magit:
|
||||||
|
|
||||||
|
#+begin_src elisp :tangle gists/magit-diff-range-current-buffer.el
|
||||||
|
(defun my/magit-diff-since (&optional since)
|
||||||
|
"Shows the diff for the current file SINCE the given date/time."
|
||||||
|
(interactive "sSince (default 24 hours ago): ")
|
||||||
|
(let* ((revisionA (format "HEAD@{%s}" (or (and (not (string-empty-p since)) since) "24 hours ago")))
|
||||||
|
(revisionB "{worktree}")
|
||||||
|
(range (string-join (list revisionA ".." revisionB))))
|
||||||
|
(magit-diff-range range () (list (buffer-file-name)))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
* Meta
|
* Meta
|
||||||
** License
|
** License
|
||||||
|
|
||||||
|
|
7
gists/magit-diff-range-current-buffer.el
Normal file
7
gists/magit-diff-range-current-buffer.el
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
(defun my/magit-diff-since (&optional since)
|
||||||
|
"Shows the diff for the current file SINCE the given date/time."
|
||||||
|
(interactive "sSince (default 24 hours ago): ")
|
||||||
|
(let* ((revisionA (format "HEAD@{%s}" (or (and (not (string-empty-p since)) since) "24 hours ago")))
|
||||||
|
(revisionB "{worktree}")
|
||||||
|
(range (string-join (list revisionA ".." revisionB))))
|
||||||
|
(magit-diff-range range () (list (buffer-file-name)))))
|
Loading…
Reference in a new issue