From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 67928@debbugs.gnu.org
Subject: bug#67928: 30.0.50; [PATCH] Load GDB history in gud-gdb
Date: Wed, 20 Dec 2023 17:41:01 +0100 [thread overview]
Message-ID: <87le9o968y.fsf@ledu-giraud.fr> (raw)
In-Reply-To: <83h6kdgccu.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 20 Dec 2023 16:47:13 +0200")
[-- Attachment #1: Type: text/plain, Size: 367 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
[...]
>> I have set 'gdb-many-windows' to 't' but sometimes I like the simpler
>> version provided by gud-gdb... But yes, this reason is not sufficient.
>> Before closing this PR, could I modify this patch to, at least, isolate
>> history loading into its own function?
>
> Yes, that's fine.
Thanks. Here's this new version.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Function-to-load-GDB-history.patch --]
[-- Type: text/x-patch, Size: 3829 bytes --]
From 8de4866f59d88edbc480b1a150f7ceb9b5cd774b Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Wed, 20 Dec 2023 12:08:30 +0100
Subject: [PATCH] Function to load GDB history
* lisp/progmodes/gdb-mi.el (gud-gdb-load-history): New function to
load GDB history.
(gdb): Call it.
---
lisp/progmodes/gdb-mi.el | 66 +++++++++++++++++++++-------------------
1 file changed, 35 insertions(+), 31 deletions(-)
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 7ae4bcea1e1..cbb165a6a0c 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -817,6 +817,39 @@ gdb--check-interpreter
(defvar gdb-control-level 0)
+(defun gdb-load-history ()
+ (when (ring-empty-p comint-input-ring) ; cf shell-mode
+ (let ((hfile (expand-file-name (or (getenv "GDBHISTFILE")
+ (if (eq system-type 'ms-dos)
+ "_gdb_history"
+ ".gdb_history"))))
+ ;; gdb defaults to 256, but we'll default to comint-input-ring-size.
+ (hsize (getenv "HISTSIZE")))
+ (dolist (file (append '("~/.gdbinit")
+ (unless (string-equal (expand-file-name ".")
+ (expand-file-name "~"))
+ '(".gdbinit"))))
+ (if (file-readable-p (setq file (expand-file-name file)))
+ (with-temp-buffer
+ (insert-file-contents file)
+ ;; TODO? check for "set history save\\( *on\\)?" and do
+ ;; not use history otherwise?
+ (while (re-search-forward
+ "^ *set history \\(filename\\|size\\) *\\(.*\\)" nil t)
+ (cond ((string-equal (match-string 1) "filename")
+ (setq hfile (expand-file-name
+ (match-string 2)
+ (file-name-directory file))))
+ ((string-equal (match-string 1) "size")
+ (setq hsize (match-string 2))))))))
+ (and (stringp hsize)
+ (integerp (setq hsize (string-to-number hsize)))
+ (> hsize 0)
+ (setq-local comint-input-ring-size hsize))
+ (if (stringp hfile)
+ (setq-local comint-input-ring-file-name hfile))
+ (comint-read-input-ring t))))
+
;;;###autoload
(defun gdb (command-line)
"Run gdb passing it COMMAND-LINE as arguments.
@@ -902,37 +935,8 @@ gdb
(setq-local gud-minor-mode 'gdbmi)
(setq-local gdb-control-level 0)
(setq comint-input-sender 'gdb-send)
- (when (ring-empty-p comint-input-ring) ; cf shell-mode
- (let ((hfile (expand-file-name (or (getenv "GDBHISTFILE")
- (if (eq system-type 'ms-dos)
- "_gdb_history"
- ".gdb_history"))))
- ;; gdb defaults to 256, but we'll default to comint-input-ring-size.
- (hsize (getenv "HISTSIZE")))
- (dolist (file (append '("~/.gdbinit")
- (unless (string-equal (expand-file-name ".")
- (expand-file-name "~"))
- '(".gdbinit"))))
- (if (file-readable-p (setq file (expand-file-name file)))
- (with-temp-buffer
- (insert-file-contents file)
- ;; TODO? check for "set history save\\( *on\\)?" and do
- ;; not use history otherwise?
- (while (re-search-forward
- "^ *set history \\(filename\\|size\\) *\\(.*\\)" nil t)
- (cond ((string-equal (match-string 1) "filename")
- (setq hfile (expand-file-name
- (match-string 2)
- (file-name-directory file))))
- ((string-equal (match-string 1) "size")
- (setq hsize (match-string 2))))))))
- (and (stringp hsize)
- (integerp (setq hsize (string-to-number hsize)))
- (> hsize 0)
- (setq-local comint-input-ring-size hsize))
- (if (stringp hfile)
- (setq-local comint-input-ring-file-name hfile))
- (comint-read-input-ring t)))
+ (gdb-load-history)
+
(gud-def gud-tbreak "tbreak %f:%l" "\C-t"
"Set temporary breakpoint at current line." t)
(gud-def gud-jump
--
2.43.0
[-- Attachment #3: Type: text/plain, Size: 18 bytes --]
--
Manuel Giraud
next prev parent reply other threads:[~2023-12-20 16:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 12:43 bug#67928: 30.0.50; [PATCH] Load GDB history in gud-gdb Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-20 13:28 ` Eli Zaretskii
2023-12-20 14:00 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-20 14:47 ` Eli Zaretskii
2023-12-20 16:41 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-12-21 11:52 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87le9o968y.fsf@ledu-giraud.fr \
--to=bug-gnu-emacs@gnu.org \
--cc=67928@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=manuel@ledu-giraud.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).