From: "Göktuğ Kayaalp" <self@gkayaalp.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Writing source code with Unicode characters
Date: Thu, 06 Feb 2014 21:23:17 +0200 [thread overview]
Message-ID: <87sirwgi56.fsf@gkayaalp.com> (raw)
In-Reply-To: 87zjm4qeqi.fsf@wanadoo.es
I just came up with a solution for this: Have an alist from two characters
to unicode symbols, and have a function, when called, takes the two
characters to the left of the point, then lookup the alist and replace
them with the cdr of matching pair:
(defvar unicode-pair-alist '((".\\" . "λ")
("->" . "→")
("=>" . "⇒")))
(defun unicode-replace-previous-two-chars ()
(interactive)
(if (or (not (boundp 'unicode-pair-alist))
(null unicode-pair-alist))
(error "Please set ``unicode-pair-alist'' in order to use this function."))
(let* ((pair (string (get-byte (- (point) 2))
(get-byte (- (point) 1))))
(usym-pair (assoc pair unicode-pair-alist)))
(if (null usym-pair)
(error (concat "Pair not in ``unicode-pair-alist'': " pair)))
(delete-backward-char 2)
(insert (cdr usym-pair))))
(global-set-key (kbd "C-'") 'unicode-replace-previous-two-chars)
One can map `->' to `→' directly, but then they can't insert `->'
easily, can they? What do you think of this? I have just came up with
this after I read your post, so I did not evaluate it's merits and perils.
Óscar Fuentes <ofv@wanadoo.es> writes:
> I'll like to experiment with using Unicode on source code (λ instead of
> lambda, etc) but it seems quite inconvenient to insert those chars with
> C-x 8 RET. Org-mode has the capability of displaying λ when you type
> \lambda, but that's just a display replacement, the raw text still is
> \lambda.
>
> What can I use to make more convenient the insertion of Unicode chars?
> (I'm mostly interested on Greek letters and other math-related symbols)
>
>
>
GK
next prev parent reply other threads:[~2014-02-06 19:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 18:26 Writing source code with Unicode characters Óscar Fuentes
2014-02-06 18:45 ` Eli Zaretskii
2014-02-06 18:48 ` Drew Adams
2014-02-06 19:23 ` Göktuğ Kayaalp [this message]
2014-02-06 20:38 ` Óscar Fuentes
2014-02-06 22:59 ` Drew Adams
2014-02-07 0:32 ` Florian Beck
[not found] <mailman.13962.1391711236.10748.help-gnu-emacs@gnu.org>
2014-02-06 20:36 ` Eric Wolf
2014-02-07 2:52 ` Rusi
2014-02-07 16:41 ` Rusi
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=87sirwgi56.fsf@gkayaalp.com \
--to=self@gkayaalp.com \
--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.