From 57366f385a2f1f35bbe741d7542096db81368c72 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 17 Mar 2011 11:23:07 +0100 Subject: Big changes, last one before I wipe it all. * Added muse * Added graphviz-dot-mode * Remove all trailing whitespace on save. This is the last commit I'm going to do before throwing it all away again. --- emacs.d/elisp/muse/muse-xml.el | 274 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 emacs.d/elisp/muse/muse-xml.el (limited to 'emacs.d/elisp/muse/muse-xml.el') diff --git a/emacs.d/elisp/muse/muse-xml.el b/emacs.d/elisp/muse/muse-xml.el new file mode 100644 index 0000000..9f26ade --- /dev/null +++ b/emacs.d/elisp/muse/muse-xml.el @@ -0,0 +1,274 @@ +;;; muse-xml.el --- publish XML files + +;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +;; Free Software Foundation, Inc. + +;; Author: Michael Olson +;; Date: Sat 23-Jul-2005 + +;; This file is part of Emacs Muse. It is not part of GNU Emacs. + +;; Emacs Muse is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published +;; by the Free Software Foundation; either version 3, or (at your +;; option) any later version. + +;; Emacs Muse is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with Emacs Muse; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; James Clarke's nxml-mode can be used for editing and validating +;; Muse-generated XML files. If you are in nxml-mode use the command +;; C-c C-s C-f to point to the schema in `contrib/muse.rnc', which +;; comes with Muse. Say yes if you are asked if you want to copy the +;; file to your location. C-c C-s C-a can then be used to reload the +;; schema if you make changes to the file. + +;;; Contributors: + +;; Peter K. Lee (saint AT corenova DOT com) made the initial +;; implementation of planner-publish.el, which was heavily borrowed +;; from. + +;; Brad Collins (brad AT chenla DOT org) provided a Compact RelaxNG +;; schema. + +;;; Code: + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Muse XML Publishing +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(require 'muse-publish) +(require 'muse-regexps) +(require 'muse-xml-common) + +(defgroup muse-xml nil + "Options controlling the behavior of Muse XML publishing. +See `muse-xml' for more information." + :group 'muse-publish) + +(defcustom muse-xml-extension ".xml" + "Default file extension for publishing XML files." + :type 'string + :group 'muse-xml) + +(defcustom muse-xml-header + " + (muse-xml-encoding)\"?> + + + <lisp>(muse-publishing-directive \"title\")</lisp> + (muse-publishing-directive \"author\") + (muse-style-element :maintainer) + (muse-publishing-directive \"date\") + + \n" + "Header used for publishing XML files. +This may be text or a filename." + :type 'string + :group 'muse-xml) + +(defcustom muse-xml-footer " + +\n" + "Footer used for publishing XML files. +This may be text or a filename." + :type 'string + :group 'muse-xml) + +(defcustom muse-xml-markup-regexps + `(;; Beginning of doc, end of doc, or plain paragraph separator + (10000 ,(concat "\\(\\(\n\\(?:[" muse-regexp-blank "]*\n\\)*" + "\\([" muse-regexp-blank "]*\n\\)\\)" + "\\|\\`\\s-*\\|\\s-*\\'\\)") + ;; this is somewhat repetitive because we only require the + ;; line just before the paragraph beginning to be not + ;; read-only + 3 muse-xml-markup-paragraph)) + "List of markup rules for publishing a Muse page to XML. +For more on the structure of this list, see `muse-publish-markup-regexps'." + :type '(repeat (choice + (list :tag "Markup rule" + integer + (choice regexp symbol) + integer + (choice string function symbol)) + function)) + :group 'muse-xml) + +(defcustom muse-xml-markup-functions + '((anchor . muse-xml-markup-anchor) + (table . muse-xml-markup-table)) + "An alist of style types to custom functions for that kind of text. +For more on the structure of this list, see +`muse-publish-markup-functions'." + :type '(alist :key-type symbol :value-type function) + :group 'muse-xml) + +(defcustom muse-xml-markup-strings + '((image-with-desc . "%s") + (image . "") + (image-link . "%s.%s") + (anchor-ref . "%s") + (url . "%s") + (link . "%s") + (link-and-anchor . "%s") + (email-addr . "%s") + (anchor . "\n") + (emdash . "%s--%s") + (comment-begin . "") + (rule . "
") + (fn-sep . "
\n") + (no-break-space . " ") + (line-break . "
") + (enddots . "....") + (dots . "...") + (section . "
") + (section-end . "") + (subsection . "
") + (subsection-end . "") + (subsubsection . "
") + (subsubsection-end . "") + (section-other . "
") + (section-other-end . "") + (section-close . "
") + (footnote . "") + (footnote-end . "") + (begin-underline . "") + (end-underline . "") + (begin-literal . "") + (end-literal . "") + (begin-emph . "") + (end-emph . "") + (begin-more-emph . "") + (end-more-emph . "") + (begin-most-emph . "") + (end-most-emph . "") + (begin-verse . "\n") + (begin-verse-line . "") + (end-verse-line . "") + (empty-verse-line . "") + (begin-last-stanza-line . "") + (end-last-stanza-line . "") + (end-verse . "") + (begin-example . "") + (end-example . "") + (begin-center . "

\n") + (end-center . "\n

") + (begin-quote . "
\n") + (end-quote . "\n
") + (begin-cite . "") + (begin-cite-author . "") + (begin-cite-year . "") + (end-cite . "") + (begin-quote-item . "

") + (end-quote-item . "

") + (begin-uli . "\n") + (end-uli . "\n") + (begin-uli-item . "") + (end-uli-item . "") + (begin-oli . "\n") + (end-oli . "\n") + (begin-oli-item . "") + (end-oli-item . "") + (begin-dl . "\n") + (end-dl . "\n") + (begin-dl-item . "\n") + (end-dl-item . "\n") + (begin-ddt . "") + (end-ddt . "") + (begin-dde . "") + (end-dde . "") + (begin-table . "\n") + (end-table . "") + (begin-table-row . " \n") + (end-table-row . " \n") + (begin-table-entry . " <%s>") + (end-table-entry . "\n")) + "Strings used for marking up text. +These cover the most basic kinds of markup, the handling of which +differs little between the various styles." + :type '(alist :key-type symbol :value-type string) + :group 'muse-xml) + +(defcustom muse-xml-encoding-default 'utf-8 + "The default Emacs buffer encoding to use in published files. +This will be used if no special characters are found." + :type 'symbol + :group 'muse-xml) + +(defcustom muse-xml-charset-default "utf-8" + "The default XML charset to use if no translation is +found in `muse-xml-encoding-map'." + :type 'string + :group 'muse-xml) + +(defun muse-xml-encoding () + (muse-xml-transform-content-type + (or (and (boundp 'buffer-file-coding-system) + buffer-file-coding-system) + muse-xml-encoding-default) + muse-xml-charset-default)) + +(defun muse-xml-markup-paragraph () + (let ((end (copy-marker (match-end 0) t))) + (goto-char (match-beginning 0)) + (when (save-excursion + (save-match-data + (and (not (get-text-property (max (point-min) (1- (point))) + 'muse-no-paragraph)) + (re-search-backward "<\\(/?\\)p[ >]" nil t) + (not (string-equal (match-string 1) "/"))))) + (when (get-text-property (1- (point)) 'muse-end-list) + (goto-char (previous-single-property-change (1- (point)) + 'muse-end-list))) + (muse-insert-markup "

")) + (goto-char end)) + (cond + ((eobp) + (unless (bolp) + (insert "\n"))) + ((get-text-property (point) 'muse-no-paragraph) + (forward-char 1) + nil) + ((eq (char-after) ?\<) + (when (looking-at (concat "<\\(format\\|code\\|link\\|image" + "\\|anchor\\|footnote\\)[ >]")) + (muse-insert-markup "

"))) + (t + (muse-insert-markup "

")))) + +(defun muse-xml-finalize-buffer () + (when (boundp 'buffer-file-coding-system) + (when (memq buffer-file-coding-system '(no-conversion undecided-unix)) + ;; make it agree with the default charset + (setq buffer-file-coding-system muse-xml-encoding-default)))) + +;;; Register the Muse XML Publisher + +(muse-define-style "xml" + :suffix 'muse-xml-extension + :regexps 'muse-xml-markup-regexps + :functions 'muse-xml-markup-functions + :strings 'muse-xml-markup-strings + :specials 'muse-xml-decide-specials + :after 'muse-xml-finalize-buffer + :header 'muse-xml-header + :footer 'muse-xml-footer + :browser 'find-file) + +(provide 'muse-xml) + +;;; muse-xml.el ends here -- cgit v1.2.3-54-g00ecf