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: Stephen Berman
Subject: Re: ncr (numeric character reference) to unicode
Date: Thu, 16 Apr 2009 15:23:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux)

On Wed, 15 Apr 2009 20:42:49 -0500 "B. T. Raven" <nihil@nihilo.net> wrote:

> Stephen Berman wrote:
[...]
>> Does this do what you want?
>>
>> (defun reverse-string (beg end)
>>   (interactive "r")
>>   (xhc beg end)
>>   (let* ((beg (region-beginning))
>>       (end (region-end))
>>       (str1 (buffer-substring beg end))
>>       (str2 (apply #'string (nreverse (string-to-list str1)))))
>>     (replace-string str1 str2 nil beg end)))
>>
>> Steve Berman
>>
>>
>>
>
> 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? 

When xhc is called on beg and end (since I mistakenly thought you wanted
to convert the HTML entities and reverse the result in one blow) the
region is changed, so it has to be recalculated for the arguments of
buffer-substring (actually, only region-end changes, so beg really
shouldn't be recalculated).  Of course, new variables could have been
used in the let* clause.

Steve Berman





reply via email to

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