Subject: bug#62198: [PATCH] Eglot: Send clientInfo during the initialize request

From: Felician Nemeth <[email-masked]>
Date: Thu, 23 Mar 2023 17:03:40 +0100

> Currently the manual advises users to list the files in
> 'package-user-dir', which is a really poor way of telling the versions
> of ELPA packages, but it's the best I've come up with.  What I meant
> is I'd like to have a way to produce a listing of packages (required
> and optional, like markdown/company/yasnippet) for inclusion in bug
> reports.

The code below might be a good starting point for this.  It is inspired
by `package-compute-transaction'.  It seems to work even with Debian's
package manager ("apt install elpa-project").  So I'd like to think that
a potential failure in the code is a sign that the bug reporter has a
non-standard installation.

(require 'find-func)
(require 'package)

(defun my-list-dependencies (packages &optional seen versions)
  "Retrun the versions of dependencies of PACKAGES.
Argument PACKAGES is a list of symbols.  SEEN, VERSION are used
internally."
  (while packages
    (let ((package (pop packages)))
      (unless (memq package seen)
        (push package seen)
        (let* ((file (condition-case error
                         (find-library-name (symbol-name package))
                       (error nil)))
               (pkg-desc (if file
                             (with-temp-buffer
                               (insert-file-contents file)
                               (package-buffer-info))
                           (if (eq package 'emacs)
                               (package-desc-create :name "emacs"
                                                    :version (version-to-list
                                                              emacs-version))
                             (package-desc-create :name (symbol-name package)
                                                  :version '(0))))))
          (push (package-desc-full-name pkg-desc) versions)
          (setq packages (append packages
                                 (mapcar #'car
                                         (package-desc-reqs pkg-desc))))))))
    versions)

(my-list-dependencies '(eglot markdown company other-optional-dependency))