Fix `+org-fix-blank-lines'
This commit is contained in:
parent
56b2c9fb54
commit
d4c3d79770
67
lisp/+org.el
67
lisp/+org.el
|
@ -143,38 +143,41 @@ N is passed to the functions."
|
|||
Optional PREFIX argument operates on the entire buffer.
|
||||
Drawers are included with their headings."
|
||||
(interactive "P")
|
||||
(org-map-entries (lambda ()
|
||||
(org-with-wide-buffer
|
||||
;; `org-map-entries' narrows the buffer, which
|
||||
;; prevents us from seeing newlines before the
|
||||
;; current heading, so we do this part widened.
|
||||
(while (not (looking-back "\n\n" nil))
|
||||
;; Insert blank lines before heading.
|
||||
(insert "\n")))
|
||||
(let ((end (org-entry-end-position)))
|
||||
;; Insert blank lines before entry content
|
||||
(forward-line)
|
||||
(while (and (org-at-planning-p)
|
||||
(< (point) (point-max)))
|
||||
;; Skip planning lines
|
||||
(forward-line))
|
||||
(while (re-search-forward
|
||||
org-drawer-regexp end t)
|
||||
;; Skip drawers. You might think that
|
||||
;; `org-at-drawer-p' would suffice, but for
|
||||
;; some reason it doesn't work correctly when
|
||||
;; operating on hidden text. This works, taken
|
||||
;; from `org-agenda-get-some-entry-text'.
|
||||
(re-search-forward "^[ \t]*:END:.*\n?" end t)
|
||||
(goto-char (match-end 0)))
|
||||
(unless (or (= (point) (point-max))
|
||||
(org-at-heading-p)
|
||||
(looking-at-p "\n"))
|
||||
(insert "\n"))))
|
||||
t
|
||||
(if prefix
|
||||
nil
|
||||
'tree)))
|
||||
(let ((org-element-use-cache nil))
|
||||
(org-map-entries (lambda ()
|
||||
(let ((beg (org-entry-beginning-position))
|
||||
(end (org-entry-end-position)))
|
||||
(org-with-wide-buffer
|
||||
;; `org-map-entries' narrows the buffer, which
|
||||
;; prevents us from seeing newlines before the
|
||||
;; current heading, so we do this part widened.
|
||||
(while (not (looking-back "\n\n" nil))
|
||||
;; Insert blank lines before heading.
|
||||
(insert "\n")))
|
||||
|
||||
;; Insert blank lines before entry content
|
||||
(forward-line)
|
||||
(while (and (org-at-planning-p)
|
||||
(< (point) (point-max)))
|
||||
;; Skip planning lines
|
||||
(forward-line))
|
||||
(while (re-search-forward
|
||||
org-drawer-regexp end t)
|
||||
;; Skip drawers. You might think that
|
||||
;; `org-at-drawer-p' would suffice, but for
|
||||
;; some reason it doesn't work correctly when
|
||||
;; operating on hidden text. This works, taken
|
||||
;; from `org-agenda-get-some-entry-text'.
|
||||
(re-search-forward "^[ \t]*:END:.*\n?" end t)
|
||||
(goto-char (match-end 0)))
|
||||
(unless (or (= (point) (point-max))
|
||||
(org-at-heading-p)
|
||||
(looking-at-p "\n"))
|
||||
(insert "\n"))))
|
||||
t
|
||||
(if prefix
|
||||
nil
|
||||
'tree))))
|
||||
|
||||
;;; org-count-words
|
||||
|
||||
|
|
Loading…
Reference in New Issue