emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BABEL] Two minor issues
@ 2010-10-30 10:58 Jambunathan K
  2010-11-20  0:07 ` Dan Davison
  0 siblings, 1 reply; 8+ messages in thread
From: Jambunathan K @ 2010-10-30 10:58 UTC (permalink / raw)
  To: emacs-orgmode


1. Improper fontification of Babel blocks

   With babel native fontification on, I see that the commented elisp
   code down below is not fontified. The problem persists if I kill the
   buffer and find it again.

#+begin_src emacs-lisp
  ;; (message "Hello World")
#+end_src  


2. C-c C-v C-M-h and C-c C-v C-x interaction

   In the block below do

   1. C-c C-v C-M-h, C-c C-v C-x C-M-\
   2. Mark (just) the code-block with C-SPC etc etc. C-c C-v C-x C-M-\

   See the difference in behaviour.

#+begin_src xml
<text:p text:style-name="Standard">This is a xref to
<text:bookmark-ref text:reference-format="text"
text:ref-name="__RefHeading__1669_1684552201">Heading8
</text:bookmark-ref>.</text:p>
#+end_src

I have transient mark mode on.

Jambunathan K.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BABEL] Two minor issues
  2010-10-30 10:58 [BABEL] Two minor issues Jambunathan K
@ 2010-11-20  0:07 ` Dan Davison
  2010-11-20  7:19   ` Sébastien Vauban
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Davison @ 2010-11-20  0:07 UTC (permalink / raw)
  To: Jambunathan K; +Cc: emacs-orgmode

Hi Jambunathan,

Sorry to be so slow to get to these,

Jambunathan K <kjambunathan@gmail.com> writes:

> 1. Improper fontification of Babel blocks
>
>    With babel native fontification on, I see that the commented elisp
>    code down below is not fontified. The problem persists if I kill the
>    buffer and find it again.
>
> #+begin_src emacs-lisp
>   ;; (message "Hello World")
> #+end_src  

err, and I haven't had the energy to investigate this one yet! (While
we're at it, here's another org-src fontification minibug that I expect
others have noticed: the closing parenthesis here comes up fontified
with what looks like the string face

#+begin_src emacs-lisp
(defvar x nil "string")
#+end_src

)

> 2. C-c C-v C-M-h and C-c C-v C-x interaction
>
>    In the block below do
>
>    1. C-c C-v C-M-h, C-c C-v C-x C-M-\
>    2. Mark (just) the code-block with C-SPC etc etc. C-c C-v C-x C-M-\
>
>    See the difference in behaviour.

OK, but I've just fixed that one.

Dan

>
> #+begin_src xml
> <text:p text:style-name="Standard">This is a xref to
> <text:bookmark-ref text:reference-format="text"
> text:ref-name="__RefHeading__1669_1684552201">Heading8
> </text:bookmark-ref>.</text:p>
> #+end_src
>
> I have transient mark mode on.
>
> Jambunathan K.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> 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] 8+ messages in thread

* Re: [BABEL] Two minor issues
  2010-11-20  0:07 ` Dan Davison
@ 2010-11-20  7:19   ` Sébastien Vauban
  2010-11-20 13:05     ` Dan Davison
  0 siblings, 1 reply; 8+ messages in thread
From: Sébastien Vauban @ 2010-11-20  7:19 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Dan,

Dan Davison wrote:
>> #+begin_src emacs-lisp
>>   ;; (message "Hello World")
>> #+end_src
>
> err, and I haven't had the energy to investigate this one yet!

Another minibug, when natively fontifying, is that the line #+begin_src is no
more fontified up to the end of the screen (well to the end of the line):
choose a font with a background color, and you will notice the difference
immediately.

The line #+end_src is well correctly fontified from begin of a line to end of
screen.

By end of screen, I mean the "whole line", even after the last character of
that line... Am I clear?

Thanks.

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] 8+ messages in thread

