본문 바로가기

카테고리 없음

Apprendre Le Fortran Pdf

Basic LispTechniquesDavid J.Cooper, Jr.February 14, 20110 Copyright 2011,Franz Inc. Cooper, Jr.ForewordComputers, and the softwareapplications that power them, permeate every facet of our daily lives. Fromgroceries to airline reservations to dental appointments, our reliance ontechnology is all-encompassing. And, it’s not enough. Every day, our expectationsof technology and software increase:.smart appliances that can be controlled via the internet.better search engines that generate information we actually want.voice-activated laptops.cars that know exactly where to goThe list isendless. Unfortunately, there is not an endless supply of programmersand developers to satisfy our insatiable appetites for new features andgadgets. Every day, hundreds of magazine and on-line articles focus on the timeand people resources needed to support future technological expectations.Further, the days of unlimited funding are over.

Investors want to see results,fast.Common Lisp(CL) is one of the few languages and development options that can meet thesechallenges. Powerful, flexible, changeable on the fly — increasingly, CL isplaying a leading role in areas with complex problem-solving demands.

Engineersin the fields of bioinformatics, scheduling, data mining, document management,B2B, and E-commerce have all turned to CL to complete their applications ontime and within budget. CL, however, no longer just appropriate for the mostcomplex problems. Applications of modest complexity, but with demanding needsfor fast development cycles and customization, are also ideal candidates forCL.Other languageshave tried to mimic CL, with limited success.

Perl, Python, Java, C, C# —they all incorporate some of the features that give Lisp its power, but theirimplementations tend to be brittle.The purpose ofthis book is to showcase the features that make CL so much better than theseimitators, and to give you a “quick-start” guide for using Common Lisp as adevelopment environment. If you are an experienced programmer in languagesother than Lisp, this guide gives you all the tools you need to begin writingLisp applications. If you’ve had some exposure to Lisp in the past, this guidewill help refresh those memories and shed some new light on CL for you.But be careful, Lisp can be addicting!This is why many Fortune 500 companies will use nothing else on their 24/7,cutting-edge, mission-critical applications. After reading this book, tryingour software, and experiencing a 3 to 10 times increase in productivity, webelieve you will feel the same way.Contents1Introduction 11.1The Past, Present, and Future of Common Lisp. 11.1.1Lisp Yesterday. 11.1.2Lisp Today. 11.1.3Lisp Tomorrow.

21.2Convergence of Hardware and Software. 31.3The CL Model of Computation.

32Operating a CL Development Environment 52.1Installing a CL Environment. 52.2Running CL in a Shell Window. 62.2.1Starting CL from a Terminal Window. 62.2.2Stopping CL from a Terminal Window. 62.3Running CL inside a Text Editor.

82.3.1A Note on Emacs and Text Editors. 82.3.2Emacs Terminology. 82.3.3Starting, Stopping, and Working With CL inside an Emacs Shell. 92.4Running CL as a subprocess of Emacs. 102.4.1Starting the CL subprocess within Emacs.

102.4.2Working with CL as an Emacs subprocess. 102.4.3Compiling and Loading a File from an Emacs buffer.

112.5Integrated Development Environment. 122.6The User Init File. 122.7Using CL as a scripting language.

132.8Debugging in CL. 142.8.1Common debugger commands. 142.8.2Interpreted vs Compiled Code. 152.8.3Use of (break) and C-c to interrupt. 162.9Developing Programs and Applications in CL. 162.9.1A Layered Approach. 162.9.2Compiling and Loading your Project.

162.9.3Creating an Application “Fasl” File. 172.9.4Creating an Image File. INTRODUCTIONPaul Graham outlines ANSI CL inhis 1996 book ANSI Common Lisp, also listed inAppendix B.Official language standardization isimportant, because it protects developers from becoming saddled with legacyapplications as new versions of a language are implemented. For example, thislack of standardization has been a continuing problem for Perl developers.Since each implementation of Perl defines the behavior of the language, it isnot uncommon to have applications that require outdated versions of Perl,making it nearly impossible to use in a mission-critical commercialenvironment. 1.1.3 Lisp TomorrowMany developers once hoped that the software developmentprocess of the future would be more automated through Computer-aided SoftwareEngineering (CASE) tools. Such tools claim to enable programmers andnon-programmers to diagram their applications visually and automaticallygenerate code. While useful to a certain extent, traditional CASE tools cannotcover domain-specific details and support all possible kinds of customizations— so developers inevitably need to hand-code the rest of their applications,breaking the link between the CASE model and the code.

