Just some words of warning: i started to work on this project some days ago. I think i fixed a lot of stuff but consider the code as experimental. Even though I’m currently editing this page with SimpleWikiEditMode my hands are shaking and i fear to screw the whole page ;-). -- DavidHansen
If you want to extend it for other Usemod wikis, copy emacswiki-browse as a starting point. To support other wiki engines, take a look at usemod-wiki-save and see whether you can adapt it.
For Usemod wikis, you must install UseMod:WikiPatches/RawMode so that the wiki script understands the raw=2 parameter. (raw=1 only delivers the plain text, which is enough for viewing, but raw=2 adds a timestamp cookie on the first line.)
There is a link to the patched script from the EmacsWiki page. But if your wiki still uses raw=1, you might still be able to use simple-wiki, if you use (shell-command…w3m) to fetch pages. (is this right?). For that:
(setq swc-pages-get-function 'swc-pages-get-w3m)
There is currently no release. The brave may get the code from CVS.
Now just add the appropriate directory to your load-path:
(add-to-list 'load-path "<path to http-emacs>/http-emacs")
Note that the files in the ElispArea only contain a comment pointing to the Savannah project. When development started, these files were hosted in the ElispArea, and only later were moved to Savannah.
Use the following:
When editing, type:
This is what I use:
(global-set-key (kbd "C-c C-o") 'swc-emacswiki-browse)
When saving a webpage with simple-emacswiki.el, it concatenates the word of the variable user-full-name to create the UserName used for the submission. If you use a different user name for wikis, get the latest savannah version and customize
Here’s a brief HOWTO.
First add the directory hosting the files in your LoadPath variable as explained into the Download section.
Then load all the necessary files:
Feel free to only load stuff you really want to use :) but note that loading all at the same time doesn’t hurt, as long as you have all the files in your LoadPath.
(add-hook 'simple-wiki-edit-mode-hook 'pcomplete-simple-wiki-setup) (setq pcomplete-ignore-case t) ;; optional
(add-hook 'simple-wiki-edit-mode-hook 'turn-off-auto-fill)
(setq longlines-show-hard-newlines t) ;; optional (add-hook 'simple-wiki-edit-mode-hook 'longlines-mode-on) (add-hook 'simple-wiki-save-before-hooks (lambda () (when longlines-mode (longlines-mode-off))))
** this item is continued on the next line.
Here is code that renames your buffers. I use the UNIQUE argument to rename-buffer so that I get a history of buffers for a page. Adapt to your liking.
(add-hook 'simple-wiki-edit-mode-hook (lambda () (when simple-wiki-url (rename-buffer (simple-wiki-page) t))))
Take care that simple-wiki-completion uses a rename hook named rename-hook.
Here is some code that lets you edit the emacswiki page displayed in the current w3m buffer:
(defvar w3m-emacswiki-url-re "^http://www\\.emacswiki\\.org/cgi-bin/wiki/\\(.*\\)" "Regular expression to match an emacswiki URL.") (defun w3m-emacswiki-edit () "Edit emacswiki page displayed in the current w3m buffer." (interactive) (if (string-match w3m-emacswiki-url-re w3m-current-url) (swc-browse "ew" (match-string 1 w3m-current-url)) (error "Not an emacswiki page!")))
The timestamp on the first line is required to do automatic conflict resolution using merge(1) – read the man page for merge: you need three files to do merging, A, B, and the common ancestor. The common ancestor is identified by the timestamp. If you delete the timestamp, the wiki will complain. If you change it, then automatic conflict resolution might yield suboptimal results. Nothing you can’t fix by using the normal interface: Click on the “Show History” link and edit the last good version.
Oddmuse (about the only wiki engine really supported by this mode) as now blogging capabilites. See Oddmuse:Minimal_Weblog_Setup.
Here is a quick an dirty function that opens a date page of the wiki from the calendar mode to easily post a new entry.
(defun swb-insert-entry (arg) "get the date page for the date indicated by point" (interactive "P") (let* ((date (calendar-cursor-to-date t)) (month (pop date)) (day (pop date)) (year (pop date)) ;date page use ISO format YYYY-MM-DD (page (format "%04d-%02d-%02d" year month day)) (nick "myblog") (buffer (get-buffer-create (concat (upcase nick) ":" page)))) (switch-to-buffer-other-window buffer) (swc-browse nick page))) ;;bind the function to b (add-hook 'calendar-mode-hook (define-key calendar-mode-map "b" 'swb-insert-entry))
Note that you need to add my blog in the wiki definitions list
You’are welcome to participate. If you don’t know what to do here is a list of ideas:
In order to allow us to integrate this package into Emacs at some time, please make sure you are prepared to assign your copyright to the FSF at some point in the far away future.
Use http://emacswiki.wikiwikiweb.de/cgi-bin/wiki.pl?action=rc&raw=1 to see recent changes, use http://emacswiki.wikiwikiweb.de/cgi-bin/wiki.pl?action=browse&id=RecentChanges&raw=2 to see and edit the intro text. – AlexSchroeder
TODO: simple elisp functions to access it
The last version let you specify the encoding in simple-wiki-definition.
(defun swd-wikiclient-wiki-save () "Save the current page with wikiclient." (let ((url simple-wiki-url) (save-func simple-wiki-save-function) (link (simple-wiki-save-link)) (http-version (swd-http-version (swd-nick simple-wiki-url))) (content-type (swd-http-coding (swd-nick simple-wiki-url))) (headers) (proc)) (setq proc (shell-command (concat "../wikiclient --type=usemod1 write " "http://interwiki.sourceforge.net/cgi-bin/wiki.pl" ":" simple-wiki-page ))) (with-current-buffer (process-buffer proc) ;; same trick as in `simple-wiki-edit'. See comment there. (set (make-local-variable 'simple-wiki-url) url) (set (make-local-variable 'simple-wiki-save-function) save-func) (set (make-local-variable 'simple-wiki-time) nil) (set (make-local-variable 'simple-wiki-content-type) content-type) (set (make-local-variable 'simple-wiki-http-version) http-version))))
Thanks a lot for your help! Here’s the working version (at least, I think it works). This is a patch to simple-wiki-definitions.el which makes it use the external program “wikiclient” to save a page to the wiki. The next step is to allow the --type argument to assume different values, which will enable the program to interact with various different WikiEngines? (whatever is supported by WikiGateway?; currently OddMuse?, UseMod?, and MoinMoin?):
(defun swd-usemod-wiki-save () "Save the current page with wikiclient." (let ((url simple-wiki-url) (save-func simple-wiki-save-function) (link (simple-wiki-save-link)) (http-version (swd-http-version (swd-nick simple-wiki-url))) (content-type (swd-http-coding (swd-nick simple-wiki-url))) (headers) (proc)) (shell-command-on-region (save-excursion (goto-line 2) (line-beginning-position)) (point-max) (concat "wikiclient --type=oddmuse1 write " link ":" (simple-wiki-page) )) ))
So, how to cookies for use with this mode? For editor passwords, I mean. I’m guessing I should use http-cookies.el, but how? – bkhl
I’m having trouble getting SimpleWikiEditMode to post data. I’ve got the following lines in my .emacs:
(setq load-path (cons "/usr/local/http-emacs" load-path)) (require 'simple-wiki-completion) (require 'simple-ecwiki) ;; copy of simple-emacswiki.el edited ;; for my oddmuse wiki (require 'simple-emacswiki) (add-hook 'simple-wiki-edit-mode-hooks 'pcomplete-simple-wiki-setup) (setq pcomplete-ignore-case t) ;; optional (add-hook 'simple-wiki-edit-mode-hooks 'turn-off-auto-fill) (add-hook 'simple-wiki-edit-mode-hooks (lambda () (when url (rename-buffer (let ((simple-wiki-url url)) (simple-wiki-page)) t))))
I get the same end results regardless of whether or not the add-hook lines are commented out. The result is that on sending the updated page, the buffer changes to read:
The buffer name doesn’t change, nor does the mode change at all. And when I browse out to the updated page--in this case SandBox--I find that I do have a new revision, but it is quite blank. If there had previously been data in the page prior to editing it with SimpleWikiEditMode it is wiped out.
I’m using Gnu Emacs 21.3.1 on Debian. And I’m using the CVS packages from Savannah.
Does anybody interested in other wiki markup rules? I’ve slightly modified simple-wiki.el adding TWiki support and improving MediaWiki? syntax highlighting. Also I’m going to add WikiText? support (used by http://www.wikispaces.com). – DmitriBrechalov
Doesnt work for me. when i type M-x swc-emacswiki-browseRET i get: Wrong type argument: listp, “close”
this is what i load: (add-to-list ‘load-path “/usr/share/emacs/site-lisp/http-emacs”) (require ‘simple-wiki-completion)