Go to the first, previous, next, last section, table of contents.


Macros: Defining New Texinfo Commands

Texinfo ¸ÅÅ©·Î(macro)¸¦ »ç¿ëÇÏ¸é »õ·Î¿î Texinfo ¸í·É¾î¸¦ ±ÛÀ̳ª ÀÌ¹Ì ÀÖ´Â ¸í·É¾î(´Ù¸¥ ¸ÅÅ©·Î±îÁö Æ÷ÇÔÇؼ­)¸¦ ºÙ¿©¼­ Á¤ÀÇÇÒ ¼ö ÀÖ´Ù. ¸ÅÅ©·Î´Â ÆĶó¹ÌÅÍ(parameter)---¸ÅÅ©·Î¸¦ ¾µ ¶§¸¶´Ù ¸ÅÅ©·Î¿¡ Á¦°øÇÏ´Â ±Û---¸¦ ¸î°³¶óµµ °¡Áú ¼ö ÀÖ´Ù. (ÀÌ ¸ÅÅ©·Î´Â @defmac ¸í·É¾î¿Í´Â ¾Æ¹«·± °ü°è°¡ ¾ø´Ù. @defmac´Â ¸Å´º¾óÀÇ ³»¿ë»óÀÇ ¸ÅÅ©·Î¸¦ ¹®¼­È­ÇÏ´Â °ÍÀÌ´Ù; see section The Template for a Definition.)

Defining Macros

¸ÅÅ©·Î¸¦ Á¤ÀÇÇÏ´Â µ¥´Â @macro Texinfo ¸í·É¾î¸¦ ¾´´Ù. ¿¹¸¦ µé¾î:

@macro macro-name{param1, param2, ...}
text ... \param1\ ...
@end macro

ÆĶó¹ÌÅÍ(parameter) param1, param2, ...´Â ¸ÅÅ©·Î°¡ ¹®¼­¿¡¼­ ¾ÕÀ¸·Î »ç¿ëµÉ¶§ Á¦°øÇØ¾ß ÇÒ ÀÎÀÚÀÌ´Ù. (´ÙÀ½ ÀýÀ» º¸¶ó).

¸ÅÅ©·Î¿¡ ÆĶó¹ÌÅÍ(parameter)°¡ ÇÊ¿ä¾øÀ¸¸é, ÅÖ ºó ¸®½ºÆ®·Î ¾²°Å³ª (`@macro foo {}') ¾Æ¿¹ Áß°ýÈ£¸¦ ¾²Áö ¾ÊÀ¸¸é µÈ´Ù (`@macro foo').

¸ÅÅ©·ÎÀÇ º»Ã¼(body)¿¡´Â ¾Õ¿¡¼­ Á¤ÀÇÇÑ ¸ÅÅ©·Î±îÁö Æ÷ÇÔÇؼ­ ¾î¶² Texinfo ¸í·ÉÀÌµç µé¾î°¥ ¼ö ÀÖ´Ù. (»óÈ£ Àç±ÍÀûÀÎ(mutually recursive) Texinfo ¸ÅÅ©·Î¸¦ ¾²´Â °ÍÀº ºÒ°¡´ÉÇÏ´Ù.) º»Ã¼(body)¿¡¼­, ÆĶó¹ÌÅÍ(parameter)ÀÇ °ªÀ» »ç¿ëÇÏ·Á¸é À§ÀÇ ¿¹¿¡¼­ `\param1\'¿Í °°ÀÌ ¹é½½·¡½¬(backslash)·Î µÑ·¯½Ñ´Ù. ÀÌ°ÍÀº ¸ÅÅ©·Î¸¦ ºÎ¸¦¶§ ´ëÀÀµÇ´Â ÀÎÀÚ·Î ¹Ù²ãÁø´Ù.

foo¶ó´Â ¸ÅÅ©·Î´Â @unmacro foo·Î Á¤ÀǸ¦ Ãë¼ÒÇÒ ¼ö ÀÖ´Ù. ÀÌ¹Ì Á¤ÀÇµÈ ¸ÅÅ©·Î¸¦ Ãë¼ÒÇÏ´Â °ÍÀº ¾Ö·¯°¡ ¾Æ´Ï´Ù. ¿¹¸¦ µé¾î:

@unmacro foo

Invoking Macros

¸ÅÅ©·Î¸¦ Á¤ÀÇÇÑ ÈÄ¿¡ (¾ÕÀÇ ÀýÀ» º¸¶ó), ´ÙÀ½°ú °°ÀÌ ¹®¼­ ³»¿¡¼­ ±× ¸ÅÅ©·Î¸¦ »ç¿ëÇÒ(invoke) ¼ö ÀÖ´Ù.

@macro-name {arg1, arg2, ...}

±×¸®°í °á°ú´Â ±× ÀÚ¸®¿¡ macro-nameÀÇ º»Ã¼(body)¸¦ ŸÀÌÇÁÇÑ °Í°ú °°´Ù. ¿¹¸¦ µé¾î:

@macro foo {p, q}
Together: \p\ & \q\.
@end macro
@foo{a, b}

°¡ ¸ÅÅ©·Î¿´´Ù¸é °á°ú´Â ´ÙÀ½À» ¸¸µé¾î ³»°Ô µÈ´Ù:

Together: a & b.

Áï, ÀÎÀÚ(argument)¿Í ÆĶó¹ÌÅÍ(parameter)´Â ½°Ç¥·Î ³ª´²Áö°í, Áß°ýÈ£·Î ¤¡¤ÌºÐµÈ´Ù; ½°Ç¥ µÚÀÇ (¾Õ¿¡´Â ¾Æ´Ï´Ù) °ø¹éÀº ¹«½ÃµÈ´Ù. ÀÎÀÚ(argument)¿¡ ½°Ç¥, Áß°ýÈ£, ¶Ç´Â ¹é½½·¡½¬(backslash)¸¦ ³ÖÀ¸·Á¸é, ´ÙÀ½°ú °°ÀÌ ¾Õ¿¡ ¹é½½·¡½¬(backslash)¸¦ ºÙÀδÙ.

@macro-name {\\\{\}\,}

ÀÌ·¸°Ô Çϸé macro-name ¸ÅÅ©·Î¿¡ `\{},'ÀÇ ÀÎÀÚ¸¦ (ÇÏÁö¸¸ °ÅÀÇ ºÐ¸íÈ÷ ¾Ö·¯¸¦ ¹ß»ýÇÑ´Ù) º¸³»ÁÖ°Ô µÈ´Ù.

¸ÅÅ©·Î°¡ ÇÑ°³ÀÇ ÀÎÀÚ¸¦ ¹Þµµ·Ï Á¤ÀǵǾî ÀÖ°í, Áß°ýÈ£°¡ ¾øÀÌ »ç¿ëµÈ´Ù¸é, ¸ÅÅ©·Î À̸§ µÚÀÇ ³ª¸ÓÁö ÁÙÀº ÀÎÀÚ·Î »ç¿ëµÈ´Ù. ¿¹¸¦ µé¾î:

@macro bar {p}
Twice: \p\, \p\.
@end macro
@bar aah

´Â ´ÙÀ½À» ¸¸µé¾î ³½´Ù.

Twice: aah, aah.

¿Í °°ÀÌ µÈ´Ù.


Go to the first, previous, next, last section, table of contents.