Emacs:上下文边距设置或填充文本以缩小列的范围?
我希望在缓冲区中快速生成如下所示的文本:Emacs:上下文边距设置或填充文本以缩小列的范围?,emacs,clojure,elisp,Emacs,Clojure,Elisp,我希望在缓冲区中快速生成如下所示的文本: (fact "This is some text which will hang out only on this part of the screen, ideally automatically flowing to the correct margins a
(fact "This is some text which will hang out
only on this part of the screen, ideally
automatically flowing to the correct
margins as I type."
(+ 1 1) => 2
;; more Clojure tests...
)
我有一个Elisp keybinding,它可以快速弹出一个起始模板,并将光标放在正确的位置:
(global-set-key "\C-of" (lambda ()
(interactive)
(insert "(fact \"\"\n\n )")
(backward-char 6)))
现在,当我输入字符串部分(“这是一些文本…”
)时,如果我能让Emacs自动将文本流到“正确”的边距,那就太棒了。有没有办法让Emacs根据您键入的位置调整边距和环绕行为?至少,你第一次在那里打字
除此之外,对于给定的文本选择,我如何使用所需的左、右边距来等效于
填充区域
?目前,fill region
删除了fact
和之间的所有空格,这是……
,并用左对齐其余部分。我现在忽略了一种更简单的方法,但我只想这样做:
fill column
设置为所需文本块的宽度
b、 将文本放在行首,即不缩进
c、 填写课文
d、 使用严格缩进
将文本缩进到所需的列中,第一行除外(事实),然后插入文本块第一行所需的缩进。然后插入临时缓冲区的内容。然后插入所需的任何其他文本/代码
依我看,我会将填充文本块与缩进文本块分开。对于我的另一种(较弱的)情况,以下内容目前似乎有效: 我希望在获得使用经验后,我必须对其进行调整,但这非常接近。尽管如此,当我在字符串中键入时,如果能够找到如何自动实现这一点,那将是一件好事
;; Set up Midje fact with mark inserted at beginning of comment text
;; (refill as needed in appropriate columns, using C-oF).
(global-set-key "\C-of" (lambda ()
(interactive)
(insert "(fact \"\"\n\n )")
(backward-char 6)
(set-mark (point))))
;; Perform the refill operation to properly reformat the text string
;; in a Midje fact, started with C-of:
(global-set-key "\C-oF" (lambda ()
(interactive)
(set-left-margin (mark) (point) 37)
(fill-region (mark) (point))))