emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Custom keymaps on org blocks
@ 2017-06-05 21:53 John Kitchin
  2017-06-06 18:16 ` Nicolas Goaziou
  2017-06-07  1:22 ` Grant Rettke
  0 siblings, 2 replies; 13+ messages in thread
From: John Kitchin @ 2017-06-05 21:53 UTC (permalink / raw)
  To: emacs-orgmode

Is there any interest in having custom keymaps on org blocks?

The idea I had is to have the option to make the major-mode keymaps be
active on the src blocks.

For example, you might want to use something like this to use the elpy
in ipython blocks and lispy-mode-map in emacs-lisp blocks

(defcustom org-src-block-keymaps
  `(("ipython" . ,(let* ((map (copy-keymap elpy-mode-map)))
		    (define-key map (kbd "C-c C-c") 'org-ctrl-c-ctrl-c)
		    (define-key map (kbd "C-c '") 'org-edit-special)
		    map))
    ("emacs-lisp" . ,(let* ((map (copy-keymap lispy-mode-map)))
		       (define-key map (kbd "C-c C-c") 'org-ctrl-c-ctrl-c)
		       (define-key map (kbd "C-c '") 'org-edit-special)
		       map)))
  "alist of custom keymaps for src blocks.")

The implementation is pretty simple, you just modify
org-fontify-meta-lines-and-blocks-1 with a line like this:

(when (assoc (org-no-properties lang) org-src-block-keymaps)
	      (add-text-properties
	       beg end `(local-map ,(cdr (assoc (org-no-properties lang)
	      org-src-block-keymaps)))))


I have tried this, and seems ok, and I wondered if anyone had an opinion
for or against this idea.

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: Custom keymaps on org blocks
  2017-06-05 21:53 Custom keymaps on org blocks John Kitchin
@ 2017-06-06 18:16 ` Nicolas Goaziou
  2017-06-07 12:58   ` John Kitchin
  2017-06-07  1:22 ` Grant Rettke
  1 sibling, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2017-06-06 18:16 UTC (permalink / raw)
  To: John Kitchin; +Cc: emacs-orgmode

Hello,

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> Is there any interest in having custom keymaps on org blocks?
>
> The idea I had is to have the option to make the major-mode keymaps be
> active on the src blocks.

There is already `org-babel-do-key-sequence-in-edit-buffer', i.e., C-c
C-v C-x.

Regards,

-- 
Nicolas Goaziou

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

* Re: Custom keymaps on org blocks
  2017-06-05 21:53 Custom keymaps on org blocks John Kitchin
  2017-06-06 18:16 ` Nicolas Goaziou
@ 2017-06-07  1:22 ` Grant Rettke
  2017-06-07 12:49   ` John Kitchin
  1 sibling, 1 reply; 13+ messages in thread
From: Grant Rettke @ 2017-06-07  1:22 UTC (permalink / raw)
  To: John Kitchin; +Cc: emacs-orgmode@gnu.org

On Mon, Jun 5, 2017 at 4:53 PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> Is there any interest in having custom keymaps on org blocks?
>
> The idea I had is to have the option to make the major-mode keymaps be
> active on the src blocks.

You want Polymode: https://github.com/vspinu/polymode

> I have tried this, and seems ok, and I wondered if anyone had an opinion
> for or against this idea.

It is confusing alternating between the Org major a mode and the
source block major mode as you scroll through documents. One second
you are an author for humans and the other an author for the computer.
That is how literate programming is defined in theory, but in practice
I don't do it like that because it is mentally jarring.

I spell check my Org-Mode Literate Documents. But the spell checker
does not check source blocks. That is up to the major mode for that
source block, not for the containing literate document. When you think
about it, probably every Org-Mode literate programming has it set up
this way, otherwise the spell checker would go crazy on typical source
code. That is revealing. The source blocks are very different "things"
than the containing document.

For me the source block is another cognitive workspace that I enter
consciously. I am digging deeper into the document itself. For me the
source block is a window into that world of the source block. In the
top level document I write literature about things, including the
various source blocks. Then I jump into editing the source block
itself.

John you once had a discussion (or answered a (my?) question) about
making source blocks not-editable. That is how I would like it to work
all the time. That is why I don't fontify source blocks natively and
that is why I wouldn't enjoy what you describe.

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

* Re: Custom keymaps on org blocks
  2017-06-07  1:22 ` Grant Rettke
