Gnus development mailing list
 help / color / mirror / Atom feed
From: Simon Josefsson <jas@extundo.com>
Cc: bugs@gnus.org (The Gnus Bugfixing Girls + Boys), ding@gnus.org
Subject: Re: Two gnus-posting-styles problems
Date: Mon, 03 Jun 2002 19:40:10 +0200	[thread overview]
Message-ID: <ilu1ybo8dmt.fsf@latte.josefsson.org> (raw)
In-Reply-To: <sxs4rgk9zto.fsf@florida.munich.redhat.com> (Hrvoje Niksic's message of "Mon, 03 Jun 2002 16:55:31 +0200")

Hrvoje Niksic <hniksic@xemacs.org> 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))




  parent reply	other threads:[~2002-06-03 17:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-03 14:55 Hrvoje Niksic
2002-06-03 15:04 ` Paul Jarc
2002-06-03 15:36 ` David S Goldberg
2002-06-03 17:40 ` Simon Josefsson [this message]
2002-06-03 17:49   ` Hrvoje Niksic
2002-06-03 18:23     ` Simon Josefsson
2002-06-03 19:48       ` Kai Großjohann
2002-06-04 13:48       ` Hrvoje Niksic
2002-06-04 16:07         ` Simon Josefsson
2002-06-03 19:45 ` Kai Großjohann

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=ilu1ybo8dmt.fsf@latte.josefsson.org \
    --to=jas@extundo.com \
    --cc=bugs@gnus.org \
    --cc=ding@gnus.org \
    /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).