editing1Add my vote for this tag create new tag
, view all tags

Using Emacs to Edit TWiki Pages

I'm trying to edit TWiki pages with (X)Emacs' web browsing and editing mode. So far, I haven't been successful. This is a description of what I've done so far and the problems I've encountered. Help and suggestions are appreciated:

(BTW, at least on my system, I could only find the W3 module in Xemacs, not in Emacs. The documentation references Emacs, so I assume, but don't know, that the W3 module can be run in Emacs.)

  • Start Xemacs (from the kde menu)

  • Choose Apps | Browse the Web from the menus

  • It took a long time to load, presumably partly because it is set up to load its home page from Indiana University. (It may also have been waiting for me to move the mouse.)

  • Finally the "Welcome to Emacs W3 4.0" screen appears.

  • Click on the clipboard icon (top toolbar) to "Fetch a URL". Enter the desired URL at the bottom of the screen. (IIRC, some other URL shows up as the default -- delete that and enter the desired URL.)

  • Again, very slow loading, even though I'm working on the same machine as the TWiki server. Finally my TWiki page comes up.

  • Navigate to the word "Edit" on the TWiki page. When highlighted press enter (or right click and choose something like "Open this link").

  • If you are on an "authorization by password" TWiki (like TWiki.org), first the "authorization failed" message appears, then you are prompted for your username and then password. ("Authorization by password" might be what is described in other places as "basic authentication" -- I mean that you have to enter a password in order to edit.)

  • I learned what (X)Emacs means by a buffer -- I can think of it as a file opened for display or editing (in a window).

  • If everything is successful, you get a new buffer containing the TWiki page to be edited, but you see only the contents of the template and the phrase "[Multiline text area]".

  • Navigate to the phrase "[Multiline text area]", and, when highlighted, press enter (or right click -- I don't think I had to choose anything).

  • The window splits and shows you the "real" text content of the TWiki page. The split window does not seem to be a "real" buffer because a new buffer does not appear on the menu drop down list of buffers.

  • Edit the page.
This is where I got stuck. I could use <ctrl>x <ctrl>s to save the page, but I didn't know what to save it as, so I just saved it as "temp". Now, how do I close the split window and save the buffer to TWiki? I couldn't find a way. (I did try just going to the other window and navigating to Preview and selecting it, but it did not save my changes.)

Aside: If I try to use Emacs (or Xemacs), I'll have to learn how to change the fonts.

  • TWiki version: 20010315 beta
  • Web server: Apache
  • Server OS: Mandrake 7.2 with MandrakeFreq update
-- RandyKramer - 17 May 2001


Randy, I don't have a final solution for you that works entirely in Xemacs, but I can tell you how to use your favorite editor to edit a Twiki page.

If you use the command line oriented browser called Lynx (see http://lynx.browser.org),

  • go to the page and then
  • use the 'edit' button to create the form with the textfield holding the TWiki page in source, then
  • enter the textfield with the cursor,
  • you can invoke your favorite editor using the key commands Ctrl-V-e. To get this working, you must have the editor defined in the Lynx configuration and have the key e mapped to the edit-textarea function - look for the latter in your lynx.cfg. Mine was installed in /usr/lib/lynx.cfg and had this feature disabled by default.
  • After editing the page and saving the file with the same name it was loaded with, you are back in Lynx (the contents of the file are put back into the textarea field).
  • You can now hit the "preview" and
  • the "save" button as usual to save the page into your TWiki web.
As I don't know if some of the TWiki developers will have a different answer to this question, I leave the support status of this message as it is.

-- GuidoOstkamp - 18 Jun 2001

This scheme can be fully automated using lynx -cmd_script= option. I am using the following comand line to edit this page:

lynx -auth:RenatoCarmo:foo -term=vt100 -nocolor -cmd_script=twiki.lynx http://twiki.org/cgi-bin/view/Support/UsingEmacsToEditTwiki > /dev/null

Things get even better if you use Emacs and the gnuserv/gnuclient pair. This way, a buffer is opened in your Emacs for editing and, when you're finished, the twiki.lynx "script" (which I'm leaving as an attachment in this page) takes care of the rest. Makes editing a wiki page as easy as editing an ordinary file!

In short, you'd have to:

  • Start the server at your emacs: M-x gnuserv-start
  • Set EDITOR=gnuclient
  • Call lynx as above.
-- RenatoCarmo - 13 Jun 2002

I'm not a TWiki developer or an Emacs user, but from when I used to use it, I remember that Ctrl-X then Ctrl-C, then saying Yes to save buffers, was the way to exit normally, saving back onto the filenames specified on entering Emacs. This is of course much too obvious for any Emacs user to mention smile

For more details, see this manual page, which uses the convention that C-x means Ctrl-X.

-- RichardDonkin - 18 Jun 2001

Thanks Guido and Richard!

As it happens, I have tried what you suggested, Guido, using nedit as "my favorite editor", and got it to work. Perhaps I can get Emacs to work the same way, and then use Richard's suggestion to quit Emacs (using C-x then C-c (and I might try C-z also to see if it works)).

But this isn't quite what I was trying to do. I want to navigate to the page using w3 (in Emacs or Xemacs) and then edit while within Emacs. (This is at least partially due to the excessive time it takes Emacs to load -- I wouldn't want to wait that long each time I edit.)

So, I'm still looking for help (but not desperately -- for now I'm editing (creating) many new pages on my "mirror" (a manual mirror) TWiki at home using a variety of editors. Then I can upload the .txt and .txt,v files to "my" TWiki on SourceForge (soon).

-- RandyKramer - 19 Jun 2001

Randy, don't use C-z, it will really mess things up by leaving Emacs suspended and not saving the file. I believe you can hugely speed up Emacs loading time by running the main process as a server and loading 'emacs clients' that are very lightweight (and appear to the user to be full Emacs). Check google.com for more info!

-- RichardDonkin - 19 Jun 2001

Thanks! I won't use C-z, and I'll put the other on my list of things to look into.

-- RandyKramer - 20 Jun 2001

"C-c, C-c" does what you want, Randy. "w3-finish-text-entry" is what it binds to.

The Multiline-Text-Area buffer is "saved" and goes away allowing you to preview.

It'd be nice if the Multiline-Text-Area buffer didn't go away and was instead just "saved". I haven't figured out how to do this yet.

It'd be nice if the buffer hung around, allowing me to do a preview in the preview buffer to see if I were truly finished w/ my editing. The fact that the buffer must go away to do a preview is very irritating.


Ted Lam

-- TheodoreLam -7 Sep 2001

Thanks very much! When I get up the ambition to try Emacs again, I'll try this. (From your comments, it is clear that Emacs is not the perfect way to edit TWiki pages. wink

I'm marking this question as answered, even though I haven't yet tried it.

-- RandyKramer - 24 Sep 2001

Another approach entirely is to use Emacs to browse and edit a remote Wiki - have a look at ZWiki:EmacsAndWiki for some ideas.

-- RichardDonkin - 28 Oct 2001


Thanks! (Somehow I didn't catch your comment in the WebChanges, found it by accident today.)

-- RandyKramer - 11 Jan 2002

I sometimes miss comments in a thread that I'm involved in as well - this is probably one reason for TopicsThatDie. Perhaps there could be a standard link in the view template that does a search for any topics updated in the last N days where your name is mentioned? Really it needs to check for topics where you have commented in the last N days but this may be hard to do without diving into RCS.

-- RichardDonkin - 12 Jan 2002

Sounds like a helpful feature to me!

-- RandyKramer - 12 Jan 2002

You might also like to look at http://www.emacswiki.org/cgi-bin/wiki.pl?WikiModeDiscussion - this page is about using Emacs to edit local and remote Wikis. EmacsWiki is all about Emacs, built on UseMod - I suspect you would find a lot of Emacs expertise there.

-- RichardDonkin - 12 Jan 2002

If you happen to be using either Mozilla or Firebird, check out the excellent (self-described dirty-hack) mozex extension. This allows you to configure (say) gnuclient as the command to edit a textarea. I used it to edit this comment. Recommended.

-- FrankHorowitz - 13 Aug 2003

Perhaps EditDaemonWithGvimIntegration (how to link to that automatically?) could be extended to support other editors.

-- EdAvis - 01 Oct 2003

  • twiki.lynx: lynx "script" for remote edition of twiki pages
The mozex extension isn't supported anymore. If you use Mozilla or Firefox I suggest you use the It's All Text! extension that does the same thing, i.e., edit texteareas using an external editor. I changed the following configuration options in my Linux machine:

  • Editor: /usr/bin/emacsclient
  • Character Set: iso-8859-1
The Editor option tells it to invoke the emacsclient binary, which makes my currently running emacs to open a temporary text file containing all the Firefox's textarea content for edition. When I finish editing it I press C-c # and the modified content is sent back to the Firefox text-area.

The Character Set option tells Firefox to encode the text with the encoding I use. The default is UTF-8, which may be what most users want.

-- GustavoChaves - 11 Sep 2007

Excellent! I've looking for something like that for some time, to edit some monster-topics without the restrictions of the browser's textarea. Now all what's missing is a decent TWiki-mode... but wait, there's Neil Van Dyke's erin.el which does at least syntax highlighting. Just teach It's All Text! to use the extension .twiki and here you go.

A minor correction: The command to finish editing is C-x # in Gnu Emacs.

-- HaraldJoerg - 12 Sep 2007

I have been working with TWiki at work for quite a while and have put together a twiki-mode for emacs that I think works really well for editing twiki pages in emacs.

I have also put in some notes about integrating with It's All Text!, as I recently started using that as well.

Some highlights of this mode:

  • Keyboard shortcuts for common operations
  • Auto-numbering of headings, numbered lists
  • Better bullet list management
  • orgtbl-minor mode for table editing
  • table numbering
  • font-lock support for syntax highlighting
-- ChristopherWhite - 2011-07-31

Thank you Christopher for sharing this emacs integration with the TWiki community!

To get broader exposure I recommend to package this as an add-on, such as EmacsEditModeAddOn. More at AddOnPackageHowTo.

-- PeterThoeny - 2011-08-01

Ok, it only took me a year, but I finally got an AddOn the includes twiki-mode.el as well as a shell script twikish that interacts with the TWiki server... See EmacsModeAddOn.

twiki-mode is pretty mature now, I have used it to edit really large and complex web pages and doing it in Emacs makes it that much easier.

-- ChristopherWhite - 2012-08-07

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatlynx twiki.lynx r1 manage 0.6 K 2002-06-13 - 17:53 RenatoCarmo lynx "script" for remote edition of twiki pages
Edit | Attach | Watch | Print version | History: r24 < r23 < r22 < r21 < r20 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r24 - 2012-08-07 - ChristopherWhite
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.