1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2025-01-19 19:07:43 +00:00

org-babel: avoid false positive matches for inline and #+lob constructs

This forces the #+lob regexp to match at the beginning of a line (with
optional preceding whitespace), and requires inline code blocks to be
surrounded by some whitespace.
This commit is contained in:
Dan Davison 2009-10-24 20:26:00 -04:00 committed by Eric Schulte
parent 5f1ea1ce70
commit 70a5963563
3 changed files with 5 additions and 7 deletions

View File

@ -74,9 +74,7 @@ options and are taken from `org-babel-defualt-inline-header-args'."
(replacement (save-match-data
(org-babel-exp-do-export
(first info) (second info) (third info) 'inline))))
;; (message "%s -> %s" (second info) replacement) ;; debugging
(setf end (+ end (- (length replacement)
(+ 6 (length (first info)) (length (second info))))))
(setq end (+ end (- (length replacement) (length (match-string 0)))))
(replace-match replacement t t)))))
(defun org-babel-exp-lob-one-liners (start end)
@ -145,7 +143,7 @@ options are taken from `org-babel-default-header-args'."
(format "src_%s{%s}" lang raw))
(t
(if (and (stringp raw) (= 0 (length raw)))
"=(no results)=" (format "=%S=" raw))))))
" =(no results)= " (format " =%S= " raw))))))
('block
(save-excursion ;; org-exp-blocks places us at the end of the block
(re-search-backward org-babel-src-block-regexp nil t)

View File

@ -55,7 +55,7 @@ add files to this list use the `org-babel-lob-ingest' command."
;; functions for executing lob one-liners
(defvar org-babel-lob-one-liner-regexp "#\\+lob:[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)[ \t]*\\([^\n]*\\)")
(defvar org-babel-lob-one-liner-regexp "^[ \t]*#\\+lob:[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)[ \t]*\\([^\n]*\\)")
(defun org-babel-lob-execute-maybe ()
"Detect if this is context for a org-babel Library Of Babel

View File

@ -115,11 +115,11 @@ then run `org-babel-pop-to-session'."
"\\([ \t]+\\([^\n]+\\)\\)?\n" ;; match header arguments
"\\([^\000]+?\\)#\\+end_src"))
(setq org-babel-inline-src-block-regexp
(concat "src_\\("
(concat "[ \t\n]src_\\("
(mapconcat 'regexp-quote value "\\|")
"\\)"
"\\(\\|\\[\\(.*\\)\\]\\)"
"{\\([^\n]+\\)}")))
"{\\([^\n]+\\)}\\(?:[ \t\n]\\|\\'\\)")))
(defun org-babel-add-interpreter (interpreter)
"Add INTERPRETER to `org-babel-interpreters' and update