From: etay.meiri@gmail.com
To: help-gnu-emacs@gnu.org
Subject: Re: Toggling the same key combination between two options
Date: Thu, 11 Sep 2008 12:27:48 -0700 (PDT) [thread overview]
Message-ID: <b06bb580-2a87-4fc7-b2de-4bc296fe3aba@c65g2000hsa.googlegroups.com> (raw)
In-Reply-To: 87tzcmldy2.fsf@hubble.informatimago.com
Thanks a lot, Pascal.
The function you provided works well for the example with the F12.
However, when I go into gud-mode and hit F9 (which is configured using
(local-set-toggling-key (kbd "<f9>") 'gud-break 'gud-remove)) it tells
me that F9 is undefined. I tried changing 'local-set-key' to 'define-
key gud-mode-map' but it did not work.
Any idea?
Thanks,
-Etay
On Sep 11, 9:44 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> etay.me...@gmail.com writes:
> > Hi,
>
> > 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?
>
> (defun local-set-toggling-key (key cmd1 cmd2)
> (interactive "KSet key locally:
> CSet key %s locally to command:
> CToggling key %s locally to command: ")
> (let ((on (gensym))
> (off (gensym)))
> (setf (symbol-function on)
> `(lambda ()
> (interactive)
> (funcall ',cmd1)
> (local-set-key ',key ',off))
> (symbol-function off)
> `(lambda ()
> (interactive)
> (funcall ',cmd2)
> (local-set-key ',key ',on)))
> (local-set-key key on)))
>
> ;; To test:
> ;; (local-set-toggling-key (kbd "<f12>")
> ;; (lambda () (interactive) (insert "a"))
> ;; (lambda () (interactive) (insert "b")))
>
> (local-set-toggling-key (kbd "<f9>") 'gud-break 'gud-remove)
>
> --
> __Pascal Bourguignon__ http://www.informatimago.com/
>
> "A TRUE Klingon warrior does not comment his code!"
next prev parent reply other threads:[~2008-09-11 19:27 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 [this message]
2008-09-11 20:25 ` Scott Frazer
2008-09-12 14:23 ` Nick Roberts
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
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=b06bb580-2a87-4fc7-b2de-4bc296fe3aba@c65g2000hsa.googlegroups.com \
--to=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.
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).