fxbois / web-mode

web template editing mode for emacs
https://web-mode.org
GNU General Public License v3.0
1.64k stars 260 forks source link

web mode auto close dosen't work on emacsclient #1271

Closed SimoneRiccardi closed 1 year ago

SimoneRiccardi commented 1 year ago

When i use emacs normally auto closing of tags works, but when i use emacs in daemon mode with an emacsclient the feature doesn't work at all. I don't know if other features have the same or similar problem

fxbois commented 1 year ago

do you mean in a terminal ?

SimoneRiccardi commented 1 year ago

no loaded by systemd. And i noticed that even html attribute tag autocompletition ( when you put equals after a tag name and immediately emacs writes an open and close quotes ) works in regular emacs but not in emacsclient

So probably is the automatic text write in gthat doesn't work

Ziqi-Yang commented 1 year ago

Testing on a nearly bare Emacs setup emacs -Q --daemon --init-directory=~/.emacs.d_test/, I found this problem is not solved. I think the source of the problem is the use of display-graphic-p in the custom variable like

(defcustom web-mode-enable-css-colorization (display-graphic-p)
  "In a CSS part, set background according to the color: #xxx, rgb(x,x,x)."
  :type 'boolean
  :group 'web-mode)

I solve this problem by

(defun mk/setup-web-mode-for-emacs-client ()
  "Setup some values of web mode for emacs cliet."
  (if (display-graphic-p)
    (setq web-mode-enable-auto-closing t
      web-mode-enable-auto-pairing t
      web-mode-enable-auto-indentation t
      web-mode-enable-auto-opening t
      web-mode-enable-auto-quoting t
      web-mode-enable-css-colorization t)))

(add-hook 'server-after-make-frame-hook #'mk/setup-web-mode-for-emacs-client)

However, I think it's better to see the problems originally solved. Thanks <3