用org中的部分句子用逗号转发句子

时间:2019-10-29 04:53:03

标签: emacs org-mode

在组织中罢工M-e,它调用org-forward-sentence,因此将点移动到句子的结尾。

我想用逗号移动。当引用org-forward-sentence时,请注意

的最后两行
(let ((sentence-end (concat (sentence-end) "\\|^\\*+ .*$")))
        (call-interactively #'forward-sentence)))))))

根据已完成的定义。

(defun org-forward-sentence (&optional _arg)
  "Go to end of sentence, or end of table field.
This will call `forward-sentence' or `org-table-end-of-field',
depending on context."
  (interactive)
  (if (and (org-at-heading-p)
       (save-restriction (skip-chars-forward " \t") (not (eolp))))
      (save-restriction
    (narrow-to-region (line-beginning-position) (line-end-position))
    (call-interactively #'forward-sentence))
    (let* ((element (org-element-at-point))
       (contents-end (org-element-property :contents-end element))
       (table (org-element-lineage element '(table) t)))
      (if (and table
           (>= (point) (org-element-property :contents-begin table))
           (< (point) contents-end))
      (call-interactively #'org-table-end-of-field)
    (save-restriction
      (when (and contents-end
             (> (point-max) contents-end)
             ;; Skip blank lines between elements.
             (< (org-element-property :end element)
            (save-excursion (goto-char contents-end)
                    (skip-chars-forward " \r\t\n"))))
        (narrow-to-region (org-element-property :contents-begin element)
                  contents-end))
      ;; End of heading is considered as the end of a sentence.
      (let ((sentence-end (concat (sentence-end) "\\|^\\*+ .*$")))
        (call-interactively #'forward-sentence)))))))

然后将dot更改为逗号

(let ((sentence-end (concat (sentence-end) "\\|^\\*+ ,*$"))) ;;changee . to ,
        (call-interactively #'forward-sentence)))))))

但是,事实证明这是错误的。

在原始功能中我应该在哪里更改。

 Define it as 
       (def org-forward-partial-sentence (&optional arg) 
and (global-set-key "\C-m"

1 个答案:

答案 0 :(得分:1)

.在正则表达式上下文中具有特殊含义,请参见手册中的(emacs)Regexps

一个很简单的修改是

(concat (sentence-end) "\\|^\\*+ .*$\\|,")

也移至,

例如,您可以只在sentence-end周围绑定org-forward-sentence,而不是更改整个功能。

(defun my-org-forward-sentence ()
  (interactive)
  (let ((sentence-end (concat (sentence-end) "\\|,")))
    (call-interactively #'org-forward-sentence)))