emacs - 不能写大写M

标签 emacs lisp

我想我的问题很明显,但我不了解 Lisp,也无法弄清楚。每次我尝试在 python 文件中写一个大写的“M”时,它都不起作用(似乎认为这是快捷方式的开始)。我的猜测是它在模块或我的 .emacs 文件中的某处,它试图将某些内容绑定(bind)到 Alt + 某些内容。但相反,它把它绑定(bind)到大写的 M 东西上。这是我的 .emacs 文件(其中大部分是我从网上复制的):

; load-path setting is only needed if the directory you put
; weblogger.el in isn't already in your load-path
(add-to-list 'load-path "~/.emacs.d/")

; Remap Ctrl-tab to M-Tab
(define-key function-key-map [(control tab)] [?\M-\t])

(require 'ipython)
(define-key py-mode-map (kbd "M-") 'anything-ipython-complete)
(define-key py-shell-map (kbd "M-") 'anything-ipython-complete)
(define-key py-mode-map (kbd "C-c M") 'anything-ipython-import-modules-from-buffer)

(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))

(require 'python-pep8)
(require 'python-pylint)

(require 'lambda-mode)
(add-hook 'python-mode-hook #'lambda-mode 1)

(require 'comint)
(define-key comint-mode-map (kbd "M-") 'comint-next-input)
(define-key comint-mode-map (kbd "M-") 'comint-previous-input)
(define-key comint-mode-map [down] 'comint-next-matching-input-from-input)
(define-key comint-mode-map [up] 'comint-previous-matching-input-from-input)

(autoload 'pylookup-lookup "pylookup")
(autoload 'pylookup-update "pylookup")
(setq pylookup-program "~/.emacs.d/pylookup/pylookup.py")
(setq pylookup-db-file "~/.emacs.d/pylookup/pylookup.db")
(global-set-key "\C-ch" 'pylookup-lookup)

(autoload 'autopair-global-mode "autopair" nil t)
(autopair-global-mode)
(add-hook 'lisp-mode-hook
          #'(lambda () (setq autopair-dont-activate t)))

(add-hook 'python-mode-hook
          #'(lambda ()
              (push '(?' . ?')
                    (getf autopair-extra-pairs :code))
              (setq autopair-handle-action-fns
                    (list #'autopair-default-handle-action
                          #'autopair-python-triple-quote-action))))

(require 'python-pep8)
(require 'python-pylint)

(add-hook 'before-save-hook 'delete-trailing-whitespace)

(autoload 'pylookup-lookup "pylookup")
(autoload 'pylookup-update "pylookup")
(setq pylookup-program "~/.emacs.d/pylookup/pylookup.py")
(setq pylookup-db-file "~/.emacs.d/pylookup/pylookup.db")
(global-set-key "\C-ch" 'pylookup-lookup)

;; Initialize Rope
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport t)

(require 'auto-complete)
(global-auto-complete-mode t)

;(when (require 'auto-complete nil t)
;  (require 'auto-complete-yasnippet)
;  (require 'auto-complete-python)
;  (require 'auto-complete-css)
;  (require 'auto-complete-cpp)
;  (require 'auto-complete-emacs-lisp)
;  (require 'auto-complete-semantic)
;  (require 'auto-complete-gtags))

;  (global-auto-complete-mode t)
;  (setq ac-auto-start 3)
;  (setq ac-dwim t)
;  (set-default 'ac-sources '(ac-source-yasnippet ac-source-abbrev ac-source-words-in-buffer ac-source-files-in-current-dir ac-source-symbols))

; (load-library "init_python")

知道我应该从哪里开始寻找问题吗?一个简单的搜索或任何其他方式来调试 .emacs 目录中的文件?

最佳答案

这在我看来是错误的:

(define-key py-mode-map (kbd "M-") 'anything-ipython-complete)
(define-key py-shell-map (kbd "M-") 'anything-ipython-complete)
(define-key comint-mode-map (kbd "M-") 'comint-next-input)
(define-key comint-mode-map (kbd "M-") 'comint-previous-input)

kbd 期望完全绑定(bind),但您正在尝试绑定(bind) M- 到一些功能。我怀疑有一封信丢失了。

(define-key py-mode-map (kbd "M-TAB") 'anything-ipython-complete)

这里,M代表META,通常绑定(bind)到ALTESC

对了,你可以做XC-h看看 以 X 开头的次要模式绑定(bind)。

关于emacs - 不能写大写M,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8705681/

相关文章:

emacs - 如何在emacs中设置缓冲区局部变量

list - 计算 LISP 中每个级别的子列表

multithreading - 如何在 Common Lisp 中实现多线程

emacs - 任何可用于浏览数据库(查看模式、运行 sql 查询)的 emacs 包?

emacs - 如何关闭间接缓冲区并返回组织模式下的主缓冲区?

java - 用于 emacs 的最佳 Java 工具

lisp - 普通 lisp linux 终端的大输出

clojure 用它的答案替换运算符

lisp - 如何根据 elisp 中的一个条件设置一堆变量?

emacs - 如何在 Emacs 中强制绑定(bind)?