]> git.eshelyaron.com Git - emacs.git/commitdiff
New m-x eglot-stderr-buffer useful for debugging
authorJoão Távora <joaotavora@gmail.com>
Mon, 28 May 2018 21:30:01 +0000 (22:30 +0100)
committerJoão Távora <joaotavora@gmail.com>
Mon, 28 May 2018 22:09:13 +0000 (23:09 +0100)
* eglot.el (eglot--make-process): Save stderr buffer in process.
(eglot-stderr-buffer): New interactive command.
(eglot--mode-line-format): Bind C-mouse-1 to new
eglot-stderr-buffer.

lisp/progmodes/eglot.el

index d75499348f88d92b8b7b4731ae188f2584df740a..f3bf2b7b031c9ebd8544336139d286e118c50ad4 100644 (file)
@@ -233,22 +233,21 @@ DEFERRED request from BUF, to be sent not later than TIMER as ID."
   "Make a process object from CONTACT.
 NAME is used to name the the started process or connection.
 CONTACT is in `eglot'.  Returns a process object."
-  (let* ((buffer (get-buffer-create (format "*%s stdout*" name)))
+  (let* ((stdout (format "*%s stdout*" name)) stderr
          (proc (cond
                 ((processp contact) contact)
                 ((integerp (cadr contact))
-                 (apply #'open-network-stream name buffer contact))
+                 (apply #'open-network-stream name stdout contact))
                 (t (make-process
-                    :name name
-                    :command contact
-                    :coding 'no-conversion
-                    :connection-type 'pipe
-                    :stderr (get-buffer-create (format "*%s stderr*" name)))))))
-    (set-process-buffer proc buffer)
-    (set-marker (process-mark proc) (with-current-buffer buffer (point-min)))
+                    :name name :command contact :buffer stdout
+                    :coding 'no-conversion :connection-type 'pipe
+                    :stderr (setq stderr (format "*%s stderr*" name)))))))
+    (process-put proc 'eglot-stderr stderr)
+    (set-process-buffer proc (get-buffer-create stdout))
+    (set-marker (process-mark proc) (with-current-buffer stdout (point-min)))
     (set-process-filter proc #'eglot--process-filter)
     (set-process-sentinel proc #'eglot--process-sentinel)
-    (with-current-buffer buffer
+    (with-current-buffer stdout
       (let ((inhibit-read-only t)) (erase-buffer) (read-only-mode t)))
     proc))
 
@@ -544,6 +543,12 @@ INTERACTIVE is t if called interactively."
     (when interactive (display-buffer buffer))
     buffer))
 
+(defun eglot-stderr-buffer (server)
+  "Pop to stderr of SERVER, if it exists, else error."
+  (interactive (list (eglot--current-server-or-lose)))
+  (if-let ((b (process-get (eglot--process server) 'eglot-stderr)))
+      (pop-to-buffer b) (user-error "[eglot] No stderr buffer!")))
+
 (defun eglot--log-event (server message &optional type)
   "Log an eglot-related event.
 SERVER is the current server.  MESSAGE is a JSON-like plist.
@@ -934,26 +939,25 @@ Uses THING, FACE, DEFS and PREPEND."
      (when name
        `(":" ,(eglot--mode-line-props
                name 'eglot-mode-line
-               '((mouse-1 eglot-events-buffer "go to events buffer")
+               '((C-mouse-1 eglot-stderr-buffer "go to stderr buffer")
+                 (mouse-1 eglot-events-buffer "go to events buffer")
                  (mouse-2 eglot-shutdown      "quit server")
                  (mouse-3 eglot-reconnect     "reconnect to server")))
          ,@(when serious-p
              `("/" ,(eglot--mode-line-props
                      "error" 'compilation-mode-line-fail
-                     '((mouse-1 eglot-events-buffer "go to events buffer")
-                       (mouse-3 eglot-clear-status  "clear this status"))
+                     '((mouse-3 eglot-clear-status  "clear this status"))
                      (format "An error occured: %s\n" status))))
          ,@(when (and doing (not done-p))
              `("/" ,(eglot--mode-line-props
                      (format "%s%s" doing
                              (if detail (format ":%s" detail) ""))
-                     'compilation-mode-line-run
-                     '((mouse-1 eglot-events-buffer "go to events buffer")))))
+                     'compilation-mode-line-run '())))
          ,@(when (cl-plusp pending)
              `("/" ,(eglot--mode-line-props
                      (format "%d" pending) 'warning
-                     '((mouse-1 eglot-events-buffer "go to events buffer")
-                       (mouse-3 eglot-clear-status  "clear this status"))
+                     '((mouse-3 eglot-forget-pending-continuations
+                                "forget these continuations"))
                      (format "%d pending requests\n" pending)))))))))
 
 (add-to-list 'mode-line-misc-info