home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / functions / dired-delete.el < prev    next >
Encoding:
Text File  |  1991-05-03  |  1.4 KB  |  42 lines

  1. ; From: phs@lifia.imag.fr (Philippe Schnoebelen)
  2. ; Subject: Dired gadget (+ general suggestion)
  3. ; Date: 13 Nov 90 21:03:38 GMT
  4. ; Organization: Lab. LIFIA -- Univ. Grenoble -- France
  5. ; Here is a little gadget for Dired:
  6. (defun dired-delete-this-file ()
  7.   "In dired, delete the file named on this line."
  8.   (interactive)
  9.   (let ((buffer-read-only nil)
  10.     (fname (dired-get-filename)))
  11.     (if (not (y-or-n-p (format "Delete file %s " fname)))
  12.     (message "OK, I won't.")
  13.     ;; else, do it !
  14.     (delete-file fname)
  15.     (delete-region (progn (beginning-of-line) (point))
  16.                (progn (forward-line 1) (point)))
  17.     (message "Done"))))
  18.  
  19. I've put:
  20.        (define-key dired-mode-map "\C-d" 'dired-delete-this-file)
  21.  
  22. in my dired-mode-hook. (Admittedly, the choice of \C-d is poor taste. Feel
  23. free to suggest improvements.)
  24.  
  25. Now, you can remove a file from your directory just by hitting \C-d when
  26. you're pointing at it in Dired. 
  27.  
  28.  
  29. I very much prefer this kind of interactive behavior over the usual (in
  30. GnuEmacs) way of marking for deletion and then deleting. A similar case
  31. could be presented for Buffer-List, or VM-summary, ...  It would be nice if
  32. this were added _in_a_consistent_way_ in all relevant Emacs packages. What
  33. do others think ?
  34. --
  35. Philippe SCHNOEBELEN,  LIFIA,  46 Av Felix VIALLET,  38000 Grenoble,  FRANCE
  36.                              email: phs@lifia.imag.fr
  37. "Algebraic symbols are used when you do not know what you are talking about."
  38.  
  39.  
  40.