emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: [PATCH] Mode-specific fontification of babel source blocks


From: David O'Toole
Subject: [Orgmode] Re: [PATCH] Mode-specific fontification of babel source blocks
Date: Wed, 4 Aug 2010 01:55:49 -0400

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 <address@hidden> wrote:
> "David O'Toole" <address@hidden> 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."
>   "Fontify #+ lines and blocks, in the correct ways."
>   (let ((case-fold-search t))
>     (if (re-search-forward
> -        "^\\([ \t]*#\\+\\(\\([a-zA-Z]+:?\\| 
> \\|$\\)\\(_\\([a-zA-Z]+\\)\\)?\\)\\(.*\\)\\) ?\\(\\(\\w\\|-\\)*\\)"
> +        ;;  1            2  3                     3  4   5           5  4   
> 2        6           6        7    7  1
> +        "^\\([ \t]*#\\+\\(\\([a-zA-Z]+:?\\| 
> \\|$\\)\\(_\\([a-zA-Z]+\\)\\)?\\)[ \t]*\\([^ \t\n]*\\)[ \t]*\\(.*\\)\\)"
>         limit t)
>        (let* ((beg (match-beginning 0))
>               (block-start (match-end 0))
>               (block-end nil)
> -              (language (downcase (if (stringp (match-string 6))
> -                                      (match-string 6)
> -                                      "AAAAAAAAAA")))
> +              (language (match-string 6))
>               (beg1 (line-beginning-position 2))
>               (dc1 (downcase (match-string 2)))
>               (dc3 (downcase (match-string 3)))
> @@ -5053,9 +5052,10 @@ will be prompted for."
>              (add-text-properties beg beg1 '(face org-meta-line))
>              (add-text-properties end1 end '(face org-meta-line))
>              (cond
> -               (org-src-fontify-natively
> -                (when (and (stringp language) (> (length language) 1))
> -                  (let* ((mode-command (intern (concat (substring language 
> 1) "-mode")))
> +               ((and org-src-fontify-natively language)
> +                (let* ((lang-mode
> +                        (or (cdr (assoc language org-src-lang-modes)) 
> (intern language)))
> +                         (mode-command (intern (concat (symbol-name 
> lang-mode) "-mode")))
>                          (string (buffer-substring-no-properties block-start 
> block-end))
>                          (modified (buffer-modified-p))
>                          (fontified-output
> @@ -5073,7 +5073,7 @@ will be prompted for."
>                       (goto-char block-start)
>                       (delete-region block-start block-end)
>                       (insert fontified-output)
> -                      (set-buffer-modified-p modified)))))
> +                      (set-buffer-modified-p modified))))
>                (quoting
>                (add-text-properties beg1 end1 '(face org-block)))
>               ((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.
>> address@hidden
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]