Skip to content

Instantly share code, notes, and snippets.

@tkurtbond
Last active January 21, 2024 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkurtbond/c4aa39ee5649688a34b10dc400cc858c to your computer and use it in GitHub Desktop.
Save tkurtbond/c4aa39ee5649688a34b10dc400cc858c to your computer and use it in GitHub Desktop.
Don't auto fill metadata lines in Nikola reST files.
;; 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