From: nozaka@jrdzzz.jrd.dec.com (Masaki Nozaka)
Subject: Re: [Q] GNUS change signature 
Organization: Digital Equipment Corporation Japan, R&D center
Date: Wed, 16 Dec 1992 10:53:27 GMT

In article <TAKEI.92Dec11195649@knuth.ip.titech.ac.jp> takei@ip.titech.ac.jp (TAKEI Masahiro) writes:

>   GNUS $@$G$O(J .signature-distribution  $@$H$$$&%U%!%$%k$,$"$l$P(J
>   distribution $@$K$h$C$F(J signature $@$OJQ$o$j$^$9$,!"(J $@%K%e!<%9%0%k!<%W(J
>   $@$4$H$KJQ$($k$h$&$JJ}K!$O$"$k$N$G$7$g$&$+!)(J

~/.signature+news.group.name
	    ^$@$3$NItJ,$O(J '+' $@$G$9!#(J
 
$@$H$$$&%U%!%$%k$r(J news.group.name $@$H$$$&%K(J$@%e!<%9%0%k!<%W$KBP$9$k(J 
signature $@$K$9$k%Q%C%A$G$9!#3:Ev$9$k4X?t$rC5$7$F!"CV$-49$($k$+!"(J
gnus $@$,%m!<%I(J$@$5$l$?$"$H$G!"$3$C$A$N4X?t$r%*!<%P%i%$%I$9$k$h$&$K!"(J
$@%m!<%I$9$k$+$7$F$/$@$5$$!#(J

~/.signature+news.group $@$H$$$&%U%!%$%k$r$D$/$C$F$*$1$P!"(J news.group.foo
$@$K$b(J news.group.baa $@$K$b$=$N(J .signature $@$,E,MQ$5$l(J$@$^$9!#(J

~/.signature-distribution $@$bM-8z$G$9!#(J


(defun gnus-inews-article ()
  "NNTP inews interface."
  (let ((signature
        (if gnus-signature-file
            (expand-file-name gnus-signature-file nil)))
       (distribution nil)
       (artbuf (current-buffer))
       (tmpbuf (get-buffer-create " *GNUS-posting*")))
    (save-excursion
      (set-buffer tmpbuf)
      (buffer-flush-undo (current-buffer))
      (erase-buffer)
      (insert-buffer-substring artbuf)
      ;; Get distribution.
      (save-restriction
       (goto-char (point-min))
       (search-forward "\n\n")
       (narrow-to-region (point-min) (point))
       (setq distribution (mail-fetch-field "distribution")))
      (widen)
      (if signature
         (progn
           ;; Change signature file by distribution.
           ;; Suggested by hyoko@flab.fujitsu.junet.
	   (if (signature-by-news-group signature)
	       (setq signature (signature-by-news-group signature)))
           (if (file-exists-p (concat signature "-" distribution))
               (setq signature (concat signature "-" distribution)))
           ;; Insert signature.
           (if (file-exists-p signature)
               (progn
                 (goto-char (point-max))
                 (insert "--\n")
                 (insert-file-contents signature)))
           ))
      ;; Prepare article headers.
      (save-restriction
       (goto-char (point-min))
       (search-forward "\n\n")
       (narrow-to-region (point-min) (point))
       (gnus-inews-insert-headers)
       ;; Save author copy of posted article. The article must be
       ;;  copied before being posted because `gnus-request-post'
       ;;  modifies the buffer.
       (let ((case-fold-search t))
         ;; Find and handle any FCC fields.
         (goto-char (point-min))
         (if (re-search-forward "^FCC:" nil t)
             (gnus-inews-do-fcc))))
      (widen)
      ;; Run final inews hooks.
      (run-hooks 'gnus-Inews-article-hook)
      ;; Post an article to NNTP server.
      ;; Return NIL if post failed.
      (prog1
         (gnus-request-post)
       (kill-buffer (current-buffer)))
      )))


(defun signature-by-news-group (signature)
  (let ((field-name "newsgroups"))
    (save-excursion
      (goto-char (point-min))
      (let ((case-fold-search t)
	    (name (concat "^" (regexp-quote field-name) "[ \t]*:[ \t]*")))
	(goto-char (point-min))
	(if (re-search-forward name nil t)
	    (progn
	      (let ((opoint (point)))
		(re-search-forward "[^a-z\\.]" nil t)
		(re-search-backward "[a-z\\.]" nil t)
		(forward-char 1)
		(while 
		    (and (not (file-exists-p 
			       (concat signature "+"
				       (buffer-substring opoint (point)))))
			 (> (point) opoint))
		  (re-search-backward "[^a-z]" nil t))
		(if (file-exists-p 
		     (concat signature "+"
			     (buffer-substring opoint (point))))
		    (concat signature "+"
			    (buffer-substring opoint (point)))
		  nil)))
	  nil)))))


$@<B$O0JA0<RFb%m!<%+%k%K%e!<%9%0%k!<%W$G$b?t9T$N(J signature $@$OD92a$.$k!"(J
1 $@9T$K$7$m!*$H$+$$$&?M$,$$$F!"$G$7$+$b!"$=$&$$$&$3$H$r8@$&?M$,$$$k$N$O(J
$@7h$^$C$?%K%e!<%9%0%k!<%W$@$C$?$N(J$@$G!"$8$c$!H`$i$,$$$k$H$3$m$G$O(J 1 $@9T$N(J
signature $@$K$7$F!"B>$G$OJL$N$b$&$9$3$7D9$$$N$r;H$*$&$H;W$C$F$D$/(J$@$C$?$b$N(J
$@$G$9!#(J 8-)

$@$N$6$+(J
--
  Digital Equipment Corporation Japan
  Research and Development center
  International System & Engineering Development Architecture
  Masaki NOZAKA Tel. 045(336)5306             |d|i|g|i|t|a|l|
Newsgroups: fj.editor.emacs