Difference between revisions of "Mediawiki.el"
m (added a comment in some lisp, because I didn't see empty "".) |
|||
Line 46: | Line 46: | ||
(require 'mediawiki) | (require 'mediawiki) | ||
− | (setq mediawiki-site-alist '(("Wikipedia" "http://en.wikipedia.org/w | + | (setq mediawiki-site-alist '(("Wikipedia" "http://en.wikipedia.org/w/ "" "" "Main Page") ; put your user name and password |
("WikEmacs" "http://wikemacs.org/w/" "" "" "Main Page"))) | ("WikEmacs" "http://wikemacs.org/w/" "" "" "Main Page"))) | ||
− | ;; Emacs users care more for WikEmacs than Wikipedia :-) | + | ;; Emacs users care more for WikEmacs than Wikipedia :-). In any case, do not forget the slash at the end of the URL. |
(setq mediawiki-site-default "WikEmacs") | (setq mediawiki-site-default "WikEmacs") | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 19:17, 19 September 2012
Description | Mediawiki interface and markup mode |
---|---|
Author | Jerry et al |
Maintainer | Mark A. Hershberger |
Source | https://code.launchpad.net/~hexmode/mediawiki-el/trunk |
Part of Emacs | no |
Mediawiki.el is a package to help add content to any mediawiki site including WikEmacs. It comes with a Major Mode to support editing Mediawiki markup.
Setup
Install mediawiki.el from el-get or ELPA.
Site requirements
The MediaWiki site that you wish to edit must have its API enabled:
$wgEnableAPI=true;
Customization
- M-x load-library RET mediawiki RET
- Load the library
- M-x customize-variable RET mediawiki-site-alist
- Configure as follows and save your settings
- Site Name: WikEmacs
- URL: http://wikemacs.org/w/
- Username: InCognito
- Password: s!cr!t
- First Page: Main Page
- You can provide "Username" and "Password" in your .authinfo file. home directory.
Alternatively you can add this snippet of Emacs Lisp code to your .emacs:
(require 'mediawiki)
(setq mediawiki-site-alist '(("Wikipedia" "http://en.wikipedia.org/w/ "" "" "Main Page") ; put your user name and password
("WikEmacs" "http://wikemacs.org/w/" "" "" "Main Page")))
;; Emacs users care more for WikEmacs than Wikipedia :-). In any case, do not forget the slash at the end of the URL.
(setq mediawiki-site-default "WikEmacs")
You can naturally add more MediaWiki sites to the mediawiki-site-alist variable.
Usage
- M-x mediawiki-site
- Choose a site (say "WikEmacs") for the current session.
- [C-c C-o] (or M-x mediawiki-open)
- Open a page. To edit the main page, type "Main Page". Make your edits.
- [C-x C-s] (or M-x mediawiki-save)
- Submit your modifications.
- [C-c] (or M-x mediawiki-save-and-bury)
- Submit modifications and bury the buffer.
Helpful Keybindings
- [C-return] (or M-x mediawiki-open-page-at-point)
- Follow or browse to a WikiLink.
- [M-g] (or M-x mediawiki-reload)
- Reload a page
Customizations
Word Wrap
Mediawiki sites are generally unfilled: do not add hard line breaks within a paragraph. There are various ways to wrap lines visually while you edit. For example in Emacs 24 you may want to enable Visual Line mode with a mode hook:
(setq mediawiki-mode-hook (lambda ()
(visual-line-mode 1)))
Edit or Create a page in a web browser
Right now Mediawiki.el fails silently whenever the site asks for number challenge (spam protection). The following snippet allows you to edit/create a page in a web browser
(defun yyr-mediawiki-browser-edit/create-page (page &optional site)
"Edit a page in browser, asks for page name (sitename also if needed)"
(interactive "sPage name (words): ")
(let* ((site (mediawiki-prompt-for-site))
(url (mediawiki-site-extract site 1))
(index "index.php?title=")
(et "&action=edit"))
(funcall 'browse-url
(message "%s%s%s%s"
url index (mediawiki-translate-pagename page) et))))
Call yyr-mediawiki-browser-edit/create-page
key binding to open current editing file in web browser?
bind mediawiki-browse to some key chord. The following uses [C-c o]
(define-key mediawiki-mode-map (kbd "C-c o") 'mediawiki-browse)