flyspell-mode disables Greek accents - emacs

When flyspell-mode is enabled and I try to write in Greek, I get an error most of the times I try to type an accent above some character:
<268632064> is undefined
The normal sequence to type a character with an accent is to first type ', followed by the appropriate vowel. Instead, whenever flyspell-mode is on, ' and the previously typed character are interpreted as a call to <268632064>, whatever that may be, which triggers an error, and, thus, the following character appears as is without an accent.
So,
when flyspell-mode is off, λ ' ε -> λέ
when flyspell-mode in on, λ ΄ ε -> λε and an <268632064> is undefined error
Note: I'm using GNU Emacs 25.3.1 (x86_64-apple-darwin16.7.0, NS appkit-1504.83 Version 10.12.6 (Build 16G29)) on a mid-2015 macbook pro.

Related

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.

Emacs: relation between keystrokes and keys

I am slightly confused by the difference between keys and key-bindings in emacs after reading the first chapter of "Writing GNU Emacs Extensions" (O'Reilly book).
The chapter starts by noting that in some emacs version the keys backspace and DEL, invoke the help menu instead of deleting. In other words, they invoke what is invoked by C-h.
The chapter then goes on to show how to change this behaviour using Lisp code. This is done by binding the keystroke C-h to the delete command.
This is a bit confusing to me. In my mind DEL, Backspace and C-h are three different keystrokes (the first two consisting of a single key).
Why does remapping C-h effect what DEL and Backspace does?
I would have thought to change what backspace does for example, you would remap backspace to another command, not the keystroke C-h.
Unless remapped by a low-level keybord driver, the effect of the Backspace key is to send the character with numeric code 8, which, in certain operating systems, is exactly the same code generated by pressing Control-h. You can verify this fact by simply writing anything on a unix (or linux) shell and then pressing Backspace and Control-h: both of them have the effect of erasing the previous character, since the character with numeric code 8 is interpreted by the operating system as the control character BS, backspace, used either to erase the last character printed or to overprint it (see wikipedia). Analogously, Control-J is equivalent to the RETURN key, etc.
The same Wikipedia page describe DEL as “originally intended to be an ignored character, but now used in some systems to erase a character”.
So, when you assign a command to a keystroke you are actually assigning a command to a character code, and if two or more keys generate the same code, by pressing them you are invoking the same command.
#Renzo answered your question about how these keys are related and how binding one can seem to affect another. Here is some more information about what's going on in this particular case.
See the Emacs manual, node DEL Does Not Delete.
There you will see this, following an explanation of the problem/confusion:
To fix the problem in every Emacs session, put one of the following
lines into your initialization file (*note Init File::). For the first
case above, where BACKSPACE deletes forwards instead of backwards, use
this line to make BACKSPACE act as DEL:
(normal-erase-is-backspace-mode 0)
For the other two cases, use this line:
(normal-erase-is-backspace-mode 1)
Another way to fix the problem for every Emacs session is to
customize the variable normal-erase-is-backspace: the value t
specifies the mode where BS or BACKSPACE is DEL, and nil
specifies the other mode. *Note Easy Customization::.
See also the GNU Emacs FAQ question about Backspace invoking help. There you will see, in addition to information similar to that above, information about how to remap DEL on UNIX - use this:
stty erase '^?'
Wrt C-j and RET (not mentioned in the question, but mentioned in #Renzo's answer): The default behavior of Emacs changed in most programming modes, in Emacs 24.4.
Starting with that release, electric--indent-mode is turned on by default, which means that RET inserts a newline character and indents, whereas C-j just inserts a newline character. Prior to that release, these keys had the opposite behaviors. If you prefer the old behavior then do this, to turn off electric-indent-mode:
(when (fboundp 'electric-indent-mode)
(electric-indent-mode -1)) ; Use classic `C-j' and `RET'.

Emacs yanking (pasting) from website always yields character code 160 instead of SPC

When copying code from the web (usually using Chrome in Ubuntu) I am frustrated by the fact that Emacs inserts blank spaces of Char:   (160, #o240, #xa0) wherever there should be a space character, Char: SPC (32, #o40, #x20). This appears fine in the editor but as soon as I try to execute the code I get errors. How can I make Emacs convert entities into normal space characters?
You can use query-replace (M-%) to convert the characters. Copy-paste can help you enter the non-breaking space.

How can I input Greek symbols like \beta, \lambda in 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.

gnu screen - changing the default escape command key to ALT-X?

In GNU screen, I want to change the default command binding to Alt-s (by tweaking .screenrc) instead of the default C-a, the reason is I use emacs hence GNU screen binds the C-a key, sending "C-a" to the emacs becomes tedious (as #Nils said, to send "C-a" I should type "C-a a"), as well as "C-a" in bash shell, and I could change the escape to C- but some of them are already mapped in emacs and other combinations are not as easy as ALT-s . If anyone has already done a ALT key mapping, please do let me know.
It is possible to work around :escape command limitations using registers and :bindkey command. Just put this in .screenrc:
# reset escape key to the default
escape ^Aa
# auxiliary register
register S ^A
# Alt + x produces ^A and acts as an escape key
bindkey "^[x" process S
## Alt + space produces ^A and acts as an escape key
# bindkey "^[ " process S
See http://adb.cba.pl/gnu-screen-tips-page-my.html#howto-alt-key-as-escape
From my reading of man screen it seems like the only meta character that screen can use for the command binding is CTRL:
escape xy
Set the command character to x and the character generating a literal
command character (by triggering the "meta" command) to y (similar to
the -e option). Each argument is either a single character, a two-character
sequence of the form "^x" (meaning "C-x"), a backslash followed by an octal
number (specifying the ASCII code of the character), or a backslash followed
by a second character, such as "\^" or "\\". The default is "^Aa".
If there is some mapping that you don't use in emacs, even if it's inconvenient, like C-|, then you could use your terminal input manager to remap ALT-X to that, letting you use the ALT binding instead. That would be a little hackish though.
I'm an Emacs and screen user as well. Although I rarely use Emacs in a terminal -- and as such in a screen session -- I didn't want to give up C-a for the shell either (which uses Emacs key bindings). My solution was to use C-j as the prefix key for screen, which I was willing to sacrifice. In Emacs programming modes it is bound to (newline-and-indent) which I bound to RET as well, so I really don't miss it.
By the way: I know this is an advise rather than an answer, but I felt this would be valuable enough to post nevertheless.
To make Alt+X the default prefix for commands and free C-a, add the following lines to .screenrc:
escape ^||
bindkey "^[x" command
As a side effect C-| will be command prefix too. If you need this keys to be free too, then fix "escape ^||" accordingly.
Screen doesn't have any shorthand syntax for alt bindings, but you can give it the octal code directly. For instance on my machine, Alt-x has the hex code F8, or 370 octal, so putting
escape \370x
in my screenrc changed the escape code to alt-X
Tested and works with screen 4.00.03 on Linux.
You may have to change the escape, since I think this may depend on things like your language and codeset, etc: how I found out what my escape code was was to type
$ echo -n ^QM-x | perl -ne 'printf "%lo\n", ord($_)'
^Q is the quoted-insert command for readline (it inserts what you type directly without trying to interpret it) and M-x was a literal Alt-X.
Fellow emacs user here.
The best solution I've found is a ~/.screenrc file with the following:
# C-a :source .screenrc
escape ^gg
Live updated here: https://gist.github.com/1058111
See also: http://ubuntuforums.org/showthread.php?t=498675
Something I have had for years in my .screenrc:
escape ^Zz
which is now hardwired in muscle memory for me.
Somehow I ended up having to share a screen with someone else's config, and now I keep stopping processes all the time (bash ^Z)... Not funny...