* Fontification of blocks @ 2010-12-10 9:02 Sébastien Vauban 2010-12-10 11:12 ` David O'Toole 2010-12-13 19:50 ` Eric Schulte 0 siblings, 2 replies; 27+ messages in thread From: Sébastien Vauban @ 2010-12-10 9:02 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ [-- Attachment #1: Type: text/plain, Size: 756 bytes --] Hi, In order to make the blocks stand out more clearly in the mix of prose, code and table results of many Babel Org files, I've added 2 new faces: - org-block-begin-line - org-block-end-line These apply to the line just before and after the block's body: #+srcname: top-10-dossiers-with-many-prestations #+begin_src sql <<< org-block-begin-line SELECT TOP 10 prsPfiID_fk, COUNT(*) AS '# Prestations' FROM prestations GROUP BY prsPfiID_fk ORDER BY COUNT(*) DESC #+end_src <<< org-block-end-line Not only for =src=, but also for =verse=, =quote=, etc. This patch takes care of the correct fontification, both in native style, and in the "no native fontification" style: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: org-block-lines.patch --] [-- Type: text/x-patch, Size: 1486 bytes --] diff --git a/lisp/org.el b/lisp/org.el index e03e9ca..f57c09b 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5137,8 +5137,8 @@ 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)) + (add-text-properties beg beg1 '(face org-block-begin-line)) + (add-text-properties end1 (+ end 1) '(face org-block-end-line)) ; for end_src (cond ((and lang org-src-fontify-natively) @@ -5149,9 +5149,9 @@ will be prompted for." ; 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)))) t)) ((member dc1 '("title:" "author:" "email:" "date:")) (add-text-properties @@ -5167,7 +5167,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:" [-- Attachment #3: Type: text/plain, Size: 52 bytes --] Best regards, Seb -- Sébastien Vauban [-- Attachment #4: Type: text/plain, Size: 222 bytes --] _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2010-12-10 9:02 Fontification of blocks Sébastien Vauban @ 2010-12-10 11:12 ` David O'Toole 2010-12-13 21:25 ` Sébastien Vauban 2010-12-13 19:50 ` Eric Schulte 1 sibling, 1 reply; 27+ messages in thread From: David O'Toole @ 2010-12-10 11:12 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs-orgmode Hi Sebastien, I give a definite Vote++ to this feature! 2010/12/10 Sébastien Vauban <wxhgmqzgwmuf@spammotel.com>: > Hi, > > In order to make the blocks stand out more clearly in the mix of prose, code > and table results of many Babel Org files, I've added 2 new faces: > > - org-block-begin-line > - org-block-end-line > > These apply to the line just before and after the block's body: > > #+srcname: top-10-dossiers-with-many-prestations > #+begin_src sql <<< org-block-begin-line > SELECT TOP 10 prsPfiID_fk, COUNT(*) AS '# Prestations' > FROM prestations > GROUP BY prsPfiID_fk > ORDER BY COUNT(*) DESC > #+end_src <<< org-block-end-line > > Not only for =src=, but also for =verse=, =quote=, etc. > > This patch takes care of the correct fontification, both in native style, and > in the "no native fontification" style: > > > > Best regards, > Seb > > -- > Sébastien Vauban > > > _______________________________________________ > 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 > > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2010-12-10 11:12 ` David O'Toole @ 2010-12-13 21:25 ` Sébastien Vauban 2010-12-22 13:36 ` Dan Davison 0 siblings, 1 reply; 27+ messages in thread From: Sébastien Vauban @ 2010-12-13 21:25 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi David, "David O'Toole" wrote: > 2010/12/10 Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>: >> In order to make the blocks stand out more clearly in the mix of prose, code >> and table results of many Babel Org files, I've added 2 new faces: >> >> - org-block-begin-line >> - org-block-end-line >> >> These apply to the line just before and after the block's body: > > I give a definite Vote++ to this feature! Thanks for the incentive. And happy to know it will please others as well... Best regards, Seb -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2010-12-13 21:25 ` Sébastien Vauban @ 2010-12-22 13:36 ` Dan Davison 2010-12-22 14:46 ` Sébastien Vauban 0 siblings, 1 reply; 27+ messages in thread From: Dan Davison @ 2010-12-22 13:36 UTC (permalink / raw) To: emacs-orgmode Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes: > Hi David, > > "David O'Toole" wrote: >> 2010/12/10 Sébastien Vauban <wxhgmqzgwmuf@spammotel.com>: >>> In order to make the blocks stand out more clearly in the mix of prose, code >>> and table results of many Babel Org files, I've added 2 new faces: >>> >>> - org-block-begin-line >>> - org-block-end-line >>> >>> These apply to the line just before and after the block's body: >> >> I give a definite Vote++ to this feature! > > Thanks for the incentive. And happy to know it will please others as well... Hi Seb, Am I right in thinking that your work in this thread superseded the discussion in http://thread.gmane.org/gmane.emacs.orgmode/32880/focus=33924 and that therefore we should terminate patch http://patchwork.newartisans.com/patch/399/ and wait for you to finish up here? I'll look forward to the finished product. Thanks, Dan > > Best regards, > Seb ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2010-12-22 13:36 ` Dan Davison @ 2010-12-22 14:46 ` Sébastien Vauban 0 siblings, 0 replies; 27+ messages in thread From: Sébastien Vauban @ 2010-12-22 14:46 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Dan, Dan Davison wrote: > Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes: >> "David O'Toole" wrote: >>> 2010/12/10 Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>: >>>> In order to make the blocks stand out more clearly in the mix of prose, >>>> code and table results of many Babel Org files, I've added 2 new faces: >>>> >>>> - org-block-begin-line >>>> - org-block-end-line >>>> >>>> These apply to the line just before and after the block's body: >>> >>> I give a definite Vote++ to this feature! >> >> Thanks for the incentive. And happy to know it will please others as >> well... > > Am I right in thinking that your work in this thread superseded the > discussion in > > http://thread.gmane.org/gmane.emacs.orgmode/32880/focus=33924 > > and that therefore we should terminate patch > > http://patchwork.newartisans.com/patch/399/ > > and wait for you to finish up here? I guess so, yes, that we can close this point, and wait for me to work on it as a whole. Eventually, I'll include (parts of) your patch in mine. > I'll look forward to the finished product. Me too... I'd like to do it ASAP, not sure though I'll be able to do it. And, if not done this week, it won't be before 2 weeks (I'm completely away next week). But I certainly keep you posted as soon as I've managed making these enhancements. Best regards, Seb -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2010-12-10 9:02 Fontification of blocks Sébastien Vauban 2010-12-10 11:12 ` David O'Toole @ 2010-12-13 19:50 ` Eric Schulte 2010-12-13 20:46 ` Sébastien Vauban 1 sibling, 1 reply; 27+ messages in thread From: Eric Schulte @ 2010-12-13 19:50 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs-orgmode Hi Seb, This looks like a very nice addition. Could you refactor your patch so that this behavior is controlled by a user configurable defcustom variable? Thanks -- Eric Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes: > Hi, > > In order to make the blocks stand out more clearly in the mix of prose, code > and table results of many Babel Org files, I've added 2 new faces: > > - org-block-begin-line > - org-block-end-line > > These apply to the line just before and after the block's body: > > #+srcname: top-10-dossiers-with-many-prestations > #+begin_src sql <<< org-block-begin-line > SELECT TOP 10 prsPfiID_fk, COUNT(*) AS '# Prestations' > FROM prestations > GROUP BY prsPfiID_fk > ORDER BY COUNT(*) DESC > #+end_src <<< org-block-end-line > > Not only for =src=, but also for =verse=, =quote=, etc. > > This patch takes care of the correct fontification, both in native style, and > in the "no native fontification" style: > > diff --git a/lisp/org.el b/lisp/org.el > index e03e9ca..f57c09b 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -5137,8 +5137,8 @@ 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)) > + (add-text-properties beg beg1 '(face org-block-begin-line)) > + (add-text-properties end1 (+ end 1) '(face org-block-end-line)) > ; for end_src > (cond > ((and lang org-src-fontify-natively) > @@ -5149,9 +5149,9 @@ will be prompted for." > ; 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)))) > t)) > ((member dc1 '("title:" "author:" "email:" "date:")) > (add-text-properties > @@ -5167,7 +5167,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:" > > Best regards, > Seb ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2010-12-13 19:50 ` Eric Schulte @ 2010-12-13 20:46 ` Sébastien Vauban 2010-12-15 17:22 ` Eric Schulte 0 siblings, 1 reply; 27+ messages in thread From: Sébastien Vauban @ 2010-12-13 20:46 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Eric, "Eric Schulte" wrote: > Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes: >> In order to make the blocks stand out more clearly in the mix of prose, >> code and table results of many Babel Org files, I've added 2 new faces: >> >> - org-block-begin-line >> - org-block-end-line >> >> These apply to the line just before and after the block's body: >> >> #+srcname: top-10-dossiers-with-many-prestations >> #+begin_src sql <<< org-block-begin-line >> SELECT TOP 10 prsPfiID_fk, COUNT(*) AS '# Prestations' >> FROM prestations >> GROUP BY prsPfiID_fk >> ORDER BY COUNT(*) DESC >> #+end_src <<< org-block-end-line >> >> Not only for =src=, but also for =verse=, =quote=, etc. > > This looks like a very nice addition. Could you refactor your patch so > that this behavior is controlled by a user configurable defcustom > variable? For sure, I'm willing whatever is needed to make it more acceptable. But I'm not sure about the purpose of that variable... You want something such as =org-have-extra-faces=, and in case of: - =t=, use them - =nil=, use the old face =org-meta-line=. Is is that? I find that to be uselessly complexifying the fontification code. What was in my mind was have 2 new deffaces (not provided in the patch), with the same default value (or even an inherit property, that's much better) as =org-meta-line=. Wouldn't that be better? In the case of the inheritage, if not customized in the color theme, the user would not see any change (I guess)... FYI, my intention is to add different faces as well for header arguments and their values... Best regards, Seb -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Re: Fontification of blocks 2010-12-13 20:46 ` Sébastien Vauban @ 2010-12-15 17:22 ` Eric Schulte 2011-02-01 21:04 ` Sébastien Vauban 0 siblings, 1 reply; 27+ messages in thread From: Eric Schulte @ 2010-12-15 17:22 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs-orgmode Hi Seb, I was thinking that it would be nice to be able to try this out through setting a variable (as most org customizations are handled) which would activate/de-activate the extra fontification. 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 existing faces. That way the default behavior is not changed by the patch, and users 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)? Many Thanks -- Eric Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes: > Hi Eric, > > "Eric Schulte" wrote: >> Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes: >>> In order to make the blocks stand out more clearly in the mix of prose, >>> code and table results of many Babel Org files, I've added 2 new faces: >>> >>> - org-block-begin-line >>> - org-block-end-line >>> >>> These apply to the line just before and after the block's body: >>> >>> #+srcname: top-10-dossiers-with-many-prestations >>> #+begin_src sql <<< org-block-begin-line >>> SELECT TOP 10 prsPfiID_fk, COUNT(*) AS '# Prestations' >>> FROM prestations >>> GROUP BY prsPfiID_fk >>> ORDER BY COUNT(*) DESC >>> #+end_src <<< org-block-end-line >>> >>> Not only for =src=, but also for =verse=, =quote=, etc. >> >> This looks like a very nice addition. Could you refactor your patch so >> that this behavior is controlled by a user configurable defcustom >> variable? > > For sure, I'm willing whatever is needed to make it more acceptable. But I'm > not sure about the purpose of that variable... > > You want something such as =org-have-extra-faces=, and in case of: > > - =t=, use them > - =nil=, use the old face =org-meta-line=. > > Is is that? I find that to be uselessly complexifying the fontification code. > What was in my mind was have 2 new deffaces (not provided in the patch), with > the same default value (or even an inherit property, that's much better) as > =org-meta-line=. > > Wouldn't that be better? In the case of the inheritage, if not customized in > the color theme, the user would not see any change (I guess)... > > FYI, my intention is to add different faces as well for header arguments and > their values... > > Best regards, > Seb ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2010-12-15 17:22 ` Eric Schulte @ 2011-02-01 21:04 ` Sébastien Vauban 2011-02-02 7:25 ` Eric S Fraga ` (2 more replies) 0 siblings, 3 replies; 27+ messages in thread From: Sébastien Vauban @ 2011-02-01 21:04 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Eric, Dan & all, "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 existing > faces. That way the default behavior is not changed by the patch, and users > 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. #+TITLE: Patch for block fontification #+DATE: 2011-02-01 #+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) FOR PEOPLE BEING MORE EXPERTS THAN I AM, it shows what I tried for adding a yellow (very visible, for test purpose) background to the natively fontified source blocks. This does not work, but is commented -- so it does not impact anything unless you uncomment it... See line "NOK". * Code #+begin_src emacs-lisp :results silent (defface org-block-begin-line '((t (:inherit org-meta-line :underline "light grey" :foreground "#008ED1" :background "#EAEAFF"))) "Face used for the line delimiting the begin of source blocks.") (defface org-block-end-line '((t (:inherit org-meta-line :overline "light grey" :foreground "#008ED1" :background "#EAEAFF"))) "Face used for the line delimiting the end of source blocks.") (defface org-block-background '((t (:background "#FFFF00"))) "Face used for the source block background.") (defun org-fontify-meta-lines-and-blocks (limit) "Fontify #+ lines and blocks, in the correct ways." (let ((case-fold-search t)) (if (re-search-forward "^\\([ \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) (lang (match-string 7)) (beg1 (line-beginning-position 2)) (dc1 (downcase (match-string 2))) (dc3 (downcase (match-string 3))) end end1 quoting block-type) (cond ((member dc1 '("html:" "ascii:" "latex:" "docbook:")) ;; a single line of backend-specific content (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) (remove-text-properties (match-beginning 0) (match-end 0) '(display t invisible t intangible t)) (add-text-properties (match-beginning 1) (match-end 3) '(font-lock-fontified t face org-meta-line)) (add-text-properties (match-beginning 6) (+ (match-end 6) 1) '(font-lock-fontified t face org-block)) ; for backend-specific code t) ((and (match-end 4) (equal dc3 "begin")) ;; Truly a block (setq block-type (downcase (match-string 5)) quoting (member block-type org-protecting-blocks)) (when (re-search-forward (concat "^[ \t]*#\\+end" (match-string 4) "\\>.*") nil t) ;; on purpose, we look further than LIMIT (setq end (match-end 0) end1 (1- (match-beginning 0))) (setq block-end (match-beginning 0)) (when quoting (remove-text-properties beg end '(display t invisible t intangible t))) (add-text-properties beg end '(font-lock-fontified t font-lock-multiline t)) (cond ((and lang org-src-fontify-natively) (org-src-font-lock-fontify-block lang block-start block-end) ;; (add-text-properties beg1 (+ end1 1) '(face org-block-background)) ; NOK from svauban: it currently overrides foreground as well! ) (quoting (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 (1+ end1) '(face org-quote))) ((string= block-type "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)) ; OK from svauban (add-text-properties (1+ end) (1+ end1) '(face org-meta-line)) (add-text-properties (1+ end) (1+ end1) '(face org-block-end-line)) ; OK from svauban t)) ((member dc1 '("title:" "author:" "email:" "date:")) (add-text-properties beg (match-end 3) (if (member (intern (substring dc1 0 -1)) org-hidden-keywords) '(font-lock-fontified t invisible t) '(font-lock-fontified t face org-document-info-keyword))) (add-text-properties (match-beginning 6) (match-end 6) (if (string-equal dc1 "title:") '(font-lock-fontified t face org-document-title) '(font-lock-fontified t face org-document-info)))) ((not (member (char-after beg) '(?\ ?\t))) ;; just any other in-buffer setting, but not indented (add-text-properties beg (1+ (match-end 0)) '(font-lock-fontified t face org-meta-line)) t) ((or (member dc1 '("begin:" "end:" "caption:" "label:" "orgtbl:" "tblfm:" "tblname:" "result:" "results:" "source:" "srcname:" "call:")) (and (match-end 4) (equal dc3 "attr"))) (add-text-properties beg (match-end 0) '(font-lock-fontified t face org-meta-line)) t) ((member dc3 '(" " "")) (add-text-properties beg (match-end 0) '(font-lock-fontified t face font-lock-comment-face))) (t nil)))))) #+end_src * Examples The above Lisp code is already an example of the way faces are applied. Here is another. ** Don't fontify natively Execute the following, answering =yes= to the revert buffer question, if you want to see how it looks like in "standard" fontification. #+begin_src emacs-lisp :results silent ;; don't fontify code in code blocks (setq org-src-fontify-natively nil) (revert-buffer) (org-shifttab) #+end_src ** Fontify natively Execute the following, answering =yes= to the revert buffer question, for the same in "native" fontification. #+begin_src emacs-lisp :results silent ;; do fontify code in code blocks (setq org-src-fontify-natively t) (revert-buffer) (org-shifttab) #+end_src ** Verse #+begin_verse Testing the fonctionality. #+end_verse ** Quote #+begin_quote Testing the fonctionality. #+end_quote Best regards, Seb -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Re: Fontification of blocks 2011-02-01 21:04 ` Sébastien Vauban @ 2011-02-02 7:25 ` Eric S Fraga 2011-02-02 14:34 ` Dan Davison 2011-02-02 22:24 ` Sébastien Vauban 2 siblings, 0 replies; 27+ messages in thread From: Eric S Fraga @ 2011-02-02 7:25 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs-orgmode Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes: > Hi Eric, Dan & all, > > "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. [...] > 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. This works very well (for me). I like the result, with or without block fontification. -- : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1 : using Org-mode version 7.4 (release_7.4.294.g8158) ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-01 21:04 ` Sébastien Vauban 2011-02-02 7:25 ` Eric S Fraga @ 2011-02-02 14:34 ` Dan Davison 2011-02-02 20:19 ` Sébastien Vauban 2011-02-02 22:24 ` Sébastien Vauban 2 siblings, 1 reply; 27+ messages in thread From: Dan Davison @ 2011-02-02 14:34 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs org-mode mailing list Hi Seb, Just quickly, one thing I noticed is that the begin/end lines were visible even inside folded trees. I.e., in a folded org file, containing many src blocks, I could see the coloured backgrounds "poking out" of the folded sections, extending to the right of the screen. Do you see that? Also, > "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 existing >> faces. That way the default behavior is not changed by the patch, and users >> 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) Could you clarify whether the above suggestions have been adopted or rejected? At the moment the code below alters the background color of the begin/end lines by default; but presumably the final version will not alter any appearances by default? How will that work? Would you be able to supply a patch, or better, put your work in a publicly accessible git branch? It's hard to see exactly what changes you have made with the full code as below. (Please contact me for write access if you'd like to use the fork at https://github.com/dandavison/org-devel.) Dan >> >> 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. > > #+TITLE: Patch for block fontification > #+DATE: 2011-02-01 > #+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) > > FOR PEOPLE BEING MORE EXPERTS THAN I AM, it shows what I tried for > adding a yellow (very visible, for test purpose) background to the > natively fontified source blocks. This does not work, but is commented > -- so it does not impact anything unless you uncomment it... See line > "NOK". > > * Code > > #+begin_src emacs-lisp :results silent > (defface org-block-begin-line > '((t (:inherit org-meta-line > :underline "light grey" :foreground "#008ED1" :background "#EAEAFF"))) > "Face used for the line delimiting the begin of source blocks.") > > (defface org-block-end-line > '((t (:inherit org-meta-line > :overline "light grey" :foreground "#008ED1" :background "#EAEAFF"))) > "Face used for the line delimiting the end of source blocks.") > > (defface org-block-background > '((t (:background "#FFFF00"))) > "Face used for the source block background.") > > (defun org-fontify-meta-lines-and-blocks (limit) > "Fontify #+ lines and blocks, in the correct ways." > (let ((case-fold-search t)) > (if (re-search-forward > "^\\([ \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) > (lang (match-string 7)) > (beg1 (line-beginning-position 2)) > (dc1 (downcase (match-string 2))) > (dc3 (downcase (match-string 3))) > end end1 quoting block-type) > (cond > ((member dc1 '("html:" "ascii:" "latex:" "docbook:")) > ;; a single line of backend-specific content > (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) > (remove-text-properties (match-beginning 0) (match-end 0) > '(display t invisible t intangible t)) > (add-text-properties (match-beginning 1) (match-end 3) > '(font-lock-fontified t face org-meta-line)) > (add-text-properties (match-beginning 6) (+ (match-end 6) 1) > '(font-lock-fontified t face org-block)) > ; for backend-specific code > t) > ((and (match-end 4) (equal dc3 "begin")) > ;; Truly a block > (setq block-type (downcase (match-string 5)) > quoting (member block-type org-protecting-blocks)) > (when (re-search-forward > (concat "^[ \t]*#\\+end" (match-string 4) "\\>.*") > nil t) ;; on purpose, we look further than LIMIT > (setq end (match-end 0) end1 (1- (match-beginning 0))) > (setq block-end (match-beginning 0)) > (when quoting > (remove-text-properties beg end > '(display t invisible t intangible t))) > (add-text-properties > beg end > '(font-lock-fontified t font-lock-multiline t)) > (cond > ((and lang org-src-fontify-natively) > (org-src-font-lock-fontify-block lang block-start block-end) > ;; (add-text-properties beg1 (+ end1 1) '(face org-block-background)) ; NOK from svauban: it currently overrides foreground as well! > ) > (quoting > (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 (1+ end1) '(face org-quote))) > ((string= block-type "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)) ; OK from svauban > (add-text-properties (1+ end) (1+ end1) '(face org-meta-line)) > (add-text-properties (1+ end) (1+ end1) '(face org-block-end-line)) ; OK from svauban > t)) > ((member dc1 '("title:" "author:" "email:" "date:")) > (add-text-properties > beg (match-end 3) > (if (member (intern (substring dc1 0 -1)) org-hidden-keywords) > '(font-lock-fontified t invisible t) > '(font-lock-fontified t face org-document-info-keyword))) > (add-text-properties > (match-beginning 6) (match-end 6) > (if (string-equal dc1 "title:") > '(font-lock-fontified t face org-document-title) > '(font-lock-fontified t face org-document-info)))) > ((not (member (char-after beg) '(?\ ?\t))) > ;; just any other in-buffer setting, but not indented > (add-text-properties > beg (1+ (match-end 0)) > '(font-lock-fontified t face org-meta-line)) > t) > ((or (member dc1 '("begin:" "end:" "caption:" "label:" > "orgtbl:" "tblfm:" "tblname:" "result:" > "results:" "source:" "srcname:" "call:")) > (and (match-end 4) (equal dc3 "attr"))) > (add-text-properties > beg (match-end 0) > '(font-lock-fontified t face org-meta-line)) > t) > ((member dc3 '(" " "")) > (add-text-properties > beg (match-end 0) > '(font-lock-fontified t face font-lock-comment-face))) > (t nil)))))) > #+end_src > > * Examples > > The above Lisp code is already an example of the way faces are > applied. Here is another. > > ** Don't fontify natively > > Execute the following, answering =yes= to the revert buffer question, > if you want to see how it looks like in "standard" fontification. > > #+begin_src emacs-lisp :results silent > ;; don't fontify code in code blocks > (setq org-src-fontify-natively nil) > > (revert-buffer) > (org-shifttab) > #+end_src > > ** Fontify natively > > Execute the following, answering =yes= to the revert buffer question, > for the same in "native" fontification. > > #+begin_src emacs-lisp :results silent > ;; do fontify code in code blocks > (setq org-src-fontify-natively t) > > (revert-buffer) > (org-shifttab) > #+end_src > > ** Verse > > #+begin_verse > Testing the fonctionality. > #+end_verse > > ** Quote > > #+begin_quote > Testing the fonctionality. > #+end_quote > > Best regards, > Seb ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-02 14:34 ` Dan Davison @ 2011-02-02 20:19 ` Sébastien Vauban 2011-02-07 12:54 ` Dan Davison 0 siblings, 1 reply; 27+ messages in thread From: Sébastien Vauban @ 2011-02-02 20:19 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Dan, Dan Davison wrote: > Just quickly, one thing I noticed is that the begin/end lines were visible > even inside folded trees. I.e., in a folded org file, containing many src > blocks, I could see the coloured backgrounds "poking out" of the folded > sections, extending to the right of the screen. Do you see that? Yes, but that's already the current situation today, *when using faces with background*. My (future) patch does not change that, and I'm not sure whether it should or not. In a way, I find this better: it makes it very clear there is a code block folded at that point in the document. Yes, I definitively prefer it that way -- if you don't mind. > Also, > >> "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 existing >>> faces. That way the default behavior is not changed by the patch, and >>> users 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) > > Could you clarify whether the above suggestions have been adopted or > rejected? I understand you're asking this question, because what you see is *not* the final patch, but just a test file for understanding the change and testing it. > At the moment the code below alters the background color of the begin/end > lines by default; but presumably the final version will not alter any > appearances by default? Exactly. > How will that work? I realize I did not correctly understood the point of Eric. What I had in mind was that the org-block-begin/end-line faces would inherit from org-meta-line with no additional feature. So, by default, it will just be a copy of all their properties. It would simplifying the code (well, not a huge deal) in the following way: instead of applying first org-meta-line, then org-block-begin/end-line, I would just apply the latter. But I can follow the idea of Eric, now that I just understood it in details, if anybody finds it more sensible. I have no position to defend on this subject. I'll follow your advice. > Would you be able to supply a patch, or better, put your work in a > publicly accessible git branch? It's hard to see exactly what changes > you have made with the full code as below. (Please contact me for write > access if you'd like to use the fork at > https://github.com/dandavison/org-devel.) Can you send me whatever required information per private mail (to the address you see, that's working!)? Looking forward to it. Best regards, Seb -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-02 20:19 ` Sébastien Vauban @ 2011-02-07 12:54 ` Dan Davison 2011-02-07 19:55 ` Sébastien Vauban 0 siblings, 1 reply; 27+ messages in thread From: Dan Davison @ 2011-02-07 12:54 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs org-mode mailing list [-- Attachment #1: Type: text/plain, Size: 1059 bytes --] Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes: > Hi Dan, > > Dan Davison wrote: >> Just quickly, one thing I noticed is that the begin/end lines were visible >> even inside folded trees. I.e., in a folded org file, containing many src >> blocks, I could see the coloured backgrounds "poking out" of the folded >> sections, extending to the right of the screen. Do you see that? > > Yes, but that's already the current situation today, *when using faces with > background*. My (future) patch does not change that, and I'm not sure whether > it should or not. In a way, I find this better: it makes it very clear there > is a code block folded at that point in the document. Yes, I definitively > prefer it that way -- if you don't mind. Hi Seb, hmm, maybe we're talking about different things. I would say this is a bug. A key part of Org's visual model is that folding hides content. Imo. I'm not saying I know how to fix it, but that's a separate issue. Here are three screenshots: org-overview: [-- Attachment #2: overview.png --] [-- Type: image/png, Size: 32932 bytes --] [-- Attachment #3: Type: text/plain, Size: 14 bytes --] org-content: [-- Attachment #4: contents.png --] [-- Type: image/png, Size: 43838 bytes --] [-- Attachment #5: Type: text/plain, Size: 11 bytes --] show-all: [-- Attachment #6: show-all.png --] [-- Type: image/png, Size: 64901 bytes --] [-- Attachment #7: Type: text/plain, Size: 2736 bytes --] (Btw, that's with the box face attribute set with your patch. Just playing with it to see if I like it.) Dan > >> Also, >> >>> "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 existing >>>> faces. That way the default behavior is not changed by the patch, and >>>> users 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) >> >> Could you clarify whether the above suggestions have been adopted or >> rejected? > > I understand you're asking this question, because what you see is *not* the > final patch, but just a test file for understanding the change and testing it. > >> At the moment the code below alters the background color of the begin/end >> lines by default; but presumably the final version will not alter any >> appearances by default? > > Exactly. > >> How will that work? > > I realize I did not correctly understood the point of Eric. What I had in mind > was that the org-block-begin/end-line faces would inherit from org-meta-line > with no additional feature. So, by default, it will just be a copy of all > their properties. > > It would simplifying the code (well, not a huge deal) in the following way: > instead of applying first org-meta-line, then org-block-begin/end-line, I > would just apply the latter. > > But I can follow the idea of Eric, now that I just understood it in details, > if anybody finds it more sensible. I have no position to defend on this > subject. I'll follow your advice. > >> Would you be able to supply a patch, or better, put your work in a >> publicly accessible git branch? It's hard to see exactly what changes >> you have made with the full code as below. (Please contact me for write >> access if you'd like to use the fork at >> https://github.com/dandavison/org-devel.) > > Can you send me whatever required information per private mail (to the address > you see, that's working!)? > > Looking forward to it. > > Best regards, > Seb [-- Attachment #8: Type: text/plain, Size: 201 bytes --] _______________________________________________ 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 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-07 12:54 ` Dan Davison @ 2011-02-07 19:55 ` Sébastien Vauban 2011-02-08 19:00 ` Dan Davison 0 siblings, 1 reply; 27+ messages in thread From: Sébastien Vauban @ 2011-02-07 19:55 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Dan, Dan Davison wrote: > Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw-XMD5yJDbdMSQIYZ4X/+iSw@public.gmane.orgrg> writes: >> Dan Davison wrote: >>> Just quickly, one thing I noticed is that the begin/end lines were visible >>> even inside folded trees. I.e., in a folded org file, containing many src >>> blocks, I could see the coloured backgrounds "poking out" of the folded >>> sections, extending to the right of the screen. Do you see that? >> >> Yes, but that's already the current situation today, *when using faces with >> background*. My (future) patch does not change that, and I'm not sure >> whether it should or not. In a way, I find this better: it makes it very >> clear there is a code block folded at that point in the document. Yes, I >> definitively prefer it that way -- if you don't mind. > > Hi Seb, hmm, maybe we're talking about different things. I think so as well. I was thinking you were talking about the delimiter line (begin_src and end_src) going up to the right end of the screen if the fully expanded view. Your picture shows it when folded. > I would say this is a bug. Indeed, that's definitely a bug. > A key part of Org's visual model is that folding hides content. Imo. I'm not > saying I know how to fix it, but that's a separate issue. Here are three > screenshots: > > org-overview: > org-content: > show-all: Can you send me your file, for me to test if I have the same problem? FYI, I've seen that once when working on my patch[1], but never ever since the last versions. Hence, just checking (plizz don't mind), are you really using the version committed in the trunk, or some older version I may have sent on this list? > (Btw, that's with the box face attribute set with your patch. Just > playing with it to see if I like it.) Maybe make a try with underline and overline -- discovered not that long ago. I find that the nicest combination... As well for headings 1 and 2. I'll send my newest color theme very soon for you to see this, if you're interested. Nope: correction, I'll put it directly on Worg. I'll ask for access, and try being autonomous for such things. Best regards, Seb Footnotes: [1] IIRC, Eric Fraga did see that as well, at some point in time. -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-07 19:55 ` Sébastien Vauban @ 2011-02-08 19:00 ` Dan Davison 2011-02-08 20:14 ` Sébastien Vauban 0 siblings, 1 reply; 27+ messages in thread From: Dan Davison @ 2011-02-08 19:00 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs org-mode mailing list Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes: > Hi Dan, > > Dan Davison wrote: >> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw-XMD5yJDbdMSQIYZ4X/+iSw@public.gmane.orgrg> writes: >>> Dan Davison wrote: >>>> Just quickly, one thing I noticed is that the begin/end lines were visible >>>> even inside folded trees. I.e., in a folded org file, containing many src >>>> blocks, I could see the coloured backgrounds "poking out" of the folded >>>> sections, extending to the right of the screen. Do you see that? >>> >>> Yes, but that's already the current situation today, *when using faces with >>> background*. My (future) patch does not change that, and I'm not sure >>> whether it should or not. In a way, I find this better: it makes it very >>> clear there is a code block folded at that point in the document. Yes, I >>> definitively prefer it that way -- if you don't mind. >> >> Hi Seb, hmm, maybe we're talking about different things. > > I think so as well. I was thinking you were talking about the delimiter line > (begin_src and end_src) going up to the right end of the screen if the fully > expanded view. > > Your picture shows it when folded. > >> I would say this is a bug. > > Indeed, that's definitely a bug. > >> A key part of Org's visual model is that folding hides content. Imo. I'm not >> saying I know how to fix it, but that's a separate issue. Here are three >> screenshots: >> >> org-overview: >> org-content: >> show-all: > > Can you send me your file, for me to test if I have the same problem? I don't have that file any longer, but the problem occurs with all files. It is somewhat unpredictable -- I mess about with block show/hide, and global visibility cycling, and it happens eventually if not at first. E.g. this file --------------------------------- * heading #+begin_src emacs-lisp 1 #+end_src --------------------------------- > > FYI, I've seen that once when working on my patch[1], but never ever since the > last versions. Hence, just checking (plizz don't mind), are you really using > the version committed in the trunk, yes, clean, HEAD is 88b793946. Note I'm on OS X (cocoa builds). Maybe someone else with OSX could try to reproduce this? It occurs with a distributed binary of aquamacs, and when loading nothing but Org, so it doesn't seem to be any local stuff of mine that's the problem. Dan > or some older version I may have sent on > this list? > >> (Btw, that's with the box face attribute set with your patch. Just >> playing with it to see if I like it.) > > Maybe make a try with underline and overline -- discovered not that long ago. > I find that the nicest combination... As well for headings 1 and 2. I'll send > my newest color theme very soon for you to see this, if you're interested. > Nope: correction, I'll put it directly on Worg. I'll ask for access, and try > being autonomous for such things. > > Best regards, > Seb > > Footnotes: > [1] IIRC, Eric Fraga did see that as well, at some point in time. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-08 19:00 ` Dan Davison @ 2011-02-08 20:14 ` Sébastien Vauban 2011-02-09 8:40 ` Dan Davison 0 siblings, 1 reply; 27+ messages in thread From: Sébastien Vauban @ 2011-02-08 20:14 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Dan, Dan Davison wrote: > Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw-XMD5yJDbdMSQIYZ4X/+iSw@public.gmane.orgrg> writes: >> Dan Davison wrote: >>> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw-XMD5yJDbdMSQIYZ4X/+iSw-XMD5yJDbdMReXY1tMh2IBh2eb7JE58TQ@public.gmane.org> writes: >>>> Dan Davison wrote: >>>>> Just quickly, one thing I noticed is that the begin/end lines were >>>>> visible even inside folded trees. I.e., in a folded org file, containing >>>>> many src blocks, I could see the coloured backgrounds "poking out" of >>>>> the folded sections, extending to the right of the screen. Do you see >>>>> that? >>> >>> I would say this is a bug. >> >> Indeed, that's definitely a bug. >> Can you send me your file, for me to test if I have the same problem? > > I don't have that file any longer, but the problem occurs with all > files. It is somewhat unpredictable -- I mess about with block > show/hide, and global visibility cycling, and it happens eventually if > not at first. E.g. this file > > --------------------------------- > * heading > #+begin_src emacs-lisp > 1 > #+end_src > --------------------------------- I could reproduce it with your above file, if the file ends on the end_src line. The following: --8<---------------cut here---------------start------------->8--- * heading #+begin_src emacs-lisp 1 #+end_src * other heading --8<---------------cut here---------------end--------------->8--- also exhibits the problem, but this one: --8<---------------cut here---------------start------------->8--- * heading #+begin_src emacs-lisp 1 #+end_src * other heading --8<---------------cut here---------------end--------------->8--- does not. So, it is related to the fact that the block is the last line of the subtree or of the file. As I always have newlines before headings, I don't see such a problem on my docs. Dan, can you confirm the above observation? Knowing this, do you have an idea on how to fix it? If not, I'll try having a play with the patched file. Best regards, Seb -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-08 20:14 ` Sébastien Vauban @ 2011-02-09 8:40 ` Dan Davison 0 siblings, 0 replies; 27+ messages in thread From: Dan Davison @ 2011-02-09 8:40 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs org-mode mailing list >>>>>> Just quickly, one thing I noticed is that the begin/end lines were >>>>>> visible even inside folded trees. I.e., in a folded org file, containing >>>>>> many src blocks, I could see the coloured backgrounds "poking out" of >>>>>> the folded sections, extending to the right of the screen. [...] >> E.g. this file >> >> --------------------------------- >> * heading >> #+begin_src emacs-lisp >> 1 >> #+end_src >> --------------------------------- > > I could reproduce it with your above file, if the file ends on the end_src > line. > > The following: > > * heading > > #+begin_src emacs-lisp > 1 > #+end_src > * other heading > > also exhibits the problem, but this one: > > * heading > > #+begin_src emacs-lisp > 1 > #+end_src > > * other heading > > does not. > > So, it is related to the fact that the block is the last line of the subtree > or of the file. > > As I always have newlines before headings, I don't see such a problem on my > docs. > > Dan, can you confirm the above observation? Confirm. Good point. > > Knowing this, do you have an idea on how to fix it? No. I do see things like this from time to time with outline-minor-mode. Can anyone suggest how to solve this folding/overlay/visibility problem? Dan > If not, I'll try having a > play with the patched file. > > Best regards, > Seb ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-01 21:04 ` Sébastien Vauban 2011-02-02 7:25 ` Eric S Fraga 2011-02-02 14:34 ` Dan Davison @ 2011-02-02 22:24 ` Sébastien Vauban 2011-02-02 22:46 ` Eric S Fraga 2011-02-03 15:02 ` Eric Schulte 2 siblings, 2 replies; 27+ messages in thread From: Sébastien Vauban @ 2011-02-02 22:24 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Eric(s), Dan & all, Sébastien 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 existing >> faces. That way the default behavior is not changed by the patch, and users >> 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!! * Code #+begin_src emacs-lisp :results silent (defface org-block-begin-line '((t (:inherit org-meta-line :underline "light grey" :foreground "#008ED1" :background "#EAEAFF"))) "Face used for the line delimiting the begin of source blocks.") (defface org-block-end-line '((t (:inherit org-meta-line :overline "light grey" :foreground "#008ED1" :background "#EAEAFF"))) "Face used for the line delimiting the end of source blocks.") (defface org-block-background '((t (:background "#FFFFEA"))) "Face used for the source block background.") (defun org-fontify-meta-lines-and-blocks (limit) "Fontify #+ lines and blocks, in the correct ways." (let ((case-fold-search t)) (if (re-search-forward "^\\([ \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) (lang (match-string 7)) (beg1 (line-beginning-position 2)) (dc1 (downcase (match-string 2))) (dc3 (downcase (match-string 3))) end end1 quoting block-type) (cond ((member dc1 '("html:" "ascii:" "latex:" "docbook:")) ;; a single line of backend-specific content (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) (remove-text-properties (match-beginning 0) (match-end 0) '(display t invisible t intangible t)) (add-text-properties (match-beginning 1) (match-end 3) '(font-lock-fontified t face org-meta-line)) (add-text-properties (match-beginning 6) (+ (match-end 6) 1) '(font-lock-fontified t face org-block)) ; for backend-specific code t) ((and (match-end 4) (equal dc3 "begin")) ;; Truly a block (setq block-type (downcase (match-string 5)) quoting (member block-type org-protecting-blocks)) (when (re-search-forward (concat "^[ \t]*#\\+end" (match-string 4) "\\>.*") nil t) ;; on purpose, we look further than LIMIT (setq end (match-end 0) end1 (1- (match-beginning 0))) (setq block-end (match-beginning 0)) (when quoting (remove-text-properties beg end '(display t invisible t intangible t))) (add-text-properties beg end '(font-lock-fontified t font-lock-multiline t)) (cond ((and lang org-src-fontify-natively) (org-src-font-lock-fontify-block lang block-start block-end) (overlay-put (make-overlay beg1 block-end) 'face 'org-block-background)) ; OK from svauban (quoting (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 (1+ end1) '(face org-quote))) ((string= block-type "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)) ; OK from svauban (add-text-properties (1+ end) (1+ end1) '(face org-meta-line)) (add-text-properties (1+ end) (1+ end1) '(face org-block-end-line)) ; OK from svauban t)) ((member dc1 '("title:" "author:" "email:" "date:")) (add-text-properties beg (match-end 3) (if (member (intern (substring dc1 0 -1)) org-hidden-keywords) '(font-lock-fontified t invisible t) '(font-lock-fontified t face org-document-info-keyword))) (add-text-properties (match-beginning 6) (match-end 6) (if (string-equal dc1 "title:") '(font-lock-fontified t face org-document-title) '(font-lock-fontified t face org-document-info)))) ((not (member (char-after beg) '(?\ ?\t))) ;; just any other in-buffer setting, but not indented (add-text-properties beg (1+ (match-end 0)) '(font-lock-fontified t face org-meta-line)) t) ((or (member dc1 '("begin:" "end:" "caption:" "label:" "orgtbl:" "tblfm:" "tblname:" "result:" "results:" "source:" "srcname:" "call:")) (and (match-end 4) (equal dc3 "attr"))) (add-text-properties beg (match-end 0) '(font-lock-fontified t face org-meta-line)) t) ((member dc3 '(" " "")) (add-text-properties beg (match-end 0) '(font-lock-fontified t face font-lock-comment-face))) (t nil)))))) #+end_src * Examples The above Lisp code is already an example of the way faces are applied. Here is another. ** Don't fontify natively Execute the following, answering =yes= to the revert buffer question, if you want to see how it looks like in "standard" fontification. #+begin_src emacs-lisp :results silent ;; don't fontify code in code blocks (setq org-src-fontify-natively nil) (revert-buffer) (org-shifttab) #+end_src ** Fontify natively Execute the following, answering =yes= to the revert buffer question, for the same in "native" fontification. #+begin_src emacs-lisp :results silent ;; do fontify code in code blocks (setq org-src-fontify-natively t) (revert-buffer) (org-shifttab) #+end_src ** Verse #+begin_verse Testing the fonctionality. What do you think? #+end_verse ** Quote #+begin_quote Testing the fonctionality. What do you think? #+end_quote Best regards, Seb -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Re: Fontification of blocks 2011-02-02 22:24 ` Sébastien Vauban @ 2011-02-02 22:46 ` Eric S Fraga 2011-02-03 15:02 ` Eric Schulte 1 sibling, 0 replies; 27+ messages in thread From: Eric S Fraga @ 2011-02-02 22:46 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs-orgmode Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes: [...] > Eric (Fraga), David (O'Toole) and Carsten, you should love the following... > when in native fontification... You are correct: I do love it! I've tried it on a large document with many source code blocks and it seems to work very well (and really helps with the presentation). I want this installed ASAP! Thanks, eric -- : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1 : using Org-mode version 7.4 (release_7.4.302.gd840.dirty) ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Re: Fontification of blocks 2011-02-02 22:24 ` Sébastien Vauban 2011-02-02 22:46 ` Eric S Fraga @ 2011-02-03 15:02 ` Eric Schulte 2011-02-03 19:57 ` Sébastien Vauban 2011-02-03 20:05 ` Eric S Fraga 1 sibling, 2 replies; 27+ messages in thread From: Eric Schulte @ 2011-02-03 15:02 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 2417 bytes --] Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes: > Hi Eric(s), Dan & all, > > Sébastien 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 existing >>> faces. That way the default behavior is not changed by the patch, and users >>> 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. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: seb-faces-for-org-blocks.patch --] [-- Type: text/x-diff, Size: 2688 bytes --] 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:" [-- Attachment #3: Type: text/plain, Size: 478 bytes --] 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 [-- Attachment #4: Type: text/plain, Size: 201 bytes --] _______________________________________________ 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 ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-03 15:02 ` Eric Schulte @ 2011-02-03 19:57 ` Sébastien Vauban 2011-02-03 20:05 ` Eric S Fraga 1 sibling, 0 replies; 27+ messages in thread From: Sébastien Vauban @ 2011-02-03 19:57 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Eric, "Eric Schulte" wrote: > +(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:" > > 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 Yes in my example test file -- I'm only using a "light theme". Not in the patch to come, as it simply is a copy of org-meta-line; so, if your org-meta-line is "dark theme"-compatible, the patch won't alter anything for you. > - I didn't notice a change in background for the code blocks I guess because your defface does not contain any background property? > - it seems that the #+end_src line is fontified but the #+begin_src line > is not That was not the case for me. > An image of my Emacs after applying the patch is available at: > http://i.imgur.com/2eu3z.png I'll now make a proper patch of what I want to submit, and let you review it. I'll share an image as well, of a possible customization. Thanks for your comments, Eric(s) and Dan. Best regards, Seb -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Re: Fontification of blocks 2011-02-03 15:02 ` Eric Schulte 2011-02-03 19:57 ` Sébastien Vauban @ 2011-02-03 20:05 ` Eric S Fraga 2011-02-03 20:44 ` Sébastien Vauban 1 sibling, 1 reply; 27+ messages in thread From: Eric S Fraga @ 2011-02-03 20:05 UTC (permalink / raw) To: Eric Schulte; +Cc: Sébastien Vauban, emacs-orgmode "Eric Schulte" <schulte.eric@gmail.com> writes: [...] > > 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. Seb's code worked for me but your patch doesn't unfortunately. > I noticed a couple of issues in the applied patch (possibly due to a > transcription error on my part). Namely Possibly? > - I believe your default faces only work for white backgrounds I have a white background and it doesn't work either but did. > - I didn't notice a change in background for the code blocks ditto with the patch. > - it seems that the #+end_src line is fontified but the #+begin_src line > is not I have the opposite (!) with your patch. I'm not sure what is wrong with the patch but there definitely must be some error unless something else has creeped in with normal org updates since yesterday. -- : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1 : using Org-mode version 7.4 (release_7.4.304.g71203.dirty) ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-03 20:05 ` Eric S Fraga @ 2011-02-03 20:44 ` Sébastien Vauban 2011-02-04 9:21 ` Sébastien Vauban 0 siblings, 1 reply; 27+ messages in thread From: Sébastien Vauban @ 2011-02-03 20:44 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ [-- Attachment #1: Type: text/plain, Size: 53 bytes --] Hi Eric(s), Here is the patch I intended to write: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001.patch --] [-- Type: text/x-patch, Size: 3006 bytes --] diff --git a/lisp/org-faces.el b/lisp/org-faces.el index c237a0e..2e9d2a3 100644 --- a/lisp/org-faces.el +++ b/lisp/org-faces.el @@ -1,6 +1,6 @@ ;;; org-faces.el --- Face definitions for Org-mode. -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 +;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 ;; Free Software Foundation, Inc. ;; Author: Carsten Dominik <carsten at orgmode dot org> @@ -511,6 +511,16 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword." :group 'org-faces :version "22.1") +(defface org-block-background + '((t (:background "#FFFFEA"))) + "Face used for the source block background.") + +(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-verbatim (org-compatible-face 'shadow '((((class color grayscale) (min-colors 88) (background light)) diff --git a/lisp/org.el b/lisp/org.el index 8acf5a9..70fda86 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -1,6 +1,6 @@ ;;; org.el --- Outline-based notes management and organizer ;; Carstens outline-mode for keeping track of everything. -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 +;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 ;; Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik <carsten at orgmode dot org> @@ -5146,16 +5146,19 @@ will be prompted for." ; 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-block-begin-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:" [-- Attachment #3: Type: text/plain, Size: 803 bytes --] Here the effect of applying it: http://i.imgur.com/3lPjH.png with the following setting in my color-theme[1]: --8<---------------cut here---------------start------------->8--- (org-block-begin-line ((t (:underline "light grey" :foreground "#008ED1" :background "#EAEAFF")))) (org-block-end-line ((t (:overline "light grey" :foreground "#008ED1" :background "#EAEAFF")))) --8<---------------cut here---------------end--------------->8--- The only thing that you *should* change in my patch is the color of the background you want, by default, in a dark theme. Is the above working for you, guys? Best regards, Seb Footnotes: [1] It should work without any customization. But, of course, if I did "need" 2 new faces, it is well to customize them... -- Sébastien Vauban [-- Attachment #4: Type: text/plain, Size: 222 bytes --] _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-03 20:44 ` Sébastien Vauban @ 2011-02-04 9:21 ` Sébastien Vauban 2011-02-04 16:18 ` Eric S Fraga 2011-02-04 20:50 ` Eric Schulte 0 siblings, 2 replies; 27+ messages in thread From: Sébastien Vauban @ 2011-02-04 9:21 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ [-- Attachment #1: Type: text/plain, Size: 1538 bytes --] Hi, As spotted by Eric Fraga: Sébastien Vauban wrote: > --- a/lisp/org-faces.el > +++ b/lisp/org-faces.el > @@ -1,6 +1,6 @@ > ;;; org-faces.el --- Face definitions for Org-mode. > > -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 > +;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 > ;; Free Software Foundation, Inc. > > ;; Author: Carsten Dominik <carsten at orgmode dot org> > @@ -511,6 +511,16 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword." > :group 'org-faces > :version "22.1") > > +(defface org-block-background > + '((t (:background "#FFFFEA"))) > + "Face used for the source block background.") > + > +(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-verbatim > (org-compatible-face 'shadow > '((((class color grayscale) (min-colors 88) (background light)) you should read the following at the 2nd =org-copy-face= command: > +(org-copy-face 'org-meta-line 'org-block-end-line > + "Face used for the line delimiting the end of source blocks.") ie, s/begin/end/ I guess it worked for me (I restarted completely Emacs for the test), as that face is defined in my color-theme now. So, it was created anyway. Corrected patch is attached to this post. Best regards, Seb -- Sébastien Vauban [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001.patch --] [-- Type: text/x-patch, Size: 3004 bytes --] diff --git a/lisp/org-faces.el b/lisp/org-faces.el index c237a0e..2e9d2a3 100644 --- a/lisp/org-faces.el +++ b/lisp/org-faces.el @@ -1,6 +1,6 @@ ;;; org-faces.el --- Face definitions for Org-mode. -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 +;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 ;; Free Software Foundation, Inc. ;; Author: Carsten Dominik <carsten at orgmode dot org> @@ -511,6 +511,16 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword." :group 'org-faces :version "22.1") +(defface org-block-background + '((t (:background "#FFFFEA"))) + "Face used for the source block background.") + +(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-end-line + "Face used for the line delimiting the end of source blocks.") + (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 8acf5a9..70fda86 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -1,6 +1,6 @@ ;;; org.el --- Outline-based notes management and organizer ;; Carstens outline-mode for keeping track of everything. -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 +;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 ;; Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik <carsten at orgmode dot org> @@ -5146,16 +5146,19 @@ will be prompted for." ; 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-block-begin-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:" [-- Attachment #3: Type: text/plain, Size: 222 bytes --] _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: Re: Fontification of blocks 2011-02-04 9:21 ` Sébastien Vauban @ 2011-02-04 16:18 ` Eric S Fraga 2011-02-04 20:50 ` Eric Schulte 1 sibling, 0 replies; 27+ messages in thread From: Eric S Fraga @ 2011-02-04 16:18 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs-orgmode Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes: [...] > Corrected patch is attached to this post. which appears to work just fine! Thanks. -- : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1 : using Org-mode version 7.4 (release_7.4.311.ga9d2.dirty) ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Re: Fontification of blocks 2011-02-04 9:21 ` Sébastien Vauban 2011-02-04 16:18 ` Eric S Fraga @ 2011-02-04 20:50 ` Eric Schulte 2011-02-06 8:52 ` Sébastien Vauban 1 sibling, 1 reply; 27+ messages in thread From: Eric Schulte @ 2011-02-04 20:50 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs-orgmode Hi Seb, This looks very nice, I am now able to turn fontification on and off as expected using your three new faces. I've just committed your patch with one minor change (not having the block background face set by default). Maybe it would be worth a worg post about how to use these faces with some example settings... Thanks -- Eric Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes: > Hi, > > As spotted by Eric Fraga: > > Sébastien Vauban wrote: >> --- a/lisp/org-faces.el >> +++ b/lisp/org-faces.el >> @@ -1,6 +1,6 @@ >> ;;; org-faces.el --- Face definitions for Org-mode. >> >> -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 >> +;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 >> ;; Free Software Foundation, Inc. >> >> ;; Author: Carsten Dominik <carsten at orgmode dot org> >> @@ -511,6 +511,16 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword." >> :group 'org-faces >> :version "22.1") >> >> +(defface org-block-background >> + '((t (:background "#FFFFEA"))) >> + "Face used for the source block background.") >> + >> +(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-verbatim >> (org-compatible-face 'shadow >> '((((class color grayscale) (min-colors 88) (background light)) > > you should read the following at the 2nd =org-copy-face= command: > >> +(org-copy-face 'org-meta-line 'org-block-end-line >> + "Face used for the line delimiting the end of source blocks.") > > ie, s/begin/end/ > > I guess it worked for me (I restarted completely Emacs for the test), as that > face is defined in my color-theme now. So, it was created anyway. > > Corrected patch is attached to this post. > > Best regards, > Seb ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fontification of blocks 2011-02-04 20:50 ` Eric Schulte @ 2011-02-06 8:52 ` Sébastien Vauban 0 siblings, 0 replies; 27+ messages in thread From: Sébastien Vauban @ 2011-02-06 8:52 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Eric, "Eric Schulte" wrote: > This looks very nice, I am now able to turn fontification on and off as > expected using your three new faces. Great. > I've just committed your patch with one minor change (not having the block > background face set by default). OK. I still think that it'd be better to have some customization made by default, because otherwise a lot of people would miss such features already-in-there. That has been "proved" yesterday at FOSDEM Brussels (great event -- certainly more to say about this later in the day), where some people are unaware of "native fontification" and the like. Of course, they would not stay unaware if they would read all messages posted here, and all the info available on Worg, but... I've the gut feeling it'd be better if it popped up for free, as this kind of stuff is unobtrusive, and "removable" if you "don't want" your code blocks to be clearly highlighted ;-) Nevertheless, I totally agree that the background face would have to be at least twofold: - once nice color for dark color theme, and - one nice color for light color theme (mine, very light yellow, or something else). But that's doable, if someone just proposes a nice one for dark backgrounds... > Maybe it would be worth a worg post about how to use these faces with > some example settings... I'll do for sure in the coming week(s). Best regards, Seb -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2011-02-09 8:40 UTC | newest] Thread overview: 27+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-12-10 9:02 Fontification of blocks Sébastien Vauban 2010-12-10 11:12 ` David O'Toole 2010-12-13 21:25 ` Sébastien Vauban 2010-12-22 13:36 ` Dan Davison 2010-12-22 14:46 ` Sébastien Vauban 2010-12-13 19:50 ` Eric Schulte 2010-12-13 20:46 ` Sébastien Vauban 2010-12-15 17:22 ` Eric Schulte 2011-02-01 21:04 ` Sébastien Vauban 2011-02-02 7:25 ` Eric S Fraga 2011-02-02 14:34 ` Dan Davison 2011-02-02 20:19 ` Sébastien Vauban 2011-02-07 12:54 ` Dan Davison 2011-02-07 19:55 ` Sébastien Vauban 2011-02-08 19:00 ` Dan Davison 2011-02-08 20:14 ` Sébastien Vauban 2011-02-09 8:40 ` Dan Davison 2011-02-02 22:24 ` Sébastien Vauban 2011-02-02 22:46 ` Eric S Fraga 2011-02-03 15:02 ` Eric Schulte 2011-02-03 19:57 ` Sébastien Vauban 2011-02-03 20:05 ` Eric S Fraga 2011-02-03 20:44 ` Sébastien Vauban 2011-02-04 9:21 ` Sébastien Vauban 2011-02-04 16:18 ` Eric S Fraga 2011-02-04 20:50 ` Eric Schulte 2011-02-06 8:52 ` Sébastien Vauban
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).