From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#67928: 30.0.50; [PATCH] Load GDB history in gud-gdb Date: Wed, 20 Dec 2023 17:41:01 +0100 Message-ID: <87le9o968y.fsf@ledu-giraud.fr> References: <871qbh9h90.fsf@ledu-giraud.fr> <83le9pgg0p.fsf@gnu.org> <87sf3x7z3i.fsf@ledu-giraud.fr> <83h6kdgccu.fsf@gnu.org> Reply-To: Manuel Giraud Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39565"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67928@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 20 17:42:24 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rFzeJ-000A47-V6 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 20 Dec 2023 17:42:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFzdx-0007Zq-Tl; Wed, 20 Dec 2023 11:42:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFzdv-0007ZX-BK for bug-gnu-emacs@gnu.org; Wed, 20 Dec 2023 11:41:59 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFzdu-0004xp-OB for bug-gnu-emacs@gnu.org; Wed, 20 Dec 2023 11:41:59 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rFzdx-0003zB-PH for bug-gnu-emacs@gnu.org; Wed, 20 Dec 2023 11:42:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 20 Dec 2023 16:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67928 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 67928-submit@debbugs.gnu.org id=B67928.170309047415238 (code B ref 67928); Wed, 20 Dec 2023 16:42:01 +0000 Original-Received: (at 67928) by debbugs.gnu.org; 20 Dec 2023 16:41:14 +0000 Original-Received: from localhost ([127.0.0.1]:41685 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFzdB-0003xi-Qj for submit@debbugs.gnu.org; Wed, 20 Dec 2023 11:41:14 -0500 Original-Received: from ledu-giraud.fr ([51.159.28.247]:10398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFzd7-0003xW-34 for 67928@debbugs.gnu.org; Wed, 20 Dec 2023 11:41:12 -0500 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=xgnFoI5r a1IzWXg9wW3lM37JnIb0imC1d5XPqKycg8I=; h=date:references:in-reply-to: subject:cc:to:from; d=ledu-giraud.fr; b=YA9rRJyLz4IbzbtU0xtTWDWN9mlJzo w+058y7Hf7RipizmOnxP5wcGjpnqkwlR2on8oETy4ox6kuuEjANGvaBQ== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=xgnFoI5ra1IzWXg9 wW3lM37JnIb0imC1d5XPqKycg8I=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=dxZfz35YzKxnt4N9xHD4V8Z5Rrz+uk8+4/v2+y H2UO3Sr6bnIrdy6Z1cTQaExdgL2SFSVYup2PhwCj79bVCKVEthVEeh4e0Zxy0Rfa9loHoo 4p+Eh8DAyKoX0IWaRS/lLwDwKcKd79dHh6kC0ybxKBJngXFUJ2VdxqQvwvOxjhJa+f1Rx8 IffCKM5MLpyJaRfNW1y7AeYiZj3d5tNgKUNz7IuUXrHFp7pdT42Tvm9GfNeNPEqL8HmwYM qJQpBXJHxusTsjbpUwI8+jCFgeqVIjdL5I/jBvL3aUJBy/n3Fsiqt1RWhmfPvFQobsHGUO Su6YZFFhSPf3nxIcGiM3g3vA== Original-Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 82d7bfe8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 20 Dec 2023 17:41:03 +0100 (CET) In-Reply-To: <83h6kdgccu.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 20 Dec 2023 16:47:13 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:276575 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Function-to-load-GDB-history.patch >From 8de4866f59d88edbc480b1a150f7ceb9b5cd774b Mon Sep 17 00:00:00 2001 From: Manuel Giraud 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 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--