;;; csm-blosxom.el -- update a blosxom journal. ;;; Copyright (C) 2004 Casey Marshall ;;; ;;; Permission to use, copy, modify, distribute, and sell this software and its ;;; documentation for any purpose is hereby granted without fee, provided that ;;; the above copyright notice appear in all copies and that both that ;;; copyright notice and this permission notice appear in supporting ;;; documentation. No representations are made about the suitability of this ;;; software for any purpose. It is provided "as is" without express or ;;; implied warranty. ;;; ;;; Post journal entries to a blosxom journal, uploading by saving via ;;; ange-ftp. Bits based on jwz-lj.el. (require 'ange-ftp) ;; Obviously, these are customizable for others. (defvar csm-blosxom-post-suffix ".txt") (defvar csm-blosxom-host "metastatic.org") (defvar csm-blosxom-user "rsdio") (defvar csm-blosxom-path "metastatic.org/text/concern/blosxom") (setq csm-blosxom-mode-map (make-sparse-keymap)) (set-keymap-parent csm-blosxom-mode-map text-mode-map) (define-key csm-blosxom-mode-map "\C-c\C-c" 'csm-blosxom-post-entry) (defun csm-blosxom-mode () (interactive) (html-mode) (use-local-map csm-blosxom-mode-map) (setq mode-name "blosxom") (setq major-mode 'csm-blosxom-mode) (run-hooks 'csm-blosxom-mode-hooks)) (defun csm-blosxom-post-entry () (interactive) (unless csm-blosxom-user (setq csm-blosxom-user (user-login-name))) (save-excursion (save-restriction (widen) (goto-char (point-min)) ;; Make a file name from the title, which is the first line of the file. ;; Only consider words separated by spaces or dashes; replace spaces ;; with dashes, lower the case. (if (re-search-forward "^\\(\\w+[- ]+\\)*\\(\\w\\|[-]\\)+" nil t) (setq subject (subst-char-in-string ?\ ?- (downcase (match-string 0)))) (setq subject "blosxom")) (setq count 0) (setq file-name nil) (setq file-path (concat "/" csm-blosxom-user "@" csm-blosxom-host ":" csm-blosxom-path)) ;; If we happen to already have an entry with that title, append -XX to ;; the name we creeated above, for increasing integers. (while (or (null file-name) (file-exists-p (concat file-path "/" file-name))) (if (= count 0) (setq file-name (concat subject csm-blosxom-post-suffix)) (setq file-name (concat subject "-" (format "%02x" count) csm-blosxom-post-suffix))) (setq count (1+ count))) (write-file (concat file-path "/" file-name)))) (kill-buffer nil)) (defun csm-blosxom-compose () "*Compose a blosxom journal entry. Use C-c C-c to post." (interactive) (switch-to-buffer (generate-new-buffer "*blosxom*")) (erase-buffer) (csm-blosxom-mode)) (provide 'csm-blosxom)