help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dired: goto directory of a file


From: Barman Brakjoller
Subject: Re: dired: goto directory of a file
Date: 15 Jan 2004 04:20:44 -0800

> in a dired buffer (particu;ar in a dired-find buffer) it would be very
> handy to be able to jump to the containing directory of a file:
> 
> eg. the dired buffer shows the line
> 
>   -rw-r--r--  1 leo  staff  618385 30 Nov 08:29 Audio/Apps/iCDc4.3.3.dmg.sit
> 
> then just jump to the directory Audio/Apps in a new dired window.

I came up with the following function which works in most cases I
guess:

(defun dired-open-containing-directory ()
  "Opens the directory where the file at point is located"
  (interactive)
  (let ((file (dired-filename-at-point)))
    (string-match "\\(.*/\\)" file)
    (find-file (substring file 0 (match-end 1)))))

Enjoy!

If there is some shorter/better way to extract the path from the full
filename and path, the function could be even shorter, but I didn't
find any function that does that.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]