From: Juri Linkov Date: Sat, 21 Jan 2017 23:18:53 +0000 (+0200) Subject: * lisp/simple.el (region-bounds): New function. X-Git-Tag: emacs-26.0.90~870^2~86 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ad29e145b16cf2966e3a9df884cbc234f1ae3e51;p=emacs.git * lisp/simple.el (region-bounds): New function. (region-noncontiguous-p): Use it. http://lists.gnu.org/archive/html/emacs-devel/2017-01/msg00044.html --- diff --git a/etc/NEWS b/etc/NEWS index 95d03a373fe..ca66df62610 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -787,6 +787,11 @@ of an arbitrary function. This generalizes 'subr-arity' for functions that are not built-in primitives. We recommend using this new function instead of 'subr-arity'. +** New function 'region-bounds' can be used in the interactive spec +to provide region boundaries (for rectangular regions more than one) +to an interactively callable function as a single argument instead of +two separate arguments region-beginning and region-end. + +++ ** 'parse-partial-sexp' state has a new element. Element 10 is non-nil when the last character scanned might be the first character diff --git a/lisp/simple.el b/lisp/simple.el index f798cd43847..bdc6abde1f1 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5410,11 +5410,15 @@ also checks the value of `use-empty-active-region'." ;; region is active when there's no mark. (progn (cl-assert (mark)) t))) +(defun region-bounds () + "Return the boundaries of the region as a list of (START . END) positions." + (funcall region-extract-function 'bounds)) + (defun region-noncontiguous-p () "Return non-nil if the region contains several pieces. An example is a rectangular region handled as a list of separate contiguous regions for each line." - (> (length (funcall region-extract-function 'bounds)) 1)) + (> (length (region-bounds)) 1)) (defvar redisplay-unhighlight-region-function (lambda (rol) (when (overlayp rol) (delete-overlay rol))))