Custom editor setup for Pelican

This commit is contained in:
Bob Mottram 2017-03-26 12:50:52 +01:00
parent a6f77d84cf
commit f29191d71f
1 changed files with 52 additions and 16 deletions

View File

@ -49,6 +49,27 @@ pelican_variables=(MY_USERNAME
PELICAN_BLOG_DOMAIN
PELICAN_BLOG_CODE)
function pelican_editor_config {
if [ ! -f $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican ]; then
echo "(add-hook 'before-save-hook 'delete-trailing-whitespace)" > $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo '(setq org-support-shift-select t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo '(setq standard-indent 4)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo '(setq-default tab-width 4)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo '(setq c-basic-offset 4)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo '(mouse-wheel-mode t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo '(setq make-backup-files t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo '(setq version-control t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo '(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo "(setq default-major-mode 'text-mode)" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo "(dolist (hook '(text-mode-hook))" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo ' (add-hook hook (lambda () (flyspell-mode 1))))' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo '(setq-default fill-column 72)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo '(setq auto-fill-mode 0)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo "(add-hook 'text-mode-hook 'turn-on-auto-fill)" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
echo "(setq-default auto-fill-function 'do-auto-fill)" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
fi
}
function pelican_regenerate_blog {
clear
echo ''
@ -61,6 +82,7 @@ function pelican_regenerate_blog {
function pelican_new_blog {
DATESTR=$(date "+%Y-%m-%d %H:%M:%S")
if [ ! -f $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry ]; then
echo $'Title: Blog Post Title' > $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
echo $"Date: ${DATESTR}" >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
echo $"Author: $(toxid --showuser)" >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
@ -74,8 +96,13 @@ function pelican_new_blog {
echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
echo $'![My image]({filename}images/myimage.jpg)' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
fi
if [ -f /usr/bin/emacs ]; then
emacs -q --load $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
else
editor $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
fi
if grep -q $"Add your text here" $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry; then
return
@ -108,8 +135,14 @@ function pelican_edit_blog {
if [ ! -f $LAST_BLOG_ENTRY ]; then
return
fi
if [ -f /usr/bin/emacs ]; then
emacs -q --load $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican $LAST_BLOG_ENTRY
else
editor $LAST_BLOG_ENTRY
regenerate_blog
fi
pelican_regenerate_blog
}
function pelican_delete_blog {
@ -653,6 +686,9 @@ function install_pelican {
chown -R $MY_USERNAME:$MY_USERNAME $PELICAN_BLOG_INSTALL_DIR
chown -R www-data:www-data $PELICAN_BLOG_PATH
pelican_editor_config
APP_INSTALLED=1
}