diff options
| author | Paul Nelson | 2025-04-21 22:14:53 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2025-04-26 16:21:21 +0300 |
| commit | f808f637f57eb0fe87fdc2ea7c2a1fd9e2f9d912 (patch) | |
| tree | dfc205cece55783c5cc415108f2ac289cc3898b7 | |
| parent | dd3429526aacef0aa98171a598a535a72b9cde39 (diff) | |
| download | emacs-f808f637f57eb0fe87fdc2ea7c2a1fd9e2f9d912.tar.gz emacs-f808f637f57eb0fe87fdc2ea7c2a1fd9e2f9d912.zip | |
Add "forward history" support for some debuggers
* lisp/progmodes/gud.el (gud-query-cmdline): Add an optional
default-list parameter to allow passing a list of "forward
history" suggestions to the minibuffer.
(perldb, pdb, guiler): Use buffer file name to suggest a default
debugging command via "forward history".
* doc/emacs/building.texi (Starting GUD): Document the new
feature.
(Bug#77989)
| -rw-r--r-- | doc/emacs/building.texi | 3 | ||||
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/progmodes/gud.el | 31 |
3 files changed, 36 insertions, 6 deletions
diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi index 02ca71f069b..39c5e79a870 100644 --- a/doc/emacs/building.texi +++ b/doc/emacs/building.texi | |||
| @@ -674,6 +674,9 @@ Run the SDB debugger. | |||
| 674 | using the minibuffer. The minibuffer's initial contents contain the | 674 | using the minibuffer. The minibuffer's initial contents contain the |
| 675 | standard executable name and options for the debugger, and sometimes | 675 | standard executable name and options for the debugger, and sometimes |
| 676 | also a guess for the name of the executable file you want to debug. | 676 | also a guess for the name of the executable file you want to debug. |
| 677 | For @code{pdb}, @code{perldb}, and @code{guiler}, if the current buffer | ||
| 678 | visits a file, pressing @kbd{M-n} (@code{next-history-element}) | ||
| 679 | in the prompt suggests a full command line including that file name. | ||
| 677 | Shell wildcards and variables are not allowed in this command line. | 680 | Shell wildcards and variables are not allowed in this command line. |
| 678 | Emacs assumes that the first command argument which does not start | 681 | Emacs assumes that the first command argument which does not start |
| 679 | with a @samp{-} is the executable file name. | 682 | with a @samp{-} is the executable file name. |
| @@ -1975,6 +1975,14 @@ normal file name starts with "file:", you can disable the URI | |||
| 1975 | recognition by invoking 'sqlite-open' with the new optional argument | 1975 | recognition by invoking 'sqlite-open' with the new optional argument |
| 1976 | DISABLE-URI non-nil. | 1976 | DISABLE-URI non-nil. |
| 1977 | 1977 | ||
| 1978 | ** GUD | ||
| 1979 | |||
| 1980 | --- | ||
| 1981 | *** pdb, perldb, and guiler suggest debugging the current file via 'M-n'. | ||
| 1982 | When starting these debuggers (e.g., 'M-x pdb') while visiting a file, | ||
| 1983 | pressing 'M-n' in the command prompt suggests a command line including | ||
| 1984 | the file name, using the minibuffer's "future history". | ||
| 1985 | |||
| 1978 | 1986 | ||
| 1979 | * New Modes and Packages in Emacs 31.1 | 1987 | * New Modes and Packages in Emacs 31.1 |
| 1980 | 1988 | ||
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 3cca55be3a7..7108673dddc 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el | |||
| @@ -757,7 +757,11 @@ The option \"--fullname\" must be included in this value." | |||
| 757 | :parent minibuffer-local-map | 757 | :parent minibuffer-local-map |
| 758 | "C-i" #'comint-dynamic-complete-filename) | 758 | "C-i" #'comint-dynamic-complete-filename) |
| 759 | 759 | ||
| 760 | (defun gud-query-cmdline (minor-mode &optional init) | 760 | (defun gud-query-cmdline (minor-mode &optional init default-list) |
| 761 | "Prompt for a command to run the debugger. | ||
| 762 | MINOR-MODE is the name of the debugger to run. INIT is the initial | ||
| 763 | command, before any history is available. DEFAULT-LIST is a list of | ||
| 764 | default commands, accessible via \\[next-history-element]." | ||
| 761 | (let* ((hist-sym (gud-symbol 'history nil minor-mode)) | 765 | (let* ((hist-sym (gud-symbol 'history nil minor-mode)) |
| 762 | (cmd-name (gud-val 'command-name minor-mode))) | 766 | (cmd-name (gud-val 'command-name minor-mode))) |
| 763 | (unless (boundp hist-sym) (set hist-sym nil)) | 767 | (unless (boundp hist-sym) (set hist-sym nil)) |
| @@ -780,7 +784,8 @@ The option \"--fullname\" must be included in this value." | |||
| 780 | (setq file f))) | 784 | (setq file f))) |
| 781 | file))))) | 785 | file))))) |
| 782 | gud-minibuffer-local-map nil | 786 | gud-minibuffer-local-map nil |
| 783 | hist-sym))) | 787 | hist-sym |
| 788 | default-list))) | ||
| 784 | 789 | ||
| 785 | (defvar gdb-first-prompt t) | 790 | (defvar gdb-first-prompt t) |
| 786 | 791 | ||
| @@ -1671,8 +1676,13 @@ Noninteractively, COMMAND-LINE should be on the form | |||
| 1671 | The directory containing the perl program becomes the initial | 1676 | The directory containing the perl program becomes the initial |
| 1672 | working directory and source-file directory for your debugger." | 1677 | working directory and source-file directory for your debugger." |
| 1673 | (interactive | 1678 | (interactive |
| 1674 | (list (gud-query-cmdline 'perldb | 1679 | (list |
| 1675 | (concat (or (buffer-file-name) "-E 0") " ")))) | 1680 | (gud-query-cmdline |
| 1681 | 'perldb | ||
| 1682 | (concat (or (buffer-file-name) "-E 0") " ") | ||
| 1683 | (when-let* ((file (buffer-file-name))) | ||
| 1684 | (list (concat gud-perldb-command-name " " | ||
| 1685 | (shell-quote-argument file) " ")))))) | ||
| 1676 | 1686 | ||
| 1677 | (gud-common-init command-line 'gud-perldb-massage-args | 1687 | (gud-common-init command-line 'gud-perldb-massage-args |
| 1678 | 'gud-perldb-marker-filter) | 1688 | 'gud-perldb-marker-filter) |
| @@ -1802,7 +1812,11 @@ If called interactively, the command line will be prompted for. | |||
| 1802 | The directory containing this file becomes the initial working | 1812 | The directory containing this file becomes the initial working |
| 1803 | directory and source-file directory for your debugger." | 1813 | directory and source-file directory for your debugger." |
| 1804 | (interactive | 1814 | (interactive |
| 1805 | (list (gud-query-cmdline 'pdb))) | 1815 | (list (gud-query-cmdline |
| 1816 | 'pdb nil | ||
| 1817 | (when-let* ((file (buffer-file-name))) | ||
| 1818 | (list (concat gud-pdb-command-name " " | ||
| 1819 | (shell-quote-argument file))))))) | ||
| 1806 | 1820 | ||
| 1807 | (gud-common-init command-line nil 'gud-pdb-marker-filter) | 1821 | (gud-common-init command-line nil 'gud-pdb-marker-filter) |
| 1808 | (setq-local gud-minor-mode 'pdb) | 1822 | (setq-local gud-minor-mode 'pdb) |
| @@ -1889,7 +1903,12 @@ This should be an executable on your path, or an absolute file name." | |||
| 1889 | The directory containing FILE becomes the initial working directory | 1903 | The directory containing FILE becomes the initial working directory |
| 1890 | and source-file directory for your debugger." | 1904 | and source-file directory for your debugger." |
| 1891 | (interactive | 1905 | (interactive |
| 1892 | (list (gud-query-cmdline 'guiler))) | 1906 | (list |
| 1907 | (gud-query-cmdline | ||
| 1908 | 'guiler nil | ||
| 1909 | (when-let* ((file (buffer-file-name))) | ||
| 1910 | (list (concat gud-guiler-command-name " " | ||
| 1911 | (shell-quote-argument file))))))) | ||
| 1893 | 1912 | ||
| 1894 | (gud-common-init command-line nil 'gud-guiler-marker-filter) | 1913 | (gud-common-init command-line nil 'gud-guiler-marker-filter) |
| 1895 | (setq-local gud-minor-mode 'guiler) | 1914 | (setq-local gud-minor-mode 'guiler) |