Browse Source

MUA handling now done with a OO-style, reworked emacs integration to use emacsclient to reuse an existing emacs instance (if any); thanks to Dan Jacobson for the report and Håkon Stordahl for the patch; Closes: #367298

suites/jessie-proposed-backports
Sandro Tosi 12 years ago
parent
commit
b321f8a514
  1. 7
      debian/changelog
  2. 2
      debian/control
  3. 27
      doc/README.Users
  4. 8
      reportbug/submit.py
  5. 45
      reportbug/utils.py
  6. 12
      share/reportbug.el

7
debian/changelog

@ -43,8 +43,13 @@ reportbug (4.10~WIP) UNRELEASED; urgency=low
email; thanks to Andrei Popescu for the report; Closes: #526631
- clarified the menu showing bugs already present, changing the title and
the buttons; thanks to Nick for the report; Closes: #462614
* reportbug/{submit.py, utils.py}, share/reportbug.el, doc/README.Users,
debian/control
- MUA handling now done with a OO-style, reworked emacs integration to use
emacsclient to reuse an existing emacs instance (if any); thanks to Dan
Jacobson for the report and Håkon Stordahl for the patch; Closes: #367298
-- Sandro Tosi <morph@debian.org> Sun, 03 Jan 2010 20:10:03 +0100
-- Sandro Tosi <morph@debian.org> Mon, 04 Jan 2010 10:01:15 +0100
reportbug (4.9) unstable; urgency=low

2
debian/control

@ -14,7 +14,7 @@ Homepage: http://alioth.debian.org/projects/reportbug/
Package: reportbug
Architecture: all
Depends: ${python:Depends}, apt, python-reportbug (= ${source:Version})
Suggests: postfix | exim4 | mail-transport-agent, gnupg | pgp, debconf-utils (>> 1.1.0), debsums (>= 2.0.47), file (>> 1.30), dlocate, python-urwid, python-gtk2, python-vte, python-gtkspell, xdg-utils
Suggests: postfix | exim4 | mail-transport-agent, gnupg | pgp, debconf-utils (>> 1.1.0), debsums (>= 2.0.47), file (>> 1.30), dlocate, python-urwid, python-gtk2, python-vte, python-gtkspell, xdg-utils, emacs22-bin-common | emacs23-bin-common
Conflicts: python-urwid (<< 0.9.8-1), python-central (<< 0.5.13), debsums (<< 2.0.47)
XB-Python-Version: ${python:Versions}
Description: reports bugs in the Debian distribution

27
doc/README.Users

@ -50,3 +50,30 @@ If after installing both of them still GTK+ UI doesn't show up, please
file a report (in text ui :) ).
Thanks to: Sandro Tosi <morph@debian.org>
How to Use `gnus` MUA effectively
=================================
reportbug is now able to use an already running instance of emacs,
instead of spawning a new one.
In order to obtain that, you have to install:
- `emacs22-bin-common` or `emacs23-bin-common` (as mentioned in
Suggests control field)
that contains the `emacsclient` program needed for the integration to
work (minimum version is 22 because earlier versions of `emacsclient`
did not support the `--eval` option).
Then a change to ~/.emacs file is needed, in order to add:
(server-start)
or else Emacs won't listen for connections from emacsclient (and a new
`emacs` instance is executed).
With this changes, using the `gnus` MUA, the mail is opened in the
running `emacs`, or if there's none, a new instance is executed.
Thanks to: Håkon Stordahl <hakon@stordahl.org>

8
reportbug/submit.py

