master e1338c6c621: Merge from origin/emacs-31

Sean Whitton <[email protected]> Mon, 3 Aug 2026 05:26:39 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: master
commit e1338c6c6213949f3983925fda54171b71ffece3
Merge: 1095d63d28f afda8c2779b
Author: Sean Whitton <[email protected]>
Commit: Sean Whitton <[email protected]>

    Merge from origin/emacs-31
    
    afda8c2779b Fix vc-hg-diff arguments to diff vs empty tree
    d828a19fdc0 Eglot: fix use of progress reporters again (bug#81514)
    74ec15e7684 ; Fix 'package--save-selected-packages' edge case (Bug#81...
    983995b54c9 ; Delete obsolete comment.
---
 lisp/emacs-lisp/package.el  | 23 +++++++++++++++++------
 lisp/minibuffer.el          |  2 --
 lisp/progmodes/eglot.el     |  9 +++++++--
 lisp/vc/vc-hg.el            |  2 +-
 test/lisp/vc/vc-hg-tests.el | 17 +++++++++++++++++
 5 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index bf567cb7b7d..e2cbd631f90 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1850,16 +1850,27 @@ Used to populate `package-selected-packages'."
              unless (memq name dep-list)
              collect name)))
 
+(defun package--save-selected-packages-1 ()
+  "Save the current value of `package-selected-packages'."
+  (customize-save-variable
+   'package-selected-packages
+   (sort package-selected-packages #'string<)))
+
 (defun package--save-selected-packages (&optional value)
-  "Set and save `package-selected-packages' to VALUE."
+  "Set `package-selected-packages' to VALUE.
+During initialization, we record VALUE but to not persist it using
+Customize, to avoid overwriting configurations that haven't yet been
+loaded.  After initisation we update the user option directly."
   (when (or value after-init-time)
     ;; It is valid to set it to nil, for example when the last package
-    ;; is uninstalled.  But it shouldn't be done at init time, to
-    ;; avoid overwriting configurations that haven't yet been loaded.
-    (setq package-selected-packages (sort value #'string<)))
+    ;; is uninstalled.  But it shouldn't be done at init time, to avoid
+    ;; overwriting configurations that haven't yet been loaded.  We fall
+    ;; back to the default value of `package-selected-packages' when
+    ;; this function is invoked by `after-init-hook'.
+    (setq package-selected-packages value))
   (if after-init-time
-      (customize-save-variable 'package-selected-packages package-selected-packages)
-    (add-hook 'after-init-hook #'package--save-selected-packages)))
+      (package--save-selected-packages-1)
+    (add-hook 'after-init-hook #'package--save-selected-packages-1)))
 
 (defun package--user-selected-p (pkg)
   "Return non-nil if PKG is a package was installed by the user.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 6c13fcabe54..7ef6f1383ab 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3130,8 +3130,6 @@ Also respects the obsolete wrapper hook `completion-in-region-functions'.
       completion-in-region-functions (start end collection predicate)
     (let ((minibuffer-completion-table collection)
           (minibuffer-completion-predicate predicate))
-      ;; HACK: if the text we are completing is already in a field, we
-      ;; want the completion field to take priority (e.g. Bug#6830).
       (when completion-in-region-mode-predicate
         (setq completion-in-region--data
 	      `(,(if (markerp start) start (copy-marker start))
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 0f0791d37ab..b27d7761111 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1491,6 +1491,11 @@ PRESERVE-BUFFERS as in `eglot-shutdown', which see."
          (lambda (x) (eq server
                          (get-text-property 0 'eglot--server (car x))))
          flymake-list-only-diagnostics))
+  ;; Cleanup progress reporters
+  (maphash (lambda (_ r)
+             (unless (eq (car r) 'eglot--mode-line-reporter )
+               (progress-reporter-done r)))
+           (eglot--progress-reporters server))
   (cond ((eglot--shutdown-requested server)
          t)
         ((not (eglot--inhibit-autoreconnect server))
@@ -2888,10 +2893,10 @@ return it back to the server.  :null is returned if the list was empty."
       (eglot--dbind ((WorkDoneProgress) kind title percentage message) value
         (pcase kind
           ("begin"
-           (upd percentage (fmt title message)
+           (upd (or percentage 0) (fmt title message)
                 (puthash token (mkpr title)
                          (eglot--progress-reporters server))))
-          ("report" (upd percentage message))
+          ("report" (upd (or percentage 0) message))
           ("end" (upd (or percentage 100) message)
            (run-at-time 2 nil
                         (lambda ()
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index a34ed82fa23..acc257dab2f 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -565,7 +565,7 @@ This requires hg 4.4 or later, for the \"-L\" option of \"hg log\"."
     (when (and (not newvers) (member oldvers (list working ".")))
       (setq oldvers nil))
     (when (and newvers (not oldvers))
-      (setq oldvers working))
+      (setq oldvers "null"))
     (apply #'vc-hg-command
 	   (or buffer "*vc-diff*")
            (if async 'async 1)
diff --git a/test/lisp/vc/vc-hg-tests.el b/test/lisp/vc/vc-hg-tests.el
index 0216c23eebe..09891f10b22 100644
--- a/test/lisp/vc/vc-hg-tests.el
+++ b/test/lisp/vc/vc-hg-tests.el
@@ -88,4 +88,21 @@ R foo"
      ("foo2" added #s(vc-hg-extra-fileinfo renamed-from "foo"))
      ("bar2" added #s(vc-hg-extra-fileinfo renamed-from "bar")))))
 
+(ert-deftest vc-hg-diff-revision-arguments ()
+  "Test `vc-hg-diff' revision arguments."
+  (cl-letf (((symbol-function 'vc-hg-command) #'list)
+            (vc-hg-diff-switches t))
+    ;; REV1 REV2 both nil: diff file against working revision
+    (should (equal (vc-hg-diff '("foo") nil nil)
+                   '("*vc-diff*" 1 ("foo") "diff")))
+    ;; REV1 nil and REV2 non-nil: diff REV2 against empty tree
+    (should (equal (vc-hg-diff '("foo") nil "22222")
+                   '("*vc-diff*" 1 ("foo") "diff" "-r" "null" "-r" "22222")))
+    ;; REV1 non-nil and REV2 nil: diff working copy against older revision
+    (should (equal (vc-hg-diff '("foo") "11111" nil)
+                   '("*vc-diff*" 1 ("foo") "diff" "-r" "11111")))
+    ;; REV1 REV2 both non-nil: diff two revisions
+    (should (equal (vc-hg-diff '("foo") "11111" "22222")
+                   '("*vc-diff*" 1 ("foo") "diff" "-r" "11111" "-r" "22222")))))
+
 ;;; vc-hg-tests.el ends here