* [patch] Caesar rotation using translate-region
@ 1999-12-06 14:26 Hrvoje Niksic
0 siblings, 0 replies; only message in thread
From: Hrvoje Niksic @ 1999-12-06 14:26 UTC (permalink / raw)
I noticed that message.el avoids using translate-region for rotating,
in order to preserve text properties. However, my tests show that, at
least under XEmacs, translate-region preserves the properties. And
judging by the source, it seems to me that it should preserve them
under FSF Emacs at least as well as the hand-crafted version does.
Doing it with translate-region is much, much, and visibly faster.
Especially for larger regions.
So here is a patch:
1999-12-06 Hrvoje Niksic <hniksic@iskon.hr>
* message.el (message-caesar-region): Use translate-region.
--- lisp/message.el.orig Mon Dec 6 15:21:48 1999
+++ lisp/message.el Mon Dec 6 15:21:49 1999
@@ -1707,14 +1707,7 @@
(/= (aref message-caesar-translation-table ?a) (+ ?a n)))
(setq message-caesar-translation-table
(message-make-caesar-translation-table n)))
- ;; Then we translate the region. Do it this way to retain
- ;; text properties.
- (while (< b e)
- (when (< (char-after b) 255)
- (subst-char-in-region
- b (1+ b) (char-after b)
- (aref message-caesar-translation-table (char-after b))))
- (incf b))))
+ (translate-region b e message-caesar-translation-table)))
(defun message-make-caesar-translation-table (n)
"Create a rot table with offset N."
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-12-06 14:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-06 14:26 [patch] Caesar rotation using translate-region Hrvoje Niksic
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 NNTP newsgroup(s).