aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/vc/vc-git.el
diff options
context:
space:
mode:
authorJuri Linkov2023-10-16 20:14:18 +0300
committerJuri Linkov2023-10-16 20:14:18 +0300
commit5827d179fb71e6fdcc63a17eb50305545ede2f37 (patch)
treeda71d5d675471b1b8e75cae35a3921cf29616082 /lisp/vc/vc-git.el
parent484fc70a7acc5a958bfeefa4b83255680c7da175 (diff)
downloademacs-5827d179fb71e6fdcc63a17eb50305545ede2f37.tar.gz
emacs-5827d179fb71e6fdcc63a17eb50305545ede2f37.zip
Refactor 'vc-default-mode-line-string' (bug#66464)
* lisp/vc/vc-hooks.el (vc-mode-line-state): New function with code moved from 'vc-default-mode-line-string'. (vc-default-mode-line-string): Use 'vc-mode-line-state'. * lisp/vc/vc-git.el (vc-git-mode-line-string): Use 'vc-mode-line-state' instead of hacking the string returned from 'vc-default-mode-line-string'. * lisp/vc/vc-hg.el (vc-hg-mode-line-string): Use 'vc-mode-line-state' instead of duplicating code from 'vc-default-mode-line-string'.
Diffstat (limited to 'lisp/vc/vc-git.el')
-rw-r--r--lisp/vc/vc-git.el21
1 files changed, 12 insertions, 9 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 5c21a5b884e..9ec45c59893 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -416,15 +416,18 @@ in the order given by `git status'."
416 416
417(defun vc-git-mode-line-string (file) 417(defun vc-git-mode-line-string (file)
418 "Return a string for `vc-mode-line' to put in the mode line for FILE." 418 "Return a string for `vc-mode-line' to put in the mode line for FILE."
419 (let* ((rev (vc-working-revision file 'Git)) 419 (pcase-let* ((backend-name "Git")
420 (disp-rev (or (vc-git--symbolic-ref file) 420 (state (vc-state file))
421 (and rev (substring rev 0 7)))) 421 (`(,state-echo ,face ,indicator)
422 (def-ml (vc-default-mode-line-string 'Git file)) 422 (vc-mode-line-state state))
423 (help-echo (get-text-property 0 'help-echo def-ml)) 423 (rev (vc-working-revision file 'Git))
424 (face (get-text-property 0 'face def-ml))) 424 (disp-rev (or (vc-git--symbolic-ref file)
425 (propertize (concat (substring def-ml 0 4) disp-rev) 425 (and rev (substring rev 0 7))))
426 'face face 426 (state-string (concat backend-name indicator disp-rev)))
427 'help-echo (concat help-echo "\nCurrent revision: " rev)))) 427 (propertize state-string 'face face 'help-echo
428 (concat state-echo " under the " backend-name
429 " version control system"
430 "\nCurrent revision: " rev))))
428 431
429(cl-defstruct (vc-git-extra-fileinfo 432(cl-defstruct (vc-git-extra-fileinfo
430 (:copier nil) 433 (:copier nil)