Article View: gnu.emacs.bug
Article #98957dired enhancements
From: jonathan
Date: Thu, 17 Jan 1991 22:31
Date: Thu, 17 Jan 1991 22:31
104 lines
4463 bytes
4463 bytes
I made some enhancements to dired. You may add them (or some
derivative thereof) to the distribution if you wish:
;;; dired-mkdir
This could be done much more efficiently:
(defun mkdir (directory)
"Make a directory relative to the current directory."
(interactive "FDirectory to create: ")
(shell-command (concat "mkdir " directory)))
(defun dired-mkdir (directory)
"Make a directory relative to the current directory."
(interactive "FDirectory to create: ")
(mkdir directory)
(revert-buffer))
(define-key dired-mode-map "" 'dired-mkdir)
(define-key dired-mode-map "" 'dired-mkdir)
This is better:
;;; Fix dired-get-filename to work with ls -F
(setq dired-listing-switches "-algF")
(fset 'dired-simple-get-filename (symbol-function 'dired-get-filename))
(defun dired-get-filename (&optional localp no-error-if-not-filep)
"Call \\[dired-simple-get-filename].
Then, if dired-listing-switches contains the F flag,
fix up the filename by getting rid of the extra character."
(let ((filename (dired-simple-get-filename localp no-error-if-not-filep))
eol)
(if (and (string-match "F" dired-listing-switches)
(save-excursion
(end-of-line)
(setq eol (point))
(beginning-of-line)
(re-search-forward
"^[ ]*\\([ds]\\|\\-..x\\|\\-.....x\\|\\-........x\\)"
eol t)))
(substring filename 0 (1- (length filename)))
filename)))
;;; dired-toggle-sort
(define-key dired-mode-map "t" 'dired-toggle-sort)
(defun dired-toggle-sort ()
"Make the dired-listing-switches variable local to the current buffer.
Then, if it contains the t flag, remove it, if not add it."
(interactive)
(make-local-variable 'dired-listing-switches)
(let ((t-flag (string-match "t" dired-listing-switches)))
(setq dired-listing-switches
(if t-flag (concat (substring dired-listing-switches 0 t-flag)
(substring dired-listing-switches (1+ t-flag)))
(concat dired-listing-switches "t"))))
(revert-buffer))
(defun dired-mode (&optional dirname)
"Mode for \"editing\" directory listings.
In dired, you are \"editing\" a list of the files in a directory.
You can move using the usual cursor motion commands.
Letters no longer insert themselves.
Instead, type d to flag a file for Deletion.
Type u to Unflag a file (remove its D flag).
Type Rubout to back up one line and unflag.
Type x to eXecute the deletions requested.
Type f to Find the current line's file
(or Dired it, if it is a directory).
Type o to find file or dired directory in Other window.
Type # to flag temporary files (names beginning with #) for Deletion.
Type ~ to flag backup files (names ending with ~) for Deletion.
Type . to flag numerical backups for Deletion.
(Spares dired-kept-versions or its numeric argument.)
Type r to rename a file.
Type c to copy a file.
Type v to view a file in View mode, returning to Dired when done.
Type g to read the directory again. This discards all deletion-flags.
Type t to toggle whether the listing is sorted by modification date.
Space and Rubout can be used to move down and up by lines.
Also: C -- compress this file. U -- uncompress this file.
B -- byte compile this file.
M, G, O -- change file's mode, group or owner.
\\{dired-mode-map}"
(interactive)
(make-local-variable 'revert-buffer-function)
(setq revert-buffer-function 'dired-revert)
(setq major-mode 'dired-mode)
(setq mode-name "Dired")
(make-local-variable 'dired-directory)
(setq dired-directory (or dirname default-directory))
(if dirname
(setq default-directory
(if (file-directory-p dirname)
dirname (file-name-directory dirname))))
(setq mode-line-buffer-identification '("Dired: %17b"))
(setq case-fold-search nil)
(setq buffer-read-only t)
(use-local-map dired-mode-map)
(run-hooks 'dired-mode-hook))
Technical Details
Message-ID:
<9101172231.AA26520@transylvania.ksr.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!ksr.com!jonathanShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,422eac631ef8f73e,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1991-01-17 14:31:39 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!ksr.com!jonathan From: jonathan@ksr.com Newsgroups: gnu.emacs.bug Subject: dired enhancements Message-ID: <9101172231.AA26520@transylvania.ksr.com> Date: 17 Jan 91 22:31:39 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 104 Approved: bug-gnu-emacs@prep.ai.mit.edu