Linux.com

Feature

Writing and publishing with Emacs Muse

By on April 09, 2007 (8:00:00 AM)

Share    Print    Comments   

Emacs a text editor, but it can be much more: a personal information manager, task manager, and an email client, for instance. For me, Emacs is a tool for writing and publishing -- especially when used with Muse mode.

Maintained by Michael Olson, Muse mode combines an easy-to-learn markup language for authoring documents with a set of styles for generating output in several formats, including:

  • LaTeX, using either the standard book or article class
  • Texinfo
  • PDF, based on LaTeX
  • HTML and XHTML
  • DocBook XML
  • Blosxom (a lightweight blogging tool)

Some of the uses that people have put Muse to include documentation and tutorials, Web pages, recipes and poems, blogs, and knowledge bases. Since I started using Muse last year, I've output LaTeX, HTML/XHTML, DocBook, and PDF files. After a bit of tweaking, the results have been very good.

Getting and installing Muse

You can download Muse directly from the project Web site. You can choose either a stable release or the latest development version. Once you've downloaded Muse, just extract the archive to your hard drive and add the following block of text to your .emacs file:

(add-to-list 'load-path "/home/scott/elisp/muse_latest/lisp")
(require 'muse-mode)
(require 'muse-html)
(require 'muse-latex)
(require 'muse-texinfo)
(require 'muse-docbook)
(require 'muse-book)

Once you've installed Muse, you can also byte-compile it. Byte-compiling is an Emacs process that turns Lisp files (the programming language in which Muse and other Emacs extensions are written) into code that Emacs can execute faster. I have a fairly fast laptop, so I didn't notice much of a difference between the byte-compiled and uncompiled versions of Muse, but your mileage may vary.

Change the load path to where you installed Muse, then fire up Emacs and start writing.

Using Muse markup

Muse's markup language is simple to learn. For the most part, you don't need to remember a bunch of tags, as you would with HTML or XML. Instead, Muse uses keyboard symbols to denote how text is formatted. For example, put one or more asterisks (*) before text to make it a heading. Type a space followed by a dash or a number to create a bulleted or numbered list. Surround text with one or more asterisks to set the text in bold or italics.

A Muse source document being edited in Emacs
A Muse source document being edited in Emacs - click to enlarge

If you think the Muse markup is wiki-like, you're not far off the mark. Muse is based on Emacs wiki mode and recycles much of the markup. But Muse also expands on it with a number of additional tags.

Some of the tags are HTML- or XML-like, right down to being surrounded by angle brackets. The tag <contents>, for instance, generates a table of contents at the beginning of a document. The <example> tag sets a block of text in monospace type, and is used for code samples.

Muse also supports hyperlinks, images, and tables with wiki-like markup directives. The Muse manual has a comprehensive explanation of all the supported markup.

Publishing files

Once you've written and marked up a document, you can publish it. Save your document and then type Esc-x muse-publish-this-file and press Enter. (Alternatively, you can publish a file that's elsewhere on your hard drive using the muse-publish-file command.)

You'll be prompted for the type of output you want to create. If you don't remember the available publishing styles, press the Tab key to view a list of them. Type the name of the style you want to use -- for example, pdf. Emacs will prompt you for the directory in which you want to output the file. You can press Enter to use the directory in which you saved your source file, or you can type the path to a different one.

Once you've done that, Emacs will publish your document. The speed of publishing depends on the size of your source file and the output format you choose. I've output 30-page PDF files in just a few seconds; HTML and XHTML files take even less time.

Customizing your output

One aspect of Muse that I don't like is that it uses the standard LaTeX article and book classes to generate LaTeX and PDF files. Visually, I don't find either appealing. But that's easy to change; you can switch to just about any LaTeX document class.

To make changes, edit the files muse-latex.el and muse-book.el. Find the entries \\documentclass{article} and \\documentclass{book} and change the document classes to whatever you like. I'm partial to replacing the article class with the hitec, refart, or paper classes. For the book class, good replacements are the memoir and scrbook classes.

Bear in mind that if you've byte-compiled the Muse files, you'll need to byte-compile muse-latex.el and muse-book.el again before your changes take effect.

The HTML and XHTML that Muse outputs is surprisingly compliant with Web standards. The XHTML output embeds a Cascading Style Sheet in the file. The styles are simple and functional, but they might not be what you're looking for. You can change them by adding the muse-htmlstyle-sheet option to the header of your document, and then adding your stylesheet information, as documented in the Muse manual.

Conclusion

If you do any sort of writing, Emacs Muse is a great way to not only author your work but publish it as well. The markup used is easy to learn, and you have many options for converting your source documents into a usable format.

If you don't think that Muse can be used for creating "professional" documents, think again. I've used it to publish several reports and a couple of short manuals for various clients -- as well as this article!

Scott Nesbitt is a writer based in Toronto, Canada, who thinks that he's found the writing tool he's always been looking for in Emacs Muse.

Share    Print    Comments   

Comments

on Writing and publishing with Emacs Muse

Note: Comments are owned by the poster. We are not responsible for their content.

One thing

Posted by: Anonymous Coward on April 09, 2007 11:55 PM
"Do one thing, and do it well."

Why don't people just use a simple text editor?
Why would they want to bloat it with task manager and e-mail functionality?

Stay true to the roots...

#

Bloat-esque

Posted by: Anonymous Coward on April 10, 2007 12:06 AM
> Why don't people just use a simple text editor?
> Why would they want to bloat it with task manager and e-mail functionality?

Because it's not actually bloated until you use the extra functionality. In other words, the functionality is extra. It sits on disk until you need it, and disk is cheap.

The price you pay for having an extensible text editor is that people will extend it.

Karl O. Pinc kop at meme com

#

Re:Bloat-esque

Posted by: Administrator on April 10, 2007 02:46 AM


Why don't people just use a simple text editor?
Why would they want to bloat it with task manager and e-mail functionality?


Because it's not actually bloated until you use the extra functionality. In other words, the functionality is extra. It sits on disk until you need it, and disk is cheap.



100% agreed. The unix philosophy of "do one thing, do it well" is all very well, but you have to know what level to apply it to. Emacs is really more of a platform than a simple program, and is probably more complex than a whole OS was back in <a href="http://en.wikipedia.org/wiki/Unix_philosophy" title="wikipedia.org">Doug McIlroy's</a wikipedia.org> days. In this context it is Muse-mode that is the program, and it does indeed do one thing and do it well (although I prefer org-mode myself).

#

Re:One thing

Posted by: Anonymous Coward on April 10, 2007 10:19 PM
Because simple text editors aren't enough for modern interactive development.

#

Re:One thing

Posted by: Anonymous Coward on April 11, 2007 02:33 AM
>>"Do one thing, and do it well."

>>Why don't people just use a simple text editor?
>>Why would they want to bloat it with task manager and e-mail functionality?

I would argue that Emacs _does_ do one thing well; that is, it's a text editor. It just happens to handle a wider variety of text than most other editors. And there in lies its beauty. Why learn one program to edit texts, another to write a program in C, another to create/edit web pages, yet another to help organize your daily tasks and still another to write/read email/USENET? And no one said you have to learn/use ALL the modes/features; just learn the ones you need now and leave the rest for if/when you need them later.

In fact, I rank Emacs as my #1 program, aside from from GNU/Linux OS, that is.<nobr> <wbr></nobr>;)

#

Edit variables, not the source files.

Posted by: Anonymous Coward on April 10, 2007 12:21 AM
Instead of editing the muse-latex.el and muse-book.el files, just use customize on the muse-latex-header and muse-book-latex-header variables. Upgrades to new versions of muse will be much smoother.

#

Muse mode is great

Posted by: Anonymous Coward on April 10, 2007 02:29 AM
Muse mode is great. Another mode worth mentioning is org-mode, a GTD-friendly minor mode based on the outliner code.

I no longer use Emacs for my main editing (I tend to use jEdit), but org-mode is so awesome that I have trouble getting rid of Emacs altogether.

#

Re:Muse mode is great

Posted by: Anonymous Coward on April 10, 2007 10:17 PM
I've found that, while there are good environments for industry-popular languages like Java and PHP, there aren't any free ones for things like Perl, Erlang, Lisp, etc. In the case where you have to use something that's not industry standard, chances are that there's an awesome, well-tested Emacs mode for it.

Especially Perl -- there's no worthwhile (i.e. not Eclipse + EPIC) free IDE for writing Perl. Emacs with ecb-minor-mode is far and away the best solution right now.

#

Muse markup

Posted by: Anonymous Coward on April 10, 2007 08:23 AM
As I see it, Muse consists of
(1) A comprehensive publishing system, integrated with Emacs
(2) The actual Muse markup language

While (1) is great; I think (2) is really not... there are already quite a few nice languages out there (like Markdown); it would be nice if Emacs Muse came with inbuilt support for a bunch of them.

#

Re:Muse markup

Posted by: Anonymous Coward on April 10, 2007 10:01 PM
I totally agree with this. Muse should support existing markups rather than create its own.

#

Re:Muse markup

Posted by: Anonymous Coward on April 10, 2007 10:14 PM
Strictly speaking, it's not using it's own.

It's basically using the same meta-markup that all of outline/planner/org modes are based on, as they all share a common heritage.

#

Muse as a way of life

Posted by: Anonymous Coward on April 10, 2007 11:12 PM
Muse is a wonderful tool for cataloging your information both inside and out of Emacs.

For instance, you can use the markup to include files etc. <include file="RubyResources.muse">

Muse can execute arbitrary emacs code when a page is entered: <lisp>(set-background-color "white")</lisp><nobr> <wbr></nobr>...or you can evaluate an emacs function, which works with TRAMP too:

(find-file "/root@example.com:~/syslog.txt")<nobr> <wbr></nobr>...plus you can use the start-process-shell-command to integrate with Nautilus etc.

These techniques allow you to organize all your project information across various technologies.

#

Re:Muse as a way of life

Posted by: Anonymous Coward on April 10, 2007 11:16 PM
stick this in your<nobr> <wbr></nobr>.emacs:

(defun browse-dir (dir-as-string)

                (start-process-shell-command

                  "browse"

                  "*scratch*"

                  (concat "/usr/bin/nautilus --no-desktop " dir-as-string)))

then evaluate in Muse:

(browse-dir "~/prj/something-lispy/")

#

Hmmm

Posted by: Anonymous Coward on April 11, 2007 03:47 AM
Seems a bit buggy, just tried to make a simple pdf:

! Package inputenc Error: Keyboard character used is undefined
(inputenc) in inputencoding `latin1'.

#

Sounds like AsciiDoc

Posted by: Anonymous Coward on April 12, 2007 10:30 AM
I've been using <a href="http://www.methods.co.nz/asciidoc/" title="methods.co.nz">AsciiDoc</a methods.co.nz> for a while now, and I'm quite happy with it. Output in a dozen (or so) different formats, wiki-like markup...it's worth a look.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya