Skip to content

Commit 5544f63

Browse files
committed
complete
1 parent 8c89e6c commit 5544f63

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

Eask

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313

1414
(depends-on "emacs" "27.1")
1515
(depends-on "sideline")
16+
(depends-on "vc-msg")
1617

1718
(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432

sideline-blame.el

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
;; Maintainer: Shen, Jen-Chieh <jcs090218@gmail.com>
77
;; URL: https://github.com/emacs-sideline/sideline-blame
88
;; Version: 0.1.0
9-
;; Package-Requires: ((emacs "27.1") (sideline "0.1.0"))
9+
;; Package-Requires: ((emacs "27.1") (sideline "0.1.0") (vc-msg "1.1.1"))
1010
;; Keywords: sideline blame
1111

1212
;; This file is not part of GNU Emacs.
@@ -32,12 +32,72 @@
3232
;;; Code:
3333

3434
(require 'sideline)
35+
(require 'vc-msg)
3536

3637
(defgroup sideline-blame nil
3738
"Show blame messages with sideline."
3839
:prefix "sideline-blame-"
3940
:group 'tool
4041
:link '(url-link :tag "Repository" "https://github.com/emacs-sideline/sideline-blame"))
4142

43+
(defcustom sideline-blame-author-format "%s, "
44+
"Format string for author name."
45+
:type 'string
46+
:group 'sideline-blame)
47+
48+
(defcustom sideline-blame-datetime-format "%b %d %Y %H:%M:%S "
49+
"Format string for datetime."
50+
:type 'string
51+
:group 'sideline-blame)
52+
53+
(defcustom sideline-blame-commit-format "◉ %s"
54+
"Format string for commit message."
55+
:type 'string
56+
:group 'sideline-blame)
57+
58+
(defcustom sideline-blame-uncommitted-author-name "Unknown"
59+
"Message for commits where you are author."
60+
:type 'string
61+
:group 'sideline-blame)
62+
63+
(defcustom sideline-blame-uncommitted-message "Uncommitted changes"
64+
"Message for uncommitted lines."
65+
:type 'string
66+
:group 'sideline-blame)
67+
68+
;;;###autoload
69+
(defun sideline-blame (command)
70+
"Backend for sideline.
71+
72+
Argument COMMAND is required in sideline backend."
73+
(cl-case command
74+
(`candidates (cons :async #'sideline-blame--get-message))))
75+
76+
(defun sideline-blame--get-message (callback &rest _)
77+
"Return the message.
78+
79+
Execute CALLBACK to display with sideline."
80+
(when-let*
81+
((plugin (vc-msg-find-plugin))
82+
(current-file (funcall vc-msg-get-current-file-function))
83+
(executer (plist-get plugin :execute))
84+
(formatter (plist-get plugin :format))
85+
(commit-info (and current-file
86+
(funcall executer
87+
current-file
88+
(funcall vc-msg-get-line-num-function)
89+
(funcall vc-msg-get-version-function))))
90+
(id (plist-get commit-info :id)))
91+
(let* ((uncommitted (zerop (string-to-number id)))
92+
(author (if uncommitted sideline-blame-uncommitted-author-name
93+
(plist-get commit-info :author)))
94+
(time (string-to-number (plist-get commit-info :author-time)))
95+
(summary (if uncommitted sideline-blame-uncommitted-message
96+
(plist-get commit-info :summary))))
97+
(funcall callback
98+
(list (concat (format sideline-blame-author-format author)
99+
(format-time-string sideline-blame-datetime-format time)
100+
(format sideline-blame-commit-format summary)))))))
101+
42102
(provide 'sideline-blame)
43103
;;; sideline-blame.el ends here

0 commit comments

Comments
 (0)