On Emacs 28’ context menu and Unix mouse-usage in general
ruzkuku.com
ruzkuku.com
The main intention is to demonstrate how context-menu-mode works, how to extend it yourself and call for people to test it before Emacs 28 is released. Having written a few forgettable articles, I ended up forgetting that intentional provocation attracts unintentional attention.
> The denunciation of the mouse usually involves invoking concepts such as the “home row”, or the cumbersome migration of the hand between keyboard and mouse. These might all be well and good, if I were a typist and as such all I did was to type. But this isn’t the case, I ponder and perceive, more than I write.
This resonated so much with me :-) I still cannot believe how many people seem to think that the ability to type really fast is important to be a good coder, when we spend the vast majority of our time reading, re-reading and podering code instead of writing it.
A mouse can afford spacial exploration. Moving text from there to here, style thinking. Versus the keyboard of jump to there, copy text, jump back, paste.
Hard to see either as superior for text. Hard to see how to use the symbolic for spatial data. (Images and such)
I have no idea where this notion of "shunning the mouse" came from. The simple fact is that when you're "in the zone", the mouse gets in the way. After having read and re-read other peoples code, and occasionally also having read half a dozen research papers, you are finally ready to dump all the code that has been brewing in your head. At that point, you are a typist. All the for-loops and switch-cases and function calls are jostling around in your head, and you want to serialize them into source code as fast as you can. When you're doing that, forget the mouse even the arrow keys are too far away. All you want is "do what I mean" with "the thing at point". Everything else just disappears outside your region of focus.
So yeah, the mouse is awesome when you're browsing and reading code. But when you're typing code, the home row is the fastest way to get it all out.
EDIT: s/two/too/ far away
On the other hand, I use the mouse a lot while coding and I would say you’re wrong here, for me. I prefer the ability to not have to think about memorized keys when coding.
I go into a state of flow based on what I believe is a combo between visualizing and imagining the code in an object form or something similar, so using a mouse is more natural since I’m still visualizing the mouse menu and the areas I have to click on instead of context switching into the mode where I try to remember keys I often look at the keyboard when typing, too, due to my way of flowing. I personally think it’s because my brain works a bit more visually and my imagination is pretty good, so I am able to map the imaginary code flow in my mind to the text version, so using a mouse to me is like navigating between the two. My mind takes the logic and is able to translate that to mouse movements easily to reach the part of the code I’m thinking about abstractly.
Personally, I’ve tried to be a better typist and tried to use emacs or vim, but I always go back to the way I do things and I’ve just decided my brain works a bit differently than many coders.
To each their own, I say; so do whatever works for you and I’ll keep using my way.
When I'm in this state, I'm probably writing pseudo-code fairly close to the real language I'm working in, and not worrying too much about errors I'm not seeing, and just trying to quickly correct the errors I do see, such that I can express my intent on screen. Finding missed typos and other errors is for a second pass and with the help of a compiler/interpreter, for code I write in that manner. It may require some additional passes to tweak things that just don't work, as well, but that's fine. The point was to get what was very clearly in my mind transferred to another medium before something caused a corruption of my mental state.
That's not to say that's the only way I write. I also often devote time to carefully pondering what's on the screen and how to best interact with it to change it in the way I want, or whether there is a better way to do it entirely and that code should be rewritten. But when I'm trying to get what's in my mind onto the screen, little things like auto-indent and being able to accomplish something while keeping my hands doing what they've been doing all add up to help in small ways.
This is how tiny bacteria with flagella operate; they whip their hairs furiously when they want to zoom towards or away from a particular stimulus, but tumble idly in intermediate zones. Having only one mode of operation isn't adaptive.
In that respect it's not whether keyboard binding or mouse context menues are better, it's about providing tools to support both contexts, so the appropriate one can be chosen at the appropriate time.
It does both. And much faster than keyboard navigation if you're moving to a text at some distance away from where your cursor currently is. Mouse is literally a pointing device. If you need to go to a point in text 10 lines above your current cursor, moving the cursor there with a mouse is definitely faster than figuring out which of the ten arcane commands will get you there.
There are other shortcuts like Ctrl+Direction to skip chunks of text. Ctrl+Left or Ctrl+Right skips words and symbols, Ctrl+Up and Ctrl+Down, in some of my language configurations, skips to the next starting point of a code block in the same branch.
Movement is very straightforward with the keyboard, and depending on the editor, does not take long to get used to. If the mouse works for you, great. It did for me too, up to a point.
I still look at the keyboard to type. (Glances to ensure focus has not moved... Love emacs' case changing commands for when the caps-lock pressed)
I have thought about learning to touch type - yes, one day.
I have tried clisubg my eyues (that is "closing my eyes") to type....
What is the use, really? I spend so much time thinking about and reflecting on code and so little actually writing it
But after experimenting with home row mods and (split) keyboards with multiple thumb keys, regular keyboard layout usage just feels terribly inefficient.
While fast typing is not a bad thing it is definitely not necessary skill of good coder. But coding and using the terminal requires frequently using special keys and combinations, which on regular keyboard require constantly moving hands to access hard to reach keys.
Using home row mods (with a special keyboard) the hands are almost resting.
When I'm writing prose, the speed I can type is the speed I can write. There are no downsides to being a competent touch typist. It's a bit much to say it makes me a better "coder" but there's no question it makes me better at my job.
As a non-native speaker, I looked it up because my intuition didn't align with your statement.
Those who downvoted probably should have done so, too, or explained why they think otherwise.
https://en.wikipedia.org/wiki/Apostrophe#Singular_nouns_endi...
As a non-native speaker, you have my sympathy and respect for learning our grand mess of a language.
This is one of the reasons I love the TrackPoint and use it exclusively. There is no physical context switching between mouse and keyboard. If you are a touch typist, it is always right there on the home row.
I am such a TrackPoint nut that on the rare occasions when I've had to work on a computer that is not a ThinkPad (a desktop or a different laptop), I use a ThinkPad wireless keyboard to give it a TrackPoint:
https://www.lenovo.com/us/en/p/accessories-and-software/keyb...
One job I had issued Dell laptops, and I found that I could put the ThinkPad keyboard right on top of the laptop keyboard. It even left the Dell's touchpad accessible. I do use two-finger touchpad scrolling once in a while.
Something I don't like about modern ThinkPad keyboards is that they took away the Menu key and replaced it with a PrtSc (screenshot) key. The Menu key is such a nice way to bring up a context menu based on the current keyboard cursor location (rather than the mouse position). These AutoHotkey rules fix that:
; Remap the PrtSc key:
; PrtSc -> Menu (like an old ThinkPad keyboard)
; Windows+PrtSc -> Screenshot of all monitors
; Windows+Alt+PrtSc -> Screenshot of current window
PrintScreen:: AppsKey
#PrintScreen:: PrintScreen
#!PrintScreen:: Send {Alt Down}{PrintScreen}{Alt Up}
This is for Windows, of course. I imagine there must be a way to do something similar on Linux.Another tip for Windows users: if you have a keyboard with a numeric pad that you don't use much, enable MouseKeys in the Windows accessibility settings. This lets you use the numpad as a "keyboard mouse" for precise mouse movement. Or if you have a ThinkPad keyboard, try my JKLmouse program (another AutoHotkey script) which gives you MouseKeys-style mouse control using the IJKL or HJKL keys (and neighboring keys for diagonal movement). It will work on other laptop keyboards too, but you really want physical mouse buttons like a ThinkPad for it to be useful.
(There is an installer, but I recommend downloading AutoHotkey and the jklmouse.ahk script from GitHub for the most flexibility.)
It's simply about pointing devices hurting my hand, wrist, and arm.
Keyboard use does not.
Is that so hard to understand?
This is what makes it an accessibility issue for me, not a preference.
For _some_ people, the mouse is easier to use, so increases accessibility for _them_. I think the OP was implying that better mouse accessibility could be added on-top of the existing keyboard support.
I use many different keyboards and pointing devices (not just mice) and the general trend I described holds true.
But then there's this whole subculture in Unix that basically claims that keyboard should be the only device used for interaction. The software that they make makes it deliberately hard, or outright impossible, to use the mouse. And there's a cult following around this, based solely on the notion that it's somehow better in general.
(A stark example of this approach is https://www.nongnu.org/ratpoison/, where it's readily obvious from the name and the logo.)
Watching the graphic and motion graphics designers at work, they're dominant hand rarely leaves their mouse, while the other hand hammers at shortcut keys to switch tools. They don't care about the home row, just using the fewest actions to complete a task.
When I'm using a piece software maybe a few times a month, I'm grateful for icons and menus to help me remember how to do anything. When I use a piece of software on a daily basis, then I learn the shortcuts until it's muscle memory, an keep my hand away from the mouse as much as possible.
On the contrary, the simplicity of the styling and layout is honestly beautiful.
To really throw gasoline on the mental fire, middle click on window usually puts you in some sort of stupid alternate scroll mode.
I prefer a right click. Mainly because middle click is _awkward_ using most laptops.
That's what I call awkward. Or Ctrl + right click, or any other solution.
I was not really paying attention and so did not expect it when I bought my first thinkpad, but it is so nice it has now become a must have for me.
Autoscroll is great by the way.
Why? It's not costing anything, action-wise
That is, even in the paradigm of middle click to paste the last selection, you still have a clipboard, don't you?
I do like the context menu way.
Eventually I remember to ctrl+c but it just flows so well, select then paste that it feels like a real step backwards going to a system that does not have it.
I do agree that the middle mouse button should be divorced from the scroll wheel.
If you want to go real old school and have a proper middle button, get an HP DY651A optical 3-button USB mouse (no scroll wheel).
This is not to say that explicit actions on the clipboard aren't useful. But, as an emacs user, I'm used to way more control over the kill ring than I typically see exercised on the clipboard.
middle click is "query for the most recently selected thing and paste" while the clipboard requires an explicit copy action. In vim (even terminal vim) with X support they are the '"' (double quote) and '+' (plus sign) registers respectively. Most other applications let you copy and paste with CUA (or for terminals shift-modified CUA) keybindings.
So for something I plan on pasting longer term (or multiple times) I will typically use the clipboard. For quick "this thing needs to go here" with the mouse I use the primary selection.
I also agree that middle-click is nearly useless on a scrollwheel. Many mice have more than two buttons these days so you can always remap a function button though (as I mention in another thread, my trackball actually has 3 legit full-size top buttons, but prior to that I remapped the "browser forward" button to be middle).
It's just badly implemented there. Internet Explorer had a completely brain-dead implementation, and every embedded webview inherited that.
Firefox always had a very nice implementation of middle-click scroll. It may sound silly, but this one of the major reasons I always hated chromium-based browsers — they do have it, but it's not nearly as nice (you can't, or at least couldn't easily scroll inside scrollable elements, the acceleration profile feels very weird, and other small things like that).
Trying to click the mouse scroll-wheel is on par with the "push the joystick straight down" click mode that some modern game controllers have in awfulness.
It has a scroll wheel, which if you press down toggles between free-wheeling and line-by-line scrolling. It also has a physical middle mouse button just below the scroll wheel.
But then mice standardised on scrollwheels and the middle button being the depression of the scrollwheel - and it's not so good anymore. It's way too easy to accidentally scroll when clicking a mouse wheel, and few people would disable the scroll wheel or get 90's type straight 3 button mouse.
The middle click in windows for "scroll mode" (or something) as you say, is useless. And I can only assume that's a mode that exists precisely because people without scrollwheels still need to scroll so it emulates the wheel. Poorly.
there are new better completion frameworks and new better ways of handling, thinking about and using key-maps .. so it look as if we're just one breakthrough away from having keymaps and menus attain some kind of parity with what M-x and M-: can deliver.
my emacs, being more of a computing environment than an editor, had 11 k org'd loc. I'm dumping that for small elisp files editable with outshine so i can nimbly add customizations to these menus and the other three dozen breakthrough (for me) packages that have appeared over the last few years.
this is all very exciting!
The byte code compiler uses gccjit to compile elisp to elf files. That, in conjunction with the use of libjansson for json handling, makes emacs substantially, noticeably faster for lsp (language server protocol, which most editors at least have support for now).
If you haven't looked at lsp yet either, I'd highly recommend it. It provides a common set of language server apis so you can have a unified completion experience between languages. I can remember all the unpleasant tricks to getting jedi mode for python, meghanada for Java, and having to memorize two totally separate apis. This is so much nicer.
[1] https://www.gnu.org/software/emacs/manual/html_node/elisp/Co...
Somehow down the line the FOSS UNIX generation decided that the ways of twm were what one should aim for.
I guess there is some romanticism to work as on the early UNIX years.
I find it amazing that Window Maker is both among the most powerful window managers i've used and the most convenient and graphical (FVWM is probably more powerful but it certainly isn't as convenient to configure/set up).
It was actually my window manager of choice between 1998 and 2003 when on Linux distributions, and I had my collection of mini widget apps.
Nowadays it seems mostly stable, to put it on a nicer way.
> Nowadays it seems mostly stable, to put it on a nicer way.
Sadly it has some bugs, though it is largely external stuff (RandR support was never implemented properly and is so broken that i don't think it is even compiled in by default, mouse settings do not work since it uses some old APIs, EWMH support is buggy/incomplete and some applications that assume it is always there have issues under it), but UI-wise it is stable (in that it doesn't try to reinvent itself - a 1997 screenshot of WM looks pretty much the same as a screenshot from a current PC, aside from increased resolutions, at least unless you are on a cheap laptop :-P).
I do try to fix some bugs myself and implement features whenever i get too annoyed by something though.
I used to have one of the old thinkpad external keyboards - http://www.notebookreview.com/notebookreview/lenovo-thinkpad... - and I used those until they broke and I couldn't find more.
I haven't used the unicomp ones, but I can wholeheartedly recommend the shinobi.
I wonder if the OP is ambidextrous? If using the mouse gave me a hand free to scribble some notes, I'd be a much more enthusiastic mouse user. Alas, both writing and mousing require my right hand, and there aren't many good uses for my left.
I failed, but in the process, I learned a few interesting things - one of which was that it was far easier for me to train myself to competently use my left hand for mousing than for writing.
This might be the case for you, too - try using your left hand to mouse for a day or two and see if you can get the hang of it.
At 20 i was consulting and ran across my first system with a mouse. I quickly realized that there was no profit in using it with my right hand since that was needed for numpad and shift selects etc.
So I moved the mouse to the left and never looked back. My hand just goes there when it makes sense -- never breaking my focus or the close-contact my right has with the keyboard. That has made this entire discussion about mouse good/bad a non-issue.
It may take some time to train yourself if you're not a puppy anymore, but its worth stepping out of that argument and into something else.
"for crying out loud", "they even moved the f-keys to the top row so that you can have the mouse on the left of your keyboard!" /<smiles>
(p.s. op .. at 36 i learned to play the conga and that allowed me to go crazy with the ambidexterity like nothing else, ever. just buy a set and give it a go!)
But also, as a left-handed person I still use my right for the mouse when using it more actively, so I could scribble thoughts simultaneously with my left if I wanted to. I think I might have only done that like, once.
USB mice are cheap, plug two in, one on each side. Makes it easier to use non-dominant hand occasionally without having to move the mouse around.
It's awkward initially, but for most people takes only a few days to be comfortable with it. Then they switch back and forth easily (I do it several times a day).
As an analogy, a lot of people (including me) started writing on a keyboard with only one hand (or at least hitting most buttons with one hand). We had to train our brains to use both. That was a lot more challenging than learning to mouse with the other hand.
I do this a lot is vscode to auto-fix issues and automatically add imports for the identifier under the caret. It's however frustrating in that it sometimes uses the underlying platform's dropdown widget, which doesn't respect my key bindings (Emacs-like, using C-p, C-n for up, down etc).
Keyboard-only is decent for text, and particularly good for text where everything that needs to be edited will be on the screen at the same time.
I call this model the "MOBA interaction model", because in those games (which include League, Smite, and Dota) you must place do exactly this.
I, too, wish that more interfaces worked this way - but there's a fundamental problem, which is that many tools (including all Unix ones) are more efficient when you can input text, which necessitates the use of both hands on the keyboard.
Which would suck for left handed people.
As for the right, as some other commenters have noted it really isn't that bad to use your non-dominant hand with a mouse. Most of the movement precision comes from the wrist and elbow, rather than finer finger control.
Because I kept the mouse in right-hand configuration, I can use any mouse with my left hand without having to switch the buttons, and I can also still use the mouse right-handed.
I know with my use of Emacs, I'd probably use or configure it like a fancy which-key: use the mouse to navigate / filter the available choices but then use the keyboard for final selection.
BUT, that I can also do with a trackpoint/ball/roller/whatever. The most important mouse thing is for freehand input like drawing. It's just not ergonomical to do that kind of thing with a trackball.
Using any kind of pointer to move a cursor in text or navigating to a different window or a different textbox isn't really a good idea. That's done better with a keyboard. But the thing most keyboard purists overlook is the thing they don't do at all (draw, hover), so they don't miss it.
Also, the author is specifically speaking about "Unx dogmatists" (not programmers in general), where using the mouse absolutely does* make you a rebel.
As you seem to have missed it, the author isn't positioning himself as a dogmatist using the mouse. He is calling Unix users who don't use the mouse dogmatists.
Not quite, I want to say is there are Unix dogmatists, that don't use the mouse because of what they think the right way to use a Unix-like system is, not that preferring to use a mouse or not makes you a (Unix) dogmatist.
I'll rather accept what you said earlier in this thread (the "I wrote this mess ..." post): that you simply meant to be provocative. That's OK in my book, even when it doesn't turn out all that great. Nothing wrong with the rest of the article, either.
Good thing then they never said the article was directed at that subset of Unixers. It was only that little provocative starting section that was.
> the author isn't positioning himself as a dogmatist using the mouse
I never said that he did.
> He is calling Unix users who don't use the mouse dogmatists
He is not. The actual article reads:
"It seems as though an irrational fear of the mouse dominates amongst Un*x dogmatists".
This observation also isn't relevant to my comment, so I'm not sure why you're bringing it up.
My point stands - you absolutely are a rebel among Unix-users to use the mouse.
Your mocking statements like "Hahaha, like you are some sort of brave free-thinker for using the mouse!" don't do anything to improve your arguments that are mostly lacking in support.
Eh - it's well known in my company where some jobs are mouse heavy and some are more keyboard heavy. Both camps get ergonomic pains, but it is more common with the mouse heavy folks.
Typing can affect hands, wrists and forearms. Mousing affects neck/shoulder/side more.
People who get it with typing tend to get it after extended use (years). People doing mouse heavy CAD work often get it quickly (1-2 years) unless they're aggressively trying to mitigate it.
Contrary to what I just said, I do think they are equally prone assuming equal usage. The reality is that a lot of programming jobs do not require a lot of continuous keyboard usage - you spend a fair amount of time thinking. It's why I get more ergonomic issues when typing emails or writing documentation than when programming.
Mouse heavy jobs, OTOH, often involve continual mouse use. So they automatically are more at risk.
/s
But seriously though, if I could just ask for two things in emacs:
1. Enable mouse mode by default (Yes -- I love UNIX too, but this is ridiculous)
2. Give up on "yanking" and "killing" with only the keyboard and allow for text selection with the mouse. OP touches on this a bit, but why anyone should have to write their own functions to accomplish it is a bad sign.
Because I know I will get yelled at for this - especially #2 - is this limitation due to the fact that emacs (and I guess, vi) act like a pager with distinct modes of operation? And, yes I know GUI versions exist, but I shouldn't have to switch to something else just because the canonical implementation is incomplete.
/rant
Well, actually...
Not as of macOS 11 it isn't. Installing the latest version from Homebrew also presents a terminal interface - hence my questions re the available GUIs.
Similar to mpv, they make a distinction between Formulas and Casks.
Context menu is a great place for these things. If it’s not in line with how out emacs overlords thought things should work, they should provide a better solution for it.
The thing I hate about emacs is how extensible it is
Emacs was invented in 1976. You think it would be stable by now?
I filed a bug report for a sub-system I will not name because I think the developers are horrid people and the software fabulous, and I was abused, shouted at and called names for using an emacs distribution three years old (out of date they called it). That is I was using software that was forty four years old.
I love you emacs - I hate you emacs -
I’ve tried to (with some success) standardise keyboard shortcuts across my entire desktop (linux w/windows vms) but im forever in keyboard he’ll.
In addition, I have awkward performance in emacs - character movement triggers a buffer save which occurs in the main thread resulting in a pretty constant lag.
Am I the only one that likes the emacs concept, hates lisp, and hates eMacs to the point where I think it should be rewritten?
I dont want to be too caught up in the cons. criticism- thanks for bringing it to someone's attention in the first place c:
Or maybe we've learned something in the decades we've been working, since before you were actually born. Get off my lawn know-it-all college kid!
Just don't force others to have to do the same. And yes, I used mice at a time where the middle button actually had been a button ;).
As for me, I'm another greybeard that doesn't need a mouse, but defaults to using it over a keyboard-only setup. Keyboard shortcuts are great for things that are frequently done, but I'd rather not spend the time to remember rarely-used features.
Granted, for any input modality, there are better and worse designs using it, but when designed properly, having an additional modality available can never be a disadvantage. When a newer modality replaces, rather than supplements, an older one, the benefits are often more debatable.
* Poor availability of navigation options other than linear order.
* Poor availability of editing / correction / undo (and conversely, there often was an easy to hit (deliberately or accidentally) button that would erase everything on the screen so you could start over. Users sometimes trained themselves to use that for any correction, because it WAS effectively superior to other available correction methods).
As an anecdote, in one job, I encountered a text based application for parts inventory management in a garage. The only way to look up parts was to type their full, exact name (And in our country, mechanics were not necessarily solid speakers of the local language).
The programmer didn't see a problem with this, arguing that his design promoted enhanced literacy among his users…
In early 00s, I did a GUI (Windows Forms) line-of-business app for a shop that was using an old TUI app written in FoxPro for their other stuff. The people who were doing data entry on that were all using the keyboard pretty much all the time. When they started using the GUI app, they kept using the keyboard - and I didn't even have to do anything special to enable it, just make sure that tab-index is correct and that all widgets have hotkeys.
Then there were the shortcuts to immediately activate the specific label, button etc. On Windows, these showed up as underlined letters up until XP (in XP and later, you have to press Alt to see them). Again, as a QoI matter, devs could forget to put them in - but it was really easy to do, and if you didn't, the lack of underlining was actually kinda noticeable. Most apps had them.
This kind of stuff was even codified, to some extent: https://en.wikipedia.org/wiki/IBM_Common_User_Access
Mice (or pointers in general) are absolutely essential in some applications: drawing and painting, CAD, 3D modelling, etc. There also hasn't been a better flow for web browsing than simply clicking on links. But making the mouse supreme has added friction to workflows in fields from programming to simple data entry.
It's why I never could really get behind the Acme text editor, as cool as it is on principle.
I made the switch to Linux earlier this year but I still miss tortoisegit literally every day.
I especially appreciate the way it makes it easy and obvious how to do things that would be complicated on the Git command line. Some examples:
Committed to the wrong branch? Drag the branch markers where you want them.
Want to see a diff between the files in two commits, possibly on unrelated branches? Click one commit, Ctrl+click the other, and the file diffs are right there.
Lost a commit and now you have to trawl through the reflog? Turn on the "Recyclable commits" checkbox and all those reflog commits show up as normal commits, complete with diffing as noted above.
I just found out earlier today after looking for context-menus.
I'd still love to see a Linux/SBCL Lisp Machine. I wonder to what extent such a thing is possible.
On another tangent, I'd love to see an Elisp compatibility package for Common Lisp, which would essentially be GNU Emacs with the C bits replaced with Common Lisp.
Or do you mean a machine that boots into Lisp, effectively using it as the OS, regardless of hardware?
SBCL already does an acceptable job producing x64 machine code.
In that case it needs better menus and GUI elements.
The correct answer to keyboard or mouse is, to a first approximation, both.