• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/

Lines Matching +defs:replace +defs:regexp +defs:in +defs:string

17 ;; GNU Emacs is distributed in the hope that it will be useful,
30 ;; documented in the Emacs manual.
32 ;; Rewritten in 1990/1991 to add tree features, file marking and
34 ;; Finished up by rms in 1992.
46 "Handling marks in Dired."
57 On systems such as MS-DOS and MS-Windows, which use `ls' emulation in Lisp,
58 some of the `ls' switches are not supported; see the doc string of
59 `insert-directory' in `ls-lisp.el' for more details."
60 :type 'string
67 ; Don't use absolute file names as /bin should be in any PATH and people
69 ; usually not in PATH.
80 (defvar dired-use-ls-dired (not (not (string-match "gnu" system-configuration)))
101 don't care about symbolic links which really end in a @, you can
113 regexp)
157 This means: if there is a dired buffer displayed in the next window,
160 The target is used in the prompt for file copy, rename etc."
166 "*If non-nil, Dired preserves the last-modified time in a file copy.
190 "This hook is run before a dired buffer is read in (created or reverted)."
207 "The functions to call when a drop in `dired-mode' is made.
209 as in other buffers. Changing this option is effective only for
211 :type '(choice (repeat (cons (regexp) (function)))
212 (const :tag "Behave as in other buffers" nil))
238 (defvar dired-flagging-regexp nil);; Last regexp used to flag files.
245 Local to each dired buffer. May be a list, in which case the car is the
264 ;; DOS/Windows-style drive letters in directory names, like in "d:/foo".
267 (defvar dired-re-exe;; match ls permission string of an executable file
278 ;; The subdirectory names in the next two lists are expanded.
282 The order of elements is the reverse of the order in the buffer.
290 (defvaralias 'dired-move-to-filename-regexp
291 'directory-listing-before-filename-regexp)
293 (defvar dired-subdir-regexp "^. \\([^\n\r]+\\)\\(:\\)[\n\r]"
294 "Regexp matching a maybe hidden subdirectory line in `ls -lR' output.
373 (list dired-subdir-regexp '(1 dired-header-face))
381 ;; simple regexp ".+". It is that regexp which matches the file name.
384 (list (concat "^[" (char-to-string dired-marker-char) "]")
388 (list (concat "^[" (char-to-string dired-del-marker) "]")
423 (list (concat "\\(" (regexp-opt completion-ignored-extensions) "\\|#\\)$")
427 ;; plus a character put in by -F.
429 (list (concat "\\(" (regexp-opt completion-ignored-extensions)
442 "Additional expressions to highlight in Dired mode.")
515 (let ((regexp (dired-marker-regexp)) next-position)
522 (setq next-position (and (re-search-forward regexp nil t)
533 (setq next-position (and (re-search-forward regexp nil t)
545 The list is in the same order as the buffer, that is, the car is the
548 Optional arg LOCALP as in `dired-get-filename'.
578 ;; For use in interactive.
581 (read-string "Dired listing switches: "
595 "\"Edit\" directory DIRNAME--delete, rename, print, etc. some files in it.
598 Dired displays a list of files in DIRNAME (which may also have
603 You can move around in it with the usual commands.
608 If DIRNAME is already in a dired buffer, that buffer is used without refresh."
616 "\"Edit\" directory DIRNAME. Like `dired' but selects in another window."
617 (interactive (dired-read-dir-and-switches "in other window "))
624 (interactive (dired-read-dir-and-switches "in other frame "))
638 (string= (file-name-as-directory dirname) dirname))
692 ;; note that buffer already is in dired-mode, if found
723 ;; is passed in directory name syntax
736 ;; Don't leave an empty buffer around in that case.
750 ;; This differs from dired-buffers-for-dir in that it does not consider
775 ;; Read in a new dired buffer
778 "Read in a new dired buffer.
779 Differs from `dired-insert-subdir' in that it accepts
818 ;; as the subdir-alist has been built in dired-readin.
825 ;; already in dired-directory, assuming a clean buffer.
849 ;; hold the largest element ("largest" in the current invocation, of
861 ;; `directory-listing-before-filename-regexp' always matches spaces
905 ;; We're now just in front of a field, with a space behind us.
909 ;; Let's look at the other line, in the same column: we
911 ;; in the space between that field and the next.
957 in that case, DIR should be a file name that uses wildcards.
967 ;; with the new value of `directory-listing-before-filename-regexp'.
976 (if (not (string-match "b" dired-actual-switches))
981 (replace-match (apply #'propertize
987 (replace-match (apply #'propertize
1004 ;; Note that dired-build-subdir-alist will replace the name
1025 help-echo "mouse-2: visit this file in other window")))
1037 (widen) ; just in case user narrowed
1058 ;; have been reinserted (else omitting in dired-x would omit marked files)
1080 (subst-char-in-region beg end ?\r ?\n)))
1091 "Mark all files remembered in ALIST.
1121 (or (string-match "R" dired-actual-switches)
1165 (define-key map "Q" 'dired-do-query-replace-regexp)
1184 ;; Make all regexp commands share a `%' prefix:
1185 ;; We used to get to the submap via a symbol dired-regexp-prefix,
1191 (define-key map "%d" 'dired-flag-files-regexp)
1192 (define-key map "%g" 'dired-mark-files-containing-regexp)
1193 (define-key map "%m" 'dired-mark-files-regexp)
1194 (define-key map "%r" 'dired-do-rename-regexp)
1195 (define-key map "%C" 'dired-do-copy-regexp)
1196 (define-key map "%H" 'dired-do-hardlink-regexp)
1197 (define-key map "%R" 'dired-do-rename-regexp)
1198 (define-key map "%S" 'dired-do-symlink-regexp)
1204 (define-key map "*%" 'dired-mark-files-regexp)
1320 :help "Display image in external viewer"))
1324 :help "Display sized image in a separate window"))
1338 :help "Mark files with different attributes in two dired buffers"))
1347 :help "Examine file at cursor in read-only mode"))
1349 '(menu-item "Display in Other Window" dired-display-file
1350 :help "Display file at cursor in other window"))
1352 '(menu-item "Find in Other Window" dired-find-file-other-window
1353 :help "Edit file at cursor in other window"))
1362 (define-key map [menu-bar regexp]
1366 [menu-bar regexp image-dired-mark-tagged-files]
1368 :help "Mark files whose image tags matches regexp"))
1370 (define-key map [menu-bar regexp dashes-1]
1373 (define-key map [menu-bar regexp downcase]
1380 (define-key map [menu-bar regexp upcase]
1385 (define-key map [menu-bar regexp hardlink]
1386 '(menu-item "Hardlink..." dired-do-hardlink-regexp
1387 :help "Make hard links for files matching regexp"))
1388 (define-key map [menu-bar regexp symlink]
1389 '(menu-item "Symlink..." dired-do-symlink-regexp
1391 :help "Make symbolic links for files matching regexp"))
1392 (define-key map [menu-bar regexp rename]
1393 '(menu-item "Rename..." dired-do-rename-regexp
1394 :help "Rename marked files matching regexp"))
1395 (define-key map [menu-bar regexp copy]
1396 '(menu-item "Copy..." dired-do-copy-regexp
1397 :help "Copy marked files matching regexp"))
1398 (define-key map [menu-bar regexp flag]
1399 '(menu-item "Flag..." dired-flag-files-regexp
1400 :help "Flag files matching regexp for deletion"))
1401 (define-key map [menu-bar regexp mark]
1402 '(menu-item "Mark..." dired-mark-files-regexp
1403 :help "Mark files matching regexp for future operations"))
1404 (define-key map [menu-bar regexp mark-cont]
1405 '(menu-item "Mark Containing..." dired-mark-files-containing-regexp
1406 :help "Mark files whose contents matches regexp"))
1483 (define-key map [menu-bar operate query-replace]
1484 '(menu-item "Query Replace in Files..." dired-do-query-replace-regexp
1485 :help "Replace regexp in marked files"))
1488 :help "Search marked files for regexp"))
1547 In Dired, you are \"editing\" a list of the files in a directory and
1548 \(optionally) its subdirectories, in the format of `ls -lR'.
1569 (or dired it in another buffer, if it is a directory).
1570 Type \\[dired-find-file-other-window] to find file or dired directory in Other window.
1571 Type \\[dired-maybe-insert-subdir] to Insert a subdirectory in this buffer.
1628 ;; list-buffers uses this to display the dir being edited in this buffer.
1658 "Undo in a dired buffer.
1659 This doesn't recover lost files, it just undoes changes in the buffer itself.
1665 (message "Change in dired buffer undone.
1666 Actual changes in files cannot be undone by Emacs."))
1701 Find the parent directory either in this buffer or another buffer.
1731 ;; Force `f' rather than `e' in the mode doc:
1771 "In Dired, examine a file in view mode, returning to Dired when done.
1772 When file is a directory, show it in this buffer if it is inserted.
1773 Otherwise, display it in another buffer."
1783 "In Dired, visit this file or directory in another window."
1788 "In Dired, display this file or directory in another window."
1793 ;;; Functions for extracting and manipulating file names in Dired buffers.
1799 name in result. A value of `verbatim' means to return the name exactly as
1800 it occurs in the buffer, and a value of t means construct name relative to
1801 `default-directory', which still may contain slashes if in a subdirectory.
1804 Otherwise, an error occurs in these cases."
1816 ;; \007 (4 chars) -> ^G (1 char) etc. in a lisp loop.
1822 (or (dired-string-replace-match
1826 ;; The above `read' will return a unibyte string if FILE
1829 (not (multibyte-string-p file)))
1830 (setq file (string-to-multibyte file)))))
1833 ;; Don't treat it as absolute in this context.
1868 (defun dired-string-replace-match (regexp string newtext
1870 "Replace first match of REGEXP in STRING with NEWTEXT.
1871 If it does not match, nil is returned instead of the new string.
1873 Optional arg GLOBAL means to replace all matches."
1876 (while (string-match regexp string start)
1877 (let ((from-end (- (length string) (match-end 0))))
1878 (setq ret (setq string (replace-match newtext t literal string)))
1879 (setq start (- (length string) from-end))))
1881 (if (not (string-match regexp string 0))
1883 (replace-match newtext t literal string))))
1888 ;; or expand in / instead default-directory if DIR=="".
1891 ;; It should be reasonably fast, though, as it is called in
1904 (if (string-match (concat "^" (regexp-quote dir)) file)
1907 ;;; (error "%s: not in directory tree growing at %s" file dir))
1911 ;;; Functions for finding the file name in a dired buffer line.
1913 (defvar dired-permission-flags-regexp
1915 "Regular expression to match the permission flags in `ls -l'.")
1930 ((re-search-forward directory-listing-before-filename-regexp eol t)
1932 ((re-search-forward dired-permission-flags-regexp eol t)
1933 ;; Ha! There *is* a file. Our regexp-from-hell just failed to find it.
1935 (error "Unrecognized line! Check directory-listing-before-filename-regexp"))
1943 ;; thus the rwx bit re-search-backward below will succeed in *this*
1952 (setq used-F (string-match "F" dired-actual-switches)
1965 dired-permission-flags-regexp nil t)
1971 (string-match
1974 (match-string 2)
1975 (match-string 3)
1976 (match-string 4)))))
2014 `default-directory'. (This still may contain slashes if in a subdirectory.)
2017 prefix arg and marked files are ignored in this case.
2021 (let ((string
2035 (kill-append string nil)
2036 (kill-new string))
2037 (message "%s" string)))
2041 ;; Keeping Dired buffers in sync with the filesystem and with each other
2044 ;; Return a list of buffers that dired DIR (top level or in-situ subdir).
2047 ;; The list is in reverse order of buffer creation, most recent last.
2056 (if (dired-in-this-tree dir (car elt))
2063 (string-match (dired-glob-regexp wildcards)
2071 (defun dired-glob-regexp (pattern)
2073 (let ((matched-in-pattern 0) ;; How many chars of PATTERN we've handled.
2074 regexp)
2075 (while (string-match "[[?*]" pattern matched-in-pattern)
2078 (setq regexp (concat regexp
2079 (regexp-quote
2080 (substring pattern matched-in-pattern
2083 (setq regexp (concat regexp "."))
2084 (setq matched-in-pattern op-end))
2092 (set-end (string-match "]" pattern set-cont))
2094 (setq regexp (concat regexp set))
2095 (setq matched-in-pattern (1+ set-end))))
2097 (setq regexp (concat regexp ".*"))
2098 (setq matched-in-pattern op-end)))))
2100 regexp
2101 (regexp-quote
2102 (substring pattern matched-in-pattern))
2108 ;;"Advertise in variable `dired-buffers' that we dired `default-directory'."
2118 ;; Remove DIR from the buffer alist in variable dired-buffers.
2120 ;; It does not affect buffers in which DIR is a subdir.
2121 ;; Removing is also done as a side-effect in dired-buffer-for-dir.
2130 (defun dired-in-this-tree (file dir)
2133 (string-match (concat "^" (regexp-quote dir)) file)))
2146 ;; Look up in the alist whether this is a headerline.
2157 ;; can't use macro, must be redefinable for other alist format in dired-nstd.
2175 (if (string= dir (car (car alist)))
2184 ;; position was found in dired-subdir-alist.
2215 ;; Used to expand subdirectory names correctly in recursive
2217 (and (string-match "R" switches)
2218 (string-match "\\`/.*:\\(/.*\\)" default-directory)
2219 (concat "\\`" (match-string 1 default-directory)))))
2222 (while (re-search-forward dired-subdir-regexp nil t)
2223 ;; Avoid taking a file name ending in a colon
2237 (not (string= new-dir-name default-directory))
2238 (string-match R-ftp-base-dir-regex new-dir-name))
2253 ;; We don't need to sort it because it is in buffer order per
2268 (string-match dired-trivial-filenames
2280 "Go to line describing file FILE in this dired buffer."
2285 ;; it in the buffer.
2299 (if (if (string= dir (expand-file-name default-directory))
2304 search-string
2306 (setq search-string
2307 (replace-regexp-in-string "\^m" "\\^m" base nil t))
2308 (setq search-string
2309 (replace-regexp-in-string "\\\\" "\\\\" search-string nil t))
2313 (search-forward (concat " " search-string)
2316 ;; or in permission bits or date or
2321 ;; ;; line (e.g. "-" would match somewhere in the
2332 ;; Where point should go in a new listing of DIRNAME.
2334 ;; You may redefine this function as you wish, e.g. like in dired-x.el.
2340 ;; They are in this file because other parts of dired need to call them.
2345 ;; overhead. Avoiding the function call seems to save about 10% in
2349 This returns a string with trailing slash, like `default-directory'.
2353 ;; probably because called in a non-dired buffer
2354 (error "No subdir-alist in %s" (current-buffer))))
2432 (regexp (dired-marker-regexp))
2435 (re-search-forward regexp nil t))
2463 ;; (car L) *must* be the *last* (bottommost) file in the dired buffer.
2464 ;; That way as changes are made in the buffer they do not shift the
2465 ;; lines still to be changed, so the (point) values in L stay valid.
2466 ;; Also, for subdirs in natural order, a subdir's files are deleted
2477 (let (failures);; files better be in reverse order for this loop!
2487 (dired-fun-in-all-buffers
2504 (defun dired-fun-in-all-buffers (directory file fun &rest args)
2508 ;; FILE may be nil, in which case ignore it.
2537 (defun dired-marker-regexp ()
2538 (concat "^" (regexp-quote (char-to-string dired-marker-char))))
2544 ;; Return a string for use in a prompt, either the current file
2614 Displays the file names in a buffer named BUFNAME;
2621 OP-SYMBOL is a member of the list in `dired-no-confirm'.
2623 in the case of one marked file, to distinguish that from using
2634 ;; That value is used (only in some cases), to mean
2644 ;; Files should be in forward order for this loop.
2645 ;; i.e., (car files) = first file in buffer.
2686 ;; (If FUNCTION inserted some new lines in between, skip them.)
2698 ;; This used to be a regexp match of the `total ...' line output by
2734 (defun dired-mark-files-in-region (start end)
2755 and \\[dired-unmark] on a subdir to remove the marks in
2802 (apply 'subst-char-in-region
2812 (defvar dired-regexp-history nil
2813 "History list of regular expressions used in Dired commands.")
2815 (defun dired-read-regexp (prompt)
2816 (read-from-minibuffer prompt nil nil nil 'dired-regexp-history))
2818 (defun dired-mark-files-regexp (regexp &optional marker-char)
2819 "Mark all files matching REGEXP for use in later commands.
2823 REGEXP is an Emacs regexp, not a shell wildcard. Thus, use `\\.o$' for
2826 (list (dired-read-regexp (concat (if current-prefix-arg "Unmark" "Mark")
2827 " files (regexp): "))
2834 (and fn (string-match regexp (file-name-nondirectory fn)))))
2837 (defun dired-mark-files-containing-regexp (regexp &optional marker-char)
2838 "Mark all files with contents containing REGEXP for use in later commands.
2842 (list (dired-read-regexp (concat (if current-prefix-arg "Unmark" "Mark")
2843 " files containing (regexp): "))
2860 (re-search-forward regexp nil t)))
2864 (re-search-forward regexp nil t))))
2868 (defun dired-flag-files-regexp (regexp)
2873 (interactive (list (dired-read-regexp "Flag for deletion (regexp): ")))
2874 (dired-mark-files-regexp regexp dired-del-marker))
2913 ;; Handle executables in case of -F option.
2927 (defcustom dired-garbage-files-regexp
2930 (concat (regexp-opt
2934 :type 'regexp
2938 "Flag for deletion all files that match `dired-garbage-files-regexp'."
2940 (dired-flag-files-regexp dired-garbage-files-regexp))
2952 ;; Handle executables in case of -F option.
2968 (let* ((cursor-in-echo-area t)
2975 (let ((string (format "\n%c" old))
2979 (while (search-forward string nil t)
2984 (subst-char-in-region (match-beginning 0)
2988 "Remove all marks from all files in the dired buffer."
3002 (string (format "\n%c" mark))
3009 (search-forward string nil t))
3015 (progn (subst-char-in-region (1- (point)) (point)
3046 ;; If LOG is a string and there are more args, it is formatted with
3047 ;; those ARGS. Usually the LOG string ends with a \n.
3065 (insert (current-time-string)
3070 (defun dired-log-summary (string failures)
3071 "State a summary of a command's failures, in echo area and log buffer.
3084 string failures))
3086 (dired-log (concat "\n" string "\n"))
3106 (defvar dired-sort-by-date-regexp
3111 (defvar dired-sort-by-name-regexp
3117 The idea is to set this buffer-locally in special dired buffers.")
3127 (cond ((string-match
3128 dired-sort-by-name-regexp dired-actual-switches)
3130 ((string-match
3131 dired-sort-by-date-regexp dired-actual-switches)
3145 (read-string "ls switches (must contain -l): " dired-actual-switches))
3152 (if (string-match " " dired-actual-switches)
3154 (if (string-match " -t\\'" dired-actual-switches)
3160 (dired-replace-in-string (concat "[-lt"
3164 (if (string-match (concat "[t" dired-ls-sorting-switches "]")
3172 ;; Don't do that--use replace-regexp-in-string instead.
3173 (defun dired-replace-in-string (regexp newtext string)
3174 ;; Replace REGEXP with NEWTEXT everywhere in STRING and return result.
3177 (while (string-match regexp string start)
3180 result (concat result (substring string start mb) newtext)
3182 (concat result (substring string start))))
3186 Values matching `dired-sort-by-date-regexp' or `dired-sort-by-name-regexp'
3187 set the minor mode accordingly, others appear literally in the mode line.
3199 "Additional processing of -R in ls option string SWITCHES.
3202 To be called first in body of `dired-sort-other', etc."
3204 ((and (string-match "R" switches)
3205 (not (string-match "R" dired-actual-switches)))
3208 ((and (string-match "R" dired-actual-switches)
3209 (not (string-match "R" switches)))
3307 URI is the file to handle. If the hostname in the URI isn't local, do nothing.
3321 "Auxiliary information to be saved in desktop file."
3330 ;; Subdirectories in `dired-subdir-alist'.
3340 "Restore a dired buffer specified in a desktop file."