Function: ex-global
ex-global is a byte-compiled function defined in vip.el.gz.
Signature
(ex-global VARIANT)
Documentation
ex global command
Source Code
;; Defined in /usr/src/emacs/lisp/obsolete/vip.el.gz
(defun ex-global (variant)
"ex global command"
(if (or ex-g-flag ex-g-variant)
(error "Global within global not allowed")
(if variant
(setq ex-g-flag nil
ex-g-variant t)
(setq ex-g-flag t
ex-g-variant nil)))
(vip-get-ex-pat)
(if (null ex-token)
(error "Missing regular expression for global command"))
(if (string= ex-token "")
(if (null vip-s-string) (error "No previous search string")
(setq ex-g-pat vip-s-string))
(setq ex-g-pat ex-token
vip-s-string ex-token))
(if (null ex-addresses)
(setq ex-addresses (list (point-max) (point-min))))
(let ((marks nil) (mark-count 0)
com-str (end (car ex-addresses)) (beg (car (cdr ex-addresses))))
(if (> beg end) (error "First address exceeds second"))
(save-excursion
(vip-enlarge-region beg end)
(exchange-point-and-mark)
(let ((cont t) (limit (point-marker)))
(exchange-point-and-mark)
;; skip the last line if empty
(beginning-of-line)
(if (and (eobp) (not (bobp))) (backward-char 1))
(while (and cont (not (bobp)) (>= (point) limit))
(beginning-of-line)
(set-mark (point))
(end-of-line)
(let ((found (re-search-backward ex-g-pat (mark) t)))
(if (or (and ex-g-flag found)
(and ex-g-variant (not found)))
(progn
(end-of-line)
(setq mark-count (1+ mark-count))
(setq marks (cons (point-marker) marks)))))
(beginning-of-line)
(if (bobp) (setq cont nil)
(forward-line -1)
(end-of-line)))))
(with-current-buffer " *ex-working-space*"
(setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
(while marks
(goto-char (car marks))
;; report progress of execution on a slow machine.
;;(message "Executing global command...")
;;(if (zerop (% mark-count 10))
;; (message "Executing global command...%d" mark-count))
(vip-ex com-str)
(setq mark-count (1- mark-count))
(setq marks (cdr marks)))))