Gnus development mailing list
 help / color / mirror / Atom feed
* [CHECK IN] posting functions hacking
@ 2001-12-12 16:19 Didier Verna
  2001-12-15 16:15 ` Raymond Scholz
  0 siblings, 1 reply; 2+ messages in thread
From: Didier Verna @ 2001-12-12 16:19 UTC (permalink / raw)


NOTE: This patch has been committed. The version below is
informational only (whitespace differences have been removed).

		Dear folks,

	I've checked in some modifications on the different posting functions
available in the group and summary buffers, following the recent discussion on
that matter. There are also two new functions bound to `i' in these two
buffers, that can be used with mail-post enabled mail backends. The `i'
binding was available in all maps. That's the only reason for this choice. I'm
open to other suggestions.


texi/ChangeLog addition:

2001-12-12  Didier Verna  <didier@lrde.epita.fr>

	* gnus.texi (Misc Group Stuff): advertise `gnus-group-news'.
	* gnus.texi (Summary Mail Commands): advertise
	`gnus-summary-news-other-window'.

lisp/ChangeLog addition:

2001-12-12  Didier Verna  <didier@xemacs.org>

	* gnus-msg.el (gnus-group-news): New function.
	* gnus-group.el (gnus-group-mode-map): bind it to `i'.
	* gnus-group.el (gnus-group-make-menu-bar): add a menu item for it.
	* gnus-salt.el (gnus-carpal-group-buffer-buttons): add a button
	for it.
	* gnus-msg.el (gnus-summary-news-other-window): New function.
	* gnus-msg.el ((gnus-summary-send-map "S" gnus-summary-mode-map)):
	bind it to `i'.
	* gnus-sum.el (gnus-summary-mode-map): bind it to `i'.
	* gnus-sum.el (gnus-summary-make-menu-bar): add a menu item for it.
	* gnus-salt.el (gnus-carpal-summary-buffer-buttons): add a button
	for it (called with a prefix).
	* gnus-msg.el (gnus-configure-posting-styles): add an optional
	group-name argument.
	* gnus-msg.el (gnus-setup-message): use it.


Gnus Patch (runsocks cvs -q diff -u -t -b -B -w lisp/gnus-msg.el lisp/gnus-group.el lisp/gnus-sum.el lisp/gnus-salt.el lisp/gnus.el texi/gnus.texi):

