[Top][All Lists]

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

Re: m4-discuss Digest, Vol 72, Issue 1

From: daniel daniel
Subject: Re: m4-discuss Digest, Vol 72, Issue 1
Date: Mon, 18 Jul 2011 10:39:49 -0700

Hi John, I had a little think about this, and the solution is quite easy:
1. cd to home directory, create a new sub-directory called m4proj, and cd into that directory: # cd ~/; mkdir m4proj; cd m4proj
2. create your inputFile.m4 with the text: A word can expand to many things.: # echo "A word can expand to many things.">inputFile.m4
3. open a text editor of your choice to create your def.m4 m4 file, and save it with the following code:
define(word,term)`'define(many,a great `many')dnl
4. run your code: m4 def.m4

Note how the inputFile.m4 is referred to via inclusion, so that if the contents of that change, then the output changes!

Having a little think,

On Mon, Jul 18, 2011 at 4:10 AM, John Allsup <address@hidden> wrote:
I've had a little think about this.  The simplest problem I can set you m4 people is the task of writing
a simple macro driven input that does the following:

Given a source file in1.m4 which contains the following:
   A word can expand to many things.
and the file def.m4 which contains
   define(word,term)define(many,a great `many')
the challenge is to generate the output
   The phrase 'A word can expand to many things' may be expanded to the following.
       A term can expand to a great many things.
using the simplest m4 input possible and by referring to the contents of the file via inclusion so that
if the contents of the input file change, the output changes accordingly.

Have a think.


On 18/07/11 03:57, John Calcote wrote:
Hi John,

I see exactly what you want, but I'm not sure what you're asking for is
reasonable. Why would you want to run a file though a macro processor and
not have it process any macros? Given your original input files, "a" and
"b", consider this sequence of commands:

cat a | m4>  out.txt
cat b>>  out.txt

This would see to accomplish exactly what you want, wouldn't it?

John Calcote

-----Original Message-----
From: m4-discuss-bounces+john.calcote=gmail.com@gnu.org
[mailto:m4-discuss-bounces+john.calcote=gmail.com@gnu.org] On Behalf Of
Sent: Sunday, July 17, 2011 10:00 AM
To: address@hidden
Subject: m4-discuss Digest, Vol 72, Issue 1

Send m4-discuss mailing list submissions to

To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to

You can reach the person managing the list at

When replying, please edit your Subject line so it is more specific than
"Re: Contents of m4-discuss digest..."

Today's Topics:

   1. Simple method of including a file that bypasses macro
      expansion (John Allsup (M4))


Message: 1
Date: Sun, 17 Jul 2011 08:15:04 +0100 (BST)
From: "John Allsup (M4)"<address@hidden>
To: address@hidden
Subject: Simple method of including a file that bypasses macro
Content-Type: text/plain; charset="utf-8"

I am relatively new to m4, but can't seem to find an equivalent to include
that bypasses macro expansion.
Suppose file 'a' contains
? hello world
and file 'b' contains
? goodbye world
and in my m4 I have defined
? define(world,and).
I a macro which I will call 'oinclude' such that ? include(a) oinclude(b)
expands to ? hello and goodbye world.

Is there a simple method?
-------------- next part --------------
An HTML attachment was scrubbed...

End of m4-discuss Digest, Vol 72, Issue 1

reply via email to

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