* Re: [BABEL] Two minor issues
  2010-11-20  7:19   ` Sébastien Vauban
@ 2010-11-20 13:05     ` Dan Davison
  2010-11-22  9:30       ` Sébastien Vauban
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Davison @ 2010-11-20 13:05 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:
>>> #+begin_src emacs-lisp
>>>   ;; (message "Hello World")
>>> #+end_src
>>
>> err, and I haven't had the energy to investigate this one yet!
>
> Another minibug, when natively fontifying, is that the line #+begin_src is no
> more fontified up to the end of the screen (well to the end of the line):
> choose a font with a background color, and you will notice the difference
> immediately.

Hi Seb,

I do remember you reported this before, but I don't use faces with
background colors and didn't get round to working out how to set the
fonts. Could you provide a reproducible example with code to set up the
necessary faces?

The three changes you made in commit ff1b5de478e8575b2d8 to support
fontification to end of line are marked below.

I'm not totally clear which line is responsible for fontifying begin_src
   up the right-hand edge of the page. Is it this one?

	      (add-text-properties beg beg1 '(face org-meta-line))

The thing is that your patch didn't change that line, which confuses me.

But anyway, in the let binding at the top we have

	      (beg1 (line-beginning-position 2))

which worries me slightly -- does that mean that your functionality
relies on fontifying the first character of the *body* of the code block
as org-meta-line? If so then isn't that incompatible with also
fontifying the block contents as code?

Your 3rd change is inside the cond, and org-src-fontify-natively comes
earlier in the cond, so seb change 3 is not being evaluated when
org-src-fontify-natively is turned on. But I guess that is not the
problem as that code is dealing with the inside of the block, right?

Dan


#+begin_src emacs-lisp
;;; begin seb change 1
	    (add-text-properties (match-beginning 6) (+ (match-end 6) 1)
				 '(font-lock-fontified t face org-block))
					; for backend-specific code
;;; end seb change 1
	    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))
	      (add-text-properties beg beg1 '(face org-meta-line))
;;; begin seb change 2
	      (add-text-properties end1 (+ end 1) '(face org-meta-line))
					; for end_src
;;; end seb change 2
	      (cond
	       ((and lang org-src-fontify-natively)
		(org-src-font-lock-fontify-block lang block-start block-end))
	       (quoting
;;; begin seb change 3
		(add-text-properties beg1 (+ end1 1) '(face
						       org-block)))
					; end of source block
;;; end seb change 3
	       ((not org-fontify-quote-and-verse-blocks))
	       ((string= block-type "quote")
		(add-text-properties beg1 end1 '(face org-quote)))
	       ((string= block-type "verse")
		(add-text-properties beg1 end1 '(face org-verse))))
	      t))
#+end_src

>
> The line #+end_src is well correctly fontified from begin of a line to end of
> screen.
>
> By end of screen, I mean the "whole line", even after the last character of
> that line... Am I clear?
>
> Thanks.
>
> Best regards,
>   Seb

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BABEL] Two minor issues
  2010-11-20 13:05     ` Dan Davison
@ 2010-11-22  9:30       ` Sébastien Vauban
  2010-11-22 14:20         ` Dan Davison
  0 siblings, 1 reply; 8+ messages in thread
From: Sébastien Vauban @ 2010-11-22  9:30 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Dan,

(resending this, as it seems to never have reached the ML)

Dan Davison wrote:
> Sébastien Vauban writes:
>> Dan Davison wrote:
>>>> #+begin_src emacs-lisp
>>>>   ;; (message "Hello World")
>>>> #+end_src
>>>
>>> err, and I haven't had the energy to investigate this one yet!
>>
>> Another minibug, when natively fontifying, is that the line #+begin_src is
>> no more fontified up to the end of the screen (well to the end of the
>> line): choose a font with a background color, and you will notice the
>> difference immediately.
>
> I do remember you reported this before, but I don't use faces with
> background colors and didn't get round to working out how to set the fonts.
> Could you provide a reproducible example with code to set up the necessary
> faces?

#+TITLE:     Native fontification minibug
#+DATE:      2010-11-20
#+LANGUAGE:  en_US

* Faces with background

To set up Org faces with a background color, choose 1 of the 2 following
solutions:

** Install my color-theme

1. Download http://orgmode.org/worg/color-themes/color-theme-sva.el, putting
   it in a directory that's part of your =load-path=.

