From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron Newsgroups: gmane.emacs.devel Subject: Re: NonGNU ELPA: New package 'xdg-appmenu' Date: Sun, 09 Jul 2023 22:39:32 +0300 Message-ID: <87y1jodgcr.fsf@eshelyaron.com> References: <871qhivj86.fsf@disroot.org> <87mt05argj.fsf@disroot.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38608"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Emacs Developer List To: Akib Azmain Turja Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jul 09 21:40:38 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qIaGs-0009qZ-Cj for ged-emacs-devel@m.gmane-mx.org; Sun, 09 Jul 2023 21:40:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIaG1-0004t1-QH; Sun, 09 Jul 2023 15:39:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIaFz-0004rv-AG for emacs-devel@gnu.org; Sun, 09 Jul 2023 15:39:44 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIaFx-0006cl-OH for emacs-devel@gnu.org; Sun, 09 Jul 2023 15:39:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1688931580; bh=p5g89tOxcKgTFY5ePdIVY1Grzb1o2dIMMvQK1qJQqEU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=WwGfN0rpdjIZm+TJFPNX13ftKgmobxVXv7chHj4p+Pxc2gI8qd2hvwWfNX+Xp9E+o QPTx5HB06LyzAhQiyKJPP2qEgAdqyB7cFVmxShZeMCp5yKKHJ/FfzP74+wJ0odlK0T /NH6DU6EQ6dWkmbuaoaJfv3gxfAVntRFJ4ITXUZJR/aw+sq67eW6BzNun+Aoaq66A9 hlke8ULYUAdXoEcA8axs5MrBjYKnduf87BFVd+uQHtv17tEpRHBBZfcPwWIO2X/YQ0 L36t3KiLgRFTCO9zNMwg9hJ+WjlhIi7/3hqmInZKQ/bw5XGa/MKf6NRlFLLs4ImizD GENc1Y5FBXQyA== In-Reply-To: <87mt05argj.fsf@disroot.org> (Akib Azmain Turja's message of "Mon, 10 Jul 2023 00:07:56 +0600") Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@eshelyaron.com; helo=eshelyaron.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307699 Archived-At: 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.