[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark 6583adaca1 134/173: intrnl: single-highlight
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark 6583adaca1 134/173: intrnl: single-highlight-mark is back |
Date: |
Fri, 28 Jan 2022 16:58:08 -0500 (EST) |
branch: externals/org-remark
commit 6583adaca150ad7239139fcc595f48245647c399
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
intrnl: single-highlight-mark is back
---
org-remark.el | 122 ++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 76 insertions(+), 46 deletions(-)
diff --git a/org-remark.el b/org-remark.el
index 77416b855c..dbc72b58d7 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -59,8 +59,7 @@
(defcustom org-remark-create-default-pen-set t
"When non-nil, Org-remark creates default pen set.
-Set to nil if you prefer for it not to.
-`org-remark-mark' is always created as a fall-back"
+Set to nil if you prefer for it not to."
:type 'boolean)
(defcustom org-remark-notes-file-path "marginalia.org"
@@ -141,8 +140,7 @@ property names with \"org-remark-\" or use \"CATEGORY\"."
(if (not label) `(user-error "org-remark-create: Label is missing")
`(progn
(add-to-list 'org-remark-available-pens
- (intern (or (when ,label (format "org-remark-mark-%s"
,label))
- "org-remark-mark")))
+ (intern (format "org-remark-mark-%s" ,label)))
(defun ,(intern (format "org-remark-mark-%s" label))
(beg end &optional id load-only)
,(format "Apply the following face to the region selected by BEG and
END.
@@ -168,7 +166,8 @@ highlight in the marginal notes file. This is meant to be
for
`org-remark-load'."
(or face "`org-remark-highlighter'") properties)
(interactive "r")
- (org-remark-mark beg end id load-only ,label ,face ,properties)))))
+ (org-remark-single-highlight-mark
+ beg end id load-only ,label ,face ,properties)))))
;; Don't use category (symbol) as a property -- it's a special one of text
;; properties. If you use it, the value also need to be a symbol; otherwise,
you
@@ -244,60 +243,32 @@ recommended to turn it on as part of Emacs initialization.
(add-to-list 'org-remark-available-pens #'org-remark-mark)
;;;###autoload
-(defun org-remark-mark (beg end &optional id load-only label face properties)
+(defun org-remark-mark (beg end &optional id load-only)
"Apply the FACE to the region selected by BEG and END.
-This function will apply FACE to the selected region. When it is
-nil, this function will use the default face `org-remark-highlighter'
-
-This function will add LABEL and PROPERTIES as overlay
-properties. PROPERTIES is a plist of pairs of a symbol and value.
+This function will apply face `org-remark-highlighter' to the selected region.
When this function is used interactively, it will generate a new
ID, always assuming it is working on a new highlighted text
region, and Org-remark will start tracking the highlight's
location in the current buffer.
-When this function is called from Elisp, ID can be optionally
-passed, indicating to Org-remark that it is an existing
-highlight. In this case, no new ID gets generated.
-
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 LOAD-ONLY is non-nil, this function will not save the
-highlight in the marginal notes file. This is meant to be for
-`org-remark-load'."
+When this function is called from Elisp, ID and LOAD-ONLY can be
+optionally passed. When ID is passed, it indicates to Org-remark
+that it is an existing highlight. In this case, no new ID gets
+generated. When LOAD-ONLY is non-nil, this function will not
+save the highlight in the marginal notes file. This is meant to
+be for `org-remark-load'."
(interactive "r")
- ;; Ensure to turn on the local minor mode
- (unless org-remark-mode (org-remark-mode +1))
- ;; UUID is too long; does not have to be the full length
- (when (not id) (setq id (substring (org-id-uuid) 0 8)))
- ;; Add highlight to the text
- (org-with-wide-buffer
- (let ((ov (make-overlay beg end nil 'FRONT-ADVANCE)))
- (overlay-put ov 'face (if face face 'org-remark-highlighter))
- (while properties
- (let ((prop (pop properties))
- (val (pop properties)))
- (overlay-put ov prop val)))
- (when label (overlay-put ov 'org-remark-label label))
- (overlay-put ov 'org-remark-id id)
- ;; Keep track of the overlay in a local variable. It's a list that is
- ;; guaranteed to contain only org-remark overlays as opposed to the one
- ;; returned by `overlay-lists' that lists any overlays.
- (push ov org-remark-highlights)
- ;; Adding overlay to the buffer does not set the buffer modified. You
- ;; cannot use `undo' to undo highlights, either.
- (unless load-only
- (org-remark-single-highlight-save (buffer-file-name)
- beg end
- (overlay-properties ov)
-
(org-remark-single-highlight-get-title)))
- (deactivate-mark)))
- (org-remark-housekeep)
- (org-remark-highlights-sort))
+ ;; FIXME
+ ;; Adding "nil" is different to removing a prop
+ ;; This will do for now
+ (org-remark-single-highlight-mark beg end id load-only nil nil
+ (list "org-remark-label" "nil")))
(defun org-remark-load ()
"Visit `org-remark-notes-file' & load the saved highlights onto current
buffer.
@@ -562,6 +533,65 @@ If there are more than one, return CAR of the list."
(setq overlays (cdr overlays)))
(car found)))
+(defun org-remark-single-highlight-mark (beg end &optional id load-only label
face properties)
+ "Apply the FACE to the region selected by BEG and END.
+
+This function will apply FACE to the selected region. When it is
+nil, this function will use the default face `org-remark-highlighter'
+
+This function will add LABEL and PROPERTIES as overlay
+properties. PROPERTIES is a plist of pairs of a symbol and value.
+
+When this function is used interactively, it will generate a new
+ID, always assuming it is working on a new highlighted text
+region, and Org-remark will start tracking the highlight's
+location in the current buffer.
+
+When this function is called from Elisp, ID can be optionally
+passed, indicating to Org-remark that it is an existing
+highlight. In this case, no new ID gets generated.
+
+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 LOAD-ONLY is non-nil, this function will not save the
+highlight in the marginal notes file. This is meant to be for
+`org-remark-load'."
+ ;; BEG and END are not selected and in the interactive call
+ ;; not Elisp call
+ (when (and (not load-only) (not mark-active))
+ (let ((bound (bounds-of-thing-at-point 'word)))
+ (setq beg (car bound) end (cdr bound))))
+ ;; Ensure to turn on the local minor mode
+ (unless org-remark-mode (org-remark-mode +1))
+ ;; UUID is too long; does not have to be the full length
+ (when (not id) (setq id (substring (org-id-uuid) 0 8)))
+ ;; Add highlight to the text
+ (org-with-wide-buffer
+ (let ((ov (make-overlay beg end nil 'FRONT-ADVANCE)))
+ (overlay-put ov 'face (if face face 'org-remark-highlighter))
+ (while properties
+ (let ((prop (pop properties))
+ (val (pop properties)))
+ (overlay-put ov prop val)))
+ (when label (overlay-put ov 'org-remark-label label))
+ (overlay-put ov 'org-remark-id id)
+ ;; Keep track of the overlay in a local variable. It's a list that is
+ ;; guaranteed to contain only org-remark overlays as opposed to the one
+ ;; returned by `overlay-lists' that lists any overlays.
+ (push ov org-remark-highlights)
+ ;; Adding overlay to the buffer does not set the buffer modified. You
+ ;; cannot use `undo' to undo highlights, either.
+ (unless load-only
+ (org-remark-single-highlight-save (buffer-file-name)
+ beg end
+ (overlay-properties ov)
+
(org-remark-single-highlight-get-title)))
+ (deactivate-mark)))
+ (org-remark-housekeep)
+ (org-remark-highlights-sort))
+
(defun org-remark-single-highlight-get-title ()
"Return the title of the current buffer.
Utility function to work with a single highlight overlay."
- [elpa] externals/org-remark d36debe2b4 124/173: add: factor out org-remark-legacy-convert, (continued)
- [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
- [elpa] externals/org-remark 9f492e184e 111/173: fix side-window, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 238a023021 141/173: docs: gh-html error, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark bbd5c4795e 144/173: docs: user manual, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark c6dccc3878 161/173: intrnl:create macro: check label to be a string, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark a55d0b7717 165/173: docs: README and user manaul, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 74c6756d72 109/173: keep default marginalia.org, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 6583adaca1 134/173: intrnl: single-highlight-mark is back,
ELPA Syncer <=
- [elpa] externals/org-remark c6ddf2fdfc 138/173: docs: user manual -- remove "incomplete", ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 937111e175 135/173: intrnl: refactor more, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark f6c3f36ded 157/173: fix: jerking buffer movement for cerain version/OS, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark bb6d48c61c 160/173: docs: Update screen shots and README, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark a097fb473a 164/173: docs: fix Makefile for GH. README minor update, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 28be5fcea9 162/173: docs: remove the note saying screen shots are from org-marginalia, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark f6fe2ad221 166/173: docs: add missing user option to variable index, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 95b408ff39 167/173: docs: add video link; fix Contributing section with Org-remark, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 266da621be 117/173: add: Legacy data facility with org-remark-tracking - main part, ELPA Syncer, 2022/01/28