unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* elisp question: format
@ 2007-06-24  6:56 Aaron Maxwell
  2007-06-28  4:39 ` Kevin Rodgers
       [not found] ` <mailman.2722.1183005606.32220.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Aaron Maxwell @ 2007-06-24  6:56 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

Is there a way to direct the format function to use a single value
repeatedly for several positional parameters?

Here's the specific example of what I mean.  In my .emacs, the
following string is used:
"/home/amax/opt/scmutils/mit-scheme/bin/scheme --band /home/amax/opt/scmutils/mit-scheme/lib/edwin-mechanics.com --heap 6000 --library /home/amax/opt/scmutils/mit-scheme/lib"

(See [1] if you're curious what it's for.)  The substring "/home/amax/opt/scmutils/mit-scheme" repeats 3 times. The idea I had is to use a format string like:

(format "%s/bin/scheme --band %s/lib/edwin-mechanics.com --heap 6000 --library %s/lib" ...(something)...)

... and to do this in a way that I only had to type that substring
once.  However, I did not find a way to do this directly.  The closest
thing I came up with is this:

(apply 'format 
       (cons "%s/bin/scheme --band %s/lib/edwin-mechanics.com --heap 6000 --library %s/lib" 
       (make-list 3 "/home/amax/opt/scmutils/mit-scheme")))

Is there a clearer way to do this? 

Thanks in advance.

[1] http://redsymbol.blogspot.com/2007/06/using-gnu-emacs-with-scmutils.html
-- 
Aaron Maxwell
http://redsymbol.net

Business Owners and Self-Employed:  You're NOT Alone!
The Business Butler - http://businessbutler.us

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

* Re: elisp question: format
       [not found] <mailman.2558.1182668174.32220.help-gnu-emacs@gnu.org>
@ 2007-06-24  9:00 ` Pascal Bourguignon
  2007-06-24 11:22 ` Daniel Jensen
  1 sibling, 0 replies; 6+ messages in thread
From: Pascal Bourguignon @ 2007-06-24  9:00 UTC (permalink / raw)
  To: help-gnu-emacs

Aaron Maxwell <amax@redsymbol.net> writes:
> Is there a way to direct the format function to use a single value
> repeatedly for several positional parameters?

No. This is not Common Lisp!

Well, you could use emacs-cl:

(load "load-cl")
(FORMAT nil "First: ~A ; Second: ~:*~A" 42)
--> "First: 42 ; Second: 42"


