WEBVTT captioned by sachac


NOTE Introduction

00:00:00.405 --> 00:00:03.606
Hello, my name is Charles Choi and welcome to my talk,

00:00:03.607 --> 00:00:06.590
Revisiting Emacs Mouse Interactions with Anju.

00:00:08.010 --> 00:00:10.633
Anju is a project to provide a better point and

00:00:10.673 --> 00:00:12.794
click experience for Emacs.

00:00:13.795 --> 00:00:16.958
Motivating Anju is the desire to align Emacs

00:00:16.998 --> 00:00:19.279
mouse interactions with what I think most mouse

00:00:19.419 --> 00:00:21.721
users would expect in 2026.

00:00:22.882 --> 00:00:25.884
This talk will be opinionated and hopefully not

00:00:25.964 --> 00:00:26.705
too triggering.

00:00:28.215 --> 00:00:30.657
For reference, Anju is a Korean word whose

00:00:30.737 --> 00:00:33.700
translation is food eaten alongside alcohol.

NOTE Why Anju?

00:00:35.221 --> 00:00:36.202
So why make Anju?

00:00:37.363 --> 00:00:39.244
Let me start with a strong assertion.

00:00:40.365 --> 00:00:42.907
It's really weird to use a mouse with Emacs out

00:00:42.927 --> 00:00:43.468
of the box.

00:00:44.549 --> 00:00:45.569
This is why I think that.

NOTE Over-committed to the middle mouse button

00:00:47.951 --> 00:00:50.494
The first one is a fixation on maintaining the

00:00:50.554 --> 00:00:51.855
middle mouse button event.

00:00:52.475 --> 00:00:54.757
This affects things like the mode line, scroll

00:00:54.797 --> 00:00:56.899
bars, dividers, and pasting text.

00:00:57.911 --> 00:01:00.372
Arguably this banding was made at a time when

00:01:00.432 --> 00:01:03.552
most mice looked like the Sun optical mice that

00:01:03.572 --> 00:01:04.973
you see here from the 90s.

00:01:05.613 --> 00:01:06.593
Times change though.

00:01:07.834 --> 00:01:10.514
For many decades now this is the baseline design

00:01:10.554 --> 00:01:14.095
of a mouse which is emulated with trackpads on laptops.

00:01:16.036 --> 00:01:18.596
The middle button has been replaced by a scroll

00:01:18.636 --> 00:01:21.017
wheel which does double duty as a button.

00:01:22.404 --> 00:01:24.625
That said, pressing this scroll wheel button is

00:01:24.666 --> 00:01:27.427
an unpleasant experience compared to the left and

00:01:27.487 --> 00:01:29.529
right buttons next to it.

00:01:31.150 --> 00:01:33.691
Given a standard right-handed configuration, the

00:01:33.752 --> 00:01:38.154
left button is used for primary selection and the

00:01:38.214 --> 00:01:41.937
right button is commonly used to raise a context menu.

NOTE Menus feel more like inventories

00:01:45.478 --> 00:01:48.540
A lot of menus in Emacs feel ad-hoc design, which

00:01:48.600 --> 00:01:51.463
results in a chaotic experience for users.

00:01:52.443 --> 00:01:55.005
Often menus feel more like inventories than an

00:01:55.065 --> 00:01:56.366
information architecture.

00:01:57.267 --> 00:01:59.909
Consider, for example, Dired, which has no less

00:01:59.949 --> 00:02:03.111
than 5 separate top-level menus, whose design is

00:02:03.211 --> 00:02:04.752
best described as mid.

00:02:05.913 --> 00:02:09.196
Picking apart this design is another talk, but

00:02:09.276 --> 00:02:12.098
I'll ask, why does bytecompile in the operate

00:02:12.138 --> 00:02:14.320
menu show up for files other than Elisp?

NOTE Surprising single vs. double-click behavior

00:02:18.233 --> 00:02:21.656
Another irritant is how Emacs handles single vs.

00:02:21.716 --> 00:02:22.876
double click behavior.

00:02:24.117 --> 00:02:27.100
Typical file managers like Microsoft Explorer and

