Key bindings do not work in emacs scheme mode - emacs

I am following the guide here for emacs lisp interface.
C-c q is supposed to quit scheme mode. However this shows C-c q is undefined error. Typing (exit) on REPL works fine. Why is this key not bound in my emacs?

I see "Note that in any given implementation, only a subset of the following keys is available", but more importantly I don't believe that documentation is talking about Emacs bindings.
My impression is that those are the bindings recognised by the REPL if you were to run it outside of Emacs.
Inside Emacs you possibly need a prefix to say "send the next sequence to the REPL". e.g. in Emacs' term you have to type C-c C-c instead of just C-c to send an interrupt to the terminal. However as it's not listed in the other page which listed interrupts in Emacs, I suspect there actually isn't an equivalent binding. Or at least not by default.

Related

How to use terminal keyboard shortcuts inside emacs multi-term

I know there's some questions that are kind of related to this already, and I know you can do stuff like
(defun term-send-esc ()
"Send ESC in term mode."
(interactive)
(term-send-raw-string "\e"))
but it would be very convenient if there was kind of a univerisal override keybinding. For example, I just ssh:ed into a remote server and tried to nano a file and couldn't figure out how to exit because Ctl-x listens for emacs bindings. Is there such a thing?
There are two term sub modes, term-char-mode (C-x C-k) and term-line-mode (C-x C-j). Char mode is closer to a terminal, line mode is closer to a regular buffer. IIRC, multiterm starts in char mode, but it rebinds some keys to make it more Emacs-like. Look at the keys that multiterm rebinds; it has some alists that are used to modify the existing term-mode keymaps instead of using its own keymap. Or use sane-term, which is not much more than some commands to create new term buffers (no mucking with key bindings).
Ctl-x listens for emacs bindings.
Not in the default term-char-mode it doesn't, so your problem is most likely with your own config.
Run a terminal in emacs -Q to confirm the standard behaviour.

Slime Autocompletion when editing file

