From: Richard M. Stallman Date: Sun, 23 Dec 2007 21:46:25 +0000 (+0000) Subject: (region-active-p): New function. X-Git-Tag: emacs-pretest-23.0.90~8856 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d03b9b3108cc27e5c8058788ffcb32068ec0d953;p=emacs.git (region-active-p): New function. (use-empty-active-region): New variable. --- diff --git a/etc/NEWS b/etc/NEWS index fb51744bab6..d7e7f0f93c6 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -149,6 +149,9 @@ word at point. ** TAB now indents the region if the region is active and `transient-mark-mode' is turned on. +** `use-empty-active-region' controls whether an empty active region +in Transient Mark mode should make commands operate on that empty region. + ** C-z now invokes `suspend-frame', C-x C-c now invokes `save-buffers-kill-terminal'. @@ -439,6 +442,9 @@ variable as having been made within Custom. ** `frame-inherited-parameters' lets new frames inherit parameters from the selected frame. +** Commands should use `region-active-p' to test whether there is +an active region that they should operate on. + ** New keymap `input-decode-map' overrides like key-translation-map, but applies before function-key-map. Also it is terminal-local contrary to key-translation-map. Terminal-specific key-sequences are generally added to diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9fb73a60a1c..76dfeb27f05 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2007-12-23 Richard Stallman + * simple.el (region-active-p): New function. + (use-empty-active-region): New variable. + * dired-aux.el (dired): Load dired.el at run time too. 2007-12-23 Juri Linkov diff --git a/lisp/simple.el b/lisp/simple.el index 22f29ab0464..2750fc85777 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3329,6 +3329,28 @@ store it in a Lisp variable. Example: (run-hooks 'deactivate-mark-hook) (set-marker (mark-marker) nil))) +(defcustom use-empty-active-region nil + "If non-nil, an active region takes control even if empty. +This applies to certain commands which, in Transient Mark mode, +apply to the active region if there is one. If the setting is t, +these commands apply to an empty active region if there is one. +If the setting is nil, these commands treat an empty active +region as if it were not active." + :type 'boolean + :version "23.1" + :group 'editing-basics) + +(defun region-active-p () + "Return t if certain commands should apply to the region. +Certain commands normally apply to text near point, +but in Transient Mark mode when the mark is active they apply +to the region instead. Such commands should use this subroutine to +test whether to do that. + +This function also obeys `use-empty-active-region'." + (and transient-mark-mode mark-active + (or use-empty-active-region (> (region-end) (region-beginning))))) + (defvar mark-ring nil "The list of former marks of the current buffer, most recent first.") (make-variable-buffer-local 'mark-ring)