7

Sometimes I use emacsclient -t -a '' in xterm, and sometimes I use emacsclient -c as a GUI application. What annoys me is that the font settings and color-theme are initialized when emacs server starts up so the window-system test doesn't take effect.

So are there any functions that I can make use of to let the emacsclient choose the face settings?

Thanks.

Hongxu Chen
  • 423
  • 1
  • 6
  • 18

3 Answers3

5

try to follow this post, they are talking about a similar issue.

here are the snippets from the post (I didnt try it myself though):

  ;; last t is for NO-ENABLE
  (load-theme 'tango t t)
  (load-theme 'tango-dark t t)

  (defun mb/pick-color-theme (frame)
    (select-frame frame)
    (if (window-system frame)
        (progn  
          (disable-theme 'tango-dark) ; in case it was active
          (enable-theme 'tango))
      (progn  
        (disable-theme 'tango) ; in case it was active
        (enable-theme 'tango-dark))))
  (add-hook 'after-make-frame-functions 'mb/pick-color-theme)

  ;; For when started with emacs or emacs -nw rather than emacs --daemon
  (if window-system
      (enable-theme 'tango)
    (enable-theme 'tango-dark))

if all goes well, it should look like: this

Shlomi
  • 206
  • 2
  • 7
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – gronostaj May 27 '13 at 11:15
  • you are right, i included the important parts in this post. – Shlomi May 27 '13 at 12:57
  • The frame-local theme settings seem difficult. But at least it works partially for my problem. Thanks. – Hongxu Chen May 28 '13 at 12:14
1

As mentioned at https://www.emacswiki.org/emacs/CustomizingFaces

"If you want different color schemes for different displays, you can customize this as well. In the customize buffer, click the [State] button and choose “Show all display specs”. Now you can use different specs for different displays."

ernobe
  • 11
  • 1
0

For me, mainly the background color was a problem.

Here's a minimal variant to customize the default face's background color to black when the frame is a tty:

(custom-set-faces
 '(default (
            (((type tty) (min-colors 256))
             (:background "black"))
            (t
             (:background "#181a26")))
    ))

black is only matched when displayed on a tty with 256 colors or less. By default, the special shade of blue is used as background color.

The same technique can be used for all other faces as well, not only the default face.

TheJJ
  • 111
  • 4