summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-12-27 23:22:07 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-12-27 23:22:07 +0100
commitf2c712a6a4aefef1e6cca794e76dc757cd4786cb (patch)
tree010d7444b5f4fd7432936ef64b737b1e531e1216
parent85ed1fd01dee462b59bcd622b3d0dee739d0214b (diff)
downloadorg-mode-f2c712a6a4aefef1e6cca794e76dc757cd4786cb.tar.gz
Fix inserting link
* lisp/org.el (org-insert-link): Fix when search option in a file link contains two consecutive slashes. Reported-by: Ag Ibragimov <agzam.ibragimov@gmail.com> <http://lists.gnu.org/r/emacs-orgmode/2017-12/msg00560.html>
-rw-r--r--lisp/org.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el
index b42108a..ad4b4ab 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10283,11 +10283,19 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
;; We are linking to this same file, with a search option
(setq link search)))))
- ;; Check if we can/should use a relative path. If yes, simplify the link
+ ;; Check if we can/should use a relative path. If yes, simplify
+ ;; the link.
(let ((case-fold-search nil))
(when (string-match "\\`\\(file\\|docview\\):" link)
(let* ((type (match-string-no-properties 0 link))
- (path (substring-no-properties link (match-end 0)))
+ (path-start (match-end 0))
+ (search (and (string-match "::\\(.*\\)\\'" link)
+ (match-string 1 link)))
+ (path
+ (if search
+ (substring-no-properties
+ link path-start (match-beginning 0))
+ (substring-no-properties link (match-end 0))))
(origpath path))
(cond
((or (eq org-link-file-path-type 'absolute)
@@ -10308,7 +10316,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
(setq path (substring (expand-file-name path)
(match-end 0)))
(setq path (abbreviate-file-name (expand-file-name path)))))))
- (setq link (concat type path))
+ (setq link (concat type path (and search (concat "::" search))))
(when (equal desc origpath)
(setq desc path)))))