diff options
author | Case Duckworth | 2020-12-10 00:28:27 -0600 |
---|---|---|
committer | Case Duckworth | 2020-12-10 00:28:27 -0600 |
commit | 49bc4f71e44e107e4cef3cc374109c5084f3abe4 (patch) | |
tree | e33b16ea469df33be67203afcede3d2a44efeab1 /config.org | |
parent | Remove keymap to tangle, but tangle on quit (diff) | |
download | emacs-49bc4f71e44e107e4cef3cc374109c5084f3abe4.tar.gz emacs-49bc4f71e44e107e4cef3cc374109c5084f3abe4.zip |
Add blank lines
Diffstat (limited to 'config.org')
-rw-r--r-- | config.org | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/config.org b/config.org index 51fb369..1c1b319 100644 --- a/config.org +++ b/config.org | |||
@@ -4,11 +4,12 @@ | |||
4 | #+EXPORT_FILE_NAME: README.md | 4 | #+EXPORT_FILE_NAME: README.md |
5 | #+OPTIONS: toc:nil | 5 | #+OPTIONS: toc:nil |
6 | #+BANKRUPTCY_COUNT: 3 | 6 | #+BANKRUPTCY_COUNT: 3 |
7 | #+Time-stamp: <2020-12-09 20:27:25 acdw> | 7 | #+Time-stamp: <2020-12-10 00:15:33 acdw> |
8 | 8 | ||
9 | Let’s configure Emacs using Org mode, they said. It’ll be fun, they said. | 9 | Let’s configure Emacs using Org mode, they said. It’ll be fun, they said. |
10 | 10 | ||
11 | * Pave the way | 11 | * Pave the way |
12 | |||
12 | ** Correct =exec-path= | 13 | ** Correct =exec-path= |
13 | 14 | ||
14 | #+begin_src emacs-lisp | 15 | #+begin_src emacs-lisp |
@@ -591,8 +592,11 @@ Until the =marginalia-annotators= settles, I’m disabling this section. | |||
591 | #+end_src | 592 | #+end_src |
592 | 593 | ||
593 | * Files | 594 | * Files |
595 | |||
594 | 596 | ||
597 | |||
595 | ** Encoding | 598 | ** Encoding |
599 | |||
596 | *** UTF-8 | 600 | *** UTF-8 |
597 | 601 | ||
598 | #+begin_src emacs-lisp | 602 | #+begin_src emacs-lisp |
@@ -861,8 +865,61 @@ I’ve put org mode under Applications, as opposed to Writing, because it’s m | |||
861 | 'scimax/org-return) | 865 | 'scimax/org-return) |
862 | #+end_src | 866 | #+end_src |
863 | 867 | ||
868 | *** Insert blank lines | ||
869 | |||
870 | from [[https://github.com/alphapapa/unpackaged.el#ensure-blank-lines-between-headings-and-before-contents][unpackaged.el]]. | ||
871 | |||
872 | #+begin_src emacs-lisp | ||
873 | ;;;###autoload | ||
874 | (defun unpackaged/org-fix-blank-lines (&optional prefix) | ||
875 | "Ensure that blank lines exist between headings and between headings and their contents. | ||
876 | With prefix, operate on whole buffer. Ensures that blank lines | ||
877 | exist after each headings's drawers." | ||
878 | (interactive "P") | ||
879 | (org-map-entries (lambda () | ||
880 | (org-with-wide-buffer | ||
881 | ;; `org-map-entries' narrows the buffer, which prevents us from seeing | ||
882 | ;; newlines before the current heading, so we do this part widened. | ||
883 | (while (not (looking-back "\n\n" nil)) | ||
884 | ;; Insert blank lines before heading. | ||
885 | (insert "\n"))) | ||
886 | (let ((end (org-entry-end-position))) | ||
887 | ;; Insert blank lines before entry content | ||
888 | (forward-line) | ||
889 | (while (and (org-at-planning-p) | ||
890 | (< (point) (point-max))) | ||
891 | ;; Skip planning lines | ||
892 | (forward-line)) | ||
893 | (while (re-search-forward org-drawer-regexp end t) | ||
894 | ;; Skip drawers. You might think that `org-at-drawer-p' would suffice, but | ||
895 | ;; for some reason it doesn't work correctly when operating on hidden text. | ||
896 | ;; This works, taken from `org-agenda-get-some-entry-text'. | ||
897 | (re-search-forward "^[ \t]*:END:.*\n?" end t) | ||
898 | (goto-char (match-end 0))) | ||
899 | (unless (or (= (point) (point-max)) | ||
900 | (org-at-heading-p) | ||
901 | (looking-at-p "\n")) | ||
902 | (insert "\n")))) | ||
903 | t (if prefix | ||
904 | nil | ||
905 | 'tree))) | ||
906 | #+end_src | ||
907 | |||
908 | **** Add a before-save-hook | ||
909 | |||
910 | #+begin_src emacs-lisp | ||
911 | (defun cribbed/org-mode-fix-blank-lines () | ||
912 | (when (eq major-mode 'org-mode) | ||
913 | (let ((current-prefix-arg 4)) ; Emulate C-u | ||
914 | (call-interactively 'unpackaged/org-fix-blank-lines)))) | ||
915 | |||
916 | (add-hook 'before-save-hook #'cribbed/org-mode-fix-blank-lines) | ||
917 | #+end_src | ||
918 | |||
864 | * Appendices | 919 | * Appendices |
920 | |||
865 | ** Emacs' files | 921 | ** Emacs' files |
922 | |||
866 | *** init.el | 923 | *** init.el |
867 | :PROPERTIES: | 924 | :PROPERTIES: |
868 | :header-args: :tangle init.el | 925 | :header-args: :tangle init.el |
@@ -871,6 +928,7 @@ I’ve put org mode under Applications, as opposed to Writing, because it’s m | |||
871 | #+begin_src emacs-lisp :comments no | 928 | #+begin_src emacs-lisp :comments no |
872 | ;; init.el -*- lexical-binding: t -*- | 929 | ;; init.el -*- lexical-binding: t -*- |
873 | #+end_src | 930 | #+end_src |
931 | |||
874 | **** Load config | 932 | **** Load config |
875 | 933 | ||
876 | from [[https://protesilaos.com/dotemacs/#h:584c3604-55a1-49d0-9c31-abe46cb1f028][Protesilaos Stavrou]]. | 934 | from [[https://protesilaos.com/dotemacs/#h:584c3604-55a1-49d0-9c31-abe46cb1f028][Protesilaos Stavrou]]. |