4

For my Emacs configuration, I use a literate programming setup. My config files are in org-mode format, and my init.el file consists mostly of org-babel lines like (org-babel-load-file "~/emacs/startup.org").

I often use describe-key to look up custom functions I have created in order to edit them. However, describe-key gives me something like:

M-s-g runs the command gnugol, which is an interactive Lisp function in `startup.el'.

in which startup.el is a link to that file. However in my case, startup.el is a file that's automatically generated (tangled?) every time I launch Emacs, so any edits I make to it will get overwritten.

How do I tell describe-key to instead give me a link directly to startup.org (or whatever config file contains the defun) so I can edit my actual config files?

Gracjan Polak
  • 1,082
  • 6
  • 21
incandescentman
  • 4,111
  • 16
  • 53
  • 1
    If you don't mind a multistep solution, you could add `:comments` header which will add commented links back to `startup.org` file when tangling `startup.el`. Then when `describe-key` takes you to `startup.el`, you should be able to use `org-babel-tangle-jump-to-org` to jump back to `startup.org`. I'm sure someone will post a better solution, so I didn't submit an answer. – Melioratus Dec 12 '15 at 21:27
  • 1
    Here's [`:comments`](http://orgmode.org/manual/comments.html) header info. – Melioratus Dec 12 '15 at 21:42
  • That page of the manual doesn't have examples of the syntax. Can you give me an idea of what it would look like to add a link to the file in the comments header? – incandescentman Dec 13 '15 at 05:09
  • 1
    `org-mode` should add the links automatically when tangling a file from a code block with `:comments noweb` header. Adding `#+HEADER: :comments noweb` line directly above `#+BEGIN_SRC:` line should work. Then tangle the file with`C-c C-v t`. When you open the new file in emacs, you should see extra comments in the source code which contain a link back to the original org file. – Melioratus Dec 15 '15 at 03:58
  • 1
    After new comments have been added, you should be able to jump back org file by putting cursor on a the linked comments link and doing 'M-x org-babel-tangle-jump-to-org`. It's been a while since I tried it but think that's how it worked. – Melioratus Dec 15 '15 at 04:07
  • I see. Now that I've tried it, I agree that it requires kind of a lot of steps in order to get to the relevant function in my org file. – incandescentman Jan 05 '16 at 07:50
  • 1
    I add [header variables](http://orgmode.org/manual/tangle_002dmode.html#tangle_002dmode) so that my tangled files are read only `:tangle-mode (identity #o444)`, read only files are opened in view-mode `view-read-only` and also use the `:comments both` option combined with an intro explaining `org-babel-jump-to-org` – p_wiersig Nov 29 '16 at 22:47

0 Answers0