00:02:29.341 --> 00:02:33.504
macOS Finder treat single click as a selection action.

00:02:34.325 --> 00:02:37.427
However, Dired and Ibuffer both treat single

00:02:37.487 --> 00:02:40.409
click as an open action like a hypertext document.

00:02:41.310 --> 00:02:45.273
This makes for a very twitchy and anxious experience.

NOTE Erratic context menu design

00:02:48.602 --> 00:02:51.563
The adoption of context menu mode introduced in

00:02:51.663 --> 00:02:54.464
Emacs 28 has been uneven at best.

00:02:55.744 --> 00:02:58.425
Many modes implement their context menu by just

00:02:58.465 --> 00:03:00.805
dumping their mode map into its contents.

00:03:01.926 --> 00:03:04.546
Such an approach fails to take advantage of

00:03:04.646 --> 00:03:07.827
building a genuinely context-sensitive interface.

NOTE What does Anju do?

00:03:14.489 --> 00:03:17.870
Anju makes opinionated changes to mouse behavior in Emacs.

00:03:19.078 --> 00:03:22.320
First is to enhance direct manipulation, as the

00:03:22.360 --> 00:03:24.922
mouse is intrinsically a pointing device.

00:03:26.263 --> 00:03:29.545
Second is to revisit how content is organized in

00:03:29.585 --> 00:03:33.328
menus for both the menu bar and context menus.

00:03:34.789 --> 00:03:37.571
And finally is to stop using the middle button.

00:03:41.238 --> 00:03:43.779
My opinions on application user interfaces are

00:03:43.819 --> 00:03:46.460
strongly informed by macOS and Windows.

00:03:47.241 --> 00:03:52.323
Guiding their design is the HIG and CUA, respectively.

00:03:53.424 --> 00:03:56.944
In building Anju, I've tried to make design decisions

00:03:56.945 --> 00:03:59.086
that are conventional to those platforms.

NOTE Who is Anju for?

00:04:02.068 --> 00:04:02.748
Who's this for?

00:04:04.603 --> 00:04:07.444
While this meme is shown in jest, there is truth

00:04:08.844 --> 00:04:11.705
that pointing tasks are more efficiently done

00:04:11.785 --> 00:04:12.326
with a mouse.

00:04:15.026 --> 00:04:17.527
More seriously though, Anju is for everybody.

00:04:18.408 --> 00:04:21.108
I contend that Emacs is capable of good mouse

00:04:21.148 --> 00:04:24.770
support and those who insist on using a keyboard

00:04:24.830 --> 00:04:25.910
alone are missing out.

00:04:26.710 --> 00:04:29.691
With Anju, Emacs users can have both a great

00:04:29.791 --> 00:04:31.752
keyboard and mouse experience.

NOTE Design principles: Making a calmer mouse experience

00:04:36.091 --> 00:04:39.514
Aspirationally, Anju tries to make using the mouse

00:04:39.874 --> 00:04:41.375
a calmer experience.

00:04:42.736 --> 00:04:44.718
Let's detail how this is achieved.

00:04:47.260 --> 00:04:49.481
First is to recognize that the mouse is a

00:04:49.542 --> 00:04:50.342
pointing device.

00:04:50.943 --> 00:04:52.944
With it, you can directly act on what you're

00:04:52.964 --> 00:04:53.505
pointing at.

NOTE Menus should be organized

00:04:55.606 --> 00:04:57.408
Second is menu organization.

00:04:58.627 --> 00:05:01.349
Menus surface actionable commands to the user.

00:05:01.830 --> 00:05:04.031
Ideally, there is an information architecture

00:05:04.071 --> 00:05:06.013
that gives structure and relevance to the

00:05:06.053 --> 00:05:07.634
commands presented to the user.

00:05:09.196 --> 00:05:12.318
Two competing objectives in organizing commands

00:05:12.498 --> 00:05:14.720
is discoverability versus concision.

00:05:15.741 --> 00:05:18.883
Discoverability wants to maximize choice, whereas

00:05:18.944 --> 00:05:21.946
concision seeks to minimize it.

