Sync up with r21-4-14-chise-0_21-22.
[chise/xemacs-chise.git-] / info / xemacs-faq.info-4
1 This is ../info/xemacs-faq.info, produced by makeinfo version 4.0b from
2 xemacs-faq.texi.
3
4 INFO-DIR-SECTION XEmacs Editor
5 START-INFO-DIR-ENTRY
6 * FAQ: (xemacs-faq).            XEmacs FAQ.
7 END-INFO-DIR-ENTRY
8
9 \1f
10 File: xemacs-faq.info,  Node: Q4.0.12,  Next: Q4.1.1,  Prev: Q4.0.11,  Up: Subsystems
11
12 Q4.0.12: Customization of VM not covered in the manual, or here.
13 ----------------------------------------------------------------
14
15    giacomo boffi <boffi@hp735.stru.polimi.it> writes:
16
17      The meta-answer is to look into the file `vm-vars.el', in the vm
18      directory of the lisp library.
19
20      `vm-vars.el' contains, initializes and carefully describes, with
21      examples of usage, the plethora of user options that _fully_
22      control VM's behavior.
23
24      Enter vm-vars, `forward-search' for toolbar, find the variables
25      that control the toolbar placement, appearance, existence, copy to
26      your `.emacs' or `.vm' and modify according to the detailed
27      instructions.
28
29      The above also applies to all the various features of VM: search
30      for some keywords, maybe the first you conjure isn't appropriate,
31      find the appropriate variables, copy and experiment.
32
33 \1f
34 File: xemacs-faq.info,  Node: Q4.1.1,  Next: Q4.1.2,  Prev: Q4.0.12,  Up: Subsystems
35
36 4.1: Web browsing with W3
37 =========================
38
39 Q4.1.1: What is W3?
40 -------------------
41
42    W3 is an advanced graphical browser written in Emacs lisp that runs
43 on XEmacs.  It has full support for cascaded style sheets, and more...
44
45    It has a home web page at
46 `http://www.cs.indiana.edu/elisp/w3/docs.html'.
47
48 \1f
49 File: xemacs-faq.info,  Node: Q4.1.2,  Next: Q4.1.3,  Prev: Q4.1.1,  Up: Subsystems
50
51 Q4.1.2: How do I run W3 from behind a firewall?
52 -----------------------------------------------
53
54    There is a long, well-written, detailed section in the W3 manual that
55 describes how to do this.  Look in the section entitled "Firewalls".
56
57 \1f
58 File: xemacs-faq.info,  Node: Q4.1.3,  Next: Q4.2.1,  Prev: Q4.1.2,  Up: Subsystems
59
60 Q4.1.3: Is it true that W3 supports style sheets and tables?
61 ------------------------------------------------------------
62
63    Yes, and much more.  W3, as distributed with the latest XEmacs is a
64 full-featured web browser.
65
66 \1f
67 File: xemacs-faq.info,  Node: Q4.2.1,  Next: Q4.2.2,  Prev: Q4.1.3,  Up: Subsystems
68
69 4.2: Reading Netnews and Mail with Gnus
70 =======================================
71
72 Q4.2.1: GNUS, (ding) Gnus, Gnus 5, September Gnus, Red Gnus, Quassia Gnus, argh!
73 --------------------------------------------------------------------------------
74
75    The Gnus numbering issues are not meant for mere mortals to know
76 them.  If you feel you _must_ enter the muddy waters of Gnus, visit the
77 excellent FAQ, maintained by Justin Sheehy, at:
78
79      `http://www.ccs.neu.edu/software/contrib/gnus/'
80
81    See also Gnus home page
82      `http://www.gnus.org/'
83
84 \1f
85 File: xemacs-faq.info,  Node: Q4.2.2,  Next: Q4.2.3,  Prev: Q4.2.1,  Up: Subsystems
86
87 Q4.2.2: This question intentionally left blank.
88 -----------------------------------------------
89
90    Obsolete question, left blank to avoid renumbering.
91
92 \1f
93 File: xemacs-faq.info,  Node: Q4.2.3,  Next: Q4.2.4,  Prev: Q4.2.2,  Up: Subsystems
94
95 Q4.2.3: How do I make Gnus stay within a single frame?
96 ------------------------------------------------------
97
98    The toolbar code to start Gnus opens the new frame--and it's a
99 feature rather than a bug.  If you don't like it, but would still like
100 to click on the seemly icon, use the following code:
101
102      (defun toolbar-news ()
103        (gnus))
104
105    It will redefine the callback function of the icon to just call
106 `gnus', without all the fancy frame stuff.
107
108 \1f
109 File: xemacs-faq.info,  Node: Q4.2.4,  Next: Q4.3.1,  Prev: Q4.2.3,  Up: Subsystems
110
111 Q4.2.4: How do I customize the From: line?
112 ------------------------------------------
113
114    How do I change the `From:' line?  I have set gnus-user-from-line to
115      Gail Gurman <gail.gurman@sybase.com>
116     , but XEmacs Gnus doesn't use it. Instead it uses
117      Gail Mara Gurman <gailg@deall>
118  and then complains that it's incorrect. Also, as you perhaps can see,
119 my Message-ID is screwy. How can I change that?
120
121 Lars Magne Ingebrigtsen <larsi@ifi.uio.no> writes:
122
123      Set `user-mail-address' to `gail.gurman@sybase.com' or
124      `mail-host-address' to `sybase.com'.
125
126 \1f
127 File: xemacs-faq.info,  Node: Q4.3.1,  Next: Q4.3.2,  Prev: Q4.2.4,  Up: Subsystems
128
129 4.3: Other Mail & News
130 ======================
131
132 Q4.3.1: How can I read and/or compose MIME messages?
133 ----------------------------------------------------
134
135    VM supports MIME natively.
136
137    You probably want to use the Tools for MIME (tm).  *Note Q4.3.2::,
138 for details.
139
140    Trey Jackson <trey@cs.berkeley.edu> has an Emacs & MIME web page at
141 `http://bmrc.berkeley.edu/~trey/emacs/mime.html'.
142
143    Another possibility is RMIME.  You may find RMIME at
144 `http://www.cinti.net/~rmoody/rmime/index.html'.
145
146 \1f
147 File: xemacs-faq.info,  Node: Q4.3.2,  Next: Q4.3.3,  Prev: Q4.3.1,  Up: Subsystems
148
149 Q4.3.2: What is TM and where do I get it?
150 -----------------------------------------
151
152    TM stands for "Tools for MIME" and not Tiny MIME.  TM integrates
153 with all major XEmacs packages like Gnus (all flavors), VM, MH-E, and
154 mailcrypt.  It provides totally transparent and trouble-free MIME
155 support.  When appropriate a message will be decoded in place in an
156 XEmacs buffer.
157
158    TM now comes as a package with XEmacs 19.16 and XEmacs 20.2.
159
160    TM was written by MORIOKA Tomohiko <morioka@jaist.ac.jp> and
161 KOBAYASHI Shuhei <shuhei-k@jaist.ac.jp>.
162
163    It is based on the work of UMEDA Masanobu
164 <umerin@mse.kyutech.ac.jp>, the original writer of GNUS.
165
166    The following information is from the `README':
167
168    "tm" is a MIME package for GNU Emacs.  tm has following functions:
169
170    * MIME style multilingual header.
171
172    * MIME message viewer (mime/viewer-mode).
173
174    * MIME message composer (mime/editor-mode).
175
176    * MIME extenders for mh-e, GNUS, RMAIL and VM.
177
178    tm is available from following anonymous ftp sites:
179    * `ftp://ftp.unicamp.br/pub/mail/mime/tm/' (Brasil).
180
181    * `ftp://ftp.th-darmstadt.de/pub/editors/GNU-Emacs/lisp/mime/'
182      (Germany).
183
184    * `ftp://ftp.tnt.uni-hannover.de/pub/editors/xemacs/contrib/'
185      (Germany).
186
187    Don't let the installation procedure & instructions stop you from
188 trying this package out--it's much simpler than it looks, and once
189 installed, trivial to use.
190
191 \1f
192 File: xemacs-faq.info,  Node: Q4.3.3,  Next: Q4.3.4,  Prev: Q4.3.2,  Up: Subsystems
193
194 Q4.3.3: Why isn't this `movemail' program working?
195 --------------------------------------------------
196
197    Ben Wing <ben@xemacs.org> writes:
198
199      It wasn't chown'ed/chmod'd correctly.
200
201 \1f
202 File: xemacs-faq.info,  Node: Q4.3.4,  Next: Q4.3.5,  Prev: Q4.3.3,  Up: Subsystems
203
204 Q4.3.4: Movemail is also distributed by Netscape?  Can that cause problems?
205 ---------------------------------------------------------------------------
206
207    Steve Baur <steve@xemacs.org> writes:
208
209      Yes.  Always use the movemail installed with your XEmacs.  Failure
210      to do so can result in lost mail.
211
212    Please refer to Jamie Zawinski's <jwz@jwz.org> notes at
213 `http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/movemail.html'.
214 In particular, this document will show you how to make Netscape use the
215 version of movemail configured for your system by the person who built
216 XEmacs.
217
218 \1f
219 File: xemacs-faq.info,  Node: Q4.3.5,  Next: Q4.4.1,  Prev: Q4.3.4,  Up: Subsystems
220
221 Q4.3.5: Where do I find pstogif (required by tm)?
222 -------------------------------------------------
223
224    pstogif is part of the latex2html package.
225
226    Jan Vroonhof <vroonhof@math.ethz.ch> writes:
227
228    latex2html is best found at the CTAN hosts and their mirrors in
229 `tex-archive/support/latex2html'.
230
231    CTAN hosts are:
232
233    * `ftp://ftp.tex.ac.uk/tex-archive/support/latex2html/'.
234
235    * `ftp://ftp.dante.de/tex-archive/support/latex2html/'.
236
237    There is a good mirror at ftp.cdrom.com;
238 `ftp://ftp.cdrom.com/pub/tex/ctan/support/latex2html/'.
239
240 \1f
241 File: xemacs-faq.info,  Node: Q4.4.1,  Next: Q4.4.2,  Prev: Q4.3.5,  Up: Subsystems
242
243 4.4: Sparcworks, EOS, and WorkShop
244 ==================================
245
246 Q4.4.1: What is SPARCworks, EOS, and WorkShop?
247 ----------------------------------------------
248
249    John Turner <turner@lanl.gov> writes:
250
251      SPARCworks is SunSoft's development environment, comprising
252      compilers (C, C++, FORTRAN 77, Fortran 90, Ada, and Pascal), a
253      debugger, and other tools such as TeamWare (for configuration
254      management), MakeTool, etc.
255
256    See `http://www.sun.com/software/Developer-products/' for more info.
257
258    EOS stands for "Era on SPARCworks", but I don't know what Era stands
259 for.
260
261    EOS is the integration of XEmacs with the SPARCworks debugger.  It
262 allows one to use an XEmacs frame to view code (complete with
263 fontification, etc.), set breakpoints, print variables, etc., while
264 using the SPARCworks debugger.  It works very well and I use it all the
265 time.
266
267    Chuck Thompson <cthomp@xemacs.org> writes:
268
269      Era stood for "Emacs Rewritten Again".  It was what we were
270      calling the modified version of Lucid Emacs for Sun when I was
271      dragged, er, allowed to work on this wonderful editor.
272
273    Martin Buchholz <martin@xemacs.org> writes:
274
275      EOS is being replaced with a new graphical development environment
276      called Sun WorkShop, which is currently (07/96) in Alpha Test.
277      For more details, check out
278      `http://www.sun.com/software/Products/Developer-products'.
279
280 \1f
281 File: xemacs-faq.info,  Node: Q4.4.2,  Next: Q4.5.1,  Prev: Q4.4.1,  Up: Subsystems
282
283 Q4.4.2: How do I start the Sun Workshop support in XEmacs 21?
284 -------------------------------------------------------------
285
286    Add the switch --with-workshop to the configure command when building
287 XEmacs and put the following in one of your startup files (e.g.
288 site-start.el or .emacs):
289
290      (when (featurep 'tooltalk)
291        (load "tooltalk-macros")
292        (load "tooltalk-util")
293        (load "tooltalk-init"))
294      (when (featurep 'sparcworks)
295        (load "sunpro-init")
296        (load "ring")
297        (load "comint")
298        (load "annotations")
299        (sunpro-startup))
300
301    If you are not using the latest Workshop (5.0) you have to apply the
302 following patch:
303
304 --- /opt/SUNWspro/lib/eserve.el.ORIG    Fri May 14 15:23:26 1999
305 +++ /opt/SUNWspro/lib/eserve.el Fri May 14 15:24:54 1999
306 @@ -42,7 +42,7 @@
307  (defvar running-xemacs nil "t if we're running XEmacs")
308  (defvar running-emacs  nil "t if we're running GNU Emacs 19")
309
310 -(if (string-match "^\\(19\\|20\\)\..*\\(XEmacs\\|Lucid\\)" emacs-version)
311 +(if (string-match "\\(XEmacs\\|Lucid\\)" emacs-version)
312      (setq running-xemacs t)
313      (setq running-emacs  t))
314
315 \1f
316 File: xemacs-faq.info,  Node: Q4.5.1,  Next: Q4.6.1,  Prev: Q4.4.2,  Up: Subsystems
317
318 4.5: Energize
319 =============
320
321 Q4.5.1: What is/was Energize?
322 -----------------------------
323
324    David N Gray <gray@meteor.harlequin.com> writes:
325      The files in `lisp/energize' are to enable Emacs to interface with
326      the "Energize Programming System", a C and C++ development
327      environment, which was a product of Lucid, Inc.  Tragically, Lucid
328      went out of business in 1994, so although Energize is still a
329      great system, if you don't already have it, there isn't any way to
330      get it now.  (Unless you happen to be in Japan; INS Engineering
331      may still be selling it there.  Tartan bought the rights to sell
332      it in the rest of the world, but never did so.)
333
334 \1f
335 File: xemacs-faq.info,  Node: Q4.6.1,  Next: Q4.7.1,  Prev: Q4.5.1,  Up: Subsystems
336
337 4.6: Infodock
338 =============
339
340 Q4.6.1: What is Infodock?
341 -------------------------
342
343    InfoDock is an integrated productivity toolset, mainly aimed at
344 technical people.  It is developed and supported by InfoDock
345 Associates, a firm that offers custom support and development for
346 InfoDock, XEmacs and GNU Emacs.  ( `http://www.infodock.com',
347 <info@infodock.com>, +1 408 243 3300).
348
349    InfoDock is built atop the XEmacs variant of GNU Emacs and so has
350 all of the power of Emacs, but with an easier to use and more
351 comprehensive menu-based user interface.  The bottom portion of this
352 text describes how it differs from XEmacs and GNU Emacs from the Free
353 Software Foundation.
354
355    InfoDock is aimed at people who want a free, turn-key productivity
356 environment.  Although InfoDock is customizable, it is not intended for
357 people who like basic versions of Emacs which need to be customized
358 extensively for local use; standard Emacs distributions are better for
359 such uses.  InfoDock is for those people who want a complete,
360 pre-customized environment in one package, which they need not touch
361 more than once or twice a year to update to new revisions.
362
363    InfoDock is pre-built for SPARC SunOS/Solaris systems, PA-RISC HP-UX,
364 and Intel Linux systems.  It is intended for use on a color display,
365 although most features will work on monochrome monitors.  Simply unpack
366 InfoDock according to the instructions in the ID-INSTALL file and you
367 are ready to run.
368
369    The InfoDock Manual is concise, yet sufficient as a user guide for
370 users who have never used an Emacs-type editor before.  For users who
371 are already familiar with Emacs, it supplements the information in the
372 GNU Emacs Manual.
373
374    InfoDock menus are much more extensive and more mature than standard
375 Emacs menus.  Each menu offers a `Manual' item which displays
376 documentation associated with the menu's functions.
377
378 Four types of menubars are provided:
379   1. An extensive menubar providing access to global InfoDock commands.
380
381   2. Mode-specific menubars tailored to the current major mode.
382
383   3. A simple menubar for basic editing to help novices get started
384      with InfoDock.
385
386   4. The standard XEmacs menubar.
387
388    Most modes also include mode-specific popup menus.  Additionally,
389 region and rectangle popup menus are included.
390
391    `Hyperbole', the everyday information manager, is a core part of
392 InfoDock.  This provides context-sensitive mouse keys, a rolodex-type
393 contact manager, programmable hypertext buttons, and an autonumbered
394 outliner with embedded hyperlink anchors.
395
396    The `OO-Browser', a multi-language object-oriented code browser, is a
397 standard part of InfoDock.
398
399    InfoDock saves a more extensive set of user options than other Emacs
400 versions.
401
402    InfoDock inserts a useful file header in many file types, showing the
403 author, summary, and last modification time of each file.  A summary
404 program can then be used to summarize all of the files in a directory,
405 for easy MANIFEST file creation.
406
407    Your working set of buffers is automatically saved and restored (if
408 you answer yes to a prompt) between InfoDock sessions.
409
410    Refined color choices for code highlighting are provided for both
411 dark and light background display frames.
412
413    The `C-z' key prefix performs frame-based commands which parallel the
414 `C-x' key prefix for window-based commands.
415
416    The Smart Menu system is included for producing command menus on dumb
417 terminals.
418
419    Lisp libraries are better categorized according to function.
420
421    Extensions and improvements to many areas of Emacs are included,
422 such as: paragraph filling, mail reading with Rmail, shell handling,
423 outlining, code highlighting and browsing, and man page browsing.
424
425    InfoDock questions, answers and discussion should go to the mail list
426 <infodock@infodock.com>.  Use <infodock-request@infodock.com> to be
427 added or removed from the list.  Always include your InfoDock version
428 number when sending help requests.
429
430    InfoDock is available across the Internet via anonymous FTP.  To get
431 it, first move to a directory into which you want the InfoDock archive
432 files placed.  We will call this <DIST-DIR>.
433
434         cd <DIST-DIR>
435
436    Ftp to ftp.xemacs.org  (Internet Host ID = 128.174.252.16):
437
438         prompt> ftp ftp.xemacs.org
439
440    Login as `anonymous' with your own <user-id>@<site-name> as a
441 password.
442
443         Name (ftp.xemacs.org): anonymous
444         331 Guest login ok, send your complete e-mail address as password.
445         Password: -<your-user-id>@<your-domain>
446         230 Guest login ok, access restrictions apply.
447
448    Move to the location of the InfoDock archives:
449
450         ftp> cd pub/infodock
451
452    Set your transfer mode to binary:
453
454         ftp> bin
455         200 Type set to I.
456
457    Turn off prompting:
458
459         ftp> prompt
460         Interactive mode off.
461
462    Retrieve the InfoDock archives that you want, either by using a `get
463 <file>' for each file you want or by using the following to get a
464 complete distribution, including all binaries:
465
466         ftp> mget ID-INSTALL
467         ftp> mget id-*
468
469    Close the FTP connection:
470
471         ftp> quit
472         221 Goodbye.
473
474    Read the `ID-INSTALL' file which you just retrieved for step-by-step
475 installation instructions.
476
477 \1f
478 File: xemacs-faq.info,  Node: Q4.7.1,  Next: Q4.7.2,  Prev: Q4.6.1,  Up: Subsystems
479
480 4.7: Other Unbundled Packages
481 =============================
482
483 Q4.7.1: What is AUC TeX?  Where do you get it?
484 ----------------------------------------------
485
486    AUC TeX is a package written by Per Abrahamsen <abraham@dina.kvl.dk>.
487 Starting with XEmacs 19.16, AUC TeX is bundled with XEmacs.  The
488 following information is from the `README' and website.
489
490    AUC TeX is an extensible package that supports writing and formatting
491 TeX files for most variants of GNU Emacs. Many different macro packages
492 are supported, including AMS TeX, LaTeX, and TeXinfo.
493
494    The most recent version is always available by ftp at
495 `ftp://sunsite.auc.dk/packages/auctex/auctex.tar.gz'.
496
497    In case you don't have access to anonymous ftp, you can get it by an
498 email request to <ftpmail@decwrl.dec.com>.
499
500    WWW users may want to check out the AUC TeX page at
501 `http://sunsite.auc.dk/auctex/'.
502
503 \1f
504 File: xemacs-faq.info,  Node: Q4.7.2,  Next: Q4.7.3,  Prev: Q4.7.1,  Up: Subsystems
505
506 Q4.7.2: Are there any Emacs Lisp Spreadsheets?
507 ----------------------------------------------
508
509    Yes.  Check out "dismal" (which stands for Dis' Mode Ain't Lotus) at
510 `ftp://cs.nyu.edu/pub/local/fox/dismal/'.
511
512 \1f
513 File: xemacs-faq.info,  Node: Q4.7.3,  Next: Q4.7.4,  Prev: Q4.7.2,  Up: Subsystems
514
515 Q4.7.3: [This question intentionally left blank]
516 ------------------------------------------------
517
518 \1f
519 File: xemacs-faq.info,  Node: Q4.7.4,  Next: Q4.7.5,  Prev: Q4.7.3,  Up: Subsystems
520
521 Q4.7.4: Problems installing AUC TeX.
522 ------------------------------------
523
524    Jan Vroonhof <vroonhof@math.ethz.ch> writes:
525
526      AUC TeX works fine on both stock Emacs and XEmacs has been doing
527      so for a very very long time. This is mostly due to the work of
528      Per Abrahamsen <abraham@dina.kvl.dk> (clap clap) in particular his
529      `easymenu' package.  Which leads to what is probably the problem...
530
531    Most problems with AUC TeX are one of two things:
532
533    * The TeX-lisp-directory in `tex-site.el' and the makefile don't
534      match.
535
536      Fix: make sure you configure AUC TeX properly *before* installing.
537
538    * You have an old version of easymenu.el in your path.
539
540      Fix: use `locate-library' and remove old versions to make sure it
541      *only* finds the one that came with XEmacs.
542
543 \1f
544 File: xemacs-faq.info,  Node: Q4.7.5,  Next: Q4.7.6,  Prev: Q4.7.4,  Up: Subsystems
545
546 Q4.7.5: Is there a reason for an Emacs package not to be included in XEmacs?
547 ----------------------------------------------------------------------------
548
549    The reason for an Emacs package not to be included in XEmacs is
550 usually one or more of the following:
551
552   1. The package has not been ported to XEmacs.  This will typically
553      happen when it uses GNU-Emacs-specific features, which make it
554      fail under XEmacs.
555
556      Porting a package to XEmacs can range from a trivial amount of
557      change to a partial or full rewrite.  Fortunately, the authors of
558      modern packages usually choose to support both Emacsen themselves.
559
560   2. The package has been decided not to be appropriate for XEmacs.  It
561      may have an equivalent or better replacement within XEmacs, in
562      which case the developers may choose not to burden themselves with
563      supporting an additional package.
564
565      Each package bundled with XEmacs means more work for the
566      maintainers, whether they want it or not.  If you are ready to
567      take over the maintenance responsibilities for the package you
568      port, be sure to say so--we will more likely include it.
569
570   3. The package simply hasn't been noted by the XEmacs development.  If
571      that's the case, the messages like yours are very useful for
572      attracting our attention.
573
574   4. The package was noted by the developers, but they simply haven't
575      yet gotten around to including/porting it.  Wait for the next
576      release or, even better, offer your help.  It will be gladly
577      accepted and appreciated.
578
579 \1f
580 File: xemacs-faq.info,  Node: Q4.7.6,  Prev: Q4.7.5,  Up: Subsystems
581
582 Q4.7.5: Is there a MatLab mode?
583 -------------------------------
584
585    Yes, a matlab mode and other items are available at the MathWorks'
586 emacs_add_ons ftp directory
587 (ftp://ftp.mathworks.com/pub/contrib/emacs_add_ons).
588
589 \1f
590 File: xemacs-faq.info,  Node: Miscellaneous,  Next: MS Windows,  Prev: Subsystems,  Up: Top
591
592 5 The Miscellaneous Stuff
593 *************************
594
595    This is part 5 of the XEmacs Frequently Asked Questions list.  This
596 section is devoted to anything that doesn't fit neatly into the other
597 sections.
598
599 * Menu:
600
601 Major & Minor Modes:
602 * Q5.0.1::      How can I do source code highlighting using font-lock?
603 * Q5.0.2::      I do not like cc-mode.  How do I use the old c-mode?
604 * Q5.0.3::      How do I get `More' Syntax Highlighting on by default?
605 * Q5.0.4::      How can I enable auto-indent?
606 * Q5.0.5::      How can I get XEmacs to come up in text/auto-fill mode by default?
607 * Q5.0.6::      How do I start up a second shell buffer?
608 * Q5.0.7::      Telnet from shell filters too much.
609 * Q5.0.8::      Why does edt emulation not work?
610 * Q5.0.9::      How can I emulate VI and use it as my default mode?
611 * Q5.0.10::     [This question intentionally left blank]
612 * Q5.0.11::     How do I turn on filladapt for all buffers?
613 * Q5.0.12::     How do I disable gnuserv from opening a new frame?
614 * Q5.0.13::     How do I start gnuserv so that each subsequent XEmacs is a client?
615 * Q5.0.14::     Strange things are happening in Shell Mode.
616 * Q5.0.15::     Where do I get the latest CC Mode?
617 * Q5.0.16::     I find auto-show-mode disconcerting.  How do I turn it off?
618 * Q5.0.17::     How can I get two instances of info?
619 * Q5.0.18::     [This question intentionally left blank]
620 * Q5.0.19::     Is there something better than LaTeX mode?
621 * Q5.0.20::     Is there a way to start a new XEmacs if there's no gnuserv running, and otherwise use gnuclient?
622
623 Emacs Lisp Programming Techniques:
624 * Q5.1.1::      The difference in key sequences between XEmacs and GNU Emacs?
625 * Q5.1.2::      Can I generate "fake" keyboard events?
626 * Q5.1.3::      Could you explain `read-kbd-macro' in more detail?
627 * Q5.1.4::      What is the performance hit of `let'?
628 * Q5.1.5::      What is the recommended use of `setq'?
629 * Q5.1.6::      What is the typical misuse of `setq'?
630 * Q5.1.7::      I like the `do' form of cl, does it slow things down?
631 * Q5.1.8::      I like recursion, does it slow things down?
632 * Q5.1.9::      How do I put a glyph as annotation in a buffer?
633 * Q5.1.10::     `map-extents' won't traverse all of my extents!
634 * Q5.1.11::     My elisp program is horribly slow.  Is there an easy way to find out where it spends time?
635
636 Sound:
637 * Q5.2.1::      How do I turn off the sound?
638 * Q5.2.2::      How do I get funky sounds instead of a boring beep?
639 * Q5.2.3::      What's NAS, how do I get it?
640 * Q5.2.4::      Sunsite sounds don't play.
641
642 Miscellaneous:
643 * Q5.3.1::      How do you make XEmacs indent CL if-clauses correctly?
644 * Q5.3.2::      Fontifying hangs when editing a postscript file.
645 * Q5.3.3::      How can I print WYSIWYG a font-locked buffer?
646 * Q5.3.4::      Getting M-x lpr to work with postscript printer.
647 * Q5.3.5::      How do I specify the paths that XEmacs uses for finding files?
648 * Q5.3.6::      [This question intentionally left blank]
649 * Q5.3.7::      Can I have the end of the buffer delimited in some way?
650 * Q5.3.8::      How do I insert today's date into a buffer?
651 * Q5.3.9::      Are only certain syntactic character classes available for abbrevs?
652 * Q5.3.10::     How can I get those oh-so-neat X-Face lines?
653 * Q5.3.11::     How do I add new Info directories?
654 * Q5.3.12::     What do I need to change to make printing work?
655
656 \1f
657 File: xemacs-faq.info,  Node: Q5.0.1,  Next: Q5.0.2,  Prev: Miscellaneous,  Up: Miscellaneous
658
659 5.0: Major & Minor Modes
660 ========================
661
662 Q5.0.1: How can I do source code highlighting using font-lock?
663 --------------------------------------------------------------
664
665    For most modes, font-lock is already set up and just needs to be
666 turned on.  This can be done by `M-x font-lock-mode', or by having
667 XEmacs automatically start it by adding lines like:
668
669      (add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock)
670      (add-hook 'dired-mode-hook      'turn-on-font-lock)
671
672    to your `.emacs'.  See the file `etc/sample.emacs' for more examples.
673
674    See also `Syntax Highlighting' from the `Options' menu.  Remember to
675 save options.
676
677 \1f
678 File: xemacs-faq.info,  Node: Q5.0.2,  Next: Q5.0.3,  Prev: Q5.0.1,  Up: Miscellaneous
679
680 Q5.0.2: I do not like cc-mode.  How do I use the old c-mode?
681 ------------------------------------------------------------
682
683    Well, first off, consider if you really want to do this.  cc-mode is
684 much more powerful than the old c-mode.  If you're having trouble
685 getting your old offsets to work, try using `c-set-offset' instead.
686 You might also consider using the package `cc-compat'.
687
688    But, if you still insist, add the following lines to your `.emacs':
689
690      (fmakunbound 'c-mode)
691      (makunbound 'c-mode-map)
692      (fmakunbound 'c++-mode)
693      (makunbound 'c++-mode-map)
694      (makunbound 'c-style-alist)
695      (load-library "old-c-mode")
696      (load-library "old-c++-mode")
697
698    This must be done before any other reference is made to either
699 c-mode or c++-mode.
700
701 \1f
702 File: xemacs-faq.info,  Node: Q5.0.3,  Next: Q5.0.4,  Prev: Q5.0.2,  Up: Miscellaneous
703
704 Q5.0.3: How do I get `More' Syntax Highlighting on by default?
705 --------------------------------------------------------------
706
707    Use the following code in your `.emacs':
708
709      (setq-default font-lock-maximum-decoration t)
710
711    In versions of XEmacs prior to 19.14, you had to use a kludgy
712 solution like this:
713
714      (setq c-font-lock-keywords c-font-lock-keywords-2
715            c++-font-lock-keywords c++-font-lock-keywords-2
716            lisp-font-lock-keywords lisp-font-lock-keywords-2)
717
718    It will work for C, C++ and Lisp.
719
720    See also `Syntax Highlighting' from the `Options' menu.  Remember to
721 save options.
722
723 \1f
724 File: xemacs-faq.info,  Node: Q5.0.4,  Next: Q5.0.5,  Prev: Q5.0.3,  Up: Miscellaneous
725
726 Q5.0.4: How can I enable auto-indent?
727 -------------------------------------
728
729    Put the following line in your `.emacs':
730
731      (setq indent-line-function 'indent-relative-maybe)
732
733    If you want to get fancy, try the `filladapt' package available
734 standard with XEmacs.  Put this into your `.emacs':
735
736      (require 'filladapt)
737      (add-hook 'text-mode-hook    'turn-on-filladapt-mode)
738      ;;; and others ...
739
740    You can customize filling and adaptive filling with Customize.
741 Select from the `Options' menu
742 `Customize->Emacs->->Editing->Fill->Fill...' or type `M-x customize
743 <RET> fill <RET>'.
744
745    Note that well-behaving text-lookalike modes will run
746 `text-mode-hook' by default (e.g. that's what Message does).  For the
747 nasty ones, you'll have to provide the `add-hook's yourself.
748
749    Please note that the `fa-extras' package is no longer useful.
750
751 \1f
752 File: xemacs-faq.info,  Node: Q5.0.5,  Next: Q5.0.6,  Prev: Q5.0.4,  Up: Miscellaneous
753
754 Q5.0.5: How can I get XEmacs to come up in text/auto-fill mode by default?
755 --------------------------------------------------------------------------
756
757    Try the following lisp in your `.emacs':
758
759      (setq default-major-mode 'text-mode)
760      (setq text-mode-hook 'turn-on-auto-fill)
761
762    *WARNING*: note that changing the value of `default-major-mode' from
763 `fundamental-mode' can break a large amount of built-in code that
764 expects newly created buffers to be in `fundamental-mode'.  (Changing
765 from `fundamental-mode' to `text-mode' might not wreak too much havoc,
766 but changing to something more exotic like a lisp-mode would break many
767 Emacs packages).
768
769    Note that Emacs by default starts up in buffer `*scratch*' in
770 `initial-major-mode', which defaults to `lisp-interaction-mode'. Thus
771 adding the following form to your Emacs init file will cause the
772 initial `*scratch*' buffer to be put into auto-fill'ed `text-mode':
773
774      (setq initial-major-mode
775            (lambda ()
776              (text-mode)
777              (turn-on-auto-fill)))
778
779    Note that after your init file is loaded, if
780 `inhibit-startup-message' is `nil' (the default) and the startup buffer
781 is `*scratch*' then the startup message will be inserted into
782 `*scratch*'; it will be removed after a timeout by erasing the entire
783 `*scratch*' buffer.  Keep in mind this default usage of `*scratch*' if
784 you desire any prior manipulation of `*scratch*' from within your Emacs
785 init file. In particular, anything you insert into `*scratch*' from
786 your init file will be later erased. Also, if you change the mode of
787 the `*scratch*' buffer, be sure that this will not interfere with
788 possible later insertion of the startup message (e.g. if you put
789 `*scratch*' into a nonstandard mode that has automatic font lock rules,
790 then the startup message might get fontified in a strange foreign
791 manner, e.g. as code in some programming language).
792
793 \1f
794 File: xemacs-faq.info,  Node: Q5.0.6,  Next: Q5.0.7,  Prev: Q5.0.5,  Up: Miscellaneous
795
796 Q5.0.6: How do I start up a second shell buffer?
797 ------------------------------------------------
798
799    In the `*shell*' buffer:
800
801      M-x rename-buffer <RET> *shell-1* <RET>
802      M-x shell RET
803
804    This will then start a second shell.  The key is that no buffer named
805 `*shell*' can exist.  It might be preferable to use `M-x
806 rename-uniquely' to rename the `*shell*' buffer instead of `M-x
807 rename-buffer'.
808
809    Alternately, you can set the variable `shell-multiple-shells'.  If
810 the value of this variable is non-nil, each time shell mode is invoked,
811 a new shell is made
812
813 \1f
814 File: xemacs-faq.info,  Node: Q5.0.7,  Next: Q5.0.8,  Prev: Q5.0.6,  Up: Miscellaneous
815
816 Q5.0.7: Telnet from shell filters too much
817 ------------------------------------------
818
819    I'm using the Emacs `M-x shell' function, and I would like to invoke
820 and use a telnet session within it.  Everything works fine except that
821 now all `^M''s are filtered out by Emacs.  Fixes?
822
823    Use `M-x rsh' or `M-x telnet' to open remote sessions rather than
824 doing rsh or telnet within the local shell buffer.  Starting with
825 XEmacs-20.3 you can also use `M-x ssh' to open secure remote session if
826 you have `ssh' installed.
827
828 \1f
829 File: xemacs-faq.info,  Node: Q5.0.8,  Next: Q5.0.9,  Prev: Q5.0.7,  Up: Miscellaneous
830
831 Q5.0.8: Why does edt emulation not work?
832 ----------------------------------------
833
834    We don't know, but you can use tpu-edt emulation instead, which works
835 fine and is a little fancier than the standard edt emulation.  To do
836 this, add the following line to your `.emacs':
837
838      (tpu-edt)
839
840    If you don't want it to replace `C-h' with an edt-style help menu
841 add this as well:
842
843      (global-set-key [(control h)] 'help-for-help)
844
845 \1f
846 File: xemacs-faq.info,  Node: Q5.0.9,  Next: Q5.0.10,  Prev: Q5.0.8,  Up: Miscellaneous
847
848 Q5.0.9: How can I emulate VI and use it as my default mode?
849 -----------------------------------------------------------
850
851    Our recommended VI emulator is viper. To make viper-mode the default,
852 add this to your `.emacs':
853
854      (viper-mode)
855
856    Michael Kifer <kifer@CS.SunySB.EDU> writes:
857
858      This should be added as close to the top of `.emacs' as you can get
859      it, otherwise some minor modes may not get viper-ized.
860
861 \1f
862 File: xemacs-faq.info,  Node: Q5.0.10,  Next: Q5.0.11,  Prev: Q5.0.9,  Up: Miscellaneous
863
864 Q5.0.10: [This question intentionally left blank]
865 -------------------------------------------------
866
867    Obsolete question, left blank to avoid renumbering
868
869 \1f
870 File: xemacs-faq.info,  Node: Q5.0.11,  Next: Q5.0.12,  Prev: Q5.0.10,  Up: Miscellaneous
871
872 Q5.0.11: How do I turn on filladapt for all buffers?
873 ----------------------------------------------------
874
875    Filladapt is a minor mode and minor modes are traditionally off by
876 default.  The following added to your `.emacs' will turn it on for all
877 buffers:
878
879      (setq-default filladapt-mode t)
880
881    Use `turn-on-filladapt-mode' to turn Filladapt on in particular
882 major modes, like this:
883
884      (add-hook 'text-mode-hook 'turn-on-filladapt-mode)
885
886 \1f
887 File: xemacs-faq.info,  Node: Q5.0.12,  Next: Q5.0.13,  Prev: Q5.0.11,  Up: Miscellaneous
888
889 Q5.0.12: How do I disable gnuserv from opening a new frame?
890 -----------------------------------------------------------
891
892    If you set the `gnuserv-frame' variable to the frame that should be
893 used to display buffers that are pulled up, a new frame will not be
894 created. For example, you could put
895
896      (setq gnuserv-frame (selected-frame))
897
898    early on in your `.emacs', to ensure that the first frame created is
899 the one used for your gnuserv buffers.
900
901    Starting in 19.15, there is an option to set the gnuserv target to
902 the current frame.  See `Options->"Other Window" Location->Make current
903 frame gnuserv target'
904
905    Starting with XEmacs-20.3 you can also change this with Customize.
906 Select from the `Options' menu
907 `Customize->Emacs->Environment->Gnuserv->Gnuserv Frame...' or type `M-x
908 customize <RET> gnuserv <RET>'.
909
910 \1f
911 File: xemacs-faq.info,  Node: Q5.0.13,  Next: Q5.0.14,  Prev: Q5.0.12,  Up: Miscellaneous
912
913 Q5.0.13: How do I start gnuserv so that each subsequent XEmacs is a client?
914 ---------------------------------------------------------------------------
915
916    Put the following in your `.emacs' file to start the server:
917
918      (gnuserv-start)
919
920    Start your first XEmacs as usual.  After that, you can do:
921
922      gnuclient randomfilename
923
924    from the command line to get your existing XEmacs process to open a
925 new frame and visit randomfilename in that window. When you're done
926 editing randomfilename, hit `C-x #' to kill the buffer and get rid of
927 the frame.
928
929    See also man page of gnuclient.
930
931 \1f
932 File: xemacs-faq.info,  Node: Q5.0.14,  Next: Q5.0.15,  Prev: Q5.0.13,  Up: Miscellaneous
933
934 Q5.0.14: Strange things are happening in Shell Mode.
935 ----------------------------------------------------
936
937    Sometimes (i.e. it's not repeatable, and I can't work out why it
938 happens) when I'm typing into shell mode, I hit return and only a
939 portion of the command is given to the shell, and a blank prompt is
940 returned.  If I hit return again, the rest of the previous command is
941 given to the shell.
942
943    Martin Buchholz <martin@xemacs.org> writes:
944
945      There is a known problem with interaction between `csh' and the
946      `filec' option and XEmacs.  You should add the following to your
947      `.cshrc':
948
949           if ( "$TERM" == emacs || "$TERM" == unknown ) unset filec
950
951 \1f
952 File: xemacs-faq.info,  Node: Q5.0.15,  Next: Q5.0.16,  Prev: Q5.0.14,  Up: Miscellaneous
953
954 Q5.0.15: Where do I get the latest CC Mode?
955 -------------------------------------------
956
957    Barry A. Warsaw <bwarsaw@cnri.reston.va.us> writes:
958
959      This can be had from `http://www.python.org/emacs/'.
960
961 \1f
962 File: xemacs-faq.info,  Node: Q5.0.16,  Next: Q5.0.17,  Prev: Q5.0.15,  Up: Miscellaneous
963
964 Q5.0.16: I find auto-show-mode disconcerting.  How do I turn it off?
965 --------------------------------------------------------------------
966
967    `auto-show-mode' controls whether or not a horizontal scrollbar
968 magically appears when a line is too long to be displayed.  This is
969 enabled by default.  To turn it off, put the following in your `.emacs':
970
971      (setq auto-show-mode nil)
972      (setq-default auto-show-mode nil)
973
974 \1f
975 File: xemacs-faq.info,  Node: Q5.0.17,  Next: Q5.0.18,  Prev: Q5.0.16,  Up: Miscellaneous
976
977 Q5.0.17: How can I get two instances of info?
978 ---------------------------------------------
979
980    You can't.  The `info' package does not provide for multiple info
981 buffers.
982
983 \1f
984 File: xemacs-faq.info,  Node: Q5.0.18,  Next: Q5.0.19,  Prev: Q5.0.17,  Up: Miscellaneous
985
986 Q5.0.18: [This question intentionally left blank]
987 -------------------------------------------------
988
989 \1f
990 File: xemacs-faq.info,  Node: Q5.0.19,  Next: Q5.0.20,  Prev: Q5.0.18,  Up: Miscellaneous
991
992 Q5.0.19: Is there something better than LaTeX mode?
993 ---------------------------------------------------
994
995    David Kastrup <dak@fsnif.neuroinformatik.ruhr-uni-bochum.de> writes:
996
997      The standard TeX modes leave much to be desired, and are somewhat
998      leniently maintained.  Serious TeX users use AUC TeX (*note
999      Q4.7.1::).
1000
1001 \1f
1002 File: xemacs-faq.info,  Node: Q5.0.20,  Next: Q5.1.1,  Prev: Q5.0.19,  Up: Miscellaneous
1003
1004 Q5.0.20: Is there a way to start a new XEmacs if there's no gnuserv running, and otherwise use gnuclient?
1005 ---------------------------------------------------------------------------------------------------------
1006
1007    Jan Vroonhof <vroonhof@math.ethz.ch> writes:
1008      Here is one of the solutions, we have this in a script called
1009      `etc/editclient.sh'.
1010            #!/bin/sh
1011            if gnuclient -batch -eval t >/dev/null 2>&1
1012            then
1013              exec gnuclient ${1+"$@"}
1014            else
1015              xemacs -unmapped -f gnuserv-start &
1016              until gnuclient -batch -eval t >/dev/null 2>&1
1017              do
1018                 sleep 1
1019              done
1020              exec gnuclient ${1+"$@"}
1021            fi
1022
1023      Note that there is a known problem when running XEmacs and
1024      'gnuclient -nw' on the same TTY.
1025
1026 \1f
1027 File: xemacs-faq.info,  Node: Q5.1.1,  Next: Q5.1.2,  Prev: Q5.0.20,  Up: Miscellaneous
1028
1029 5.1: Emacs Lisp Programming Techniques
1030 ======================================
1031
1032 Q5.1.1: What is the difference in key sequences between XEmacs and GNU Emacs?
1033 -----------------------------------------------------------------------------
1034
1035    Erik Naggum <clerik@naggum.no> writes;
1036
1037      Emacs has a legacy of keyboards that produced characters with
1038      modifier bits, and therefore map a variety of input systems into
1039      this scheme even today.  XEmacs is instead optimized for X events.
1040      This causes an incompatibility in the way key sequences are
1041      specified, but both Emacs and XEmacs will accept a key sequence as
1042      a vector of lists of modifiers that ends with a key, e.g., to bind
1043      `M-C-a', you would say `[(meta control a)]' in both Emacsen.
1044      XEmacs has an abbreviated form for a single key, just (meta
1045      control a).  Emacs has an abbreviated form for the Control and the
1046      Meta modifiers to string-characters (the ASCII characters), as in
1047      `\M-\C-a'.  XEmacs users need to be aware that the abbreviated
1048      form works only for one-character key sequences, while Emacs users
1049      need to be aware that the string-character is rather limited.
1050      Specifically, the string-character can accommodate only 256
1051      different values, 128 of which have the Meta modifier and 128 of
1052      which have not.  In each of these blocks, only 32 characters have
1053      the Control modifier.  Whereas `[(meta control A)]' differs from
1054      `[(meta control a)]' because the case differs, `\M-\C-a' and
1055      `\M-\C-A' do not.  Programmers are advised to use the full common
1056      form, both because it is more readable and less error-prone, and
1057      because it is supported by both Emacsen.
1058
1059    Another (even safer) way to be sure of the key-sequences is to use
1060 the `read-kbd-macro' function, which takes a string like `C-c <up>',
1061 and converts it to the internal key representation of the Emacs you
1062 use.  The function is available both on XEmacs and GNU Emacs.
1063
1064 \1f
1065 File: xemacs-faq.info,  Node: Q5.1.2,  Next: Q5.1.3,  Prev: Q5.1.1,  Up: Miscellaneous
1066
1067 Q5.1.2: Can I generate "fake" keyboard events?
1068 ----------------------------------------------
1069
1070    I wonder if there is an interactive function that can generate
1071 "fake" keyboard events.  This way, I could simply map them inside
1072 XEmacs.
1073
1074    This seems to work:
1075
1076      (defun cg--generate-char-event (ch)
1077        "Generate an event, as if ch has been typed"
1078        (dispatch-event (character-to-event ch)))
1079      
1080      ;;  Backspace and Delete stuff
1081      (global-set-key [backspace]
1082        (lambda () (interactive) (cg--generate-char-event 127)))
1083      (global-set-key [unknown_keysym_0x4]
1084        (lambda () (interactive) (cg--generate-char-event 4)))
1085
1086 \1f
1087 File: xemacs-faq.info,  Node: Q5.1.3,  Next: Q5.1.4,  Prev: Q5.1.2,  Up: Miscellaneous
1088
1089 Q5.1.3: Could you explain `read-kbd-macro' in more detail?
1090 ----------------------------------------------------------
1091
1092    The `read-kbd-macro' function returns the internal Emacs
1093 representation of a human-readable string (which is its argument).
1094 Thus:
1095
1096      (read-kbd-macro "C-c C-a")
1097      => [(control ?c) (control ?a)]
1098      
1099      (read-kbd-macro "C-c C-. <up>")
1100      => [(control ?c) (control ?.) up]
1101
1102    In GNU Emacs the same forms will be evaluated to what GNU Emacs
1103 understands internally--the sequences `"\C-x\C-c"' and `[3 67108910
1104 up]', respectively.
1105
1106    The exact "human-readable" syntax is defined in the docstring of
1107 `edmacro-mode'.  I'll repeat it here, for completeness.
1108
1109      Format of keyboard macros during editing:
1110
1111      Text is divided into "words" separated by whitespace.  Except for
1112      the words described below, the characters of each word go directly
1113      as characters of the macro.  The whitespace that separates words is
1114      ignored.  Whitespace in the macro must be written explicitly, as in
1115      `foo <SPC> bar <RET>'.
1116
1117         * The special words `RET', `SPC', `TAB', `DEL', `LFD', `ESC',
1118           and `NUL' represent special control characters.  The words
1119           must be written in uppercase.
1120
1121         * A word in angle brackets, e.g., `<return>', `<down>', or
1122           `<f1>', represents a function key.  (Note that in the standard
1123           configuration, the function key `<return>' and the control key
1124           <RET> are synonymous.)  You can use angle brackets on the
1125           words <RET>, <SPC>, etc., but they are not required there.
1126
1127         * Keys can be written by their ASCII code, using a backslash
1128           followed by up to six octal digits.  This is the only way to
1129           represent keys with codes above \377.
1130
1131         * One or more prefixes `M-' (meta), `C-' (control), `S-'
1132           (shift), `A-' (alt), `H-' (hyper), and `s-' (super) may
1133           precede a character or key notation.  For function keys, the
1134           prefixes may go inside or outside of the brackets: `C-<down>'
1135           == `<C-down>'.  The prefixes may be written in any order:
1136           `M-C-x' == `C-M-x'.
1137
1138           Prefixes are not allowed on multi-key words, e.g., `C-abc',
1139           except that the Meta prefix is allowed on a sequence of
1140           digits and optional minus sign: `M--123' == `M-- M-1 M-2 M-3'.
1141
1142         * The `^' notation for control characters also works: `^M' ==
1143           `C-m'.
1144
1145         * Double angle brackets enclose command names: `<<next-line>>'
1146           is shorthand for `M-x next-line <RET>'.
1147
1148         * Finally, `REM' or `;;' causes the rest of the line to be
1149           ignored as a comment.
1150
1151      Any word may be prefixed by a multiplier in the form of a decimal
1152      number and `*': `3*<right>' == `<right> <right> <right>', and
1153      `10*foo' == `foofoofoofoofoofoofoofoofoofoo'.
1154
1155      Multiple text keys can normally be strung together to form a word,
1156      but you may need to add whitespace if the word would look like one
1157      of the above notations: `; ; ;' is a keyboard macro with three
1158      semicolons, but `;;;' is a comment.  Likewise, `\ 1 2 3' is four
1159      keys but `\123' is a single key written in octal, and `< right >'
1160      is seven keys but `<right>' is a single function key.  When in
1161      doubt, use whitespace.
1162
1163 \1f
1164 File: xemacs-faq.info,  Node: Q5.1.4,  Next: Q5.1.5,  Prev: Q5.1.3,  Up: Miscellaneous
1165
1166 Q5.1.4: What is the performance hit of `let'?
1167 ---------------------------------------------
1168
1169    In most cases, not noticeable.  Besides, there's no avoiding
1170 `let'--you have to bind your local variables, after all.  Some pose a
1171 question whether to nest `let's, or use one `let' per function.  I
1172 think because of clarity and maintenance (and possible future
1173 implementation), `let'-s should be used (nested) in a way to provide
1174 the clearest code.
1175
1176 \1f
1177 File: xemacs-faq.info,  Node: Q5.1.5,  Next: Q5.1.6,  Prev: Q5.1.4,  Up: Miscellaneous
1178
1179 Q5.1.5: What is the recommended use of `setq'?
1180 ----------------------------------------------
1181
1182    * Global variables
1183
1184      You will typically `defvar' your global variable to a default
1185      value, and use `setq' to set it later.
1186
1187      It is never a good practice to `setq' user variables (like
1188      `case-fold-search', etc.), as it ignores the user's choice
1189      unconditionally.  Note that `defvar' doesn't change the value of a
1190      variable if it was bound previously.  If you wish to change a
1191      user-variable temporarily, use `let':
1192
1193           (let ((case-fold-search nil))
1194             ...                                   ; code with searches that must be case-sensitive
1195             ...)
1196
1197      You will notice the user-variables by their docstrings beginning
1198      with an asterisk (a convention).
1199
1200    * Local variables
1201
1202      Bind them with `let', which will unbind them (or restore their
1203      previous value, if they were bound) after exiting from the `let'
1204      form.  Change the value of local variables with `setq' or whatever
1205      you like (e.g. `incf', `setf' and such).  The `let' form can even
1206      return one of its local variables.
1207
1208      Typical usage:
1209
1210           ;; iterate through the elements of the list returned by
1211           ;; `hairy-function-that-returns-list'
1212           (let ((l (hairy-function-that-returns-list)))
1213             (while l
1214               ... do something with (car l) ...
1215               (setq l (cdr l))))
1216
1217      Another typical usage includes building a value simply to work
1218      with it.
1219
1220           ;; Build the mode keymap out of the key-translation-alist
1221           (let ((inbox (file-truename (expand-file-name box)))
1222                 (i 0))
1223             ... code dealing with inbox ...
1224             inbox)
1225
1226      This piece of code uses the local variable `inbox', which becomes
1227      unbound (or regains old value) after exiting the form.  The form
1228      also returns the value of `inbox', which can be reused, for
1229      instance:
1230
1231           (setq foo-processed-inbox
1232                 (let .....))
1233
1234 \1f
1235 File: xemacs-faq.info,  Node: Q5.1.6,  Next: Q5.1.7,  Prev: Q5.1.5,  Up: Miscellaneous
1236
1237 Q5.1.6: What is the typical misuse of `setq' ?
1238 ----------------------------------------------
1239
1240    A typical misuse is probably `setq'ing a variable that was meant to
1241 be local.  Such a variable will remain bound forever, never to be
1242 garbage-collected.  For example, the code doing:
1243
1244      (defun my-function (whatever)
1245        (setq a nil)
1246        ... build a large list ...
1247        ... and exit ...)
1248
1249    does a bad thing, as `a' will keep consuming memory, never to be
1250 unbound.  The correct thing is to do it like this:
1251
1252      (defun my-function (whatever)
1253        (let (a)                              ; default initialization is to nil
1254          ... build a large list ...
1255          ... and exit, unbinding `a' in the process  ...)
1256
1257    Not only is this prettier syntactically, but it makes it possible for
1258 Emacs to garbage-collect the objects which `a' used to reference.
1259
1260    Note that even global variables should not be `setq'ed without
1261 `defvar'ing them first, because the byte-compiler issues warnings.  The
1262 reason for the warning is the following:
1263
1264      (defun flurgoze nil)                    ; ok, global internal variable
1265      ...
1266      
1267      (setq flurghoze t)                      ; ops!  a typo, but semantically correct.
1268                                              ; however, the byte-compiler warns.
1269      
1270      While compiling toplevel forms:
1271      ** assignment to free variable flurghoze
1272
1273 \1f
1274 File: xemacs-faq.info,  Node: Q5.1.7,  Next: Q5.1.8,  Prev: Q5.1.6,  Up: Miscellaneous
1275
1276 Q5.1.7: I like the `do' form of cl, does it slow things down?
1277 -------------------------------------------------------------
1278
1279    It shouldn't.  Here is what Dave Gillespie has to say about cl.el
1280 performance:
1281
1282      Many of the advanced features of this package, such as `defun*',
1283      `loop', and `setf', are implemented as Lisp macros.  In
1284      byte-compiled code, these complex notations will be expanded into
1285      equivalent Lisp code which is simple and efficient.  For example,
1286      the forms
1287
1288           (incf i n)
1289           (push x (car p))
1290
1291      are expanded at compile-time to the Lisp forms
1292
1293           (setq i (+ i n))
1294           (setcar p (cons x (car p)))
1295
1296      which are the most efficient ways of doing these respective
1297      operations in Lisp.  Thus, there is no performance penalty for
1298      using the more readable `incf' and `push' forms in your compiled
1299      code.
1300
1301      _Interpreted_ code, on the other hand, must expand these macros
1302      every time they are executed.  For this reason it is strongly
1303      recommended that code making heavy use of macros be compiled.  (The
1304      features labelled "Special Form" instead of "Function" in this
1305      manual are macros.)  A loop using `incf' a hundred times will
1306      execute considerably faster if compiled, and will also
1307      garbage-collect less because the macro expansion will not have to
1308      be generated, used, and thrown away a hundred times.
1309
1310      You can find out how a macro expands by using the `cl-prettyexpand'
1311      function.
1312
1313 \1f
1314 File: xemacs-faq.info,  Node: Q5.1.8,  Next: Q5.1.9,  Prev: Q5.1.7,  Up: Miscellaneous
1315
1316 Q5.1.8: I like recursion, does it slow things down?
1317 ---------------------------------------------------
1318
1319    Yes.  Emacs byte-compiler cannot do much to optimize recursion.  But
1320 think well whether this is a real concern in Emacs.  Much of the Emacs
1321 slowness comes from internal mechanisms such as redisplay, or from the
1322 fact that it is an interpreter.
1323
1324    Please try not to make your code much uglier to gain a very small
1325 speed gain.  It's not usually worth it.
1326