emacs-devel
[Top][All Lists]
Advanced

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

Using rot13-region in format-alist


From: Juanma Barranquero
Subject: Using rot13-region in format-alist
Date: Thu, 11 Sep 2008 05:04:48 +0200

I have the following patch to make format-alist use rot13-region (from
lisp/rot13.el) instead of the external command "tr" for the ROT13
format. The main reason is that "tr" is not available on Windows
unless the user has installed it from one of the available
Unix-compatibility toolsets.

The only trouble is that rot13-region converts also uppercase letters
(which is IMHO a more common interpretation of how ROT13 works), while
the tr commands used in format-alist do not. That breaks compatibility
with files encoded with the current implementation. OTOH, as case is
preserved, any possible trouble is easily fixed; and it's hard to
imagine anyone using ROT13 to store valuable data anyhow.

So I'd like to go on with the commit.

Comments?

  Juanma



2008-09-11  Juanma Barranquero  <address@hidden>

        * format.el (format-alist): Use `rot13-region' for ROT13 format
        instead of external command "tr".

        * rot13.el (rot13-region): Add dummy arg BUFFER for compatibility
        with `format-alist'.



Index: lisp/format.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/format.el,v
retrieving revision 1.61
diff -u -2 -r1.61 format.el
--- lisp/format.el      6 May 2008 07:57:36 -0000       1.61
+++ lisp/format.el      10 Sep 2008 15:41:32 -0000
@@ -83,5 +83,5 @@
     (rot13 "rot13"
           nil
-          "tr a-mn-z n-za-m" "tr a-mn-z n-za-m" t nil)
+          rot13-region rot13-region t nil)
     (duden "Duden Ersatzdarstellung"
           nil
Index: lisp/rot13.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/rot13.el,v
retrieving revision 1.28
diff -u -2 -r1.28 rot13.el
--- lisp/rot13.el       6 May 2008 07:57:48 -0000       1.28
+++ lisp/rot13.el       10 Sep 2008 15:49:12 -0000
@@ -80,6 +80,7 @@

 ;;;###autoload
-(defun rot13-region (start end)
-  "ROT13 encrypt the region between START and END in current buffer."
+(defun rot13-region (start end &optional buffer)
+  "ROT13 encrypt the region between START and END in current buffer.
+Optional arg BUFFER is ignored (for use in `format-alist')."
   (interactive "r")
   (translate-region start end rot13-translate-table))




reply via email to

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