wikipedia manual
Table of contents
Overview
The wikipedia.el package provides a comprehensive Emacs interface for Wikipedia.
It builds on top of mediawiki.el, which handles the low-level protocol details,
and adds higher-level workflows for editing, reviewing, and managing Wikipedia
content.
The package requires Emacs 29.1 or later and mediawiki.el for the
underlying API communication. Optionally, gptel provides AI-powered
features (citation generation, edit summary generation, and watchlist
review scoring), and pangram.el provides AI-generated text detection.
When available, corresponding groups appear in the transient menu
(Transient menu).
Before using any commands, you must configure at least one
wiki site via mediawiki-site-alist and establish a session with
wikipedia-login (Session management).
The package is organized around several core workflows:
Page editing: open pages for editing in
mediawiki-modebuffers, preview rendered HTML, and publish changes back to the wiki (Page editing).Draft management: save work-in-progress edits as local files that persist across sessions (Draft management).
Watchlist: browse your watchlist with a grouped, expandable interface that shows recent changes organized by page, with unread tracking and background prefetching of diffs (Watchlist).
Revision history: inspect the full revision history of any page, view diffs between arbitrary revisions, and navigate between historical snapshots (Revision history).
User inspection: view user contributions, visit user pages, send thanks, and look up detailed editing statistics via XTools (User inspection, XTools statistics).
Local mirror: synchronize watched pages to a local SQLite database for offline browsing and faster access (Synchronization and local mirror).
Diff follow mode: automatically display diffs as you navigate entries in the watchlist, history, or contributions buffers (Diff follow mode).
AI-powered editing (requires
gptel): generate Wikipedia citation templates, produce edit summaries from diffs, and score watchlist changes by review priority (AI commands).Wiki link completion: get title suggestions from the MediaWiki API as you type inside
[[...]]links (Wiki link completion).
All commands are accessible through a unified transient menu (Transient menu).
The development repository is on GitHub.
User options
Diff display
The user option wikipedia-diff-function controls how diffs are
displayed throughout the package. It accepts two values:
unified(the default): show diffs in a single buffer using Emacs’s built-indiff-mode. This is compact and integrates well with the diff follow mode (Diff follow mode).ediff: useediff-buffersfor side-by-side comparison. This gives a richer interactive experience but opens multiple windows and is incompatible with diff follow mode.
Change this option if you prefer side-by-side comparison and do not use diff follow mode.
Draft storage
The user option wikipedia-draft-directory specifies the directory
where local drafts are stored. Each draft is saved as a .wiki file
named after the page title, using a byte-level encoding scheme for
filesystem safety. The default value is wikipedia-drafts/ inside
user-emacs-directory.
Change this if you want drafts stored in a different location, for example a directory that is synchronized across machines.
XTools integration
The user option wikipedia-xtools-base-url specifies the base URL for
the XTools API. The default value is https://xtools.wmcloud.org/api.
You would only change this if the XTools service moves to a different
URL.
The user option wikipedia-xtools-project specifies the default project
for XTools queries. The default value is en.wikipedia.org. Change
this if you primarily edit a different Wikipedia language edition or
another MediaWiki project (e.g., de.wikipedia.org or
commons.wikimedia.org).
Local database
The user option wikipedia-db-file specifies the path to the SQLite
database file used for local page storage. The default value is
wikipedia.db inside user-emacs-directory. Change this if you want
the database stored elsewhere, for example to keep it separate from
your Emacs configuration.
Synchronization
The user option wikipedia-sync-revision-limit controls the maximum
number of revisions to synchronize per page. The default value is 20.
Increase this if you want deeper local history; decrease it if
synchronization is too slow.
The user option wikipedia-sync-fetch-content controls whether full
revision content (wikitext) is fetched during synchronization. When
non-nil (the default), the content of the most recent revision is
downloaded and stored locally, enabling offline viewing and local diffs.
Set this to nil if you only want revision metadata without the actual
page content.
AI configuration
All AI-powered commands require the gptel package. When gptel is
not installed, the AI groups in the transient menu are hidden and the
commands signal an error if called directly.
The user option wikipedia-ai-backend specifies the gptel backend name
for AI commands (e.g., "Gemini" or "Claude"). When nil, the
backend is inferred from the model or falls back to gptel-backend.
The user option wikipedia-ai-model specifies the gptel model for AI
commands. When nil, it defaults to gptel-model.
Both options accept three forms:
nil: use the gptel default.- A single value (symbol for model, string for backend): use it for all AI commands.
- An alist mapping command keys to values, with
tas the fallback:
(setq wikipedia-ai-model
'((cite . gemini-2.0-flash)
(review . claude-sonnet-4-5-20250514)
(t . gemini-2.0-flash-lite)))
Valid command keys are cite (Citation generation),
summarize (Edit summary generation), and
review (Watchlist review). Commands not
listed in the alist fall back to the t entry, then to gptel-model.
The user options wikipedia-ai-review-backend and
wikipedia-ai-review-model provide per-command overrides specifically
for watchlist review. When set, they take precedence over the alist in
wikipedia-ai-model / wikipedia-ai-backend.
The user options wikipedia-ai-citation-system-prompt,
wikipedia-ai-summarize-system-prompt, wikipedia-ai-review-system-prompt,
and wikipedia-ai-review-prompt control the LLM prompts for their
respective commands. Customize these to change the AI’s behavior.
Before scoring, the review system normalizes the wikitext by stripping
citation markup and splitting sentences, so the AI receives a standard
unified diff at sentence granularity. This makes citation-only changes
invisible (scored 0.0) and section moves clearly recognizable.
The user option wikipedia-ai-summarize-auto controls whether
wikipedia-publish automatically generates an AI edit summary before
prompting. When non-nil, the minibuffer is pre-filled with the AI’s
suggestion, which you can edit before confirming. Defaults to nil.
The user option wikipedia-ai-review-auto controls whether the
watchlist is automatically scored after each refresh. When non-nil,
wikipedia-ai-review-watchlist runs automatically, so entries are always
scored without pressing R.
The user option wikipedia-ai-review-verbose controls whether
per-entry progress messages are shown during scoring.
Wiki link completion
The user option wikipedia-completion-limit controls the maximum number
of title candidates fetched from the MediaWiki API for each completion
request. The default value is 15. Increase this if you find that the
desired page frequently does not appear among the suggestions; decrease
it if API latency is a concern on slow connections.
Commands
Session management
The command wikipedia-login establishes a session with a wiki site.
When called interactively, it prompts for a site name from those
configured in mediawiki-site-alist. You must call this command (or
let it be called implicitly) before using any other wikipedia.el
commands. Most commands call wp--ensure-logged-in internally, which
will prompt you to select a site if no session is active.
Page editing
The command wikipedia-open opens a Wikipedia page for editing in a
mediawiki-mode buffer. When called interactively, it prompts for the
page title, defaulting to the title at point if available (for example,
when invoked from a watchlist or history buffer).
The command wikipedia-publish saves the current buffer’s content back
to the wiki. It prompts for an edit summary in the minibuffer. When
wikipedia-ai-summarize-auto is non-nil (AI
configuration), the summary prompt is pre-filled with an AI-generated
suggestion. The alias wikipedia-save is provided for
discoverability.
The command wikipedia-browse opens the page in an external web browser
via browse-url. Like wikipedia-open, it defaults to the title at
point.
The command wikipedia-eww-open opens the Wikipedia article displayed
in the current EWW buffer for editing. It extracts the article title
from the EWW URL and calls wikipedia-open, positioning point at the
corresponding location in the wikitext source. This is useful when
browsing Wikipedia in EWW and wanting to quickly fix something in the
source. The command is also available from the transient menu
(Transient menu) under e.
The minor mode wikipedia-edit-mode provides additional keybindings and
completion when editing a wiki page. It displays WP in the mode line
lighter, registers wikipedia-completion-at-point for wiki link
completion (Wiki link completion), and adds
the following bindings:
| Key | Command | Description |
|---|---|---|
C-c C-p | wikipedia-preview | Preview rendered HTML |
C-c C-d | wikipedia-diff-to-live | Diff buffer against live |
C-c C-s | wikipedia-ai-summarize | Generate AI edit summary |
Preview
The command wikipedia-preview sends the current buffer’s wikitext to
the MediaWiki parse API and displays the rendered HTML in a dedicated
preview buffer. The preview uses shr-render-region to display the
HTML as formatted text within Emacs.
The preview buffer uses wikipedia-preview-mode, which provides the
following keybindings:
| Key | Command | Description |
|---|---|---|
e | wikipedia-preview-edit | Switch back to the source buffer |
g | wikipedia-preview-refresh | Re-render the preview from source |
q | quit-window | Close the preview window |
The preview buffer supports revert-buffer (bound to g in
special-mode), which re-fetches the preview from the source buffer.
Draft management
Drafts allow you to save work-in-progress edits locally before
publishing them to the wiki. Each draft is a .wiki file stored in
wikipedia-draft-directory (Draft storage).
The command wikipedia-draft-save saves the current buffer’s content as
a local draft. It requires the buffer to have a page title set (as is
the case when editing a page opened via wikipedia-open). Saving a
draft for the same page overwrites the previous draft.
The command wikipedia-draft-open prompts you to select a draft from
the list of saved drafts, then opens it in a mediawiki-mode buffer
with wikipedia-edit-mode enabled. From there, you can continue
editing and eventually publish with wikipedia-publish.
The command wikipedia-draft-delete prompts for a draft to delete, with
a confirmation prompt before removing the file.
Page titles are encoded into safe filenames using a byte-level escape
scheme: characters outside [a-zA-Z0-9 .-] are replaced with _XX
sequences (where XX is the hexadecimal byte value of each UTF-8
byte). This ensures filenames are portable across operating systems
while remaining mostly human-readable for ASCII titles.
Watchlist
The command wikipedia-watchlist opens a buffer displaying your
Wikipedia watchlist. Entries are grouped by page title: each page
appears as a collapsible group header showing the most recent change
summary, the contributing users, and the total size change. Pages with
multiple recent changes display a count (e.g., “Article name (3
changes)”).
The watchlist fetches unseen changes from the last 30 days, excluding bot edits and minor edits. After loading, it asynchronously prefetches revision content in the background so that diffs can be displayed instantly when you navigate to an entry.
Navigation
Group headers with more than one change can be expanded and collapsed.
The command wikipedia-watchlist-toggle-expand, bound to TAB and
SPC, toggles the group at point. Expanded groups show individual
entries indented below the header, with per-edit timestamps, users, size
changes, and summaries. The indicators ▶ (collapsed) and ▼
(expanded) show the current state.
The commands wikipedia-watchlist-expand-all (e) and
wikipedia-watchlist-collapse-all (c) expand or collapse every group
at once.
Actions
The command wikipedia-watchlist-open-page (RET, o) opens the page
at point for editing, marking it as read. The command
wikipedia-watchlist-show-diff (d, v) displays the diff for the
change at point, using the method specified by wikipedia-diff-function
(Diff display). The command
wikipedia-watchlist-show-history (h) opens the full revision history
for the page. The command wikipedia-watchlist-browse (b) opens the
page in an external browser.
Unread tracking
Unread entries are displayed in bold (using the wikipedia-watchlist-unread
face). Opening a page or viewing its diff marks it as read, both
locally and on the server. The command wikipedia-watchlist-mark-all-read
(m or !) marks every entry as read.
Managing watched pages
The command wikipedia-watchlist-watch (w) adds a page to your
watchlist. The command wikipedia-watchlist-unwatch (x) removes a
page, after confirmation. Both commands default to the title at point
and send the request asynchronously.
Full keybinding reference
| Key | Command | Description |
|---|---|---|
RET | wikipedia-watchlist-open-page | Open page for editing |
TAB | wikipedia-watchlist-toggle-expand | Toggle group expansion |
SPC | wikipedia-watchlist-toggle-expand | Toggle group expansion |
d | wikipedia-watchlist-show-diff | Show diff for entry |
v | wikipedia-watchlist-show-diff | Show diff for entry |
f | wikipedia-diff-follow-mode | Toggle diff follow mode |
h | wikipedia-watchlist-show-history | Show page history |
b | wikipedia-watchlist-browse | Open in browser |
B | wikipedia-browse | Browse any page |
e | wikipedia-watchlist-expand-all | Expand all groups |
c | wikipedia-watchlist-collapse-all | Collapse all groups |
m | wikipedia-watchlist-mark-all-read | Mark all as read |
! | wikipedia-watchlist-mark-all-read | Mark all as read |
o | wikipedia-watchlist-open-page | Open page for editing |
t | wikipedia-thank | Thank user for edit |
u | wikipedia-user-at-point | Inspect user at point |
s | wikipedia-xtools-user-stats | User stats via XTools |
w | wikipedia-watchlist-watch | Watch a page |
x | wikipedia-watchlist-unwatch | Unwatch a page |
g | wikipedia-watchlist-refresh | Refresh the watchlist |
q | quit-window | Close the window |
Revision history
The command wikipedia-history opens a buffer displaying the revision
history of a page. When called interactively, it prompts for the page
title. The history buffer shows each revision’s ID, date, author,
size, and edit summary in a tabulated list, sorted by date (newest
first).
Viewing and comparing revisions
The command wikipedia-history-view-revision (RET, v) fetches and
displays the full wikitext of the revision at point in a read-only
buffer.
The command wikipedia-history-diff-to-previous (d) shows the diff
between the revision at point and its parent revision. This corresponds
to Wikipedia’s “prev” link. The command
wikipedia-history-diff-to-current (c) shows the diff between the
revision at point and the most recent revision, corresponding to
Wikipedia’s “cur” link.
The command wikipedia-history-diff-revisions (D) prompts for two
revision IDs and displays the diff between them. This is useful for
comparing non-adjacent revisions.
The command wikipedia-history-browse-revision (b) opens the revision
at point in an external browser.
Full keybinding reference
| Key | Command | Description |
|---|---|---|
RET | wikipedia-history-view-revision | View revision wikitext |
v | wikipedia-history-view-revision | View revision wikitext |
d | wikipedia-history-diff-to-previous | Diff to parent (prev) |
c | wikipedia-history-diff-to-current | Diff to latest (cur) |
D | wikipedia-history-diff-revisions | Diff arbitrary revisions |
f | wikipedia-diff-follow-mode | Toggle diff follow mode |
b | wikipedia-history-browse-revision | Open revision in browser |
B | wikipedia-browse | Browse any page |
o | wikipedia-open | Open page for editing |
t | wikipedia-thank | Thank user for edit |
u | wikipedia-user-at-point | Inspect user at point |
s | wikipedia-xtools-user-stats | User stats via XTools |
w | wikipedia-watchlist-watch | Watch this page |
x | wikipedia-watchlist-unwatch | Unwatch this page |
g | wikipedia-history-refresh | Refresh history |
q | quit-window | Close the window |
User inspection
The command wikipedia-user-contributions opens a buffer displaying a
user’s recent contributions. When called interactively, it prompts for
the username, defaulting to the user at point when available (e.g., when
invoked from a watchlist or history buffer). The contributions buffer
shows each edit’s timestamp, page title, size change, and edit summary.
Contribution actions
The command wikipedia-user-contributions-view-diff (RET, d) shows
the diff between the contribution at point and its parent revision. The
command wikipedia-user-contributions-view-revision (v) displays the
full wikitext. The command wikipedia-user-contributions-open-page
(o) opens the page for editing.
The command wikipedia-user-contributions-browse (b) opens the
revision in an external browser. The command
wikipedia-user-contributions-show-history (h) opens the full page
history. The command wikipedia-user-contributions-thank (t) sends a
thank notification for the edit.
User page and profile commands
The command wikipedia-user-page opens the user page (User:USERNAME)
for editing. The command wikipedia-user-talk opens the user’s talk
page. The command wikipedia-user-browse opens the user page in an
external browser.
The command wikipedia-user-at-point inspects the user at point in any
of the list buffers (watchlist, history, contributions), opening their
contributions.
The command wikipedia-user-stats is a convenience wrapper that calls
wikipedia-xtools-user-stats (XTools statistics).
Sending thanks
The command wikipedia-thank sends a thank notification to the author
of the revision at point. It prompts for confirmation before sending.
This command works from any buffer where a revision ID is available
(history, watchlist, or contributions).
Full keybinding reference
| Key | Command | Description |
|---|---|---|
RET | wikipedia-user-contributions-view-diff | Show diff |
d | wikipedia-user-contributions-view-diff | Show diff |
v | wikipedia-user-contributions-view-revision | View wikitext |
o | wikipedia-user-contributions-open-page | Open page for editing |
h | wikipedia-user-contributions-show-history | Show page history |
b | wikipedia-user-contributions-browse | Open in browser |
B | wikipedia-browse | Browse any page |
f | wikipedia-diff-follow-mode | Toggle diff follow mode |
t | wikipedia-user-contributions-thank | Thank for this edit |
u | wikipedia-user-at-point | Inspect user at point |
s | wikipedia-user-stats | User stats via XTools |
w | wikipedia-watchlist-watch | Watch this page |
x | wikipedia-watchlist-unwatch | Unwatch this page |
g | wikipedia-user-contributions-refresh | Refresh contributions |
q | quit-window | Close the window |
XTools statistics
The XTools commands fetch and display editing statistics from the XTools API, a service that provides detailed analysis of editing activity on MediaWiki projects. These commands supplement the information available through the MediaWiki API with data such as top edited pages and detailed edit breakdowns.
User statistics
The command wikipedia-xtools-user-stats displays comprehensive
statistics for a user. The output includes:
- Basic information: user ID, registration date, project.
- Admin status (highlighted if the user is a sysop or bureaucrat).
- Edit counts: live edits, deleted edits, total, and pages created.
- Activity period: first edit and most recent edit timestamps.
- User group memberships (local and global).
- Top 10 most-edited pages in the article namespace.
The command combines data from both the XTools API (edit counts) and the MediaWiki API (registration, groups, contribution timestamps) to present a unified view.
Page statistics
The command wikipedia-xtools-page-stats displays statistics for a
page, including revision count, number of editors, minor edit count,
average edit size, page size, creation date, and top editors.
The command wikipedia-xtools-top-editors displays a detailed list of
the top editors for a page, showing each editor’s edit count, minor edit
count, and the date range of their activity.
Synchronization and local mirror
The synchronization and mirror system stores Wikipedia pages and their revision history in a local SQLite database, enabling offline browsing and faster access to frequently visited pages.
Synchronizing pages
The command wikipedia-sync-page synchronizes a single page to the
local database. It downloads revision metadata (up to
wikipedia-sync-revision-limit revisions) and, if
wikipedia-sync-fetch-content is non-nil, the full wikitext of the most
recent revision.
The command wikipedia-sync-watchlist performs a bulk synchronization of
all pages from your watchlist. It first fetches the watchlist, marks
each page as watched in the database, and then synchronizes each page
individually with a brief delay between requests to avoid overloading
the server. Pages that fail to synchronize are reported in a summary
message without aborting the remaining pages.
The command wikipedia-sync-update re-synchronizes all pages already
marked as watched in the local database. Use this for routine updates
after the initial wikipedia-sync-watchlist import.
Browsing the local mirror
The command wikipedia-mirror opens a buffer listing all pages stored in
the local database, showing each page’s title, revision count, last sync
time, and watched status.
From the mirror browser, you can open a page for online editing (RET,
o), view its local revision history (h), synchronize a single page
(s), or synchronize all watched pages (S).
| Key | Command | Description |
|---|---|---|
RET | wikipedia-mirror-open-page | Open page for online editing |
o | wikipedia-mirror-open-page | Open page for online editing |
h | wikipedia-mirror-show-history | Show local revision history |
s | wikipedia-mirror-sync-page | Sync this page |
S | wikipedia-mirror-sync-all | Sync all watched pages |
g | wikipedia-mirror-refresh | Refresh the list |
q | quit-window | Close the window |
Local revision history
The local history buffer shows revisions stored in the database for a
given page. The command wikipedia-mirror-history-view (RET, v)
displays the stored wikitext of the revision at point. The command
wikipedia-mirror-history-diff (d) shows the diff between the
revision and its parent, using locally stored content.
Both commands require that the revision content was downloaded during synchronization. If content is not available, an error is reported.
| Key | Command | Description |
|---|---|---|
RET | wikipedia-mirror-history-view | View stored wikitext |
v | wikipedia-mirror-history-view | View stored wikitext |
d | wikipedia-mirror-history-diff | Diff to parent revision |
g | wikipedia-mirror-history-refresh | Refresh history |
q | quit-window | Close the window |
Database management
The command wikipedia-db-close closes the database connection. The
connection is opened lazily on first use and remains open for the
duration of the Emacs session.
The command wikipedia-db-stats displays a summary of the database
contents: the number of pages, watched pages, revisions, and revisions
with stored content.
Diff follow mode
The minor mode wikipedia-diff-follow-mode automatically displays the
diff for the entry at point whenever you move to a different line in a
list buffer. It works in the watchlist, history, and contributions
buffers and is toggled with f in any of these modes.
When enabled, navigating to a new entry triggers an automatic diff display in an adjacent window. If both revisions are already in the cache (populated by the watchlist’s background prefetching), the diff appears instantly. Otherwise, the revisions are fetched asynchronously and the diff is displayed when both arrive, with a “Loading diff…” placeholder in the meantime.
Diff follow mode requires wikipedia-diff-function to be set to
unified (Diff display). Attempting
to enable it when ediff is selected produces a warning and the mode
remains disabled.
In watchlist mode, viewing a diff via follow mode also marks the entry as read (Unread tracking).
AI commands
All AI commands require the gptel package. See AI
configuration for backend and model settings.
Citation generation
The command wikipedia-ai-cite generates a properly formatted Wikipedia
citation template from a URL or free-text source description. The
generated citation uses the appropriate template ({{cite web}},
{{cite book}}, {{cite journal}}, etc.) and is inserted at point.
When called interactively, it prompts for the input. Examples:
- A URL:
https://example.com/article - A description:
"The Wealth of Nations by Adam Smith, 1776"
Edit summary generation
The command wikipedia-ai-summarize generates an AI-powered edit
summary for the current buffer’s changes. It compares the buffer
against the live version on Wikipedia, sends the unified diff to the
LLM, and produces a concise summary following Wikipedia’s
edit summary conventions:
standard abbreviations, specific descriptions, and a 500-character
limit.
The generated summary is stored in a buffer-local variable. When you
next call wikipedia-publish, the summary pre-fills the minibuffer
prompt so you can review and edit it before confirming.
When wikipedia-ai-summarize-auto is non-nil, wikipedia-publish
calls this command automatically before prompting, removing the need to
invoke it separately.
Watchlist review
The command wikipedia-ai-review-watchlist scores watchlist changes
using AI to prioritize review. Each watchlist group is assigned a score
between 0.0 (trivial, no review needed) and 1.0 (highly significant,
should be reviewed).
The command fetches the unified diff for each unscored group asynchronously, sends it to the LLM, and parses the JSON response containing a score and a brief reason. Scores are persisted in the local SQLite database and restored when the watchlist is reopened.
In the watchlist buffer:
| Key | Command | Description |
|---|---|---|
R | wikipedia-ai-review-watchlist | Score unscored entries |
S | sort by score | Toggle score vs. recency sort |
I | show reason | Display AI reasoning |
High scores (>=0.7) are highlighted with a warning face; low scores (<=0.3) are dimmed.
Wiki link completion
When wikipedia-edit-mode is active (Page editing),
typing inside a [[...]] wiki link triggers completion via
wikipedia-completion-at-point. The function queries the MediaWiki
prefixsearch API for page titles matching what you have typed so far,
and presents the results through the standard Emacs completion UI
(completion-at-point, typically triggered with C-M-i or TAB
depending on your configuration).
Completion activates only when point is in the link target portion of a
wiki link — that is, after [[ and before any | pipe character. If
you are typing the display text after the pipe (e.g., [[Foo|some text), completion does not trigger, since the display text is
free-form.
Results are cached for five minutes per prefix to avoid redundant API
calls. The number of candidates per request is controlled by
wikipedia-completion-limit (Wiki link
completion options).
Transient menu
The command wikipedia-transient opens a transient menu providing quick
access to all wikipedia.el commands. The menu is arranged in
vertically aligned columns, each containing one or two thematic groups:
- Page / Draft: page operations (open, publish, preview, diff, edit from EWW, browse, login) and draft management (save, open, delete).
- User / XTools: user commands (contributions, user page, talk, browse, thank) and XTools statistics (user stats, page stats, top editors).
- Watchlist / History (
hprefix): watchlist operations (open, watch/unwatch, browse, mark all read) and history commands (open, undo, restore). - Sync & Mirror (
sprefix): sync commands (sync page, sync watchlist, sync update, mirror). - AI (
aprefix): AI commands (detect AI, clear overlays, generate citation, generate edit summary, review watchlist). This column is shown only whenpangram.elorgptelis installed; individual items are further filtered by their specific library dependency.
Bind wikipedia-transient to a convenient key for quick access to any
command in the package.