(fix): widen before title extraction (#1232)

Prevent renaming file and changing links incorrectly due to using (org-narrow-to-subtree) and saving.
This commit is contained in:
Herbert Jones
2020-11-03 23:34:40 -06:00
committed by GitHub
parent 7c83a84db3
commit bc5c41d212
2 changed files with 14 additions and 12 deletions

View File

@ -14,6 +14,7 @@
- [#1199](https://github.com/org-roam/org-roam/issues/1199) make Org-roam link insertions respect `org-roam-link-title-format` everywhere.
- [#1201](https://github.com/org-roam/org-roam/issues/1201) fix `org-roam-db-build-cache` failing in scenarios involving duplicate IDs and deleted files.
- [#1226](https://github.com/org-roam/org-roam/issues/1226) only update relative path of file links
- [#1232](https://github.com/org-roam/org-roam/issues/1232) fix incorrect title extractions from narrowed buffers
## 1.2.2 (06-10-2020)

View File

@ -669,18 +669,19 @@ Reads from the \"roam_alias\" property."
(defun org-roam--extract-titles (&optional sources nested)
"Extract the titles from current buffer using SOURCES.
If NESTED, return the first successful result from SOURCES."
(let (coll res)
(cl-dolist (source (or sources
org-roam-title-sources))
(setq res (if (symbolp source)
(funcall (intern (concat "org-roam--extract-titles-" (symbol-name source))))
(org-roam--extract-titles source t)))
(when res
(if (not nested)
(setq coll (nconc coll res))
(setq coll res)
(cl-return))))
coll))
(org-with-wide-buffer
(let (coll res)
(cl-dolist (source (or sources
org-roam-title-sources))
(setq res (if (symbolp source)
(funcall (intern (concat "org-roam--extract-titles-" (symbol-name source))))
(org-roam--extract-titles source t)))
(when res
(if (not nested)
(setq coll (nconc coll res))
(setq coll res)
(cl-return))))
coll)))
(defun org-roam--extract-tags-all-directories (file)
"Extract tags from using the directory path FILE.