From: Joe Wreschnig Date: Sun, 30 Jul 2017 13:47:36 +0000 (+0200) Subject: Handle reST/Markdown title differences in `pelican-set-field’. X-Git-Tag: v20170807~28 X-Git-Url: https://git.korewanetadesu.com/?a=commitdiff_plain;h=0629935734a1ee35d4657ea862b8ca5205f7198e;p=pelican-mode.git Handle reST/Markdown title differences in `pelican-set-field’. Add `pelican-remove-field’ helper function. --- diff --git a/pelican-mode.el b/pelican-mode.el index 2fa86e1..fc9de9b 100644 --- a/pelican-mode.el +++ b/pelican-mode.el @@ -125,12 +125,18 @@ the unquoted printed representation of it is used: (interactive "sField: \nsValue: ") (save-excursion (goto-char 0) + (when (and (derived-mode-p 'rst-mode) + (re-search-forward "^#" nil t)) + (forward-line 2)) (if (re-search-forward (concat "^" (pelican-field field ".+*")) nil t) (replace-match (pelican-field field value)) - (re-search-forward "#") - (forward-line 2) - (re-search-forward "^$") - (replace-match (pelican-field field value))))) + (when value + (re-search-forward "^$") + (replace-match (pelican-field field value)))))) + +(defun pelican-remove-field (field) + "Remove FIELD." + (pelican-set-field field nil)) (defun pelican-set-title (title) "Set the title to TITLE."