2017-07-29 11:00:51 -04:00
|
|
|
|
;;; dired-aux.el --- less commonly used parts of dired -*- lexical-binding: t -*-
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2022-01-01 02:45:51 -05:00
|
|
|
|
;; Copyright (C) 1985-1986, 1992, 1994, 1998, 2000-2022 Free Software
|
2015-01-01 14:26:41 -08:00
|
|
|
|
;; Foundation, Inc.
|
1992-07-22 04:22:42 +00:00
|
|
|
|
|
1992-07-16 17:20:42 +00:00
|
|
|
|
;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>.
|
2019-05-25 13:43:06 -07:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
2001-08-29 15:02:01 +00:00
|
|
|
|
;; Keywords: files
|
2010-08-29 12:17:13 -04:00
|
|
|
|
;; Package: emacs
|
1992-07-16 21:47:34 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
1992-07-16 17:20:42 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
1993-03-22 03:27:18 +00:00
|
|
|
|
;; The parts of dired mode not normally used. This is a space-saving hack
|
|
|
|
|
;; to avoid having to load a large mode when all that's wanted are a few
|
|
|
|
|
;; functions.
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; Rewritten in 1990/1991 to add tree features, file marking and
|
|
|
|
|
;; sorting by Sebastian Kremer <sk@thp.uni-koeln.de>.
|
|
|
|
|
;; Finished up by rms in 1992.
|
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
1992-07-16 17:20:42 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2016-02-13 13:18:17 -05:00
|
|
|
|
(require 'cl-lib)
|
2007-12-23 19:14:55 +00:00
|
|
|
|
;; We need macros in dired.el to compile properly,
|
|
|
|
|
;; and we call subroutines in it too.
|
|
|
|
|
(require 'dired)
|
1992-08-03 03:44:51 +00:00
|
|
|
|
|
2006-09-11 02:25:00 +00:00
|
|
|
|
(defvar dired-create-files-failures nil
|
|
|
|
|
"Variable where `dired-create-files' records failing file names.
|
|
|
|
|
Functions that operate recursively can store additional names
|
|
|
|
|
into this list; they also should call `dired-log' to log the errors.")
|
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
|
|
|
|
;;; Diffing and compressing
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2002-04-17 09:54:47 +00:00
|
|
|
|
(defconst dired-star-subst-regexp "\\(^\\|[ \t]\\)\\*\\([ \t]\\|$\\)")
|
|
|
|
|
(defconst dired-quark-subst-regexp "\\(^\\|[ \t]\\)\\?\\([ \t]\\|$\\)")
|
2017-07-02 22:09:02 +09:00
|
|
|
|
(make-obsolete-variable 'dired-star-subst-regexp nil "26.1")
|
|
|
|
|
(make-obsolete-variable 'dired-quark-subst-regexp nil "26.1")
|
|
|
|
|
|
|
|
|
|
(defun dired-isolated-string-re (string)
|
|
|
|
|
"Return a regexp to match STRING isolated.
|
|
|
|
|
Isolated means that STRING is surrounded by spaces or at the beginning/end
|
|
|
|
|
of a string followed/prefixed with an space.
|
|
|
|
|
The regexp capture the preceding blank, STRING and the following blank as
|
|
|
|
|
the groups 1, 2 and 3 respectively."
|
2020-09-20 14:16:19 +02:00
|
|
|
|
(format "\\(?1:\\`\\|[ \t]\\)\\(?2:%s\\)\\(?3:[ \t]\\|\\'\\)" string))
|
2017-07-02 22:09:02 +09:00
|
|
|
|
|
2020-09-20 14:16:19 +02:00
|
|
|
|
(defun dired--star-or-qmark-p (string match &optional keep start)
|
2017-07-02 22:09:02 +09:00
|
|
|
|
"Return non-nil if STRING contains isolated MATCH or `\\=`?\\=`'.
|
|
|
|
|
MATCH should be the strings \"?\", `\\=`?\\=`', \"*\" or nil. The latter
|
|
|
|
|
means STRING contains either \"?\" or `\\=`?\\=`' or \"*\".
|
|
|
|
|
If optional arg KEEP is non-nil, then preserve the match data. Otherwise,
|
|
|
|
|
this function changes it and saves MATCH as the second match group.
|
2020-09-20 14:16:19 +02:00
|
|
|
|
START is the position to start matching from.
|
2017-07-02 22:09:02 +09:00
|
|
|
|
|
|
|
|
|
Isolated means that MATCH is surrounded by spaces or at the beginning/end
|
|
|
|
|
of STRING followed/prefixed with an space. A match to `\\=`?\\=`',
|
|
|
|
|
isolated or not, is also valid."
|
2020-09-20 14:16:19 +02:00
|
|
|
|
(let ((regexp (dired-isolated-string-re (if match (regexp-quote match) "[*?]"))))
|
2017-07-02 22:09:02 +09:00
|
|
|
|
(when (or (null match) (equal match "?"))
|
2020-09-20 14:16:19 +02:00
|
|
|
|
(cl-callf concat regexp "\\|\\(?1:\\)\\(?2:`\\?`\\)\\(?3:\\)"))
|
|
|
|
|
(funcall (if keep #'string-match-p #'string-match) regexp string start)))
|
|
|
|
|
|
|
|
|
|
(defun dired--need-confirm-positions (command string)
|
|
|
|
|
"Search for non-isolated matches of STRING in COMMAND.
|
|
|
|
|
Return a list of positions that match STRING, but would not be
|
|
|
|
|
considered \"isolated\" by `dired--star-or-qmark-p'."
|
|
|
|
|
(cl-assert (= (length string) 1))
|
|
|
|
|
(let ((start 0)
|
|
|
|
|
(isolated-char-positions nil)
|
|
|
|
|
(confirm-positions nil)
|
|
|
|
|
(regexp (regexp-quote string)))
|
|
|
|
|
;; Collect all ? and * surrounded by spaces and `?`.
|
|
|
|
|
(while (dired--star-or-qmark-p command string nil start)
|
|
|
|
|
(push (cons (match-beginning 2) (match-end 2))
|
|
|
|
|
isolated-char-positions)
|
|
|
|
|
(setq start (match-end 2)))
|
|
|
|
|
;; Now collect any remaining ? and *.
|
|
|
|
|
(setq start 0)
|
|
|
|
|
(while (string-match regexp command start)
|
|
|
|
|
(unless (cl-member (match-beginning 0) isolated-char-positions
|
|
|
|
|
:test (lambda (pos match)
|
|
|
|
|
(<= (car match) pos (cdr match))))
|
|
|
|
|
(push (match-beginning 0) confirm-positions))
|
|
|
|
|
(setq start (match-end 0)))
|
|
|
|
|
confirm-positions))
|
|
|
|
|
|
|
|
|
|
(defun dired--mark-positions (positions)
|
|
|
|
|
(let ((markers (make-string
|
|
|
|
|
(1+ (apply #'max positions))
|
|
|
|
|
?\s)))
|
|
|
|
|
(dolist (pos positions)
|
|
|
|
|
(setf (aref markers pos) ?^))
|
|
|
|
|
markers))
|
|
|
|
|
|
|
|
|
|
(defun dired--highlight-no-subst-chars (positions command mark)
|
|
|
|
|
(cl-callf substring-no-properties command)
|
|
|
|
|
(dolist (pos positions)
|
|
|
|
|
(add-face-text-property pos (1+ pos) 'warning nil command))
|
|
|
|
|
(if mark
|
|
|
|
|
(concat command "\n" (dired--mark-positions positions))
|
|
|
|
|
command))
|
|
|
|
|
|
|
|
|
|
(defun dired--no-subst-explain (buf char-positions command mark-positions)
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(insert
|
|
|
|
|
(format-message "\
|
|
|
|
|
If your command contains occurrences of `*' surrounded by
|
|
|
|
|
whitespace, `dired-do-shell-command' substitutes them for the
|
|
|
|
|
entire file list to process. Otherwise, if your command contains
|
|
|
|
|
occurrences of `?' surrounded by whitespace or `%s', Dired will
|
|
|
|
|
run the command once for each file, substituting `?' for each
|
|
|
|
|
file name.
|
|
|
|
|
|
|
|
|
|
Your command contains occurrences of `%s' that will not be
|
|
|
|
|
substituted, and will be passed through normally to the shell.
|
|
|
|
|
|
|
|
|
|
%s
|
|
|
|
|
|
2021-06-30 20:10:30 +02:00
|
|
|
|
\(Press ^ to %s markers below these occurrences.)
|
2020-09-20 14:16:19 +02:00
|
|
|
|
"
|
|
|
|
|
"`"
|
|
|
|
|
(string (aref command (car char-positions)))
|
|
|
|
|
(dired--highlight-no-subst-chars char-positions command mark-positions)
|
|
|
|
|
(if mark-positions "remove" "add")))))
|
|
|
|
|
|
|
|
|
|
(defun dired--no-subst-ask (char nb-occur details)
|
|
|
|
|
(let ((hilit-char (propertize (string char) 'face 'warning))
|
|
|
|
|
(choices `(?y ?n ?? ,@(when details '(?^)))))
|
2020-12-30 11:54:01 +02:00
|
|
|
|
(read-char-choice
|
2020-09-20 14:16:19 +02:00
|
|
|
|
(format-message
|
|
|
|
|
(ngettext
|
|
|
|
|
"%d occurrence of `%s' will not be substituted. Proceed? (%s) "
|
|
|
|
|
"%d occurrences of `%s' will not be substituted. Proceed? (%s) "
|
|
|
|
|
nb-occur)
|
|
|
|
|
nb-occur hilit-char (mapconcat #'string choices ", "))
|
|
|
|
|
choices)))
|
|
|
|
|
|
|
|
|
|
(defun dired--no-subst-confirm (char-positions command)
|
|
|
|
|
(let ((help-buf (get-buffer-create "*Dired help*"))
|
|
|
|
|
(char (aref command (car char-positions)))
|
|
|
|
|
(nb-occur (length char-positions))
|
|
|
|
|
(done nil)
|
|
|
|
|
(details nil)
|
|
|
|
|
(markers nil)
|
|
|
|
|
proceed)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(save-window-excursion
|
|
|
|
|
(while (not done)
|
|
|
|
|
(cl-case (dired--no-subst-ask char nb-occur details)
|
|
|
|
|
(?y
|
|
|
|
|
(setq done t
|
|
|
|
|
proceed t))
|
|
|
|
|
(?n
|
|
|
|
|
(setq done t
|
|
|
|
|
proceed nil))
|
|
|
|
|
(??
|
|
|
|
|
(if details
|
|
|
|
|
(progn
|
|
|
|
|
(quit-window nil details)
|
|
|
|
|
(setq details nil))
|
|
|
|
|
(dired--no-subst-explain
|
|
|
|
|
help-buf char-positions command markers)
|
|
|
|
|
(setq details (display-buffer help-buf))))
|
|
|
|
|
(?^
|
|
|
|
|
(setq markers (not markers))
|
|
|
|
|
(dired--no-subst-explain
|
|
|
|
|
help-buf char-positions command markers)))))
|
|
|
|
|
(kill-buffer help-buf))
|
|
|
|
|
proceed))
|
2002-04-17 09:54:47 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-diff (file &optional switches)
|
2016-08-06 13:13:57 +03:00
|
|
|
|
"Compare file at point with FILE using `diff'.
|
|
|
|
|
If called interactively, prompt for FILE.
|
|
|
|
|
If the mark is active in Transient Mark mode, use the file at the mark
|
|
|
|
|
as the default for FILE. (That's the mark set by \\[set-mark-command],
|
|
|
|
|
not by Dired's \\[dired-mark] command.)
|
|
|
|
|
If the file at point has a backup file, use that as the default FILE.
|
|
|
|
|
If the file at point is a backup file, use its original, if that exists
|
|
|
|
|
and can be found. Note that customizations of `backup-directory-alist'
|
|
|
|
|
and `make-backup-file-name-function' change where this function searches
|
|
|
|
|
for the backup file, and affect its ability to find the original of a
|
|
|
|
|
backup file.
|
|
|
|
|
|
|
|
|
|
FILE is the first argument given to the `diff' function. The file at
|
|
|
|
|
point is the second argument given to `diff'.
|
2012-09-08 22:48:26 +08:00
|
|
|
|
|
2012-09-19 02:40:39 +03:00
|
|
|
|
With prefix arg, prompt for second argument SWITCHES, which is
|
2016-08-06 13:13:57 +03:00
|
|
|
|
the string of command switches used as the third argument of `diff'."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive
|
2009-11-25 17:15:19 +00:00
|
|
|
|
(let* ((current (dired-get-filename t))
|
2013-02-28 23:51:11 +02:00
|
|
|
|
;; Get the latest existing backup file or its original.
|
|
|
|
|
(oldf (if (backup-file-name-p current)
|
|
|
|
|
(file-name-sans-versions current)
|
|
|
|
|
(diff-latest-backup-file current)))
|
2012-09-19 02:40:39 +03:00
|
|
|
|
;; Get the file at the mark.
|
|
|
|
|
(file-at-mark (if (and transient-mark-mode mark-active)
|
|
|
|
|
(save-excursion (goto-char (mark t))
|
|
|
|
|
(dired-get-filename t t))))
|
2016-08-06 13:13:57 +03:00
|
|
|
|
(separate-dir (and oldf
|
|
|
|
|
(not (equal (file-name-directory oldf)
|
|
|
|
|
(dired-current-directory)))))
|
2012-09-19 02:40:39 +03:00
|
|
|
|
(default-file (or file-at-mark
|
2016-08-06 13:13:57 +03:00
|
|
|
|
;; If the file with which to compare
|
|
|
|
|
;; doesn't exist, or we cannot intuit it,
|
|
|
|
|
;; we forget that name and don't show it
|
|
|
|
|
;; as the default, as an indication to the
|
|
|
|
|
;; user that she should type the file
|
|
|
|
|
;; name.
|
|
|
|
|
(and (if (and oldf (file-readable-p oldf)) oldf)
|
|
|
|
|
(if separate-dir
|
|
|
|
|
oldf
|
|
|
|
|
(file-name-nondirectory oldf)))))
|
2012-09-19 02:40:39 +03:00
|
|
|
|
;; Use it as default if it's not the same as the current file,
|
|
|
|
|
;; and the target dir is current or there is a default file.
|
|
|
|
|
(default (if (and (not (equal default-file current))
|
|
|
|
|
(or (equal (dired-dwim-target-directory)
|
|
|
|
|
(dired-current-directory))
|
|
|
|
|
default-file))
|
|
|
|
|
default-file))
|
|
|
|
|
(target-dir (if default
|
2016-08-06 13:13:57 +03:00
|
|
|
|
(if separate-dir
|
|
|
|
|
(file-name-directory default)
|
|
|
|
|
(dired-current-directory))
|
2012-09-19 02:40:39 +03:00
|
|
|
|
(dired-dwim-target-directory)))
|
2020-08-24 19:15:27 +02:00
|
|
|
|
(defaults (append
|
|
|
|
|
(if (backup-file-name-p current)
|
|
|
|
|
;; This is a backup file -- put the other
|
|
|
|
|
;; main file, and the other backup files into
|
|
|
|
|
;; the `M-n' list.
|
|
|
|
|
(delete (expand-file-name current)
|
|
|
|
|
(cons (expand-file-name
|
|
|
|
|
(file-name-sans-versions current))
|
|
|
|
|
(file-backup-file-names
|
|
|
|
|
(file-name-sans-versions current))))
|
|
|
|
|
;; Non-backup file -- use the backup files as
|
|
|
|
|
;; `M-n' candidates.
|
|
|
|
|
(file-backup-file-names current))
|
|
|
|
|
(dired-dwim-target-defaults (list current) target-dir))))
|
2012-09-19 02:40:39 +03:00
|
|
|
|
(list
|
|
|
|
|
(minibuffer-with-setup-hook
|
|
|
|
|
(lambda ()
|
2020-12-09 09:18:04 +01:00
|
|
|
|
(setq-local minibuffer-default-add-function nil)
|
2012-09-19 02:40:39 +03:00
|
|
|
|
(setq minibuffer-default defaults))
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 16:56:44 +02:00
|
|
|
|
(read-file-name (format-prompt "Diff %s with" default current)
|
|
|
|
|
target-dir default t))
|
2012-09-19 02:40:39 +03:00
|
|
|
|
(if current-prefix-arg
|
|
|
|
|
(read-string "Options for diff: "
|
|
|
|
|
(if (stringp diff-switches)
|
|
|
|
|
diff-switches
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(mapconcat #'identity diff-switches " ")))))))
|
2009-12-17 01:16:15 +00:00
|
|
|
|
(let ((current (dired-get-filename t)))
|
|
|
|
|
(when (or (equal (expand-file-name file)
|
|
|
|
|
(expand-file-name current))
|
|
|
|
|
(and (file-directory-p file)
|
|
|
|
|
(equal (expand-file-name current file)
|
|
|
|
|
(expand-file-name current))))
|
|
|
|
|
(error "Attempt to compare the file to itself"))
|
2013-02-28 23:51:11 +02:00
|
|
|
|
(if (and (backup-file-name-p current)
|
|
|
|
|
(equal file (file-name-sans-versions current)))
|
|
|
|
|
(diff current file switches)
|
|
|
|
|
(diff file current switches))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-backup-diff (&optional switches)
|
|
|
|
|
"Diff this file with its backup file or vice versa.
|
|
|
|
|
Uses the latest backup, if there are several numerical backups.
|
|
|
|
|
If this file is a backup, diff it with its original.
|
1993-08-07 19:25:43 +00:00
|
|
|
|
The backup file is the first file given to `diff'.
|
|
|
|
|
With prefix arg, prompt for argument SWITCHES which is options for `diff'."
|
|
|
|
|
(interactive
|
2021-06-30 20:10:30 +02:00
|
|
|
|
(if current-prefix-arg
|
|
|
|
|
(list (read-string "Options for diff: "
|
|
|
|
|
(if (stringp diff-switches)
|
|
|
|
|
diff-switches
|
|
|
|
|
(mapconcat #'identity diff-switches " "))))
|
|
|
|
|
nil))
|
1993-08-07 19:25:43 +00:00
|
|
|
|
(diff-backup (dired-get-filename) switches))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2005-03-24 19:48:09 +00:00
|
|
|
|
;;;###autoload
|
2003-12-01 01:56:19 +00:00
|
|
|
|
(defun dired-compare-directories (dir2 predicate)
|
|
|
|
|
"Mark files with different file attributes in two dired buffers.
|
|
|
|
|
Compare file attributes of files in the current directory
|
|
|
|
|
with file attributes in directory DIR2 using PREDICATE on pairs of files
|
|
|
|
|
with the same name. Mark files for which PREDICATE returns non-nil.
|
2004-03-23 07:39:35 +00:00
|
|
|
|
Mark files with different names if PREDICATE is nil (or interactively
|
2005-03-24 19:48:09 +00:00
|
|
|
|
with empty input at the predicate prompt).
|
2003-12-01 01:56:19 +00:00
|
|
|
|
|
|
|
|
|
PREDICATE is a Lisp expression that can refer to the following variables:
|
|
|
|
|
|
|
|
|
|
size1, size2 - file size in bytes
|
|
|
|
|
mtime1, mtime2 - last modification time in seconds, as a float
|
|
|
|
|
fa1, fa2 - list of file attributes
|
|
|
|
|
returned by function `file-attributes'
|
|
|
|
|
|
|
|
|
|
where 1 refers to attribute of file in the current dired buffer
|
|
|
|
|
and 2 to attribute of file in second dired buffer.
|
|
|
|
|
|
|
|
|
|
Examples of PREDICATE:
|
|
|
|
|
|
|
|
|
|
(> mtime1 mtime2) - mark newer files
|
|
|
|
|
(not (= size1 size2)) - mark files with different sizes
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(not (string= (file-attribute-modes fa1) - mark files with different modes
|
|
|
|
|
(file-attribute-modes fa2)))
|
|
|
|
|
(not (and (= (file-attribute-user-id fa1) - mark files with different UID
|
|
|
|
|
(file-attribute-user-id fa2))
|
|
|
|
|
(= (file-attribute-group-id fa1) - and GID.
|
2020-03-23 02:35:33 +02:00
|
|
|
|
(file-attribute-group-id fa2))))
|
|
|
|
|
|
|
|
|
|
If the region is active in Transient Mark mode, mark files
|
|
|
|
|
only in the active region if `dired-mark-region' is non-nil."
|
2003-12-01 01:56:19 +00:00
|
|
|
|
(interactive
|
2009-11-25 17:15:19 +00:00
|
|
|
|
(list
|
|
|
|
|
(let* ((target-dir (dired-dwim-target-directory))
|
|
|
|
|
(defaults (dired-dwim-target-defaults nil target-dir)))
|
|
|
|
|
(minibuffer-with-setup-hook
|
|
|
|
|
(lambda ()
|
2020-12-09 09:18:04 +01:00
|
|
|
|
(setq-local minibuffer-default-add-function nil)
|
2009-11-25 17:15:19 +00:00
|
|
|
|
(setq minibuffer-default defaults))
|
|
|
|
|
(read-directory-name (format "Compare %s with: "
|
|
|
|
|
(dired-current-directory))
|
|
|
|
|
target-dir target-dir t)))
|
|
|
|
|
(read-from-minibuffer "Mark if (lisp expr or RET): " nil nil t nil "nil")))
|
2003-12-01 01:56:19 +00:00
|
|
|
|
(let* ((dir1 (dired-current-directory))
|
|
|
|
|
(file-alist1 (dired-files-attributes dir1))
|
|
|
|
|
(file-alist2 (dired-files-attributes dir2))
|
2005-07-11 04:25:01 +00:00
|
|
|
|
file-list1 file-list2)
|
|
|
|
|
(setq file-alist1 (delq (assoc "." file-alist1) file-alist1))
|
|
|
|
|
(setq file-alist1 (delq (assoc ".." file-alist1) file-alist1))
|
|
|
|
|
(setq file-alist2 (delq (assoc "." file-alist2) file-alist2))
|
|
|
|
|
(setq file-alist2 (delq (assoc ".." file-alist2) file-alist2))
|
|
|
|
|
(setq file-list1 (mapcar
|
2019-03-17 13:35:20 -04:00
|
|
|
|
#'cadr
|
2003-12-01 01:56:19 +00:00
|
|
|
|
(dired-file-set-difference
|
|
|
|
|
file-alist1 file-alist2
|
2005-07-11 04:25:01 +00:00
|
|
|
|
predicate))
|
|
|
|
|
file-list2 (mapcar
|
2019-03-17 13:35:20 -04:00
|
|
|
|
#'cadr
|
2003-12-01 01:56:19 +00:00
|
|
|
|
(dired-file-set-difference
|
|
|
|
|
file-alist2 file-alist1
|
2005-07-11 04:25:01 +00:00
|
|
|
|
predicate)))
|
2003-12-01 01:56:19 +00:00
|
|
|
|
(dired-fun-in-all-buffers
|
|
|
|
|
dir1 nil
|
|
|
|
|
(lambda ()
|
|
|
|
|
(dired-mark-if
|
|
|
|
|
(member (dired-get-filename nil t) file-list1) nil)))
|
|
|
|
|
(dired-fun-in-all-buffers
|
|
|
|
|
dir2 nil
|
|
|
|
|
(lambda ()
|
|
|
|
|
(dired-mark-if
|
|
|
|
|
(member (dired-get-filename nil t) file-list2) nil)))
|
2019-05-05 22:43:27 +03:00
|
|
|
|
(message "Marked in dir1: %s, in dir2: %s"
|
|
|
|
|
(format-message (ngettext "%d file" "%d files" (length file-list1))
|
|
|
|
|
(length file-list1))
|
|
|
|
|
(format-message (ngettext "%d file" "%d files" (length file-list2))
|
|
|
|
|
(length file-list2)))))
|
2003-12-01 01:56:19 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-file-set-difference (list1 list2 predicate)
|
|
|
|
|
"Combine LIST1 and LIST2 using a set-difference operation.
|
|
|
|
|
The result list contains all file items that appear in LIST1 but not LIST2.
|
|
|
|
|
This is a non-destructive function; it makes a copy of the data if necessary
|
|
|
|
|
to avoid corrupting the original LIST1 and LIST2.
|
|
|
|
|
PREDICATE (see `dired-compare-directories') is an additional match
|
|
|
|
|
condition. Two file items are considered to match if they are equal
|
|
|
|
|
*and* PREDICATE evaluates to t."
|
|
|
|
|
(if (or (null list1) (null list2))
|
|
|
|
|
list1
|
|
|
|
|
(let (res)
|
|
|
|
|
(dolist (file1 list1)
|
|
|
|
|
(unless (let ((list list2))
|
|
|
|
|
(while (and list
|
2014-04-06 14:15:09 -04:00
|
|
|
|
(let* ((file2 (car list))
|
|
|
|
|
(fa1 (car (cddr file1)))
|
|
|
|
|
(fa2 (car (cddr file2))))
|
|
|
|
|
(or
|
|
|
|
|
(not (equal (car file1) (car file2)))
|
|
|
|
|
(eval predicate
|
|
|
|
|
`((fa1 . ,fa1)
|
|
|
|
|
(fa2 . ,fa2)
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(size1 . ,(file-attribute-size fa1))
|
|
|
|
|
(size2 . ,(file-attribute-size fa2))
|
2014-04-06 14:15:09 -04:00
|
|
|
|
(mtime1
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
. ,(float-time (file-attribute-modification-time fa1)))
|
2014-04-06 14:15:09 -04:00
|
|
|
|
(mtime2
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
. ,(float-time (file-attribute-modification-time fa2)))
|
2014-04-06 14:15:09 -04:00
|
|
|
|
)))))
|
2003-12-01 01:56:19 +00:00
|
|
|
|
(setq list (cdr list)))
|
|
|
|
|
list)
|
2014-04-06 14:15:09 -04:00
|
|
|
|
(push file1 res)))
|
2003-12-01 01:56:19 +00:00
|
|
|
|
(nreverse res))))
|
|
|
|
|
|
|
|
|
|
(defun dired-files-attributes (dir)
|
|
|
|
|
"Return a list of all file names and attributes from DIR.
|
2009-09-24 01:37:14 +00:00
|
|
|
|
List has a form of (file-name full-file-name (attribute-list))."
|
2003-12-01 01:56:19 +00:00
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (file-name)
|
|
|
|
|
(let ((full-file-name (expand-file-name file-name dir)))
|
|
|
|
|
(list file-name
|
|
|
|
|
full-file-name
|
|
|
|
|
(file-attributes full-file-name))))
|
|
|
|
|
(directory-files dir)))
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
2003-12-01 01:56:19 +00:00
|
|
|
|
|
2011-07-30 12:14:58 +03:00
|
|
|
|
;;; Change file attributes
|
2004-05-01 03:47:42 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-do-chxxx (attribute-name program op-symbol arg)
|
2011-07-30 12:14:58 +03:00
|
|
|
|
;; Change file attributes (group, owner, timestamp) of marked files and
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; refresh their file lines.
|
|
|
|
|
;; ATTRIBUTE-NAME is a string describing the attribute to the user.
|
|
|
|
|
;; PROGRAM is the program used to change the attribute.
|
2011-07-30 12:14:58 +03:00
|
|
|
|
;; OP-SYMBOL is the type of operation (for use in `dired-mark-pop-up').
|
|
|
|
|
;; ARG describes which files to use, as in `dired-get-marked-files'.
|
2018-02-06 23:32:08 +02:00
|
|
|
|
(let* ((files (dired-get-marked-files t arg nil nil t))
|
2012-09-19 01:57:45 +03:00
|
|
|
|
;; The source of default file attributes is the file at point.
|
2012-09-19 23:09:55 +03:00
|
|
|
|
(default-file (dired-get-filename t t))
|
2012-09-19 01:57:45 +03:00
|
|
|
|
(default (when default-file
|
|
|
|
|
(cond ((eq op-symbol 'touch)
|
|
|
|
|
(format-time-string
|
|
|
|
|
"%Y%m%d%H%M.%S"
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(file-attribute-modification-time
|
|
|
|
|
(file-attributes default-file))))
|
2012-09-19 01:57:45 +03:00
|
|
|
|
((eq op-symbol 'chown)
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(file-attribute-user-id
|
|
|
|
|
(file-attributes default-file 'string)))
|
2012-09-19 01:57:45 +03:00
|
|
|
|
((eq op-symbol 'chgrp)
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(file-attribute-group-id
|
|
|
|
|
(file-attributes default-file 'string))))))
|
2021-10-05 03:34:08 +02:00
|
|
|
|
(prompt (format-prompt "Change %s of %%s to"
|
|
|
|
|
(when (eq op-symbol 'touch)
|
|
|
|
|
"now")
|
|
|
|
|
attribute-name))
|
2011-09-12 16:45:56 -04:00
|
|
|
|
(new-attribute (dired-mark-read-string prompt nil op-symbol
|
2012-04-16 21:49:40 -04:00
|
|
|
|
arg files default
|
|
|
|
|
(cond ((eq op-symbol 'chown)
|
|
|
|
|
(system-users))
|
|
|
|
|
((eq op-symbol 'chgrp)
|
|
|
|
|
(system-groups)))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(operation (concat program " " new-attribute))
|
2016-08-06 12:44:38 +03:00
|
|
|
|
;; When file-name-coding-system is set to something different
|
|
|
|
|
;; from locale-coding-system, leaving the encoding
|
|
|
|
|
;; determination to call-process will do the wrong thing,
|
|
|
|
|
;; because the arguments in this case are file names, not
|
|
|
|
|
;; just some arbitrary text. (This must be bound last, to
|
|
|
|
|
;; avoid adverse effects on any of the preceding forms.)
|
|
|
|
|
(coding-system-for-write (or file-name-coding-system
|
|
|
|
|
default-file-name-coding-system))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
failures)
|
|
|
|
|
(setq failures
|
|
|
|
|
(dired-bunch-files 10000
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'dired-check-process
|
2002-04-17 09:54:47 +00:00
|
|
|
|
(append
|
2004-03-31 16:33:00 +00:00
|
|
|
|
(list operation program)
|
2012-09-14 02:42:39 +03:00
|
|
|
|
(unless (or (string-equal new-attribute "")
|
|
|
|
|
;; Use `eq' instead of `equal'
|
|
|
|
|
;; to detect empty input (bug#12399).
|
|
|
|
|
(eq new-attribute default))
|
2011-09-12 16:45:56 -04:00
|
|
|
|
(if (eq op-symbol 'touch)
|
|
|
|
|
(list "-t" new-attribute)
|
|
|
|
|
(list new-attribute)))
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 17:17:29 +02:00
|
|
|
|
(if (string-match-p "gnu" system-configuration)
|
1997-01-02 02:30:23 +00:00
|
|
|
|
'("--") nil))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
files))
|
|
|
|
|
(dired-do-redisplay arg);; moves point if ARG is an integer
|
|
|
|
|
(if failures
|
|
|
|
|
(dired-log-summary
|
|
|
|
|
(format "%s: error" operation)
|
|
|
|
|
nil))))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-chmod (&optional arg)
|
|
|
|
|
"Change the mode of the marked (or next ARG) files.
|
2019-10-14 16:00:05 +02:00
|
|
|
|
Both octal numeric modes like `644' and symbolic modes like `g+w'
|
|
|
|
|
are supported. Type M-n to pull the file attributes of the file
|
|
|
|
|
at point into the minibuffer.
|
|
|
|
|
|
|
|
|
|
See Info node `(coreutils)File permissions' for more information.
|
2021-09-25 10:30:27 +03:00
|
|
|
|
Alternatively, see the man page for \"chmod(1)\".
|
2019-10-14 16:00:05 +02:00
|
|
|
|
|
|
|
|
|
Note that on MS-Windows only the `w' (write) bit is meaningful:
|
|
|
|
|
resetting it makes the file read-only. Changing any other bit
|
|
|
|
|
has no effect on MS-Windows."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive "P")
|
2018-02-06 23:32:08 +02:00
|
|
|
|
(let* ((files (dired-get-marked-files t arg nil nil t))
|
2012-09-19 01:57:45 +03:00
|
|
|
|
;; The source of default file attributes is the file at point.
|
2012-09-19 23:09:55 +03:00
|
|
|
|
(default-file (dired-get-filename t t))
|
2012-09-19 01:57:45 +03:00
|
|
|
|
(modestr (when default-file
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(file-attribute-modes (file-attributes default-file))))
|
2008-07-31 17:17:35 +00:00
|
|
|
|
(default
|
|
|
|
|
(and (stringp modestr)
|
|
|
|
|
(string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr)
|
Use string-replace instead of replace-regexp-in-string
`string-replace` is easier to understand, less error-prone, much
faster, and results in shorter Lisp and byte code. Use it where
applicable and obviously safe (erring on the conservative side).
* admin/authors.el (authors-scan-change-log):
* lisp/autoinsert.el (auto-insert-alist):
* lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent)
(calc-edit-macro-combine-ext-command)
(calc-edit-macro-combine-var-name):
* lisp/calc/calc-units.el (math-make-unit-string):
* lisp/calendar/cal-html.el (cal-html-comment):
* lisp/calendar/cal-tex.el (cal-tex-comment):
* lisp/calendar/icalendar.el (icalendar--convert-string-for-export)
(icalendar--convert-string-for-import):
* lisp/calendar/iso8601.el (iso8601--concat-regexps)
(iso8601--full-time-match, iso8601--combined-match):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/todo-mode.el (todo-filter-items-filename):
* lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name)
(cedet-file-name-to-directory-name):
* lisp/comint.el (comint-watch-for-password-prompt):
* lisp/dired-aux.el (dired-do-chmod):
* lisp/dired-x.el (dired-man):
* lisp/dired.el (dired-insert-directory, dired-goto-file-1):
* lisp/emacs-lisp/comp.el (comp-c-func-name):
* lisp/emacs-lisp/re-builder.el (reb-copy):
* lisp/erc/erc-dcc.el (erc-dcc-unquote-filename):
* lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy)
(erc-update-mode-line-buffer, erc-message-english-PART):
* lisp/files.el (make-backup-file-name-1, files--transform-file-name)
(read-file-modes):
* lisp/fringe.el (fringe-mode):
* lisp/gnus/gnus-art.el (gnus-button-handle-info-url):
* lisp/gnus/gnus-group.el (gnus-group-completing-read):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-search.el (gnus-search-query-parse-date)
(gnus-search-transform-expression, gnus-search-run-search):
* lisp/gnus/gnus-start.el (gnus-dribble-enter):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-mode-string-quote):
* lisp/gnus/message.el (message-put-addresses-in-ecomplete)
(message-parse-mailto-url, message-mailto-1):
* lisp/gnus/mml-sec.el (mml-secure-epg-sign):
* lisp/gnus/mml-smime.el (mml-smime-epg-verify):
* lisp/gnus/mml2015.el (mml2015-epg-verify):
* lisp/gnus/nnmaildir.el (nnmaildir--system-name)
(nnmaildir-request-list, nnmaildir-retrieve-groups)
(nnmaildir-request-group, nnmaildir-retrieve-headers):
* lisp/gnus/nnrss.el (nnrss-node-text):
* lisp/gnus/spam-report.el (spam-report-gmane-internal)
(spam-report-user-mail-address):
* lisp/ibuffer.el (name):
* lisp/image-dired.el (image-dired-pngnq-thumb)
(image-dired-pngcrush-thumb, image-dired-optipng-thumb)
(image-dired-create-thumb-1):
* lisp/info.el (Info-set-mode-line):
* lisp/international/mule-cmds.el (describe-language-environment):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rfc2368.el (rfc2368-parse-mailto-url):
* lisp/mail/rmail.el (rmail-insert-inbox-text)
(rmail-simplified-subject-regexp):
* lisp/mail/rmailout.el (rmail-output-body-to-file):
* lisp/mail/undigest.el (rmail-digest-rfc1153):
* lisp/man.el (Man-default-man-entry):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc--debug):
* lisp/net/browse-url.el (browse-url-mail):
* lisp/net/eww.el (eww-update-header-line-format):
* lisp/net/newst-backend.el (newsticker-save-item):
* lisp/net/rcirc.el (rcirc-sentinel):
* lisp/net/soap-client.el (soap-decode-date-time):
* lisp/nxml/rng-cmpct.el (rng-c-literal-2-re):
* lisp/nxml/xmltok.el (let*):
* lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex)
(nnir-run-find-grep):
* lisp/play/dunnet.el (dun-doassign):
* lisp/play/handwrite.el (handwrite):
* lisp/proced.el (proced-format-args):
* lisp/profiler.el (profiler-report-header-line-format):
* lisp/progmodes/gdb-mi.el (gdb-mi-quote):
* lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex)
(makefile-make-font-lock-keywords):
* lisp/progmodes/prolog.el (prolog-guess-fill-prefix):
* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
* lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal):
* lisp/progmodes/which-func.el (which-func-current):
* lisp/replace.el (query-replace-read-from)
(occur-engine, replace-quote):
* lisp/select.el (xselect--encode-string):
* lisp/ses.el (ses-export-tab):
* lisp/subr.el (shell-quote-argument):
* lisp/term/pc-win.el (msdos-show-help):
* lisp/term/w32-win.el (w32--set-selection):
* lisp/term/xterm.el (gui-backend-set-selection):
* lisp/textmodes/picture.el (picture-tab-search):
* lisp/thumbs.el (thumbs-call-setroot-command):
* lisp/tooltip.el (tooltip-show-help-non-mode):
* lisp/transient.el (transient-format-key):
* lisp/url/url-mailto.el (url-mailto):
* lisp/vc/log-edit.el (log-edit-changelog-ours-p):
* lisp/vc/vc-bzr.el (vc-bzr-status):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* lisp/vc/vc-svn.el (vc-svn-after-dir-status):
* lisp/xdg.el (xdg-desktop-strings):
* test/lisp/electric-tests.el (defun):
* test/lisp/term-tests.el (term-simple-lines):
* test/lisp/time-stamp-tests.el (formatz-mod-del-colons):
* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-unfinished-edit-01):
* test/src/json-tests.el (json-parse-with-custom-null-and-false-objects):
Use `string-replace` instead of `replace-regexp-in-string`.
2021-08-08 18:58:46 +02:00
|
|
|
|
(string-replace
|
2008-07-31 17:17:35 +00:00
|
|
|
|
"-" ""
|
|
|
|
|
(format "u=%s,g=%s,o=%s"
|
|
|
|
|
(match-string 1 modestr)
|
|
|
|
|
(match-string 2 modestr)
|
|
|
|
|
(match-string 3 modestr)))))
|
2007-09-10 09:58:29 +00:00
|
|
|
|
(modes (dired-mark-read-string
|
2011-09-12 16:45:56 -04:00
|
|
|
|
"Change mode of %s to: "
|
2011-09-14 11:06:28 -04:00
|
|
|
|
nil 'chmod arg files default))
|
2011-09-12 16:45:56 -04:00
|
|
|
|
num-modes)
|
2012-09-15 01:58:43 +03:00
|
|
|
|
(cond ((or (equal modes "")
|
|
|
|
|
;; Use `eq' instead of `equal'
|
|
|
|
|
;; to detect empty input (bug#12399).
|
|
|
|
|
(eq modes default))
|
2011-09-12 16:45:56 -04:00
|
|
|
|
;; We used to treat empty input as DEFAULT, but that is not
|
|
|
|
|
;; such a good idea (Bug#9361).
|
|
|
|
|
(error "No file mode specified"))
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 17:17:29 +02:00
|
|
|
|
((string-match-p "^[0-7]+" modes)
|
2011-09-12 16:45:56 -04:00
|
|
|
|
(setq num-modes (string-to-number modes 8))))
|
|
|
|
|
|
2007-09-10 09:58:29 +00:00
|
|
|
|
(dolist (file files)
|
|
|
|
|
(set-file-modes
|
|
|
|
|
file
|
|
|
|
|
(if num-modes num-modes
|
Add 'nofollow' flag to set-file-modes etc.
This avoids some race conditions (Bug#39683). E.g., if some other
program changes a file to a symlink between the time Emacs creates
the file and the time it changes the file’s permissions, using the
new flag prevents Emacs from inadvertently changing the
permissions of a victim in some completely unrelated directory.
* admin/merge-gnulib (GNULIB_MODULES): Add fchmodat.
* doc/lispref/files.texi (Testing Accessibility, Changing Files):
* doc/lispref/os.texi (File Notifications):
* etc/NEWS:
Adjust documentation accordingly.
* lib/chmodat.c, lib/fchmodat.c, lib/lchmod.c, m4/fchmodat.m4:
* m4/lchmod.m4: New files, copied from Gnulib.
* lib/gnulib.mk.in: Regenerate.
* lisp/dired-aux.el (dired-do-chmod):
* lisp/doc-view.el (doc-view-make-safe-dir):
* lisp/emacs-lisp/autoload.el (autoload--save-buffer):
* lisp/emacs-lisp/bytecomp.el (byte-compile-file):
* lisp/eshell/em-pred.el (eshell-pred-file-mode):
* lisp/files.el (backup-buffer-copy, copy-directory):
* lisp/gnus/mail-source.el (mail-source-movemail):
* lisp/gnus/mm-decode.el (mm-display-external):
* lisp/gnus/nnmail.el (nnmail-write-region):
* lisp/net/tramp-adb.el (tramp-adb-handle-file-local-copy)
(tramp-adb-handle-write-region):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-directly):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-write-region):
* lisp/net/tramp.el (tramp-handle-write-region)
(tramp-make-tramp-temp-file):
* lisp/server.el (server-ensure-safe-dir):
* lisp/url/url-util.el (url-make-private-file):
When getting or setting file modes, avoid following symbolic links
when the file is not supposed to be a symbolic link.
* lisp/doc-view.el (doc-view-make-safe-dir):
Omit no-longer-needed separate symlink test.
* lisp/gnus/gnus-util.el (gnus-set-file-modes):
* lisp/net/tramp.el (tramp-handle-file-modes):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-set-file-modes):
* src/fileio.c (symlink_nofollow_flag): New function.
(Ffile_modes, Fset_file_modes):
Support an optional FLAG arg. All C callers changed.
* lisp/net/ange-ftp.el (ange-ftp-set-file-modes):
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-modes):
* lisp/net/tramp-sh.el (tramp-sh-handle-set-file-modes):
* lisp/net/tramp-smb.el (tramp-smb-handle-set-file-modes):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-set-file-modes):
Accept an optional FLAG arg that is currently ignored,
and add a FIXME comment for it.
* m4/gnulib-comp.m4: Regenerate.
2020-02-23 16:19:42 -08:00
|
|
|
|
(file-modes-symbolic-to-number modes (file-modes file 'nofollow)))
|
|
|
|
|
'nofollow))
|
2007-09-10 09:58:29 +00:00
|
|
|
|
(dired-do-redisplay arg)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-chgrp (&optional arg)
|
2012-09-19 01:57:45 +03:00
|
|
|
|
"Change the group of the marked (or next ARG) files.
|
|
|
|
|
Type M-n to pull the file attributes of the file at point
|
|
|
|
|
into the minibuffer."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive "P")
|
2019-07-08 14:03:17 +02:00
|
|
|
|
(if (and (memq system-type '(ms-dos windows-nt))
|
|
|
|
|
(not (file-remote-p default-directory)))
|
2001-07-15 16:15:35 +00:00
|
|
|
|
(error "chgrp not supported on this system"))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-do-chxxx "Group" "chgrp" 'chgrp arg))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-chown (&optional arg)
|
2012-09-19 01:57:45 +03:00
|
|
|
|
"Change the owner of the marked (or next ARG) files.
|
|
|
|
|
Type M-n to pull the file attributes of the file at point
|
|
|
|
|
into the minibuffer."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive "P")
|
2019-07-08 14:03:17 +02:00
|
|
|
|
(if (and (memq system-type '(ms-dos windows-nt))
|
|
|
|
|
(not (file-remote-p default-directory)))
|
2001-07-15 16:15:35 +00:00
|
|
|
|
(error "chown not supported on this system"))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-do-chxxx "Owner" dired-chown-program 'chown arg))
|
|
|
|
|
|
2004-06-09 01:04:28 +00:00
|
|
|
|
;;;###autoload
|
2004-03-31 16:33:00 +00:00
|
|
|
|
(defun dired-do-touch (&optional arg)
|
|
|
|
|
"Change the timestamp of the marked (or next ARG) files.
|
2012-09-19 01:57:45 +03:00
|
|
|
|
This calls touch.
|
|
|
|
|
Type M-n to pull the file attributes of the file at point
|
|
|
|
|
into the minibuffer."
|
2004-03-31 16:33:00 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(dired-do-chxxx "Timestamp" dired-touch-program 'touch arg))
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; Process all the files in FILES in batches of a convenient size,
|
|
|
|
|
;; by means of (FUNCALL FUNCTION ARGS... SOME-FILES...).
|
|
|
|
|
;; Batches are chosen to need less than MAX chars for the file names,
|
|
|
|
|
;; allowing 3 extra characters of separator per file name.
|
|
|
|
|
(defun dired-bunch-files (max function args files)
|
|
|
|
|
(let (pending
|
2002-09-15 01:52:08 +00:00
|
|
|
|
past
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(pending-length 0)
|
|
|
|
|
failures)
|
|
|
|
|
;; Accumulate files as long as they fit in MAX chars,
|
|
|
|
|
;; then process the ones accumulated so far.
|
|
|
|
|
(while files
|
|
|
|
|
(let* ((thisfile (car files))
|
|
|
|
|
(thislength (+ (length thisfile) 3))
|
|
|
|
|
(rest (cdr files)))
|
|
|
|
|
;; If we have at least 1 pending file
|
|
|
|
|
;; and this file won't fit in the length limit, process now.
|
|
|
|
|
(if (and pending (> (+ thislength pending-length) max))
|
2002-09-15 01:52:08 +00:00
|
|
|
|
(setq pending (nreverse pending)
|
|
|
|
|
;; The elements of PENDING are now in forward order.
|
|
|
|
|
;; Do the operation and record failures.
|
|
|
|
|
failures (nconc (apply function (append args pending))
|
|
|
|
|
failures)
|
2011-11-17 01:09:20 -08:00
|
|
|
|
;; Transfer the elements of PENDING onto PAST
|
2002-09-15 01:52:08 +00:00
|
|
|
|
;; and clear it out. Now PAST contains the first N files
|
|
|
|
|
;; specified (for some N), and FILES contains the rest.
|
|
|
|
|
past (nconc past pending)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
pending nil
|
|
|
|
|
pending-length 0))
|
|
|
|
|
;; Do (setq pending (cons thisfile pending))
|
|
|
|
|
;; but reuse the cons that was in `files'.
|
|
|
|
|
(setcdr files pending)
|
|
|
|
|
(setq pending files)
|
|
|
|
|
(setq pending-length (+ thislength pending-length))
|
|
|
|
|
(setq files rest)))
|
2002-09-15 01:52:08 +00:00
|
|
|
|
(setq pending (nreverse pending))
|
|
|
|
|
(prog1
|
|
|
|
|
(nconc (apply function (append args pending))
|
|
|
|
|
failures)
|
|
|
|
|
;; Now the original list FILES has been put back as it was.
|
|
|
|
|
(nconc past pending))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2015-05-08 20:13:47 -04:00
|
|
|
|
(defvar lpr-printer-switch)
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-print (&optional arg)
|
|
|
|
|
"Print the marked (or next ARG) files.
|
|
|
|
|
Uses the shell command coming from variables `lpr-command' and
|
|
|
|
|
`lpr-switches' as default."
|
|
|
|
|
(interactive "P")
|
2015-05-08 20:14:42 -04:00
|
|
|
|
(require 'lpr)
|
2018-02-06 23:32:08 +02:00
|
|
|
|
(let* ((file-list (dired-get-marked-files t arg nil nil t))
|
2014-01-02 17:35:00 -05:00
|
|
|
|
(lpr-switches
|
|
|
|
|
(if (and (stringp printer-name)
|
|
|
|
|
(string< "" printer-name))
|
|
|
|
|
(cons (concat lpr-printer-switch printer-name)
|
|
|
|
|
lpr-switches)
|
|
|
|
|
lpr-switches))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(command (dired-mark-read-string
|
|
|
|
|
"Print %s with: "
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(mapconcat #'identity
|
1995-03-12 18:38:20 +00:00
|
|
|
|
(cons lpr-command
|
|
|
|
|
(if (stringp lpr-switches)
|
|
|
|
|
(list lpr-switches)
|
|
|
|
|
lpr-switches))
|
|
|
|
|
" ")
|
1992-06-24 02:14:18 +00:00
|
|
|
|
'print arg file-list)))
|
|
|
|
|
(dired-run-shell-command (dired-shell-stuff-it command file-list nil))))
|
|
|
|
|
|
2011-09-12 16:45:56 -04:00
|
|
|
|
(defun dired-mark-read-string (prompt initial op-symbol arg files
|
2021-06-30 20:10:30 +02:00
|
|
|
|
&optional default-value collection)
|
2011-09-12 16:45:56 -04:00
|
|
|
|
"Read args for a Dired marked-files command, prompting with PROMPT.
|
|
|
|
|
Return the user input (a string).
|
|
|
|
|
|
|
|
|
|
INITIAL, if non-nil, is the initial minibuffer input.
|
|
|
|
|
OP-SYMBOL is an operation symbol (see `dired-no-confirm').
|
2012-06-22 15:30:33 +08:00
|
|
|
|
ARG is normally the prefix argument for the calling command;
|
|
|
|
|
it is passed as the first argument to `dired-mark-prompt'.
|
|
|
|
|
FILES should be a list of marked files' names.
|
2011-09-12 16:45:56 -04:00
|
|
|
|
|
2012-06-22 15:30:33 +08:00
|
|
|
|
Optional arg DEFAULT-VALUE is a default value or list of default
|
|
|
|
|
values, passed as the seventh arg to `completing-read'.
|
2012-04-16 21:52:00 -04:00
|
|
|
|
|
2012-06-22 15:30:33 +08:00
|
|
|
|
Optional arg COLLECTION is a collection of possible completions,
|
|
|
|
|
passed as the second arg to `completing-read'."
|
2011-09-12 16:45:56 -04:00
|
|
|
|
(dired-mark-pop-up nil op-symbol files
|
2012-04-16 21:49:40 -04:00
|
|
|
|
'completing-read
|
2011-09-12 16:45:56 -04:00
|
|
|
|
(format prompt (dired-mark-prompt arg files))
|
2012-04-16 21:49:40 -04:00
|
|
|
|
collection nil nil initial nil default-value nil))
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
;;; Cleaning a directory: flagging some backups for deletion
|
1992-07-28 19:38:08 +00:00
|
|
|
|
|
1992-08-03 03:44:51 +00:00
|
|
|
|
(defvar dired-file-version-alist)
|
|
|
|
|
|
2004-06-09 01:04:28 +00:00
|
|
|
|
;;;###autoload
|
1992-07-28 19:38:08 +00:00
|
|
|
|
(defun dired-clean-directory (keep)
|
|
|
|
|
"Flag numerical backups for deletion.
|
|
|
|
|
Spares `dired-kept-versions' latest versions, and `kept-old-versions' oldest.
|
|
|
|
|
Positive prefix arg KEEP overrides `dired-kept-versions';
|
|
|
|
|
Negative prefix arg KEEP overrides `kept-old-versions' with KEEP made positive.
|
|
|
|
|
|
|
|
|
|
To clear the flags on these files, you can use \\[dired-flag-backup-files]
|
|
|
|
|
with a prefix argument."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(setq keep (if keep (prefix-numeric-value keep) dired-kept-versions))
|
|
|
|
|
(let ((early-retention (if (< keep 0) (- keep) kept-old-versions))
|
|
|
|
|
(late-retention (if (<= keep 0) dired-kept-versions keep))
|
|
|
|
|
(dired-file-version-alist ()))
|
|
|
|
|
(message "Cleaning numerical backups (keeping %d late, %d old)..."
|
|
|
|
|
late-retention early-retention)
|
|
|
|
|
;; Look at each file.
|
|
|
|
|
;; If the file has numeric backup versions,
|
|
|
|
|
;; put on dired-file-version-alist an element of the form
|
|
|
|
|
;; (FILENAME . VERSION-NUMBER-LIST)
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-map-dired-file-lines #'dired-collect-file-versions)
|
1992-07-28 19:38:08 +00:00
|
|
|
|
;; Sort each VERSION-NUMBER-LIST,
|
|
|
|
|
;; and remove the versions not to be deleted.
|
|
|
|
|
(let ((fval dired-file-version-alist))
|
|
|
|
|
(while fval
|
|
|
|
|
(let* ((sorted-v-list (cons 'q (sort (cdr (car fval)) '<)))
|
|
|
|
|
(v-count (length sorted-v-list)))
|
|
|
|
|
(if (> v-count (+ early-retention late-retention))
|
|
|
|
|
(rplacd (nthcdr early-retention sorted-v-list)
|
|
|
|
|
(nthcdr (- v-count late-retention)
|
|
|
|
|
sorted-v-list)))
|
|
|
|
|
(rplacd (car fval)
|
|
|
|
|
(cdr sorted-v-list)))
|
|
|
|
|
(setq fval (cdr fval))))
|
|
|
|
|
;; Look at each file. If it is a numeric backup file,
|
|
|
|
|
;; find it in a VERSION-NUMBER-LIST and maybe flag it for deletion.
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-map-dired-file-lines #'dired-trample-file-versions)
|
1992-07-28 19:38:08 +00:00
|
|
|
|
(message "Cleaning numerical backups...done")))
|
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
|
|
|
|
;;; Subroutines of dired-clean-directory
|
1992-07-28 19:38:08 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-map-dired-file-lines (fun)
|
|
|
|
|
;; Perform FUN with point at the end of each non-directory line.
|
1998-08-13 23:01:05 +00:00
|
|
|
|
;; FUN takes one argument, the absolute filename.
|
1992-07-28 19:38:08 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let (file buffer-read-only)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (not (eobp))
|
|
|
|
|
(save-excursion
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 17:17:29 +02:00
|
|
|
|
(and (not (looking-at-p dired-re-dir))
|
1992-07-28 19:38:08 +00:00
|
|
|
|
(not (eolp))
|
|
|
|
|
(setq file (dired-get-filename nil t)) ; nil on non-file
|
|
|
|
|
(progn (end-of-line)
|
|
|
|
|
(funcall fun file))))
|
|
|
|
|
(forward-line 1)))))
|
|
|
|
|
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defvar backup-extract-version-start) ; used in backup-extract-version
|
|
|
|
|
|
1992-07-28 19:38:08 +00:00
|
|
|
|
(defun dired-collect-file-versions (fn)
|
1994-11-16 14:26:42 +00:00
|
|
|
|
(let ((fn (file-name-sans-versions fn)))
|
|
|
|
|
;; Only do work if this file is not already in the alist.
|
|
|
|
|
(if (assoc fn dired-file-version-alist)
|
|
|
|
|
nil
|
|
|
|
|
;; If it looks like file FN has versions, return a list of the versions.
|
|
|
|
|
;;That is a list of strings which are file names.
|
1994-12-22 04:16:36 +00:00
|
|
|
|
;;The caller may want to flag some of these files for deletion.
|
1994-11-16 14:26:42 +00:00
|
|
|
|
(let* ((base-versions
|
|
|
|
|
(concat (file-name-nondirectory fn) ".~"))
|
1997-05-10 05:43:58 +00:00
|
|
|
|
(backup-extract-version-start (length base-versions))
|
1994-11-16 14:26:42 +00:00
|
|
|
|
(possibilities (file-name-all-completions
|
|
|
|
|
base-versions
|
|
|
|
|
(file-name-directory fn)))
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(versions (mapcar #'backup-extract-version possibilities)))
|
1994-11-16 14:26:42 +00:00
|
|
|
|
(if versions
|
|
|
|
|
(setq dired-file-version-alist
|
|
|
|
|
(cons (cons fn versions)
|
|
|
|
|
dired-file-version-alist)))))))
|
1992-07-28 19:38:08 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-trample-file-versions (fn)
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 17:17:29 +02:00
|
|
|
|
(let* ((start-vn (string-match-p "\\.~[0-9]+~$" fn))
|
1992-07-28 19:38:08 +00:00
|
|
|
|
base-version-list)
|
|
|
|
|
(and start-vn
|
|
|
|
|
(setq base-version-list ; there was a base version to which
|
|
|
|
|
(assoc (substring fn 0 start-vn) ; this looks like a
|
|
|
|
|
dired-file-version-alist)) ; subversion
|
2005-05-16 11:34:49 +00:00
|
|
|
|
(not (memq (string-to-number (substring fn (+ 2 start-vn)))
|
1992-07-28 19:38:08 +00:00
|
|
|
|
base-version-list)) ; this one doesn't make the cut
|
|
|
|
|
(progn (beginning-of-line)
|
|
|
|
|
(delete-char 1)
|
|
|
|
|
(insert dired-del-marker)))))
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;; Shell commands
|
|
|
|
|
|
2008-04-22 19:51:57 +00:00
|
|
|
|
(declare-function mailcap-file-default-commands "mailcap" (files))
|
|
|
|
|
|
2018-06-12 12:24:09 +08:00
|
|
|
|
(defvar dired-aux-files)
|
|
|
|
|
|
2022-08-04 12:14:10 +02:00
|
|
|
|
(defun dired-minibuffer-default-add-shell-commands ()
|
2009-02-22 23:38:04 +00:00
|
|
|
|
"Return a list of all commands associated with current dired files.
|
|
|
|
|
This function is used to add all related commands retrieved by `mailcap'
|
2008-04-22 19:51:57 +00:00
|
|
|
|
to the end of the list of defaults just after the default value."
|
|
|
|
|
(interactive)
|
2018-06-12 12:24:09 +08:00
|
|
|
|
(let ((commands (and (boundp 'dired-aux-files)
|
|
|
|
|
(require 'mailcap nil t)
|
|
|
|
|
(mailcap-file-default-commands dired-aux-files))))
|
2008-04-22 19:51:57 +00:00
|
|
|
|
(if (listp minibuffer-default)
|
|
|
|
|
(append minibuffer-default commands)
|
|
|
|
|
(cons minibuffer-default commands))))
|
2007-11-16 01:19:13 +00:00
|
|
|
|
|
2008-04-07 18:57:28 +00:00
|
|
|
|
;; This is an extra function so that you can redefine it, e.g., to use gmhist.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-read-shell-command (prompt arg files)
|
2011-07-11 22:54:26 -04:00
|
|
|
|
"Read a dired shell command.
|
|
|
|
|
PROMPT should be a format string with one \"%s\" format sequence,
|
|
|
|
|
which is replaced by the value returned by `dired-mark-prompt',
|
|
|
|
|
with ARG and FILES as its arguments. FILES should be a list of
|
|
|
|
|
file names. The result is used as the prompt.
|
|
|
|
|
|
2022-08-16 19:52:48 +02:00
|
|
|
|
Use `dired-guess-shell-command' to offer a smarter default choice
|
|
|
|
|
of shell command."
|
2008-04-22 19:51:57 +00:00
|
|
|
|
(minibuffer-with-setup-hook
|
|
|
|
|
(lambda ()
|
2018-06-12 12:24:09 +08:00
|
|
|
|
(setq-local dired-aux-files files)
|
|
|
|
|
(setq-local minibuffer-default-add-function
|
2022-08-04 12:14:10 +02:00
|
|
|
|
#'dired-minibuffer-default-add-shell-commands))
|
2011-02-19 11:20:38 -08:00
|
|
|
|
(setq prompt (format prompt (dired-mark-prompt arg files)))
|
2022-08-16 19:52:48 +02:00
|
|
|
|
(dired-mark-pop-up nil 'shell files
|
|
|
|
|
'dired-guess-shell-command prompt files)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2022-03-22 17:48:13 +01:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defcustom dired-confirm-shell-command t
|
2022-05-24 13:17:53 +02:00
|
|
|
|
"Whether to prompt for confirmation for `dired-do-shell-command'.
|
2022-03-22 17:48:13 +01:00
|
|
|
|
If non-nil, prompt for confirmation if the command contains potentially
|
|
|
|
|
dangerous characters. If nil, never prompt for confirmation."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'dired
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
2008-07-29 16:36:42 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-async-shell-command (command &optional arg file-list)
|
|
|
|
|
"Run a shell command COMMAND on the marked files asynchronously.
|
|
|
|
|
|
2012-07-17 21:40:15 +03:00
|
|
|
|
Like `dired-do-shell-command', but adds `&' at the end of COMMAND
|
|
|
|
|
to execute it asynchronously.
|
|
|
|
|
|
|
|
|
|
When operating on multiple files, asynchronous commands
|
|
|
|
|
are executed in the background on each file in parallel.
|
|
|
|
|
In shell syntax this means separating the individual commands
|
|
|
|
|
with `&'. However, when COMMAND ends in `;' or `;&' then commands
|
|
|
|
|
are executed in the background on each file sequentially waiting
|
|
|
|
|
for each command to terminate before running the next command.
|
|
|
|
|
In shell syntax this means separating the individual commands with `;'.
|
|
|
|
|
|
2022-05-20 01:35:58 +02:00
|
|
|
|
The output appears in the buffer named by `shell-command-buffer-name-async'.
|
|
|
|
|
|
|
|
|
|
Commands that are run asynchronously do not accept user input."
|
2008-07-29 16:36:42 +00:00
|
|
|
|
(interactive
|
2018-02-06 23:32:08 +02:00
|
|
|
|
(let ((files (dired-get-marked-files t current-prefix-arg nil nil t)))
|
2008-07-29 16:36:42 +00:00
|
|
|
|
(list
|
|
|
|
|
;; Want to give feedback whether this file or marked files are used:
|
|
|
|
|
(dired-read-shell-command "& on %s: " current-prefix-arg files)
|
|
|
|
|
current-prefix-arg
|
|
|
|
|
files)))
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 17:17:29 +02:00
|
|
|
|
(unless (string-match-p "&[ \t]*\\'" command)
|
2008-07-29 16:36:42 +00:00
|
|
|
|
(setq command (concat command " &")))
|
|
|
|
|
(dired-do-shell-command command arg file-list))
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;;###autoload
|
1997-06-30 06:13:58 +00:00
|
|
|
|
(defun dired-do-shell-command (command &optional arg file-list)
|
1992-08-03 03:44:51 +00:00
|
|
|
|
"Run a shell command COMMAND on the marked files.
|
2012-07-17 21:40:15 +03:00
|
|
|
|
If no files are marked or a numeric prefix arg is given,
|
1992-08-03 03:44:51 +00:00
|
|
|
|
the next ARG files are used. Just \\[universal-argument] means the current file.
|
|
|
|
|
The prompt mentions the file(s) or the marker, as appropriate.
|
|
|
|
|
|
2002-01-12 20:14:25 +00:00
|
|
|
|
If there is a `*' in COMMAND, surrounded by whitespace, this runs
|
|
|
|
|
COMMAND just once with the entire file list substituted there.
|
1992-08-03 03:44:51 +00:00
|
|
|
|
|
2002-01-12 20:14:25 +00:00
|
|
|
|
If there is no `*', but there is a `?' in COMMAND, surrounded by
|
2017-07-02 22:09:02 +09:00
|
|
|
|
whitespace, or a `\\=`?\\=`' this runs COMMAND on each file
|
|
|
|
|
individually with the file name substituted for `?' or `\\=`?\\=`'.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2002-01-12 20:14:25 +00:00
|
|
|
|
Otherwise, this runs COMMAND on each file individually with the
|
|
|
|
|
file name added at the end of COMMAND (separated by a space).
|
1999-12-06 16:44:28 +00:00
|
|
|
|
|
2017-07-02 22:09:02 +09:00
|
|
|
|
`*' and `?' when not surrounded by whitespace nor `\\=`' have no special
|
2002-01-12 20:14:25 +00:00
|
|
|
|
significance for `dired-do-shell-command', and are passed through
|
2012-01-10 21:37:31 -05:00
|
|
|
|
normally to the shell, but you must confirm first.
|
|
|
|
|
|
|
|
|
|
If you want to use `*' as a shell wildcard with whitespace around
|
|
|
|
|
it, write `*\"\"' in place of just `*'. This is equivalent to just
|
|
|
|
|
`*' in the shell, but avoids Dired's special handling.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2012-07-17 21:40:15 +03:00
|
|
|
|
If COMMAND ends in `&', `;', or `;&', it is executed in the
|
2020-08-09 19:13:53 +03:00
|
|
|
|
background asynchronously, and the output appears in the buffer named
|
|
|
|
|
by `shell-command-buffer-name-async'. When operating on multiple files
|
|
|
|
|
and COMMAND ends in `&', the shell command is executed on each file
|
|
|
|
|
in parallel. However, when COMMAND ends in `;' or `;&', then commands
|
|
|
|
|
are executed in the background on each file sequentially waiting for
|
|
|
|
|
each command to terminate before running the next command. You can
|
|
|
|
|
also use `dired-do-async-shell-command' that automatically adds `&'.
|
2012-07-17 21:40:15 +03:00
|
|
|
|
|
|
|
|
|
Otherwise, COMMAND is executed synchronously, and the output
|
2020-08-09 19:13:53 +03:00
|
|
|
|
appears in the buffer named by `shell-command-buffer-name'.
|
2002-01-12 20:14:25 +00:00
|
|
|
|
|
|
|
|
|
This feature does not try to redisplay Dired buffers afterward, as
|
|
|
|
|
there's no telling what files COMMAND may have changed.
|
|
|
|
|
Type \\[dired-do-redisplay] to redisplay the marked files.
|
|
|
|
|
|
2009-09-24 01:37:14 +00:00
|
|
|
|
When COMMAND runs, its working directory is the top-level directory
|
|
|
|
|
of the Dired buffer, so output files usually are created there
|
|
|
|
|
instead of in a subdir.
|
1999-07-20 01:24:47 +00:00
|
|
|
|
|
|
|
|
|
In a noninteractive call (from Lisp code), you must specify
|
2006-05-20 18:19:36 +00:00
|
|
|
|
the list of file names explicitly with the FILE-LIST argument, which
|
2019-10-14 21:29:48 +02:00
|
|
|
|
can be produced by `dired-get-marked-files', for example.
|
|
|
|
|
|
2022-08-16 19:52:48 +02:00
|
|
|
|
`dired-guess-shell-alist-default' and
|
2019-10-14 21:29:48 +02:00
|
|
|
|
`dired-guess-shell-alist-user' are consulted when the user is
|
2022-03-22 17:48:13 +01:00
|
|
|
|
prompted for the shell command to use interactively.
|
|
|
|
|
|
|
|
|
|
Also see the `dired-confirm-shell-command' variable."
|
2021-06-30 20:10:30 +02:00
|
|
|
|
;; Functions dired-run-shell-command and dired-shell-stuff-it do the
|
|
|
|
|
;; actual work and can be redefined for customization.
|
1997-06-30 06:13:58 +00:00
|
|
|
|
(interactive
|
2018-02-06 23:32:08 +02:00
|
|
|
|
(let ((files (dired-get-marked-files t current-prefix-arg nil nil t)))
|
1997-06-30 06:13:58 +00:00
|
|
|
|
(list
|
|
|
|
|
;; Want to give feedback whether this file or marked files are used:
|
2012-07-17 21:40:15 +03:00
|
|
|
|
(dired-read-shell-command "! on %s: " current-prefix-arg files)
|
1997-06-30 06:13:58 +00:00
|
|
|
|
current-prefix-arg
|
|
|
|
|
files)))
|
2017-07-02 22:09:02 +09:00
|
|
|
|
(let* ((on-each (not (dired--star-or-qmark-p command "*" 'keep)))
|
|
|
|
|
(no-subst (not (dired--star-or-qmark-p command "?" 'keep)))
|
2020-09-20 14:16:19 +02:00
|
|
|
|
(confirmations nil)
|
2017-06-26 17:20:42 +09:00
|
|
|
|
;; Get confirmation for wildcards that may have been meant
|
|
|
|
|
;; to control substitution of a file name or the file name list.
|
2020-09-20 14:16:19 +02:00
|
|
|
|
(ok (cond
|
|
|
|
|
((not (or on-each no-subst))
|
|
|
|
|
(error "You can not combine `*' and `?' substitution marks"))
|
2022-03-22 17:48:13 +01:00
|
|
|
|
((not dired-confirm-shell-command)
|
|
|
|
|
t)
|
2020-09-20 14:16:19 +02:00
|
|
|
|
((setq confirmations (dired--need-confirm-positions command "*"))
|
|
|
|
|
(dired--no-subst-confirm confirmations command))
|
|
|
|
|
((setq confirmations (dired--need-confirm-positions command "?"))
|
|
|
|
|
(dired--no-subst-confirm confirmations command))
|
|
|
|
|
(t))))
|
2018-10-11 17:23:30 +09:00
|
|
|
|
(cond ((not ok) (message "Command canceled"))
|
|
|
|
|
(t
|
|
|
|
|
(if on-each
|
|
|
|
|
(dired-bunch-files (- 10000 (length command))
|
|
|
|
|
(lambda (&rest files)
|
|
|
|
|
(dired-run-shell-command
|
|
|
|
|
(dired-shell-stuff-it command files t arg)))
|
|
|
|
|
nil file-list)
|
|
|
|
|
;; execute the shell command
|
|
|
|
|
(dired-run-shell-command
|
2020-09-20 14:16:19 +02:00
|
|
|
|
(dired-shell-stuff-it command file-list nil arg)))))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;; Might use {,} for bash or csh:
|
|
|
|
|
(defvar dired-mark-prefix ""
|
|
|
|
|
"Prepended to marked files in dired shell commands.")
|
|
|
|
|
(defvar dired-mark-postfix ""
|
|
|
|
|
"Appended to marked files in dired shell commands.")
|
|
|
|
|
(defvar dired-mark-separator " "
|
|
|
|
|
"Separates marked files in dired shell commands.")
|
|
|
|
|
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun dired-shell-stuff-it (command file-list on-each &optional _raw-arg)
|
2021-06-30 20:10:30 +02:00
|
|
|
|
;; "Make up a shell command line from COMMAND and FILE-LIST.
|
|
|
|
|
;; If ON-EACH is t, COMMAND should be applied to each file, else
|
|
|
|
|
;; simply concat all files and apply COMMAND to this.
|
|
|
|
|
;; FILE-LIST's elements will be quoted for the shell."
|
|
|
|
|
;; Might be redefined for smarter things and could then use RAW-ARG
|
|
|
|
|
;; (coming from interactive P and currently ignored) to decide what to do.
|
|
|
|
|
;; Smart would be a way to access basename or extension of file names.
|
2012-07-17 21:40:15 +03:00
|
|
|
|
(let* ((in-background (string-match "[ \t]*&[ \t]*\\'" command))
|
|
|
|
|
(command (if in-background
|
|
|
|
|
(substring command 0 (match-beginning 0))
|
|
|
|
|
command))
|
|
|
|
|
(sequentially (string-match "[ \t]*;[ \t]*\\'" command))
|
|
|
|
|
(command (if sequentially
|
|
|
|
|
(substring command 0 (match-beginning 0))
|
|
|
|
|
command))
|
2016-04-08 17:45:16 +03:00
|
|
|
|
(parallel-in-background
|
|
|
|
|
(and in-background (not sequentially) (not (eq system-type 'ms-dos))))
|
|
|
|
|
(w32-shell (and (fboundp 'w32-shell-dos-semantics)
|
|
|
|
|
(w32-shell-dos-semantics)))
|
2018-01-13 17:52:04 +01:00
|
|
|
|
(file-remote (file-remote-p default-directory))
|
2016-04-08 17:45:16 +03:00
|
|
|
|
;; The way to run a command in background in Windows shells
|
|
|
|
|
;; is to use the START command. The /B switch means not to
|
|
|
|
|
;; create a new window for the command.
|
2018-01-13 17:52:04 +01:00
|
|
|
|
(cmd-prefix (if (and w32-shell (not file-remote)) "start /b " ""))
|
2016-04-08 17:45:16 +03:00
|
|
|
|
;; Windows shells don't support chaining with ";", they use
|
|
|
|
|
;; "&" instead.
|
2018-01-13 17:52:04 +01:00
|
|
|
|
(cmd-sep (if (and (or (not w32-shell) file-remote)
|
|
|
|
|
(not parallel-in-background))
|
|
|
|
|
";" "&"))
|
2012-07-17 21:40:15 +03:00
|
|
|
|
(stuff-it
|
2017-07-02 22:09:02 +09:00
|
|
|
|
(if (dired--star-or-qmark-p command nil 'keep)
|
2012-07-17 21:40:15 +03:00
|
|
|
|
(lambda (x)
|
2016-04-08 17:45:16 +03:00
|
|
|
|
(let ((retval (concat cmd-prefix command)))
|
2017-07-02 22:09:02 +09:00
|
|
|
|
(while (dired--star-or-qmark-p retval nil)
|
2012-07-17 21:40:15 +03:00
|
|
|
|
(setq retval (replace-match x t t retval 2)))
|
|
|
|
|
retval))
|
2016-04-08 17:45:16 +03:00
|
|
|
|
(lambda (x) (concat cmd-prefix command dired-mark-separator x)))))
|
2022-02-20 14:49:41 +01:00
|
|
|
|
;; If a file name starts with "-", add a "./" to avoid the command
|
|
|
|
|
;; interpreting it as a command line switch.
|
|
|
|
|
(setq file-list (mapcar (lambda (file)
|
|
|
|
|
(if (string-match "\\`-" file)
|
|
|
|
|
(concat "./" file)
|
|
|
|
|
file))
|
|
|
|
|
file-list))
|
2012-07-17 21:40:15 +03:00
|
|
|
|
(concat
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(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)
|
2022-08-29 17:15:17 +02:00
|
|
|
|
" &wait")
|
2019-03-17 13:35:20 -04:00
|
|
|
|
"")))
|
|
|
|
|
(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)))
|
2022-05-20 10:37:15 +02:00
|
|
|
|
(concat
|
|
|
|
|
(funcall stuff-it files)
|
|
|
|
|
;; Be consistent in how we treat inputs to commands -- do
|
|
|
|
|
;; the same here as in the `on-each' case.
|
|
|
|
|
(if (and in-background (not w32-shell))
|
2022-08-29 17:15:17 +02:00
|
|
|
|
" &wait"
|
2022-05-20 10:37:15 +02:00
|
|
|
|
"")))))
|
|
|
|
|
(or (and in-background "&")
|
2022-05-20 01:35:58 +02:00
|
|
|
|
""))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;; This is an extra function so that it can be redefined by ange-ftp.
|
2004-06-09 01:04:28 +00:00
|
|
|
|
;;;###autoload
|
1992-08-03 03:44:51 +00:00
|
|
|
|
(defun dired-run-shell-command (command)
|
1998-03-24 17:08:34 +00:00
|
|
|
|
(let ((handler
|
|
|
|
|
(find-file-name-handler (directory-file-name default-directory)
|
|
|
|
|
'shell-command)))
|
|
|
|
|
(if handler (apply handler 'shell-command (list command))
|
|
|
|
|
(shell-command command)))
|
1992-08-03 03:44:51 +00:00
|
|
|
|
;; Return nil for sake of nconc in dired-bunch-files.
|
|
|
|
|
nil)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-check-process (msg program &rest arguments)
|
2021-12-07 19:46:15 +02:00
|
|
|
|
"Display MSG, then run PROGRAM, and log any error messages from it.
|
|
|
|
|
ARGUMENTS should be strings to be passed to PROGRAM as command-line
|
|
|
|
|
arguments.
|
|
|
|
|
|
|
|
|
|
If PROGRAM exits successfully, display \"MSG...done\" and return nil.
|
|
|
|
|
If PROGRAM exits abnormally, save in `dired-log-buffer' the command
|
|
|
|
|
that invoked PROGRAM and the messages it emitted, and return either
|
|
|
|
|
the offending ARGUMENTS or PROGRAM if no ARGUMENTS were provided."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(let (err-buffer err (dir default-directory))
|
|
|
|
|
(message "%s..." msg)
|
|
|
|
|
(save-excursion
|
|
|
|
|
;; Get a clean buffer for error output:
|
|
|
|
|
(setq err-buffer (get-buffer-create " *dired-check-process output*"))
|
|
|
|
|
(set-buffer err-buffer)
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(setq default-directory dir ; caller's default-directory
|
2019-03-17 13:35:20 -04:00
|
|
|
|
err (not (eq 0 (apply #'process-file program nil t nil arguments))))
|
2021-11-13 15:14:02 +01:00
|
|
|
|
(dired-uncache dir)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(if err
|
|
|
|
|
(progn
|
|
|
|
|
(dired-log (concat program " " (prin1-to-string arguments) "\n"))
|
|
|
|
|
(dired-log err-buffer)
|
|
|
|
|
(or arguments program t))
|
|
|
|
|
(kill-buffer err-buffer)
|
|
|
|
|
(message "%s...done" msg)
|
|
|
|
|
nil))))
|
2015-10-16 13:57:22 +02:00
|
|
|
|
|
|
|
|
|
(defun dired-shell-command (cmd)
|
|
|
|
|
"Run CMD, and check for output.
|
2015-10-21 16:39:36 +02:00
|
|
|
|
On error, pop up the log buffer.
|
|
|
|
|
Return the result of `process-file' - zero for success."
|
|
|
|
|
(let ((out-buffer " *dired-check-process output*")
|
|
|
|
|
(dir default-directory))
|
2015-10-16 13:57:22 +02:00
|
|
|
|
(with-current-buffer (get-buffer-create out-buffer)
|
|
|
|
|
(erase-buffer)
|
2022-07-02 13:19:04 +02:00
|
|
|
|
(let ((default-directory dir) res)
|
|
|
|
|
(with-connection-local-variables
|
|
|
|
|
(setq res (process-file
|
|
|
|
|
shell-file-name
|
|
|
|
|
nil
|
|
|
|
|
t
|
|
|
|
|
nil
|
|
|
|
|
shell-command-switch
|
|
|
|
|
cmd))
|
|
|
|
|
(dired-uncache dir)
|
|
|
|
|
(unless (zerop res)
|
|
|
|
|
(pop-to-buffer out-buffer))
|
|
|
|
|
res)))))
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
2022-08-16 17:14:33 +02:00
|
|
|
|
|
|
|
|
|
;;; Guess shell command
|
|
|
|
|
|
|
|
|
|
;; * `dired-guess-shell-command' provides smarter defaults for
|
|
|
|
|
;; `dired-read-shell-command'.
|
|
|
|
|
;;
|
|
|
|
|
;; * `dired-guess-shell-command' calls `dired-guess-default' with list of
|
|
|
|
|
;; marked files.
|
|
|
|
|
;;
|
|
|
|
|
;; * Parse `dired-guess-shell-alist-user' and
|
|
|
|
|
;; `dired-guess-shell-alist-default' (in that order) for the first REGEXP
|
|
|
|
|
;; that matches the first file in the file list.
|
|
|
|
|
;;
|
|
|
|
|
;; * If the REGEXP matches all the entries of the file list then evaluate
|
|
|
|
|
;; COMMAND, which is either a string or a Lisp expression returning a
|
|
|
|
|
;; string. COMMAND may be a list of commands.
|
|
|
|
|
;;
|
|
|
|
|
;; * Return this command to `dired-guess-shell-command' which prompts user
|
|
|
|
|
;; with it. The list of commands is put into the list of default values.
|
|
|
|
|
;; If a command is used successfully then it is stored permanently in
|
|
|
|
|
;; `dired-shell-command-history'.
|
|
|
|
|
|
|
|
|
|
;; Guess what shell command to apply to a file.
|
|
|
|
|
(defvar dired-shell-command-history nil
|
|
|
|
|
"History list for commands that read dired-shell commands.")
|
|
|
|
|
|
|
|
|
|
;; Default list of shell commands.
|
|
|
|
|
|
|
|
|
|
;; NOTE: Use `gunzip -c' instead of `zcat' on `.gz' files. Some do not
|
|
|
|
|
;; install GNU zip's version of zcat.
|
|
|
|
|
|
|
|
|
|
(autoload 'Man-support-local-filenames "man")
|
|
|
|
|
(autoload 'vc-responsible-backend "vc")
|
|
|
|
|
|
|
|
|
|
(defvar dired-guess-shell-alist-default
|
|
|
|
|
(list
|
|
|
|
|
(list "\\.tar\\'"
|
|
|
|
|
'(if dired-guess-shell-gnutar
|
|
|
|
|
(concat dired-guess-shell-gnutar " xvf")
|
|
|
|
|
"tar xvf")
|
|
|
|
|
;; Extract files into a separate subdirectory
|
|
|
|
|
'(if dired-guess-shell-gnutar
|
|
|
|
|
(concat "mkdir " (file-name-sans-extension file)
|
|
|
|
|
"; " dired-guess-shell-gnutar " -C "
|
|
|
|
|
(file-name-sans-extension file) " -xvf")
|
|
|
|
|
(concat "mkdir " (file-name-sans-extension file)
|
|
|
|
|
"; tar -C " (file-name-sans-extension file) " -xvf"))
|
|
|
|
|
;; List archive contents.
|
|
|
|
|
'(if dired-guess-shell-gnutar
|
|
|
|
|
(concat dired-guess-shell-gnutar " tvf")
|
|
|
|
|
"tar tvf"))
|
|
|
|
|
|
|
|
|
|
;; REGEXPS for compressed archives must come before the .Z rule to
|
|
|
|
|
;; be recognized:
|
|
|
|
|
(list "\\.tar\\.Z\\'"
|
|
|
|
|
;; Untar it.
|
|
|
|
|
'(if dired-guess-shell-gnutar
|
|
|
|
|
(concat dired-guess-shell-gnutar " zxvf")
|
|
|
|
|
(concat "zcat * | tar xvf -"))
|
|
|
|
|
;; Optional conversion to gzip format.
|
|
|
|
|
'(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
|
|
|
|
|
" " dired-guess-shell-znew-switches))
|
|
|
|
|
|
|
|
|
|
;; gzip'ed archives
|
|
|
|
|
(list "\\.t\\(ar\\.\\)?gz\\'"
|
|
|
|
|
'(if dired-guess-shell-gnutar
|
|
|
|
|
(concat dired-guess-shell-gnutar " zxvf")
|
|
|
|
|
(concat "gunzip -qc * | tar xvf -"))
|
|
|
|
|
;; Extract files into a separate subdirectory
|
|
|
|
|
'(if dired-guess-shell-gnutar
|
|
|
|
|
(concat "mkdir " (file-name-sans-extension file)
|
|
|
|
|
"; " dired-guess-shell-gnutar " -C "
|
|
|
|
|
(file-name-sans-extension file) " -zxvf")
|
|
|
|
|
(concat "mkdir " (file-name-sans-extension file)
|
|
|
|
|
"; gunzip -qc * | tar -C "
|
|
|
|
|
(file-name-sans-extension file) " -xvf -"))
|
|
|
|
|
;; Optional decompression.
|
|
|
|
|
'(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q" ""))
|
|
|
|
|
;; List archive contents.
|
|
|
|
|
'(if dired-guess-shell-gnutar
|
|
|
|
|
(concat dired-guess-shell-gnutar " ztvf")
|
|
|
|
|
(concat "gunzip -qc * | tar tvf -")))
|
|
|
|
|
|
|
|
|
|
;; bzip2'ed archives
|
|
|
|
|
(list "\\.t\\(ar\\.bz2\\|bz\\)\\'"
|
|
|
|
|
"bunzip2 -c * | tar xvf -"
|
|
|
|
|
;; Extract files into a separate subdirectory
|
|
|
|
|
'(concat "mkdir " (file-name-sans-extension file)
|
|
|
|
|
"; bunzip2 -c * | tar -C "
|
|
|
|
|
(file-name-sans-extension file) " -xvf -")
|
|
|
|
|
;; Optional decompression.
|
|
|
|
|
"bunzip2")
|
|
|
|
|
|
|
|
|
|
;; xz'ed archives
|
|
|
|
|
(list "\\.t\\(ar\\.\\)?xz\\'"
|
|
|
|
|
"unxz -c * | tar xvf -"
|
|
|
|
|
;; Extract files into a separate subdirectory
|
|
|
|
|
'(concat "mkdir " (file-name-sans-extension file)
|
|
|
|
|
"; unxz -c * | tar -C "
|
|
|
|
|
(file-name-sans-extension file) " -xvf -")
|
|
|
|
|
;; Optional decompression.
|
|
|
|
|
"unxz")
|
|
|
|
|
|
2022-09-08 02:48:46 +02:00
|
|
|
|
;; zstandard archives
|
|
|
|
|
`(,(rx (or ".tar.zst" ".tzst") eos) "unzstd -c %i | tar -xf -")
|
|
|
|
|
`(,(rx ".zst" eos) "unzstd --rm")
|
|
|
|
|
|
2022-08-16 17:14:33 +02:00
|
|
|
|
'("\\.shar\\.Z\\'" "zcat * | unshar")
|
|
|
|
|
'("\\.shar\\.g?z\\'" "gunzip -qc * | unshar")
|
|
|
|
|
|
|
|
|
|
'("\\.e?ps\\'" "ghostview" "xloadimage" "lpr")
|
|
|
|
|
(list "\\.e?ps\\.g?z\\'" "gunzip -qc * | ghostview -"
|
|
|
|
|
;; Optional decompression.
|
|
|
|
|
'(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
|
|
|
|
|
(list "\\.e?ps\\.Z\\'" "zcat * | ghostview -"
|
|
|
|
|
;; Optional conversion to gzip format.
|
|
|
|
|
'(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
|
|
|
|
|
" " dired-guess-shell-znew-switches))
|
|
|
|
|
|
|
|
|
|
(list "\\.patch\\'"
|
|
|
|
|
'(if (eq (ignore-errors (vc-responsible-backend default-directory)) 'Git)
|
|
|
|
|
"cat * | git apply"
|
|
|
|
|
"cat * | patch"))
|
|
|
|
|
(list "\\.patch\\.g?z\\'" "gunzip -qc * | patch"
|
|
|
|
|
;; Optional decompression.
|
|
|
|
|
'(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
|
|
|
|
|
(list "\\.patch\\.Z\\'" "zcat * | patch"
|
|
|
|
|
;; Optional conversion to gzip format.
|
|
|
|
|
'(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
|
|
|
|
|
" " dired-guess-shell-znew-switches))
|
|
|
|
|
|
|
|
|
|
;; The following four extensions are useful with dired-man ("N" key)
|
|
|
|
|
;; FIXME "man ./" does not work with dired-do-shell-command,
|
|
|
|
|
;; because there seems to be no way for us to modify the filename,
|
|
|
|
|
;; only the command. Hmph. `dired-man' works though.
|
|
|
|
|
(list "\\.\\(?:[0-9]\\|man\\)\\'"
|
|
|
|
|
'(let ((loc (Man-support-local-filenames)))
|
|
|
|
|
(cond ((eq loc 'man-db) "man -l")
|
|
|
|
|
((eq loc 'man) "man ./")
|
|
|
|
|
(t
|
|
|
|
|
"cat * | tbl | nroff -man -h | col -b"))))
|
|
|
|
|
(list "\\.\\(?:[0-9]\\|man\\)\\.g?z\\'"
|
|
|
|
|
'(let ((loc (Man-support-local-filenames)))
|
|
|
|
|
(cond ((eq loc 'man-db)
|
|
|
|
|
"man -l")
|
|
|
|
|
((eq loc 'man)
|
|
|
|
|
"man ./")
|
|
|
|
|
(t "gunzip -qc * | tbl | nroff -man -h | col -b")))
|
|
|
|
|
;; Optional decompression.
|
|
|
|
|
'(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
|
|
|
|
|
(list "\\.[0-9]\\.Z\\'"
|
|
|
|
|
'(let ((loc (Man-support-local-filenames)))
|
|
|
|
|
(cond ((eq loc 'man-db) "man -l")
|
|
|
|
|
((eq loc 'man) "man ./")
|
|
|
|
|
(t "zcat * | tbl | nroff -man -h | col -b")))
|
|
|
|
|
;; Optional conversion to gzip format.
|
|
|
|
|
'(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
|
|
|
|
|
" " dired-guess-shell-znew-switches))
|
|
|
|
|
'("\\.pod\\'" "perldoc" "pod2man * | nroff -man")
|
|
|
|
|
|
|
|
|
|
'("\\.dvi\\'" "xdvi" "dvips") ; preview and printing
|
|
|
|
|
'("\\.au\\'" "play") ; play Sun audiofiles
|
|
|
|
|
'("\\.mpe?g\\'\\|\\.avi\\'" "xine -p")
|
|
|
|
|
'("\\.ogg\\'" "ogg123")
|
|
|
|
|
'("\\.mp3\\'" "mpg123")
|
|
|
|
|
'("\\.wav\\'" "play")
|
|
|
|
|
'("\\.uu\\'" "uudecode") ; for uudecoded files
|
|
|
|
|
'("\\.hqx\\'" "mcvert")
|
|
|
|
|
'("\\.sh\\'" "sh") ; execute shell scripts
|
|
|
|
|
'("\\.xbm\\'" "bitmap") ; view X11 bitmaps
|
|
|
|
|
'("\\.gp\\'" "gnuplot")
|
|
|
|
|
'("\\.p[bgpn]m\\'" "xloadimage")
|
|
|
|
|
'("\\.gif\\'" "xloadimage") ; view gif pictures
|
|
|
|
|
'("\\.tif\\'" "xloadimage")
|
|
|
|
|
'("\\.png\\'" "display") ; xloadimage 4.1 doesn't grok PNG
|
|
|
|
|
'("\\.jpe?g\\'" "xloadimage")
|
|
|
|
|
'("\\.fig\\'" "xfig") ; edit fig pictures
|
|
|
|
|
'("\\.out\\'" "xgraph") ; for plotting purposes.
|
|
|
|
|
'("\\.tex\\'" "latex" "tex")
|
|
|
|
|
'("\\.texi\\(nfo\\)?\\'" "makeinfo" "texi2dvi")
|
|
|
|
|
'("\\.pdf\\'" "xpdf")
|
|
|
|
|
'("\\.doc\\'" "antiword" "strings")
|
|
|
|
|
'("\\.rpm\\'" "rpm -qilp" "rpm -ivh")
|
|
|
|
|
'("\\.dia\\'" "dia")
|
|
|
|
|
'("\\.mgp\\'" "mgp")
|
|
|
|
|
|
|
|
|
|
;; Some other popular archivers.
|
|
|
|
|
(list "\\.zip\\'" "unzip" "unzip -l"
|
|
|
|
|
;; Extract files into a separate subdirectory
|
|
|
|
|
'(concat "unzip" (if dired-guess-shell-gzip-quiet " -q")
|
|
|
|
|
" -d " (file-name-sans-extension file)))
|
|
|
|
|
'("\\.zoo\\'" "zoo x//")
|
|
|
|
|
'("\\.lzh\\'" "lharc x")
|
|
|
|
|
'("\\.arc\\'" "arc x")
|
|
|
|
|
'("\\.shar\\'" "unshar")
|
|
|
|
|
'("\\.rar\\'" "unrar x")
|
|
|
|
|
'("\\.7z\\'" "7z x")
|
|
|
|
|
|
|
|
|
|
;; Compression.
|
|
|
|
|
(list "\\.g?z\\'" '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
|
|
|
|
|
(list "\\.dz\\'" "dictunzip")
|
|
|
|
|
(list "\\.bz2\\'" "bunzip2")
|
|
|
|
|
(list "\\.xz\\'" "unxz")
|
|
|
|
|
(list "\\.Z\\'" "uncompress"
|
|
|
|
|
;; Optional conversion to gzip format.
|
|
|
|
|
'(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
|
|
|
|
|
" " dired-guess-shell-znew-switches))
|
|
|
|
|
|
|
|
|
|
'("\\.sign?\\'" "gpg --verify"))
|
|
|
|
|
"Default alist used for shell command guessing.
|
|
|
|
|
See `dired-guess-shell-alist-user'.")
|
|
|
|
|
|
|
|
|
|
(defun dired-guess-default (files)
|
|
|
|
|
"Return a shell command, or a list of commands, appropriate for FILES.
|
|
|
|
|
See `dired-guess-shell-alist-user'."
|
|
|
|
|
(let* ((case-fold-search dired-guess-shell-case-fold-search)
|
|
|
|
|
(programs
|
|
|
|
|
(delete-dups
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (command)
|
|
|
|
|
(eval command `((file . ,(car files)))))
|
|
|
|
|
(seq-reduce
|
|
|
|
|
#'append
|
|
|
|
|
(mapcar #'cdr
|
|
|
|
|
(seq-filter (lambda (elem)
|
|
|
|
|
(seq-every-p
|
|
|
|
|
(lambda (file)
|
|
|
|
|
(string-match-p (car elem) file))
|
|
|
|
|
files))
|
|
|
|
|
(append dired-guess-shell-alist-user
|
|
|
|
|
dired-guess-shell-alist-default)))
|
|
|
|
|
nil)))))
|
|
|
|
|
(if (length= programs 1)
|
|
|
|
|
(car programs)
|
|
|
|
|
programs)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-guess-shell-command (prompt files)
|
|
|
|
|
"Ask user with PROMPT for a shell command, guessing a default from FILES."
|
|
|
|
|
(let ((default (dired-guess-default files))
|
|
|
|
|
default-list val)
|
|
|
|
|
(if (null default)
|
|
|
|
|
;; Nothing to guess
|
|
|
|
|
(read-shell-command prompt nil 'dired-shell-command-history)
|
|
|
|
|
(setq prompt (replace-regexp-in-string ": $" " " prompt))
|
|
|
|
|
(if (listp default)
|
|
|
|
|
;; More than one guess
|
|
|
|
|
(setq default-list default
|
|
|
|
|
default (car default)
|
|
|
|
|
prompt (concat
|
|
|
|
|
prompt
|
|
|
|
|
(format "{%d guesses} " (length default-list))))
|
|
|
|
|
;; Just one guess
|
|
|
|
|
(setq default-list (list default)))
|
|
|
|
|
;; Put the first guess in the prompt but not in the initial value.
|
|
|
|
|
(setq prompt (concat prompt (format "[%s]: " default)))
|
|
|
|
|
;; All guesses can be retrieved with M-n
|
|
|
|
|
(setq val (read-shell-command prompt nil
|
|
|
|
|
'dired-shell-command-history
|
|
|
|
|
default-list))
|
|
|
|
|
;; If we got a return, then return default.
|
|
|
|
|
(if (equal val "") default val))))
|
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
;;; Commands that delete or redisplay part of the dired buffer
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-kill-line (&optional arg)
|
2011-07-06 20:26:29 +02:00
|
|
|
|
"Kill the current line (not the files).
|
|
|
|
|
With a prefix argument, kill that many lines starting with the current line.
|
|
|
|
|
\(A negative argument kills backward.)"
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(setq arg (prefix-numeric-value arg))
|
|
|
|
|
(let (buffer-read-only file)
|
|
|
|
|
(while (/= 0 arg)
|
|
|
|
|
(setq file (dired-get-filename nil t))
|
|
|
|
|
(if (not file)
|
2001-07-15 16:15:35 +00:00
|
|
|
|
(error "Can only kill file lines")
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(save-excursion (and file
|
|
|
|
|
(dired-goto-subdir file)
|
|
|
|
|
(dired-kill-subdir)))
|
Replace still more end-of-line etc with line-end-position, etc.
* lisp/gnus/nnbabyl.el (nnbabyl-request-move-article, nnbabyl-delete-mail)
(nnbabyl-check-mbox): Use point-at-bol.
* lisp/cedet/semantic/lex.el (semantic-lex-ignore-comments, semantic-flex):
* lisp/cedet/semantic/grammar.el (semantic-grammar-epilogue):
* lisp/cedet/ede/speedbar.el (ede-find-nearest-file-line):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/ede/autoconf-edit.el (autoconf-delete-parameter):
Use point-at-bol and point-at-eol.
* lisp/vc/emerge.el (emerge-line-number-in-buf):
* lisp/textmodes/ispell.el (ispell-region):
* lisp/textmodes/fill.el (current-fill-column):
* lisp/progmodes/xscheme.el (xscheme-send-current-line):
* lisp/progmodes/vhdl-mode.el (vhdl-current-line, vhdl-line-copy):
* lisp/progmodes/tcl.el (tcl-hairy-scan-for-comment):
* lisp/progmodes/sh-script.el (sh-handle-prev-do):
* lisp/progmodes/meta-mode.el (meta-indent-line):
* lisp/progmodes/idlwave.el (idlwave-goto-comment, idlwave-fill-paragraph)
(idlwave-in-quote):
* lisp/progmodes/idlw-shell.el (idlwave-shell-current-frame)
(idlwave-shell-update-bp-overlays, idlwave-shell-sources-filter):
* lisp/progmodes/fortran.el (fortran-looking-at-if-then):
* lisp/progmodes/etags.el (find-tag-in-order, etags-snarf-tag):
* lisp/progmodes/cperl-mode.el (cperl-sniff-for-indent)
(cperl-find-pods-heres):
* lisp/progmodes/ada-mode.el (ada-get-current-indent, ada-narrow-to-defun):
* lisp/net/quickurl.el (quickurl-list-insert):
* lisp/net/ldap.el (ldap-search-internal):
* lisp/net/eudc.el (eudc-expand-inline):
* lisp/mail/sendmail.el (sendmail-send-it):
* lisp/mail/mspools.el (mspools-visit-spool, mspools-get-spool-name):
* lisp/emulation/viper-cmd.el (viper-paren-match, viper-backward-indent)
(viper-brac-function):
* lisp/calc/calc-yank.el (calc-do-grab-region):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/term.el (term-move-columns, term-insert-spaces):
* lisp/speedbar.el (speedbar-highlight-one-tag-line):
* lisp/simple.el (current-word):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* lisp/info.el (Info-find-node-in-buffer-1, Info-follow-reference)
(Info-scroll-down):
* lisp/hippie-exp.el (he-line-beg):
* lisp/epa.el (epa--marked-keys):
* lisp/dired-aux.el (dired-kill-line, dired-do-kill-lines)
(dired-update-file-line, dired-add-entry, dired-remove-entry)
(dired-relist-entry):
* lisp/buff-menu.el (Buffer-menu-buffer):
* lisp/array.el (current-line):
* lisp/allout.el (allout-resolve-xref)
(allout-latex-verbatim-quote-curr-line):
Replace yet more uses of end-of-line etc with line-end-position.
2010-11-08 21:33:07 -08:00
|
|
|
|
(delete-region (line-beginning-position)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(progn (forward-line 1) (point)))
|
|
|
|
|
(if (> arg 0)
|
|
|
|
|
(setq arg (1- arg))
|
|
|
|
|
(setq arg (1+ arg))
|
|
|
|
|
(forward-line -1))))
|
|
|
|
|
(dired-move-to-filename)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2022-06-20 01:49:24 +02:00
|
|
|
|
(defun dired-do-kill-lines (&optional arg fmt init-count)
|
|
|
|
|
"Remove all marked lines, or the next ARG lines.
|
|
|
|
|
The files or directories on those lines are _not_ deleted. Only the
|
|
|
|
|
Dired listing is affected. To restore the removals, use `\\[revert-buffer]'.
|
2020-08-05 11:27:54 +02:00
|
|
|
|
|
2022-06-20 01:49:24 +02:00
|
|
|
|
With a numeric prefix arg, remove that many lines going forward,
|
|
|
|
|
starting with the current line. (A negative prefix arg removes lines
|
|
|
|
|
going backward.)
|
2020-08-05 11:27:54 +02:00
|
|
|
|
|
2022-06-20 01:49:24 +02:00
|
|
|
|
If you use a prefix arg to remove the line for a subdir whose listing
|
|
|
|
|
you have inserted into the Dired buffer, then that subdir listing is
|
|
|
|
|
also removed.
|
2020-08-05 11:27:54 +02:00
|
|
|
|
|
2022-06-20 01:49:24 +02:00
|
|
|
|
To remove a subdir listing _without_ removing the subdir's line in its
|
|
|
|
|
parent listing, go to the header line of the subdir listing and use
|
|
|
|
|
this command with any prefix arg.
|
2021-03-02 08:07:59 +01:00
|
|
|
|
|
2022-06-20 01:49:24 +02:00
|
|
|
|
When called from Lisp, non-nil INIT-COUNT is added to the number of
|
|
|
|
|
lines removed by this invocation, for the reporting message.
|
2021-03-02 08:07:59 +01:00
|
|
|
|
|
2022-06-20 01:49:24 +02:00
|
|
|
|
A FMT of \"\" will suppress the messaging."
|
|
|
|
|
;; Returns count of killed lines.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive "P")
|
1992-08-03 03:44:51 +00:00
|
|
|
|
(if arg
|
|
|
|
|
(if (dired-get-subdir)
|
2022-06-20 01:49:24 +02:00
|
|
|
|
(dired-kill-subdir)
|
|
|
|
|
(dired-kill-line arg))
|
1992-08-03 03:44:51 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
2022-06-20 01:49:24 +02:00
|
|
|
|
(let ((count (or init-count 0))
|
|
|
|
|
(regexp (dired-marker-regexp))
|
|
|
|
|
(inhibit-read-only t))
|
|
|
|
|
(while (and (not (eobp))
|
|
|
|
|
(re-search-forward regexp nil t))
|
|
|
|
|
(setq count (1+ count))
|
|
|
|
|
(delete-region (line-beginning-position)
|
|
|
|
|
(progn (forward-line 1) (point))))
|
|
|
|
|
(unless (equal "" fmt)
|
|
|
|
|
(message (or fmt "Killed %d line%s.") count (dired-plural-s count)))
|
|
|
|
|
count))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
;;; Compression
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-compress ()
|
|
|
|
|
;; Compress or uncompress the current file.
|
|
|
|
|
;; Return nil for success, offending filename else.
|
|
|
|
|
(let* (buffer-read-only
|
1992-09-13 06:01:19 +00:00
|
|
|
|
(from-file (dired-get-filename))
|
|
|
|
|
(new-file (dired-compress-file from-file)))
|
|
|
|
|
(if new-file
|
1993-08-08 05:00:25 +00:00
|
|
|
|
(let ((start (point)))
|
|
|
|
|
;; Remove any preexisting entry for the name NEW-FILE.
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 17:17:29 +02:00
|
|
|
|
(ignore-errors (dired-remove-entry new-file))
|
1993-08-08 05:00:25 +00:00
|
|
|
|
(goto-char start)
|
|
|
|
|
;; Now replace the current line with an entry for NEW-FILE.
|
2020-01-08 18:21:53 +02:00
|
|
|
|
;; But don't remove the current line if either FROM-FILE or
|
|
|
|
|
;; NEW-FILE is a directory, because compressing/uncompressing
|
|
|
|
|
;; directories doesn't remove the original.
|
|
|
|
|
(if (or (file-directory-p from-file)
|
|
|
|
|
(file-directory-p new-file))
|
|
|
|
|
(dired-add-entry new-file nil t)
|
|
|
|
|
(dired-update-file-line new-file))
|
|
|
|
|
nil)
|
2019-07-26 10:34:02 +02:00
|
|
|
|
(dired-log (concat "Failed to (un)compress " from-file))
|
1992-09-13 06:01:19 +00:00
|
|
|
|
from-file)))
|
|
|
|
|
|
1996-03-03 06:10:06 +00:00
|
|
|
|
(defvar dired-compress-file-suffixes
|
2015-10-21 16:39:36 +02:00
|
|
|
|
'(
|
2015-10-22 12:05:59 +02:00
|
|
|
|
;; "tar -zxf" isn't used because it's not available on the
|
2020-08-05 17:36:50 -07:00
|
|
|
|
;; Solaris 10 version of tar (obsolete in 2024?).
|
|
|
|
|
;; Same thing on AIX 7.1 (obsolete 2023?) and 7.2 (obsolete 2022?).
|
2021-09-21 19:05:15 +02:00
|
|
|
|
("\\.tar\\.gz\\'" "" "gzip -dc %i | tar -xf -")
|
|
|
|
|
("\\.tar\\.xz\\'" "" "xz -dc %i | tar -xf -")
|
|
|
|
|
("\\.tgz\\'" "" "gzip -dc %i | tar -xf -")
|
2021-09-01 09:37:12 +02:00
|
|
|
|
("\\.gz\\'" "" "gzip -d")
|
2019-08-23 05:31:17 +02:00
|
|
|
|
("\\.lz\\'" "" "lzip -d")
|
1996-03-03 06:10:06 +00:00
|
|
|
|
("\\.Z\\'" "" "uncompress")
|
|
|
|
|
;; For .z, try gunzip. It might be an old gzip file,
|
|
|
|
|
;; or it might be from compact? pack? (which?) but gunzip handles both.
|
2021-09-01 09:37:12 +02:00
|
|
|
|
("\\.z\\'" "" "gzip -d")
|
2004-03-23 07:39:35 +00:00
|
|
|
|
("\\.dz\\'" "" "dictunzip")
|
|
|
|
|
("\\.tbz\\'" ".tar" "bunzip2")
|
1998-08-27 15:21:25 +00:00
|
|
|
|
("\\.bz2\\'" "" "bunzip2")
|
2009-11-19 07:42:20 +00:00
|
|
|
|
("\\.xz\\'" "" "unxz")
|
2015-10-16 13:57:22 +02:00
|
|
|
|
("\\.zip\\'" "" "unzip -o -d %o %i")
|
2021-09-21 19:05:15 +02:00
|
|
|
|
("\\.tar\\.zst\\'" "" "unzstd -c %i | tar -xf -")
|
|
|
|
|
("\\.tzst\\'" "" "unzstd -c %i | tar -xf -")
|
2019-06-24 15:56:32 +02:00
|
|
|
|
("\\.zst\\'" "" "unzstd --rm")
|
2016-03-29 15:59:35 +02:00
|
|
|
|
("\\.7z\\'" "" "7z x -aoa -o%o %i")
|
1996-03-03 06:10:06 +00:00
|
|
|
|
;; This item controls naming for compression.
|
2021-05-17 18:03:55 +02:00
|
|
|
|
("\\.tar\\'" ".tgz" nil))
|
1996-03-03 06:10:06 +00:00
|
|
|
|
"Control changes in file name suffixes for compression and uncompression.
|
|
|
|
|
Each element specifies one transformation rule, and has the form:
|
2015-10-16 13:57:22 +02:00
|
|
|
|
(REGEXP NEW-SUFFIX PROGRAM)
|
1996-03-03 06:10:06 +00:00
|
|
|
|
The rule applies when the old file name matches REGEXP.
|
|
|
|
|
The new file name is computed by deleting the part that matches REGEXP
|
|
|
|
|
(as well as anything after that), then adding NEW-SUFFIX in its place.
|
|
|
|
|
If PROGRAM is non-nil, the rule is an uncompression rule,
|
|
|
|
|
and uncompression is done by running PROGRAM.
|
2015-10-16 13:57:22 +02:00
|
|
|
|
|
|
|
|
|
Within PROGRAM, %i denotes the input file, and %o denotes the
|
|
|
|
|
output file.
|
|
|
|
|
|
2015-10-13 15:39:12 +02:00
|
|
|
|
Otherwise, the rule is a compression rule, and compression is done with gzip.
|
|
|
|
|
ARGS are command switches passed to PROGRAM.")
|
1996-03-03 06:10:06 +00:00
|
|
|
|
|
2021-05-17 18:03:55 +02:00
|
|
|
|
(defcustom dired-compress-file-default-suffix nil
|
|
|
|
|
"Default suffix for compressing a single file.
|
|
|
|
|
If nil, \".gz\" will be used."
|
2021-05-19 08:28:35 -07:00
|
|
|
|
:type '(choice (const :tag ".gz" nil) string)
|
2021-05-17 18:03:55 +02:00
|
|
|
|
:group 'dired
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defvar dired-compress-file-alist
|
|
|
|
|
'(("\\.gz\\'" . "gzip -9f %i")
|
|
|
|
|
("\\.bz2\\'" . "bzip2 -9f %i")
|
|
|
|
|
("\\.xz\\'" . "xz -9f %i")
|
|
|
|
|
("\\.zst\\'" . "zstd -qf -19 --rm -o %o %i"))
|
|
|
|
|
"Controls the compression shell command for `dired-do-compress-to'.
|
|
|
|
|
|
|
|
|
|
Each element is (REGEXP . CMD), where REGEXP is the name of the
|
|
|
|
|
archive to which you want to compress, and CMD is the
|
|
|
|
|
corresponding command.
|
|
|
|
|
|
|
|
|
|
Within CMD, %i denotes the input file(s), and %o denotes the
|
|
|
|
|
output file. %i path(s) are relative, while %o is absolute.")
|
|
|
|
|
|
|
|
|
|
(defcustom dired-compress-directory-default-suffix nil
|
|
|
|
|
"Default suffix for compressing a directory.
|
|
|
|
|
If nil, \".tar.gz\" will be used."
|
2021-05-19 08:28:35 -07:00
|
|
|
|
:type '(choice (const :tag ".tar.gz" nil) string)
|
2021-05-17 18:03:55 +02:00
|
|
|
|
:group 'dired
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
2015-10-21 16:39:36 +02:00
|
|
|
|
(defvar dired-compress-files-alist
|
2017-11-01 02:33:59 +03:00
|
|
|
|
'(("\\.tar\\.gz\\'" . "tar -cf - %i | gzip -c9 > %o")
|
|
|
|
|
("\\.tar\\.bz2\\'" . "tar -cf - %i | bzip2 -c9 > %o")
|
|
|
|
|
("\\.tar\\.xz\\'" . "tar -cf - %i | xz -c9 > %o")
|
2019-06-24 15:56:32 +02:00
|
|
|
|
("\\.tar\\.zst\\'" . "tar -cf - %i | zstd -19 -o %o")
|
2021-01-24 00:34:44 +01:00
|
|
|
|
("\\.tar\\.lz\\'" . "tar -cf - %i | lzip -c9 > %o")
|
|
|
|
|
("\\.tar\\.lzo\\'" . "tar -cf - %i | lzop -c9 > %o")
|
2021-01-21 17:08:28 +01:00
|
|
|
|
("\\.zip\\'" . "zip %o -r --filesync %i")
|
|
|
|
|
("\\.pax\\'" . "pax -wf %o %i"))
|
2021-05-17 18:03:55 +02:00
|
|
|
|
"Controls the compression shell command for `dired-do-compress-to'.
|
2015-10-21 16:39:36 +02:00
|
|
|
|
|
|
|
|
|
Each element is (REGEXP . CMD), where REGEXP is the name of the
|
2017-11-22 17:52:11 -05:00
|
|
|
|
archive to which you want to compress, and CMD is the
|
2015-10-21 16:39:36 +02:00
|
|
|
|
corresponding command.
|
|
|
|
|
|
|
|
|
|
Within CMD, %i denotes the input file(s), and %o denotes the
|
2021-01-24 00:53:38 +01:00
|
|
|
|
output file. %i path(s) are relative, while %o is absolute.")
|
2015-10-21 16:39:36 +02:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-compress-to ()
|
|
|
|
|
"Compress selected files and directories to an archive.
|
2016-09-23 11:08:34 +03:00
|
|
|
|
Prompt for the archive file name.
|
|
|
|
|
Choose the archiving command based on the archive file-name extension
|
|
|
|
|
and `dired-compress-files-alist'."
|
2015-10-21 16:39:36 +02:00
|
|
|
|
(interactive)
|
2018-02-06 23:32:08 +02:00
|
|
|
|
(let* ((in-files (dired-get-marked-files nil nil nil nil t))
|
2016-09-23 11:08:34 +03:00
|
|
|
|
(out-file (expand-file-name (read-file-name "Compress to: ")))
|
2015-10-21 16:39:36 +02:00
|
|
|
|
(rule (cl-find-if
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(string-match (car x) out-file))
|
|
|
|
|
dired-compress-files-alist)))
|
|
|
|
|
(cond ((not rule)
|
|
|
|
|
(error
|
|
|
|
|
"No compression rule found for %s, see `dired-compress-files-alist'"
|
|
|
|
|
out-file))
|
|
|
|
|
((and (file-exists-p out-file)
|
|
|
|
|
(not (y-or-n-p
|
|
|
|
|
(format "%s exists, overwrite?"
|
|
|
|
|
(abbreviate-file-name out-file)))))
|
|
|
|
|
(message "Compression aborted"))
|
|
|
|
|
(t
|
|
|
|
|
(when (zerop
|
|
|
|
|
(dired-shell-command
|
2016-10-29 21:18:31 -04:00
|
|
|
|
(format-spec (cdr rule)
|
2022-05-06 17:33:41 +02:00
|
|
|
|
`((?o . ,(shell-quote-argument
|
|
|
|
|
(file-local-name out-file)))
|
Fix and extend format-spec (bug#41758)
* lisp/format-spec.el: Use lexical-binding. Remove dependence on
subr-x.el.
(format-spec-make): Clarify docstring.
(format-spec--parse-modifiers): Rename to...
(format-spec--parse-flags): ...this and simplify. In particular,
don't bother parsing :space-pad which is redundant and unused.
(format-spec--pad): Remove, replacing with...
(format-spec--do-flags): ...this new helper function which performs
more of format-spec's supported text manipulation.
(format-spec): Autoload. Allow optional argument to take on special
values 'ignore' and 'delete' for more control over what happens when
a replacement for a format specification isn't provided. Bring back
proper support for a precision modifier similar to that of 'format'.
* lisp/battery.el (battery-format): Rewrite in terms of format-spec.
(battery-echo-area-format, battery-mode-line-format): Mention
support of format-spec syntax in docstrings.
* doc/lispref/strings.texi (Custom Format Strings):
* etc/NEWS: Document and announce these changes.
* lisp/dired-aux.el (dired-do-compress-to):
* lisp/erc/erc-match.el (erc-log-matches):
* lisp/erc/erc.el (erc-update-mode-line-buffer):
* lisp/gnus/gnus-sieve.el (gnus-sieve-update):
* lisp/gnus/gssapi.el (open-gssapi-stream):
* lisp/gnus/mail-source.el (mail-source-fetch-file)
(mail-source-fetch-directory, mail-source-fetch-pop)
(mail-source-fetch-imap):
* lisp/gnus/message.el (message-insert-formatted-citation-line):
* lisp/image-dired.el:
* lisp/net/eww.el:
* lisp/net/imap.el (imap-kerberos4-open, imap-gssapi-open)
(imap-shell-open):
* lisp/net/network-stream.el (network-stream-open-shell):
* lisp/obsolete/tls.el (open-tls-stream):
* lisp/textmodes/tex-mode.el:
Remove extraneous loads and autoloads of format-spec now that it is
autoloaded and simplify its uses where possible.
* test/lisp/battery-tests.el (battery-format): Test new format-spec
support.
* test/lisp/format-spec-tests.el (test-format-spec): Rename to...
(format-spec) ...this, extending test cases.
(test-format-unknown): Rename to...
(format-spec-unknown): ...this, extending test cases.
(test-format-modifiers): Rename to...
(format-spec-flags): ...this.
(format-spec-make, format-spec-parse-flags, format-spec-do-flags)
(format-spec-do-flags-truncate, format-spec-do-flags-pad)
(format-spec-do-flags-chop, format-spec-do-flags-case): New tests.
2020-05-29 19:56:14 +01:00
|
|
|
|
(?i . ,(mapconcat
|
|
|
|
|
(lambda (in-file)
|
|
|
|
|
(shell-quote-argument
|
2021-09-21 19:13:35 +02:00
|
|
|
|
(file-relative-name in-file)))
|
Fix and extend format-spec (bug#41758)
* lisp/format-spec.el: Use lexical-binding. Remove dependence on
subr-x.el.
(format-spec-make): Clarify docstring.
(format-spec--parse-modifiers): Rename to...
(format-spec--parse-flags): ...this and simplify. In particular,
don't bother parsing :space-pad which is redundant and unused.
(format-spec--pad): Remove, replacing with...
(format-spec--do-flags): ...this new helper function which performs
more of format-spec's supported text manipulation.
(format-spec): Autoload. Allow optional argument to take on special
values 'ignore' and 'delete' for more control over what happens when
a replacement for a format specification isn't provided. Bring back
proper support for a precision modifier similar to that of 'format'.
* lisp/battery.el (battery-format): Rewrite in terms of format-spec.
(battery-echo-area-format, battery-mode-line-format): Mention
support of format-spec syntax in docstrings.
* doc/lispref/strings.texi (Custom Format Strings):
* etc/NEWS: Document and announce these changes.
* lisp/dired-aux.el (dired-do-compress-to):
* lisp/erc/erc-match.el (erc-log-matches):
* lisp/erc/erc.el (erc-update-mode-line-buffer):
* lisp/gnus/gnus-sieve.el (gnus-sieve-update):
* lisp/gnus/gssapi.el (open-gssapi-stream):
* lisp/gnus/mail-source.el (mail-source-fetch-file)
(mail-source-fetch-directory, mail-source-fetch-pop)
(mail-source-fetch-imap):
* lisp/gnus/message.el (message-insert-formatted-citation-line):
* lisp/image-dired.el:
* lisp/net/eww.el:
* lisp/net/imap.el (imap-kerberos4-open, imap-gssapi-open)
(imap-shell-open):
* lisp/net/network-stream.el (network-stream-open-shell):
* lisp/obsolete/tls.el (open-tls-stream):
* lisp/textmodes/tex-mode.el:
Remove extraneous loads and autoloads of format-spec now that it is
autoloaded and simplify its uses where possible.
* test/lisp/battery-tests.el (battery-format): Test new format-spec
support.
* test/lisp/format-spec-tests.el (test-format-spec): Rename to...
(format-spec) ...this, extending test cases.
(test-format-unknown): Rename to...
(format-spec-unknown): ...this, extending test cases.
(test-format-modifiers): Rename to...
(format-spec-flags): ...this.
(format-spec-make, format-spec-parse-flags, format-spec-do-flags)
(format-spec-do-flags-truncate, format-spec-do-flags-pad)
(format-spec-do-flags-chop, format-spec-do-flags-case): New tests.
2020-05-29 19:56:14 +01:00
|
|
|
|
in-files " "))))))
|
2019-05-05 22:43:27 +03:00
|
|
|
|
(message (ngettext "Compressed %d file to %s"
|
|
|
|
|
"Compressed %d files to %s"
|
|
|
|
|
(length in-files))
|
2015-10-21 16:39:36 +02:00
|
|
|
|
(length in-files)
|
|
|
|
|
(file-name-nondirectory out-file)))))))
|
|
|
|
|
|
1993-12-23 03:34:57 +00:00
|
|
|
|
;;;###autoload
|
1992-09-13 06:01:19 +00:00
|
|
|
|
(defun dired-compress-file (file)
|
2015-10-13 14:07:10 +02:00
|
|
|
|
"Compress or uncompress FILE.
|
|
|
|
|
Return the name of the compressed or uncompressed file.
|
|
|
|
|
Return nil if no change in files."
|
1996-03-03 06:10:06 +00:00
|
|
|
|
(let ((handler (find-file-name-handler file 'dired-compress-file))
|
2015-10-13 14:07:10 +02:00
|
|
|
|
suffix newname
|
2015-10-16 13:57:22 +02:00
|
|
|
|
(suffixes dired-compress-file-suffixes)
|
|
|
|
|
command)
|
1996-03-03 06:10:06 +00:00
|
|
|
|
;; See if any suffix rule matches this file name.
|
|
|
|
|
(while suffixes
|
|
|
|
|
(let (case-fold-search)
|
2015-10-13 14:07:10 +02:00
|
|
|
|
(if (string-match (car (car suffixes)) file)
|
|
|
|
|
(setq suffix (car suffixes) suffixes nil))
|
|
|
|
|
(setq suffixes (cdr suffixes))))
|
1996-03-03 06:10:06 +00:00
|
|
|
|
;; If so, compute desired new name.
|
2002-04-17 09:54:47 +00:00
|
|
|
|
(if suffix
|
2015-10-13 14:07:10 +02:00
|
|
|
|
(setq newname (concat (substring file 0 (match-beginning 0))
|
|
|
|
|
(nth 1 suffix))))
|
1992-09-13 06:01:19 +00:00
|
|
|
|
(cond (handler
|
2015-10-13 14:07:10 +02:00
|
|
|
|
(funcall handler 'dired-compress-file file))
|
|
|
|
|
((file-symlink-p file)
|
|
|
|
|
nil)
|
2015-10-16 13:57:22 +02:00
|
|
|
|
((and suffix (setq command (nth 2 suffix)))
|
2021-09-21 19:05:15 +02:00
|
|
|
|
(if (string-match "%[io]" command)
|
|
|
|
|
(prog1 (setq newname (file-name-as-directory newname))
|
|
|
|
|
(dired-shell-command
|
|
|
|
|
(replace-regexp-in-string
|
2021-11-13 15:14:02 +01:00
|
|
|
|
"%o" (shell-quote-argument (file-local-name newname))
|
2021-09-21 19:05:15 +02:00
|
|
|
|
(replace-regexp-in-string
|
2021-11-13 15:14:02 +01:00
|
|
|
|
"%i" (shell-quote-argument (file-local-name file))
|
2021-09-21 19:05:15 +02:00
|
|
|
|
command
|
|
|
|
|
nil t)
|
|
|
|
|
nil t)))
|
|
|
|
|
;; We found an uncompression rule.
|
|
|
|
|
(let ((match (string-search " " command))
|
|
|
|
|
(msg (concat "Uncompressing " file)))
|
|
|
|
|
(unless (if match
|
|
|
|
|
(dired-check-process msg
|
|
|
|
|
(substring command 0 match)
|
|
|
|
|
(substring command (1+ match))
|
2021-11-13 15:14:02 +01:00
|
|
|
|
(file-local-name file))
|
2021-09-21 19:05:15 +02:00
|
|
|
|
(dired-check-process msg
|
|
|
|
|
command
|
2021-11-13 15:14:02 +01:00
|
|
|
|
(file-local-name file)))
|
2021-09-21 19:05:15 +02:00
|
|
|
|
newname))))
|
2015-10-13 14:07:10 +02:00
|
|
|
|
(t
|
|
|
|
|
;; We don't recognize the file as compressed, so compress it.
|
|
|
|
|
;; Try gzip; if we don't have that, use compress.
|
|
|
|
|
(condition-case nil
|
2015-10-16 16:44:20 +02:00
|
|
|
|
(if (file-directory-p file)
|
2021-05-17 18:03:55 +02:00
|
|
|
|
(let* ((suffix
|
|
|
|
|
(or dired-compress-directory-default-suffix
|
|
|
|
|
".tar.gz"))
|
|
|
|
|
(rule (cl-find-if
|
|
|
|
|
(lambda (x) (string-match-p (car x) suffix))
|
|
|
|
|
dired-compress-files-alist)))
|
|
|
|
|
(if rule
|
|
|
|
|
(let ((out-name (concat file suffix))
|
|
|
|
|
(default-directory (file-name-directory file)))
|
|
|
|
|
(dired-shell-command
|
|
|
|
|
(replace-regexp-in-string
|
2021-11-13 15:14:02 +01:00
|
|
|
|
"%o" (shell-quote-argument
|
|
|
|
|
(file-local-name out-name))
|
2021-05-17 18:03:55 +02:00
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"%i" (shell-quote-argument
|
|
|
|
|
(file-name-nondirectory file))
|
|
|
|
|
(cdr rule)
|
|
|
|
|
nil t)
|
|
|
|
|
nil t))
|
|
|
|
|
out-name)
|
|
|
|
|
(user-error
|
|
|
|
|
"No compression rule found for \
|
|
|
|
|
`dired-compress-directory-default-suffix' %s, see `dired-compress-files-alist' for\
|
2021-09-22 20:26:40 +02:00
|
|
|
|
the supported suffixes list"
|
2021-05-17 18:03:55 +02:00
|
|
|
|
dired-compress-directory-default-suffix)))
|
|
|
|
|
(let* ((suffix (or dired-compress-file-default-suffix ".gz"))
|
|
|
|
|
(out-name (concat file suffix))
|
|
|
|
|
(rule (cl-find-if
|
|
|
|
|
(lambda (x) (string-match-p (car x) suffix))
|
|
|
|
|
dired-compress-file-alist)))
|
|
|
|
|
(if (not rule)
|
|
|
|
|
(user-error "No compression rule found for suffix %s, \
|
2021-09-22 20:26:40 +02:00
|
|
|
|
see `dired-compress-file-alist' for the supported suffixes list"
|
2021-05-17 18:03:55 +02:00
|
|
|
|
dired-compress-file-default-suffix)
|
2021-05-18 17:49:05 +02:00
|
|
|
|
(and (file-exists-p file)
|
|
|
|
|
(or (not (file-exists-p out-name))
|
2021-05-17 18:03:55 +02:00
|
|
|
|
(y-or-n-p
|
|
|
|
|
(format
|
|
|
|
|
"File %s already exists. Really compress? "
|
|
|
|
|
out-name)))
|
|
|
|
|
(dired-shell-command
|
2015-10-16 16:44:20 +02:00
|
|
|
|
(replace-regexp-in-string
|
2021-11-13 15:14:02 +01:00
|
|
|
|
"%o" (shell-quote-argument
|
|
|
|
|
(file-local-name out-name))
|
2021-05-17 18:03:55 +02:00
|
|
|
|
(replace-regexp-in-string
|
2021-11-13 15:14:02 +01:00
|
|
|
|
"%i" (shell-quote-argument (file-local-name file))
|
2021-05-17 18:03:55 +02:00
|
|
|
|
(cdr rule)
|
|
|
|
|
nil t)
|
|
|
|
|
nil t))
|
|
|
|
|
(or (file-exists-p out-name)
|
|
|
|
|
(setq out-name (concat file ".z")))
|
|
|
|
|
;; Rename the compressed file to NEWNAME
|
|
|
|
|
;; if it hasn't got that name already.
|
|
|
|
|
(if (and newname (not (equal newname out-name)))
|
|
|
|
|
(progn
|
|
|
|
|
(rename-file out-name newname t)
|
|
|
|
|
newname)
|
|
|
|
|
out-name)))))
|
2015-10-13 14:07:10 +02:00
|
|
|
|
(file-error
|
|
|
|
|
(if (not (dired-check-process (concat "Compressing " file)
|
2021-11-13 15:14:02 +01:00
|
|
|
|
"compress" "-f"
|
|
|
|
|
(file-local-name file)))
|
2015-10-13 14:07:10 +02:00
|
|
|
|
;; Don't use NEWNAME with `compress'.
|
|
|
|
|
(concat file ".Z"))))))))
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-mark-confirm (op-symbol arg)
|
|
|
|
|
;; Request confirmation from the user that the operation described
|
|
|
|
|
;; by OP-SYMBOL is to be performed on the marked files.
|
|
|
|
|
;; Confirmation consists in a y-or-n question with a file list
|
|
|
|
|
;; pop-up unless OP-SYMBOL is a member of `dired-no-confirm'.
|
|
|
|
|
;; The files used are determined by ARG (as in dired-get-marked-files).
|
1997-03-20 12:39:57 +00:00
|
|
|
|
(or (eq dired-no-confirm t)
|
|
|
|
|
(memq op-symbol dired-no-confirm)
|
2005-05-15 21:34:47 +00:00
|
|
|
|
;; Pass t for DISTINGUISH-ONE-MARKED so that a single file which
|
|
|
|
|
;; is marked pops up a window. That will help the user see
|
|
|
|
|
;; it isn't the current line file.
|
2018-02-06 23:32:08 +02:00
|
|
|
|
(let ((files (dired-get-marked-files t arg nil t t))
|
1992-11-03 09:25:26 +00:00
|
|
|
|
(string (if (eq op-symbol 'compress) "Compress or uncompress"
|
|
|
|
|
(capitalize (symbol-name op-symbol)))))
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-mark-pop-up nil op-symbol files #'y-or-n-p
|
1992-11-03 09:25:26 +00:00
|
|
|
|
(concat string " "
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-mark-prompt arg files) "? ")))))
|
|
|
|
|
|
|
|
|
|
(defun dired-map-over-marks-check (fun arg op-symbol &optional show-progress)
|
2021-06-30 20:10:30 +02:00
|
|
|
|
;; "Map FUN over marked files (with second ARG like in dired-map-over-marks)
|
|
|
|
|
;; and display failures.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2021-06-30 20:10:30 +02:00
|
|
|
|
;; FUN takes zero args. It returns non-nil (the offending object, e.g.
|
|
|
|
|
;; the short form of the filename) for a failure and probably logs a
|
|
|
|
|
;; detailed error explanation using function `dired-log'.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2021-06-30 20:10:30 +02:00
|
|
|
|
;; OP-SYMBOL is a symbol describing the operation performed (e.g.
|
|
|
|
|
;; `compress'). It is used with `dired-mark-pop-up' to prompt the user
|
|
|
|
|
;; (e.g. with `Compress * [2 files]? ') and to display errors (e.g.
|
|
|
|
|
;; `Failed to compress 1 of 2 files - type W to see why ("foo")')
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2021-06-30 20:10:30 +02:00
|
|
|
|
;; SHOW-PROGRESS if non-nil means redisplay dired after each file."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(if (dired-mark-confirm op-symbol arg)
|
|
|
|
|
(let* ((total-list;; all of FUN's return values
|
|
|
|
|
(dired-map-over-marks (funcall fun) arg show-progress))
|
|
|
|
|
(total (length total-list))
|
|
|
|
|
(failures (delq nil total-list))
|
1992-11-03 09:25:26 +00:00
|
|
|
|
(count (length failures))
|
|
|
|
|
(string (if (eq op-symbol 'compress) "Compress or uncompress"
|
|
|
|
|
(capitalize (symbol-name op-symbol)))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(if (not failures)
|
2019-05-05 22:43:27 +03:00
|
|
|
|
(message (ngettext "%s: %d file." "%s: %d files." total)
|
|
|
|
|
string total)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; end this bunch of errors:
|
|
|
|
|
(dired-log-summary
|
2019-05-05 22:43:27 +03:00
|
|
|
|
(format (ngettext "Failed to %s %d of %d file"
|
|
|
|
|
"Failed to %s %d of %d files"
|
|
|
|
|
total)
|
|
|
|
|
(downcase string) count total)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
failures)))))
|
|
|
|
|
|
2004-06-09 01:04:28 +00:00
|
|
|
|
;;;###autoload
|
2011-01-08 14:17:23 -05:00
|
|
|
|
(defun dired-query (sym prompt &rest args)
|
|
|
|
|
"Format PROMPT with ARGS, query user, and store the result in SYM.
|
|
|
|
|
The return value is either nil or t.
|
|
|
|
|
|
|
|
|
|
The user may type y or SPC to accept once; n or DEL to skip once;
|
|
|
|
|
! to accept this and subsequent queries; or q or ESC to decline
|
|
|
|
|
this and subsequent queries.
|
|
|
|
|
|
|
|
|
|
If SYM is already bound to a non-nil value, this function may
|
|
|
|
|
return automatically without querying the user. If SYM is !,
|
|
|
|
|
return t; if SYM is q or ESC, return nil."
|
|
|
|
|
(let* ((char (symbol-value sym))
|
|
|
|
|
(char-choices '(?y ?\s ?n ?\177 ?! ?q ?\e)))
|
|
|
|
|
(cond ((eq char ?!)
|
|
|
|
|
t) ; accept, and don't ask again
|
|
|
|
|
((memq char '(?q ?\e))
|
|
|
|
|
nil) ; skip, and don't ask again
|
|
|
|
|
(t ; no previous answer - ask now
|
|
|
|
|
(setq prompt
|
More-conservative ‘format’ quote restyling
Instead of restyling curved quotes for every call to ‘format’,
create a new function ‘format-message’ that does the restyling,
and using the new function instead of ‘format’ only in contexts
where this seems appropriate.
Problem reported by Dmitry Gutov and Andreas Schwab in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html
* doc/lispref/commands.texi (Using Interactive):
* doc/lispref/control.texi (Signaling Errors, Signaling Errors):
* doc/lispref/display.texi (Displaying Messages, Progress):
* doc/lispref/elisp.texi:
* doc/lispref/help.texi (Keys in Documentation):
* doc/lispref/minibuf.texi (Minibuffer Misc):
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Document the changes.
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/apropos.el (apropos-library):
* lisp/calc/calc-ext.el (calc-record-message)
(calc-user-function-list):
* lisp/calc/calc-help.el (calc-describe-key, calc-full-help):
* lisp/calc/calc-lang.el (math-read-big-balance):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--add-diary-entry):
* lisp/cedet/mode-local.el (mode-local-print-binding)
(mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-completion-message):
* lisp/cedet/semantic/edit.el (semantic-parse-changes-failed):
* lisp/cedet/semantic/wisent/comp.el (wisent-log):
* lisp/cedet/srecode/insert.el (srecode-insert-show-error-report):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dframe.el (dframe-message):
* lisp/dired-aux.el (dired-query):
* lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1):
* lisp/emacs-lisp/bytecomp.el (byte-compile-log)
(byte-compile-log-file, byte-compile-warn, byte-compile-form):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv-analyze-form):
* lisp/emacs-lisp/check-declare.el (check-declare-warn):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet):
* lisp/emacs-lisp/edebug.el (edebug-format):
* lisp/emacs-lisp/eieio-core.el (eieio-oref):
* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message)
(eldoc-message):
* lisp/emacs-lisp/elint.el (elint-file, elint-log):
* lisp/emacs-lisp/find-func.el (find-function-library):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring):
* lisp/emacs-lisp/package.el (package-compute-transaction)
(package-install-button-action, package-delete-button-action)
(package-menu--list-to-prompt):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emacs-lisp/warnings.el (lwarn, warn):
* lisp/emulation/viper-cmd.el:
(viper-toggle-parse-sexp-ignore-comments)
(viper-kill-buffer, viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/facemenu.el (facemenu-add-new-face):
* lisp/faces.el (face-documentation, read-face-name)
(face-read-string, read-face-font, describe-face):
* lisp/files.el (find-alternate-file, hack-local-variables)
(hack-one-local-variable--obsolete, write-file)
(basic-save-buffer, delete-directory):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--obsolete)
(help-fns--interactive-only, describe-function-1)
(describe-variable):
* lisp/help.el (describe-mode):
* lisp/info-xref.el (info-xref-output):
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
* lisp/international/kkc.el (kkc-error):
* lisp/international/mule-cmds.el:
(select-safe-coding-system-interactively)
(select-safe-coding-system, describe-input-method):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/international/quail.el (quail-error):
* lisp/minibuffer.el (minibuffer-message):
* lisp/mpc.el (mpc--debug):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-message):
* lisp/net/gnutls.el (gnutls-message-maybe):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/nsm.el (nsm-query-user):
* lisp/net/rlogin.el (rlogin):
* lisp/net/soap-client.el (soap-warning):
* lisp/net/tramp.el (tramp-debug-message):
* lisp/nxml/nxml-outln.el (nxml-report-outline-error):
* lisp/nxml/nxml-parse.el (nxml-parse-error):
* lisp/nxml/rng-cmpct.el (rng-c-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/org/org-ctags.el:
(org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/proced.el (proced-log):
* lisp/progmodes/ebnf2ps.el (ebnf-log):
* lisp/progmodes/flymake.el (flymake-log):
* lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle):
* lisp/replace.el (occur-1):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, define-alternatives):
* lisp/startup.el (command-line):
* lisp/subr.el (error, user-error, add-to-list):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* src/callint.c (Fcall_interactively):
* src/editfns.c (Fmessage, Fmessage_box):
Restyle the quotes of format strings intended for use as a
diagnostic, when restyling seems appropriate.
* lisp/subr.el (format-message): New function.
* src/doc.c (Finternal__text_restyle): New function.
(syms_of_doc): Define it.
2015-08-23 22:38:02 -07:00
|
|
|
|
(concat (apply #'format-message prompt args)
|
2011-01-08 14:17:23 -05:00
|
|
|
|
(if help-form
|
|
|
|
|
(format " [Type yn!q or %s] "
|
2011-12-02 09:18:18 -05:00
|
|
|
|
(key-description (vector help-char)))
|
2011-01-08 14:17:23 -05:00
|
|
|
|
" [Type y, n, q or !] ")))
|
2020-12-30 11:54:01 +02:00
|
|
|
|
(set sym (setq char (read-char-choice prompt char-choices)))
|
2011-01-08 14:17:23 -05:00
|
|
|
|
(if (memq char '(?y ?\s ?!)) t)))))
|
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-compress (&optional arg)
|
2018-11-22 21:05:14 +02:00
|
|
|
|
"Compress or uncompress marked (or next ARG) files.
|
|
|
|
|
If invoked on a directory, compress all of the files in
|
|
|
|
|
the directory and all of its subdirectories, recursively,
|
|
|
|
|
into a .tar.gz archive.
|
|
|
|
|
If invoked on a .tar.gz or a .tgz or a .zip or a .7z archive,
|
|
|
|
|
uncompress and unpack all the files in the archive."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive "P")
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-map-over-marks-check #'dired-compress arg 'compress t))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
|
|
|
|
;;; Commands for Emacs Lisp files - load and byte compile
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-byte-compile ()
|
|
|
|
|
;; Return nil for success, offending file name else.
|
|
|
|
|
(let* ((filename (dired-get-filename))
|
1994-07-13 05:10:06 +00:00
|
|
|
|
elc-file buffer-read-only failure)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(condition-case err
|
|
|
|
|
(save-excursion (byte-compile-file filename))
|
|
|
|
|
(error
|
|
|
|
|
(setq failure err)))
|
1994-07-13 05:10:06 +00:00
|
|
|
|
(setq elc-file (byte-compile-dest-file filename))
|
1995-08-29 16:22:25 +00:00
|
|
|
|
(or (file-exists-p elc-file)
|
|
|
|
|
(setq failure t))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(if failure
|
|
|
|
|
(progn
|
|
|
|
|
(dired-log "Byte compile error for %s:\n%s\n" filename failure)
|
|
|
|
|
(dired-make-relative filename))
|
|
|
|
|
(dired-remove-file elc-file)
|
|
|
|
|
(forward-line) ; insert .elc after its .el file
|
|
|
|
|
(dired-add-file elc-file)
|
|
|
|
|
nil)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-byte-compile (&optional arg)
|
|
|
|
|
"Byte compile marked (or next ARG) Emacs Lisp files."
|
|
|
|
|
(interactive "P")
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-map-over-marks-check #'dired-byte-compile arg 'byte-compile t))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-load ()
|
|
|
|
|
;; Return nil for success, offending file name else.
|
|
|
|
|
(let ((file (dired-get-filename)) failure)
|
|
|
|
|
(condition-case err
|
2021-06-30 20:10:30 +02:00
|
|
|
|
(load file nil nil t)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(error (setq failure err)))
|
|
|
|
|
(if (not failure)
|
|
|
|
|
nil
|
|
|
|
|
(dired-log "Load error for %s:\n%s\n" file failure)
|
|
|
|
|
(dired-make-relative file))))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-load (&optional arg)
|
|
|
|
|
"Load the marked (or next ARG) Emacs Lisp files."
|
|
|
|
|
(interactive "P")
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-map-over-marks-check #'dired-load arg 'load t))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-redisplay (&optional arg test-for-subdir)
|
|
|
|
|
"Redisplay all marked (or next ARG) files.
|
|
|
|
|
If on a subdir line, redisplay that subdirectory. In that case,
|
2004-06-07 21:24:31 +00:00
|
|
|
|
a prefix arg lets you edit the `ls' switches used for the new listing.
|
|
|
|
|
|
|
|
|
|
Dired remembers switches specified with a prefix arg, so that reverting
|
|
|
|
|
the buffer will not reset them. However, using `dired-undo' to re-insert
|
|
|
|
|
or delete subdirectories can bypass this machinery. Hence, you sometimes
|
|
|
|
|
may have to reset some subdirectory switches after a `dired-undo'.
|
|
|
|
|
You can reset all subdirectory switches to the default using
|
2004-06-15 22:09:18 +00:00
|
|
|
|
\\<dired-mode-map>\\[dired-reset-subdir-switches].
|
2006-05-06 14:37:40 +00:00
|
|
|
|
See Info node `(emacs)Subdir switches' for more details."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; Moves point if the next ARG files are redisplayed.
|
|
|
|
|
(interactive "P\np")
|
|
|
|
|
(if (and test-for-subdir (dired-get-subdir))
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(let* ((dir (dired-get-subdir))
|
|
|
|
|
(switches (cdr (assoc-string dir dired-switches-alist))))
|
|
|
|
|
(dired-insert-subdir
|
|
|
|
|
dir
|
|
|
|
|
(when arg
|
|
|
|
|
(read-string "Switches for listing: "
|
|
|
|
|
(or switches
|
|
|
|
|
dired-subdir-switches
|
|
|
|
|
dired-actual-switches)))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(message "Redisplaying...")
|
|
|
|
|
;; message much faster than making dired-map-over-marks show progress
|
1995-06-20 15:31:30 +00:00
|
|
|
|
(dired-uncache
|
|
|
|
|
(if (consp dired-directory) (car dired-directory) dired-directory))
|
2017-04-16 23:36:26 -07:00
|
|
|
|
(dired-map-over-marks (let ((fname (dired-get-filename nil t))
|
2011-07-05 11:51:56 +02:00
|
|
|
|
;; Postpone readin hook till we map
|
2010-12-06 14:55:21 -05:00
|
|
|
|
;; over all marked files (Bug#6810).
|
|
|
|
|
(dired-after-readin-hook nil))
|
2017-04-16 23:36:26 -07:00
|
|
|
|
(if (not fname)
|
|
|
|
|
(error "No file on this line")
|
|
|
|
|
(message "Redisplaying... %s" fname)
|
|
|
|
|
(dired-update-file-line fname)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
arg)
|
2010-12-06 14:55:21 -05:00
|
|
|
|
(run-hooks 'dired-after-readin-hook)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-move-to-filename)
|
|
|
|
|
(message "Redisplaying...done")))
|
2004-06-07 21:24:31 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-reset-subdir-switches ()
|
|
|
|
|
"Set `dired-switches-alist' to nil and revert dired buffer."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq dired-switches-alist nil)
|
|
|
|
|
(revert-buffer))
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-update-file-line (file)
|
|
|
|
|
;; Delete the current line, and insert an entry for FILE.
|
|
|
|
|
;; If FILE is nil, then just delete the current line.
|
|
|
|
|
;; Keeps any marks that may be present in column one (doing this
|
|
|
|
|
;; here is faster than with dired-add-entry's optional arg).
|
|
|
|
|
;; Does not update other dired buffers. Use dired-relist-entry for that.
|
2011-02-27 17:31:20 -08:00
|
|
|
|
(let* ((opoint (line-beginning-position))
|
2015-10-16 13:57:22 +02:00
|
|
|
|
(char (char-after opoint))
|
|
|
|
|
(buffer-read-only))
|
Replace still more end-of-line etc with line-end-position, etc.
* lisp/gnus/nnbabyl.el (nnbabyl-request-move-article, nnbabyl-delete-mail)
(nnbabyl-check-mbox): Use point-at-bol.
* lisp/cedet/semantic/lex.el (semantic-lex-ignore-comments, semantic-flex):
* lisp/cedet/semantic/grammar.el (semantic-grammar-epilogue):
* lisp/cedet/ede/speedbar.el (ede-find-nearest-file-line):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/ede/autoconf-edit.el (autoconf-delete-parameter):
Use point-at-bol and point-at-eol.
* lisp/vc/emerge.el (emerge-line-number-in-buf):
* lisp/textmodes/ispell.el (ispell-region):
* lisp/textmodes/fill.el (current-fill-column):
* lisp/progmodes/xscheme.el (xscheme-send-current-line):
* lisp/progmodes/vhdl-mode.el (vhdl-current-line, vhdl-line-copy):
* lisp/progmodes/tcl.el (tcl-hairy-scan-for-comment):
* lisp/progmodes/sh-script.el (sh-handle-prev-do):
* lisp/progmodes/meta-mode.el (meta-indent-line):
* lisp/progmodes/idlwave.el (idlwave-goto-comment, idlwave-fill-paragraph)
(idlwave-in-quote):
* lisp/progmodes/idlw-shell.el (idlwave-shell-current-frame)
(idlwave-shell-update-bp-overlays, idlwave-shell-sources-filter):
* lisp/progmodes/fortran.el (fortran-looking-at-if-then):
* lisp/progmodes/etags.el (find-tag-in-order, etags-snarf-tag):
* lisp/progmodes/cperl-mode.el (cperl-sniff-for-indent)
(cperl-find-pods-heres):
* lisp/progmodes/ada-mode.el (ada-get-current-indent, ada-narrow-to-defun):
* lisp/net/quickurl.el (quickurl-list-insert):
* lisp/net/ldap.el (ldap-search-internal):
* lisp/net/eudc.el (eudc-expand-inline):
* lisp/mail/sendmail.el (sendmail-send-it):
* lisp/mail/mspools.el (mspools-visit-spool, mspools-get-spool-name):
* lisp/emulation/viper-cmd.el (viper-paren-match, viper-backward-indent)
(viper-brac-function):
* lisp/calc/calc-yank.el (calc-do-grab-region):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/term.el (term-move-columns, term-insert-spaces):
* lisp/speedbar.el (speedbar-highlight-one-tag-line):
* lisp/simple.el (current-word):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* lisp/info.el (Info-find-node-in-buffer-1, Info-follow-reference)
(Info-scroll-down):
* lisp/hippie-exp.el (he-line-beg):
* lisp/epa.el (epa--marked-keys):
* lisp/dired-aux.el (dired-kill-line, dired-do-kill-lines)
(dired-update-file-line, dired-add-entry, dired-remove-entry)
(dired-relist-entry):
* lisp/buff-menu.el (Buffer-menu-buffer):
* lisp/array.el (current-line):
* lisp/allout.el (allout-resolve-xref)
(allout-latex-verbatim-quote-curr-line):
Replace yet more uses of end-of-line etc with line-end-position.
2010-11-08 21:33:07 -08:00
|
|
|
|
(delete-region opoint (progn (forward-line 1) (point)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(if file
|
2015-10-16 13:57:22 +02:00
|
|
|
|
(progn
|
|
|
|
|
(dired-add-entry file nil t)
|
|
|
|
|
;; Replace space by old marker without moving point.
|
|
|
|
|
;; Faster than goto+insdel inside a save-excursion?
|
|
|
|
|
(when char
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(subst-char-in-region opoint (1+ opoint) ?\s char)))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-move-to-filename))
|
|
|
|
|
|
1993-12-23 03:34:57 +00:00
|
|
|
|
;;;###autoload
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-add-file (filename &optional marker-char)
|
|
|
|
|
(dired-fun-in-all-buffers
|
1997-03-22 03:39:39 +00:00
|
|
|
|
(file-name-directory filename) (file-name-nondirectory filename)
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'dired-add-entry filename marker-char))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2011-02-18 19:53:35 -08:00
|
|
|
|
(defvar dired-omit-mode)
|
|
|
|
|
(declare-function dired-omit-regexp "dired-x" ())
|
|
|
|
|
(defvar dired-omit-localp)
|
|
|
|
|
|
1997-06-23 06:34:29 +00:00
|
|
|
|
(defun dired-add-entry (filename &optional marker-char relative)
|
2011-02-18 19:53:35 -08:00
|
|
|
|
"Add a new dired entry for FILENAME.
|
|
|
|
|
Optionally mark it with MARKER-CHAR (a character, else uses
|
|
|
|
|
`dired-marker-char'). Note that this adds the entry `out of order'
|
|
|
|
|
if files are sorted by time, etc.
|
|
|
|
|
Skips files that match `dired-trivial-filenames'.
|
|
|
|
|
Exposes hidden subdirectories if a file is added there.
|
|
|
|
|
|
|
|
|
|
If `dired-x' is loaded and `dired-omit-mode' is enabled, skips
|
|
|
|
|
files matching `dired-omit-regexp'."
|
|
|
|
|
(if (or (not (featurep 'dired-x))
|
|
|
|
|
(not dired-omit-mode)
|
|
|
|
|
;; Avoid calling ls for files that are going to be omitted anyway.
|
|
|
|
|
(let ((omit-re (dired-omit-regexp)))
|
|
|
|
|
(or (string= omit-re "")
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 17:17:29 +02:00
|
|
|
|
(not (string-match-p omit-re
|
|
|
|
|
(cond
|
|
|
|
|
((eq 'no-dir dired-omit-localp)
|
|
|
|
|
filename)
|
|
|
|
|
((eq t dired-omit-localp)
|
|
|
|
|
(dired-make-relative filename))
|
|
|
|
|
(t
|
|
|
|
|
(dired-make-absolute
|
|
|
|
|
filename
|
|
|
|
|
(file-name-directory filename)))))))))
|
2011-02-18 19:53:35 -08:00
|
|
|
|
;; Do it!
|
|
|
|
|
(progn
|
|
|
|
|
(setq filename (directory-file-name filename))
|
|
|
|
|
;; Entry is always for files, even if they happen to also be directories
|
|
|
|
|
(let* ((opoint (point))
|
|
|
|
|
(cur-dir (dired-current-directory))
|
|
|
|
|
(directory (if relative cur-dir (file-name-directory filename)))
|
|
|
|
|
reason)
|
|
|
|
|
(setq filename
|
|
|
|
|
(if relative
|
|
|
|
|
(file-relative-name filename directory)
|
|
|
|
|
(file-name-nondirectory filename))
|
|
|
|
|
reason
|
|
|
|
|
(catch 'not-found
|
|
|
|
|
(if (string= directory cur-dir)
|
|
|
|
|
(progn
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(end-of-line)
|
|
|
|
|
(if (dired--hidden-p)
|
2011-02-18 19:53:35 -08:00
|
|
|
|
(dired-unhide-subdir))
|
|
|
|
|
;; We are already where we should be, except when
|
|
|
|
|
;; point is before the subdir line or its total line.
|
|
|
|
|
(let ((p (dired-after-subdir-garbage cur-dir)))
|
|
|
|
|
(if (< (point) p)
|
|
|
|
|
(goto-char p))))
|
|
|
|
|
;; else try to find correct place to insert
|
|
|
|
|
(if (dired-goto-subdir directory)
|
|
|
|
|
(progn ;; unhide if necessary
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(if (dired--hidden-p)
|
2011-02-18 19:53:35 -08:00
|
|
|
|
;; Point is at end of subdir line.
|
|
|
|
|
(dired-unhide-subdir))
|
|
|
|
|
;; found - skip subdir and `total' line
|
|
|
|
|
;; and uninteresting files like . and ..
|
|
|
|
|
;; This better not move into the next subdir!
|
|
|
|
|
(dired-goto-next-nontrivial-file))
|
|
|
|
|
;; not found
|
|
|
|
|
(throw 'not-found "Subdir not found")))
|
|
|
|
|
(let (buffer-read-only opoint)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq opoint (point))
|
|
|
|
|
;; Don't expand `.'.
|
|
|
|
|
;; Show just the file name within directory.
|
|
|
|
|
(let ((default-directory directory))
|
|
|
|
|
(dired-insert-directory
|
|
|
|
|
directory
|
|
|
|
|
(concat dired-actual-switches " -d")
|
|
|
|
|
(list filename)))
|
|
|
|
|
(goto-char opoint)
|
|
|
|
|
;; Put in desired marker char.
|
|
|
|
|
(when marker-char
|
|
|
|
|
(let ((dired-marker-char
|
|
|
|
|
(if (integerp marker-char) marker-char
|
|
|
|
|
dired-marker-char)))
|
|
|
|
|
(dired-mark nil)))
|
|
|
|
|
;; Compensate for a bug in ange-ftp.
|
|
|
|
|
;; It inserts the file's absolute name, rather than
|
|
|
|
|
;; the relative one. That may be hard to fix since it
|
|
|
|
|
;; is probably controlled by something in ftp.
|
|
|
|
|
(goto-char opoint)
|
|
|
|
|
(let ((inserted-name (dired-get-filename 'verbatim)))
|
|
|
|
|
(if (file-name-directory inserted-name)
|
|
|
|
|
(let (props)
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(forward-char (- (length inserted-name)))
|
|
|
|
|
(setq props (text-properties-at (point)))
|
|
|
|
|
(delete-char (length inserted-name))
|
|
|
|
|
(let ((pt (point)))
|
|
|
|
|
(insert filename)
|
|
|
|
|
(set-text-properties pt (point) props))
|
|
|
|
|
(forward-char 1))
|
|
|
|
|
(forward-line 1)))
|
|
|
|
|
(forward-line -1)
|
|
|
|
|
(if dired-after-readin-hook
|
|
|
|
|
;; The subdir-alist is not affected...
|
|
|
|
|
(save-excursion ; ...so we can run it right now:
|
|
|
|
|
(save-restriction
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(narrow-to-region (point)
|
|
|
|
|
(line-beginning-position 2))
|
|
|
|
|
(run-hooks 'dired-after-readin-hook))))
|
|
|
|
|
(dired-move-to-filename))
|
|
|
|
|
;; return nil if all went well
|
|
|
|
|
nil))
|
|
|
|
|
(if reason ; don't move away on failure
|
|
|
|
|
(goto-char opoint))
|
|
|
|
|
(not reason))) ; return t on success, nil else
|
|
|
|
|
;; Don't do it (dired-omit-mode).
|
|
|
|
|
;; Return t for success (perhaps we should return file-exists-p).
|
|
|
|
|
t))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-after-subdir-garbage (dir)
|
|
|
|
|
;; Return pos of first file line of DIR, skipping header and total
|
|
|
|
|
;; or wildcard lines.
|
|
|
|
|
;; Important: never moves into the next subdir.
|
|
|
|
|
;; DIR is assumed to be unhidden.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(or (dired-goto-subdir dir) (error "This cannot happen"))
|
|
|
|
|
(forward-line 1)
|
|
|
|
|
(while (and (not (eolp)) ; don't cross subdir boundary
|
|
|
|
|
(not (dired-move-to-filename)))
|
2021-06-30 20:10:30 +02:00
|
|
|
|
(forward-line 1))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(point)))
|
|
|
|
|
|
1993-12-23 03:34:57 +00:00
|
|
|
|
;;;###autoload
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-remove-file (file)
|
2020-09-04 06:09:23 +02:00
|
|
|
|
"Remove entry FILE on each dired buffer.
|
|
|
|
|
Note this doesn't delete FILE in the file system.
|
|
|
|
|
See `dired-delete-file' in case you wish that."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-fun-in-all-buffers
|
1997-03-22 03:39:39 +00:00
|
|
|
|
(file-name-directory file) (file-name-nondirectory file)
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'dired-remove-entry file))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
1993-12-23 03:34:57 +00:00
|
|
|
|
;;;###autoload
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-relist-file (file)
|
2002-09-15 01:52:08 +00:00
|
|
|
|
"Create or update the line for FILE in all Dired buffers it would belong in."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-fun-in-all-buffers (file-name-directory file)
|
1997-03-22 03:39:39 +00:00
|
|
|
|
(file-name-nondirectory file)
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'dired-relist-entry file))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-relist-entry (file)
|
|
|
|
|
;; Relist the line for FILE, or just add it if it did not exist.
|
1998-08-13 23:01:05 +00:00
|
|
|
|
;; FILE must be an absolute file name.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(let (buffer-read-only marker)
|
|
|
|
|
;; If cursor is already on FILE's line delete-region will cause
|
|
|
|
|
;; save-excursion to fail because of floating makers,
|
|
|
|
|
;; moving point to beginning of line. Sigh.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(and (dired-goto-file file)
|
|
|
|
|
(delete-region (progn (beginning-of-line)
|
|
|
|
|
(setq marker (following-char))
|
|
|
|
|
(point))
|
Replace still more end-of-line etc with line-end-position, etc.
* lisp/gnus/nnbabyl.el (nnbabyl-request-move-article, nnbabyl-delete-mail)
(nnbabyl-check-mbox): Use point-at-bol.
* lisp/cedet/semantic/lex.el (semantic-lex-ignore-comments, semantic-flex):
* lisp/cedet/semantic/grammar.el (semantic-grammar-epilogue):
* lisp/cedet/ede/speedbar.el (ede-find-nearest-file-line):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/ede/autoconf-edit.el (autoconf-delete-parameter):
Use point-at-bol and point-at-eol.
* lisp/vc/emerge.el (emerge-line-number-in-buf):
* lisp/textmodes/ispell.el (ispell-region):
* lisp/textmodes/fill.el (current-fill-column):
* lisp/progmodes/xscheme.el (xscheme-send-current-line):
* lisp/progmodes/vhdl-mode.el (vhdl-current-line, vhdl-line-copy):
* lisp/progmodes/tcl.el (tcl-hairy-scan-for-comment):
* lisp/progmodes/sh-script.el (sh-handle-prev-do):
* lisp/progmodes/meta-mode.el (meta-indent-line):
* lisp/progmodes/idlwave.el (idlwave-goto-comment, idlwave-fill-paragraph)
(idlwave-in-quote):
* lisp/progmodes/idlw-shell.el (idlwave-shell-current-frame)
(idlwave-shell-update-bp-overlays, idlwave-shell-sources-filter):
* lisp/progmodes/fortran.el (fortran-looking-at-if-then):
* lisp/progmodes/etags.el (find-tag-in-order, etags-snarf-tag):
* lisp/progmodes/cperl-mode.el (cperl-sniff-for-indent)
(cperl-find-pods-heres):
* lisp/progmodes/ada-mode.el (ada-get-current-indent, ada-narrow-to-defun):
* lisp/net/quickurl.el (quickurl-list-insert):
* lisp/net/ldap.el (ldap-search-internal):
* lisp/net/eudc.el (eudc-expand-inline):
* lisp/mail/sendmail.el (sendmail-send-it):
* lisp/mail/mspools.el (mspools-visit-spool, mspools-get-spool-name):
* lisp/emulation/viper-cmd.el (viper-paren-match, viper-backward-indent)
(viper-brac-function):
* lisp/calc/calc-yank.el (calc-do-grab-region):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/term.el (term-move-columns, term-insert-spaces):
* lisp/speedbar.el (speedbar-highlight-one-tag-line):
* lisp/simple.el (current-word):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* lisp/info.el (Info-find-node-in-buffer-1, Info-follow-reference)
(Info-scroll-down):
* lisp/hippie-exp.el (he-line-beg):
* lisp/epa.el (epa--marked-keys):
* lisp/dired-aux.el (dired-kill-line, dired-do-kill-lines)
(dired-update-file-line, dired-add-entry, dired-remove-entry)
(dired-relist-entry):
* lisp/buff-menu.el (Buffer-menu-buffer):
* lisp/array.el (current-line):
* lisp/allout.el (allout-resolve-xref)
(allout-latex-verbatim-quote-curr-line):
Replace yet more uses of end-of-line etc with line-end-position.
2010-11-08 21:33:07 -08:00
|
|
|
|
(line-beginning-position 2)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(setq file (directory-file-name file))
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(dired-add-entry file (if (eq ?\s marker) nil marker)))))
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;; Copy, move/rename, making hard and symbolic links
|
|
|
|
|
|
1997-05-28 04:22:11 +00:00
|
|
|
|
(defcustom dired-backup-overwrite nil
|
2008-12-03 05:48:14 +00:00
|
|
|
|
"Non-nil if Dired should ask about making backups before overwriting files.
|
1997-05-28 04:22:11 +00:00
|
|
|
|
Special value `always' suppresses confirmation."
|
|
|
|
|
:type '(choice (const :tag "off" nil)
|
|
|
|
|
(const :tag "suppress" always)
|
1998-06-24 08:55:53 +00:00
|
|
|
|
(other :tag "ask" t))
|
1997-05-28 04:22:11 +00:00
|
|
|
|
:group 'dired)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2008-04-06 20:11:37 +00:00
|
|
|
|
;; This is a fluid var used in dired-handle-overwrite. It should be
|
|
|
|
|
;; let-bound whenever dired-copy-file etc are called. See
|
|
|
|
|
;; dired-create-files for an example.
|
|
|
|
|
(defvar dired-overwrite-confirmed)
|
1992-08-03 03:44:51 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-handle-overwrite (to)
|
2002-09-15 01:52:08 +00:00
|
|
|
|
;; Save old version of file TO that is to be overwritten.
|
1992-08-03 03:44:51 +00:00
|
|
|
|
;; `dired-overwrite-confirmed' and `overwrite-backup-query' are fluid vars
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; from dired-create-files.
|
1996-05-04 05:30:37 +00:00
|
|
|
|
(let (backup)
|
2008-04-06 00:03:38 +00:00
|
|
|
|
(when (and dired-backup-overwrite
|
|
|
|
|
dired-overwrite-confirmed
|
|
|
|
|
(setq backup (car (find-backup-file-name to)))
|
|
|
|
|
(or (eq 'always dired-backup-overwrite)
|
|
|
|
|
(dired-query 'overwrite-backup-query
|
|
|
|
|
"Make backup for existing file `%s'? "
|
|
|
|
|
to)))
|
|
|
|
|
(rename-file to backup 0) ; confirm overwrite of old backup
|
|
|
|
|
(dired-relist-entry backup))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
1993-12-23 03:34:57 +00:00
|
|
|
|
;;;###autoload
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-copy-file (from to ok-flag)
|
|
|
|
|
(dired-handle-overwrite to)
|
2006-09-11 02:25:00 +00:00
|
|
|
|
(dired-copy-file-recursive from to ok-flag dired-copy-preserve-time t
|
2020-08-11 15:16:11 +02:00
|
|
|
|
dired-recursive-copies dired-copy-dereference))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2007-11-22 13:49:34 +00:00
|
|
|
|
(declare-function make-symbolic-link "fileio.c")
|
|
|
|
|
|
2017-10-21 13:05:48 +09:00
|
|
|
|
(defcustom dired-create-destination-dirs nil
|
|
|
|
|
"Whether Dired should create destination dirs when copying/removing files.
|
|
|
|
|
If nil, don't create them.
|
2018-02-26 23:40:13 -08:00
|
|
|
|
If `always', create them without asking.
|
2021-11-09 16:19:45 +03:30
|
|
|
|
If `ask', ask for user confirmation.
|
|
|
|
|
|
|
|
|
|
Also see `dired-create-destination-dirs-on-trailing-dirsep'."
|
2017-10-21 13:05:48 +09:00
|
|
|
|
:type '(choice (const :tag "Never create non-existent dirs" nil)
|
|
|
|
|
(const :tag "Always create non-existent dirs" always)
|
|
|
|
|
(const :tag "Ask for user confirmation" ask))
|
|
|
|
|
:group 'dired
|
|
|
|
|
:version "27.1")
|
|
|
|
|
|
2021-11-09 16:19:45 +03:30
|
|
|
|
(defcustom dired-create-destination-dirs-on-trailing-dirsep nil
|
|
|
|
|
"If non-nil, treat a trailing slash at queried destination dir specially.
|
|
|
|
|
|
|
|
|
|
If this variable is non-nil and a single destination filename is
|
|
|
|
|
queried which ends in a directory separator (/), it will be
|
|
|
|
|
treated as a non-existent directory and acted on according to
|
|
|
|
|
`dired-create-destination-dirs'.
|
|
|
|
|
|
|
|
|
|
This option is only relevant if `dired-create-destination-dirs'
|
|
|
|
|
is non-nil, too.
|
|
|
|
|
|
|
|
|
|
For example, if both `dired-create-destination-dirs' and this
|
|
|
|
|
option are non-nil, renaming a directory named `old_name' to
|
|
|
|
|
`new_name/' (note the trailing directory separator) where
|
|
|
|
|
`new_name' does not exists already, it will be created and
|
|
|
|
|
`old_name' be moved into it. If only `new_name' (without the
|
|
|
|
|
trailing /) is given or this option or
|
|
|
|
|
`dired-create-destination-dirs' is `nil', `old_name' will be
|
|
|
|
|
renamed to `new_name'."
|
|
|
|
|
:type '(choice
|
|
|
|
|
(const :tag
|
|
|
|
|
(concat "Do not treat destination dirs with a "
|
|
|
|
|
"trailing directory separator specially")
|
|
|
|
|
nil)
|
|
|
|
|
(const :tag
|
|
|
|
|
(concat "Treat destination dirs with trailing "
|
|
|
|
|
"directory separator specially")
|
|
|
|
|
t))
|
|
|
|
|
:group 'dired
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
2017-10-21 13:05:48 +09:00
|
|
|
|
(defun dired-maybe-create-dirs (dir)
|
|
|
|
|
"Create DIR if doesn't exist according to `dired-create-destination-dirs'."
|
|
|
|
|
(when (and dired-create-destination-dirs (not (file-exists-p dir)))
|
|
|
|
|
(if (or (eq dired-create-destination-dirs 'always)
|
|
|
|
|
(yes-or-no-p (format "Create destination dir `%s'? " dir)))
|
|
|
|
|
(dired-create-directory dir))))
|
|
|
|
|
|
1999-09-16 19:29:30 +00:00
|
|
|
|
(defun dired-copy-file-recursive (from to ok-flag &optional
|
2020-08-11 15:16:11 +02:00
|
|
|
|
preserve-time top recursive
|
|
|
|
|
dereference)
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(when (and (eq t (file-attribute-type (file-attributes from)))
|
2012-04-01 10:44:24 +08:00
|
|
|
|
(file-in-directory-p to from))
|
2012-02-24 19:04:03 +01:00
|
|
|
|
(error "Cannot copy `%s' into its subdirectory `%s'" from to))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(let ((attrs (file-attributes from)))
|
2005-05-19 15:42:01 +00:00
|
|
|
|
(if (and recursive
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(eq t (file-attribute-type attrs))
|
2005-05-19 15:42:01 +00:00
|
|
|
|
(or (eq recursive 'always)
|
2019-09-23 17:35:03 +02:00
|
|
|
|
(yes-or-no-p (format "Copy %s recursively? " from))))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(copy-directory from to preserve-time)
|
2005-05-19 15:42:01 +00:00
|
|
|
|
(or top (dired-handle-overwrite to))
|
2006-09-11 02:25:00 +00:00
|
|
|
|
(condition-case err
|
2020-08-11 15:16:11 +02:00
|
|
|
|
(if (and (not dereference)
|
|
|
|
|
(stringp (file-attribute-type attrs)))
|
2006-09-11 02:25:00 +00:00
|
|
|
|
;; It is a symlink
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(make-symbolic-link (file-attribute-type attrs) to ok-flag)
|
2017-10-21 13:05:48 +09:00
|
|
|
|
(dired-maybe-create-dirs (file-name-directory to))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(copy-file from to ok-flag preserve-time))
|
2007-06-27 21:11:04 +00:00
|
|
|
|
(file-date-error
|
2006-09-11 02:25:00 +00:00
|
|
|
|
(push (dired-make-relative from)
|
|
|
|
|
dired-create-files-failures)
|
2006-11-05 15:00:31 +00:00
|
|
|
|
(dired-log "Can't set date on %s:\n%s\n" from err))))))
|
1999-09-16 19:29:30 +00:00
|
|
|
|
|
2019-11-07 01:14:58 +02:00
|
|
|
|
(defcustom dired-vc-rename-file nil
|
|
|
|
|
"Whether Dired should register file renaming in underlying vc system.
|
|
|
|
|
If nil, use default `rename-file'.
|
|
|
|
|
If non-nil and the renamed files are under version control,
|
|
|
|
|
rename them using `vc-rename-file'."
|
|
|
|
|
:type '(choice (const :tag "Use rename-file" nil)
|
|
|
|
|
(const :tag "Use vc-rename-file" t))
|
|
|
|
|
:group 'dired
|
|
|
|
|
:version "27.1")
|
|
|
|
|
|
1993-12-23 03:34:57 +00:00
|
|
|
|
;;;###autoload
|
2002-09-15 01:52:08 +00:00
|
|
|
|
(defun dired-rename-file (file newname ok-if-already-exists)
|
2020-09-04 06:09:23 +02:00
|
|
|
|
"Rename FILE to NEWNAME.
|
|
|
|
|
Signal a `file-already-exists' error if a file NEWNAME already exists
|
|
|
|
|
unless OK-IF-ALREADY-EXISTS is non-nil."
|
2022-04-11 14:31:04 +03:00
|
|
|
|
(let ((file-is-dir-p (file-directory-p file)))
|
|
|
|
|
(dired-handle-overwrite newname)
|
|
|
|
|
(dired-maybe-create-dirs (file-name-directory newname))
|
|
|
|
|
(if (and dired-vc-rename-file
|
|
|
|
|
(vc-backend file)
|
|
|
|
|
(ignore-errors (vc-responsible-backend newname)))
|
|
|
|
|
(vc-rename-file file newname)
|
|
|
|
|
;; error is caught in -create-files
|
|
|
|
|
(rename-file file newname ok-if-already-exists))
|
|
|
|
|
;; Silently rename the visited file of any buffer visiting this file.
|
|
|
|
|
(and (get-file-buffer file)
|
|
|
|
|
(with-current-buffer (get-file-buffer file)
|
|
|
|
|
(set-visited-file-name newname nil t)))
|
|
|
|
|
(dired-remove-file file)
|
|
|
|
|
;; See if it's an inserted subdir, and rename that, too.
|
|
|
|
|
(when file-is-dir-p
|
|
|
|
|
(dired-rename-subdir file newname))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-rename-subdir (from-dir to-dir)
|
|
|
|
|
(setq from-dir (file-name-as-directory from-dir)
|
|
|
|
|
to-dir (file-name-as-directory to-dir))
|
1997-03-22 03:39:39 +00:00
|
|
|
|
(dired-fun-in-all-buffers from-dir nil
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'dired-rename-subdir-1 from-dir to-dir)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; Update visited file name of all affected buffers
|
1994-09-16 21:35:29 +00:00
|
|
|
|
(let ((expanded-from-dir (expand-file-name from-dir))
|
|
|
|
|
(blist (buffer-list)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(while blist
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer (car blist)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(if (and buffer-file-name
|
2022-06-21 21:21:12 +02:00
|
|
|
|
(dired-in-this-tree-p buffer-file-name expanded-from-dir))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(let ((modflag (buffer-modified-p))
|
2020-09-27 00:50:39 +02:00
|
|
|
|
(to-file (replace-regexp-in-string
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(concat "^" (regexp-quote from-dir))
|
|
|
|
|
to-dir
|
|
|
|
|
buffer-file-name)))
|
|
|
|
|
(set-visited-file-name to-file)
|
|
|
|
|
(set-buffer-modified-p modflag))))
|
|
|
|
|
(setq blist (cdr blist)))))
|
|
|
|
|
|
|
|
|
|
(defun dired-rename-subdir-1 (dir to)
|
|
|
|
|
;; Rename DIR to TO in headerlines and dired-subdir-alist, if DIR or
|
|
|
|
|
;; one of its subdirectories is expanded in this buffer.
|
1994-09-16 21:35:29 +00:00
|
|
|
|
(let ((expanded-dir (expand-file-name dir))
|
|
|
|
|
(alist dired-subdir-alist)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(elt nil))
|
|
|
|
|
(while alist
|
|
|
|
|
(setq elt (car alist)
|
|
|
|
|
alist (cdr alist))
|
2022-04-11 14:31:04 +03:00
|
|
|
|
(if (dired-in-this-tree-p (car elt) expanded-dir)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; ELT's subdir is affected by the rename
|
|
|
|
|
(dired-rename-subdir-2 elt dir to)))
|
|
|
|
|
(if (equal dir default-directory)
|
|
|
|
|
;; if top level directory was renamed, lots of things have to be
|
|
|
|
|
;; updated:
|
|
|
|
|
(progn
|
|
|
|
|
(dired-unadvertise dir) ; we no longer dired DIR...
|
|
|
|
|
(setq default-directory to
|
|
|
|
|
dired-directory (expand-file-name;; this is correct
|
|
|
|
|
;; with and without wildcards
|
2017-07-21 13:17:14 +09:00
|
|
|
|
(file-name-nondirectory (if (stringp dired-directory)
|
|
|
|
|
dired-directory
|
|
|
|
|
(car dired-directory)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
to))
|
|
|
|
|
(let ((new-name (file-name-nondirectory
|
2017-07-21 13:17:14 +09:00
|
|
|
|
(directory-file-name (if (stringp dired-directory)
|
|
|
|
|
dired-directory
|
|
|
|
|
(car dired-directory))))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; try to rename buffer, but just leave old name if new
|
|
|
|
|
;; name would already exist (don't try appending "<%d>")
|
|
|
|
|
(or (get-buffer new-name)
|
|
|
|
|
(rename-buffer new-name)))
|
|
|
|
|
;; ... we dired TO now:
|
|
|
|
|
(dired-advertise)))))
|
|
|
|
|
|
|
|
|
|
(defun dired-rename-subdir-2 (elt dir to)
|
2004-06-06 02:26:46 +00:00
|
|
|
|
;; Update the headerline and dired-subdir-alist element, as well as
|
|
|
|
|
;; dired-switches-alist element, of directory described by
|
|
|
|
|
;; alist-element ELT to reflect the moving of DIR to TO. Thus, ELT
|
|
|
|
|
;; describes either DIR itself or a subdir of DIR.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((regexp (regexp-quote (directory-file-name dir)))
|
|
|
|
|
(newtext (directory-file-name to))
|
|
|
|
|
buffer-read-only)
|
2019-11-10 22:15:31 +01:00
|
|
|
|
(goto-char (cdr elt))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; Update subdir headerline in buffer
|
|
|
|
|
(if (not (looking-at dired-subdir-regexp))
|
|
|
|
|
(error "%s not found where expected - dired-subdir-alist broken?"
|
|
|
|
|
dir)
|
|
|
|
|
(goto-char (match-beginning 1))
|
|
|
|
|
(if (re-search-forward regexp (match-end 1) t)
|
|
|
|
|
(replace-match newtext t t)
|
|
|
|
|
(error "Expected to find `%s' in headerline of %s" dir (car elt))))
|
2004-06-06 02:26:46 +00:00
|
|
|
|
;; Update buffer-local dired-subdir-alist and dired-switches-alist
|
|
|
|
|
(let ((cons (assoc-string (car elt) dired-switches-alist))
|
|
|
|
|
(cur-dir (dired-normalize-subdir
|
2020-09-27 00:50:39 +02:00
|
|
|
|
(replace-regexp-in-string regexp newtext (car elt)))))
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(setcar elt cur-dir)
|
|
|
|
|
(when cons (setcar cons cur-dir))))))
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2011-04-19 15:44:55 +02:00
|
|
|
|
;; Bound in dired-create-files
|
|
|
|
|
(defvar overwrite-query)
|
|
|
|
|
(defvar overwrite-backup-query)
|
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
|
|
|
|
;;; The basic function for half a dozen variations on cp/mv/ln/ln -s
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-create-files (file-creator operation fn-list name-constructor
|
|
|
|
|
&optional marker-char)
|
2011-04-03 17:23:23 -04:00
|
|
|
|
"Create one or more new files from a list of existing files FN-LIST.
|
|
|
|
|
This function also handles querying the user, updating Dired
|
|
|
|
|
buffers, and displaying a success or failure message.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2011-04-03 17:23:23 -04:00
|
|
|
|
FILE-CREATOR should be a function. It is called once for each
|
|
|
|
|
file in FN-LIST, and must create a new file, querying the user
|
|
|
|
|
and updating Dired buffers as necessary. It should accept three
|
|
|
|
|
arguments: the old file name, the new name, and an argument
|
|
|
|
|
OK-IF-ALREADY-EXISTS with the same meaning as in `copy-file'.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2011-04-03 17:23:23 -04:00
|
|
|
|
OPERATION should be a capitalized string describing the operation
|
|
|
|
|
performed (e.g. `Copy'). It is used for error logging.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2011-04-03 17:23:23 -04:00
|
|
|
|
FN-LIST is the list of files to copy (full absolute file names).
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2011-04-03 17:23:23 -04:00
|
|
|
|
NAME-CONSTRUCTOR should be a function accepting a single
|
|
|
|
|
argument, the name of an old file, and returning either the
|
|
|
|
|
corresponding new file name or nil to skip.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2012-06-22 15:30:33 +08:00
|
|
|
|
If optional argument MARKER-CHAR is non-nil, mark each
|
|
|
|
|
newly-created file's Dired entry with the character MARKER-CHAR,
|
|
|
|
|
or with the current marker character if MARKER-CHAR is t."
|
2006-09-11 02:25:00 +00:00
|
|
|
|
(let (dired-create-files-failures failures
|
|
|
|
|
skipped (success-count 0) (total (length fn-list)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(let (to overwrite-query
|
|
|
|
|
overwrite-backup-query) ; for dired-handle-overwrite
|
2008-03-26 03:34:07 +00:00
|
|
|
|
(dolist (from fn-list)
|
2021-06-02 10:13:58 +02:00
|
|
|
|
;; Position point on the current file -- this is useful if
|
|
|
|
|
;; handling a number of files to show where we're working at.
|
|
|
|
|
(dired-goto-file from)
|
2008-03-26 03:34:07 +00:00
|
|
|
|
(setq to (funcall name-constructor from))
|
|
|
|
|
(if (equal to from)
|
|
|
|
|
(progn
|
|
|
|
|
(setq to nil)
|
|
|
|
|
(dired-log "Cannot %s to same file: %s\n"
|
|
|
|
|
(downcase operation) from)))
|
|
|
|
|
(if (not to)
|
|
|
|
|
(setq skipped (cons (dired-make-relative from) skipped))
|
|
|
|
|
(let* ((overwrite (file-exists-p to))
|
|
|
|
|
(dired-overwrite-confirmed ; for dired-handle-overwrite
|
|
|
|
|
(and overwrite
|
2021-11-22 11:45:44 +01:00
|
|
|
|
(let ((help-form (format-message
|
|
|
|
|
(substitute-command-keys "\
|
|
|
|
|
Type \\`SPC' or \\`y' to overwrite file `%s',
|
|
|
|
|
\\`DEL' or \\`n' to skip to next,
|
|
|
|
|
\\`ESC' or \\`q' to not overwrite any of the remaining files,
|
|
|
|
|
\\`!' to overwrite all remaining files with no more questions.") to)))
|
2008-03-26 03:34:07 +00:00
|
|
|
|
(dired-query 'overwrite-query
|
|
|
|
|
"Overwrite `%s'?" to))))
|
|
|
|
|
;; must determine if FROM is marked before file-creator
|
|
|
|
|
;; gets a chance to delete it (in case of a move).
|
|
|
|
|
(actual-marker-char
|
|
|
|
|
(cond ((integerp marker-char) marker-char)
|
|
|
|
|
(marker-char (dired-file-marker from)) ; slow
|
|
|
|
|
(t nil))))
|
2012-02-24 19:04:03 +01:00
|
|
|
|
;; Handle the `dired-copy-file' file-creator specially
|
|
|
|
|
;; When copying a directory to another directory or
|
|
|
|
|
;; possibly to itself or one of its subdirectories.
|
|
|
|
|
;; e.g "~/foo/" => "~/test/"
|
|
|
|
|
;; or "~/foo/" =>"~/foo/"
|
|
|
|
|
;; or "~/foo/ => ~/foo/bar/")
|
|
|
|
|
;; In this case the 'name-constructor' have set the destination
|
|
|
|
|
;; TO to "~/test/foo" because the old emacs23 behavior
|
|
|
|
|
;; of `copy-directory' was to not create the subdirectory
|
|
|
|
|
;; and instead copy the contents.
|
|
|
|
|
;; With the new behavior of `copy-directory'
|
|
|
|
|
;; (similar to the `cp' shell command) we don't
|
|
|
|
|
;; need such a construction of the target directory,
|
|
|
|
|
;; so modify the destination TO to "~/test/" instead of "~/test/foo/".
|
|
|
|
|
(let ((destname (file-name-directory to)))
|
|
|
|
|
(when (and (file-directory-p from)
|
|
|
|
|
(file-directory-p to)
|
|
|
|
|
(eq file-creator 'dired-copy-file))
|
|
|
|
|
(setq to destname))
|
2012-03-31 00:49:29 +08:00
|
|
|
|
;; If DESTNAME is a subdirectory of FROM, not a symlink,
|
|
|
|
|
;; and the method in use is copying, signal an error.
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(and (eq t (file-attribute-type (file-attributes destname)))
|
2012-03-31 00:49:29 +08:00
|
|
|
|
(eq file-creator 'dired-copy-file)
|
2012-04-01 10:44:24 +08:00
|
|
|
|
(file-in-directory-p destname from)
|
2012-03-31 00:52:52 +08:00
|
|
|
|
(error "Cannot copy `%s' into its subdirectory `%s'"
|
2012-03-31 00:49:29 +08:00
|
|
|
|
from to)))
|
2021-05-06 13:08:56 +02:00
|
|
|
|
;; Check, that `dired-do-symlink' does not create symlinks
|
|
|
|
|
;; on different hosts.
|
|
|
|
|
(when (and (eq file-creator 'make-symbolic-link)
|
|
|
|
|
(not (equal (file-remote-p from) (file-remote-p to))))
|
|
|
|
|
(error "Cannot symlink `%s' to `%s' on another host" from to))
|
2008-03-26 03:34:07 +00:00
|
|
|
|
(condition-case err
|
|
|
|
|
(progn
|
|
|
|
|
(funcall file-creator from to dired-overwrite-confirmed)
|
|
|
|
|
(if overwrite
|
|
|
|
|
;; If we get here, file-creator hasn't been aborted
|
|
|
|
|
;; and the old entry (if any) has to be deleted
|
|
|
|
|
;; before adding the new entry.
|
|
|
|
|
(dired-remove-file to))
|
|
|
|
|
(setq success-count (1+ success-count))
|
|
|
|
|
(message "%s: %d of %d" operation success-count total)
|
|
|
|
|
(dired-add-file to actual-marker-char))
|
|
|
|
|
(file-error ; FILE-CREATOR aborted
|
|
|
|
|
(progn
|
|
|
|
|
(push (dired-make-relative from)
|
|
|
|
|
failures)
|
2019-05-05 22:43:27 +03:00
|
|
|
|
(dired-log "%s: `%s' to `%s' failed:\n%s\n"
|
2008-03-26 03:34:07 +00:00
|
|
|
|
operation from to err))))))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(cond
|
2006-09-11 02:25:00 +00:00
|
|
|
|
(dired-create-files-failures
|
|
|
|
|
(setq failures (nconc failures dired-create-files-failures))
|
|
|
|
|
(dired-log-summary
|
2019-05-05 22:43:27 +03:00
|
|
|
|
(format (ngettext "%s failed for %d file in %d requests"
|
|
|
|
|
"%s failed for %d files in %d requests"
|
|
|
|
|
(length failures))
|
|
|
|
|
operation (length failures) total)
|
2006-09-11 02:25:00 +00:00
|
|
|
|
failures))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(failures
|
|
|
|
|
(dired-log-summary
|
2019-05-05 22:43:27 +03:00
|
|
|
|
(format (ngettext "%s: %d of %d file failed"
|
|
|
|
|
"%s: %d of %d files failed"
|
|
|
|
|
total)
|
|
|
|
|
operation (length failures) total)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
failures))
|
|
|
|
|
(skipped
|
|
|
|
|
(dired-log-summary
|
2019-05-05 22:43:27 +03:00
|
|
|
|
(format (ngettext "%s: %d of %d file skipped"
|
|
|
|
|
"%s: %d of %d files skipped"
|
|
|
|
|
total)
|
|
|
|
|
operation (length skipped) total)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
skipped))
|
|
|
|
|
(t
|
2019-05-05 22:43:27 +03:00
|
|
|
|
(message (ngettext "%s: %d file done"
|
|
|
|
|
"%s: %d files done"
|
|
|
|
|
success-count)
|
|
|
|
|
operation success-count))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-move-to-filename))
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2021-05-21 21:31:48 +03:00
|
|
|
|
(defcustom dired-do-revert-buffer nil
|
|
|
|
|
"Automatically revert Dired buffers after `dired-do' operations.
|
|
|
|
|
This option controls whether to refresh the directory listing in a
|
|
|
|
|
Dired buffer that is the destination of one of these operations:
|
|
|
|
|
`dired-do-copy', `dired-do-rename', `dired-do-symlink', `dired-do-hardlink'.
|
|
|
|
|
If the value is t, always revert the Dired buffer updated in the result
|
|
|
|
|
of these operations.
|
|
|
|
|
If the value is a function, it is called with the destination directory name
|
|
|
|
|
as a single argument, and the buffer is reverted after Dired operations
|
|
|
|
|
if the function returns non-nil."
|
|
|
|
|
:type '(choice
|
|
|
|
|
(const :tag "Don't revert" nil)
|
|
|
|
|
(const :tag "Always revert destination directory" t)
|
|
|
|
|
(const :tag "Revert only local Dired buffers"
|
|
|
|
|
(lambda (dir) (not (file-remote-p dir))))
|
|
|
|
|
(function :tag "Predicate function"))
|
|
|
|
|
:group 'dired
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-do-create-files (op-symbol file-creator operation arg
|
2000-10-04 23:35:52 +00:00
|
|
|
|
&optional marker-char op1
|
|
|
|
|
how-to)
|
|
|
|
|
"Create a new file for each marked file.
|
2012-06-22 15:30:33 +08:00
|
|
|
|
Prompt user for a target directory in which to create the new
|
|
|
|
|
files. The target may also be a non-directory file, if only
|
|
|
|
|
one file is marked. The initial suggestion for target is the
|
|
|
|
|
Dired buffer's current directory (or, if `dired-dwim-target' is
|
|
|
|
|
non-nil, the current directory of a neighboring Dired window).
|
2022-01-22 15:42:59 +01:00
|
|
|
|
|
2000-10-04 23:35:52 +00:00
|
|
|
|
OP-SYMBOL is the symbol for the operation. Function `dired-mark-pop-up'
|
|
|
|
|
will determine whether pop-ups are appropriate for this OP-SYMBOL.
|
2022-01-22 15:42:59 +01:00
|
|
|
|
|
2000-10-04 23:35:52 +00:00
|
|
|
|
FILE-CREATOR and OPERATION as in `dired-create-files'.
|
2022-01-22 15:42:59 +01:00
|
|
|
|
|
2000-10-04 23:35:52 +00:00
|
|
|
|
ARG as in `dired-get-marked-files'.
|
2022-01-22 15:42:59 +01:00
|
|
|
|
|
2000-10-04 23:35:52 +00:00
|
|
|
|
Optional arg MARKER-CHAR as in `dired-create-files'.
|
2022-01-22 15:42:59 +01:00
|
|
|
|
|
2000-10-04 23:35:52 +00:00
|
|
|
|
Optional arg OP1 is an alternate form for OPERATION if there is
|
|
|
|
|
only one file.
|
2022-01-22 15:42:59 +01:00
|
|
|
|
|
2011-11-17 01:09:20 -08:00
|
|
|
|
Optional arg HOW-TO determines how to treat the target.
|
2008-10-22 20:21:21 +00:00
|
|
|
|
If HOW-TO is nil, use `file-directory-p' to determine if the
|
|
|
|
|
target is a directory. If so, the marked file(s) are created
|
2022-01-22 15:42:59 +01:00
|
|
|
|
inside that directory.
|
2008-10-22 20:21:21 +00:00
|
|
|
|
If HOW-TO is t, target is always treated as a plain file.
|
|
|
|
|
Otherwise, HOW-TO should be a function of one argument, TARGET.
|
|
|
|
|
If its return value is nil, TARGET is regarded as a plain file.
|
|
|
|
|
If it return value is a list, TARGET is a generalized
|
|
|
|
|
directory (e.g. some sort of archive). The first element of
|
|
|
|
|
this list must be a function with at least four arguments:
|
|
|
|
|
operation - as OPERATION above.
|
|
|
|
|
rfn-list - list of the relative names for the marked files.
|
|
|
|
|
fn-list - list of the absolute names for the marked files.
|
|
|
|
|
target - the name of the target itself.
|
2018-03-01 17:31:21 +02:00
|
|
|
|
The rest of elements of the list returned by HOW-TO are optional
|
|
|
|
|
arguments for the function that is the first element of the list.
|
2022-01-22 15:42:59 +01:00
|
|
|
|
|
|
|
|
|
This can be useful because by default, copying a single file
|
|
|
|
|
would replace the tar file. But this could be overridden to
|
|
|
|
|
add or replace entries in the tar file.
|
|
|
|
|
|
2008-10-22 20:21:21 +00:00
|
|
|
|
For any other return value, TARGET is treated as a directory."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(or op1 (setq op1 operation))
|
2018-02-06 23:32:08 +02:00
|
|
|
|
(let* ((fn-list (dired-get-marked-files nil arg nil nil t))
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(rfn-list (mapcar #'dired-make-relative fn-list))
|
1999-09-16 19:29:30 +00:00
|
|
|
|
(dired-one-file ; fluid variable inside dired-create-files
|
|
|
|
|
(and (consp fn-list) (null (cdr fn-list)) (car fn-list)))
|
2000-11-28 16:43:45 +00:00
|
|
|
|
(target-dir (dired-dwim-target-directory))
|
|
|
|
|
(default (and dired-one-file
|
2017-02-27 16:26:06 +09:00
|
|
|
|
(not dired-dwim-target) ; Bug#25609
|
2000-11-28 16:43:45 +00:00
|
|
|
|
(expand-file-name (file-name-nondirectory (car fn-list))
|
|
|
|
|
target-dir)))
|
2009-11-25 17:15:19 +00:00
|
|
|
|
(defaults (dired-dwim-target-defaults fn-list target-dir))
|
1999-09-16 19:29:30 +00:00
|
|
|
|
(target (expand-file-name ; fluid variable inside dired-create-files
|
2009-11-25 17:15:19 +00:00
|
|
|
|
(minibuffer-with-setup-hook
|
|
|
|
|
(lambda ()
|
2020-12-09 09:18:04 +01:00
|
|
|
|
(setq-local minibuffer-default-add-function nil)
|
2009-11-25 17:15:19 +00:00
|
|
|
|
(setq minibuffer-default defaults))
|
|
|
|
|
(dired-mark-read-file-name
|
2019-07-26 11:12:03 +02:00
|
|
|
|
(format "%s %%s %s: "
|
|
|
|
|
(if dired-one-file op1 operation)
|
|
|
|
|
(if (memq op-symbol '(symlink hardlink))
|
|
|
|
|
;; Linking operations create links
|
|
|
|
|
;; from the prompted file name; the
|
|
|
|
|
;; other operations copy (etc) to the
|
|
|
|
|
;; prompted file name.
|
|
|
|
|
"from" "to"))
|
2009-11-25 17:15:19 +00:00
|
|
|
|
target-dir op-symbol arg rfn-list default))))
|
2018-04-05 12:15:54 +09:00
|
|
|
|
(into-dir
|
|
|
|
|
(progn
|
2021-11-09 16:19:45 +03:30
|
|
|
|
(when
|
|
|
|
|
(or
|
|
|
|
|
(not dired-one-file)
|
|
|
|
|
(and dired-create-destination-dirs-on-trailing-dirsep
|
|
|
|
|
(directory-name-p target)))
|
|
|
|
|
(dired-maybe-create-dirs target))
|
2018-04-05 12:15:54 +09:00
|
|
|
|
(cond ((null how-to)
|
|
|
|
|
;; Allow users to change the letter case of
|
|
|
|
|
;; a directory on a case-insensitive
|
|
|
|
|
;; filesystem. If we don't test these
|
|
|
|
|
;; conditions up front, file-directory-p
|
|
|
|
|
;; below will return t on a case-insensitive
|
|
|
|
|
;; filesystem, and Emacs will try to move
|
|
|
|
|
;; foo -> foo/foo, which fails.
|
|
|
|
|
(if (and (file-name-case-insensitive-p (car fn-list))
|
|
|
|
|
(eq op-symbol 'move)
|
|
|
|
|
dired-one-file
|
|
|
|
|
(string= (downcase
|
|
|
|
|
(expand-file-name (car fn-list)))
|
|
|
|
|
(downcase
|
|
|
|
|
(expand-file-name target)))
|
|
|
|
|
(not (string=
|
|
|
|
|
(file-name-nondirectory (car fn-list))
|
|
|
|
|
(file-name-nondirectory target))))
|
|
|
|
|
nil
|
|
|
|
|
(file-directory-p target)))
|
|
|
|
|
((eq how-to t) nil)
|
|
|
|
|
(t (funcall how-to target))))))
|
1999-09-16 19:29:30 +00:00
|
|
|
|
(if (and (consp into-dir) (functionp (car into-dir)))
|
|
|
|
|
(apply (car into-dir) operation rfn-list fn-list target (cdr into-dir))
|
|
|
|
|
(if (not (or dired-one-file into-dir))
|
|
|
|
|
(error "Marked %s: target must be a directory: %s" operation target))
|
2020-08-06 12:11:57 +02:00
|
|
|
|
(if (and (not (file-directory-p (car fn-list)))
|
|
|
|
|
(not (file-directory-p target))
|
|
|
|
|
(directory-name-p target))
|
|
|
|
|
(error "%s: Target directory does not exist: %s" operation target))
|
1999-09-16 19:29:30 +00:00
|
|
|
|
;; rename-file bombs when moving directories unless we do this:
|
|
|
|
|
(or into-dir (setq target (directory-file-name target)))
|
2021-05-25 21:29:24 +02:00
|
|
|
|
(prog1
|
|
|
|
|
(dired-create-files
|
|
|
|
|
file-creator operation fn-list
|
|
|
|
|
(if into-dir ; target is a directory
|
|
|
|
|
;; This function uses fluid variable target when called
|
|
|
|
|
;; inside dired-create-files:
|
|
|
|
|
(lambda (from)
|
|
|
|
|
(expand-file-name (file-name-nondirectory from) target))
|
|
|
|
|
(lambda (_from) target))
|
|
|
|
|
marker-char)
|
|
|
|
|
(when (or (eq dired-do-revert-buffer t)
|
|
|
|
|
(and (functionp dired-do-revert-buffer)
|
|
|
|
|
(funcall dired-do-revert-buffer target)))
|
|
|
|
|
(dired-fun-in-all-buffers (file-name-directory target) nil
|
|
|
|
|
#'revert-buffer))))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;; Read arguments for a marked-files command that wants a file name,
|
|
|
|
|
;; perhaps popping up the list of marked files.
|
|
|
|
|
;; ARG is the prefix arg and indicates whether the files came from
|
|
|
|
|
;; marks (ARG=nil) or a repeat factor (integerp ARG).
|
|
|
|
|
;; If the current file was used, the list has but one element and ARG
|
|
|
|
|
;; does not matter. (It is non-nil, non-integer in that case, namely '(4)).
|
2000-10-03 17:35:47 +00:00
|
|
|
|
;; DEFAULT is the default value to return if the user just hits RET;
|
|
|
|
|
;; if it is omitted or nil, then the name of the directory is used.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2000-10-03 17:35:47 +00:00
|
|
|
|
(defun dired-mark-read-file-name (prompt dir op-symbol arg files
|
|
|
|
|
&optional default)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-mark-pop-up
|
|
|
|
|
nil op-symbol files
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'read-file-name
|
2000-10-03 17:35:47 +00:00
|
|
|
|
(format prompt (dired-mark-prompt arg files)) dir default))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2019-10-27 02:20:15 +03:00
|
|
|
|
(defun dired-dwim-target-directories ()
|
2020-05-15 00:03:18 +02:00
|
|
|
|
(if (functionp dired-dwim-target)
|
|
|
|
|
(funcall dired-dwim-target)
|
|
|
|
|
(dired-dwim-target-next)))
|
2019-11-12 23:21:14 +02:00
|
|
|
|
|
2019-11-17 00:06:16 +02:00
|
|
|
|
(defun dired-dwim-target-next (&optional all-frames)
|
|
|
|
|
;; Return directories from all next windows with dired-mode buffers.
|
2019-11-12 23:21:14 +02:00
|
|
|
|
(mapcan (lambda (w)
|
|
|
|
|
(with-current-buffer (window-buffer w)
|
|
|
|
|
(when (eq major-mode 'dired-mode)
|
|
|
|
|
(list (dired-current-directory)))))
|
|
|
|
|
(delq (selected-window) (window-list-1
|
2019-11-17 00:06:16 +02:00
|
|
|
|
(next-window nil 'nomini all-frames)
|
|
|
|
|
'nomini all-frames))))
|
|
|
|
|
|
|
|
|
|
(defun dired-dwim-target-next-visible ()
|
|
|
|
|
;; Return directories from all next visible windows with dired-mode buffers.
|
|
|
|
|
(dired-dwim-target-next 'visible))
|
2019-11-12 23:21:14 +02:00
|
|
|
|
|
|
|
|
|
(defun dired-dwim-target-recent ()
|
2019-10-27 02:20:15 +03:00
|
|
|
|
;; Return directories from all visible windows with dired-mode buffers
|
|
|
|
|
;; ordered by most-recently-used.
|
|
|
|
|
(mapcar #'cdr (sort (mapcan (lambda (w)
|
|
|
|
|
(with-current-buffer (window-buffer w)
|
|
|
|
|
(when (eq major-mode 'dired-mode)
|
|
|
|
|
(list (cons (window-use-time w)
|
|
|
|
|
(dired-current-directory))))))
|
|
|
|
|
(delq (selected-window)
|
|
|
|
|
(window-list-1 nil 'nomini 'visible)))
|
|
|
|
|
(lambda (a b) (> (car a) (car b))))))
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-dwim-target-directory ()
|
|
|
|
|
;; Try to guess which target directory the user may want.
|
2009-11-25 17:15:19 +00:00
|
|
|
|
;; If there is a dired buffer displayed in one of the next windows,
|
|
|
|
|
;; use its current subdir, else use current subdir of this dired buffer.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(let ((this-dir (and (eq major-mode 'dired-mode)
|
|
|
|
|
(dired-current-directory))))
|
|
|
|
|
;; non-dired buffer may want to profit from this function, e.g. vm-uudecode
|
|
|
|
|
(if dired-dwim-target
|
2019-10-27 02:20:15 +03:00
|
|
|
|
(or (car (dired-dwim-target-directories)) this-dir)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
this-dir)))
|
2009-11-25 17:15:19 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-dwim-target-defaults (fn-list target-dir)
|
|
|
|
|
;; Return a list of default values for file-reading functions in Dired.
|
|
|
|
|
;; This list may contain directories from Dired buffers in other windows.
|
|
|
|
|
;; `fn-list' is a list of file names used to build a list of defaults.
|
|
|
|
|
;; When nil or more than one element, a list of defaults will
|
|
|
|
|
;; contain only directory names. `target-dir' is a directory name
|
|
|
|
|
;; to exclude from the returned list, for the case when this
|
|
|
|
|
;; directory name is already presented in initial input.
|
|
|
|
|
;; For Dired operations that support `dired-dwim-target',
|
|
|
|
|
;; the argument `target-dir' should have the value returned
|
|
|
|
|
;; from `dired-dwim-target-directory'.
|
|
|
|
|
(let ((dired-one-file
|
|
|
|
|
(and (consp fn-list) (null (cdr fn-list)) (car fn-list)))
|
|
|
|
|
(current-dir (and (eq major-mode 'dired-mode)
|
|
|
|
|
(dired-current-directory)))
|
2019-10-27 02:20:15 +03:00
|
|
|
|
;; Get a list of directories of visible buffers in dired-mode.
|
|
|
|
|
(dired-dirs (dired-dwim-target-directories)))
|
2009-11-25 17:15:19 +00:00
|
|
|
|
;; Force the current dir to be the first in the list.
|
|
|
|
|
(setq dired-dirs
|
2019-10-27 02:20:15 +03:00
|
|
|
|
(delete-dups (delq nil (cons current-dir dired-dirs))))
|
2009-11-25 17:15:19 +00:00
|
|
|
|
;; Remove the target dir (if specified) or the current dir from
|
|
|
|
|
;; default values, because it should be already in initial input.
|
|
|
|
|
(setq dired-dirs (delete (or target-dir current-dir) dired-dirs))
|
|
|
|
|
;; Return a list of default values.
|
|
|
|
|
(if dired-one-file
|
|
|
|
|
;; For one file operation, provide a list that contains
|
|
|
|
|
;; other directories, other directories with the appended filename
|
|
|
|
|
;; and the current directory with the appended filename, e.g.
|
|
|
|
|
;; 1. /TARGET-DIR/
|
|
|
|
|
;; 2. /TARGET-DIR/FILENAME
|
|
|
|
|
;; 3. /CURRENT-DIR/FILENAME
|
|
|
|
|
(append dired-dirs
|
|
|
|
|
(mapcar (lambda (dir)
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(file-name-nondirectory (car fn-list)) dir))
|
|
|
|
|
(reverse dired-dirs))
|
|
|
|
|
(list (expand-file-name
|
|
|
|
|
(file-name-nondirectory (car fn-list))
|
|
|
|
|
(or target-dir current-dir))))
|
|
|
|
|
;; For multi-file operation, return only a list of other directories.
|
|
|
|
|
dired-dirs)))
|
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2018-08-02 13:20:46 +09:00
|
|
|
|
;; We use this function in `dired-create-directory' and
|
|
|
|
|
;; `dired-create-empty-file'; the return value is the new entry
|
|
|
|
|
;; in the updated Dired buffer.
|
|
|
|
|
(defun dired--find-topmost-parent-dir (filename)
|
|
|
|
|
"Return the topmost nonexistent parent dir of FILENAME.
|
|
|
|
|
FILENAME is a full file name."
|
|
|
|
|
(let ((try filename) new)
|
|
|
|
|
(while (and try (not (file-exists-p try)) (not (equal new try)))
|
|
|
|
|
(setq new try
|
|
|
|
|
try (directory-file-name (file-name-directory try))))
|
|
|
|
|
new))
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-create-directory (directory)
|
2011-03-19 18:07:41 -04:00
|
|
|
|
"Create a directory called DIRECTORY.
|
2017-10-15 19:36:58 +03:00
|
|
|
|
Parent directories of DIRECTORY are created as needed.
|
2011-03-19 18:07:41 -04:00
|
|
|
|
If DIRECTORY already exists, signal an error."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list (read-file-name "Create directory: " (dired-current-directory))))
|
2007-11-17 01:27:52 +00:00
|
|
|
|
(let* ((expanded (directory-file-name (expand-file-name directory)))
|
2018-08-02 13:20:46 +09:00
|
|
|
|
new)
|
2011-03-19 18:07:41 -04:00
|
|
|
|
(if (file-exists-p expanded)
|
|
|
|
|
(error "Cannot create directory %s: file exists" expanded))
|
2018-08-02 13:20:46 +09:00
|
|
|
|
(setq new (dired--find-topmost-parent-dir expanded))
|
2007-11-17 01:27:52 +00:00
|
|
|
|
(make-directory expanded t)
|
|
|
|
|
(when new
|
|
|
|
|
(dired-add-file new)
|
|
|
|
|
(dired-move-to-filename))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2018-08-02 13:20:46 +09:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-create-empty-file (file)
|
|
|
|
|
"Create an empty file called FILE.
|
2021-09-14 08:43:18 +02:00
|
|
|
|
Add a new entry for the new file in the Dired buffer.
|
|
|
|
|
Parent directories of FILE are created as needed.
|
|
|
|
|
If FILE already exists, signal an error."
|
2018-08-02 13:20:46 +09:00
|
|
|
|
(interactive (list (read-file-name "Create empty file: ")))
|
|
|
|
|
(let* ((expanded (expand-file-name file))
|
|
|
|
|
new)
|
|
|
|
|
(if (file-exists-p expanded)
|
|
|
|
|
(error "Cannot create file %s: file exists" expanded))
|
|
|
|
|
(setq new (dired--find-topmost-parent-dir expanded))
|
|
|
|
|
(make-empty-file file 'parents)
|
|
|
|
|
(when new
|
|
|
|
|
(dired-add-file new)
|
|
|
|
|
(dired-move-to-filename))))
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-into-dir-with-symlinks (target)
|
|
|
|
|
(and (file-directory-p target)
|
|
|
|
|
(not (file-symlink-p target))))
|
|
|
|
|
;; This may not always be what you want, especially if target is your
|
|
|
|
|
;; home directory and it happens to be a symbolic link, as is often the
|
|
|
|
|
;; case with NFS and automounters. Or if you want to make symlinks
|
|
|
|
|
;; into directories that themselves are only symlinks, also quite
|
|
|
|
|
;; common.
|
|
|
|
|
|
|
|
|
|
;; So we don't use this function as value for HOW-TO in
|
|
|
|
|
;; dired-do-symlink, which has the minor disadvantage of
|
|
|
|
|
;; making links *into* a symlinked-dir, when you really wanted to
|
|
|
|
|
;; *overwrite* that symlink. In that (rare, I guess) case, you'll
|
|
|
|
|
;; just have to remove that symlink by hand before making your marked
|
|
|
|
|
;; symlinks.
|
|
|
|
|
|
1999-09-16 19:29:30 +00:00
|
|
|
|
(defvar dired-copy-how-to-fn nil
|
2009-09-24 01:37:14 +00:00
|
|
|
|
"Either nil or a function used by `dired-do-copy' to determine target.
|
2022-01-22 15:42:59 +01:00
|
|
|
|
See HOW-TO argument for `dired-do-create-files' for an explanation.")
|
1999-09-16 19:29:30 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-copy (&optional arg)
|
|
|
|
|
"Copy all marked (or next ARG) files, or copy the current file.
|
2020-08-11 15:16:11 +02:00
|
|
|
|
ARG has to be numeric for above functionality. See
|
|
|
|
|
`dired-get-marked-files' for more details.
|
|
|
|
|
|
2012-06-22 15:30:33 +08:00
|
|
|
|
When operating on just the current file, prompt for the new name.
|
2006-10-18 10:50:28 +00:00
|
|
|
|
|
2012-06-22 15:30:33 +08:00
|
|
|
|
When operating on multiple or marked files, prompt for a target
|
|
|
|
|
directory, and make the new copies in that directory, with the
|
|
|
|
|
same names as the original files. The initial suggestion for the
|
|
|
|
|
target directory is the Dired buffer's current directory (or, if
|
|
|
|
|
`dired-dwim-target' is non-nil, the current directory of a
|
|
|
|
|
neighboring Dired window).
|
|
|
|
|
|
|
|
|
|
If `dired-copy-preserve-time' is non-nil, this command preserves
|
|
|
|
|
the modification time of each old file in the copy, similar to
|
|
|
|
|
the \"-p\" option for the \"cp\" shell command.
|
|
|
|
|
|
2022-04-28 13:48:17 +02:00
|
|
|
|
The `dired-keep-marker-copy' user option controls how this
|
|
|
|
|
command handles file marking. The default is to mark all new
|
|
|
|
|
copies of files with a \"C\" mark.
|
|
|
|
|
|
2020-08-11 15:16:11 +02:00
|
|
|
|
This command copies symbolic links by creating new ones,
|
|
|
|
|
similar to the \"-d\" option for the \"cp\" shell command.
|
|
|
|
|
But if `dired-copy-dereference' is non-nil, the symbolic
|
|
|
|
|
links are dereferenced and then copied, similar to the \"-L\"
|
|
|
|
|
option for the \"cp\" shell command. If ARG is a cons with
|
|
|
|
|
element 4 (`\\[universal-argument]'), the inverted value of
|
2021-09-29 19:10:00 +02:00
|
|
|
|
`dired-copy-dereference' will be used.
|
|
|
|
|
|
|
|
|
|
Also see `dired-do-revert-buffer'."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive "P")
|
2020-08-11 15:16:11 +02:00
|
|
|
|
(let ((dired-recursive-copies dired-recursive-copies)
|
|
|
|
|
(dired-copy-dereference (if (equal arg '(4))
|
|
|
|
|
(not dired-copy-dereference)
|
|
|
|
|
dired-copy-dereference)))
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-do-create-files 'copy #'dired-copy-file
|
2005-06-23 21:23:17 +00:00
|
|
|
|
"Copy"
|
2000-02-17 09:13:39 +00:00
|
|
|
|
arg dired-keep-marker-copy
|
|
|
|
|
nil dired-copy-how-to-fn)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-symlink (&optional arg)
|
|
|
|
|
"Make symbolic links to current file or all marked (or next ARG) files.
|
|
|
|
|
When operating on just the current file, you specify the new name.
|
|
|
|
|
When operating on multiple or marked files, you specify a directory
|
|
|
|
|
and new symbolic links are made in that directory
|
2001-04-27 15:40:29 +00:00
|
|
|
|
with the same names that the files currently have. The default
|
|
|
|
|
suggested for the target directory depends on the value of
|
2007-02-02 14:51:08 +00:00
|
|
|
|
`dired-dwim-target', which see.
|
|
|
|
|
|
2021-09-29 19:10:00 +02:00
|
|
|
|
For relative symlinks, use \\[dired-do-relsymlink].
|
|
|
|
|
|
|
|
|
|
Also see `dired-do-revert-buffer'."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive "P")
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-do-create-files 'symlink #'make-symbolic-link
|
2021-06-30 20:10:30 +02:00
|
|
|
|
"Symlink" arg dired-keep-marker-symlink))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2022-07-08 18:31:17 +02:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-relsymlink (&optional arg)
|
|
|
|
|
"Relative symlink all marked (or next ARG) files into a directory.
|
|
|
|
|
Otherwise make a relative symbolic link to the current file.
|
|
|
|
|
This creates relative symbolic links like
|
|
|
|
|
|
|
|
|
|
foo -> ../bar/foo
|
|
|
|
|
|
|
|
|
|
not absolute ones like
|
|
|
|
|
|
|
|
|
|
foo -> /ugly/file/name/that/may/change/any/day/bar/foo
|
|
|
|
|
|
|
|
|
|
For absolute symlinks, use \\[dired-do-symlink]."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(dired-do-create-files 'relsymlink #'dired-make-relative-symlink
|
|
|
|
|
"RelSymLink" arg dired-keep-marker-relsymlink))
|
|
|
|
|
|
|
|
|
|
(defun dired-make-relative-symlink (file1 file2 &optional ok-if-already-exists)
|
|
|
|
|
"Make a symbolic link (pointing to FILE1) in FILE2.
|
|
|
|
|
The link is relative (if possible), for example
|
|
|
|
|
|
|
|
|
|
\"/vol/tex/bin/foo\" \"/vol/local/bin/foo\"
|
|
|
|
|
|
|
|
|
|
results in
|
|
|
|
|
|
|
|
|
|
\"../../tex/bin/foo\" \"/vol/local/bin/foo\""
|
|
|
|
|
(interactive "FRelSymLink: \nFRelSymLink %s: \np")
|
|
|
|
|
(let (name1 name2 len1 len2 (index 0) sub)
|
|
|
|
|
(setq file1 (expand-file-name file1)
|
|
|
|
|
file2 (expand-file-name file2)
|
|
|
|
|
len1 (length file1)
|
|
|
|
|
len2 (length file2))
|
|
|
|
|
;; Find common initial file name components:
|
|
|
|
|
(let (next)
|
|
|
|
|
(while (and (setq next (string-search "/" file1 index))
|
|
|
|
|
(< (setq next (1+ next)) (min len1 len2))
|
|
|
|
|
;; For the comparison, both substrings must end in
|
|
|
|
|
;; `/', so NEXT is *one plus* the result of the
|
|
|
|
|
;; string-search.
|
|
|
|
|
;; E.g., consider the case of linking "/tmp/a/abc"
|
|
|
|
|
;; to "/tmp/abc" erroneously giving "/tmp/a" instead
|
|
|
|
|
;; of "/tmp/" as common initial component
|
|
|
|
|
(string-equal (substring file1 0 next)
|
|
|
|
|
(substring file2 0 next)))
|
|
|
|
|
(setq index next))
|
|
|
|
|
(setq name2 file2
|
|
|
|
|
sub (substring file1 0 index)
|
|
|
|
|
name1 (substring file1 index)))
|
|
|
|
|
(if (string-equal sub "/")
|
|
|
|
|
;; No common initial file name found
|
|
|
|
|
(setq name1 file1)
|
|
|
|
|
;; Else they have a common parent directory
|
|
|
|
|
(let ((tem (substring file2 index))
|
|
|
|
|
(start 0)
|
|
|
|
|
(count 0))
|
|
|
|
|
;; Count number of slashes we must compensate for ...
|
|
|
|
|
(while (setq start (string-search "/" tem start))
|
|
|
|
|
(setq count (1+ count)
|
|
|
|
|
start (1+ start)))
|
|
|
|
|
;; ... and prepend a "../" for each slash found:
|
|
|
|
|
(dotimes (_ count)
|
|
|
|
|
(setq name1 (concat "../" name1)))))
|
|
|
|
|
(make-symbolic-link
|
|
|
|
|
(directory-file-name name1) ; must not link to foo/
|
|
|
|
|
; (trailing slash!)
|
|
|
|
|
name2 ok-if-already-exists)))
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-hardlink (&optional arg)
|
|
|
|
|
"Add names (hard links) current file or all marked (or next ARG) files.
|
|
|
|
|
When operating on just the current file, you specify the new name.
|
|
|
|
|
When operating on multiple or marked files, you specify a directory
|
|
|
|
|
and new hard links are made in that directory
|
2001-04-27 15:40:29 +00:00
|
|
|
|
with the same names that the files currently have. The default
|
|
|
|
|
suggested for the target directory depends on the value of
|
2021-09-29 19:10:00 +02:00
|
|
|
|
`dired-dwim-target', which see.
|
|
|
|
|
|
|
|
|
|
Also see `dired-do-revert-buffer'."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive "P")
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-do-create-files 'hardlink #'dired-hardlink
|
2021-06-30 20:10:30 +02:00
|
|
|
|
"Hardlink" arg dired-keep-marker-hardlink))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2002-09-15 01:52:08 +00:00
|
|
|
|
(defun dired-hardlink (file newname &optional ok-if-already-exists)
|
|
|
|
|
(dired-handle-overwrite newname)
|
|
|
|
|
;; error is caught in -create-files
|
|
|
|
|
(add-name-to-file file newname ok-if-already-exists)
|
|
|
|
|
;; Update the link count
|
|
|
|
|
(dired-relist-file file))
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-rename (&optional arg)
|
|
|
|
|
"Rename current file or all marked (or next ARG) files.
|
|
|
|
|
When renaming just the current file, you specify the new name.
|
2001-04-27 15:40:29 +00:00
|
|
|
|
When renaming multiple or marked files, you specify a directory.
|
2002-09-15 01:52:08 +00:00
|
|
|
|
This command also renames any buffers that are visiting the files.
|
2001-04-27 15:40:29 +00:00
|
|
|
|
The default suggested for the target directory depends on the value
|
2021-09-29 19:10:00 +02:00
|
|
|
|
of `dired-dwim-target', which see.
|
|
|
|
|
|
|
|
|
|
Also see `dired-do-revert-buffer'."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive "P")
|
2022-09-24 15:27:50 +02:00
|
|
|
|
(when (seq-find (lambda (file)
|
|
|
|
|
(member (file-name-nondirectory file) '("." "..")))
|
|
|
|
|
(dired-get-marked-files nil arg))
|
|
|
|
|
(user-error "Can't rename \".\" or \"..\" files"))
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-do-create-files 'move #'dired-rename-file
|
1992-06-24 02:14:18 +00:00
|
|
|
|
"Move" arg dired-keep-marker-rename "Rename"))
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
;;; Operate on files matched by regexp
|
|
|
|
|
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defvar rename-regexp-query)
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-do-create-files-regexp
|
2021-06-30 20:10:30 +02:00
|
|
|
|
(file-creator operation arg regexp newname &optional whole-name marker-char)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; Create a new file for each marked file using regexps.
|
|
|
|
|
;; FILE-CREATOR and OPERATION as in dired-create-files.
|
|
|
|
|
;; ARG as in dired-get-marked-files.
|
|
|
|
|
;; Matches each marked file against REGEXP and constructs the new
|
|
|
|
|
;; filename from NEWNAME (like in function replace-match).
|
2003-01-14 23:11:42 +00:00
|
|
|
|
;; Optional arg WHOLE-NAME means match/replace the whole file name
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; instead of only the non-directory part of the file.
|
|
|
|
|
;; Optional arg MARKER-CHAR as in dired-create-files.
|
|
|
|
|
(let* ((fn-list (dired-get-marked-files nil arg))
|
|
|
|
|
(operation-prompt (concat operation " `%s' to `%s'?"))
|
2021-11-22 11:45:44 +01:00
|
|
|
|
(rename-regexp-help-form (format-message
|
|
|
|
|
(substitute-command-keys "\
|
|
|
|
|
Type \\`SPC' or \\`y' to %s one match, \\`DEL' or \\`n' to skip to next,
|
|
|
|
|
\\`!' to %s all remaining matches with no more questions.")
|
|
|
|
|
(downcase operation)
|
|
|
|
|
(downcase operation)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(regexp-name-constructor
|
|
|
|
|
;; Function to construct new filename using REGEXP and NEWNAME:
|
2003-01-14 23:11:42 +00:00
|
|
|
|
(if whole-name ; easy (but rare) case
|
2017-06-26 14:22:27 +09:00
|
|
|
|
(lambda (from)
|
|
|
|
|
(let ((to (dired-string-replace-match regexp from newname))
|
|
|
|
|
;; must bind help-form directly around call to
|
|
|
|
|
;; dired-query
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(help-form rename-regexp-help-form))
|
2017-06-26 14:22:27 +09:00
|
|
|
|
(if to
|
|
|
|
|
(and (dired-query 'rename-regexp-query
|
|
|
|
|
operation-prompt
|
|
|
|
|
from
|
|
|
|
|
to)
|
|
|
|
|
to)
|
|
|
|
|
(dired-log "%s: %s did not match regexp %s\n"
|
|
|
|
|
operation from regexp))))
|
|
|
|
|
;; not whole-name, replace non-directory part only
|
|
|
|
|
(lambda (from)
|
|
|
|
|
(let* ((new (dired-string-replace-match
|
|
|
|
|
regexp (file-name-nondirectory from) newname))
|
|
|
|
|
(to (and new ; nil means there was no match
|
|
|
|
|
(expand-file-name new
|
|
|
|
|
(file-name-directory from))))
|
|
|
|
|
(help-form rename-regexp-help-form))
|
|
|
|
|
(if to
|
|
|
|
|
(and (dired-query 'rename-regexp-query
|
|
|
|
|
operation-prompt
|
|
|
|
|
(dired-make-relative from)
|
|
|
|
|
(dired-make-relative to))
|
|
|
|
|
to)
|
|
|
|
|
(dired-log "%s: %s did not match regexp %s\n"
|
|
|
|
|
operation (file-name-nondirectory from) regexp))))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
rename-regexp-query)
|
|
|
|
|
(dired-create-files
|
|
|
|
|
file-creator operation fn-list regexp-name-constructor marker-char)))
|
|
|
|
|
|
|
|
|
|
(defun dired-mark-read-regexp (operation)
|
|
|
|
|
;; Prompt user about performing OPERATION.
|
2003-01-14 23:11:42 +00:00
|
|
|
|
;; Read and return list of: regexp newname arg whole-name.
|
|
|
|
|
(let* ((whole-name
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(equal 0 (prefix-numeric-value current-prefix-arg)))
|
|
|
|
|
(arg
|
2003-01-14 23:11:42 +00:00
|
|
|
|
(if whole-name nil current-prefix-arg))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(regexp
|
2014-03-22 16:56:19 -07:00
|
|
|
|
(read-regexp
|
|
|
|
|
(concat (if whole-name "Abs. " "") operation " from (regexp): ")
|
|
|
|
|
nil 'dired-regexp-history))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(newname
|
|
|
|
|
(read-string
|
2003-01-14 23:11:42 +00:00
|
|
|
|
(concat (if whole-name "Abs. " "") operation " " regexp " to: "))))
|
|
|
|
|
(list regexp newname arg whole-name)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2003-01-14 23:11:42 +00:00
|
|
|
|
(defun dired-do-rename-regexp (regexp newname &optional arg whole-name)
|
2001-04-30 13:37:00 +00:00
|
|
|
|
"Rename selected files whose names match REGEXP to NEWNAME.
|
|
|
|
|
|
|
|
|
|
With non-zero prefix argument ARG, the command operates on the next ARG
|
|
|
|
|
files. Otherwise, it operates on all the marked files, or the current
|
|
|
|
|
file if none are marked.
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
As each match is found, the user must type a character saying
|
|
|
|
|
what to do with it. For directions, type \\[help-command] at that time.
|
|
|
|
|
NEWNAME may contain \\=\\<n> or \\& as in `query-replace-regexp'.
|
|
|
|
|
REGEXP defaults to the last regexp used.
|
1998-08-13 23:01:05 +00:00
|
|
|
|
|
|
|
|
|
With a zero prefix arg, renaming by regexp affects the absolute file name.
|
|
|
|
|
Normally, only the non-directory part of the file name is used and changed."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive (dired-mark-read-regexp "Rename"))
|
|
|
|
|
(dired-do-create-files-regexp
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'dired-rename-file
|
2003-01-14 23:11:42 +00:00
|
|
|
|
"Rename" arg regexp newname whole-name dired-keep-marker-rename))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2003-01-14 23:11:42 +00:00
|
|
|
|
(defun dired-do-copy-regexp (regexp newname &optional arg whole-name)
|
2001-04-30 13:37:00 +00:00
|
|
|
|
"Copy selected files whose names match REGEXP to NEWNAME.
|
1999-03-09 03:09:39 +00:00
|
|
|
|
See function `dired-do-rename-regexp' for more info."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive (dired-mark-read-regexp "Copy"))
|
1999-09-16 19:29:30 +00:00
|
|
|
|
(let ((dired-recursive-copies nil)) ; No recursive copies.
|
|
|
|
|
(dired-do-create-files-regexp
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'dired-copy-file
|
1999-09-16 19:29:30 +00:00
|
|
|
|
(if dired-copy-preserve-time "Copy [-p]" "Copy")
|
2003-01-14 23:11:42 +00:00
|
|
|
|
arg regexp newname whole-name dired-keep-marker-copy)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2003-01-14 23:11:42 +00:00
|
|
|
|
(defun dired-do-hardlink-regexp (regexp newname &optional arg whole-name)
|
2001-04-30 13:37:00 +00:00
|
|
|
|
"Hardlink selected files whose names match REGEXP to NEWNAME.
|
1999-03-09 03:09:39 +00:00
|
|
|
|
See function `dired-do-rename-regexp' for more info."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive (dired-mark-read-regexp "HardLink"))
|
|
|
|
|
(dired-do-create-files-regexp
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'add-name-to-file
|
2003-01-14 23:11:42 +00:00
|
|
|
|
"HardLink" arg regexp newname whole-name dired-keep-marker-hardlink))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2003-01-14 23:11:42 +00:00
|
|
|
|
(defun dired-do-symlink-regexp (regexp newname &optional arg whole-name)
|
2001-04-30 13:37:00 +00:00
|
|
|
|
"Symlink selected files whose names match REGEXP to NEWNAME.
|
1999-03-09 03:09:39 +00:00
|
|
|
|
See function `dired-do-rename-regexp' for more info."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive (dired-mark-read-regexp "SymLink"))
|
|
|
|
|
(dired-do-create-files-regexp
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'make-symbolic-link
|
2003-01-14 23:11:42 +00:00
|
|
|
|
"SymLink" arg regexp newname whole-name dired-keep-marker-symlink))
|
2022-07-08 18:31:17 +02:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-relsymlink-regexp (regexp newname &optional arg whole-name)
|
|
|
|
|
"RelSymlink all marked files containing REGEXP to NEWNAME.
|
|
|
|
|
See functions `dired-do-rename-regexp' and `dired-do-relsymlink'
|
|
|
|
|
for more info."
|
|
|
|
|
(interactive (dired-mark-read-regexp "RelSymLink"))
|
|
|
|
|
(dired-do-create-files-regexp
|
|
|
|
|
#'dired-make-relative-symlink
|
|
|
|
|
"RelSymLink" arg regexp newname whole-name dired-keep-marker-relsymlink))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
|
|
|
|
;;; Change case of file names
|
|
|
|
|
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defvar rename-non-directory-query)
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-create-files-non-directory
|
2021-06-30 20:10:30 +02:00
|
|
|
|
(file-creator basename-constructor operation arg)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; Perform FILE-CREATOR on the non-directory part of marked files
|
|
|
|
|
;; using function BASENAME-CONSTRUCTOR, with query for each file.
|
|
|
|
|
;; OPERATION like in dired-create-files, ARG as in dired-get-marked-files.
|
|
|
|
|
(let (rename-non-directory-query)
|
|
|
|
|
(dired-create-files
|
|
|
|
|
file-creator
|
|
|
|
|
operation
|
|
|
|
|
(dired-get-marked-files nil arg)
|
2017-06-26 14:22:27 +09:00
|
|
|
|
(lambda (from)
|
|
|
|
|
(let ((to (concat (file-name-directory from)
|
|
|
|
|
(funcall basename-constructor
|
|
|
|
|
(file-name-nondirectory from)))))
|
2021-11-22 11:45:44 +01:00
|
|
|
|
(and (let ((help-form (format-message
|
|
|
|
|
(substitute-command-keys "\
|
|
|
|
|
Type \\`SPC' or \\`y' to %s one file, \\`DEL' or \\`n' to skip to next,
|
|
|
|
|
\\`!' to %s all remaining matches with no more questions.")
|
|
|
|
|
(downcase operation)
|
|
|
|
|
(downcase operation))))
|
2017-06-26 14:22:27 +09:00
|
|
|
|
(dired-query 'rename-non-directory-query
|
|
|
|
|
(concat operation " `%s' to `%s'")
|
|
|
|
|
(dired-make-relative from)
|
|
|
|
|
(dired-make-relative to)))
|
|
|
|
|
to)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
dired-keep-marker-rename)))
|
|
|
|
|
|
|
|
|
|
(defun dired-rename-non-directory (basename-constructor operation arg)
|
|
|
|
|
(dired-create-files-non-directory
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
#'dired-rename-file
|
1992-06-24 02:14:18 +00:00
|
|
|
|
basename-constructor operation arg))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-upcase (&optional arg)
|
|
|
|
|
"Rename all marked (or next ARG) files to upper case."
|
|
|
|
|
(interactive "P")
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-rename-non-directory #'upcase "Rename upcase" arg))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-downcase (&optional arg)
|
|
|
|
|
"Rename all marked (or next ARG) files to lower case."
|
|
|
|
|
(interactive "P")
|
Use #' instead of (function ...)
* lisp/dired-aux.el (dired-do-chxxx, dired-clean-directory)
(dired-mark-confirm, dired-query, dired-byte-compile)
(dired-load, dired-update-file-line, dired-after-subdir-garbage)
(dired-relist-file, dired-rename-subdir, dired-do-create-files)
(dired-mark-read-file-name, dired-do-copy, dired-do-symlink)
(dired-do-hardlink, dired-do-rename, dired-do-rename-regexp)
(dired-do-copy-regexp, dired-do-hardlink-regexp)
(dired-do-symlink-regexp, dired-create-files-non-directory)
(dired-upcase, dired-downcase)
* lisp/dired.el (dired-mode, dired-copy-filename-as-kill)
(dired-internal-do-deletions, dired-internal-do-deletions):
Prefer #' instead of (function ...).
2017-06-26 14:22:34 +09:00
|
|
|
|
(dired-rename-non-directory #'downcase "Rename downcase" arg))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
;;; Insert subdirectory
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-maybe-insert-subdir (dirname &optional
|
|
|
|
|
switches no-error-if-not-dir-p)
|
|
|
|
|
"Insert this subdirectory into the same dired buffer.
|
|
|
|
|
If it is already present, just move to it (type \\[dired-do-redisplay] to refresh),
|
|
|
|
|
else inserts it at its natural place (as `ls -lR' would have done).
|
|
|
|
|
With a prefix arg, you may edit the ls switches used for this listing.
|
|
|
|
|
You can add `R' to the switches to expand the whole tree starting at
|
|
|
|
|
this subdirectory.
|
2004-06-07 21:24:31 +00:00
|
|
|
|
This function takes some pains to conform to `ls -lR' output.
|
|
|
|
|
|
|
|
|
|
Dired remembers switches specified with a prefix arg, so that reverting
|
|
|
|
|
the buffer will not reset them. However, using `dired-undo' to re-insert
|
|
|
|
|
or delete subdirectories can bypass this machinery. Hence, you sometimes
|
|
|
|
|
may have to reset some subdirectory switches after a `dired-undo'.
|
|
|
|
|
You can reset all subdirectory switches to the default using
|
2004-06-15 22:09:18 +00:00
|
|
|
|
\\<dired-mode-map>\\[dired-reset-subdir-switches].
|
2006-05-06 14:37:40 +00:00
|
|
|
|
See Info node `(emacs)Subdir switches' for more details."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list (dired-get-filename)
|
|
|
|
|
(if current-prefix-arg
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(read-string "Switches for listing: "
|
|
|
|
|
(or dired-subdir-switches dired-actual-switches)))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(let ((opoint (point)))
|
|
|
|
|
;; We don't need a marker for opoint as the subdir is always
|
|
|
|
|
;; inserted *after* opoint.
|
|
|
|
|
(setq dirname (file-name-as-directory dirname))
|
|
|
|
|
(or (and (not switches)
|
2014-12-25 21:17:43 +03:00
|
|
|
|
(when (dired-goto-subdir dirname)
|
|
|
|
|
(unless (dired-subdir-hidden-p dirname)
|
|
|
|
|
(dired-initial-position dirname))
|
|
|
|
|
t))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-insert-subdir dirname switches no-error-if-not-dir-p))
|
|
|
|
|
;; Push mark so that it's easy to find back. Do this after the
|
|
|
|
|
;; insert message so that the user sees the `Mark set' message.
|
|
|
|
|
(push-mark opoint)))
|
|
|
|
|
|
1999-12-09 02:01:26 +00:00
|
|
|
|
;;;###autoload
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(defun dired-insert-subdir (dirname &optional switches no-error-if-not-dir-p)
|
2012-06-22 15:30:33 +08:00
|
|
|
|
"Insert this subdirectory into the same Dired buffer.
|
|
|
|
|
If it is already present, overwrite the previous entry;
|
|
|
|
|
otherwise, insert it at its natural place (as `ls -lR' would
|
|
|
|
|
have done).
|
1992-06-24 02:14:18 +00:00
|
|
|
|
With a prefix arg, you may edit the `ls' switches used for this listing.
|
|
|
|
|
You can add `R' to the switches to expand the whole tree starting at
|
|
|
|
|
this subdirectory.
|
|
|
|
|
This function takes some pains to conform to `ls -lR' output."
|
|
|
|
|
;; NO-ERROR-IF-NOT-DIR-P needed for special filesystems like
|
|
|
|
|
;; Prospero where dired-ls does the right thing, but
|
|
|
|
|
;; file-directory-p has not been redefined.
|
|
|
|
|
(interactive
|
|
|
|
|
(list (dired-get-filename)
|
|
|
|
|
(if current-prefix-arg
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(read-string "Switches for listing: "
|
|
|
|
|
(or dired-subdir-switches dired-actual-switches)))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(setq dirname (file-name-as-directory (expand-file-name dirname)))
|
|
|
|
|
(or no-error-if-not-dir-p
|
|
|
|
|
(file-directory-p dirname)
|
|
|
|
|
(error "Attempt to insert a non-directory: %s" dirname))
|
|
|
|
|
(let ((elt (assoc dirname dired-subdir-alist))
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(cons (assoc-string dirname dired-switches-alist))
|
|
|
|
|
(modflag (buffer-modified-p))
|
|
|
|
|
(old-switches switches)
|
|
|
|
|
switches-have-R mark-alist case-fold-search buffer-read-only)
|
|
|
|
|
(and (not switches) cons (setq switches (cdr cons)))
|
|
|
|
|
(dired-insert-subdir-validate dirname switches)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; case-fold-search is nil now, so we can test for capital `R':
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 17:17:29 +02:00
|
|
|
|
(if (setq switches-have-R (and switches (string-match-p "R" switches)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; avoid duplicated subdirs
|
|
|
|
|
(setq mark-alist (dired-kill-tree dirname t)))
|
|
|
|
|
(if elt
|
|
|
|
|
;; If subdir is already present, remove it and remember its marks
|
|
|
|
|
(setq mark-alist (nconc (dired-insert-subdir-del elt) mark-alist))
|
|
|
|
|
(dired-insert-subdir-newpos dirname)) ; else compute new position
|
|
|
|
|
(dired-insert-subdir-doupdate
|
|
|
|
|
dirname elt (dired-insert-subdir-doinsert dirname switches))
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(when old-switches
|
|
|
|
|
(if cons
|
|
|
|
|
(setcdr cons switches)
|
|
|
|
|
(push (cons dirname switches) dired-switches-alist)))
|
|
|
|
|
(when switches-have-R
|
|
|
|
|
(dired-build-subdir-alist switches)
|
2020-09-27 00:50:39 +02:00
|
|
|
|
(setq switches (string-replace "R" "" switches))
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(dolist (cur-ass dired-subdir-alist)
|
|
|
|
|
(let ((cur-dir (car cur-ass)))
|
2022-06-21 21:21:12 +02:00
|
|
|
|
(and (dired-in-this-tree-p cur-dir dirname)
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(let ((cur-cons (assoc-string cur-dir dired-switches-alist)))
|
|
|
|
|
(if cur-cons
|
|
|
|
|
(setcdr cur-cons switches)
|
|
|
|
|
(push (cons cur-dir switches) dired-switches-alist)))))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-initial-position dirname)
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(save-excursion (dired-mark-remembered mark-alist))
|
|
|
|
|
(restore-buffer-modified-p modflag)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-insert-subdir-validate (dirname &optional switches)
|
|
|
|
|
;; Check that it is valid to insert DIRNAME with SWITCHES.
|
|
|
|
|
;; Signal an error if invalid (e.g. user typed `i' on `..').
|
2022-06-21 21:21:12 +02:00
|
|
|
|
(or (dired-in-this-tree-p dirname (expand-file-name default-directory))
|
2021-09-27 23:56:55 +02:00
|
|
|
|
(error "%s: Not in this directory tree" dirname))
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(let ((real-switches (or switches dired-subdir-switches)))
|
|
|
|
|
(when real-switches
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(let (case-fold-search)
|
|
|
|
|
(mapcar
|
2017-06-26 14:22:27 +09:00
|
|
|
|
(lambda (x)
|
|
|
|
|
(or (eq (null (string-match-p x real-switches))
|
|
|
|
|
(null (string-match-p x dired-actual-switches)))
|
|
|
|
|
(error
|
|
|
|
|
"Can't have dirs with and without -%s switches together" x)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; all switches that make a difference to dired-get-filename:
|
2004-06-06 02:26:46 +00:00
|
|
|
|
'("F" "b"))))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-alist-add (dir new-marker)
|
|
|
|
|
;; Add new DIR at NEW-MARKER. Sort alist.
|
|
|
|
|
(dired-alist-add-1 dir new-marker)
|
|
|
|
|
(dired-alist-sort))
|
|
|
|
|
|
|
|
|
|
(defun dired-alist-sort ()
|
|
|
|
|
;; Keep the alist sorted on buffer position.
|
|
|
|
|
(setq dired-subdir-alist
|
|
|
|
|
(sort dired-subdir-alist
|
2017-06-26 14:22:27 +09:00
|
|
|
|
(lambda (elt1 elt2)
|
2019-11-10 22:15:31 +01:00
|
|
|
|
(> (cdr elt1)
|
|
|
|
|
(cdr elt2))))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2004-06-09 00:25:30 +00:00
|
|
|
|
(defun dired-kill-tree (dirname &optional remember-marks kill-root)
|
2000-10-04 23:35:52 +00:00
|
|
|
|
"Kill all proper subdirs of DIRNAME, excluding DIRNAME itself.
|
2004-06-09 00:25:30 +00:00
|
|
|
|
Interactively, you can kill DIRNAME as well by using a prefix argument.
|
|
|
|
|
In interactive use, the command prompts for DIRNAME.
|
|
|
|
|
|
|
|
|
|
When called from Lisp, if REMEMBER-MARKS is non-nil, return an alist
|
|
|
|
|
of marked files. If KILL-ROOT is non-nil, kill DIRNAME as well."
|
|
|
|
|
(interactive "DKill tree below directory: \ni\nP")
|
|
|
|
|
(setq dirname (file-name-as-directory (expand-file-name dirname)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(let ((s-alist dired-subdir-alist) dir m-alist)
|
|
|
|
|
(while s-alist
|
|
|
|
|
(setq dir (car (car s-alist))
|
|
|
|
|
s-alist (cdr s-alist))
|
2004-06-09 00:25:30 +00:00
|
|
|
|
(and (or kill-root (not (string-equal dir dirname)))
|
2021-08-08 16:45:50 +02:00
|
|
|
|
(dired-in-this-tree-p dir dirname)
|
2004-06-09 00:25:30 +00:00
|
|
|
|
(dired-goto-subdir dir)
|
|
|
|
|
(setq m-alist (nconc (dired-kill-subdir remember-marks) m-alist))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
m-alist))
|
|
|
|
|
|
|
|
|
|
(defun dired-insert-subdir-newpos (new-dir)
|
|
|
|
|
;; Find pos for new subdir, according to tree order.
|
|
|
|
|
;;(goto-char (point-max))
|
lisp/*.el: Remove lexical-binding warnings; additional small cleanups.
* calculator.el (calculator): Mark unused argument.
(calculator-paste, calculator-quit, calculator-integer-p):
Use ignore-errors.
(calculator-string-to-number, calculator-decimal, calculator-exp)
(calculator-op-or-exp): Use string-match-p.
* dired-aux.el (dired-compress): Use ignore-errors.
(dired-do-chxxx, dired-do-chmod, dired-trample-file-versions)
(dired-do-async-shell-command, dired-do-shell-command)
(dired-shell-stuff-it, dired-compress-file, dired-insert-subdir)
(dired-insert-subdir-validate): Use string-match-p.
(dired-map-dired-file-lines, dired-subdir-hidden-p): Use looking-at-p.
(dired-add-entry): Use string-match-p, looking-at-p.
(dired-insert-subdir-newpos): Remove unused local variable.
* dired.el (dired-buffer-more-recently-used-p): Declare.
(dired-insert-set-properties, dired-insert-old-subdirs):
Use ignore-errors.
* filenotify.el (file-notify-callback): Remove unused local variable.
* filesets.el (filesets-error): Mark unused argument.
(filesets-which-command-p, filesets-filter-dir-names)
(filesets-directory-files, filesets-get-external-viewer)
(filesets-ingroup-get-data): Use string-match-p.
* find-file.el (ff-other-file-name, ff-other-file-name)
(ff-find-the-other-file, ff-cc-hh-converter):
Remove unused local variables.
(ff-get-file-name): Use string-match-p.
(ff-all-dirs-under): Use ignore-errors.
* follow.el (follow-comint-scroll-to-bottom): Mark unused argument.
(follow-select-if-visible): Remove unused local variable.
* forms.el (read-file-filter): Move declaration.
(forms--make-format, forms--make-parser, forms-insert-record):
Quote function with #'.
(forms--update): Use string-match-p. Quote function with #'.
* help-mode.el (help-dir-local-var-def): Mark unused argument.
(help-make-xrefs): Use looking-at-p.
(help-xref-on-pp): Use looking-at-p, ignore-errors.
* ibuffer.el (ibuffer-ext-visible-p): Declare.
(ibuffer-confirm-operation-on): Use string-match-p.
* msb.el (msb-item-handler, msb-dired-item-handler):
Mark unused arguments.
* ses.el (ses-decode-cell-symbol)
(ses-kill-override): Remove unused local variable.
(ses-create-cell-variable, ses-relocate-formula): Use string-match-p.
(ses-load): Use ignore-errors, looking-at-p.
(ses-jump-safe): Use ignore-errors.
(ses-export-tsv, ses-export-tsf, ses-unsafe): Mark unused arguments.
* tabify.el (untabify, tabify): Mark unused arguments.
* thingatpt.el (thing-at-point--bounds-of-well-formed-url):
Mark unused argument.
(bounds-of-thing-at-point, thing-at-point-bounds-of-list-at-point)
(thing-at-point-newsgroup-p, form-at-point): Use ignore-errors.
2013-08-10 17:17:29 +02:00
|
|
|
|
(let ((alist dired-subdir-alist) elt dir new-pos)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(while alist
|
|
|
|
|
(setq elt (car alist)
|
|
|
|
|
alist (cdr alist)
|
2011-04-19 15:44:55 +02:00
|
|
|
|
dir (car elt))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(if (dired-tree-lessp dir new-dir)
|
|
|
|
|
;; Insert NEW-DIR after DIR
|
|
|
|
|
(setq new-pos (dired-get-subdir-max elt)
|
|
|
|
|
alist nil)))
|
|
|
|
|
(goto-char new-pos))
|
|
|
|
|
;; want a separating newline between subdirs
|
|
|
|
|
(or (eobp)
|
|
|
|
|
(forward-line -1))
|
|
|
|
|
(insert "\n")
|
|
|
|
|
(point))
|
|
|
|
|
|
|
|
|
|
(defun dired-insert-subdir-del (element)
|
|
|
|
|
;; Erase an already present subdir (given by ELEMENT) from buffer.
|
|
|
|
|
;; Move to that buffer position. Return a mark-alist.
|
2019-11-10 22:15:31 +01:00
|
|
|
|
(let ((begin-marker (cdr element)))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(goto-char begin-marker)
|
|
|
|
|
;; Are at beginning of subdir (and inside it!). Now determine its end:
|
|
|
|
|
(goto-char (dired-subdir-max))
|
|
|
|
|
(or (eobp);; want a separating newline _between_ subdirs:
|
|
|
|
|
(forward-char -1))
|
|
|
|
|
(prog1
|
|
|
|
|
(dired-remember-marks begin-marker (point))
|
|
|
|
|
(delete-region begin-marker (point)))))
|
|
|
|
|
|
|
|
|
|
(defun dired-insert-subdir-doinsert (dirname switches)
|
2002-09-15 01:52:08 +00:00
|
|
|
|
;; Insert ls output after point.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; Return the boundary of the inserted text (as list of BEG and END).
|
2002-10-16 21:32:41 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((begin (point)))
|
|
|
|
|
(let ((dired-actual-switches
|
|
|
|
|
(or switches
|
2004-06-06 02:26:46 +00:00
|
|
|
|
dired-subdir-switches
|
2020-09-27 00:50:39 +02:00
|
|
|
|
(string-replace "R" "" dired-actual-switches))))
|
2002-10-16 21:32:41 +00:00
|
|
|
|
(if (equal dirname (car (car (last dired-subdir-alist))))
|
|
|
|
|
;; If doing the top level directory of the buffer,
|
|
|
|
|
;; redo it as specified in dired-directory.
|
|
|
|
|
(dired-readin-insert)
|
|
|
|
|
(dired-insert-directory dirname dired-actual-switches nil nil t)))
|
|
|
|
|
(list begin (point)))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-insert-subdir-doupdate (dirname elt beg-end)
|
|
|
|
|
;; Point is at the correct subdir alist position for ELT,
|
|
|
|
|
;; BEG-END is the subdir-region (as list of begin and end).
|
|
|
|
|
(if elt ; subdir was already present
|
|
|
|
|
;; update its position (should actually be unchanged)
|
2019-11-10 22:15:31 +01:00
|
|
|
|
(set-marker (cdr elt) (point-marker))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(dired-alist-add dirname (point-marker)))
|
|
|
|
|
;; The hook may depend on the subdir-alist containing the just
|
|
|
|
|
;; inserted subdir, so run it after dired-alist-add:
|
|
|
|
|
(if dired-after-readin-hook
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((begin (nth 0 beg-end))
|
|
|
|
|
(end (nth 1 beg-end)))
|
|
|
|
|
(goto-char begin)
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region begin end)
|
|
|
|
|
;; hook may add or delete lines, but the subdir boundary
|
|
|
|
|
;; marker floats
|
|
|
|
|
(run-hooks 'dired-after-readin-hook))))))
|
|
|
|
|
|
|
|
|
|
(defun dired-tree-lessp (dir1 dir2)
|
1998-08-13 23:01:05 +00:00
|
|
|
|
;; Lexicographic order on file name components, like `ls -lR':
|
2007-08-08 07:40:09 +00:00
|
|
|
|
;; DIR1 < DIR2 if DIR1 comes *before* DIR2 in an `ls -lR' listing,
|
|
|
|
|
;; i.e., if DIR1 is a (grand)parent dir of DIR2,
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; or DIR1 and DIR2 are in the same parentdir and their last
|
|
|
|
|
;; components are string-lessp.
|
|
|
|
|
;; Thus ("/usr/" "/usr/bin") and ("/usr/a/" "/usr/b/") are tree-lessp.
|
|
|
|
|
;; string-lessp could arguably be replaced by file-newer-than-file-p
|
2015-05-21 10:04:45 -07:00
|
|
|
|
;; if dired-actual-switches contained t.
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(setq dir1 (file-name-as-directory dir1)
|
|
|
|
|
dir2 (file-name-as-directory dir2))
|
2021-11-09 23:58:42 +01:00
|
|
|
|
(let ((components-1 (split-string dir1 "/"))
|
|
|
|
|
(components-2 (split-string dir2 "/")))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(while (and components-1
|
|
|
|
|
components-2
|
|
|
|
|
(equal (car components-1) (car components-2)))
|
|
|
|
|
(setq components-1 (cdr components-1)
|
|
|
|
|
components-2 (cdr components-2)))
|
|
|
|
|
(let ((c1 (car components-1))
|
|
|
|
|
(c2 (car components-2)))
|
|
|
|
|
|
|
|
|
|
(cond ((and c1 c2)
|
|
|
|
|
(string-lessp c1 c2))
|
|
|
|
|
((and (null c1) (null c2))
|
|
|
|
|
nil) ; they are equal, not lessp
|
|
|
|
|
((null c1) ; c2 is a subdir of c1: c1<c2
|
|
|
|
|
t)
|
|
|
|
|
((null c2) ; c1 is a subdir of c2: c1>c2
|
|
|
|
|
nil)
|
|
|
|
|
(t (error "This can't happen"))))))
|
|
|
|
|
|
|
|
|
|
(defun dired-split (pat str &optional limit)
|
|
|
|
|
"Splitting on regexp PAT, turn string STR into a list of substrings.
|
|
|
|
|
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,
|
|
|
|
|
|
2022-08-03 13:13:57 +02:00
|
|
|
|
(mapconcat #\\='identity (dired-split SEP STRING) SEP)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
is always equal to STRING."
|
2021-11-09 23:58:42 +01:00
|
|
|
|
(declare (obsolete split-string "29.1"))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(let* ((start (string-match pat str))
|
|
|
|
|
(result (list (substring str 0 start)))
|
|
|
|
|
(count 1)
|
|
|
|
|
(end (if start (match-end 0))))
|
|
|
|
|
(if end ; else nothing left
|
|
|
|
|
(while (and (or (not (integerp limit))
|
|
|
|
|
(< count limit))
|
|
|
|
|
(string-match pat str end))
|
|
|
|
|
(setq start (match-beginning 0)
|
|
|
|
|
count (1+ count)
|
|
|
|
|
result (cons (substring str end start) result)
|
|
|
|
|
end (match-end 0)
|
|
|
|
|
start end)
|
|
|
|
|
))
|
|
|
|
|
(if (and (or (not (integerp limit))
|
|
|
|
|
(< count limit))
|
|
|
|
|
end) ; else nothing left
|
|
|
|
|
(setq result
|
|
|
|
|
(cons (substring str end) result)))
|
|
|
|
|
(nreverse result)))
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
;;; Moving by subdirectories
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-prev-subdir (arg &optional no-error-if-not-found no-skip)
|
|
|
|
|
"Go to previous subdirectory, regardless of level.
|
|
|
|
|
When called interactively and not on a subdir line, go to this subdir's line."
|
|
|
|
|
;;(interactive "p")
|
|
|
|
|
(interactive
|
|
|
|
|
(list (if current-prefix-arg
|
|
|
|
|
(prefix-numeric-value current-prefix-arg)
|
|
|
|
|
;; if on subdir start already, don't stay there!
|
|
|
|
|
(if (dired-get-subdir) 1 0))))
|
|
|
|
|
(dired-next-subdir (- arg) no-error-if-not-found no-skip))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-goto-subdir (dir)
|
2022-07-03 15:16:23 +02:00
|
|
|
|
"Go to end of header line of inserted directory DIR in this Dired buffer.
|
|
|
|
|
When called interactively, prompt for the inserted subdirectory
|
|
|
|
|
to go to.
|
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
Return value of point on success, otherwise return nil.
|
2019-03-17 13:35:20 -04:00
|
|
|
|
The next char is \\n."
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(prog1 ; let push-mark display its message
|
|
|
|
|
(list (expand-file-name
|
2022-07-03 15:16:23 +02:00
|
|
|
|
(completing-read "Goto inserted directory: "
|
|
|
|
|
dired-subdir-alist nil t
|
|
|
|
|
(dired-current-directory))))
|
|
|
|
|
(push-mark))
|
|
|
|
|
dired-mode)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(setq dir (file-name-as-directory dir))
|
|
|
|
|
(let ((elt (assoc dir dired-subdir-alist)))
|
|
|
|
|
(and elt
|
2019-11-10 22:15:31 +01:00
|
|
|
|
(goto-char (cdr elt))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; dired-subdir-hidden-p and dired-add-entry depend on point being
|
2019-03-17 13:35:20 -04:00
|
|
|
|
;; at \n after this function succeeds.
|
|
|
|
|
(progn (end-of-line)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(point)))))
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-mark-subdir-files ()
|
1998-05-16 04:14:04 +00:00
|
|
|
|
"Mark all files except `.' and `..' in current subdirectory.
|
|
|
|
|
If the Dired buffer shows multiple directories, this command
|
|
|
|
|
marks the files listed in the subdirectory that point is in."
|
1994-05-07 01:56:19 +00:00
|
|
|
|
(interactive)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(let ((p-min (dired-subdir-min)))
|
|
|
|
|
(dired-mark-files-in-region p-min (dired-subdir-max))))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-kill-subdir (&optional remember-marks)
|
|
|
|
|
"Remove all lines of current subdirectory.
|
|
|
|
|
Lower levels are unaffected."
|
|
|
|
|
;; With optional REMEMBER-MARKS, return a mark-alist.
|
|
|
|
|
(interactive)
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(let* ((beg (dired-subdir-min))
|
|
|
|
|
(end (dired-subdir-max))
|
|
|
|
|
(modflag (buffer-modified-p))
|
|
|
|
|
(cur-dir (dired-current-directory))
|
|
|
|
|
(cons (assoc-string cur-dir dired-switches-alist))
|
|
|
|
|
buffer-read-only)
|
2016-04-24 17:05:33 +02:00
|
|
|
|
(when (equal cur-dir (expand-file-name default-directory))
|
|
|
|
|
(error "Attempt to kill top level directory"))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(prog1
|
|
|
|
|
(if remember-marks (dired-remember-marks beg end))
|
|
|
|
|
(delete-region beg end)
|
|
|
|
|
(if (eobp) ; don't leave final blank line
|
|
|
|
|
(delete-char -1))
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(dired-unsubdir cur-dir)
|
|
|
|
|
(when cons
|
|
|
|
|
(setq dired-switches-alist (delete cons dired-switches-alist)))
|
|
|
|
|
(restore-buffer-modified-p modflag))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-unsubdir (dir)
|
|
|
|
|
;; Remove DIR from the alist
|
|
|
|
|
(setq dired-subdir-alist
|
|
|
|
|
(delq (assoc dir dired-subdir-alist) dired-subdir-alist)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-tree-up (arg)
|
|
|
|
|
"Go up ARG levels in the dired tree."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(let ((dir (dired-current-directory)))
|
|
|
|
|
(while (>= arg 1)
|
|
|
|
|
(setq arg (1- arg)
|
|
|
|
|
dir (file-name-directory (directory-file-name dir))))
|
|
|
|
|
;;(setq dir (expand-file-name dir))
|
|
|
|
|
(or (dired-goto-subdir dir)
|
2001-07-15 16:15:35 +00:00
|
|
|
|
(error "Cannot go up to %s - not in this tree" dir))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-tree-down ()
|
|
|
|
|
"Go down in the dired tree."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((dir (dired-current-directory)) ; has slash
|
|
|
|
|
pos case-fold-search) ; filenames are case sensitive
|
|
|
|
|
(let ((rest (reverse dired-subdir-alist)) elt)
|
|
|
|
|
(while rest
|
|
|
|
|
(setq elt (car rest)
|
|
|
|
|
rest (cdr rest))
|
2021-08-08 16:45:50 +02:00
|
|
|
|
(if (dired-in-this-tree-p (directory-file-name (car elt)) dir)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
(setq rest nil
|
|
|
|
|
pos (dired-goto-subdir (car elt))))))
|
|
|
|
|
(if pos
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
(error "At the bottom"))))
|
2021-03-14 20:24:07 +01:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
;;; Hiding
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-hide-subdir (arg)
|
|
|
|
|
"Hide or unhide the current subdirectory and move to next directory.
|
|
|
|
|
Optional prefix arg is a repeat factor.
|
|
|
|
|
Use \\[dired-hide-all] to (un)hide all directories."
|
|
|
|
|
(interactive "p")
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(with-silent-modifications
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(while (>= (setq arg (1- arg)) 0)
|
|
|
|
|
(let* ((cur-dir (dired-current-directory))
|
|
|
|
|
(hidden-p (dired-subdir-hidden-p cur-dir))
|
|
|
|
|
(elt (assoc cur-dir dired-subdir-alist))
|
|
|
|
|
(end-pos (1- (dired-get-subdir-max elt)))
|
|
|
|
|
buffer-read-only)
|
|
|
|
|
;; keep header line visible, hide rest
|
2019-11-10 22:15:31 +01:00
|
|
|
|
(goto-char (cdr elt))
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(end-of-line)
|
2004-06-06 02:26:46 +00:00
|
|
|
|
(if hidden-p
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(dired--unhide (point) end-pos)
|
|
|
|
|
(dired--hide (point) end-pos)))
|
|
|
|
|
(dired-next-subdir 1 t))))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2010-01-20 11:42:50 -05:00
|
|
|
|
(defun dired-hide-all (&optional ignored)
|
1992-06-24 02:14:18 +00:00
|
|
|
|
"Hide all subdirectories, leaving only their header lines.
|
|
|
|
|
If there is already something hidden, make everything visible again.
|
|
|
|
|
Use \\[dired-hide-subdir] to (un)hide a particular subdirectory."
|
|
|
|
|
(interactive "P")
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(with-silent-modifications
|
|
|
|
|
(if (text-property-any (point-min) (point-max) 'invisible 'dired)
|
|
|
|
|
(dired--unhide (point-min) (point-max))
|
1992-06-24 02:14:18 +00:00
|
|
|
|
;; hide
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(let ((pos (point-max))) ; pos of end of last directory
|
|
|
|
|
(dolist (subdir dired-subdir-alist)
|
2019-11-10 22:15:31 +01:00
|
|
|
|
(let ((start (cdr subdir)) ; pos of prev dir
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(end (save-excursion
|
|
|
|
|
(goto-char pos) ; current dir
|
|
|
|
|
;; we're somewhere on current dir's line
|
|
|
|
|
(forward-line -1)
|
|
|
|
|
(point))))
|
|
|
|
|
(dired--hide start end))
|
2019-11-10 22:15:31 +01:00
|
|
|
|
(setq pos (cdr subdir))))))) ; prev dir gets current dir
|
1992-06-24 02:14:18 +00:00
|
|
|
|
|
2008-07-29 14:42:35 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
;;; Search only in file names in the Dired buffer
|
2008-07-29 14:42:35 +00:00
|
|
|
|
|
|
|
|
|
(defcustom dired-isearch-filenames nil
|
2008-12-03 05:48:14 +00:00
|
|
|
|
"Non-nil to Isearch in file names only.
|
2008-11-22 20:40:28 +00:00
|
|
|
|
If t, Isearch in Dired always matches only file names.
|
|
|
|
|
If `dwim', Isearch matches file names when initial point position is on
|
|
|
|
|
a file name. Otherwise, it searches the whole buffer without restrictions."
|
2008-07-29 14:42:35 +00:00
|
|
|
|
:type '(choice (const :tag "No restrictions" nil)
|
2008-11-22 20:40:28 +00:00
|
|
|
|
(const :tag "When point is on a file name initially, search file names" dwim)
|
|
|
|
|
(const :tag "Always search in file names" t))
|
2008-07-29 14:42:35 +00:00
|
|
|
|
:group 'dired
|
|
|
|
|
:version "23.1")
|
|
|
|
|
|
2013-08-05 14:05:46 -04:00
|
|
|
|
(define-minor-mode dired-isearch-filenames-mode
|
2008-07-31 16:50:54 +00:00
|
|
|
|
"Toggle file names searching on or off.
|
2022-03-28 21:00:32 +03:00
|
|
|
|
When on, Isearch skips matches outside file names using the search function
|
|
|
|
|
`dired-isearch-search-filenames' that matches only at file names.
|
|
|
|
|
When off, it uses the default search function."
|
2021-04-11 23:47:14 -04:00
|
|
|
|
:lighter nil
|
2013-08-05 14:05:46 -04:00
|
|
|
|
(if dired-isearch-filenames-mode
|
2022-03-28 21:00:32 +03:00
|
|
|
|
(add-function :around (local 'isearch-search-fun-function)
|
|
|
|
|
#'dired-isearch-search-filenames
|
2019-03-17 13:35:20 -04:00
|
|
|
|
'((isearch-message-prefix . "filename ")))
|
2022-03-28 21:00:32 +03:00
|
|
|
|
(remove-function (local 'isearch-search-fun-function)
|
|
|
|
|
#'dired-isearch-search-filenames))
|
2013-08-05 14:05:46 -04:00
|
|
|
|
(when isearch-mode
|
|
|
|
|
(setq isearch-success t isearch-adjusted t)
|
|
|
|
|
(isearch-update)))
|
2008-07-31 16:50:54 +00:00
|
|
|
|
|
2008-07-30 14:18:28 +00:00
|
|
|
|
;;;###autoload
|
2008-07-29 14:42:35 +00:00
|
|
|
|
(defun dired-isearch-filenames-setup ()
|
|
|
|
|
"Set up isearch to search in Dired file names.
|
|
|
|
|
Intended to be added to `isearch-mode-hook'."
|
2008-11-22 20:40:28 +00:00
|
|
|
|
(when (or (eq dired-isearch-filenames t)
|
|
|
|
|
(and (eq dired-isearch-filenames 'dwim)
|
|
|
|
|
(get-text-property (point) 'dired-filename)))
|
2013-08-05 14:05:46 -04:00
|
|
|
|
(define-key isearch-mode-map "\M-sff" 'dired-isearch-filenames-mode)
|
|
|
|
|
(dired-isearch-filenames-mode 1)
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(add-hook 'isearch-mode-end-hook #'dired-isearch-filenames-end nil t)))
|
2008-07-29 14:42:35 +00:00
|
|
|
|
|
|
|
|
|
(defun dired-isearch-filenames-end ()
|
|
|
|
|
"Clean up the Dired file name search after terminating isearch."
|
2013-05-28 01:42:11 +03:00
|
|
|
|
(define-key isearch-mode-map "\M-sff" nil)
|
2013-08-05 14:05:46 -04:00
|
|
|
|
(dired-isearch-filenames-mode -1)
|
2019-03-17 13:35:20 -04:00
|
|
|
|
(remove-hook 'isearch-mode-end-hook #'dired-isearch-filenames-end t)
|
2018-01-23 00:14:10 +02:00
|
|
|
|
(unless isearch-suspended
|
2019-11-29 00:54:52 +03:00
|
|
|
|
(kill-local-variable 'dired-isearch-filenames)))
|
2008-07-29 14:42:35 +00:00
|
|
|
|
|
2022-03-28 21:00:32 +03:00
|
|
|
|
(defun dired-isearch-search-filenames (orig-fun)
|
|
|
|
|
"Return the function that searches inside file names.
|
|
|
|
|
The returned function narrows the search to match the search string
|
|
|
|
|
only as part of a file name enclosed by the text property `dired-filename'.
|
|
|
|
|
It's intended to override the default search function."
|
2022-08-27 22:43:40 +03:00
|
|
|
|
(isearch-search-fun-in-text-property
|
|
|
|
|
(funcall orig-fun) '(dired-filename dired-symlink-filename)))
|
2013-05-28 01:42:11 +03:00
|
|
|
|
|
2008-07-29 14:42:35 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-isearch-filenames ()
|
|
|
|
|
"Search for a string using Isearch only in file names in the Dired buffer."
|
|
|
|
|
(interactive)
|
2020-12-09 09:18:04 +01:00
|
|
|
|
(setq-local dired-isearch-filenames t)
|
2018-01-23 00:14:10 +02:00
|
|
|
|
(isearch-forward nil t))
|
2008-07-29 14:42:35 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-isearch-filenames-regexp ()
|
|
|
|
|
"Search for a regexp using Isearch only in file names in the Dired buffer."
|
|
|
|
|
(interactive)
|
2020-12-09 09:18:04 +01:00
|
|
|
|
(setq-local dired-isearch-filenames t)
|
2018-01-23 00:14:10 +02:00
|
|
|
|
(isearch-forward-regexp nil t))
|
2008-07-29 14:42:35 +00:00
|
|
|
|
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2021-03-14 20:24:07 +01:00
|
|
|
|
;;; Functions for searching in tags style among marked files
|
1994-10-22 16:00:31 +00:00
|
|
|
|
|
2008-07-28 14:28:59 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-isearch ()
|
|
|
|
|
"Search for a string through all marked files using Isearch."
|
|
|
|
|
(interactive)
|
|
|
|
|
(multi-isearch-files
|
* lisp/multifile.el: New file, extracted from etags.el
The main motivation for this change was the introduction of
project-query-replace. dired's multi-file query&replace was implemented
on top of etags.el even though it did not use TAGS in any way, so I moved
this generic multifile code into its own package, with a nicer interface,
and then used that in project.el.
* lisp/progmodes/project.el (project-files): New generic function.
(project-search, project-query-replace): New commands.
* lisp/dired-aux.el (dired-do-search, dired-do-query-replace-regexp):
Use multifile.el instead of etags.el.
* lisp/progmodes/etags.el: Remove redundant :groups.
(next-file-list): Remove var.
(tags-loop-revert-buffers): Make it an obsolete alias.
(next-file): Don't autoload (it can't do anything useful before some
other etags.el function setup the multifile operation).
(tags--all-files): New function, extracted from next-file.
(tags-next-file): Rename from next-file.
Rewrite using tags--all-files and multifile-next-file.
(next-file): Keep it as an obsolete alias.
(tags-loop-operate, tags-loop-scan): Mark as obsolete.
(tags--compat-files, tags--compat-initialize): New function.
(tags-loop-continue): Rewrite using multifile-continue. Mark as obsolete.
(tags--last-search-operate-function): New var.
(tags-search, tags-query-replace): Rewrite using multifile.el.
* lisp/emacs-lisp/generator.el (iter-end-of-sequence): Use 'define-error'.
(iter-make): New macro.
(iter-empty): New iterator.
* lisp/menu-bar.el (menu-bar-search-menu, menu-bar-replace-menu):
tags-loop-continue -> multifile-continue.
2018-09-22 11:46:35 -04:00
|
|
|
|
(dired-get-marked-files nil nil #'dired-nondirectory-p nil t)))
|
2008-07-28 14:28:59 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-isearch-regexp ()
|
|
|
|
|
"Search for a regexp through all marked files using Isearch."
|
|
|
|
|
(interactive)
|
|
|
|
|
(multi-isearch-files-regexp
|
2018-02-06 23:32:08 +02:00
|
|
|
|
(dired-get-marked-files nil nil 'dired-nondirectory-p nil t)))
|
2008-07-28 14:28:59 +00:00
|
|
|
|
|
2019-05-17 06:07:00 +02:00
|
|
|
|
(declare-function fileloop-continue "fileloop" ())
|
|
|
|
|
|
1994-10-22 16:00:31 +00:00
|
|
|
|
;;;###autoload
|
1995-04-15 05:42:25 +00:00
|
|
|
|
(defun dired-do-search (regexp)
|
1994-10-22 16:00:31 +00:00
|
|
|
|
"Search through all marked files for a match for REGEXP.
|
2019-08-02 14:16:25 +02:00
|
|
|
|
If no files are marked, search through the file under point.
|
|
|
|
|
|
1994-10-22 16:00:31 +00:00
|
|
|
|
Stops when a match is found.
|
2019-08-02 14:16:25 +02:00
|
|
|
|
|
2019-08-01 21:21:59 +02:00
|
|
|
|
To continue searching for next match, use command \\[fileloop-continue]."
|
1994-10-22 16:00:31 +00:00
|
|
|
|
(interactive "sSearch marked files (regexp): ")
|
2019-02-07 12:20:09 +03:00
|
|
|
|
(fileloop-initialize-search
|
* lisp/multifile.el: New file, extracted from etags.el
The main motivation for this change was the introduction of
project-query-replace. dired's multi-file query&replace was implemented
on top of etags.el even though it did not use TAGS in any way, so I moved
this generic multifile code into its own package, with a nicer interface,
and then used that in project.el.
* lisp/progmodes/project.el (project-files): New generic function.
(project-search, project-query-replace): New commands.
* lisp/dired-aux.el (dired-do-search, dired-do-query-replace-regexp):
Use multifile.el instead of etags.el.
* lisp/progmodes/etags.el: Remove redundant :groups.
(next-file-list): Remove var.
(tags-loop-revert-buffers): Make it an obsolete alias.
(next-file): Don't autoload (it can't do anything useful before some
other etags.el function setup the multifile operation).
(tags--all-files): New function, extracted from next-file.
(tags-next-file): Rename from next-file.
Rewrite using tags--all-files and multifile-next-file.
(next-file): Keep it as an obsolete alias.
(tags-loop-operate, tags-loop-scan): Mark as obsolete.
(tags--compat-files, tags--compat-initialize): New function.
(tags-loop-continue): Rewrite using multifile-continue. Mark as obsolete.
(tags--last-search-operate-function): New var.
(tags-search, tags-query-replace): Rewrite using multifile.el.
* lisp/emacs-lisp/generator.el (iter-end-of-sequence): Use 'define-error'.
(iter-make): New macro.
(iter-empty): New iterator.
* lisp/menu-bar.el (menu-bar-search-menu, menu-bar-replace-menu):
tags-loop-continue -> multifile-continue.
2018-09-22 11:46:35 -04:00
|
|
|
|
regexp
|
|
|
|
|
(dired-get-marked-files nil nil #'dired-nondirectory-p)
|
|
|
|
|
'default)
|
2019-02-07 12:20:09 +03:00
|
|
|
|
(fileloop-continue))
|
1994-10-22 16:00:31 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2000-05-16 14:32:59 +00:00
|
|
|
|
(defun dired-do-query-replace-regexp (from to &optional delimited)
|
1995-04-15 05:42:25 +00:00
|
|
|
|
"Do `query-replace-regexp' of FROM with TO, on all marked files.
|
2022-04-21 14:54:45 +03:00
|
|
|
|
As each match is found, the user must type a character saying
|
|
|
|
|
what to do with it. Type SPC or `y' to replace the match,
|
|
|
|
|
DEL or `n' to skip and go to the next match. For more directions,
|
|
|
|
|
type \\[help-command] at that time.
|
|
|
|
|
|
1994-10-22 16:00:31 +00:00
|
|
|
|
Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
|
2022-04-21 14:54:45 +03:00
|
|
|
|
If you exit the query-replace loop (\\[keyboard-quit], RET or q), you can
|
2022-05-08 13:17:34 +02:00
|
|
|
|
resume the query replace with the command \\[fileloop-continue]."
|
1994-10-22 16:00:31 +00:00
|
|
|
|
(interactive
|
2005-08-09 21:38:24 +00:00
|
|
|
|
(let ((common
|
|
|
|
|
(query-replace-read-args
|
|
|
|
|
"Query replace regexp in marked files" t t)))
|
|
|
|
|
(list (nth 0 common) (nth 1 common) (nth 2 common))))
|
* lisp/multifile.el: New file, extracted from etags.el
The main motivation for this change was the introduction of
project-query-replace. dired's multi-file query&replace was implemented
on top of etags.el even though it did not use TAGS in any way, so I moved
this generic multifile code into its own package, with a nicer interface,
and then used that in project.el.
* lisp/progmodes/project.el (project-files): New generic function.
(project-search, project-query-replace): New commands.
* lisp/dired-aux.el (dired-do-search, dired-do-query-replace-regexp):
Use multifile.el instead of etags.el.
* lisp/progmodes/etags.el: Remove redundant :groups.
(next-file-list): Remove var.
(tags-loop-revert-buffers): Make it an obsolete alias.
(next-file): Don't autoload (it can't do anything useful before some
other etags.el function setup the multifile operation).
(tags--all-files): New function, extracted from next-file.
(tags-next-file): Rename from next-file.
Rewrite using tags--all-files and multifile-next-file.
(next-file): Keep it as an obsolete alias.
(tags-loop-operate, tags-loop-scan): Mark as obsolete.
(tags--compat-files, tags--compat-initialize): New function.
(tags-loop-continue): Rewrite using multifile-continue. Mark as obsolete.
(tags--last-search-operate-function): New var.
(tags-search, tags-query-replace): Rewrite using multifile.el.
* lisp/emacs-lisp/generator.el (iter-end-of-sequence): Use 'define-error'.
(iter-make): New macro.
(iter-empty): New iterator.
* lisp/menu-bar.el (menu-bar-search-menu, menu-bar-replace-menu):
tags-loop-continue -> multifile-continue.
2018-09-22 11:46:35 -04:00
|
|
|
|
(dolist (file (dired-get-marked-files nil nil #'dired-nondirectory-p nil t))
|
2003-12-01 01:56:19 +00:00
|
|
|
|
(let ((buffer (get-file-buffer file)))
|
|
|
|
|
(if (and buffer (with-current-buffer buffer
|
|
|
|
|
buffer-read-only))
|
2004-02-08 22:38:51 +00:00
|
|
|
|
(error "File `%s' is visited read-only" file))))
|
2019-02-07 12:20:09 +03:00
|
|
|
|
(fileloop-initialize-replace
|
* lisp/multifile.el: New file, extracted from etags.el
The main motivation for this change was the introduction of
project-query-replace. dired's multi-file query&replace was implemented
on top of etags.el even though it did not use TAGS in any way, so I moved
this generic multifile code into its own package, with a nicer interface,
and then used that in project.el.
* lisp/progmodes/project.el (project-files): New generic function.
(project-search, project-query-replace): New commands.
* lisp/dired-aux.el (dired-do-search, dired-do-query-replace-regexp):
Use multifile.el instead of etags.el.
* lisp/progmodes/etags.el: Remove redundant :groups.
(next-file-list): Remove var.
(tags-loop-revert-buffers): Make it an obsolete alias.
(next-file): Don't autoload (it can't do anything useful before some
other etags.el function setup the multifile operation).
(tags--all-files): New function, extracted from next-file.
(tags-next-file): Rename from next-file.
Rewrite using tags--all-files and multifile-next-file.
(next-file): Keep it as an obsolete alias.
(tags-loop-operate, tags-loop-scan): Mark as obsolete.
(tags--compat-files, tags--compat-initialize): New function.
(tags-loop-continue): Rewrite using multifile-continue. Mark as obsolete.
(tags--last-search-operate-function): New var.
(tags-search, tags-query-replace): Rewrite using multifile.el.
* lisp/emacs-lisp/generator.el (iter-end-of-sequence): Use 'define-error'.
(iter-make): New macro.
(iter-empty): New iterator.
* lisp/menu-bar.el (menu-bar-search-menu, menu-bar-replace-menu):
tags-loop-continue -> multifile-continue.
2018-09-22 11:46:35 -04:00
|
|
|
|
from to (dired-get-marked-files nil nil #'dired-nondirectory-p)
|
|
|
|
|
(if (equal from (downcase from)) nil 'default)
|
|
|
|
|
delimited)
|
2019-02-07 12:20:09 +03:00
|
|
|
|
(fileloop-continue))
|
2002-03-29 14:45:05 +00:00
|
|
|
|
|
2016-01-24 05:17:52 +03:00
|
|
|
|
(declare-function xref-query-replace-in-results "xref")
|
2019-12-26 17:39:48 +02:00
|
|
|
|
(declare-function project--files-in-directory "project")
|
2016-01-18 22:11:46 +03:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-find-regexp (regexp)
|
2016-05-02 22:57:06 +03:00
|
|
|
|
"Find all matches for REGEXP in all marked files.
|
2019-08-02 14:16:25 +02:00
|
|
|
|
|
|
|
|
|
If no files are marked, use the file under point.
|
|
|
|
|
|
2016-05-03 19:14:31 +03:00
|
|
|
|
For any marked directory, all of its files are searched recursively.
|
|
|
|
|
However, files matching `grep-find-ignored-files' and subdirectories
|
2016-05-04 01:02:43 +03:00
|
|
|
|
matching `grep-find-ignored-directories' are skipped in the marked
|
2016-05-03 19:14:31 +03:00
|
|
|
|
directories.
|
|
|
|
|
|
|
|
|
|
REGEXP should use constructs supported by your local `grep' command."
|
2016-01-18 22:11:46 +03:00
|
|
|
|
(interactive "sSearch marked files (regexp): ")
|
|
|
|
|
(require 'grep)
|
2019-05-30 20:29:29 +03:00
|
|
|
|
(require 'xref)
|
2016-01-18 22:11:46 +03:00
|
|
|
|
(defvar grep-find-ignored-files)
|
2018-07-09 09:29:09 -04:00
|
|
|
|
(declare-function rgrep-find-ignored-directories "grep" (dir))
|
2019-12-26 17:39:48 +02:00
|
|
|
|
(let* ((marks (dired-get-marked-files nil nil nil nil t))
|
2016-01-18 22:11:46 +03:00
|
|
|
|
(ignores (nconc (mapcar
|
2019-03-17 13:35:20 -04:00
|
|
|
|
#'file-name-as-directory
|
2018-07-09 09:29:09 -04:00
|
|
|
|
(rgrep-find-ignored-directories default-directory))
|
2016-01-18 22:11:46 +03:00
|
|
|
|
grep-find-ignored-files))
|
2019-05-24 04:50:44 +03:00
|
|
|
|
(fetcher
|
|
|
|
|
(lambda ()
|
2019-12-26 17:39:48 +02:00
|
|
|
|
(let (files xrefs)
|
|
|
|
|
(mapc
|
|
|
|
|
(lambda (mark)
|
|
|
|
|
(if (file-directory-p mark)
|
|
|
|
|
(setq files (nconc
|
|
|
|
|
(project--files-in-directory mark ignores "*")
|
|
|
|
|
files))
|
|
|
|
|
(push mark files)))
|
2022-04-28 12:27:39 +02:00
|
|
|
|
(reverse marks))
|
2021-06-22 17:10:19 +02:00
|
|
|
|
(message "Searching...")
|
2019-12-26 17:39:48 +02:00
|
|
|
|
(setq xrefs
|
2019-12-29 15:11:53 +03:00
|
|
|
|
(xref-matches-in-files regexp files))
|
2019-05-24 04:50:44 +03:00
|
|
|
|
(unless xrefs
|
|
|
|
|
(user-error "No matches for: %s" regexp))
|
2021-06-22 17:10:19 +02:00
|
|
|
|
(message "Searching...done")
|
2019-05-24 04:50:44 +03:00
|
|
|
|
xrefs))))
|
2022-02-21 03:09:32 +02:00
|
|
|
|
(xref-show-xrefs fetcher nil)))
|
2016-01-18 22:11:46 +03:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-do-find-regexp-and-replace (from to)
|
2016-05-02 22:57:06 +03:00
|
|
|
|
"Replace matches of FROM with TO, in all marked files.
|
2019-08-02 14:16:25 +02:00
|
|
|
|
|
2022-04-21 14:54:45 +03:00
|
|
|
|
As each match is found, the user must type a character saying
|
|
|
|
|
what to do with it. Type SPC or `y' to replace the match,
|
|
|
|
|
DEL or `n' to skip and go to the next match. For more directions,
|
|
|
|
|
type \\[help-command] at that time.
|
|
|
|
|
|
2019-08-02 14:16:25 +02:00
|
|
|
|
If no files are marked, use the file under point.
|
|
|
|
|
|
2016-05-02 22:57:06 +03:00
|
|
|
|
For any marked directory, matches in all of its files are replaced,
|
2016-05-03 19:14:31 +03:00
|
|
|
|
recursively. However, files matching `grep-find-ignored-files'
|
2016-05-04 01:02:43 +03:00
|
|
|
|
and subdirectories matching `grep-find-ignored-directories' are skipped
|
2016-05-03 19:14:31 +03:00
|
|
|
|
in the marked directories.
|
|
|
|
|
|
2022-04-21 13:48:16 +02:00
|
|
|
|
REGEXP should use constructs supported by your local `grep' command.
|
|
|
|
|
|
|
|
|
|
Also see `query-replace' for user options that affect how this
|
|
|
|
|
function works."
|
2016-01-18 22:11:46 +03:00
|
|
|
|
(interactive
|
|
|
|
|
(let ((common
|
|
|
|
|
(query-replace-read-args
|
|
|
|
|
"Query replace regexp in marked files" t t)))
|
|
|
|
|
(list (nth 0 common) (nth 1 common))))
|
2020-12-01 03:46:27 +02:00
|
|
|
|
(require 'xref)
|
|
|
|
|
(defvar xref-show-xrefs-function)
|
2021-09-06 17:07:25 +03:00
|
|
|
|
(defvar xref-auto-jump-to-first-xref)
|
2020-12-01 03:46:27 +02:00
|
|
|
|
(with-current-buffer
|
|
|
|
|
(let ((xref-show-xrefs-function
|
|
|
|
|
;; Some future-proofing (bug#44905).
|
2021-09-06 17:07:25 +03:00
|
|
|
|
(custom--standard-value 'xref-show-xrefs-function))
|
|
|
|
|
;; Disable auto-jumping, it will mess up replacement logic.
|
|
|
|
|
xref-auto-jump-to-first-xref)
|
2020-12-01 03:46:27 +02:00
|
|
|
|
(dired-do-find-regexp from))
|
2016-01-24 05:17:52 +03:00
|
|
|
|
(xref-query-replace-in-results from to)))
|
2016-01-18 22:11:46 +03:00
|
|
|
|
|
2002-03-29 14:45:05 +00:00
|
|
|
|
(defun dired-nondirectory-p (file)
|
|
|
|
|
(not (file-directory-p file)))
|
2001-01-26 13:14:11 +00:00
|
|
|
|
|
2000-07-10 07:02:03 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-show-file-type (file &optional deref-symlinks)
|
|
|
|
|
"Print the type of FILE, according to the `file' command.
|
2011-07-01 15:37:00 +02:00
|
|
|
|
If you give a prefix to this command, and FILE is a symbolic
|
|
|
|
|
link, then the type of the file linked to by FILE is printed
|
|
|
|
|
instead."
|
2000-07-10 07:02:03 +00:00
|
|
|
|
(interactive (list (dired-get-filename t) current-prefix-arg))
|
2009-08-25 08:47:39 +00:00
|
|
|
|
(let (process-file-side-effects)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(if deref-symlinks
|
|
|
|
|
(process-file "file" nil t t "-L" "--" file)
|
|
|
|
|
(process-file "file" nil t t "--" file))
|
|
|
|
|
(when (bolp)
|
|
|
|
|
(backward-delete-char 1))
|
|
|
|
|
(message "%s" (buffer-string)))))
|
1994-10-22 16:00:31 +00:00
|
|
|
|
|
2020-03-30 01:34:47 +03:00
|
|
|
|
|
|
|
|
|
;;; Version control from dired
|
|
|
|
|
|
|
|
|
|
(declare-function vc-dir-unmark-all-files "vc-dir")
|
|
|
|
|
(declare-function vc-dir-mark-files "vc-dir")
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun dired-vc-next-action (verbose)
|
|
|
|
|
"Do the next version control operation on marked files/directories.
|
|
|
|
|
When only files are marked then call `vc-next-action' with the
|
|
|
|
|
same value of the VERBOSE argument.
|
|
|
|
|
When also directories are marked then call `vc-dir' and mark
|
|
|
|
|
the same files/directories in the VC-Dir buffer that were marked
|
|
|
|
|
in the Dired buffer."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(let* ((marked-files
|
|
|
|
|
(dired-get-marked-files nil nil nil nil t))
|
|
|
|
|
(mark-files
|
|
|
|
|
(when (cl-some #'file-directory-p marked-files)
|
|
|
|
|
;; Fix deficiency of Dired by adding slash to dirs
|
|
|
|
|
(mapcar (lambda (file)
|
|
|
|
|
(if (file-directory-p file)
|
|
|
|
|
(file-name-as-directory file)
|
|
|
|
|
file))
|
|
|
|
|
marked-files))))
|
|
|
|
|
(if mark-files
|
|
|
|
|
(let ((transient-hook (make-symbol "vc-dir-mark-files")))
|
|
|
|
|
(fset transient-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(remove-hook 'vc-dir-refresh-hook transient-hook t)
|
|
|
|
|
(vc-dir-unmark-all-files t)
|
|
|
|
|
(vc-dir-mark-files mark-files)))
|
|
|
|
|
(vc-dir-root)
|
|
|
|
|
(add-hook 'vc-dir-refresh-hook transient-hook nil t))
|
|
|
|
|
(vc-next-action verbose))))
|
|
|
|
|
|
|
|
|
|
(declare-function vc-compatible-state "vc")
|
|
|
|
|
|
2020-06-17 02:18:11 +03:00
|
|
|
|
;;;###autoload
|
2020-03-30 01:34:47 +03:00
|
|
|
|
(defun dired-vc-deduce-fileset (&optional state-model-only-files not-state-changing)
|
|
|
|
|
(let ((backend (vc-responsible-backend default-directory))
|
|
|
|
|
(files (dired-get-marked-files nil nil nil nil t))
|
|
|
|
|
only-files-list
|
|
|
|
|
state
|
|
|
|
|
model)
|
|
|
|
|
(when (and (not not-state-changing) (cl-some #'file-directory-p files))
|
|
|
|
|
(user-error "State changing VC operations on directories supported only in `vc-dir'"))
|
|
|
|
|
|
|
|
|
|
(when state-model-only-files
|
|
|
|
|
(setq only-files-list (mapcar (lambda (file) (cons file (vc-state file))) files))
|
|
|
|
|
(setq state (cdar only-files-list))
|
|
|
|
|
;; Check that all files are in a consistent state, since we use that
|
|
|
|
|
;; state to decide which operation to perform.
|
|
|
|
|
(dolist (crt (cdr only-files-list))
|
|
|
|
|
(unless (vc-compatible-state (cdr crt) state)
|
|
|
|
|
(error "When applying VC operations to multiple files, the files are required\nto be in similar VC states.\n%s in state %s clashes with %s in state %s"
|
|
|
|
|
(car crt) (cdr crt) (caar only-files-list) state)))
|
|
|
|
|
(setq only-files-list (mapcar 'car only-files-list))
|
|
|
|
|
(when (and state (not (eq state 'unregistered)))
|
|
|
|
|
(setq model (vc-checkout-model backend only-files-list))))
|
|
|
|
|
(list backend files only-files-list state model)))
|
|
|
|
|
|
2022-08-04 12:14:10 +02:00
|
|
|
|
(define-obsolete-function-alias 'minibuffer-default-add-dired-shell-commands
|
|
|
|
|
#'dired-minibuffer-default-add-shell-commands "29.1")
|
|
|
|
|
|
2020-03-30 01:34:47 +03:00
|
|
|
|
|
1994-06-10 21:09:40 +00:00
|
|
|
|
(provide 'dired-aux)
|
|
|
|
|
|
2009-09-11 06:50:14 +00:00
|
|
|
|
;; Local Variables:
|
2015-12-17 20:37:51 +00:00
|
|
|
|
;; generated-autoload-file: "dired-loaddefs.el"
|
2009-09-11 06:50:14 +00:00
|
|
|
|
;; End:
|
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;;; dired-aux.el ends here
|