[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dired-git-info 9f34bd7 1/8: Implement truncating of mes
From: |
Clemens Radermacher |
Subject: |
[elpa] externals/dired-git-info 9f34bd7 1/8: Implement truncating of messages if length exceeds window size |
Date: |
Wed, 11 Dec 2019 14:32:36 -0500 (EST) |
branch: externals/dired-git-info
commit 9f34bd7b462ca39455f4036d3afab06661620444
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>
Implement truncating of messages if length exceeds window size
---
dired-git-info.el | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/dired-git-info.el b/dired-git-info.el
index d3b7f81..ad109ba 100644
--- a/dired-git-info.el
+++ b/dired-git-info.el
@@ -178,6 +178,29 @@ info format and defaults to `dgi-commit-message-format'."
(split-string (buffer-string) "\n"))))
+(defun dgi--format-line-overlay (msg)
+ "Format message MSG for current dired line."
+ (let* ((le (line-end-position))
+ (aw (- (window-width)
+ (1+ (save-excursion
+ (goto-char le)
+ (current-column))))))
+ (if (not (> aw 0))
+ "\n"
+ (concat (dgi--clamp-string msg aw)
+ "\n"))))
+
+(defun dgi--clamp-string (str max)
+ "Return STRING truncated to MAX length if needed."
+ (propertize
+ (if (> (length str) max)
+ (concat (substring str 0
+ (- max (+ (length str) 3)))
+ "...")
+ str)
+ 'face 'dgi-commit-message-face))
+
+
;;;###autoload
(define-minor-mode dired-git-info-mode
"Toggle git message info in current dired buffer."
@@ -208,10 +231,7 @@ info format and defaults to `dgi-commit-message-format'."
?\s)))
(goto-char (line-end-position))
(let ((ov (make-overlay (point) (1+ (point))))
- (ovs (concat spc
- (propertize
- msg 'face 'dgi-commit-message-face)
- "\n")))
+ (ovs (dgi--format-line-overlay (concat spc msg))))
(push ov dgi--commit-ovs)
;; I don't use after-string because I didn't get it to work
;; in combination with hl-line-mode overlay
- [elpa] externals/dired-git-info updated (b4c5636 -> 7a43e22), Clemens Radermacher, 2019/12/11
- [elpa] externals/dired-git-info 9f34bd7 1/8: Implement truncating of messages if length exceeds window size,
Clemens Radermacher <=
- [elpa] externals/dired-git-info 88d0dc4 6/8: Add dired-git-info-auto-enable, Clemens Radermacher, 2019/12/11
- [elpa] externals/dired-git-info 7a43e22 8/8: Add note about ELPA package delay, Clemens Radermacher, 2019/12/11
- [elpa] externals/dired-git-info 6ec44d7 2/8: extend config info in readme, Clemens Radermacher, 2019/12/11
- [elpa] externals/dired-git-info 488c172 3/8: melpa -> elpa, Clemens Radermacher, 2019/12/11
- [elpa] externals/dired-git-info 7b14812 5/8: Merge pull request #6 from it-is-wednesday/patch-1, Clemens Radermacher, 2019/12/11
- [elpa] externals/dired-git-info 65a3a9c 7/8: Fix description, Clemens Radermacher, 2019/12/11
- [elpa] externals/dired-git-info cf4e7cf 4/8: replace handrolled auto enable function, Clemens Radermacher, 2019/12/11