emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding a few more finder keywords


From: Oleh Krehel
Subject: Re: Adding a few more finder keywords
Date: Tue, 09 Jun 2015 18:47:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Drew Adams <address@hidden> writes:

> If you need something new, then add something new.  Don't
> compromise existing constructs that others have been happily
> using in ways you don't approve of or cannot make use of.
> Share the road.

It seems that a misunderstanding lead you to believe that someone is
enforcing something. I ensure you that this isn't so. There will never
be a warning unless the package author specifically runs an interactive
command because he wants to check if his package will generate a
warning.

Inventing a new section is an option, but it's a cumbersome and
unnecessary path. I can have what I want with just `Keywords:' without
imposing anything on anyone, possibly offering a guideline through a
separate checkdoc utility that so far comes disabled by default.

Let me show you what I have in mind. All the code I wrote just now, I
require nothing more than extending the list of recommended keywords:

(defun finder-add-packages ()
  (let ((keys (delete-dups (package-all-keywords))))
    (dolist (key keys)
      (let ((packages (package-menu--refresh t (list key)))
            (kw (intern key)))
        (puthash kw
                 (delete-dups
                  (append
                   (gethash kw finder-keywords-hash)
                   (mapcar (lambda (x)
                             (package-desc-name (car x)))
                           packages)))
                 finder-keywords-hash)))))

(defun finder-add-keywords ()
  (setq finder-known-keywords
      (mapcar
       (lambda (x)
         (cons x (prin1-to-string x)))
       (hash-table-keys finder-keywords-hash))))

(defun finder-add-good-keywords ()
  (setq finder-known-keywords
        (delete-dups
         (append finder-known-keywords
                 '((python . "Python programming language")
                   (clojure . "Clojure programming language")
                   (ocaml . "OCaml programming language"))))))

Call `finder-add-packages' to add the `package-list-packages' content to
`finder-keywords-hash'.

Now, calling `finder-add-keywords' will cause chaos: "M-x"
`finder-list-keywords' results in a buffer with 1473 lines.

But resetting `finder-known-keywords' to its definition and calling
`finder-add-good-keywords' will extend the amount of sections by 3 to 39
- still a comfortable number.  Now, very conveniently I can browse the
packages available for Python, Clojure and OCaml.  Zero changes in
outside packages. Zero changes to `Keywords:'. Only change is that some
keywords were promoted to `finder-known-keywords', and the package list
was processed into finder (which takes quite long - around 10 seconds).

This is all the functionality that I wanted. Now, I'd like to make this
functionality available to users, with (almost) zero configuration.
What remains to do is to add more than just these 3 keywords to
`finder-add-good-keywords', but not 1200.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]