emacs - 更改标记段落行为

标签 emacs

如何更改默认的 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/

相关文章:

emacs - emacs cider/paredit/clojure-mode 中的缩进配置

emacs - eval/从文件加载时如何使emacs默认切换到*scheme*?

emacs - 使用 X 转发连接到远程 Emacs

emacs - 变量只在声明中突出显示? (Emacs c++-模式)

emacs - 在多个emacs缓冲区上执行特定命令

macos - 为什么 Shift+箭头绑定(bind)在 emacs 终端中的 clojure 模式下不起作用?

emacs - 如何在 EMACS 中缩进/自动格式化 HOCON?

emacs - 如何编写 emacs lisp 代码来添加新的突出显示模式?

emacs - 在 Emacs 中将光标移动到 12 个月旋转日历上的日期的算法

emacs - Emacs 中剪贴板的文件路径