mirror of
https://github.com/chrisbarrett/nursery
synced 2025-08-25 14:13:31 -05:00
Apply formatting correctly to text in headline
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(require 'org)
|
(require 'org)
|
||||||
|
(require 'thingatpt)
|
||||||
|
|
||||||
(defgroup org-format nil
|
(defgroup org-format nil
|
||||||
"Automatically format org buffers on save."
|
"Automatically format org buffers on save."
|
||||||
@@ -53,6 +54,12 @@ Only applies to level-1 headings in the document."
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(defun org-format--delete-empty-lines ()
|
||||||
|
(goto-char (line-beginning-position))
|
||||||
|
(while (thing-at-point-looking-at (rx bol (* space) eol))
|
||||||
|
(delete-region (line-beginning-position) (1+ (line-end-position)))))
|
||||||
|
|
||||||
(defun org-format--ensure-empty-lines (n)
|
(defun org-format--ensure-empty-lines (n)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (line-beginning-position))
|
(goto-char (line-beginning-position))
|
||||||
@@ -95,11 +102,11 @@ Only applies to level-1 headings in the document."
|
|||||||
org-format-blank-lines-before-subheadings))))
|
org-format-blank-lines-before-subheadings))))
|
||||||
(org-format--ensure-empty-lines headline-spacing)))
|
(org-format--ensure-empty-lines headline-spacing)))
|
||||||
|
|
||||||
(unless (or (org-at-heading-p)
|
(unless (and (fboundp 'org-transclusion-within-transclusion-p)
|
||||||
(when (fboundp 'org-transclusion-within-transclusion-p)
|
(org-transclusion-within-transclusion-p))
|
||||||
(org-transclusion-within-transclusion-p)))
|
(forward-line 1)
|
||||||
|
(org-format--delete-empty-lines)
|
||||||
(org-format--ensure-empty-lines org-format-blank-lines-before-meta)
|
(org-format--ensure-empty-lines org-format-blank-lines-before-meta)
|
||||||
|
|
||||||
(org-end-of-meta-data t)
|
(org-end-of-meta-data t)
|
||||||
(org-format--ensure-empty-lines org-format-blank-lines-before-content)))
|
(org-format--ensure-empty-lines org-format-blank-lines-before-content)))
|
||||||
t
|
t
|
||||||
|
Reference in New Issue
Block a user