我目前在我的 .emacs 中有这个,它在 Linux 中工作得很好:
;; paredit
;; this is from somewhere else on Stackoverflow
;; deals with curly brackets matching and stuff
;; I edited the answer a little bit
(defmacro setup-paredit (func-name mode-map)
`(defun ,func-name ()
(define-key ,mode-map
(kbd "DEL") 'paredit-backward-delete)
(define-key ,mode-map
(kbd "{") 'paredit-open-curly)
(define-key ,mode-map
(kbd "}") 'paredit-close-curly)
(modify-syntax-entry ?\{ "(}")
(modify-syntax-entry ?\} "){")
(modify-syntax-entry ?\[ "(]")
(modify-syntax-entry ?\] ")[")
(modify-syntax-entry ?~ "' ")
(modify-syntax-entry ?, " ")
(modify-syntax-entry ?^ "'")
(modify-syntax-entry ?= "'")))
(defmacro setup-paredit-mode (func-name mode-map mode-hook)
`(progn (setup-paredit ,func-name ,mode-map)
(add-hook ',mode-hook ',func-name)
(add-hook ',mode-hook 'enable-paredit-mode)))
;; probably doing lots of things wrong but at least this seems to work well
(setup-paredit-mode setup-c++-paredit c++-mode-map c++-mode-hook)
(setup-paredit-mode setup-slime-repl-paredit slime-repl-mode-map slime-repl-mod\
e-hook)
(setup-paredit-mode setup-slime-paredit slime-mode-map slime-mode-hook)
(setup-paredit-mode setup-clojure-paredit clojure-mode-map clojure-mode-hook)
(setup-paredit-mode setup-emacs-paredit emacs-lisp-mode-map emacs-lisp-mode-hoo\
k)
(setup-paredit-mode setup-css-paredit css-mode-map css-mode-hook)
但是 Mac OS X 中的最后一位使箭头键产生以下输出:
[C [A [D [A [B [D [C [B [D [B [D]]]]]]]]]]]
击球时的另一个奇怪的事情C-x C-c
:
Symbol's function definition is void: switch-to-buffer-in-tab
我终于用C-x C-z
.
如果我在 之后注释掉最后一部分,这些就不会发生;; probably...
,所以问题可能就在那里。我应该如何解决这个问题?
编辑:
我找到了这个。简单地复制粘贴那里的代码是行不通的。按箭头键给了我这个:
# ESC [ ⇧A ESC [ ⇧B ESC [ ⇧C ESC [ ⇧D #
不过,作为新手,我不确定如何“适当地调整上面给出的代码”。(还有那个向上的箭头在做什么?)
编辑 2:
C-c C-x
至少,这个问题似乎已经用这个 .emacs 代码以某种方式解决了:
;; Fix Mac arrow keys
(if (not window-system);; Only use in tty-sessions.
(progn
(defvar arrow-keys-map (make-sparse-keymap) "Keymap for arrow keys")
(define-key esc-map "[" arrow-keys-map)
(define-key arrow-keys-map "⇧A" 'previous-line)
(define-key arrow-keys-map "⇧B" 'next-line)
(define-key arrow-keys-map "⇧C" 'forward-char)
(define-key arrow-keys-map "⇧D" 'backward-char)))
当 paredit 处于活动状态时,箭头键仍然不起作用。
编辑 3:
我应该补充一点,所有这些都发生在终端内。我不确定 GUI 是否仍然会发生这种情况,因为不知何故我的 .emacs 导致 Aquamacs 不显示任何窗口。
箭头键在 Emacs GUI 中工作正常,但在-nw
模式下不行。