如何在Emacs中以编程方式查找在哪个映射中键绑定(How to find in which map a key binding is from programmatically in Emacs)
例如,通过Ch k,我可以向Emacs询问“C在这个缓冲区中做了什么?”。 如果当前的缓冲区是我设置的Lisp缓冲区,Emacs会回答paredit-forward-slurp-sexp。 从这一点上,我可以猜测,C权与paredit-forward-slurp-sexp的绑定来自paredit模式映射,因为命令名由paredit加上前缀,但这是一种启发式。 我该如何以编程方式来做这件事,也就是说,我怎样才能问“在这个缓冲区中来自哪里的C-right的绑定?”
在这种情况下,编写一个函数检查当前全局地图,当前主要模式地图,paredit-mode-map,paredit-forward-mode-map,paredit-forward-slurp-mode-map,paredit-forward-slurp-sexp-模式映射的唯一途径?
For example, with C-h k I can ask to Emacs "what does C-right do in this buffer?". If the current buffer was a Lisp buffer in my setup, Emacs would answer paredit-forward-slurp-sexp. From that, I can guess that the binding of C-right to paredit-forward-slurp-sexp is from the paredit mode map because the command name is prefixed by paredit, but that's a heuristic. How can I do that programmatically, i.e., how can I ask "where is the binding of C-right in this buffer coming from?"
Is writing a function that in this case checks current global map, current major mode map, paredit-mode-map, paredit-forward-mode-map, paredit-forward-slurp-mode-map, paredit-forward-slurp-sexp-mode-map the only way?
原文:https://stackoverflow.com/questions/18801018
最满意答案
这些是文本文件,因此它们不包含任何包含这些信息的头文件。
使用
__version__
属性指定版本并要求Microsoft编写此功能。Those are textfiles and thus they don't contain any header to include such information.
Specify the version with
__version__
attribute and ask Microsoft to write this functionality.
相关问答
更多-
您可以执行任何系统命令并使用qx捕获STDOUT: use warnings; use strict; my $v = qx(python -V); print $v; You can execute any system command and capture STDOUT with qx: use warnings; use strict; my $v = qx(python -V); print $v;
-
此信息在sys模块中的sys.version字符串中可用: >>> import sys 人类可读: >>> print (sys.version) #parentheses necessary in python 3. 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] 进一步处理: >>> sys.version_info (2, 5, 2, 'final', 0) # or >> ...
-
import os os.system("C:\path_to_python\python.exe C:\path_to_file\file.py") os.system()返回命令的退出值,所以如果你需要脚本的一些输出,这将不起作用。 import os os.system("C:\path_to_python\python.exe C:\path_to_file\file.py") os.system() returns the command's exit value so if you need ...
-
Python脚本的版本(Version of python script)[2022-11-19]
这些是文本文件,因此它们不包含任何包含这些信息的头文件。 使用__version__属性指定版本并要求Microsoft编写此功能。 Those are textfiles and thus they don't contain any header to include such information. Specify the version with __version__ attribute and ask Microsoft to write this functionality. -
指定Python版本的最常用方法是shebang ,它是文件的第一行: #!/usr/bin/python # this program is run by Python 2 #!/usr/bin/python3 # Python 3 The most common way of specifying the Python version is the shebang, which is the first line of the file: #!/usr/bin/python # this progr ...
-
在具有相同python版本的脚本中重新启动python脚本(Restart of python script within script with same python version)[2023-05-06]
我觉得我可能会误解某些东西,但我想你只是想通过'python2.7'作为参数列表的第一个元素而不是'python' 。 或者如果您不确定可执行文件的名称是什么,请传递sys.executable可执行文件。 The following works independent of which python version you are using: os.execv(sys.executable,[sys.executable.split("/")[-1]]+sys.argv) -
这可能是由以下原因造成的。 您的脚本导入了一些由旧版python编译的第三方库。 要解决此问题,请重新安装最新的库。 It is probably caused by the following. Your script imports some third-party library which was compiled by an older python version. To fix this, reinstall the up-to-date library.
-
/usr/local/python3.2.3/bin/python3 -V /usr/local/python3.2.3/bin/python3 ext.py /usr/local/python3.2.3/bin/python3 -V /usr/local/python3.2.3/bin/python3 ext.py
-
如何用其他python版本以编程方式运行另一个python脚本?(How programmatically run another python script with other python version?)[2022-03-07]
您有几个选项,但最常见的概念是使用os.system来执行脚本。 明确的口译员 os.system('python2.6 myscript.py') 依靠shebang选择合适的口译员 os.system('myscript.py') 为此,您的脚本必须将第一行设置为 #!/usr/bin/env python2.6 你的python2.6可执行文件需要在你的PATH 。 如果你需要stdin / stdout操作 subprocess.Popen('myscript.py', subprocess. ... -
>>> import sys >>> sys.version_info sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0) >>> sys.version_info[0] 2 有关详细信息,请参阅https://docs.python.org/2/library/sys.html 。 sys.version_info provides the version of the used Python inter ...