]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: new eglot--format to fix quote substitution woes (bug#73472)
authorJoão Távora <joaotavora@gmail.com>
Mon, 6 Jan 2025 10:47:13 +0000 (10:47 +0000)
committerEshel Yaron <me@eshelyaron.com>
Wed, 8 Jan 2025 08:36:46 +0000 (09:36 +0100)
* lisp/progmodes/eglot.el (eglot--guess-contact): Use eglot--format.
(eglot--format): New helper.
(eglot--error, eglot--message, eglot--warn)
(eglot--apply-text-edits, eglot-rename): Use eglot--format.

(cherry picked from commit c3ec174a6c2d1118e82aecceb203634f7b567e20)

lisp/progmodes/eglot.el

index 48ad8e024dd46eedc750a33b7c46fa648f643761..7313f2876d2a1bc2d8ef5ad9880e0dd51f373ecb 100644 (file)
@@ -1323,16 +1323,19 @@ be guessed."
           (and base-prompt
                (cond (current-prefix-arg base-prompt)
                      ((null guess)
-                      (format "[eglot] Couldn't guess LSP server for `%s'\n%s"
-                              main-mode base-prompt))
+                      (eglot--format
+                       "[eglot] Couldn't guess LSP server for `%s'\n%s"
+                       main-mode base-prompt))
                      ((and program
                            (not (file-name-absolute-p program))
                            (not (compat-call executable-find program t)))
                       (if full-program-invocation
-                          (concat (format "[eglot] I guess you want to run `%s'"
-                                          full-program-invocation)
-                                  (format ", but I can't find `%s' in PATH!"
-                                          program)
+                          (concat (eglot--format
+                                   "[eglot] I guess you want to run `%s'"
+                                   full-program-invocation)
+                                  (eglot--format
+                                   ", but I can't find `%s' in PATH!"
+                                   program)
                                   "\n" base-prompt)
                         (eglot--error
                          (concat "`%s' not found in PATH, but can't form"
@@ -1701,19 +1704,23 @@ in project `%s'."
 \f
 ;;; Helpers (move these to API?)
 ;;;
+(defun eglot--format (format &rest args)
+  "Like `format`, but substitutes quotes."
+  (apply #'format (substitute-quotes format) args))
+
 (defun eglot--error (format &rest args)
   "Error out with FORMAT with ARGS."
-  (error "[eglot] %s" (apply #'format format args)))
+  (error "[eglot] %s" (apply #'eglot--format format args)))
 
 (defun eglot--message (format &rest args)
   "Message out with FORMAT with ARGS."
-  (message "[eglot] %s" (apply #'format format args)))
+  (message "[eglot] %s" (apply #'eglot--format format args)))
 
 (defun eglot--warn (format &rest args)
   "Warning message with FORMAT and ARGS."
   (apply #'eglot--message (concat "(warning) " format) args)
   (let ((warning-minimum-level :error))
-    (display-warning 'eglot (apply #'format format args) :warning)))
+    (display-warning 'eglot (apply #'eglot--format format args) :warning)))
 
 (defalias 'eglot--bol
   (if (fboundp 'pos-bol) #'pos-bol
@@ -3634,7 +3641,7 @@ If SILENT, don't echo progress in mode-line."
            (howmany (length edits))
            (reporter (unless silent
                        (make-progress-reporter
-                        (format "[eglot] applying %s edits to `%s'..."
+                        (eglot--format "[eglot] applying %s edits to `%s'..."
                                 howmany (current-buffer))
                         0 howmany)))
            (done 0))
@@ -3756,8 +3763,9 @@ edit proposed by the server."
   "Rename the current symbol to NEWNAME."
   (interactive
    (list (read-from-minibuffer
-          (format "Rename `%s' to: " (or (thing-at-point 'symbol t)
-                                         "unknown symbol"))
+          (eglot--format "Rename `%s' to: "
+                         (or (thing-at-point 'symbol t)
+                             "unknown symbol"))
           nil nil nil nil
           (symbol-name (symbol-at-point)))))
   (eglot-server-capable-or-lose :renameProvider)