[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tags for functions
From: |
Ted Zlatanov |
Subject: |
Re: tags for functions |
Date: |
Wed, 28 Jan 2009 11:41:33 -0600 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) |
On Wed, 28 Jan 2009 02:02:51 +0200 Juri Linkov <address@hidden> 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 <address@hidden> 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
- Re: tags for functions, (continued)
- Re: tags for functions, Stefan Monnier, 2009/01/22
- Re: tags for functions, Ted Zlatanov, 2009/01/22
- Re: tags for functions, Glenn Morris, 2009/01/21
- Re: tags for functions, Ted Zlatanov, 2009/01/22
- Re: tags for functions, Juri Linkov, 2009/01/24
- Re: tags for functions, Ted Zlatanov, 2009/01/26
- Re: tags for functions, Juri Linkov, 2009/01/26
- Re: tags for functions, Ted Zlatanov, 2009/01/27
- Re: tags for functions, Juri Linkov, 2009/01/27
- Re: tags for functions, Lennart Borgman, 2009/01/27
- Re: tags for functions,
Ted Zlatanov <=
- Re: tags for functions, Stefan Monnier, 2009/01/28
- Re: tags for functions, Ted Zlatanov, 2009/01/28
- Re: tags for functions, Stefan Monnier, 2009/01/28
- Re: tags for functions, Ted Zlatanov, 2009/01/29
- Re: tags for functions, Stefan Monnier, 2009/01/29
- Re: tags for functions, Ted Zlatanov, 2009/01/30
- RE: tags for functions, Drew Adams, 2009/01/30
- Re: tags for functions, Ted Zlatanov, 2009/01/30
- Re: tags for functions, Juri Linkov, 2009/01/31
- Re: tags for functions, Stefan Monnier, 2009/01/30