diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2008-11-18 07:53:54 +0100 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2008-11-18 07:53:54 +0100 |
commit | b52ba29529a2cb4da2f742fc63bab9772343c29c (patch) | |
tree | f7ec5897e282fbfd2c6d52e4a9a0da9e04f2bf8c | |
parent | 4a46ec644af684a0d71894563d05ed288fd0d50f (diff) | |
download | org-mode-b52ba29529a2cb4da2f742fc63bab9772343c29c.tar.gz |
Improve file link matching.
Michael Ekstrand wrote:
I've been trying to work with links to man pages in
Org (using org-man.el). When I try to create a link to a
Perl module in the File package namespace, however,
`org-insert-link' tries to do its same-file link detection
and winds up breaking the link. The result is that the link
man:File::MimeInfo
gets rewritten to
file::MimeInfo
Naturally, this isn't what I want. Looking at
`org-insert-link', it seems that the problem may be that its
same-file link detection is matching 'file:' at
beginning-of-word, which it is in this case. In the general
case for which 'file:' detection is being used, is there a
reason to match against `\<' rather than `^' or
`^[[:space:]]*'? Changing to one of the latter two
expressions would, I believe, keep it From rewriting these
links I am trying to create.
Michael is right, and I have made this change.
-rwxr-xr-x | lisp/ChangeLog | 4 | ||||
-rw-r--r-- | lisp/org.el | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 53a21fd..4832abd 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2008-11-18 Carsten Dominik <carsten.dominik@gmail.com> + + * org.el (org-insert-link): Improve file link matching. + 2008-11-17 Carsten Dominik <carsten.dominik@gmail.com> * org-colview.el (org-columns-display-here): New argument diff --git a/lisp/org.el b/lisp/org.el index fdfb07f..b400493 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6517,7 +6517,7 @@ used as the link location instead of reading one interactively." ;; Check if we are linking to the current file with a search option ;; If yes, simplify the link by using only the search option. (when (and buffer-file-name - (string-match "\\<file:\\(.+?\\)::\\([^>]+\\)" link)) + (string-match "^file:\\(.+?\\)::\\([^>]+\\)" link)) (let* ((path (match-string 1 link)) (case-fold-search nil) (search (match-string 2 link))) @@ -6527,7 +6527,7 @@ used as the link location instead of reading one interactively." (setq link search))))) ;; Check if we can/should use a relative path. If yes, simplify the link - (when (string-match "\\<file:\\(.*\\)" link) + (when (string-match "^file:\\(.*\\)" link) (let* ((path (match-string 1 link)) (origpath path) (case-fold-search nil)) |