+Pelican is a static site generator which can process a variety of
+text file formats. For more information, see URL
+https://blog.getpelican.com/.
+
+Rather than manually enabling this mode, you may wish to use
+`pelican-global-mode' or `pelican-mode-enable-if-site'.
+
+When Pelican mode is enabled, additional commands are available
+for editing articles or pages:
+
+\\{pelican-mode-map}"
+ :group 'pelican-mode
+ :require 'pelican-mode
+ :keymap pelican-mode-map
+ :lighter " Pelican")
+
+;;;###autoload
+(define-globalized-minor-mode pelican-global-mode pelican-mode
+ (lambda ()
+ (when (derived-mode-p #'text-mode)
+ (pelican-mode-enable-if-site)))
+ :group 'pelican-mode
+ :require 'pelican-mode)
+
+;;;###autoload
+(defun pelican-mode-enable-if-site ()
+ "Enable `pelican-mode' if this buffer is part of a Pelican site.
+
+Pelican sites are detected by looking for a file named `pelicanconf.py'
+in an ancestor directory."
+ (when (pelican-mode-find-root)
+ (pelican-mode)))
+
+\f
+
+;; User Commands
+
+(defun pelican-mode-set-field (field value)
+ "Set FIELD to VALUE.
+
+FIELD may be a string or a symbol; if it is a symbol, the
+symbol name is used (removing a leading ':' if present).
+
+When called from Lisp, VALUE may be any value; except for the
+following special values, the unquoted printed representation of
+it is used:
+
+- `now' means the current time.
+
+- `slug' means the file's path relative to the document root sans
+ extension; see `pelican-mode-default-slug'.
+
+- nil or an empty string removes the field.
+
+The buffer must be in a format listed in `pelican-mode-formats'
+for this function to work correctly."
+ (interactive "sField: \nsValue: ")
+ (setq value (pcase value
+ ('now (format-time-string "%Y-%m-%d %H:%M"))
+ ('slug (pelican-mode-default-slug))
+ ('"" nil)
+ (_ value)))
+ (when (symbolp field)
+ (setq field (string-remove-prefix ":" (symbol-name field))))
+ (let ((set-field
+ (assoc-default nil pelican-mode-formats #'derived-mode-p)))
+ (unless set-field
+ (error "Unsupported major mode %S" major-mode))
+ (save-excursion
+ (goto-char 0)
+ (funcall set-field field value))))
+
+(defun pelican-mode-remove-field (field)
+ "Remove FIELD."
+ (interactive "sField: ")
+ (pelican-mode-set-field field nil))
+
+(defun pelican-mode-set-title (title)
+ "Set the title to TITLE."
+ (interactive "sTitle: ")
+ (pelican-mode-set-field :title title))
+
+(defun pelican-mode-update-date (&optional original)
+ "Update the document's modification date.
+
+If ORIGINAL is non-nil, the publication date is updated rather
+than the modification date."
+ (interactive "P")
+ (pelican-mode-set-field (if original :date :modified) 'now))
+
+(defun pelican-mode-publish ()
+ "Remove draft or hidden status from a Pelican article."
+ (interactive)
+ (pelican-mode-remove-field :status)
+ (pelican-mode-update-date :date))
+
+(defun pelican-mode-insert-article-header (title tags)
+ "Insert a Pelican header for an article with a TITLE and TAGS."