CASE systems fall shortof being a true “problemsolving tool.”The recursive nature of CL, and itsnatural ability to build applications in layers and build upon itself — inessence, code which writes code which writes code, makes CL a muchbetter software engineering solution. CL programs can generate other CLprograms (usually at compile-time), allowing the developer to define all partsof the application in one unified high-level language.

Using macros andfunctions, naturally supported by the CL syntax, the system can convertapplications written in the high-level language automatically into “final”code. Thus, CL is both a programming language and a powerful CASE tool, and thereis no need to break the connection.Several other features of CL also save significantdevelopment time and manpower:.Automatic Memory Management/Garbage Collection: inherent in CL’s basicarchitecture.Dynamic Typing: In CL, values have types, but variables do not. Thismeans that you don’t have to declare variables, or placeholders, ahead of timeto be of a particular type; you can simply create them or modify them on thefly.Dynamic Redefinition: You can add new operations and functionality tothe running CL process without the need for downtime. In fact, a program can berunning in one thread, while parts of the code are redefined in another thread.Moreover, as soon as the redefinitions are finished, the application will usethe new code and is effectively modified while running.

Fortran Notes Pdf

This feature isespecially useful for server applications that cannot afford downtimes – youcan patch and repair them while they are running. Portability: The“abstract machine” quality of CL makes programs especially portable.1.2.CONVERGENCE OF HARDWARE AND SOFTWARE 3.Standard Features: CL contains many built-in features and datastructures that are non-standard in other languages. Features such asfull-blown symbol tables and package systems, hash tables, list structures, anda comprehensive object system are several “automatic” features which wouldrequire significant developer time to recreate in other languages.1.2Convergenceof Hardware and SoftwareThe most common criticism of Lisp usually made byprogrammers unfamiliar with the language is that Lisp applications are too bigand too slow.

While this may have been true 20 years ago, it is absolutely notthe case today. Today’s inexpensive commodity computers have more memory thansome of the most powerful machines available just five years ago, and easilymeet the computing needs of a typical CL application. Hardware is no longer thecritical factor. Programmers and development time are!Further, CL programming teams tend to besmall, because the inherent features in CL empower developers to do more.Without excessive effort, a single CL developer can create and deploy asophisticated, powerful program in a much shorter period of time than ifanother language were used.1.3The CLModel of ComputationProgramming in CL is distinguished from programming in otherlanguages due to its unique syntax and development mode. CL allows developersto make changes and test them immediately, in an incremental manner. Inother languages, a developer must follow the “compile-link-run-test” cycle.These extra steps add minutes or hours to each cycle of development, andbreak the programmer’s thought process.

Multiply these figures by days, weeks,and months — and the potential savings are phenomenal.4 CHAPTER 1. INTRODUCTIONChapter 2Operatinga CL Development EnvironmentThis chapter covers some of the hands-on techniques usedwhen working with a CL development environment, specifically, the Allegro CL R environment from FranzInc. If you are completely unfamiliar with any Lisp language, you may wish toreference Chapter 3 as you read this chapter.Ideally, whilereading this chapter, you should have access to an actual Common Lisp sessionand try typing in some of the examples.When workingwith Common Lisp, it helps to think of the environment as its own operatingsystem, sitting on top of whatever operating system you happen to be workingwith. In fact, people used to build entire workstations and operatingsystems in Lisp. The Symbolics Common Lisp environment still runs as anemulated machine on top of the 64-bit Compaq/DEC Alpha CPU, with its ownLisp-based operating system.A complete and current listing ofavailable CL systems can be found on the Association of Lisp Users website, atThese systems follow the samebasic principles, and most of what you learn and write on one system can beapplied and ported over to others.

