unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: tags for functions
Date: Wed, 28 Jan 2009 11:41:33 -0600	[thread overview]
Message-ID: <86r62ne3aq.fsf@lifelogs.com> (raw)
In-Reply-To: 87hc3kfgb8.fsf@jurta.org

On Wed, 28 Jan 2009 02:02:51 +0200 Juri Linkov <juri@jurta.org> wrote: 

JL> (defun my-move-defun ()
JL>   "Docstring.
JL> @keywords keyword1, keyword2")

JL> (defun my-copy-defun ()
JL>   "Docstring.
JL> @keywords keyword3, keyword4")

JL> (let (keywordlist docstr)
JL>   (mapatoms
JL>    (lambda (symbol)
JL>      (when (and (functionp symbol) (setq docstr (documentation symbol t))
JL>                 (string-match "@keywords \\(.*\\)" docstr))
JL>        (add-to-list 'keywordlist
JL>                     (cons symbol (split-string (match-string 1 docstr)
JL>                                                "\\s-*,\\s-*" t))))))
JL>   keywordlist)

JL> => '((my-copy-defun "keyword3" "keyword4")
JL>      (my-move-defun "keyword1" "keyword2"))

I see, thank you for explaining.

On Wed, 28 Jan 2009 01:36:03 +0100 Lennart Borgman <lennart.borgman@gmail.com> wrote: 

LB> 8.4 seconds (evaled) on my pc.

LB> Maybe :keywords is better?

It seems to me that modifying (defun) to update a cache is the best
approach, since that's the only way the documentation string is normally
created or modified AFAIK.  Maybe a defun-after-hook would be
appropriate, in case people want to run other code on a defun call?  At
least for me, a defun-after-hook would solve it, and require no changes
outside of setting up defun-after-hook.  In contrast, :keywords requires
changing things significantly, and (declare) as Stefan suggested
requires code changes everywhere.

Setting things up would require, at any point:

1) fill defun-after-hook with the cache population function

2) populate the cache with all the docs for functions already defined,
using mapatoms

So it doesn't require to be set up at any particular time, and can be a
loadable package.

Also, this needs to be fast.  The cache can hold reverse mapping from
keyword to list of functions, so it would be much faster to mapatoms for
the common usage scenarios (look up all keywords and look up functions
for a keyword).  Obviously, looking up keywords for function doesn't
require mapatoms so it will be fast regardless.

Thanks
Ted





  parent reply	other threads:[~2009-01-28 17:41 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-20 20:36 tags for functions Ted Zlatanov
2009-01-20 20:44 ` Lennart Borgman
2009-01-21 22:11   ` Ted Zlatanov
2009-01-21 22:13     ` Lennart Borgman
2009-01-22 14:20       ` Ted Zlatanov
2009-01-22 19:39         ` Stefan Monnier
2009-01-22 20:09           ` Ted Zlatanov
2009-01-21 22:22     ` Glenn Morris
2009-01-22 14:54       ` Ted Zlatanov
2009-01-25  0:32         ` Juri Linkov
2009-01-26 19:50           ` Ted Zlatanov
2009-01-26 23:55             ` Juri Linkov
2009-01-27 14:31               ` Ted Zlatanov
2009-01-28  0:02                 ` Juri Linkov
2009-01-28  0:36                   ` Lennart Borgman
2009-01-28 17:41                   ` Ted Zlatanov [this message]
2009-01-28 18:40                     ` Stefan Monnier
2009-01-28 20:38                       ` Ted Zlatanov
2009-01-29  1:43                         ` Stefan Monnier
2009-01-29 20:03                           ` Ted Zlatanov
2009-01-29 21:52                             ` Stefan Monnier
2009-01-30 15:34                               ` Ted Zlatanov
2009-01-30 16:06                                 ` Drew Adams
2009-01-30 16:52                                   ` Ted Zlatanov
2009-01-31 17:52                                     ` Juri Linkov
2009-01-31  1:55                                   ` Stefan Monnier
2009-01-31  2:02                                     ` Drew Adams
2009-01-29 20:32                           ` Lennart Borgman
2009-01-30 15:29                             ` Ted Zlatanov
  -- strict thread matches above, loose matches on Subject: below --
2009-01-22  8:07 MON KEY
2009-01-22 14:47 ` Ted Zlatanov
2009-01-22 18:15 S+*n_Pe*rm*n
2009-01-22 18:49 ` MON KEY
2009-01-22 20:38 ` Ted Zlatanov
2009-01-23  1:46 S+*n_Pe*rm*n
2009-01-27 18:53 ` MON KEY

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=86r62ne3aq.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --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).