[Top][All Lists]

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

Fontification of org code block not printed

From: Stefan-W. Hahn
Subject: Fontification of org code block not printed
Date: Mon, 28 Jul 2014 18:02:32 +0200
User-agent: Mutt/1.5.21 (2010-09-15)


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

commit 59b20d77aec5055417eeec039af84de88cda12b2
Author: Stefan Monnier <address@hidden>
Date:   Mon Jun 30 22:25:52 2014 -0400

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

When using org blocks like:

(from org.el)
#+BEGIN_SRC elisp
(defun org-fontify-meta-lines-and-blocks-1 (limit)
  "Fontify #+ lines and blocks."
               ((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

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:

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

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)
        (setq position (min property-change overlay-change)
              before-string nil
              after-string nil)
        (setq face
              (cond ((invisible-p from)
                    ((get-char-property from 'face))
                    (t 'default)))

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-W. Hahn                          It is easy to make things.
                                        It is hard to make things simple.

reply via email to

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