emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Helo for defun/macro arguments list in minibuffer when in org-babel src blocks?
@ 2021-07-24 19:50 Arthur Miller
  2021-07-25  0:05 ` Tim Cross
  0 siblings, 1 reply; 5+ messages in thread
From: Arthur Miller @ 2021-07-24 19:50 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1276 bytes --]


I have been doing quite some programming with elisp in org mode, and one
thing I am missing is this help that Emacs shows in minibuffer for
functions and macros. You can see the example in the attached image. I
am not sure what I have to enable (or disable? :)) to get it to work in
babel src blocks? Or is it even possible?

Some few days ago I stumbled on a blog post by J. Kitchin about enabling
orignal mode maps in src block:

https://kitchingroup.cheme.cmu.edu/blog/2017/06/10/Adding-keymaps-to-src-blocks-via-org-font-lock-hook/

That was another thing I was missing, and that one work really well.
Thank yuu John! 

Can that hack be used to enable this help to pup up in minibuffer as
well. I am not familiar what causes that lookup, but I see it happends
even when Emacs is started with -Q option, so it is something built-in
and enabled by default, probably in elisp-mode itself.

Last thing I miss is company doing it's thing. I can complete by
pressing TAB, but I would still like it to happen automatically. Is it
just me being noob and not enabling something, or is it bit more
coplicated than so?

Sorry for the long writing, but basically what I ask is, can we get more
of usualy elisp stuff hanpening in babel src blocks? 

Best regards and thanks for help


[-- Attachment #2: example.png --]
[-- Type: image/png, Size: 55194 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Helo for defun/macro arguments list in minibuffer when in org-babel src blocks?
  2021-07-24 19:50 Helo for defun/macro arguments list in minibuffer when in org-babel src blocks? Arthur Miller
@ 2021-07-25  0:05 ` Tim Cross
  2021-07-25  8:50   ` Arthur Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Cross @ 2021-07-25  0:05 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

when you are editing source blocks are you using org-edit-special, 
normally
bound to C-c ') or are you just editing the source blocks directly 
within the
org buffer?

The functionality you are referring to sounds like eldoc minor 
mode.

If you open a dedicated buffer to edit a file in the same language 
as your
source blocks, do you see the behaviour you want. For example, 
open a file
called test.el and edit some Emacs lisp. If you don't see the 
behaviour your
after, you need to configure emacs-lisp-mode to load eldoc mode. 
Try typing M-x
eldoc-mode <ret> and see if you then get the behaviour your after. 
If you do,
then read up on eldoc-mode and how to enable it.

The environment you get with a dedicated buffer and that you get 
with
org-edit-special should be roughly the same. So the trick is to 
get things
working how you like them using a dedicated *.el buffer and then 
use
org-edit-special whenever you need to edit source blocks. There is 
also another
good reason to use org-edit-special - there are some situations 
where org needs
to add some special escaping characters in source blocks to enable 
things to be
parsed correctly. Using org-edit-special ensures this occurs when 
necessary.
Editing the source blocks directly does not.

Arthur Miller <arthur.miller@live.com> writes:

> I have been doing quite some programming with elisp in org mode, 
> and one
> thing I am missing is this help that Emacs shows in minibuffer 
> for
> functions and macros. You can see the example in the attached 
> image. I
> am not sure what I have to enable (or disable? :)) to get it to 
> work in
> babel src blocks? Or is it even possible?
>
> Some few days ago I stumbled on a blog post by J. Kitchin about 
> enabling
> orignal mode maps in src block:
>
> <https://kitchingroup.cheme.cmu.edu/blog/2017/06/10/Adding-keymaps-to-src-blocks-via-org-font-lock-hook/>
>
> That was another thing I was missing, and that one work really 
> well.
> Thank yuu John!
>
> Can that hack be used to enable this help to pup up in 
> minibuffer as
> well. I am not familiar what causes that lookup, but I see it 
> happends
> even when Emacs is started with -Q option, so it is something 
> built-in
> and enabled by default, probably in elisp-mode itself.
>
> Last thing I miss is company doing it's thing. I can complete by
> pressing TAB, but I would still like it to happen automatically. 
> Is it
> just me being noob and not enabling something, or is it bit more
> coplicated than so?
>
> Sorry for the long writing, but basically what I ask is, can we 
> get more
> of usualy elisp stuff hanpening in babel src blocks?
>


Regards,

Tim

--
*Tim Cross*

/For gor sake stop laughing, this is serious!/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Helo for defun/macro arguments list in minibuffer when in org-babel src blocks?
  2021-07-25  0:05 ` Tim Cross
@ 2021-07-25  8:50   ` Arthur Miller
  2021-07-25  9:03     ` Tim Cross
  0 siblings, 1 reply; 5+ messages in thread
From: Arthur Miller @ 2021-07-25  8:50 UTC (permalink / raw)
  To: Tim Cross; +Cc: emacs-orgmode

