[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/add-vdiff 803fd6d 098/258: Add subtraction style option
From: |
Justin Burkett |
Subject: |
[elpa] scratch/add-vdiff 803fd6d 098/258: Add subtraction style option |
Date: |
Wed, 17 May 2017 08:13:30 -0400 (EDT) |
branch: scratch/add-vdiff
commit 803fd6d32d17766b33f562070a39156a34294846
Author: justbur <address@hidden>
Commit: justbur <address@hidden>
Add subtraction style option
---
vdiff.el | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 53 insertions(+), 5 deletions(-)
diff --git a/vdiff.el b/vdiff.el
index 31fb2a8..79098a9 100644
--- a/vdiff.el
+++ b/vdiff.el
@@ -103,6 +103,23 @@
https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Class-Table.htm
:group 'vdiff
:type 'string)
+(defcustom vdiff-subtraction-style 'full
+ "How to represent subtractions (i.e., deleted lines). The
+default is full which means add the same number of (fake) lines
+as those that were removed. The choice single means add only one
+fake line. The choice fringe means don't add lines but do
+indicate the subtraction location in the fringe."
+ :group 'vdiff
+ :type '(radio (const :tag "Add same number of fake lines" full)
+ (const :tag "Add single line" single)
+ (const :tag "Add no lines but use fringe" fringe)))
+
+(defcustom vdiff-subtraction-fill-char ?-
+ "Character to use for filling subtraction lines. See also
+`vdiff-subtraction-style'."
+ :group 'vdiff
+ :type 'integer)
+
(defface vdiff-addition-face
'((t :inherit diff-added))
"Face for additions"
@@ -500,13 +517,44 @@ of a \"word\"."
;; * Add overlays
+(defvar vdiff--insertion-arrow-bits
+ (apply
+ #'vector
+ (mapcar
+ (lambda (line)
+ (apply
+ '+
+ (mapcar
+ (lambda (el)
+ (let ((ex (1- (length line))))
+ (* el (expt 2 ex)))) line)))
+ '((0 0 0 1 1 1 1 1)
+ (0 0 0 1 1 1 1 1)
+ (0 1 1 1 1 1 1 1)
+ (1 1 1 1 1 0 0 1)
+ (1 1 1 0 0 0 0 0)
+ (1 1 0 0 0 0 0 0)
+ (1 0 0 0 0 0 0 0)
+ (0 0 0 0 0 0 0 0)))))
+
+(define-fringe-bitmap 'vdiff--insertion-arrow vdiff--insertion-arrow-bits)
+
(defun vdiff--make-subtraction-string (n-lines)
- (let (string)
+ (let ((n-lines (if (eq 'single vdiff-subtraction-style)
+ 1
+ n-lines))
+ string)
(dotimes (_ n-lines)
- (push (make-string (1- (vdiff--min-window-width)) ?-) string))
- (propertize
- (concat (mapconcat #'identity string "\n") "\n")
- 'face 'vdiff-subtraction-face)))
+ (push (make-string (1- (vdiff--min-window-width))
+ vdiff-subtraction-fill-char) string))
+ (if (eq vdiff-subtraction-style 'fringe)
+ (propertize
+ " "
+ 'face 'vdiff-subtraction-face
+ 'display '(left-fringe vdiff--insertion-arrow))
+ (propertize
+ (concat (mapconcat #'identity string "\n") "\n")
+ 'face 'vdiff-subtraction-face))))
(defun vdiff--add-subtraction-overlay (n-lines)
(let* ((ovr (make-overlay (point) (1+ (point)))))
- [elpa] scratch/add-vdiff ff1fbc4 248/258: vdiff: Generate ancestor buffer in merge-conflict, (continued)
- [elpa] scratch/add-vdiff ff1fbc4 248/258: vdiff: Generate ancestor buffer in merge-conflict, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff d243767 253/258: README: Add entry points and vimdiff bindings, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 79b3434 052/258: Make some arg names more consistent, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 528a5ce 051/258: Simplify logic for sending/receiving changes, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff c2f1ad9 068/258: Add vdiff-hydra.el, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff e94d187 059/258: Simplify adding overlays, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 4596948 081/258: Reduce load in vdiff--scroll-function, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff d65fcd7 083/258: Simplify commentary, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 0777eda 099/258: Add vdiff-refresh binding to prefix map, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff d46f686 094/258: Make README table narrower, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 803fd6d 098/258: Add subtraction style option,
Justin Burkett <=
- [elpa] scratch/add-vdiff 5f2c72c 105/258: Change alignment algorithm, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff f481a82 112/258: Add refresh timer delay, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 28d28b7 116/258: Add restore windows command, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 905be9c 122/258: Map remove refinements command, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 717d5b6 121/258: Allow failed line translation, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff b267885 137/258: Merge branch 'gvol-master', Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 8daa391 133/258: Add case and whitespace toggles, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 95a1230 154/258: Fix vscroll bug, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff e556705 151/258: Simplify scroll function, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff f36b6b2 162/258: Fix line-translation error, Justin Burkett, 2017/05/17