Mercurial > emacs
changeset 109814:ea341a06439f
Add command C-c m in report-emacs-bug that puts the bug into preferred mailer.
Depends on xdg-email being available.
* lisp/mail/emacsbug.el (report-emacs-bug-insert-to-mailer)
(report-emacs-bug-can-use-xdg-email): New functions.
(report-emacs-bug): Set can-xdg-email to result of
report-emacs-bug-can-use-xdg-email. If can-xdg-email bind
\C-cm to report-emacs-bug-insert-to-mailer and add help text
about it.
author | Jan D. <jan.h.d@swipnet.se> |
---|---|
date | Tue, 17 Aug 2010 12:07:41 +0200 |
parents | 17256ad564e9 |
children | 7714e8a59020 3226ac2da7f7 |
files | lisp/ChangeLog lisp/mail/emacsbug.el |
diffstat | 2 files changed, 59 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Tue Aug 17 10:01:10 2010 +0200 +++ b/lisp/ChangeLog Tue Aug 17 12:07:41 2010 +0200 @@ -1,18 +1,11 @@ 2010-08-17 Jan Djärv <jan.h.d@swipnet.se> - * net/browse-url.el (browse-url-default-browser): Add cond - for browse-url-xdg-open - (browse-url-can-use-xdg-open, browse-url-xdg-open): New functions - -2010-08-17 Glenn Morris <rgm@gnu.org> - - * progmodes/cc-engine.el (c-new-BEG, c-new-END) - (c-fontify-recorded-types-and-refs): Define for compiler. - * progmodes/cc-mode.el (c-new-BEG, c-new-END): Move definitions - before use. - - * calendar/icalendar.el (icalendar--convert-recurring-to-diary): - Fix format call. + * mail/emacsbug.el (report-emacs-bug-insert-to-mailer) + (report-emacs-bug-can-use-xdg-email): New functions. + (report-emacs-bug): Set can-xdg-email to result of + report-emacs-bug-can-use-xdg-email. If can-xdg-email bind + \C-cm to report-emacs-bug-insert-to-mailer and add help text + about it. 2010-08-17 Michael Albinus <michael.albinus@gmx.de>
--- a/lisp/mail/emacsbug.el Tue Aug 17 10:01:10 2010 +0200 +++ b/lisp/mail/emacsbug.el Tue Aug 17 12:07:41 2010 +0200 @@ -74,6 +74,52 @@ (declare-function message-sort-headers "message" ()) (defvar message-strip-special-text-properties) +(defun report-emacs-bug-can-use-xdg-email () + "Check if xdg-email can be used, i.e. we are on Gnome, KDE or xfce4." + (and (getenv "DISPLAY") + (executable-find "xdg-email") + (or (getenv "GNOME_DESKTOP_SESSION_ID") + ;; GNOME_DESKTOP_SESSION_ID is deprecated, check on Dbus also. + (condition-case nil + (eq 0 (call-process + "dbus-send" nil nil nil + "--dest=org.gnome.SessionManager" + "--print-reply" + "/org/gnome/SessionManager" + "org.gnome.SessionManager.CanShutdown")) + (error nil)) + (equal (getenv "KDE_FULL_SESSION") "true") + (condition-case nil + (eq 0 (call-process + "/bin/sh" nil nil nil + "-c" + "xprop -root _DT_SAVE_MODE|grep xfce4")) + (error nil))))) + +(defun report-emacs-bug-insert-to-mailer () + (interactive) + (save-excursion + (let* ((to (progn + (goto-char (point-min)) + (forward-line) + (and (looking-at "^To: \\(.*\\)") + (match-string-no-properties 1)))) + (subject (progn + (forward-line) + (and (looking-at "^Subject: \\(.*\\)") + (match-string-no-properties 1)))) + (body (progn + (forward-line 2) + (if (> (point-max) (point)) + (buffer-substring-no-properties (point) (point-max)))))) + (if (and to subject body) + (start-process "xdg-email" nil "xdg-email" + "--subject" subject + "--body" body + (concat "mailto:" to)) + (error "Subject, To or body not found"))))) + + ;;;###autoload (defun report-emacs-bug (topic &optional recent-keys) "Report a bug in GNU Emacs. @@ -93,6 +139,7 @@ (prompt-properties '(field emacsbug-prompt intangible but-helpful rear-nonsticky t)) + (can-xdg-email (report-emacs-bug-can-use-xdg-email)) user-point message-end-point) (setq message-end-point (with-current-buffer (get-buffer-create "*Messages*") @@ -226,6 +273,9 @@ ;; This is so the user has to type something in order to send easily. (use-local-map (nconc (make-sparse-keymap) (current-local-map))) (define-key (current-local-map) "\C-c\C-i" 'report-emacs-bug-info) + (if can-xdg-email + (define-key (current-local-map) "\C-cm" + 'report-emacs-bug-insert-to-mailer)) ;; Could test major-mode instead. (cond ((memq mail-user-agent '(message-user-agent gnus-user-agent)) (setq report-emacs-bug-send-command "message-send-and-exit" @@ -245,6 +295,9 @@ report-emacs-bug-send-command)))) (princ (substitute-command-keys " Type \\[kill-buffer] RET to cancel (don't send it).\n")) + (if can-xdg-email + (princ (substitute-command-keys + " Type \\[report-emacs-bug-insert-to-mailer] to insert text to you preferred mail program.\n"))) (terpri) (princ (substitute-command-keys " Type \\[report-emacs-bug-info] to visit in Info the Emacs Manual section