all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* emacsclient question: tty-setup-hook and X specific config
@ 2018-11-22 22:00 Hadrien Lacour
  2018-11-23  8:53 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Hadrien Lacour @ 2018-11-22 22:00 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 966 bytes --]

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

[-- Attachment #2: .emacs --]
[-- Type: text/plain, Size: 4252 bytes --]

(add-to-list 'load-path "~/.emacs.d/lisp/")

(defun x-config ()
  ;; Theming
  (message "Applying X config")
  (custom-set-variables
   '(ansi-color-faces-vector
	 [default default default italic underline success warning error])
   '(ansi-color-names-vector
	 ["black" "red3" "ForestGreen" "yellow3" "blue" "magenta3" "DeepSkyBlue"
	  "gray50"])
   '(custom-enabled-themes (quote (deeper-blue)))
   '(package-selected-packages (quote (company eglot auctex))))
  (custom-set-faces
   '(default ((t (:inherit nil :stipple nil :background "#181a26" :foreground
						   "gray80" :inverse-video nil :box nil :strike-through
						   nil :overline nil :underline nil :slant normal
						   :weight normal :height 120 :width normal :foundry
						   "1ASC" :family "xos4 Terminus")))))
  (setq-default cursor-type '(bar . 1))
  ;; Packages
  (require 'package)
  (add-to-list 'package-archives
			   '("melpa-stable" . "https://stable.melpa.org/packages/") t)
  (add-to-list 'package-archives
			   '("melpa" . "http://melpa.milkbox.net/packages/") t)
  (package-initialize)
  ;; Completion
  (require 'company)
  (add-hook 'prog-mode-hook 'company-mode)
  (setq
   company-minimum-prefix-length 3
   company-idle-delay 0
   company-tooltip-limit 10
   company-dabbrev-downcase nil)
  ;; Eglot
  (require 'eglot)
  (add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd"))
  (add-hook 'c-mode-hook 'eglot-ensure)
  ;; Various prog-mode stuff
  (add-hook 'prog-mode-hook 'electric-pair-mode)
  (add-hook 'prog-mode-hook 'linum-mode))

(defun apply-x-config (&optional frame)
  (if (display-graphic-p frame)
	  (x-config)))

;; Apply config when creating a frame or launching emacs
(add-hook 'after-make-frame-functions 'apply-x-config)
(add-hook 'tty-setup-hook (lambda () (message "tty-setuphook run")))
(apply-x-config)

;; Misc display
(setq-default indent-tabs-mode t)
(setq-default tab-width 4)
(set-default 'truncate-lines t)
(add-hook 'prog-mode-hook (show-paren-mode 1))

;; c-mode
(setq c-default-style "bsd"
	  c-basic-offset 4)
(c-set-offset 'case-label '+)
(c-set-offset 'arglist-cont-nonempty '+)
(c-set-offset 'statement-cont '+)

;; sh-mode
(setq sh-indent-after-continuation 'always)

;; elisp-mode
(put 'if 'lisp-indent-function nil)

;; diff-mode
(defun custom-diff-colors ()
  (set-face-foreground 'diff-added "green")
  (set-face-background 'diff-added "unspecified")
  (set-face-foreground 'diff-removed "red")
  (set-face-background 'diff-removed "unspecified")
  (set-face-background 'diff-file-header "unspecified"))
(eval-after-load "diff-mode" '(custom-diff-colors))

;; Latex
(add-hook 'LaTeX-mode-hook 'auto-fill-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq-default TeX-master nil)
(setq TeX-auto-save t)
(setq TeX-parse-self t)

;; Vapoursynth
(add-to-list 'auto-mode-alist '("\\.vpy\\'" . python-mode))

;; Spellcheck
(setq ispell-dictionary "fr_FR")

;; Ruler
(require 'whitespace)
(setq whitespace-line-column 79)
(setq whitespace-style '(face lines-tail))
(global-whitespace-mode 1)

;; Misc bindings
(defun sed-on-region (b e script)
  "Run a sed script on a region"
  (interactive "r\nsSed script on region: ")
  (call-process-region b e "sed" t t t "-E" "--" script))
(global-set-key (kbd "C-c C-e") 'sed-on-region)

(defun comment-region-binding ()
  (local-set-key (kbd "C-c C-u") 'uncomment-region)
  (local-set-key (kbd "C-c C-c") 'comment-region))
(add-hook 'prog-mode-hook 'comment-region-binding)
(add-hook 'LaTeX-mode-hook 'comment-region-binding)
(setq smerge-command-prefix "\C-cm")

(add-hook 'prog-mode-hook
	(lambda()
		(local-set-key (kbd "C-c <right>") 'hs-show-block)
		(local-set-key (kbd "C-c <left>")  'hs-hide-block)
		(local-set-key (kbd "C-c <up>")	   'hs-hide-all)
		(local-set-key (kbd "C-c <down>")  'hs-show-all)
	(hs-minor-mode t)))

;; Misc
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(setq inhibit-startup-screen t)
(setq auto-save-default nil)
(setq backup-inhibited t)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(setq-default fill-column 79)
(setq frame-resize-pixelwise t)
(savehist-mode t)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)

[-- Attachment #3: st.el --]
[-- Type: text/plain, Size: 321 bytes --]

(message "Registering st keybinds")
(define-key input-decode-map "^[[1;5A" [C-up])
(define-key input-decode-map "^[[1;5B" [C-down])
(define-key input-decode-map "^[[1;5C" [C-right])
(define-key input-decode-map "^[[1;5D" [C-left])
(define-key input-decode-map "^[[1~" [home])
(define-key input-decode-map "^[[4~" [end])

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: emacsclient question: tty-setup-hook and X specific config
  2018-11-22 22:00 emacsclient question: tty-setup-hook and X specific config Hadrien Lacour
@ 2018-11-23  8:53 ` Eli Zaretskii
       [not found]   ` <20181123103151.qrjd7oaztls7jgsd@gentoo-zen2700x>
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2018-11-23  8:53 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Thu, 22 Nov 2018 23:00:50 +0100
> From: Hadrien Lacour <hadrien.lacour@posteo.net>
> 
> * 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?

> * 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.

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?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: emacsclient question: tty-setup-hook and X specific config
       [not found]   ` <20181123103151.qrjd7oaztls7jgsd@gentoo-zen2700x>
@ 2018-11-24  7:37     ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2018-11-24  7:37 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 23 Nov 2018 11:31:51 +0100
> From: Hadrien Lacour <hadrien.lacour@posteo.net>
> 
> On Fri, Nov 23, 2018 at 10:53:13AM +0200, Eli Zaretskii wrote:
> > 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.

> > 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?
> 
> I wasn't very accurate. The problem is that:
>  	$ 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.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-24  7:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-22 22:00 emacsclient question: tty-setup-hook and X specific config Hadrien Lacour
2018-11-23  8:53 ` Eli Zaretskii
     [not found]   ` <20181123103151.qrjd7oaztls7jgsd@gentoo-zen2700x>
2018-11-24  7:37     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.