home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / elisp / elisp-29 < prev    next >
Encoding:
GNU Info File  |  1993-05-31  |  49.6 KB  |  1,219 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.  
  4.    This is edition 2.0 of the GNU Emacs Lisp Reference Manual, for
  5. Emacs Version 19.
  6.  
  7.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  8. Cambridge, MA 02139 USA
  9.  
  10.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided that
  18. the entire resulting derived work is distributed under the terms of a
  19. permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that this permission notice may be stated in a
  24. translation approved by the Foundation.
  25.  
  26. 
  27. File: elisp,  Node: Holiday Customizing,  Next: Date Display Format,  Prev: Calendar Customizing,  Up: Calendar
  28.  
  29. Customizing the Holidays
  30. ========================
  31.  
  32.    Emacs knows about holidays defined by entries on one of several
  33. lists.  You can customize theses lists of holidays to your own needs,
  34. adding holidays or deleting lists of holidays.  The lists of holidays
  35. that Emacs uses are for general holidays (`general-holidays'), local
  36. holidays (`local-holidays'), Christian holidays (`christian-holidays'),
  37. Hebrew (Jewish) holidays (`hebrew-holidays'), Islamic (Moslem) holidays
  38. (`islamic-holidays'), and other holidays (`other-holidays').
  39.  
  40.    The general holidays are, by default, holidays common throughout the
  41. United States.  To eliminate these holidays, set `general-holidays' to
  42. `nil'.
  43.  
  44.    There are no default local holidays (but sites may supply some).  You
  45. can set the variable `local-holidays' to any list of holidays, as
  46. described below.
  47.  
  48.    By default, Emacs does not consider all the holidays of these
  49. religions, only those commonly found in secular calendars.  For a more
  50. extensive collection of religious holidays, you can set any (or all) of
  51. the variables `all-christian-calendar-holidays',
  52. `all-hebrew-calendar-holidays', or `all-islamic-calendar-holidays' to
  53. `t'.  If you want to eliminate the religious holidays, set any or all
  54. of the corresponding variables `christian-holidays', `hebrew-holidays',
  55. and `islamic-holidays' to `nil'.
  56.  
  57.    You can set the variable `other-holidays' to any list of holidays.
  58. This list, normally empty, is intended for your use.
  59.  
  60.    Each of the lists (`general-holidays'), (`local-holidays'),
  61. (`christian-holidays'), (`hebrew-holidays'), (`islamic-holidays'),and
  62. (`other-holidays') is a list of "holiday forms", each holiday form
  63. describing a holiday (or sometimes a list of holidays).  Holiday forms
  64. may have the following formats:
  65.  
  66. `(fixed MONTH DAY STRING)'
  67.      A fixed date on the Gregorian calendar.  MONTH and DAY are
  68.      numbers, STRING is the name of the holiday.
  69.  
  70. `(float MONTH DAYNAME K STRING)'
  71.      The Kth DAYNAME in MONTH on the Gregorian calendar (DAYNAME=0 for
  72.      Sunday, and so on); negative K means count back from the end of
  73.      the month.  STRING is the name of the holiday.
  74.  
  75. `(hebrew MONTH DAY STRING)'
  76.      A fixed date on the Hebrew calendar.  MONTH and DAY are numbers,
  77.      STRING is the name of the holiday.
  78.  
  79. `(islamic MONTH DAY STRING)'
  80.      A fixed date on the Islamic calendar.  MONTH and DAY are numbers,
  81.      STRING is the name of the holiday.
  82.  
  83. `(julian MONTH DAY STRING)'
  84.      A fixed date on the Julian calendar.  MONTH and DAY are numbers,
  85.      STRING is the name of the holiday.
  86.  
  87. `(sexp SEXP STRING)'
  88.      SEXP is a Lisp expression that should use the variable `year' to
  89.      compute the date of a holiday, or `nil' if the holiday doesn't
  90.      happen this year.  The value represents the date as a list of the
  91.      form `(MONTH DAY YEAR)'.  STRING is the name of the holiday.
  92.  
  93. `(if BOOLEAN HOLIDAY-FORM &optional HOLIDAY-FORM)'
  94.      A choice between two holidays based on the value of BOOLEAN.
  95.  
  96. `(FUNCTION &optional ARGS)'
  97.      Dates requiring special computation; ARGS, if any, are passed in a
  98.      list to the function `calendar-holiday-function-FUNCTION'.
  99.  
  100.    For example, suppose you want to add Bastille Day, celebrated in
  101. France on July 14.  You can do this by adding the following line to
  102. your `.emacs' file:
  103.  
  104.      (setq other-holidays '((fixed 7 14 "Bastille Day")))
  105.  
  106. The holiday form `(fixed 7 14 "Bastille Day")' specifies the fourteenth
  107. day of the seventh month (July).
  108.  
  109.    Many holidays occur on a specific day of the week, at a specific time
  110. of month.  Here is a holiday form describing Hurricane Supplication Day,
  111. celebrated in the Virgin Islands on the fourth Monday in August:
  112.  
  113.      (float 8 1 4 "Hurricane Supplication Day")
  114.  
  115. Here the 8 specifies August, the 1 specifies Monday (Sunday is 0,
  116. Tuesday is 2, and so on), and the 4 specifies the fourth occurrence in
  117. the month (1 specifies the first occurrence, 2 the second occurrence,
  118. -1 the last occurrence, -2 the second-to-last occurrence, and so on).
  119.  
  120.    You can specify holidays that occur on fixed days of the Hebrew,
  121. Islamic, and Julian calendars too.  For example,
  122.  
  123.      (setq other-holidays
  124.            '((hebrew 10 2 "Last day of Hanukkah")
  125.              (islamic 3 12 "Mohammed's Birthday")
  126.              (julian 4 2 "Jefferson's Birthday")))
  127.  
  128. adds the last day of Hanukkah (since the Hebrew months are numbered with
  129. 1 starting from Nisan), the Islamic feast celebrating Mohammed's
  130. birthday (since the Islamic months are numbered from 1 starting with
  131. Muharram), and Thomas Jefferson's birthday, which is 2 April 1743 on the
  132. Julian calendar.
  133.  
  134.    To include a holiday conditionally, use either the `if' or the
  135. `sexp' form.  For example, American presidential elections occur on the
  136. first Tuesday after the first Monday in November of years divisible by
  137. 4:
  138.  
  139.      (sexp (if (= 0 (% year 4))
  140.                (calendar-gregorian-from-absolute
  141.                  (1+ (calendar-dayname-on-or-before
  142.                         1 (+ 6 (calendar-absolute-from-gregorian
  143.                                  (list 11 1 year))))))
  144.            "US Presidential Election"))
  145.  
  146. or
  147.  
  148.      (if (= 0 (% displayed-year 4))
  149.          (fixed 11
  150.                 (extract-calendar-day
  151.                   (calendar-gregorian-from-absolute
  152.                     (1+ (calendar-dayname-on-or-before
  153.                           1 (+ 6 (calendar-absolute-from-gregorian
  154.                                    (list 11 1 displayed-year)))))))
  155.                 "US Presidential Election"))
  156.  
  157.    Some holidays just don't fit into any of these forms because special
  158. calculations are involved in their determination.  In such cases you
  159. must write a Lisp function to do the calculation.  The function should
  160. return a (possibly empty) list of the relevant Gregorian dates among the
  161. range visible in the calendar window, with descriptive strings, like
  162. this:
  163.  
  164.      (((6 27 1991) "Lunar Eclipse") ((7 11 1991) "Solar Eclipse") ... )
  165.  
  166. 
  167. File: elisp,  Node: Date Display Format,  Next: Time Display Format,  Prev: Holiday Customizing,  Up: Calendar
  168.  
  169. Date Display Format
  170. ===================
  171.  
  172.    You can customize the manner of displaying dates in the diary, in
  173. mode lines, and in messages by setting `calendar-date-display-form'.
  174. This variable is a list of expressions that can involve the variables
  175. `month', `day', and `year', all numbers in string form, and `monthname'
  176. and `dayname', both alphabetic strings.  In the American style, the
  177. default value of this list is as follows:
  178.  
  179.      ((if dayname (concat dayname ", ")) monthname " " day ", " year)
  180.  
  181. while in the European style this value is the default:
  182.  
  183.      ((if dayname (concat dayname ", ")) day " " monthname " " year)
  184.  
  185.    The ISO standard date representation is this:
  186.  
  187.      (year "-" month "-" day)
  188.  
  189. This specifies a typical American format:
  190.  
  191.      (month "/" day "/" (substring year -2))
  192.  
  193. 
  194. File: elisp,  Node: Time Display Format,  Next: Daylight Savings,  Prev: Date Display Format,  Up: Calendar
  195.  
  196. Time Display Format
  197. ===================
  198.  
  199.    In the calendar, diary, and related buffers, Emacs displays times of
  200. day in the conventional American style with the hours from 1 through 12,
  201. minutes, and either `am' or `pm'.  If you prefer the "military"
  202. (European) style of writing times--in which the hours go from 00 to
  203. 23--you can alter the variable `calendar-time-display-form'.  This
  204. variable is a list of expressions that can involve the variables
  205. `12-hours', `24-hours', and `minutes', all numbers in string form, and
  206. `am-pm' and `time-zone', both alphabetic strings.  The default
  207. definition of `calendar-time-display-form' is as follows:
  208.  
  209.      (12-hours ":" minutes am-pm (if time-zone " (") time-zone (if time-zone ")"))
  210.  
  211.    Setting `calendar-time-display-form' to
  212.  
  213.      (24-hours ":" minutes (if time-zone " (") time-zone (if time-zone ")"))
  214.  
  215. gives military-style times like `21:07 (UT)' if time zone names are
  216. defined, and times like `21:07' if they are not.
  217.  
  218. 
  219. File: elisp,  Node: Daylight Savings,  Next: Diary Customizing,  Prev: Time Display Format,  Up: Calendar
  220.  
  221. Daylight Savings Time
  222. =====================
  223.  
  224.    Emacs understands the difference between standard time and daylight
  225. savings time--the times given for sunrise, sunset, solstices,
  226. equinoxes, and the phases of the moon take that into account.  The
  227. default starting and stopping dates for daylight savings time are the
  228. present-day American rules of the first Sunday in April until the last
  229. Sunday in October, but you can specify whatever rules you want by
  230. setting `calendar-daylight-savings-starts' and
  231. `calendar-daylight-savings-ends'.  Their values should be Lisp
  232. expressions that refer to the variable `year', and evaluate to the
  233. Gregorian date on which daylight savings time starts or (respectively)
  234. ends, in the form of a list `(MONTH DAY YEAR)'.
  235.  
  236.    Emacs uses these expressions to determine the starting date of
  237. daylight savings time for the holiday list and for correcting times of
  238. day in the solar and lunar calculations.
  239.  
  240.    The default value of `calendar-daylight-savings-starts' is this,
  241.  
  242.      (calendar-nth-named-day 1 0 4 year)
  243.  
  244. which computes the first 0th day (Sunday) of the fourth month (April) in
  245. the year specified by `year'.  If daylight savings time were changed to
  246. start on October 1, you would set `calendar-daylight-savings-starts' to
  247.  
  248.      (list 10 1 year)
  249.  
  250.    For a more complex example, suppose daylight savings time begins on
  251. the first of Nisan on the Hebrew calendar.  You would set
  252. `calendar-daylight-savings-starts' to
  253.  
  254.      (calendar-gregorian-from-absolute
  255.        (calendar-absolute-from-hebrew
  256.          (list 1 1 (+ year 3760))))
  257.  
  258. because Nisan is the first month in the Hebrew calendar and the Hebrew
  259. year differs from the Gregorian year by 3760 at Nisan.
  260.  
  261.    If there is no daylight savings time at your location, or if you want
  262. all times in standard time, set `calendar-daylight-savings-starts' and
  263. `calendar-daylight-savings-ends' to `nil'.
  264.  
  265. 
  266. File: elisp,  Node: Diary Customizing,  Next: Hebrew/Islamic Entries,  Prev: Daylight Savings,  Up: Calendar
  267.  
  268. Customizing the Diary
  269. =====================
  270.  
  271.    Ordinarily, the mode line of the diary buffer window indicates any
  272. holidays that fall on the date of the diary entries.  The process of
  273. checking for holidays can take several seconds, so including holiday
  274. information delays the display of the diary buffer noticeably.  If you'd
  275. prefer to have a faster display of the diary buffer but without the
  276. holiday information, set the variable `holidays-in-diary-buffer' to
  277. `nil'.
  278.  
  279.    The variable `number-of-diary-entries' controls the number of days
  280. of diary entries to be displayed at one time.  It affects the initial
  281. display when `view-diary-entries-initially' is `t', as well as the
  282. command `M-x diary'.  For example, the default value is 1, which says
  283. to display only the current day's diary entries.  If the value is 2,
  284. both the current day's and the next day's entries are displayed.  The
  285. value can also be a vector of seven elements: if the value is `[0 2 2 2
  286. 2 4 1]' then no diary entries appear on Sunday, the current date's and
  287. the next day's diary entries appear Monday through Thursday, Friday
  288. through Monday's entries appear on Friday, while on Saturday only that
  289. day's entries appear.
  290.  
  291.    The variable `print-diary-entries-hook' is a normal hook run after
  292. preparation of a temporary buffer containing just the diary entries
  293. currently visible in the diary buffer.  (The other, irrelevant diary
  294. entries are really absent from the temporary buffer; in the diary
  295. buffer, they are merely hidden.)  The default value of this hook does
  296. the printing with the command `lpr-buffer'.  If you want to use a
  297. different command to do the printing, just change the value of this
  298. hook.  Other uses might include, for example, rearranging the lines into
  299. order by day and time.
  300.  
  301.    You can customize the form of dates in your diary file, if neither
  302. the standard American nor European styles suits your needs, by setting
  303. the variable `diary-date-forms'.  This variable is a list of forms of
  304. dates recognized in the diary file.  Each form is a list of regular
  305. expressions (*note Regular Expressions::.) and the variables `month',
  306. `day', `year', `monthname', and `dayname'.  The variable `monthname'
  307. matches the name of the month, capitalized or not, or its three-letter
  308. abbreviation, followed by a period or not; it matches `*'.  Similarly,
  309. `dayname' matches the name of the day, capitalized or not, or its
  310. three-letter abbreviation, followed by a period or not.  The variables
  311. `month', `day', and `year' match those numerical values, preceded by
  312. arbitrarily many zeros; they also match `*'.  The default value of
  313. `diary-date-forms' in the American style is
  314.  
  315.      ((month "/" day "[^/0-9]")
  316.       (month "/" day "/" year "[^0-9]")
  317.       (monthname " *" day "[^,0-9]")
  318.       (monthname " *" day ", *" year "[^0-9]")
  319.       (dayname "\\W"))
  320.  
  321. Emacs matches of the diary entries with the date forms is done with the
  322. standard syntax table from Fundamental mode (*note Syntax Tables::.),
  323. but with the `*' changed so that it is a word constituent.
  324.  
  325.    The forms on the list must be *mutually exclusive* and must not
  326. match any portion of the diary entry itself, just the date.  If, to be
  327. mutually exclusive, the pattern must match a portion of the diary entry
  328. itself, the first element of the form *must* be `backup'.  This causes
  329. the date recognizer to back up to the beginning of the current word of
  330. the diary entry.  Even if you use `backup', the form must absolutely
  331. not match more than a portion of the first word of the diary entry.
  332. The default value of `diary-date-forms' in the European style is this
  333. list:
  334.  
  335.      ((day "/" month "[^/0-9]")
  336.       (day "/" month "/" year "[^0-9]")
  337.       (backup day " *" monthname "\\W+\\<[^*0-9]")
  338.       (day " *" monthname " *" year "[^0-9]")
  339.       (dayname "\\W"))
  340.  
  341. Notice the use of `backup' in the middle form because part of the diary
  342. entry must be matched to distinguish this form from the following one.
  343.  
  344. 
  345. File: elisp,  Node: Hebrew/Islamic Entries,  Next: Fancy Diary Display,  Prev: Diary Customizing,  Up: Calendar
  346.  
  347. Hebrew- and Islamic-Date Diary Entries
  348. ======================================
  349.  
  350.    Your diary file can have entries based on Hebrew or Islamic dates, as
  351. well as entries based on our usual Gregorian calendar.  However, because
  352. the processing of such entries is time-consuming and most people don't
  353. need them, you must customize the processing of your diary file to
  354. specify that you want such entries recognized.  If you want Hebrew-date
  355. diary entries, for example, you must include these lines in your
  356. `.emacs' file:
  357.  
  358.      (setq nongregorian-diary-listing-hook 'list-hebrew-diary-entries)
  359.      (setq nongregorian-diary-marking-hook 'mark-hebrew-diary-entries)
  360.  
  361. If you want Islamic-date entries, include these lines in your `.emacs'
  362. file:
  363.  
  364.      (setq nongregorian-diary-listing-hook 'list-islamic-diary-entries)
  365.      (setq nongregorian-diary-marking-hook 'mark-islamic-diary-entries)
  366.  
  367. If you want both Hebrew- and Islamic-date entries, include these lines:
  368.  
  369.      (setq nongregorian-diary-listing-hook
  370.            '(list-hebrew-diary-entries list-islamic-diary-entries))
  371.      (setq nongregorian-diary-marking-hook
  372.            '(mark-hebrew-diary-entries mark-islamic-diary-entries))
  373.  
  374.    Hebrew- and Islamic-date diary entries have the same formats as
  375. Gregorian-date diary entries, except that the date must be preceded with
  376. an `H' for Hebrew dates and an `I' for Islamic dates.  Moreover,
  377. because the Hebrew and Islamic month names are not uniquely specified
  378. by the first three letters, you may not abbreviate them.  For example,
  379. a diary entry for the Hebrew date Heshvan 25 could look like
  380.  
  381.      HHeshvan 25 Happy Hebrew birthday!
  382.  
  383. and would appear in the diary for any date that corresponds to Heshvan
  384. 25 on the Hebrew calendar.  Similarly, an Islamic-date diary entry
  385. might be
  386.  
  387.      IDhu al-Qada 25 Happy Islamic birthday!
  388.  
  389. and would appear in the diary for any date that corresponds to Dhu
  390. al-Qada 25 on the Islamic calendar.
  391.  
  392.    As with Gregorian-date diary entries, Hebrew- and Islamic-date
  393. entries are nonmarking if they are preceded with an ampersand (`&').
  394.  
  395.    There are commands to help you in making Hebrew- and Islamic-date
  396. entries to your diary:
  397.  
  398. `i h d'
  399.      Add a diary entry for the Hebrew date corresponding to the
  400.      selected date (`insert-hebrew-diary-entry').
  401.  
  402. `i h m'
  403.      Add a diary entry for the day of the Hebrew month corresponding to
  404.      the selected date (`insert-monthly-hebrew-diary-entry').
  405.  
  406. `i h y'
  407.      Add a diary entry for the day of the Hebrew year corresponding to
  408.      the selected date (`insert-yearly-hebrew-diary-entry').
  409.  
  410. `i i d'
  411.      Add a diary entry for the Islamic date corresponding to the
  412.      selected date (`insert-islamic-diary-entry').
  413.  
  414. `i i m'
  415.      Add a diary entry for the day of the Islamic month corresponding
  416.      to the selected date (`insert-monthly-islamic-diary-entry').
  417.  
  418. `i i y'
  419.      Add a diary entry for the day of the Islamic year corresponding to
  420.      the selected date (`insert-yearly-islamic-diary-entry').
  421.  
  422.    These commands work exactly like the corresponding commands for
  423. ordinary diary entries: Move point to a date in the calendar window and
  424. the above commands insert the Hebrew or Islamic date (corresponding to
  425. the date indicated by point) at the end of your diary file and you can
  426. then type the diary entry.  If you want the diary entry to be
  427. nonmarking, give a numeric argument to the command.
  428.  
  429. 
  430. File: elisp,  Node: Fancy Diary Display,  Next: Included Diary Files,  Prev: Hebrew/Islamic Entries,  Up: Calendar
  431.  
  432. Fancy Diary Display
  433. ===================
  434.  
  435.    Diary display works by preparing the diary buffer and then running
  436. the hook `diary-display-hook'.  The default value of this hook hides
  437. the irrelevant diary entries and then displays the buffer
  438. (`simple-diary-display').  However, if you specify the hook as follows,
  439.  
  440.      (add-hook 'diary-display-hook 'fancy-diary-display)
  441.  
  442. then fancy mode displays diary entries and holidays by copying them into
  443. a special buffer that exists only for display.  Copying provides an
  444. opportunity to change the displayed text to make it prettier--for
  445. example, to sort the entries by the dates they apply to.
  446.  
  447.    As with simple diary display, you can print a hard copy of the buffer
  448. with `print-diary-entries'.  To print a hard copy of a day-by-day diary
  449. for a week by positioning point on Sunday of that week, type `7 d' and
  450. then do `M-x print-diary-entries'.  As usual, the inclusion of the
  451. holidays slows down the display slightly; you can speed things up by
  452. setting the variable `holidays-in-diary-buffer' to `nil'.
  453.  
  454.    Ordinarily, the fancy diary buffer does not show days for which
  455. there are no diary entries, even if that day is a holiday.  If you want
  456. such days to be shown in the fancy diary buffer, set the variable
  457. `diary-list-include-blanks' to `t'.
  458.  
  459.    If you use the fancy diary display, you can use the normal hook
  460. `list-diary-entries-hook' to sort each day's diary entries by their
  461. time of day.  Add this line to your `.emacs' file:
  462.  
  463.      (add-hook 'list-diary-entries-hook 'sort-diary-entries)
  464.  
  465. For each day, this sorts diary entries that begin with a recognizable
  466. time of day according to their times.  Diary entries without times come
  467. first within each day.
  468.  
  469. 
  470. File: elisp,  Node: Included Diary Files,  Next: Sexp Diary Entries,  Prev: Fancy Diary Display,  Up: Calendar
  471.  
  472. Included Diary Files
  473. ====================
  474.  
  475.    If you use the fancy diary display, you can have diary entries from
  476. other files included with your own by an "include" mechanism.  This
  477. facility makes possible the sharing of common diary files among groups
  478. of users.  Lines in the diary file of this form:
  479.  
  480.      #include "FILENAME"
  481.  
  482. includes the diary entries from the file FILENAME in the fancy diary
  483. buffer (because the ordinary diary buffer is just the buffer associated
  484. with your diary file, you cannot use the include mechanism unless you
  485. use the fancy diary buffer).  The include mechanism is recursive, by
  486. the way, so that included files can include other files, and so on; you
  487. must be careful not to have a cycle of inclusions, of course.  To
  488. enable the include facility, add lines as follows to your `.emacs' file:
  489.  
  490.      (add-hook 'list-diary-entries-hook 'include-other-diary-files)
  491.      (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
  492.  
  493. 
  494. File: elisp,  Node: Sexp Diary Entries,  Next: Appt Customizing,  Prev: Included Diary Files,  Up: Calendar
  495.  
  496. Sexp Entries and the Fancy Diary Display
  497. ========================================
  498.  
  499.    Sexp diary entries allow you to do more than just have complicated
  500. conditions under which a diary entry applies.  If you use the fancy
  501. diary display, sexp entries can generate the text of the entry depending
  502. on the date itself.  For example, an anniversary diary entry can insert
  503. the number of years since the anniversary date into the text of the
  504. diary entry.  Thus the `%d' in this dairy entry:
  505.  
  506.      %%(diary-anniversary 10 31 1948) Arthur's birthday (%d years old)
  507.  
  508. gets replaced by the age, so on October 31, 1990 the entry appears in
  509. the fancy diary buffer like this:
  510.  
  511.      Arthur's birthday (42 years old)
  512.  
  513. If the diary file instead contains this entry:
  514.  
  515.      %%(diary-anniversary 10 31 1948) Arthur's %d%s birthday
  516.  
  517. the entry in the fancy diary buffer for October 31, 1990 appears like
  518. this:
  519.  
  520.      Arthur's 42nd birthday
  521.  
  522.    Similarly, cyclic diary entries can interpolate the number of
  523. repetitions that have occurred:
  524.  
  525.      %%(diary-cyclic 50 1 1 1990) Renew medication (%d%s time)
  526.  
  527. looks like this:
  528.  
  529.      Renew medication (5th time)
  530.  
  531. in the fancy diary display on September 8, 1990.
  532.  
  533.    The generality of sexp diary entries lets you specify any diary entry
  534. that you can describe algorithmically.  Suppose you get paid on the 21st
  535. of the month if it is a weekday, and to the Friday before if the 21st is
  536. on a weekend.  The diary entry
  537.  
  538.      &%%(let ((dayname (calendar-day-of-week date))
  539.               (day (car (cdr date))))
  540.            (or (and (= day 21) (memq dayname '(1 2 3 4 5)))
  541.                (and (memq day '(19 20)) (= dayname 5)))
  542.               ) Pay check deposited
  543.  
  544. applies to just those dates.  This example illustrates how the sexp can
  545. depend on the variable `date'; this variable is a list (MONTH DAY YEAR)
  546. that gives the Gregorian date for which the diary entries are being
  547. found.  If the value of the expression is `t', the entry applies to
  548. that date.  If the expression evaluates to `nil', the entry does *not*
  549. apply to that date.
  550.  
  551.    The following sexp diary entries take advantage of the ability (in
  552. the fancy diary display) to concoct diary entries based on the date:
  553.  
  554. `%%(diary-sunrise-sunset)'
  555.      Make a diary entry for the local times of today's sunrise and
  556.      sunset.
  557.  
  558. `%%(diary-phases-of-moon)'
  559.      Make a diary entry for the phases (quarters) of the moon.
  560.  
  561. `%%(diary-day-of-year)'
  562.      Make a diary entry with today's day number in the current year and
  563.      the number of days remaining in the current year.
  564.  
  565. `%%(diary-iso-date)'
  566.      Make a diary entry with today's equivalent ISO commercial date.
  567.  
  568. `%%(diary-julian-date)'
  569.      Make a diary entry with today's equivalent date on the Julian
  570.      calendar.
  571.  
  572. `%%(diary-astro-day-number)'
  573.      Make a diary entry with today's equivalent astronomical (Julian)
  574.      day number.
  575.  
  576. `%%(diary-hebrew-date)'
  577.      Make a diary entry with today's equivalent date on the Hebrew
  578.      calendar.
  579.  
  580. `%%(diary-islamic-date)'
  581.      Make a diary entry with today's equivalent date on the Islamic
  582.      calendar.
  583.  
  584. `%%(diary-french-date)'
  585.      Make a diary entry with today's equivalent date on the French
  586.      Revolutionary calendar.
  587.  
  588. `%%(diary-mayan-date)'
  589.      Make a diary entry with today's equivalent date on the Mayan
  590.      calendar.
  591.  
  592. Thus including the diary entry
  593.  
  594.      &%%(diary-hebrew-date)
  595.  
  596. causes every day's diary display to contain the equivalent date on the
  597. Hebrew calendar, if you are using the fancy diary display.  (With simple
  598. diary display, the line `&%%(diary-hebrew-date)' appears in the diary
  599. for any date, but does nothing particularly useful.)
  600.  
  601.    There are a number of other available sexp diary entries that are
  602. important to those who follow the Hebrew calendar:
  603.  
  604. `%%(diary-rosh-hodesh)'
  605.      Make a diary entry that tells the occurrence and ritual
  606.      announcement of each new Hebrew month.
  607.  
  608. `%%(diary-parasha)'
  609.      Make a Saturday diary entry that tells the weekly synagogue
  610.      scripture reading.
  611.  
  612. `%%(diary-sabbath-candles)'
  613.      Make a Friday diary entry that tells the *local time* of Sabbath
  614.      candle lighting.
  615.  
  616. `%%(diary-omer)'
  617.      Make a diary entry that gives the omer count, when appropriate.
  618.  
  619. `%%(diary-yahrzeit MONTH DAY YEAR) NAME'
  620.      Make a diary entry marking the anniversary of a date of death.
  621.      The date is the *Gregorian* (civil) date of death.  The diary
  622.      entry appears on the proper Hebrew calendar anniversary and on the
  623.      day before.  (In the European style, the order of the parameters
  624.      is changed to DAY, MONTH, YEAR.)
  625.  
  626. 
  627. File: elisp,  Node: Appt Customizing,  Prev: Sexp Diary Entries,  Up: Calendar
  628.  
  629. Customizing Appointment Reminders
  630. =================================
  631.  
  632.    You can specify exactly how Emacs reminds you of an appointment and
  633. how far in advance it begins doing so.  Here are the variables that you
  634. can set:
  635.  
  636. `appt-message-warning-time'
  637.      The time in minutes before an appointment that the reminder
  638.      begins.  The default is 10 minutes.
  639.  
  640. `appt-audible'
  641.      If this is `t' (the default), Emacs rings the terminal bell for
  642.      appointment reminders.
  643.  
  644. `appt-visible'
  645.      If this is `t' (the default), Emacs displays the appointment
  646.      message in echo area.
  647.  
  648. `appt-display-mode-line'
  649.      If this is `t' (the default), Emacs displays the number of minutes
  650.      to the appointment on the mode line.
  651.  
  652. `appt-msg-window'
  653.      If this is `t' (the default), Emacs displays the appointment
  654.      message in another window.
  655.  
  656. `appt-display-duration'
  657.      The number of seconds an appointment message is displayed.  The
  658.      default is 5 seconds.
  659.  
  660. 
  661. File: elisp,  Node: Tips,  Next: GNU Emacs Internals,  Prev: Calendar,  Up: Top
  662.  
  663. Tips and Standards
  664. ******************
  665.  
  666.    This chapter describes no additional features of Emacs Lisp.
  667. Instead it gives advice on making effective use of the features
  668. described in the previous chapters.
  669.  
  670. * Menu:
  671.  
  672. * Style Tips::                Writing clean and robust programs.
  673. * Compilation Tips::          Making compiled code run fast.
  674. * Documentation Tips::        Writing readable documentation strings.
  675. * Comment Tips::          Conventions for writing comments.
  676. * Library Headers::           Standard headers for library packages.
  677.  
  678. 
  679. File: elisp,  Node: Style Tips,  Next: Compilation Tips,  Up: Tips
  680.  
  681. Writing Clean Lisp Programs
  682. ===========================
  683.  
  684.    Here are some tips for avoiding common errors in writing Lisp code
  685. intended for widespread use:
  686.  
  687.    * Since all global variables share the same name space, and all
  688.      functions share another name space, you should choose a short word
  689.      to distinguish your program from other Lisp programs.  Then take
  690.      care to begin the names of all global variables, constants, and
  691.      functions with the chosen prefix.  This helps avoid name conflicts.
  692.  
  693.      This recommendation applies even to names for traditional Lisp
  694.      primitives that are not primitives in Emacs Lisp--even to `cadr'.
  695.      Believe it or not, there is more than one plausible way to define
  696.      `cadr'.  Play it safe; append your name prefix to produce a name
  697.      like `foo-cadr' or `mylib-cadr' instead.
  698.  
  699.      If one prefix is insufficient, your package may use two or three
  700.      alternative common prefixes, so long as they make sense.
  701.  
  702.      Separate the prefix from the rest of the symbol name with a hyphen,
  703.      `-'.  This will be consistent with Emacs itself and with most Emacs
  704.      Lisp programs.
  705.  
  706.    * It is often useful to put a call to `provide' in each separate
  707.      library program, at least if there is more than one entry point to
  708.      the program.
  709.  
  710.    * If one file FOO uses a macro defined in another file BAR, FOO
  711.      should contain `(require 'BAR)' before the first use of the macro.
  712.      (And BAR should contain `(provide 'BAR)', to make the `require'
  713.      work.)  This will cause BAR to be loaded when you byte-compile
  714.      FOO.  Otherwise, you risk compiling FOO without the necessary
  715.      macro loaded, and that would produce compiled code that won't work
  716.      right.  *Note Compiling Macros::.
  717.  
  718.    * If you define a major mode, make sure to run a hook variable using
  719.      `run-hooks', just as the existing major modes do.  *Note Hooks::.
  720.  
  721.    * Please do not define `C-c LETTER' as a key in your major modes.
  722.      These sequences are reserved for users; they are the *only*
  723.      sequences reserved for users, so we cannot do without them.
  724.  
  725.      Instead, define sequences consisting of `C-c' followed by a
  726.      non-letter.  These sequences are reserved for major modes.
  727.  
  728.      Changing all the major modes in Emacs 18 so they would follow this
  729.      convention was a lot of work.  Abandoning this convention would
  730.      waste that work and inconvenience the users.
  731.  
  732.    * It is a bad idea to define aliases for the Emacs primitives.  Use
  733.      the standard names instead.
  734.  
  735.    * Redefining an Emacs primitive is an even worse idea.  It may do
  736.      the right thing for a particular program, but there is no telling
  737.      what other programs might break as a result.
  738.  
  739.    * If a file does replace any of the functions or library programs of
  740.      standard Emacs, prominent comments at the beginning of the file
  741.      should say which functions are replaced, and how the behavior of
  742.      the replacements differs from that of the originals.
  743.  
  744.    * If a file requires certain standard library programs to be loaded
  745.      beforehand, then the comments at the beginning of the file should
  746.      say so.
  747.  
  748.    * Please keep the names of your Emacs Lisp source files to 13
  749.      characters or less.  This way, if the files are compiled, the
  750.      compiled files' names will be 14 characters or less, which is
  751.      short enough to fit on all kinds of Unix systems.
  752.  
  753.    * Don't use `next-line' or `previous-line' in programs; nearly
  754.      always, `forward-line' is more convenient as well as more
  755.      predictable and robust.  *Note Text Lines::.
  756.  
  757.    * Don't use functions that set the mark in your Lisp code (unless
  758.      you are writing a command to set the mark).  The mark is a
  759.      user-level feature, so it is incorrect to change the mark except
  760.      to supply a value for the user's benefit.  *Note The Mark::.
  761.  
  762.      In particular, don't use these functions:
  763.  
  764.         * `beginning-of-buffer', `end-of-buffer'
  765.  
  766.         * `replace-string', `replace-regexp'
  767.  
  768.      If you just want to move point, or replace a certain string,
  769.      without any of the other features intended for interactive users,
  770.      you can replace these functions with one or two lines of simple
  771.      Lisp code.
  772.  
  773.    * The recommended way to print a message in the echo area is with
  774.      the `message' function, not `princ'.  *Note The Echo Area::.
  775.  
  776.    * When you encounter an error condition, call the function `error'
  777.      (or `signal').  The function `error' does not return.  *Note
  778.      Signaling Errors::.
  779.  
  780.      Do not use `message', `throw', `sleep-for', or `beep' to report
  781.      errors.
  782.  
  783.    * Avoid using recursive edits.  Instead, do what the Rmail `w'
  784.      command does: use a new local keymap that contains one command
  785.      defined to switch back to the old local keymap.  Or do what the
  786.      `edit-options' command does: switch to another buffer and let the
  787.      user switch back at will.  *Note Recursive Editing::.
  788.  
  789.    * In some other systems there is a convention of choosing variable
  790.      names that begin and end with `*'.  We don't use that convention
  791.      in Emacs Lisp, so please don't use it in your library.  (In fact,
  792.      in Emacs names of this form are conventionally used for
  793.      program-generated buffers.) The users will find Emacs more
  794.      coherent if all libraries use the same conventions.
  795.  
  796.    * Indent each function with `C-M-q' (`indent-sexp') using the
  797.      default indentation parameters.
  798.  
  799.    * Don't make a habit of putting close-parentheses on lines by
  800.      themselves; Lisp programmers find this disconcerting.  Once in a
  801.      while, when there is a sequence of many consecutive
  802.      close-parentheses, it may make sense to split them in one or two
  803.      significant places.
  804.  
  805.    * Please put a copyright notice on the file if you give copies to
  806.      anyone.  Use the same lines that appear at the top of the Lisp
  807.      files in Emacs itself.  If you have not signed papers to assign
  808.      the copyright to the Foundation, then place your name in the
  809.      copyright notice in place of the Foundation's name.
  810.  
  811. 
  812. File: elisp,  Node: Compilation Tips,  Next: Documentation Tips,  Prev: Style Tips,  Up: Tips
  813.  
  814. Tips for Making Compiled Code Fast
  815. ==================================
  816.  
  817.    Here are ways of improving the execution speed of byte-compiled lisp
  818. programs.
  819.  
  820.    * Use the `profile' library to profile your program.  See the file
  821.      `profile.el' for instructions.
  822.  
  823.    * Use iteration rather than recursion whenever possible.  Function
  824.      calls are slow in Emacs Lisp even when a compiled function is
  825.      calling another compiled function.
  826.  
  827.    * Using the primitive list-searching functions `memq', `assq' or
  828.      `assoc' is even faster than explicit iteration.  It may be worth
  829.      rearranging a data structure so that one of these primitive search
  830.      functions can be used.
  831.  
  832.    * Certain built-in functions are handled specially by the byte
  833.      compiler avoiding the need for an ordinary function call.  It is a
  834.      good idea to use these functions rather than alternatives.  To see
  835.      whether a function is handled specially by the compiler, examine
  836.      its `byte-compile' property.  If the property is non-`nil', then
  837.      the function is handled specially.
  838.  
  839.      For example, the following input will show you that `aref' is
  840.      compiled specially (*note Array Functions::.) while `elt' is not
  841.      (*note Sequence Functions::.):
  842.  
  843.           (get 'aref 'byte-compile)
  844.                => byte-compile-two-args
  845.  
  846.           (get 'elt 'byte-compile)
  847.                => nil
  848.  
  849.    * Make small functions inline, so that calls to them in compiled
  850.      code run faster.  *Note Inline Functions::.
  851.  
  852. 
  853. File: elisp,  Node: Documentation Tips,  Next: Comment Tips,  Prev: Compilation Tips,  Up: Tips
  854.  
  855. Tips for Documentation Strings
  856. ==============================
  857.  
  858.    Here are some tips for the writing of documentation strings.
  859.  
  860.    * Every command, function or variable intended for users to know
  861.      about should have a documentation string.
  862.  
  863.    * An internal subroutine of a Lisp program need not have a
  864.      documentation string, and you can save space by using a comment
  865.      instead.
  866.  
  867.    * The first line of the documentation string should consist of one
  868.      or two complete sentences which stand on their own as a summary.
  869.      In particular, start the line with a capital letter and end with a
  870.      period.
  871.  
  872.      The documentation string can have additional lines which expand on
  873.      the details of how to use the function or variable.  The
  874.      additional lines should be made up of complete sentences also, but
  875.      they may be filled if that looks good.
  876.  
  877.    * Do not start or end a documentation string with whitespace.
  878.  
  879.    * Format the documentation string so that it fits in an Emacs window
  880.      on an 80 column screen.  It is a good idea for most lines to be no
  881.      wider than 60 characters.  The first line can be wider if
  882.      necessary to fit the information that ought to be there.
  883.  
  884.      However, rather than simply filling the entire documentation
  885.      string, you can make it much more readable by choosing line breaks
  886.      with care.  Use blank lines between topics if the documentation
  887.      string is long.
  888.  
  889.    * *Do not* indent subsequent lines of a documentation string so that
  890.      the text is lined up in the source code with the text of the first
  891.      line.  This looks nice in the source code, but looks bizarre when
  892.      users view the documentation.  Remember that the indentation
  893.      before the starting double-quote is not part of the string!
  894.  
  895.    * A variable's documentation string should start with `*' if the
  896.      variable is one that users would want to set interactively often.
  897.      If the value is a long list, or a function, or if the variable
  898.      would only be set in init files, then don't start the
  899.      documentation string with `*'.  *Note Defining Variables::.
  900.  
  901.    * The documentation string for a variable that is a yes-or-no flag
  902.      should start with words such as "Non-nil means...", to make it
  903.      clear both that the variable only has two meaningfully distinct
  904.      values and which value means "yes".
  905.  
  906.    * When a function's documentation string mentions the value of an
  907.      argument of the function, use the argument name in capital letters
  908.      as if it were a name for that value.  Thus, the documentation
  909.      string of the function `/' refers to its second argument as
  910.      `DIVISOR'.
  911.  
  912.      Also use all caps for meta-syntactic variables, such as when you
  913.      show the decomposition of a list or vector into subunits, some of
  914.      which may be variable.
  915.  
  916.    * When a documentation string refers to a Lisp symbol, write it as it
  917.      would be printed (which usually means in lower case), with
  918.      single-quotes around it.  For example: ``lambda''.  There are two
  919.      exceptions: write `t' and `nil' without single-quotes.
  920.  
  921.    * Don't write key sequences directly in documentation strings.
  922.      Instead, use the `\\[...]' construct to stand for them.  For
  923.      example, instead of writing `C-f', write `\\[forward-char]'.  When
  924.      the documentation string is printed, Emacs will substitute
  925.      whatever key is currently bound to `forward-char'.  This will
  926.      usually be `C-f', but if the user has moved key bindings, it will
  927.      be the correct key for that user.  *Note Keys in Documentation::.
  928.  
  929.    * In documentation strings for a major mode, you will want to refer
  930.      to the key bindings of that mode's local map, rather than global
  931.      ones.  Therefore, use the construct `\\<...>' once in the
  932.      documentation string to specify which key map to use.  Do this
  933.      before the first use of `\\[...]'.  The text inside the `\\<...>'
  934.      should be the name of the variable containing the local keymap for
  935.      the major mode.
  936.  
  937.      It is not practical to use `\\[...]' very many times, because
  938.      display of the documentation string will become slow.  So use this
  939.      to describe the most important commands in your major mode, and
  940.      then use `\\{...}' to display the rest of the mode's keymap.
  941.  
  942.    * Don't use the term "Elisp", since that is or was a trademark.  Use
  943.      the term "Emacs Lisp".
  944.  
  945. 
  946. File: elisp,  Node: Comment Tips,  Next: Library Headers,  Prev: Documentation Tips,  Up: Tips
  947.  
  948. Tips on Writing Comments
  949. ========================
  950.  
  951.    We recommend these conventions for where to put comments and how to
  952. indent them:
  953.  
  954. `;'
  955.      Comments that start with a single semicolon, `;', should all be
  956.      aligned to the same column on the right of the source code.  Such
  957.      comments usually explain how the code on the same line does its
  958.      job.  In Lisp mode and related modes, the `M-;'
  959.      (`indent-for-comment') command automatically inserts such a `;' in
  960.      the right place, or aligns such a comment if it is already
  961.      inserted.
  962.  
  963.      (The following examples are taken from the Emacs sources.)
  964.  
  965.           (setq base-version-list                 ; there was a base
  966.                 (assoc (substring fn 0 start-vn)  ; version to which
  967.                        file-version-assoc-list))  ; this looks like
  968.                                                   ; a subversion
  969.  
  970. `;;'
  971.      Comments that start with two semicolons, `;;', should be aligned to
  972.      the same level of indentation as the code.  Such comments are used
  973.      to describe the purpose of the following lines or the state of the
  974.      program at that point.  For example:
  975.  
  976.           (prog1 (setq auto-fill-function
  977.                        ...
  978.                        ...
  979.             ;; update mode-line
  980.             (force-mode-line-update)))
  981.  
  982.      These comments are also written before a function definition to
  983.      explain what the function does and how to call it properly.
  984.  
  985. `;;;'
  986.      Comments that start with three semicolons, `;;;', should start at
  987.      the left margin.  Such comments are not used within function
  988.      definitions, but are used to make more general comments.  For
  989.      example:
  990.  
  991.           ;;; This Lisp code is run in Emacs
  992.           ;;; when it is to operate asa server
  993.           ;;; for other processes.
  994.  
  995. `;;;;'
  996.      Comments that start with four semicolons, `;;;;', should be aligned
  997.      to the left margin and are used for headings of major sections of a
  998.      program.  For example:
  999.  
  1000.           ;;;; The kill ring
  1001.  
  1002. The indentation commands of the Lisp modes in Emacs, such as `M-;'
  1003. (`indent-for-comment') and TAB (`lisp-indent-line') automatically
  1004. indent comments according to these conventions, depending on the the
  1005. number of semicolons.  *Note Manipulating Comments: (emacs)Comments.
  1006.  
  1007.    If you wish to "comment out" a number of lines of code, use triple
  1008. semicolons at the beginnings of the lines.
  1009.  
  1010.    Any character may be included in a comment, but it is advisable to
  1011. precede a character with syntactic significance in Lisp (such as `\' or
  1012. unpaired `(' or `)') with a `\', to prevent it from confusing the Emacs
  1013. commands for editing Lisp.
  1014.  
  1015. 
  1016. File: elisp,  Node: Library Headers,  Prev: Comment Tips,  Up: Tips
  1017.  
  1018. Conventional Headers for Emacs Libraries
  1019. ========================================
  1020.  
  1021.    Emacs 19 has conventions for using special comments in Lisp libraries
  1022. to divide them into sections and give information such as who wrote
  1023. them.  This section explains these conventions.  First, an example:
  1024.  
  1025.      ;;; lisp-mnt.el --- minor mode for Emacs Lisp maintainers
  1026.      
  1027.      ;; Copyright (C) 1992 Free Software Foundation, Inc.
  1028.      
  1029.      ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
  1030.      ;; Maintainer: Eric S. Raymond <esr@snark.thyrsus.com>
  1031.      ;; Created: 14 Jul 1992
  1032.      ;; Version: 1.2
  1033.      ;; Keywords: docs
  1034.      
  1035.      ;; This file is part of GNU Emacs.
  1036.      COPYING CONDITIONS...
  1037.  
  1038.    The very first line should have this format:
  1039.  
  1040.      ;;; FILENAME --- DESCRIPTION
  1041.  
  1042. The description should be complete in one line.
  1043.  
  1044.    After the copyright notice come several "header comment" lines, each
  1045. beginning with `;;; HEADER-NAME:'.  Here is a table of the conventional
  1046. possibilities for HEADER-NAME:
  1047.  
  1048. `Author'
  1049.      This line states the name and net address of at least the principal
  1050.      author of the library.
  1051.  
  1052.      If there are multiple authors, you can list them on continuation
  1053.      lines led by `;;<TAB>', like this:
  1054.  
  1055.           ;; Author: Ashwin Ram <Ram-Ashwin@cs.yale.edu>
  1056.           ;;    Dave Sill <de5@ornl.gov>
  1057.           ;;    Dave Brennan <brennan@hal.com>
  1058.           ;;    Eric Raymond <esr@snark.thyrsus.com>
  1059.  
  1060. `Maintainer'
  1061.      This line should contain a single name/address as in the Author
  1062.      line, or an address only, or the string "FSF".  If there is no
  1063.      maintainer line, the person(s) in the Author field are presumed to
  1064.      be the maintainers.  The example above is mildly bogus because the
  1065.      maintainer line is redundant.
  1066.  
  1067.      The idea behind the `Author' and `Maintainer' lines is to make
  1068.      possible a Lisp function to "send mail to the maintainer" without
  1069.      having to mine the name out by hand.
  1070.  
  1071.      Be sure to surround the network address with `<...>' if you
  1072.      include the person's full name as well as the network address.
  1073.  
  1074. `Created'
  1075.      This optional line gives the original creation date of the file.
  1076.      For historical interest only.
  1077.  
  1078. `Version'
  1079.      If you wish to record version numbers for the individual Lisp
  1080.      program, put them in this line.
  1081.  
  1082. `Adapted-By'
  1083.      In this header line, place the name of the person who adapted the
  1084.      library for installation (to make it fit the style conventions, for
  1085.      example.
  1086.  
  1087. `Keywords'
  1088.      This line lists keywords for the `finder-by-keyword' help command.
  1089.      This field is important; it's how people will find your package
  1090.      when they're looking for things by topic area.
  1091.  
  1092.    Just about every Lisp library ought to have the `Author' and
  1093. `Keywords' header comment lines.  Use the others if they are
  1094. appropriate.  You can also put in header lines with other header
  1095. names--they have no standard meanings, so they can't do any harm.
  1096.  
  1097.    We use additional stylized comments to subdivide the contents of the
  1098. library file.  Here is a table of them:
  1099.  
  1100. `;;; Commentary:'
  1101.      This begins introductory comments that explain how the library
  1102.      works.  It should come right after the copying permissions.
  1103.  
  1104. `;;; Change log:'
  1105.      This begins change log information stored in the library file (if
  1106.      you store the change history there).  For most of the Lisp files
  1107.      distributed with Emacs, the change history is kept in the file
  1108.      `ChangeLog' and not in the source file at all; these files do not
  1109.      have a `;;; Change log:' line.
  1110.  
  1111. `;;; Code:'
  1112.      This begins the actual code of the program.
  1113.  
  1114. `;;; FILENAME ends here'
  1115.      This is the "footer line"; it appears at the very end of the file.
  1116.      Its purpose is to enable people to detect truncated versions of
  1117.      the file from the lack of a footer line.
  1118.  
  1119. 
  1120. File: elisp,  Node: GNU Emacs Internals,  Next: Standard Errors,  Prev: Tips,  Up: Top
  1121.  
  1122. GNU Emacs Internals
  1123. *******************
  1124.  
  1125.    This chapter describes how the runnable Emacs executable is dumped
  1126. with the preloaded Lisp libraries in it, how storage is allocated, and
  1127. some internal aspects of GNU Emacs that may be of interest to C
  1128. programmers.
  1129.  
  1130. * Menu:
  1131.  
  1132. * Building Emacs::      How to preload Lisp libraries into Emacs.
  1133. * Pure Storage::        A kludge to make preloaded Lisp functions sharable.
  1134. * Garbage Collection::  Reclaiming space for Lisp objects no longer used.
  1135. * Object Internals::    Data formats of buffers, windows, processes.
  1136. * Writing Emacs Primitives::   Writing C code for Emacs.
  1137.  
  1138. 
  1139. File: elisp,  Node: Building Emacs,  Next: Pure Storage,  Prev: GNU Emacs Internals,  Up: GNU Emacs Internals
  1140.  
  1141. Building Emacs
  1142. ==============
  1143.  
  1144.    The first step in building Emacs is to compile the C sources.  This
  1145. produces a program called `temacs', also called a "bare impure Emacs".
  1146. It contains the Emacs Lisp interpreter and I/O routines, but not the
  1147. editing commands.
  1148.  
  1149.    Then, to create a working Emacs editor, issue the `temacs -l loadup'
  1150. command.  This directs `temacs' to evaluate the Lisp files specified in
  1151. the file `loadup.el'.  These files set up the normal Emacs editing
  1152. environment, resulting in an Emacs which is still impure but no longer
  1153. bare.
  1154.  
  1155.    It takes a long time to load the standard Lisp files.  Luckily, you
  1156. don't have to do this each time you run Emacs; `temacs' can dump out an
  1157. executable program called `emacs' which has these files preloaded.
  1158. `emacs' starts more quickly because it does not need to load the files.
  1159. This is the program that is normally installed.
  1160.  
  1161.    To create `emacs', use the command `temacs -batch -l loadup dump'.
  1162. The purpose of `-batch' here is to prevent `temacs' from trying to
  1163. initialize any of its data on the terminal; this ensures that the
  1164. tables of terminal information are empty in the dumped Emacs.
  1165.  
  1166.    When the `emacs' executable is started, it automatically loads the
  1167. user's `.emacs' file, or the default initialization file `default.el'
  1168. if the user has none.  (*Note Starting Up::.)  With the `.emacs' file,
  1169. you can produce a version of Emacs that suits you and is not the same
  1170. as the version other people use.  With `default.el', you can customize
  1171. Emacs for all the users at your site who don't choose to customize it
  1172. for themselves.  (For further reflection: why is this different from
  1173. the case of the barber who shaves every man who doesn't shave himself?)
  1174.  
  1175.    On some systems, dumping does not work.  Then, you must start Emacs
  1176. with the `temacs -l loadup' command each time you use it.  This takes a
  1177. long time, but since you need to start Emacs once a day at most--and
  1178. once a week or less frequently if you never log out--the extra time is
  1179. not too severe a problem.
  1180.  
  1181.    Before `emacs' is dumped, the documentation strings for primitive
  1182. and preloaded functions (and variables) need to be found in the file
  1183. where they are stored.  This is done by calling `Snarf-documentation'
  1184. (*note Accessing Documentation::.).  These strings were moved out of
  1185. `emacs' to make it smaller.  *Note Documentation Basics::.
  1186.  
  1187.  - Function: dump-emacs TO-FILE FROM-FILE
  1188.      This function dumps the current state of Emacs into an executable
  1189.      file TO-FILE.  It takes symbols from FROM-FILE (this is normally
  1190.      the executable file `temacs').
  1191.  
  1192.      If you use this function in an Emacs that was already dumped, you
  1193.      must set `command-line-processed' to `nil' first for good results.
  1194.      *Note Command Line Arguments::.
  1195.  
  1196.  - Command: emacs-version
  1197.      This function returns a string describing the version of Emacs
  1198.      that is running.  It is useful to include this string in bug
  1199.      reports.
  1200.  
  1201.           (emacs-version)
  1202.             => "GNU Emacs 18.36.1 of Fri Feb 27 1987 on slug
  1203.                (berkeley-unix)"
  1204.  
  1205.      Called interactively, the function prints the same information in
  1206.      the echo area.
  1207.  
  1208.  - Variable: emacs-build-time
  1209.      The value of this variable is the time at which Emacs was built at
  1210.      the local site.
  1211.  
  1212.           emacs-build-time
  1213.                => "Fri Feb 27 14:55:57 1987"
  1214.  
  1215.  - Variable: emacs-version
  1216.      The value of this variable is the version of Emacs being run.  It
  1217.      is a string, e.g. `"18.36.1"'.
  1218.  
  1219.