Small optimization
* lisp/org.el (org-adaptive-fill-function): Do not compute fill prefix if point is at a heading or an inlinetask. Also change "? " into "?\s" for better code readability.
This commit is contained in:
parent
c9a5ba09f1
commit
39d0433637
107
lisp/org.el
107
lisp/org.el
|
@ -22727,63 +22727,62 @@ matches in paragraphs or comments, use it."
|
||||||
((looking-at message-cite-prefix-regexp)
|
((looking-at message-cite-prefix-regexp)
|
||||||
(throw 'exit (match-string-no-properties 0)))
|
(throw 'exit (match-string-no-properties 0)))
|
||||||
((looking-at org-outline-regexp)
|
((looking-at org-outline-regexp)
|
||||||
(throw 'exit (make-string (length (match-string 0)) ? ))))))
|
(throw 'exit (make-string (length (match-string 0)) ?\s))))))
|
||||||
(org-with-wide-buffer
|
(org-with-wide-buffer
|
||||||
(let* ((p (line-beginning-position))
|
(unless (org-at-heading-p)
|
||||||
(element (save-excursion
|
(let* ((p (line-beginning-position))
|
||||||
(beginning-of-line)
|
(element (save-excursion
|
||||||
(or (ignore-errors (org-element-at-point))
|
(beginning-of-line)
|
||||||
(user-error "An element cannot be parsed line %d"
|
(org-element-at-point)))
|
||||||
(line-number-at-pos (point))))))
|
(type (org-element-type element))
|
||||||
(type (org-element-type element))
|
(post-affiliated (org-element-property :post-affiliated element)))
|
||||||
(post-affiliated (org-element-property :post-affiliated element)))
|
(unless (and post-affiliated (< p post-affiliated))
|
||||||
(unless (and post-affiliated (< p post-affiliated))
|
(case type
|
||||||
(case type
|
(comment
|
||||||
(comment
|
|
||||||
(save-excursion
|
|
||||||
(beginning-of-line)
|
|
||||||
(looking-at "[ \t]*")
|
|
||||||
(concat (match-string 0) "# ")))
|
|
||||||
(footnote-definition "")
|
|
||||||
((item plain-list)
|
|
||||||
(make-string (org-list-item-body-column
|
|
||||||
(or post-affiliated
|
|
||||||
(org-element-property :begin element)))
|
|
||||||
? ))
|
|
||||||
(paragraph
|
|
||||||
;; Fill prefix is usually the same as the current line,
|
|
||||||
;; unless the paragraph is at the beginning of an item.
|
|
||||||
(let ((parent (org-element-property :parent element)))
|
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(cond ((eq (org-element-type parent) 'item)
|
(looking-at "[ \t]*")
|
||||||
(make-string (org-list-item-body-column
|
(concat (match-string 0) "# ")))
|
||||||
(org-element-property :begin parent))
|
(footnote-definition "")
|
||||||
? ))
|
((item plain-list)
|
||||||
((and adaptive-fill-regexp
|
(make-string (org-list-item-body-column
|
||||||
;; Locally disable
|
(or post-affiliated
|
||||||
;; `adaptive-fill-function' to let
|
(org-element-property :begin element)))
|
||||||
;; `fill-context-prefix' handle
|
?\s))
|
||||||
;; `adaptive-fill-regexp' variable.
|
(paragraph
|
||||||
(let (adaptive-fill-function)
|
;; Fill prefix is usually the same as the current line,
|
||||||
(fill-context-prefix
|
;; unless the paragraph is at the beginning of an item.
|
||||||
post-affiliated
|
(let ((parent (org-element-property :parent element)))
|
||||||
(org-element-property :end element)))))
|
(save-excursion
|
||||||
((looking-at "[ \t]+") (match-string 0))
|
(beginning-of-line)
|
||||||
(t "")))))
|
(cond ((eq (org-element-type parent) 'item)
|
||||||
(comment-block
|
(make-string (org-list-item-body-column
|
||||||
;; Only fill contents if P is within block boundaries.
|
(org-element-property :begin parent))
|
||||||
(let* ((cbeg (save-excursion (goto-char post-affiliated)
|
?\s))
|
||||||
(forward-line)
|
((and adaptive-fill-regexp
|
||||||
(point)))
|
;; Locally disable
|
||||||
(cend (save-excursion
|
;; `adaptive-fill-function' to let
|
||||||
(goto-char (org-element-property :end element))
|
;; `fill-context-prefix' handle
|
||||||
(skip-chars-backward " \r\t\n")
|
;; `adaptive-fill-regexp' variable.
|
||||||
(line-beginning-position))))
|
(let (adaptive-fill-function)
|
||||||
(when (and (>= p cbeg) (< p cend))
|
(fill-context-prefix
|
||||||
(if (save-excursion (beginning-of-line) (looking-at "[ \t]+"))
|
post-affiliated
|
||||||
(match-string 0)
|
(org-element-property :end element)))))
|
||||||
""))))))))))
|
((looking-at "[ \t]+") (match-string 0))
|
||||||
|
(t "")))))
|
||||||
|
(comment-block
|
||||||
|
;; Only fill contents if P is within block boundaries.
|
||||||
|
(let* ((cbeg (save-excursion (goto-char post-affiliated)
|
||||||
|
(forward-line)
|
||||||
|
(point)))
|
||||||
|
(cend (save-excursion
|
||||||
|
(goto-char (org-element-property :end element))
|
||||||
|
(skip-chars-backward " \r\t\n")
|
||||||
|
(line-beginning-position))))
|
||||||
|
(when (and (>= p cbeg) (< p cend))
|
||||||
|
(if (save-excursion (beginning-of-line) (looking-at "[ \t]+"))
|
||||||
|
(match-string 0)
|
||||||
|
"")))))))))))
|
||||||
|
|
||||||
(declare-function message-goto-body "message" ())
|
(declare-function message-goto-body "message" ())
|
||||||
(defvar message-cite-prefix-regexp) ; From message.el
|
(defvar message-cite-prefix-regexp) ; From message.el
|
||||||
|
|
Loading…
Reference in New Issue