New command to ASCII-fy the article buffer, based on org-entities.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Tue, 9 Nov 2010 18:45:25 +0000 (19:45 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Tue, 9 Nov 2010 18:45:25 +0000 (19:45 +0100)
lisp/ChangeLog
lisp/dgnushack.el
lisp/gnus-art.el
lisp/gnus-sum.el
lisp/shr.el
texi/ChangeLog
texi/gnus.texi

index 36b7fdd..d54da0d 100644 (file)
@@ -1,5 +1,9 @@
 2010-11-09  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * shr.el (browse-url-mailto): Autoload.
+
+       * gnus-art.el (article-treat-non-ascii): New command and keystroke.
+
        * message.el (message-subject-trailing-was-ask-regexp): A ] in a []
        regexp doesn't need quoting.
 
index 384db33..a7f804a 100644 (file)
@@ -35,6 +35,9 @@
 (require 'cl)
 (require 'iswitchb)
 
+(ignore-errors
+  (require 'org-entities))
+
 (defvar srcdir (or (getenv "srcdir") "."))
 (defvar loaddir (and load-file-name (file-name-directory load-file-name)))
 
index 97e8ccc..0e354dc 100644 (file)
@@ -2114,6 +2114,27 @@ try this wash."
   (interactive)
   (article-translate-strings gnus-article-dumbquotes-map))
 
+(defun article-treat-non-ascii ()
+  "Translate many Unicode characters into their ASCII equivalents."
+  (interactive)
+  (require 'org-entities)
+  (let ((table (make-char-table nil)))
+    (dolist (elem org-entities)
+      (when (and (listp elem)
+                (= (length (nth 6 elem)) 1))
+       (set-char-table-range table
+                             (aref (nth 6 elem) 0)
+                             (nth 4 elem))))
+    (save-excursion
+      (when (article-goto-body)
+       (let ((inhibit-read-only t)
+             replace)
+         (while (not (eobp))
+           (if (not (setq replace (aref table (following-char))))
+               (forward-char 1)
+             (delete-char 1)
+             (insert replace))))))))
+
 (defun article-translate-characters (from to)
   "Translate all characters in the body of the article according to FROM and TO.
 FROM is a string of characters to translate from; to is a string of
@@ -4248,6 +4269,7 @@ If variable `gnus-use-long-file-name' is non-nil, it is
      article-date-lapsed
      article-emphasize
      article-treat-dumbquotes
+     article-treat-non-ascii
      article-normalize-headers
      ;;(article-show-all . gnus-article-show-all-headers)
      )))
index ad2f5b6..9715510 100644 (file)
@@ -2096,6 +2096,7 @@ increase the score of each group you read."
   "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
   "p" gnus-article-verify-x-pgp-sig
   "d" gnus-article-treat-dumbquotes
+  "U" gnus-article-treat-non-ascii
   "i" gnus-summary-idna-message)
 
 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
@@ -2420,6 +2421,7 @@ gnus-summary-show-article-from-menu-as-charset-%s" cs))))
                gnus-article-remove-leading-whitespace t])
              ["Overstrike" gnus-article-treat-overstrike t]
              ["Dumb quotes" gnus-article-treat-dumbquotes t]
+             ["Non-ASCII" gnus-article-treat-non-ascii t]
              ["Emphasis" gnus-article-emphasize t]
              ["Word wrap" gnus-article-fill-cited-article t]
              ["Fill long lines" gnus-article-fill-long-lines t]
index a567f20..e0ea76c 100644 (file)
@@ -418,6 +418,7 @@ redirects somewhere else."
 ;; url-cache-extract autoloads url-cache.
 (declare-function url-cache-create-filename "url-cache" (url))
 (autoload 'mm-disable-multibyte "mm-util")
+(autoload 'browse-url-mailto "browse-url")
 
 (defun shr-get-image-data (url)
   "Get image data for URL.
index 2fbc40a..a1ea6e6 100644 (file)
@@ -1,3 +1,7 @@
+2010-11-09  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * gnus.texi (Article Washing): Document gnus-article-treat-non-ascii.
+
 2010-11-04  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus.texi (Customizing the IMAP Connection): Remove nnir mention,
index 83a8d82..198cdcf 100644 (file)
@@ -9664,6 +9664,17 @@ an attempt to provide more quoting characters.  If you see something
 like @code{\222} or @code{\264} where you're expecting some kind of
 apostrophe or quotation mark, then try this wash.
 
+@item W A
+@kindex W A (Summary)
+@findex gnus-article-treat-non-ascii
+@cindex Unicode
+@cindex Non-@acronym{ASCII}
+Translate many non-@acronym{ASCII} characters into their
+@acronym{ASCII} equivalents (@code{gnus-article-treat-non-ascii}).
+This is mostly useful if you're on a terminal that has a limited font
+and does't show accented characters, ``advanced'' punctuation, and the
+like.  For instance, @samp{ยป} is tranlated into @samp{>>}, and so on.
+
 @item W Y f
 @kindex W Y f (Summary)
 @findex gnus-article-outlook-deuglify-article