diff --git a/ORGWEBPAGE/Changes.org b/ORGWEBPAGE/Changes.org index 7148e21d2..64237cee1 100644 --- a/ORGWEBPAGE/Changes.org +++ b/ORGWEBPAGE/Changes.org @@ -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 diff --git a/doc/org.texi b/doc/org.texi index 75ed152f6..458afb2ed 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -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} diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 443a72a51..4f67a0358 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -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. diff --git a/lisp/org-exp.el b/lisp/org-exp.el index f33ef2165..8931e3da9 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -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,20 +1474,25 @@ let the link point to the corresponding section." (slink (org-solidify-link-text link)) found props pos (target - (or (cdr (assoc slink target-alist)) - (save-excursion - (unless (string-match org-link-types-re link) - (setq found (condition-case nil (org-link-search link) - (error nil))) - (when (and found - (or (org-on-heading-p) - (not (eq found 'dedicated)))) - (or (get-text-property (point) 'target) - (get-text-property - (max (point-min) - (1- (previous-single-property-change - (point) 'target))) - 'target)))))))) + (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 + (setq found (condition-case nil (org-link-search link) + (error nil))) + (when (and found + (or (org-on-heading-p) + (not (eq found 'dedicated)))) + (or (get-text-property (point) 'target) + (get-text-property + (max (point-min) + (1- (previous-single-property-change + (point) 'target))) + 'target)))))))) (when target (set-match-data md) (goto-char (match-beginning 1)) @@ -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 "" 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)))) + ((string= type "file") ;; FILE link (let* ((filename path) @@ -3027,12 +3047,6 @@ lang=\"%s\" xml:lang=\"%s\"> (concat "" 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 ;; just publish the path, as default (setq rpl (concat "<" type ":" diff --git a/lisp/org.el b/lisp/org.el index db6a035b2..1b08ed3c6 100644 --- a/lisp/org.el +++ b/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)