[Emacs]C-j的作用是什么,有点不对

在看文档的时候,这里有点疑问

C-j at the end of s-expression prints the result in the scratch buffer.


但是我试了一下,只是换行而已,查一下帮助文档

C-j runs the command electric-newline-and-maybe-indent (found in
global-map), which is an interactive compiled Lisp function in
‘electric.el’.

It is bound to C-j.

(electric-newline-and-maybe-indent)

Insert a newline.
If ‘electric-indent-mode’ is enabled, that’s that, but if it
is *disabled* then additionally indent according to major mode.
Indentation is done using the value of ‘indent-line-function’.
In programming language modes, this is the same as TAB.
In some text modes, where TAB inserts a tab, this command indents to the
column specified by the function ‘current-left-margin’.

[back]

我不知道这有什么误解,请帮我看看

应该是eval-print-last-sexp,你是不是配置了什么东西?确定是在scratch buffer吗?

不是诶,在文件里


吓死我了,原来是缓存区错了,感谢提醒

文件里没有的,想用的话

(define-key emacs-lisp-mode-map (kbd "C-j") #'eval-print-last-sexp)

不过在文件里的话推荐用C-x C-e,不会在文件里插入结果,而是会打印到下面的minibuffer。

每一个mode C-j的快捷键不一样吧。没有的话,自己设一下就好。