From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Fantin Subject: Re: Re: Native TAB in code blocks Date: Fri, 3 Sep 2010 10:11:41 +0200 Message-ID: References: <8739uvw0hg.fsf@stats.ox.ac.uk> <87vd7j1nck.fsf@stats.ox.ac.uk> <87lj7kqh3f.fsf_-_@stats.ox.ac.uk> <4C7FD932.3070705@ccbr.umn.edu> <87vd6om0ch.fsf_-_@stats.ox.ac.uk> <87vd6n2888.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=44477 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrRNZ-0000bp-JH for emacs-orgmode@gnu.org; Fri, 03 Sep 2010 04:12:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OrRNY-0002SV-0P for emacs-orgmode@gnu.org; Fri, 03 Sep 2010 04:12:09 -0400 Received: from mail-qw0-f41.google.com ([209.85.216.41]:58138) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrRNX-0002SM-S1 for emacs-orgmode@gnu.org; Fri, 03 Sep 2010 04:12:07 -0400 Received: by qwf7 with SMTP id 7so1981893qwf.0 for ; Fri, 03 Sep 2010 01:12:07 -0700 (PDT) In-Reply-To: <87vd6n2888.fsf@stats.ox.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: emacs-orgmode Mailinglist , Carsten Dominik Another great addition Dan, thanks ! Cheers On Thu, Sep 2, 2010 at 10:36 PM, Dan Davison wrote= : > Carsten Dominik writes: > >> On Thu, Sep 2, 2010 at 9:06 PM, Dan Davison wro= te: >>> Erik Iverson writes: >>> >>>> Dan, >>>> >>>> Thank you to David and yourself for this great feature. =C2=A0I have >>>> absolutely no opinion about the default on/off, except to say it >>>> looks great on. >>>> >>>> Is your TAB key patch[1] in master yet? >>>> http://www.mail-archive.com/emacs-orgmode@gnu.org/msg28640.html >>> >>> Hi Erik, >>> >>> Since these[1] changes, language-native TAB can be achieved in code >>> blocks via C-c C-v C-x TAB and C-c C-v x TAB. We can add this to >>> org-tab-first-hook, controlled by a variable `org-src-tab-acts-natively= ' >>> as below. Carsten -- would you like to add this to Org, or leave it as = a >>> user customisation? >> >> I think we can add this to Org. =C2=A0Maybe default off, for now? > > OK, done. So > > (setq org-src-tab-acts-natively t) > > to turn it on. > > Dan > >> >> - Carten >> >>> >>> Dan >>> >>> >>> --8<---------------cut here---------------start------------->8--- >>> diff --git a/lisp/org-src.el b/lisp/org-src.el >>> index 6c09cbd..d1948cc 100644 >>> --- a/lisp/org-src.el >>> +++ b/lisp/org-src.el >>> @@ -715,6 +715,19 @@ Org-babel commands." >>> =C2=A0 =C2=A0 =C2=A0(call-interactively >>> =C2=A0 =C2=A0 =C2=A0 (lookup-key org-babel-map key))))) >>> >>> +(defvar org-src-tab-acts-natively nil >>> + =C2=A0"If non-nil, the effect of TAB in a code block is as if it were >>> +issued in the language major mode buffer.") >>> + >>> +(defun org-src-native-tab-command-maybe () >>> + =C2=A0"Perform language-specific TAB action. >>> +Alter code block according to effect of TAB in the language major >>> +mode." >>> + =C2=A0(and org-src-tab-acts-natively >>> + =C2=A0 =C2=A0 =C2=A0 (org-babel-do-key-sequence-in-edit-buffer (kbd "= TAB")))) >>> + >>> +(add-hook 'org-tab-first-hook 'org-src-native-tab-command-maybe) >>> + >>> =C2=A0(defun org-src-font-lock-fontify-block (lang start end) >>> =C2=A0 "Fontify code block. >>> =C2=A0This function is called by emacs automatic fontification, as long >>> --8<---------------cut here---------------end--------------->8--- >>> >>> >>> Footnotes: >>> >>> [1] http://thread.gmane.org/gmane.emacs.orgmode/28950 >>> >>>> >>>> >>>> >>>> Dan Davison wrote: >>>>> I've just pushed changes which mean that Org now fontifies code in co= de >>>>> blocks. Currently, this is turned on by default, so it would be helpf= ul >>>>> if people could report any problems, and opinions as to whether it >>>>> should be on or off by default. >>>>> >>>>> To turn it off, use >>>>> >>>>> (setq org-src-fontify-natively nil) >>>>> >>>>> With it off, there are two functions for manually fontifying code >>>>> blocks: `org-src-fontify-block' and `org-src-fontify-buffer'. >>>>> >>>>> With it on, on my netbook, there is a slight delay when typing in cod= e >>>>> blocks of over 100 lines in length, and this is pronounced in code >>>>> blocks of several hundred lines. >>>>> >>>>> Just to be clear, this is fontification only -- no other language maj= or >>>>> mode features -- so the default method of editing code is still C-c ' >>>>> (org-edit-src-code). >>>>> >>>>> Thanks to David O'Toole for the original patch. The final version of = the >>>>> patch is based on Carsten's suggestions for a more efficient >>>>> implementation. >>>>> >>>>> Dan >>>>> >>>>> >>>>> Dan Davison writes: >>>>> >>>>>> Dan Davison writes: >>>>>> >>>>>>> "David O'Toole" writes: >>>>>>> >>>>>>>> I've got a preliminary patch that adds optional "native" fontifica= tion >>>>>>>> for source blocks. It uses the block's declared mode to fontify th= e >>>>>>>> block text. So now blocks look the way they should, and this opens= the >>>>>>>> way to further enhancements. >>>>>>> Hi David, >>>>>>> >>>>>>> This is great! Here's a patch which allows the src blocks to have >>>>>>> switches and header args, and also uses `org-src-lang-modes' to fin= d the >>>>>>> major mode. >>>>>> I'm resending this as a match against the current master branch, and= as >>>>>> an attachment so that it goes into the patchwork system. I am keepin= g >>>>>> this line of patches in branch `src-block-fontification' at >>>>>> git://github.com/dandavison/org-devel.git >>>>>> >>>>>> Dan >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Emacs-orgmode mailing list >>>>>> Please use `Reply All' to send replies to the list. >>>>>> Emacs-orgmode@gnu.org >>>>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >>>>> >>>>> >>>>> _______________________________________________ >>>>> Emacs-orgmode mailing list >>>>> Please use `Reply All' to send replies to the list. >>>>> Emacs-orgmode@gnu.org >>>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >>>> >>>> _______________________________________________ >>>> Emacs-orgmode mailing list >>>> Please use `Reply All' to send replies to the list. >>>> Emacs-orgmode@gnu.org >>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >>> >>> >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode >