From: João Távora Date: Wed, 2 May 2018 14:36:26 +0000 (+0100) Subject: Slightly more user friendly start X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~674 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bdfba7ed6290554e2908e1aaba2f5887bc073c37;p=emacs.git Slightly more user friendly start * eglot.el (eglot-new-process): signal DidOpen for every file in project. (eglot-editing-mode): Offer to start process. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 6e5954ca807..d3428a73a74 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -193,7 +193,17 @@ INTERACTIVE is t if called interactively." major-mode)) probe))) (lambda () - (eglot--message "Connected")))))))) + (eglot--message "Connected") + (dolist (buffer (buffer-list)) + (with-current-buffer buffer + (if (and buffer-file-name + (cl-some + (lambda (root) + (string-prefix-p + (expand-file-name root) + (expand-file-name buffer-file-name))) + (project-roots project))) + (eglot--signalDidOpen))))))))))) (defun eglot--process-sentinel (process change) "Called with PROCESS undergoes CHANGE." @@ -647,16 +657,19 @@ running. INTERACTIVE is t if called interactively." nil nil eglot-mode-map - (cond (eglot-editing-mode - (eglot-mode 1) - (add-hook 'after-change-functions 'eglot--after-change nil t) - (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t) - (if (eglot--current-process) - (eglot--signalDidOpen) - (eglot--warn "No process"))) - (t - (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t) - (remove-hook 'after-change-functions 'eglot--after-change t)))) + (cond + (eglot-editing-mode + (eglot-mode 1) + (add-hook 'after-change-functions 'eglot--after-change nil t) + (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t) + (if (eglot--current-process) + (eglot--signalDidOpen) + (if (y-or-n-p "No process, try to start one with `eglot-new-process'? ") + (eglot-new-process t) + (eglot--warn "No process")))) + (t + (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t) + (remove-hook 'after-change-functions 'eglot--after-change t)))) (define-minor-mode eglot-mode "Minor mode for all buffers managed by EGLOT in some way." nil