From: Masatake YAMATO <jet@gyve.org>
Subject: gdb <-> .gdbinit
Date: Fri, 01 Aug 2003 12:21:59 +0900 (JST) [thread overview]
Message-ID: <20030801.122159.107253677.jet@gyve.org> (raw)
You may want to open/select .gdbinit from gdb(buffer created by M-x gdb) quickly.
After editing .gdbinit you may also want to select gdb buffer quickly.
With following patch, you can move between .gdbinit buffer and gdb quickly with
C-cC-v.
2003-08-01 Masatake YAMATO <jet@gyve.org>
* progmodes/gud.el (gdb-script-select-associated-gud-buffer): New function.
(gud-gdb-find-script): New function.
(gdb): bind "\C-c\C-v" to gud-gdb-find-script in local key map.
(gdb-script-associated-gud-buffer): New variable.
(gdb-script-mode): make gdb-script-associated-gud-buffer buffer local.
bind "\C-c\C-v" to gdb-script-select-associated-gud-buffer in
gdb-script-mode-map.
cvs diff: warning: unrecognized response `access control disabled, clients can connect from any host' from cvs server
Warning: Remote host denied X11 forwarding.
Index: lisp/progmodes/gud.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/gud.el,v
retrieving revision 1.4
diff -u -r1.4 gud.el
--- lisp/progmodes/gud.el 28 Jul 2003 06:27:09 -0000 1.4
+++ lisp/progmodes/gud.el 31 Jul 2003 09:19:53 -0000
@@ -486,6 +486,7 @@
(gud-def gud-run "run" nil "Run the program.")
(local-set-key "\C-i" 'gud-gdb-complete-command)
+ (local-set-key "\C-c\C-v" 'gud-gdb-find-script)
(setq comint-prompt-regexp "^(.*gdb[+]?) *")
(setq paragraph-start comint-prompt-regexp)
(run-hooks 'gdb-mode-hook)
@@ -2883,6 +2884,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; GDB script mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defvar gdb-script-associated-gud-buffer nil
+ "Gud buffer selected before gdb script buffer is selected.
+Used in `gdb-script-select-associated-gud-buffer' and `gud-gdb-find-script'.")
(defvar gdb-script-mode-syntax-table
(let ((st (make-syntax-table)))
@@ -2954,6 +2958,35 @@
(save-excursion (indent-line-to indent))
(indent-line-to indent)))))
+(defun gud-gdb-find-script (homedir)
+ "Open .gdbinit file.
+With a prefix argument HOMEDIR, .gdbinit under the home directory is open.
+Without a prefix argument, .gdbinit under the current directory is open."
+ (interactive "P")
+ (setq gdb-script-associated-gud-buffer (let ((buffer (current-buffer)))
+ (if homedir
+ (find-file "~/.gdbinit")
+ (find-file "./.gdbinit"))
+ buffer)))
+
+(defun gdb-script-select-associated-gud-buffer ()
+ "Select gud buffer selected before gdb script buffer is selected.
+Buffer specified by`gdb-script-associated-gud-buffer' is selected.
+`gdb-script-associated-gud-buffer' is set by `gud-gdb-find-script'.
+If `gdb-script-associated-gud-buffer' is nil, gdb is launched after asking user."
+ (interactive)
+ (if (and gdb-script-associated-gud-buffer (buffer-live-p gdb-script-associated-gud-buffer))
+ (switch-to-buffer gdb-script-associated-gud-buffer)
+ (when (y-or-n-p "No associated gud buffer for this buffer. Run gdb? ")
+ (let ((script-buffer (current-buffer))
+ gud-buffer)
+ (call-interactively 'gdb)
+ (setq gud-buffer (current-buffer))
+ (save-excursion
+ (set-buffer script-buffer)
+ (setq gdb-script-associated-gud-buffer gud-buffer))))))
+
+
;;;###autoload
(add-to-list 'auto-mode-alist '("/\\.gdbinit" . gdb-script-mode))
@@ -2971,7 +3004,9 @@
(font-lock-syntactic-keywords
. gdb-script-font-lock-syntactic-keywords)
(font-lock-syntactic-face-function
- . gdb-script-font-lock-syntactic-face))))
+ . gdb-script-font-lock-syntactic-face)))
+ (make-local-variable 'gdb-script-associated-gud-buffer)
+ (define-key gdb-script-mode-map "\C-c\C-v" 'gdb-script-select-associated-gud-buffer))
(provide 'gud)
next reply other threads:[~2003-08-01 3:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-01 3:21 Masatake YAMATO [this message]
2003-07-31 17:43 ` gdb <-> .gdbinit Nick Roberts
2003-08-02 4:46 ` Richard Stallman
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=20030801.122159.107253677.jet@gyve.org \
--to=jet@gyve.org \
/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).