nobiot / org-remark

Highlight & annotate text, EWW, Info, and EPUB
https://nobiot.github.io/org-remark/
GNU General Public License v3.0
436 stars 22 forks source link

Nov.el support #58

Closed nobiot closed 1 year ago

nobiot commented 1 year ago

Aiming for v1.2.0. #54 has been merged. This PR should be the development branch for it.

nobiot commented 1 year ago

I have introduced a minor mode org-remark-nov-mode. Activate it to enable nov-mode support. Loading the file does not change the behaviour of the system. I do the following:

(add-to-list 'load-path (expand-file-name "org-remark" my/repos))
(require 'org-remark-global-tracking)
(org-remark-global-tracking-mode +1)

(with-eval-after-load 'nov
  (require 'org-remark-nov)
  (org-remark-nov-mode +1))
sati-bodhi commented 1 year ago

I run into the following warning/error when trying to save the *marginal-notes* buffer with the new dev/nov.el branch.

If this warning appears regularly, please report the warning text to Org mode mailing list (M-x org-submit-bug-report).
The element is: "(paragraph (:begin 31740 :end 31934 :contents-begin 31740 :contents-end 31932 :post-blank 2 :post-affiliated 31740 :mode nil :granularity element :cached t :parent (section (:begin 31211 :end 31934 :contents-begin 31211 :contents-end 31932 :robust-begin 31211 :robust-end 31930 :post-blank 2 :post-affiliated 31211 :mode section :granularity element :cached t :parent (headline ...) :org-element--cache-sync-key (2 . 31209))) :org-element--cache-sync-key (2 . 31739)))"
 The real element is: "(paragraph (:begin 31475 :end 31741 :contents-begin 31475 :contents-end 31740 :post-blank 1 :post-affiliated 31475 :mode nil :granularity element :parent (section (:begin 31212 :end 31935 :contents-begin 31212 :contents-end 31933 :robust-begin 31212 :robust-end 31931 :post-blank 2 :post-affiliated 31212 :mode section :granularity element :parent (headline ...)))))"
 Cache around :begin:
(paragraph (:begin 31474 :end 31740 :contents-begin 31474 :contents-end 31739 :post-blank 1 :post-affiliated 31474 :mode nil :granularity element :cached t :parent (section (:begin 31211 :end 31934 :contents-begin 31211 :contents-end 31932 :robust-begin 31211 :robust-end 31930 :post-blank 2 :post-affiliated 31211 :mode section :granularity element :cached t :parent (headline (:raw-value "Infant's Coping Behavior" :begin 31182 :end 31934 :pre-blank 0 :contents-begin 31211 :contents-end 31932 :robust-begin 31371 :robust-end 31930 :level 3 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 2 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 31182 :ORG-REMARK-BEG "16139" :ORG-REMARK-END "16164" :ORG-REMARK-ID "51c0f7b6" :ORG-REMARK-LABEL "nil" :ID "d1325dc8-fa5d-4000-9402-db97d98247bd" :title "Infant's Coping Behavior" :mode nil :granularity element :cached t :parent (headline (:raw-value "Chapter 11" :begin 26416 :end 31934 :pre-blank 0 :contents-begin 26430 :contents-end 31932 :robust-begin 26540 :robust-end 31930 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 2 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 26416 :ORG-REMARK-FILE "The Neurobehavioral and Social-Emotional D - Ed Tronick.epub/22_Chapter11" :title "Chapter 11" :mode nil :granularity element :org-element--cache-sync-key (2 . 26415) :cached t :parent (headline (:raw-value "Neurobehavioral and Social-Emotional Development - Ed Tronick" :begin 1 :end 41697 :pre-blank 0 :contents-begin 65 :contents-end 41689 :robust-begin 306 :robust-end 41687 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 8 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :ORG-REMARK-NOV-FILE "/home/sati/Calibre Library/Ed Tronick/The Neurobehavioral and Social-Emotional Development of Infants and Children (Norton Series on (1040)/The Neurobehavioral and Social-Emotional D - Ed Tronick.epub" :title "Neurobehavioral and Social-Emotional Development - Ed Tronick" :mode first-section :granularity element :cached t :parent (org-data (:begin 1 :contents-begin 1 :contents-end 41689 :end 41697 :robust-begin 3 :robust-end 41687 :post-blank 8 :post-affiliated 1 :path "/home/sati/org/roam/marginalia.org" :mode org-data :CATEGORY "marginalia" :cached t)) :org-element--cache-sync-key (1 . 1))))) :org-element--cache-sync-key (2 . 31181))) :org-element--cache-sync-key (2 . 31209))) :org-element--cache-sync-key (2 . 31473)))
(paragraph (:begin 31474 :end 31740 :contents-begin 31474 :contents-end 31739 :post-blank 1 :post-affiliated 31474 :mode nil :granularity element :cached t :parent (section (:begin 31211 :end 31934 :contents-begin 31211 :contents-end 31932 :robust-begin 31211 :robust-end 31930 :post-blank 2 :post-affiliated 31211 :mode section :granularity element :cached t :parent (headline (:raw-value "Infant's Coping Behavior" :begin 31182 :end 31934 :pre-blank 0 :contents-begin 31211 :contents-end 31932 :robust-begin 31371 :robust-end 31930 :level 3 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 2 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 31182 :ORG-REMARK-BEG "16139" :ORG-REMARK-END "16164" :ORG-REMARK-ID "51c0f7b6" :ORG-REMARK-LABEL "nil" :ID "d1325dc8-fa5d-4000-9402-db97d98247bd" :title "Infant's Coping Behavior" :mode nil :granularity element :cached t :parent (headline (:raw-value "Chapter 11" :begin 26416 :end 31934 :pre-blank 0 :contents-begin 26430 :contents-end 31932 :robust-begin 26540 :robust-end 31930 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 2 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 26416 :ORG-REMARK-FILE "The Neurobehavioral and Social-Emotional D - Ed Tronick.epub/22_Chapter11" :title "Chapter 11" :mode nil :granularity element :org-element--cache-sync-key (2 . 26415) :cached t :parent (headline (:raw-value "Neurobehavioral and Social-Emotional Development - Ed Tronick" :begin 1 :end 41697 :pre-blank 0 :contents-begin 65 :contents-end 41689 :robust-begin 306 :robust-end 41687 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 8 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :ORG-REMARK-NOV-FILE "/home/sati/Calibre Library/Ed Tronick/The Neurobehavioral and Social-Emotional Development of Infants and Children (Norton Series on (1040)/The Neurobehavioral and Social-Emotional D - Ed Tronick.epub" :title "Neurobehavioral and Social-Emotional Development - Ed Tronick" :mode first-section :granularity element :cached t :parent (org-data (:begin 1 :contents-begin 1 :contents-end 41689 :end 41697 :robust-begin 3 :robust-end 41687 :post-blank 8 :post-affiliated 1 :path "/home/sati/org/roam/marginalia.org" :mode org-data :CATEGORY "marginalia" :cached t)) :org-element--cache-sync-key (1 . 1))))) :org-element--cache-sync-key (2 . 31181))) :org-element--cache-sync-key (2 . 31209))) :org-element--cache-sync-key (2 . 31473)))
(paragraph (:begin 31740 :end 31934 :contents-begin 31740 :contents-end 31932 :post-blank 2 :post-affiliated 31740 :mode nil :granularity element :cached t :parent (section (:begin 31211 :end 31934 :contents-begin 31211 :contents-end 31932 :robust-begin 31211 :robust-end 31930 :post-blank 2 :post-affiliated 31211 :mode section :granularity element :cached t :parent (headline (:raw-value "Infant's Coping Behavior" :begin 31182 :end 31934 :pre-blank 0 :contents-begin 31211 :contents-end 31932 :robust-begin 31371 :robust-end 31930 :level 3 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 2 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 31182 :ORG-REMARK-BEG "16139" :ORG-REMARK-END "16164" :ORG-REMARK-ID "51c0f7b6" :ORG-REMARK-LABEL "nil" :ID "d1325dc8-fa5d-4000-9402-db97d98247bd" :title "Infant's Coping Behavior" :mode nil :granularity element :cached t :parent (headline (:raw-value "Chapter 11" :begin 26416 :end 31934 :pre-blank 0 :contents-begin 26430 :contents-end 31932 :robust-begin 26540 :robust-end 31930 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 2 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 26416 :ORG-REMARK-FILE "The Neurobehavioral and Social-Emotional D - Ed Tronick.epub/22_Chapter11" :title "Chapter 11" :mode nil :granularity element :org-element--cache-sync-key (2 . 26415) :cached t :parent (headline (:raw-value "Neurobehavioral and Social-Emotional Development - Ed Tronick" :begin 1 :end 41697 :pre-blank 0 :contents-begin 65 :contents-end 41689 :robust-begin 306 :robust-end 41687 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 8 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :ORG-REMARK-NOV-FILE "/home/sati/Calibre Library/Ed Tronick/The Neurobehavioral and Social-Emotional Development of Infants and Children (Norton Series on (1040)/The Neurobehavioral and Social-Emotional D - Ed Tronick.epub" :title "Neurobehavioral and Social-Emotional Development - Ed Tronick" :mode first-section :granularity element :cached t :parent (org-data (:begin 1 :contents-begin 1 :contents-end 41689 :end 41697 :robust-begin 3 :robust-end 41687 :post-blank 8 :post-affiliated 1 :path "/home/sati/org/roam/marginalia.org" :mode org-data :CATEGORY "marginalia" :cached t)) :org-element--cache-sync-key (1 . 1))))) :org-element--cache-sync-key (2 . 31181))) :org-element--cache-sync-key (2 . 31209))) :org-element--cache-sync-key (2 . 31739))) Disable showing Disable logging
Warning (org-element-cache): org-element--cache: Org parser error in marginalia.org::#<marker at 41991 in marginalia.org>. Resetting.
 The error was: (error "Invalid search bound (wrong side of point)")
 Backtrace:
"  backtrace-to-string(nil)
  org-element-at-point(#<marker at 41991 in marginalia.org>)
  org-element-cache-map(#f(compiled-function (el) #<bytecode -0x1c09f7f926917880>) :next-re \"^\\\\*+ \" :fail-re \"^\\\\*+ \" :narrow t)
  org-scan-tags(org-encrypt-entry (lambda (todo tags-list level) (progn (setq org-cached-props nil) (or (and (member \"crypt\" tags-list))))) nil)
  org-encrypt-entries()
  run-hooks(before-save-hook)
  basic-save-buffer(nil)
  save-buffer()
  (if (not bang) (save-buffer) (write-file filename))
  (cond ((= 0 (length filename)) (user-error \"Please specify a file name for the buffer\")) ((eq (aref filename 0) 33) (shell-command-on-region beg end (substring filename 1))) ((or append (and beg end)) (write-region beg end filename append nil nil (not (or append bang)))) ((null bufname) (write-file filename (not bang))) ((string= filename bufname) (if (not bang) (save-buffer) (write-file filename))) (t (write-region nil nil filename nil (not bufname) nil (not bang))))
  (let* ((append-and-filename (evil-extract-append file-or-append)) (append (car append-and-filename)) (filename (cdr append-and-filename)) (bufname (buffer-file-name (buffer-base-buffer)))) (if (= 0 (length filename)) (progn (setq filename bufname))) (cond ((= 0 (length filename)) (user-error \"Please specify a file name for the buffer\")) ((eq (aref filename 0) 33) (shell-command-on-region beg end (substring filename 1))) ((or append (and beg end)) (write-region beg end filename append nil nil (not (or append bang)))) ((null bufname) (write-file filename (not bang))) ((string= filename bufname) (if (not bang) (save-buffer) (write-file filename))) (t (write-region nil nil filename nil (not bufname) nil (not bang)))))
  (if (and evil-inhibit-operator (called-interactively-p 'any)) nil (let* ((append-and-filename (evil-extract-append file-or-append)) (append (car append-and-filename)) (filename (cdr append-and-filename)) (bufname (buffer-file-name (buffer-base-buffer)))) (if (= 0 (length filename)) (progn (setq filename bufname))) (cond ((= 0 (length filename)) (user-error \"Please specify a file name for the buffer\")) ((eq (aref filename 0) 33) (shell-command-on-region beg end (substring filename 1))) ((or append (and beg end)) (write-region beg end filename append nil nil (not (or append bang)))) ((null bufname) (write-file filename (not bang))) ((string= filename bufname) (if (not bang) (save-buffer) (write-file filename))) (t (write-region nil nil filename nil (not bufname) nil (not bang))))))
  (let ((evil-inhibit-operator evil-inhibit-operator-value)) (if (and evil-inhibit-operator (called-interactively-p 'any)) nil (let* ((append-and-filename (evil-extract-append file-or-append)) (append (car append-and-filename)) (filename (cdr append-and-filename)) (bufname (buffer-file-name (buffer-base-buffer)))) (if (= 0 (length filename)) (progn (setq filename bufname))) (cond ((= 0 (length filename)) (user-error \"Please specify a file name for the buffer\")) ((eq (aref filename 0) 33) (shell-command-on-region beg end (substring filename 1))) ((or append (and beg end)) (write-region beg end filename append nil nil (not (or append bang)))) ((null bufname) (write-file filename (not bang))) ((string= filename bufname) (if (not bang) (save-buffer) (write-file filename))) (t (write-region nil nil filename nil (not bufname) nil (not bang)))))))
  (unwind-protect (let ((evil-inhibit-operator evil-inhibit-operator-value)) (if (and evil-inhibit-operator (called-interactively-p 'any)) nil (let* ((append-and-filename (evil-extract-append file-or-append)) (append (car append-and-filename)) (filename (cdr append-and-filename)) (bufname (buffer-file-name (buffer-base-buffer)))) (if (= 0 (length filename)) (progn (setq filename bufname))) (cond ((= 0 (length filename)) (user-error \"Please specify a file name for the buffer\")) ((eq (aref filename 0) 33) (shell-command-on-region beg end (substring filename 1))) ((or append (and beg end)) (write-region beg end filename append nil nil (not ...))) ((null bufname) (write-file filename (not bang))) ((string= filename bufname) (if (not bang) (save-buffer) (write-file filename))) (t (write-region nil nil filename nil (not bufname) nil (not bang))))))) (setq evil-inhibit-operator-value nil))
  evil-write(nil nil nil nil nil)
  funcall-interactively(evil-write nil nil nil nil nil)
  call-interactively(evil-write)
  (cond ((not evil-ex-range) (setq this-command evil-ex-command) (evil-exit-visual-state) (run-hooks 'pre-command-hook) (call-interactively evil-ex-command) (run-hooks 'post-command-hook)) (t (let ((ex-range (evil-copy-range evil-ex-range)) beg end) (evil-expand-range ex-range) (setq beg (evil-range-beginning ex-range) end (evil-range-end ex-range)) (let ((sortvar (sort (list beg end) '<))) (setq beg (car-safe (prog1 sortvar (setq sortvar ...))) end (car-safe (prog1 sortvar (setq sortvar ...))))) (setq this-command evil-ex-command) (run-hooks 'pre-command-hook) (set-mark end) (goto-char beg) (activate-mark) (call-interactively evil-ex-command) (run-hooks 'post-command-hook) (if restore-point (progn (goto-char restore-point))))))
  (unwind-protect (cond ((not evil-ex-range) (setq this-command evil-ex-command) (evil-exit-visual-state) (run-hooks 'pre-command-hook) (call-interactively evil-ex-command) (run-hooks 'post-command-hook)) (t (let ((ex-range (evil-copy-range evil-ex-range)) beg end) (evil-expand-range ex-range) (setq beg (evil-range-beginning ex-range) end (evil-range-end ex-range)) (let ((sortvar (sort ... ...))) (setq beg (car-safe (prog1 sortvar ...)) end (car-safe (prog1 sortvar ...)))) (setq this-command evil-ex-command) (run-hooks 'pre-command-hook) (set-mark end) (goto-char beg) (activate-mark) (call-interactively evil-ex-command) (run-hooks 'post-command-hook) (if restore-point (progn (goto-char restore-point)))))) (if (buffer-live-p buf) (progn (save-current-buffer (set-buffer buf) (deactivate-mark)))))
  (let ((buf (current-buffer))) (if evil-ex-reverse-range (progn (setq evil-ex-reverse-range nil) (if (y-or-n-p \"Backward range given, OK to swap? \") nil (user-error \"\")))) (unwind-protect (cond ((not evil-ex-range) (setq this-command evil-ex-command) (evil-exit-visual-state) (run-hooks 'pre-command-hook) (call-interactively evil-ex-command) (run-hooks 'post-command-hook)) (t (let ((ex-range (evil-copy-range evil-ex-range)) beg end) (evil-expand-range ex-range) (setq beg (evil-range-beginning ex-range) end (evil-range-end ex-range)) (let ((sortvar ...)) (setq beg (car-safe ...) end (car-safe ...))) (setq this-command evil-ex-command) (run-hooks 'pre-command-hook) (set-mark end) (goto-char beg) (activate-mark) (call-interactively evil-ex-command) (run-hooks 'post-command-hook) (if restore-point (progn (goto-char restore-point)))))) (if (buffer-live-p buf) (progn (save-current-buffer (set-buffer buf) (deactivate-mark))))))
  (let* ((count (if (numberp range) (progn range))) (range (if (evil-range-p range) (progn range))) (bang (and (let ((save-match-data-internal (match-data))) (unwind-protect (progn (string-match \".!$\" command)) (set-match-data save-match-data-internal 'evaporate))) t)) (evil-ex-point (point)) (evil-ex-range (or range (and count (evil-ex-range count count)))) (evil-ex-command (evil-ex-completed-binding command)) (restore-point (if (evil-get-command-property evil-ex-command :restore-point) (progn (if (evil-visual-state-p) (min (point) (or ... most-positive-fixnum)) (point))))) (evil-ex-bang (and bang t)) (evil-ex-argument (copy-sequence argument)) (evil-this-type (evil-type evil-ex-range)) (current-prefix-arg count) (prefix-arg current-prefix-arg)) (if (stringp evil-ex-argument) (progn (set-text-properties 0 (length evil-ex-argument) nil evil-ex-argument))) (let ((buf (current-buffer))) (if evil-ex-reverse-range (progn (setq evil-ex-reverse-range nil) (if (y-or-n-p \"Backward range given, OK to swap? \") nil (user-error \"\")))) (unwind-protect (cond ((not evil-ex-range) (setq this-command evil-ex-command) (evil-exit-visual-state) (run-hooks 'pre-command-hook) (call-interactively evil-ex-command) (run-hooks 'post-command-hook)) (t (let ((ex-range ...) beg end) (evil-expand-range ex-range) (setq beg (evil-range-beginning ex-range) end (evil-range-end ex-range)) (let (...) (setq beg ... end ...)) (setq this-command evil-ex-command) (run-hooks 'pre-command-hook) (set-mark end) (goto-char beg) (activate-mark) (call-interactively evil-ex-command) (run-hooks 'post-command-hook) (if restore-point (progn ...))))) (if (buffer-live-p buf) (progn (save-current-buffer (set-buffer buf) (deactivate-mark)))))))
  evil-ex-call-command(nil #(\"w\" 0 1 (ex-index 25829)) nil)
  eval((evil-ex-call-command nil #(\"w\" 0 1 (ex-index 25829)) nil))
  (if evil-ex-expression (eval evil-ex-expression) (user-error \"Ex: syntax error\"))
  (if (= 0 (length result)) nil (if evil-ex-expression (eval evil-ex-expression) (user-error \"Ex: syntax error\")))
  evil-ex-execute(#(\"w\" 0 1 (ex-index 25829)))
  (let ((evil-ex-current-buffer (current-buffer)) (evil-ex-previous-command (if initial-input nil (car-safe evil-ex-history))) evil-ex-argument-handler evil-ex-info-string result) (let ((fun (if initial-input #'evil-ex-setup-and-update #'evil-ex-setup)) (setup-hook (make-symbol \"minibuffer-setup\"))) (fset setup-hook #'(lambda nil (remove-hook 'minibuffer-setup-hook setup-hook) (funcall fun))) (unwind-protect (progn (add-hook 'minibuffer-setup-hook setup-hook) (setq result (read-from-minibuffer \":\" (or initial-input (and evil-ex-previous-command evil-want-empty-ex-last-command ...)) evil-ex-completion-map nil 'evil-ex-history (if evil-want-empty-ex-last-command (progn evil-ex-previous-command)) t))) (remove-hook 'minibuffer-setup-hook setup-hook))) (evil-ex-execute result))
  evil-ex(nil)
  funcall-interactively(evil-ex nil)
  call-interactively(evil-ex nil nil)
  command-execute(evil-ex)
"
nobiot commented 1 year ago

Hi @sati-bodhi, this error comes from Org upstream.

I suggest you try to update Org to the latest, or go back to the latest stable version (9.5, I think). Something tells me that you use Doom -- if this is true, I believe Doom pins Org to a certain commit in the development branch for 9.6 and it is not always the latest. You might need to wait for it to be the latest and then doom-sync.

If none seems to change Org's behavior and you see the same/similar warning consistently, I'd suggest that you follow the instruction at the beginning of the warning message, as below:

If this warning appears regularly, please report the warning text to Org mode mailing list (M-x org-submit-bug-report).