2. Insert the following somewhere in your =.emacs= file:

   #+begin_src emacs-lisp
   ;; the real color theme functions
   (when (require 'color-theme)

     ;; initialize the color theme package
     (if (fboundp 'color-theme-initialize)
         (color-theme-initialize))

     ;; color themes will be installed for all frames
     (setq color-theme-is-global t)

     ;; set my default color theme
     (when (try-require 'color-theme-sva)
       (color-theme-sva)))
   #+end_src

Doing so, you'll benefit of all customizations I've done (and re-done... and
re-re-done...) around faces in general, and Org faces in particular. You may
like it, or hate it, but you shouldn't stay indifferent to it...

** Customize some Org faces

Alternatively, you can just update the two most important faces (regarding
this question), directly from here, by executing this code:

#+begin_src emacs-lisp
(set-face-attribute 'org-meta-line nil
                    :foreground "#008ED1"
                    :background "#EAEAFF")

(set-face-attribute 'org-block nil
                    :foreground "blue1"
                    :background "#FFFFEA")
#+end_src

#+results:

* Example

The above code already is 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.

#+begin_src emacs-lisp
;; don't fontify code in code blocks
(setq org-src-fontify-natively nil)

(revert-buffer)
(org-shifttab)
#+end_src

#+results:

** What do you see?

#+begin_src emacs-lisp
;; (message "Hello World")
(message "Hello World")
#+end_src

** Fontify natively

Execute the following, answering =yes= to the revert buffer question.

#+begin_src emacs-lisp
;; do fontify code in code blocks
(setq org-src-fontify-natively t)

(revert-buffer)
(org-shifttab)
#+end_src

#+results:

What do you see?

Notice that, when in native fontification, the open parenthesis of the =setq=
line (second line of the last code block) is wrongly fontified.


> The three changes you made in commit ff1b5de478e8575b2d8 to support
> fontification to end of line are marked below.
>
> I'm not totally clear which line is responsible for fontifying begin_src up
> the right-hand edge of the page. Is it this one?
>
> 	      (add-text-properties beg beg1 '(face org-meta-line))
>
> The thing is that your patch didn't change that line, which confuses me.

The "native fontification" has been introduced a couple of weeks *after* my
patch. Maybe someone reverted the change in that line, which could explain,
well, a lot...


> But anyway, in the let binding at the top we have
>
> 	      (beg1 (line-beginning-position 2))
>
> which worries me slightly -- does that mean that your functionality relies
> on fontifying the first character of the *body* of the code block as
> org-meta-line? If so then isn't that incompatible with also fontifying the
> block contents as code?
>
> Your 3rd change is inside the cond, and org-src-fontify-natively comes
> earlier in the cond, so seb change 3 is not being evaluated when
> org-src-fontify-natively is turned on. But I guess that is not the problem
> as that code is dealing with the inside of the block, right?
>
> Dan
>
> #+begin_src emacs-lisp
> ;;; begin seb change 1
> 	    (add-text-properties (match-beginning 6) (+ (match-end 6) 1)
> 				 '(font-lock-fontified t face org-block))
> 					; for backend-specific code
> ;;; end seb change 1
> 	    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))
> 	      (add-text-properties beg beg1 '(face org-meta-line))
> ;;; begin seb change 2
> 	      (add-text-properties end1 (+ end 1) '(face org-meta-line))
> 					; for end_src
> ;;; end seb change 2
> 	      (cond
> 	       ((and lang org-src-fontify-natively)
> 		(org-src-font-lock-fontify-block lang block-start block-end))
> 	       (quoting
> ;;; begin seb change 3
> 		(add-text-properties beg1 (+ end1 1) '(face
> 						       org-block)))
> 					; end of source block
> ;;; end seb change 3
> 	       ((not org-fontify-quote-and-verse-blocks))
> 	       ((string= block-type "quote")
> 		(add-text-properties beg1 end1 '(face org-quote)))
> 	       ((string= block-type "verse")
> 		(add-text-properties beg1 end1 '(face org-verse))))
> 	      t))
> #+end_src

Honestly, the way I update that code has been mainly done by sequences of
trials and errors. The above code is, for me, still quite complex to
understand with vars such as beg, beg1, end, end1 for which I hadn't
completely understood the meaning. Otherwise, I would even have proposed a
renaming of some of them. But, I think that whatever we do, such a code will
stay complex to understand and change.

Find here a picture of what we see (since my patch) without native
fontification.

    http://www.mygooglest.com/sva/No-Native-Fontification.png

Also, a picture with the "new" setting of native fontification.

    http://www.mygooglest.com/sva/Native-Fontification-Minibug.png

Hope this helps. If you need help, I'm willing to take a look back a it (still
trying and testing the effect of changes), but it won't be before a couple of
days.

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] 8+ messages in thread

* Re: [BABEL] Two minor issues
  2010-11-22  9:30       ` Sébastien Vauban
@ 2010-11-22 14:20         ` Dan Davison
  2010-11-22 20:14           ` Sébastien Vauban
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Davison @ 2010-11-22 14:20 UTC (permalink / raw)
  To: emacs org-mode mailing list

Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
writes:

> Hi Dan,
>
> (resending this, as it seems to never have reached the ML)

Could you tell me what I should do with the random characters in the
addresses that appear in your emails? I've deleted the addresses and
just sending to emacs-orgmode@gnu.org, is that OK?

> Dan Davison wrote:
>> Sébastien Vauban writes:
>>> Dan Davison wrote:

<...>

> Honestly, the way I update that code has been mainly done by sequences of
> trials and errors. The above code is, for me, still quite complex to
> understand with vars such as beg, beg1, end, end1 for which I hadn't
> completely understood the meaning.

This seems to work -- could you try it out?

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org.el b/lisp/org.el
index e2de48e..0b082da 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5102,9 +5102,6 @@ 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))
@@ -5117,6 +5114,8 @@ will be prompted for."
 		(add-text-properties beg1 end1 '(face org-quote)))
 	       ((string= block-type "verse")
 		(add-text-properties beg1 end1 '(face org-verse))))
+	      (add-text-properties beg beg1 '(face org-meta-line))
+	      (add-text-properties (1+ end) (1+ end1) '(face org-meta-line))
 	      t))
 	   ((member dc1 '("title:" "author:" "email:" "date:"))
 	    (add-text-properties
--8<---------------cut here---------------end--------------->8---


Dan


> Otherwise, I would even have proposed a
> renaming of some of them. But, I think that whatever we do, such a code will
> stay complex to understand and change.
>
> Find here a picture of what we see (since my patch) without native
> fontification.
>
>     http://www.mygooglest.com/sva/No-Native-Fontification.png
>
> Also, a picture with the "new" setting of native fontification.
>
>     http://www.mygooglest.com/sva/Native-Fontification-Minibug.png
>
> Hope this helps. If you need help, I'm willing to take a look back a it (still
> trying and testing the effect of changes), but it won't be before a couple of
> days.
>
> Best regards,
>   Seb

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BABEL] Two minor issues
  2010-11-22 14:20         ` Dan Davison
@ 2010-11-22 20:14           ` Sébastien Vauban
  2010-11-22 21:36             ` Sébastien Vauban
  0 siblings, 1 reply; 8+ messages in thread
From: Sébastien Vauban @ 2010-11-22 20:14 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Dan,

Dan Davison wrote:
> S=C3=A9bastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw-XMD5yJDbdMRS5n6/RkiaJA@public.gmane.orgne.org>
> writes:
> Could you tell me what I should do with the random characters in the
> addresses that appear in your emails?

I think it's the "encryption" done by Gmane, isn't it?  Do you currently have
a problem with them?  I did not change anything, though.


> I've deleted the addresses and just sending to emacs-orgmode-mXXj517/zsQ@public.gmane.org, is
> that OK?

I always received your mails directly to my inbox up to now, so no need to
change your procedure. Anyway, I'm reading thru the newsgroup, so I should
always see your answers there as well.


>> Dan Davison wrote:
>>> S=C3=A9bastien Vauban writes:
>>>> Dan Davison wrote:
>
> <...>
>
>> Honestly, the way I update that code has been mainly done by sequences of
>> trials and errors. The above code is, for me, still quite complex to
>> understand with vars such as beg, beg1, end, end1 for which I hadn't
>> completely understood the meaning.
>
> This seems to work -- could you try it out?

Perfect for me!  Thanks a lot...

> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/org.el b/lisp/org.el
> index e2de48e..0b082da 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -5102,9 +5102,6 @@ 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))
> @@ -5117,6 +5114,8 @@ will be prompted for."
>  		(add-text-properties beg1 end1 '(face org-quote)))
>  	       ((string=3D block-type "verse")
>  		(add-text-properties beg1 end1 '(face org-verse))))
> +	      (add-text-properties beg beg1 '(face org-meta-line))
> +	      (add-text-properties (1+ end) (1+ end1) '(face org-meta-line))
>  	      t))
>  	   ((member dc1 '("title:" "author:" "email:" "date:"))
>  	    (add-text-properties
> --8<---------------cut here---------------end--------------->8---

The only remaining problem (even tinier -- maybe not to find, but for the
Orger) is: when in native fontification, the open parenthesis of the =setq=
line (second line of the last code block) is wrongly fontified.

But that was there before your patch. So, unrelated...

Would you, though, have an idea how to introduce a background color for the
source block part, I'd take it. If not, its status stays, for me, SOMEDAY ;-)

Thanks a lot for your contrib.

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] 8+ messages in thread

* Re: [BABEL] Two minor issues
  2010-11-22 20:14           ` Sébastien Vauban
@ 2010-11-22 21:36             ` Sébastien Vauban
  0 siblings, 0 replies; 8+ messages in thread
From: Sébastien Vauban @ 2010-11-22 21:36 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Dan,

Sébastien Vauban wrote:
> Dan Davison wrote:
>> This seems to work -- could you try it out?
>
> Perfect for me!  Thanks a lot...

Just discovered a problem:
- right fontification (of everything) when code begins in col 0
- no fontification when col > 0

Example:

--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp :results wrap :exports both
  "something else"
#+end_src

now indented
- first
- second

  #+begin_src emacs-lisp :results wrap :exports both
    "something else"
  #+end_src
--8<---------------cut here---------------end--------------->8---

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] 8+ messages in thread

end of thread, other threads:[~2010-11-22 21:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-30 10:58 [BABEL] Two minor issues Jambunathan K
2010-11-20  0:07 ` Dan Davison
2010-11-20  7:19   ` Sébastien Vauban
2010-11-20 13:05     ` Dan Davison
2010-11-22  9:30       ` Sébastien Vauban
2010-11-22 14:20         ` Dan Davison
2010-11-22 20:14           ` Sébastien Vauban
2010-11-22 21:36             ` Sébastien Vauban

Code repositories for project(s) associated with this 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).