Emacs can be used for editing MoinMoin pages: just copy/paste from your browser to emacs, edit, copy/paste back to browser.

Installation

  1. Download moinmoin-mode.el and install in your Emacs load path. Make sure the file name is moinmoin-mode.el. This mode provides moinmoin-mode with outline-mode–based hierarchical navigation and fontification.

  2. Download and install screen-lines.el and install in your Emacs load path. This mode by Yuji Minejima allows to edit long lines without breaking them—this is very handy, for example, if you want to be compatible with GUI editors.

  3. Add (require 'moinmoin-mode) to your initialization file (e.g., .emacs.el)

    screen-lines is unnecessary here. Recent emacsen have longlines-mode built-in, which achieves the same thing. See the attached file. -- JonathanLange

Use M-x moinmoin-mode to start moinmoin-mode or use files with .wiki extension to load it automatically.

If you use Firefox/Iceweasel, you will find this extension is wonderful: It's All Text! It enables firefox to edit the moinmoin page through Emacs! But note that, if you are using NTEmacs in Windows, things will be a little different.

  1. You have to set a environment variable in Windows.
    • Right click on "My Computer", click "Properties", select "Advanced" tab, click "Environment Variables", add a new variable in "User variables for [UID]" with Name "HOME" and Value "/path/to/your/.emacs", and click "OK" to finish.

  2. You can choose your editor as "emacs" or "emacsclient" in the preferences setting dialog of It's All Text!.

    • If you choose emacs, every time you want to do edit, a new eamcs instance will be launched; while emacsclient is chosen, you have to make sure that you have already start the emacs server.

      And, if you are annoyed with that Windows CMD window every time you execute emacsclient, you may pass an additional argument to emacsclient, which is -n. Right now you can not do this using It's All Text! directly, but have to hack it.

    • Find the js files It's All Text! installed in your Firfox profile directory.

    • Open cacheobj.js, go to line 264, change this line to args = ["-n", filename].

    • Restart you Firefox, and that's it.
  3. One more thing, you can put ".wiki" at the beginning of "File Extensions" in preferences setting dialog of It's All Text!, and the moinmoin-mode can be automatically enabled.

Features

This mode provide several facilities:

Tutorial

This is a small tutorial:

Open an empty file and execute M-x moinmoin-mode. If the installation was OK you will see MoinMoin on your mode line. Start to type something using MoinMoin markup, for example,

Some `typewriter text,` ''italic text,'' '''bold text''', and even __underlined text__.

If fontification is enabled you should see each text with appropriate face (you can customize faces with M-x customize-face).

Remove everything (or go to an empty line) and type = once:

=  =

A header line is prepared. Type the header of a section:

= Header 1 =

With point (cursor) somewhere on the header line type = again:

== Header 1 ==

The level of the header is increased. Now type C-- = (Control with minus and after this = along):

= Header 1 =

The level of the header is decreased. Now enter some text and some more headers:

= Header 1 =
Some text
== Header 1.1 ==
Some text
== Header 1.2 ==
Some text
= Header 2 =
== Header 2.1 ==
Some text

Now type C-c C-t:

= Header 1 =...
== Header 1.1 ==...
== Header 1.2 ==...
= Header 2 =...
== Header 2.1 ==...

All the text becomes invisible and you see only headings (outline of the document). Use C-c C-a to make everything in buffer visible back. You can also hide/show subtree, children, move between headings—see help of the outline mode in your emacs manual. Now type C-x h to mark the whole buffer and type =:

== Header 1 ==
Some text
=== Header 1.1 ===
Some text
=== Header 1.2 ===
Some text
== Header 2 ==
=== Header 2.1 ===
Some text

The level of each header in the region is increased. Use C-- = to decrease it back. Go to line with Header 1.2 and press C-c a:

== Header 1 ==
Some text
=== Header 1.1 ===
Some text
=== Header 1.2 ===
[[Anchor(Header-1-2)]]
Some text
== Header 2 ==
=== Header 2.1 ===
Some text

An anchor for the section was inserted. Go to the line with last Some text and press C-c a:

== Header 1 ==
Some text
=== Header 1.1 ===
Some text
=== Header 1.2 ===
[[Anchor(Header-1-2)]]
Some text
== Header 2 ==
=== Header 2.1 ===
Some text[[Anchor()]]

A template for anchor was inserted—you can type anchor name, e.g., eof. Go to the end of the first Some text line and enter [, #, TAB, H, TAB, Enter:

== Header 1 ==
Some text [#Header-1-2 Header 1.2]
=== Header 1.1 ===
Some text
=== Header 1.2 ===
[[Anchor(Header-1-2)]]
Some text
== Header 2 ==
=== Header 2.1 ===
Some text[[Anchor(eof)]]

A reference to the anchor and the name of the title of its section was inserted. If you do not want the section title use a prefix argument: type [, C-u, #, etc. Put the point somewhere after [# and type C-c g you are moved to the referenced anchor. You can also go, for example, to the start of the line and type C-c g, e, Enter to go to eof (it is the only anchor which starts with e).

Remove everything again and type

 * item

Put point at the end of line and type M-Enter, another item:

 * item
 * another item

you can now enter a new item. M-Enter works with other types of lists as well:

 * item
 * another item
 1. item
 1. another item
 a. item
 a. another item

Remove everything and type ", text, ":

“text”

Left and right quote HTML-entities were inserted: “text”. If you want to enter " (for example, to write such manual) type C-q ". To insert en-dash and em-dash type - twice or three times respectively, for example, type 11, -, -, 12 to get: 11–12. By the way, if you want to know what type of dash to use in each particular situation use the following advice from the TeXbook:

If you type - four times you get a rule:

----

<- and -> becomes

&larr; and &rarr;

That is “← and →”.

Questions and proposals

Put here you questions and change requests.


Thanks for this. How about calling it "Emoincs?"


I would like to add some improvements, how can I contact the author?


I think the name moinmoin-mode is just fine, thanks. But how about putting the text into a subpage or attachment so that I can download the file directly, using curl or w3m?


How does this work with longlines.el instead of screen-lines.el? -- TedStern 2006-04-13 22:32:27


Just my 2 cts : mark-active variable should be changed to region-exists-p function in moinmoin-insert-equal(increment).

I've also had good a experience with the PhysicalLineMove mode, that wraps paragraphs properly, but only on screen. Magic! :) There are a few commands that are ran at the end of the mode setup, that, in my opinion, should be setup in a hook. For example, I don't use the abbrev-mode, but moimoin-mode sets it up for me anyways. If there was a moinmoin-mode-hook, I could also add my prefered ways of editing text to it, like http://www.emacswiki.org/cgi-bin/wiki/LongLines or http://www.emacswiki.org/cgi-bin/wiki/PhysicalLineMove... -- TheAnarcat 2006-11-08 20:01:57


Great work! I wonder if it is not better to create another list item when you press Enter, instead of requiring Meta + Enter. Usually when you create a list, you need another list item several times, and only one regular new line at the end. This is also how it works in common word processors.


The font lock colors chosen in this mode only really work for light backgrounds. It would be nice if someone could extend the defface definitions to also define sensible colors for dark backgrounds.

Compatibility issues

moinmoin-mode.el doesn't work with emacs 21.3. A comment in the file states ;; Compatibility: GNU Emacs 22.0.50.1 (probably others). Fixing two problems makes the mode mostly workable in emacs 21.3:

Since emacs 22 hasn't been released yet, it would be great to have this mode work with the latest released emacs.

-- Mat Martineau 2006-06-02

--- original/moinmoin-mode.el  2011-12-03 17:47:16.000000000 -0500
+++ derived/moinmoin-mode.el   2011-12-03 17:36:46.000000000 -0500
@@ -17,1 +17,0 @@
-(require 'screen-lines) ; uses screen-lines.el by Yuji Minejima, tested with 0.55
@@ -579,3 +578,2 @@
   (toggle-truncate-lines 0)                    ; do not truncate
-  (screen-lines-mode 1)                        ; use screen lines
   (moinmoin-setup-font-lock)

I have a fix, but it's a bit stupid: just hack the .el file to define the function if it's missing. I added this near the end of moinmoin-mode.el:

(or (fboundp 'looking-back)
; taken straight out of http://cvs.savannah.gnu.org/viewcvs/emacs/emacs/lisp/subr.el?rev=1.530&view=auto
(defun looking-back (regexp &optional limit greedy)
  "Return non-nil if text before point matches regular expression REGEXP.
Like `looking-at' except matches before point, and is slower.
LIMIT if non-nil speeds up the search by specifying a minimum
starting position, to avoid checking matches that would start
before LIMIT.
If GREEDY is non-nil, extend the match backwards as far as possible,
stopping when a single additional previous character cannot be part
of a match for REGEXP."
  (let ((start (point))
        (pos
         (save-excursion
           (and (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t)
                (point)))))
    (if (and greedy pos)
        (save-restriction
          (narrow-to-region (point-min) start)
          (while (and (> pos (point-min))
                      (save-excursion
                        (goto-char pos)
                        (backward-char 1)
                        (looking-at (concat "\\(?:"  regexp "\\)\\'"))))
            (setq pos (1- pos)))
          (save-excursion
            (goto-char pos)
            (looking-at (concat "\\(?:"  regexp "\\)\\'")))))
    (not (null pos))))
)

Simple enough, "Works for me". -- TheAnarcat 2006-10-21 16:30:50

Ok, I did not think that it was so easy.

Thanks for the hint !

Another issue I'm having is moinmoin-setup-font-lock: Symbol's value as variable is void: font-lock-extra-managed-props. And font-lock doesn't work. GNU Emacs 21.4.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2006-10-25 on raven, modified by Debian. -- TheAnarcat 2006-11-08 19:48:31

Issue came to me, it cannot work properly with my GNU Emacs 23.0.0.6 (i686-pc-linux-gnu, GTK+ Version 2.10.12) of 2007-06-12 on qsun-thinkpad, comment out  (setq font-lock-beginning-of-syntax-function '(lambda () (goto-char 1))) , it just works. ---Quan Sun

May be you also want to use editmoin -- ReimarBauer 2010-01-14 07:45:21

Incompatibility with python-mode

Running GNU Emacs 22.3.1 (i386-apple-darwin9.8.0, Carbon Version 1.6.0) aka Aquamacs 1.9.

I can reproduce the problem by first start a buffer in moinmoin-mode then another file with python-mode.

Works okay if I start python-mode first.

Trace follows:

Debugger entered--Lisp error: (wrong-type-argument symbolp (lambda nil (goto-char 1)))
  font-lock-compile-keywords(("\\(?:\\_<\\(?:False\\|True\\|a\\(?:nd\\|s\\(?:sert\\)?\\)\\|break\\|continue\\|del\\|e\\(?:l\\(?:if\\|se\\)\\|x\\(?:cept\\|ec\\)\\)\\|f\\(?:inally\\|or\\|rom\\)\\|global\\|i\\(?:mport\\|[fns]\\)\\|lambda\\|not\\|or\\|p\\(?:ass\\|rint\\)\\|r\\(?:aise\\|eturn\\)\\|self\\|try\\|w\\(?:hile\\|ith\\)\\|yield\\)\\_>\\)" ("\\(?:\\_<None\\_>\\)" . font-lock-constant-face) ("\\(?:\\_<\\(class\\)[[:space:]]+\\(\\(?:[[:word:]]\\|_\\)+\\)\\)" (1 font-lock-keyword-face) (2 font-lock-type-face)) ("\\(?:\\_<\\(def\\)[[:space:]]+\\(\\(?:[[:word:]]\\|_\\)+\\)\\)" (1 font-lock-keyword-face) (2 font-lock-function-name-face)) ("\\(?:^\\(\\(?:[[:word:]]\\|_\\)+\\)[[:space:]]*=\\)" (1 font-lock-variable-name-face)) ("\\(?:@\\(?:[[:word:]]\\|_\\)+\\)" (0 font-lock-preprocessor-face))))
  font-lock-set-defaults()
  font-lock-mode-internal(t)
  font-lock-default-function(t)
  font-lock-mode()
  turn-on-font-lock()
  turn-on-font-lock-if-enabled()
  global-font-lock-mode-enable-in-buffers()
  run-hooks(after-change-major-mode-hook)
  run-mode-hooks(python-mode-hook)
  python-mode()
  set-auto-mode-0(python-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer x.py> "/tmp/x.py" nil nil "/private/tmp/x.py" (26578718 234881026))
  find-file-noselect("/tmp/x.py" nil nil t)
  find-file-other-window("/tmp/x.py" t)
  call-interactively(find-file-other-window)

LesterCheung 2010-02-16 11:17:00

MoinMoin: EmacsForMoinMoin (last edited 2011-12-03 23:22:54 by Unw)