bug#72966: 30.0.90; [PATCH] php-ts-mode: custom php.ini config for the built-in php webserver
Ciao, this patch adds a new CONFIG attribute to 'php-ts-mode-run-php-webserver' that allows you to specify an alternative php.ini file to the default (or whatever is specified in 'php-ts-mode-php-config'). Thanks. Vincenzo. >From 8b64219e081a086559728251172d710b51e2 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Mon, 2 Sep 2024 14:11:01 +0200 Subject: [PATCH] Support for custom php.ini for the built-in PHP web server. A new CONFIG attribute, which defaults to 'php-ts-mode-php-config', allows an alternative php.ini file to be specified for the built-in web server. The 'php-ts-mode-run-php-webserver' function, when called interactively with a prefix argument, also requires this new attribute. * lisp/progmodes/php-ts-mode.el (php-ts-mode-run-php-webserver): New CONFIG attribute. Update docstring. * lisp/progmodes/php-ts-mode.el (php-ts-mode--webserver-read-args): Support the new TYPE. Update docstring. --- lisp/progmodes/php-ts-mode.el | 33 ++--- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el index 3f89de14075..34304049c5c 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -1469,8 +1469,12 @@ php-ts-mode ;;;###autoload -(defun php-ts-mode-run-php-webserver (&optional port hostname document-root -router-script num-of-workers) +(defun php-ts-mode-run-php-webserver (&optional port +hostname +document-root +router-script +config +num-of-workers) "Run PHP built-in web server. PORT: Port number of built-in web server, default `php-ts-mode-ws-port'. @@ -1482,12 +1486,14 @@ php-ts-mode-run-php-webserver Prompt for the document-root if the default value is nil. ROUTER-SCRIPT: Path of the router PHP script, see `https://www.php.net/manual/en/features.commandline.webserver.php' +CONFIG: Alternative php.ini config, default `php-ts-mode-php-config'. NUM-OF-WORKERS: Before run the web server set the PHP_CLI_SERVER_WORKERS env variable useful for testing code against multiple simultaneous requests. + Interactively, when invoked with prefix argument, always prompt -for PORT, HOSTNAME, DOCUMENT-ROOT and ROUTER-SCRIPT." +for PORT, HOSTNAME, DOCUMENT-ROOT, ROUTER-SCRIPT and CONFIG." (interactive (when current-prefix-arg (php-ts-mode--webserver-read-args))) (let* ((port (or @@ -1502,6 +1508,9 @@ php-ts-mode-run-php-webserver document-root php-ts-mode-ws-document-root (php-ts-mode--webserver-read-args 'document-root))) + (config (or config + (when php-ts-mode-php-config + (expand-file-name php-ts-mode-php-config (host (format "%s:%d" hostname port)) (name (format "PHP web server on: %s" host)) (buf-name (format "*%s*" name)) @@ -1509,6 +1518,8 @@ php-ts-mode-run-php-webserver nil (list "-S" host "-t" document-root + (when config + (format "-c %s" config)) router-script))) (process-environment (cons (cond @@ -1529,8 +1540,8 @@ php-ts-mode-run-php-webserver (defun php-ts-mode--webserver-read-args (&optional type) "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." +The optional TYPE can be the symbol \"port\", \"hostname\", \"document-root\", +\"router-script\" or \"config\", otherwise it requires all of them." (let ((ask-port (lambda () (read-number "Port: " 3000))) (ask-hostname (lambda () @@ -1546,17 +1557,25 @@ php-ts-mode--webserver-read-args (read-file-name "Router script: " (file-name-directory (or (buffer-file-name) - default-directory))) + default-directory)) +(ask-config (lambda() + (expand-file-name + (read-file-name "Alternative php.ini: " + (file-name-directory +
bug#72966: 30.0.90; [PATCH] php-ts-mode: custom php.ini config for the built-in php webserver
Ok, thanks. I will fix ASAP. Vincenzo. In data lunedì 2 settembre 2024 16:23:53 CEST, Eli Zaretskii ha scritto: > > From: Vincenzo Pupillo > > Date: Mon, 02 Sep 2024 15:29:23 +0200 > > > > Ciao, > > this patch adds a new CONFIG attribute to 'php-ts-mode-run-php-webserver' > > that allows you to specify an alternative php.ini file to the default (or > > whatever is specified in 'php-ts-mode-php-config'). > > Thanks. > > > -(defun php-ts-mode-run-php-webserver (&optional port hostname > > document-root - > > router-script num-of-workers) +(defun php-ts-mode-run-php-webserver > > (&optional port > > +hostname > > +document-root > > +router-script > > +config > > +num-of-workers) > > > >"Run PHP built-in web server. > > This changes a public API in backward-incompatible way, something we > don't do, because it could break someone's code out there. (It is > true that php-ts-mode was introduced in Emacs 30, but that version is > already in pretest and will be released soon, so I don't think we can > change this there, either.) > > So please find a backward-compatible way of adding this feature, > perhaps add the new CONFIG argument as the last one? > > Also, I think this needs a NEWS entry describing the change in > behavior.
bug#72966: 30.0.90; [PATCH] php-ts-mode: custom php.ini config for the built-in php webserver
Hi Eli, I followed your suggestion and moved the CONFIG argument. I also added a new entry to the NEWS file. Thanks. Vincenzo In data lunedì 2 settembre 2024 16:23:53 CEST, Eli Zaretskii ha scritto: > > From: Vincenzo Pupillo > > Date: Mon, 02 Sep 2024 15:29:23 +0200 > > > > Ciao, > > this patch adds a new CONFIG attribute to 'php-ts-mode-run-php-webserver' > > that allows you to specify an alternative php.ini file to the default (or > > whatever is specified in 'php-ts-mode-php-config'). > > Thanks. > > > -(defun php-ts-mode-run-php-webserver (&optional port hostname > > document-root - > > router-script num-of-workers) +(defun php-ts-mode-run-php-webserver > > (&optional port > > +hostname > > +document-root > > +router-script > > +config > > +num-of-workers) > > > >"Run PHP built-in web server. > > This changes a public API in backward-incompatible way, something we > don't do, because it could break someone's code out there. (It is > true that php-ts-mode was introduced in Emacs 30, but that version is > already in pretest and will be released soon, so I don't think we can > change this there, either.) > > So please find a backward-compatible way of adding this feature, > perhaps add the new CONFIG argument as the last one? > > Also, I think this needs a NEWS entry describing the change in > behavior. >From ae9182be63bfa8625c8c8486c1856dced4fb9152 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Mon, 2 Sep 2024 14:11:01 +0200 Subject: [PATCH] Support for custom php.ini for the built-in PHP web server. A new CONFIG attribute, which defaults to 'php-ts-mode-php-config', allows an alternative php.ini file to be specified for the built-in web server. The 'php-ts-mode-run-php-webserver' function, when called interactively with a prefix argument, also requires this new attribute. * etc/NEWS: Described the new CONFIG attribute and the different behavior of 'php-ts-mode-run-php-webserver'. * lisp/progmodes/php-ts-mode.el (php-ts-mode--parent-html-bol): Fix docstring. * lisp/progmodes/php-ts-mode.el (php-ts-mode-run-php-webserver): New CONFIG attribute. Update docstring. * lisp/progmodes/php-ts-mode.el (php-ts-mode--webserver-read-args): Support the new TYPE. Update docstring. --- etc/NEWS | 10 + lisp/progmodes/php-ts-mode.el | 75 +++ 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index f2c999a3955..0539bf47479 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1965,6 +1965,16 @@ the 'widget-inactive' face). If non-nil, moving point forward or backward between widgets by typing 'TAB' or 'S-TAB' skips over inactive widgets. The default value is nil. +** PHP-ts mode + +--- +*** 'php-ts-mode-run-php-webserver' now accepts a custom php.ini. +A new attribute, CONFIG, allows you to specify an custom php.ini. +By default it retains the previous behavior: prompt for HOSTNAME +and PORT only if their respective values are nil. +Interactively, when invoked with prefix argument, always prompt for +PORT, HOSTNAME, DOCUMENT-ROOT, ROUTER-SCRIPT, NUM-OF-WORKERS and CONFIG. + ** Ruby mode --- diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el index 3f89de14075..f8d240b746b 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -490,7 +490,7 @@ php-ts-mode--parent-html-bol (treesit-node-start parent) (defun php-ts-mode--parent-html-heuristic (node parent _bol &rest _) - "Returns position based on html indentation. + "Return position based on html indentation. Returns 0 if the NODE is after the , otherwise returns the indentation point of the last word before the NODE, plus the @@ -1469,8 +1469,12 @@ php-ts-mode ;;;###autoload -(defun php-ts-mode-run-php-webserver (&optional port hostname document-root -router-script num-of-workers) +(defun php-ts-mode-run-php-webserver (&optional port +hostname +document-root +router-script +num-of-workers +config) "Run PHP built-in web server. PORT: Port number of built-in web server, default `php-ts-mode-ws-port'. @@ -
bug#72966: 30.0.90; [PATCH] php-ts-mode: custom php.ini config for the built-in php webserver
In data domenica 8 settembre 2024 08:48:09 CEST, Eli Zaretskii ha scritto: > > From: Vincenzo Pupillo > > Cc: 72...@debbugs.gnu.org > > Date: Thu, 05 Sep 2024 21:16:29 +0200 > > > > Hi Eli, I followed your suggestion and moved the CONFIG argument. I also > > added a new entry to the NEWS file. > > Thanks, installed on the master branch, and closing the bug. > > Please in the future try to adhere to our conventions of leaving two > spaces between sentences (I fixed that in this patch). Thank you Eli. Vincenzo.
bug#72814: 31.0.50; Add a variable controlling doxygen support in C/C++/Java?
In data martedì 27 agosto 2024 14:22:16 CEST, Eli Zaretskii ha scritto: > > From: Yuan Fu > > Date: Mon, 26 Aug 2024 20:13:52 -0700 > > Cc: e...@gnu.org, > > > > vincenzo.pupi...@unimi.it > > > > Yuan Fu writes: > > > X-Debbugs-CC: e...@gnu.org <mailto:e...@gnu.org>, > > > vincenzo.pupi...@unimi.it > > > > > > Should we add a custom option that controls whether to enable doxygen > > > support in c-ts-mode/c++-ts-mode/java-ts-mode? > > > > > > Technically this isn’t a problem, since the doxygen support is only > > > enabled if there’s doxygen grammar on the system. But many people > > > (me) might install a grammar bundle that includes dozens of > > > grammars for convenience. Then the doxygen support would turn on when > > > the user doesn’t really intend to use it. > > > > > > I propose we add custom options like c-ts-mode-enable-doxygen and set it > > > to t by default, so the default behavior is still to enable doxygen > > > support when the grammar for it exists, but people who don’t want to pay > > > for it can turn it off by setting the option to nil. > > > > > > Yuan > > > > Eli, WDYT? > > I'm okay with such an option, but it should be careful to check > whether the corresponding grammar library is available, and offer a > user-friendly diagnostic if not. Try to take a look at this patch. Is it okay? Vincenzo >From 0a6d90f25dfddc1da88b5e47a97bc09fe50a6d34 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Mon, 9 Sep 2024 09:20:42 +0200 Subject: [PATCH] Add a user option to disable Doxygen syntax highlighting (bug#72814). Both 'c-ts-mode' and 'java-ts-mode' have a new user option, 'c-ts-mode-enable-doxygen' and 'java-ts-mode-enable-doxygen' (defaults to t) which allow to disable syntax highlighting of comment blocks based on the Doxygen grammar. * lisp/progmodes/c-ts-mode.el: Add the 'c-ts-mode-enable-doxygen' user option variable to disable doxygen grammar. (bug#72814) * lisp/progmodes/c-ts-mode.el (c-ts-mode, c++-ts-mode): Use the new 'c-ts-mode-enable-dodygen' option. * lisp/progmodes/java-ts-mode.el: Add the 'java-ts-mode-enable-doxygen' user option variable to disable doxygen grammar. (bug#72814) * lisp/progmodes/java-ts-mode.el (java-ts-mode): Use the new 'java-ts-mode-enable-dodygen' option. * etc/NEWS: Document the change. --- etc/NEWS | 16 lisp/progmodes/c-ts-mode.el| 71 -- lisp/progmodes/java-ts-mode.el | 35 +++-- 3 files changed, 83 insertions(+), 39 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index c6f8b0062e4..5762bc22c54 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -224,6 +224,22 @@ package of the current buffer. It is bound to 'C-c C-t p' in 'go-ts-mode'. The 'go-ts-mode-build-tags' user option is available to set a list of build tags for the test commands. +** C-ts mode + +*** New user option 'c-ts-mode-enable-doxygen'. +By default, 'c-ts-mode-enable-doxygen' is t, and doxygen comment blocks +are syntax-highlighted if the doxygen grammar is available. If Non-nil, +the comment blocks are highlighted like other comments. + +** Java-ts mode + +*** New user option 'java-ts-mode-enable-doxygen'. +By default, 'java-ts-mode-enable-doxygen' is t, and doxygen comment blocks +are syntax-highlighted if the doxygen grammar is available. If Non-nil, +the comment blocks are highlighted like other comments. + ** Emacs Lisp mode --- diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 7f23b30a88a..3adf5673e67 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -216,6 +216,17 @@ c-ts-mode-emacs-sources-support :safe 'booleanp :group 'c) +(defcustom c-ts-mode-enable-doxygen t + "Enable doxygen syntax highlighting. +If nil, disable doxygen based font lock for comment. +This needs to be set before enabling `c-ts-mode'; if you change +the value after enabling `c-ts-mode', toggle the mode off and on +again." + :version "31.1" + :type 'boolean + :safe 'booleanp + :group 'c) + ;;; Syntax table (defvar c-ts-mode--syntax-table @@ -1354,20 +1365,22 @@ c-ts-mode (treesit-font-lock-recompute-features '(emacs-devel))) ;; Inject doxygen parser for comment. - (when (treesit-ready-p 'doxygen t) -(setq-local treesit-primary-parser primary-parser) -(setq-local treesit-font-lock-settings -(append - treesit-font-lock-settings - c-ts-mode-doxygen-comment-font-lock-settings)) -
bug#72814: 31.0.50; Add a variable controlling doxygen support in C/C++/Java?
In data mercoledì 11 settembre 2024 06:53:32 CEST, Yuan Fu ha scritto: > > > On Sep 9, 2024, at 2:50 AM, Vincenzo Pupillo wrote: > > > > In data martedì 27 agosto 2024 14:22:16 CEST, Eli Zaretskii ha scritto: > >>> From: Yuan Fu > >>> Date: Mon, 26 Aug 2024 20:13:52 -0700 > >>> Cc: e...@gnu.org, > >>> > >>> vincenzo.pupi...@unimi.it > >>> > >>> Yuan Fu writes: > >>>> X-Debbugs-CC: e...@gnu.org <mailto:e...@gnu.org>, > >>>> vincenzo.pupi...@unimi.it > >>>> > >>>> Should we add a custom option that controls whether to enable doxygen > >>>> support in c-ts-mode/c++-ts-mode/java-ts-mode? > >>>> > >>>> Technically this isn’t a problem, since the doxygen support is only > >>>> enabled if there’s doxygen grammar on the system. But many people > >>>> (me) might install a grammar bundle that includes dozens of > >>>> grammars for convenience. Then the doxygen support would turn on when > >>>> the user doesn’t really intend to use it. > >>>> > >>>> I propose we add custom options like c-ts-mode-enable-doxygen and set it > >>>> to t by default, so the default behavior is still to enable doxygen > >>>> support when the grammar for it exists, but people who don’t want to pay > >>>> for it can turn it off by setting the option to nil. > >>>> > >>>> Yuan > >>> > >>> Eli, WDYT? > >> > >> I'm okay with such an option, but it should be careful to check > >> whether the corresponding grammar library is available, and offer a > >> user-friendly diagnostic if not. > > > > Try to take a look at this patch. Is it okay? > > > > Vincenzo > > <0001-Add-a-user-option-to-disable-Doxygen-syntax-highligh.patch> > > Thanks for taking this up! I won’t signal a warning if doxygen grammar isn’t > found. Imagine a user without doxygen grammar, and din’t change > c-ts-mode-enable-doxygen: they’ll get a warning whenever they open a C file. > We should either set c-ts-mode-enable-doxygen to nil by default, or not warn > when doxygen grammar doesn’t exist. Otherwise, the patch looks good to me. Okay, fine. But Eli said something different... What do we do? Vincenzo > > Yuan >