[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
display keywords in package.el
From: |
Ted Zlatanov |
Subject: |
display keywords in package.el |
Date: |
Mon, 09 Dec 2013 11:01:28 -0500 |
User-agent: |
Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) |
The attached patch will:
- factor out the button creation to a new `package-make-button' function
- insert a list of clickable keywords for any package with a Keywords
header (it must be in the archive-contents extras; GNU ELPA has it and
other ELPAs like MELPA may wish to follow suit)
- clicking the keyword runs `(finder-list-matches "keyword")' which is
usually what the user wants.
TODO: `(finder-list-matches "keyword")' only looks at the local files,
if I understand finder.el correctly. It should be fixed to also display
the remote packages. I don't think it's required for this patch,
though, it can be done in a followup patch.
Let me know if you see any problems. I'll commit otherwise.
Thanks
Ted
=== modified file 'lisp/emacs-lisp/package.el'
--- lisp/emacs-lisp/package.el 2013-11-20 21:01:00 +0000
+++ lisp/emacs-lisp/package.el 2013-12-09 15:51:59 +0000
@@ -1353,7 +1353,9 @@
(reqs (if desc (package-desc-reqs desc)))
(version (if desc (package-desc-version desc)))
(archive (if desc (package-desc-archive desc)))
- (homepage (if desc (cdr (assoc :url (package-desc-extras desc)))))
+ (extras (and desc (package-desc-extras desc)))
+ (homepage (cdr (assoc :url extras)))
+ (keywords (cdr (assoc :keywords extras)))
(built-in (eq pkg-dir 'builtin))
(installable (and archive (not built-in)))
(status (if desc (package-desc-status desc) "orphan"))
@@ -1392,15 +1394,10 @@
(insert (capitalize status))
(insert " from " (format "%s" archive))
(insert " -- ")
- (let ((button-text (if (display-graphic-p) "Install" "[Install]"))
- (button-face (if (display-graphic-p)
- '(:box (:line-width 2 :color "dark grey")
- :background "light grey"
- :foreground "black")
- 'link)))
- (insert-text-button button-text 'face button-face 'follow-link t
- 'package-desc desc
- 'action 'package-install-button-action)))
+ (package-make-button
+ "Install"
+ 'action 'package-install-button-action
+ 'package-desc desc))
(t (insert (capitalize status) ".")))
(insert "\n")
(insert " " (propertize "Archive" 'font-lock-face 'bold)
@@ -1433,6 +1430,15 @@
(insert " " (propertize "Homepage" 'font-lock-face 'bold) ": ")
(help-insert-xref-button homepage 'help-url homepage)
(insert "\n"))
+ (when keywords
+ (insert " " (propertize "Keywords" 'font-lock-face 'bold) ": ")
+ (dolist (k keywords)
+ (package-make-button
+ k
+ 'package-keyword k
+ 'action 'package-keyword-button-action)
+ (insert " "))
+ (insert "\n"))
(let* ((all-pkgs (append (cdr (assq name package-alist))
(cdr (assq name package-archive-contents))
(let ((bi (assq name package--builtins)))
@@ -1503,6 +1509,20 @@
(revert-buffer nil t)
(goto-char (point-min)))))
+(defun package-keyword-button-action (button)
+ (let ((pkg-keyword (button-get button 'package-keyword)))
+ (finder-list-matches pkg-keyword)))
+
+(defun package-make-button (text &rest props)
+ (let ((button-text (if (display-graphic-p) text (concat "[" text "]")))
+ (button-face (if (display-graphic-p)
+ '(:box (:line-width 2 :color "dark grey")
+ :background "light grey"
+ :foreground "black")
+ 'link)))
+ (apply 'insert-text-button button-text 'face button-face 'follow-link t
+ props)))
+
;;;; Package menu mode.
- display keywords in package.el,
Ted Zlatanov <=
- Re: display keywords in package.el, Jambunathan K, 2013/12/11
- Re: display keywords in package.el, Ted Zlatanov, 2013/12/11
- Re: display keywords in package.el, Jambunathan K, 2013/12/11
- Re: display keywords in package.el, Stefan Monnier, 2013/12/11
- Re: display keywords in package.el, Ted Zlatanov, 2013/12/12
- Re: display keywords in package.el, Ted Zlatanov, 2013/12/14
- display keywords in package.el, T.V. Raman, 2013/12/15
- Re: display keywords in package.el, Stefan Monnier, 2013/12/15
- Re: display keywords in package.el, Ted Zlatanov, 2013/12/16