[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark e02519836d 38/75: fix(line): spacer movement
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark e02519836d 38/75: fix(line): spacer movement |
Date: |
Fri, 6 Oct 2023 12:59:19 -0400 (EDT) |
branch: externals/org-remark
commit e02519836d44483da08e274f7adaa068c1b284b4
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
fix(line): spacer movement
---
org-remark-line.el | 54 ++++++++++++++++++++++++++----------------------------
1 file changed, 26 insertions(+), 28 deletions(-)
diff --git a/org-remark-line.el b/org-remark-line.el
index 900bb5543a..9cb85df2a3 100644
--- a/org-remark-line.el
+++ b/org-remark-line.el
@@ -59,14 +59,6 @@ in cons cell (or nil) before function
(defvar-local org-remark-line-margins-set-p nil
"State if margins are set by `org-remark-line' for current buffer.")
-(defcustom org-remark-line-margin-side 'left-margin
- "The side of margin to display line highlights.
-Left or rigth can be chosen."
- :local t
- :type '(radio
- (const :tag "Left margin" left-margin)
- (const :tag "Right margin" right-margin)))
-
;;;###autoload
(define-minor-mode org-remark-line-mode
"Enable Org-remark to highlight and annotate the whole line."
@@ -85,14 +77,14 @@ Left or rigth can be chosen."
(add-hook 'window-size-change-functions
#'org-remark-line-set-window-margins 95 :local)
;; Need to reload to cater to margin changes done by `olivetti'.
- (add-hook 'window-size-change-functions
- #'org-remark-highlights-load 96 :local)
+ ;;(add-hook 'window-size-change-functions
+ ;; #'org-remark-highlights-load 96 :local)
(org-remark-line-set-window-margins))
(remove-hook 'org-remark-find-dwim-functions #'org-remark-line-find :local)
(remove-hook 'window-size-change-functions
#'org-remark-line-set-window-margins :local)
- (remove-hook 'window-size-change-functions
- #'org-remark-highlights-load :local)
+;; (remove-hook 'window-size-change-functions
+;; #'org-remark-highlights-load :local)
(when org-remark-line-margins-set-p
(setq left-margin-width (car org-remark-line-margins-original))
(setq right-margin-width (cdr org-remark-line-margins-original))
@@ -100,6 +92,11 @@ Left or rigth can be chosen."
(set-window-buffer (get-buffer-window) (current-buffer) nil)
(setq org-remark-line-margins-set-p nil))))
+;; Default line-highlighter pen
+(org-remark-create "line"
+ `org-remark-line-highlighter
+ `(org-remark-type line))
+
(defun org-remark-line-set-window-margins (&optional window)
"Set the margins of current window that displays current buffer.
Return a cons of the form (LEFT-WIDTH . RIGHT-WIDTH). If a
@@ -152,10 +149,6 @@ by `overlays-in'."
(highlights (overlays-in bol bol)))
(seq-find #'org-remark-line-highlight-p highlights)))
-(org-remark-create "line"
- `org-remark-line-highlighter
- `(org-remark-type line))
-
(cl-defmethod org-remark-beg-end ((_org-remark-type (eql 'line)))
(let ((bol (org-remark-line-pos-bol (point))))
(list bol bol)))
@@ -163,7 +156,7 @@ by `overlays-in'."
(cl-defmethod org-remark-highlight-make-overlay (beg end face
(_org-remark-type (eql 'line)))
"Make and return a highlight overlay for line-highlight.
Return nil when no window is created for current buffer."
-(when (get-buffer-window)
+ (when (get-buffer-window)
(unless org-remark-line-mode (org-remark-line-mode +1))
(let* ((face (or face 'org-remark-line-highlighter))
(left-margin (or (car (window-margins)) left-margin-width))
@@ -191,8 +184,10 @@ Return nil when no window is created for current buffer."
`((margin ,org-remark-line-margin-side)
,spaces)))
(overlay-put spacer-ov 'category 'org-remark-spacer)
- (overlay-put spacer-ov 'insert-in-front-hooks
- (list 'org-remark-line-highlight-modified))
+ ;; Let highlight overlay to take care of the spacer movement
+ ;;(overlay-put spacer-ov 'insert-in-front-hooks
+ ;; (list 'org-remark-line-highlight-modified))
+
;; line-highlight overlay
(overlay-put ov 'before-string
(propertize " " 'display
@@ -208,21 +203,25 @@ Return nil when no window is created for current buffer."
(copy-overlay spacer-ov)
ov)))
-(defun org-remark-line-highlight-find-spacer (pos)
+(defun org-remark-line-highlight-find-spacers (pos)
+ "Find the two spacers for POS."
(let ((highlights (overlays-in pos pos)))
- (seq-find (lambda (ov)
- (eql 'org-remark-spacer (overlay-get ov 'category)))
- highlights)))
+ (seq-filter (lambda (ov)
+ (eql 'org-remark-spacer (overlay-get ov 'category)))
+ highlights)))
(defun org-remark-line-highlight-modified (ov after-p beg _end &optional
_length)
"Move the overlay to follow the point when ENTER in the line."
(when after-p
(save-excursion (goto-char beg)
(when (looking-at "\n")
- ;; Spacer needs to move before the hightlight to keep
the sequence.
- (let ((spacer (org-remark-line-highlight-find-spacer
beg)))
- (when spacer (move-overlay spacer (1+ beg) (1+ beg))))
- (move-overlay ov (1+ beg) (1+ beg))))))
+ ;; The sequence must be 1. spacer; 2. highlight 3. spacer
+ (let ((spacers (org-remark-line-highlight-find-spacers
beg)))
+ (when spacers
+ (move-overlay (pop spacers) (1+ beg) (1+ beg)))
+ (move-overlay ov (1+ beg) (1+ beg))
+ (when spacers
+ (move-overlay (pop spacers) (1+ beg) (1+ beg))))))))
(cl-defmethod org-remark-highlight-headline-text (ov (_org-remark-type (eql
'line)))
"Return the first x characters of the line.
@@ -280,7 +279,6 @@ Return nil when no window is created for current buffer."
(overlay-put ov 'before-string (propertize " " 'display (list
`(margin ,org-remark-line-margin-side) icon-string)))))
(t (ignore))))))
-
(cl-defmethod org-remark-icon-highlight-get-face (highlight (_org-remark-type
(eql 'line)))
"Return the face of the line-highilght in a margin."
(get-text-property 0 'face
- [elpa] externals/org-remark 94ba0ecea0 21/75: fix(line): When source narrowed, existing line-hls move wrongly, (continued)
- [elpa] externals/org-remark 94ba0ecea0 21/75: fix(line): When source narrowed, existing line-hls move wrongly, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark e7aae5e4f4 25/75: doc: docstring for org-remark-highlight-mark-overlay, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark f28dc7e7f5 62/75: docs: update docstrings for remove and delete, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 18f39bf119 56/75: Merge branch 'main' into dev/1.3.0, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 4ad2be30e4 13/75: fix(icon): the line icon not displaying, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark e136189485 34/75: fix(line): window margin wrongly sets minibuffer's margin, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 8f9875f714 24/75: doc(line): Remove unused source comments (old code), ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 6dbf1cca4a 35/75: fix(line): svg icon does not get the face correctly, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 3f5ea6777b 32/75: fix(line): window selection is utterly confused, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 533167091a 42/75: fix(line):Right margin expands every window-size-change-func call, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark e02519836d 38/75: fix(line): spacer movement,
ELPA Syncer <=
- [elpa] externals/org-remark 6364474a73 48/75: Merge branch 'main' into dev/line-highlight, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 680651e339 37/75: refactor(icon): remove unnecessary source comment (old func), ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 193fe279ea 49/75: feat(line):add line-number as a property to the highlight headline, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark f7031507db 15/75: fix: defgeneric seems needed anyway.., ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark d72fa0ef45 70/75: fix: regression next/prev-view opens the notes when there is none, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 2b68d4748c 51/75: Merge branch 'main' into dev/line-highlight, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 833d909264 61/75: docs: NEWS for the current development branch (WIP), ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark cfaf02d823 72/75: docs: minor update to README and article on SVG icon, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark cbc26304a8 23/75: refactor: add org-remark-default-features to automatically load, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark f37ddb69e7 22/75: fix(change): force trigger of notes buffer face, ELPA Syncer, 2023/10/06