summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2011-01-13 14:04:28 -0700
committerEric Schulte <schulte.eric@gmail.com>2011-01-13 14:07:19 -0700
commitc8e5ba90cc73145b80943ca71eadea2cf4a37e8e (patch)
tree1355858b3334f48da8b9837637cfa5509a0db785
parent0dfde2da72f9c46fc7c0270a9e1fb608d0633415 (diff)
downloadorg-mode-c8e5ba90cc73145b80943ca71eadea2cf4a37e8e.tar.gz
ob: ob-jump-to-org is more robust to link comment impostors
* lisp/ob-tangle.el (org-babel-tangle-jump-to-org): Ever wider searches until either a matching block is found, or the limits of the file are reached.
-rw-r--r--lisp/ob-tangle.el30
1 files changed, 17 insertions, 13 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index c5ef2a1..0dbb621 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -393,7 +393,7 @@ form
(insert-comment
(org-fill-template org-babel-tangle-comment-format-end link-data))))))
-;; detangling functions
+;; dangling functions
(defvar org-bracket-link-analytic-regexp)
(defun org-babel-detangle (&optional source-code-file)
"Propagate changes in source file back original to Org-mode file.
@@ -420,20 +420,24 @@ which enable the original code blocks to be found."
"Jump from a tangled code file to the related Org-mode file."
(interactive)
(let ((mid (point))
- target-buffer target-char
- start end link path block-name body)
+ start end done
+ target-buffer target-char link path block-name body)
(save-window-excursion
(save-excursion
- (unless (and (re-search-backward org-bracket-link-analytic-regexp nil t)
- (setq start (point-at-eol))
- (setq link (match-string 0))
- (setq path (match-string 3))
- (setq block-name (match-string 5))
- (re-search-forward
- (concat " " (regexp-quote block-name) " ends here") nil t)
- (setq end (point-at-bol))
- (< start mid) (< mid end))
- (error "not in tangled code"))
+ (while (and (re-search-backward org-bracket-link-analytic-regexp nil t)
+ (not ; ever wider searches until matching block comments
+ (and (setq start (point-at-eol))
+ (setq link (match-string 0))
+ (setq path (match-string 3))
+ (setq block-name (match-string 5))
+ (save-excursion
+ (save-match-data
+ (re-search-forward
+ (concat " " (regexp-quote block-name)
+ " ends here") nil t)
+ (setq end (point-at-bol))))))))
+ (unless (and start (< start mid) (< mid end))
+ (error "not in tangled code"))
(setq body (org-babel-trim (buffer-substring start end))))
(when (string-match "::" path)
(setq path (substring path 0 (match-beginning 0))))