From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Re: Fontification of blocks Date: Thu, 03 Feb 2011 08:02:19 -0700 Message-ID: <871v3pp3e3.fsf@gmail.com> References: <80aakevw4w.fsf@missioncriticalit.com> <8739q1ihas.fsf@gmail.com> <80r5dlpfj6.fsf@missioncriticalit.com> <87ei9jkl0l.fsf@gmail.com> <80sjw7qxem.fsf@missioncriticalit.com> <80ei7q9is6.fsf@missioncriticalit.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=48271 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pl0i0-0001RV-DF for emacs-orgmode@gnu.org; Thu, 03 Feb 2011 10:02:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pl0hy-00025J-Mc for emacs-orgmode@gnu.org; Thu, 03 Feb 2011 10:02:56 -0500 Received: from mail-gx0-f169.google.com ([209.85.161.169]:38389) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pl0hy-00025B-Ha for emacs-orgmode@gnu.org; Thu, 03 Feb 2011 10:02:54 -0500 Received: by gxk5 with SMTP id 5so585650gxk.0 for ; Thu, 03 Feb 2011 07:02:54 -0800 (PST) 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: =?utf-8?Q?S=C3=A9bastien?= Vauban Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable S=C3=A9bastien Vauban writes: > Hi Eric(s), Dan & all, > > S=C3=A9bastien Vauban wrote: >> "Eric Schulte" wrote: >>> I think that adding a new block delimiter face which inherits from the >>> org-meta face as you've suggested is the way to go. >>> >>> I would recommend however that rather than removing/changing the >>> org-meta-line, quote and verse delimiting faces to cover the entire line >>> you simply add the org-block-begin/end-line face overtop of these exist= ing >>> faces. That way the default behavior is not changed by the patch, and u= sers >>> have more control over the final display. >>> >>> In fact rather than having the org-block-begin/end-line faces inherit >>> from org-meta-line why not have them begin as empty faces. Do you think >>> this sounds like a good way to go? If so would you mind submitting a >>> patch which >>> - doesn't remove existing faces but rather adds these new faces overtop >>> of them >>> - includes of definition of the org-block-begin/end-line faces to empty >>> faces (otherwise the elisp compiler will warn of references to >>> undefined variables) >>> >>> Also, could you share an example code snippet which initializes the >>> org-block-begin/end-line faces initialized (either here and/or on worg)? >> >> Here a proposition that goes in that direction -- not yet a real patch, = but >> something for you to have a look at. Should be easy to test, at least, >> that's what I tried to achieve. > > Eric (Fraga), David (O'Toole) and Carsten, you should love the following.= .. > when in native fontification... > > #+TITLE: Test file for future patch (for block fontification) > #+DATE: 2011-02-02 > #+LANGUAGE: en_US > > * Abstract > > This is the new code that I will supply as a patch. To test it, just > evaluate the next source block, and please report any problem. > > What it does: > > - Add 2 faces for the lines delimiting the beginning and the end of > the source block > > - Fixes a tiny bug (affecting the begin delimiter line of source > blocks) when in "native" fontification (from Dan Davison) > > - NEW!! >>> Add a light yellow background in native mode!!! <<< NEW!! > Hi Seb, Thanks for sharing this code. I couldn't help myself but to turn it into a patch as that has become my favorite way of reviewing new code. The resulting patch it attached. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=seb-faces-for-org-blocks.patch diff --git a/lisp/org-faces.el b/lisp/org-faces.el index c237a0e..0cf5269 100644 --- a/lisp/org-faces.el +++ b/lisp/org-faces.el @@ -511,6 +511,16 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword." :group 'org-faces :version "22.1") + +(org-copy-face 'org-meta-line 'org-block-begin-line + "Face used for the line delimiting the begin of source blocks.") + +(org-copy-face 'org-meta-line 'org-block-begin-line + "Face used for the line delimiting the end of source blocks.") + +(defface org-block-background nil + "Face used for the source block background.") + (defface org-verbatim (org-compatible-face 'shadow '((((class color grayscale) (min-colors 88) (background light)) diff --git a/lisp/org.el b/lisp/org.el index 52de784..35da334 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5141,21 +5141,24 @@ will be prompted for." (add-text-properties beg end '(font-lock-fontified t font-lock-multiline t)) - (add-text-properties beg beg1 '(face org-meta-line)) - (add-text-properties end1 (+ end 1) '(face org-meta-line)) - ; for end_src (cond ((and lang org-src-fontify-natively) - (org-src-font-lock-fontify-block lang block-start block-end)) + (org-src-font-lock-fontify-block lang block-start block-end) + (overlay-put (make-overlay beg1 block-end) + 'face 'org-block-background)) (quoting - (add-text-properties beg1 (+ end1 1) '(face - org-block))) + (add-text-properties beg1 (+ end1 1) '(face org-block))) ; end of source block ((not org-fontify-quote-and-verse-blocks)) ((string= block-type "quote") - (add-text-properties beg1 end1 '(face org-quote))) + (add-text-properties beg1 (1+ end1) '(face org-quote))) ((string= block-type "verse") - (add-text-properties beg1 end1 '(face org-verse)))) + (add-text-properties beg1 (1+ end1) '(face org-verse)))) + (add-text-properties beg beg1 '(face org-meta-line)) + (add-text-properties beg beg1 '(face org-block-begin-line)) + (add-text-properties (1+ end) (1+ end1) '(face org-meta-line)) + (add-text-properties (1+ end) (1+ end1) + '(face org-block-end-line)) t)) ((member dc1 '("title:" "author:" "email:" "date:")) (add-text-properties @@ -5171,7 +5174,7 @@ will be prompted for." ((not (member (char-after beg) '(?\ ?\t))) ;; just any other in-buffer setting, but not indented (add-text-properties - beg (match-end 0) + beg (1+ (match-end 0)) '(font-lock-fontified t face org-meta-line)) t) ((or (member dc1 '("begin:" "end:" "caption:" "label:" --=-=-= Content-Type: text/plain I noticed a couple of issues in the applied patch (possibly due to a transcription error on my part). Namely - I believe your default faces only work for white backgrounds - I didn't notice a change in background for the code blocks - it seems that the #+end_src line is fontified but the #+begin_src line is not An image of my Emacs after applying the patch is available at: http://i.imgur.com/2eu3z.png Thanks for sharing, I hope this feedback is helpful. Best -- Eric --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --=-=-=--