diff options
| author | Richard M. Stallman | 1994-12-22 04:16:36 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-12-22 04:16:36 +0000 |
| commit | f9acc7fb73e679264f68f00be9b3a9fabccff30d (patch) | |
| tree | b7eb3fae1cdf70ab2db32249f33e7e907354007b | |
| parent | ffd04ed01fba0746b90b1798a03eae6cc4aab2e1 (diff) | |
| download | emacs-f9acc7fb73e679264f68f00be9b3a9fabccff30d.tar.gz emacs-f9acc7fb73e679264f68f00be9b3a9fabccff30d.zip | |
(dired-string-replace-match): Moved to dired.el.
| -rw-r--r-- | lisp/dired-aux.el | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 83355b991b6..c3b8373e610 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; dired-aux.el --- all of dired except what people usually use | 1 | ;;; dired-aux.el --- less commonly used parts of dired -*-byte-compile-dynamic: t;-*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -252,7 +252,7 @@ with a prefix argument." | |||
| 252 | nil | 252 | nil |
| 253 | ;; If it looks like file FN has versions, return a list of the versions. | 253 | ;; If it looks like file FN has versions, return a list of the versions. |
| 254 | ;;That is a list of strings which are file names. | 254 | ;;That is a list of strings which are file names. |
| 255 | ;;The caller may want to flag some of these files for deletion." | 255 | ;;The caller may want to flag some of these files for deletion. |
| 256 | (let* ((base-versions | 256 | (let* ((base-versions |
| 257 | (concat (file-name-nondirectory fn) ".~")) | 257 | (concat (file-name-nondirectory fn) ".~")) |
| 258 | (bv-length (length base-versions)) | 258 | (bv-length (length base-versions)) |
| @@ -966,36 +966,6 @@ Special value `always' suppresses confirmation.") | |||
| 966 | (dired-normalize-subdir | 966 | (dired-normalize-subdir |
| 967 | (dired-replace-in-string regexp newtext (car elt))))))) | 967 | (dired-replace-in-string regexp newtext (car elt))))))) |
| 968 | 968 | ||
| 969 | ;; Cloning replace-match to work on strings instead of in buffer: | ||
| 970 | ;; The FIXEDCASE parameter of replace-match is not implemented. | ||
| 971 | ;;;###autoload | ||
| 972 | (defun dired-string-replace-match (regexp string newtext | ||
| 973 | &optional literal global) | ||
| 974 | "Replace first match of REGEXP in STRING with NEWTEXT. | ||
| 975 | If it does not match, nil is returned instead of the new string. | ||
| 976 | Optional arg LITERAL means to take NEWTEXT literally. | ||
| 977 | Optional arg GLOBAL means to replace all matches." | ||
| 978 | (if global | ||
| 979 | (let ((result "") (start 0) mb me) | ||
| 980 | (while (string-match regexp string start) | ||
| 981 | (setq mb (match-beginning 0) | ||
| 982 | me (match-end 0) | ||
| 983 | result (concat result | ||
| 984 | (substring string start mb) | ||
| 985 | (if literal | ||
| 986 | newtext | ||
| 987 | (dired-expand-newtext string newtext))) | ||
| 988 | start me)) | ||
| 989 | (if mb ; matched at least once | ||
| 990 | (concat result (substring string start)) | ||
| 991 | nil)) | ||
| 992 | ;; not GLOBAL | ||
| 993 | (if (not (string-match regexp string 0)) | ||
| 994 | nil | ||
| 995 | (concat (substring string 0 (match-beginning 0)) | ||
| 996 | (if literal newtext (dired-expand-newtext string newtext)) | ||
| 997 | (substring string (match-end 0)))))) | ||
| 998 | |||
| 999 | (defun dired-expand-newtext (string newtext) | 969 | (defun dired-expand-newtext (string newtext) |
| 1000 | ;; Expand \& and \1..\9 (referring to STRING) in NEWTEXT, using match data. | 970 | ;; Expand \& and \1..\9 (referring to STRING) in NEWTEXT, using match data. |
| 1001 | ;; Note that in Emacs 18 match data are clipped to current buffer | 971 | ;; Note that in Emacs 18 match data are clipped to current buffer |