1

I have a lot of my emacs configuration in an org babel file, which I load with org-babel-load-file. My configuration is in my-emacs-config.org.

When I use describe-function for one of the functions I define there, it links to the tangled .el file, but I'd like it to link to my org file.

For example:

my-function is a Lisp function in ‘../my-emacs-config.el’.

(my-function)

Blah blah documentation for my function here.

[back]

The ../my-emacs-config.el is a link. But I want that to link to ../my-emacs-config.org -- the original org source file.

Note that the manual has a bit on the :comments link header argument (see here) but that just seems to put an org-mode style link at the top of the output .el file. I want something that advises describe-function or somehow gives me a link to the org source file.

Any ideas?

1
  • 1
    Are the .org files and the corresponding tangled .el files in the same directory? If so, you can get the .el file and interject a transformation to the corresponding .org file, perhaps by redefining find-list-object-file-name which is the function used by describe-function to get the path.
    – NickD
    Sep 5, 2022 at 13:59

1 Answer 1

1

Thanks to @NickD and the magic of :filter-return advice, this turns out to be super simple: we write a function that akes the file name that find-lisp-object-file-name returns, and for those that came from our literate org files, change the .el to .org.

For my setup, here's all I need to do:

(defun filter-find-lisp-object-file-name (fn)
  "If the output of `find-lisp-object-file-name' is config.el,
change that to config.org; otherwise, this is the identity
 function."
  (if (string= fn "/home/dan/.emacs.d/my-emacs-config.el")
      "/home/dan/.emacs.d/my-emacs-config.org"
      fn))

(advice-add 'find-lisp-object-file-name :filter-return #'filter-find-lisp-object-file-name)

The filter-return advice function is very simple: it just needs some logic to identify the .el files that come from my literate .org files, and to change those appropriately. In my case, there's only one, so the logic is very simple, but it would be straightforward to do some parsing of the path or other logic. For anything not from my configuration, the filter just passes through the file name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.