help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: code listp to determine wich os I'm running on


From: Renato
Subject: Re: code listp to determine wich os I'm running on
Date: Wed, 29 Jan 2014 23:12:58 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20131104 Icedove/17.0.10

Sorry Emanuel...
what's wrong?

(if (string= system-type "gnu/linux")
    (setq percorso-variable "\home\renato\Dropbox\emacs_prof\")
  (message "fatto"))
  (if (string= system-type "windows-nt")
      (setq percorso "c:/doc/Dropbox") ))

It does,t works... :-(

Renato


On 29/01/2014 21:28, Emanuel Berg wrote:
Renato <renato.pontefice@gmail.com> writes:

Hi, I'm looking for some code to insert in my .emacs
to determine wich s.o I'm running. ...
Instead of `string-equal', there is string= which is an
alias for `string-equal'. Might be faster to type and
takes less place.

You don't need to use progn for a single form. Use
progn when you want to execute a bunch of forms, and
then have the *last* form's value to be the evaluation
of the whole progn form. This is what the "n" is -
execute n programs, and return the value of the last
(the "nth"). Compare: prog1

(progn 1 2 3) ; 3
(prog1 1 2 3) ; 1

The if in Lisp looks like this:

(if condition then else)

E.g., (if (> x y) x y) => x, if x is bigger than y,
else y. (You may omit the "else" part if it is `nil',
since then the whole if form will evaluate to nil
anyway, if not the condition is true.)

But you already used `cond'. `cond' and if are the
same: cond is nested ifs, if you like. To you, as a
programmer, it doesn't matter if cond is syntactic
sugar for `if', or if it is the other way around. This
only matters to the guy not programming Lisp programs,
but the Lisp system itself.

(if (string= system-type "gnu/linux")
     (setq some-variable "...")
   (if (string= system-type "...")
       (setq some-variable "...") ))

Or with `cond':

(setq some-variable
       (cond ((string= system-type "gnu/linux") 'value-1)
             ((string= system-type "...")       'value-2) ))

And so on. (You can do this in any way you like.)

You don't need to do the F1 maneuver to check
results. Just place point (the cursor) to the right of
the right-most paren, then hit `C-x C-e' (for
`eval-last-sexp'). This also works for symbols
(variables).

With the load-path though - do you really need to set
it?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]