From: dstein64
Subject: Two Lisp Questions
Date: 
Message-ID: <e3b31365-1b5b-42db-8bdf-bbf2c4cd144e@k13g2000hse.googlegroups.com>
Sorry for the vague subject title, but I could not think of anything
better. Anyhow, is there any Lisp function that returns the name of
the computer that it is executed on. I have a function that uses
sockets to connect to some program, and it would be best if I can have
a function that automatically retrieves the name of the machine. Also,
is there any read function that reads tokens that are separated by
spaces. I know that the read function can do this, but it will also
read an entire parenthetical item as one item, rather than dividing it
into sub-tokens that are separated by spaces. Any built in function?
If not, this will be pretty straightforward to implement using read-
char, but I was just wondering if anything was built in. Thanks.

From: dstein64
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <b39348eb-7517-41b4-a1b5-2010189bdae5@d1g2000hsg.googlegroups.com>
Also, on a completely separate note, in emacs, how do I enter
arguments to emacs functions? For example there is the following
function:

(ps-print-buffer-with-faces &optional filename)

Ordinarily, I would type M-x ps-print-buffer-with-faces. With no
arguments, output is sent to the printer. I use M-x to enter function.
How can I also add arguments. Although I only mentioned one example, I
would like to know if there is a general way to enter arguments.
Thanks.
From: Rupert Swarbrick
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <87k5j3l9pu.fsf@gmail.com>
One option is using M-: and then typing it in. Normally one can give
these things prefix arguments, but that only allows numbers, I
think. If there's some name you always end up using, why not write a
short elisp function to do it and bind it to a key chord?

Rupert
From: Giorgos Keramidas
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <87r6day1ww.fsf@kobe.laptop>
On Sat, 12 Apr 2008 10:10:37 +0100, Rupert Swarbrick <··········@gmail.com> wrote:
> One option is using M-: and then typing it in. Normally one can give
> these things prefix arguments, but that only allows numbers, I
> think. If there's some name you always end up using, why not write a
> short elisp function to do it and bind it to a key chord?

Correct.  It's relatively easy to write an `interactive' wrapper, than
can prompt for the filename and pass it as an argument to another
function:

  (defun keramida-ps-print-buffer-with-faces (filename)
    (interactive "sFilename: ")
    (ps-print-buffer-with-faces filename))

Then you can use `M-x keramida-ps-print-buffer-with-faces', and it
should prompt for a filename before invoking the current implementation
of the `ps-print-buffer-with-faces' command.
From: Pascal Bourguignon
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <87bq4e332o.fsf@thalassa.informatimago.com>
Giorgos Keramidas <········@ceid.upatras.gr> writes:

> On Sat, 12 Apr 2008 10:10:37 +0100, Rupert Swarbrick <··········@gmail.com> wrote:
>> One option is using M-: and then typing it in. Normally one can give
>> these things prefix arguments, but that only allows numbers, I
>> think. If there's some name you always end up using, why not write a
>> short elisp function to do it and bind it to a key chord?
>
> Correct.  It's relatively easy to write an `interactive' wrapper, than
> can prompt for the filename and pass it as an argument to another
> function:
>
>   (defun keramida-ps-print-buffer-with-faces (filename)
>     (interactive "sFilename: ")
>     (ps-print-buffer-with-faces filename))
>
> Then you can use `M-x keramida-ps-print-buffer-with-faces', and it
> should prompt for a filename before invoking the current implementation
> of the `ps-print-buffer-with-faces' command.

Of course, but in the case of ps-print-buffer-with-faces if you took
the pain of reading the doc, you'd knew that you only have to type C-u
M-x ps-print-buffer-with-faces RET to be asked the file name...

