(Try to) fix indentation of Org headings converted from list items
Not quite sure whether this is it, but looks better than before.
This commit is contained in:
parent
4697c53197
commit
2de58df052
@ -430,6 +430,8 @@ history of the buffer."
|
|||||||
;; Generate headline and store it somewhere
|
;; Generate headline and store it somewhere
|
||||||
(let* ((body (buffer-substring-no-properties (org-element-contents-begin last-seen-item)
|
(let* ((body (buffer-substring-no-properties (org-element-contents-begin last-seen-item)
|
||||||
(org-element-end last-seen-item)))
|
(org-element-end last-seen-item)))
|
||||||
|
(indent-offset (- (org-element-begin last-seen-item)
|
||||||
|
(org-element-contents-begin last-seen-item)))
|
||||||
(first-line-of-body (seq-take-while #'(lambda (x) (not (= x ?\n))) body))
|
(first-line-of-body (seq-take-while #'(lambda (x) (not (= x ?\n))) body))
|
||||||
(rest-of-body (string-trim (seq-drop-while #'(lambda (x) (not (= x ?\n))) body))))
|
(rest-of-body (string-trim (seq-drop-while #'(lambda (x) (not (= x ?\n))) body))))
|
||||||
|
|
||||||
@ -437,6 +439,12 @@ history of the buffer."
|
|||||||
(delete-region (org-element-begin last-seen-item)
|
(delete-region (org-element-begin last-seen-item)
|
||||||
(org-element-end last-seen-item))
|
(org-element-end last-seen-item))
|
||||||
|
|
||||||
|
;; Adjust indentation of `rest-of-body' by `indent-offset'
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert rest-of-body)
|
||||||
|
(indent-region (point-min) (point-max) indent-offset)
|
||||||
|
(setq rest-of-body (buffer-string)))
|
||||||
|
|
||||||
;; Set up capture buffer
|
;; Set up capture buffer
|
||||||
(org-capture-put :key "")
|
(org-capture-put :key "")
|
||||||
(org-capture-put :description "")
|
(org-capture-put :description "")
|
||||||
@ -461,10 +469,7 @@ Via %%(with-temp-buffer (db/org-add-link-to-current-clock) (string-trim (buffer-
|
|||||||
(org-capture-set-target-location)
|
(org-capture-set-target-location)
|
||||||
(org-capture-place-template)
|
(org-capture-place-template)
|
||||||
|
|
||||||
(indent-region (point-min) (point-max))
|
|
||||||
|
|
||||||
;; Ensure that two line breaks are placed at the end of the heading
|
;; Ensure that two line breaks are placed at the end of the heading
|
||||||
|
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(while (looking-back "\n" 1)
|
(while (looking-back "\n" 1)
|
||||||
(delete-char -1))
|
(delete-char -1))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user