Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: floyd@barrow.com (Floyd L. Davidson)
Subject: Re: dealing with windows \222 char
Date: Sat, 06 Mar 2004 12:38:22 -0900	[thread overview]
Message-ID: <87u111irld.fld@barrow.com> (raw)
In-Reply-To: <vita-brevis-breviter-in-brevi-finietur-mors-venit-velociter-quae-neminem-veretur-87smglpuiq.fsf@gothgoose.net>

Marcus Frings <iam-est-hora-surgere@despammed.com> wrote:
>* Arnaud Vandyck <avdyk@debian.org> wrote:
>
>> Cookie is a great solution and it works really fine...
>
>Ah, great!
>
>> I suppose I have to use something like:
>> (load-file "~/.gnus_dumbquotes.el")
>
>Exactly! That's the way how I do it.

I have two functions in my init files for GNU Emacs and XEmacs,
which affect the same problem.  By putting them in the init
files I have the functionality available when not running Gnus,
as I occasionally find odd extended ascii characters when doing
regular editing.

One function changes the way the characters are displayed
on the screen.  The other function modifies the current
buffer, making the changes permanent.

I've added these to menubar menus, because I don't use them
often enough to remember a key sequence.  However, in my ~/.gnus
file I do add the fld-fix-buffer function to the
message-send-news-hook, so that every article I post to Usenet
is "fixed" before being posted.  That changes any of the
specified characters in any quoted text, and it also does
untabify on the entire buffer and deletes all trailing white
space.  There is also a variable to toggle it on or off, and I
have a menubar menu item that does that in case I want to post
an article that has not been adjusted.

;;;
;;;  Display various extended ascii characters
;;;
(defvar bdt (make-display-table))

(defun fld-buffer-display-table ()
  "Change current-display-table to print various high bit
  extended ASCII characters  as regular ascii
  characters or string.

   \\200 --> EUR    \\214 --> OE    \\227 --> ---
   \\202 --> ,      \\221 --> \`    \\226 --> --
   \\203 --> f      \\222 --> \'    \\230 --> ~
   \\204 --> ,,     \\223 --> \"    \\231 --> (TM)
   \\205 --> ...    \\224 --> \"    \\233 --> >
   \\213 --> <      \\225 --> *     \\234 --> oe"

  (interactive)
  (setq bdt (make-display-table))
  (aset bdt ?\200 [?E ?U ?R])           ;\200 = EUR
  (aset bdt ?\202 [?,])                 ;\202 = ,
  (aset bdt ?\203 [?f])                 ;\203 = f
  (aset bdt ?\204 [?, ?,])              ;\204 = ,,
  (aset bdt ?\205 [?. ?. ?.])           ;\205 = ...
  (aset bdt ?\213 [?<])                 ;\213 = <
  (aset bdt ?\214 [?O ?E])              ;\214 = OE
  (aset bdt ?\221 [?`])                 ;\221 = `
  (aset bdt ?\222 [?'])                 ;\222 = '
  (aset bdt ?\223 [?\"])                ;\223 = "
  (aset bdt ?\224 [?\"])                ;\224 = "
  (aset bdt ?\225 [?*])                 ;\225 = *
  (aset bdt ?\226 [?- ?-])              ;\226 = --
  (aset bdt ?\227 [?- ?- ?-])           ;\227 = ---
  (aset bdt ?\230 [?~])                 ;\230 = ~
  (aset bdt ?\231 [?( ?T ?m ?)])        ;\231 = (Tm)
  (aset bdt ?\233 [?>])                 ;\233 = >
  (aset bdt ?\234 [?o ?e])              ;\230 = oe

  (eval-when-compile
    (when (not (featurep 'xemacs)) (defun set-specifier (d1 d2) ())))
  (when (featurep 'xemacs)
    (set-specifier current-display-table bdt))
  (setq buffer-display-table current-display-table))


;;;
;;; Untabify and replace various Extended ASCII characters
;;;
(defvar fld-fix-buffer-status t)
(defun fld-fix-buffer ()
 "Fix a buffer:  Trim trailing whitespace, replace tabs with
  spaces and change various high bit set Extended ASCII
  characters to seven-bit ASCII equivalents.  Disabled when
  fld-fix-buffer-status is nil.  Character replacements are:

   \\200 --> EUR    \\214 --> OE    \\227 --> ---
   \\202 --> ,      \\221 --> \`    \\226 --> --
   \\203 --> f      \\222 --> \'    \\230 --> ~
   \\204 --> ,,     \\223 --> \"    \\231 --> (TM)
   \\205 --> ...    \\224 --> \"    \\233 --> >
   \\213 --> <      \\225 --> *     \\234 --> oe"

  (interactive)
  (if fld-fix-buffer-status
      (save-excursion
        (goto-char (point-min))
        (replace-regexp "\\([\t ]\\)*$" "")       ; trim trailing whitespace
        (mark-whole-buffer)
        (untabify (point) (mark))                 ; untabify
        ;; replace various Extended ASCII characters
        (goto-char (point-min))
        (replace-string "\234" "oe")
        (goto-char (point-min))
        (replace-string "\233" ">")
        (goto-char (point-min))
        (replace-string "\231" "(Tm)")
        (goto-char (point-min))
        (replace-string "\230" "~")
        (goto-char (point-min))
        (replace-string "\227" "---")
        (goto-char (point-min))
        (replace-string "\226" "--")
        (goto-char (point-min))
        (replace-string "\225" "*")
        (goto-char (point-min))
        (replace-string "\224" "\"")
        (goto-char (point-min))
        (replace-string "\223" "\"")
        (goto-char (point-min))
        (replace-string "\222" "\'")
        (goto-char (point-min))
        (replace-string "\221" "\`")
        (goto-char (point-min))
        (replace-string "\214" "OE")
        (goto-char (point-min))
        (replace-string "\213" "<")
        (goto-char (point-min))
        (replace-string "\205" "...")
        (goto-char (point-min))
        (replace-string "\204" ",,")
        (goto-char (point-min))
        (replace-string "\203" "f")
        (goto-char (point-min))
        (replace-string "\202" ",")
        (goto-char (point-min))
        (replace-string "\200" "EUR")
        (goto-char (point-min))
        (replace-string "\r\n" "\n")
        (set-mark nil)
        (when (featurep 'xemacs)
          (zmacs-deactivate-region))  ; clears highlighted region
        (message "Buffer fixed..."))))

--
Floyd L. Davidson           <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska)                         floyd@barrow.com


      reply	other threads:[~2004-03-06 21:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87znaunir7.fsf@oz.fapse.ulg.ac.be>
2004-03-06 14:59 ` Erwan David
     [not found] ` <vita-brevis-breviter-in-brevi-finietur-mors-venit-velociter-quae-neminem-veretur-87r7w6ui5k.fsf@gothgoose.net>
     [not found]   ` <87smgmyn0v.fsf@oz.fapse.ulg.ac.be>
     [not found]     ` <vita-brevis-breviter-in-brevi-finietur-mors-venit-velociter-quae-neminem-veretur-87brn9x6rl.fsf@gothgoose.net>
     [not found]       ` <87k71x6ew6.fsf@oz.fapse.ulg.ac.be>
2004-03-06 20:53         ` Marcus Frings
2004-03-06 21:38           ` Floyd L. Davidson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87u111irld.fld@barrow.com \
    --to=floyd@barrow.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).