summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-12-07 23:11:10 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-12-07 23:11:10 +0100
commit3c64f0661727485d6ee3bfa1aae956b441fa8312 (patch)
tree288a1673303adef18ec6d5081305c5eda5c4ee85
parentc797cc0f8786493d097675e0c74f4cfdde42831c (diff)
downloadorg-mode-3c64f0661727485d6ee3bfa1aae956b441fa8312.tar.gz
Allow coderef on otherwise empty lines
* lisp/org-src.el (org-src-coderef-regexp): Update regexp. * lisp/ox.el (org-export-resolve-coderef): Use function above. Reported-by: D M German <dmg@turingmachine.org> <http://permalink.gmane.org/gmane.emacs.orgmode/110656>
-rw-r--r--lisp/org-src.el2
-rw-r--r--lisp/ox.el15
2 files changed, 7 insertions, 10 deletions
diff --git a/lisp/org-src.el b/lisp/org-src.el
index bcc93ac..89f3238 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -765,7 +765,7 @@ white spaces. Match group 2 contains the same string without any
surrounding space. Match group 3 contains the label.
A coderef format regexp can only match at the end of a line."
- (format "\\S-\\([ \t]*\\(%s\\)[ \t]*\\)$"
+ (format "\\([ \t]*\\(%s\\)[ \t]*\\)$"
(replace-regexp-in-string
"%s"
(if label (regexp-quote label) "\\([-a-zA-Z0-9_][-a-zA-Z0-9_ ]*\\)")
diff --git a/lisp/ox.el b/lisp/ox.el
index 63d0394..e776849 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -4171,18 +4171,15 @@ error if no block contains REF."
(lambda (el)
(with-temp-buffer
(insert (org-trim (org-element-property :value el)))
- (let* ((label-fmt (regexp-quote
- (or (org-element-property :label-fmt el)
- org-coderef-label-format)))
- (ref-re
- (format "^.*?\\S-.*?\\([ \t]*\\(%s\\)\\)[ \t]*$"
- (format label-fmt ref))))
+ (let* ((label-fmt (or (org-element-property :label-fmt el)
+ org-coderef-label-format))
+ (ref-re (org-src-coderef-regexp label-fmt ref)))
;; Element containing REF is found. Resolve it to
;; either a label or a line number, as needed.
(when (re-search-backward ref-re nil t)
- (cond
- ((org-element-property :use-labels el) ref)
- (t (+ (or (org-export-get-loc el info) 0) (line-number-at-pos))))))))
+ (if (org-element-property :use-labels el) ref
+ (+ (or (org-export-get-loc el info) 0)
+ (line-number-at-pos)))))))
info 'first-match)
(signal 'org-link-broken (list ref))))