fix(org): compatibility issues

This commit is contained in:
Kiana Sheibani 2024-08-14 05:08:03 -04:00
parent aea71adb3c
commit 02bbdde2d2
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -3160,9 +3160,8 @@ Inline images in Org are file links pointing to images without a description. Us
(defadvice! +org-inline-desc (old-fn protocol link description)
"Disable inline images with descriptions when `+org-inline-image-desc'
is non-nil."
:around '(org-yt-image-data-fun
+org-inline-image-data-fn
+org-http-image-data-fn)
:around (list #'+org-inline-image-data-fn
#'+org-http-image-data-fn)
(when (or +org-inline-image-desc (null description))
(funcall old-fn protocol link description)))
#+end_src
@ -3294,19 +3293,17 @@ Annoyingly, the only good way to fix these issues is to completely override the
When an explicit category is not specified, Org mode typically defaults to the filename (sans extension). This ... sort of makes sense? I guess? It doesn't really, because filename conventions don't make for good agenda category names. I want my category names to be in title case, whereas a file name is typically going to be all lowercase and without spaces. This is especially bad for Org-roam, where filenames are automatically generated and way too long to be a UI element.
To fix this issue, it's... "easy" to patch Org-mode's category system[fn:2]. The following code sets things up so that the file's =#+title= metadata is used as the default category, falling back on the default behavior if a title is not given.
To fix this issue, it's... "easy" to patch Org-mode's category system. The following code sets things up so that the file's =#+title= metadata is used as the default category, falling back on the default behavior if a title is not given.
#+begin_src emacs-lisp
(defadvice! ~/org-default-category (old-fn)
"Modify how Org resolves the default category through the
`org-category' variable."
:around '(org-refresh-category-properties org-element-org-data-parser)
:around #'org-element--get-category
(let ((org-category (or org-category (org-get-title))))
(funcall old-fn)))
#+end_src
[fn:2] It took me multiple hours of combing through Org's source code in order to find the multiple places(???) where this behavior was implemented and to figure out how to modify it. At least the final code is short!
** Org Roam
#+call: confpkg("Org: Roam")