reddit / emacs
What's your personal preference to write äöüß etc. in Emacs?
divinedominion · 2022-07-27 06:32
I'm using the option key on my Mac to enter accented characters and Umlauts. I do this system-wide, with an ANSI QWERTY keyboard.
Now in Emacs, there's plenty of ways to get to an `ü`. There are modes which let you enter `"u`, for example.
I ponder binding my Meta key to the option key ⌥; it's currently bound to Cmd ⌘ so I have the ability to enter umlauts easily. (But given how little I need that in Emacs, since all my writing there is in English, I might as well switch and then have nicer key bindings.)
Which modes do you personally prefer to use for this?
mattias_jcb · 2022-07-27 06:39
I use the Compose key for most characters not on my keyboard. So åäö for example are already there since I have a Swedish keyboard but for ß I do Compose + s + s.
mickeyp · 2022-07-27 07:01
You can bind commonly used letters to a custom key, if that's all you need.
Input methods work well if you context switch into different languages and you have to write more than the odd line or two.
There's also the compose interface with ready-made keys. Like `C-x 8`. Maybe that's enough also?
And finally you could switch your keyboard configuration at an OS-level also. At least, I know that's a thing on Windows and Linux, so I'm guessing it's the same on a Mac.
There's also the compose key as /u/mattias_jcb suggests.
pimiddy · 2022-07-27 07:11
I have the TeX input method bound in all text modes and use that. I'm not completely satisfied, but it's fine for me.
anaumann · 2022-07-27 07:15
I'm using the deadkeys of the US international keyboard layout, which comes down to writing `"u` everywhere :)
On some operating systems, there are also a couple of shortcuts like AltGr-y for `ü`, but I'm using the deadkeys anyway, because they kind of make sense and I know what I get, even with characters I don't use as often(like `ë` in French).
_viz_ · 2022-07-27 07:22
If you're using Emacs 28, there's also the compose input method.
Frodo478 · 2022-07-27 08:08
You can use [accent](https://github.com/elias94/accent), an extensions that does what you want and is customisable
MechoLupan · 2022-07-27 08:17
For all diacritics and symbols I can't enter directly, I use the input method `rfc1345`.
So to enter those letters I would write `&a:`, `&o:`, `&u:` and `&ss`.
KleenexQ · 2022-07-27 08:17
This, I have no compose key but on linux I've bound it to AltGr+Menu
vcored · 2022-07-27 08:19
`(set-input-method ‘german-postfix)`
Turns ae -> ä,
ue -> ü,
oe -> ö,
sz -> ß.
For literal ue/oe/ae/sz, type uee/oee/aee/szz.
Euro sign € is also typable as E=
16rlut3Br · 2022-07-27 08:21
I use 'german-postfix' as input method with C-x RET C-\\ (set-input-method) and type ae for ä, etc. After selecting it once per session it's possible to toggle with C-\\, which also would prompt for the method if none is selected.
7890yuiop · 2022-07-27 08:26
I use one of the standard Emacs input methods for all fancy characters, so it's just a matter of `C-\` to toggle it on.
Anything unusual, I typically enter by name via `C-x 8 RET`
sjuswede · 2022-07-27 08:32
I push the corresponding key on the keyboard. For ß, it's AltGr s. For å, it's å. For ü, it's <dead>"followed by u. This is in Xorg.
I never even considered that Emacs could do this for me. Could be handy, for when I need to be on a system which is not set to Swedish.
KleenexQ · 2022-07-27 08:47
For rarely used symbols I find M-x insert-char to be fine, but also have AltGr+Menu set up as my compose key system wide for easily putting in the most common symbols
_viz_ · 2022-07-27 09:48
Where I'm from, you will be excused for dropping the accents so that's what I usually do but if I absolutely must include those, then I use the compose input method (with a few changes to the default translation rules, and more translations).
Typing in my first language is impossible unless you use an actual input method, the then built-in ones (itrans, inscript) were horrible so I submitted a patch to add tamil-phonetic to Emacs and that's what I use. (PS, if you're a Tamil speaker and are familiar with the Tamil99 keyboard layout, then please test out github.com/vizs/tamil99, mikka nandri).
I have a command to turn the Greek and the Latin alphabets to their mathematical equivalents, I use this fairly often. I should turn this into a quail IM (or maybe robin) since it is not so ergonomic.
Atemu12 · 2022-07-27 09:57
I use the right option key for the language layer in the us altgr-intl layout but you could probably do the same for the mac special character input:
(setq mac-right-option-modifier "none")
chewxy · 2022-07-27 10:08
C-x-8-RET then type the name of the character. If it's frequently used like when I write code in APL, then I just put them in my keyboard.
torwag · 2022-07-27 10:08
That's what I used before switching the keyboard layout under Linux to US-int, which gives you AltGr+{a, u, o, s} to get ä, ü, ö, ß... There exist even more for e. g. French.
Only trouble, I am now so used to English layout keyboards, that I can't stand a German keyboard anymore. This starts to get a problem as less and less laptop manufactures sell foreigner keyboard layouts. Even on ThinkPads it is not longer selectable on all models.
On the pro side.... The (), {} are so easy reachable on English keyboard layouts.
mickeyp · 2022-07-27 10:59
You can customize `default-input-method` and change the default.
mickeyp · 2022-07-27 11:00
For something like APL, you should consider writing an input method instead. Someone may have written one for APL already.
Here's an example:
https://www.masteringemacs.org/article/inserting-emoji-input-methods
nanounanue · 2022-07-27 12:28
I use an US intl layout. From there you can have access to all those symbols using Alt GR (level 3) , Shift Alt GR (level 4) and the compose key (level 5).I also changed Caps lock into Ctrl and Left Ctrl into Hyper
divinedominion · 2022-07-27 12:40
These are the reasons I switched to US QWERTY layouts as well :)
I don't have an Alt Gr key ;(
divinedominion · 2022-07-27 12:41
Thanks! Do you like that input?
divinedominion · 2022-07-27 12:46
That would require some re-learning, but chiefly using the right option key for this might work 🤔
divinedominion · 2022-07-27 12:59
That's input method is kind of sweet. When `&` is pressed, it shows a list of acceptable characters in the minibuffer as an aid.
divinedominion · 2022-07-27 13:00
Popover is too cumbersome for writing an email _in_ German, but the library looks nice and would help for other inputs. Thanks!
divinedominion · 2022-07-27 13:04
What's your compose key?
divinedominion · 2022-07-27 13:05
Thanks for the tip!
divinedominion · 2022-07-27 13:06
Can you explain what you mean by deadkeys? Googling this looks like it's a system setting to not recognize some accent composition characters
divinedominion · 2022-07-27 13:15
FWIW I quite like it already. Doesn't get in the way of writing non German text so far.
MechoLupan · 2022-07-27 13:32
It is. You'd need a reference tho: https://datatracker.ietf.org/doc/html/rfc1345, "discovering" will take you only so far.
But remembering [this table](https://i.imgur.com/B0pLEdq.png) in section 2.3, and a couple of individual sequences, like
Mnemonic | Result
-----|-----
`&"6` `&"9` `&:9` `&9"` | “ ” „ ‟
`&Eu` | €
`&-N` `&-M`| – — (en/em dash)
`&1-o` `&2-o` | ① ②
`&+-` `&5s` `&5S` | ± ₅ ⁵
it's enough for 99% of cases.
_viz_ · 2022-07-27 13:56
> It is. You'd need a reference tho: https://datatracker.ietf.org/doc/html/rfc1345, "discovering" will take you only so far.
Is C-h C-\\ rfc1345 RET that bad?
lindyhopdreams · 2022-07-27 13:59
This.
This is what I do
MechoLupan · 2022-07-27 14:06
It isn't bad per se, but there you can only visually find the symbol you want.
In the RFC page you can search for its name, and also learn the encoding rationale.
Btw, a good method to learn how to input symbols you read elsewhere is to paste them into Emacs and run `C-u C-x =` with the point on them.
agumonkey · 2022-07-27 14:25
I delegate to xfce ..
mattias_jcb · 2022-07-27 14:29
I made CAPS LOCK be Compose since it was a button i only ever used by mistake before.
ErkiDerLoony · 2022-07-27 14:43
This is also what I do because together with a customised keyboard layout for macos it works almost everywhere.
_viz_ · 2022-07-27 14:58
> Btw, a good method to learn how to input symbols you read elsewhere is to paste them into Emacs and run C-u C-x = with the point on them.
Doesn't always work IME. I got incorrect recommendation for Tamil characters (don't remember what the character was anymore).
centzon400 · 2022-07-27 15:06
【AltGr】with a partially modified `~/.XComponse`
So a typical entry might look like:
`<Multi_key> <l> <l> <b> : "【" # Left Black Lenticular Bracket U+3010`
For Non-Latin scripts I just 'Super+Space' into the relevant input keyboard.
I use https://www.lexilogos.com/keyboard/greek_ancient.htm for polytonic Greek if away from setup.
(GNU/Linux, if that was obvious, BTW.)
disinformationtheory · 2022-07-27 15:54
I used to use LaTeX, and I hardly ever need non-Latin characters.
`(setq default-input-method "TeX")`
`C-\` -> toggle default-input-method, `\` appears in modeline
`u\"`->`ü`, `\pi` -> `π`
ThorstoneS · 2022-07-27 15:57
System wide compose key on right-Alt. That way it works not only in Emacs, but everywhere.
anaumann · 2022-07-27 16:10
It's basically an implicit compose key with a couple of keys like the quotation marks(`"`). The US international layout on Linux and Windows has those enabled by default.
So instead of giving you the quotation marks, the key won't do anything(it's "dead"), but you have to press a second key to make it do something.. You can either press space, that will give you the quotation marks on top of.. well, space(ie. nothing).. or you can press a letter key that can take diacritics(eg. `a`, `o`, `u` for Germans) and it will print quotation marks on top of that letter to generate `ä`, `ö`, `ü`.. I think, on old typewriters, those keys would not advance the carriage, so you could type two letters in the same space or press space to advance to the next letter/column..
Same works for the grave accent(ie. the backtick `\\`\` will give you è`,`à`,`ò`), the acute accent(ie. a single quotation mark or forward tick`'`will give you`á`,`é`,`ó`), the circumflex(ie. the caretwill give you`^(â)`,`^(ê)`,`^(ô)`) and the tilde`^(\~)`, that will give you`^(ã)`, ñ,`^(õ\`...)
All pretty logical to me.. The only thing it doesn't do well is the nordic `ø`, `å` or `æ` or the German `ß`... I use `Alt-Gr` and `l`, `w`, `z` and `s` for those, but except from the German `ß`, I don't use them that often.. There are also shortcuts for others(and even things like `ö` on `AltGr-p`, so it's close to the `o` :D), but I hardly ever need them myself.
In the beginning, using the deadkeys will feel a bit slower, because you press a key and nothing happens, then you have to remember the combination and maybe correct a couple of mistakes(I had to try a couple to find the `AltGr` combinations above), but over time, it will feel like second nature and it's not an emacs-only solution, but works pretty much everywhere..
Great, reddit has garbled the formatting, but I guess it's still readable :)
anaumann · 2022-07-27 16:17
>Only trouble, I am now so used to English layout keyboards, that I can't stand a German keyboard anymore.
Hint: Look for keyboards in Dutch online shops :) I spent the last two years in the Netherlands and most keyboards just have one of the english layouts on them, sometimes you get a choice between UK international and US ANSI...
Got the perfect keyboard for me there.. A keychron K6 in US ANSI :)
jsled · 2022-07-27 16:59
Is this different from the xinput compose-key based method that's worked forever?
jsled · 2022-07-27 17:00
Compose key, bound to right-ALT, with https://github.com/kragen/xcompose and a few custom timesavers on top
purcell · 2022-07-27 17:36
I personally just use Command for Meta on the Mac, with the Option key set to trigger the usual MacOS-wide composition of accented characters. So no Emacs modes or input methods involved, and accented chars work the same way in all apps.
divinedominion · 2022-07-27 17:49
That's what I currently do as well, and the consistency is nice. Do you bind your right ⌘ key to Super or whatever, then, or do you also miss out on all the modifier separation and end up with using Meta for macOS shortcuts?
zweispieler · 2022-07-27 18:05
I use an English Keyboard but require some German letters sometimes.
What I have is a system-wide shortcut to toggle between the EN and DE keyboard layout (using i3wm or sway)
I used to have both left and right Shift key pressed together, but I switched to Super+Space.
vcored · 2022-07-27 19:56
If it does get in the way, just toggle the input method with `C-\`.
xtifr · 2022-07-27 20:10
I use the compose key, which I have bound to Caps Lock. This is, of course, a system-wide setting, not an Emacs-specific one. I even have some custom compose sequences defined in \~/.XCompose for things like 'p' 'i' = π (and, I admit, some bonus emoji).
jsled · 2022-07-27 20:55
[the way, the truth, and the light](https://github.com/kragen/xcompose)
vcored · 2022-07-27 22:00
I rarely need these letters, so I mostly stick to Gnome’s “Compose” key feature for those occasions.
But if I’d have to write German prose in Emacs I would definitely prefer the postfix input-method over compose.
redback-spider · 2022-07-27 23:40
The advantage of this aproach is that it works outside of emacs, the disadvantage is that key chords are not ergonomic you will hurt your fingers over time with it.
A middle ground would be to activate sticky keys that you don't have to hold that alt-gr key.
danderzei · 2022-07-28 02:47
I use the international keyboard layout. No Emacs setting needed.
_viz_ · 2022-07-28 03:19
In terms of translation rules, no? But the input method shines in that it gives you all the Quail stuff like suggestions, one to many translations (i.e., one key can be translated to two strings), etc.
Schievel1 · 2022-07-28 04:12
I’m using the compose key. I bound it to right alt.
For work PC there’s wincompose
divinedominion · 2022-07-28 06:08
FWIW I'm giving up my OS's compose key, more or less, if I bind Alt/Option to Meta :) so that's going to go away
divinedominion · 2022-07-28 06:11
macOS offers these by default in the software; the hold duration is ~0.5s I'd guess. I'm by no means a fast typist, but making that 'freeze frame' move is so weird :)
Another idea would be to use steno-like simultaneous key presses; QMK supports that, so it'd work on my external keyboard at least. Then I'd have to press in the space between U and I to trigger both and get an ü, or similar. Hm
purcell · 2022-07-28 06:40
No, I never use the RHS modifier keys.
anaumann · 2022-07-28 07:02
That's why I went for the US international layout and its deadkeys :)
After a while, I was almost back to normal speeds :) But of course it takes a tiny bit more time to press two keys rather than one :D
maniacalradish · 2022-07-28 09:30
Assuming that you are using Umlauts regularly (for Germans, for instance): Emacs is certainly not the only piece of software you are using.
So I don't think a solution implemented in Emacs only is reasonable, unless it is something that also works outside of Emacs (like if Emacs collapses ue to ü, which will also be readable if it does not work in another programme).
This is why I've chosen to select another (modify the existing) keyboard layout.
In case you are undecided between a German keyboard layout and a US layout, I recommend having a look at Neo (there is a QWERTZ version).
The second and third layer of the top row is ****ed up, but I think the rest is OK.
You have your Umlauts plus Slashes and brackets are nice to reach.
I used to use a custom layout, but it was tedious to reconfigure that every time I switched to a new device (I use Windows and Debian for work, MacOS and Manjaro for private use).
divinedominion · 2022-07-28 10:18
I actually learned to touch type with Neo2 ~10 years ago -- I ditched it for my work because I like the convenient placement of parens and brackets and curly braces on QWERTY much more. So I end up with `Alt + U + U` to enter `ü` (actually Option, not Alt, because I'm on a Mac)
Your advice is reasonable and echoes what /u/purcell wrote.
It's also why I initially chose to bind Cmd to Meta, not Alt: the same input scheme works system-wide.
With the `'german-postfix` input method I'm not exactly grinding to a halt. But it requires some mental effort, still.
I notice how little German I write inside Emacs, though.
Gallipo · 2022-07-28 11:08
I also use neo2. Takes some time (4-6 weeks in my case) to get used to, but for me it was worth it. I think it is designed with the German language in mind (easily reachable ä,ö,ü,ß) but it is also quite useful for portugese (é, ão, …) and and english. I asume (no first hand experience) it's also usable for french, spanish, swedish or other languages.
It has this concept of "layers" which require key-combinations to reach stuff like `"([<{` and also maps a number-pad, arrow-keys and more to combinations. That adds some complexity when used with emacs (e.g. for `C-/` you have to press `C-#-/`), which I personally still consider easier than the german standard QERTZ-layout.
I suspect it is only usefull for the few users who are willing to invest a lot of time learning while not knowing if they ever will be able to get used to the "layer-concept". But who will that be if not an emacs user ;)
Gallipo · 2022-07-28 11:11
>convenient placement of parens and brackets and curly braces on QWERTY
That's true for QWERTY, but not for QWERTZ, which is the standard layout for the german language. It's placement of parens and brackets and curly braces (and more) is pure horror.
redback-spider · 2022-07-28 12:23
Are we talking about the Alt-gr thing or the "ae" thing, because the former of course linux can do to, maybe not "by default". But I have even addons that I sadly tend to not use often, where I can press some key to open a texbox of the browser as a emacs frame write and save/commit it back. So that as example I can use the "ae".
But it's more sad that you can't just have UIs for everything in emacs and need browsers in the first place :D
divinedominion · 2022-07-28 17:04
> Are we talking about the Alt-gr thing or the "ae" thing
with what exactly? The "pressing between keys" idea?
redback-spider · 2022-07-28 20:47
the "macOS offers these by default"
hubisan-one · 2022-08-08 12:25
Thanks for mentioning using a keyboard layout and the AltGr key. Was checking out the US international layout and stumbled upon the European keyboard layout ([eurkey](https://eurkey.steffen.bruentjen.eu/)). That's what I am using now.
ThorstoneS · 2022-08-10 12:11
It's usually the right ALT key. They have the same label, but can be mapped independently.
Himmenuhin · 2022-08-23 14:19
How can one define compose key in the .emacs file?
For example, this doesn't work for me:
(define-key global-map (kbd "M-#") '(kbd "<Multi_key>"))
mattias_jcb · 2022-08-23 14:32
No idea. I set it up in my operating system.