[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark 46d3722ea1 017/173: feat: Add om/next and /p
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark 46d3722ea1 017/173: feat: Add om/next and /prev |
Date: |
Fri, 28 Jan 2022 16:57:55 -0500 (EST) |
branch: externals/org-remark
commit 46d3722ea12e424ead3c1cf4b4db59b0f6d98e4a
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
feat: Add om/next and /prev
---
README.org | 8 +++++++-
marginalia.org | 29 +++++++++++++++++++++++++---
org-marginalia.el | 57 +++++++++++++++++++++++++++++++++++++++++++++++++------
3 files changed, 84 insertions(+), 10 deletions(-)
diff --git a/README.org b/README.org
index 48a1ce22b9..6bb0dd180e 100644
--- a/README.org
+++ b/README.org
@@ -81,6 +81,12 @@ This command visits the marginalia file and load the saved
highlights onto the c
- =om/remove= ::
This command removes the highlight at point. It will remove the highlight, and
remove the properties from the marginalia, but will keep the headline and notes
in tact.
+- =om/next= (=C-c n ]= by default) ::
+Move to the next highlight if any. If there is none below the cursor, and
there is a highlight above, loop back to the top one.
+
+- =om/prev= (=C-c n [= by default) ::
+Move to the previous highlight if any. If there is none above the cursor, and
there is a highlight below, loop back to the bottom one.
+
* Customizing
- You can customize settings in the =org-marginalia= group.
@@ -116,7 +122,7 @@ Feedback welcome in this repo, or in
[[https://org-roam.discourse.group/t/protot
I am aiming to keep this package to be small and focused. I plan to add the
following features, and probably consider it to be feature complete for my
purposes.
1. =om/toggle-display= to toggle show/hide of highlights without losing them
-2. =om/next= and =om/previous= to easily navigate highlighted regions in the
buffer
+2. DONE =om/next= and =om/prev= to easily navigate highlighted regions in the
buffer
* License
diff --git a/marginalia.org b/marginalia.org
index be3ab14ad1..191e21a53f 100644
--- a/marginalia.org
+++ b/marginalia.org
@@ -23,11 +23,34 @@
** defun om/next
:PROPERTIES:
:marginalia-id: e0047cec
-:marginalia-source-beg: 14856
-:marginalia-source-end: 14869
+:marginalia-source-beg: 15055
+:marginalia-source-end: 15068
:END:
[[file:~/local-repos/org-marginalia/org-marginalia.el][org-marginalia]]
=(view-file "marginalia.org")= is interesting. It visits the file with
read-only mode on. Press q to quit. But if you turn off read-only-mode, you can
then edt the buffer.
-Also... It's useful to be able to cycle through (or view a list of)
highlights. You may not see them.
+Also... It's useful to be able to cycle through (or view a list of)
highlights. You may not see them.
+
+For listing, built-in `tabulated-list-mode` exists. Additionallly,
hierarchy.el, tablist.el, or lister.el (of publicimageltd, author of delve).
+
+
+
+** Author
+:PROPERTIES:
+:marginalia-id: f323a57f
+:marginalia-source-beg: 143
+:marginalia-source-end: 149
+:END:
+[[file:~/local-repos/org-marginalia/org-marginalia.el][org-marginalia]]
+
+** defun om/list-highlights-positions
+[[file:~/local-repos/org-marginalia/org-marginalia.el][org-marginalia]]
+
+** om/sort-highlights-list ()
+:PROPERTIES:
+:marginalia-id: 3be187c7
+:marginalia-source-beg: 18227
+:marginalia-source-end: 18253
+:END:
+[[file:~/local-repos/org-marginalia/org-marginalia.el][org-marginalia]]
diff --git a/org-marginalia.el b/org-marginalia.el
index 2125179482..6ac9ae9103 100644
--- a/org-marginalia.el
+++ b/org-marginalia.el
@@ -202,6 +202,8 @@ the mode, `toggle' toggles the state."
:keymap (let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c n o") #'om/open)
(define-key map (kbd "C-c m") #'om/mark)
+ (define-key map (kbd "C-c ]") #'om/next)
+ (define-key map (kbd "C-c [") #'om/prev)
map)
(cond
(org-marginalia-mode
@@ -224,8 +226,8 @@ passed. If so, no new ID gets generated.
Every highlighted texts in the local buffer is tracked by
`om/highlights' local variable. The highlght is sorted by the
-beginning point; this should be useful when `om/next' and
-`om/previous' are implemented (not yet)."
+beginning point in the ascending; this is useful for `om/next'
+and `om/prev'."
(interactive "r")
;; UUID is too long; does not have to be the full length
(when (not id) (setq id (substring (org-id-uuid) 0 8)))
@@ -356,11 +358,23 @@ marginalia, but will keep the headline and notes."
(defun om/toggle-display ()
"WIP: Toggle showing/hiding of highlights in current bufer.")
+(seq-find (lambda (p) (> p (point))) (om/list-highlights-positions) (nth 0
(om/list-highlights-positions) ))
+
(defun om/next ()
- "WIP.")
+ "Look at the current point, and move to the next highlight, if any.
+If there is none below the point, but there is a highlight in the
+buffer, go back to the first one."
+ (interactive)
+ (if (not om/highlights) (message "No highlights present in this buffer.")
+ (goto-char (om/find-next-highlight))))
-(defun om/previous ()
- "WIP.")
+(defun om/prev ()
+ "Look at the current point, and move to the previous highlight, if any.
+If there is none above the point, but there is a highlight in the
+buffer, go back to the last one."
+ (interactive)
+ (if (not om/highlights) (message "No highlights present in this buffer.")
+ (goto-char (om/find-prev-highlight))))
;;;; Functions
@@ -418,12 +432,43 @@ creat a new headline at the end of the buffer."
(defun om/make-highlight-marker (point)
"Return marker of the insertion-type t for POINT.
The insertion-type is important in order for the highlight
-position (beg and end points) in sycn with the highlited text
+position (beg and end points) in sync with the highlighted text
properties."
(let ((marker (set-marker (make-marker) point)))
(set-marker-insertion-type marker t)
marker))
+(defun om/list-highlights-positions (&optional reverse)
+ "Return list of beg points of highlights in this buffer.
+By default, the list is in ascending order.
+If none, return nil.
+If REVERSE is non-nil, return list in the descending order."
+ (when om/highlights
+ (let ((list (mapcar (lambda (h)
+ (marker-position (car (cdr h))))
+ om/highlights)))
+ (if reverse (reverse list) list))))
+
+(defun om/find-next-highlight ()
+ "Return the beg point of the next highlight.
+Look through `om/highlights' list."
+
+ (when-let ((points (om/list-highlights-positions)))
+ ;; Find the first occurance of p > (point). If none, this means all the
+ ;; points occur before the current point. Take the first one. Assume
+ ;; `om/highlights' is sorted in the ascending order (it is).
+ (seq-find (lambda (p) (> p (point))) points (nth 0 points))))
+
+(defun om/find-prev-highlight ()
+ "Return the beg point of the previous highlight.
+Look through `om/highlights' list (in descending order)."
+
+ (when-let ((points (om/list-highlights-positions 'reverse)))
+ ;; Find the first occurance of p < (point). If none, this means all the
+ ;; points occur before the current point. Take the first one. Assume
+ ;; `om/highlights' is sorted in the descending order .
+ (seq-find (lambda (p) (< p (point))) points (nth 0 points))))
+
;;;; Footer
(provide 'org-marginalia)
- [elpa] externals/org-remark ca86e1156c 041/173: fix: om/list-highlights-positions, (continued)
- [elpa] externals/org-remark ca86e1156c 041/173: fix: om/list-highlights-positions, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 460eab8db0 046/173: doc: Update README (marginalia), ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark caf73e6f86 052/173: doc: Update docstrings for om/- next/prev, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 78a218c505 051/173: doc: Update docstrings for om/-next/prev, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark b60992beb5 053/173: doc: Update comments and readme, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 7534424f4d 055/173: break: Replace prefix "om/" with "org-marginalia";, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark c7a5ba5e3b 057/173: Merge branch 'main' of https://github.com/nobiot/org-marginalia, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 020c862da7 007/173: doc: Fix the badge display, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 04124b352e 015/173: doc: Minor update readme, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 3cc500cb4a 018/173: internal: private fn first to avoid macro error, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 46d3722ea1 017/173: feat: Add om/next and /prev,
ELPA Syncer <=
- [elpa] externals/org-remark 3a5076b8ef 019/173: internal: Update program header, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark c8bbe51411 021/173: doc: Fix some documentation errors, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 2687b8eabf 031/173: admin: merging two machines on my end, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 922d78fbd3 032/173: fix: out of bound for invisible regions, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 022f067983 035/173: doc: Change modified date to be manual, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 447edb9d6d 037/173: intrnl: Add file var to make README as marginalia, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 840381a503 040/173: doc: Correct some program comments, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark a2fa4f9955 043/173: fix: om/list-highlights-positions, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 048c0e806e 044/173: intrnl: Update most functions to return t/nil, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 22eed1f5c2 042/173: fix: om/list-highlights-positions, ELPA Syncer, 2022/01/28