Tim Cross <theophilusx@gmail.com> writes:

> Hi,
>
> when you are editing source blocks are you using org-edit-special, normally
> bound to C-c ') or are you just editing the source blocks directly within the
> org buffer?
No I don't narrow.

> The functionality you are referring to sounds like eldoc minor mode.
Yes it is, I was just looking at elisp-mode.el, and saw the eldoc
support. I tried to defadvice around with that scimax spoof function
from J.K's article, but I don't really get it to work.

> If you open a dedicated buffer to edit a file in the same language as your
> source blocks, do you see the behaviour you want. For example, open a file
> called test.el and edit some Emacs lisp. If you don't see the behaviour your
> after, you need to configure emacs-lisp-mode to load eldoc mode. Try typing M-x
> eldoc-mode <ret> and see if you then get the behaviour your after. If you do,
> then read up on eldoc-mode and how to enable it.

>                   Using org-edit-special ensures this occurs when necessary.
> Editing the source blocks directly does not.

I know, I would kind of like to skip to narrow back and forth. I
understand I maybe stretching it a bit, but kind-a cool if it could work
directly in src blocks without narrowing. 

> The environment you get with a dedicated buffer and that you get with
> org-edit-special should be roughly the same. So the trick is to get things
> working how you like them using a dedicated *.el buffer and then use
> org-edit-special whenever you need to edit source blocks. There is also another
> good reason to use org-edit-special - there are some situations where org needs
> to add some special escaping characters in source blocks to enable things to be
> parsed correctly.

Indeed. I had to introduce some macros because of <>[] chars being
parsed wrongly so syntax highlight and identation in src blocks get
screwed. I think I asked for helped about it. J.K. posted his answer in
SX, but I couldn't get that to work, so I just wrote few simple macros
that fixed at least syntax and indenting. Lispy is also really badly
screwed in org-buffer directly, at least for me cursor jumps all over
the place.

Anyway, after trying the "scimax-hack" (if I can call it so), which
works so fine with keymaps, I thought it might work with eldoc and
company too. I am just not sure which things to hook into that spoof
function.

(advice-add 'eldoc-mode :around 'scimax-spoof-mode)

That one let me enabke eldoc-mode which otherwise does not want to run
in org mode (for me at least). However I still don't see the defun
signature in echo area. I tried to hook via those two below:

(advice-add 'elisp-completion-at-point :around 'scimax-spoof-mode)
(advice-add 'elisp-eldoc-documentation-function :around 'scimax-spoof-mode)

but still nothing in echo area :).

Anyway, thanks for any help!

> Arthur Miller <arthur.miller@live.com> writes:
>
>> I have been doing quite some programming with elisp in org mode, and one
>> thing I am missing is this help that Emacs shows in minibuffer for
>> functions and macros. You can see the example in the attached image. I
>> am not sure what I have to enable (or disable? :)) to get it to work in
>> babel src blocks? Or is it even possible?
>>
>> Some few days ago I stumbled on a blog post by J. Kitchin about enabling
>> orignal mode maps in src block:
>>
>> <https://kitchingroup.cheme.cmu.edu/blog/2017/06/10/Adding-keymaps-to-src-blocks-via-org-font-lock-hook/>
>>
>> That was another thing I was missing, and that one work really well.
>> Thank yuu John!
>>
>> Can that hack be used to enable this help to pup up in minibuffer as
>> well. I am not familiar what causes that lookup, but I see it happends
>> even when Emacs is started with -Q option, so it is something built-in
>> and enabled by default, probably in elisp-mode itself.
>>
>> Last thing I miss is company doing it's thing. I can complete by
>> pressing TAB, but I would still like it to happen automatically. Is it
>> just me being noob and not enabling something, or is it bit more
>> coplicated than so?
>>
>> Sorry for the long writing, but basically what I ask is, can we get more
>> of usualy elisp stuff hanpening in babel src blocks?
>>
>
>
> Regards,
>
> Tim
>
> --
> *Tim Cross*
>
> /For gor sake stop laughing, this is serious!/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Helo for defun/macro arguments list in minibuffer when in org-babel src blocks?
  2021-07-25  8:50   ` Arthur Miller
@ 2021-07-25  9:03     ` Tim Cross
  2021-07-25  9:48       ` Arthur Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Cross @ 2021-07-25  9:03 UTC (permalink / raw)
  To: Arthur Miller; +Cc: emacs-orgmode


Arthur Miller <arthur.miller@live.com> writes:

> Tim Cross <theophilusx@gmail.com> writes:
>
>> Hi,
>>
>> when you are editing source blocks are you using org-edit-special, normally
>> bound to C-c ') or are you just editing the source blocks directly within the
>> org buffer?
> No I don't narrow.

Note that org-edit-special isn't really narrowing. Rather, it opens a
new buffer (there are options to control how it does this i.e. replace
org buffer, split to open in new buffer, open in new frame etc) which puts the source block
into the native mode for the language being edited.  For example, if
your editing an emacs-lisp block, the edit special buffer will be in
emacs-lisp-mode and will have all the facilities you would normally have
when opening an emacs lisp file.

What it sounds like you want to do is just have all the (for example)
emacs-lisp mode and associated minor modes activated when your cursor is
within a source block within the org buffer. This is extremely difficult
to. Part of the problem is that modes like emacs-lisp-mode are designed
to operate on buffers. There are some 'special' packages, like mmm-mode
which try to support this type of functionality, but to be honest, I've
never found them very good and they often have significant performance
problems.

Of course, this is emacs and you can probably get something mostly
working, but it will take considerable effort and may well have
performance hits as well as other unexpected side effects. I think your
definitely 'swimming against the flow' and suspect that in the end, you
will spend far more time trying to maintain your hacks rather than
actually focusing on the work you want to get done. I originally went down a
similar path, but then realised, it was much easier just to get use to
using org-edit-special and focus on getting that to work just how I like
it. Now, I don't even notice/think about it. I just hit the key to open
the buffer, edit it and then exit. I have it setup so that the original
org buffer is still displayed, so I can see/scroll the org buffer in
case I need to reference other information in the buffer etc. All the
bits I want work just like they do when I edit 'native' buffers for the
language being edited (syntax, indentation, snippets/completion,
symbol/documentation lookup etc).

Anyway, good luck.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Helo for defun/macro arguments list in minibuffer when in org-babel src blocks?
  2021-07-25  9:03     ` Tim Cross