00:05:24.924 --> 00:05:27.245
Anju takes the opinion that the menu bar should

00:05:27.265 --> 00:05:32.387
be optimized for discoverability, and that

00:05:32.447 --> 00:05:34.688
context menus are all about concision.

NOTE Concision is achieved with context

00:05:37.550 --> 00:05:40.851
To get concision, you need to take into account context.

00:05:41.732 --> 00:05:42.692
What is context?

00:05:43.452 --> 00:05:46.073
It is the set of circumstances that give meaning

00:05:46.334 --> 00:05:47.014
to an event.

00:05:48.543 --> 00:05:51.946
In general, for a context menu, the event is the

00:05:51.986 --> 00:05:55.248
place on the screen where the context menu is raised.

NOTE Example context criteria

00:05:58.030 --> 00:06:00.652
Different criteria can determine when a command

00:06:00.712 --> 00:06:02.433
is shown in a context menu.

00:06:03.794 --> 00:06:06.456
These include the position of the mouse, whether

00:06:06.516 --> 00:06:09.138
text is selected, what mode is active.

00:06:09.539 --> 00:06:12.121
A whole host of different criteria can be

00:06:12.301 --> 00:06:15.003
generated and this is just only a subset here.

00:06:16.144 --> 00:06:18.825
Combinatorial logic on this criteria determines

00:06:19.046 --> 00:06:21.847
if and how a command is displayed in the menu.

00:06:24.588 --> 00:06:29.471
Other menu design concerns include nesting menus

00:06:29.511 --> 00:06:33.033
so they don't go no more than two deep, surfacing

00:06:33.113 --> 00:06:37.015
relevant commands as shelf space is limited, and

00:06:37.075 --> 00:06:39.436
minimizing switching between the mouse and

00:06:39.496 --> 00:06:42.938
keyboard to keep your hands in one place.

NOTE Anju demo

00:06:45.567 --> 00:06:47.408
So, let's show Anju in action.

00:06:48.409 --> 00:06:51.070
Note that in the videos, a black circle overlay

00:06:51.150 --> 00:06:53.752
is a left mouse button press and a green circle

00:06:53.852 --> 00:06:54.552
is for the right.

00:06:55.513 --> 00:06:57.714
By default, clicking on the right mouse button

00:06:57.794 --> 00:06:59.615
will raise a context menu.

NOTE Direct manipulation: Window splitting

00:07:03.558 --> 00:07:07.460
Anju uses direct manipulation to support managing windows.

00:07:10.586 --> 00:07:14.388
From a context menu, a submenu for window

00:07:14.428 --> 00:07:16.229
management is provided.

00:07:16.309 --> 00:07:19.391
As the demo illustrates, this submenu provides

00:07:19.431 --> 00:07:22.913
commands to split the current window to the side

00:07:22.973 --> 00:07:23.473
and below.

00:07:24.774 --> 00:07:27.776
Note how the new window boundary corresponds to

00:07:27.856 --> 00:07:29.617
where the mouse position is.

00:07:31.498 --> 00:07:33.959
This submenu also supports deletion of the

00:07:33.999 --> 00:07:34.640
current window.

NOTE Window swapping

00:07:40.508 --> 00:07:42.989
When multiple windows are displayed, the window

00:07:43.029 --> 00:07:46.970
management menu provides a submenu for swapping windows.

00:07:48.130 --> 00:07:51.151
This menu is designed to only show possible swap

00:07:51.331 --> 00:07:53.892
directions, as it is context-sensitive.

NOTE Mode line

00:07:58.233 --> 00:08:01.254
Support for direct manipulation is already in the

00:08:01.314 --> 00:08:03.855
mode line, which can resize a window both

00:08:03.995 --> 00:08:05.736
vertically and horizontally.

00:08:06.705 --> 00:08:09.827
Anju modifies the mode line to let the user

00:08:09.907 --> 00:08:12.367
maximize the window from it

00:08:12.368 --> 00:08:14.189
with a left double-click event.

00:08:14.829 --> 00:08:17.270
The double-click must occur on a blank space on

