[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 0c8bf49 02/25: New option: diff-hl-margin-symbols-alist
From: |
Dmitry Gutov |
Subject: |
[elpa] master 0c8bf49 02/25: New option: diff-hl-margin-symbols-alist |
Date: |
Sat, 8 Dec 2018 19:19:35 -0500 (EST) |
branch: master
commit 0c8bf49c6f351d70ab5f32ff9f26b74ee1df3948
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
New option: diff-hl-margin-symbols-alist
Closes #78.
---
diff-hl-margin.el | 46 ++++++++++++++++++++++++++++++++--------------
1 file changed, 32 insertions(+), 14 deletions(-)
diff --git a/diff-hl-margin.el b/diff-hl-margin.el
index 32aa123..e6d0b94 100644
--- a/diff-hl-margin.el
+++ b/diff-hl-margin.el
@@ -44,6 +44,18 @@
"Highlight buffer changes on margin"
:group 'diff-hl)
+(defcustom diff-hl-margin-symbols-alist
+ '((insert . "+") (delete . "-") (change . "!")
+ (unknown . "?") (ignored . "i"))
+ "Associative list from symbols to strings."
+ :type '(alist :key-type symbol
+ :value-type string
+ :options (insert delete change unknown ignored))
+ :set (lambda (symbol value)
+ (defvar diff-hl-margin-spec-cache)
+ (set-default symbol value)
+ (setq diff-hl-margin-spec-cache nil)))
+
;;;###autoload
(define-minor-mode diff-hl-margin-mode
"Toggle displaying `diff-hl-mode' highlights on the margin."
@@ -91,23 +103,29 @@ You probably shouldn't use this function directly."
(defun diff-hl-margin-minor-mode-off ()
(diff-hl-margin-minor-mode -1))
-(defvar diff-hl-margin-spec-cache
- (cl-loop for (type . char) in '((insert . "+") (delete . "-")
- (change . "!") (unknown . "?")
- (ignored . "i"))
- nconc
- (cl-loop for side in '(left right)
- collect
- (cons (cons type side)
- (propertize
- " " 'display
- `((margin ,(intern (format "%s-margin" side)))
- ,(propertize char 'face
- (intern (format "diff-hl-%s"
type)))))))))
+(defvar diff-hl-margin-spec-cache nil)
+
+(defun diff-hl-margin-spec-cache ()
+ (or diff-hl-margin-spec-cache
+ (setq diff-hl-margin-spec-cache
+ (diff-hl-margin-build-spec-cache))))
+
+(defun diff-hl-margin-build-spec-cache ()
+ (cl-loop for (type . char) in diff-hl-margin-symbols-alist
+ nconc
+ (cl-loop for side in '(left right)
+ collect
+ (cons
+ (cons type side)
+ (propertize
+ " " 'display
+ `((margin ,(intern (format "%s-margin" side)))
+ ,(propertize char 'face
+ (intern (format "diff-hl-%s" type)))))))))
(defun diff-hl-highlight-on-margin (ovl type _shape)
(let ((spec (cdr (assoc (cons type diff-hl-side)
- diff-hl-margin-spec-cache))))
+ (diff-hl-margin-spec-cache)))))
(overlay-put ovl 'before-string spec)))
(provide 'diff-hl-margin)
- [elpa] master updated (cd8bbda -> 7964c46), Dmitry Gutov, 2018/12/08
- [elpa] master 0c8bf49 02/25: New option: diff-hl-margin-symbols-alist,
Dmitry Gutov <=
- [elpa] master 1f864d6 03/25: Fix revert prompt, Dmitry Gutov, 2018/12/08
- [elpa] master f8ce39d 01/25: Solve the "cloned indirect buffer" problem, Dmitry Gutov, 2018/12/08
- [elpa] master fa74f2f 04/25: Merge pull request #80 from ryuslash/master, Dmitry Gutov, 2018/12/08
- [elpa] master 6a09f77 06/25: Merge pull request #81 from Wilfred/user_error_no_hunks, Dmitry Gutov, 2018/12/08
- [elpa] master 04c3b01 05/25: Use `user-error' when we can't proceed., Dmitry Gutov, 2018/12/08
- [elpa] master c476e40 07/25: Update the Requirements section, Dmitry Gutov, 2018/12/08
- [elpa] master 8dab389 09/25: Add separate set of faces for diff-hl-margin-mode, Dmitry Gutov, 2018/12/08
- [elpa] master 1d672dd 11/25: Clarify diff-hl-flydiff-mode docstring, Dmitry Gutov, 2018/12/08
- [elpa] master 3e9d264 08/25: Clean up diff-hl-dired process buffers, Dmitry Gutov, 2018/12/08
- [elpa] master 09b9354 12/25: Add a variable for the diff-hl-mode lighter, Dmitry Gutov, 2018/12/08