;; Helper keybindings for weblogger mode ;; ;; ;; Copyright (c) 2009 Akarsh Simha ;; ;; License: The GNU General Public License version 3 ;; (http://www.gnu.org/copyleft/gpl.html) ;; Define destination directory / URL root for uploaded files ;; TODO: Replace the following (setq weblogger-upload-dest "foo@host:path/blog_files/") ;; scp destination prefix (setq weblogger-upload-url "http://foodomain.com/path/blog_files/") ;; base URL for web links ;; Upload a file to the server (defun weblogger-upload-file (filename) (interactive "FFind file: ") ;; Let the user find the file interactively if no filename is supplied (setq destfname (car (last (split-string filename "/")))) (shell-command (concat "scp " filename " " weblogger-upload-dest destfname) "*Upload Output*") (concat weblogger-upload-url destfname) ) ;; Upload a file to server and insert a link at point (defun weblogger-insert-file (filename) (interactive "FFind file: ") ;; Let the user find the file interactively if no filename is supplied (insert (concat "")) (backward-char 4) ) ;; Upload an image to server and insert a tag at point (defun weblogger-insert-image (filename) (interactive "FFind file: ") ;; Let the user find the file interactively if no filename is supplied (insert "\"\"") ) (defun weblogger-insert-image-scale (filename) (interactive "FFind file: ") ;; Let the user find the file interactively if no filename is supplied (setq image-url (weblogger-upload-file filename)) (insert " \"\" ") ) ;; Load TexDrive to get LaTeX support (load-file "~/.emacs.d/texdrive.el") ;; ;; NOTE: Ugly code. This screws up a good lot of defintions from ;; texdrive. Don't use this if you are going to use texdrive without ;; for purposes other than your blog. ;; ;; Override texdrive-insert-formula to prepend the upload URL to the ;; filename (defun weblogger-insert-formula (tex title) (interactive "sFormula (TeX):\nsTitle:") (insert (concat ""))) ;; Tailored version of texdrive-buffer-formulae-assoc for weblogger ;; purposes (defun weblogger-tex-buffer-formulae-assoc () "return an assoc of ( ) starting for the whole buffer" (save-excursion (goto-char 0) (weblogger-tex-formulae-assoc))) ;; Tailor texdrive-formulae-assoc to avoid capturing the prepended ;; base URL (weblogger-upload-url) (defun weblogger-tex-formulae-assoc () "return an assoc of ( ) starting from point" (when (re-search-forward (concat "