From 49bc4f71e44e107e4cef3cc374109c5084f3abe4 Mon Sep 17 00:00:00 2001
From: Case Duckworth
Date: Thu, 10 Dec 2020 00:28:27 -0600
Subject: Add blank lines

---
 README.md  | 20 +++++++++++---------
 config.org | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index 866b4d3..dfcc845 100644
--- a/README.md
+++ b/README.md
@@ -601,7 +601,7 @@ I add it to the `find-file-hook` *and* `before-save-hook` because I don't want t
       :config
       (show-smartparens-global-mode +1)
       :hook
-      (prog-mode-hook . smart-parens-strict-mode))
+      (prog-mode-hook . smartparens-strict-mode))
 
 
 ## Line numbers
@@ -620,8 +620,6 @@ I add it to the `find-file-hook` *and* `before-save-hook` because I don't want t
     (add-hook 'prog-mode-hook #'acdw/enable-line-numbers)
 
 
-<a id="org92fae61"></a>
-
 # Writing
 
 
@@ -659,7 +657,7 @@ I add it to the `find-file-hook` *and* `before-save-hook` because I don't want t
 
 ## Org mode
 
-I’ve put org mode under Applications, as opposed to [8](#org92fae61), because it’s  more generally-applicable than that.
+I’ve put org mode under Applications, as opposed to Writing, because it’s  more generally-applicable than that.
 
     (use-package org
       :custom
@@ -668,6 +666,7 @@ I’ve put org mode under Applications, as opposed to [8](#org92fae61), because
       (org-fontify-whole-heading-line t)
       (org-fontify-quote-and-verse-blocks t)
       (org-pretty-entities t)
+      (org-num-mode +1)
     
       (org-src-tab-acts-natively t)
       (org-src-fontify-natively t)
@@ -820,6 +819,14 @@ I’ve put org mode under Applications, as opposed to [8](#org92fae61), because
     	       (byte-compile-file f (not disable-load))))))))))
 
 
+### Add a hook to tangle when quitting
+
+    (defun acdw/refresh-emacs-no-load ()
+      (refresh-emacs t))
+    
+    (add-hook 'kill-emacs-hook #'acdw/refresh-emacs-no-load)
+
+
 ## License
 
 Copyright © 2020 Case Duckworth <acdw@acdw.net>
@@ -852,8 +859,3 @@ GPL, for what should be fairly obvious reasons.  To that, I say:
 
 **SUE ME, RMS!**
 
-
-## Keymaps for *this* file
-
-This isn’t working … yet.
-
diff --git a/config.org b/config.org
index 51fb369..1c1b319 100644
--- a/config.org
+++ b/config.org
@@ -4,11 +4,12 @@
 #+EXPORT_FILE_NAME: README.md
 #+OPTIONS: toc:nil
 #+BANKRUPTCY_COUNT: 3
-#+Time-stamp: <2020-12-09 20:27:25 acdw>
+#+Time-stamp: <2020-12-10 00:15:33 acdw>
 
 Let’s configure Emacs using Org mode, they said.  It’ll be fun, they said.
 
 * Pave the way
+
 ** Correct =exec-path=
 
  #+begin_src emacs-lisp
@@ -591,8 +592,11 @@ Until the =marginalia-annotators= settles, I’m disabling this section.
 #+end_src
 
 * Files
+
   
+
 ** Encoding
+
 *** UTF-8
 
  #+begin_src emacs-lisp
@@ -861,8 +865,61 @@ I’ve put org mode under Applications, as opposed to Writing, because it’s  m
     'scimax/org-return)
 #+end_src
 
+*** Insert blank lines
+
+from [[https://github.com/alphapapa/unpackaged.el#ensure-blank-lines-between-headings-and-before-contents][unpackaged.el]].
+
+#+begin_src emacs-lisp
+  ;;;###autoload
+  (defun unpackaged/org-fix-blank-lines (&optional prefix)
+    "Ensure that blank lines exist between headings and between headings and their contents.
+  With prefix, operate on whole buffer. Ensures that blank lines
+  exist after each headings's drawers."
+    (interactive "P")
+    (org-map-entries (lambda ()
+		       (org-with-wide-buffer
+			;; `org-map-entries' narrows the buffer, which prevents us from seeing
+			;; newlines before the current heading, so we do this part widened.
+			(while (not (looking-back "\n\n" nil))
+			  ;; Insert blank lines before heading.
+			  (insert "\n")))
+		       (let ((end (org-entry-end-position)))
+			 ;; Insert blank lines before entry content
+			 (forward-line)
+			 (while (and (org-at-planning-p)
+				     (< (point) (point-max)))
+			   ;; Skip planning lines
+			   (forward-line))
+			 (while (re-search-forward org-drawer-regexp end t)
+			   ;; Skip drawers. You might think that `org-at-drawer-p' would suffice, but
+			   ;; for some reason it doesn't work correctly when operating on hidden text.
+			   ;; This works, taken from `org-agenda-get-some-entry-text'.
+			   (re-search-forward "^[ \t]*:END:.*\n?" end t)
+			   (goto-char (match-end 0)))
+			 (unless (or (= (point) (point-max))
+				     (org-at-heading-p)
+				     (looking-at-p "\n"))
+			   (insert "\n"))))
+		     t (if prefix
+			   nil
+			 'tree)))
+#+end_src
+
+**** Add a before-save-hook
+
+#+begin_src emacs-lisp
+  (defun cribbed/org-mode-fix-blank-lines ()
+    (when (eq major-mode 'org-mode)
+      (let ((current-prefix-arg 4)) ; Emulate C-u
+	(call-interactively 'unpackaged/org-fix-blank-lines))))
+
+  (add-hook 'before-save-hook #'cribbed/org-mode-fix-blank-lines)
+#+end_src
+
 * Appendices
+
 ** Emacs' files
+
 *** init.el
     :PROPERTIES:
     :header-args: :tangle init.el
@@ -871,6 +928,7 @@ I’ve put org mode under Applications, as opposed to Writing, because it’s  m
   #+begin_src emacs-lisp :comments no
   ;; init.el -*- lexical-binding: t -*-
   #+end_src
+
 **** Load config
 
   from [[https://protesilaos.com/dotemacs/#h:584c3604-55a1-49d0-9c31-abe46cb1f028][Protesilaos Stavrou]].
-- 
cgit 1.4.1-21-gabe81