@ 2017-06-07 12:49   ` John Kitchin
  2017-06-07 23:52     ` Grant Rettke
  0 siblings, 1 reply; 13+ messages in thread
From: John Kitchin @ 2017-06-07 12:49 UTC (permalink / raw)
  To: Grant Rettke; +Cc: emacs-orgmode@gnu.org


Grant Rettke writes:

> On Mon, Jun 5, 2017 at 4:53 PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
>> Is there any interest in having custom keymaps on org blocks?
>>
>> The idea I had is to have the option to make the major-mode keymaps be
>> active on the src blocks.
>
> You want Polymode: https://github.com/vspinu/polymode

I have never been able to get polymode to work. Do have an incantation
that works?

>
>> I have tried this, and seems ok, and I wondered if anyone had an opinion
>> for or against this idea.
>
> It is confusing alternating between the Org major a mode and the
> source block major mode as you scroll through documents. One second
> you are an author for humans and the other an author for the computer.
> That is how literate programming is defined in theory, but in practice
> I don't do it like that because it is mentally jarring.

Interesting perspective. I find switching to special edit mode jarring,
particularly when it is just for the key bindings, e.g. lispy mode, or
getting python indentation to work.

>
> I spell check my Org-Mode Literate Documents. But the spell checker
> does not check source blocks. That is up to the major mode for that
> source block, not for the containing literate document. When you think
> about it, probably every Org-Mode literate programming has it set up
> this way, otherwise the spell checker would go crazy on typical source
> code. That is revealing. The source blocks are very different "things"
> than the containing document.
>
> For me the source block is another cognitive workspace that I enter
> consciously. I am digging deeper into the document itself. For me the
> source block is a window into that world of the source block. In the
> top level document I write literature about things, including the
> various source blocks. Then I jump into editing the source block
> itself.
>
> John you once had a discussion (or answered a (my?) question) about
> making source blocks not-editable. That is how I would like it to work
> all the time. That is why I don't fontify source blocks natively and
> that is why I wouldn't enjoy what you describe.

That is ok, the hack I made is totally optional. If you don't define an
alternative map for a block, it just gets the orgmode map. You can even
just locally redefine a few key bindings on the org-mode map that are
only valid in the block.


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: Custom keymaps on org blocks
  2017-06-06 18:16 ` Nicolas Goaziou
@ 2017-06-07 12:58   ` John Kitchin
  2017-06-07 13:21     ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: John Kitchin @ 2017-06-07 12:58 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode


Nicolas Goaziou writes:

> Hello,
>
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
>> Is there any interest in having custom keymaps on org blocks?
>>
>> The idea I had is to have the option to make the major-mode keymaps be
>> active on the src blocks.
>
> There is already `org-babel-do-key-sequence-in-edit-buffer', i.e., C-c
> C-v C-x.

For once in a while uses this works, but this isn't really a solution
for key-bindings that are composable, e.g. in lispy. There you can use
single key-presses to navigate, rearrange, insert code, etc...

Also it adds three chords to every key-binding out of the box, it would
be fewer keys to just go to special edit mode unless you make a simpler
key definition!

>
> Regards,


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: Custom keymaps on org blocks
  2017-06-07 12:58   ` John Kitchin
@ 2017-06-07 13:21     ` Nicolas Goaziou
  2017-06-07 13:50       ` John Kitchin
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2017-06-07 13:21 UTC (permalink / raw)
  To: John Kitchin; +Cc: emacs-orgmode

Hello,

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> For once in a while uses this works, but this isn't really a solution
> for key-bindings that are composable, e.g. in lispy. There you can use
> single key-presses to navigate, rearrange, insert code, etc...
>
> Also it adds three chords to every key-binding out of the box, it would
> be fewer keys to just go to special edit mode unless you make a simpler
> key definition!

Sure, but I have the feeling that it isn't Org job to allow keybindings
for multiple major modes in the same buffer. Note that we already did
this with links, but I think that specific part of link revamp may have
gone too far.

