]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix 'wrong-type-argument' in 'php-ts-mode--webserver-read-args'
authorVincenzo Pupillo <v.pupillo@gmail.com>
Sat, 15 Jun 2024 16:57:29 +0000 (18:57 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 17 Jun 2024 10:43:50 +0000 (12:43 +0200)
Prevents php-ts-mode--webserver-read-args from throwing an
error if the current buffer is not associated with a file.
* lisp/progmodes/php-ts-mode.el (php-ts-mode--webserver-read-args):
Use 'default-directory if' the current buffer is not associated
with a file.  (Bug#71574)
(php-ts-mode-run-php-webserver): Fix doc string.

(cherry picked from commit 13c4fc3dc72d87af89d92f40808cf4f1285eddab)

lisp/progmodes/php-ts-mode.el

index f6b805f7e8e31c69a61c1300dc2754aadc192998..64138db9dc8e067adc902695c0ed6db4b9cf1ffb 100644 (file)
@@ -1467,7 +1467,7 @@ for PORT, HOSTNAME, DOCUMENT-ROOT and ROUTER-SCRIPT."
 (derived-mode-add-parents 'php-ts-mode '(php-mode))
 
 (defun php-ts-mode--webserver-read-args (&optional type)
-  "Helper for php-ts-mode-run-php-webserver.
+  "Helper for `php-ts-mode-run-php-webserver'.
 The optional TYPE can be the symbol \"port\", \"hostname\", \"document-root\" or
 \"router-script\", otherwise it requires all of them."
   (let ((ask-port (lambda ()
@@ -1477,11 +1477,15 @@ The optional TYPE can be the symbol \"port\", \"hostname\", \"document-root\" or
         (ask-document-root (lambda ()
                              (expand-file-name
                               (read-directory-name "Document root: "
-                                                   (file-name-directory (buffer-file-name))))))
+                                                   (file-name-directory
+                                                    (or (buffer-file-name)
+                                                        default-directory))))))
         (ask-router-script (lambda ()
                              (expand-file-name
                               (read-file-name "Router script: "
-                                              (file-name-directory (buffer-file-name)))))))
+                                              (file-name-directory
+                                               (or (buffer-file-name)
+                                                   default-directory)))))))
     (cl-case type
       (port (funcall ask-port))
       (hostname (funcall ask-hostname))