unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: dired: goto directory of a file
Date: Thu, 15 Jan 2004 08:57:44 -0700	[thread overview]
Message-ID: <4006B878.5020501@yahoo.com> (raw)
In-Reply-To: 1c58a7c3.0401150420.7ffe6306@posting.google.com

Barman Brakjoller wrote:

>>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.

C-h f file-name-directory


It's described in detail in the File Name Components node of the Emacs
Lisp manual; you might also want to browse the other subnodes of the
File Names node.

-- 
Kevin Rodgers

  reply	other threads:[~2004-01-15 15:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-14 11:42 dired: goto directory of a file leo
2004-01-15 12:20 ` Barman Brakjoller
2004-01-15 15:57   ` Kevin Rodgers [this message]
2004-01-15 22:37   ` problems with dired-filename-at-point (was Re: dired: goto directory of a file) leo
2004-01-15 22:57     ` Kevin Rodgers
2004-01-28  8:54 ` dired: goto directory of a file Kai Grossjohann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4006B878.5020501@yahoo.com \
    --to=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).