mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix) workaround for cite backlinks crashing (#1454)
Co-authored-by: Jethro Kuan <jethrokuan95@gmail.com>
This commit is contained in:
committed by
GitHub
parent
1ea5b029a5
commit
537f167503
@ -34,11 +34,22 @@
|
||||
(require 'magit-section)
|
||||
(require 'org-roam-structs)
|
||||
(require 'org-roam-mode)
|
||||
(require 'org-roam-capture)
|
||||
(eval-when-compile
|
||||
(require 'org-roam-macs))
|
||||
|
||||
(declare-function org-roam-id-at-point "org-roam")
|
||||
(declare-function org-roam-id-at-point "org-roam" ())
|
||||
(declare-function org-roam--tags-table "org-roam" ())
|
||||
(declare-function org-roam-file-at-point "org-roam-unlinked-references" (&optional assert))
|
||||
|
||||
(defvar org-roam-directory)
|
||||
(defvar org-roam-mode-sections)
|
||||
(defvar org-roam-capture-additional-template-props)
|
||||
(defvar org-roam-title-to-slug-function)
|
||||
|
||||
(declare-function org-element-property "org-element" (property element))
|
||||
;; alternatively,
|
||||
;; (require 'org-element)
|
||||
|
||||
;;; Section
|
||||
;;;; Definition
|
||||
@ -225,7 +236,7 @@ PROPERTIES contains properties about the link."
|
||||
(magit-insert-section section (org-roam-preview-section)
|
||||
(pcase-let ((`(,begin ,end ,s) (org-roam-node-preview (org-roam-node-file source-node)
|
||||
point)))
|
||||
(insert (org-fontify-like-in-org-mode s) "\n")
|
||||
(insert (org-roam-fontify-like-in-org-mode s) "\n")
|
||||
(oset section file (org-roam-node-file source-node))
|
||||
(oset section begin begin)
|
||||
(oset section end end)))))
|
||||
@ -299,7 +310,8 @@ window instead."
|
||||
(let ((random-row (seq-random-elt (org-roam-db-query [:select [id file pos] :from nodes]))))
|
||||
(org-roam-node-visit (org-roam-node-create :id (nth 0 random-row)
|
||||
:file (nth 1 random-row)
|
||||
:point (nth 2 random-row)))))
|
||||
:point (nth 2 random-row))
|
||||
other-window)))
|
||||
|
||||
|
||||
(provide 'org-roam-node)
|
||||
|
@ -77,6 +77,34 @@
|
||||
(when org-roam-verbose
|
||||
(apply #'message `(,(concat "(org-roam) " format-string) ,@args))))
|
||||
|
||||
(defvar org-ref-buffer-hacked)
|
||||
|
||||
(defun org-roam-fontify-like-in-org-mode (s)
|
||||
"Fontify string S like in Org mode.
|
||||
Like `org-fontify-like-in-org-mode', but supports `org-ref'."
|
||||
;; NOTE: pretend that the temporary buffer created by `org-fontify-like-in-org-mode' to
|
||||
;; fontify a `cite:' reference has been hacked by org-ref, whatever that means;
|
||||
;;
|
||||
;; `org-ref-cite-link-face-fn', which is used to supply a face for `cite:' links, calls
|
||||
;; `hack-dir-local-variables' rationalizing that `bibtex-completion' would throw some warnings
|
||||
;; otherwise. This doesn't seem to be the case and calling this function just before
|
||||
;; `org-font-lock-ensure' (alias of `font-lock-ensure') actually instead of fixing the alleged
|
||||
;; warnings messes the things so badly that `font-lock-ensure' crashes with error and doesn't let
|
||||
;; org-roam to proceed further. I don't know what's happening there exactly but disabling this hackery
|
||||
;; fixes the crashing. Fortunately, org-ref provides the `org-ref-buffer-hacked' switch, which we use
|
||||
;; here to make it believe that the buffer was hacked.
|
||||
;;
|
||||
;; This is a workaround for `cite:' links and does not have any effect on other ref types.
|
||||
;;
|
||||
;; `org-ref-buffer-hacked' is a buffer-local variable, therefore we inline
|
||||
;; `org-fontify-like-in-org-mode' here
|
||||
(with-temp-buffer
|
||||
(insert s)
|
||||
(let ((org-ref-buffer-hacked t))
|
||||
(org-mode)
|
||||
(org-font-lock-ensure)
|
||||
(buffer-string))))
|
||||
|
||||
(defun org-roam-set-header-line-format (string)
|
||||
"Set the header-line using STRING.
|
||||
If the `face' property of any part of STRING is already set, then
|
||||
|
Reference in New Issue
Block a user