From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Are abbrevs for this?
Date: Wed, 10 Jun 2009 16:53:26 -0700 (PDT) [thread overview]
Message-ID: <183b9113-69f1-45a2-8bec-a3fbdae5e92f@d38g2000prn.googlegroups.com> (raw)
In-Reply-To: mailman.368.1244642017.2239.help-gnu-emacs@gnu.org
On Jun 10, 6:53 am, "Paulo J. Matos" <pocma...@gmail.com> wrote:
> Hi all,
>
> I am developing a new major mode for a new specification language
> which uses a lot of unicode symbols but it also has an ascii notation.
> Like some scheme modes convert the lambda keyword into the greek
> lambda letter, I have a table of keywords that would like them to be
> changed into unicode symbols.
>
> Can I use abbrevs for this?
you can use abbrev, like this:
Q: How to use abbrev to input unicode chars?
Put the following in your emacs init file:
(define-abbrev-table 'global-abbrev-table '(
("alpha" "α" nil 0)
("beta" "β" nil 0)
("gamma" "γ" nil 0)
("theta" "θ" nil 0)
("Infinity" "∞" nil 0)
("ar1" "→" nil 0)
("ar2" "⇒" nil 0)
))
(abbrev-mode t) ; turn on abbrev mode
Then, when you type “alpha ”, it will become “α”.
• Emacs and Unicode Tips
http://xahlee.org/emacs/emacs_n_unicode.html
if you already have typed text and want to replace them to unicode,
you can also do so. See:
Q: How to replace “&” by “&” in a region?
Place the following in your emacs init file:
(defun replace-string-pairs-region (start end mylist)
"Replace string pairs in region."
(save-restriction
(narrow-to-region start end)
(mapc
(lambda (arg)
(goto-char (point-min))
(while (search-forward (car arg) nil t) (replace-match (cadr
arg)) )
) mylist
)
)
)
(defun replace-html-chars (start end)
"Replace “<” by “<” and other similar HTML chars that needs to be
encoded."
(interactive "r")
(replace-string-pairs-region start end '(
("&" "&")
("<" "<")
(">" ">")
)
)
)
With the above code, you can select a region, then press “Alt+x
replace-html-chars”, and have all “&”, “>”, “<” replaced by their
encoded entity. You can define a keyboard shortcut for easy operation.
You can also use the code to replace some HTML entities by their
actual unicode characters. For example:
“ → “
” → ”
é → é
© → ©
-> → →
=> → ⇒
Pi → π
Infinity → ∞
This makes the HTML source code more elegant and readible. (You need
to declare your charset as one of unicode encodings. See Character
Sets and Encoding in HTML)
• Emacs and HTML Tips
http://xahlee.org/emacs/emacs_html.html
Xah
∑ http://xahlee.org/
☄
next parent reply other threads:[~2009-06-10 23:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.368.1244642017.2239.help-gnu-emacs@gnu.org>
2009-06-10 23:53 ` Xah Lee [this message]
2009-06-11 7:53 ` Are abbrevs for this? TomSW
2009-06-11 11:42 ` Paulo J. Matos
[not found] ` <mailman.451.1244720587.2239.help-gnu-emacs@gnu.org>
2009-06-11 11:55 ` TomSW
2009-06-13 8:14 ` harven
2009-06-10 13:53 Paulo J. Matos
2009-06-11 1:13 ` Maurizio Vitale
2009-06-11 11:43 ` Paulo J. Matos
2009-06-11 12:18 ` Maurizio Vitale
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=183b9113-69f1-45a2-8bec-a3fbdae5e92f@d38g2000prn.googlegroups.com \
--to=xahlee@gmail.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.