diff options
| author | Philip Kaludercic | 2022-02-14 13:47:31 +0100 |
|---|---|---|
| committer | Philip Kaludercic | 2022-02-14 14:59:05 +0100 |
| commit | edd73bd0d5474b71cbd4261c6a722be8f652bb9a (patch) | |
| tree | 958400ee6111967493ed902395b69abe9f0c0a0c | |
| parent | 04c4c578c71cae77b3b782497808bb2321da3be1 (diff) | |
| download | emacs-edd73bd0d5474b71cbd4261c6a722be8f652bb9a.tar.gz emacs-edd73bd0d5474b71cbd4261c6a722be8f652bb9a.zip | |
Add command to contact maintainer
* package.el (package-menu-mode-map): Add package-contact-maintainer.
(package--query-desc): Extract a common utility function.
(package-browse-url): Use package--query-desc.
(package-contact-maintainer): Add command.
| -rw-r--r-- | lisp/emacs-lisp/package.el | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index c3f6174c19a..58fc55da124 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el | |||
| @@ -2917,6 +2917,7 @@ either a full name or nil, and EMAIL is a valid email address." | |||
| 2917 | "r" #'revert-buffer | 2917 | "r" #'revert-buffer |
| 2918 | "~" #'package-menu-mark-obsolete-for-deletion | 2918 | "~" #'package-menu-mark-obsolete-for-deletion |
| 2919 | "w" #'package-browse-url | 2919 | "w" #'package-browse-url |
| 2920 | "m" #'package-contact-maintainer | ||
| 2920 | "x" #'package-menu-execute | 2921 | "x" #'package-menu-execute |
| 2921 | "h" #'package-menu-quick-help | 2922 | "h" #'package-menu-quick-help |
| 2922 | "H" #'package-menu-hide-package | 2923 | "H" #'package-menu-hide-package |
| @@ -4378,11 +4379,22 @@ beginning of the line." | |||
| 4378 | (package-version-join (package-desc-version package-desc)) | 4379 | (package-version-join (package-desc-version package-desc)) |
| 4379 | (package-desc-summary package-desc)))) | 4380 | (package-desc-summary package-desc)))) |
| 4380 | 4381 | ||
| 4382 | (defun package--query-desc (&optional alist) | ||
| 4383 | "Query the user for a package or return the package at point. | ||
| 4384 | The optional argument ALIST must consist of elements with the | ||
| 4385 | form (PKG-NAME PKG-DESC). If not specified, it will default to | ||
| 4386 | `package-alist'." | ||
| 4387 | (or (tabulated-list-get-id) | ||
| 4388 | (let ((alist (or alist package-alist))) | ||
| 4389 | (cadr (assoc (completing-read "Package: " alist nil t) | ||
| 4390 | alist #'string=))))) | ||
| 4391 | |||
| 4381 | (defun package-browse-url (desc &optional secondary) | 4392 | (defun package-browse-url (desc &optional secondary) |
| 4382 | "Open the website of the package under point in a browser. | 4393 | "Open the website of the package under point in a browser. |
| 4383 | `browse-url' is used to determine the browser to be used. | 4394 | `browse-url' is used to determine the browser to be used. If |
| 4384 | If SECONDARY (interactively, the prefix), use the secondary browser." | 4395 | SECONDARY (interactively, the prefix), use the secondary browser. |
| 4385 | (interactive (list (tabulated-list-get-id) | 4396 | DESC must be a `package-desc' object." |
| 4397 | (interactive (list (package--query-desc) | ||
| 4386 | current-prefix-arg) | 4398 | current-prefix-arg) |
| 4387 | package-menu-mode) | 4399 | package-menu-mode) |
| 4388 | (unless desc | 4400 | (unless desc |
| @@ -4394,6 +4406,28 @@ If SECONDARY (interactively, the prefix), use the secondary browser." | |||
| 4394 | (funcall browse-url-secondary-browser-function url) | 4406 | (funcall browse-url-secondary-browser-function url) |
| 4395 | (browse-url url)))) | 4407 | (browse-url url)))) |
| 4396 | 4408 | ||
| 4409 | ;; TODO: Allow attaching a patch to send directly to the maintainer. | ||
| 4410 | ;; Ideally this should be able to detect the local changes, convert | ||
| 4411 | ;; these into patches. | ||
| 4412 | (defun package-contact-maintainer (desc) | ||
| 4413 | "Prepare a message to send to the maintainers of a package. | ||
| 4414 | DESC must be a `package-desc' object." | ||
| 4415 | (interactive (list (package--query-desc package-archive-contents)) | ||
| 4416 | package-menu-mode) | ||
| 4417 | (unless desc | ||
| 4418 | (user-error "No package here")) | ||
| 4419 | (let* ((extras (package-desc-extras desc)) | ||
| 4420 | (maint (alist-get :maintainer extras)) | ||
| 4421 | (name (package-desc-name desc)) | ||
| 4422 | (subject (read-string "Subject: "))) | ||
| 4423 | (unless maint | ||
| 4424 | (user-error "Package has no explicit maintainer")) | ||
| 4425 | (compose-mail | ||
| 4426 | (with-temp-buffer | ||
| 4427 | (package--print-email-button maint) | ||
| 4428 | (string-trim (substring-no-properties (buffer-string)))) | ||
| 4429 | (format "[%s] %s" name subject)))) | ||
| 4430 | |||
| 4397 | ;;;; Introspection | 4431 | ;;;; Introspection |
| 4398 | 4432 | ||
| 4399 | (defun package-get-descriptor (pkg-name) | 4433 | (defun package-get-descriptor (pkg-name) |