emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Fontification of org code block not printed
@ 2014-07-28 16:02 Stefan-W. Hahn
  2014-07-28 16:57 ` Bastien
  2014-07-29  9:38 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan-W. Hahn @ 2014-07-28 16:02 UTC (permalink / raw)
  To: emacs-orgmode, emacs-devel

Hello,

I'm using org-mode and have had some trouble with printing with faces, which
has been solved in emacs. Currently I'm using the following
version:

commit 59b20d77aec5055417eeec039af84de88cda12b2
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Date:   Mon Jun 30 22:25:52 2014 -0400

    * lisp/ps-def.el (ps-generate-postscript-with-faces1): Don't mess with
    buffer-invisibility-spec.


When using org blocks like:

(from org.el)
#+BEGIN_SRC elisp
(defun org-fontify-meta-lines-and-blocks-1 (limit)
  "Fontify #+ lines and blocks."
..
	      (cond
	       ((and lang (not (string= lang "")) org-src-fontify-natively)
		(org-src-font-lock-fontify-block lang block-start block-end)
		;; remove old background overlays
		(mapc (lambda (ov)
			(if (eq (overlay-get ov 'face) 'org-block-background)
			    (delete-overlay ov)))
		      (overlays-at (/ (+ beg1 block-end) 2)))
		;; add a background overlay
		(setq ovl (make-overlay beg1 block-end))
                (overlay-put ovl 'face 'org-block-background)
                (overlay-put ovl 'evaporate t))  ;; make it go away when empty
..
#+END_SRC

The text between #+BEGIN_SRC and #+END_SRC gets fontified with the
fontification of the given mode, in this case elisp.

A describe-text-properties at position of 'd' of defun gives:

#+BEGIN_QUOTE
Text content at position 858:

There is an overlay here:
 From 857 to 1499
  evaporate            t
  face                 org-block-background


There are text properties here:
  face                 font-lock-keyword-face
  font-lock-fontified  t
  font-lock-multiline  t
  fontified            t
#+END_QUOTE

This all is correct and fontified visible in the emacs buffer.

But if this part is going to be postscript printed the fontifiying _is_ not
to be printed.

The face for printing is retrieved in ps-generate-postscript-with-faces1
(from ps-def.el) with 'get-char-property'.

(from ps-def.el)
#+BEGIN_SRC elisp
  (defun ps-generate-postscript-with-faces1 (from to)
..
      (while (< from to)
	(and (< property-change to)	; Don't search for property change
					; unless previous search succeeded.
	     (setq property-change (next-property-change from nil to)))
	(and (< overlay-change to)	; Don't search for overlay change
					; unless previous search succeeded.
	     (setq overlay-change (min (next-overlay-change from)
				       to)))
	(setq position (min property-change overlay-change)
	      before-string nil
	      after-string nil)
	(setq face
	      (cond ((invisible-p from)
		     'emacs--invisible--face)
		    ((get-char-property from 'face))
		    (t 'default)))
..
#+END_SRC

The call to get-char-property gives for every position the face of the overlay,
which is org-block-background, and not the face of the propertized text.

I think this will be the same for all such #+BEGIN/#+END blocks in org-mode.

I'm sure that this is not what I expect but I'm not sure if this is a fault
in ps-def.el or org.el. Because of this I send this to both mailing lists to
get help before sending an error report.

With kind regards,
Stefan

-- 
Stefan-W. Hahn                          It is easy to make things.
                                        It is hard to make things simple.

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

* Re: Fontification of org code block not printed
  2014-07-28 16:02 Fontification of org code block not printed Stefan-W. Hahn
@ 2014-07-28 16:57 ` Bastien
  2014-07-29 17:07   ` Stefan-W. Hahn
       [not found]   ` <87lhrdtmyq.fsf-E3UqQZAQFPqWIDz0JBNUog@public.gmane.org>
  2014-07-29  9:38 ` Stefan Monnier
  1 sibling, 2 replies; 6+ messages in thread
From: Bastien @ 2014-07-28 16:57 UTC (permalink / raw)
  To: Stefan-W. Hahn; +Cc: emacs-orgmode, emacs-devel

Hi Stefan,

thanks for the thorough analysis.

"Stefan-W. Hahn" <stefan.hahn@s-hahn.de> writes:

> I'm sure that this is not what I expect but I'm not sure if this is a fault
> in ps-def.el or org.el.

This is the fault of Org.

I fixed this in master by removing `org-block-background'.

This is radical but I think this is really better:
http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=f8b42e8

Sebastien, let's think about another way of getting a
color for the background, if that's really needed.

-- 
 Bastien

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