The examples in this guide were preparedusing Allegro CL for Linux. Where possible, we will note Allegro CL-specificsyntax and extensions.2.1 Installing a CLEnvironmentInstalling a CL environment is generally a straightforwardprocess. For Allegro CL on Linux, this basically involves running a simpleshell script which steps you through some licensing information, then proceedsto unpack the distribution, and sets up the CL executable and supporting files.TheWindows installation involves somewhat less typing and more mouse clicking.5. 2.2 RunningCL in a Shell WindowThe most primitive and simplestway to run CL is directly from the Unix (Linux) shell from within a terminalwindow.

Apprendre Le Fortran Pdf File

Most programmers do not work this way on a daily basis because othermodes of use provide more power and convenience with fewer keystrokes.This mode of working is sometimesuseful for logging into a running CL system on a remote host (e.g. A CL processacting as a webserver) when using a slow dial-up connection.

Fortran

2.2.1 Starting CL from aTerminal WindowTo start a CL session from aterminal window, simply type alispfrom the Unix (or DOS) command line. Assuming your shellexecution path is set up properly and CL is installed properly, you will seesome introductory information, then will be presented with a Command Promptwhich should look very similar to the following:CL-USER(1):CL has entered its read-eval-printloop, and is waiting for you to type something which it will then read,evaluate to obtain a return-value, and finally print thisresulting return-value.The USERprinted before the prompt refers to the current CL package (moreon Packages later), and the number (1)simply keeps track of how many commands have been entered at the prompt.

2.2.2 Stopping CL from aTerminal WindowNow that you have learned how tostart CL, you should probably know how to stop it. InAllegro CL, one easy way to stop the CL process is to type(excl:exit)at the Command Prompt. This should return you to the shell.In very rare cases, a stronger hammer is required to stop the CL process, inwhich case you can try typing(excl:exit 0:no-unwind t)Try It: Now try startingand stopping CL several times, to get a feel for it. In general, you shouldnotice that CL starts much more quickly on subsequent invocations. This isbecause the entire executable file has already been read into the computer’smemory and does not have to be read from the disk every time.A shortcutfor the (excl:exit) commandis the toplevel command:exit.Toplevel commands are words which are preceded by a colon : that you can type at the CLCommand Prompt as a shorthand way of making CL do something.Try It: Startthe CL environment. Then, using your favorite text editor, create a file and place thefollowing text into it (don’t worry about understanding the text for now):2.2.

RUNNING CL IN A SHELL WINDOW(in-package:user)(defun hello (write-string 'Hello,World!' ))Save the file to disk.

Chapter 3If youare new to the CL language, we recommend that you supplement this chapter withother resources. See the Bibliography in Appendix B for some suggestions. TheBibliography also lists two interactive online CL tutorials from TulaneUniversity and Texas A&M, which you may wish to visit.In the meantime, this chapter willprovide a condensed overview of the language. Please note, however, that thisbook is intended as a summary, and will not delve into some of the more subtleand powerful techniques possible with Common Lisp.The first thing you shouldobserve about CL (and most languages in the Lisp family) is that it uses ageneralized prefix notation.One of the most frequent actions in aCL program, or at the toplevel read-eval-print loop, is to call a function.This is most often done by writing an expression which names thefunction, followed by its arguments. Here is an example:(+ 2 2)This expression consists of thefunction named by the symbol “+,”followed by the arguments 2 andanother 2.

