From 35336ec33c5c90d93004ad8b46e989bcc9520c02 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo 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. (Bug#71574) (php-ts-mode-run-php-webserver): Fix doc string. (cherry picked from commit 13c4fc3dc72d87af89d92f40808cf4f1285eddab) --- 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 f6b805f7e8e..64138db9dc8 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -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)) -- 2.39.2