Emacs can be used for editing MoinMoin pages: just copy/paste from your browser to emacs, edit, copy/paste back to browser.
Installation
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.
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.
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.
- 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.
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.
- 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.
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:
Syntax highlighting (almost bug-to-bug compatible with MoinMoin/parser/wiki.py);
Outline of the page and selective display (by outline-mode);
- Automagic insertion of anchors and references to them;
- Automagic insertion of HTML entities (left and right quotes, em- and en- dashes, and arrows: “–”, “—”, “→”, and “←”).
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:
- Hyphens are used for compound words like “daughter-in-law” and “X-rated”. En-dashes are used for number ranges like “pages 13–34,” and also in contexts like “exercise 1.2.6–52”. Em-dashes are used for punctuation in sentences—they are what we often call simply dashes.
If you type - four times you get a rule:
----
<- and -> becomes
← and →
That is “← and →”.
Questions and proposals
Put here you questions and change requests.
Thanks for this. How about calling it "Emoincs?"
- moinmoin-mode is the name which most emacs users will try in a search engines and it is already (2006-04-15) the first result in Google.
I would like to add some improvements, how can I contact the author?
Try mail.ru with name 1r1jk4n3
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?
- I put the update into a subpage to retain history.
Thanks, but a link would be helpful, so I'm adding one here: moinmoin-mode.el
-- TedStern 2006-04-17 21:22:10Fixed, thanks. Unfortunately, it does not work with wget.
No, nor with curl. But it does work with w3m -dump! – TedStern
MoinMoin has anti-bot mesures, use wget -U Mozilla <url>. -- TheAnarcat 2006-10-21 16:25:58
How does this work with longlines.el instead of screen-lines.el? -- TedStern 2006-04-13 22:32:27
The problem is that a lot of moinmoin formating (in wiki.py and thus in moinmoin-mode.el) depends on the fact that the start and the end are on the same line, so, to the best of my knowledge (that is if longlines.el does not provide some easy way for lisp code to treat soft brakes as spaces), porting of moinmoin-mode to longlines is going to be far from trivial.
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:
Replace (toggle-truncate-lines 0) with (setq truncate-lines nil)
Define the looking-back function, which is missing in emacs versions before 22. I copied the function out of subr.el in the emacs 22 source.
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
- It doesn't work on my Emacs23. Sorry, I found out that this works on Emacs23(at least Emacs23.0.0(NS 9.0-pre3)).
I thought it won't work before because I didn't install screen-lines.el(I thought it's optional.) After install screen-lines.el, everything is OK. -- WeakishJiang
- For emacs-23.1, I simply removed screen-lines.el to avoid conflict (with built-in customization truncate-lines) -- Unw
--- 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)
moinmoin-mode.el does not work fine with XEmacs 21.4.x (looking-back, font-lock-add-keywords, ...) How can I fix it ? -- FredericPetit
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
- I just commented the three offending lines - most of the font-lock-mode stuff seems to work after that. --Anagramster
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