Subject: 30.0.50; [PATCH] Fix wrong-type-argument in php-ts-mode--webserver-read-args
From: Vincenzo Pupillo <[email-masked]>
To: [email-masked]
Date: Sat, 15 Jun 2024 19:53:18 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Ciao,
php-ts-mode-run-php-webserver throws an error if the current buffer is not 
associated with a file. This is due to php-ts-mode--webserver-read-args. php-
ts-mode--webserver-read-args now uses default-directory if buffer-file-name 
returns nil. 
The included patch fixes this.

Thanks.
Vincenzo

From 4a22bae2bd7515801037f3ab55f1a514a7e82aef Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <[email-masked]>
Date: Sat, 15 Jun 2024 18:57:29 +0200
Subject: [PATCH] Fix wrong-type-argument in php-ts-mode--webserver-read-args

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.
* lisp/progmodes/php-ts-mode.el (php-ts-mode-run-php-webserver):
  Fix doc string.
---
 lisp/progmodes/php-ts-mode.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el
index fc029a17120..1a8a0a44468 100644
--- a/lisp/progmodes/php-ts-mode.el
+++ b/lisp/progmodes/php-ts-mode.el
@@ -1464,7 +1464,7 @@ php-ts-mode-run-php-webserver
 (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 ()
@@ -1474,11 +1474,15 @@ php-ts-mode--webserver-read-args
         (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))
-- 
2.45.2