@ -430,15 +430,11 @@ def send_report(body, attachments, mua, fromaddr, sendto, ccaddr, bccaddr,
ewrite('Original write failed, wrote bug report to %s\n', msgname)
if mua:
for bit in mua.split():
if '%s' not in bit: break
ewrite("Spawning %s...\n", bit or mua)
if '%s' not in mua:
mua += ' %s'
ewrite("Spawning %s...\n", mua.name)
returnvalue = 0
succeeded = False
while not succeeded:
returnvalue = ui.system(mua % commands.mkarg(filename)[1:])
returnvalue = mua.send(filename)
if returnvalue != 0:
ewrite("Mutt users should be aware it is mandatory to edit the draft before sending.\n")
mtitle = 'Report has not been sent yet; what do you want to do now?'

45
reportbug/utils.py

@ -46,6 +46,9 @@ import subprocess
import debianbts
from string import ascii_letters, digits
# needed for MUA send
import ui.text_ui as ui
# Paths for dpkg
DPKGLIB = '/var/lib/dpkg'
AVAILDB = os.path.join(DPKGLIB, 'available')
@ -752,13 +755,43 @@ CONFIG_ARGS = (
'printonly', 'offline', 'check_uid', 'smtptls', 'smtpuser', 'smtppasswd',
'paranoid')
class Mua:
command = ""
name = ""
def __init__(self, command):
self.command = command
self.name = command.split()[0]
def send(self, filename):
mua = self.command
if '%s' not in mua:
mua += ' %s'
return ui.system(mua % commands.mkarg(filename)[1:])
class Gnus(Mua):
name = "gnus"
def __init__(self):
pass
def send(self, filename):
elisp = """(progn
(load-file "/usr/share/reportbug/reportbug.el")
(tfheen-reportbug-insert-template "%s"))"""
filename = re.sub("[\"\\\\]", "\\\\\\g<0>", filename)
elisp = commands.mkarg(elisp % filename)
return ui.system("emacsclient --no-wait --eval %s 2>/dev/null"
" || emacs --eval %s" % (elisp, elisp))
MUA = {
'mutt' : 'mutt -H',
'mh' : '/usr/bin/mh/comp -use -file',
'gnus' : 'REPORTBUG=%s emacs -l /usr/share/reportbug/reportbug.el -f tfheen-reportbug-insert-template',
'mutt' : Mua('mutt -H'),
'mh' : Mua('/usr/bin/mh/comp -use -file'),
'gnus' : Gnus(),
}
MUA['nmh'] = MUA['mh']
# TODO: convert them to class methods
MUAVERSION = {
MUA['mutt'] : 'mutt -v',
MUA['mh'] : '/usr/bin/mh/comp -use -file',
@ -774,7 +807,9 @@ def mua_is_supported(mua):
elif mua == 'gnus' or mua == MUA['gnus']:
mua = 'gnus'
else:
mua = mua.split()[0]
pass
# FIXME: to adapt to new OO-style; previously it was:
# mua = mua.split()[0]
if mua not in MUA:
return False
else:
@ -789,7 +824,7 @@ def mua_exists(mua):
elif mua == 'gnus' or mua == MUA['gnus']:
mua = MUA['gnus']
else:
mua = MUA[mua.split()[0]]
mua = MUA[mua]
output = '/dev/null'
if os.path.exists(output):
try:

12
share/reportbug.el

@ -10,10 +10,10 @@
(if (or
;; Check for a separately packaged release of Gnus
;; (second component of version number even):
(= (% (string-to-int (match-string 2 gnus-version-number)) 2) 0)
(= (% (string-to-number (match-string 2 gnus-version-number)) 2) 0)
;; Check for a separately packaged pre-release of Gnus
;; (first component of version number 0):
(= (string-to-int (match-string 1 gnus-version-number)) 0))
(= (string-to-number (match-string 1 gnus-version-number)) 0))
(require 'gnus-load))
(defun tfheen-set-header (header value)
@ -24,10 +24,10 @@
(insert value)
(widen))
(defun tfheen-reportbug-insert-template ()
(defun tfheen-reportbug-insert-template (reportbug-template)
(interactive)
(require 'gnus)
(find-file (getenv "REPORTBUG"))
(find-file reportbug-template)
(let ((subject (message-fetch-field "Subject"))
(toaddr (or (message-fetch-field "To") "submit@bugs.debian.org")))
(gnus-narrow-to-body)
@ -37,5 +37,7 @@
(tfheen-set-header "To" toaddr)
(gnus-narrow-to-body)
(insert body)
(goto-char (point-min))
(search-forward "\n\n" nil t)
(widen)))
(kill-buffer (find-buffer-visiting (getenv "REPORTBUG"))))
(kill-buffer (find-buffer-visiting reportbug-template)))

Loading…
Cancel
Save