[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/files.el,v
From: |
Jason Rumney |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/files.el,v |
Date: |
Wed, 02 Jul 2008 13:19:12 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Jason Rumney <jasonr> 08/07/02 13:19:09
Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.985
retrieving revision 1.986
diff -u -b -r1.985 -r1.986
--- lisp/files.el 11 Jun 2008 01:47:47 -0000 1.985
+++ lisp/files.el 2 Jul 2008 13:19:04 -0000 1.986
@@ -31,7 +31,6 @@
(defvar font-lock-keywords)
-
(defgroup backup nil
"Backups of edited data files."
:group 'files)
@@ -3693,7 +3692,7 @@
"Given the name of a numeric backup file, FN, return the backup number.
Uses the free variable `backup-extract-version-start', whose value should be
the index in the name where the version number begins."
- (if (and (string-match "[0-9]+~$" fn backup-extract-version-start)
+ (if (and (string-match "[0-9]+~/?$" fn backup-extract-version-start)
(= (match-beginning 0) backup-extract-version-start))
(string-to-number (substring fn backup-extract-version-start -1))
0))
@@ -5783,6 +5782,48 @@
(file-modes-symbolic-to-number value modes)))))
+;; Trash can handling.
+(defcustom trash-directory "~/.Trash"
+ "Directory for `move-file-to-trash' to move files and directories to.
+This directory is only used when the function `system-move-file-to-trash' is
+not defined. Relative paths are interpreted relative to `default-directory'.
+See also `delete-by-moving-to-trash'."
+ :type 'directory
+ :group 'auto-save
+ :version "23.1")
+
+(declare-function system-move-file-to-trash "w32fns.c" (filename))
+
+(defun move-file-to-trash (filename)
+ "Move file (or directory) name FILENAME to the trash.
+This function is called by `delete-file' and `delete-directory' when
+`delete-by-moving-to-trash' is non-nil. On platforms that define
+`system-move-file-to-trash', that function is used to move FILENAME to the
+system trash, otherwise FILENAME is moved to `trash-directory'.
+Returns nil on success."
+ (interactive "fMove file to trash: ")
+ (cond
+ ((fboundp 'system-move-file-to-trash)
+ (system-move-file-to-trash filename))
+ (t
+ (let* ((trash-dir (expand-file-name trash-directory))
+ (fn (directory-file-name (expand-file-name filename)))
+ (fn-nondir (file-name-nondirectory fn))
+ (new-fn (expand-file-name fn-nondir trash-dir)))
+ (or (file-directory-p trash-dir)
+ (make-directory trash-dir t))
+ (and (file-exists-p new-fn)
+ ;; make new-fn unique.
+ ;; example: "~/.Trash/abc.txt" -> "~/.Trash/abc.txt.~1~"
+ (let ((version-control t))
+ (setq new-fn (car (find-backup-file-name new-fn)))))
+ ;; stop processing if fn is same or parent directory of trash-dir.
+ (and (string-match fn trash-dir)
+ (error "Filename `%s' is same or parent directory of
trash-directory"
+ filename))
+ (rename-file fn new-fn)))))
+
+
(define-key ctl-x-map "\C-f" 'find-file)
(define-key ctl-x-map "\C-r" 'find-file-read-only)
(define-key ctl-x-map "\C-v" 'find-alternate-file)
- [Emacs-diffs] Changes to emacs/lisp/files.el,v,
Jason Rumney <=
- [Emacs-diffs] Changes to emacs/lisp/files.el,v, Jason Rumney, 2008/07/11
- [Emacs-diffs] Changes to emacs/lisp/files.el,v, Chong Yidong, 2008/07/30
- [Emacs-diffs] Changes to emacs/lisp/files.el,v, Dan Nicolaescu, 2008/07/31
- [Emacs-diffs] Changes to emacs/lisp/files.el,v, Juri Linkov, 2008/07/31
- [Emacs-diffs] Changes to emacs/lisp/files.el,v, Chong Yidong, 2008/07/31
- [Emacs-diffs] Changes to emacs/lisp/files.el,v, Juanma Barranquero, 2008/07/31