]> git.eshelyaron.com Git - emacs.git/commitdiff
Work with any old directory, no formal project needed
authorJoão Távora <joaotavora@gmail.com>
Sun, 13 May 2018 21:03:32 +0000 (22:03 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sun, 13 May 2018 21:05:09 +0000 (22:05 +0100)
Actually, uses a "transient project" which project-current returns if
desperate.

* README.md: Update

* eglot.el (eglot--current-process)
(eglot--current-process-or-lose): Simplify.
(eglot): Maybe prompt user for project.

lisp/progmodes/eglot.el

index 2e872dc5237373729218c0ae708ed35f3a8267dc..c1b63ea6e3d678fdbedab50f52794db966e8d7e9 100644 (file)
@@ -24,8 +24,7 @@
 
 ;;; Commentary:
 
-;; M-x eglot in some file under some .git controlled dir should get
-;; you started, but see README.md.
+;; Simply M-x eglot should be enough to get you started, but see README.md.
 
 ;;; Code:
 
@@ -79,15 +78,13 @@ lasted more than that many seconds."
 
 (defun eglot--current-process ()
   "The current logical EGLOT process."
-  (let* ((cur (project-current))
-         (processes (and cur (gethash cur eglot--processes-by-project))))
-    (cl-find major-mode processes :key #'eglot--major-mode)))
+  (let* ((probe (or (project-current) (cons 'transient default-directory))))
+    (cl-find major-mode (gethash probe eglot--processes-by-project)
+             :key #'eglot--major-mode)))
 
 (defun eglot--current-process-or-lose ()
   "Return the current EGLOT process or error."
-  (or (eglot--current-process)
-      (eglot--error "No current EGLOT process%s"
-                    (if (project-current) "" " (Also no current project)"))))
+  (or (eglot--current-process) (eglot--error "No current EGLOT process")))
 
 (defmacro eglot--define-process-var
     (var-sym initval &optional doc)
@@ -326,11 +323,8 @@ MANAGED-MAJOR-MODE.
 
 INTERACTIVE is t if called interactively."
   (interactive (eglot--interactive))
-  (let* ((project (project-current))
+  (let* ((project (project-current 'maybe))
          (short-name (eglot--project-short-name project)))
-    (unless project (eglot--error "Cannot work without a current project!"))
-    (unless command (eglot--error "Don't know how to start EGLOT for %s buffers"
-                                  major-mode))
     (let ((current-process (eglot--current-process)))
       (if (and (process-live-p current-process)
                interactive