Handle reST/Markdown title differences in `pelican-set-field’.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Sun, 30 Jul 2017 13:47:36 +0000 (15:47 +0200)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Sun, 30 Jul 2017 13:48:36 +0000 (15:48 +0200)
Add `pelican-remove-field’ helper function.

pelican-mode.el

index 2fa86e1cd30382bcaeacacc1ee80754a55779523..fc9de9b496f34755147c0303b0b0a4aa94cbe72b 100644 (file)
@@ -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."