* Can emacs be used to develop an editor for special characters ?
@ 2005-09-10 1:00 Chandan Talukdar
0 siblings, 0 replies; 2+ messages in thread
From: Chandan Talukdar @ 2005-09-10 1:00 UTC (permalink / raw)
[-- Attachment #1.1: Type: text/plain, Size: 312 bytes --]
Hello,
I need to develop an editor for some special characters, which are are used
in a field of medicine. Some of these characters have no digital equivalents
i.e they are not part of any existing character sets. Can emacs be used for
this purpose ? If so, how do I go about it.
Thanks,
--Chandan
[-- Attachment #1.2: Type: text/html, Size: 333 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Can emacs be used to develop an editor for special characters ?
[not found] <mailman.6438.1126314171.20277.help-gnu-emacs@gnu.org>
@ 2005-09-10 1:51 ` Pascal Bourguignon
0 siblings, 0 replies; 2+ messages in thread
From: Pascal Bourguignon @ 2005-09-10 1:51 UTC (permalink / raw)
Chandan Talukdar <c.discussions@gmail.com> writes:
> I need to develop an editor for some special characters, which are are
> used in a field of medicine. Some of these characters have no digital
> equivalents i.e they are not part of any existing character sets. Can
> emacs be used for this purpose ? If so, how do I go about it.
> Thanks,
Yes.
You can overlay a region with a bitmap, in effect you can display any
kind of glyphs.
Here is what I used in emacs 21.3 to display a left arrow instead of '_'.
(Unfortunately it doesn't seem to work anymore in emacs 22).
(defvar lse-assign-image
(find-image
(list
(list :type 'xbm
:width 7
:height 12
:ascent 91
:background nil
:foreground nil
:data
(loop
with lines = (mapcar
(lambda (line)
(loop
with vec = (make-bool-vector (length line) nil)
for bit in (mapcar
(lambda (char) (STRING/= char "."))
(split-string line ""))
for i from 0 below (length vec)
do (setf (aref vec i) bit)
finally (return vec)))
(split-string ".......\n.......\n.......\n..**...\n.**....\n******.\n.**....\n..**...\n.......\n.......\n.......\n.......\n"))
with pic = (make-vector (length lines) nil)
for line in lines
for i from 0
do (setf (aref pic i) line)
finally (return pic)))))
"A left arrow glyph.")
(defun lse-underline-to-assign ()
(interactive)
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(while (search-forward "_" nil t)
(delete-region (match-beginning 0) (match-end 0))
(insert-image lse-assign-image "_")))))
(defun lse-put-image (image pos &optional string area)
"Put image IMAGE in front of POS in the current buffer.
IMAGE must be an image created with `create-image' or `defimage'.
IMAGE is displayed by putting an overlay into the current buffer with a
`before-string' STRING that has a `display' property whose value is the
image. STRING is defaulted if you omit it.
POS may be an integer or marker.
AREA is where to display the image. AREA nil or omitted means
display it in the text area, a value of `left-margin' means
display it in the left marginal area, a value of `right-margin'
means display it in the right marginal area."
(unless string (setq string "x"))
(let ((buffer (current-buffer)))
(unless (eq (car-safe image) 'image)
(error "Not an image: %s" image))
(unless (or (null area) (memq area '(left-margin right-margin)))
(error "Invalid area %s" area))
(let (overlay
(curpos (point))
(prop (if (null area) image (list (list 'margin area) image))))
(setq string (copy-seq string))
(put-text-property 0 (length string) 'display prop string)
(insert string)
(setq overlay (make-overlay curpos (point) buffer))
(overlay-put overlay 'put-image t)
(overlay-put overlay 'evaporate t)
(overlay-put overlay 'intangible nil)
)))
(defun lse-assign ()
"Insert an assign operator (the ASCII code of the underline)
but adding an overlay on it with the `lse-assign-image' (a left arrow)."
(interactive)
(lse-put-image lse-assign-image (point) "_"))
(local-set-key (kbd "_") (function lse-assign))
Internally, AFAIK emacs still doesn't use unicode. I don't know if
you'll be able to use private unicode codepoints to represent these
character. Another possibility is to use some kind of "entity" in the
file and buffer and display an overlay on them. You could use
something like HTML entities: &cubitus; and the font-locking to
substitute the overlays. Here is what I do to display greek letters
instead of their names in my sources. When I write beta it shows as
the greek letter beta. Instead of compose-region you could put an
image.
(defvar *letter-regexp-format* "[^A-Za-z0-9]\\(%s\\)[^A-Za-z0-9]")
(defconst +greek-letters+
'( "alpha" "beta" "gamma" "delta" "epsilon" "zeta" "eta"
"theta" "iota" "kappa" "lambda" "mu" "nu" "xi" "omicron" "pi"
"rho" "terminalsigma" "sigma" "tau"
"upsilon" "phi" "chi" "psi" "omega" )
"The order of these strings is fixed by the encoding of greek-iso8859-7!")
(defun greek-letter-font-lock ()
"
RETURN: A font-lock-keywords list mapping greek letter names
to greek characters.
"
(when (<= 21 emacs-major-version)
(let ((maj 64) (min 96))
(mapcan
(lambda (letter)
(incf maj) (incf min)
`(
(,(format *letter-regexp-format* (upcase letter))
(1 (progn (compose-region (match-beginning 1) (match-end 1)
,(make-char 'greek-iso8859-7 maj)
'decompose-region)
nil)))
(,(format *letter-regexp-format* (downcase letter))
(1 (progn (compose-region (match-beginning 1) (match-end 1)
,(make-char 'greek-iso8859-7 min)
'decompose-region)
nil)))))
+greek-letters+))))
Note that if your medical characters can actually be built as a
composition of existing character you can use compose-region to
compose them.
--
__Pascal Bourguignon__ http://www.informatimago.com/
Small brave carnivores
Kill pine cones and mosquitoes
Fear vacuum cleaner
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-09-10 1:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.6438.1126314171.20277.help-gnu-emacs@gnu.org>
2005-09-10 1:51 ` Can emacs be used to develop an editor for special characters ? Pascal Bourguignon
2005-09-10 1:00 Chandan Talukdar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).