comparison lisp/simple.el @ 87377:1b576fc3020d

(region-active-p): New function. (use-empty-active-region): New variable.
author Richard M. Stallman <rms@gnu.org>
date Sun, 23 Dec 2007 21:45:35 +0000
parents a99a2e8bc21e
children 9ec633b7a53d
comparison
equal deleted inserted replaced
87376:c3656622dbff 87377:1b576fc3020d
3327 ;; we must clear mark-active in any mode. 3327 ;; we must clear mark-active in any mode.
3328 (setq mark-active nil) 3328 (setq mark-active nil)
3329 (run-hooks 'deactivate-mark-hook) 3329 (run-hooks 'deactivate-mark-hook)
3330 (set-marker (mark-marker) nil))) 3330 (set-marker (mark-marker) nil)))
3331 3331
3332 (defcustom use-empty-active-region nil
3333 "If non-nil, an active region takes control even if empty.
3334 This applies to certain commands which, in Transient Mark mode,
3335 apply to the active region if there is one. If the setting is t,
3336 these commands apply to an empty active region if there is one.
3337 If the setting is nil, these commands treat an empty active
3338 region as if it were not active."
3339 :type 'boolean
3340 :version "23.1"
3341 :group 'editing-basics)
3342
3343 (defun region-active-p ()
3344 "Return t if certain commands should apply to the region.
3345 Certain commands normally apply to text near point,
3346 but in Transient Mark mode when the mark is active they apply
3347 to the region instead. Such commands should use this subroutine to
3348 test whether to do that.
3349
3350 This function also obeys `use-empty-active-region'."
3351 (and transient-mark-mode mark-active
3352 (or use-empty-active-region (> (region-end) (region-beginning)))))
3353
3332 (defvar mark-ring nil 3354 (defvar mark-ring nil
3333 "The list of former marks of the current buffer, most recent first.") 3355 "The list of former marks of the current buffer, most recent first.")
3334 (make-variable-buffer-local 'mark-ring) 3356 (make-variable-buffer-local 'mark-ring)
3335 (put 'mark-ring 'permanent-local t) 3357 (put 'mark-ring 'permanent-local t)
3336 3358