00:08:17.290 --> 00:08:20.632
the mode line as other text on the mode line can

00:08:20.692 --> 00:08:22.013
accept mouse events.

00:08:23.323 --> 00:08:26.406
After maximizing a window, the user can return

00:08:26.466 --> 00:08:29.109
back to the earlier window configuration by

00:08:29.169 --> 00:08:32.472
repeating the same left double-click event again.

00:08:33.614 --> 00:08:35.876
Another change to the mode line is binding the

00:08:35.917 --> 00:08:38.740
window management menu to the right mouse button.

NOTE Menu bar

00:08:46.300 --> 00:08:48.661
Anju changes the menu bar to enhance

00:08:48.721 --> 00:08:49.641
discoverability.

00:08:50.262 --> 00:08:53.562
In particular, Anju tries to surface

00:08:53.563 --> 00:08:55.943
Emacs-specific features that distinguish it

00:08:55.944 --> 00:08:58.304
from less capable editors.

00:08:59.065 --> 00:09:01.746
I strongly feel that usage of these features is

00:09:01.866 --> 00:09:04.307
why you would want to use Emacs in the first place.

00:09:05.067 --> 00:09:07.028
The catch is that many of these features are

00:09:07.208 --> 00:09:07.988
undiscoverable.

00:09:08.888 --> 00:09:11.289
Anju tries to remedy this by making them

00:09:11.569 --> 00:09:13.050
prominent in the menu bar.

NOTE Edit menu

00:09:16.823 --> 00:09:20.166
Anju has many special case commands for editing

00:09:20.226 --> 00:09:21.607
text of different sizes.

00:09:22.308 --> 00:09:25.110
Such commands work on text extents ranging from

00:09:25.210 --> 00:09:27.372
words to sentences to paragraphs.

00:09:28.753 --> 00:09:31.075
Anju adds such commands to the edit menu.

00:09:31.975 --> 00:09:35.318
Commands to duplicate, align, and delete text are

00:09:35.398 --> 00:09:36.960
also added.

00:09:36.980 --> 00:09:39.822
This demo here offers a glimpse into the editing

00:09:39.882 --> 00:09:41.023
powers of Emacs.

00:09:42.495 --> 00:09:45.337
Duplicating text can be done in one step with a

00:09:45.397 --> 00:09:46.398
duplicate command.

00:09:47.259 --> 00:09:50.381
Same for text alignment to a regular expression.

00:09:51.502 --> 00:09:54.985
Rectangle commands are a powerful editing feature of Emacs.

00:09:55.686 --> 00:09:59.629
Using C-M-mouse-1, you can select a rectangle.

00:10:00.770 --> 00:10:03.992
The rectangle submenu will then be enabled in the edit menu.

00:10:05.453 --> 00:10:09.497
Multiple spaces can be reduced to one with the

00:10:09.577 --> 00:10:10.918
`just-one-space` command.

00:10:16.855 --> 00:10:19.678
And then here we can see `flush-lines` at work,

00:10:20.700 --> 00:10:23.683
flushing all lines that contain an instance of

00:10:23.703 --> 00:10:24.344
the word pair.

NOTE Registers menu

00:10:30.338 --> 00:10:33.579
Registers are an Emacs feature to store different

00:10:33.619 --> 00:10:35.879
kinds of runtime information such as text

00:10:35.919 --> 00:10:39.340
clippings, position, window configuration, and

00:10:39.380 --> 00:10:40.460
keyboard macros.

00:10:41.060 --> 00:10:44.241
In this demo, we'll store two different text

00:10:44.261 --> 00:10:47.342
selections into two different registers and then

00:10:47.422 --> 00:10:49.282
insert each stored register.

00:10:58.348 --> 00:11:01.311
Here we'll insert register 1.

00:11:03.913 --> 00:11:06.375
And in this demo, we'll insert register 2.

00:11:10.679 --> 00:11:12.160
That concludes that demo.

00:11:12.460 --> 00:11:14.482
I'm of the opinion that registers are so

00:11:14.542 --> 00:11:17.484
important that I've made them a top-level menu in

