all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* multi-line conditionals in elisp
@ 2002-12-22 19:00 Michael Powe
  2002-12-22 19:12 ` David Kastrup
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michael Powe @ 2002-12-22 19:00 UTC (permalink / raw)


hello,

sorry for the dumb question, but i'm sure of the best way to do
this. i have emacs installed on several machines and would like to use
a single .emacs.  it's annoying to have to maintain different ones,
and i forget sometimes that one library is installed on one machine
but not on another.

my solution was to put a conditional in the .emacs to test for the
existence of a library before following its loading instructions.
what i'm having a problem with, is conditionals of this format:

if (true)
  do item one
  do item two
  do item three
  ...
else
  do item four

this is trivial in other languages, but not, it seems, in elisp.  (i
think it's just a case of, i don't really understand the language.)
here's what i did:

(if (locate-library "python-mode")
    (cond((autoload 'python-mode "python-mode" "Python editing mode" t)
	  (setq auto-mode-alist
		(cons '("\\.py$" . python-mode) auto-mode-alist))))
  (message "python library not found"))

this seems to work. (just putting an extra pair of parens around the
multiple statements did not work.  i guess that would be the
equivalent of {} in C.)  but i'm not sure if it's the best or only
way.  after all, if i have more than two items in the first part of
the conditional, that means stringing along multiple conds.  an
example would be mailcrypt, which in one of my .emacs has 7 line
items, setting and loading variables.  i dunno, it seems clumsy to me
because i'd be invoking the cond not because i'm interested in its
outcome per se, but just to force execution of the next statement.

thanks for any help.

mp

nb. trivial note: on my main workstation, i maintain my dot-files in
rcs.  i noted yesterday that my oldest entry in the .emacs is from
january 30, 1998.  so, in a little over a month, it will be 5 years
old.  that's a lot of bits & bytes through the pipe.  and emacs is
still God's Own Editor(tm).  ;-)  Happy Holidays!

-- 
Michael Powe					Waterbury, CT
-------------------------------------------------------------
"The most likely way for the world to be destroyed, most experts
agree, is by accident.  That's where we come in.  We're computer
professionals.  We cause accidents."  -- Nathaniel Borenstein

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

* Re: multi-line conditionals in elisp
  2002-12-22 19:00 multi-line conditionals in elisp Michael Powe
@ 2002-12-22 19:12 ` David Kastrup
  2002-12-22 22:48   ` Michael Powe
       [not found] ` <michael+gnus@trollope.org>
       [not found] ` <mailman.524.1040584903.19936.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 7+ messages in thread
From: David Kastrup @ 2002-12-22 19:12 UTC (permalink / raw)


Michael Powe <michael+gnus@trollope.org> writes:

> sorry for the dumb question, but i'm sure of the best way to do
> this. i have emacs installed on several machines and would like to use
> a single .emacs.  it's annoying to have to maintain different ones,
> and i forget sometimes that one library is installed on one machine
> but not on another.
> 
> my solution was to put a conditional in the .emacs to test for the
> existence of a library before following its loading instructions.
> what i'm having a problem with, is conditionals of this format:
> 
> if (true)
>   do item one
>   do item two
>   do item three
>   ...
> else
>   do item four
> 
> this is trivial in other languages, but not, it seems, in elisp.  (i
> think it's just a case of, i don't really understand the language.)
> here's what i did:
> 
> (if (locate-library "python-mode")
>     (cond((autoload 'python-mode "python-mode" "Python editing mode" t)
> 	  (setq auto-mode-alist
> 		(cons '("\\.py$" . python-mode) auto-mode-alist))))
>   (message "python library not found"))

That is junk.  I recommend you look up progn.

> nb. trivial note: on my main workstation, i maintain my dot-files in
> rcs.  i noted yesterday that my oldest entry in the .emacs is from
> january 30, 1998.  so, in a little over a month, it will be 5 years
> old.  that's a lot of bits & bytes through the pipe.

5 years and you don't know progn.  That certainly _is_ impressive.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: multi-line conditionals in elisp
       [not found] ` <michael+gnus@trollope.org>
