Answers:
绑定<
到self-insert-command
bash模式,然后将仅插入字符。
默认情况下,绑定到sh-maybe-here-document
bash模式时,该函数会自动插入。
这是反弹钥匙的一种方法:
(add-hook 'sh-set-shell-hook 'my-disable-here-document)
(defun my-disable-here-document ()
(local-set-key "<" 'self-insert-command))
<
已绑定self-insert-command
。
如果要禁用here-doc行为的唯一原因是它阻止您插入here-string <<<,则绑定C-<
到包含的函数(insert "<<<")
将起作用,并且仍然允许自动here-doc模板
(defun my-here-string()
"Insert <<< (eg. for a bash here-string)"
(interactive)
(insert "<<<"))
(global-set-key (kbd "C-<") 'my-here-string)
看一下之后:http : //web.mit.edu/dosathena/sandbox/emacs-19.28/lisp/sh-script.el 我想到了这个解决方案:
;; disable the automatic EOF generation in Shell Mode
(defvar sh-use-prefix nil
"If non-nil when loading, `$' and `<' will be C-c $ and C-c < .")
(defvar sh-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (if sh-use-prefix "\C-c<" "<")
(local-set-key "<" 'self-insert-command))
map)
"Keymap used in Shell-Script mode.")