Zoltan King
Zoltan King

Reputation: 2272

How to insert unusual characters in emacs?

In VIM I can insert unusual characters by using digraphs:

<C-K>{char1}{char2}

for example the ¿ character is represented by the ?I digraph.

<C-K>?I

then I can define a custom list for digraphs in a separate file, but for now, I'm just going to post the content of that file:

digraph uh 601  " ə UNSTRESSED SCHWA VOWEL
digraph uH 652  " ʌ STRESSED SCHWA VOWEL
digraph ii 618  " ɪ NEAR-CLOSE NEAR-FRONT UNROUNDED VOWEL
digraph uu 650  " ʊ NEAR-CLOSE NEAR-BACK ROUNDED VOWEL
digraph ee 603  " ɛ OPEN-MID FRONT UNROUNDED VOWEL
digraph er 604  " ɜ OPEN-MID CENTRAL UNROUNDED VOWEL
digraph oh 596  " ɔ OPEN-MID BACK ROUNDED VOWEL
digraph ae 230  " æ NEAR-OPEN FRONT UNROUNDED VOWEL
digraph ah 593  " ɑ OPEN BACK UNROUNDED VOWEL
digraph th 952  " θ VOICELESS DENTAL FRICATIVE
digraph tH 240  " ð VOICED DENTAL FRICATIVE
digraph sh 643  " ʃ VOICELESS POSTALVEOLAR FRICATIVE
digraph zs 658  " ʒ VOICED POSTALVEOLAR FRICATIVE
digraph ts 679  " ʧ VOICELESS POSTALVEOLAR AFFRICATE
digraph dz 676  " ʤ VOICED POSTALVEOLAR AFFRICATE
digraph ng 331  " ŋ VOICED VELAR NASAL
digraph as 688  " ʰ ASPIRATED
digraph ps 712  " ˈ PRIMARY STRESS
digraph ss 716  " ˌ SECONDARY STRESS
digraph st 794  "  ̚ NO AUDIBLE RELEASE
digraph li 8255 " ‿ LINKING

They are symbols of the phonetic alphabet I frequently use in documents.

The question is: Is there a way to port the same symbols to emacs so I can use them possibly with the same letter combination "uh, uH, ii, uu" and so on?

Upvotes: 1

Views: 928

Answers (3)

pyrocrasty
pyrocrasty

Reputation: 787

A nicer alternative to M-x insert-char is to use helm-ucs (or alternatively helm-unicode). This brings up a nice list of unicode characters in a helm interface. You can enter words of the name in any order (eg "alpha small greek") to choose from characters matching those strings.

note: helm-ucs takes a few seconds to load the first time it's used in a session, but helm-unicode doesn't suffer from this problem.

Upvotes: 1

Metropolis
Metropolis

Reputation: 2128

M-x insert-char will let you interactively search for a character to insert. Searching for 'schwa' brings up a set of different schwa's to choose from.

For characters I've found I like to insert often, I've added keybinding for them like this:

(global-set-key (kbd "C-<down>") (lambda () (interactive) (insert "↓")))

where I just copy-and-pasted the character I want into that string there. Looking at the docs, you should be able to create a keybinding using insert char with the name or the hex key of the character you want, as well: https://www.gnu.org/software/emacs/manual/html_node/emacs/Inserting-Text.html

Upvotes: 1

legoscia
legoscia

Reputation: 41618

First of all, Emacs comes with three "input methods" that let you type IPA characters, ipa-kirshenbaum, ipa-praat and ipa-x-sampa. You can see the description of them by typing C-h I (for describe-input-method), and you can switch to one of them with C-u C-\ (for toggle-input-method with a prefix argument).

If you'd rather use your own combinations, you can define your own input method:

(quail-define-package
 "my-ipa-symbols" "" "IPA" t
 "My IPA input method

Documentation goes here."
 nil t nil nil nil nil nil nil nil nil t)

(quail-define-rules
 ("uh" ?ə) ; UNSTRESSED SCHWA VOWEL
 ("uH" ?ʌ) ; STRESSED SCHWA VOWEL

 ;; add more combinations here
 )

Evaluate that with eval-buffer or eval-region, and then switch to the newly created input method with C-u C-\ my-ipa-symbols.

Upvotes: 5

Related Questions