Index: lisp/gnus-msg.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-msg.el,v
retrieving revision 6.60
diff -u -u -t -b -B -w -r6.60 gnus-msg.el
--- lisp/gnus-msg.el	2001/11/27 19:15:09	6.60
+++ lisp/gnus-msg.el	2001/12/12 16:21:26
@@ -217,6 +217,7 @@
 
 (gnus-define-keys (gnus-summary-send-map "S" gnus-summary-mode-map)
   "p" gnus-summary-post-news
+  "i" gnus-summary-news-other-window
   "f" gnus-summary-followup
   "F" gnus-summary-followup-with-original
   "c" gnus-summary-cancel-article
@@ -264,7 +265,16 @@
        (setq mml-buffer-list nil)
        (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc)
        (add-hook 'message-header-setup-hook 'gnus-inews-insert-archive-gcc)
-       (add-hook 'message-mode-hook 'gnus-configure-posting-styles)
+       ;; #### FIXME: for a reason that I did not manage to identify yet,
+       ;; the variable `gnus-newsgroup-name' does not honor a dynamically
+       ;; scoped or setq'ed value from a caller like `C-u gnus-summary-mail'.
+       ;; After evaluation of @forms below, it gets the value we actually want
+       ;; to override, and the posting styles are used. For that reason, I've
+       ;; added an optional argument to `gnus-configure-posting-styles' to
+       ;; make sure that the correct value for the group name is used. -- drv
+       (add-hook 'message-mode-hook
+                 (lambda ()
+                   (gnus-configure-posting-styles ,group)))
        (unwind-protect
            (progn
              ,@forms)
@@ -413,15 +423,47 @@
                                          (gnus-read-active-file-p))
                       (gnus-group-group-name))
                   ""))
+          ;; #### see comment in gnus-setup-message -- drv
           (gnus-setup-message 'message (message-mail)))
       (save-excursion
         (set-buffer buffer)
         (setq gnus-newsgroup-name group)))))
 
+(defun gnus-group-news (&optional arg)
+  "Start composing a news.
+If ARG, post to group under point.
+If ARG is 1, prompt for group name to post to.
+
+This function prepares a news even when using mail groups.  This is useful
+for posting messages to mail groups without actually sending them over the
+network.  The corresponding backend must have a 'request-post method."
+  (interactive "P")
+  ;; We can't `let' gnus-newsgroup-name here, since that leads
+  ;; to local variables leaking.
+  (let ((group gnus-newsgroup-name)
+        (buffer (current-buffer)))
+    (unwind-protect
+        (progn
+          (setq gnus-newsgroup-name
+                (if arg
+                    (if (= 1 (prefix-numeric-value arg))
+                        (completing-read "Use group: "
+                                         gnus-active-hashtb nil
+                                         (gnus-read-active-file-p))
+                      (gnus-group-group-name))
+                  ""))
+          ;; #### see comment in gnus-setup-message -- drv
+          (gnus-setup-message 'message
+            (message-news (gnus-group-real-name gnus-newsgroup-name))))
+      (save-excursion
+        (set-buffer buffer)
+        (setq gnus-newsgroup-name group)))))
+
 (defun gnus-group-post-news (&optional arg)
-  "Start composing a news message.
-If ARG, post to the group under point.
-If ARG is 1, prompt for a group name."
+  "Start composing a message (a news by default).
+If ARG, post to group under point.  If ARG is 1, prompt for group name.
+Depending on the selected group, the message might be either a mail or
+a news."
   (interactive "P")
   ;; Bind this variable here to make message mode hooks work ok.
   (let ((gnus-newsgroup-name
@@ -433,11 +475,79 @@
            "")))
     (gnus-post-news 'post gnus-newsgroup-name)))
 
-(defun gnus-summary-post-news ()
-  "Start composing a news message."
-  (interactive)
-  (gnus-post-news 'post gnus-newsgroup-name))
+(defun gnus-summary-mail-other-window (&optional arg)
+  "Start composing a mail in another window.
+Use the posting of the current group by default.
+If ARG, don't do that.  If ARG is 1, prompt for group name to find the
+posting style."
+  (interactive "P")
+  ;; We can't `let' gnus-newsgroup-name here, since that leads
+  ;; to local variables leaking.
+  (let ((group gnus-newsgroup-name)
+        (buffer (current-buffer)))
+    (unwind-protect
+        (progn
+          (setq gnus-newsgroup-name
+                (if arg
+                    (if (= 1 (prefix-numeric-value arg))
+                        (completing-read "Use group: "
+                                         gnus-active-hashtb nil
+                                         (gnus-read-active-file-p))
+                      "")
+                  gnus-newsgroup-name))
+          ;; #### see comment in gnus-setup-message -- drv
+          (gnus-setup-message 'message (message-mail)))
+      (save-excursion
+        (set-buffer buffer)
+        (setq gnus-newsgroup-name group)))))
+
+(defun gnus-summary-news-other-window (&optional arg)
+  "Start composing a news in another window.
+Post to the current group by default.
+If ARG, don't do that.  If ARG is 1, prompt for group name to post to.
+
+This function prepares a news even when using mail groups.  This is useful
+for posting messages to mail groups without actually sending them over the
+network.  The corresponding backend must have a 'request-post method."
+  (interactive "P")
+  ;; We can't `let' gnus-newsgroup-name here, since that leads
+  ;; to local variables leaking.
+  (let ((group gnus-newsgroup-name)
+        (buffer (current-buffer)))
+    (unwind-protect
+        (progn
+          (setq gnus-newsgroup-name
+                (if arg
+                    (if (= 1 (prefix-numeric-value arg))
+                        (completing-read "Use group: "
+                                         gnus-active-hashtb nil
+                                         (gnus-read-active-file-p))
+                      "")
+                  gnus-newsgroup-name))
+          ;; #### see comment in gnus-setup-message -- drv
+          (gnus-setup-message 'message
+            (message-news (gnus-group-real-name gnus-newsgroup-name))))
+      (save-excursion
+        (set-buffer buffer)
+        (setq gnus-newsgroup-name group)))))
 
+(defun gnus-summary-post-news (&optional arg)
+  "Start composing a message.  Post to the current group by default.
+If ARG, don't do that.  If ARG is 1, prompt for a group name to post to.
+Depending on the selected group, the message might be either a mail or
+a news."
+  (interactive "P")
+  ;; Bind this variable here to make message mode hooks work ok.
+  (let ((gnus-newsgroup-name
+         (if arg
+             (if (= 1 (prefix-numeric-value arg))
+                 (completing-read "Newsgroup: " gnus-active-hashtb nil
+                                  (gnus-read-active-file-p))
+               "")
+           gnus-newsgroup-name)))
+    (gnus-post-news 'post gnus-newsgroup-name)))
+
+
 (defun gnus-summary-followup (yank &optional force-news)
   "Compose a followup to an article.
 If prefix argument YANK is non-nil, original article is yanked automatically."
@@ -977,12 +1087,6 @@
           (when (gnus-y-or-n-p "Send this complaint? ")
             (message-send-and-exit)))))))
 
-(defun gnus-summary-mail-other-window ()
-  "Compose mail in other window."
-  (interactive)
-  (gnus-setup-message 'message
-    (message-mail)))
-
 (defun gnus-mail-parse-comma-list ()
   (let (accumulated
         beg)
@@ -1382,10 +1486,10 @@
 
 ;;; Posting styles.
 
-(defun gnus-configure-posting-styles ()
+(defun gnus-configure-posting-styles (&optional group-name)
   "Configure posting styles according to `gnus-posting-styles'."
   (unless gnus-inhibit-posting-styles
-    (let ((group (or gnus-newsgroup-name ""))
+    (let ((group (or group-name gnus-newsgroup-name ""))
           (styles gnus-posting-styles)
           style match variable attribute value v results
           filep name address element)
Index: lisp/gnus-group.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-group.el,v
retrieving revision 6.50
diff -u -u -t -b -B -w -r6.50 gnus-group.el
--- lisp/gnus-group.el	2001/12/09 14:09:36	6.50
+++ lisp/gnus-group.el	2001/12/12 16:21:26
@@ -543,6 +543,7 @@
     "l" gnus-group-list-groups
     "L" gnus-group-list-all-groups
     "m" gnus-group-mail
+    "i" gnus-group-news
     "g" gnus-group-get-new-news
     "\M-g" gnus-group-get-new-news-this-group
     "R" gnus-group-restart
@@ -867,7 +868,8 @@
         ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
         ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
        ["Send a mail" gnus-group-mail t]
-       ["Post an article..." gnus-group-post-news t]
+       ["Send a message (mail or news)" gnus-group-post-news t]
+       ["Create a local message" gnus-group-news t]
        ["Check for new news" gnus-group-get-new-news
         ,@(if (featurep 'xemacs) '(t)
             '(:help "Get newly arrived articles"))
Index: lisp/gnus-sum.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-sum.el,v
retrieving revision 6.129
diff -u -u -t -b -B -w -r6.129 gnus-sum.el
--- lisp/gnus-sum.el	2001/12/12 05:51:27	6.129
+++ lisp/gnus-sum.el	2001/12/12 16:21:29
@@ -1542,6 +1542,7 @@
     gnus-mouse-2 gnus-mouse-pick-article
     "m" gnus-summary-mail-other-window
     "a" gnus-summary-post-news
+    "i" gnus-summary-news-other-window
     "x" gnus-summary-limit-to-unread
     "s" gnus-summary-isearch-article
     "t" gnus-summary-toggle-header
@@ -2012,7 +2013,7 @@
     (easy-menu-define
       gnus-summary-post-menu gnus-summary-mode-map ""
       `("Post"
-        ["Post an article" gnus-summary-post-news
+        ["Send a message (mail or news)" gnus-summary-post-news
          ,@(if (featurep 'xemacs) '(t)
              '(:help "Post an article"))]
         ["Followup" gnus-summary-followup
@@ -2038,6 +2039,7 @@
         ["Resend message" gnus-summary-resend-message t]
         ["Send bounced mail" gnus-summary-resend-bounced-mail t]
         ["Send a mail" gnus-summary-mail-other-window t]
+        ["Create a local message" gnus-summary-news-other-window t]
         ["Uuencode and post" gnus-uu-post-news
          ,@(if (featurep 'xemacs) '(t)
              '(:help "Post a uuencoded article"))]
Index: lisp/gnus-salt.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-salt.el,v
retrieving revision 6.6
diff -u -u -t -b -B -w -r6.6 gnus-salt.el
--- lisp/gnus-salt.el	2001/11/06 15:06:21	6.6
+++ lisp/gnus-salt.el	2001/12/12 16:21:29
@@ -899,6 +899,7 @@
     ("matching" . gnus-group-list-matching)
     ("post" . gnus-group-post-news)
     ("mail" . gnus-group-mail)
+    ("local" . (lambda () (interactive) (gnus-group-news 0)))
     ("rescan" . gnus-group-get-new-news)
     ("browse-foreign" . gnus-group-browse-foreign)
     ("exit" . gnus-group-exit)))
@@ -929,7 +930,8 @@
     ("kill" . gnus-summary-kill-thread)
     "post"
     ("post" . gnus-summary-post-news)
-    ("mail" . gnus-summary-mail)
+    ("local" . gnus-summary-news-other-window)
+    ("mail" . gnus-summary-mail-other-window)
     ("followup" . gnus-summary-followup-with-original)
     ("reply" . gnus-summary-reply-with-original)
     ("cancel" . gnus-summary-cancel-article)
Index: lisp/gnus.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus.el,v
retrieving revision 6.65
diff -u -u -t -b -B -w -r6.65 gnus.el
--- lisp/gnus.el	2001/11/09 21:58:45	6.65
+++ lisp/gnus.el	2001/12/12 16:21:29
@@ -2008,7 +2008,8 @@
      ("gnus-msg" (gnus-summary-send-map keymap)
       gnus-article-mail gnus-copy-article-buffer gnus-extended-version)
      ("gnus-msg" :interactive t
-      gnus-group-post-news gnus-group-mail gnus-summary-post-news
+      gnus-group-post-news gnus-group-mail gnus-group-news
+      gnus-summary-post-news gnus-summary-news-other-window
       gnus-summary-followup gnus-summary-followup-with-original
       gnus-summary-cancel-article gnus-summary-supersede-article
       gnus-post-news gnus-summary-reply gnus-summary-reply-with-original
Index: texi/gnus.texi
===================================================================
RCS file: /usr/local/cvsroot/gnus/texi/gnus.texi,v
retrieving revision 6.191
diff -u -u -t -b -B -w -r6.191 gnus.texi
--- texi/gnus.texi	2001/12/10 12:32:01	6.191
+++ texi/gnus.texi	2001/12/12 16:21:32
@@ -3843,14 +3843,33 @@
 @item a
 @kindex a (Group)
 @findex gnus-group-post-news
-Post an article to a group (@code{gnus-group-post-news}).  If given a
-prefix, the current group name will be used as the default.
-@xref{Composing Messages}.
+Start composing a message (a news by default)
+(@code{gnus-group-post-news}).  If given a prefix, post to the group
+under the point.  If the prefix is 1, prompt for a group to post to.
+Contrary to what the name of this function suggests, the prepared
+article might be a mail instead of a news, if a mail group is specified
+with the prefix argument.  @xref{Composing Messages}.
 
 @item m
 @kindex m (Group)
 @findex gnus-group-mail
-Mail a message somewhere (@code{gnus-group-mail}).  @xref{Composing Messages}.
+Mail a message somewhere (@code{gnus-group-mail}).  If given a prefix,
+use the posting style of the group under the point.  If the prefix is 1,
+prompt for a group name to find the posting style.
+@xref{Composing Messages}.
+
+@item i
+@kindex i (Group)
+@findex gnus-group-news
+Start composing a news (@code{gnus-group-news}).  If given a prefix,
+post to the group under the point.  If the prefix is 1, prompt
+for group to post to.  @xref{Composing Messages}.
+
+This function actually prepares a news even when using mail groups.
+This is useful for "posting" messages to mail groups without actually
+sending them over the network: they're just saved directly to the group
+in question.  The corresponding backend must have a request-post method
+for this to work though.
 
 @end table
 
@@ -4960,8 +4979,24 @@
 @kindex S m (Summary)
 @findex gnus-summary-mail-other-window
 @c @icon{gnus-summary-mail-originate}
-Send a mail to some other person
-(@code{gnus-summary-mail-other-window}).
+Prepare a mail (@code{gnus-summary-mail-other-window}).  By default, use
+the posting style of the current group.  If given a prefix, disable that.
+If the prefix is 1, prompt for a group name to find the posting style.
+
+@item S i
+@itemx i
+@kindex i (Summary)
+@kindex S i (Summary)
+@findex gnus-summary-news-other-window
+Prepare a news (@code{gnus-summary-news-other-window}).  By default,
+post to the current group.  If given a prefix, disable that.  If the
+prefix is 1, prompt for a group to post to.
+
+This function actually prepares a news even when using mail groups.
+This is useful for "posting" messages to mail groups without actually
+sending them over the network: they're just saved directly to the group
+in question.  The corresponding backend must have a request-post method
+for this to work though.
 
 @item S D b
 @kindex S D b (Summary)
@@ -5039,8 +5074,9 @@
 @kindex S p (Summary)
 @findex gnus-summary-post-news
 @c @icon{gnus-summary-post-news}
-Post an article to the current group
-(@code{gnus-summary-post-news}).
+Prepare for posting an article (@code{gnus-summary-post-news}).  By
+default, post to the current group.  If given a prefix, disable that.
+If the prefix is 1, prompt for another group instead.
 
 @item S f
 @itemx f

-- 
Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 53 14 59 47
94276 Le Kremlin-Bicêtre, France   Fax.+33 (1) 53 14 59 22   didier@xemacs.org



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

* Re: [CHECK IN] posting functions hacking
  2001-12-12 16:19 [CHECK IN] posting functions hacking Didier Verna
@ 2001-12-15 16:15 ` Raymond Scholz
  0 siblings, 0 replies; 2+ messages in thread
From: Raymond Scholz @ 2001-12-15 16:15 UTC (permalink / raw)


Didier Verna <didier@lrde.epita.fr> writes:

> 	I've checked in some modifications on the different posting functions
> available in the group and summary buffers, following the recent discussion on
> that matter. There are also two new functions bound to `i' in these two
> buffers, that can be used with mail-post enabled mail backends. The `i'
> binding was available in all maps. That's the only reason for this choice. I'm
> open to other suggestions.

Ah, fine.  So this may improve handling of virtual groups too, right?

I'm running a group "virtual.emacs" consisting of gnu.emacs.help and
comp.emacs for some months now.  Following up to articles inserts the
Newsgroups header of the original message.  But for new posts, I have
to manually add a Newsgroups header because Gnus assumes virtual
groups to be mail groups.

WIBNI your code would respect the `to-list' group parameter?  Or are
`to-list' and `to-address' for mail only?  Ah, there's `to-group'!
But it is used for both: new posts (with `a') and follow-ups.  I
think, what I want is `to-group-new' and `to-group-followup' or
something like that.

Cheers, Ray
-- 
Raymond Scholz - rscholz@zonix.de - PGP - http://www.zonix.de/



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

end of thread, other threads:[~2001-12-15 16:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-12 16:19 [CHECK IN] posting functions hacking Didier Verna
2001-12-15 16:15 ` Raymond Scholz

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