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
|
** Overview
|
||||||
** Details
|
** 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
|
*** Changes in iCalendar export
|
||||||
Deadline and scheduling time stamps are now treated
|
Deadline and scheduling time stamps are now treated
|
||||||
differently in iCalendar export. The default behavior is now
|
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
|
@example
|
||||||
http://www.astro.uva.nl/~dominik @r{on the web}
|
http://www.astro.uva.nl/~dominik @r{on the web}
|
||||||
file:/home/dominik/images/jupiter.jpg @r{file, absolute path}
|
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}
|
file:papers/last.pdf @r{file, relative path}
|
||||||
|
./papers/last.pdf @r{same as above}
|
||||||
news:comp.emacs @r{Usenet link}
|
news:comp.emacs @r{Usenet link}
|
||||||
mailto:adent@@galaxy.net @r{Mail link}
|
mailto:adent@@galaxy.net @r{Mail link}
|
||||||
vm:folder @r{VM folder link}
|
vm:folder @r{VM folder link}
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
(org-icalendar-include-todo): Default changed to t.
|
(org-icalendar-include-todo): Default changed to t.
|
||||||
(org-print-icalendar-entries): Implement better utilization of
|
(org-print-icalendar-entries): Implement better utilization of
|
||||||
scheduling and deadline time stamps.
|
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,
|
* org-clock.el (org-clocktable-shift): Also undertand yesterday,
|
||||||
lastweek etc.
|
lastweek etc.
|
||||||
|
|
|
@ -1415,10 +1415,12 @@ on this string to produce the exported version."
|
||||||
|
|
||||||
(defun org-export-kill-licensed-text ()
|
(defun org-export-kill-licensed-text ()
|
||||||
"Remove all text that is marked with a :org-license-to-kill property."
|
"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)
|
(while (setq p (text-property-any (point-min) (point-max)
|
||||||
:org-license-to-kill t))
|
: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)
|
(defun org-export-define-heading-targets (target-alist)
|
||||||
"Find all headings and define the targets for them.
|
"Find all headings and define the targets for them.
|
||||||
|
@ -1472,20 +1474,25 @@ let the link point to the corresponding section."
|
||||||
(slink (org-solidify-link-text link))
|
(slink (org-solidify-link-text link))
|
||||||
found props pos
|
found props pos
|
||||||
(target
|
(target
|
||||||
(or (cdr (assoc slink target-alist))
|
(cond
|
||||||
(save-excursion
|
((cdr (assoc slink target-alist)))
|
||||||
(unless (string-match org-link-types-re link)
|
((string-match org-link-types-re link) nil)
|
||||||
(setq found (condition-case nil (org-link-search link)
|
((or (file-name-absolute-p link)
|
||||||
(error nil)))
|
(string-match "^\\." link))
|
||||||
(when (and found
|
nil)
|
||||||
(or (org-on-heading-p)
|
(t
|
||||||
(not (eq found 'dedicated))))
|
(save-excursion
|
||||||
(or (get-text-property (point) 'target)
|
(setq found (condition-case nil (org-link-search link)
|
||||||
(get-text-property
|
(error nil)))
|
||||||
(max (point-min)
|
(when (and found
|
||||||
(1- (previous-single-property-change
|
(or (org-on-heading-p)
|
||||||
(point) 'target)))
|
(not (eq found 'dedicated))))
|
||||||
'target))))))))
|
(or (get-text-property (point) 'target)
|
||||||
|
(get-text-property
|
||||||
|
(max (point-min)
|
||||||
|
(1- (previous-single-property-change
|
||||||
|
(point) 'target)))
|
||||||
|
'target))))))))
|
||||||
(when target
|
(when target
|
||||||
(set-match-data md)
|
(set-match-data md)
|
||||||
(goto-char (match-beginning 1))
|
(goto-char (match-beginning 1))
|
||||||
|
@ -2954,8 +2961,14 @@ lang=\"%s\" xml:lang=\"%s\">
|
||||||
(setq start 0)
|
(setq start 0)
|
||||||
(while (string-match org-bracket-link-analytic-regexp line start)
|
(while (string-match org-bracket-link-analytic-regexp line start)
|
||||||
(setq start (match-beginning 0))
|
(setq start (match-beginning 0))
|
||||||
(setq type (if (match-end 2) (match-string 2 line) "internal"))
|
|
||||||
(setq path (match-string 3 line))
|
(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))
|
(setq desc1 (if (match-end 5) (match-string 5 line))
|
||||||
desc2 (if (match-end 2) (concat type ":" path) path)
|
desc2 (if (match-end 2) (concat type ":" path) path)
|
||||||
descp (and desc1 (not (equal desc1 desc2)))
|
descp (and desc1 (not (equal desc1 desc2)))
|
||||||
|
@ -2987,6 +3000,13 @@ lang=\"%s\" xml:lang=\"%s\">
|
||||||
;; standard URL
|
;; standard URL
|
||||||
(setq link (concat type ":" path))
|
(setq link (concat type ":" path))
|
||||||
(setq rpl (concat "<a href=\"" link "\">" desc "</a>")))
|
(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")
|
((string= type "file")
|
||||||
;; FILE link
|
;; FILE link
|
||||||
(let* ((filename path)
|
(let* ((filename path)
|
||||||
|
@ -3027,12 +3047,6 @@ lang=\"%s\" xml:lang=\"%s\">
|
||||||
(concat "<a href=\"" thefile "\">" desc "</a>")))
|
(concat "<a href=\"" thefile "\">" desc "</a>")))
|
||||||
(if (not valid) (setq rpl desc))))
|
(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
|
(t
|
||||||
;; just publish the path, as default
|
;; just publish the path, as default
|
||||||
(setq rpl (concat "<i><" type ":"
|
(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)
|
(while (string-match " *\n *" link)
|
||||||
(setq link (replace-match " " t t link)))
|
(setq link (replace-match " " t t link)))
|
||||||
(setq link (org-link-expand-abbrev link))
|
(setq link (org-link-expand-abbrev link))
|
||||||
(if (string-match org-link-re-with-space2 link)
|
(cond
|
||||||
(setq type (match-string 1 link) path (match-string 2 link))
|
((or (file-name-absolute-p link)
|
||||||
(setq type "thisfile" path 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)))
|
(throw 'match t)))
|
||||||
|
|
||||||
(when (get-text-property (point) 'org-linked-text)
|
(when (get-text-property (point) 'org-linked-text)
|
||||||
|
|
Loading…
Reference in New Issue