* Are abbrevs for this?
@ 2009-06-10 13:53 Paulo J. Matos
2009-06-11 1:13 ` Maurizio Vitale
0 siblings, 1 reply; 9+ messages in thread
From: Paulo J. Matos @ 2009-06-10 13:53 UTC (permalink / raw
To: emacs list
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?
Cheers,
--
Paulo Jorge Matos - pocmatos at gmail.com
http://www.pmatos.net
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Are abbrevs for this?
[not found] <mailman.368.1244642017.2239.help-gnu-emacs@gnu.org>
@ 2009-06-10 23:53 ` Xah Lee
2009-06-11 7:53 ` TomSW
0 siblings, 1 reply; 9+ messages in thread
From: Xah Lee @ 2009-06-10 23:53 UTC (permalink / raw
To: help-gnu-emacs
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/
☄
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Are abbrevs for this?
2009-06-10 13:53 Paulo J. Matos
@ 2009-06-11 1:13 ` Maurizio Vitale
2009-06-11 11:43 ` Paulo J. Matos
0 siblings, 1 reply; 9+ messages in thread
From: Maurizio Vitale @ 2009-06-11 1:13 UTC (permalink / raw
To: help-gnu-emacs
>>>>> "Paulo" == Paulo J Matos <pocmatos@gmail.com> writes:
Paulo> Hi all, I am developing a new major mode for a new
Paulo> specification language which uses a lot of unicode symbols
Paulo> but it also has an ascii notation. Like some scheme modes
Paulo> convert the lambda keyword into the greek lambda letter, I
Paulo> have a table of keywords that would like them to be changed
Paulo> into unicode symbols.
Paulo> Can I use abbrevs for this?
Possibly, but take a look at Tuareg, a mode for editing Ocaml.
They do replace keyword with unicode symbols, but they offer the
capability of rather seamlessly editing the original keyword.
OTH,
Maurizio
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Are abbrevs for this?
2009-06-10 23:53 ` Are abbrevs for this? Xah Lee
@ 2009-06-11 7:53 ` TomSW
2009-06-11 11:42 ` Paulo J. Matos
[not found] ` <mailman.451.1244720587.2239.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 9+ messages in thread
From: TomSW @ 2009-06-11 7:53 UTC (permalink / raw
To: help-gnu-emacs
On Jun 11, 1:53 am, Xah Lee <xah...@gmail.com> wrote:
> 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.
If the scheme modes are anything like pretty-haskell, they don't
actually convert the text, they use font-lock to disguise "lambda" as
the greek letter - the source code itself doesn't change.
> > Can I use abbrevs for this?
Yes, if you want to replace the ascii notation with the unicode
symbols in the source code. If that is the case then the notation
sounds more like a set of conventional abbreviations than a part of
the language, in which case it would be nice to permit users to
customise the abbreviations; if in fact the ascii notation is part of
the language then the font-lock approach might work.
regards,
Tom SW
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Are abbrevs for this?
2009-06-11 7:53 ` TomSW
@ 2009-06-11 11:42 ` Paulo J. Matos
[not found] ` <mailman.451.1244720587.2239.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 9+ messages in thread
From: Paulo J. Matos @ 2009-06-11 11:42 UTC (permalink / raw
To: TomSW; +Cc: help-gnu-emacs
On Thu, Jun 11, 2009 at 8:53 AM, TomSW<tom.weissmann@gmail.com> wrote:
> On Jun 11, 1:53 am, Xah Lee <xah...@gmail.com> wrote:
>> 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.
>
> If the scheme modes are anything like pretty-haskell, they don't
> actually convert the text, they use font-lock to disguise "lambda" as
> the greek letter - the source code itself doesn't change.
>
That's the approach I need...
>> > Can I use abbrevs for this?
>
> Yes, if you want to replace the ascii notation with the unicode
> symbols in the source code. If that is the case then the notation
> sounds more like a set of conventional abbreviations than a part of
> the language, in which case it would be nice to permit users to
> customise the abbreviations; if in fact the ascii notation is part of
> the language then the font-lock approach might work.
>
Can you ref any example doing that? Would the haskell-mode be the
thing to look at?
Cheers,
Paulo Matos
> regards,
> Tom SW
>
--
Paulo Jorge Matos - pocmatos at gmail.com
http://www.pmatos.net
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Are abbrevs for this?
2009-06-11 1:13 ` Maurizio Vitale
@ 2009-06-11 11:43 ` Paulo J. Matos
2009-06-11 12:18 ` Maurizio Vitale
0 siblings, 1 reply; 9+ messages in thread
From: Paulo J. Matos @ 2009-06-11 11:43 UTC (permalink / raw
To: maurizio.vitale; +Cc: help-gnu-emacs
On Thu, Jun 11, 2009 at 2:13 AM, Maurizio
Vitale<mav@cuma.polymath-solutions.lan> wrote:
>>>>>> "Paulo" == Paulo J Matos <pocmatos@gmail.com> writes:
>
> Paulo> Hi all, I am developing a new major mode for a new
> Paulo> specification language which uses a lot of unicode symbols
> Paulo> but it also has an ascii notation. Like some scheme modes
> Paulo> convert the lambda keyword into the greek lambda letter, I
> Paulo> have a table of keywords that would like them to be changed
> Paulo> into unicode symbols.
>
> Paulo> Can I use abbrevs for this?
>
> Possibly, but take a look at Tuareg, a mode for editing Ocaml.
> They do replace keyword with unicode symbols, but they offer the
> capability of rather seamlessly editing the original keyword.
This is the kind of thing Tom mentioned, right?
> OTH,
>
> Maurizio
>
>
>
>
>
--
Paulo Jorge Matos - pocmatos at gmail.com
http://www.pmatos.net
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Are abbrevs for this?
[not found] ` <mailman.451.1244720587.2239.help-gnu-emacs@gnu.org>
@ 2009-06-11 11:55 ` TomSW
2009-06-13 8:14 ` harven
1 sibling, 0 replies; 9+ messages in thread
From: TomSW @ 2009-06-11 11:55 UTC (permalink / raw
To: help-gnu-emacs
On Jun 11, 1:42 pm, "Paulo J. Matos" <pocma...@gmail.com> wrote:
> > Yes, if you want to replace the ascii notation with the unicode
> > symbols in the source code. If that is the case then the notation
> > sounds more like a set of conventional abbreviations than a part of
> > the language, in which case it would be nice to permit users to
> > customise the abbreviations; if in fact the ascii notation is part of
> > the language then the font-lock approach might work.
>
> Can you ref any example doing that? Would the haskell-mode be the
> thing to look at?
Yes. Some details here: http://www.haskell.org/haskellwiki/Haskell_mode_for_Emacs.
cheers,
Tom SW
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Are abbrevs for this?
2009-06-11 11:43 ` Paulo J. Matos
@ 2009-06-11 12:18 ` Maurizio Vitale
0 siblings, 0 replies; 9+ messages in thread
From: Maurizio Vitale @ 2009-06-11 12:18 UTC (permalink / raw
To: help-gnu-emacs
>>>>> "Paulo" == Paulo J Matos <pocmatos@gmail.com> writes:
Paulo> On Thu, Jun 11, 2009 at 2:13 AM, Maurizio
Paulo> Vitale<mav@cuma.polymath-solutions.lan> wrote:
>>>>>>> "Paulo" == Paulo J Matos <pocmatos@gmail.com> writes:
>>
>> Paulo> Hi all, I am developing a new major mode for a new
>> Paulo> specification language which uses a lot of unicode
>> symbols Paulo> but it also has an ascii notation. Like some
>> scheme modes Paulo> convert the lambda keyword into the greek
>> lambda letter, I Paulo> have a table of keywords that would
>> like them to be changed Paulo> into unicode symbols.
>>
>> Paulo> Can I use abbrevs for this?
>>
>> Possibly, but take a look at Tuareg, a mode for editing Ocaml.
>> They do replace keyword with unicode symbols, but they offer the
>> capability of rather seamlessly editing the original keyword.
Paulo> This is the kind of thing Tom mentioned, right?
Yes, although I'm not familiar with the Haskell mode implementation. You
know have two modes to get "inspiration" from. I'd really follow this
route rather than inserting unicode into the source code: some users may
use non-unicode aware editors, at times you may want to use Unix
commands (grep, sed, awk) that may not know of unicode, etc...
Cheers,
Maurizio
--
Paulo Jorge Matos - pocmatos at gmail.com
Paulo> http://www.pmatos.net
--
Maurizio Vitale
Polymath Solutions
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Are abbrevs for this?
[not found] ` <mailman.451.1244720587.2239.help-gnu-emacs@gnu.org>
2009-06-11 11:55 ` TomSW
@ 2009-06-13 8:14 ` harven
1 sibling, 0 replies; 9+ messages in thread
From: harven @ 2009-06-13 8:14 UTC (permalink / raw
To: help-gnu-emacs
"Paulo J. Matos" <pocmatos@gmail.com> writes:
> On Thu, Jun 11, 2009 at 8:53 AM, TomSW<tom.weissmann@gmail.com> wrote:
>> On Jun 11, 1:53 am, Xah Lee <xah...@gmail.com> wrote:
>>> 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.
>>
>> If the scheme modes are anything like pretty-haskell, they don't
>> actually convert the text, they use font-lock to disguise "lambda" as
>> the greek letter - the source code itself doesn't change.
>>
>
> That's the approach I need...
Here is the code
;; real lisp hackers use the lambda character
;; courtesy of stefan monnier on c.l.l
(defun sm-lambda-mode-hook ()
(font-lock-add-keywords
nil `(("\\<lambda\\>"
(0 (progn (compose-region (match-beginning 0) (match-end 0)
,(make-char 'greek-iso8859-7 107))
nil))))))
(add-hook 'emacs-lisp-mode-hook 'sm-lambda-mode-hook)
(add-hook 'lisp-interactive-mode-hook 'sm-lamba-mode-hook)
(add-hook 'scheme-mode-hook 'sm-lambda-mode-hook)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-06-13 8:14 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.368.1244642017.2239.help-gnu-emacs@gnu.org>
2009-06-10 23:53 ` Are abbrevs for this? Xah Lee
2009-06-11 7:53 ` 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
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.