unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: Gud keybindings
Date: Thu, 14 Aug 2014 23:13:02 +0200	[thread overview]
Message-ID: <874mxeixlt.fsf@debian.uxu> (raw)
In-Reply-To: mailman.7092.1407988122.1147.help-gnu-emacs@gnu.org

Yuri Khan <yuri.v.khan@gmail.com> writes:

> That would work but is inelegant. Here in C++ world,
> we don't pay for what we don't use — having each
> keypress of "s" check if Gud is active runs very much
> counter to that principle.

I think it is very fast both to setup and to use. Try
it yourself. Here, I've set it up globally - it would
be better to have it but for the desired modes. And
that can be automatized as well: you setup a defun to
do the changes, and then you send that defun a keymap
argument to specify what mode should be affected. Put a
bunch of those in a list and iterate it, sending the
elements to the defun one by one.

(defvar some-mode nil)
(setq some-mode t)

(global-set-key
 "s"
 (lambda () (interactive) (if some-mode (message "do mode thing")
                            (insert ?s) )))

(global-set-key "s" 'self-insert-command) ; reset

>> If it is, you can write a defun, we-are-debugging
>> which rebinds the keys, and correspondingly
>> no-bugs-left to reset. You can automatize this
>> second part like, if a non-debug key is pressed, it
>> is not only self-inserted, it also disables the
>> debugging keys.
>
> This equates to a global minor mode, doesn’t it?

The example I provided is a minor mode, yes, but you
don't need to do it like that. You can have a defun
that changes the keys (using the current map) and then
another defun that resets them. But - why not make it a
minor mode to get a lighter, proper documentation, and
all?

-- 
underground experts united


  parent reply	other threads:[~2014-08-14 21:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.7049.1407907858.1147.help-gnu-emacs@gnu.org>
2014-08-13 19:14 ` Gud keybindings Emanuel Berg
2014-08-14  3:48   ` Yuri Khan
     [not found]   ` <mailman.7092.1407988122.1147.help-gnu-emacs@gnu.org>
2014-08-14 21:13     ` Emanuel Berg [this message]
2014-08-13  5:30 Yuri Khan
2014-08-18  9:27 ` Yuri Khan
2014-08-19  1:49   ` Stefan Monnier
2014-08-19  5:03     ` Yuri Khan
     [not found] ` <mailman.7183.1408354083.1147.help-gnu-emacs@gnu.org>
2014-08-18 22:56   ` Emanuel Berg

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=874mxeixlt.fsf@debian.uxu \
    --to=embe8573@student.uu.se \
    --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).