gpt4 book ai didi

emacs - 更改标记段落行为

转载 作者:行者123 更新时间:2023-12-05 00:00:35 26 4
gpt4 key购买 nike

如何更改默认的 emacs 标记段落功能行为以不选择第一个空行?

my emacs http://dl.dropbox.com/u/1019877/e2.PNG

我已经制作了 Bohzidars 升级版,它也适用于一线。

(global-set-key (kbd "M-h") (lambda ()
(interactive)
(mark-paragraph)
(if (> (line-number-at-pos) 1)
(next-line))
(beginning-of-line)))

谢谢你们的提示。

最佳答案

当前接受的答案有两个缺点:1) 不接受参数和 2) 不允许通过重复调用标记更多段落(特别是这非常有用)。这是我的解决方案 - 它是原始标记段落,最后是下一行命令。条件确保它也适用于文件的第一个。

可能更经济的解决方案是使用建议,但我还不知道如何使用它们:)。

(defun rs-mark-paragraph (&optional arg allow-extend)
"The original default mark-paragraph, but doesn't mark the first
empty line. Put point at beginning of this paragraph, mark at
end. The paragraph marked is the one that contains point or
follows point.

With argument ARG, puts mark at end of a following paragraph, so that
the number of paragraphs marked equals ARG.

If ARG is negative, point is put at end of this paragraph, mark is put
at beginning of this or a previous paragraph.

Interactively, if this command is repeated
or (in Transient Mark mode) if the mark is active,
it marks the next ARG paragraphs after the ones already marked."
(interactive "p\np")
(unless arg (setq arg 1))
(when (zerop arg)
(error "Cannot mark zero paragraphs"))
(cond ((and allow-extend
(or (and (eq last-command this-command) (mark t))
(and transient-mark-mode mark-active)))
(set-mark
(save-excursion
(goto-char (mark))
(forward-paragraph arg)
(point))))
(t
(forward-paragraph arg)
(push-mark nil t t)
(backward-paragraph arg)
(if (/= (line-number-at-pos) 1)
(next-line)))))

关于emacs - 更改标记段落行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9940101/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com