From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/36152 Path: main.gmane.org!not-for-mail From: Russ Allbery Newsgroups: gmane.emacs.gnus.general Subject: Re: supercite and special characters Date: 08 May 2001 13:06:07 -0700 Organization: The Eyrie Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035171786 7054 80.91.224.250 (21 Oct 2002 03:43:06 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 03:43:06 +0000 (UTC) Return-Path: Original-Received: (qmail 29083 invoked by alias); 8 May 2001 20:06:15 -0000 Original-Received: (qmail 29078 invoked from network); 8 May 2001 20:06:15 -0000 Original-Received: from windlord.stanford.edu (171.64.13.23) by gnus.org with SMTP; 8 May 2001 20:06:15 -0000 Original-Received: (qmail 27933 invoked by uid 50); 8 May 2001 20:06:08 -0000 Original-To: ding@gnus.org In-Reply-To: Jochen Lillich's message of "08 May 2001 20:57:57 +0200" User-Agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands) Original-Lines: 137 Xref: main.gmane.org gmane.emacs.gnus.general:36152 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:36152 Jochen Lillich 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 ;; 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)