X-Git-Url: https://git.korewanetadesu.com/?p=pelican-mode.git;a=blobdiff_plain;f=pelican-mode.el;h=5fbd12965d455488767e38c02145add04da892fe;hp=2fa86e1cd30382bcaeacacc1ee80754a55779523;hb=6961723664a6a705c7ee05e6f0e508610ae0a108;hpb=a6411acffe11f155e2a5e7fb6b3e4749e2c3d38f diff --git a/pelican-mode.el b/pelican-mode.el index 2fa86e1..5fbd129 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." @@ -147,12 +153,12 @@ the unquoted printed representation of it is used: (defun pelican-update-date () "Update a Pelican date header." (interactive) - (pelican-set-field "date" (pelican-timestamp))) + (pelican-set-field :date 'now)) (defun pelican-publish-draft () "Remove draft status from a Pelican post." (interactive) - (pelican-set-field "status" nil) + (pelican-remove-field :status) (pelican-update-date)) (defun pelican-page-p ()