@ 2021-07-25  9:48       ` Arthur Miller
  0 siblings, 0 replies; 5+ messages in thread
From: Arthur Miller @ 2021-07-25  9:48 UTC (permalink / raw)
  To: Tim Cross; +Cc: emacs-orgmode

Tim Cross <theophilusx@gmail.com> writes:

> Arthur Miller <arthur.miller@live.com> writes:
>
>> Tim Cross <theophilusx@gmail.com> writes:
>>
>>> Hi,
>>>
>>> when you are editing source blocks are you using org-edit-special, normally
>>> bound to C-c ') or are you just editing the source blocks directly within the
>>> org buffer?
>> No I don't narrow.
>
> Note that org-edit-special isn't really narrowing. Rather, it opens a
> new buffer (there are options to control how it does this i.e. replace
> org buffer, split to open in new buffer, open in new frame etc) which puts the source block
> into the native mode for the language being edited.  For example, if
> your editing an emacs-lisp block, the edit special buffer will be in
> emacs-lisp-mode and will have all the facilities you would normally have
> when opening an emacs lisp file.
>
> What it sounds like you want to do is just have all the (for example)
> emacs-lisp mode and associated minor modes activated when your cursor is
> within a source block within the org buffer. This is extremely difficult
> to. Part of the problem is that modes like emacs-lisp-mode are designed
> to operate on buffers.

Yes indeed. I am quite aware of difficulties involved. I did myself a
small [[https://github.com/amno1/dired-auto-readme][hack to dired mode to "auto show" readme files]], and got into all
those problems there.

That one major mode per buffer is starting to be a limitation. What we
really would need is a major mode per region, or some other mean to be
able to combine modes. Maybe something like a "primary mode" which would
be what Emacs opens into when a file is loaded, i.e. 'org-mode' in this
example and secondary modes, which would be other major modes loaded,
and somehow activated per region or I don't know. But that is a
day-dreaming :). It would require rebuilding entire machinery.

>                        There are some 'special' packages, like mmm-mode
> which try to support this type of functionality, but to be honest, I've
> never found them very good and they often have significant performance
> problems.

Yes I know. I tried with mmm-mode, didn't really work well for me.

> Of course, this is emacs and you can probably get something mostly
> working, but it will take considerable effort and may well have
> performance hits as well as other unexpected side effects. I think your
> definitely 'swimming against the flow' and suspect that in the end, you

Haha, definitely :-). But that is the story of my entire life ;-).

Yes, in this case, that is correct. What I am doing here is bending
entire org-mode to do something it is not supposed to do. If you are
interested you can take a look at [[https://github.com/amno1/.emacs.d/blob/main/init.org][my little app on my github]]:

Look at "org hacks" under generator heading.

> will spend far more time trying to maintain your hacks rather than
> actually focusing on the work you want to get done. I originally went down a

That is what is hapening, but I started this as a hobby project as well
as a learning experience. I really suck at both Emacs internals and
elisp, so I need something like this as a learning project.

> Anyway, good luck.

Thanks, and thank you for the tips and feedback.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-25  9:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-24 19:50 Helo for defun/macro arguments list in minibuffer when in org-babel src blocks? Arthur Miller
2021-07-25  0:05 ` Tim Cross
2021-07-25  8:50   ` Arthur Miller
2021-07-25  9:03     ` Tim Cross
2021-07-25  9:48       ` Arthur Miller

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).