* managing my keybindings
@ 2010-05-08 0:38 LanX
2010-05-08 2:09 ` Lennart Borgman
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: LanX @ 2010-05-08 0:38 UTC (permalink / raw)
To: help-gnu-emacs
Hi
I'm looking for suggestions how to manage my keybindings.
I would like to:
a) list them (only *my* keybindings)
b) easily navigate to the place where they are defined
c) attach documentation to them
d) warn me about conflicts
my first idea is to create wrapper functions/macros `my-global-set-
key' and `my-local-set-key' which buffer the necessary informations
when defining the bindings.
But chances are high that I'm reinventing the wheel, so please gimme
some ideas! 8)
Cheers
Rolf
PS: another "brute force" approach would be creating an extra
function starting with "mykey-" for every keybinding. I could list
them by this naming convention and navigate to the files ... well not
too elegant...
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: managing my keybindings
2010-05-08 0:38 managing my keybindings LanX
@ 2010-05-08 2:09 ` Lennart Borgman
2010-05-08 12:22 ` LanX
[not found] ` <mailman.0.1273284589.603.help-gnu-emacs@gnu.org>
2010-05-09 18:21 ` LanX
2 siblings, 1 reply; 9+ messages in thread
From: Lennart Borgman @ 2010-05-08 2:09 UTC (permalink / raw)
To: LanX; +Cc: help-gnu-emacs
On Sat, May 8, 2010 at 2:38 AM, LanX <lanx.perl@googlemail.com> wrote:
> Hi
>
> I'm looking for suggestions how to manage my keybindings.
>
> I would like to:
>
> a) list them (only *my* keybindings)
Use define-minor-mode and make a global minor mode. Define your key
bindings there.
> b) easily navigate to the place where they are defined
Define them in one place.
> c) attach documentation to them
Documentation are bound to functions, not key bindings. (You can add
comments where you bind the keys, of course.)
> d) warn me about conflicts
Use what is said in "Key binding conventions", see
M-: (info "(elisp) Key binding conventions")
> my first idea is to create wrapper functions/macros `my-global-set-
> key' and `my-local-set-key' which buffer the necessary informations
> when defining the bindings.
>
> But chances are high that I'm reinventing the wheel, so please gimme
> some ideas! 8)
>
> Cheers
> Rolf
>
> PS: another "brute force" approach would be creating an extra
> function starting with "mykey-" for every keybinding. I could list
> them by this naming convention and navigate to the files ... well not
> too elegant...
>
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <mailman.0.1273284589.603.help-gnu-emacs@gnu.org>]
* Re: managing my keybindings
[not found] ` <mailman.0.1273284589.603.help-gnu-emacs@gnu.org>
@ 2010-05-09 11:29 ` Andreas Politz
2010-05-09 11:55 ` Lennart Borgman
0 siblings, 1 reply; 9+ messages in thread
From: Andreas Politz @ 2010-05-09 11:29 UTC (permalink / raw)
To: help-gnu-emacs
Lennart Borgman <lennart.borgman@gmail.com> writes:
> On Sat, May 8, 2010 at 2:38 AM, LanX <lanx.perl@googlemail.com> wrote:
>> Hi
>>
>> I'm looking for suggestions how to manage my keybindings.
>>
>> I would like to:
>>
>> a) list them (only *my* keybindings)
>
> Use define-minor-mode and make a global minor mode. Define your key
> bindings there.
>
That's a good idea, but how do we assert, this modes map stays
at the top of minor-mode-map-alist ?
-ap
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: managing my keybindings
2010-05-09 11:29 ` Andreas Politz
@ 2010-05-09 11:55 ` Lennart Borgman
0 siblings, 0 replies; 9+ messages in thread
From: Lennart Borgman @ 2010-05-09 11:55 UTC (permalink / raw)
To: Andreas Politz; +Cc: help-gnu-emacs
On Sun, May 9, 2010 at 1:29 PM, Andreas Politz <politza@fh-trier.de> wrote:
> Lennart Borgman <lennart.borgman@gmail.com> writes:
>
>> On Sat, May 8, 2010 at 2:38 AM, LanX <lanx.perl@googlemail.com> wrote:
>>> Hi
>>>
>>> I'm looking for suggestions how to manage my keybindings.
>>>
>>> I would like to:
>>>
>>> a) list them (only *my* keybindings)
>>
>> Use define-minor-mode and make a global minor mode. Define your key
>> bindings there.
>>
>
> That's a good idea, but how do we assert, this modes map stays
> at the top of minor-mode-map-alist ?
That is a bit harder, but you can use the tool "Rebind My Choosen
Keys" (ie rebind-keys-mode) in nXhtml for that.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: managing my keybindings
2010-05-08 0:38 managing my keybindings LanX
2010-05-08 2:09 ` Lennart Borgman
[not found] ` <mailman.0.1273284589.603.help-gnu-emacs@gnu.org>
@ 2010-05-09 18:21 ` LanX
2010-05-09 19:12 ` LanX
2 siblings, 1 reply; 9+ messages in thread
From: LanX @ 2010-05-09 18:21 UTC (permalink / raw)
To: help-gnu-emacs
Hi
I found this approach using aliases
in a config file tst.el I write
---------------------------
(defalias 'my-comment-indent 'comment-indent "DOCUMENTATION")
(local-set-key "#" 'my-comment-indent)
----------------------------
C-h k # will show me now
-----------------------------
# runs the command my-comment-indent, which is an alias for `comment-
indent' in
`tst.el'.
It is bound to #.
(my-comment-indent &optional CONTINUE)
DOCUMENTATION
------------------------------
Now in "C-h m" and "C-h b" I will be able to identify my bindings
because of the leading "my-".
Creating a hs-minor-mode would be sufficient for hiding the rest.
What I'm struggling with is the best way to create a defmacro/defun
called "mine" such that I can automate the aliasing and can write
something like
(local-set-key "#" (mine 'comment-indent) )
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: managing my keybindings
2010-05-09 18:21 ` LanX
@ 2010-05-09 19:12 ` LanX
2010-05-10 14:10 ` Stefan Monnier
0 siblings, 1 reply; 9+ messages in thread
From: LanX @ 2010-05-09 19:12 UTC (permalink / raw)
To: help-gnu-emacs
WORKS! :)
-----------------------------
(defun mine (func comment) ""
(let (my-func)
(setq my-func (intern (concat "my-" (symbol-name func))))
(defalias my-func func comment)
my-func
)
)
(local-set-key (kbd "M-a") (mine 'mark-whole-buffer "optional Comment
for Binding"))
(describe-key (kbd "M-a"))
--------------------------
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: managing my keybindings
2010-05-09 19:12 ` LanX
@ 2010-05-10 14:10 ` Stefan Monnier
2010-05-10 14:25 ` LanX
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2010-05-10 14:10 UTC (permalink / raw)
To: help-gnu-emacs
> (let (my-func)
> (setq my-func (intern (concat "my-" (symbol-name func))))
This is kind of like:
int my-func = 0;
my-func = <somethingelse>;
except that Elisp's semantics make it harder for the (byte-)compiler to
eliminate the redundant initialization.
A generally good rule of thumb is "setq (aka assignment) is bad for your
karma". So just write:
(let ((my-func (intern (concat "my-" (symbol-name func)))))
-- Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: managing my keybindings
2010-05-10 14:10 ` Stefan Monnier
@ 2010-05-10 14:25 ` LanX
0 siblings, 0 replies; 9+ messages in thread
From: LanX @ 2010-05-10 14:25 UTC (permalink / raw)
To: help-gnu-emacs
> A generally good rule of thumb is "setq (aka assignment) is bad for your
> karma". So just write:
>
> (let ((my-func (intern (concat "my-" (symbol-name func)))))
>
> -- Stefan
Thanks Stefan!
Actually I tried this more than once, but was stuck in error message
"Attempt to set a constant symbol: nil"
Now I realize that I just forgot one level of parens. :(
(Anyway I knew posting ugly code provokes a fast response ;-)
Cheers
Rolf
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-05-10 14:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-08 0:38 managing my keybindings LanX
2010-05-08 2:09 ` Lennart Borgman
2010-05-08 12:22 ` LanX
[not found] ` <mailman.0.1273284589.603.help-gnu-emacs@gnu.org>
2010-05-09 11:29 ` Andreas Politz
2010-05-09 11:55 ` Lennart Borgman
2010-05-09 18:21 ` LanX
2010-05-09 19:12 ` LanX
2010-05-10 14:10 ` Stefan Monnier
2010-05-10 14:25 ` LanX
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.