help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ncr (numeric character reference) to unicode


From: Kevin Rodgers
Subject: Re: ncr (numeric character reference) to unicode
Date: Wed, 15 Apr 2009 22:35:03 -0600
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)

B. T. Raven wrote:
That would probably do a little more than I want. Miles' expand html function is only needed if someone sends these ncr sequences in email. Btw, why are beg and end calculated in the function if they are passed to it? This almost does what I want:

(defun reverse-bufsubstring (beg end)
  (interactive "r")
  (let* (
     (str1 (buffer-substring beg end))
     (str2 (apply #'string (nreverse (string-to-list str1)))))
    (replace-string str1 str2 nil beg end)))


except that it converts

same
one
as
before

into this:

erofeb
sa
eno
emas

so now that has to be reversed line by line rather than character by character. Anyway, all of this is just a kludge until the gurus come up with a real bidi functionality.

(defun reverse-region-by-line (beg end)
  (interactive "r")
  (save-excursion
    (goto-char beg)
    (while (and (< (point) end) (re-search-forward "\\=.*$" end t))
      (replace-match (apply #'string
                            (nreverse (string-to-list (match-string 0)))))
      (forward-line))))


--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

[Prev in Thread] Current Thread [Next in Thread]