Created
October 24, 2022 15:57
-
-
Save abrochard/4b3858e155fa76697058673866f55d2f to your computer and use it in GitHub Desktop.
Quick gist to play around with magit-section
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; See https://magit.vc/manual/magit-section.html | |
(defun magit-test-section () | |
(interactive) | |
;; create a new buffer | |
(with-current-buffer (get-buffer-create "*magit-test-section*") | |
;; trigger the magit section mode | |
(magit-section-mode) | |
;; deactivate the buffer read-only mode temporarily | |
(let ((inhibit-read-only t)) | |
;; wipe the buffer clean | |
(erase-buffer) | |
;; can start inserting sections | |
(magit-insert-section (magit-section "Section1") | |
(magit-insert-heading (insert "Heading1")) | |
(magit-insert-section-body (insert "Body1\n\n"))) | |
(magit-insert-section (magit-section "Section2") | |
(magit-insert-heading (insert "Heading2")) | |
(magit-insert-section-body (insert "Body2\n\n"))) | |
(magit-insert-section (magit-section "Section3") | |
(magit-insert-heading (insert "Heading3")) | |
;; can nest section inside other sections | |
(magit-insert-section (magit-section "Section3a") | |
(magit-insert-heading (insert "Heading3a")) | |
(magit-insert-section-body (insert "Body3a\n\n"))) | |
(magit-insert-section (magit-section "Section3b") | |
(magit-insert-heading (insert "Heading3b")) | |
(magit-insert-section-body (insert "Body3b\n\n"))) | |
) | |
) | |
;; we're done editing the buffer | |
;; swith to it | |
(pop-to-buffer (current-buffer)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment