From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/45079 Path: main.gmane.org!not-for-mail From: Simon Josefsson Newsgroups: gmane.emacs.gnus.general Subject: Re: Two gnus-posting-styles problems Date: Mon, 03 Jun 2002 19:40:10 +0200 Sender: owner-ding@hpc.uh.edu Message-ID: References: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1023126278 7001 127.0.0.1 (3 Jun 2002 17:44:38 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 3 Jun 2002 17:44:38 +0000 (UTC) Cc: bugs@gnus.org (The Gnus Bugfixing Girls + Boys), ding@gnus.org Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17Evsk-0001oo-00 for ; Mon, 03 Jun 2002 19:44:38 +0200 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 17Evop-000733-00; Mon, 03 Jun 2002 12:40:35 -0500 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Mon, 03 Jun 2002 12:40:52 -0500 (CDT) Original-Received: from sclp3.sclp.com (qmailr@sclp3.sclp.com [209.196.61.66]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id MAA29620 for ; Mon, 3 Jun 2002 12:40:39 -0500 (CDT) Original-Received: (qmail 14662 invoked by alias); 3 Jun 2002 17:40:17 -0000 Original-Received: (qmail 14652 invoked from network); 3 Jun 2002 17:40:16 -0000 Original-Received: from 178.230.13.217.in-addr.dgcsystems.net (HELO yxa.extundo.com) (217.13.230.178) by gnus.org with SMTP; 3 Jun 2002 17:40:16 -0000 Original-Received: from latte.josefsson.org (yxa.extundo.com [217.13.230.178]) (authenticated bits=0) by yxa.extundo.com (8.12.3/8.12.3) with ESMTP id g53HeEWa010344; Mon, 3 Jun 2002 19:40:14 +0200 Original-To: Hrvoje Niksic Mail-Copies-To: nobody In-Reply-To: (Hrvoje Niksic's message of "Mon, 03 Jun 2002 16:55:31 +0200") Original-Lines: 135 User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2.90 (i686-pc-linux-gnu) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:45079 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:45079 Hrvoje Niksic writes: > 1. It's unclear exactly what a HEADER match in fact matches. First I > thought it matches the header in the message buffer. I thought > this would work: > > ;; Use Red Hat address when responding to Red Hat people. > ((header "to" "redhat.com") > (address "hniksic@redhat.com")) > > But it doesn't, because it matches the "gnus article copy" buffer. Yes -- the "header" posting style uses to the last viewed message, I think this is documented, altough perhaps not well enough. Perhaps ((header "from" "redhat.com") (address "hniksic@redhat.com")) is useful? > 1a. Even worse, it uses the "gnus article copy" buffer even when it is > completely unrelated to the message currently being composed. For > example, I pressed `a' or `m' in the Summary buffer and was trying > to figure out why the hell it thought that the Red Hat address > should be used. It turned out that my old "gnus article copy" > buffer happened addressed to a Red Hat person. I agree it is confusing. Does the patch below help? > 2. I tried to fix #1 by explicitly matching the stuff from the Message > buffer, like this: > > ((and (message-fetch-field "to") > (string-match "redhat\\.com" (message-fetch-field "to"))) > (address "hniksic@redhat.com")) > > But that didn't work because `gnus-configure-posting-styles' is > called from `message-mode-hook', which gets run when the Message > buffer is still completely empty. It should be called at a later > stage, when the buffer has already been set up. There's a dependency problem here, not all functions that use information from the message buffer and modify the contents of the message buffer can be called last. I think the ordering has changed several times, but it won't ever satisfy everyone. I think the approach should be that you shouldn't count on information being available in the message buffers unless... err, it is available. Index: gnus-msg.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus-msg.el,v retrieving revision 6.92 diff -u -p -u -w -r6.92 gnus-msg.el --- gnus-msg.el 2002/05/30 10:19:30 6.92 +++ gnus-msg.el 2002/06/03 17:55:48 @@ -242,9 +242,15 @@ See also the `mml-default-encrypt-method (defcustom gnus-confirm-mail-reply-to-news nil "If non-nil, Gnus requests confirmation when replying to news. This is done because new users often reply by mistake when reading -news." +news. +This can also be a function which should return non-nil iff a +confirmation is needed, or a regexp, in which case a confirmation is +asked if the group name matches the regexp." :group 'gnus-message - :type 'boolean) + :type '(choice (const :tag "No" nil) + (const :tag "Yes" nil) + (regexp :tag "Iff group matches regexp") + (function :tag "Iff function evaluates to non-nil"))) ;;; Internal variables. @@ -490,6 +496,8 @@ If ARG is 1, prompt for a group name to ;; We can't `let' gnus-newsgroup-name here, since that leads ;; to local variables leaking. (let ((group gnus-newsgroup-name) + ;; make sure last viewed article doesn't affect posting styles: + (gnus-article-copy) (buffer (current-buffer))) (unwind-protect (progn @@ -519,6 +527,8 @@ network. The corresponding backend must ;; We can't `let' gnus-newsgroup-name here, since that leads ;; to local variables leaking. (let ((group gnus-newsgroup-name) + ;; make sure last viewed article doesn't affect posting styles: + (gnus-article-copy) (buffer (current-buffer))) (unwind-protect (progn @@ -550,7 +560,9 @@ a news." (completing-read "Newsgroup: " gnus-active-hashtb nil (gnus-read-active-file-p)) (gnus-group-group-name)) - ""))) + "")) + ;; make sure last viewed article doesn't affect posting styles: + (gnus-article-copy)) (gnus-post-news 'post gnus-newsgroup-name))) (defun gnus-summary-mail-other-window (&optional arg) @@ -562,6 +574,8 @@ posting style." ;; We can't `let' gnus-newsgroup-name here, since that leads ;; to local variables leaking. (let ((group gnus-newsgroup-name) + ;; make sure last viewed article doesn't affect posting styles: + (gnus-article-copy) (buffer (current-buffer))) (unwind-protect (progn @@ -591,6 +605,8 @@ network. The corresponding backend must ;; We can't `let' gnus-newsgroup-name here, since that leads ;; to local variables leaking. (let ((group gnus-newsgroup-name) + ;; make sure last viewed article doesn't affect posting styles: + (gnus-article-copy) (buffer (current-buffer))) (unwind-protect (progn @@ -991,7 +1007,11 @@ If VERY-WIDE, make a very wide reply." ;; Allow user to require confirmation before replying by mail to the ;; author of a news article. (when (or (not (gnus-news-group-p gnus-newsgroup-name)) - (not gnus-confirm-mail-reply-to-news) + (not (cond ((stringp gnus-confirm-mail-reply-to-news) + (string-match gnus-confirm-mail-reply-to-news gnus-newsgroup-name)) + ((functionp gnus-confirm-mail-reply-to-news) + (funcall gnus-confirm-mail-reply-to-news)) + (t gnus-confirm-mail-reply-to-news))) (y-or-n-p "Really reply by mail to article author? ")) (let* ((article (if (listp (car yank))