diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2011-10-26 10:45:28 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2011-10-26 10:45:28 +0200 |
commit | dba3e22c93a9c2862a604f82475947b5f5e98819 (patch) | |
tree | 96966adbcba13bb622ce5320b0e441288d8e2381 | |
parent | 679a0e1fe93d630820185f931087328d32e81077 (diff) | |
download | org-mode-dba3e22c93a9c2862a604f82475947b5f5e98819.tar.gz |
Have a more informative return value for `org-in-block-p'
* lisp/org.el (org-in-block-p): Return matched name of block, if any.
It can be useful when a list of block names is provided as an argument.
-rw-r--r-- | lisp/org.el | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el index a572b94..fe87eda 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -19434,9 +19434,13 @@ position before START-RE (resp. after END-RE)." (cons beg end)))))) (defun org-in-block-p (names) - "Is point inside any block whose name belongs to NAMES? + "Non-nil when point belongs to a block whose name belongs to NAMES. -NAMES is a list of strings containing names of blocks." +NAMES is a list of strings containing names of blocks. + +Return first block name matched, or nil. Beware that in case of +nested blocks, the returned name may not belong to the closest +block from point." (save-match-data (catch 'exit (let ((case-fold-search t) @@ -19448,7 +19452,7 @@ NAMES is a list of strings containing names of blocks." (concat "^[ \t]*#\\+begin_" n) (concat "^[ \t]*#\\+end_" n) lim-up lim-down) - (throw 'exit t)))) + (throw 'exit n)))) names)) nil))) |