00:11:17.504 --> 00:11:18.165
the menu bar.

NOTE Bookmarks

00:11:22.168 --> 00:11:24.809
Another feature that I think is important enough

00:11:24.869 --> 00:11:26.529
to put in the menu bar is bookmarks,

00:11:26.530 --> 00:11:29.811
which lets you keep track of different documents

00:11:29.812 --> 00:11:30.792
for later recall.

00:11:31.393 --> 00:11:33.614
Once you start using them, you'll quickly learn

00:11:33.734 --> 00:11:36.175
what an essential feature they are to Emacs.

NOTE Text formatting

00:11:41.258 --> 00:11:43.819
For text modes, a text formatting menu is

00:11:43.899 --> 00:11:45.380
provided by the menu bar.

00:11:46.437 --> 00:11:48.781
Anju enhances this by adding menus for

00:11:48.821 --> 00:11:52.708
transforming, styling, and filling in selected text.

NOTE Macro recorder menu

00:12:12.998 --> 00:12:16.061
Emacs has the ability to record user actions for

00:12:16.121 --> 00:12:17.061
playback later.

00:12:17.662 --> 00:12:20.364
This is called a keyboard macro, but despite its

00:12:20.444 --> 00:12:25.869
naming, such macros can also record mouse events.

00:12:25.909 --> 00:12:28.611
Anju adds a macro recorder menu to the Tools

00:12:28.651 --> 00:12:31.173
menu, providing access to both creating and

00:12:31.273 --> 00:12:32.214
editing macros.

00:12:33.074 --> 00:12:35.777
This demo shows the creation of a macro with a

00:12:35.837 --> 00:12:40.841
counter and shows how the macro can be edited and

00:12:41.121 --> 00:12:42.422
the counter adjusted.

NOTE Context menus

00:13:25.882 --> 00:13:29.083
Anju builds off context menu mode to provide many

00:13:29.183 --> 00:13:31.483
enhancements to many different modes.

00:13:32.124 --> 00:13:35.144
These menus test multiple criteria to offer a

00:13:35.184 --> 00:13:38.665
concise set of context-sensitive commands.

00:13:38.705 --> 00:13:41.346
Anju also provides context menus that are

00:13:41.426 --> 00:13:43.066
non-mode specific as well.

00:13:44.026 --> 00:13:46.567
Let's see a couple of these context menus in action.

NOTE Dired context menu

00:13:49.881 --> 00:13:53.404
Anju provides a simplified context menu for Dired

00:13:54.125 --> 00:13:56.727
that focuses on basic commands

00:13:56.728 --> 00:13:58.890
for a selected file or directory.

00:13:59.991 --> 00:14:02.752
The context menu supports creating, hiding,

00:14:02.753 --> 00:14:05.655
and removing subviews, which enables work

00:14:05.656 --> 00:14:06.857
on a directory hierarchy.

NOTE Elisp context menu

00:14:12.815 --> 00:14:15.537
Dig deep enough and you'll find Elisp everywhere

00:14:15.637 --> 00:14:16.217
in Emacs.

00:14:16.958 --> 00:14:20.080
Anji offers a way to evaluate and debug Elisps

00:14:20.140 --> 00:14:21.381
through a context menu.

00:14:22.142 --> 00:14:24.924
In this demo, we'll debug a command that copies

00:14:25.084 --> 00:14:28.326
all the notes blocks in an Org file into the kill ring.

00:14:29.367 --> 00:14:31.588
As part of the debugging, we'll set up a

00:14:31.648 --> 00:14:34.329
watchlist to keep track of variables

00:14:34.330 --> 00:14:36.672
and set some breakpoints. Note how

00:14:36.673 --> 00:14:38.814
everything here is mouse driven.

00:14:39.154 --> 00:14:42.116
There's no need to recall arcane key bindings.

00:14:44.230 --> 00:14:45.511
We'll set some breakpoints.

00:14:46.291 --> 00:14:49.752
The first one on the loop, the while loop in

00:14:49.792 --> 00:14:52.513
there, and then the one right after the loop

