X-Git-Url: https://git.korewanetadesu.com/?p=pelican-mode.git;a=blobdiff_plain;f=pelican-mode.el;h=df0503f3a785931bb4f02a0b67c55585e8c60ca1;hp=15db6cf6bf48006db64715024514be8b4d638e20;hb=993581b3d5ab84df353d312cac09b803c782795b;hpb=05e7356c4e6e5a61737c323837684acdc38efc69 diff --git a/pelican-mode.el b/pelican-mode.el index 15db6cf..df0503f 100644 --- a/pelican-mode.el +++ b/pelican-mode.el @@ -103,15 +103,19 @@ (defun pelican-set-field (field value) "Set FIELD to VALUE." + (interactive "sField: \nsValue: ") (save-excursion (goto-char 0) (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))))) (defun pelican-set-title (title) "Set the title to TITLE." + (interactive "sTitle: ") (if (pelican-is-markdown) (pelican-set-field "title" title) (save-excursion @@ -172,20 +176,12 @@ "Check if this buffer is under a Pelican site." (not (null (pelican-find-root)))) -(defun pelican-enable-if-site () - "Enable `pelican-mode' if this buffer is under a Pelican site." - (when (pelican-is-in-site) - (pelican-mode 1))) - (defun pelican-make (target) "Execute TARGET in a Makefile at the root of the site." (interactive "sMake Pelican target: ") - (if-let ((default-directory (pelican-find-root))) - (let ((output (get-buffer-create "*Pelican Output*"))) - (display-buffer output) - (pop-to-buffer output) - (compilation-mode) - (start-process "Pelican Makefile" output "make" target)) + (if-let (default-directory (pelican-find-root)) + (compilation-start (format "make %s" target) + nil (lambda (_) "*pelican*")) (message "This doesn't look like a Pelican site."))) (defun pelican-make-html () @@ -217,12 +213,18 @@ "Toggle Pelican mode. Interactively with no argument, this command toggles the mode. -to show buffer size and position in mode-line." +for editing Pelican site files." :init-value nil :lighter " Pelican" :keymap pelican-keymap :group 'pelican) +;;;###autoload +(defun pelican-enable-if-site () + "Enable `pelican-mode' if this buffer is under a Pelican site." + (when (pelican-is-in-site) + (pelican-mode 1))) + ;;;###autoload (add-hook 'markdown-mode-hook 'pelican-enable-if-site)