aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Kågedal <david@virtutech.com>2009-12-04 08:55:01 +0100
committerDavid Kågedal <david@virtutech.com>2009-12-04 08:55:01 +0100
commit43ee50b6b9f99abd4c11915ec87776e745b0df37 (patch)
treeaa7dadf88622f71a5ab98c586901bd68ecb9f002
parent0b9ea6b8c230e531546ae67c797bc486605e2e54 (diff)
downloadstgit-43ee50b6b9f99abd4c11915ec87776e745b0df37.tar.gz
stgit.el: Use format-spec when formatting file information
Signed-off-by: David Kågedal <david@virtutech.com>
-rw-r--r--contrib/stgit.el62
1 files changed, 37 insertions, 25 deletions
diff --git a/contrib/stgit.el b/contrib/stgit.el
index aa9f14c..dbfce0f 100644
--- a/contrib/stgit.el
+++ b/contrib/stgit.el
@@ -90,6 +90,22 @@ format characters are recognized:
:group 'stgit
:set 'stgit-set-default)
+(defcustom stgit-file-line-format " %-11s %-2m %n %c"
+ "The format string used to format file lines.
+The format string is passed to `format-spec' and the following
+format characters are recognized:
+
+ %s - A string describing the status of the file.
+
+ %m - Mode change information
+
+ %n - The file name.
+
+ %c - A description of file changes."
+ :type 'string
+ :group 'stgit
+ :set 'stgit-set-default)
+
(defface stgit-branch-name-face
'((t :inherit bold))
"The face used for the StGit branch name"
@@ -457,12 +473,11 @@ Returns nil if there was no output."
stgit-file-status-code-strings))
(score (stgit-file-cr-score file)))
(when code
- (format "%-11s "
- (if (and score (/= score 100))
- (format "%s %s" (cdr code)
- (propertize (format "%d%%" score)
- 'face 'stgit-description-face))
- (cdr code))))))
+ (if (and score (/= score 100))
+ (format "%s %s" (cdr code)
+ (propertize (format "%d%%" score)
+ 'face 'stgit-description-face))
+ (cdr code)))))
(defun stgit-file-status-code (str &optional score)
"Return stgit status code from git status string"
@@ -505,8 +520,8 @@ Cf. `stgit-file-type-string'."
((zerop old-type)
(if (= new-type #o100)
""
- (format " (%s)" (stgit-file-type-string new-type))))
- (t (format " (%s -> %s)"
+ (format "(%s)" (stgit-file-type-string new-type))))
+ (t (format "(%s -> %s)"
(stgit-file-type-string old-type)
(stgit-file-type-string new-type))))))
@@ -579,23 +594,20 @@ Cf. `stgit-file-type-change-string'."
(concat (stgit-file-cr-from file) arrow (stgit-file-cr-to file)))))
(defun stgit-file-pp (file)
- (let ((status (stgit-file-status file))
- (name (if (stgit-file-copy-or-rename file)
- (stgit-describe-copy-or-rename file)
- (stgit-file-file file)))
- (mode-change (stgit-file-mode-change-string
- (stgit-file-old-perm file)
- (stgit-file-new-perm file)))
- (start (point)))
- (insert (format " %-12s%s%s%s%s\n"
- (stgit-file-status-code-as-string file)
- mode-change
- (if (zerop (length mode-change)) "" " ")
- name
- (propertize (stgit-file-type-change-string
- (stgit-file-old-perm file)
- (stgit-file-new-perm file))
- 'face 'stgit-description-face)))
+ (let ((start (point))
+ (spec (format-spec-make
+ ?s (stgit-file-status-code-as-string file)
+ ?m (stgit-file-mode-change-string
+ (stgit-file-old-perm file)
+ (stgit-file-new-perm file))
+ ?n (if (stgit-file-copy-or-rename file)
+ (stgit-describe-copy-or-rename file)
+ (stgit-file-file file))
+ ?c (propertize (stgit-file-type-change-string
+ (stgit-file-old-perm file)
+ (stgit-file-new-perm file))
+ 'face 'stgit-description-face))))
+ (insert (format-spec stgit-file-line-format spec) "\n")
(add-text-properties start (point)
(list 'entry-type 'file
'file-data file))))