@ 2002-12-22 19:21   ` Peter S Galbraith
  0 siblings, 0 replies; 7+ messages in thread
From: Peter S Galbraith @ 2002-12-22 19:21 UTC (permalink / raw)
  Cc: help-gnu-emacs

Michael Powe <michael+gnus@trollope.org> wrote:

> this is trivial in other languages, but not, it seems, in elisp.  (i
> think it's just a case of, i don't really understand the language.)

The latter.

> (if (locate-library "python-mode")
>     (cond((autoload 'python-mode "python-mode" "Python editing mode" t)
> 	  (setq auto-mode-alist
> 		(cons '("\\.py$" . python-mode) auto-mode-alist))))
>   (message "python library not found"))

(if (locate-library "python-mode")
    (progn
      (autoload 'python-mode "python-mode" "Python editing mode" t)
      (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)))
  (message "python library not found"))

or

(if (not (locate-library "python-mode"))
    (message "python library not found")
  (autoload 'python-mode "python-mode" "Python editing mode" t)
  (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)))

or forget the message:

(when (locate-library "python-mode")
  (autoload 'python-mode "python-mode" "Python editing mode" t)
  (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)))

Peter

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

* Re: multi-line conditionals in elisp
       [not found] ` <mailman.524.1040584903.19936.help-gnu-emacs@gnu.org>
@ 2002-12-22 22:40   ` Michael Powe
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Powe @ 2002-12-22 22:40 UTC (permalink / raw)


>>>>> "Peter" == Peter S Galbraith <p.galbraith@globetrotter.net> writes:

    Peter> Michael Powe <michael+gnus@trollope.org> wrote:
    >> this is trivial in other languages, but not, it seems, in
    >> elisp.  (i think it's just a case of, i don't really understand
    >> the language.)

    Peter> The latter.

    >> (if (locate-library "python-mode") (cond((autoload 'python-mode
    >> "python-mode" "Python editing mode" t) (setq auto-mode-alist
    >> (cons '("\\.py$" . python-mode) auto-mode-alist)))) (message
    >> "python library not found"))

    Peter> (if (locate-library "python-mode") (progn (autoload
    Peter> 'python-mode "python-mode" "Python editing mode" t) (setq
    Peter> auto-mode-alist (cons '("\\.py$" . python-mode)
    Peter> auto-mode-alist))) (message "python library not found"))

thanks, i will look into that more closely.

mp

-- 
Michael Powe					Waterbury, CT
-------------------------------------------------------------
"The most likely way for the world to be destroyed, most experts
agree, is by accident.  That's where we come in.  We're computer
professionals.  We cause accidents."  -- Nathaniel Borenstein

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

* Re: multi-line conditionals in elisp
  2002-12-22 19:12 ` David Kastrup
@ 2002-12-22 22:48   ` Michael Powe
  2002-12-22 23:05     ` David Kastrup
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Powe @ 2002-12-22 22:48 UTC (permalink / raw)


