Initial Commit
[packages] / xemacs-packages / hyperbole / hgnus.el
1 ;;; hgnus.el --- Support Hyperbole buttons in news reader/poster: GNUS.
2
3 ;; Copyright (C) 1991-1995, 2004 Free Software Foundation, Inc.
4 ;; Developed with support from Motorola Inc.
5
6 ;; Author: Bob Weiner, Brown U.
7 ;; Maintainer: Mats Lidell <matsl@contactor.se>
8 ;; Keywords: hypermedia, news
9
10 ;; This file is part of GNU Hyperbole.
11
12 ;; GNU Hyperbole is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 3, or (at
15 ;; your option) any later version.
16
17 ;; GNU Hyperbole is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ;; General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
26
27 ;;; Commentary:
28 ;;
29 ;;   This only works with GNUS 3.15 or above, so be sure to check your
30 ;;   newsreader version {M-ESC gnus-version RET} before reporting any
31 ;;   problems.
32 ;;
33 ;;   Automatically configured for use in "hyperbole.el".
34 ;;   If hsite loading fails prior to initializing Hyperbole Gnus support,
35 ;;
36 ;;       {M-x Gnus-init RTN}
37 ;;
38 ;;   will do it.
39 ;;
40 ;;
41 ;;   Have not yet overloaded 'news-reply-yank-original'
42 ;;   to yank and hide button data from news article buffer.
43
44 ;;; Code:
45
46 ;;;
47 ;;; Other required Elisp libraries
48 ;;;
49
50 (require 'hmail)
51 (require 'hsmail)
52 (require 'gnus-msg)
53
54 ;;;
55 ;;; Public variables
56 ;;;
57
58 (setq hnews:composer 'news-reply-mode
59       hnews:lister   'gnus-summary-mode
60       hnews:reader   'gnus-article-mode)
61
62
63 ;;;
64 ;;; Public functions
65 ;;;
66
67 (defun Gnus-init ()
68   "Initializes Hyperbole support for Gnus Usenet news reading."
69   (interactive)
70   nil)
71
72 (defun lnews:to ()
73   "Sets current buffer to the Usenet news article summary listing buffer."
74   (and (eq major-mode hnews:reader) (set-buffer gnus-summary-buffer)))
75
76 (defun rnews:to ()
77   "Sets current buffer to the Usenet news article reader buffer."
78   (and (eq major-mode hnews:lister) (set-buffer gnus-article-buffer)))
79
80 (defun rnews:summ-msg-to ()
81   "Displays news message associated with current summary header."
82   (let ((article (gnus-summary-article-number)))
83     (if (or (null gnus-current-article)
84             (/= article gnus-current-article))
85         ;; Selected subject is different from current article's.
86         (gnus-summary-display-article article))))
87
88
89 ;;; Overlay 'gnus-inews-article' from "gnuspost.el" to make it include
90 ;;; any signature before Hyperbole button data.  Does this by having
91 ;;; signature inserted within narrowed buffer and then applies a hook to
92 ;;; have the buffer widened before sending.
93 (hypb:function-symbol-replace
94   'gnus-inews-article 'widen 'hmail:msg-narrow)
95
96 ;;; Overload this function from "rnewspost.el" for supercite compatibility
97 ;;; only when supercite is in use.
98 (if (hypb:supercite-p)
99     (defun news-reply-yank-original (arg)
100       "Supercite version of news-reply-yank-original.
101 Insert the message being replied to in the reply buffer. Puts point
102 before the mail headers and mark after body of the text.  Calls
103 mail-yank-original to actually yank the message into the buffer and
104 cite text.  
105
106 If mail-yank-original is not overloaded by supercite, each nonblank
107 line is indented ARG spaces (default 3).  Just \\[universal-argument]
108 as ARG means don't indent and don't delete any header fields."
109       (interactive "P")
110       (mail-yank-original arg)
111       (exchange-point-and-mark)
112       (run-hooks 'news-reply-header-hook))
113   )
114
115 ;;;
116 ;;; Private variables
117 ;;;
118 ;;;
119 (var:append 'gnus-Inews-article-hook '(widen))
120 ;;;
121 ;;; Hide any Hyperbole button data and highlight buttons if possible
122 ;;; in news article being read.
123 (var:append 'gnus-article-prepare-hook
124             (if (fboundp 'hproperty:but-create)
125                 '(hmail:msg-narrow hproperty:but-create)
126               '(hmail:msg-narrow)))
127
128 (if (fboundp 'hproperty:but-create)
129     (var:append 'gnus-summary-prepare-hook '(hproperty:but-create)))
130
131 ;;; Try to setup comment addition as the first element of these hooks.
132 (if (fboundp 'add-hook)
133     ;; Called from 'news-post-news' if prev unsent article exists and user
134     ;; says erase it.  Add a comment on Hyperbole button support.
135     (progn
136       (add-hook 'news-setup-hook 'smail:comment-add)
137       ;; Called from 'news-post-news' if no prev unsent article exists.
138       ;; Add a comment on Hyperbole button support.
139       (add-hook 'news-reply-mode-hook 'smail:comment-add))
140   (var:append 'news-setup-hook '(smail:comment-add))
141   (var:append 'news-reply-mode-hook '(smail:comment-add)))
142
143 (provide 'hgnus)
144
145 ;;; hgnus.el ends here