commit 617e6a9edd3f3f153c87c6840de6fb49800a28a8 parent d06d12ce9f36af919568124363d466a627e36253 Author: Vincent Demeester <vincent@sbr.pm> Date: Tue, 20 Oct 2020 14:42:13 +0200 tools/emacs: enhance vc-mode 🙃 Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
M | tools/emacs/config/config-appearance.el | | | 16 | +++++++++++----- |
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/emacs/config/config-appearance.el b/tools/emacs/config/config-appearance.el @@ -158,11 +158,17 @@ questions. Else use completion to select the tab to switch to." mode-line-end-spaces (list (propertize " " 'display '(space :align-to (- right 19))) 'display-time-string)) - (defadvice vc-mode-line (after me/vc-mode-line () activate) - "Strip backend from the VC information." - (when (stringp vc-mode) - (let ((vc-text (replace-regexp-in-string "^ Git" "" vc-mode))) - (setq vc-mode vc-text)))) + (advice-add #'vc-git-mode-line-string :filter-return #'my-replace-git-status) + (defun my-replace-git-status (tstr) + (let* ((tstr (replace-regexp-in-string "Git" "" tstr)) + (first-char (substring tstr 0 1)) + (rest-chars (substring tstr 1))) + (cond + ((string= ":" first-char) ;;; Modified + (replace-regexp-in-string "^:" "~ " tstr)) + ((string= "-" first-char) ;; No change + (replace-regexp-in-string "^-" "- " tstr)) + (t tstr)))) (moody-replace-mode-line-buffer-identification) (moody-replace-vc-mode))