all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dired: goto directory of a file
@ 2004-01-14 11:42 leo
  2004-01-15 12:20 ` Barman Brakjoller
  2004-01-28  8:54 ` dired: goto directory of a file Kai Grossjohann
  0 siblings, 2 replies; 6+ messages in thread
From: leo @ 2004-01-14 11:42 UTC (permalink / raw)


hi there

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.

cheers, leo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dired: goto directory of a file
  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
  2004-01-15 22:37   ` problems with dired-filename-at-point (was Re: dired: goto directory of a file) leo
  2004-01-28  8:54 ` dired: goto directory of a file Kai Grossjohann
  1 sibling, 2 replies; 6+ messages in thread
From: Barman Brakjoller @ 2004-01-15 12:20 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dired: goto directory of a file
  2004-01-15 12:20 ` Barman Brakjoller
@ 2004-01-15 15:57   ` Kevin Rodgers
  2004-01-15 22:37   ` problems with dired-filename-at-point (was Re: dired: goto directory of a file) leo
  1 sibling, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2004-01-15 15:57 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* problems with dired-filename-at-point (was Re: dired: goto directory of a file)
  2004-01-15 12:20 ` Barman Brakjoller
  2004-01-15 15:57   ` Kevin Rodgers
@ 2004-01-15 22:37   ` leo
  2004-01-15 22:57     ` Kevin Rodgers
  1 sibling, 1 reply; 6+ messages in thread
From: leo @ 2004-01-15 22:37 UTC (permalink / raw)


"Barman Brakjoller" <brakjoller@hotmail.com> wrote in message
news:1c58a7c3.0401150420.7ffe6306@posting.google.com...
> > 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)))))

thanks. i have tried this and it works in dired-find buffers but
unfortunatly not in dired subdirs:

dired-filename-at-point doesn't work correctly in subdirs. eg the buffer
shows something like

  c:/_home:
  total 17  free 6651216
  drwxrwxrwx        0 Jan 15 15:13 .
  drwxrwxrwx        0 Jan  1  1970 ..
  drwxrwxrwx        0 Jan  6 16:24 emacs
  [...]

  c:/_home/emacs:
  total 3
  drwxrwxrwx        0 Jan  6 16:24 .
  drwxrwxrwx        0 Jan 15 15:13 ..
  drwxrwxrwx        0 Jan 15 17:41 user-lisp
  [...]

  c:/_home/emacs/user-lisp:
  total 36
  drwxrwxrwx        0 Jan 16 09:23 .
  drwxrwxrwx        0 Jan  6 16:24 ..
  -rw-rw-rw-     4922 Jan 15 17:41 leo-frames.el

now i set the point to the line with leo-frames.el, then
`dired-filename-at-point' tells me c:/_home/leo-frames.el. that's obviously
wrong.

any idea?

leo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: problems with dired-filename-at-point (was Re: dired: goto directory of a file)
  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
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2004-01-15 22:57 UTC (permalink / raw)


leo wrote:

> thanks. i have tried this and it works in dired-find buffers but
> unfortunatly not in dired subdirs:
> 
> dired-filename-at-point doesn't work correctly in subdirs. eg the buffer
> shows something like
> 
>   c:/_home:
>   total 17  free 6651216
>   drwxrwxrwx        0 Jan 15 15:13 .
>   drwxrwxrwx        0 Jan  1  1970 ..
>   drwxrwxrwx        0 Jan  6 16:24 emacs
>   [...]
> 
>   c:/_home/emacs:
>   total 3
>   drwxrwxrwx        0 Jan  6 16:24 .
>   drwxrwxrwx        0 Jan 15 15:13 ..
>   drwxrwxrwx        0 Jan 15 17:41 user-lisp
>   [...]
> 
>   c:/_home/emacs/user-lisp:
>   total 36
>   drwxrwxrwx        0 Jan 16 09:23 .
>   drwxrwxrwx        0 Jan  6 16:24 ..
>   -rw-rw-rw-     4922 Jan 15 17:41 leo-frames.el
> 
> now i set the point to the line with leo-frames.el, then
> `dired-filename-at-point' tells me c:/_home/leo-frames.el. that's obviously
> wrong.

Use the the dired-current-directory function (and you won't even have to strip
off "leo-frames.el" to get the directory name).

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dired: goto directory of a file
  2004-01-14 11:42 dired: goto directory of a file leo
  2004-01-15 12:20 ` Barman Brakjoller
@ 2004-01-28  8:54 ` Kai Grossjohann
  1 sibling, 0 replies; 6+ messages in thread
From: Kai Grossjohann @ 2004-01-28  8:54 UTC (permalink / raw)


leo <leo@bella.local> writes:

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

You can do RET on the file and then use dired-jump.  (dired-jump is
part of dired-x.  C-x j might be a good binding for it, as
jump-to-register is also available as C-x r j.)

Kai

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-01-28  8:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.