[deleted] · 2022-03-04 17:07
I do a lot of literate programming and I feel a little bit annoying the fact
that I could not find an easy way of using imenu list for the language I'm developing in.
I have a project in common lisp, and I wrote this function
(defun imenu-literate (src-edit?)
(interactive "P")
(let ((imenu-generic-expression lisp-imenu-generic-expression)
(imenu-create-index-function #'imenu-default-create-index-function))
(imenu-list-update-safe)
(imenu-list-refresh)
(call-interactively #'imenu)
(when src-edit?
(org-edit-special))))
which is fair enough to understand and works but it sure feels like
a Hack. Moreover I'd like to use this for more languages
and I'd like to set the underlying mode through org mode as a pragma.
But since this would be so convenient I wanted to ask if there is already
something like this and I don't have to invent a new wheel.
Cheers!
00-11 · 2022-03-04 17:30
Please format your code by indenting each line 4 spaces.
----
Reddit apparently isn't capable of providing a horizontal scroll bar (?), so your code appears truncated at the right - at least with the "classic" UI (which is much better than the "new improved" UI).
paretoOptimalDev · 2022-03-04 17:52
I use consult-imenu to see heading structure. From reading the code it looks like this is for source blocks? How do you use it?
Illiamen · 2022-03-04 23:25
You might be interested in the command `org-babel-goto-named-src-block`.
[deleted] · 2022-03-05 11:27
it is for the source blocks but when you are not editing specially any of them. I want to have a `consult-imenu` functionality for the underlying language in the source blocks so that while I am in the org-mode document I can jump to the definition of a function in a source block.
I would like to separate between the `consult-imenu` behaviour for org-mode and for the language of my choice that is embedded in the org-mode document.
The function I posted is a crude approach to it, what it does is that
it calls something like `consult-imenu` (just `imenu`) with the imenu rules
for common lisp, so that I can jump to the definition of some lisp function I wrote in some src-blocks.
I was wondering of course if someone has already written a package for something like this. My rough approach is not really so good because it forces imenu to parse the whole org-mode document and it would be better to let it parse only the src block contents and ignore the rest.
[deleted] · 2022-03-05 11:29
I know this, but I find it a little but cumbersome because then I have to name every src-block. If I had a src-block with a python function
def foo():
pass
I would like not to have to name the source block like `fun-foo` or so,
because maybe I want to define two functions in the src block.
Nevertheless, it is a valid approach, thanks for reminding me of that.
takeonrules · 2022-03-05 14:15
This is super nice, and I was trying to figure out how to add marginalia/annotations to these results. Following along to see where this solution quest goes.
[deleted] · 2022-03-05 20:53
I am not finding anything about this,
this is a gist of what I have right now in my emacs config
https://gist.github.com/alejandrogallo/b4d828ae92ae2691951d4a3d2c1f75dd