How can I input Greek symbols like \beta, \lambda in emacs? - emacs

How can I input Greek symbols using the TeX descriptions (like \beta, \alpha, \lambda, etc) in emacs?

Use
C-x RET C-\ TeX RET
to get TeX entry mode. Then you can use many of the standard sequences from TeX to enter things.
\alpha α
\Gamma Γ
as well as the whole gamut of mathematical symbols
\rightarrow →
\Leftarrow ⇐
\oplus ⊕
\int ∫
x_3 x₃
M^-^1 M⁻¹
v^x vˣ

I tend to use the RFC 1345 input mode for this.
C-x RET C-\ "rfc1345" RET
You can then turn the input mode on and off with C-\.
According to RFC 1345, Greek characters are accessed by appending the * character. Special symbols in general start with &. So you can type &a* and get α, &l* gets λ. I use RFC 1345 because it also gives me access to all sorts of other symbols, like &TE for ∃ "there exists" or &FA for ∀ "for all".
You could also use the Greek input mode, which is easier to use but doesn't give you extra symbols.
C-x RET C-\ "greek" RET
One of the advantages of these methods is that they work the same way across all platforms — as long as you're using Emacs.

i always input `λ' by the following punch:
C-x 8 RET 3bb

You can also learn some unicode and use M-x ucs-insert, e.g. M-x ucs-insert 3BB gives you a beautiful lambda.

There is also the greek-babel input method which is selected (similarly to other input methods) with C-x RET C-\ greek-babel.
In this mode, the regular alphabet keys are mapped to greek characters as shown in this little table:
Αα Ββ Γγ Δδ Εε Ζζ Ηη Θθ Ιι Κκ Λλ Μμ Νν Ξξ Οο Ππ Ρρ Σσς Ττ Υυ Φφ Χχ Ψψ Ωω
Aa Bb Gg Dd Ee Zz Hh Jj Ii Kk Ll Mm Nn Xx Oo Pp Rr Ssc Tt Uu Ff Qq Yy Ww
plus some for entering sampi, digamma, stigma, koppa and various diacriticals. For a full list of the mappings done by greek-babel use C-h I greek-babel.
In ordinary usage the only somewhat weird mappings to watch out for are Θ/θ, ς, Υ/υ, Ψ/ψ and Ω/ω.
It is named so because the LaTeX package babel when loaded with the greek option enables one to type greek text with regular latin latters using the above mapping.
This input mapping is especially useful if you're writing the occasional Greek word in a (La)TeX document that you want to keep fully in UTF-8 without any ugly hacks like writing bibloc in your source instead of actual Greek βιβλος.
<Rant>
As a side note, things like C-\ are really annoying with a Danish keyboard because \ = AltGr + <, so to enter C-\ you need to hold down both Ctrl keys plus AltGr. If you hold just one Ctrl key plus AltGr plus < you just get a backslash.
</Rant>

I have Ubuntu set up so that I can type in Greek after pressing Shift+CapsLock — λικε τηισ — and then press Shift+CapsLock again to get back to Latin letters. Are you using Windows, MacOS, what?
Edit: You're using Ubuntu too, so: go to Start menu → System → Preferences → Keyboard → Layouts. [Add...] a layout for Greece. Select a key combination you like under [Options...] → Key(s) to switch between layouts. Personally I don't have "Separate layout for each window" set, but YMMV. Finally, I clicked [Apply System-Wide...].
(I'm using Ubuntu lucid 10.04 LTS — if you're using a newer version, the steps might be slightly different.)

Depending on your goal, e.g. which programming language you want to edit, you might want to consider using the input mode available in agda2-mode; it provides a more programming oriented alternative to TeX (but very similar);
Use Agda's input method in other emacs mode?
http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Docs.UnicodeInput
I'm personally using it with my Haskell buffers instead of the TeX input method or the automagic but limited Haskell unicode input method.
Examples:
typing \:: yields ∷
typing \-> yields →
typing \br yields ℝ
Installing agda2-mode means using your package manager or Cabal to install Agda (e.g. brew install agda on OS X), then $ agda-mode compile and then:
(load-file (let ((coding-system-for-read 'utf-8))
(shell-command-to-string "agda-mode locate")))
Optionally, to auto-enable the agda input mode for e.g. Haskell buffers:
(require 'agda-input)
(add-hook 'haskell-mode-hook
(lambda () (set-input-method "Agda")))

if you have an Apple, there is a very easy way to access all of the characters available to the "Character Viewer".
In Sys Prefs -> keyboard -> input sources, select show input menu in menu bar.
Bring up the character viewer and then make favorites of the N characters you need to access. Then, hit the small box to the right of char viewers search bar. The char viewer disappears, and what's left is a small window with your chosen char set. Position your cursor in your editor, click on the desired char in the favs.

You can copy paste them from the character map to the editor.

Related

How do I use Latex/Tex-inspired keybindings in Dr. Racket?

The Racket Docs say that to use a Latex/Tex-inspired keybinding like
\Downarrow for ⇓ that we should do something with C-\ M-\ c:x;l:
C-\ M-\ c:x;l : traces backwards from the insertion point, looking for a backslash followed by a LaTeX macro name or a prefix of such a name. If a macro name is found, it replaces the backslash and the name with the corresponding key in the table below ...
The parts that confuse me are:
What does C-\ M-\ c:x;l mean? I suspect the C-\ M-\ c:x;l is Ctrl, followed by Option, followed by something.
I'm not sure I follow the business about tracing backwards. If I have my hands on the keyboard and I want to type an arrow, what do I actually do?
I think that the documentation you refer to is showing three likely bindings, but the DrRacket docs say that the final word on keybindings is to be found by consulting the Show Active Keybindings menu item from the Edit menu. When I check Show Active Keybindings on my DrRacket installation, I see as one of the options: TeX compress (~c:m:\), which is equivalent to M-\, i.e., pressing Meta-\ together. Entering \Downarrow followed by Meta-\ in the interactions area, I am greeted with the expected character: ⇓.

How to enter special symbols with Alt in Emacs under Mac Os X?

In Mac Os X using the alt key with some other key will produce a series of special symbols. E.g. alt-' results in æ, alt-3 results in £, etc. When using emacs, however, I can no longer input these special symbols this way since alt is now mapped to meta. Is there a way to map alt to some other key combo? Or maybe use the left alt as meta only and have the right behave as it normally does in other apps?
There are additional methods to obtain special characters other than the one mentioned in this answer, but I personally prefer the best of both worlds -- i.e., I use the left alt/option key as meta, and I use the right alt/option key for stock Apple stuff -- e.g., special characters like the ones mentioned by the original poster:
(setq ns-alternate-modifier 'meta)
(setq ns-right-alternate-modifier 'none)

How to type unicode characters by name in spacemacs?

Is there some plugin that allows you to type unicode characters by name easily?
For example :
Writing \gamma and hitting TAB would replace the \gamma with γ.
Writing \Gamma and ... with Γ.
Writing \-> ... →.
Et cetera.
C-x 8 RET lets you do this anywhere in Emacs. I imagine it works for Spacemacs too, but someone will correct me if that is not quite correct.
It prompts you for the Unicode name with completion (ignoring case).
You can alternatively enter just the numeric code point for the character, instead of completing to its name.
[Caveat: Dunno whether Spacemacs plays nicely with Icicles - haven't tried it.]
If you use Icicles, and if option icicle-read-char-by-name-multi-completion-flag is non-nil, then C-x 8 RET is enhanced in a few ways:
It shows in *Completions*, for each candidate Unicode
character, its name and code point, as well as the character
itself.
When you cycle among the matching candidates, the name and code
point of the current candidate are shown in the mode line. The
code point is shown in hexadecimal, octal, and decimal
notations.
Completion candidates are in fact multi-completions, meaning
that you can match against the name or the code point, or both.
You can even match the character itself. Why might you want to
do that? To see the corresponding Unicode character name(s),
including any old names. For example, for the character `
(grave accent) you get these two completion candidates:
GRAVE ACCENT 60 `
SPACING GRAVE 60 `
The main purpose for this is to show you the characters and code
points together with their names (WYSIWYG). The characters are
shown in *Completions* using the same font as the frame from
which you invoked C-x 8 RET. That you can also match against
the characters themselves is just a nice-to-have.
The most important features of the Icicles version of C-x 8 RET
are (a) seeing the characters and code points (WYSIWYG) and (b)
being able to use progressive completion, so you can use multiple
simple patterns instead of a single complex pattern.
I don't use spacemacs, so I'm not sure if this works there.
I set default-input-method to "TeX". I can toggle to it with toggle-input-method (C-\). When it's enabled, there's a \ on the far left of the mode line.
This isn't the same as entering unicode chars by name, but probably closer to what you described.

