emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org-remark 8e66af27d4 3/8: Merge branch 'echo-text'


From: ELPA Syncer
Subject: [elpa] externals/org-remark 8e66af27d4 3/8: Merge branch 'echo-text'
Date: Sat, 24 Dec 2022 02:57:58 -0500 (EST)

branch: externals/org-remark
commit 8e66af27d49d0fa101837a41839ce3e5f245884b
Merge: 6779999bda 7995630552
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>

    Merge branch 'echo-text'
---
 org-remark.el | 46 ++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/org-remark.el b/org-remark.el
index 3e92de14d3..fee39a83e6 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -338,7 +338,7 @@ 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 mode)
+(defun org-remark-mark (beg end &optional id text mode)
   "Apply face `org-remark-highlighter' to the region between BEG and END.
 
 When this function is used interactively, it will generate a new
@@ -366,7 +366,8 @@ marginal notes file.  The expected values are nil, :load and
   ;; This will do for now
   (org-remark-highlight-mark beg end id mode
                              nil nil
-                             (list 'org-remark-label "nil")))
+                             (list 'org-remark-label "nil"
+                                   'help-echo text)))
 
 (when org-remark-create-default-pen-set
   ;; Create default pen set.
@@ -390,11 +391,20 @@ in the current buffer.  Each highlight is an overlay."
   (org-remark-highlights-sort)
   (let ((filename (org-remark-source-find-file-name)))
     (dolist (h org-remark-highlights)
-      (let ((beg (overlay-start h))
-            (end (overlay-end h))
-            (props (overlay-properties h)))
+      (let* ((beg (overlay-start h))
+             (end (overlay-end h))
+             (props (overlay-properties h)))
+        (org-remark-highlight-update beg end)
         (org-remark-highlight-save filename beg end props)))))
 
+(defun org-remark-highlight-update (beg end)
+  "Update help echo text of overlay at BEG, END with TEXT."
+  (let* ((ov (car (overlays-at beg)))
+         (id (overlay-get ov 'org-remark-id))
+         (note (assoc id (org-remark-highlights-get)))
+         (text (car (last note))))
+    (overlay-put ov 'help-echo text)))
+
 (defun org-remark-open (point &optional view-only)
   "Open marginal notes file for highlight at POINT.
 The marginal notes will be narrowed to the relevant headline to
@@ -947,10 +957,11 @@ load the highlights"
     (let ((id (car highlight))
           (beg (caadr highlight))
           (end (cdadr highlight))
+          (text (cadddr highlight))
           (label (caddr highlight)))
       (let ((fn (intern (concat "org-remark-mark-" label))))
         (unless (functionp fn) (setq fn #'org-remark-mark))
-        (funcall fn beg end id :load)))))
+        (funcall fn beg end id text :load)))))
 
 (defun org-remark-highlights-get ()
   "Return a list of highlights from the marginal notes file.
@@ -991,13 +1002,32 @@ Each highlight is a list in the following structure:
                                                org-remark-prop-source-beg)))
                           (end (string-to-number
                                 (org-entry-get (point)
-                                               org-remark-prop-source-end))))
+                                               org-remark-prop-source-end)))
+                          (text (org-remark-highlights-text-get)))
                  (push (list id
                              (cons beg end)
-                             (org-entry-get (point) "org-remark-label"))
+                             (org-entry-get (point) "org-remark-label")
+                             text)
                        highlights))))
            highlights))))))
 
+(defun org-remark-highlights-text-get ()
+  "Return the text body of a highlight in the notes buffer."
+  (let ((full-text
+         (save-excursion
+           (org-end-of-meta-data :full)
+           (if
+               ;; handle empty annotation
+               ;; (org-end-of-meta-data :full) took us to next org heading):
+               (looking-at org-heading-regexp)
+               "[empty entry]"
+             (buffer-substring-no-properties
+              (point)
+              (org-end-of-subtree))))))
+    (if (< 200 (length full-text))
+        (substring-no-properties full-text 0 200)
+      full-text)))
+
 (defun org-remark-highlights-get-positions (&optional reverse)
   "Return list of the beginning point of all visible highlights in this buffer.
 By default, the list is in ascending order.  If REVERSE is



reply via email to

[Prev in Thread] Current Thread [Next in Thread]