As you mayhave guessed, when this expression is evaluated it will return the value 4.Try it: Trytyping this expression at your command prompt, and see the return-value beingprinted on the console.What is it that is actually happeninghere? When CL is asked to evaluate an expression (as in thetoplevel read-eval-print loop), it evaluates the expression according tothe following rules:1.If the expression is a number (i.e. Looks like a number), itsimply evaluates to itself (a number):CL-USER(8): 9999192.If the expression looks like a string (i.e. Is surrounded bydouble-quotes), it also simply evaluates to itself:CL-USER(9): 'Be braver - youcan’t cross a chasm in two small jumps.' 'Be braver - you can’t cross achasm in two small jumps.' 3.If the expression looks like a literal symbol, it will simplyevaluate to that symbol (more on this in Section 3.1.4):CL-USER(12): ’my-symbolMY-SYMBOL4.If the expression looks like a list (i.e.

Is surrounded byparentheses), CL assumes that the first element in this list is a symbolwhich names a function or a macro, and the rest of theelements in the list represent the arguments to the function or macro.(We will discuss functions first, macros later). A function cantake zero or more arguments, and can return zero or more return-values.Often a function only returns one return-value:CL-USER(14): (expt 2 5)32Try it: Try typing the followingfunctional expressions at your command prompt, and convince yourself that theprinted return-values make sense:(+ 2 2)(+ 2)2(+)(+ (+ 2 2) (+ 3 3))(+ (+ 2 2))(sys:user-name)(user-homedir-pathname)(get-universal-time);; returns numberof seconds since January 1, 1900 (search 'Dr.' 'I am Dr.Strangelove')'I am Dr. Strangelove'(subseq 'I am Dr.Strangelove'(search 'Dr.' 'I am Dr.Strangelove'))Note that the arguments to a function can themselves beany kind of the above expressions.

They are evaluated in order, from left toright, and finally they are passed to the function for it to evaluate. Thiskind of nesting can be arbitrarily deep. Do not be concerned about getting lostin an ocean of parentheses — most serious text editors can handle deeply nestedparentheses with ease, and moreover will automatically indent your expressionsso that you, as the programmer, never have to concern yourself with matchingparentheses.One of the nicest things aboutLisp is the simplicity and consistency of its syntax.

What we have covered sofar pertaining to the evaluation of arguments to functions is just abouteverything you need to know about the syntax. The rules for macros are verysimilar, with the primary difference being that all the arguments of a macroare not necessarily evaluated at the time the macro is called — they can betransformed into something else first.This simple consistent syntax is awelcome relief from other widely used languages such as C, C, Java, Perl, andPython.

These languages claim to use a “more natural” “infix” syntax, but inreality their syntax is a confused mixture of prefix, infix, and postfix. Theyuse infix only for the simplest arithmetic operations such as2 + 2and3.

13anduse postfix in certain cases such as iand char.But mostly they actually use a prefix syntax much the sameas Lisp, as in:split(@array, ':');So, if you have been programmingin these other languages, you have been using prefix notation all along, butmay not have noticed it. If you look at it this way, the prefix notation ofLisp will seem much less alien to you.Sometimes you want to specify an expression at the toplevelread-eval-print loop, or inside a program, but you do not want CL toevaluate this expression. You want just the literal expression. CL provides thespecial operator quote forthis purpose.

