diff --git a/README.org b/README.org index 18a1d93..6bc0cda 100644 --- a/README.org +++ b/README.org @@ -108,11 +108,10 @@ Alternatively, you can use ~use-package~ to set up Org-remark. The example provi #+begin_src emacs-lisp (use-package org-remark-global-tracking ;; It is recommended that `org-remark-global-tracking-mode' be - ;; enabled when Emacs initializes. You can put it to - ;; `after-init-hook' as in the comment above + ;; enabled when Emacs initializes. You can set it in + ;; `after-init-hook'. :hook after-init :config - (org-remark-global-tracking-mode +1) ;; Selectively keep or comment out the following if you want to use ;; extensions for Info-mode, EWW, and NOV.el (EPUB) respectively. (use-package org-remark-info :after info :config (org-remark-info-mode +1)) diff --git a/docs/org-remark.org b/docs/org-remark.org index c7cf572..458ef3b 100644 --- a/docs/org-remark.org +++ b/docs/org-remark.org @@ -103,29 +103,30 @@ Alternatively, you can use ~use-package~ to set up Org-remark. The example provi #+name: setup-with-use-package #+begin_src emacs-lisp + (use-package org-remark-global-tracking + ;; It is recommended that `org-remark-global-tracking-mode' be + ;; enabled when Emacs initializes. You can set it in + ;; `after-init-hook'. + :hook after-init + :config + ;; Selectively keep or comment out the following if you want to use + ;; extensions for Info-mode, EWW, and NOV.el (EPUB) respectively. + (use-package org-remark-info :after info :config (org-remark-info-mode +1)) + (use-package org-remark-eww :after eww :config (org-remark-eww-mode +1)) + (use-package org-remark-nov :after nov :config (org-remark-nov-mode +1))) + (use-package org-remark :bind (;; :bind keyword also implicitly defers org-remark itself. - ;; Keybindings before :map is set for global-map. + ;; Keybindings before :map is set for global-map. Adjust the keybinds + ;; as you see fit. ("C-c n m" . org-remark-mark) - ("C-c n l" . org-remark-mark-line) ; new in v1.3 + ("C-c n l" . org-remark-mark-line) :map org-remark-mode-map ("C-c n o" . org-remark-open) ("C-c n ]" . org-remark-view-next) ("C-c n [" . org-remark-view-prev) ("C-c n r" . org-remark-remove) - ("C-c n d" . org-remark-delete)) - ;; Alternative way to enable `org-remark-global-tracking-mode' in - ;; `after-init-hook'. - ;; :hook (after-init . org-remark-global-tracking-mode) - :init - ;; It is recommended that `org-remark-global-tracking-mode' be - ;; enabled when Emacs initializes. Alternatively, you can put it to - ;; `after-init-hook' as in the comment above - (org-remark-global-tracking-mode +1) - :config - (use-package org-remark-info :after info :config (org-remark-info-mode +1)) - (use-package org-remark-eww :after eww :config (org-remark-eww-mode +1)) - (use-package org-remark-nov :after nov :config (org-remark-nov-mode +1))) + ("C-c n d" . org-remark-delete))) #+end_src * Getting Started diff --git a/org-remark.el b/org-remark.el index 7474d34..3fae25e 100644 --- a/org-remark.el +++ b/org-remark.el @@ -830,6 +830,8 @@ Return nil if not and outputs a message in the echo." (org-remark-find-prev-highlight)))) (if p (progn (goto-char p) + (when (and org-remark-reveal-p (org-invisible-p (point)) + (org-remark--reveal-context))) ;; Setup the overriding keymap. (unless overriding-terminal-local-map (let ((prefix-keys (substring (this-single-command-keys) 0 -1)) @@ -842,6 +844,14 @@ Return nil if not and outputs a message in the echo." (message "No visible highlights present in the buffer") nil)))) +(defun org-remark--reveal-context () + (pcase-let + ((`(,fn . ,ov) + (get-char-property-and-overlay (point) 'isearch-open-invisible))) + (cond ((and (functionp fn) ov) (funcall fn ov)) + ((and (derived-mode-p 'org-mode)) + (org-fold-show-context 'link-search))))) + (defun org-remark-find-next-highlight () "Return the beg point of the next highlight. Look through `org-remark-highlights' list." @@ -1713,6 +1723,18 @@ This function also set `org-remark-highlights' to nil." (when (overlay-get ov 'org-remark-id) (delete-overlay ov))))) +(defvar-local org-remark-reveal-p nil) + +(defun org-remark-reveal-activate-locally () + (interactive) + (setq-local org-remark-reveal-p t) + (message "Org-remark-next/prev now show hidden highlighs.")) + +(defun org-remark-reveal-deactivate-locally () + (interactive) + (setq-local org-remark-reveal-p nil) + (message "Org-remark-next/prev now keep hidden highlighs hidden.")) + (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 @@ -1728,13 +1750,17 @@ If none, return nil." (lambda (h) (let ((p (overlay-start h))) ;; Checking if the p is visible or not - (if (or - (> p (point-max)) - (< p (point-min)) - ;; When the highlight is within a visible folded - ;; area, this function returns 'outline - (org-invisible-p p)) - nil p))) + (cond ((or (> p (point-max)) (< p (point-min))) nil) + ;; When the highlight is within a visible folded + ;; area, this function returns 'outline + + ;; When `org-remark-reveal-p' is non-nil, invisible + ;; highlights due to folding will be + ;; revealed. Those highlights outside the narrowed + ;; regions will remain hidden. + ((org-invisible-p p) + (if org-remark-reveal-p p nil)) + (t p)))) list)) (setq list (remove nil list)) (when list