;; -*- coding: utf-8 -*- ;; part of Xah Lee's emacs init file. ;; 2011-05-28 ;; Xah Lee, ;; ∑ http://xahlee.org/ (defun make-blogger-entry () "Make a blogger entry. Copy the current buffer. create a new buffer. Make it html-mode. paste it in. remove the header and footer. fix all relative links to http://xahlee.org/ links. add a “Perm URL with updates: ‹link›” sentence at top. This new content is ready to be posted to blogger." (interactive) (let (bds p1 p2 cssStr mainText thisFilePath currentDir newBuff permLink) (setq bds (get-selection-or-unit 'buffer)) (setq mainText (elt bds 0) ) (setq p1 (elt bds 1) ) (setq p2 (elt bds 2) ) (setq thisFilePath (buffer-file-name)) (setq currentDir (file-name-directory thisFilePath)) (setq newBuff (generate-new-buffer "*blogger temp*")) (switch-to-buffer newBuff) (html-mode) (insert mainText) ;; get css declaration, if any (let (p3 p4 ) (goto-char 1) (if (search-forward "") (setq p4 (point) ) (setq cssStr (buffer-substring-no-properties p3 p4)) ) (progn (setq cssStr "") ) ) ) ;; remove header (goto-char 1) (when (search-forward "
[^<]+?
" ""] ["Xah Lee, [-<>/ ,…time0-9]+?
" ""] ["" ""] ["Perm URL with updates: " "" permLink "" "
\n\n") ) ;; insert css string (goto-char 1) (insert cssStr "\n\n") (replace-regexp-pairs-region 1 (point-max) '( ["\n\n+" "\n\n"] )) (goto-char 1) (kill-new (buffer-string)) ))