From: Glenn Morris Date: Wed, 8 Feb 2012 05:29:16 +0000 (-0800) Subject: * doc/lispref/loading.texi (Named Features): Update the require example. X-Git-Tag: emacs-pretest-24.0.94~243 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=14a1f3806c3d189d0dd10db863320fa36d428fd1;p=emacs.git * doc/lispref/loading.texi (Named Features): Update the require example. The new one reflects the current code, and has a bonus free example of lets + requires too. --- diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index a172f82d2e5..0546ec9e936 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,7 @@ +2012-02-08 Glenn Morris + + * loading.texi (Named Features): Update the require example. + 2012-02-07 Glenn Morris * modes.texi (Defining Minor Modes): diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 8d8fec62e2c..0b822751df6 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi @@ -696,23 +696,29 @@ already. If not, it loads the feature from the appropriate file. This file should call @code{provide} at the top level to add the feature to @code{features}; if it fails to do so, @code{require} signals an error. - For example, in @file{emacs/lisp/prolog.el}, -the definition for @code{run-prolog} includes the following code: + For example, in @file{idlwave.el}, the definition for +@code{idlwave-complete-filename} includes the following code: @smallexample -(defun run-prolog () - "Run an inferior Prolog process, with I/O via buffer *prolog*." - (interactive) - (require 'comint) - (switch-to-buffer (make-comint "prolog" prolog-program-name)) - (inferior-prolog-mode)) +(defun idlwave-complete-filename () + "Use the comint stuff to complete a file name." + (require 'comint) + (let* ((comint-file-name-chars "~/A-Za-z0-9+@:_.$#%=@{@}\\-") + (comint-completion-addsuffix nil) + ...) + (comint-dynamic-complete-filename))) @end smallexample @noindent The expression @code{(require 'comint)} loads the file @file{comint.el} -if it has not yet been loaded. This ensures that @code{make-comint} is -defined. Features are normally named after the files that provide them, -so that @code{require} need not be given the file name. +if it has not yet been loaded, ensuring that +@code{comint-dynamic-complete-filename} is defined. Features are +normally named after the files that provide them, so that +@code{require} need not be given the file name. (Note that it is +important that the @code{require} statement be outside the body of the +@code{let}. Loading a library while its variables are let-bound can +have unintended consequences, namely the variables becoming unbound +after the let exits.) The @file{comint.el} file contains the following top-level expression: