7 ms·
Improving Emacs Isearch Usability with Transient
- bloopernova 3y agoOh this is actually very cool. I didn't know about Transient or that I can create a custom workflow menu. Will be really nice for, just like the article, those commands I don't remember or that have vast numbers of options. Thank you for sharing, I found the article very useful.
- User23 3y agoTransient is, if I recall, a big part of magit’s special sauce. It’s a great library for interactive chording.
- brobsc 3y ago> a big part of magit’s special sauce I’d say it’s what makes magit.. magit. The whole command composition interface (almost like chords) is what drives people to it. The looks and some fringe M-x commands are… just there
- snotrockets 3y agowhich-key (https://github.com/justbur/emacs-which-key https://github.com/justbur/emacs-which-key) adds a similar functionality to most (all?) commands.
- koito17 3y agowhich-key is more like autocomplete for keybinds. I consider it orthogonal to transient. It's meant for modals that show you what keybinds actually exist given some "prefix" you have just inputted. If I had to make an analogy, I'd say which-key is closer to company+counsel+ivy than transient. I have used which-key with the three packages I just mentioned for as long as I have been using Emacs, and this is how I've always seen its role.
- agumonkey 3y agoThere's more to magit, especially its way of grabbing information from context in the log/graph view for instance, or the implicit chunkning, it's pure papercut removal.
- globular-toast 3y agoIt also enables super easy workflows. To give an example, consider working on a fork of a project from GitHub. You clone the project from its source and make some changes and commit them. Where do you push the changes? You make a fork on GitHub. Go to magit, press a couple of keys to add a remote, name it the same as your GitHub username, magit automatically sets the URL correctly. Now you realise you've put those commits on your new master branch but etiquette says you should put them on a separate branch. A couple of keys creates a "spinoff branch". Magit automatically creates a new branch at that point, sets the upstream of that branch to the old upstream (e.g. origin/master) and resets the old branch (master) to its upstream. Now because your remote is set as "push default" you can easily push to it. Magit will now show you if upstream (the other remote) has diverged which means you press a couple of keys to rebase on to upstream then force push to your fork. And this doesn't even mention things like doing an interactive rebase. Magit helps immensely there. The diff "dwim" is useful too. The list goes on.
- agumonkey 3y agohaha yeah magit rebase makes you learn without trying. Everyday I have colleagues screaming in terror having to rebase, while emacs users are whistling. i'm also curious about having magit extensions, as many people say, git lacks some stuff as UI, and they may fit very well around magit
- globular-toast 3y agoThe "spinoff" feature I mentioned is a magit extension. As are other things like stashing (git's own stashing only recently got updated to be able to do little bit more of what magit can do). Magit actually claims to be a git porcelain, not just a git GUI. I think the long term goal is still to do what it does via libgit and not even use the git CLI at all.
- thomastjeffery 3y ago> The default keybindings for said commands are cursed. Default keybindings are a curse. Software in general would be so much better if keybindings were always explicitly part of the user's configuration. Despite that being technically the case in Emacs, the reality just isn't as practical as it should be. Every default keybinding brings an assumption into UI/UX. That assumption can never be removed: it can only be moved.
- ParetoOptimal 3y agoThe problem is designing coherent usable keybindings is a large undertaking. Plus things like C-c C-f and similar working throughout many different elisp packages in a predictable useful way is super valuable.
- taeric 3y agoYeah, I'm confused on what the complaint is? Is the desire that it is always explicitly coded in a config file? You could probably dump the keymap to a file on initial load? You could extend that so that if default is different from the last time it was loaded, you could let the user know, and then replace with any user defined one. (Letting user know is mainly so they can decide if new commands need mapping.) That said, I'd hazard this is not that useful?
- db48x 3y agoYea, that doesn’t make much sense to me either. Maybe they should go to whatever Emacs buffer they have open and type `C-h B` to dump out the entire list of keybindings available in that buffer. That will probably disabuse them of the notion that the user has to personally invent all of them. Mine is 2.4k lines long! And that’s just for the modes that I happen to be using for that particular JSON file; many of the key bindings in a C++ or Rust file would be similar, but so many would be completely different.
- thomastjeffery 3y ago
- chewxy 3y agoemacs' discoverability has been quite terrible. A couple years back I wrote half of a package to do ascii art before I discovered artist-mode. And I had been using emacs for close to a decade by then. This year I discovered ace-window had hidden keybindings (C-x o then instead of choosing the window you want, type '?' to get the dispatch menu). Again, I've been using ace-window for about a decade. Adding a transient dispatch menu to Isearch would be great. I'd also suggest a more global keybinding for hidden dispatch menu (I suggest M-? for dispatch menus when using the minibuffer and ? for other modes). Also this blog post makes me want to make me transform my embark to using transient
- SoftTalker 3y agoYeah I probably use 5% (or less) of emacs's functionality. It's still the best editor I've ever found.
- pkd 3y agoThe which-key package helps a lot with discoverability, in my experience.
- chewxy 3y agowhich-key helps a lot with prefix commands. But doesn't help when you don't know the variants of I search that have silly default key bindings like the aforementioned C-M-@
- cvdub 3y agoC-h a (apropos-command) makes finding things with unexpected names a lot easier. I relied on C-h f (describe-function) for years, but that only matches function names. Apropos searches doc strings as well.
- agumonkey 3y agoit's the curse of large programs, regularly you'll read "I've been using emacs for N decades and I had no ideas this existed ..." I somehow RTFM'd three times, allegedly diligently and yet I still missed a lot of spots. And emacs development pace increased, so I'm due to a 4th RTFM :)
- neilv 3y ago> The default keybindings for said commands are cursed. (Seriously, C-M-@ to call isearch-query-replace-regexp ?) BTW, this isn't only a problem with `isearch`. I suspect that other multiple-simultaneous-keypresses tend to be hard on most people's hands. Which can be bad for your typing-oriented career, and for other humans uses of hands. Some alternatives in Emacs: * Try to press the modifier key(s) with one hand, and the non-modifier key with the other. * If the modifier(s) require contorting in uncomfortable ways, consider whether moving from home row is easier. * When an Emacs key sequence includes the "Meta" modifier (`M-`), consider whether pressing and releasing the Esc key first, and then doing the remaining key/combo, is easier. * Make a better key binding. Examples: (global-set-key [f5] 'call-last-kbd-macro) (global-set-key [f12] 'undo) (global-set-key [XF86Back] '(lambda () (interactive) (other-window -1))) * Learn fancier Emacs features which might mean not having to type this or not as often (keyboard macros is just one). * Use or write a function or package that automates the higher-level task. For writing your own, you can learn from one of these two manuals, and just start experimenting in your running Emacs: https://www.gnu.org/software/emacs/manual/html_node/eintr/ https://www.gnu.org/software/emacs/manual/html_node/eintr/ https://www.gnu.org/software/emacs/manual/html_node/elisp/ https://www.gnu.org/software/emacs/manual/html_node/elisp/
- kickingvegas 3y agoPersonally, I'm not a fan of key-bindings of the form <modifier sequence>-<some symbol that requires a shift key>. That said, what I find intriguing about including the Transient package in Emacs is the potential for supporting menu-driven Transient interfaces to existing commands in a way that doesn't break their default behavior. Such future Transient menus could be shipped as a default and obviate the need to learn complex key bindings.
- cesnja 3y agoI think which-key already solves exactly that: https://github.com/justbur/emacs-which-key https://github.com/justbur/emacs-which-key
- 3y ago
- kickingvegas 3y agoHi folks! Great to see all the interest in my post. Feel free to ask me questions/post observations related to it.
- d0mine 3y agoRelated: to create submenu with sticky keys, there is Hydra: https://github.com/abo-abo/hydra https://github.com/abo-abo/hydra
- eviks 3y ago> The default keybindings for said commands are cursed. (Seriously, C-M-@ to call isearch-query-replace-regexp ?) If only software allowed to be shipped with a different set of defaults or more convenient alternatives...
- eviks 3y agoModality or contextual keymaps is indeed a very powerful concept and it seems like the only way to have usable complicated keybinding schemes, so nice that this stacked/transient override was added
- s0l1dsnak3123 3y agoI've been using Transient in a similar way, but for operations on specific filetypes I use vigorously. For example, I have a ruby transient which provides a single UI for my favourite refactoring functions across the LSP server and various Emacs packages I use. I find using transient this way allows me to streamline the more complex tasks I perform by giving me an easy to conceive UI which hides the detail when I'm knee deep in bugs - but all the power of Emacs is still there under the hood when I need it. I suspect many people would get further with Emacs if they learned use-package and transient instead of picking up Doom Emacs or Space Emacs (which was how I started; they are great projects in their own right but can be limiting due to their own DSL which is a departure from vanilla Emacs).