From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: Gud keybindings Date: Thu, 14 Aug 2014 23:13:02 +0200 Organization: Aioe.org NNTP Server Message-ID: <874mxeixlt.fsf@debian.uxu> References: <87ha1gtd6n.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1408050929 28168 80.91.229.3 (14 Aug 2014 21:15:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Aug 2014 21:15:29 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 14 23:15:22 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XI2Mj-0002ux-Rk for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Aug 2014 23:15:21 +0200 Original-Received: from localhost ([::1]:56488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XI2Mi-0005n2-Rt for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Aug 2014 17:15:20 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 44 Original-NNTP-Posting-Host: SIvZRMPqRkkTHAHL6NkRuw.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:NA42j/+KNtO3SoWhwReMgliolqg= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:206941 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:99217 Archived-At: Yuri Khan 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