4

Hopefully a simple question.

I code in c++ in emacs with a dark background and the syntax highlighting is perfect for viewing that way, however when I print on white paper, some of the colours like yellow/orange don't show well against the light background.

I have tried doing M-x invert-faces default in the buffer and then printing, but this has no effect.

I am able to select the word, do M-x customize-face, and change the foreground colour this way, which works, but I don't want to do this when I'm printing. It's variable names that I want to change the colour of but only when printing.

What I would like to do it have a custom functions, which would temporarily change all variable names in that buffer to a different colour, print it, and then change them back.

The output of customize-buffer looks like:

Editing a setting changes only the text in this buffer.
To apply your changes, use the Save or Set buttons.
Saving a change normally works by editing your init file.
For details, see [Saving Customizations] in the [Emacs manual].


 Operate on all settings in this buffer that are not marked HIDDEN:
 [Set for current session] [Save for future sessions]
 [Undo edits] [Reset to saved] [Erase customizations]   [Exit]

Font Lock Variable Name Face:(sample) [Hide Face]
   [State]: SAVED and set.
   Font Lock mode face used to highlight variable names.
Groups: [Font Lock Faces]
Choice: [Value Menu]
 Attributes: [ ] Font Family: *
             [ ] Font Foundry: *
             [ ] Width: *
             [ ] Height: *
             [X] Weight: [Value Menu] light
             [ ] Slant: *
             [ ] Underline: *
             [ ] Overline: *
             [ ] Strike-through: *
             [ ] Box around text: *
             [ ] Inverse-video: *
             [X] Foreground: #FF8400    (sample)
             [ ] Background: *
             [ ] Stipple: *
             [ ] Inherit: *

Any thoughts on how to proceed?

Thanks

Joey

Joey O
  • 135
  • 3

2 Answers2

2

You can use ps-extend-face to tell ps-print to print using anther color.

(ps-extend-face FACE-EXTENSION &optional MERGE-P ALIST-SYM)

Extend face in ALIST-SYM.

If optional MERGE-P is non-nil, extensions in FACE-EXTENSION list are merged with face extensions in ALIST-SYM; otherwise, overrides.

If optional ALIST-SYM is nil, `ps-print-face-extension-alist' is used; otherwise, it should be an alist symbol.

The elements of FACE-EXTENSION list have the form:

(FACE-NAME FOREGROUND BACKGROUND EXTENSION...)

FACE-NAME is a face name symbol.

FOREGROUND and BACKGROUND may be nil or a string that denotes the foreground and background colors respectively.

EXTENSION is one of the following symbols: bold - use bold font. italic - use italic font. underline - put a line under text. strikeout - like underline, but the line is in middle of text. overline - like underline, but the line is over the text.
shadow - text will have a shadow. box - text will be surrounded by a box. outline - print characters as hollow outlines.

If EXTENSION is any other symbol, it is ignored.

For example (from the file comments):

(ps-extend-face '(font-lock-keyword-face "RoyalBlue" nil bold) 'MERGE)
Lindydancer
  • 6,095
  • 1
  • 13
  • 25
0

You could try M-x Customize, then search for Ps Use Face Background, choose Always use face background.

Drew
  • 75,699
  • 9
  • 109
  • 225