From mboxrd@z Thu Jan 1 00:00:00 1970 From: "David O'Toole" Subject: Re: [PATCH] Mode-specific fontification of babel source blocks Date: Wed, 4 Aug 2010 01:55:49 -0400 Message-ID: References: <8739uvw0hg.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=44672 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OgWxG-0004mP-Tk for emacs-orgmode@gnu.org; Wed, 04 Aug 2010 01:55:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OgWxF-0000wq-BO for emacs-orgmode@gnu.org; Wed, 04 Aug 2010 01:55:54 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:53699) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OgWxF-0000wT-3Y for emacs-orgmode@gnu.org; Wed, 04 Aug 2010 01:55:53 -0400 Received: by wyg36 with SMTP id 36so5713391wyg.0 for ; Tue, 03 Aug 2010 22:55:49 -0700 (PDT) In-Reply-To: <8739uvw0hg.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 Hi, I don't have much more to do on the patch. I suspect it could be slow with larger files, perhaps it could be programmed to only refontify changed blocks (i.e. use the caching mechanism for block results to prevent redundant fontifying. Perhaps someone who knows about babel internals can help? On Tue, Aug 3, 2010 at 10:55 PM, Dan Davison wrote= : > "David O'Toole" writes: > >> I've got a preliminary patch that adds optional "native" fontification >> for source blocks. It uses the block's declared mode to fontify the >> 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 find the > major mode. Do you want to host this somewhere while it evolves? I've > put my commits in branch src-block-display of > git://repo.or.cz/org-mode/babel.git for the moment. > > --8<---------------cut here---------------start------------->8--- > diff --git a/lisp/org.el b/lisp/org.el > index 843e4fe..ad8b7f9 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -5012,14 +5012,13 @@ will be prompted for." > =A0 "Fontify #+ lines and blocks, in the correct ways." > =A0 (let ((case-fold-search t)) > =A0 =A0 (if (re-search-forward > - =A0 =A0 =A0 =A0"^\\([ \t]*#\\+\\(\\([a-zA-Z]+:?\\| \\|$\\)\\(_\\([a-zA-= Z]+\\)\\)?\\)\\(.*\\)\\) ?\\(\\(\\w\\|-\\)*\\)" > + =A0 =A0 =A0 =A0;; =A01 =A0 =A0 =A0 =A0 =A0 =A02 =A03 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 3 =A04 =A0 5 =A0 =A0 =A0 =A0 =A0 5 =A04 =A0 2 =A0 = =A0 =A0 =A06 =A0 =A0 =A0 =A0 =A0 6 =A0 =A0 =A0 =A07 =A0 =A07 =A01 > + =A0 =A0 =A0 =A0"^\\([ \t]*#\\+\\(\\([a-zA-Z]+:?\\| \\|$\\)\\(_\\([a-zA-= Z]+\\)\\)?\\)[ \t]*\\([^ \t\n]*\\)[ \t]*\\(.*\\)\\)" > =A0 =A0 =A0 =A0 limit t) > =A0 =A0 =A0 =A0(let* ((beg (match-beginning 0)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 (block-start (match-end 0)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 (block-end nil) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0(language (downcase (if (stringp (match-stri= ng 6)) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0(match-string 6) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0"AAAAAAAAAA"))) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0(language (match-string 6)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 (beg1 (line-beginning-position 2)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 (dc1 (downcase (match-string 2))) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 (dc3 (downcase (match-string 3))) > @@ -5053,9 +5052,10 @@ will be prompted for." > =A0 =A0 =A0 =A0 =A0 =A0 =A0(add-text-properties beg beg1 '(face org-meta-= line)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0(add-text-properties end1 end '(face org-meta-= line)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0(cond > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (org-src-fontify-natively > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(when (and (stringp language) (> (length= language) 1)) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(let* ((mode-command (intern (concat= (substring language 1) "-mode"))) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ((and org-src-fontify-natively language) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(let* ((lang-mode > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(or (cdr (assoc language= org-src-lang-modes)) (intern language))) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (mode-command (intern (= concat (symbol-name lang-mode) "-mode"))) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(string (buffer-substr= ing-no-properties block-start block-end)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(modified (buffer-modi= fied-p)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(fontified-output > @@ -5073,7 +5073,7 @@ will be prompted for." > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (goto-char block-start) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (delete-region block-start bl= ock-end) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (insert fontified-output) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(set-buffer-modified-p modif= ied))))) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(set-buffer-modified-p modif= ied)))) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(quoting > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(add-text-properties beg1 end1 '(face org-= block))) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 ((not org-fontify-quote-and-verse-blocks)) > --8<---------------cut here---------------end--------------->8--- > > >> Anyone up for an icons theme standard >> discussion? > > Yes. > > 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 >