[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vc-got 2d83de2 074/145: implement vc-got-dir-printer
From: |
ELPA Syncer |
Subject: |
[elpa] externals/vc-got 2d83de2 074/145: implement vc-got-dir-printer |
Date: |
Thu, 9 Sep 2021 15:58:36 -0400 (EDT) |
branch: externals/vc-got
commit 2d83de2ecf9274d3ab0469cabb968114d1d1bedb
Author: Omar Polo <op@omarpolo.com>
Commit: Omar Polo <op@omarpolo.com>
implement vc-got-dir-printer
This way we can control how each file gets displayed in the *vc-dir*
buffer and display the staged information.
The advice around vc-dir-move-to-goal-column is needed otherwise `n'
and `p' moves the cursor to the wrong column. vc-dir.el hardcodes
that value to 25.
---
vc-got.el | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 64 insertions(+), 8 deletions(-)
diff --git a/vc-got.el b/vc-got.el
index 4421901..23070ec 100755
--- a/vc-got.el
+++ b/vc-got.el
@@ -35,7 +35,7 @@
;; * state DONE
;; - dir-status-files DONE
;; - dir-extra-headers DONE
-;; - dir-printer NOT IMPLEMENTED
+;; - dir-printer DONE
;; - status-fileinfo-extra NOT IMPLEMENTED
;; * working-revision DONE
;; * checkout-model DONE
@@ -134,6 +134,10 @@
(require 'vc)
(require 'vc-annotate)
+;; FIXME: avoid loading this? We only need it for
+;; vc-dir-filename-mouse-map in our custom printer.
+(require 'vc-dir)
+
(require 'vc-got-stage)
(defgroup vc-got nil
@@ -233,17 +237,19 @@ files)."
(cl-loop until (eobp)
;; the format of each line is
;; <status-char> <stage-char> <spc> <filename> \n
- collect (let* ((file-status (prog1 (char-after)
+ collect (let* ((file-status (prog1 (vc-got--parse-status-char
+ (char-after))
(forward-char)))
- (stage-status (prog1 (char-after)
+ (stage-status (prog1 (vc-got--parse-stage-char
+ (char-after))
(forward-char)))
(filename (progn
(forward-char)
(buffer-substring (point)
(line-end-position)))))
(list filename
- (vc-got--parse-status-char file-status)
- (vc-got--parse-stage-char stage-status)))
+ (or file-status (and stage-status
'up-to-date))
+ stage-status))
do (forward-line))))))
(defun vc-got--parse-status-char (c)
@@ -262,9 +268,9 @@ files)."
(defun vc-got--parse-stage-char (c)
"Parse the stage status char C into a symbol."
(cl-case c
- (?M 'edited)
- (?A 'added)
- (?D 'removed)))
+ (?M 'edit)
+ (?A 'add)
+ (?D 'remove)))
(defun vc-got--tree-parse ()
"Parse into an alist the output of got tree -i in the current buffer."
@@ -426,6 +432,44 @@ FILES is nil, consider all the files in DIR."
(propertize "Branch : " 'face 'font-lock-type-face)
(vc-got--current-branch)))
+(defun vc-got-dir-printer (info)
+ "Pretty-printer for the vc-dir-fileinfo structure INFO."
+ (let* ((isdir (vc-dir-fileinfo->directory info))
+ (state (if isdir "" (vc-dir-fileinfo->state info)))
+ (stage-state (vc-dir-fileinfo->extra info))
+ (filename (vc-dir-fileinfo->name info)))
+ (insert
+ (propertize
+ (format "%c" (if (vc-dir-fileinfo->marked info) ?* ? ))
+ 'face 'font-lock-type-face)
+ " "
+ (propertize
+ (format "%-14s" state)
+ 'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face)
+ ((memq state '(missing conflict)) 'font-lock-warning-face)
+ ((eq state 'edited) 'font-lock-constant-face)
+ (t 'font-lock-variable-name-face))
+ 'mouse-face 'highlight)
+ " "
+ (propertize
+ (if stage-state
+ (format "staged:%-7s" stage-state)
+ (format "%-14s" ""))
+ 'face (cond ((memq stage-state '(add edit)) 'font-lock-constant-face)
+ ((eq stage-state 'remove) 'font-lock-warning-face)
+ (t 'font-lock-variable-name-face)))
+ " "
+ (propertize
+ (format "%s" filename)
+ 'face
+ (if isdir 'font-lock-comment-delimiter-face
'font-lock-function-name-face)
+ 'help-echo
+ (if isdir
+ "Directory\nVC operations can be applied to it\nmouse-3: Pop-up menu"
+ "File\nmouse-3: Pop-up menu")
+ 'mouse-face 'highlight
+ 'keymap vc-dir-filename-mouse-map))))
+
(defun vc-got-working-revision (file)
"Return the id of the last commit that touched the FILE or \"0\" for a new
(but added) file."
(or
@@ -697,5 +741,17 @@ Value is returned as floating point fractional number of
days."
(forward-line))
found)))))
+
+;; hacks
+(defun vc-got-fix-dir-move-to-goal-column (fn)
+ "Move the cursor on the file column.
+Adviced around vc-dir-move-to-goal-column because it hardcodes column 25."
+ (if (not (vc-find-root default-directory ".got"))
+ (funcall fn)
+ (beginning-of-line)
+ (unless (eolp)
+ (forward-char 34))))
+(advice-add 'vc-dir-move-to-goal-column :around
#'vc-got-fix-dir-move-to-goal-column)
+
(provide 'vc-got)
;;; vc-got.el ends here
- [elpa] externals/vc-got 8da4c01 049/145: remove debugging comments, (continued)
- [elpa] externals/vc-got 8da4c01 049/145: remove debugging comments, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 3f25d9f 051/145: add vc-got-annotate (#4), ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 8228942 050/145: fix vc-got-dir-status-files, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got fab791a 052/145: vc-got--call flatten and filter arg list, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 8b635a9 054/145: implement repository-url, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got c27df03 055/145: print more info in vc-got-dir-extra-headers, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got a96df0e 056/145: provide unregister and delete-file commands (#7), ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 3d2d3c3 059/145: drop vc-got-unregister, not used, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got c819459 077/145: trap c-g during stage operation, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got eacbf76 065/145: don't hardcode got questions, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 2d83de2 074/145: implement vc-got-dir-printer,
ELPA Syncer <=
- [elpa] externals/vc-got 43c93a8 063/145: typo, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 6eea6cf 075/145: drop unnecessary `:group's directive in defcustom, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 8ed796d 062/145: vc-got-dir-status-files: show changes in subdirs, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got ffa81a1 067/145: typo, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 6b6c8a7 064/145: fundamentals for staging changes, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 93562d9 073/145: fix default directory during stage operation, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 67332ba 076/145: docs fixes, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 5b4a6b9 069/145: more docs, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got a323f60 071/145: show list of files when committing staged stuff, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got daae979 066/145: implement vc-got-stage-commit to commit staged changes, ELPA Syncer, 2021/09/09