Also, it could be troublesome because some interactive functions may
depend on a mode specific variables, which are not initialized while in
Org mode.

As far as Org is concerned, C-c ', i.e., `org-edit-special' is the way
to go, IMO.

WDYT?

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

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

* Re: Custom keymaps on org blocks
  2017-06-07 13:21     ` Nicolas Goaziou
@ 2017-06-07 13:50       ` John Kitchin
  2017-06-08  0:22         ` Grant Rettke
  2017-06-10  9:03         ` Nicolas Goaziou
  0 siblings, 2 replies; 13+ messages in thread
From: John Kitchin @ 2017-06-07 13:50 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org

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

I can see that. There are plenty of cases that certainly would not work,
e.g. in a Python block it would be a mistake to run a command that sends
the buffer to the interpreter! In the example I provided, you can see I
also had to "preserve" a few org-bindings so you could still do C-c ' to
get to the special edit. If you didn't know what was happening, it might
also appear that certain org-bindings you were used to had stopped working,
e.g. I have a lightning fast muscle memory to export a buffer, but it
doesn't work when in a src block with this modification (unless of course
it is "preserved" in the keymap). Whether this matters is up to the user,
since they get to choose how the keymap is defined. I would expect it
defaults to the org-mode-keymap.

On the other hand, there are times when I am working on a document that has
a lot of short code blocks, e.g. for lecture notes or blog posts, where it
is sufficiently tedious to me to switch in and out of the special edit mode
that I wanted to try this solution out, and it became clear you can't
really try it out without modifying the core org code that does the
font-locking on a block.

I don't think we have to go so far as to say we make multiple major mode
keybindings available, so much as context specific keybindings available
where there is value in it. We already have this in org-speed keys for
example, and even these can be context specific to do different things on
headings (even different things on headings with specific properties) and
blocks (
http://kitchingroup.cheme.cmu.edu/blog/2016/12/22/Context-specific-org-mode-speed-keys/
).

If there was a change to org to enable this, I wouldn't expect the core to
change behavior for anyone, it would just make it possible for users to
change this if they wanted to. The same way they can customize the face of
a code block for different languages.



John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


On Wed, Jun 7, 2017 at 7:21 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
> > For once in a while uses this works, but this isn't really a solution
> > for key-bindings that are composable, e.g. in lispy. There you can use
> > single key-presses to navigate, rearrange, insert code, etc...
> >
> > Also it adds three chords to every key-binding out of the box, it would
> > be fewer keys to just go to special edit mode unless you make a simpler
> > key definition!
>
> Sure, but I have the feeling that it isn't Org job to allow keybindings
> for multiple major modes in the same buffer. Note that we already did
> this with links, but I think that specific part of link revamp may have
> gone too far.
>
> Also, it could be troublesome because some interactive functions may
> depend on a mode specific variables, which are not initialized while in
> Org mode.
>
> As far as Org is concerned, C-c ', i.e., `org-edit-special' is the way
> to go, IMO.
>
> WDYT?
>
> Regards,
>
> --
> Nicolas Goaziou                                                0x80A93738
>

