Skip to content

Commit

Permalink
Change to how description is retrieved from resource links.
Browse files Browse the repository at this point in the history
Fixes #315
  • Loading branch information
Kungsgeten committed Jun 2, 2020
1 parent c1d1643 commit 8a727b0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions org-brain.el
Original file line number Diff line number Diff line change
Expand Up @@ -1245,14 +1245,18 @@ A link can be either an org link or an org attachment.
The car is the raw-link and the cdr is the description."
(let ((links
(delete-dups
(org-element-map (org-brain-entry-data entry) 'link
(lambda (link)
(unless (member (org-element-property :type link)
org-brain-ignored-resource-links)
(cons (org-element-property :raw-link link)
(when-let ((desc (car (org-element-contents link))))
(replace-regexp-in-string "[ \t\n\r]+" " " desc)))))
nil nil t))))
(with-temp-buffer
(insert-file-contents (org-brain-entry-path entry))
(org-element-map (org-brain-entry-data entry) 'link
(lambda (link)
(unless (member (org-element-property :type link)
org-brain-ignored-resource-links)
(cons (org-element-property :raw-link link)
(when-let ((beg (org-element-property :contents-begin link))
(end (org-element-property :contents-end link)))
(replace-regexp-in-string
"[ \t\n\r]+" " " (buffer-substring beg end))))))
nil nil t)))))
(if (org-brain-filep entry)
links
;; Headline entry
Expand Down

0 comments on commit 8a727b0

Please sign in to comment.