14

I just discovered C-x 8 RET as a way to insert Unicode characters by Unicode name or hex code. I have not (yet?) memorised all Unicode character names, so I don't always find the right character.

There is, for example, the character "SNOW CAPPED MOUNTAIN". If I type just "MOUNTAIN" this character will not appear the completion list. I need to remember to search for "SNOW" to see this particular character in the list of completions.

As someone who has become dependent on IDO for anything involving completion, this lack of flexibility is rather unnerving. I use ido-ubiquitous-mode.

How can I use IDO-like matching for Unicode input? How can I use flexible completion for ALL THE THINGS?

(I would be okay with abandoning IDO mode if there was something better.)

6
  • As a workaround for that same problem, I would type C-q SPC mountain TAB. That would match any character name with "mountain" as non-first word.
    – legoscia
    Commented Nov 5, 2014 at 14:52
  • 1
    Have a look at emacs.stackexchange.com/a/3139/2094 for helm-based completion.
    – abo-abo
    Commented Nov 5, 2014 at 14:54
  • 1
    Hmm, this sounds like a bug you can report at the project's issue tracker.
    – wasamasa
    Commented Nov 5, 2014 at 15:12
  • 1
    If you type *cap*mou TAB, then you get the whole completion(s).
    – Juancho
    Commented Nov 5, 2014 at 16:00
  • @Juancho that's true, but it's not the behaviour I want
    – user2005
    Commented Nov 5, 2014 at 16:10

5 Answers 5

9

As @wasamasa suggested, ido-ubiquitous should take care of completion when insert-char is used. There is a bug report that was closed in 2013, but I still see this behaviour with Emacs 24.4 and ido-ubiquitous version 20140904.1547, so I filed another bug report.

EDIT:

The maintainer of ido-ubiquitous wrote this:

Ok, I figured out the problem. There are a lot of unicode characters, so the list of completions is exceeding ido-ubiquitous-max-items and ido-ubiquitous is disabling itself for that reason. On my system, there are almost 40k completions available, and the default for ido-ubiquitous-max-items is 30k. Setting it to 50k enables ido completion for insert-char for me. So try customizing that.

Indeed, (setq ido-ubiquitous-max-items 50000) fixes it.

2
  • 1
    For ido-completing-read+, use (setq ido-cr+-max-items 50000) to fix this error.
    – Bach Lien
    Commented Feb 6, 2018 at 8:45
  • Neither flag is working for me with ido-completing-read+.
    – asmeurer
    Commented Jan 28, 2021 at 21:06
5

To get snow capped mountain included when you just type mount, you may want to do:

(push '(unicode-name (styles substring)) completion-category-overrides)

Actually, maybe this substring style should be enabled by default for unicode names, like it is for buffer names. Maybe you should lobby for it via M-x report-emacs-bug.

3

If you use Icicles then C-x 8 RET lets you use substring or regexp or fuzzy matching during completion. And you can use progressive completion, to match against multiple (e.g. simple) patterns.

In addition, if option icicle-read-char-by-name-multi-completion-flag is non-nil, which it is by default, then you can use multi-completion to match against any combination of these:

  • the Unicode name
  • the Unicode code point, as a hexidecimal numeral
  • the character itself (as it appears in text, not an integer)

Completion candidates you see in buffer *Completions* contain all of these components - WYSIWYG.

Why might you want to match against the character itself? To see the corresponding Unicode code points and 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      `
1
  • 1
    I think I should really try Icicles one day. Thanks for your answer.
    – user2005
    Commented Nov 6, 2014 at 9:26
0

You can use command apropos-char in library apu.el to show all of the Unicode chars whose names match a regexp or list of words you type. By default, words are matched as substrings.

In the list of matches, you can hit ^ to insert the char shown on the current line into the buffer where you invoked apropos-char, at point. Or you can hit C-y to copy that char to the kill ring (or M-y to copy it to the secondary selection). (Hit RET to see more info about the char.)

0

You can customize it:

Completion Category Overrides:
Alist:
INS DEL Category: Value Menu unicode-name
            Properties to override:
            [X] Completion Styles:
                Select a style from the menu;
                insert a new menu to add more styles:
                INS DEL Choice: Value Menu substring
                INS
            [ ] Completion Cycling:
                Select one value from the menu.
                Choice: Value Menu No cycling
INS
    State : SAVED and set.
   List of category-specific user overrides for completion styles. Hide
   Each override has the shape (CATEGORY . ALIST) where ALIST is
   an association list that can specify properties such as:
   - ‘styles’: the list of ‘completion-styles’ to use for that category.
   - ‘cycle’: the ‘completion-cycle-threshold’ to use for that category.
   Categories are symbols such as ‘buffer’ and ‘file’, used when
   completing buffer and file names, respectively.
   This overrides the defaults specified in ‘completion-category-defaults’.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.