Gnus development mailing list
 help / color / mirror / Atom feed
* supercite and special characters
@ 2001-05-08 18:57 Jochen Lillich
  2001-05-08 20:06 ` Russ Allbery
  0 siblings, 1 reply; 2+ messages in thread
From: Jochen Lillich @ 2001-05-08 18:57 UTC (permalink / raw)


Hi,

if the author name in the From: header contains special characters
like German umlauts, supercite screws up the name. Can I do something
about that?

Thanks,

	Jochen


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: supercite and special characters
  2001-05-08 18:57 supercite and special characters Jochen Lillich
@ 2001-05-08 20:06 ` Russ Allbery
  0 siblings, 0 replies; 2+ messages in thread
From: Russ Allbery @ 2001-05-08 20:06 UTC (permalink / raw)


Jochen Lillich <jl@teamlinux.de> writes:

> if the author name in the From: header contains special characters like
> German umlauts, supercite screws up the name. Can I do something about
> that?

I've been using the following for a long time:

;; rra-sc.el -- Supercite initialization file.
;; $Id: rra-sc.el,v 1.2 2001/03/12 00:43:25 eagle Exp $
;;
;; Written by Russ Allbery <rra@stanford.edu>
;; This work is hereby placed in the public domain by its author.
;;
;; This is intended for loading from sc-load-hook and resets a bunch of
;; Supercite default settings so that it behaves like a normal citation engine
;; and never attempts to do its own weird quoting.

;; Recognize either : or > as a citation delimiter.
(setq sc-citation-delimiter-regexp "[:>]+")
(setq sc-citation-separator-regexp "[ 	]?")

;; Ensure that we don't recognize words as part of a citation.  Yes, this
;; means that my Supercite configuration actually does not recognize standard
;; Supercite citing.  This is a feature.  Standard Supercite citing is really
;; broken.
(setq sc-citation-root-regexp "~~~")
(setq sc-citation-nonnested-root-regexp "~~~")

;; When I cite messages, I want to nest citations rather than doing that
;; broken Supercite cruft with people's names.
(setq sc-nested-citation-p t)

;; Just insert a "> ".  Nothing else.
(setq sc-citation-leader "")
(setq sc-reference-tag-string "")

;; Don't ask me about attribution strings.
(setq sc-confirm-always-p nil)

;; Do not try to adjust the whitespace or wrapping of cited text.  I'll do
;; that myself.
(setq sc-auto-fill-region-p nil)
(setq sc-fixup-whitespace-p nil)

;; Override sc-get-address with something that's less picky about what it's
;; willing to consider an address (supercite's default truncates the address
;; at the first odd-looking character).
(defun sc-get-address (from author)
  "Get the full email address path from FROM.
AUTHOR is the author's name (which is removed from the address)."
  (let ((eos (length from)))
    (if (string-match (concat "\\(^\\|^\"\\)" (regexp-quote author)
                              "\\(\\s +\\|\"\\s +\\)") from 0)
        (let ((address (substring from (match-end 0) eos)))
          (if (and (= (aref address 0) ?<)
                   (= (aref address (1- (length address))) ?>))
              (substring address 1 (1- (length address)))
            address))
      (if (string-match
           "[      ]*<?\\([^       (>]+@[^ 	(>]+\\)" from 0)
          (sc-submatch 1 from)
        ""))))

;; Override sc-attribs-extract-namestring so that it will correctly cope with
;; From headers that contain no address (which is becoming more common with
;; munging, even if it's technically illegal).
(defun sc-attribs-extract-namestring (from)
  "Extract the name string from FROM.
This should be the author's full name minus an optional title."
  (let ((namestring
         (or
          ;; If there is a <...> in the name, treat everything before that as
          ;; the full name.  Even if it contains parens, use the whole thing.
          ;; On the other hand, we do look for quotes in the usual way.
          (and (string-match " *<.*>" from 0)
               (let ((before-angles
                      (sc-name-substring from 0 (match-beginning 0) 0)))
                 (if (string-match "\".*\"" before-angles 0)
                     (sc-name-substring
                      before-angles (match-beginning 0) (match-end 0) 1)
                   before-angles)))
          (sc-name-substring
           from (string-match "(.*)" from 0) (match-end 0) 1)
          (sc-name-substring
           from (string-match "\".*\"" from 0) (match-end 0) 1)
          (sc-name-substring
           from (string-match "\\([-.a-zA-Z0-9_]+\\s *\\)+" from 0)
           (match-end 0) 0)
          (sc-attribs-emailname from))))
    ;; Strip off any leading or trailing whitespace.
    (if namestring
        (let ((bos 0)
              (eos (1- (length namestring))))
          (while (and (<= bos eos)
                      (memq (aref namestring bos) '(32 ?\t)))
            (setq bos (1+ bos)))
          (while (and (> eos bos)
                      (memq (aref namestring eos) '(32 ?\t)))
            (setq eos (1- eos)))
          (substring namestring bos (1+ eos))))))

;; Build my attribution line.  Pull the author out of Supercite's parse of the
;; mail headers, and put their address in <>s.  Make sure that the "name"
;; doesn't end in whitespace (thus making for odd double whitespace in the
;; attribution).  Also insert the name of the newsgroup where I was reading
;; the message unless I was reading it in a strange group.
(defun rra-sc-header ()
  "Attribution header code for Supercite."
  (let ((author (let ((testauthor (sc-mail-field "sc-author")))
                  (if (string= " " (substring testauthor -1 nil))
                      (substring testauthor 0 -1)
                    testauthor)))
        (address (or (sc-mail-field "sc-from-address")
                     (sc-mail-field "sc-reply-address")
                     "")))
    (insert sc-reference-tag-string
            (if (not (or (string-match "^nnml:" gnus-newsgroup-name)
                         (string-match "^nntp\+" gnus-newsgroup-name)
                         (string= gnus-newsgroup-name
                                  (sc-mail-field "newsgroups"))))
                (concat "In " gnus-newsgroup-name ", ")
              "")
            (if (> (length author) 0)
                (concat author
                        (if (> (length address) 0)
                            (concat " <" address ">")
                          ""))
              (if (> (length address) 0) address "someone"))
            " writes:\n")))

;; Set this as the attribution writer.
(setq sc-rewrite-header-list (list '(rra-sc-header)))
(setq sc-preferred-header-style 0)

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-05-08 20:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-08 18:57 supercite and special characters Jochen Lillich
2001-05-08 20:06 ` Russ Allbery

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).