projects
/
pelican-mode.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3315a18
)
Clean up title setting logic.
author
Joe Wreschnig
<joe.wreschnig@gmail.com>
Sun, 18 Jun 2017 18:56:12 +0000
(20:56 +0200)
committer
Joe Wreschnig
<joe.wreschnig@gmail.com>
Sun, 18 Jun 2017 18:56:12 +0000
(20:56 +0200)
pelican-mode.el
patch
|
blob
|
history
diff --git
a/pelican-mode.el
b/pelican-mode.el
index
f82be8a
..
15db6cf
100644
(file)
--- a/
pelican-mode.el
+++ b/
pelican-mode.el
@@
-49,12
+49,16
@@
(t (error "Unsupported major mode %S" major-mode)))
""))
(t (error "Unsupported major mode %S" major-mode)))
""))
+(defun pelican-rst-title (title)
+ "Create a ReSt version of TITLE."
+ (concat title "\n" (make-string (string-width title) ?#) "\n\n"))
+
(defun pelican-title (title)
"Format a TITLE for the current document, according to major mode."
(cond ((derived-mode-p 'markdown-mode)
(pelican-field "title" title))
((derived-mode-p 'rst-mode)
(defun pelican-title (title)
"Format a TITLE for the current document, according to major mode."
(cond ((derived-mode-p 'markdown-mode)
(pelican-field "title" title))
((derived-mode-p 'rst-mode)
- (
concat title "\n" (make-string (string-width title) ?#) "\n"
))
+ (
pelican-rst-title title
))
(t (error "Unsupported major mode %S" major-mode))))
(defun pelican-header (title date status category tags slug)
(t (error "Unsupported major mode %S" major-mode))))
(defun pelican-header (title date status category tags slug)
@@
-106,6
+110,17
@@
(re-search-forward "^$")
(replace-match (pelican-field field value)))))
(re-search-forward "^$")
(replace-match (pelican-field field value)))))
+(defun pelican-set-title (title)
+ "Set the title to TITLE."
+ (if (pelican-is-markdown)
+ (pelican-set-field "title" title)
+ (save-excursion
+ (goto-char 0)
+ (let ((header (pelican-rst-title title)))
+ (if (looking-at ".*\n#+\n+")
+ (replace-match header)
+ (insert header))))))
+
(defun pelican-update-date ()
"Update a Pelican date header."
(interactive)
(defun pelican-update-date ()
"Update a Pelican date header."
(interactive)
@@
-208,7
+223,6
@@
to show buffer size and position in mode-line."
:keymap pelican-keymap
:group 'pelican)
:keymap pelican-keymap
:group 'pelican)
-
;;;###autoload
(add-hook 'markdown-mode-hook 'pelican-enable-if-site)
;;;###autoload
(add-hook 'markdown-mode-hook 'pelican-enable-if-site)