If you don't read the doc, will you read my post?

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"Logiciels libres : nourris au code source sans farine animale."
From: Giorgos Keramidas
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <87r6dapg3w.fsf@kobe.laptop>
On Sun, 13 Apr 2008 04:23:43 +0200, Pascal Bourguignon wrote:
>Giorgos Keramidas <········@ceid.upatras.gr> writes:
>>On Sat, 12 Apr 2008 10:10:37 +0100, Rupert Swarbrick <··········@gmail.com> wrote:
>>> One option is using M-: and then typing it in. Normally one can give
>>> these things prefix arguments, but that only allows numbers, I
>>> think. If there's some name you always end up using, why not write a
>>> short elisp function to do it and bind it to a key chord?
>>
>> Correct.  It's relatively easy to write an `interactive' wrapper, than
>> can prompt for the filename and pass it as an argument to another
>> function:
>>
>>   (defun keramida-ps-print-buffer-with-faces (filename)
>>     (interactive "sFilename: ")
>>     (ps-print-buffer-with-faces filename))
>>
>> Then you can use `M-x keramida-ps-print-buffer-with-faces', and it
>> should prompt for a filename before invoking the current implementation
>> of the `ps-print-buffer-with-faces' command.
>
> Of course, but in the case of ps-print-buffer-with-faces if you took
> the pain of reading the doc, you'd knew that you only have to type C-u
> M-x ps-print-buffer-with-faces RET to be asked the file name...

Ah, you are right of course!  I was too hasty to post.

> If you don't read the doc, will you read my post?

Sure.  I read *all* your posts, FWIW :-)
From: Barry Margolin
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <barmar-A4D2A7.00001212042008@newsgroups.comcast.net>
In article 
<····································@k13g2000hse.googlegroups.com>,
 dstein64 <········@gmail.com> wrote:

> Sorry for the vague subject title, but I could not think of anything
> better. Anyhow, is there any Lisp function that returns the name of
> the computer that it is executed on. I have a function that uses

There's no standard function, but I expect just about every 
implementation has a custom function for this.  Check your documentation.

> sockets to connect to some program, and it would be best if I can have
> a function that automatically retrieves the name of the machine. Also,
> is there any read function that reads tokens that are separated by
> spaces. I know that the read function can do this, but it will also
> read an entire parenthetical item as one item, rather than dividing it
> into sub-tokens that are separated by spaces. Any built in function?
> If not, this will be pretty straightforward to implement using read-
> char, but I was just wondering if anything was built in. Thanks.

No, there's no built-in function for this.  Use read-line and then 
search for #\space.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Pascal Bourguignon
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <87tzi72lpi.fsf@thalassa.informatimago.com>
Barry Margolin <······@alum.mit.edu> writes:

> In article 
> <····································@k13g2000hse.googlegroups.com>,
>  dstein64 <········@gmail.com> wrote:
>
>> Sorry for the vague subject title, but I could not think of anything
>> better. Anyhow, is there any Lisp function that returns the name of
>> the computer that it is executed on. I have a function that uses
>
> There's no standard function, but I expect just about every 
> implementation has a custom function for this.  Check your documentation.

[···@thalassa ~]$ clall '(machine-instance)'


========================================================================
CLISP 2.41 (2006-10-13) (built on thalassa.lan.informatimago.com [192.168.1.198]) 


Evaluation of
(MACHINE-INSTANCE)
produced nothing on *STANDARD-OUTPUT*
produced nothing on *ERROR-OUTPUT*
produced no error
produced the following vals:
--> "thalassa.informatimago.com [192.168.7.1]"

; loading system definition from
; /usr/share/common-lisp/systems/asdf-binary-locations.asd into
; #<PACKAGE "ASDF0">
; registering #<SYSTEM ASDF-BINARY-LOCATIONS {AEB9471}> as ASDF-BINARY-LOCATIONS

========================================================================
SBCL 1.0.15-gentoo 


Evaluation of
(MACHINE-INSTANCE)
produced nothing on *STANDARD-OUTPUT*
produced nothing on *ERROR-OUTPUT*
produced no error
produced the following vals:
--> "thalassa"


========================================================================
pCMU Common Lisp CVS 19c 19c-release + minimal debian patches (19C) 


Evaluation of
(MACHINE-INSTANCE)
produced nothing on *STANDARD-OUTPUT*
produced nothing on *ERROR-OUTPUT*
produced no error
produced the following vals:
--> "thalassa"


========================================================================
GNU Common Lisp (GCL) GCL 2.6.7 


Evaluation of
(MACHINE-INSTANCE)
produced nothing on *STANDARD-OUTPUT*
produced nothing on *ERROR-OUTPUT*
produced no error
produced the following vals:
--> NIL


========================================================================
ECL 0.9g 


Evaluation of
(MACHINE-INSTANCE)
produced nothing on *STANDARD-OUTPUT*
produced nothing on *ERROR-OUTPUT*
produced no error
produced the following vals:
--> "i686"


========================================================================

[···@thalassa ~]$ 


