all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Florian Beck <abstraktion@t-online.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Inserting an unicode character
Date: Fri, 17 Jul 2009 21:57:58 +0200	[thread overview]
Message-ID: <873a8v9j5l.fsf@sophokles.streitblatt.de> (raw)
In-Reply-To: 2b670b7e0907171151s4906b62ds922dd4ce73c406fd@mail.gmail.com

Alberto Simões <hashashin@gmail.com> writes:

> Is there any way to visit an unicode table from within emacs? Or, for
> instance, inserting the caracter using its name.

The emacs sources come with a file called »UnicodeData.txt« (in admin/unidata/). You can do
all kinds of cool things with it. To insert a character by name:


(defvar unicode-character-alist nil)
(defvar unicode-character-names nil)

(defun unicode-get-names ()
  (let (unidata)
    (with-temp-buffer
      (insert-file-contents "/path/to/emacs/admin/unidata/UnicodeData.txt")
      (goto-char (point-min))
      (while (re-search-forward "^\\(?1:[[:alnum:]]+\\);\\(?2:.*?\\);" nil t)
	(add-to-list 'unidata
		     (cons (downcase (match-string 2)) (string-to-number (match-string 1) 16)))))
    (setq unicode-character-names (mapcar 'car unidata))
    (setq unicode-character-alist unidata)))

(defun unicode-insert-by-name (name)
  (interactive
   (list
    (progn
      (unless unicode-character-names (unicode-get-names))
      (completing-read
       "Insert unicode character named: "
       unicode-character-names nil t))))
  (insert (cdr (assoc name unicode-character-alist))))


-- 
Florian Beck





  reply	other threads:[~2009-07-17 19:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-17 18:51 Inserting an unicode character Alberto Simões
2009-07-17 19:57 ` Florian Beck [this message]
     [not found] <mailman.2710.1247856675.2239.help-gnu-emacs@gnu.org>
2009-07-17 19:05 ` Teemu Likonen
2009-07-17 23:45 ` Xah Lee
2009-07-18 16:16   ` Jason Rumney
2009-07-18 17:49     ` Xah Lee
2009-07-18 17:55       ` Xah Lee
2009-07-19 16:20         ` Alberto Simões

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=873a8v9j5l.fsf@sophokles.streitblatt.de \
    --to=abstraktion@t-online.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.