From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Custom keymaps on org blocks Date: Sat, 10 Jun 2017 15:31:48 -0400 Message-ID: References: <878tl5ugl9.fsf@nicolasgoaziou.fr> <87o9u0ylu6.fsf@nicolasgoaziou.fr> <87efusz02q.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="f403045e9ccc1363210551a02398" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJm6x-0000Vn-LK for emacs-orgmode@gnu.org; Sat, 10 Jun 2017 15:31:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJm6w-0006R1-5l for emacs-orgmode@gnu.org; Sat, 10 Jun 2017 15:31:51 -0400 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:36740) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dJm6v-0006QV-TG for emacs-orgmode@gnu.org; Sat, 10 Jun 2017 15:31:50 -0400 Received: by mail-wr0-x233.google.com with SMTP id v111so61031130wrc.3 for ; Sat, 10 Jun 2017 12:31:49 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: "emacs-orgmode@gnu.org" --f403045e9ccc1363210551a02398 Content-Type: text/plain; charset="UTF-8" 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 wrote: > > Nicolas Goaziou writes: > > > Hello, > > > > John Kitchin 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 > --f403045e9ccc1363210551a02398 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
In case anyone would like to try this themselves, I docume= nted what I tried here:=C2=A0http:/= /kitchingroup.cheme.cmu.edu/blog/2017/06/10/Adding-keymaps-to-src-blocks-vi= a-org-font-lock-hook/

John

---------------------------= --------
Professor John Kitchin=C2=A0
Doherty Hall A207F
Departmen= t of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 1= 5213
412-268-7803

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

Nicolas Goaziou writes:

> Hello,
>
> John Kitchin <jkitchin@a= ndrew.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 ca= n't
>> really try it out without modifying the core org code that does th= e
>> 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 ava= ilable
>> 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 th= ings on
>> headings (even different things on headings with specific properti= es) and
>> blocks (
>> http= ://kitchingroup.cheme.cmu.edu/blog/2016/12/22/Context-specific-or= g-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 use= rs 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<= br> 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

--f403045e9ccc1363210551a02398--