Fast unicode input in Emacs with US layout - unicode

I would like to have a quick way to input unicode characters with multicharacter sequences. For example to input ä I would type \a. Searching for this, I found agda-input.
While I could adapt the agda-input for my use, I don't really need the whole emacs mode for my purpose. So I was wondering if such thing already exists.
It is probably also not that difficult to code such input mode. I would appriciate if someone suggested on how to do that.

As #legoscia mentioned, you can use the TeX input method for such things, which is probably more general than agda-input (which seems to be specific for a programming language) and is also built in.
(setq default-input-method "TeX")
Then switch to the input method with C-\ or M-x toggle-input-method. You can then type "ä" with \"a. The minibuffer has hints when you type \.
There are other input methods (M-x list-input-methods), but TeX is a good one if you're not concerned with a specific language, or if you know LaTeX.

Related

Julia: How to deal with special unicode characters

I am working with the Distributions package which uses special unicode characters for many of the variables within types. The normal distribution, for instance, uses μ and σ. If I want to edit the standard deviation, I need to somehow type:
n.σ = 5.0
Is it possible to type these values into the repl (outside of using copy-paste)? How does one create these characters with one's keyboard?
Thank you
At the REPL, use LaTeX shortcuts, e.g. type \sigma and press tab to autocomplete. Note you need to using Julia 0.3 or higher for this to work.
Many text editors have add-ins to do something similar, e.g. https://github.com/mvoidex/UnicodeMath for SublimeText.
In Windows 10 and Linux under most modern desktops you can add a Greek keyboard map and then switch between Greek and English using [[windows button]]+space. Since many Latin / English letters are derived from ancient Greek, these have analogs so S types a Sigma (σΣ), D, a delta(δΔ) etc. ετψ.
Figured it out by looking up "Entering Unicode in Linux" on Google.
One can press Ctrl+Shift+u, then the 4-digit UTF-16 Hex encoding for the character. For example, σ = u03bc
Tt is difficult to remember all the unicodes or latex shortcuts (at least for me) or search it on the web. When working with REPL or jupyter notebook, Julia has provided a simple way to do it as mentioned here:
You can also get information on how to type a symbol by entering it in the REPL help, i.e. by typing ? and then entering the symbol in the REPL (e.g., by copy-paste from somewhere you saw the symbol).
For example:

Using unicode / utf-8 in programmers editors

