Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get full path of currently opened file?

40 views
Skip to first unread message

jikk

unread,
Sep 19, 2011, 4:22:46 PM9/19/11
to
HI, all

I'm trying to use emacs in combination with cscope.
Sometimes, I got lost by not knowing where the file is located in
source tree.
Is there any simple command that I use for this case? say, "M-x
display-file-path" or something similar.

Thanks for your help in advance.

John Bokma

unread,
Sep 19, 2011, 4:56:47 PM9/19/11
to
jikk <aix...@gmail.com> writes:

> HI, all
>
> I'm trying to use emacs in combination with cscope.
> Sometimes, I got lost by not knowing where the file is located in
> source tree.
> Is there any simple command that I use for this case? say, "M-x
> display-file-path" or something similar.

M-x pwd

Shows the directory the file is in.

--
John Bokma j3b

Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/
Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html

Alan Mackenzie

unread,
Sep 19, 2011, 5:16:28 PM9/19/11
to
jikk <aix...@gmail.com> wrote:
> HI, all

> I'm trying to use emacs in combination with cscope.
> Sometimes, I got lost by not knowing where the file is located in
> source tree.
> Is there any simple command that I use for this case? say, "M-x
> display-file-path" or something similar.

Using C-x C-v `find-alternate-file' displays the full path. Just do
C-g to get back to normal editing.

> Thanks for your help in advance.

--
Alan Mackenzie (Nuremberg, Germany).

Fredrik Axelsson

unread,
Sep 20, 2011, 2:20:24 AM9/20/11
to
M-: (buffer-file-name)

Shows the full path of the visited file.

Stefan Monnier

unread,
Sep 20, 2011, 9:56:26 PM9/20/11
to
>> I'm trying to use emacs in combination with cscope.
>> Sometimes, I got lost by not knowing where the file is located in
>> source tree.
>> Is there any simple command that I use for this case? say,  "M-x
>> display-file-path" or something similar.
>>
>> Thanks for your help in advance.

> M-: (buffer-file-name)

> Shows the full path of the visited file.

BTW, the convention on GNU systems is to use the word "path" only for
lists of directories (as in $PATH or load-path), whereas what the user
is asking for would simply be an absolute file name.


Stefan

Sylvain Rousseau

unread,
Mar 28, 2012, 5:44:42 PM3/28/12
to jikk, help-gn...@gnu.org
Try

(setq frame-title-format
      '(:eval
        (concat "Emacs: "
                (or
                 buffer-file-name
                 (and (eq major-mode 'dired-mode)
                      (expand-file-name
                       (if (listp dired-directory)
                           (car dired-directory)
                         dired-directory)))
                 (buffer-name)))))

 to see the path in the frame title.


Sylvain.
0 new messages