unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* why alias man to woman doesn't work?
@ 2012-04-04 23:50 Xah Lee
  2012-04-05  1:28 ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Xah Lee @ 2012-04-04 23:50 UTC (permalink / raw)
  To: help-gnu-emacs

got this comment.

«You define man as an alias for woman? woman doesn't work all the
time, if it fails, how do you invoke man?»

major lol. :D

http://xahlee.org/emacs/emacs_alias.html

why doesn't alias man to woman work?
i have this alias:

(defalias 'man 'woman)

but it still calls man when M-x on man.

 Xah


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

* Re: why alias man to woman doesn't work?
  2012-04-04 23:50 why alias man to woman doesn't work? Xah Lee
@ 2012-04-05  1:28 ` Stefan Monnier
  2012-04-05  7:02   ` Xah Lee
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Stefan Monnier @ 2012-04-05  1:28 UTC (permalink / raw)
  To: help-gnu-emacs

> why doesn't alias man to woman work?
> i have this alias:

> (defalias 'man 'woman)

> but it still calls man when M-x on man.

Good question.  The technical reason is that woman.el begins with
(require 'man), so when you do M-x man, it autoloads `woman', which
loads `man', which redefines `man' thus overwriting your defalias.

So you have to do

   (defalias 'man 'woman)
   (eval-after-load 'woman '(defalias 'man 'woman))

to get what you want,


        Stefan


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

* Re: why alias man to woman doesn't work?
  2012-04-05  1:28 ` Stefan Monnier
@ 2012-04-05  7:02   ` Xah Lee
  2012-04-05  7:38   ` Sebastien Vauban
  2012-04-06 21:28   ` Xah Lee
  2 siblings, 0 replies; 10+ messages in thread
From: Xah Lee @ 2012-04-05  7:02 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 4, 6:28 pm, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > why doesn't alias man to woman work?
> > i have this alias:
> > (defalias 'man 'woman)
> > but it still calls man when M-x on man.
>
> Good question.  The technical reason is that woman.el begins with
> (require 'man), so when you do M-x man, it autoloads `woman', which
> loads `man', which redefines `man' thus overwriting your defalias.
>
> So you have to do
>
>    (defalias 'man 'woman)
>    (eval-after-load 'woman '(defalias 'man 'woman))
>
> to get what you want,
>
>         Stefan


thanks. Good info.

 Xah


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

* Re: why alias man to woman doesn't work?
  2012-04-05  1:28 ` Stefan Monnier
  2012-04-05  7:02   ` Xah Lee
@ 2012-04-05  7:38   ` Sebastien Vauban
  2012-04-05 10:52     ` Tassilo Horn
                       ` (2 more replies)
  2012-04-06 21:28   ` Xah Lee
  2 siblings, 3 replies; 10+ messages in thread
From: Sebastien Vauban @ 2012-04-05  7:38 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

Hi Stefan,

Stefan Monnier wrote:
>> why doesn't alias man to woman work?
>> i have this alias:
>
>> (defalias 'man 'woman)
>
>> but it still calls man when M-x on man.
>
> Good question.  The technical reason is that woman.el begins with
> (require 'man), so when you do M-x man, it autoloads `woman', which
> loads `man', which redefines `man' thus overwriting your defalias.
>
> So you have to do
>
>    (defalias 'man 'woman)
>    (eval-after-load 'woman '(defalias 'man 'woman))
>
> to get what you want,

Do I understand correctly that the above code will load `woman' when being
parsed, while:

     (eval-after-load "woman" '(defalias 'man 'woman))

would wait until woman was invoked by some other command?

If yes, for performance reasons, one should prefer the latter writing, in
order to have a quicker startup time of Emacs, right?

Just wanna be sure I correctly understood (or not!) this part...

Best regards,
  Seb

-- 
Sebastien Vauban


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

* Re: why alias man to woman doesn't work?
  2012-04-05  7:38   ` Sebastien Vauban
@ 2012-04-05 10:52     ` Tassilo Horn
  2012-04-05 13:02     ` Doug Lewan
  2012-04-05 14:19     ` Stefan Monnier
  2 siblings, 0 replies; 10+ messages in thread
From: Tassilo Horn @ 2012-04-05 10:52 UTC (permalink / raw)
  To: help-gnu-emacs

"Sebastien Vauban"
<wxhgmqzgwmuf@spammotel.com> writes:

Hi Sebastien,

> Do I understand correctly that the above code will load `woman' when
> being parsed, while:
>
>      (eval-after-load "woman" '(defalias 'man 'woman))
>
> would wait until woman was invoked by some other command?

Not until woman was invoked, but until woman.el is loaded.  You can also
write

  (eval-after-load 'woman '(...))

which would evaluate the quoted form after the feature woman has been
provided.  Usually, (provide 'foo) is the last form in a file foo.el, so
in most cases both are equivalent.

> If yes, for performance reasons, one should prefer the latter writing,
> in order to have a quicker startup time of Emacs, right?

Nobody *should*, but it's a possibly way to speed up emacs startup time.
For example, all customizations for programming modes need not be done
until you visit a file of that language.

I have a small macro for that, because I always forget that the form
given to eval-after-load has to be quoted and to have an implicit progn.

--8<---------------cut here---------------start------------->8---
(defmacro th-defer-eval (feature &rest forms)
  "Defer evaluation of FORMS after FEATURE has been provided.
A shorthand for

  (eval-after-load 'FEATURE
     '(progn
	FORMS))

used like

  (th-defer-eval foobar
    (do-this-after-loading-foobar)
    (do-that-after-loading-foobar))"
  (declare (indent defun))
  `(eval-after-load (quote ,feature)
     '(progn
	,@forms)))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo




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

* RE: why alias man to woman doesn't work?
  2012-04-05  7:38   ` Sebastien Vauban
  2012-04-05 10:52     ` Tassilo Horn
@ 2012-04-05 13:02     ` Doug Lewan
  2012-04-05 14:19     ` Stefan Monnier
  2 siblings, 0 replies; 10+ messages in thread
From: Doug Lewan @ 2012-04-05 13:02 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

> -----Original Message-----
> ...
> 
> Do I understand correctly that the above code will load `woman' when
> being
> parsed, while:
> 
>      (eval-after-load "woman" '(defalias 'man 'woman))
> 
> would wait until woman was invoked by some other command?
> 
> If yes, for performance reasons, one should prefer the latter writing,
> in
> order to have a quicker startup time of Emacs, right?
> 
> Just wanna be sure I correctly understood (or not!) this part...
> 
> Best regards,
>   Seb
> 
> --
> Sebastien Vauban

I think you understand. That's exactly why emacs has (eval-after-load).
I just brought up a bare emacs and (length features) => 87.
Those are overwhelmingly the "compiled in" features.

If you run temacs you can see it loading them.
It will give you a real appreciation for the cost of loading packages.
Start up of emacs -nw is almost instantaneous; 
by my count, start up of temacs took about 7 seconds.



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

* Re: why alias man to woman doesn't work?
  2012-04-05  7:38   ` Sebastien Vauban
  2012-04-05 10:52     ` Tassilo Horn
  2012-04-05 13:02     ` Doug Lewan
@ 2012-04-05 14:19     ` Stefan Monnier
  2012-04-05 14:38       ` Sebastien Vauban
  2 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2012-04-05 14:19 UTC (permalink / raw)
  To: help-gnu-emacs

>> (defalias 'man 'woman)
>> (eval-after-load 'woman '(defalias 'man 'woman))
> Do I understand correctly that the above code will load `woman' when being
> parsed, while:

No.

>      (eval-after-load "woman" '(defalias 'man 'woman))

> would wait until woman was invoked by some other command?

If you remove the first line, then M-x man will not load woman.


        Stefan


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

* Re: why alias man to woman doesn't work?
  2012-04-05 14:19     ` Stefan Monnier
@ 2012-04-05 14:38       ` Sebastien Vauban
  0 siblings, 0 replies; 10+ messages in thread
From: Sebastien Vauban @ 2012-04-05 14:38 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

Stefan,

Stefan Monnier wrote:
>>> (defalias 'man 'woman)
>>> (eval-after-load 'woman '(defalias 'man 'woman))
>>
>> Do I understand correctly that the above code will load `woman' when being
>> parsed, while:
>
> No.
>
>>      (eval-after-load "woman" '(defalias 'man 'woman))
>
>> would wait until woman was invoked by some other command?
>
> If you remove the first line, then M-x man will not load woman.

My question was about

    (eval-after-load 'whatever ...)

vs

    (eval-after-load "whatever" ...)

I thought, after reading documentation[1], that:

- with a symbol, it would load whatever package immediately, and then run the
  extra code after that

- with a string, it would wait for whatever package to be loaded, and then run
  the extra code after that

But you infirmed what I was thinking.

Thanks for your input!

Best regards,
  Seb

Footnotes:

[1] I can't find exactly which one anymore, though, between C-h f or the GNU
Emacs Lisp Reference Manual or ...


-- 
Sebastien Vauban


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

* Re: why alias man to woman doesn't work?
  2012-04-05  1:28 ` Stefan Monnier
  2012-04-05  7:02   ` Xah Lee
  2012-04-05  7:38   ` Sebastien Vauban
@ 2012-04-06 21:28   ` Xah Lee
  2012-04-10  2:39     ` Stefan Monnier
  2 siblings, 1 reply; 10+ messages in thread
From: Xah Lee @ 2012-04-06 21:28 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 4, 6:28 pm, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > why doesn't alias man to woman work?
> > i have this alias:
> > (defalias 'man 'woman)
> > but it still calls man when M-x on man.
>
> Good question.  The technical reason is that woman.el begins with
> (require 'man), so when you do M-x man, it autoloads `woman', which
> loads `man', which redefines `man' thus overwriting your defalias.
>
> So you have to do
>
>    (defalias 'man 'woman)
>    (eval-after-load 'woman '(defalias 'man 'woman))
>
> to get what you want,
>
>         Stefan

btw, why's women (require 'man)
 that seems...incenstual. It's supposed to be independent.

 Xah


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

* Re: why alias man to woman doesn't work?
  2012-04-06 21:28   ` Xah Lee
@ 2012-04-10  2:39     ` Stefan Monnier
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2012-04-10  2:39 UTC (permalink / raw)
  To: help-gnu-emacs

> btw, why's women (require 'man)
>  that seems...incenstual.  It's supposed to be independent.

Because woman's main purpose is to provide what /usr/bin/man (and/or
nroff/groff) does, rather than what man.el does.  So some of the
remaining functionality and customizations can be shared between
the two.


        Stefan


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

end of thread, other threads:[~2012-04-10  2:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-04 23:50 why alias man to woman doesn't work? Xah Lee
2012-04-05  1:28 ` Stefan Monnier
2012-04-05  7:02   ` Xah Lee
2012-04-05  7:38   ` Sebastien Vauban
2012-04-05 10:52     ` Tassilo Horn
2012-04-05 13:02     ` Doug Lewan
2012-04-05 14:19     ` Stefan Monnier
2012-04-05 14:38       ` Sebastien Vauban
2012-04-06 21:28   ` Xah Lee
2012-04-10  2:39     ` Stefan Monnier

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