I want to bind GUI dialog File -> Open File
to Ctrl
+ o
I can (global-set-key (kbd "C-o") 'find-file)
but I want it exactly with gui.
How can I do it?
I want to bind GUI dialog File -> Open File
to Ctrl
+ o
I can (global-set-key (kbd "C-o") 'find-file)
but I want it exactly with gui.
How can I do it?
File -> Open File
is just a GUI binding to find-file
.
By binding it to "C-o", you can then open a file using "C-o". However, this will only bring up the standard find-file
interface, which uses the echo area.
In order to also get a GUI dialogue box, you need to get emacs to think that find-file
has been clicked, rather than invoked by keyboard. The solution to that can be found in
Emacs M-x commands for invoking "GUI-style" menus.
Putting the two together (i.e. put them in your .emacs file and evaluate them):
(global-set-key (kbd "C-o") 'find-file)
(defadvice find-file-read-args (around find-file-read-args-always-use-dialog-box act)
"Simulate invoking menu item as if by the mouse; see `use-dialog-box'."
(let ((last-nonmenu-event nil))
ad-do-it))
Note, C-o
is already bound to open-line
- which will 'insert a newline and leave point before it`.
dired
(C-x d
) which may get you what you want. –
Lovegrass Following the comment by @squidy, here is the complete answer to what the OP asks (tested on emacs 24.3.1):
(global-set-key (kbd "C-o") 'menu-find-file-existing)
(defadvice find-file-read-args (around find-file-read-args-always-use-dialog-box act)
"Simulate invoking menu item as if by the mouse; see `use-dialog-box'."
(let ((last-nonmenu-event nil))
ad-do-it))
© 2022 - 2024 — McMap. All rights reserved.
dired-mode
-C-x d
. – Lovegrass