File: reportbug.el

package info (click to toggle)
reportbug 13.2.0
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,248 kB
  • sloc: python: 9,838; sh: 70; makefile: 41; lisp: 31
file content (43 lines) | stat: -rw-r--r-- 1,610 bytes parent folder | download | duplicates (8)
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
;; Vague implementation of needed code to invoke Gnus from reportbug
;; by Tollef Fog Heen
(require 'gnus)

;; Match each component of Gnus' version number.
(string-match "^\\([0-9]+\\)\\.\\([0-9]+\\)\\(?:\\.\\([0-9]+\\)\\)?$"
	      gnus-version-number)
;; Only load gnus-load if using a separately packaged Gnus (that is,
;; not the Gnus bundled with Emacs).
(if (or
     ;; Check for a separately packaged release of Gnus
     ;; (second component of version number even):
     (= (% (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-number (match-string 1 gnus-version-number)) 0))
    (require 'gnus-load))

(defun tfheen-set-header (header value)
  "Insert a string at the beginning of a header."
  (message-narrow-to-head)
  (goto-char (point-min))
  (search-forward (format "%s: " header) (point-max) t)
  (insert value)
  (widen))

(defun tfheen-reportbug-insert-template (reportbug-template)
  (interactive)
  (require 'gnus)
  (find-file reportbug-template)
  (let ((subject (message-fetch-field "Subject"))
        (toaddr (or (message-fetch-field "To") "submit@bugs.debian.org")))
    (gnus-narrow-to-body)
    (let ((body (or (buffer-string) "")))
      (gnus-summary-mail-other-window)
      (tfheen-set-header "Subject" subject)
      (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 reportbug-template)))