Merge branch 'maint'
This commit is contained in:
commit
9eddf47059
58
lisp/org.el
58
lisp/org.el
|
@ -18562,7 +18562,8 @@ conventions:
|
|||
from `image-file-name-regexp' and it has no contents.
|
||||
|
||||
2. Its description consists in a single link of the previous
|
||||
type.
|
||||
type. In this case, that link must be a well-formed plain
|
||||
or angle link, i.e., it must have an explicit \"file\" type.
|
||||
|
||||
When optional argument INCLUDE-LINKED is non-nil, also links with
|
||||
a text description part will be inlined. This can be nice for
|
||||
|
@ -18578,8 +18579,7 @@ boundaries."
|
|||
(unless refresh
|
||||
(org-remove-inline-images)
|
||||
(when (fboundp 'clear-image-cache) (clear-image-cache)))
|
||||
(org-with-wide-buffer
|
||||
(goto-char (or beg (point-min)))
|
||||
(org-with-point-at (or beg 1)
|
||||
(let* ((case-fold-search t)
|
||||
(file-extension-re (image-file-name-regexp))
|
||||
(link-abbrevs (mapcar #'car
|
||||
|
@ -18588,23 +18588,47 @@ boundaries."
|
|||
;; Check absolute, relative file names and explicit
|
||||
;; "file:" links. Also check link abbreviations since
|
||||
;; some might expand to "file" links.
|
||||
(file-types-re (format "[][]\\[\\(?:file\\|[./~]%s\\)"
|
||||
(file-types-re
|
||||
(format "\\[\\[\\(?:file%s:\\|[./~]\\)\\|\\]\\[\\(<?file:\\)"
|
||||
(if (not link-abbrevs) ""
|
||||
(format "\\|\\(?:%s:\\)"
|
||||
(regexp-opt link-abbrevs))))))
|
||||
(concat "\\|" (regexp-opt link-abbrevs))))))
|
||||
(while (re-search-forward file-types-re end t)
|
||||
(let ((link (save-match-data (org-element-context))))
|
||||
;; Check if we're at an inline image, i.e., an image file
|
||||
;; link without a description (unless INCLUDE-LINKED is
|
||||
;; non-nil).
|
||||
(when (and (equal "file" (org-element-property :type link))
|
||||
(or include-linked
|
||||
(null (org-element-contents link)))
|
||||
(string-match-p file-extension-re
|
||||
(let* ((link (org-element-lineage
|
||||
(save-match-data (org-element-context))
|
||||
'(link) t))
|
||||
(inner-start (match-beginning 1))
|
||||
(path
|
||||
(cond
|
||||
;; No link at point; no inline image.
|
||||
((not link) nil)
|
||||
;; File link without a description. Also handle
|
||||
;; INCLUDE-LINKED here since it should have
|
||||
;; precedence over the next case. I.e., if link
|
||||
;; contains filenames in both the path and the
|
||||
;; description, prioritize the path only when
|
||||
;; INCLUDE-LINKED is non-nil.
|
||||
((or (not (org-element-property :contents-begin link))
|
||||
include-linked)
|
||||
(and (equal "file" (org-element-property :type link))
|
||||
(org-element-property :path link)))
|
||||
(let ((file (expand-file-name
|
||||
(org-link-unescape
|
||||
(org-element-property :path link)))))
|
||||
;; Link with a description. Check if description
|
||||
;; is a filename. Even if Org doesn't have syntax
|
||||
;; for those -- clickable image -- constructs, fake
|
||||
;; them, as in `org-export-insert-image-links'.
|
||||
((not inner-start) nil)
|
||||
(t
|
||||
(org-with-point-at inner-start
|
||||
(and (looking-at
|
||||
(if (char-equal ?< (char-after inner-start))
|
||||
org-angle-link-re
|
||||
org-plain-link-re))
|
||||
;; File name must fill the whole
|
||||
;; description.
|
||||
(= (org-element-property :contents-end link)
|
||||
(match-end 0))
|
||||
(match-string 2)))))))
|
||||
(when (and path (string-match-p file-extension-re path))
|
||||
(let ((file (expand-file-name (org-link-unescape path))))
|
||||
(when (file-exists-p file)
|
||||
(let ((width
|
||||
;; Apply `org-image-actual-width' specifications.
|
||||
|
|
Loading…
Reference in New Issue