all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nick Roberts <nickrob@snap.net.nz>
To: etay.meiri@gmail.com
Cc: help-gnu-emacs@gnu.org
Subject: Re: Toggling the same key combination between two options
Date: Sat, 13 Sep 2008 02:23:28 +1200	[thread overview]
Message-ID: <18634.31584.699029.301395@kahikatea.snap.net.nz> (raw)
In-Reply-To: <d921ea22-aec5-45a1-b4d2-c7a5aa4d7734@t54g2000hsg.googlegroups.com>

 > I have F8 and F9 mapped to gud-remove and gud-break (respectively) in
 > gud-mode.
 > I'd like to mimic the behaviour of Visual Studio where F9 toggles
 > between setting and removing the breakpoint. Is it possible to
 > configure emacs so that it will toggle between the two bindings every
 > time the key is pressed?

Assuming that you're using Emacs 22.1 or later you can do this by clicking on
the fringe/margin using mouse-1 (gdb-mouse-set-clear-breakpoint).  If you
really want to use F9, e.g., from a console, you can adapt this function:


(define-key gud-minor-mode-map [f9] 'gdb-set-clear-breakpoint)

(defun gdb-set-clear-breakpoint ()
  (interactive)
  (if (or (buffer-file-name) (eq major-mode 'gdb-assembler-mode))
      (if (or 
	   (let ((start (- (line-beginning-position) 1))
		 (end (+ (line-end-position) 1)))
	     (catch 'breakpoint
	       (dolist (overlay (overlays-in start end))
		 (if (overlay-get overlay 'put-break)
		     (throw 'breakpoint t)))))
	   (eq (car (fringe-bitmaps-at-pos)) 'breakpoint))
	  (gud-remove nil)
	(gud-break nil))))

which will set or clear the breakpoint on the line at point (the location of
the active cursor).


-- 
Nick                                           http://www.inet.net.nz/~nickrob




  parent reply	other threads:[~2008-09-12 14:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-11 18:15 Toggling the same key combination between two options etay.meiri
2008-09-11 18:44 ` Pascal J. Bourguignon
2008-09-11 19:27   ` etay.meiri
2008-09-11 20:25   ` Scott Frazer
2008-09-12 14:23 ` Nick Roberts [this message]
2008-09-12 22:06 ` E.L.K.
2008-09-12 22:12   ` Lennart Borgman (gmail)
2008-09-12 22:53     ` gdb-toggle-breakpoint [was Re: Toggling the same key combination between two options] Nick Roberts
2008-09-12 23:09       ` Lennart Borgman (gmail)
2008-09-12 22:51   ` Toggling the same key combination between two options Nick Roberts

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18634.31584.699029.301395@kahikatea.snap.net.nz \
    --to=nickrob@snap.net.nz \
    --cc=etay.meiri@gmail.com \
    --cc=help-gnu-emacs@gnu.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.