Dired: Use invisibility-spec instead of selective-display
* lisp/dired.el (dired-subdir-regexp): No need to pay attention to \r. (dired-remember-hidden): Use pcase-dolist and dired--hidden-p. (dired-mode): Set invisibility-spec instead of selective-display. (dired--hidden-p, dired--hide, dired--unhide, dired--find-hidden-pos): New functions. (dired-move-to-end-of-filename): Use dired--hidden-p. (dired-next-subdir): No need to pay attention to \r. (dired-fun-in-all-buffers): Use push. * lisp/dired-aux.el (dired-unhide-subdir, dired-hide-subdir, dired-hide-all): Use the new functions and with-silent-modifications. (dired-add-entry): Use dired--hidden-p. (dired-goto-subdir): No need to pay attention to \r. (dired-hide-check): Remove. (dired-subdir-hidden-p): Use dired--hidden-p. (dired-do-find-regexp): Use file-name-as-directory.
This commit is contained in:
parent
2f50a990b7
commit
5055e14dda
2 changed files with 139 additions and 129 deletions
|
@ -148,7 +148,7 @@ the string of command switches used as the third argument of `diff'."
|
|||
(read-string "Options for diff: "
|
||||
(if (stringp diff-switches)
|
||||
diff-switches
|
||||
(mapconcat 'identity diff-switches " ")))))))
|
||||
(mapconcat #'identity diff-switches " ")))))))
|
||||
(let ((current (dired-get-filename t)))
|
||||
(when (or (equal (expand-file-name file)
|
||||
(expand-file-name current))
|
||||
|
@ -173,7 +173,7 @@ With prefix arg, prompt for argument SWITCHES which is options for `diff'."
|
|||
(list (read-string "Options for diff: "
|
||||
(if (stringp diff-switches)
|
||||
diff-switches
|
||||
(mapconcat 'identity diff-switches " "))))
|
||||
(mapconcat #'identity diff-switches " "))))
|
||||
nil))
|
||||
(diff-backup (dired-get-filename) switches))
|
||||
|
||||
|
@ -227,12 +227,12 @@ Examples of PREDICATE:
|
|||
(setq file-alist2 (delq (assoc "." file-alist2) file-alist2))
|
||||
(setq file-alist2 (delq (assoc ".." file-alist2) file-alist2))
|
||||
(setq file-list1 (mapcar
|
||||
'cadr
|
||||
#'cadr
|
||||
(dired-file-set-difference
|
||||
file-alist1 file-alist2
|
||||
predicate))
|
||||
file-list2 (mapcar
|
||||
'cadr
|
||||
#'cadr
|
||||
(dired-file-set-difference
|
||||
file-alist2 file-alist1
|
||||
predicate)))
|
||||
|
@ -491,7 +491,7 @@ Uses the shell command coming from variables `lpr-command' and
|
|||
lpr-switches))
|
||||
(command (dired-mark-read-string
|
||||
"Print %s with: "
|
||||
(mapconcat 'identity
|
||||
(mapconcat #'identity
|
||||
(cons lpr-command
|
||||
(if (stringp lpr-switches)
|
||||
(list lpr-switches)
|
||||
|
@ -597,7 +597,7 @@ with a prefix argument."
|
|||
(possibilities (file-name-all-completions
|
||||
base-versions
|
||||
(file-name-directory fn)))
|
||||
(versions (mapcar 'backup-extract-version possibilities)))
|
||||
(versions (mapcar #'backup-extract-version possibilities)))
|
||||
(if versions
|
||||
(setq dired-file-version-alist
|
||||
(cons (cons fn versions)
|
||||
|
@ -822,27 +822,28 @@ can be produced by `dired-get-marked-files', for example."
|
|||
retval))
|
||||
(lambda (x) (concat cmd-prefix command dired-mark-separator x)))))
|
||||
(concat
|
||||
(cond (on-each
|
||||
(format "%s%s"
|
||||
(mapconcat stuff-it (mapcar 'shell-quote-argument file-list)
|
||||
cmd-sep)
|
||||
;; POSIX shells running a list of commands in the background
|
||||
;; (LIST = cmd_1 & [cmd_2 & ... cmd_i & ... cmd_N &])
|
||||
;; return once cmd_N ends, i.e., the shell does not
|
||||
;; wait for cmd_i to finish before executing cmd_i+1.
|
||||
;; That means, running (shell-command LIST) may not show
|
||||
;; the output of all the commands (Bug#23206).
|
||||
;; Add 'wait' to force those POSIX shells to wait until
|
||||
;; all commands finish.
|
||||
(or (and parallel-in-background (not w32-shell)
|
||||
"&wait")
|
||||
"")))
|
||||
(t
|
||||
(let ((files (mapconcat 'shell-quote-argument
|
||||
file-list dired-mark-separator)))
|
||||
(when (cdr file-list)
|
||||
(setq files (concat dired-mark-prefix files dired-mark-postfix)))
|
||||
(funcall stuff-it files))))
|
||||
(cond
|
||||
(on-each
|
||||
(format "%s%s"
|
||||
(mapconcat stuff-it (mapcar #'shell-quote-argument file-list)
|
||||
cmd-sep)
|
||||
;; POSIX shells running a list of commands in the background
|
||||
;; (LIST = cmd_1 & [cmd_2 & ... cmd_i & ... cmd_N &])
|
||||
;; return once cmd_N ends, i.e., the shell does not
|
||||
;; wait for cmd_i to finish before executing cmd_i+1.
|
||||
;; That means, running (shell-command LIST) may not show
|
||||
;; the output of all the commands (Bug#23206).
|
||||
;; Add 'wait' to force those POSIX shells to wait until
|
||||
;; all commands finish.
|
||||
(or (and parallel-in-background (not w32-shell)
|
||||
"&wait")
|
||||
"")))
|
||||
(t
|
||||
(let ((files (mapconcat #'shell-quote-argument
|
||||
file-list dired-mark-separator)))
|
||||
(when (cdr file-list)
|
||||
(setq files (concat dired-mark-prefix files dired-mark-postfix)))
|
||||
(funcall stuff-it files))))
|
||||
(or (and in-background "&") ""))))
|
||||
|
||||
;; This is an extra function so that it can be redefined by ange-ftp.
|
||||
|
@ -872,7 +873,7 @@ Else returns nil for success."
|
|||
(set-buffer err-buffer)
|
||||
(erase-buffer)
|
||||
(setq default-directory dir ; caller's default-directory
|
||||
err (not (eq 0 (apply 'process-file program nil t nil arguments))))
|
||||
err (not (eq 0 (apply #'process-file program nil t nil arguments))))
|
||||
(if err
|
||||
(progn
|
||||
(dired-log (concat program " " (prin1-to-string arguments) "\n"))
|
||||
|
@ -1349,7 +1350,7 @@ See Info node `(emacs)Subdir switches' for more details."
|
|||
;; Replace space by old marker without moving point.
|
||||
;; Faster than goto+insdel inside a save-excursion?
|
||||
(when char
|
||||
(subst-char-in-region opoint (1+ opoint) ?\040 char)))))
|
||||
(subst-char-in-region opoint (1+ opoint) ?\s char)))))
|
||||
(dired-move-to-filename))
|
||||
|
||||
;;;###autoload
|
||||
|
@ -1403,8 +1404,8 @@ files matching `dired-omit-regexp'."
|
|||
(catch 'not-found
|
||||
(if (string= directory cur-dir)
|
||||
(progn
|
||||
(skip-chars-forward "^\r\n")
|
||||
(if (eq (following-char) ?\r)
|
||||
(end-of-line)
|
||||
(if (dired--hidden-p)
|
||||
(dired-unhide-subdir))
|
||||
;; We are already where we should be, except when
|
||||
;; point is before the subdir line or its total line.
|
||||
|
@ -1414,7 +1415,7 @@ files matching `dired-omit-regexp'."
|
|||
;; else try to find correct place to insert
|
||||
(if (dired-goto-subdir directory)
|
||||
(progn ;; unhide if necessary
|
||||
(if (= (following-char) ?\r)
|
||||
(if (dired--hidden-p)
|
||||
;; Point is at end of subdir line.
|
||||
(dired-unhide-subdir))
|
||||
;; found - skip subdir and `total' line
|
||||
|
@ -1523,7 +1524,7 @@ files matching `dired-omit-regexp'."
|
|||
(point))
|
||||
(line-beginning-position 2)))
|
||||
(setq file (directory-file-name file))
|
||||
(dired-add-entry file (if (eq ?\040 marker) nil marker)))))
|
||||
(dired-add-entry file (if (eq ?\s marker) nil marker)))))
|
||||
|
||||
;;; Copy, move/rename, making hard and symbolic links
|
||||
|
||||
|
@ -2562,7 +2563,7 @@ Optional third arg LIMIT (>= 1) is a limit to the length of the
|
|||
resulting list.
|
||||
Thus, if SEP is a regexp that only matches itself,
|
||||
|
||||
(mapconcat 'identity (dired-split SEP STRING) SEP)
|
||||
(mapconcat #'identity (dired-split SEP STRING) SEP)
|
||||
|
||||
is always equal to STRING."
|
||||
(let* ((start (string-match pat str))
|
||||
|
@ -2610,7 +2611,7 @@ When called interactively and not on a subdir line, go to this subdir's line."
|
|||
(defun dired-goto-subdir (dir)
|
||||
"Go to end of header line of DIR in this dired buffer.
|
||||
Return value of point on success, otherwise return nil.
|
||||
The next char is either \\n, or \\r if DIR is hidden."
|
||||
The next char is \\n."
|
||||
(interactive
|
||||
(prog1 ; let push-mark display its message
|
||||
(list (expand-file-name
|
||||
|
@ -2625,8 +2626,8 @@ The next char is either \\n, or \\r if DIR is hidden."
|
|||
(and elt
|
||||
(goto-char (dired-get-subdir-min elt))
|
||||
;; dired-subdir-hidden-p and dired-add-entry depend on point being
|
||||
;; at either \r or \n after this function succeeds.
|
||||
(progn (skip-chars-forward "^\r\n")
|
||||
;; at \n after this function succeeds.
|
||||
(progn (end-of-line)
|
||||
(point)))))
|
||||
|
||||
;;;###autoload
|
||||
|
@ -2699,18 +2700,13 @@ Lower levels are unaffected."
|
|||
;;; hiding
|
||||
|
||||
(defun dired-unhide-subdir ()
|
||||
(let (buffer-read-only)
|
||||
(subst-char-in-region (dired-subdir-min) (dired-subdir-max) ?\r ?\n)))
|
||||
|
||||
(defun dired-hide-check ()
|
||||
(or selective-display
|
||||
(error "selective-display must be t for subdir hiding to work!")))
|
||||
(with-silent-modifications
|
||||
(dired--unhide (dired-subdir-min) (dired-subdir-max))))
|
||||
|
||||
(defun dired-subdir-hidden-p (dir)
|
||||
(and selective-display
|
||||
(save-excursion
|
||||
(dired-goto-subdir dir)
|
||||
(= (following-char) ?\r))))
|
||||
(save-excursion
|
||||
(dired-goto-subdir dir)
|
||||
(dired--hidden-p)))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-hide-subdir (arg)
|
||||
|
@ -2718,8 +2714,7 @@ Lower levels are unaffected."
|
|||
Optional prefix arg is a repeat factor.
|
||||
Use \\[dired-hide-all] to (un)hide all directories."
|
||||
(interactive "p")
|
||||
(dired-hide-check)
|
||||
(let ((modflag (buffer-modified-p)))
|
||||
(with-silent-modifications
|
||||
(while (>= (setq arg (1- arg)) 0)
|
||||
(let* ((cur-dir (dired-current-directory))
|
||||
(hidden-p (dired-subdir-hidden-p cur-dir))
|
||||
|
@ -2728,12 +2723,11 @@ Use \\[dired-hide-all] to (un)hide all directories."
|
|||
buffer-read-only)
|
||||
;; keep header line visible, hide rest
|
||||
(goto-char (dired-get-subdir-min elt))
|
||||
(skip-chars-forward "^\n\r")
|
||||
(end-of-line)
|
||||
(if hidden-p
|
||||
(subst-char-in-region (point) end-pos ?\r ?\n)
|
||||
(subst-char-in-region (point) end-pos ?\n ?\r)))
|
||||
(dired-next-subdir 1 t))
|
||||
(restore-buffer-modified-p modflag)))
|
||||
(dired--unhide (point) end-pos)
|
||||
(dired--hide (point) end-pos)))
|
||||
(dired-next-subdir 1 t))))
|
||||
|
||||
;;;###autoload
|
||||
(defun dired-hide-all (&optional ignored)
|
||||
|
@ -2741,28 +2735,20 @@ Use \\[dired-hide-all] to (un)hide all directories."
|
|||
If there is already something hidden, make everything visible again.
|
||||
Use \\[dired-hide-subdir] to (un)hide a particular subdirectory."
|
||||
(interactive "P")
|
||||
(dired-hide-check)
|
||||
(let ((modflag (buffer-modified-p))
|
||||
buffer-read-only)
|
||||
(if (save-excursion
|
||||
(goto-char (point-min))
|
||||
(search-forward "\r" nil t))
|
||||
;; unhide - bombs on \r in filenames
|
||||
(subst-char-in-region (point-min) (point-max) ?\r ?\n)
|
||||
(with-silent-modifications
|
||||
(if (text-property-any (point-min) (point-max) 'invisible 'dired)
|
||||
(dired--unhide (point-min) (point-max))
|
||||
;; hide
|
||||
(let ((pos (point-max)) ; pos of end of last directory
|
||||
(alist dired-subdir-alist))
|
||||
(while alist ; while there are dirs before pos
|
||||
(subst-char-in-region (dired-get-subdir-min (car alist)) ; pos of prev dir
|
||||
(save-excursion
|
||||
(goto-char pos) ; current dir
|
||||
;; we're somewhere on current dir's line
|
||||
(forward-line -1)
|
||||
(point))
|
||||
?\n ?\r)
|
||||
(setq pos (dired-get-subdir-min (car alist))) ; prev dir gets current dir
|
||||
(setq alist (cdr alist)))))
|
||||
(restore-buffer-modified-p modflag)))
|
||||
(let ((pos (point-max))) ; pos of end of last directory
|
||||
(dolist (subdir dired-subdir-alist)
|
||||
(let ((start (dired-get-subdir-min subdir)) ; pos of prev dir
|
||||
(end (save-excursion
|
||||
(goto-char pos) ; current dir
|
||||
;; we're somewhere on current dir's line
|
||||
(forward-line -1)
|
||||
(point))))
|
||||
(dired--hide start end))
|
||||
(setq pos (dired-get-subdir-min subdir))))))) ; prev dir gets current dir
|
||||
|
||||
;;;###end dired-ins.el
|
||||
|
||||
|
@ -2788,8 +2774,8 @@ When off, it uses the original predicate."
|
|||
nil nil nil
|
||||
(if dired-isearch-filenames-mode
|
||||
(add-function :before-while (local 'isearch-filter-predicate)
|
||||
#'dired-isearch-filter-filenames
|
||||
'((isearch-message-prefix . "filename ")))
|
||||
#'dired-isearch-filter-filenames
|
||||
'((isearch-message-prefix . "filename ")))
|
||||
(remove-function (local 'isearch-filter-predicate)
|
||||
#'dired-isearch-filter-filenames))
|
||||
(when isearch-mode
|
||||
|
@ -2805,13 +2791,13 @@ Intended to be added to `isearch-mode-hook'."
|
|||
(get-text-property (point) 'dired-filename)))
|
||||
(define-key isearch-mode-map "\M-sff" 'dired-isearch-filenames-mode)
|
||||
(dired-isearch-filenames-mode 1)
|
||||
(add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t)))
|
||||
(add-hook 'isearch-mode-end-hook #'dired-isearch-filenames-end nil t)))
|
||||
|
||||
(defun dired-isearch-filenames-end ()
|
||||
"Clean up the Dired file name search after terminating isearch."
|
||||
(define-key isearch-mode-map "\M-sff" nil)
|
||||
(dired-isearch-filenames-mode -1)
|
||||
(remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t)
|
||||
(remove-hook 'isearch-mode-end-hook #'dired-isearch-filenames-end t)
|
||||
(unless isearch-suspended
|
||||
(custom-reevaluate-setting 'dired-isearch-filenames)))
|
||||
|
||||
|
@ -2905,7 +2891,7 @@ REGEXP should use constructs supported by your local `grep' command."
|
|||
(declare-function rgrep-find-ignored-directories "grep" (dir))
|
||||
(let* ((files (dired-get-marked-files nil nil nil nil t))
|
||||
(ignores (nconc (mapcar
|
||||
(lambda (s) (concat s "/"))
|
||||
#'file-name-as-directory
|
||||
(rgrep-find-ignored-directories default-directory))
|
||||
grep-find-ignored-files))
|
||||
(xrefs (mapcan
|
||||
|
|
122
lisp/dired.el
122
lisp/dired.el
|
@ -364,12 +364,12 @@ This is an alist of the form (SUBDIR . SWITCHES).")
|
|||
(defvaralias 'dired-move-to-filename-regexp
|
||||
'directory-listing-before-filename-regexp)
|
||||
|
||||
(defvar dired-subdir-regexp "^. \\([^\n\r]+\\)\\(:\\)[\n\r]"
|
||||
(defvar dired-subdir-regexp "^. \\(.+\\)\\(:\\)\n"
|
||||
"Regexp matching a maybe hidden subdirectory line in `ls -lR' output.
|
||||
Subexpression 1 is the subdirectory proper, no trailing colon.
|
||||
The match starts at the beginning of the line and ends after the end
|
||||
of the line (\\n or \\r).
|
||||
Subexpression 2 must end right before the \\n or \\r.")
|
||||
of the line.
|
||||
Subexpression 2 must end right before the \\n.")
|
||||
|
||||
(defgroup dired-faces nil
|
||||
"Faces used by Dired."
|
||||
|
@ -548,7 +548,7 @@ Return value is the number of files marked, or nil if none were marked."
|
|||
(setq count 0)
|
||||
(when ,msg
|
||||
(message "%s %ss%s..."
|
||||
(cond ((eq dired-marker-char ?\040) "Unmarking")
|
||||
(cond ((eq dired-marker-char ?\s) "Unmarking")
|
||||
((eq dired-del-marker dired-marker-char)
|
||||
"Flagging")
|
||||
(t "Marking"))
|
||||
|
@ -568,7 +568,7 @@ Return value is the number of files marked, or nil if none were marked."
|
|||
count
|
||||
,msg
|
||||
(dired-plural-s count)
|
||||
(if (eq dired-marker-char ?\040) "un" "")
|
||||
(if (eq dired-marker-char ?\s) "un" "")
|
||||
(if (eq dired-marker-char dired-del-marker)
|
||||
"flagged" "marked"))))
|
||||
(and (> count 0) count)))
|
||||
|
@ -1539,9 +1539,8 @@ change; the point does."
|
|||
|
||||
(defun dired-remember-marks (beg end)
|
||||
"Return alist of files and their marks, from BEG to END."
|
||||
(if selective-display ; must unhide to make this work.
|
||||
(let ((inhibit-read-only t))
|
||||
(subst-char-in-region beg end ?\r ?\n)))
|
||||
(if (dired--find-hidden-pos (point-min) (point-max))
|
||||
(dired--unhide (point-min) (point-max))) ;Must unhide to make this work.
|
||||
(let (fil chr alist)
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
|
@ -1568,15 +1567,12 @@ Each element of ALIST looks like (FILE . MARKERCHAR)."
|
|||
|
||||
(defun dired-remember-hidden ()
|
||||
"Return a list of names of subdirs currently hidden."
|
||||
(let ((l dired-subdir-alist) dir pos result)
|
||||
(while l
|
||||
(setq dir (car (car l))
|
||||
pos (cdr (car l))
|
||||
l (cdr l))
|
||||
(let (result)
|
||||
(pcase-dolist (`(,dir . ,pos) dired-subdir-alist)
|
||||
(goto-char pos)
|
||||
(skip-chars-forward "^\r\n")
|
||||
(if (eq (following-char) ?\r)
|
||||
(setq result (cons dir result))))
|
||||
(end-of-line)
|
||||
(if (dired--hidden-p)
|
||||
(push dir result)))
|
||||
result))
|
||||
|
||||
(defun dired-insert-old-subdirs (old-subdir-alist)
|
||||
|
@ -2135,9 +2131,9 @@ Keybindings:
|
|||
mode-name "Dired"
|
||||
;; case-fold-search nil
|
||||
buffer-read-only t
|
||||
selective-display t ; for subdirectory hiding
|
||||
mode-line-buffer-identification
|
||||
(propertized-buffer-identification "%17b"))
|
||||
(add-to-invisibility-spec '(dired . t))
|
||||
;; Ignore dired-hide-details-* value of invisible text property by default.
|
||||
(when (eq buffer-invisibility-spec t)
|
||||
(setq buffer-invisibility-spec (list t)))
|
||||
|
@ -2160,8 +2156,8 @@ Keybindings:
|
|||
(when (featurep 'dnd)
|
||||
(setq-local dnd-protocol-alist
|
||||
(append dired-dnd-protocol-alist dnd-protocol-alist)))
|
||||
(add-hook 'file-name-at-point-functions 'dired-file-name-at-point nil t)
|
||||
(add-hook 'isearch-mode-hook 'dired-isearch-filenames-setup nil t)
|
||||
(add-hook 'file-name-at-point-functions #'dired-file-name-at-point nil t)
|
||||
(add-hook 'isearch-mode-hook #'dired-isearch-filenames-setup nil t)
|
||||
(run-mode-hooks 'dired-mode-hook))
|
||||
|
||||
;; Idiosyncratic dired commands that don't deal with marks.
|
||||
|
@ -2266,7 +2262,8 @@ directory in another window."
|
|||
(error "File no longer exists; type `g' to update Dired buffer")))))
|
||||
|
||||
;; Force C-m keybinding rather than `f' or `e' in the mode doc:
|
||||
(define-obsolete-function-alias 'dired-advertised-find-file 'dired-find-file "23.2")
|
||||
(define-obsolete-function-alias 'dired-advertised-find-file
|
||||
#'dired-find-file "23.2")
|
||||
(defun dired-find-file ()
|
||||
"In Dired, visit the file or directory named on this line."
|
||||
(interactive)
|
||||
|
@ -2514,6 +2511,34 @@ See options: `dired-hide-details-hide-symlink-targets' and
|
|||
'remove-from-invisibility-spec)
|
||||
'dired-hide-details-link))
|
||||
|
||||
;;; Functions to hide/unhide text
|
||||
|
||||
(defun dired--find-hidden-pos (start end)
|
||||
(text-property-any start end 'invisible 'dired))
|
||||
|
||||
(defun dired--hidden-p (&optional pos)
|
||||
(eq (get-char-property (or pos (point)) 'invisible) 'dired))
|
||||
|
||||
(defun dired--hide (start end)
|
||||
;; The old code used selective-display which only works at
|
||||
;; a line-granularity, so it used start and end positions that where
|
||||
;; approximate ("anywhere on the line is fine").
|
||||
(save-excursion
|
||||
(put-text-property (progn (goto-char start) (line-end-position))
|
||||
(progn (goto-char end) (line-end-position))
|
||||
'invisible 'dired)))
|
||||
|
||||
(defun dired--unhide (start end)
|
||||
;; The old code used selective-display which only works at
|
||||
;; a line-granularity, so it used start and end positions that where
|
||||
;; approximate ("anywhere on the line is fine").
|
||||
;; FIXME: This also removes other invisible properties!
|
||||
(save-excursion
|
||||
(remove-text-properties
|
||||
(progn (goto-char start) (line-end-position))
|
||||
(progn (goto-char end) (line-end-position))
|
||||
'(invisible))))
|
||||
|
||||
;;; Functions for finding the file name in a dired buffer line.
|
||||
|
||||
(defvar dired-permission-flags-regexp
|
||||
|
@ -2553,12 +2578,11 @@ Return the position of the beginning of the filename, or nil if none found."
|
|||
;; This is the UNIX version.
|
||||
(if (get-text-property (point) 'dired-filename)
|
||||
(goto-char (next-single-property-change (point) 'dired-filename))
|
||||
(let (opoint file-type executable symlink hidden used-F eol)
|
||||
(setq used-F (dired-check-switches dired-actual-switches "F" "classify")
|
||||
opoint (point)
|
||||
eol (line-end-position)
|
||||
hidden (and selective-display
|
||||
(save-excursion (search-forward "\r" eol t))))
|
||||
(let ((opoint (point))
|
||||
(used-F (dired-check-switches dired-actual-switches "F" "classify"))
|
||||
(eol (line-end-position))
|
||||
(hidden (dired--hidden-p))
|
||||
file-type executable symlink)
|
||||
(if hidden
|
||||
nil
|
||||
(save-excursion ;; Find out what kind of file this is:
|
||||
|
@ -2795,7 +2819,7 @@ You can then feed the file name(s) to other commands with \\[yank]."
|
|||
(if pos
|
||||
(progn
|
||||
(goto-char pos)
|
||||
(or no-skip (skip-chars-forward "^\n\r"))
|
||||
(or no-skip (end-of-line))
|
||||
(point))
|
||||
(if no-error-if-not-found
|
||||
nil ; return nil if not found
|
||||
|
@ -3187,17 +3211,17 @@ non-empty directories is allowed."
|
|||
(dired-move-to-filename))
|
||||
|
||||
(defun dired-fun-in-all-buffers (directory file fun &rest args)
|
||||
;; In all buffers dired'ing DIRECTORY, run FUN with ARGS.
|
||||
;; If the buffer has a wildcard pattern, check that it matches FILE.
|
||||
;; (FILE does not include a directory component.)
|
||||
;; FILE may be nil, in which case ignore it.
|
||||
;; Return list of buffers where FUN succeeded (i.e., returned non-nil).
|
||||
"In all buffers dired'ing DIRECTORY, run FUN with ARGS.
|
||||
If the buffer has a wildcard pattern, check that it matches FILE.
|
||||
(FILE does not include a directory component.)
|
||||
FILE may be nil, in which case ignore it.
|
||||
Return list of buffers where FUN succeeded (i.e., returned non-nil)."
|
||||
(let (success-list)
|
||||
(dolist (buf (dired-buffers-for-dir (expand-file-name directory)
|
||||
file))
|
||||
(dolist (buf (dired-buffers-for-dir (expand-file-name directory) file))
|
||||
(with-current-buffer buf
|
||||
(if (apply fun args)
|
||||
(setq success-list (cons (buffer-name buf) success-list)))))
|
||||
(push buf success-list))))
|
||||
;; FIXME: AFAICT, this return value is not used by any of the callers!
|
||||
success-list))
|
||||
|
||||
;; Delete the entry for FILE from
|
||||
|
@ -3430,7 +3454,7 @@ no ARGth marked file is found before this line."
|
|||
(and (dired-goto-file file)
|
||||
(progn
|
||||
(beginning-of-line)
|
||||
(if (not (equal ?\040 (following-char)))
|
||||
(if (not (equal ?\s (following-char)))
|
||||
(following-char))))))
|
||||
|
||||
(defun dired-mark-files-in-region (start end)
|
||||
|
@ -3488,7 +3512,7 @@ If looking at a subdir, unmark all its files except `.' and `..'.
|
|||
If the region is active in Transient Mark mode, unmark all files
|
||||
in the active region."
|
||||
(interactive (list current-prefix-arg t))
|
||||
(let ((dired-marker-char ?\040))
|
||||
(let ((dired-marker-char ?\s))
|
||||
(dired-mark arg interactive)))
|
||||
|
||||
(defun dired-flag-file-deletion (arg &optional interactive)
|
||||
|
@ -3527,11 +3551,11 @@ As always, hidden subdirs are not affected."
|
|||
;; use subst instead of insdel because it does not move
|
||||
;; the gap and thus should be faster and because
|
||||
;; other characters are left alone automatically
|
||||
(apply 'subst-char-in-region
|
||||
(apply #'subst-char-in-region
|
||||
(point) (1+ (point))
|
||||
(if (eq ?\040 (following-char)) ; SPC
|
||||
(list ?\040 dired-marker-char)
|
||||
(list dired-marker-char ?\040))))
|
||||
(if (eq ?\s (following-char))
|
||||
(list ?\s dired-marker-char)
|
||||
(list dired-marker-char ?\s))))
|
||||
(forward-line 1)))))
|
||||
|
||||
;;; Commands to mark or flag files based on their characteristics or names.
|
||||
|
@ -3562,7 +3586,7 @@ object files--just `.o' will mark more than you might think."
|
|||
(dired-get-filename nil t) t))
|
||||
"\\'"))))
|
||||
'dired-regexp-history)
|
||||
(if current-prefix-arg ?\040)))
|
||||
(if current-prefix-arg ?\s)))
|
||||
(let ((dired-marker-char (or marker-char dired-marker-char)))
|
||||
(dired-mark-if
|
||||
(and (not (looking-at-p dired-re-dot))
|
||||
|
@ -3585,7 +3609,7 @@ since it was last visited."
|
|||
(list (read-regexp (concat (if current-prefix-arg "Unmark" "Mark")
|
||||
" files containing (regexp): ")
|
||||
nil 'dired-regexp-history)
|
||||
(if current-prefix-arg ?\040)))
|
||||
(if current-prefix-arg ?\s)))
|
||||
(let ((dired-marker-char (or marker-char dired-marker-char)))
|
||||
(dired-mark-if
|
||||
(and (not (looking-at-p dired-re-dot))
|
||||
|
@ -3622,14 +3646,14 @@ The match is against the non-directory part of the filename. Use `^'
|
|||
"Mark all symbolic links.
|
||||
With prefix argument, unmark or unflag all those files."
|
||||
(interactive "P")
|
||||
(let ((dired-marker-char (if unflag-p ?\040 dired-marker-char)))
|
||||
(let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))
|
||||
(dired-mark-if (looking-at-p dired-re-sym) "symbolic link")))
|
||||
|
||||
(defun dired-mark-directories (unflag-p)
|
||||
"Mark all directory file lines except `.' and `..'.
|
||||
With prefix argument, unmark or unflag all those files."
|
||||
(interactive "P")
|
||||
(let ((dired-marker-char (if unflag-p ?\040 dired-marker-char)))
|
||||
(let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))
|
||||
(dired-mark-if (and (looking-at-p dired-re-dir)
|
||||
(not (looking-at-p dired-re-dot)))
|
||||
"directory file")))
|
||||
|
@ -3638,7 +3662,7 @@ With prefix argument, unmark or unflag all those files."
|
|||
"Mark all executable files.
|
||||
With prefix argument, unmark or unflag all those files."
|
||||
(interactive "P")
|
||||
(let ((dired-marker-char (if unflag-p ?\040 dired-marker-char)))
|
||||
(let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))
|
||||
(dired-mark-if (looking-at-p dired-re-exe) "executable file")))
|
||||
|
||||
;; dired-x.el has a dired-mark-sexp interactive command: mark
|
||||
|
@ -3648,7 +3672,7 @@ With prefix argument, unmark or unflag all those files."
|
|||
"Flag for deletion files whose names suggest they are auto save files.
|
||||
A prefix argument says to unmark or unflag those files instead."
|
||||
(interactive "P")
|
||||
(let ((dired-marker-char (if unflag-p ?\040 dired-del-marker)))
|
||||
(let ((dired-marker-char (if unflag-p ?\s dired-del-marker)))
|
||||
(dired-mark-if
|
||||
;; It is less than general to check for # here,
|
||||
;; but it's the only way this runs fast enough.
|
||||
|
@ -3887,7 +3911,7 @@ The idea is to set this buffer-locally in special Dired buffers.")
|
|||
(force-mode-line-update)))
|
||||
|
||||
(define-obsolete-function-alias 'dired-sort-set-modeline
|
||||
'dired-sort-set-mode-line "24.3")
|
||||
#'dired-sort-set-mode-line "24.3")
|
||||
|
||||
(defun dired-sort-toggle-or-edit (&optional arg)
|
||||
"Toggle sorting by date, and refresh the Dired buffer.
|
||||
|
@ -4129,7 +4153,7 @@ Ask means pop up a menu for the user to select one of copy, move or link."
|
|||
(dired dired-dir)
|
||||
;; The following elements of `misc-data' are the keys
|
||||
;; from `dired-subdir-alist'.
|
||||
(mapc 'dired-maybe-insert-subdir (cdr misc-data))
|
||||
(mapc #'dired-maybe-insert-subdir (cdr misc-data))
|
||||
(current-buffer))
|
||||
(message "Desktop: Directory %s no longer exists." dir)
|
||||
(when desktop-missing-file-warning (sit-for 1))
|
||||
|
|
Loading…
Add table
Reference in a new issue