Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emacsclient and modeline/echo-area #118

Open
ImAReplicant opened this issue Mar 15, 2022 · 7 comments
Open

emacsclient and modeline/echo-area #118

ImAReplicant opened this issue Mar 15, 2022 · 7 comments

Comments

@ImAReplicant
Copy link

Hi,

The appearance of nano-emacs is a bit different when using emacsclient.
The bottom modeline/echo-area is not the right color, with the dark theme the modeline appears white and with the light theme the modeline is black.
Here is an example with the dark theme:

nano_emcacsclient

To fix this, I had to add these lines to my init.el file:

  • For the separator line:
(set-face-attribute 'mode-line-inactive nil :underline "#434C5E" :foreground "#2E3440")
(set-face-attribute 'mode-line nil :underline "#434C5E" :foreground "#2E3440")
  • For the text color of the echo-area buffer, the function nano-theme--minibuffer seems to be called before the echo-area buffer with emacsclient, so I added this hook but I don't know if it's a good workaround:

(add-hook 'echo-area-clear-hook 'nano-theme--minibuffer)

Another problem concerns nano-face-strong, with emacsclient the font is different because of the condition on display-graphic-p
I added this to my init.el file:
(set-face-attribute 'nano-face-strong nil :weight 'medium)

@rougier
Copy link
Owner

rougier commented Mar 28, 2022

Thanks for the report. Do yu know if there's a way to detect if an instance is a client such that we can have specific code for such case?

@ImAReplicant
Copy link
Author

After some research, I discovered that (daemonp) is set to t if the daemon is started and nil if not.

I also observed another problem with the echo-area, I noticed that if (require 'nano-session) is commented out, the echo-area text color is not applied if I run emacs from the desktop environment icon, but it is if I run the emacs -q -l init.el command.

Here is the init.el file I tried with:

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(setq package-enable-at-startup nil)

(straight-use-package 'use-package)
(setq straight-use-package-by-default t)


(straight-use-package
 '(nano-emacs :type git :host github :repo "rougier/nano-emacs"))

;; (require 'nano-base-colors)
;; (require 'nano-colors)
(require 'nano-faces)
(require 'nano-theme-dark)
(require 'nano-theme)
;; (require 'nano-splash)
;; (require 'nano-modeline)
;; (require 'nano-layout)
;; (require 'nano-defaults)
(require 'nano-session) ; comment to see the bug
;; (require 'nano-bindings)

(nano-faces)
(nano-theme)

;; (provide 'init)
;; ;;; init.el ends here

@rougier
Copy link
Owner

rougier commented Mar 31, 2022

Could you try with nano-theme (available on ELPA) to see if it fix things?

@ImAReplicant
Copy link
Author

ImAReplicant commented Apr 1, 2022

Ok I tried with nano-theme, here is what I noticed :

  • With Roboto Mono Nerd Font install
    • launch from icon => bug echo-area color
    • emacs -l init.el => good
    • emacsclient => bug echo-area color
  • Without Roboto Mono Nerd Font
    • launch from icon => good
    • emacs -l init.el => good
    • emacsclient => bug echo-area color

I have the same behavior as I try with the default package manager instead of straight.el.

My init.el file :

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(setq package-enable-at-startup nil)

(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

(straight-use-package '(nano-theme :type git :host github
                                   :repo "rougier/nano-theme"))

(require 'nano-theme)
(nano-mode)(nano-dark) ; nano-mode needed for echo-area color

(straight-use-package '(nano-modeline :type git :host github
                                   :repo "rougier/nano-modeline"))

(provide 'init)
;;; init.el ends here

Edit:
Like before I can prevent this problem with this hook:

(add-hook 'echo-area-clear-hook 'echo-area-hook)
(defun echo-area-hook ()
  (dolist (buffer (list " *Minibuf-0*" " *Echo Area 0*"
                        " *Minibuf-1*" " *Echo Area 1*"))
    (when (get-buffer buffer)
      (with-current-buffer buffer
        (face-remap-add-relative 'default 'nano-faded)))
    (remove-hook 'echo-area-clear-hook 'echo-area-hook))) ; remove the hook after the function is executed

@rougier
Copy link
Owner

rougier commented Apr 9, 2022

Thanks for the report. Could you try a regular (load-theme nano-dark) instead of (nano-dark)?

@ImAReplicant
Copy link
Author

No difference with (load-theme 'nano-dark) but I have to activate (setq custom-safe-themes t) otherwise I get a confirmation message every time I launch Emacs.

Note that if I use M-x load-theme RET nano-dark RET after Emacs load, the color of echo-area is well taken into account.

@rougier
Copy link
Owner

rougier commented Apr 21, 2022

I think this means that we have to use an after-init-hook to install the faces for the minibuffer/echo area. I wonder how other themes do it. I'll try to look into it. Don't hesitate to remind me here on my progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants