From: Eshel Yaron <me@eshelyaron.com>
To: Akib Azmain Turja <akib@disroot.org>
Cc: Emacs Developer List <emacs-devel@gnu.org>
Subject: Re: NonGNU ELPA: New package 'xdg-appmenu'
Date: Sun, 09 Jul 2023 22:39:32 +0300 [thread overview]
Message-ID: <87y1jodgcr.fsf@eshelyaron.com> (raw)
In-Reply-To: <87mt05argj.fsf@disroot.org> (Akib Azmain Turja's message of "Mon, 10 Jul 2023 00:07:56 +0600")
Hey,
>> XDG Appmenu allows you to run XDG desktop application right from your
>> Emacs. To run an application, just do `M-x xdg-appmenu'.
I've just tried it out and it seems convenient and works really well!
One suggestion: you could add an `annotation-function` in `xdg-appmenu`
instead of relying on integration with `marginalia`. That way you can
get mostly the same results without requiring the user to install and
configure `marginalia`. E.g.:
diff --git a/xdg-appmenu.el b/xdg-appmenu.el
index 733b5d7..a47dc99 100644
--- a/xdg-appmenu.el
+++ b/xdg-appmenu.el
@@ -29,13 +29,6 @@ ;;; Commentary:
;; XDG Appmenu allows you to run XDG desktop application right from
;; your Emacs. To run an application, just do `M-x xdg-appmenu'.
-;; If you use Marginalia, you might want to add the following to your
-;; init file to show the description of each application in the
-;; minibuffer prompt:
-
-;; (push '(xdg-app xdg-appmenu-marginalia-annotate builtin none)
-;; marginalia-annotator-registry)
-
;;; Code:
(require 'subr-x)
@@ -177,7 +170,8 @@ (defun xdg-appmenu (app)
"Run application: "
(lambda (string pred action)
(if (eq action 'metadata)
- `(metadata (category . xdg-app))
+ `(metadata (category . xdg-app)
+ (annotation-function . xdg-appmenu-annotate))
(complete-with-action action xdg-appmenu--list
string pred)))
nil t nil 'xdg-appmenu-history))))
@@ -189,18 +183,18 @@ (defun xdg-appmenu (app)
(when (nth 3 spec)
(pop-to-buffer-same-window buffer)))))
-(defvar marginalia-separator)
-(declare-function marginalia--truncate "marginalia")
-
-(defun xdg-appmenu-marginalia-annotate (cand)
+(defun xdg-appmenu-annotate (cand)
"Annotate candidate CAND with its comment."
- (let ((spec (assoc cand xdg-appmenu--list)))
- (if (or (not spec) (not (nth 4 spec))
- (string-empty-p (nth 4 spec)))
- ""
- (concat #(" " 0 1 (marginalia--align t)) marginalia-separator
- (propertize (marginalia--truncate (nth 4 spec) 1.0)
- 'face 'marginalia-documentation)))))
+ (let* ((spec (assoc cand xdg-appmenu--list))
+ (max-width (seq-max (mapcar #'string-width
+ (mapcar #'car
+ xdg-appmenu--list))))
+ (annotation (nth 4 spec)))
+ (unless (or (not annotation) (string-empty-p annotation))
+ (concat
+ (propertize " " 'display
+ `(space :align-to ,(+ 2 max-width)))
+ (truncate-string-to-width annotation 80 nil nil t)))))
(defun xdg-appmenu-terminal-runner-term (app command)
"Run shell command COMMAND in a Term buffer.
next prev parent reply other threads:[~2023-07-09 19:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-08 9:35 NonGNU ELPA: New package 'xdg-appmenu' Akib Azmain Turja
2023-07-09 18:07 ` Akib Azmain Turja
2023-07-09 19:39 ` Eshel Yaron [this message]
2023-07-10 1:59 ` Richard Stallman
2023-07-10 7:53 ` Akib Azmain Turja
2023-07-19 16:23 ` Akib Azmain Turja
2023-09-05 18:31 ` Akib Azmain Turja
2023-09-05 20:11 ` Stefan Kangas
2023-09-06 6:27 ` Juri Linkov
2023-09-06 7:13 ` Stefan Kangas
2023-09-06 18:47 ` Akib Azmain Turja
2023-09-06 20:00 ` Stefan Kangas
2023-09-06 7:42 ` Philip Kaludercic
2023-09-06 18:56 ` Akib Azmain Turja
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y1jodgcr.fsf@eshelyaron.com \
--to=me@eshelyaron.com \
--cc=akib@disroot.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).