branch: externals/debbugs
commit 01ca46fd92849e932d689b0ad28dec5014e56409
Author: Michael Albinus <michael.albi...@gmx.de>
Commit: Michael Albinus <michael.albi...@gmx.de>

    Fix some nits
    
    * Makefile (TARGET): Filter-out debbugs-pkg.elc.
    
    * debbugs-compat.el (main-thread): Define if it doesn't exist.
    (url-http-create-request): Add an advice.
    
    * debbugs-gnu.el (debbugs-gnu-use-threads): Fix docstring.
    (debbugs-gnu-show-last-result): Print thread error if any.
    (debbugs-gnu-show-reports): Use `debbugs-gnu-local-print-function'
    as before.
    
    * debbugs-org.el (debbugs-org-use-threads): Add variable alias.
    
    * debbugs-ug.texi (Retrieving Bugs): Mention debbugs-org-use-threads.
---
 Makefile          |  3 ++-
 debbugs-compat.el | 13 +++++++++++++
 debbugs-gnu.el    | 14 ++++++++++++--
 debbugs-org.el    |  6 ++++++
 debbugs-ug.texi   |  3 +++
 5 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 7d2975dedc..3d54c2c7b6 100644
--- a/Makefile
+++ b/Makefile
@@ -2,9 +2,10 @@ EMACS ?= emacs
 
 SOURCE=$(wildcard *.el)
 TESTSOURCE=$(wildcard test/*.el)
-TARGET=$(patsubst %.el,%.elc,$(SOURCE))
+TARGET=$(filter-out debbugs-pkg.elc,$(patsubst %.el,%.elc,$(SOURCE)))
 TESTTARGET=$(patsubst %.el,%.elc,$(TESTSOURCE))
 
+
 .PHONY: all build check clean
 .PRECIOUS: %.elc
 
diff --git a/debbugs-compat.el b/debbugs-compat.el
index 96628a1921..49de171584 100644
--- a/debbugs-compat.el
+++ b/debbugs-compat.el
@@ -24,6 +24,10 @@
 ;;; Commentary:
 ;;; Code:
 
+;; `main-thread' has been added in Emacs 27.1.
+(unless (boundp 'main-thread)
+  (defconst main-thread nil))
+
 ;; Function `string-replace' is new in Emacs 28.1.
 (defalias 'debbugs-compat-string-replace
   (if (fboundp 'string-replace)
@@ -33,6 +37,15 @@
         (replace-regexp-in-string
          (regexp-quote from-string) to-string in-string t t)))))
 
+;; `soap-invoke-internal' let-binds `url-http-attempt-keepalives' to
+;; t, which is not thread-safe.  We override this setting.
+(defvar url-http-attempt-keepalives)
+(advice-add
+ 'url-http-create-request :around
+ (lambda (orig-fun)
+   (with-no-warnings (setq url-http-attempt-keepalives nil))
+   (funcall orig-fun)))
+
 (provide 'debbugs-compat)
 
 ;;; debbugs-compat.el ends here
diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index c713bfa889..8f71c853ea 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -29,6 +29,10 @@
 ;; show and manipulate bug reports from Emacs, but it could be used
 ;; also for other GNU projects which use the same bug tracker.
 
+;; Retrieving bugs is performed in a separate thread.  This is
+;; controlled by user option `debbugs-gnu-use-threads'.  Set it to nil
+;; if you want to change this behavior.
+
 ;; The bug tracker is called interactively by
 ;;
 ;;   M-x debbugs-gnu
@@ -793,7 +797,7 @@ Shall be bound in `debbugs-org-*' functions.")
 
 (defcustom debbugs-gnu-use-threads (and main-thread t)
   "Whether to use threads when retrieving bugs.
-This doesn't when Emacs is compiled without threading support."
+This doesn't apply when Emacs is compiled without threading support."
   :type 'boolean
   :version "30.1")
 
@@ -921,6 +925,12 @@ This function assumes the variable `user-mail-address' is 
defined."
 (defun debbugs-gnu-show-last-result ()
   "Switch to buffer with the recent retrieved bugs"
   (interactive)
+  ;; `thread-last-error' has an argument since Emacs 27.1.  This
+  ;; doesn't matter, because in Emacs 26 we don't use threads.
+  (when-let ((err
+              (ignore-errors
+                (with-no-warnings (funcall 'thread-last-error 'cleanup)))))
+    (message "debbugs-gnu-show-last-result: %S" err))
   (when (ignore-errors (get-buffer debbugs-gnu-current-buffer))
     (pop-to-buffer-same-window debbugs-gnu-current-buffer)))
 
@@ -1140,7 +1150,7 @@ are taken from the cache instead."
           'append))))
 
     (tabulated-list-init-header)
-    (funcall debbugs-gnu-current-print-function)
+    (funcall debbugs-gnu-local-print-function)
 
     (set-buffer-modified-p nil)
     (goto-char (point-min))))
diff --git a/debbugs-org.el b/debbugs-org.el
index ebd3e24df8..629f7247cb 100644
--- a/debbugs-org.el
+++ b/debbugs-org.el
@@ -27,6 +27,10 @@
 ;; on the GNU bug tracker debbugs.gnu.org.  Its main purpose is to
 ;; show and manipulate bug reports as org-mode TODO items.
 
+;; Retrieving bugs is performed in a separate thread.  This is
+;; controlled by user option `debbugs-org-use-threads'.  Set it to nil
+;; if you want to change this behavior.
+
 ;; The bug tracker is called interactively by
 ;;
 ;;   M-x debbugs-org
@@ -132,6 +136,8 @@
 (defvar debbugs-gnu-local-query)
 (defvar debbugs-gnu-local-filter)
 
+(defvaralias 'debbugs-org-use-threads 'debbugs-gnu-use-threads)
+
 (defconst debbugs-org-severity-priority
   (let ((priority ?A))
     (mapcar
diff --git a/debbugs-ug.texi b/debbugs-ug.texi
index 9110efe132..ee7ede19e1 100644
--- a/debbugs-ug.texi
+++ b/debbugs-ug.texi
@@ -108,6 +108,9 @@ The user option @code{debbugs-gnu-use-threads}, when set to
 retrieval is performed.  Threaded bug retrieval is also suppressed if
 the number of bugs to be retrieved is known in advance, and it is
 smaller than the user option @code{debbugs-gnu-use-threads-lower-limit}.
+
+@vindex debbugs-org-use-threads
+@code{debbugs-org-use-threads} an alias of this user option.
 @end defopt
 
 @section Basic Commands

Reply via email to