gcl is not very able. No surprise here.  But at least it's conformant.
ecl is wrong.  i686 is not an instance, it's a class.  It's even an abstract class!


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"This statement is false."            In Lisp: (defun Q () (eq nil (Q)))
From: Juanjo
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <70dfe23b-edfe-4134-8f8c-68865d8585ad@t12g2000prg.googlegroups.com>
On Apr 12, 4:26 pm, Pascal Bourguignon <····@informatimago.com> wrote:
> ecl is wrong.  i686 is not an instance, it's a class.  It's even an abstract class!

I have fixed this. In the CVS version ECL now uses various environment
variables and the output of the uname() function, where available.

Juanjo

$ ecl
ECL (Embeddable Common-Lisp) 0.9j (CVS 2008-04-13 20:34)
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.  Top level.
> (machine-instance)
"benasque2.local"
> (machine-type)
"i386"
> (machine-version)
NIL
> (software-type)
"Darwin"
> (software-version)
"8.11.1"
From: Pascal Bourguignon
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <87bq4d5p09.fsf@hubble.informatimago.com>
Juanjo <·····················@googlemail.com> writes:

> On Apr 12, 4:26 pm, Pascal Bourguignon <····@informatimago.com> wrote:
>> ecl is wrong.  i686 is not an instance, it's a class.  It's even an abstract class!
>
> I have fixed this. In the CVS version ECL now uses various environment
> variables and the output of the uname() function, where available.
>
> Juanjo

Thank you!

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"Debugging?  Klingons do not debug! Our software does not coddle the
weak."
From: Pascal Bourguignon
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <87y77jk98p.fsf@thalassa.informatimago.com>
dstein64 <········@gmail.com> writes:

> Sorry for the vague subject title, but I could not think of anything
> better. Anyhow, is there any Lisp function that returns the name of
> the computer that it is executed on. I have a function that uses
> sockets to connect to some program, and it would be best if I can have
> a function that automatically retrieves the name of the machine. 

(apropos "MACHINE" "CL")

> Also,
> is there any read function that reads tokens that are separated by
> spaces. I know that the read function can do this, but it will also
> read an entire parenthetical item as one item, rather than dividing it
> into sub-tokens that are separated by spaces.

You could flatten the read list.

> Any built in function?
> If not, this will be pretty straightforward to implement using read-
> char, but I was just wondering if anything was built in. Thanks.

Or by disabling the #\( reader macro.

(defvar *readtable-wo-list* (copy-readtable nil))
(defun read-self (stream ch) (declare (ignore stream)) (values (intern (string ch))))
(set-macro-character #\( (function read-self) nil *readtable-wo-list*)
(set-macro-character #\) (function read-self) nil *readtable-wo-list*)
(let ((*readtable* *readtable-wo-list*)) 
     (with-input-from-string (in "a (b c) d) e)")
       (loop :for token = (read in nil in)
             :until (eq token in)
             :collect token)))
--> (A |(| B C |)| D |)| E |)|)


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

This is a signature virus.  Add me to your signature and help me to live.
From: Joshua Taylor
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <177506d1-5352-4714-9162-e43e6f48248d@m71g2000hse.googlegroups.com>
On Apr 11, 11:50 pm, dstein64 <········@gmail.com> wrote:
> Sorry for the vague subject title, but I could not think of anything
> better. Anyhow, is there any Lisp function that returns the name of
> the computer that it is executed on. I have a function that uses
> sockets to connect to some program, and it would be best if I can have
> a function that automatically retrieves the name of the machine. Also,
> is there any read function that reads tokens that are separated by
> spaces. I know that the read function can do this, but it will also
> read an entire parenthetical item as one item, rather than dividing it
> into sub-tokens that are separated by spaces. Any built in function?
> If not, this will be pretty straightforward to implement using read-
> char, but I was just wondering if anything was built in. Thanks.

Several people have written about implementation-specific functions,
but there are some CL functions that you might find useful (although
their /results/ are still implementation specific).

From http://www.lisp.org/HyperSpec/Body/sec_the_envir_t_dictionary.html

Function LISP-IMPLEMENTATION-TYPE, LISP-IMPLEMENTATION-VERSION
Function SHORT-SITE-NAME, LONG-SITE-NAME
Function MACHINE-INSTANCE
Function MACHINE-TYPE
Function MACHINE-VERSION
Function SOFTWARE-TYPE, SOFTWARE-VERSION

On Lispworks 5.0, OS X 10.4, machine-instance returned the name of my
machine.