Are RET and C-m really the same exactly?

In the graphical mode, RET does the same as C-m, namely newline.
However, when I use M-a or M-e, they seem to distinguish between them. The newline produced by RET, they skip all to a double-RET point, and with the newline produced by C-m, they move the cursor line by line. Why so?
Description (C-h k) for both keys shows the same.
If it matters, it is Emacs23.3.1 on Ubuntu 12.04.
The answer could be dependent on the mode you're in as well as in the key codes generated by your operating system. When I hit Ctrl-h k Ctrl-m in the *scratch* buffer on my Windows box, I'll get the info for (newline) with the information that it is bound to RET. Theoretically, in some other mode, C-m and RET could be set to different functions. This requires, of course, that the OS doesn't generate the same key code.
What Emacs writes as RET (or as <RET>) is, yes, the same character as C-m - it is the ASCII control character 13. This is so regardless of what keyboard etc. you have.
However, the logical key (aka "key sequence") that Emacs sees when you hit the phisical (keyboard) key named Enter or Return might be different from RET (aka C-m). To see what key Emacs recognizes when you hit that keyboard key, use C-h k and hit the key. If Emacs says RET then this is the typical case, and yes, hitting that key is then identical to pressing Control and hitting m (assuming the key labeled Control does what it does typically).
In the graphical mode, the answer is yes (unless keys are redefined, of course).
Careful examination of my file showed that the effect I observed was a coincidence. It was exactly in those paragraphs which I C-m'ed that all lines would end in a dot (it was a poem).
Actually, C-h k key description says the same thing for both keys. Thanks to schaueho's answer for pushing me in this direction.

How to replace '_' by space in emacs

I have a text file which I am only able to look that there is an underscore between some words only using emcas editor but not other editors such as vi. I do not know how to use emacs but I wanted to replace these underscores "_" by space in the emacs editor automated fashion. How can I do that ?
I believe that those underscore aren't really underscore, but non breaking space (U+00A0 unicode char), that Emacs show as underscore with a different color. You probably don't need to replace them, but if this is really needed, just use M-x replace-string and kill and yank one of those non-breaking space in the string to be replaced.
Hit the M-x key-combination (that is, hold meta key - alt on windows - and hit x) type replace-string and hit enter. You can then type [underscore] enter [space] enter.
In Emacs notation:
M-x replace-string RET _ RET " "
Should the previous answer not solve it: Remember that as a coding system error. Check with C-x = if it's char 95.
If not, check variables coding-system-for-read, coding-system-for-write, buffer-file-coding-system
Finally, get emacs core developers at help-gnu-emacs#gnu.org