Function: vi-effective-range

vi-effective-range is a byte-compiled function defined in vi.el.gz.

Signature

(vi-effective-range MOTION-COMMAND ARG)

Documentation

Return (begin . end) of the range spanned by executing the given MOTION-COMMAND with ARG.
   MOTION-COMMAND in ready-to-eval list form is not yet supported.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/vi.el.gz
(defun vi-effective-range (motion-command arg)
  "Return (begin . end) of the range spanned by executing the given
MOTION-COMMAND with ARG.
   MOTION-COMMAND in ready-to-eval list form is not yet supported."
  (save-excursion
    (let ((begin (point)) end opoint
	  (moving-unit (get motion-command 'point-moving-unit)))
      (setq prefix-arg arg)
      (setq opoint (point))
      (command-execute motion-command nil)
;; Check if there is any effective motion. Note that for single line operation
;; the motion-command causes no effective point movement (since it moves up or
;; down zero lines), but it should be counted as effectively moved.
      (if (and (= (point) opoint) (not (eq moving-unit 'line)))
	  (cons opoint opoint)		; no effective motion
	(if (eq moving-unit 'region)
	    (setq begin (or (mark) (point))))
	(if (<= begin (point))
	    (setq end (point))
	  (setq end begin)
	  (setq begin (point)))
	(cond ((or (eq moving-unit 'match) (eq moving-unit 'find))
	       (setq end (1+ end)))
	      ((eq moving-unit 'line)
	       (goto-char begin) (beginning-of-line) (setq begin (point))
	       (goto-char end) (forward-line 1) (beginning-of-line) (setq end (point))))
	(if (> end (point-max)) (setq end (point-max))) ; force in buffer region
	(cons begin end)))))