Emacs is digested better in bite sized chunks.
--
Ron Denis
E-mail : rde...@lucent.com
Consultant
Lucent Technologies Inc.
> Is there a package available (google found none) which could show me
> something like a "command/function of the day".
The race to write `Info-goto-random-emacs-command-node' is probably on right
now....
--
Dave Pearson: | lbdb.el - LBDB interface.
http://www.davep.org/ | sawfish.el - Sawfish mode.
Emacs: | uptimes.el - Record emacs uptimes.
http://www.davep.org/emacs/ | quickurl.el - Recall lists of URLs.
> Is there a package available (google found none) which could show me
> something like a "command/function of the day".
>
> Emacs is digested better in bite sized chunks.
Thinking about it a little more, one possible quick-n-dirty method of doing
this would be:
-- cut here ----------------------------------------------------------------
(require 'cl)
(defun totd ()
"Describe a random command."
(interactive)
(with-output-to-temp-buffer "*Tip of the day*"
(princ
(concat "Your tip for the day is:\n========================\n\n"
(describe-function
(let ((commands (loop for s across obarray
when (commandp s) collect s)))
(nth (random (length commands)) commands)))))))
-- cut here ----------------------------------------------------------------
. o O ( Is there a better method of getting a list of commands? Am I right )
( in thinking that elisp doesn't have a "give me a list of commands" )
( function? I would have thought there was one but I couldn't see it )
( during a quick look. )
--(Once apon a time, in gnu.emacs.help,)--
--(Dave Pearson said it like only they can.)--
--
--(UIN=66618055)--
--(tt...@faux.local_04:45_/home/faux)-- cat .sig
GUI's are for slackers. ibpconf.sh 6.1 on freshmeat.net
The easiest way to customize the command line. By Faux_Pseudo
It's a damn poor mind that can only think of one way to spell a word.
- Andrew Jackson
> Now that is a very cool little bit of code. Just one more thing thow. is
> there a way to have it also display what the keybinding is for the totd if
> one is set for it?
Again, quick and dirty:
-- cut here ----------------------------------------------------------------
(defun totd ()
(interactive)
(with-output-to-temp-buffer "*Tip of the day*"
(let* ((commands (loop for s across obarray
when (commandp s) collect s))
(command (nth (random (length commands)) commands)))
(princ
(concat "Your tip for the day is:\n========================\n\n"
(describe-function command)
"\n\nInvoke with:\n\n"
(with-temp-buffer
(where-is command t)
(buffer-string)))))))
-- cut here ----------------------------------------------------------------
Stuff this code in your ~/.emacs.
(defadvice describe-function (after show-help act)
"Append info about key bindings for the described function."
(when function
(let* ((inhibit-read-only t)
(lst (where-is-internal function
overriding-local-map
nil nil))
(str (mapconcat 'key-description lst "\n")))
(when (> (length str) 0)
(set-buffer "*Help*")
(goto-char (point-max))
(insert
(if (= (length lst) 1)
(format "\n\n%s is bound to: %s" function str)
(format "\n\n%s is bound to:\n%s" function str)))))))
Henrik
--
Soylent Green is People!
now if you wouldn't mind droping everything you are doing and adding a
history function so you can see the previous totds in last to first
order .... woops sorry about that
but when you say "Again, quick and dirty" it reminds me of one time
linus said "I must be an idiot, it took me 5 minutes to find that bug"
to which some one replied "only 5 minuts?"
and some one else replied: "if you are an idiot then we need some new words
to discribe us mortals."
--(Once apon a time, in gnu.emacs.help,)--
--(Dave Pearson said it like only they can.)--
> now if you wouldn't mind droping everything you are doing and adding a
> history function so you can see the previous totds in last to first order
> .... woops sorry about that
Much better is alphabetic order. Use:
C-h i m emacs RET m command index RET
You'll be there all day reading tips of the day. ;>
;; f2 displays tip of the day
(global-set-key [(f2)] (lambda () (interactive) (totd)))
;; f3 comand-apropos on lisp function at point
(global-set-key [(f3)] (lambda ()
(interactive) (command-apropos (current-word))))
i wouldnt mind getting as good at lisp as i am at bash
--(Once apon a time, in gnu.emacs.help,)--
--(Dave Pearson said it like only they can.)--
Also, it would be nice to have the output go to, e.g., the
*scratch*-buffer upon startup, rather than creating an extra buffer.
Albert.
> Unfortunately this does not seem to be a good "tip of the day": whenever I
> startup a new emacs, I get the same sequence of commands.
That's because you need to tell random to use a new seed:
,----[ From the elisp manual entry for `random' ]
| In Emacs, pseudo-random numbers are generated from a "seed" number.
| Starting from any given seed, the `random' function always generates
| the same sequence of numbers. Emacs always starts with the same seed
| value, so the sequence of values of `random' is actually the same in
| each Emacs run! For example, in one operating system, the first call
| to `(random)' after you start Emacs always returns -1457731, and the
| second one always returns -7692030. This repeatability is helpful for
| debugging.
`----
> Also, it would be nice to have the output go to, e.g., the
> *scratch*-buffer upon startup, rather than creating an extra buffer.
It should be easy enough for you to modify it for your own purposes.
As an aside, Aaron Crane was kind enough to point out that looping over
obarray in the way I was wasn't going to work too well. Given this the code
is probably better written (actually it's probably better totally
re-written, perhaps at some point...) as:
-- cut here ----------------------------------------------------------------
(defun totd ()
(interactive)
(with-output-to-temp-buffer "*Tip of the day*"
(let* ((commands (loop for s being the symbols
when (commandp s) collect s))
(command (nth (random (length commands)) commands)))
(princ
(concat "Your tip for the day is:\n========================\n\n"
(describe-function command)
"\n\nInvoke with:\n\n"
(with-temp-buffer
(where-is command t)
(buffer-string)))))))
-- cut here ----------------------------------------------------------------
--
Here's what I've been using:
(defadvice describe-function (after where-is activate)
"Call `\\[where-is] FUNCTION'."
(where-is (ad-get-arg 0)))
It doesn't give you the bindings nicely formatted in the *Help* buffer like
Henrik's version does, but it does display them in the echo area even when
the function's docstring is too big to fit in the *Help* window.
--
Kevin Rodgers <kev...@ihs.com> Lead Software Engineer
Information Handling Services Electronic Systems Development
15 Inverness Way East, M/S A114 GO BUFFS!
Englewood CO 80112-5776 USA 1+ (303) 397-2807[voice]/705-4258[fax]
> * Faux_Pseudo <Faux_...@24.177.56.253>:
>> Now that is a very cool little bit of code. Just one more thing
>> thow. is there a way to have it also display what the
>> keybinding is for the totd if one is set for it?
> Again, quick and dirty:
[totd.el]
Yeah, that's cool and all, but where's the ASCII paperclip?
kevin
*sorry about that i dont normaly bad mouth ms in the groups but i have
had a little much to drink and cant resist right now. At least it
wasn't the M$ tritness and i came up with something differant.
--(Once apon a time, in gnu.emacs.help,)--
--(Kevin Harris said it like only they can.)--
> I would however love to have a ascii paper clip to play with in emacs.
> maybe some new major mode based on picture-mode
Check DejaGoogleNews for the archives of <URL:news:comp.emacs>. I seem to
remember someone playing around with the idea of a paperclip.el a couple of
years back. Dunno if anything came of it.