unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* display keywords in package.el
@ 2013-12-09 16:01 Ted Zlatanov
  2013-12-11 11:13 ` Jambunathan K
  0 siblings, 1 reply; 10+ messages in thread
From: Ted Zlatanov @ 2013-12-09 16:01 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 726 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: package-describe-keywords.patch --]
[-- Type: text/x-diff, Size: 2949 bytes --]

=== 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)))
+
 \f
 ;;;; Package menu mode.
 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: display keywords in package.el
  2013-12-09 16:01 display keywords in package.el Ted Zlatanov
@ 2013-12-11 11:13 ` Jambunathan K
  2013-12-11 19:04   ` Ted Zlatanov
  0 siblings, 1 reply; 10+ messages in thread
From: Jambunathan K @ 2013-12-11 11:13 UTC (permalink / raw)
  To: emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

> `(finder-list-matches "keyword")'

(require 'finder) is missing.

I get the following error.

package-keyword-button-action: Symbol's function definition is void:
finder-list-matches



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: display keywords in package.el
  2013-12-11 11:13 ` Jambunathan K
@ 2013-12-11 19:04   ` Ted Zlatanov
  2013-12-11 19:12     ` Jambunathan K
  2013-12-12  3:34     ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: Ted Zlatanov @ 2013-12-11 19:04 UTC (permalink / raw)
  To: emacs-devel

On Wed, 11 Dec 2013 16:43:51 +0530 Jambunathan K <kjambunathan@gmail.com> wrote: 

JK> Ted Zlatanov <tzz@lifelogs.com> writes:
>> `(finder-list-matches "keyword")'

JK> (require 'finder) is missing.

JK> I get the following error.

JK> package-keyword-button-action: Symbol's function definition is void:
JK> finder-list-matches

Well, finder.el requires package.el... it's a circular dependency.  But
there's nothing else in Emacs that will browse packages by keyword.

Ted




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: display keywords in package.el
  2013-12-11 19:04   ` Ted Zlatanov
@ 2013-12-11 19:12     ` Jambunathan K
  2013-12-12  3:34     ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Jambunathan K @ 2013-12-11 19:12 UTC (permalink / raw)
  To: emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

> Well, finder.el requires package.el... it's a circular dependency.  But
> there's nothing else in Emacs that will browse packages by keyword.

I am on version "115462
dmantipov@yandex.ru-20131211150604-oevkf8sugu925g0l"

1. M-x list-packages
2. Put your cursor on all.el line
3. ?
4. left click on button named "matching" in help buffer

package-keyword-button-action: Symbol's function definition is void:
finder-list-matches

If I,

   M-x load-library finder

left click works and shows regi.   



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: display keywords in package.el
  2013-12-11 19:04   ` Ted Zlatanov
  2013-12-11 19:12     ` Jambunathan K
@ 2013-12-12  3:34     ` Stefan Monnier
  2013-12-12 15:38       ` Ted Zlatanov
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2013-12-12  3:34 UTC (permalink / raw)
  To: emacs-devel

> But there's nothing else in Emacs that will browse packages
> by keyword.

We should fix this, by adding a "filter by keyword" option to
package-list.


        Stefan



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: display keywords in package.el
  2013-12-12  3:34     ` Stefan Monnier
@ 2013-12-12 15:38       ` Ted Zlatanov
  2013-12-14 20:03         ` Ted Zlatanov
  0 siblings, 1 reply; 10+ messages in thread
From: Ted Zlatanov @ 2013-12-12 15:38 UTC (permalink / raw)
  To: emacs-devel

On Wed, 11 Dec 2013 22:34:38 -0500 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote: 

>> But there's nothing else in Emacs that will browse packages
>> by keyword.

SM> We should fix this, by adding a "filter by keyword" option to
SM> package-list.

That's my plan, but finder.el already does this.  It makes no sense to
keep two separate interfaces for browsing local-only (finder.el) and
local+remote packages (package.el).  So I was going to implement it more
generally ASAP (when I have the time).

Meanwhile we can simply remove the button action for the keywords or
leave it broken.  I opted to leave it broken temporarily because it's
a very "soft" failure and does not break anything AFAIK.

Ted




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: display keywords in package.el
  2013-12-12 15:38       ` Ted Zlatanov
@ 2013-12-14 20:03         ` Ted Zlatanov
  2013-12-16  0:19           ` T.V. Raman
  0 siblings, 1 reply; 10+ messages in thread
From: Ted Zlatanov @ 2013-12-14 20:03 UTC (permalink / raw)
  To: emacs-devel

On Thu, 12 Dec 2013 10:38:25 -0500 Ted Zlatanov <tzz@lifelogs.com> wrote: 

TZ> On Wed, 11 Dec 2013 22:34:38 -0500 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote: 
>>> But there's nothing else in Emacs that will browse packages
>>> by keyword.

SM> We should fix this, by adding a "filter by keyword" option to
SM> package-list.

TZ> That's my plan, but finder.el already does this.  It makes no sense to
TZ> keep two separate interfaces for browsing local-only (finder.el) and
TZ> local+remote packages (package.el).  So I was going to implement it more
TZ> generally ASAP (when I have the time).

TZ> Meanwhile we can simply remove the button action for the keywords or
TZ> leave it broken.  I opted to leave it broken temporarily because it's
TZ> a very "soft" failure and does not break anything AFAIK.

This is implemented properly now:

* `f' and a menu item will filter by keyword

* the header line shows "Package[keyword]" when the list is filtered

* `q' leaves the filtered view, kind of like finder

* only one level of filtering and one keyword are supported

* there is no keyword list menu like finder.el has

* remove finder.el dependency

* convenience `package-menu-filter-interactive' interactive function
  (maybe it should be `list-packages-keyword'?)

* very handy `package--mapc' helper function added
  
Future work (please do it if you're interested):

* `package-menu--generate' could use `package--mapc'

* merge finder.el and package.el and remove the need for finder-inf.el
  and the `finder-keywords-hash' and so on.

* keyword list menu like finder.el has

Let me know if you have issues...
Ted




^ permalink raw reply	[flat|nested] 10+ messages in thread

* display keywords in package.el
  2013-12-14 20:03         ` Ted Zlatanov
@ 2013-12-16  0:19           ` T.V. Raman
  2013-12-16  3:50             ` Stefan Monnier
  2013-12-16 14:26             ` Ted Zlatanov
  0 siblings, 2 replies; 10+ messages in thread
From: T.V. Raman @ 2013-12-16  0:19 UTC (permalink / raw)
  To: emacs-devel

Would be nice to filter by archive.

I tried  a quick and dirty impl by let-binding package-archives
but sadly that didn't work.
-- 

-- 


On 12/14/13, Ted Zlatanov <tzz@lifelogs.com> wrote:
> On Thu, 12 Dec 2013 10:38:25 -0500 Ted Zlatanov <tzz@lifelogs.com> wrote:
>
> TZ> On Wed, 11 Dec 2013 22:34:38 -0500 Stefan Monnier
> <monnier@IRO.UMontreal.CA> wrote:
>>>> But there's nothing else in Emacs that will browse packages
>>>> by keyword.
>
> SM> We should fix this, by adding a "filter by keyword" option to
> SM> package-list.
>
> TZ> That's my plan, but finder.el already does this.  It makes no sense to
> TZ> keep two separate interfaces for browsing local-only (finder.el) and
> TZ> local+remote packages (package.el).  So I was going to implement it
> more
> TZ> generally ASAP (when I have the time).
>
> TZ> Meanwhile we can simply remove the button action for the keywords or
> TZ> leave it broken.  I opted to leave it broken temporarily because it's
> TZ> a very "soft" failure and does not break anything AFAIK.
>
> This is implemented properly now:
>
> * `f' and a menu item will filter by keyword
>
> * the header line shows "Package[keyword]" when the list is filtered
>
> * `q' leaves the filtered view, kind of like finder
>
> * only one level of filtering and one keyword are supported
>
> * there is no keyword list menu like finder.el has
>
> * remove finder.el dependency
>
> * convenience `package-menu-filter-interactive' interactive function
>   (maybe it should be `list-packages-keyword'?)
>
> * very handy `package--mapc' helper function added
>
> Future work (please do it if you're interested):
>
> * `package-menu--generate' could use `package--mapc'
>
> * merge finder.el and package.el and remove the need for finder-inf.el
>   and the `finder-keywords-hash' and so on.
>
> * keyword list menu like finder.el has
>
> Let me know if you have issues...
> Ted
>
>
>



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: display keywords in package.el
  2013-12-16  0:19           ` T.V. Raman
@ 2013-12-16  3:50             ` Stefan Monnier
  2013-12-16 14:26             ` Ted Zlatanov
  1 sibling, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2013-12-16  3:50 UTC (permalink / raw)
  To: T.V. Raman; +Cc: emacs-devel

> Would be nice to filter by archive.
> I tried  a quick and dirty impl by let-binding package-archives
> but sadly that didn't work.

You can sort by archives, which should in most cases provide
a sufficient approximation.


        Stefan



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: display keywords in package.el
  2013-12-16  0:19           ` T.V. Raman
  2013-12-16  3:50             ` Stefan Monnier
@ 2013-12-16 14:26             ` Ted Zlatanov
  1 sibling, 0 replies; 10+ messages in thread
From: Ted Zlatanov @ 2013-12-16 14:26 UTC (permalink / raw)
  To: emacs-devel

On Sun, 15 Dec 2013 16:19:01 -0800 "T.V. Raman" <tv.raman.tv@gmail.com> wrote: 

TVR> Would be nice to filter by archive.
TVR> I tried  a quick and dirty impl by let-binding package-archives
TVR> but sadly that didn't work.

I can implement this but don't see the use case.  What's the practical
difference between one package archive and another, as far as the user
is concerned?  I have never needed it.

I could rework the keywords search to be more generic, though.  I think
the more typical use cases are:

* filter out unsigned packages
* search for a regex in the source
* filter by author

I still think we should allow only one filter at a time to keep the UI
and the code simple, so these would be compounded in the search spec.

Ted




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-12-16 14:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-09 16:01 display keywords in package.el Ted Zlatanov
2013-12-11 11:13 ` Jambunathan K
2013-12-11 19:04   ` Ted Zlatanov
2013-12-11 19:12     ` Jambunathan K
2013-12-12  3:34     ` Stefan Monnier
2013-12-12 15:38       ` Ted Zlatanov
2013-12-14 20:03         ` Ted Zlatanov
2013-12-16  0:19           ` T.V. Raman
2013-12-16  3:50             ` Stefan Monnier
2013-12-16 14:26             ` Ted Zlatanov

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).