aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2021-01-04 15:31:58 -0500
committerStefan Monnier2021-01-04 15:31:58 -0500
commita79e1a85f8f20911be3bbac883ee7bdffcfbe7a0 (patch)
treea8d8e3f7c3c4421c3ecb56252af7a7dd9533d5a9
parent42c3f7a134f8e51f4eb78e907abb521421e50e39 (diff)
downloademacs-a79e1a85f8f20911be3bbac883ee7bdffcfbe7a0.tar.gz
emacs-a79e1a85f8f20911be3bbac883ee7bdffcfbe7a0.zip
* lisp/mail/reporter.el: Use lexical-binding
(reporter--run-functions): New function. (reporter-dump-state): Use it and simplify the code.
-rw-r--r--lisp/mail/reporter.el82
1 files changed, 42 insertions, 40 deletions
diff --git a/lisp/mail/reporter.el b/lisp/mail/reporter.el
index f4de299f537..2e583a470d6 100644
--- a/lisp/mail/reporter.el
+++ b/lisp/mail/reporter.el
@@ -1,4 +1,4 @@
1;;; reporter.el --- customizable bug reporting of lisp programs 1;;; reporter.el --- customizable bug reporting of lisp programs -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 1993-1998, 2001-2021 Free Software Foundation, Inc. 3;; Copyright (C) 1993-1998, 2001-2021 Free Software Foundation, Inc.
4 4
@@ -158,7 +158,7 @@ composed.")
158 t) 158 t)
159 (error indent-enclosing-p)))) 159 (error indent-enclosing-p))))
160 160
161(defun reporter-lisp-indent (indent-point state) 161(defun reporter-lisp-indent (_indent-point state)
162 "A better lisp indentation style for bug reporting." 162 "A better lisp indentation style for bug reporting."
163 (save-excursion 163 (save-excursion
164 (goto-char (1+ (nth 1 state))) 164 (goto-char (1+ (nth 1 state)))
@@ -193,7 +193,7 @@ MAILBUF is the mail buffer being composed."
193 (<= maxwidth (current-column))) 193 (<= maxwidth (current-column)))
194 (save-excursion 194 (save-excursion
195 (let ((compact-p (not (memq varsym reporter-dont-compact-list))) 195 (let ((compact-p (not (memq varsym reporter-dont-compact-list)))
196 (lisp-indent-function 'reporter-lisp-indent)) 196 (lisp-indent-function #'reporter-lisp-indent))
197 (goto-char here) 197 (goto-char here)
198 (reporter-beautify-list maxwidth compact-p)))) 198 (reporter-beautify-list maxwidth compact-p))))
199 (insert "\n")) 199 (insert "\n"))
@@ -206,6 +206,11 @@ MAILBUF is the mail buffer being composed."
206 (error 206 (error
207 (error "")))) 207 (error ""))))
208 208
209(defun reporter--run-functions (funs)
210 (if (functionp funs)
211 (funcall funs)
212 (mapc #'funcall funs)))
213
209(defun reporter-dump-state (pkgname varlist pre-hooks post-hooks) 214(defun reporter-dump-state (pkgname varlist pre-hooks post-hooks)
210 "Dump the state of the mode specific variables. 215 "Dump the state of the mode specific variables.
211PKGNAME contains the name of the mode as it will appear in the bug 216PKGNAME contains the name of the mode as it will appear in the bug
@@ -230,42 +235,39 @@ properly.
230PRE-HOOKS is run after the Emacs version and PKGNAME are inserted, but 235PRE-HOOKS is run after the Emacs version and PKGNAME are inserted, but
231before the VARLIST is dumped. POST-HOOKS is run after the VARLIST is 236before the VARLIST is dumped. POST-HOOKS is run after the VARLIST is
232dumped." 237dumped."
233 (let ((buffer (current-buffer))) 238 (insert "Emacs : " (emacs-version) "\n")
234 (set-buffer buffer) 239 (and pkgname
235 (insert "Emacs : " (emacs-version) "\n") 240 (insert "Package: " pkgname "\n"))
236 (and pkgname 241 (reporter--run-functions pre-hooks)
237 (insert "Package: " pkgname "\n")) 242 (if (not varlist)
238 (run-hooks 'pre-hooks) 243 nil
239 (if (not varlist) 244 (insert "\ncurrent state:\n==============\n")
240 nil 245 ;; create an emacs-lisp-mode buffer to contain the output, which
241 (insert "\ncurrent state:\n==============\n") 246 ;; we'll later insert into the mail buffer
242 ;; create an emacs-lisp-mode buffer to contain the output, which 247 (condition-case fault
243 ;; we'll later insert into the mail buffer 248 (let ((mailbuf (current-buffer))
244 (condition-case fault 249 (elbuf (get-buffer-create " *tmp-reporter-buffer*")))
245 (let ((mailbuf (current-buffer)) 250 (with-current-buffer elbuf
246 (elbuf (get-buffer-create " *tmp-reporter-buffer*"))) 251 (emacs-lisp-mode)
247 (with-current-buffer elbuf 252 (erase-buffer)
248 (emacs-lisp-mode) 253 (insert "(setq\n")
249 (erase-buffer) 254 (lisp-indent-line)
250 (insert "(setq\n") 255 (mapc
251 (lisp-indent-line) 256 (lambda (varsym-or-cons-cell)
252 (mapc 257 (let ((varsym (or (car-safe varsym-or-cons-cell)
253 (lambda (varsym-or-cons-cell) 258 varsym-or-cons-cell))
254 (let ((varsym (or (car-safe varsym-or-cons-cell) 259 (printer (or (cdr-safe varsym-or-cons-cell)
255 varsym-or-cons-cell)) 260 'reporter-dump-variable)))
256 (printer (or (cdr-safe varsym-or-cons-cell) 261 (funcall printer varsym mailbuf)))
257 'reporter-dump-variable))) 262 varlist)
258 (funcall printer varsym mailbuf))) 263 (lisp-indent-line)
259 varlist) 264 (insert ")\n"))
260 (lisp-indent-line) 265 (insert-buffer-substring elbuf))
261 (insert ")\n")) 266 (error
262 (insert-buffer-substring elbuf)) 267 (insert "State could not be dumped due to the following error:\n\n"
263 (error 268 (format "%s" fault)
264 (insert "State could not be dumped due to the following error:\n\n" 269 "\n\nYou should still send this bug report."))))
265 (format "%s" fault) 270 (reporter--run-functions post-hooks))
266 "\n\nYou should still send this bug report."))))
267 (run-hooks 'post-hooks)
268 ))
269 271
270 272
271(defun reporter-compose-outgoing () 273(defun reporter-compose-outgoing ()
@@ -365,7 +367,7 @@ mail-sending package is used for editing and sending the message."
365 (skip-chars-backward " \t\n") 367 (skip-chars-backward " \t\n")
366 (setq reporter-initial-text (buffer-substring after-sep-pos (point)))) 368 (setq reporter-initial-text (buffer-substring after-sep-pos (point))))
367 (if (setq hookvar (get agent 'hookvar)) 369 (if (setq hookvar (get agent 'hookvar))
368 (add-hook hookvar 'reporter-bug-hook nil t)) 370 (add-hook hookvar #'reporter-bug-hook nil t))
369 371
370 ;; compose the minibuf message and display this. 372 ;; compose the minibuf message and display this.
371 (let* ((sendkey-whereis (where-is-internal 373 (let* ((sendkey-whereis (where-is-internal