Use default Org function to remove identation
Should be more robust?
This commit is contained in:
parent
b798b13a94
commit
a53a8ccbd2
@ -414,8 +414,6 @@ history of the buffer."
|
||||
;; Generate headline and store it somewhere
|
||||
(let* ((body (buffer-substring-no-properties (org-element-contents-begin 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))
|
||||
(rest-of-body (string-trim (seq-drop-while #'(lambda (x) (not (= x ?\n))) body))))
|
||||
|
||||
@ -423,12 +421,6 @@ history of the buffer."
|
||||
(delete-region (org-element-begin 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
|
||||
(org-capture-put :key "")
|
||||
(org-capture-put :description "")
|
||||
@ -449,7 +441,7 @@ Via %%(with-temp-buffer (db/org-add-link-to-current-clock) (string-trim (buffer-
|
||||
;; Quote % to prevent unintented expansion by
|
||||
;; `org-capture-fill-template'.
|
||||
(replace-regexp-in-string "%" "\\\\%" first-line-of-body)
|
||||
(replace-regexp-in-string "%" "\\\\%" rest-of-body))))
|
||||
(replace-regexp-in-string "%" "\\\\%" (org-remove-indentation rest-of-body)))))
|
||||
(org-capture-set-target-location)
|
||||
(org-capture-place-template)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user