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.
This commit is contained in:
Nicolas Goaziou 2011-10-26 10:45:28 +02:00
parent 679a0e1fe9
commit dba3e22c93
1 changed files with 7 additions and 3 deletions

View File

@ -19434,9 +19434,13 @@ position before START-RE (resp. after END-RE)."
(cons beg end)))))) (cons beg end))))))
(defun org-in-block-p (names) (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 (save-match-data
(catch 'exit (catch 'exit
(let ((case-fold-search t) (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]*#\\+begin_" n)
(concat "^[ \t]*#\\+end_" n) (concat "^[ \t]*#\\+end_" n)
lim-up lim-down) lim-up lim-down)
(throw 'exit t)))) (throw 'exit n))))
names)) names))
nil))) nil)))