There are a lot of programmers editors that claim to support unicode / utf-8. I've tried a number of them (UltraEdit, jedit, emedit) but none of them tell you how to actually enter unicode characters into a file. Some of them tell you how to change the default file encoding to utf-8 or how to select a font that has good support for utf-8, but not how to enter utf-8 into a file using their editor.
The Go language (and some others) support utf-8 and I like the idea of using the actual utf-8 symbols for variables instead of variables with names like omega. I haven't found a programmers editor yet that actually allows you to do this, though.
The only editor / word processor that I've found that lets you how to enter unicode is Microsoft Word. Type the unicode and Alt+X and Word converts it. To get the Greek letter omega type "03c9" followed by Alt+X. UltraEdit will let you copy utf-8 from a web page into it, but their docs don't say how to actually enter utf-8 in a file, and their tech. support people don't know either.
This should be simple, but seems to be completely undocumented. Is there some key combination convention the lets you enter unicode into these editors that supposedly support unicode the way that Ctrl-F is widely used for search?
Thanks.
The standard programmer’s editor vim(1) supports limited Unicode input even if your operating system should be too broken to do so (are there any such, still?).
Just enter ^VuXXXX, where XXXX represents exactly four hex digits.
That will allow you to enter the ~6% of Unicode allocated to the Basic Multilingual Plane. The rest are forbidden to you.
This may be fixed in a newer release.
Otherwise, just use your mouse.
A few techniques I use if an editor is lacking:
Use the Windows charmap.exe utility to select characters and paste into a document.
Install an input method editor (IME) to write in a particular language.
Windows ALT keycodes.
Better to set your keyboard to generate Unicode characters across all Windows applications than to rely on a single application's custom input feature IMO.
Use the EnableHexNumpad feature and you can type any character in the Basic Multilingual Plane using Alt+numbad-plus,hexcode. (May not be of much use on a laptop without a numpad though.)
Or if there are particular characters you want to type a lot, find a keyboard layout that allows you to type them directly. For example eurokb might cover it, or you can make your own with MSKLC.
Old question, but you can type a lot of unicode in GNU Emacs or Vim
GNU Emacs: M-x set-input-method RET tex (or C-x RET C-\ tex) will let you type \omega to generate ω
Vim: Vim digraphs can generate unicode; C-k w * in insert mode gives you ω.
deceze hit the nail on the head. (S)he just didn't elaborate. bobince gave a bit more.
And I'm hazarding a guess that you're a developer or tester working on L14N or I18N. I'm also guessing you need to do more than just a few characters here or there, or you'd be satisfied with pasting from another app. So, I'll share some advice. (note: here, "you" refers to the next person to look here. I'm sure the original poster doesn't care anymore by now. :-))
If you're on Windows 10, install an appropriate keyboard driver that lets you input the characters you want into any application. I'm sure Linux has support for the same sort of thing.
E.g. I'm teaching myself Hindi (हिंदी), so I installed Windows' Hindi (Devanangari) support. I typed "Hindi", in Hindi using that support, then I switched back to US English to do the rest of this post. If all you need are accented characters from Western European languages, you can install the INTL English support and type directly in español or français or whatever.
Don't look at entering Unicode characters as entering some sort of special data amidst your English text. It's just someone else's language. Use their keyboard. Type their language.
I'm writing a flashcard app to help my learning. I'm using the Hindi keyboard support to type characters into Word, WordPad, Excel, and the Visual Studio editor. And that Hindi keyboard support works exactly the same way in all of those apps, as I'd expect it to work in just about any text editor that supports Unicode. And as you saw above, it also works in a simple text edit control in Chrome. No copy and paste. No remembering special codes. It's as ubiquitous as ctrl-F.
It looks like the unicode support in programmers editors (except for some Microsoft products) is mostly read-only. They can open a file with unicode and display the characters, but typing unicode into a file is a different story. If you want to enter unicode in a programmers editor you can copy it from somewhere else (a web page or Microsoft Word or Notepad) and paste it into the editor, but the editors make typing unicode difficult or impossible.
UltraEdit tech support referred me to this web page which explains a lot. Unfortunately none of the solutions worked with UltraEdit.
Microsoft Word and Notepad support unicode entry. Type the unicode value followed by Alt+X and it converts the hexadecimal and displays it. You can then copy and paste it into UltraEdit or one of the other programmers editors. As others have mentioned unicode support depends on support within the operating system as well as the editor.
What got me interested in using unicode in source code files is Mark Summerfield's book Programming in Go. He includes an example .go file that uses unicode. It would be great to use unicode Greek characters for variable names instead of variables named "omega" or "theta".
Using unicode in source code is a bad idea, however. Support for unicode in programmers editors is lousy, and developers would have to save or convert their source code files to utf-8 instead of ASCII. Developer's tools are just not ready to write code in unicode no matter how neat the idea sounds.

Emacs - how to avoid or replace wrong character encodings?

Assume that I receive a Spanish text written in MS word and saved as plain text (.txt). Unfortunately, all the Spanish accents show up like this:
Un \372ltimo an\341lisis
Can anybody tell me how I can avoid this, or at least how I can replace these characters? They are simply not found by the replace-regexp-functions, otherwise I could write a little elisp function that replaces every occurence of them by the associated Spanish accented character.
This looks like ISO 8859-1 (Latin-1) encoding.
Visit the file with that coding system instead. If Emacs does not automatically identify the coding system, you can revisit the file with an explicit coding system with revert-buffer-with-coding-system (C-x RET r).
For example, if you are looking at the garbled file you describe,
C-x RET r
latin-1 RET
yes RET
Then you can set the coding system you want for saving (C-x RET f) and specifying something like utf-8.

Emacs transliteration?

Is there some way to get transliteration to work in Emacs, sort of like it does in Gmail now? I am particularly interested in getting it to work in Cyrillic.
For reference, Gmail does something like the following:
I can type svoboda and it will output свобода. This allows somebody like me who speaks Russian but cannot type to easily input Cyrillic characters. In Gmail this works with other languages, but I am only really worried about Cyrillic.
I think this will do it:
M-x set-input-method cyrillic-translit

Emacs automatic encoding conversion

When I open a buffer in Emacs containing a German Umlaut (the word "Präsentation" occurs in a string), Emacs automatically converts it to a different encoding as soon as I save the file.
How can I tell Emacs to leave the encoding alone?
M-x set-buffer-file-coding-system is what you are looking for.
You might also have a look at http://www.delorie.com/gnu/docs/emacs/emacs_221.html.
Perhaps you want find-file-literally.
I don't know whether its a bug in stackoverflow, or you really mean you see an A~ and universal currency symbol in Emacs. If the problem is Emacs displaying the wrong characters, then the following might help:
(prefer-coding-system 'utf-8)