annotate lisp/wdired.el @ 90349:23de6e67f400

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Mon, 06 Mar 2006 02:16:33 +0000
parents bdaa27dd39d3
children 45a2e01db282
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; wdired.el --- Rename files editing their names in dired buffers
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2
68651
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68152
diff changeset
3 ;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
4
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5 ;; Filename: wdired.el
61350
796b7fe4bfd8 (wdired-advise-functions, wdired-add-skip-in-replace)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61030
diff changeset
6 ;; Author: Juan León Lahoz García <juanleon1@gmail.com>
796b7fe4bfd8 (wdired-advise-functions, wdired-add-skip-in-replace)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61030
diff changeset
7 ;; Version: 2.0
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
8 ;; Keywords: dired, environment, files, renaming
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
9
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
11
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
13 ;; modify it under the terms of the GNU General Public License as
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14 ;; published by the Free Software Foundation; either version 2, or (at
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
15 ;; your option) any later version.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
16
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
17 ;; This program is distributed in the hope that it will be useful, but
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
20 ;; General Public License for more details.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
21
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62746
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62746
diff changeset
25 ;; Boston, MA 02110-1301, USA.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27 ;;; Commentary:
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29 ;; wdired.el (the "w" is for writable) provides an alternative way of
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30 ;; renaming files.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31 ;;
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32 ;; Have you ever wished to use C-x r t (string-rectangle), M-%
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
33 ;; (query-replace), M-c (capitalize-word), etc... to change the name of
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
34 ;; the files in a "dired" buffer? Now you can do this. All the power
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
35 ;; of Emacs commands are available to renaming files!
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
36 ;;
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 ;; This package provides a function that makes the filenames of a a
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 ;; dired buffer editable, by changing the buffer mode (which inhibits
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 ;; all of the commands of dired mode). Here you can edit the names of
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 ;; one or more files and directories, and when you press C-c C-c, the
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 ;; renaming takes effect and you are back to dired mode.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 ;;
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
43 ;; Another things you can do with WDired:
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 ;;
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 ;; - To move files to another directory (by typing their path,
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 ;; absolute or relative, as a part of the new filename).
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 ;;
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 ;; - To change the target of symbolic links.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 ;;
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 ;; - To change the permission bits of the filenames (in systems with a
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 ;; working unix-alike `dired-chmod-program'). See and customize the
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
52 ;; variable `wdired-allow-to-change-permissions'. To change a single
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 ;; char (toggling between its two more usual values) you can press
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
54 ;; the space bar over it or left-click the mouse. To set any char to
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 ;; an specific value (this includes the SUID, SGID and STI bits) you
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
56 ;; can use the key labeled as the letter you want. Please note that
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 ;; permissions of the links cannot be changed in that way, because
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 ;; the change would affect to their targets, and this would not be
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 ;; WYSIWYG :-).
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 ;;
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 ;; - To mark files for deletion, by deleting their whole filename.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 ;;; Installation:
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 ;; Add this file (byte-compiling it is recommended) to your load-path.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 ;; Then add one of these set of lines (or similar ones) to your config:
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 ;;
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 ;; This is the easy way:
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 ;;
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 ;; (require 'wdired)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 ;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 ;;
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
73 ;; This is the recommended way for faster Emacs startup time and lower
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
74 ;; memory consumption:
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 ;;
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 ;; (autoload 'wdired-change-to-wdired-mode "wdired")
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
77 ;; (eval-after-load "dired"
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78 ;; '(lambda ()
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
79 ;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 ;; (define-key dired-mode-map
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81 ;; [menu-bar immediate wdired-change-to-wdired-mode]
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 ;; '("Edit File Names" . wdired-change-to-wdired-mode))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 ;;
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
84 ;; Type "M-x customize-group RET wdired" if you want to make changes
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
85 ;; to the default behavior.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 ;;; Usage:
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 ;; Then, you can start editing the names of the files by typing "r"
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 ;; (or whatever key you choose, or M-x wdired-change-to-wdired-mode).
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 ;; Use C-c C-c when finished or C-c C-k to abort. You can use also the
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 ;; menu options: in dired mode, "Edit File Names" under "Immediate".
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93 ;; While editing the names, a new submenu "WDired" is available at top
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94 ;; level. You can customize the behavior of this package from this
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 ;; menu.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 ;;; Change Log:
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
99 ;; Google is your friend (previous versions with complete changelogs
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
100 ;; were posted to gnu.emacs.sources)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
102 ;;; Code:
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
103
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
104 (defvar dired-backup-overwrite) ; Only in Emacs 20.x this is a custom var
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
106 (require 'dired)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
107 (autoload 'dired-do-create-files-regexp "dired-aux")
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
108 (autoload 'dired-call-process "dired-aux")
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
109
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110 (defgroup wdired nil
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 "Mode to rename files by editing their names in dired buffers."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 :group 'dired)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 (defcustom wdired-use-interactive-rename nil
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
115 "If non-nil, WDired requires confirmation before actually renaming files.
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
116 If nil, WDired doesn't require confirmation to change the file names,
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
117 and the variable `wdired-confirm-overwrite' controls whether it is ok
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
118 to overwrite files without asking."
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
119 :type 'boolean
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
120 :group 'wdired)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
121
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
122 (defcustom wdired-confirm-overwrite t
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
123 "If nil the renames can overwrite files without asking.
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
124 This variable has no effect at all if `wdired-use-interactive-rename'
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
125 is not nil."
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
126 :type 'boolean
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127 :group 'wdired)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
128
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
129 (defcustom wdired-use-dired-vertical-movement nil
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
130 "If t, the \"up\" and \"down\" movement works as in Dired mode.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 That is, always move the point to the beginning of the filename at line.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
133 If `sometimes, only move to the beginning of filename if the point is
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
134 before it, and `track-eol' is honored. This behavior is very handy
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
135 when editing several filenames.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
136
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
137 If nil, \"up\" and \"down\" movement is done as in any other buffer."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
138 :type '(choice (const :tag "As in any other mode" nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
139 (const :tag "Smart cursor placement" sometimes)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
140 (other :tag "As in dired mode" t))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
141 :group 'wdired)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
143 (defcustom wdired-allow-to-redirect-links t
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
144 "If non-nil, the target of the symbolic links are editable.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
145 In systems without symbolic links support, this variable has no effect
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146 at all."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
147 :type 'boolean
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
148 :group 'wdired)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
150 (defcustom wdired-allow-to-change-permissions nil
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
151 "If non-nil, the permissions bits of the files are editable.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
152
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
153 If t, to change a single bit, put the cursor over it and press the
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
154 space bar, or left click over it. You can also hit the letter you want
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155 to set: if this value is allowed, the character in the buffer will be
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156 changed. Anyway, the point is advanced one position, so, for example,
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
157 you can keep the <x> key pressed to give execution permissions to
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 everybody to that file.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
160 If `advanced, the bits are freely editable. You can use
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161 `string-rectangle', `query-replace', etc. You can put any value (even
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162 newlines), but if you want your changes to be useful, you better put a
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
163 intelligible value.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
165 Anyway, the real change of the permissions is done by the external
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
166 program `dired-chmod-program', which must exist."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167 :type '(choice (const :tag "Not allowed" nil)
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
168 (const :tag "Toggle/set bits" t)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
169 (other :tag "Bits freely editable" advanced))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 :group 'wdired)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
171
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
172 (defvar wdired-mode-map
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
173 (let ((map (make-sparse-keymap)))
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
174 (define-key map "\C-x\C-s" 'wdired-finish-edit)
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
175 (define-key map "\C-c\C-c" 'wdired-finish-edit)
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
176 (define-key map "\C-c\C-k" 'wdired-abort-changes)
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
177 (define-key map "\C-c\C-[" 'wdired-abort-changes)
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
178 (define-key map "\C-m" 'ignore)
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
179 (define-key map "\C-j" 'ignore)
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
180 (define-key map "\C-o" 'ignore)
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
181 (define-key map [up] 'wdired-previous-line)
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
182 (define-key map "\C-p" 'wdired-previous-line)
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
183 (define-key map [down] 'wdired-next-line)
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
184 (define-key map "\C-n" 'wdired-next-line)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
185
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
186 (define-key map [menu-bar wdired]
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
187 (cons "WDired" (make-sparse-keymap "WDired")))
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
188 (define-key map [menu-bar wdired wdired-customize]
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
189 '("Options" . wdired-customize))
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
190 (define-key map [menu-bar wdired dashes]
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
191 '("--"))
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
192 (define-key map [menu-bar wdired wdired-abort-changes]
68152
3a7458f9152d (wdired-mode-map): Add help echo for wdired-abort-changes.
Nick Roberts <nickrob@snap.net.nz>
parents: 67561
diff changeset
193 '(menu-item "Abort Changes" wdired-abort-changes
3a7458f9152d (wdired-mode-map): Add help echo for wdired-abort-changes.
Nick Roberts <nickrob@snap.net.nz>
parents: 67561
diff changeset
194 :help "Abort changes and return to dired mode"))
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
195 (define-key map [menu-bar wdired wdired-finish-edit]
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
196 '("Commit Changes" . wdired-finish-edit))
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
197
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
198 (define-key map [remap upcase-word] 'wdired-upcase-word)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
199 (define-key map [remap capitalize-word] 'wdired-capitalize-word)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
200 (define-key map [remap downcase-word] 'wdired-downcase-word)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
201
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
202 map))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
203
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
204 (defvar wdired-mode-hook nil
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
205 "Hooks run when changing to WDired mode.")
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
206
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
207 ;; Local variables (put here to avoid compilation gripes)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
208 (defvar wdired-col-perm) ;; Column where the permission bits start
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
209 (defvar wdired-old-content)
67561
827930ad591b (wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents: 65582
diff changeset
210 (defvar wdired-old-point)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 (defun wdired-mode ()
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214 "\\<wdired-mode-map>File Names Editing mode.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
216 Press \\[wdired-finish-edit] to make the changes to take effect
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
217 and exit. To abort the edit, use \\[wdired-abort-changes].
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
218
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
219 In this mode you can edit the names of the files, the target of
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
220 the links and the permission bits of the files. You can use
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
221 \\[customize-group] RET wdired to customize WDired behavior.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
222
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
223 The only editable texts in a WDired buffer are filenames,
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
224 symbolic link targets, and filenames permission."
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
225 (interactive)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
226 (error "This mode can be enabled only by `wdired-change-to-wdired-mode'"))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
227 (put 'wdired-mode 'mode-class 'special)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
228
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
229
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
230 ;;;###autoload
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
231 (defun wdired-change-to-wdired-mode ()
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
232 "Put a dired buffer in a mode in which filenames are editable.
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
233 \\<wdired-mode-map>
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
234 This mode allows the user to change the names of the files, and after
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
235 typing \\[wdired-finish-edit] Emacs renames the files and directories
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
236 in disk.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
237
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
238 See `wdired-mode'."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
239 (interactive)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
240 (set (make-local-variable 'wdired-old-content)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
241 (buffer-substring (point-min) (point-max)))
67561
827930ad591b (wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents: 65582
diff changeset
242 (set (make-local-variable 'wdired-old-point) (point))
61350
796b7fe4bfd8 (wdired-advise-functions, wdired-add-skip-in-replace)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61030
diff changeset
243 (set (make-local-variable 'query-replace-skip-read-only) t)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
244 (use-local-map wdired-mode-map)
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
245 (force-mode-line-update)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
246 (setq buffer-read-only nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
247 (dired-unadvertise default-directory)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
248 (add-hook 'kill-buffer-hook 'wdired-check-kill-buffer nil t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249 (setq major-mode 'wdired-mode)
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
250 (setq mode-name "Editable Dired")
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
251 (setq revert-buffer-function 'wdired-revert)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
252 ;; I temp disable undo for performance: since I'm going to clear the
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
253 ;; undo list, it can save more than a 9% of time with big
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
254 ;; directories because setting properties modify the undo-list.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
255 (buffer-disable-undo)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
256 (wdired-preprocess-files)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
257 (if wdired-allow-to-change-permissions
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
258 (wdired-preprocess-perms))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
259 (if (and wdired-allow-to-redirect-links (fboundp 'make-symbolic-link))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
260 (wdired-preprocess-symlinks))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
261 (buffer-enable-undo) ; Performance hack. See above.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
262 (set-buffer-modified-p nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
263 (setq buffer-undo-list nil)
62746
0fe5c8d2cd65 (wdired-change-to-wdired-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents: 61473
diff changeset
264 (run-mode-hooks 'wdired-mode-hook)
67561
827930ad591b (wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents: 65582
diff changeset
265 (message "%s" (substitute-command-keys
827930ad591b (wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents: 65582
diff changeset
266 "Press \\[wdired-finish-edit] when finished \
61030
6b0506554db8 (wdired-change-to-wdired-mode):
Juri Linkov <juri@jurta.org>
parents: 60141
diff changeset
267 or \\[wdired-abort-changes] to abort changes")))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
268
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
269
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
270 ;; Protect the buffer so only the filenames can be changed, and put
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
271 ;; properties so filenames (old and new) can be easily found.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
272 (defun wdired-preprocess-files ()
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
273 (put-text-property 1 2 'front-sticky t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274 (save-excursion
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275 (goto-char (point-min))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 (let ((b-protection (point))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
277 filename)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
278 (while (not (eobp))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279 (setq filename (dired-get-filename nil t))
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
280 (when (and filename
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
281 (not (member (file-name-nondirectory filename) '("." ".."))))
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
282 (dired-move-to-filename)
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
283 (put-text-property (- (point) 2) (1- (point)) 'old-name filename)
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
284 (put-text-property b-protection (1- (point)) 'read-only t)
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
285 (setq b-protection (dired-move-to-end-of-filename t)))
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
286 (put-text-property (point) (1+ (point)) 'end-name t)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287 (forward-line))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288 (put-text-property b-protection (point-max) 'read-only t))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
289
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290 ;; This code is a copy of some dired-get-filename lines.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291 (defsubst wdired-normalize-filename (file)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
292 (setq file
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
293 ;; FIXME: shouldn't we check for a `b' argument or somesuch before
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
294 ;; doing such unquoting? --Stef
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295 (read (concat
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
296 "\"" (replace-regexp-in-string
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
297 "\\([^\\]\\|\\`\\)\"" "\\1\\\\\"" file)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
298 "\"")))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
299 (and file buffer-file-coding-system
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
300 (not file-name-coding-system)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
301 (not default-file-name-coding-system)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
302 (setq file (encode-coding-string file buffer-file-coding-system)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303 file)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
304
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
305 (defun wdired-get-filename (&optional no-dir old)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
306 "Return the filename at line.
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
307 Similar to `dired-get-filename' but it doesn't rely on regexps. It
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
308 relies on WDired buffer's properties. Optional arg NO-DIR with value
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
309 non-nil means don't include directory. Optional arg OLD with value
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
310 non-nil means return old filename."
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
311 ;; FIXME: Use dired-get-filename's new properties.
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
312 (let* ((end (line-end-position))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
313 (beg (next-single-property-change
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
314 (line-beginning-position) 'old-name nil end)))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
315 (unless (eq beg end)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
316 (let ((file
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
317 (if old
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
318 (get-text-property beg 'old-name)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
319 (wdired-normalize-filename
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
320 (buffer-substring-no-properties
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
321 (+ 2 beg) (next-single-property-change (1+ beg) 'end-name))))))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
322 (if (or no-dir old)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
323 file
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
324 (and file (> (length file) 0)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
325 (concat (dired-current-directory) file)))))))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
326
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
327
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
328 (defun wdired-change-to-dired-mode ()
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
329 "Change the mode back to dired."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
330 (let ((inhibit-read-only t))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331 (remove-text-properties (point-min) (point-max)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332 '(read-only nil local-map nil)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
333 (put-text-property 1 2 'front-sticky nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
334 (use-local-map dired-mode-map)
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
335 (force-mode-line-update)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
336 (setq buffer-read-only t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
337 (setq major-mode 'dired-mode)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
338 (setq mode-name "Dired")
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
339 (dired-advertise)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
340 (remove-hook 'kill-buffer-hook 'wdired-check-kill-buffer t)
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
341 (set (make-local-variable 'revert-buffer-function) 'dired-revert))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
342
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
343
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344 (defun wdired-abort-changes ()
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
345 "Abort changes and return to dired mode."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
346 (interactive)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
347 (let ((inhibit-read-only t))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
348 (erase-buffer)
67561
827930ad591b (wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents: 65582
diff changeset
349 (insert wdired-old-content)
827930ad591b (wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents: 65582
diff changeset
350 (goto-char wdired-old-point))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
351 (wdired-change-to-dired-mode)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
352 (set-buffer-modified-p nil)
55371
a96e9558b1ea (wdired-change-to-wdired-mode): Quote wdired-mode-hook in run-hooks.
Lars Hansen <larsh@soem.dk>
parents: 55109
diff changeset
353 (setq buffer-undo-list nil)
a96e9558b1ea (wdired-change-to-wdired-mode): Quote wdired-mode-hook in run-hooks.
Lars Hansen <larsh@soem.dk>
parents: 55109
diff changeset
354 (message "Changes aborted"))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
355
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
356 (defun wdired-finish-edit ()
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
357 "Actually rename files based on your editing in the Dired buffer."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
358 (interactive)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
359 (wdired-change-to-dired-mode)
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
360 (let ((overwrite (or (not wdired-confirm-overwrite) 1))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
361 (changes nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
362 (files-deleted nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
363 (errors 0)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
364 file-ori file-new tmp-value)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
365 (save-excursion
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
366 (if (and wdired-allow-to-redirect-links
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
367 (fboundp 'make-symbolic-link))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
368 (progn
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
369 (setq tmp-value (wdired-do-symlink-changes))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
370 (setq errors (cdr tmp-value))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
371 (setq changes (car tmp-value))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
372 (if (and wdired-allow-to-change-permissions
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
373 (boundp 'wdired-col-perm)) ; could have been changed
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
374 (progn
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
375 (setq tmp-value (wdired-do-perm-changes))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
376 (setq errors (+ errors (cdr tmp-value)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
377 (setq changes (or changes (car tmp-value)))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
378 (goto-char (point-max))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
379 (while (not (bobp))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
380 (setq file-ori (wdired-get-filename nil t))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
381 (if file-ori
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
382 (setq file-new (wdired-get-filename)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
383 (if (and file-ori (not (equal file-new file-ori)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
384 (progn
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
385 (setq changes t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
386 (if (not file-new) ;empty filename!
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
387 (setq files-deleted (cons file-ori files-deleted))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
388 (progn
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
389 (setq file-new (substitute-in-file-name file-new))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
390 (if wdired-use-interactive-rename
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
391 (wdired-search-and-rename file-ori file-new)
56545
c3fa830eb56c (wdired-finish-edit): Require dired-aux before locally binding dired-backup-overwrite.
Lars Hansen <larsh@soem.dk>
parents: 55371
diff changeset
392 ;; If dired-rename-file autoloads dired-aux while
c3fa830eb56c (wdired-finish-edit): Require dired-aux before locally binding dired-backup-overwrite.
Lars Hansen <larsh@soem.dk>
parents: 55371
diff changeset
393 ;; dired-backup-overwrite is locally bound,
c3fa830eb56c (wdired-finish-edit): Require dired-aux before locally binding dired-backup-overwrite.
Lars Hansen <larsh@soem.dk>
parents: 55371
diff changeset
394 ;; dired-backup-overwrite won't be initialized.
c3fa830eb56c (wdired-finish-edit): Require dired-aux before locally binding dired-backup-overwrite.
Lars Hansen <larsh@soem.dk>
parents: 55371
diff changeset
395 ;; So we must ensure dired-aux is loaded.
c3fa830eb56c (wdired-finish-edit): Require dired-aux before locally binding dired-backup-overwrite.
Lars Hansen <larsh@soem.dk>
parents: 55371
diff changeset
396 (require 'dired-aux)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
397 (condition-case err
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
398 (let ((dired-backup-overwrite nil))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
399 (dired-rename-file file-ori file-new
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
400 overwrite))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
401 (error
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
402 (setq errors (1+ errors))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
403 (dired-log (concat "Rename `" file-ori "' to `"
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
404 file-new "' failed:\n%s\n")
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
405 err))))))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
406 (forward-line -1)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
407 (if changes
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
408 (revert-buffer) ;The "revert" is necessary to re-sort the buffer
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
409 (let ((inhibit-read-only t))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
410 (remove-text-properties (point-min) (point-max)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
411 '(old-name nil end-name nil old-link nil
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
412 end-link nil end-perm nil
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
413 old-perm nil perm-changed nil))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
414 (message "(No changes to be performed)")))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
415 (if files-deleted
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
416 (wdired-flag-for-deletion files-deleted))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
417 (if (> errors 0)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
418 (dired-log-summary (format "%d rename actions failed" errors) nil)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
419 (set-buffer-modified-p nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
420 (setq buffer-undo-list nil))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
421
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
422 ;; Rename a file, searching it in a modified dired buffer, in order
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
423 ;; to be able to use `dired-do-create-files-regexp' and get its
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
424 ;; "benefits".
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
425 (defun wdired-search-and-rename (filename-ori filename-new)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
426 (save-excursion
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
427 (goto-char (point-max))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
428 (forward-line -1)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
429 (let ((exit-while nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
430 curr-filename)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
431 (while (not exit-while)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
432 (setq curr-filename (wdired-get-filename))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
433 (if (and curr-filename
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
434 (equal (substitute-in-file-name curr-filename) filename-new))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
435 (progn
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
436 (setq exit-while t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
437 (let ((inhibit-read-only t))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
438 (dired-move-to-filename)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
439 (search-forward (wdired-get-filename t) nil t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
440 (replace-match (file-name-nondirectory filename-ori) t t))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
441 (dired-do-create-files-regexp
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
442 (function dired-rename-file)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
443 "Move" 1 ".*" filename-new nil t))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
444 (progn
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
445 (forward-line -1)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
446 (beginning-of-line)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
447 (setq exit-while (= 1 (point)))))))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
448
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
449 ;; marks a list of files for deletion
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
450 (defun wdired-flag-for-deletion (filenames-ori)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
451 (save-excursion
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
452 (goto-char (point-min))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
453 (while (not (eobp))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
454 (if (member (dired-get-filename nil t) filenames-ori)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
455 (dired-flag-file-deletion 1)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
456 (forward-line)))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
457
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
458 (defun wdired-customize ()
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
459 "Customize WDired options."
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
460 (interactive)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
461 (customize-apropos "wdired" 'groups))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
463 (defun wdired-revert (&optional arg noconfirm)
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
464 "Discard changes in the buffer and update it based on changes on disk.
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
465 Optional arguments are ignored."
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
466 (wdired-change-to-dired-mode)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 (revert-buffer)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
468 (wdired-change-to-wdired-mode))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
469
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470 (defun wdired-check-kill-buffer ()
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
471 ;; FIXME: Can't we use the normal mechanism for that? --Stef
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472 (if (and
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
473 (buffer-modified-p)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
474 (not (y-or-n-p "Buffer changed. Discard changes and kill buffer? ")))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
475 (error nil)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
476
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
477 (defun wdired-next-line (arg)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
478 "Move down lines then position at filename or the current column.
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
479 See `wdired-use-dired-vertical-movement'. Optional prefix ARG
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
480 says how many lines to move; default is one line."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
481 (interactive "p")
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
482 (next-line arg)
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
483 (if (or (eq wdired-use-dired-vertical-movement t)
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
484 (and wdired-use-dired-vertical-movement
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
485 (< (current-column)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
486 (save-excursion (dired-move-to-filename)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
487 (current-column)))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
488 (dired-move-to-filename)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
489
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
490 (defun wdired-previous-line (arg)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
491 "Move up lines then position at filename or the current column.
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
492 See `wdired-use-dired-vertical-movement'. Optional prefix ARG
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
493 says how many lines to move; default is one line."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
494 (interactive "p")
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
495 (previous-line arg)
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
496 (if (or (eq wdired-use-dired-vertical-movement t)
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
497 (and wdired-use-dired-vertical-movement
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
498 (< (current-column)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
499 (save-excursion (dired-move-to-filename)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
500 (current-column)))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
501 (dired-move-to-filename)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
502
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
503 ;; Put the needed properties to allow the user to change links' targets
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
504 (defun wdired-preprocess-symlinks ()
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
505 (let ((inhibit-read-only t))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
506 (save-excursion
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
507 (goto-char (point-min))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
508 (while (not (eobp))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
509 (if (looking-at dired-re-sym)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
510 (progn
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
511 (re-search-forward " -> \\(.*\\)$")
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
512 (put-text-property (- (match-beginning 1) 2)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
513 (1- (match-beginning 1)) 'old-link
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
514 (match-string-no-properties 1))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
515 (put-text-property (match-end 1) (1+ (match-end 1)) 'end-link t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
516 (put-text-property (1- (match-beginning 1))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
517 (match-end 1) 'read-only nil)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
518 (forward-line)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
519 (beginning-of-line)))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
520
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
521
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
522 (defun wdired-get-previous-link (&optional old move)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
523 "Return the next symlink target.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
524 If OLD, return the old target. If MOVE, move point before it."
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
525 (let ((beg (previous-single-property-change (point) 'old-link nil)))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
526 (when beg
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
527 (let ((target
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
528 (if old
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
529 (get-text-property (1- beg) 'old-link)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
530 (buffer-substring-no-properties
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
531 (1+ beg) (next-single-property-change beg 'end-link)))))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
532 (if move (goto-char (1- beg)))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
533 (and target (wdired-normalize-filename target))))))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
534
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
535 ;; Perform the changes in the target of the changed links.
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
536 (defun wdired-do-symlink-changes ()
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
537 (let ((changes nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
538 (errors 0)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
539 link-to-ori link-to-new link-from)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
540 (goto-char (point-max))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
541 (while (setq link-to-new (wdired-get-previous-link))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
542 (setq link-to-ori (wdired-get-previous-link t t))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
543 (setq link-from (wdired-get-filename nil t))
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
544 (unless (equal link-to-new link-to-ori)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
545 (setq changes t)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
546 (if (equal link-to-new "") ;empty filename!
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
547 (setq link-to-new "/dev/null"))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
548 (condition-case err
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
549 (progn
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
550 (delete-file link-from)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
551 (make-symbolic-link
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
552 (substitute-in-file-name link-to-new) link-from))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
553 (error
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
554 (setq errors (1+ errors))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
555 (dired-log (concat "Link `" link-from "' to `"
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
556 link-to-new "' failed:\n%s\n")
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
557 err)))))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
558 (cons changes errors)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
559
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
560 ;; Perform a "case command" skipping read-only words.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
561 (defun wdired-xcase-word (command arg)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
562 (if (< arg 0)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
563 (funcall command arg)
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
564 (while (> arg 0)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
565 (condition-case err
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
566 (progn
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
567 (funcall command 1)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
568 (setq arg (1- arg)))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
569 (error
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
570 (if (not (forward-word 1))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
571 (setq arg 0)))))))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
572
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
573 (defun wdired-downcase-word (arg)
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
574 "WDired version of `downcase-word'.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
575 Like original function but it skips read-only words."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
576 (interactive "p")
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
577 (wdired-xcase-word 'downcase-word arg))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
578
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
579 (defun wdired-upcase-word (arg)
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
580 "WDired version of `upcase-word'.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
581 Like original function but it skips read-only words."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
582 (interactive "p")
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
583 (wdired-xcase-word 'upcase-word arg))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
584
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
585 (defun wdired-capitalize-word (arg)
61473
496c7a7bdacc Doc fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61350
diff changeset
586 "WDired version of `capitalize-word'.
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
587 Like original function but it skips read-only words."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
588 (interactive "p")
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
589 (wdired-xcase-word 'capitalize-word arg))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
590
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
591
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
592 ;; The following code deals with changing the access bits (or
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
593 ;; permissions) of the files.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
594
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
595 (defvar wdired-perm-mode-map
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
596 (let ((map (make-sparse-keymap)))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
597 (define-key map " " 'wdired-toggle-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
598 (define-key map "r" 'wdired-set-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
599 (define-key map "w" 'wdired-set-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
600 (define-key map "x" 'wdired-set-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
601 (define-key map "-" 'wdired-set-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
602 (define-key map "S" 'wdired-set-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
603 (define-key map "s" 'wdired-set-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
604 (define-key map "T" 'wdired-set-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
605 (define-key map "t" 'wdired-set-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
606 (define-key map "s" 'wdired-set-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
607 (define-key map "l" 'wdired-set-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
608 (define-key map [down-mouse-1] 'wdired-mouse-toggle-bit)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
609 map))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
610
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
611 ;; Put a local-map to the permission bits of the files, and store the
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
612 ;; original name and permissions as a property
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
613 (defun wdired-preprocess-perms ()
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
614 (let ((inhibit-read-only t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
615 filename)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
616 (set (make-local-variable 'wdired-col-perm) nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
617 (save-excursion
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
618 (goto-char (point-min))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
619 (while (not (eobp))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
620 (if (and (not (looking-at dired-re-sym))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
621 (setq filename (wdired-get-filename)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
622 (progn
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
623 (re-search-forward dired-re-perms)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
624 (or wdired-col-perm
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
625 (setq wdired-col-perm (- (current-column) 9)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
626 (if (eq wdired-allow-to-change-permissions 'advanced)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
627 (put-text-property (match-beginning 0) (match-end 0)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
628 'read-only nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
629 (put-text-property (1+ (match-beginning 0)) (match-end 0)
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
630 'keymap wdired-perm-mode-map))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
631 (put-text-property (match-end 0) (1+ (match-end 0)) 'end-perm t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
632 (put-text-property (match-beginning 0) (1+ (match-beginning 0))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
633 'old-perm (match-string-no-properties 0))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
634 (forward-line)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
635 (beginning-of-line)))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
636
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
637 (defun wdired-perm-allowed-in-pos (char pos)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
638 (cond
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
639 ((= char ?-) t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
640 ((= char ?r) (= (% pos 3) 0))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
641 ((= char ?w) (= (% pos 3) 1))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
642 ((= char ?x) (= (% pos 3) 2))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
643 ((memq char '(?s ?S)) (memq pos '(2 5)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
644 ((memq char '(?t ?T)) (= pos 8))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
645 ((= char ?l) (= pos 5))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
646
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
647 (defun wdired-set-bit ()
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
648 "Set a permission bit character."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
649 (interactive)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
650 (if (wdired-perm-allowed-in-pos last-command-char
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
651 (- (current-column) wdired-col-perm))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
652 (let ((new-bit (char-to-string last-command-char))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
653 (inhibit-read-only t)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
654 (pos-prop (- (point) (- (current-column) wdired-col-perm))))
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
655 (put-text-property 0 1 'keymap wdired-perm-mode-map new-bit)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
656 (put-text-property 0 1 'read-only t new-bit)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
657 (insert new-bit)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
658 (delete-char 1)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
659 (put-text-property pos-prop (1- pos-prop) 'perm-changed t))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
660 (forward-char 1)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
661
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
662 (defun wdired-toggle-bit ()
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
663 "Toggle the permission bit at point."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
664 (interactive)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
665 (let ((inhibit-read-only t)
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
666 (new-bit (cond
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
667 ((not (eq (char-after (point)) ?-)) "-")
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
668 ((= (% (- (current-column) wdired-col-perm) 3) 0) "r")
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
669 ((= (% (- (current-column) wdired-col-perm) 3) 1) "w")
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
670 (t "x")))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
671 (pos-prop (- (point) (- (current-column) wdired-col-perm))))
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
672 (put-text-property 0 1 'keymap wdired-perm-mode-map new-bit)
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
673 (put-text-property 0 1 'read-only t new-bit)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
674 (insert new-bit)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
675 (delete-char 1)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
676 (put-text-property pos-prop (1- pos-prop) 'perm-changed t)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
677
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
678 (defun wdired-mouse-toggle-bit (event)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
679 "Toggle the permission bit that was left clicked."
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
680 (interactive "e")
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
681 (mouse-set-point event)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
682 (wdired-toggle-bit))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
683
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
684 ;; Allowed chars for 4000 bit are Ss in position 3
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
685 ;; Allowed chars for 2000 bit are Ssl in position 6
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
686 ;; Allowed chars for 1000 bit are Tt in position 9
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
687 (defun wdired-perms-to-number (perms)
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
688 (+
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
689 (if (= (elt perms 1) ?-) 0 400)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
690 (if (= (elt perms 2) ?-) 0 200)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
691 (case (elt perms 3)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
692 (?- 0)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
693 (?S 4000)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
694 (?s 4100)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
695 (t 100))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
696 (if (= (elt perms 4) ?-) 0 40)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
697 (if (= (elt perms 5) ?-) 0 20)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
698 (case (elt perms 6)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
699 (?- 0)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
700 (?S 2000)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
701 (?s 2010)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
702 (t 10))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
703 (if (= (elt perms 7) ?-) 0 4)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
704 (if (= (elt perms 8) ?-) 0 2)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
705 (case (elt perms 9)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
706 (?- 0)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
707 (?T 1000)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
708 (?t 1001)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
709 (t 1))))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
710
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
711 ;; Perform the changes in the permissions of the files that have
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
712 ;; changed.
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
713 (defun wdired-do-perm-changes ()
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
714 (let ((changes nil)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
715 (errors 0)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
716 (prop-wanted (if (eq wdired-allow-to-change-permissions 'advanced)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
717 'old-perm 'perm-changed))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
718 filename perms-ori perms-new perm-tmp)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
719 (goto-char (next-single-property-change (point-min) prop-wanted
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
720 nil (point-max)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
721 (while (not (eobp))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
722 (setq perms-ori (get-text-property (point) 'old-perm))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
723 (setq perms-new (buffer-substring-no-properties
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
724 (point) (next-single-property-change (point) 'end-perm)))
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
725 (unless (equal perms-ori perms-new)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
726 (setq changes t)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
727 (setq filename (wdired-get-filename nil t))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
728 (if (= (length perms-new) 10)
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
729 (progn
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
730 (setq perm-tmp
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
731 (int-to-string (wdired-perms-to-number perms-new)))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
732 (unless (equal 0 (dired-call-process dired-chmod-program
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
733 t perm-tmp filename))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
734 (setq errors (1+ errors))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
735 (dired-log (concat dired-chmod-program " " perm-tmp
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
736 " `" filename "' failed\n\n"))))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
737 (setq errors (1+ errors))
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
738 (dired-log (concat "Cannot parse permission `" perms-new
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
739 "' for file `" filename "'\n\n"))))
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
740 (goto-char (next-single-property-change (1+ (point)) prop-wanted
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
741 nil (point-max))))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
742 (cons changes errors)))
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
743
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
744 (provide 'wdired)
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
745
68680
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
746 ;; Local Variables:
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
747 ;; coding: latin-1
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
748 ;; byte-compile-dynamic: t
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
749 ;; End:
bdaa27dd39d3 (wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68671
diff changeset
750
55109
043dd9a4d1b4 (wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55107
diff changeset
751 ;; arch-tag: bc00902e-526f-4305-bc7f-8862a559184f
55098
dedd285e197e New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
752 ;;; wdired.el ends here