summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-12-14 10:02:25 +0100
committerBastien Guerry <bzg@altern.org>2012-12-14 10:02:25 +0100
commita7afe7df1ae5996680e74a781306ddc9630d8f7f (patch)
tree3e86a40ea4eb821fc5589b81c7d97e06d545f52c
parentc4bf1eeed4cae772d4893a6ecce7c94f5c3c24e4 (diff)
downloadorg-mode-a7afe7df1ae5996680e74a781306ddc9630d8f7f.tar.gz
org.el (org-in-src-block-p): Return t when on #+BEGIN|END_SRC lines.
* org.el (org-in-src-block-p): Return t when point is at the #+BEGIN_SRC/#+END_SRC lines unless the new optional parameter 'inside is set to t.
-rw-r--r--lisp/org.el19
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 60e2a8b..15dbd9a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20238,13 +20238,20 @@ and end of string."
"Is S an ID created by UUIDGEN?"
(string-match "\\`[0-9a-f]\\{8\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{12\\}\\'" (downcase s)))
-(defun org-in-src-block-p nil
- "Whether point is in a code source block."
+(defun org-in-src-block-p (&optional inside)
+ "Whether point is in a code source block.
+When INSIDE is non-nil, don't consider we are within a src block
+when point is at #+BEGIN_SRC or #+END_SRC."
(let (ov)
- (when (setq ov (overlays-at (point)))
- (memq 'org-block-background
- (overlay-properties
- (car ov))))))
+ (or (when (setq ov (overlays-at (point)))
+ (memq 'org-block-background
+ (overlay-properties
+ (car ov))))
+ (and (not inside)
+ (save-match-data
+ (save-excursion
+ (move-beginning-of-line 1)
+ (looking-at ".*#\\+\\(BEGIN\\|END\\)_SRC")))))))
(defun org-context ()
"Return a list of contexts of the current cursor position.