I am new to Lisp. I installed LIsp in a box to learn Common Lisp. In the slime-repl I can use autocompletion using the tab key. However I want to do so in other buffers - files - I edit. For instance I want to do the following:
C-x b ;; Here I switch to the buffer corresponding to my file. S I am not in the repl anymore.
(remove-i ;; Here I use the tab key, but nothing occurs.
In the repl buffer, I can type (remove-i and I will see matching functions such as remove-if and remove-if-not.
How can I add lisp autocompletion while editing any other file?
C-M-i (translated from <M-tab>) runs the command slime-complete-symbol (found
in slime-mode-indirect-map), which is an interactive compiled Lisp function in
‘slime.el’.
It is bound to C-c TAB, C-M-i, <menu-bar> <SLIME> <Complete Symbol>.
(slime-complete-symbol)
Complete the symbol at point.
Completion is performed by ‘slime-completion-at-point-functions’.
You can bind this function to TAB, if you want.
Peter

Emacs - Can't map C-[

I'm trying to map C-[ in Emacs to do the same as C-g. I tried this:
(global-set-key "\C-[" 'keyboard-escape-quit)
But Emacs behaves strangely after remapping C-[. For example, M-x stops working and if I try to remap M-x I get the following error:
error: Key sequence M-x starts with non-prefix key ESC
Why does this happen? Is there a workaround?
C-[ is the same as ESC, the Escape key. You probably do not want to rebind ESC, since it is used in many, many, many keybindings, as a prefix key. It implements the Meta key modifier in many cases, which is probably why you say that "Emacs behaves strangely" after you rebound it (removing its prefix-key behavior). See the Emacs manual, node User Input.
As to "Is there a workaround?" -- pick another key (leave ESC alone).
And wrt ESC and C-g: See the Emacs manual, node Quitting (also node Menu Bar).

Clojure documentation in Emacs

Is it possible to view Clojure function documentation in Emacs? Namely, can I configure Emacs to lookup Clojure functions under the cursor?
I'm using clojure-mode and SLIME. Oddly, I can't even use apropos or dir in SLIME's repl, although they're automatically loaded by lein repl.
Try the function slime-describe-symbol, which is usually bound to C-c C-d d.
Place the point somewhere near the function name and hit C-c, then C-d, and then d.
There's also slime-describe-function, bound to C-c C-d f, but I rarely use it, as it's less general than the aforementioned symbol-related lookup function.
To see all the documentation-related functions, press C-c C-d C-h. These bindings are not specific to Clojure; they are instead defined by SLIME, and will work as well if not better for other Lisp dialects.
I find the combination of slime-apropos and eldoc minor mode (make sure you have swank-clojure 1.4.0 as it fixes both of those) better than the slime-describe-symbol/function commands mentioned above.
From SLIME REPL you can run (use 'clojure.repl). This will make functions like apropos and doc available

writing lisp emacs key binding and cannot specify the <delete> character

For some reason I got the default M-del key binding for backward-kill-word mapped to a scan for matching brackets and resetting is not working, so I am trying to set the global key binding in lisp. So I wrote in ~/.emacs.d/init.el the lisp commands:
(global-set-key (kbd "M-h") 'backward-kill-word)
(global-set-key (kbd "M-<\delete>") ‘backward-kill-word)
I tried them with C-x C-e and they both give the 'backward-kill-word output but only the first key-binding works "M-h", the other is ignored and M-del still trying the strange scanning action. The delete key works in emacs elsewhere, so it seems like "delete" is not being mapped to the physical key in lisp (and the backslash is there to show in this text only as the word was being commented out). Any idea what keyword to use or special character?
Best.
(I looked for libraries that may have overrided this command but I cannot find them)
On some systems, the delete key is defined as an alias to C-d. This is done through function-key-map on GNU Emacs <23 and local-function-key-map on GNU Emacs 23. (I've observed this behavior on Debian and Ubuntu 10.04 under X.) The purpose of such translations is to isolate people who code modes from the terminal intricacies: a mode that wants to shadow the delete command only needs to rebind C-d and not wonder if it should rebind delete (is that a delete left or delete right?) or deletechar or something else.
If there is a global or local binding for delete, it shadows this translation to C-d. However, if you press ESC delete, if there is no global or local binding for ESC delete, the second key is translated to C-d. This translation has precedence over the interpretation of ESC delete as M-delete. So ESC delete becomes equivalent to C-M-d.
This is arguably a bug in Emacs: the effect of ESC delete should be the same as M-delete, and there is no reason why ESC delete would run down-list which has nothing to do with deletion.
There are several possible fixes; I don't know which is best. One that should work with any version of Emacs is
(global-set-key [?\e delete] 'backward-kill-word)
The really nice thing about kbd is that what you type there is the same string that Emacs displays. So, try the following
C-h k M-<\delete> (to use your syntax)
or
M-x describe-key M-<\delete>
Emacs (for me) responds with:
M-DEL (translated from <M-delete>)
runs the command backward-kill-word,
which is an interactive compiled Lisp
function in `simple.el'.
It is bound to , M-DEL.
(backward-kill-word arg)
....
Which you can see shows that the representation for the key you want is M-DEL or M-delete.
Which is a long way of getting to the point that what you want is
(global-set-key (kbd "M-delete") 'backward-kill-word)
Of course, if you have something in your .emacs that overrides it, the above won't help. You'll need to find that included library and stop using it (or customize its behavior).
You might want to call global-set-key interactively to see how it interprets meta-delete. Also try local-set-key to ensure the strange binding is not mode-specific.
After not being able to find the library holding the conflict I found this webpage
http://www.cs.cmu.edu/cgi-bin/info2www?%28emacs%29Rebinding
Changing Key Bindings Interactively...
`M-x global-set-key KEY CMD '
Define KEY globally to run CMD....
Normally, C-z' is bound to the function
suspend-emacs' (when not using the X Window System), but you can
change C-z' to invoke an interactive subshell within Emacs, by binding
it toshell' as follows:
M-x global-set-key <RET> C-z shell <RET>
`global-set-key' reads the command name after the key. After you
press the key, a message like this appears so that you can confirm that
you are binding the key you want:
Set key C-z to command:...
And now the standard default is returned to by doing
M-x global-set-key M-del ...
backward-kill-word
But this is transient and must be done on each reload, any way to make this permanent?
Putting a command into the init.el is not overriding the other effect