comparison lisp/wdired.el @ 67561:827930ad591b

(wdired-old-point): New internal variable. (wdired-change-to-wdired-mode): Set it buffer-locally. (wdired-abort-changes): Restore point after aborting changes.
author Juri Linkov <juri@jurta.org>
date Wed, 14 Dec 2005 07:45:07 +0000
parents 4d1085b02d64
children 3a7458f9152d
comparison
equal deleted inserted replaced
67560:2d2062823ea5 67561:827930ad591b
209 "Hooks run when changing to WDired mode.") 209 "Hooks run when changing to WDired mode.")
210 210
211 ;; Local variables (put here to avoid compilation gripes) 211 ;; Local variables (put here to avoid compilation gripes)
212 (defvar wdired-col-perm) ;; Column where the permission bits start 212 (defvar wdired-col-perm) ;; Column where the permission bits start
213 (defvar wdired-old-content) 213 (defvar wdired-old-content)
214 (defvar wdired-old-point)
214 215
215 216
216 (defun wdired-mode () 217 (defun wdired-mode ()
217 "\\<wdired-mode-map>File Names Editing mode. 218 "\\<wdired-mode-map>File Names Editing mode.
218 219
240 241
241 See `wdired-mode'." 242 See `wdired-mode'."
242 (interactive) 243 (interactive)
243 (set (make-local-variable 'wdired-old-content) 244 (set (make-local-variable 'wdired-old-content)
244 (buffer-substring (point-min) (point-max))) 245 (buffer-substring (point-min) (point-max)))
246 (set (make-local-variable 'wdired-old-point) (point))
245 (set (make-local-variable 'query-replace-skip-read-only) t) 247 (set (make-local-variable 'query-replace-skip-read-only) t)
246 (use-local-map wdired-mode-map) 248 (use-local-map wdired-mode-map)
247 (force-mode-line-update) 249 (force-mode-line-update)
248 (setq buffer-read-only nil) 250 (setq buffer-read-only nil)
249 (dired-unadvertise default-directory) 251 (dired-unadvertise default-directory)
262 (wdired-preprocess-symlinks)) 264 (wdired-preprocess-symlinks))
263 (buffer-enable-undo) ; Performance hack. See above. 265 (buffer-enable-undo) ; Performance hack. See above.
264 (set-buffer-modified-p nil) 266 (set-buffer-modified-p nil)
265 (setq buffer-undo-list nil) 267 (setq buffer-undo-list nil)
266 (run-mode-hooks 'wdired-mode-hook) 268 (run-mode-hooks 'wdired-mode-hook)
267 (message "%s" (substitute-command-keys "Press \\[wdired-finish-edit] when finished \ 269 (message "%s" (substitute-command-keys
270 "Press \\[wdired-finish-edit] when finished \
268 or \\[wdired-abort-changes] to abort changes"))) 271 or \\[wdired-abort-changes] to abort changes")))
269 272
270 273
271 ;; Protect the buffer so only the filenames can be changed, and put 274 ;; Protect the buffer so only the filenames can be changed, and put
272 ;; properties so filenames (old and new) can be easily found. 275 ;; properties so filenames (old and new) can be easily found.
346 (defun wdired-abort-changes () 349 (defun wdired-abort-changes ()
347 "Abort changes and return to dired mode." 350 "Abort changes and return to dired mode."
348 (interactive) 351 (interactive)
349 (let ((inhibit-read-only t)) 352 (let ((inhibit-read-only t))
350 (erase-buffer) 353 (erase-buffer)
351 (insert wdired-old-content)) 354 (insert wdired-old-content)
355 (goto-char wdired-old-point))
352 (wdired-change-to-dired-mode) 356 (wdired-change-to-dired-mode)
353 (set-buffer-modified-p nil) 357 (set-buffer-modified-p nil)
354 (setq buffer-undo-list nil) 358 (setq buffer-undo-list nil)
355 (message "Changes aborted")) 359 (message "Changes aborted"))
356 360