forked from rswgnu/hyperbole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hgnus.el
122 lines (103 loc) · 4.29 KB
/
hgnus.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
;;; hgnus.el --- GNU Hyperbole buttons in news reader/poster: GNUS -*- lexical-binding: t; -*-
;;
;; Author: Bob Weiner
;;
;; Orig-Date: 24-Dec-91 at 22:29:28
;; Last-Mod: 9-May-22 at 00:01:49 by Bob Weiner
;;
;; Copyright (C) 1991-2022 Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.
;;; Commentary:
;;
;; This only works with GNUS 3.15 or above, so be sure to check your
;; newsreader version {M-ESC gnus-version RET} before reporting any
;; problems.
;;
;; Automatically configured for use in "hyperbole.el".
;; If hsettings loading fails prior to initializing Hyperbole Gnus support,
;;
;; {M-x Gnus-init RET}
;;
;; will do it.
;;
;;
;; Have not yet overloaded 'news-reply-yank-original'
;; to yank and hide button data from news article buffer.
;;
;;; Code:
;;; ************************************************************************
;;; Other required Elisp libraries
;;; ************************************************************************
(eval-and-compile (mapc #'require '(hload-path hmail hsmail hypb gnus-msg)))
;;; ************************************************************************
;;; Public variables
;;; ************************************************************************
(setq hnews:composer 'news-reply-mode
hnews:lister 'gnus-summary-mode
hnews:reader 'gnus-article-mode)
;;; ************************************************************************
;;; Public functions
;;; ************************************************************************
;;;###autoload
(defun Gnus-init ()
"Initialize Hyperbole support for Gnus Usenet news reading."
(interactive)
nil)
(defun lnews:to ()
"Set current buffer to the Usenet news article summary listing buffer."
(and (eq major-mode hnews:reader) (set-buffer gnus-summary-buffer)))
(defun rnews:to ()
"Set current buffer to the Usenet news article reader buffer."
(and (eq major-mode hnews:lister) (set-buffer gnus-article-buffer)))
(defun rnews:summ-msg-to ()
"Displays news message associated with current summary header."
(let ((article (gnus-summary-article-number)))
(if (or (null gnus-current-article)
(/= article gnus-current-article))
;; Selected subject is different from current article's.
(gnus-summary-display-article article))))
;;; Overload this function from "rnewspost.el" for supercite compatibility
;;; only when supercite is in use.
(if (hypb:supercite-p)
(defun news-reply-yank-original (arg)
"Supercite version of news-reply-yank-original.
Insert the message being replied to in the reply buffer. Puts point
before the mail headers and mark after body of the text. Calls
mail-yank-original to actually yank the message into the buffer and
cite text.
If mail-yank-original is not overloaded by supercite, each nonblank
line is indented ARG spaces (default 3). Just \\[universal-argument]
as ARG means don't indent and don't delete any header fields."
(interactive "P")
(mail-yank-original arg)
(exchange-point-and-mark)
(run-hooks 'news-reply-header-hook)))
;;; ************************************************************************
;;; Private variables
;;; ************************************************************************
;;;
(var:append 'gnus-Inews-article-hook '(widen))
;;;
;;; Hide any Hyperbole button data and highlight buttons if possible
;;; in news article being read.
(var:append 'gnus-article-prepare-hook
(if (fboundp 'hproperty:but-create)
'(hmail:msg-narrow hproperty:but-create)
'(hmail:msg-narrow)))
(if (fboundp 'hproperty:but-create)
(var:append 'gnus-summary-prepare-hook '(hproperty:but-create)))
;;; Try to setup comment addition as the first element of these hooks.
(if (fboundp 'add-hook)
;; Called from 'news-post-news' if prev unsent article exists and user
;; says erase it. Add a comment on Hyperbole button support.
(progn
(add-hook 'news-setup-hook #'smail:comment-add)
;; Called from 'news-post-news' if no prev unsent article exists.
;; Add a comment on Hyperbole button support.
(add-hook 'news-reply-mode-hook #'smail:comment-add))
(var:append 'news-setup-hook '(smail:comment-add))
(var:append 'news-reply-mode-hook '(smail:comment-add)))
(provide 'hgnus)
;;; hgnus.el ends here