emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 6ac92c65a8 1/2: Add use-region-beginning and use-region-end


From: Lars Ingebrigtsen
Subject: master 6ac92c65a8 1/2: Add use-region-beginning and use-region-end
Date: Tue, 9 Aug 2022 15:13:17 -0400 (EDT)

branch: master
commit 6ac92c65a800e593d6a8aaf7f089c3811fcb7f33
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add use-region-beginning and use-region-end
    
    * lisp/simple.el (use-region-beginning, use-region-end): New functions.
    (use-region-p): Mention them in the doc strings (bug#45607).
---
 lisp/simple.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index e7768837f6..a4ea345ca5 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6863,6 +6863,14 @@ point otherwise."
   :version "23.1"
   :group 'editing-basics)
 
+(defun use-region-beginning ()
+  "Return the start of the region if `use-region-p'."
+  (and (use-region-p) (region-beginning)))
+
+(defun use-region-end ()
+  "Return the end of the region if `use-region-p'."
+  (and (use-region-p) (region-end)))
+
 (defun use-region-p ()
   "Return t if the region is active and it is appropriate to act on it.
 This is used by commands that act specially on the region under
@@ -6873,7 +6881,11 @@ mark is active; furthermore, if 
`use-empty-active-region' is nil,
 the region must not be empty.  Otherwise, the return value is nil.
 
 For some commands, it may be appropriate to ignore the value of
-`use-empty-active-region'; in that case, use `region-active-p'."
+`use-empty-active-region'; in that case, use `region-active-p'.
+
+Also see the convenience functions `use-region-beginning' and
+`use-region-end', which may be handy when writing `interactive'
+specs."
   (and (region-active-p)
        (or use-empty-active-region (> (region-end) (region-beginning)))
        t))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]