User interface Emacs M-x命令,用于调用;“图形用户界面风格”;菜单
问题:在Emacs变体使用特定于操作系统的桌面功能的情况下,我如何找到在Emacs中执行基于GUI的操作的M-x等效命令 背景:传统的理解是,Emacs中的所有内容都是命令,只要知道命令的名称,就可以通过M-x调用命令。假设此语句是正确的,那么在基于“桌面”的Emacs变体中,如何查找用于触发“GUI样式”菜单的命令的名称 例如,如果我用鼠标选择文件菜单来打开文件,会弹出操作系统特定的“GUI”样式的文件打开对话框,等待我的输入 我怎样才能找到做同样事情的M-x等效命令 我以为描述键会告诉我我需要知道什么,但它是使用的指示:User interface Emacs M-x命令,用于调用;“图形用户界面风格”;菜单,user-interface,emacs,scripting,elisp,command,User Interface,Emacs,Scripting,Elisp,Command,问题:在Emacs变体使用特定于操作系统的桌面功能的情况下,我如何找到在Emacs中执行基于GUI的操作的M-x等效命令 背景:传统的理解是,Emacs中的所有内容都是命令,只要知道命令的名称,就可以通过M-x调用命令。假设此语句是正确的,那么在基于“桌面”的Emacs变体中,如何查找用于触发“GUI样式”菜单的命令的名称 例如,如果我用鼠标选择文件菜单来打开文件,会弹出操作系统特定的“GUI”样式的文件打开对话框,等待我的输入 我怎样才能找到做同样事情的M-x等效命令 我以为描述键会告诉我我需
M-x menu-find-file-existing
不调用“GUI”样式的文件打开对话框。相反,它使用的是Emacs内部的非GUI操作系统中性变体。哇,很高兴你这么问。我一直想自己查一查
C-hk
然后是菜单选项将告诉您这一点。例如,以下是您从选择菜单/编辑/粘贴中获得的信息:
<menu-bar> <edit> <paste> runs the command clipboard-yank
which is an interactive compiled Lisp function in `menu-bar.el'.
It is bound to <paste>, <f18>, <menu-bar> <edit> <paste>.
(clipboard-yank)
Insert the clipboard contents, or the last stretch of killed text.
你需要诱使Emacs认为键盘没有被使用,这不像诱使它认为鼠标被使用那样直观。:)
在WinXP上的Emacs 22.2.1上测试。不过,我相信这个范例已经存在了一段时间,所以它应该适用于较旧的emac。不知道XEmacs的工作原理是否类似。如果我没有弄错的话,M-x描述键相当于Emacs默认的C-h k。很高兴知道它可以描述的不仅仅是键绑定。不幸的是,它似乎没有描述特定于GUI的变体来触发特定于操作系统的对话框。
(defun menu-find-file-existing ()
"Edit the existing file FILENAME."
(interactive)
(let* ((mustmatch (not (and (fboundp 'x-uses-old-gtk-dialog)
(x-uses-old-gtk-dialog))))
(filename (car (find-file-read-args "Find file: " mustmatch))))
(if mustmatch
(find-file-existing filename)
(find-file filename))))
(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))