This version of mediawiki.el represents a merging of wikipedia-mode.el (maintained by Uwe Brauer) from EmacsWiki for its font-lock code, menu, draft mode, replying and convenience functions to produce mediawiki.el 2.0.
The package has been reorganized into a modular structure for better maintainability and code organization, while maintaining full backward compatibility.
If you use MELPA, you can install via the M-x package-list-packages interface. This is preferable as you will have access to updates automatically.
Alternatively, if you have emacs 30+ you can use:
<syntaxhighlight lang="Emacs Lisp"> (use-package mediawiki :vc (:url "https://github.com/hexmode/mediawiki-el" :rev :latest)) </syntaxhighlight>
Otherwise, just make sure this file is in your load-path (usually ~/.emacs.d is included) and put (require 'mediawiki) in your ~/.emacs or ~/.emacs.d/init.el file.
Note: The modular structure is completely transparent to users. Simply require 'mediawiki as before and all functionality will be available. The reorganization maintains full backward compatibility.
M-x customize-group RET mediawiki RET *dink* *dink* M-x mediawiki-site RET Wikipedia RET
Open a wiki file: M-x mediawiki-open Save a wiki buffer: C-x C-s Save a wiki buffer with a different name: C-x C-w
Although there is a place to put your password when you customize this package, there is no need to store your password in plain text.
If mediawiki sees that the password is empty, then it will use the auth-source library to retrieve the password. This will allow you to use encryption to store your passwords.
The mediawiki.el package is now organized into the following modular components:
- mediawiki.el - Main entry point with package metadata and requires
- mediawiki-core.el - Core variables, constants, and fundamental utilities
- mediawiki-faces.el - Font-lock face definitions for MediaWiki syntax
- mediawiki-font-lock.el - Font-lock keywords and syntax highlighting rules
- mediawiki-api.el - MediaWiki API interaction and data processing
- mediawiki-auth.el - Authentication and login management
- mediawiki-http.el - HTTP utilities and compatibility functions
- mediawiki-page.el - Page editing, saving, and content management
- mediawiki-draft.el - Draft functionality and temporary editing
- mediawiki-site.el - Site configuration and management
- mediawiki-utils.el - General utility functions
- mediawiki-mode.el - Major mode definition and user interface
OAuth 2.0 is the preferred way to authenticate with MediaWiki sites. Password-based login (bot passwords) is deprecated on Wikimedia wikis and may not be available on others.
To use OAuth with a Wikimedia wiki, you need to register a consumer application:
- Visit https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oauth2
- Fill in the fields:
- Application name:
mediawiki.el - Consumer version:
1.0 - Application description: A short description of your use
- Check This consumer is only for use by USERNAME (replace USERNAME with your wiki username) to create an owner-only consumer — this is the simplest option
- Application name:
- Scroll down to Applicable grants and select the permissions you need (e.g., Edit existing pages, Edit protected pages, Edit your user CSS/JSON/JavaScript, Edit the MediaWiki namespace and sitewide/user JSON)
- Read and accept the terms, then click Propose consumer
- On the next page you will see your Client application key, Client application secret, and Access token
Once you have your OAuth consumer credentials, configure mediawiki.el to use them. You can either:
- Use the interactive command: <kbd>M-x mediawiki-oauth-setup-site</kbd>
- Or add the properties directly to
mediawiki-site-alistin your Emacs init file:
To avoid storing secrets in plain text, you can omit :oauth-client-secret and :oauth-access-token from your config and store them in auth-source instead (e.g., in ~/.authinfo.gpg):
<syntaxhighlight lang="text"> machine en.wikipedia.org login YOUR_CLIENT_APPLICATION_KEY password YOUR_CLIENT_APPLICATION_SECRET port mediawiki-client-secret machine en.wikipedia.org login YOUR_CLIENT_APPLICATION_KEY password YOUR_ACCESS_TOKEN port mediawiki-access-token </syntaxhighlight>
With the client credentials and access token configured, mediawiki.el will automatically use OAuth 2.0 Bearer token authentication for all API requests to this site.
- Change customization to explicitly tell mediawiki.el to use the auth-source library.
- Optionally use org-mode formatting for editing and translate that to mw
- Move url-* methods to url-http
- Use the MW API to support searching, etc.
- Clean up and thoroughly test imported wikimedia.el code
- Improve language support. Currently there is a toggle for English or German. This should probably just be replaced with the ability to use MediaWiki's i18n files in json format.