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).
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")
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).
How can I add a word to the dictionary in flyspell without using a mouse? I know, I can use the regular ispell.el binding M-$ and and go through the menu for that, however, this needs multiple keystrokes.
Is it possible to bind the "Save Word" functionality from the flyspell pop-up window to to a single key?
When you get to choose options - press i that should add it into your local dictionary (well, does for me anyway :)).
Thorough examination of ispell.el shows that there's no special function to do it, but you could have one of you own:
(defun save-ispell-word (word)
(interactive "sA word you want to add to dictionary ")
(ispell-send-string (concat "*" word "\n"))
(setq ispell-pdict-modified-p '(t)))
But it will work only in ispell minor mode.
For my day job, I live in Emacs. Utterly. I also have become pretty dependent on CScope to help me find things in the code.
Normally, I have 2 windows in a split (C-x 3):
alt text http://bitthicket.com/files/emacs-2split.JPG
And I use the right window for code buffers and the left window for the CScope search buffer. When you do a CScope search and select a result, it automatically updates the right-side window to show the buffer referred to by the result. This is all well and good, except that it causes me to lose my place in some other buffer that I was studying. Sometimes this is no biggie, because [C-s u] gets me back to where I was.
What would be better, though, is to have 3 split windows like this ([C-x 2] in the left window):
alt text http://bitthicket.com/files/emacs-3split.jpg
And have the bottom left window contain the CScope search buffer, and the top left window be the only buffer that CScope ever updates. That way, I can see my CScope searches and navigate around the code without losing the buffer I'm focused on.
Anyone know how I can do that?
Put this in your .emacs file:
;; Toggle window dedication
(defun toggle-window-dedicated ()
"Toggle whether the current active window is dedicated or not"
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window
(not (window-dedicated-p window))))
"Window '%s' is dedicated"
"Window '%s' is normal")
(current-buffer)))
Then bind it to some key - I use the Pause key:
(global-set-key [pause] 'toggle-window-dedicated)
And then use it to "dedicate" the window you want locked. then cscope can only open files from its result window in some OTHER window. Works a charm. I specifically use it for exactly this purpose - keeping one source file always on screen, while using cscope in a second buffer/window, and looking at cscope results in a third.
Well, I decided to not be a reputation-whore and find the answer myself. I looked in cscope.el as shown on the Emacs wiki, as well as the xcscope.el that comes with the cscope RPM package on RHEL.
Neither appear to give a way to do what I'm wanting. The way is probably to edit the ELisp by adding a package variable like *browse-buffer* or something and just initialize that variable if not already initialized the first time the user does [C-c C-s g] or whatever, and always have the resulting code shown in *browse-buffer*. Then the user can put the *browse-buffer* wherever he wants it.