>>>>> "David" == David Kastrup <David.Kastrup@t-online.de> writes:

    David> Michael Powe <michael+gnus@trollope.org> writes:
    >> sorry for the dumb question, but i'm sure of the best way to do
    >> this. i have emacs installed on several machines and would like
    >> to use a single .emacs.  it's annoying to have to maintain
    >> different ones, and i forget sometimes that one library is
    >> installed on one machine but not on another.
    >> 
    >> my solution was to put a conditional in the .emacs to test for
    >> the existence of a library before following its loading
    >> instructions.  what i'm having a problem with, is conditionals
    >> of this format:
    >> 
    >> if (true) do item one do item two do item three ...  else do
    >> item four
    >> 
    >> this is trivial in other languages, but not, it seems, in
    >> elisp.  (i think it's just a case of, i don't really understand
    >> the language.)  here's what i did:
    >> 
    >> (if (locate-library "python-mode") (cond((autoload 'python-mode
    >> "python-mode" "Python editing mode" t) (setq auto-mode-alist
    >> (cons '("\\.py$" . python-mode) auto-mode-alist)))) (message
    >> "python library not found"))

    David> That is junk.  I recommend you look up progn.

    >> nb. trivial note: on my main workstation, i maintain my
    >> dot-files in rcs.  i noted yesterday that my oldest entry in
    >> the .emacs is from january 30, 1998.  so, in a little over a
    >> month, it will be 5 years old.  that's a lot of bits & bytes
    >> through the pipe.

    David> 5 years and you don't know progn.  That certainly _is_
    David> impressive.

well, i'm ignorant and you are a jerk.  which one of us is worse off?
hint: i don't think it's me.  i can learn what i don't know, but you
can never change your character.  thank you very little for taking
time out of your busy day to ridicule me.

mp

-- 
Michael Powe					Waterbury, CT
-------------------------------------------------------------
"The most likely way for the world to be destroyed, most experts
agree, is by accident.  That's where we come in.  We're computer
professionals.  We cause accidents."  -- Nathaniel Borenstein

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

* Re: multi-line conditionals in elisp
  2002-12-22 22:48   ` Michael Powe
@ 2002-12-22 23:05     ` David Kastrup
  2002-12-24  3:17       ` Jesper Harder
  0 siblings, 1 reply; 7+ messages in thread
From: David Kastrup @ 2002-12-22 23:05 UTC (permalink / raw)


Michael Powe <michael+gnus@trollope.org> writes:

> >>>>> "David" == David Kastrup <David.Kastrup@t-online.de> writes:
> 
>     >> nb. trivial note: on my main workstation, i maintain my
>     >> dot-files in rcs.  i noted yesterday that my oldest entry in
>     >> the .emacs is from january 30, 1998.  so, in a little over a
>     >> month, it will be 5 years old.  that's a lot of bits & bytes
>     >> through the pipe.
> 
>     David> 5 years and you don't know progn.  That certainly _is_
>     David> impressive.
> 
> well, i'm ignorant and you are a jerk.  which one of us is worse off?
> hint: i don't think it's me.  i can learn what i don't know,

Not if you piss off the people that could teach you.  Score adjusted.

> but you can never change your character.  thank you very little for
> taking time out of your busy day to ridicule me.

In case you haven't noticed, I also gave you the answer.  Should not
happen again.

My busy day has been spent working on supporting people's problems
with AUCTeX (of which I am maintainer), fixing configuration problems
for various users of preview-latex (of which I am main author and
maintainer) and smashing my head in order to figure out a good way to
implement data structures in LaTeX making multiple footnote apparatus
and marginal notes maintainable easibly, so that there will in due
time be a freely available solution for literary scientists.

Yes, I am worse off than you, definitely, since I am concerned with
the problems of many more people, rather than just tiny personal
little problems that could easily be looked up in readily available
material like the free Elisp tutorial.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: multi-line conditionals in elisp
  2002-12-22 23:05     ` David Kastrup
@ 2002-12-24  3:17       ` Jesper Harder
  0 siblings, 0 replies; 7+ messages in thread
From: Jesper Harder @ 2002-12-24  3:17 UTC (permalink / raw)


David Kastrup <David.Kastrup@t-online.de> writes:

> Michael Powe <michael+gnus@trollope.org> writes:
>
>> well, i'm ignorant and you are a jerk.  which one of us is worse off?
>> hint: i don't think it's me.  i can learn what i don't know,
>
> Not if you piss off the people that could teach you.  Score adjusted.

  When it shall really be possible to lead a person to a specific
  place, one first of all has to be careful to find where he is and
  start from there.

  This is the secret of the art of helping.  Anyone who is not able to
  do so is simply seducing himself into believing that he is able to
  help others.

  To really help another person I must understand more than him but
  first of all understand what he understands.

  When I don't do this my superior understanding does not help him at
  all.

  Yet when I start to impose my superior understanding, then it is
  because of my vanity and pride, in that I don't really want to help
  him but wish him to admire me instead.  But all true help begins
  with humility.

  The helper must first humble himself to the one he wishes to help
  and thereby understand that helping is not to rule but to serve.
  That helping is not being the most domineering but the most patient.
  That helping is willingness to tolerate, for the present, being
  wrong and not understanding what the other understands.

       -- Søren Kierkegaard, Brudstykke af en ligefrem meddelelse

'nuff said!

(and apologies for my translation which doesn't really do justice to the
eloquence of the original).

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

end of thread, other threads:[~2002-12-24  3:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-22 19:00 multi-line conditionals in elisp Michael Powe
2002-12-22 19:12 ` David Kastrup
2002-12-22 22:48   ` Michael Powe
2002-12-22 23:05     ` David Kastrup
2002-12-24  3:17       ` Jesper Harder
     [not found] ` <michael+gnus@trollope.org>
2002-12-22 19:21   ` Peter S Galbraith
     [not found] ` <mailman.524.1040584903.19936.help-gnu-emacs@gnu.org>
2002-12-22 22:40   ` Michael Powe

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.