For example,(quote a)will return the literal symbol A. Note that, by default, the CL reader willconvert all symbol names to uppercase at the time the symbol is read into thesystem. Note also that symbols, if evaluated “as is,” (i.e. ((a 20)(b 30))is not evaluated (actually, themacro has the effect of transforming this into something else before the CLevaluator even sees it). Because this assignment section is not evaluated bythe let macro, it doesnot have to be quoted, like a list which is an argument to a function wouldhave to be. As you can see, the assignment section is a list of lists, where eachinternal list is a pair whose firstis a symbol, and whose secondis a value (which will be evaluated).

These symbols (a and b) are the local variables, and they are assignedto the respective values.The body consistsof any number of expressions which come after the assignment section and beforethe closing parenthesis of the letstatement. The expressions in this body are evaluated normally, and ofcourse any expression can refer to the value of any of the local variablessimply by referring directly to its symbol. If the body consists of more thanone expression, the final return-value of the body is the return-value of itslast expression.New Localvariables in CL are said to have lexical scope, which means that theyare only accessible in the code which is textually contained within the body ofthe let.

The term lexicalis derived from the fact that the behavior of these variables can bedetermined simply by reading the text of the source code, and is notaffected by what happens during the program’s execution.Dynamic scope happens when youbasically mix the concept of global parameters and local let variables. That is, if youuse the name of a previously established parameter inside the assignmentsection of a let, likethis:(let ((.todays-humidity. 50))(do-something))the parameter will have thespecified value not only textually within the the body of the let, but also in anyfunctions which may get called from within the body of the let. The globalvalue of the parameter in any other contexts will not be affected. Because thisscoping behavior is determined by the runtime “dynamic” execution of theprogram, we refer to it as dynamic scope.Dynamic scopeis often used for changing the value of a particular global parameter onlywithin a particular tree of function calls.

Using Dynamic scope, you canaccomplish this without affecting other places in the program which may bereferring to the parameter. Also, you do not have to remember to have your code“reset” the parameter back to a default global value, since it willautomatically “bounce” back to its normal global value.Dynamic scoping capability isespecially useful in a multithreaded CL, i.e., a CL process which canhave many (virtually) simultaneous threads of execution. A parameter can takeon a dynamically scoped value in one thread, without affecting the value of theparameter in any of the other concurrently running threads.In this section we will presentsome of the fundamental native CL operators for manipulating lists as datastructures. CONTROL OF EXECUTIONIf you have one list, and desire another list of the samelength, there is a good chance that you can use one of the mapping functions. Mapcar is the most common ofsuch functions.

Mapcar takesa function and one or more lists, and maps the function across eachelement of the list, producing a new resulting list. The term car comesfrom the original way in Lisp of referring to the first of a list (“contents of address register”).Therefore mapcar takesits function and applies it to the firstof each successive rest ofthe list:CL-USER(29): (defun twice (num)(. num 2))TWICECL-USER(30): (mapcar #’twice ’(1 2 34))(2 4 6 8)“Lambda” (unnamed) functions are used very frequentlywith mapcar and similarmapping functions.

More on this in Section 3.4.3.Property lists (“ plists”) provide a simple yetpowerful way to handle keyword-value pairs. A plist is simply a list,with an even number of elements, where each pair of elements represents a namedvalue.

Fortran

Here is an example of a plist:(:michigan 'Lansing':illinois 'Springfield':pennsylvania 'Harrisburg')In this plist, the keys arekeyword symbols, and the values are strings. The keys in a plist arevery often keyword symbols. 3.7.1 Importing and Exporting SymbolsPackages can export symbolsto make them accessible from other packages, and import symbols to makethem appear to be local to the package.If a symbolis exported from one package but not imported into the current package, it isstill valid to refer to it. In order to refer to symbols in other packages,qualify the symbol with the package name and a single colon: package-2:foo.If a symbol is not exported from theoutside package, you can still refer to it, but this would represent astyle violation, as signified by the fact that you have to use a double-colon: package-2::bar. 3.7.2 The Keyword PackageWe have seen many occurences of symbols whose names arepreceded by a colon (:).These symbols actually reside within the:keywordpackage, and the colon is just a shorthand way of writing and printingthem.

Keyword symbols are generally used for enumerated values and to name(keyword) function arguments. They are “immune” to package (i.e. There is nopossibility of confusion about which package they are in), which makes themespecially convenient for these purposes.3.8 CommonStumbling BlocksThis section discusses common errors and stumbling blocksthat new CL users often encounter. 3.8.1 QuotesOne common pitfall is not understanding when to quote expressions.Quoting a single symbol simply returns the symbol, whereas without the quotes,the symbol is treated as a variable:CL-USER(6): (setq x 1) 1CL-USER(7): x 1CL-USER(8): ’xXQuoting a list returns the list, whereas without thequotes, the list is treated as a function (or macro) call:CL-USER(10): ’(+ 1 2)(+ 1 2)CL-USER(11): (first ’(+ 1 2)) +CL-USER(12): (+ 1 2) 3CL-USER(13): (first (+ 1 2))Error: Attempt to take the car of 3which is not listp. 3.8.2 Function Argument ListsWhen you define a function with defun, the arguments go insidetheir own list:CL-USER(19): (defun square (num)(.

num num))SQUAREBut when you call the function, the argument listcomes spliced in directly after the function name:CL-USER(20): (square 4)16A common mistake is to put the argument list into its ownlist when calling the function, like this:CL-USER(21) (square (4))Error: Funcall of 4 which is anon-function.If you are used to programming in Perl or Java, you willlikely do this occasionally while you are getting used to CL syntax. 3.8.3 Symbols vs. StringsAnother point of confusion is the difference betweensymbols and strings. The symbol AAAand the string 'AAA'are treated in completely different ways by CL. Symbols reside inpackages; strings do not. Moreover, all references to a given symbol in a givenpackage refer to the same actual address in memory — a given symbol in a givenpackage is only allocated once. In contrast, CL might allocate new memorywhenever the user defines a string, so multiple copies of the same string ofcharacters could occur multiple times in memory.

Consider this example:CL-USER(17): (setq a1 ’aaa)AAACL-USER(18): (setq a2 ’aaa)AAACL-USER(19): (eql a1 a2)TEQL compares actual pointers orintegers — A1 and A2 both point to the samesymbol in the same part of memory.CL-USER(20): (setq b1 'bbb')'bbb'CL-USER(21): (setq b2 'bbb')'bbb'CL-USER(22): (eql b1 b2) NILCL-USER(23): (string-equal b1 b2) TAgain, EQL compares pointers, but here B1 and B2 point to different memory addresses, althoughthose addresses happen to contain the same string. Chapter 4InterfacesOne of the strong points of modern commercially-supportedCL environments is their flexibility in working with other environments. In thischapter we present a sampling of some interfaces and packages which come inhandy for developing real-world CL applications and connecting them to theoutside environment.

Some of the packages covered in this chapter arecommercial extensions to Common Lisp as provided with Franz Inc’s Allegro CL,and some of them are available as open-source offerings.4.1 Interfacingwith the Operating SystemOne of the most basic means of interacting with the outsideworld is simply to invoke commands at the operating system level, in similarfashion to Perl’s “system” command. In Allegro CL, one way to accomplish thisis with the function:command-output.This command takes a string which represents a command (possibly witharguments) to be executed through an operating system shell, such as the “C”shell on Unix:(:command-output'ls')When invoked in this fashion,this function returns the the Standard Output from the shell command as astring. Alternatively, you can specify that the output go to another location,such as a file, or a variable defined inside the CL session.When using:command-output, you can also specifywhether CL should wait for the shell command to complete, or should simply goabout its business and let the shell command complete asynchronously.4.2 ForeignFunction InterfaceAllegro CL’s foreign function interface allows youto load compiled libraries and object code from C, C, Fortran, and otherlanguages, and call functions defined in this code55as if they were defined natively in CL. 66 CHAPTER 4. INTERFACESChapter 5SqueakymailThis chapter will present asample application in CL, called “Squeakymail,” for filtering and browsingemail. Squeakymail demonstrates the use of many of Allegro CL’s interfaces andspecial features covered in the previous chapter, in an application of under500 lines.Please note that Squeakymail is anopen-source application and is still evolving, so you should obtain the latestcode if you wish to work with it. Please contact Genworks at for informationon obtaining the current Squeakymail codebase.5.1 Overview of SqueakymailSqueakymail is a multi-user, server-based application whichperforms two main tasks:1.It fetches mail for each user from one or more remote POP (Post OfficeProtocol) accounts, analyses it, scores it for its probability of being “spam”(junk email), and stores it in a local queue for final classification by theuser.

This fetching goes on perpetually, as a background thread running in theCL image.2.It provides a simple web-based interface for each user to be able toview the incoming mail headers and bodies, and confirm or override thepre-scoring on each message. Appendix ASqueakymail with Genworks’ GDL/GWLGenworks International producesand sells a Knowledge Base system based on Allegro CL called General-purposeDeclarative Language. Appendix BBibliographyThis Bibliography should also be considered as aRecommended Reading list. ANSI CommonLisp, by Paul Graham. Prentice-Hall, Inc, Englewood Cliffs, NewJersey. 1996.

Common Lisp, theLanguage, 2nd Edition, by Steele, Guy L., Jr., with Scott E. Fahlman,Richard P. Gabriel, David A. Moon, Daniel L.Weinreb, Daniel G. Bobrow, Linda G. DeMichiel, Sonya E.

Keene, Gregor Kiczales,Crispin Perdue, Kent M. Pitman, Richard C.

Waters, and Jon L. DigitalPress, Bedford, MA. 1990. ANSI CL Hyperspec,by Kent M. Available at. Learning GnuEmacs, by Eric Raymond.

O’Reilly and Associates. 1996.Association of Lisp Users website, many other resources and references,at.Usenet Newsgroup.

Successful Lisp,by David Lamkin, available at.Franz Website (Commercial CL Vendor), at.Xanalys Lispworks Website (Commercial CL Vendor), at. SymbolicsWebsite (Commercial CL Vendor), atAPPENDIX B. BIBLIOGRAPHY.Digitool Website (Macintosh Common Lisp Vendor), at.Corman Lisp Website (Commercial CL Vendor), at.Genworks International Website (CL-based tools, services, and pointersto other resources) at.Knowledge Technologies International Website, at.Tulane Lisp Tutorial, available at.Texas A&M Lisp Tutorial, available atAppendix CEmacs CustomizationC.1Lisp ModeWhen you edit a Lisp file inEmacs, Emacs should automatically put you into Lisp Mode orCommon Lisp Mode. You will see this in the status bar nearthe bottom of the screen. Lisp Mode gives you many convenient commands forworking with List expressions, otherwise known as Symbolic Expressions, or s-expressions,or sexp’s for short.For a complete overview of Lisp Mode,issue the command M-xdescribe-mode in Emacs.

Table C.1 describes a sampling of the commandsavailable in Lisp Mode.C.2MakingYour Own KeychordsYou may wish to automate somecommands which do not already have keychords associated with them. The usualway to do this is to invoke some global-set-keycommands in the.emacs file(Emacs’ initialization file) in your home directory. Here are some exampleentries you could put in this file, along with comments describing what theydo:APPENDIX C. EMACS CUSTOMIZATION;; Make C-x & switch to the.common-lisp. buffer(global-set-key 'C-x&'’(lambda (interactive)(switch-to-buffer'.common-lisp.' )));; Make function key 5 (F5) start orvisit an OS shell.(global-set-key f5 ’(lambda(interactive) (shell)));; Make sure M-p functions to scrollthrough previous commands.

(global-set-key 'M-p' ’fi:pop-input);; Make sure M-n functions to scrollthrough next commands. (global-set-key 'M-n' ’fi:push-input);; Enable the hilighting of selectedtext to show up.(transient-mark-mode 1)C.3 KeyboardMappingIf you plan to spend significant time working with yourkeyboard, consider investing some time in setting it up so you can use iteffectively. As a minimum, you should make sure your Control and Meta keys areset up so that you can get at them without moving your hands away from the“home keys” on the keyboard. This means that:.The Control key should be to the left of the “A” key, assessible withthe little finger of your left hand.The Meta keys should be on each side of the space bar, accessible bytucking your right or left thumb under the palm of your hand.If you are working on an XWindowterminal (e.g. A Unix or Linux machine, or a PC running an X Server such asHummingbird eXceed) you can customize your keyboard with the xmodmap Unix command.

Some of these commands areactually available in Fundamental mode as wellKeychordActionEmacs FunctionC-M-spaceMark sexp starting at pointmark-sexpM-wCopy marked expressionkill-ring-saveC-yPaste copied expressionyankC-M-kKill the sexp starting at pointkill-sexpC-M-fMove point forward by one sexpforward-sexpC-M-bMove point backward by one sexpbackward-sexpM-/Dynamically expand currentword (cycles through choices on repeat)dabbrev-expandTableC.1: Common Commands of the Emacs-Lisp Interface898.

The example programs and worksheets on this site are available for download for educational purposes and may be used in any way that is appropriate provided that you comply with the following conditions. If you have a special need that is not catered for by these conditions, please me. I will probably agree to most reasonable requests.The content of this site is distributed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. If you wish to redistribute the material you may do so provided you use (copy and paste) the following attribution to your website.