;;; replace.el --- replace commands for Emacs
-;; Copyright (C) 1985-1987, 1992, 1994, 1996-1997, 2000-2013 Free
-;; Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1992, 1994, 1996-1997, 2000-2013
+;; Free Software Foundation, Inc.
;; Maintainer: FSF
;; Package: emacs
(if (and transient-mark-mode mark-active)
(region-end)))))
(perform-replace from-string to-string nil nil delimited nil nil start end))
+(put 'replace-string 'interactive-only
+ "use `search-forward' and `replace-match' instead.")
(defun replace-regexp (regexp to-string &optional delimited start end)
"Replace things after point matching REGEXP with TO-STRING.
(if (and transient-mark-mode mark-active)
(region-end)))))
(perform-replace regexp to-string nil t delimited nil nil start end))
+(put 'replace-regexp 'interactive-only
+ "use `re-search-forward' and `replace-match' instead.")
\f
(defvar regexp-history nil
;; so as to override faces copied from the buffer.
`(face ,match-face)))
curstring)
- (setq start (match-end 0))))
+ ;; Avoid infloop (Bug#7593).
+ (let ((end (match-end 0)))
+ (setq start (if (= start end) (1+ start) end)))))
;; Generate the string to insert for this match
(let* ((match-prefix
;; Using 7 digits aligns tabs properly.
(defun replace-eval-replacement (expression count)
(let* ((replace-count count)
- (replacement (eval expression)))
+ err
+ (replacement
+ (condition-case err
+ (eval expression)
+ (error
+ (error "Error evaluating replacement expression: %S" err)))))
(if (stringp replacement)
replacement
(prin1-to-string replacement t))))