I'm trying to define my own shortcuts for DrRacket.
I created the file necessary to make C-Z as undo (it's C-_ or C-x;C-u in emacs Keybindings) :
#lang s-exp framework/keybinding-lang
(keybinding "c:z" undo)
However, nothing happens when I add it to keyboards shortcuts.
What did I miss ?
a) You can enable C-Z, C-X, C-V, C-C, etc. editing style by checking "Enable keybindings in menus" in Edit>Preferences>Edition>General.
b) If you want only this particular binding to work, try with:
(keybinding "c:z" (lambda (editor evt) (send editor undo)))
You may need to restart DrRacket (not sure).
Related
In Emacs, I make no use of the default command linked with +. Hence, I would like to use this keyboard shortcut to open the graphical dialog box for "Open File...". How should I proceed to set this ?
Put the following in your .emacs file:
(global-set-key (kbd "+") (lambda ()
(interactive)
(let (last-nonmenu-event)
(menu-find-file-existing))))
Then either type M-x eval-buffer or restart Emacs.
However - are you really absolutely sure that you will never ever need the + for anything else (such as, say, inserting a +)? Perhaps consider using at least something like CTRL + as your keyboard shortcut instead of just +... this could easily be implemented by replacing "+" in the above code snippet with "C-+".
Similar to #Thomas's answer (and I'd pose the same question about using +):
(global-set-key (kbd "+") (lambda ()
(interactive)
(let (use-file-dialog)
(menu-find-file-existing))))
Dunno which is better, or whether it matters. But at least this way you will perhaps have done C-h v use-file-dialog to understand what that variable does and hence why this code does what you want.
(menu-find-file-existing is just the command that menu-bar File > Open File... is bound to. It's what C-h k tells you when you click that menu item.)
I'd like to rebind
C-up to "M-p : bring the previously entered expression down to the prompt"
and
C-down to "M-n : bring the expression after the current expression in the expression history down to the prompt"
Racket behaves differently from my default terminal where I can use these control bindings to scroll through previous expressions. The racket manual gives some examples of rebindings but does not explain how to rebind a key only in the interactions window which is what is needed here. What it's doing is keeping the same binding for C-up & C-down to mean move the cursor up and down, as is useful in the editor window, in the interaction prompt. But I don't think I want that as I can't see the use of it.
This is what I have for my own use. Feel free to adapt it:
#lang s-exp framework/keybinding-lang
(require drracket/tool-lib)
(define (register-repl key command command-fallback)
(keybinding key (λ (ed evt)
(define canvas (send ed get-canvas))
(send (send ed get-keymap) call-function
(if (is-a? canvas drracket:unit:interactions-canvas%)
command
command-fallback)
ed evt #t))))
(register-repl "d:up" "put-previous-sexp" "beginning-of-file")
(register-repl "d:down" "put-next-sexp" "end-of-file")
When the auto-complete menu pops up in Emacs, what key do I use to navigate up and down the menu besides the up and down arrows? I tried C-n and C-p but that makes the menu disappear and move my cursor up and down the text area instead.
You can also use M-p and M-n to select the previous and next candidates respectively as described in the Summary section of the User Manual.
An answer to this question with the C-n and C-p keybindings could be:
; Cycle candidates with C-n and C-p
(setq ac-use-menu-map t)
Setting this variable (that comes from auto-complete.el) to true will remap the keybindings. auto-complete.el says a special keymap ac-menu-map on completing menu will be used. This is where the binding is made.
With DrRacket,v6.0 on Windows7, I want to change the keybinding "c:/" to "tab", and use "Complete Word" as in the Edit menu.
I followed these instructions to write a file but it does not work.
Here is my file's code:
#lang s-exp framework/keybinding-lang
(define (rebind key command)
(keybinding
key
(λ (ed evt)
(send (send ed get-keymap) call-function
command ed evt #t))))
(rebind "tab" "Complete Word")
I added it to the keybindings but nothing happens when I press the tab key.
Can anyone tell me why?
Use auto-complete instead:
(keybinding "tab" (λ(editor event) (send editor auto-complete)))
Finding the correct functions for keybinding is a bit of a trial and error process, to my experience. The function names as written in the menu "Edit/Keybindings/Show active keybindings" (approximate translation from French) are not always the correct ones it seems.
In particular, here it is written "Word completion" but it does not seem to work for me, whereas "TeX compress" does work (but has a different function).
I am learning emacs at the moment and tried to write an easy vhdl program for testing. I can see that the vhdl-mode might be an interesting feature, but I would like to know how I can turn it off for the moment and how I can reactivate it later on.
Use the command M-x fundamental-mode, that is:
Press (and hold) the meta key (which is usually the Alt key)
Press x
This will take the cursor into the echo area at the bottom of the screen/frame. Type fundamental-mode and press return.
To disable VHDL mode permanently, you will have to change the file-extension mapping used by emacs to associate a file's extension with a particular major mode. You can do this by writing a custom .emacs configuration file. Look for auto-mode-alist in the emacs manual:
(setq auto-mode-alist (remove (rassoc 'vhdl-mode auto-mode-alist) auto-mode-alist))
Change to some other mode, e.g.
M-x fundamental-mode RET
or
M-x indented-text-mode RET
re-enable it by entering
M-x vhdl-mode RET