Subject: ges-post 0.4 -- post elisp files to gnu.emacs.sources using Gnus
From: Michael Schierl <[email-masked]>
Date: Fri, 19 Mar 2004 13:56:05 +0100
Newsgroups: gnu.emacs.sources

(This post was automatically generated using ges-post.el, version 0.4)

;;; ges-post.el --- post elisp files to gnu.emacs.sources using Gnus

;; Copyright (C) 2004 Michael Schierl

;; Author: Michael Schierl <[email-masked]>
;; Created: 14 March 2004
;; Keywords: gnu.emacs.sources posting Gnus
;; Version: 0.4

(defconst ges-post-version "0.4"
  "Version of ges-post.")

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.

;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; gnu.emacs.sources is a newsgroup to post Elisp sources to. Since
;; the job of creating such postings is quite repetitive, Emacs can
;; help you with it. After having loaded the source file just type M-x
;; ges-post-current-buffer RET and a Gnus message buffer will be
;; prepared for you containing the full source and a default subject
;; (file name, version number (if detectable) and summary line). You
;; will be asked for a group (just hit RET for gnu.emacs.sources) and
;; whether you want to send the article directly. Otherwise point is
;; placed before the first line, so you can easily add a comment there
;; if you want to.

;; you can customize `ges-post-use-mime' to send files as a MIME
;; attachment (default is no for backwards compatibility) or
;; `ges-post-gnus-plugged' if you want to start Gnus unplugged when it
;; is not started yet.

;;; History:

;; 2004-03-19 Suggestion by Reiner Steib <[email-masked]>
;;   - Moved defgroup "ges-post" below "gnus-message"

;; 2004-03-17 Patch by Steve Youngs <[email-masked]>
;;    - Added a defgroup "ges-post", a subgroup of "gnus-fun".
;;    - Made the defcustoms use it
;;    - Added a keybinding
;;    - Added a convenience alias `ges-post -> ges-post-current-buffer'
;;    - Added an autoload so that entering emacs-lisp-mode will load ges-post
;;    - I figure there's no harm in a bit of advertising...

;; 2004-03-16 Patch by Steve Youngs <[email-masked]>:
;;    - start Gnus automatically if needed
;;    - ask for group name
;;    - use lisp-mnt functions to determine summary and version
;;    - optionally post as a MIME attachment
;;    - send article automatically if desired

;; 2004-03-14 First "release" in gnu.emacs.sources

;;; Code:

(require 'gnus-msg)
(require 'lisp-mnt)

(defgroup ges-post nil
  "Customisations for ges-post."
  :prefix "ges-post-"
  :group 'gnus-message)

(defcustom ges-post-use-mime nil
  "*When non-nil post as a MIME attachment."
  :group 'ges-post
  :type 'boolean)

(defcustom ges-post-gnus-plugged t
  "*When non-nil, start Gnus in \"plugged\" mode."
  :group 'ges-post
  :type 'boolean)

(defcustom ges-post-advertise t
  "*When non-nil advertise how the post was generated.

This inserts a line at the top of the article body advertising the
fact that the post was generated with `ges-post'.  Simply set this to
`nil' to turn this feature off."
  :type 'boolean
  :group 'ges-post)

(defconst ges-post-advertising-blurb
  (concat
   "(This post was automatically generated using ges-post.el, version "
   ges-post-version
   ")\n\n")
  "Blowing our own trumpet.")

(defun ges-post-current-buffer ()
  "Prepare a posting of current buffer to gnu.emacs.sources.
Point will be placed before first line so that you can add some
comments."
  (interactive)
  (let* ((mybuf (current-buffer)) 
        (name (or (lm-get-package-name)
                  (read-string "Package name: ")))
        (summary (or (lm-summary)
                     (read-string "Short one-line description of package: ")))
        (version (or (lm-version)
                     (read-string "Package version: ")))
        (shortname (file-name-sans-extension name))
        (subject (concat shortname " " version " -- " summary)))
    ;; If Gnus isn't running, start it.
    (unless (gnus-alive-p)
      (if ges-post-gnus-plugged
	  (gnus)
	(gnus-unplugged)))
    (gnus-group-post-news 1)
    (unless (message-field-value "Newsgroups")
      (message-goto-newsgroups)
      (insert "gnu.emacs.sources"))
    (message-goto-subject)
    (insert subject)
    (message-goto-body)
    (if ges-post-use-mime
	(mml-insert-empty-tag 'part 
			      'type "application/emacs-lisp" 
			      'buffer (buffer-name mybuf)
			      'disposition "inline"
			      'description name)
      (insert-buffer mybuf))
    (when ges-post-advertise
      (message-goto-body)
      (insert ges-post-advertising-blurb))
    (when (featurep 'font-lock) (font-lock-fontify-buffer))
    (if (y-or-n-p "Do you wish to add/alter anything before sending? ")
	(message-goto-body)
      (message-send-and-exit))))

(defalias 'ges-post 'ges-post-current-buffer)

(define-key emacs-lisp-mode-map "\M-\C-g" 'ges-post-current-buffer)

;;;###autoload(add-hook 'emacs-lisp-mode-hook '(lambda () (require 'ges-post)))

(provide 'ges-post)

;;; ges-post.el ends here