Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tip of the Day

16 views
Skip to first unread message

Ron Denis

unread,
Apr 20, 2001, 10:16:49 AM4/20/01
to
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.

--
Ron Denis
E-mail : rde...@lucent.com
Consultant
Lucent Technologies Inc.

Dave Pearson

unread,
Apr 20, 2001, 12:26:17 PM4/20/01
to
* Ron Denis <rde...@lucent.com>:

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

Dave Pearson

unread,
Apr 21, 2001, 3:26:33 AM4/21/01
to
* Ron Denis <rde...@lucent.com>:

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

Faux_Pseudo

unread,
Apr 21, 2001, 4:34:30 AM4/21/01
to
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?

--(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

Dave Pearson

unread,
Apr 21, 2001, 8:27:41 AM4/21/01
to
* 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:

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

Henrik Enberg

unread,
Apr 21, 2001, 1:48:11 PM4/21/01
to
Faux_...@24.177.56.253 (Faux_Pseudo):

> 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?

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!

Faux_Pseudo

unread,
Apr 22, 2001, 4:41:32 AM4/22/01
to
perfect. thanks for that.

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

Dave Pearson

unread,
Apr 22, 2001, 5:19:18 AM4/22/01
to
* Faux_Pseudo <Faux_...@24.177.56.253>:

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

Faux_Pseudo

unread,
Apr 22, 2001, 8:21:04 AM4/22/01
to
well i probably wont do that but seeing as how i am just now learning
to use lisp i did take what i saw in the code and morphed it with
another bit i found to help me out a little

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

Albert REINER

unread,
Apr 21, 2001, 12:13:47 PM4/21/01
to
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.

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.

Dave Pearson

unread,
Apr 22, 2001, 1:29:02 PM4/22/01
to
* Albert REINER <Use-Author-Address-Header@[127.1]>:

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

--

Kevin Rodgers

unread,
Apr 23, 2001, 1:01:43 PM4/23/01
to
Henrik Enberg wrote:
> 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)))))))

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]

Kevin Harris

unread,
May 1, 2001, 8:01:55 PM5/1/01
to
Dave Pearson <davep...@davep.org> writes:

> * 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

Faux_Pseudo

unread,
May 2, 2001, 7:00:09 AM5/2/01
to
totd.el is a great idea but even microscrung* has admited defeat with
the paper clip guy and will not be including him in there new
releases.
I would however love to have a ascii paper clip to play with in emacs.
maybe some new major mode based on picture-mode

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

Dave Pearson

unread,
May 2, 2001, 9:26:57 AM5/2/01
to
* Faux_Pseudo <Faux_...@24.177.56.253>:

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

0 new messages