Allow omitting the "file:" prefix in some file links.
The file path must be absolute, or it must start with "./" or "../".
This commit is contained in:
parent
84c2010d2c
commit
9b084b22f5
|
@ -17,6 +17,23 @@
|
|||
|
||||
** Overview
|
||||
** Details
|
||||
|
||||
*** Simplified way to specify file links
|
||||
|
||||
In a link, you can now leave uout the "file:" prefix if you
|
||||
write an absolute file name like =/Users/dominik/.emacs= or
|
||||
=~/.emacs=, or if you write a relative file name by using
|
||||
=./= or =../= to start the file path. You cannot write a
|
||||
plain file name, because plain text is interpreted as an
|
||||
internal link.
|
||||
|
||||
So for example, a link to an image /A.jpg/ with a thumbnail
|
||||
/B.jpg/ can now be written like
|
||||
|
||||
#+begin_src org
|
||||
[[./A.jpg][./B.jpg] ]
|
||||
#+end_src
|
||||
|
||||
*** Changes in iCalendar export
|
||||
Deadline and scheduling time stamps are now treated
|
||||
differently in iCalendar export. The default behavior is now
|
||||
|
|
|
@ -2399,7 +2399,9 @@ the colon. The following list shows examples for each link type.
|
|||
@example
|
||||
http://www.astro.uva.nl/~dominik @r{on the web}
|
||||
file:/home/dominik/images/jupiter.jpg @r{file, absolute path}
|
||||
/home/dominik/images/jupiter.jpg @r{same as above}
|
||||
file:papers/last.pdf @r{file, relative path}
|
||||
./papers/last.pdf @r{same as above}
|
||||
news:comp.emacs @r{Usenet link}
|
||||
mailto:adent@@galaxy.net @r{Mail link}
|
||||
vm:folder @r{VM folder link}
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
(org-icalendar-include-todo): Default changed to t.
|
||||
(org-print-icalendar-entries): Implement better utilization of
|
||||
scheduling and deadline time stamps.
|
||||
(org-export-target-internal-links, org-export-as-html): Allow file
|
||||
lines without the "file:" prefix if the file path is an absolute
|
||||
path or starts with ".".
|
||||
|
||||
* org-clock.el (org-clocktable-shift): Also undertand yesterday,
|
||||
lastweek etc.
|
||||
|
|
|
@ -1415,10 +1415,12 @@ on this string to produce the exported version."
|
|||
|
||||
(defun org-export-kill-licensed-text ()
|
||||
"Remove all text that is marked with a :org-license-to-kill property."
|
||||
(let (p)
|
||||
(let (p q)
|
||||
(while (setq p (text-property-any (point-min) (point-max)
|
||||
:org-license-to-kill t))
|
||||
(delete-region p (next-single-property-change p :org-license-to-kill)))))
|
||||
(delete-region
|
||||
p (or (next-single-property-change p :org-license-to-kill)
|
||||
(point-max))))))
|
||||
|
||||
(defun org-export-define-heading-targets (target-alist)
|
||||
"Find all headings and define the targets for them.
|
||||
|
@ -1472,9 +1474,14 @@ let the link point to the corresponding section."
|
|||
(slink (org-solidify-link-text link))
|
||||
found props pos
|
||||
(target
|
||||
(or (cdr (assoc slink target-alist))
|
||||
(cond
|
||||
((cdr (assoc slink target-alist)))
|
||||
((string-match org-link-types-re link) nil)
|
||||
((or (file-name-absolute-p link)
|
||||
(string-match "^\\." link))
|
||||
nil)
|
||||
(t
|
||||
(save-excursion
|
||||
(unless (string-match org-link-types-re link)
|
||||
(setq found (condition-case nil (org-link-search link)
|
||||
(error nil)))
|
||||
(when (and found
|
||||
|
@ -2954,8 +2961,14 @@ lang=\"%s\" xml:lang=\"%s\">
|
|||
(setq start 0)
|
||||
(while (string-match org-bracket-link-analytic-regexp line start)
|
||||
(setq start (match-beginning 0))
|
||||
(setq type (if (match-end 2) (match-string 2 line) "internal"))
|
||||
(setq path (match-string 3 line))
|
||||
(setq type (cond
|
||||
((match-end 2) (match-string 2 line))
|
||||
((save-match-data
|
||||
(or (file-name-absolute-p path)
|
||||
(string-match "^\\.\\.?/" path)))
|
||||
"file")
|
||||
(t "internal")))
|
||||
(setq desc1 (if (match-end 5) (match-string 5 line))
|
||||
desc2 (if (match-end 2) (concat type ":" path) path)
|
||||
descp (and desc1 (not (equal desc1 desc2)))
|
||||
|
@ -2987,6 +3000,13 @@ lang=\"%s\" xml:lang=\"%s\">
|
|||
;; standard URL
|
||||
(setq link (concat type ":" path))
|
||||
(setq rpl (concat "<a href=\"" link "\">" desc "</a>")))
|
||||
|
||||
((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
|
||||
;; The link protocol has a function for format the link
|
||||
(setq rpl
|
||||
(save-match-data
|
||||
(funcall fnc (org-link-unescape path) desc1 'html))))
|
||||
|
||||
((string= type "file")
|
||||
;; FILE link
|
||||
(let* ((filename path)
|
||||
|
@ -3027,12 +3047,6 @@ lang=\"%s\" xml:lang=\"%s\">
|
|||
(concat "<a href=\"" thefile "\">" desc "</a>")))
|
||||
(if (not valid) (setq rpl desc))))
|
||||
|
||||
((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
|
||||
;; The link protocol has a function for format the link
|
||||
(setq rpl
|
||||
(save-match-data
|
||||
(funcall fnc (org-link-unescape path) desc1 'html))))
|
||||
|
||||
(t
|
||||
;; just publish the path, as default
|
||||
(setq rpl (concat "<i><" type ":"
|
||||
|
|
10
lisp/org.el
10
lisp/org.el
|
@ -7123,9 +7123,13 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
|
|||
(while (string-match " *\n *" link)
|
||||
(setq link (replace-match " " t t link)))
|
||||
(setq link (org-link-expand-abbrev link))
|
||||
(if (string-match org-link-re-with-space2 link)
|
||||
(setq type (match-string 1 link) path (match-string 2 link))
|
||||
(setq type "thisfile" path link))
|
||||
(cond
|
||||
((or (file-name-absolute-p link)
|
||||
(string-match "^\\.\\.?/" link))
|
||||
(setq type "file" path link))
|
||||
((string-match org-link-re-with-space2 link)
|
||||
(setq type (match-string 1 link) path (match-string 2 link)))
|
||||
(t (setq type "thisfile" path link)))
|
||||
(throw 'match t)))
|
||||
|
||||
(when (get-text-property (point) 'org-linked-text)
|
||||
|
|
Loading…
Reference in New Issue