[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark f353630ddd 153/173: fix:toggle: marking when
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark f353630ddd 153/173: fix:toggle: marking when toggle hidden confuses the state |
Date: |
Fri, 28 Jan 2022 16:58:10 -0500 (EST) |
branch: externals/org-remark
commit f353630ddd1bc8679fdb624c72a27962ba63dd44
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
fix:toggle: marking when toggle hidden confuses the state
Add local variable `org-remark-highlights-hidden' to control state. Now you
mark when hidden, mark will toggle the highlights to show first. This
avoids
the confused state.
---
org-remark.el | 62 ++++++++++++++++++++++++++++++++---------------------------
1 file changed, 34 insertions(+), 28 deletions(-)
diff --git a/org-remark.el b/org-remark.el
index 129d7e7f8b..9da7a53ec9 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -100,6 +100,9 @@ represents a highlighted text region.
On `save-buffer' each highlight will be save in the notes file at
`org-remark-notes-file-path'.")
+(defvar-local org-remark-highlights-hidden nil
+ "Keep hidden/shown state of the highlights in current buffer.")
+
(defvar org-remark-last-notes-buffer nil
"Stores the cloned indirect buffer visiting the notes file.
It is meant to exist only one of these in each Emacs session.")
@@ -217,7 +220,7 @@ recommended to turn it on as part of Emacs initialization.
(add-hook 'after-save-hook #'org-remark-save nil t)
(add-hook 'kill-buffer-hook #'org-remark-tracking-save nil t)
;; Tracking
- (org-remafrk-notes-track-file (buffer-file-name))))
+ (org-remark-notes-track-file (buffer-file-name)))
(t
;; Deactivate
(when org-remark-highlights
@@ -274,11 +277,16 @@ A Org headline entry for the highlght will be created in
the
marginal notes file specified by `org-remark-notes-file-path'.
If the file does not exist yet, it will be created.
-When this function is called from Elisp, ID can be optionally
-passed, indicating to Org-remark that it is to load an existing
-highlight. In this case, no new ID gets generated and the
-highlight saved again, avoiding the unnecessary round-trip back
-to the database."
+When this function is called from Elisp, ID can be
+optionally passed, indicating to Org-remark that it is to load an
+existing highlight. In this case, no new ID gets generated and
+the highlight saved again, avoiding the unnecessary round-trip
+back to the database.
+
+MODE is also an argument which can be passed from Elisp. It
+determines whether or not highlight is to be saved in the
+marginal notes file. The expected values are nil, :load and
+:change."
(interactive (org-remark-region-or-word))
;; FIXME
;; Adding "nil" is different to removing a prop
@@ -434,15 +442,10 @@ highlights are hidden, thus it is recommended to use this
function, instead of `org-remark-mode', if you would just like to
hide the highlights."
(interactive)
- (when-let ((highlights org-remark-highlights))
- ;; Check the first highlight in the buffer
- ;; If it's hidden, all hidden. Show them.
- ;; If not, all shown. Hide them.
- (if-let* ((beg (overlay-start (nth 0 highlights)))
- (hidden-p (get-char-property beg 'org-remark-hidden)))
- (org-remark-highlights-show)
- (org-remark-highlights-hide))
- t))
+ (if org-remark-highlights-hidden
+ (org-remark-highlights-show)
+ (org-remark-highlights-hide))
+ t)
(defun org-remark-change (&optional pen)
"Change the highlight at point to PEN.
@@ -472,7 +475,8 @@ If you have done so by error, you could still `undo' it in
the
marginal notes buffer, but not in the current buffer as adding
and removing overlays are not part of the undo tree."
(interactive "d\nP")
- (when-let ((ov (org-remark-find-overlay-at-point)))
+ (when-let ((ov (org-remark-find-overlay-at-point point))
+ (id (overlay-get ov 'org-remark-id)))
;; Remove the highlight overlay and id Where there is more than one, remove
;; only one It should be last-in-first-out in general but overlays
functions
;; don't guarantee it
@@ -536,11 +540,13 @@ Look through `org-remark-highlights' list (in descending
order)."
;; `org-remark-highlights' is sorted in the descending order .
(seq-find (lambda (p) (< p (point))) points (nth 0 points))))
-(defun org-remark-find-overlay-at-point ()
- "Return one org-remark overlay at point.
+(defun org-remark-find-overlay-at-point (&optional point)
+ "Return one org-remark overlay at POINT.
+When point is nil, use the current point.
If there are more than one, return CAR of the list."
- (let ((overlays (overlays-at (point)))
- found)
+ (let* ((pt (or point (point)))
+ (overlays (overlays-at pt))
+ found)
(while overlays
(let ((overlay (car overlays)))
(if (overlay-get overlay 'org-remark-id)
@@ -568,7 +574,7 @@ region, and Org-remark will start tracking the highlight's
location in the current buffer.
MODE determines whether or not highlight is to be saved in the
-marginal notes file. The expected values are nil, :load and
+marginal notes file. The expected values are nil, :load and
:change.
A Org headline entry for the highlght will be created in the
@@ -582,6 +588,9 @@ highlight saved again, avoiding the unnecessary round-trip
back
to the database."
;; Ensure to turn on the local minor mode
(unless org-remark-mode (org-remark-mode +1))
+ ;; When highlights are toggled hidden, only the new one gets highlighted in
+ ;; the wrong toggle state.
+ (when org-remark-highlights-hidden (org-remark-highlights-show))
;; Add highlight to the text
(org-with-wide-buffer
(let ((ov (make-overlay beg end nil :front-advance))
@@ -740,12 +749,9 @@ Return t if an entry is removed or deleted."
(dolist (prop (org-entry-properties))
(when (string-prefix-p "org-remark-" (downcase (car prop)))
(org-delete-property (car prop))))
- ;; Backward compatible
- (org-delete-property org-remark-prop-id)
- (org-delete-property org-remark-prop-source-beg)
- (org-delete-property org-remark-prop-source-end)
(when delete
- ;; TODO I would love to add the y-n prompt if there is any notes
written
+ ;; TODO I would love to add the y-n prompt if there is any notes
+ ;; written
(delete-region (point-min)(point-max))
(message "Deleted the marginal notes entry"))
(when (buffer-modified-p) (save-buffer))))
@@ -903,7 +909,7 @@ state."
(overlay-put highlight 'org-remark-face (overlay-get highlight 'face))
(overlay-put highlight 'face nil)
(overlay-put highlight 'org-remark-hidden t))
- t))
+ (setq org-remark-highlights-hidden t)))
(defun org-remark-highlights-show ()
"Show highlights.
@@ -915,7 +921,7 @@ the show/hide state."
(dolist (highlight highlights)
(overlay-put highlight 'org-remark-hidden nil)
(overlay-put highlight 'face (overlay-get highlight 'org-remark-face)))
- t))
+ (setq org-remark-highlights-hidden nil)))
(defun org-remark-highlights-housekeep ()
"Housekeep the internal variable `org-remark-highlights'.
- [elpa] externals/org-remark 4554fc817a 132/173: rm: org-remark-pen-factory -> merged with org-remark-create, (continued)
- [elpa] externals/org-remark 4554fc817a 132/173: rm: org-remark-pen-factory -> merged with org-remark-create, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 4042e9434f 137/173: doc: User Manual first draft, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark bee736f6e3 131/173: intrnl: refactor mark, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark a7de41bdfa 139/173: docs: NEWS and README (incomplete, WIP), ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 50bfb96d69 140/173: Merge branch 'dev/name-change', ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 0c7fd2d711 143/173: docs: README for Org-remark, update user manual and css, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 1b2db44fa7 145/173: docs: user manaul, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 69d0259e20 146/173: docs: user manaul, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 62cba0ec63 148/173: fix: change now updates the marginal notes, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark f43e4afc34 152/173: add: toggle to menu; intrnl: refactor, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark f353630ddd 153/173: fix:toggle: marking when toggle hidden confuses the state,
ELPA Syncer <=
- [elpa] externals/org-remark da77d9dfba 154/173: fix: pen menu function for 27.x, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 4782d43f0f 155/173: add: change to menu items, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 713f64b7cb 168/173: docs: minor change to the demo/marginalia.org, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 7226f4d01e 173/173: docs: add delete; add help string to menu items, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 4b5d9c3fda 171/173: fix:delete quit window if it did not exist on calling delete, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 9deaecd211 116/173: add: Legacy data facility wtih org-remark-tracking, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark d36debe2b4 124/173: add: factor out org-remark-legacy-convert, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark f30ad4f570 122/173: fix: program error in save, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark b9a8409e27 126/173: docs: copyright & dates, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark e3dd998e6b 130/173: add: register the default pen function for change, ELPA Syncer, 2022/01/28