Acebulf · 2022-03-19 02:51
Hello all,
I've started a new job writing lisp, and using emacs as the default environment. I'm still learning the editor (and the language), but the part I'm having the most trouble adapting to is C-z C-x C-c C-v commands that are standard with Windows. Given that I've used those commands since I've used computers in general, I don't think it's going to be easy to switch over.
I've seen that there is a mode that sort of removes that possibility, CUA mode, but it seems like it would interfere with most of the slime commands. C-c and C-x seem to be very busy keys.
And so I have thought of a solution that I think would work, and it's crackpot enough that I think trying it will be fun. I'm not completely sure it will work, and so am requesting community input.
OK, so here's the plan. I'm going to de-mothball my custom keyboard which allows me to remap keys. Then I would remap the Caps-Lock key to one of the F13-F24 keys, and then using that as the Control for emacs sequences. C-c would be (Caps lock)-c and C-x would be (Caps lock)-x. I think that's possible to change in my init file? Emacs has proven to be a remarkable beast in its extensibility and I'm like 90% sure that this is doable.
Anyway, I am wondering if there is some obvious problem with this plan, other than the glaringly obvious one which is that it's less trouble to just learn the shortcuts. (What's the fun in that, though?)
7890yuiop · 2022-03-19 03:32
The really important question is: who hired you, and are they still looking for lisp programmers? :)
11fdriver · 2022-03-19 03:37
[So, I presume you know that CUA-mode only affects the shortcuts when the region is active (i.e. when text is selected). At all other times `C-c` and `C-x` behave as normal. I also presume that you're aware that even when the region is active, you can quickly double-tap `C-c` or `C-x` to access the original functionality.]
I can't really see any glaring issues. I'd create a custom sparse keymap bound to whichever key you settle on, and then bind the variables `ctl-x-map` and `mode-specific-keymap` to keys in that map. I use `ESC ESC` for my custom map, but I don't use it for anything I need too frequently.
Alternatively, you might use the Super key (`s-` prefix in Emacs), and then bind `s-x` and `s-c` to the relevant equivalents.
Let me know if this makes sense, happy to help if not!
Edit: also look at cua-mode's enhanced rectangle-selection mode if you haven't already (accessed using `C-return`). It's pretty nifty.
7890yuiop · 2022-03-19 04:00
Given how many people prefer to use caps lock for ctrl in Emacs anyhow, that seems like quite a reasonable approach.
The main issue that springs to mind is that, as you're not *swapping* caps lock with something, you're maybe losing caps lock in the process. I also rebound caps lock (it's just an additional Ctrl key) but I enable all modifier locks with a double-tap of the relevant modifier (e.g. Shift), so maybe you can program that on your keyboard?
If you make your caps lock key into a non-Ctrl modifier such as Hyper (or Alt) then you could translate `H-x` (or `A-x`) and friends in Emacs:
(define-key key-translation-map (kbd "H-x") (kbd "C-x"))
(define-key key-translation-map (kbd "H-c") (kbd "C-c"))
(define-key key-translation-map (kbd "H-v") (kbd "C-v"))
Although I suppose that's no help if you're rebinding `C-x` to `kill-region`, etc...
Acebulf · 2022-03-19 04:19
>I also rebound caps lock (it's just an additional Ctrl key) but I enable all modifier locks with a double-tap of the relevant modifier (e.g. Shift), so maybe you can program that on your keyboard?
That's a good point. I think last time I did keyboard-messing-about I had just inverted ctrl and caps lock, but this may no longer stand. I think I might remap it so that Ctrl + (remapped caps-lock) outputs caps lock.
Danrobi1 · 2022-03-19 04:58
Just use Emacs default. I bet in few weeks you'd forget about CUA.
Top_Bird1552 · 2022-03-19 08:02
I'd like to know, too. For whom are you working and what are you using lisp for?
Acebulf · 2022-03-19 17:42
I'm not going to dox myself by revealing my employer, but we use CL as a DSL to interact with home-built hardware.
thetemp_ · 2022-03-20 01:04
Remember that you can also get to C-x and C-c by pressing C-S-x or C-S-c, respectively. And those won't conflict with CUA's use of C-x or C-c even when the region is active.
So if you're going to program your keyboard to get to those prefixes from other keys, have it simulate the shifted key combination.
(And you actually don't need a programmable keyboard to do this, but that's another topic.)