Last active
January 21, 2024 20:05
-
-
Save tkurtbond/c4aa39ee5649688a34b10dc400cc858c to your computer and use it in GitHub Desktop.
Don't auto fill metadata lines in Nikola reST files.
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
;; Nikola metadata lines start like this: | |
;; .. keyword: | |
;; They shouldn't be wrapped. | |
(defvar tkb-nikola-metadata-regexp "\\.\\. [a-z]+:") | |
(defun tkb-nikola-rest-fill-nobreak-p () | |
"Don't fill on metadata lines in nikola reST posts." | |
(save-excursion | |
(beginning-of-line) | |
(looking-at tkb-nikola-metadata-regexp))) | |
(defun tkb-nikola-rest-hook () | |
(interactive) | |
(when (and (string-match "\\.rst\\'" (buffer-file-name)) | |
(looking-at tkb-nikola-metadata-regexp)) | |
(make-local-variable 'fill-nobreak-predicate) | |
(setq fill-nobreak-predicate (list #'tkb-nikola-rest-fill-nobreak-p)))) | |
(add-to-list 'find-file-hook #'tkb-nikola-rest-hook) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment