From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: tags for functions Date: Wed, 28 Jan 2009 11:41:33 -0600 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <86r62ne3aq.fsf@lifelogs.com> References: <867i4pemv5.fsf@lifelogs.com> <86y6x49un4.fsf@lifelogs.com> <86ljt39ysz.fsf@lifelogs.com> <87tz7oxodr.fsf@jurta.org> <86mydd3kzv.fsf@lifelogs.com> <87pri9k64b.fsf@jurta.org> <86ljsw252p.fsf@lifelogs.com> <87hc3kfgb8.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1233165513 26866 80.91.229.12 (28 Jan 2009 17:58:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Jan 2009 17:58:33 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 28 18:59:47 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LSEhV-00064J-OI for ged-emacs-devel@m.gmane.org; Wed, 28 Jan 2009 18:59:46 +0100 Original-Received: from localhost ([127.0.0.1]:54059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSEgD-0000lD-Mm for ged-emacs-devel@m.gmane.org; Wed, 28 Jan 2009 12:58:25 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LSEOg-0004LB-JC for emacs-devel@gnu.org; Wed, 28 Jan 2009 12:40:18 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LSEOf-0004JG-4c for emacs-devel@gnu.org; Wed, 28 Jan 2009 12:40:17 -0500 Original-Received: from [199.232.76.173] (port=42373 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSEOe-0004It-Qm for emacs-devel@gnu.org; Wed, 28 Jan 2009 12:40:16 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:48940 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LSEOe-0005xr-B7 for emacs-devel@gnu.org; Wed, 28 Jan 2009 12:40:16 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LSEOc-0005aj-8g for emacs-devel@gnu.org; Wed, 28 Jan 2009 17:40:14 +0000 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 28 Jan 2009 17:40:14 +0000 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 28 Jan 2009 17:40:14 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 58 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:FoUeMHnTP9sZJzvhXt7pUzsZuQw= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:108330 Archived-At: On Wed, 28 Jan 2009 02:02:51 +0200 Juri Linkov 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 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