[comp.emacs] load-path code

markl@PTT.LCS.MIT.EDU (02/11/88)

Repository: PTT

Originating-Client: thyme


[Uck -- mailer burp.  Let's get it right this time...]

   From: msb@ho5cad.ATT.COM
   Date: 8 Feb 88 14:59:34 GMT
   Sender: nuucp@ho7cad.ATT.COM

   [...]

   (setq load-path (cons (expand-file-name "~/lib/emacs") load-path))

   [...]

   My first question:
	   Why is this a "better solution"?

"Better" is not the right word in the sense that it is faster or more
efficient; I think "more elegant" is a better choice.  There is a
minimum amount of complexity in the expression, which makes it easy to
understand.

   My second question:
	   I am just starting to learn some of this GNU .el stuff -- I'd
   looked a bit into the UniPress .ml stuff.  Since there is not a
   'tutorial' on the language, I'd be interested to hear from some
   experienced .el-programmers.  All of the following were proposed as
   solutions to the original problem.  Are any of the following good/bad,
   correct/incorrect, efficient/inefficient, etc?

   (setq load-path (cons (format "%s/.emacs" (getenv "HOME")) load-path))

This is simply broken.  ".emacs" is a file, not a directory.  The
code's appearance is not bad, just overly complex when compared to
the versions that follow.

   (setq load-path (concat (getenv "HOME") "/elisp-library") load-path)

This is a bit better, but also more complex than necessary.

   (setq load-path (cons (substitute-in-file-name "$HOME/emacs") load-path))
   (setq load-path (cons (expand-file-name "~/lib/emacs") load-path))

These are your best choices: the pathname is built by one form--very
easy to read.

   My third question:
	   Is it true that there is no 'tutorial' on the elisp language?

"Real Soon Now" has been the anthem I've heard for months now; your
only current option is to look at emacs-lisp code until you are blue
in the face and hope something sinks in.  That is the problem with all
the code you listed above.  There are so many utility functions
available that without a manual, people are forced to pick the ones
they have seen before even if there are simpler ones that will do the
job.  While writing my mail system, I found over and over that I could
reduce 20 lines of emacs-lisp code to 5 lines simply by using an
obscure function I hadn't come across before...

Cheers,

markl

Internet: markl@ptt.lcs.mit.edu

Mark L. Lambert
MIT Laboratory for Computer Science
Distributed Systems Group

----------

karl@haddock.ISC.COM (Karl Heuer) (02/17/88)

In article <8802111252.AA18432@PTT.LCS.MIT.EDU> markl@PTT.LCS.MIT.EDU writes:
>[msb@ho5cad.ATT.COM writes:]
>>[karl@haddock.ima.isc.com writes that a better solution is:]
>>>(setq load-path (cons (expand-file-name "~/lib/emacs") load-path))
>>Why is this a "better solution"?
>
>"Better" is not the right word in the sense that it is faster or more
>efficient; I think "more elegant" is a better choice.  There is a
>minimum amount of complexity in the expression, which makes it easy to
>understand.

Moreover, it uses the same filename convention as the rest of Emacs.  I didn't
mention it in my previous posting, but what I *really* use in my .emacs is
  (setq load-path (cons (expand-file-name "~karl/lib/emacs") load-path))
so that it will do the right thing even if I borrow someone else's account and
use "emacs -u karl".  None of the other proposed solutions will allow this
generalization.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint