Difference between revisions of "Emacs Mediawiki"

From ArchWiki
Jump to: navigation, search
(Configuration)
(Env browser.)
(17 intermediate revisions by 8 users not shown)
Line 1: Line 1:
[[Category:ArchWiki Tools (English)]]
+
[[Category:Text editors]]
 
+
 
{{Article summary start}}
 
{{Article summary start}}
 
{{Article summary text|Emacs Mediawiki Mode is an emacs major mode which is evolved from an old copy of mediawiki mode frome wikipedia.org. It helps to edit remote wiki articles on wiki sites running mediawiki in emacs editor directly.}}
 
{{Article summary text|Emacs Mediawiki Mode is an emacs major mode which is evolved from an old copy of mediawiki mode frome wikipedia.org. It helps to edit remote wiki articles on wiki sites running mediawiki in emacs editor directly.}}
 
{{Article summary heading|Related}}
 
{{Article summary heading|Related}}
 
{{Article summary wiki|Emacs}}
 
{{Article summary wiki|Emacs}}
 +
{{Article summary wiki|ArchWiki:About}}
 
{{Article summary end}}
 
{{Article summary end}}
 
 
== Installation ==
 
== Installation ==
  
There is a package in [[AUR]]:{{Package AUR|emacs-mediawiki-bzr}}.
+
There is a package in [[AUR]]:{{AUR|emacs-mediawiki-bzr}}.
  
 
Or you can directly download the source from https://launchpad.net/mediawiki-el .
 
Or you can directly download the source from https://launchpad.net/mediawiki-el .
Line 15: Line 14:
 
== Configuration ==
 
== Configuration ==
  
After you install the package from AUR, open your emacs configuration file (usually, {{Filename|~/.emacs}}) and add the following line in it.
+
After you install the package from AUR, open your emacs configuration file (usually, {{ic|~/.emacs}}) and add the following line in it.
  
 
  (require 'mediawiki)
 
  (require 'mediawiki)
Line 25: Line 24:
 
               mediawiki-site-alist))
 
               mediawiki-site-alist))
  
Where ''Archwiki'' is the name for the site. ''https:/wiki.archlinux.org/'' is the url of the site and ''username'' and ''password'' is your username and password of this site. ''Main Page'' is the default page opened when you connect to the site.
+
Where '''''Archwiki''''' is the name for the site. '''''https:/wiki.archlinux.org/''''' is the url of the site and '''''username''''' and '''''password''''' is your username and password of this site. '''''Main Page''''' is the default page opened when you connect to the site.
  
Other sites can also be added by append the configuration list to the list variable '''mediawiki-site-alist'''.
+
Other sites can also be added by appending the configuration list to the list variable '''mediawiki-site-alist'''.
  
 
== Usage ==
 
== Usage ==
  
 +
After the configuration, you can use emacs to edit the wiki pages directly. Open your emacs and do the following to connect to the site.
 +
 +
M-x mediawiki-site RET {site name} RET
 +
 +
Now that you are connected, the default page should be opened. If you would rather edit another page. do the following to open it.
 +
 +
M-x mediawiki-open RET {page title} RET
 +
 +
Some useful keybindings are:
 +
 +
* C-x C-s – save this page
 +
* C-c C-c – save this page and bury the buffer
 +
* C-return – open the page under point for editing
 +
* TAB – go to the next wiki link
 +
* M-n – next page in the page ring
 +
* M-p – previous page in the page ring
 +
* M-g – reload the current page
 +
 +
Now enjoy editing wiki pages in emacs!
 +
 +
==Tips and tricks==
 +
 +
MediaWiki provies a hook to customize configuration.
 +
