unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A way to get a list of available functions / variables?
@ 2008-02-24 16:20 Taylor Venable
  2008-02-24 16:38 ` Johannes Weiner
  0 siblings, 1 reply; 6+ messages in thread
From: Taylor Venable @ 2008-02-24 16:20 UTC (permalink / raw)
  To: emacs-devel

Is there a way to programmatically get the list of available functions?
I'm thinking there must be a table somewhere which relates symbol names
to actual function definitions, but can you get all the names in the
table from Lisp code?  If so, my second question would then be if I
could do the same for variables.

The reason I ask is I've got this thing going on at my college where
I'll write up an Emacs "function of the day" on the whiteboard in the
computer science lounge.  It'd be cool if I could automate this process
to automatically choose a random function or variable and build like an
RSS feed of the results or something.  Because I don't know how many
times I've been just randomly browsing around the documentation or
source and found something like c-subword-mode that I otherwise would
not have known even existed!

Thanks.

-- 
Taylor Venable            http://real.metasyntax.net:2357/

foldr = lambda f, i, l: (len(l) == 1 and [f(l[0], i)] or
                         [f(l[0], foldr(f, i, l[1:]))])[0]




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

* Re: A way to get a list of available functions / variables?
  2008-02-24 16:20 A way to get a list of available functions / variables? Taylor Venable
@ 2008-02-24 16:38 ` Johannes Weiner
  2008-02-25  1:42   ` Taylor Venable
  2008-05-16 22:23   ` Davis Herring
  0 siblings, 2 replies; 6+ messages in thread
From: Johannes Weiner @ 2008-02-24 16:38 UTC (permalink / raw)
  To: Taylor Venable; +Cc: emacs-devel

Hi,

Taylor Venable <taylor@metasyntax.net> writes:

> Is there a way to programmatically get the list of available functions?
> I'm thinking there must be a table somewhere which relates symbol names
> to actual function definitions, but can you get all the names in the
> table from Lisp code?  If so, my second question would then be if I
> could do the same for variables.

mapatoms might help:

(let (cmds vars)
  (mapatoms (lambda (atom)
	      (cond
	       ((commandp atom)
		(setq cmds (cons atom cmds)))
	       ((custom-variable-p atom)
		(setq vars (cons atom vars)))))))

Or with CL functions and without distinguishing between commands and
variables:

(remove-if-not (lambda (atom)
		 (or (commandp atom)
		     (custom-variable-p atom)))
	       obarray)

> The reason I ask is I've got this thing going on at my college where
> I'll write up an Emacs "function of the day" on the whiteboard in the
> computer science lounge.  It'd be cool if I could automate this process
> to automatically choose a random function or variable and build like an
> RSS feed of the results or something.  Because I don't know how many
> times I've been just randomly browsing around the documentation or
> source and found something like c-subword-mode that I otherwise would
> not have known even existed!

Sounds like a good idea.

	Hannes




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

* Re: A way to get a list of available functions / variables?
  2008-02-24 16:38 ` Johannes Weiner
@ 2008-02-25  1:42   ` Taylor Venable
  2008-02-26  2:00     ` Xavier Maillard
  2008-05-16 22:23   ` Davis Herring
  1 sibling, 1 reply; 6+ messages in thread
From: Taylor Venable @ 2008-02-25  1:42 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: emacs-devel

Johannes Weiner <hannes@saeurebad.de> writes:

>> Is there a way to programmatically get the list of available functions?
>> I'm thinking there must be a table somewhere which relates symbol names
>> to actual function definitions, but can you get all the names in the
>> table from Lisp code?  If so, my second question would then be if I
>> could do the same for variables.
>
> mapatoms might help:
>
> (let (cmds vars)
>   (mapatoms (lambda (atom)
> 	      (cond
> 	       ((commandp atom)
> 		(setq cmds (cons atom cmds)))
> 	       ((custom-variable-p atom)
> 		(setq vars (cons atom vars)))))))

That is very cool, thanks much!

>> The reason I ask is I've got this thing going on at my college where
>> I'll write up an Emacs "function of the day" on the whiteboard in the
>> computer science lounge.  It'd be cool if I could automate this process
>> to automatically choose a random function or variable and build like an
>> RSS feed of the results or something.  Because I don't know how many
>> times I've been just randomly browsing around the documentation or
>> source and found something like c-subword-mode that I otherwise would
>> not have known even existed!
>
> Sounds like a good idea.

Thanks; I'll post to emacs-help when I get it finished and working suitably.

-- 
Taylor Venable            http://real.metasyntax.net:2357/

foldr = lambda f, i, l: (len(l) == 1 and [f(l[0], i)] or
                         [f(l[0], foldr(f, i, l[1:]))])[0]




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

* Re: A way to get a list of available functions / variables?
  2008-02-25  1:42   ` Taylor Venable
@ 2008-02-26  2:00     ` Xavier Maillard
  0 siblings, 0 replies; 6+ messages in thread
From: Xavier Maillard @ 2008-02-26  2:00 UTC (permalink / raw)
  To: Taylor Venable; +Cc: hannes, emacs-devel


   Thanks; I'll post to emacs-help when I get it finished and working suitably.

You'd rather want to post this into gnu-emacs-source instead
which is a "source code oriented mailing-list" for GNU Emacs.

	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org




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

* Re: A way to get a list of available functions / variables?
  2008-02-24 16:38 ` Johannes Weiner
  2008-02-25  1:42   ` Taylor Venable
@ 2008-05-16 22:23   ` Davis Herring
  2008-05-16 22:33     ` David Kastrup
  1 sibling, 1 reply; 6+ messages in thread
From: Davis Herring @ 2008-05-16 22:23 UTC (permalink / raw)
  To: emacs-devel; +Cc: Taylor Venable

> (remove-if-not (lambda (atom)
> 		 (or (commandp atom)
> 		     (custom-variable-p atom)))
> 	       obarray)

Unless CL is a lot more clever than I think it is, this won't work: the
obarray is really a hash table with linked buckets, and Lisp can't see the
links.  (See (elisp)Creating symbols.)

Davis

PS - Sorry for the long delay in writing this.

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.




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

* Re: A way to get a list of available functions / variables?
  2008-05-16 22:23   ` Davis Herring
@ 2008-05-16 22:33     ` David Kastrup
  0 siblings, 0 replies; 6+ messages in thread
From: David Kastrup @ 2008-05-16 22:33 UTC (permalink / raw)
  To: herring; +Cc: Taylor Venable, emacs-devel

"Davis Herring" <herring@lanl.gov> writes:

>> (remove-if-not (lambda (atom)
>> 		 (or (commandp atom)
>> 		     (custom-variable-p atom)))
>> 	       obarray)
>
> Unless CL is a lot more clever than I think it is, this won't work: the
> obarray is really a hash table with linked buckets, and Lisp can't see the
> links.  (See (elisp)Creating symbols.)

That's what mapatoms is for.

(let (l) (mapatoms (lambda (atom) (when (or (commandp atom)
  (custom-variable-p atom)) (push atom l)))) l)


-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




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

end of thread, other threads:[~2008-05-16 22:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-24 16:20 A way to get a list of available functions / variables? Taylor Venable
2008-02-24 16:38 ` Johannes Weiner
2008-02-25  1:42   ` Taylor Venable
2008-02-26  2:00     ` Xavier Maillard
2008-05-16 22:23   ` Davis Herring
2008-05-16 22:33     ` David Kastrup

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