[-- Attachment #2: Type: text/html, Size: 4361 bytes --]

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

* Re: Custom keymaps on org blocks
  2017-06-07 12:49   ` John Kitchin
@ 2017-06-07 23:52     ` Grant Rettke
  0 siblings, 0 replies; 13+ messages in thread
From: Grant Rettke @ 2017-06-07 23:52 UTC (permalink / raw)
  To: John Kitchin; +Cc: emacs-orgmode@gnu.org

On Wed, Jun 7, 2017 at 7:49 AM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> Grant Rettke writes:
>
>> You want Polymode: https://github.com/vspinu/polymode
>
> I have never been able to get polymode to work. Do have an incantation
> that works?

I forgot that I set it up for R markdown files. But it did work on my
machine after manually installing the `polymode' package.

https://github.com/grettke/home/blob/master/.emacs.el#L1992-L2005

>> It is confusing alternating between the Org major a mode and the
>> source block major mode as you scroll through documents. One second
>> you are an author for humans and the other an author for the computer.
>> That is how literate programming is defined in theory, but in practice
>> I don't do it like that because it is mentally jarring.
>
> Interesting perspective. I find switching to special edit mode jarring,
> particularly when it is just for the key bindings, e.g. lispy mode, or
> getting python indentation to work.

We are both surprised!

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

* Re: Custom keymaps on org blocks
  2017-06-07 13:50       ` John Kitchin
@ 2017-06-08  0:22         ` Grant Rettke
  2017-06-10  9:03         ` Nicolas Goaziou
  1 sibling, 0 replies; 13+ messages in thread
From: Grant Rettke @ 2017-06-08  0:22 UTC (permalink / raw)
  To: John Kitchin; +Cc: emacs-orgmode@gnu.org, Nicolas Goaziou

On Wed, Jun 7, 2017 at 8:50 AM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> On the other hand, there are times when I am working on a document that has
> a lot of short code blocks, e.g. for lecture notes or blog posts, where it
> is sufficiently tedious to me to switch in and out of the special edit mode

These bindings make source block navigation and editing really fast and fun!

(define-key org-mode-map (kbd "s-j") #'org-babel-next-src-block)
(define-key org-mode-map (kbd "s-k") #'org-babel-previous-src-block)
(define-key org-mode-map (kbd "s-l") #'org-edit-src-code)
(define-key org-src-mode-map (kbd "s-l") #'org-edit-src-exit)

Here the 'l' key binding is the most important. It makes for fast
entry and exit of the source block.

For my mind the default bindings "C-c '" interrupts my mental flow. It
is like hearing the sound of a cash register drawer sliding out, doing
some work there and then getting shoved back in every single time.
Ouch.

On the other hand, "s-l" both to enter and exit the source blocks, is
like hearing a gentle breath of air to cool a cup of tea that is a
tiny bit too warm, doing your work and then another gentle breath when
you leave the block.

That is the best way I can describe how much difference the two
bindings make. It is really a "feels" thing, and it feels a lot
better.

Seriously, these bindings might make you fall in love with source
block editing all the time.

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

* Re: Custom keymaps on org blocks
  2017-06-07 13:50       ` John Kitchin
  2017-06-08  0:22         ` Grant Rettke
@ 2017-06-10  9:03         ` Nicolas Goaziou
  2017-06-10 13:58           ` John Kitchin
  1 sibling, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2017-06-10  9:03 UTC (permalink / raw)
  To: John Kitchin; +Cc: emacs-orgmode@gnu.org

Hello,

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> On the other hand, there are times when I am working on a document that has
> a lot of short code blocks, e.g. for lecture notes or blog posts, where it
> is sufficiently tedious to me to switch in and out of the special edit mode
> that I wanted to try this solution out, and it became clear you can't
> really try it out without modifying the core org code that does the
> font-locking on a block.

Are you sure about it? There are two hooks related to fontification:
`org-font-lock-set-keywords-hook' and `org-font-lock-hook'. I'm
surprised none can help you in this case.

> I don't think we have to go so far as to say we make multiple major mode
> keybindings available, so much as context specific keybindings available
> where there is value in it. We already have this in org-speed keys for
> example, and even these can be context specific to do different things on
> headings (even different things on headings with specific properties) and
> blocks (
> http://kitchingroup.cheme.cmu.edu/blog/2016/12/22/Context-specific-org-mode-speed-keys/
> ).

Neat hack.

> If there was a change to org to enable this, I wouldn't expect the core to
> change behavior for anyone, it would just make it possible for users to
> change this if they wanted to. The same way they can customize the face of
> a code block for different languages.

Fair enough. Would you want to provide a proper patch?

Thank you.


Regards,

-- 
Nicolas Goaziou

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

* Re: Custom keymaps on org blocks
  2017-06-10  9:03         ` Nicolas Goaziou
@ 2017-06-10 13:58           ` John Kitchin
  2017-06-10 19:31             ` John Kitchin
  0 siblings, 1 reply; 13+ messages in thread
From: John Kitchin @ 2017-06-10 13:58 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org


Nicolas Goaziou writes:

> Hello,
>
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
>> On the other hand, there are times when I am working on a document that has
>> a lot of short code blocks, e.g. for lecture notes or blog posts, where it
>> is sufficiently tedious to me to switch in and out of the special edit mode
>> that I wanted to try this solution out, and it became clear you can't
>> really try it out without modifying the core org code that does the
>> font-locking on a block.
>
> Are you sure about it? There are two hooks related to fontification:
> `org-font-lock-set-keywords-hook' and `org-font-lock-hook'. I'm
> surprised none can help you in this case.

You are totally right on this. I can use org-font-lock-hook to take care
of this. Thanks for the pointer.

>
>> I don't think we have to go so far as to say we make multiple major mode
>> keybindings available, so much as context specific keybindings available
>> where there is value in it. We already have this in org-speed keys for
>> example, and even these can be context specific to do different things on
>> headings (even different things on headings with specific properties) and
>> blocks (
>> http://kitchingroup.cheme.cmu.edu/blog/2016/12/22/Context-specific-org-mode-speed-keys/
>> ).
>
> Neat hack.

Thanks!

>
>> If there was a change to org to enable this, I wouldn't expect the core to
>> change behavior for anyone, it would just make it possible for users to
>> change this if they wanted to. The same way they can customize the face of
>> a code block for different languages.
>
> Fair enough. Would you want to provide a proper patch?

With the hook I don't think it is necessary. Thanks for all the
discussion though (everyone) it was helpful to think it through.
>
> Thank you.
>
>
> Regards,


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: Custom keymaps on org blocks
  2017-06-10 13:58           ` John Kitchin
@ 2017-06-10 19:31             ` John Kitchin
  2018-09-05 15:52               ` Matt Price
  0 siblings, 1 reply; 13+ messages in thread
From: John Kitchin @ 2017-06-10 19:31 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org

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

In case anyone would like to try this themselves, I documented what I tried
here:
http://kitchingroup.cheme.cmu.edu/blog/2017/06/10/Adding-keymaps-to-src-blocks-via-org-font-lock-hook/

John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


On Sat, Jun 10, 2017 at 9:58 AM, John Kitchin <jkitchin@andrew.cmu.edu>
wrote:

>
> Nicolas Goaziou writes:
>
> > Hello,
> >
> > John Kitchin <jkitchin@andrew.cmu.edu> writes:
> >
> >> On the other hand, there are times when I am working on a document that
> has
> >> a lot of short code blocks, e.g. for lecture notes or blog posts, where
> it
> >> is sufficiently tedious to me to switch in and out of the special edit
> mode
> >> that I wanted to try this solution out, and it became clear you can't
> >> really try it out without modifying the core org code that does the
> >> font-locking on a block.
> >
> > Are you sure about it? There are two hooks related to fontification:
> > `org-font-lock-set-keywords-hook' and `org-font-lock-hook'. I'm
> > surprised none can help you in this case.
>
> You are totally right on this. I can use org-font-lock-hook to take care
> of this. Thanks for the pointer.
>
> >
> >> I don't think we have to go so far as to say we make multiple major mode
> >> keybindings available, so much as context specific keybindings available
> >> where there is value in it. We already have this in org-speed keys for
> >> example, and even these can be context specific to do different things
> on
> >> headings (even different things on headings with specific properties)
> and
> >> blocks (
> >> http://kitchingroup.cheme.cmu.edu/blog/2016/12/22/Context-
> specific-org-mode-speed-keys/
> >> ).
> >
> > Neat hack.
>
> Thanks!
>
> >
> >> If there was a change to org to enable this, I wouldn't expect the core
> to
> >> change behavior for anyone, it would just make it possible for users to
> >> change this if they wanted to. The same way they can customize the face
> of
> >> a code block for different languages.
> >
> > Fair enough. Would you want to provide a proper patch?
>
> With the hook I don't think it is necessary. Thanks for all the
> discussion though (everyone) it was helpful to think it through.
> >
> > Thank you.
> >
> >
> > Regards,
>
>
> --
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>

[-- Attachment #2: Type: text/html, Size: 4116 bytes --]

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

* Re: Custom keymaps on org blocks
  2017-06-10 19:31             ` John Kitchin
@ 2018-09-05 15:52               ` Matt Price
  0 siblings, 0 replies; 13+ messages in thread
From: Matt Price @ 2018-09-05 15:52 UTC (permalink / raw)
  To: Org Mode

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

Necroposting here.  I was wondering if anyone has tried polymode recently,
and whether it still has the problems John described in his earlier posts.
I notice that poly-org is being actively developed but I haven't tried it
out yet...

On Sat, Jun 10, 2017 at 3:32 PM John Kitchin <jkitchin@andrew.cmu.edu>
wrote:

> In case anyone would like to try this themselves, I documented what I
> tried here:
> http://kitchingroup.cheme.cmu.edu/blog/2017/06/10/Adding-keymaps-to-src-blocks-via-org-font-lock-hook/
>
> John
>
> -----------------------------------
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
>
> On Sat, Jun 10, 2017 at 9:58 AM, John Kitchin <jkitchin@andrew.cmu.edu>
> wrote:
>
>>
>> Nicolas Goaziou writes:
>>
>> > Hello,
>> >
>> > John Kitchin <jkitchin@andrew.cmu.edu> writes:
>> >
>> >> On the other hand, there are times when I am working on a document
>> that has
>> >> a lot of short code blocks, e.g. for lecture notes or blog posts,
>> where it
>> >> is sufficiently tedious to me to switch in and out of the special edit
>> mode
>> >> that I wanted to try this solution out, and it became clear you can't
>> >> really try it out without modifying the core org code that does the
>> >> font-locking on a block.
>> >
>> > Are you sure about it? There are two hooks related to fontification:
>> > `org-font-lock-set-keywords-hook' and `org-font-lock-hook'. I'm
>> > surprised none can help you in this case.
>>
>> You are totally right on this. I can use org-font-lock-hook to take care
>> of this. Thanks for the pointer.
>>
>> >
>> >> I don't think we have to go so far as to say we make multiple major
>> mode
>> >> keybindings available, so much as context specific keybindings
>> available
>> >> where there is value in it. We already have this in org-speed keys for
>> >> example, and even these can be context specific to do different things
>> on
>> >> headings (even different things on headings with specific properties)
>> and
>> >> blocks (
>> >>
>> http://kitchingroup.cheme.cmu.edu/blog/2016/12/22/Context-specific-org-mode-speed-keys/
>> >> ).
>> >
>> > Neat hack.
>>
>> Thanks!
>>
>> >
>> >> If there was a change to org to enable this, I wouldn't expect the
>> core to
>> >> change behavior for anyone, it would just make it possible for users to
>> >> change this if they wanted to. The same way they can customize the
>> face of
>> >> a code block for different languages.
>> >
>> > Fair enough. Would you want to provide a proper patch?
>>
>> With the hook I don't think it is necessary. Thanks for all the
>> discussion though (everyone) it was helpful to think it through.
>> >
>> > Thank you.
>> >
>> >
>> > Regards,
>>
>>
>> --
>> Professor John Kitchin
>> Doherty Hall A207F
>> Department of Chemical Engineering
>> Carnegie Mellon University
>> Pittsburgh, PA 15213
>> 412-268-7803
>> @johnkitchin
>> http://kitchingroup.cheme.cmu.edu
>>
>
>

[-- Attachment #2: Type: text/html, Size: 4753 bytes --]

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

end of thread, other threads:[~2018-09-05 15:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05 21:53 Custom keymaps on org blocks John Kitchin
2017-06-06 18:16 ` Nicolas Goaziou
2017-06-07 12:58   ` John Kitchin
2017-06-07 13:21     ` Nicolas Goaziou
2017-06-07 13:50       ` John Kitchin
2017-06-08  0:22         ` Grant Rettke
2017-06-10  9:03         ` Nicolas Goaziou
2017-06-10 13:58           ` John Kitchin
2017-06-10 19:31             ` John Kitchin
2018-09-05 15:52               ` Matt Price
2017-06-07  1:22 ` Grant Rettke
2017-06-07 12:49   ` John Kitchin
2017-06-07 23:52     ` Grant Rettke

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).