Yep, not only do I have (require 'cl) first thing in my ~/.emacs, but
I also have (load "load-cl") next...

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

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.

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

* Re: elisp question: format
       [not found] <mailman.2558.1182668174.32220.help-gnu-emacs@gnu.org>
  2007-06-24  9:00 ` elisp question: format Pascal Bourguignon
@ 2007-06-24 11:22 ` Daniel Jensen
  2007-06-25  8:59   ` Aaron Maxwell
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel Jensen @ 2007-06-24 11:22 UTC (permalink / raw)
  To: help-gnu-emacs

Aaron Maxwell <amax@redsymbol.net> writes:

> Is there a way to direct the format function to use a single value
> repeatedly for several positional parameters?

You can use format-spec for this.

(require 'format-spec)                  ; from Gnus

(format-spec "%s/bin/scheme --band %s/lib/edwin-mechanics.com ..."
             '((?s . "/home/amax/opt/scmutils/mit-scheme")))

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

* Re: elisp question: format
  2007-06-24 11:22 ` Daniel Jensen
@ 2007-06-25  8:59   ` Aaron Maxwell
  0 siblings, 0 replies; 6+ messages in thread
From: Aaron Maxwell @ 2007-06-25  8:59 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks for the answers, guys, good to know - I appreciate it.
-A

On Sunday 24 June 2007 04:22, Daniel Jensen wrote:
> Aaron Maxwell <amax@redsymbol.net> writes:
> > Is there a way to direct the format function to use a single value
> > repeatedly for several positional parameters?
>
> You can use format-spec for this.
>
> (require 'format-spec)                  ; from Gnus
>
> (format-spec "%s/bin/scheme --band %s/lib/edwin-mechanics.com ..."
>              '((?s . "/home/amax/opt/scmutils/mit-scheme")))
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

-- 
Aaron Maxwell
http://redsymbol.net

Business Owners and Self-Employed:  You're NOT Alone!
The Business Butler - http://businessbutler.us

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

* Re: elisp question: format
  2007-06-24  6:56 Aaron Maxwell
@ 2007-06-28  4:39 ` Kevin Rodgers
       [not found] ` <mailman.2722.1183005606.32220.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2007-06-28  4:39 UTC (permalink / raw)
  To: help-gnu-emacs

Aaron Maxwell wrote:
> Hi,
> 
> Is there a way to direct the format function to use a single value
> repeatedly for several positional parameters?
> 
> Here's the specific example of what I mean.  In my .emacs, the
> following string is used:
> "/home/amax/opt/scmutils/mit-scheme/bin/scheme --band /home/amax/opt/scmutils/mit-scheme/lib/edwin-mechanics.com --heap 6000 --library /home/amax/opt/scmutils/mit-scheme/lib"
> 
> (See [1] if you're curious what it's for.)  The substring "/home/amax/opt/scmutils/mit-scheme" repeats 3 times. The idea I had is to use a format string like:
> 
> (format "%s/bin/scheme --band %s/lib/edwin-mechanics.com --heap 6000 --library %s/lib" ...(something)...)
> 
> ... and to do this in a way that I only had to type that substring
> once.  However, I did not find a way to do this directly.  The closest
> thing I came up with is this:
> 
> (apply 'format 
>        (cons "%s/bin/scheme --band %s/lib/edwin-mechanics.com --heap 6000 --library %s/lib" 
>        (make-list 3 "/home/amax/opt/scmutils/mit-scheme")))
> 
> Is there a clearer way to do this? 

(let ((scheme-home "/home/amax/opt/scmutils/mit-scheme"))
   (format "%s/bin/scheme --band %s/lib/edwin-mechanics.com --heap 6000 
--library %s/lib"
	  scheme-home scheme-home scheme-home))

-- 
Kevin Rodgers
Denver, Colorado, USA

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

* Re: elisp question: format
       [not found] ` <mailman.2722.1183005606.32220.help-gnu-emacs@gnu.org>
@ 2007-06-29 13:26   ` Joel J. Adamson
  0 siblings, 0 replies; 6+ messages in thread
From: Joel J. Adamson @ 2007-06-29 13:26 UTC (permalink / raw)
  To: help-gnu-emacs

Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:

> Aaron Maxwell wrote:
>>
>> Is there a clearer way to do this? 
>
> (let ((scheme-home "/home/amax/opt/scmutils/mit-scheme"))
>   (format "%s/bin/scheme --band %s/lib/edwin-mechanics.com --heap 6000
> --library %s/lib"
> 	  scheme-home scheme-home scheme-home))

And what if I wanted to repeat it a thousand times?

Joel

-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

*Joel's guide to sending attachments:
1.  put all the files you want to send in a folder and archive the
folder using tar, then compress it with gzip or bzip2
2.  please send me .pdf, .html, or text in place of Word documents:
http://www.gnu.org/philosophy/sylvester-response.html

*Did you know there's a FREE alternative to using word processors?
http://www.edafe.org/latex/
http://en.wikipedia.org/wiki/LaTeX
http://nitens.org/taraborelli/latex

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

end of thread, other threads:[~2007-06-29 13:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2558.1182668174.32220.help-gnu-emacs@gnu.org>
2007-06-24  9:00 ` elisp question: format Pascal Bourguignon
2007-06-24 11:22 ` Daniel Jensen
2007-06-25  8:59   ` Aaron Maxwell
2007-06-24  6:56 Aaron Maxwell
2007-06-28  4:39 ` Kevin Rodgers
     [not found] ` <mailman.2722.1183005606.32220.help-gnu-emacs@gnu.org>
2007-06-29 13:26   ` Joel J. Adamson

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