00:14:53.834 --> 00:14:57.875
completes, which is the `kill-new` statement on

00:14:57.995 --> 00:14:59.576
lines 13 and 20.

00:15:02.337 --> 00:15:04.278
And then we'll do a little step through.

00:15:11.270 --> 00:15:15.693
Get to our first breakpoint and we'll watch some variables.

00:15:15.773 --> 00:15:18.854
We'll watch the start variable and the end variable.

00:15:18.954 --> 00:15:23.857
Those are two variables that keep track of the

00:15:24.378 --> 00:15:29.040
start of a region and the end of a region for

00:15:29.100 --> 00:15:37.665
where a notes block is, in the Org file, that is.

00:15:37.685 --> 00:15:40.307
We'll see that the value of start is

00:15:40.953 --> 00:15:44.396
changed to 153 if we step through again.

00:15:49.261 --> 00:15:53.645
We'll see that the end variable has updated at

00:15:53.685 --> 00:15:57.168
the end of that loop to 258.

00:15:57.449 --> 00:16:01.152
Then we'll remove those breakpoints on loop and

00:16:01.212 --> 00:16:03.815
advance always so that we get out of it.

00:16:05.355 --> 00:16:11.004
And here we'll want to inspect a list of strings

00:16:11.064 --> 00:16:12.005
called `buflist`.

00:16:13.087 --> 00:16:17.073
We can see that all of the contents of the

00:16:17.173 --> 00:16:19.236
Org file have been extracted.

NOTE Org Mode context menu

00:16:25.837 --> 00:16:28.698
Anju's context menu for Org Mode takes advantage

00:16:28.799 --> 00:16:30.980
of structural information about the Org file.

00:16:31.500 --> 00:16:34.061
The context menu can test what kind of section

00:16:34.101 --> 00:16:36.662
the point is in and adjust itself accordingly.

00:16:37.323 --> 00:16:39.564
For example, if the point is on a heading,

00:16:40.464 --> 00:16:42.525
commands relevant to a heading are shown.

00:16:44.346 --> 00:16:47.508
Similar treatment is done for other structural elements.

NOTE Menu item introspection

00:16:56.073 --> 00:16:58.895
In Emacs, nearly everything is introspectable,

00:16:59.095 --> 00:17:01.116
and that includes menu items.

00:17:01.176 --> 00:17:03.677
In this demo, we can find out the command

00:17:03.817 --> 00:17:06.979
underlying the jump command in the registers menu.

00:17:08.819 --> 00:17:10.281
Let's see the demo in action.

00:17:10.421 --> 00:17:13.522
So, we'll first go to the help menu in the menu

00:17:13.563 --> 00:17:17.805
bar, click on "Describe key or mouse", and then

00:17:17.925 --> 00:17:20.746
select the jump item in the registers menu.

00:17:21.327 --> 00:17:23.588
You'll see a help buffer pop up

00:17:24.186 --> 00:17:26.669
showing that it is the command `jump-to-register`.

00:17:26.909 --> 00:17:30.392
Pressing `s` will then show the source code.

NOTE Anju summary

00:17:33.994 --> 00:17:36.935
In summary, Anju updates mouse interactions

00:17:36.936 --> 00:17:39.998
in Emacs to be familiar to users more accustomed to

00:17:40.058 --> 00:17:41.439
a point-and-click experience.

00:17:41.900 --> 00:17:44.762
Anju does so by enhancing the mode line,

00:17:46.959 --> 00:17:49.501
the menu bar and context menus.

00:17:50.342 --> 00:17:53.144
Only a subset of the menus provided by Anju have

00:17:53.164 --> 00:17:54.745
been demonstrated here.

00:17:55.505 --> 00:17:58.127
Viewers are welcome to try Anju out to discover

00:17:58.267 --> 00:18:01.129
all of its offerings.

00:18:01.209 --> 00:18:04.132
Anju is available on MELPA and you can get its

00:18:04.172 --> 00:18:05.533
source code on GitHub.

00:18:06.233 --> 00:18:07.594
Feedback is always welcome.

00:18:08.295 --> 00:18:08.695
Thank you.
