comparison lisp/dired.el @ 25415:862886e87cf5

(dired-string-replace-match): Return `nil' when no match found with global search.
author Richard M. Stallman <rms@gnu.org>
date Sat, 28 Aug 1999 18:23:14 +0000
parents c79fbd7d8162
children 76420959ca81
comparison
equal deleted inserted replaced
25414:7c4808c6804b 25415:862886e87cf5
1313 "Replace first match of REGEXP in STRING with NEWTEXT. 1313 "Replace first match of REGEXP in STRING with NEWTEXT.
1314 If it does not match, nil is returned instead of the new string. 1314 If it does not match, nil is returned instead of the new string.
1315 Optional arg LITERAL means to take NEWTEXT literally. 1315 Optional arg LITERAL means to take NEWTEXT literally.
1316 Optional arg GLOBAL means to replace all matches." 1316 Optional arg GLOBAL means to replace all matches."
1317 (if global 1317 (if global
1318 (let ((start 0)) 1318 (let ((start 0) ret)
1319 (while (string-match regexp string start) 1319 (while (string-match regexp string start)
1320 (let ((from-end (- (length string) (match-end 0)))) 1320 (let ((from-end (- (length string) (match-end 0))))
1321 (setq string (replace-match newtext t literal string)) 1321 (setq ret (setq string (replace-match newtext t literal string)))
1322 (setq start (- (length string) from-end)))) 1322 (setq start (- (length string) from-end))))
1323 string) 1323 ret)
1324 (if (not (string-match regexp string 0)) 1324 (if (not (string-match regexp string 0))
1325 nil 1325 nil
1326 (replace-match newtext t literal string)))) 1326 (replace-match newtext t literal string))))
1327 1327
1328 (defun dired-make-absolute (file &optional dir) 1328 (defun dired-make-absolute (file &optional dir)