And, while not entirely relevant, I was pleased when I first found:

Function USER-HOMEDIR-PATHNAME

//JT
From: Marco Antoniotti
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <db031692-abc8-4911-9ea5-baef960d6bf5@59g2000hsb.googlegroups.com>
On Apr 12, 5:21 pm, Joshua Taylor <···········@gmail.com> wrote:
> On Apr 11, 11:50 pm, dstein64 <········@gmail.com> wrote:
>
> > Sorry for the vague subject title, but I could not think of anything
> > better. Anyhow, is there any Lisp function that returns the name of
> > the computer that it is executed on. I have a function that uses
> > sockets to connect to some program, and it would be best if I can have
> > a function that automatically retrieves the name of the machine. Also,
> > is there any read function that reads tokens that are separated by
> > spaces. I know that the read function can do this, but it will also
> > read an entire parenthetical item as one item, rather than dividing it
> > into sub-tokens that are separated by spaces. Any built in function?
> > If not, this will be pretty straightforward to implement using read-
> > char, but I was just wondering if anything was built in. Thanks.
>
> Several people have written about implementation-specific functions,
> but there are some CL functions that you might find useful (although
> their /results/ are still implementation specific).
>
> Fromhttp://www.lisp.org/HyperSpec/Body/sec_the_envir_t_dictionary.html
>
> Function LISP-IMPLEMENTATION-TYPE, LISP-IMPLEMENTATION-VERSION
> Function SHORT-SITE-NAME, LONG-SITE-NAME
> Function MACHINE-INSTANCE
> Function MACHINE-TYPE
> Function MACHINE-VERSION
> Function SOFTWARE-TYPE, SOFTWARE-VERSION
>
> On Lispworks 5.0, OS X 10.4, machine-instance returned the name of my
> machine.
>
> And, while not entirely relevant, I was pleased when I first found:
>
> Function USER-HOMEDIR-PATHNAME
>
> //JT

Hi

I have not updated it recently, but that would be what CL-ENVIRONMENT
should be for.  Have a look at it in the CLOCC.

Cheers
--
Marco
From: Jeffrey
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <xeKdnTVIWItceZ7VnZ2dnUVZ_qninZ2d@comcast.com>
dstein64 wrote:
> Sorry for the vague subject title, but I could not think of anything
> better. Anyhow, is there any Lisp function that returns the name of
> the computer that it is executed on. I have a function that uses
> sockets to connect to some program, and it would be best if I can have
> a function that automatically retrieves the name of the machine. Also,
> is there any read function that reads tokens that are separated by
> spaces. I know that the read function can do this, but it will also
> read an entire parenthetical item as one item, rather than dividing it
> into sub-tokens that are separated by spaces. Any built in function?
> If not, this will be pretty straightforward to implement using read-
> char, but I was just wondering if anything was built in. Thanks.

If you don't mind using a library:

http://weitz.de/cl-ppcre/

Has a split function that will break on whitespace if you ask it to. 
Plus, a good regular expression library will eventually prove useful, so 
  it won't hurt to learn your way around it now.
From: John Thingstad
Subject: Re: Two Lisp Questions
Date: 
Message-ID: <op.t9mlsbb6ut4oq5@pandora.alfanett.no>
P� Tue, 15 Apr 2008 01:12:01 +0200, skrev Jeffrey <·······@comcast.net>:

> dstein64 wrote:
>> Sorry for the vague subject title, but I could not think of anything
>> better. Anyhow, is there any Lisp function that returns the name of
>> the computer that it is executed on. I have a function that uses
>> sockets to connect to some program, and it would be best if I can have
>> a function that automatically retrieves the name of the machine. Also,
>> is there any read function that reads tokens that are separated by
>> spaces. I know that the read function can do this, but it will also
>> read an entire parenthetical item as one item, rather than dividing it
>> into sub-tokens that are separated by spaces. Any built in function?
>> If not, this will be pretty straightforward to implement using read-
>> char, but I was just wondering if anything was built in. Thanks.
>
> If you don't mind using a library:
>
> http://weitz.de/cl-ppcre/
>
> Has a split function that will break on whitespace if you ask it to.  
> Plus, a good regular expression library will eventually prove useful, so  
>   it won't hurt to learn your way around it now.


or just split-sequence
http://www.cliki.net/SPLIT-SEQUENCE

--------------
John Thingstad