Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a link to external file line in Emacs org-mode

Tags:

emacs

org-mode

I have 2 files:

  1. php file with code
  2. org file with docs

How to create a link to a line in php file from org file? So clicking it will move the cursor to the appropriate line in php file.

like image 743
user4035 Avatar asked Aug 22 '12 20:08

user4035


People also ask

What is Org Store link?

The main function is org-store-link , called with M-x org-store-link . Because of its importance, we suggest to bind it to a widely available key (see Activation). It stores a link to the current location. The link is stored for later insertion into an Org buffer—see below.

How do I enter Org Mode in Emacs?

Emacs does not actually understand you are editing an Org document, yet. To enable Org mode on your current document, type M-x org-mode which will enable the Org mode on the current document. Those are minuses, not underscores.

Does Org mode come with Emacs?

Emacs has included Org Mode as a major mode by default since 2006. Bastien Guerry is the current maintainer, in cooperation with an active development community. Since its success in Emacs, some other systems now provide functions to work with org files.


2 Answers

Use this notation in the org mode to create a link:

[[/path/to/file.php::line][string-to-display]]

If you want the file name to be displayed, use just

[[/path/to/file.php::line]]

See Hyperlinks in the Org mode Info page for details and other ways to specify links.

like image 129
choroba Avatar answered Sep 22 '22 12:09

choroba


If I understand the question right you can do it automatically with two org-mode commands:

Move the point to a line in a php file and M-x org-store-link.

Go to an org file and C-c C-l or M-x org-insert-link and follow the instructions in the minibuffer.

You are done, click the link or C-c C-o when the point is on it to open the link.

I have org-store-link on C-c l and org-insert-link on the default C-c C-l. This makes the process very convenient and fast to execute.

Have fun with org-mode.

like image 28
Nek Avatar answered Sep 20 '22 12:09

Nek