Function: eshell-pred-substitute

eshell-pred-substitute is a byte-compiled function defined in em-pred.el.gz.

Signature

(eshell-pred-substitute &optional REPEAT)

Documentation

Return a modifier function that will substitute matches.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-pred.el.gz
(defun eshell-pred-substitute (&optional repeat)
  "Return a modifier function that will substitute matches."
  (let* ((match (or (eshell-get-delimited-modifier-argument t)
                    (error "Malformed pattern string for modifier `s'")))
         (replace (or (eshell-get-delimited-modifier-argument)
                      (error "Malformed replace string for modifier `s'")))
         (function (if repeat
                       (lambda (str)
                         (replace-regexp-in-string match replace str t))
                     (lambda (str)
                       (if (string-match match str)
                           (replace-match replace t nil str)
                         (error (concat str ": substitution failed")))))))
    (lambda (lst) (mapcar function lst))))