Discussion:
emacsclient question: tty-setup-hook and X specific config
Hadrien Lacour
2018-11-22 22:00:50 UTC
Permalink
Hello,

I'm trying to convert my current .emacs config to work with
emacs --daemon/emacsclient. So far I've encountered two problems:

* The tty-hook-setup hook is run as it should (on `emacs -nw` and
`emacsclient -nw` invocations) but doesn't load my terminal specific file
after the first `emacsclient -nw` call.
$ emacs -nw myfile
$ emacs --daemon
$ emacsclient -nw -c myfile
$ emacsclient -nw -c myfile
The last line doesn't load st.el (attached).

* I want to apply theming only for graphical frames, but If I do:
$ emacs --daemon
$ emacsclient -nw -c myfile
$ emacsclient -c myfile
$ emacsclient -nw -c myfile

The theme is applied for the last two lines, even when using the -c option each
time.


The first one looks like a bug to me, and the second is just me not knowing how
to do that. Attached are my config file (~/.emacs) and my terminal file
(~/.emacs.d/lisp/term/st.el). Any idea about the why and how to fix it?


Regards,
Hadrien Lacour
Eli Zaretskii
2018-11-23 08:53:13 UTC
Permalink
Date: Thu, 22 Nov 2018 23:00:50 +0100
* The tty-hook-setup hook is run as it should (on `emacs -nw` and
`emacsclient -nw` invocations) but doesn't load my terminal specific file
after the first `emacsclient -nw` call.
$ emacs -nw myfile
$ emacs --daemon
$ emacsclient -nw -c myfile
$ emacsclient -nw -c myfile
The last line doesn't load st.el (attached).
Terminal initialization file is loaded only once into a given session.
Why is it a problem in your case? The st.el file you show just
performs key bindings, why do you need to do that more than once?
$ emacs --daemon
$ emacsclient -nw -c myfile
$ emacsclient -c myfile
$ emacsclient -nw -c myfile
The theme is applied for the last two lines, even when using the -c option each
time.
Not sure I understand why you thought -c had anything to do with theme
application. Anyway, if you want a theme to be applied only to GUI
frames, how about turning on the theme in the
after-make-frame-functions hook?
Eli Zaretskii
2018-11-24 07:37:17 UTC
Permalink
Date: Fri, 23 Nov 2018 11:31:51 +0100
Post by Eli Zaretskii
Terminal initialization file is loaded only once into a given session.
Why is it a problem in your case? The st.el file you show just
performs key bindings, why do you need to do that more than once?
Well, for some reason, the keybinds are forgotten when this file isn't loaded.
If you can provide a recipe for reproducing this, please submit a bug
report with that recipe.
Post by Eli Zaretskii
Not sure I understand why you thought -c had anything to do with theme
application. Anyway, if you want a theme to be applied only to GUI
frames, how about turning on the theme in the
after-make-frame-functions hook?
$ emacs --daemon
$ emacsclient -nw -c myfile (no theme)
$ emacsclient -c myfile (theme)
$ emacsclient -nw -c myfile (theme)
When I don't want the last line to have theming (because it is a tty session).
I thought that -c meant "new frame", and that the theme only applied to the
current frame, which is obviously wrong.
A theme is global. I don't think we have facilities for frame-local
themes.
So, is there way to do this? Do I need to reset the theme with
tty-setup-hook?
Not necessarily that hook, but some hook that is called when a frame
is created. I'd suggest after-make-frame-functions.
I wouldn't need all this if I could just make emacs work with st-256color,
though (it acts as if I only have 16).
You need to teach Emacs to recognize that, see xterm.el for how it is
done for xterm.

Loading...