[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Toggling the same key combination between two options
From: |
Nick Roberts |
Subject: |
Re: Toggling the same key combination between two options |
Date: |
Sat, 13 Sep 2008 02:23:28 +1200 |
> 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