--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
> I started working with Slime. One very useful function is
> slime-complete-symbol. But this is bound to M-TAB. A lot of operating
> systems use this for switch application. So the key binding will not
> work then. I tried to change it to C-TAB, but that did not work. In the
> source I saw that it was also bound to C-c C-i, but when using that I
> get C-TAB is undefined. What is the best way to change the key binding?
> Also: would it not be better to change the default key-binding?
Have you tried hitting C-c <tab> ? (rather than C-<tab>). This is what I
use here and (grepping through my emacs customisations) I don't think
I've changed the keybindings.
If you'd prefer something else, you probably want (untested) something
like
(add-hook
lisp-mode-hook
(lambda () (local-set-key (kbd "my-combo") 'slime-complete-symbol)))
Rupert
>> I started working with Slime. One very useful function is
>> slime-complete-symbol. But this is bound to M-TAB. A lot of operating
>> systems use this for switch application. So the key binding will not
>> work then. I tried to change it to C-TAB, but that did not work. In the
>> source I saw that it was also bound to C-c C-i, but when using that I
>> get C-TAB is undefined. What is the best way to change the key binding?
>> Also: would it not be better to change the default key-binding?
>
> Have you tried hitting C-c <tab> ? (rather than C-<tab>). This is what I
> use here and (grepping through my emacs customisations) I don't think
> I've changed the keybindings.
Same effect. Also tried C-c C-TAB. Also the same effect.
> If you'd prefer something else, you probably want (untested) something
> like
>
> (add-hook
> lisp-mode-hook
> (lambda () (local-set-key (kbd "my-combo") 'slime-complete-symbol)))
Does this not bind to too much?
It looks like key bindings with TAB have a problem on my system. I bound
it now also to C-c C-t and when I query this combination with C-h k C-c
C-t, I get:
C-c C-t runs the command slime-complete-symbol
which is an interactive Lisp function in `slime.el'.
It is bound to C-TAB, C-c C-TAB, C-c C-t, C-M-TAB.
(slime-complete-symbol)
Complete the symbol at point.
But when I ask about the TAB combinations, I get that they are not
defined. A 'little' weird.
Windowing systems have a tendency to steal a frightening number of key
bindings. Who knows what they'll take next? TAB and M-TAB have been
standard bindings in Emacs for completion for longer than most windowing
systems have existed, and it seems a bit counterproductive for Emacs to
dance round the window managers of any particular decade.
How about using ESC TAB (two separate keypresses) instead? If it bothers
you very greatly (it probably doesn't), you might be able to use a leaner
window manager, or even better a straight text terminal, where this and
many other annoyances simply don't happen.
> I tried to change it to C-TAB, but that did not work.
If you say exactly what you tried and precisely how it "did not work", we
might be able to make it work.
> In the source I saw that it was also bound to C-c C-i, but when using
> that I get C-TAB is undefined. What is the best way to change the key
> binding?
With `define-key' in your .emacs.
> Also: would it not be better to change the default key-binding?
See above.
--
Alan Mackenzie (Nuremberg, Germany).
Hi Rupert!
>> In the source I saw that it was also bound to C-c C-i, but when using
>> that I get C-TAB is undefined. [...]
>
> Have you tried hitting C-c <tab> ? (rather than C-<tab>).
In Emacs, `C-i' *is* TAB, and `C-m' *is* RET. ;-)
Bye,
Tassilo
Hi Cecil,
> I started working with Slime. One very useful function is
> slime-complete-symbol. But this is bound to M-TAB. A lot of
> operating systems use this for switch application.
Depending on you OS and your window manager, you may be possible to
change that. I configured my WM to use only bindings starting with the
Super-key (the windows key), so that they don't interfer with emacs.
Bye,
Tassilo
>> I started working with Slime. One very useful function is
>> slime-complete-symbol. But this is bound to M-TAB. A lot of operating
>> systems use this for switch application. So the key binding will not
>> work then.
>
> Windowing systems have a tendency to steal a frightening number of key
> bindings. Who knows what they'll take next? TAB and M-TAB have been
> standard bindings in Emacs for completion for longer than most windowing
> systems have existed, and it seems a bit counterproductive for Emacs to
> dance round the window managers of any particular decade.
That is a good point. And because in Emacs it is very easy to change
your bindings, I have defined:
(add-hook 'slime-mode-hook
(lambda () (local-set-key (kbd "C-c C-t") 'slime-complete-symbol)))
Maybe it is not the best key binding. I choose t because that is the
first letter of TAB. ;-) When someone has a better idea ...
By the way, just TAB is not a problem. For example when editing a lisp
file TAB just does the expansion as it should do.
> How about using ESC TAB (two separate keypresses) instead?
That wants to execute complete-symbol. Maybe the documentation of Slime
is wrong, or I did something to break Slime. I have to look into that.
> If it bothers you very greatly (it probably doesn't),
Not very much, no.
>> I tried to change it to C-TAB, but that did not work.
>
> If you say exactly what you tried and precisely how it "did not work", we
> might be able to make it work.
In slime-repl.el in slime-define-keys slime-repl-mode-map there is the
line:
("\M-\t" 'slime-complete-symbol)
I changed that to:
("\C-\t" 'slime-complete-symbol)
but that did properly not work because Emacs does not get it.
>> that I get C-TAB is undefined. What is the best way to change the key
>> binding?
>
> With `define-key' in your .emacs.
I did it with the above mentioned add-hook.
>> Also: would it not be better to change the default key-binding?
>
> See above.
I understand.
>> I started working with Slime. One very useful function is
>> slime-complete-symbol. But this is bound to M-TAB. A lot of
>> operating systems use this for switch application.
>
> Depending on you OS and your window manager, you may be possible to
> change that. I configured my WM to use only bindings starting with the
> Super-key (the windows key), so that they don't interfer with emacs.
That is something to look into. I have had a similar problem with Ctrl +
function key. On the other hand Ctrl + function key is very handy for
changing virtual desktop. (Linux with KDE) I'll let it sink a little.
> That is a good point. And because in Emacs it is very easy to change
> your bindings, I have defined:
> (add-hook 'slime-mode-hook
> (lambda () (local-set-key (kbd "C-c C-t")
> 'slime-complete-symbol)))
That does not work. What is the good way to define this?
>> That is a good point. And because in Emacs it is very easy to change
>> your bindings, I have defined:
>> (add-hook 'slime-mode-hook
>> (lambda () (local-set-key (kbd "C-c C-t")
>> 'slime-complete-symbol)))
>
> That does not work. What is the good way to define this?
I understood things wrong. In the buffer where I am editing a CL file
C-c Tab does what it should do. (So I do not need the C-c C-t stuff.)
But I want it also to work in my *inferior-lisp* buffer. (That is where
I until now was trying to do it.) Is this possible, or do I want to
much?
> Windowing systems have a tendency to steal a frightening number of key
> bindings. Who knows what they'll take next?
Don't let them. Most sensible window managers let you choose
the "action" key; I set mine to be that otherwise
useless key, the one with the pretty "Windows" icon on it.
I look forward to the day when I'm able to buy a keyboard(*) which doesn't
propangandize for a convicted monopolist. I'd also like a pony.
--ap
(*) I use a unicomp Model-M clone keyboard, for its excellent tactile
feed. Please don't bother recommending replacement keyboards. :-)
>>> In the source I saw that it was also bound to C-c C-i, but when using
>>> that I get C-TAB is undefined. [...]
>>
>> Have you tried hitting C-c <tab> ? (rather than C-<tab>).
>
> In Emacs, `C-i' *is* TAB, and `C-m' *is* RET. ;-)
Yes, sorry I meant C-i or <tab>, rather than C-<tab>. Under X11, at
least, these seem to be two different keys.
Rupert
So you need to find a dedicated button for it.
"Caps lock" is one of possibilities, it is easy to use it on most keyboards,
but "caps lock" is usually intercepted by OS, and changing that on each
system you use might be annoying.
I've found that F12 is a good button for symbol completion.
It is not used by Emacs or OS, and it is easy to trigger.
It is a good idea to have same binding both in lisp buffers and in repl:
(add-hook 'slime-mode-hook
'(lambda ()
(define-key slime-mode-map [f12] 'slime-complete-symbol)))
(add-hook 'slime-repl-mode-hook
'(lambda ()
(define-key slime-repl-mode-map [f12] 'slime-complete-symbol)))
HTH
>>> That is a good point. And because in Emacs it is very easy to change
>>> your bindings, I have defined:
>>> (add-hook 'slime-mode-hook
>>> (lambda () (local-set-key (kbd "C-c C-t")
>>> 'slime-complete-symbol)))
>>
>> That does not work. What is the good way to define this?
>
> I understood things wrong. In the buffer where I am editing a CL file
> C-c Tab does what it should do. (So I do not need the C-c C-t stuff.)
> But I want it also to work in my *inferior-lisp* buffer. (That is where
> I until now was trying to do it.) Is this possible, or do I want to
> much?
Hm, in inferior lisp or slime repl? Anyway, there are
inferior-lisp-mode-hook and slime-repl-mode-hook, where you could add
your snippet like you already did in slime-mode-hook.
Bye,
Tassilo
>> I understood things wrong. In the buffer where I am editing a CL file
>> C-c Tab does what it should do. (So I do not need the C-c C-t stuff.)
>> But I want it also to work in my *inferior-lisp* buffer. (That is where
>> I until now was trying to do it.) Is this possible, or do I want to
>> much?
>
> Hm, in inferior lisp or slime repl? Anyway, there are
> inferior-lisp-mode-hook and slime-repl-mode-hook, where you could add
> your snippet like you already did in slime-mode-hook.
The *inferior-lip* buffer is the repl. But here TAB is bound to
slime-indent-and-complete-symbol and that does what I want. So problem solved.
> Symbol completion is frequently used feature, so it would suck if
> it requires two key presses.
>
> So you need to find a dedicated button for it.
>
> "Caps lock" is one of possibilities, it is easy to use it on most keyboards,
> but "caps lock" is usually intercepted by OS, and changing that on each
> system you use might be annoying.
>
> I've found that F12 is a good button for symbol completion.
> It is not used by Emacs or OS, and it is easy to trigger.
I do not find C-c TAB a big problem. It is not really more work as going
for a function key. And in the repl buffer TAB is bound to
slime-indent-and-complete-symbol and this is good enough for me.
But thanks anyway for the suggestion.
You might prefer using the slime-repl over the *inferior-lisp*
buffer. It's a lot more integrated with slime and has a lot of fancy
features. Try loading the slime-repl contrib (or slime-fancy, which loads a lot
of other goodies too) and see if you prefer it.
Cheers,
drewc
Sure, it is not a big problem, it is just a matter of convenience. I've
found
that having single key for both I can type code using completions in
a totally automatic, mechanical way -- I switch between code editor
and REPL pretty often, and difference in keybindings is sort of distracting.
Maybe I could get it automatic with default TAB completion, but that would
take much more time, I think.
Having a single key instead of combo reduces hand strain, which also
helps having less distractions.
> Tassilo Horn <tas...@member.fsf.org> writes:
>
>>> I understood things wrong. In the buffer where I am editing a CL file
>>> C-c Tab does what it should do. (So I do not need the C-c C-t stuff.)
>>> But I want it also to work in my *inferior-lisp* buffer. (That is where
>>> I until now was trying to do it.) Is this possible, or do I want to
>>> much?
>>
>> Hm, in inferior lisp or slime repl? Anyway, there are
>> inferior-lisp-mode-hook and slime-repl-mode-hook, where you could add
>> your snippet like you already did in slime-mode-hook.
>
> The *inferior-lip* buffer is the repl. But here TAB is bound to
> slime-indent-and-complete-symbol and that does what I want. So problem solved.
Just to clarify a little.
SLIME uses both inferior-lisp AND slime-repl buffers. However, what you
get depends a little on how you have SLIME setup.
When you run slime, there is a command called slime-setup. If you just
have
(slime-setup)
in your .emacs config, you only get the inferior-lisp buffer for direct
interaction with the inferior lisp process. However, slime also has
slime-repl, which is a repl written in emacs lisp. This repl, if
loaded, interacts with the inferior-lisp process, but gives you a higher
level abstraction. If your running slime-repl, you don't interact
directly with lisp via the inferior-lisp repl/buffer. To enable this
repl, you have to put
(slime-setup '(slime-repl))
Note also that slime comes with a 'meta' level configuration, which
automatically loads some of the contrib packages, such as slime-repl,
called slime-fancy. It also adds some of the other 'popular' contribb
modules. to load this, you would put
(slime-setup '(slime-fancy))
in your .emacs.
I mention all of this because the way you customize key bindings will
depend on your ocnfiguration. If your just running (slime-setup) with no
additional contrib modules, you will need to use hooks for inferior-lisp
to get the changes in the lisp repl. However, if your running either
(slime-setup '(slime-repl)) or (slime-setup '(slime-fancy)), you will
need to set your key bindings using the slime-repl hook. For source
code, you need to set key bindings using the slime-mode-hook, as
slime-mode is the mode used for source code buffers when editing a file
of lisp code.
My advice is
1. Start with just (slime-setup) and ensure that is working. don't worry
about key bindings, just ensure it works OK. Once all seems fine, change
your config to be
(slime-setup '(slime-fancy))
and check that works correctly. At this point, start looking at various
key binding tweaks. Note that its when you start loadiing some of the
contrib modules, you really begin to see the power/benefits of SLIME
over other emacs lisp interfaces, such as the older ilisp package. As
you become more familiar with common lisp and you begin to use/need the
more advanced features, such as the slime inspector, profiler,
cross-referencing, etc, you can start looking at loading some of the
other contrib packages. However, its not worth loading some of these
other packages until your at a point where both your CL and meacs
experience and the type of code your writing is advanced enough to
benefit from the more advanced features. Loading them before they are
needed are likely to complicate and confuse matters before necessary.
HTH
Tim
--
tcross (at) rapttech dot com dot au
> Cecil Westerhof <Ce...@decebal.nl> writes:
>> Tassilo Horn <tas...@member.fsf.org> writes:
>>
>>> Hm, in inferior lisp or slime repl? Anyway, there are
>>> inferior-lisp-mode-hook and slime-repl-mode-hook, where you could add
>>> your snippet like you already did in slime-mode-hook.
>>
>> The *inferior-lip* buffer is the repl. But here TAB is bound to
>> slime-indent-and-complete-symbol and that does what I want. So problem
>> solved.
>
> You might prefer using the slime-repl over the *inferior-lisp*
They are not the same? In *inferior-lisp* there is a repl. I'll look
into it.
> buffer. It's a lot more integrated with slime and has a lot of fancy
> features. Try loading the slime-repl contrib (or slime-fancy, which loads a lot
> of other goodies too) and see if you prefer it.
I'll try them out.
Hi Cecil,
>>> The *inferior-lip* buffer is the repl. But here TAB is bound to
>>> slime-indent-and-complete-symbol and that does what I want. So
>>> problem solved.
>>
>> You might prefer using the slime-repl over the *inferior-lisp*
>
> They are not the same? In *inferior-lisp* there is a repl. I'll look
> into it.
Yes, both are the repl. But the slime repl is more enhanced, and better
integrated with slime. Just try it.
Bye,
Tassilo
My preferred method is to enable tabkey2-mode (M-x tabkey2-mode) which
enables 'chaining' of completion functions after the appropriate
indent operation.
By default in a lisp buffer, tabkey2 will invoke dabbrev-expand on the
second press of the tab key, but you can customize the value of
tabkey2-completion-functions and have it invoke slime-complete-symbol
instead.
I find this works well: I can type a couple of characters of a symbol
name following a ( and hit tab twice, giving me correct indentation
and the complete symbol name (or most of it)
Matt