For example, if {{keypress|C-return}} does not work for you, you can redefine it easily:
 +
{{bc|
 +
(setq mediawiki-mode-hook
 +
    (lambda ()
 +
        (define-key mediawiki-mode-map (kbd "C-c RET") 'mediawiki-open-page-at-point)
 +
))
 +
}}
 +
 +
===Autofill off===
 +
Wikis do not autofill paragraphs. If you do so, it might confuse history diffs, and thus making them useless.
 +
So you'd be better off turning the auto-fill feature completely off.
 +
Add to the hook the following line:
 +
{{bc|
 +
(setq mediawiki-mode-hook (lambda ()
 +
                          ;; ...
 +
                            (turn-off-auto-fill)
 +
))
 +
}}
  
 +
===Specifying the browser===
 +
A convenient feature of Mediawiki is the {{ic|mediawiki-browse}} function which let you see the result of the page in a web browser.
 +
The browser is chosen following the ''browse-url'' plugin. You can configure this behaviour. For example:
 +
{{bc|
 +
(setq browse-url-generic-program (executable-find (getenv "BROWSER"))
 +
browse-url-browser-function 'browse-url-generic)
 +
}}
 +
will use your environment browser, whereas
 +
{{bc|
 +
(setq browse-url-generic-program (executable-find "dwb")
 +
browse-url-browser-function 'browse-url-generic)
 +
}}
 +
will specifically use the [[dwb]] browser.
  
 
== See also ==
 
== See also ==

Revision as of 09:37, 26 January 2013

Summary help replacing me
Emacs Mediawiki Mode is an emacs major mode which is evolved from an old copy of mediawiki mode frome wikipedia.org. It helps to edit remote wiki articles on wiki sites running mediawiki in emacs editor directly.
Related
Emacs
ArchWiki:About

Installation

There is a package in AUR:emacs-mediawiki-bzrAUR.

Or you can directly download the source from https://launchpad.net/mediawiki-el .

Configuration

After you install the package from AUR, open your emacs configuration file (usually, ~/.emacs) and add the following line in it.

(require 'mediawiki)

Then add the mediawiki sites to the configuration file. For example, the following line adds ArchWiki to it.

(setq mediawiki-site-alist
      (append '("ArchWiki" "https://wiki.archlinux.org/" "username" "password" "Main Page")
              mediawiki-site-alist))

Where Archwiki is the name for the site. https:/wiki.archlinux.org/ is the url of the site and username and password is your username and password of this site. Main Page is the default page opened when you connect to the site.

Other sites can also be added by appending the configuration list to the list variable mediawiki-site-alist.

Usage

After the configuration, you can use emacs to edit the wiki pages directly. Open your emacs and do the following to connect to the site.

M-x mediawiki-site RET {site name} RET

Now that you are connected, the default page should be opened. If you would rather edit another page. do the following to open it.

M-x mediawiki-open RET {page title} RET

Some useful keybindings are:

  • C-x C-s – save this page
  • C-c C-c – save this page and bury the buffer
  • C-return – open the page under point for editing
  • TAB – go to the next wiki link
  • M-n – next page in the page ring
  • M-p – previous page in the page ring
  • M-g – reload the current page

Now enjoy editing wiki pages in emacs!

Tips and tricks

MediaWiki provies a hook to customize configuration. For example, if Template:Keypress does not work for you, you can redefine it easily:

(setq mediawiki-mode-hook
    (lambda ()
        (define-key mediawiki-mode-map (kbd "C-c RET") 'mediawiki-open-page-at-point)
))

Autofill off

Wikis do not autofill paragraphs. If you do so, it might confuse history diffs, and thus making them useless. So you'd be better off turning the auto-fill feature completely off. Add to the hook the following line:

(setq mediawiki-mode-hook (lambda ()
                          ;; ...
                            (turn-off-auto-fill)
))

Specifying the browser

A convenient feature of Mediawiki is the mediawiki-browse function which let you see the result of the page in a web browser. The browser is chosen following the browse-url plugin. You can configure this behaviour. For example:

(setq browse-url-generic-program (executable-find (getenv "BROWSER"))
browse-url-browser-function 'browse-url-generic)

will use your environment browser, whereas

(setq browse-url-generic-program (executable-find "dwb")
browse-url-browser-function 'browse-url-generic)

will specifically use the dwb browser.

See also