* Re: Fontification of org code block not printed
  2014-07-28 16:02 Fontification of org code block not printed Stefan-W. Hahn
  2014-07-28 16:57 ` Bastien
@ 2014-07-29  9:38 ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2014-07-29  9:38 UTC (permalink / raw)
  To: Stefan-W. Hahn; +Cc: emacs-orgmode, emacs-devel

> I'm sure that this is not what I expect but I'm not sure if this is a fault
> in ps-def.el or org.el. Because of this I send this to both mailing lists to
> get help before sending an error report.

It's a problem in the ps-def.el code which handles the `face' property
in a "naive" way: it fails to merge the various active face properties
(from the various overlays and the text-property).


        Stefan

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

* Re: Fontification of org code block not printed
  2014-07-28 16:57 ` Bastien
@ 2014-07-29 17:07   ` Stefan-W. Hahn
       [not found]   ` <87lhrdtmyq.fsf-E3UqQZAQFPqWIDz0JBNUog@public.gmane.org>
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan-W. Hahn @ 2014-07-29 17:07 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode, emacs-devel

Mail von Bastien, Mon, 28 Jul 2014 at 18:57:37 +0200:

Hello Bastian,

> This is the fault of Org.
> 
> I fixed this in master by removing `org-block-background'.
> 
> This is radical but I think this is really better:
> http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=f8b42e8

I tested and it works as I expect.

Thanks for your fast reply.

With kind regards,
Stefan

-- 
Stefan-W. Hahn                          It is easy to make things.
                                        It is hard to make things simple.

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

* Re: Fontification of org code block not printed
       [not found]   ` <87lhrdtmyq.fsf-E3UqQZAQFPqWIDz0JBNUog@public.gmane.org>
@ 2014-08-01  7:31     ` Francesco Pizzolante
  2015-05-25 12:22       ` Joe Corneli
  0 siblings, 1 reply; 6+ messages in thread
From: Francesco Pizzolante @ 2014-08-01  7:31 UTC (permalink / raw)
  To: Bastien
  Cc: emacs-orgmode-mXXj517/zsQ, Stefan-W. Hahn, emacs-devel-mXXj517/zsQ

Hi Bastien,

> This is the fault of Org.
>
> I fixed this in master by removing `org-block-background'.
>
> This is radical but I think this is really better:
> http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=f8b42e8
>
> Sebastien, let's think about another way of getting a
> color for the background, if that's really needed.

I have to say that I'm surprised about the way this issue has been
fixed. Let me tell you why.

1) The fix 'simply' removes a useful Org functionality, which I use for
   3 years now, without providing any alternative.

2) The first approach would have been to try to fix the issue instead of
   completely removing the functionality which, as I already said, is
   present since a long time.

3) A possible workaround, without completely removing
   org-block-background, would have been to add a variable in order for
   people to activate (or de-activate) it and use it (or avoid the
   issue).

4) To conclude, according to Stefan Monnier (see his answser from
   2014-07-29 11:38), the issue is due to a bug in ps-def.el and not in
   Org:

> It's a problem in the ps-def.el code which handles the `face' property
> in a "naive" way: it fails to merge the various active face properties
> (from the various overlays and the text-property).

Could you, then, put org-block-background back and let the fix be done
in Emacs and not in Org?

Thanks a lot.

Regards,
 Francesco

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

* Re: Fontification of org code block not printed
  2014-08-01  7:31     ` Francesco Pizzolante
@ 2015-05-25 12:22       ` Joe Corneli
  0 siblings, 0 replies; 6+ messages in thread
From: Joe Corneli @ 2015-05-25 12:22 UTC (permalink / raw)
  To: Francesco Pizzolante
  Cc: Bastien, Org-mode mailing list, Stefan-W. Hahn, emacs-devel

On Fri, Aug 1, 2014 at 8:31 AM, Francesco Pizzolante
<fpz@missioncriticalit.com> wrote:

> I have to say that I'm surprised about the way this issue has been
> fixed. Let me tell you why.
>
> 1) The fix 'simply' removes a useful Org functionality, which I use for
>    3 years now, without providing any alternative.

Wouldn't it be possible to use Polymode, as in this image?
https://github.com/vspinu/polymode/blob/master/img/org.png

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

end of thread, other threads:[~2015-05-25 12:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-28 16:02 Fontification of org code block not printed Stefan-W. Hahn
2014-07-28 16:57 ` Bastien
2014-07-29 17:07   ` Stefan-W. Hahn
     [not found]   ` <87lhrdtmyq.fsf-E3UqQZAQFPqWIDz0JBNUog@public.gmane.org>
2014-08-01  7:31     ` Francesco Pizzolante
2015-05-25 12:22       ` Joe Corneli
2014-07-29  9:38 ` Stefan Monnier

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).