From: Russ Allbery <rra@stanford.edu>
Subject: Re: supercite and special characters
Date: 08 May 2001 13:06:07 -0700 [thread overview]
Message-ID: <ylsnifppw0.fsf@windlord.stanford.edu> (raw)
In-Reply-To: Jochen Lillich's message of "08 May 2001 20:57:57 +0200"
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/>
prev parent reply other threads:[~2001-05-08 20:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-08 18:57 Jochen Lillich
2001-05-08 20:06 ` Russ Allbery [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=ylsnifppw0.fsf@windlord.stanford.edu \
--to=rra@stanford.edu \
/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).