Settings for GUI / Terminal emacs only

I am trying to install a theme - one only for the terminal, and the other only for gui. I read this topic: Running some init Emacs commands only in GUI mode

What brought me here: https://superuser.com/questions/165335/how-can-i-show-the-emacs-menu-in-gui-emacs-frames-but-not-in-tty-frames-when -usi

And I tried to create a function that matches my needs.

(defun set-frame-theme (frame)
  (let ((want-theme (memq (framep frame) '(x w32 ns))))
    (set-frame-parameter frame '(load-theme '(if want-theme monokai solarized-dark) t))))
(add-hook 'after-make-frame-functions 'set-frame-theme)

This does not work. I try to download monokai only if gui, otherwise load the sunshine. It works for the GUI, but causes the terminal to crash.

Suggestions?

+5
source share
4 answers

emacs lisp,   (--) true, emacs .

.emacs

(if (display-graphic-p)
    (load-GUI-theme)
  (load-Terminal-theme))

, is-in-terminal

(defun is-in-terminal()
    (not (display-graphic-p)))

,

(if (is-in-terminal)
    (load-Terminal-theme)
  (load-GUI-theme))

Terminal Only , , progn, , Emacs GUI

(defmacro when-term (&rest body)
  "Works just like `progn' but will only evaluate expressions in VAR when Emacs is running in a terminal else just nil."
  `(when (is-in-terminal) ,@body))

:

(when-term
    (load-my-term-theme)
    (set-some-keybindings)
    (foo-bar))

, , .

, , :

https://github.com/jordonbiondo/Emacs/blob/master/Jorbi/jorbi-util.el

+11

, - . .

0

emacs . , , emacs. HEAD .

0

All Articles