123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585 |
- This is /home/cyd/emacs/doc/lispref/../../info/elisp, produced by
- makeinfo version 4.13 from /home/cyd/emacs/doc/lispref/elisp.texi.
- This is the `GNU Emacs Lisp Reference Manual' corresponding to Emacs
- version 24.2.
- Copyright (C) 1990-1996, 1998-2012 Free Software Foundation, Inc.
- Permission is granted to copy, distribute and/or modify this
- document under the terms of the GNU Free Documentation License,
- Version 1.3 or any later version published by the Free Software
- Foundation; with the Invariant Sections being "GNU General Public
- License," with the Front-Cover texts being "A GNU Manual," and
- with the Back-Cover Texts as in (a) below. A copy of the license
- is included in the section entitled "GNU Free Documentation
- License."
- (a) The FSF's Back-Cover Text is: "You have the freedom to copy and
- modify this GNU manual. Buying copies from the FSF supports it in
- developing GNU and promoting software freedom."
- INFO-DIR-SECTION GNU Emacs Lisp
- START-INFO-DIR-ENTRY
- * Elisp: (elisp). The Emacs Lisp Reference Manual.
- END-INFO-DIR-ENTRY
- File: elisp, Node: Startup Summary, Next: Init File, Up: Starting Up
- 39.1.1 Summary: Sequence of Actions at Startup
- ----------------------------------------------
- When Emacs is started up, it performs the following operations (see
- `normal-top-level' in `startup.el'):
- 1. It adds subdirectories to `load-path', by running the file named
- `subdirs.el' in each directory in the list. Normally, this file
- adds the directory's subdirectories to the list, and those are
- scanned in their turn. The files `subdirs.el' are normally
- generated automatically when Emacs is installed.
- 2. It registers input methods by loading any `leim-list.el' file
- found in the `load-path'.
- 3. It sets the variable `before-init-time' to the value of
- `current-time' (*note Time of Day::). It also sets
- `after-init-time' to `nil', which signals to Lisp programs that
- Emacs is being initialized.
- 4. It sets the language environment and the terminal coding system,
- if requested by environment variables such as `LANG'.
- 5. It does some basic parsing of the command-line arguments.
- 6. If not running in batch mode, it initializes the window system that
- the variable `initial-window-system' specifies (*note
- initial-window-system: Window Systems.). The initialization
- function for each supported window system is specified by
- `window-system-initialization-alist'. If the value of
- `initial-window-system' is WINDOWSYSTEM, then the appropriate
- initialization function is defined in the file
- `term/WINDOWSYSTEM-win.el'. This file should have been compiled
- into the Emacs executable when it was built.
- 7. It runs the normal hook `before-init-hook'.
- 8. If appropriate, it creates a graphical frame. This is not done if
- the options `--batch' or `--daemon' were specified.
- 9. It initializes the initial frame's faces, and sets up the menu bar
- and tool bar if needed. If graphical frames are supported, it
- sets up the tool bar even if the current frame is not a graphical
- one, since a graphical frame may be created later on.
- 10. It use `custom-reevaluate-setting' to re-initialize the members of
- the list `custom-delayed-init-variables'. These are any
- pre-loaded user options whose default value depends on the
- run-time, rather than build-time, context. *Note
- custom-initialize-delay: Building Emacs.
- 11. It loads the library `site-start', if it exists. This is not done
- if the options `-Q' or `--no-site-file' were specified.
- 12. It loads your init file (*note Init File::). This is not done if
- the options `-q', `-Q', or `--batch' were specified. If the `-u'
- option was specified, Emacs looks for the init file in that user's
- home directory instead.
- 13. It loads the library `default', if it exists. This is not done if
- `inhibit-default-init' is non-`nil', nor if the options `-q',
- `-Q', or `--batch' were specified.
- 14. It loads your abbrevs from the file specified by
- `abbrev-file-name', if that file exists and can be read (*note
- abbrev-file-name: Abbrev Files.). This is not done if the option
- `--batch' was specified.
- 15. If `package-enable-at-startup' is non-`nil', it calls the function
- `package-initialize' to activate any optional Emacs Lisp package
- that has been installed. *Note Packaging Basics::.
- 16. It sets the variable `after-init-time' to the value of
- `current-time'. This variable was set to `nil' earlier; setting
- it to the current time signals that the initialization phase is
- over, and, together with `before-init-time', provides the
- measurement of how long it took.
- 17. It runs the normal hook `after-init-hook'.
- 18. If the buffer `*scratch*' exists and is still in Fundamental mode
- (as it should be by default), it sets its major mode according to
- `initial-major-mode'.
- 19. If started on a text terminal, it loads the terminal-specific Lisp
- library, which is specified by the variable `term-file-prefix'
- (*note Terminal-Specific::). This is not done in `--batch' mode,
- nor if `term-file-prefix' is `nil'.
- 20. It displays the initial echo area message, unless you have
- suppressed that with `inhibit-startup-echo-area-message'.
- 21. It processes any command-line options that were not handled
- earlier.
- 22. It now exits if the option `--batch' was specified.
- 23. If `initial-buffer-choice' is a string, it visits the file with
- that name. If the `*scratch*' buffer exists and is empty, it
- inserts `initial-scratch-message' into that buffer.
- 24. It runs `emacs-startup-hook' and then `term-setup-hook'.
- 25. It calls `frame-notice-user-settings', which modifies the
- parameters of the selected frame according to whatever the init
- files specify.
- 26. It runs `window-setup-hook'. *Note Window Systems::.
- 27. It displays the "startup screen", which is a special buffer that
- contains information about copyleft and basic Emacs usage. This is
- not done if `inhibit-startup-screen' or `initial-buffer-choice'
- are non-`nil', or if the `--no-splash' or `-Q' command-line
- options were specified.
- 28. If the option `--daemon' was specified, it calls `server-start'
- and detaches from the controlling terminal. *Note Emacs Server:
- (emacs)Emacs Server.
- 29. If started by the X session manager, it calls
- `emacs-session-restore' passing it as argument the ID of the
- previous session. *Note Session Management::.
- The following options affect some aspects of the startup sequence.
- -- User Option: inhibit-startup-screen
- This variable, if non-`nil', inhibits the startup screen. In that
- case, Emacs typically displays the `*scratch*' buffer; but see
- `initial-buffer-choice', below.
- Do not set this variable in the init file of a new user, or in a
- way that affects more than one user, as that would prevent new
- users from receiving information about copyleft and basic Emacs
- usage.
- `inhibit-startup-message' and `inhibit-splash-screen' are aliases
- for this variable.
- -- User Option: initial-buffer-choice
- If non-`nil', this variable is a string that specifies a file or
- directory for Emacs to display after starting up, instead of the
- startup screen.
- -- User Option: inhibit-startup-echo-area-message
- This variable controls the display of the startup echo area
- message. You can suppress the startup echo area message by adding
- text with this form to your init file:
- (setq inhibit-startup-echo-area-message
- "YOUR-LOGIN-NAME")
- Emacs explicitly checks for an expression as shown above in your
- init file; your login name must appear in the expression as a Lisp
- string constant. You can also use the Customize interface. Other
- methods of setting `inhibit-startup-echo-area-message' to the same
- value do not inhibit the startup message. This way, you can
- easily inhibit the message for yourself if you wish, but
- thoughtless copying of your init file will not inhibit the message
- for someone else.
- -- User Option: initial-scratch-message
- This variable, if non-`nil', should be a string, which is inserted
- into the `*scratch*' buffer when Emacs starts up. If it is `nil',
- the `*scratch*' buffer is empty.
- The following command-line options affect some aspects of the startup
- sequence. *Note Initial Options: (emacs)Initial Options.
- `--no-splash'
- Do not display a splash screen.
- `--batch'
- Run without an interactive terminal. *Note Batch Mode::.
- `--daemon'
- Do not initialize any display; just start a server in the
- background.
- `--no-init-file'
- `-Q'
- Do not load either the init file, or the `default' library.
- `--no-site-file'
- Do not load the `site-start' library.
- `--quick'
- `-Q'
- Equivalent to `-q --no-site-file --no-splash'.
- File: elisp, Node: Init File, Next: Terminal-Specific, Prev: Startup Summary, Up: Starting Up
- 39.1.2 The Init File
- --------------------
- When you start Emacs, it normally attempts to load your "init file".
- This is either a file named `.emacs' or `.emacs.el' in your home
- directory, or a file named `init.el' in a subdirectory named `.emacs.d'
- in your home directory.
- The command-line switches `-q', `-Q', and `-u' control whether and
- where to find the init file; `-q' (and the stronger `-Q') says not to
- load an init file, while `-u USER' says to load USER's init file
- instead of yours. *Note Entering Emacs: (emacs)Entering Emacs. If
- neither option is specified, Emacs uses the `LOGNAME' environment
- variable, or the `USER' (most systems) or `USERNAME' (MS systems)
- variable, to find your home directory and thus your init file; this
- way, even if you have su'd, Emacs still loads your own init file. If
- those environment variables are absent, though, Emacs uses your user-id
- to find your home directory.
- An Emacs installation may have a "default init file", which is a
- Lisp library named `default.el'. Emacs finds this file through the
- standard search path for libraries (*note How Programs Do Loading::).
- The Emacs distribution does not come with this file; it is intended for
- local customizations. If the default init file exists, it is loaded
- whenever you start Emacs. But your own personal init file, if any, is
- loaded first; if it sets `inhibit-default-init' to a non-`nil' value,
- then Emacs does not subsequently load the `default.el' file. In batch
- mode, or if you specify `-q' (or `-Q'), Emacs loads neither your
- personal init file nor the default init file.
- Another file for site-customization is `site-start.el'. Emacs loads
- this _before_ the user's init file. You can inhibit the loading of
- this file with the option `--no-site-file'.
- -- User Option: site-run-file
- This variable specifies the site-customization file to load before
- the user's init file. Its normal value is `"site-start"'. The
- only way you can change it with real effect is to do so before
- dumping Emacs.
- *Note Init File Examples: (emacs)Init Examples, for examples of how
- to make various commonly desired customizations in your `.emacs' file.
- -- User Option: inhibit-default-init
- If this variable is non-`nil', it prevents Emacs from loading the
- default initialization library file. The default value is `nil'.
- -- Variable: before-init-hook
- This normal hook is run, once, just before loading all the init
- files (`site-start.el', your init file, and `default.el'). (The
- only way to change it with real effect is before dumping Emacs.)
- -- Variable: after-init-hook
- This normal hook is run, once, just after loading all the init
- files (`site-start.el', your init file, and `default.el'), before
- loading the terminal-specific library (if started on a text
- terminal) and processing the command-line action arguments.
- -- Variable: emacs-startup-hook
- This normal hook is run, once, just after handling the command line
- arguments, just before `term-setup-hook'. In batch mode, Emacs
- does not run either of these hooks.
- -- Variable: user-init-file
- This variable holds the absolute file name of the user's init
- file. If the actual init file loaded is a compiled file, such as
- `.emacs.elc', the value refers to the corresponding source file.
- -- Variable: user-emacs-directory
- This variable holds the name of the `.emacs.d' directory. It is
- `~/.emacs.d' on all platforms but MS-DOS.
- File: elisp, Node: Terminal-Specific, Next: Command-Line Arguments, Prev: Init File, Up: Starting Up
- 39.1.3 Terminal-Specific Initialization
- ---------------------------------------
- Each terminal type can have its own Lisp library that Emacs loads when
- run on that type of terminal. The library's name is constructed by
- concatenating the value of the variable `term-file-prefix' and the
- terminal type (specified by the environment variable `TERM').
- Normally, `term-file-prefix' has the value `"term/"'; changing this is
- not recommended. Emacs finds the file in the normal manner, by
- searching the `load-path' directories, and trying the `.elc' and `.el'
- suffixes.
- The usual role of a terminal-specific library is to enable special
- keys to send sequences that Emacs can recognize. It may also need to
- set or add to `input-decode-map' if the Termcap or Terminfo entry does
- not specify all the terminal's function keys. *Note Terminal Input::.
- When the name of the terminal type contains a hyphen or underscore,
- and no library is found whose name is identical to the terminal's name,
- Emacs strips from the terminal's name the last hyphen or underscore and
- everything that follows it, and tries again. This process is repeated
- until Emacs finds a matching library, or until there are no more
- hyphens or underscores in the name (i.e. there is no terminal-specific
- library). For example, if the terminal name is `xterm-256color' and
- there is no `term/xterm-256color.el' library, Emacs tries to load
- `term/xterm.el'. If necessary, the terminal library can evaluate
- `(getenv "TERM")' to find the full name of the terminal type.
- Your init file can prevent the loading of the terminal-specific
- library by setting the variable `term-file-prefix' to `nil'. This
- feature is useful when experimenting with your own peculiar
- customizations.
- You can also arrange to override some of the actions of the
- terminal-specific library by setting the variable `term-setup-hook'.
- This is a normal hook that Emacs runs at the end of its initialization,
- after loading both your init file and any terminal-specific libraries.
- You could use this hook to define initializations for terminals that do
- not have their own libraries. *Note Hooks::.
- -- Variable: term-file-prefix
- If the value of this variable is non-`nil', Emacs loads a
- terminal-specific initialization file as follows:
- (load (concat term-file-prefix (getenv "TERM")))
- You may set the `term-file-prefix' variable to `nil' in your init
- file if you do not wish to load the terminal-initialization file.
- On MS-DOS, Emacs sets the `TERM' environment variable to
- `internal'.
- -- Variable: term-setup-hook
- This variable is a normal hook that Emacs runs after loading your
- init file, the default initialization file (if any) and the
- terminal-specific Lisp file.
- You can use `term-setup-hook' to override the definitions made by a
- terminal-specific file.
- For a related feature, *note window-setup-hook: Window Systems.
- File: elisp, Node: Command-Line Arguments, Prev: Terminal-Specific, Up: Starting Up
- 39.1.4 Command-Line Arguments
- -----------------------------
- You can use command-line arguments to request various actions when you
- start Emacs. Note that the recommended way of using Emacs is to start
- it just once, after logging in, and then do all editing in the same
- Emacs session (*note Entering Emacs: (emacs)Entering Emacs.). For this
- reason, you might not use command-line arguments very often;
- nonetheless, they can be useful when invoking Emacs from session
- scripts or debugging Emacs. This section describes how Emacs processes
- command-line arguments.
- -- Function: command-line
- This function parses the command line that Emacs was called with,
- processes it, and (amongst other things) loads the user's init
- file and displays the startup messages.
- -- Variable: command-line-processed
- The value of this variable is `t' once the command line has been
- processed.
- If you redump Emacs by calling `dump-emacs', you may wish to set
- this variable to `nil' first in order to cause the new dumped Emacs
- to process its new command-line arguments.
- -- Variable: command-switch-alist
- This variable is an alist of user-defined command-line options and
- associated handler functions. By default it is empty, but you can
- add elements if you wish.
- A "command-line option" is an argument on the command line, which
- has the form:
- -OPTION
- The elements of the `command-switch-alist' look like this:
- (OPTION . HANDLER-FUNCTION)
- The CAR, OPTION, is a string, the name of a command-line option
- (not including the initial hyphen). The HANDLER-FUNCTION is
- called to handle OPTION, and receives the option name as its sole
- argument.
- In some cases, the option is followed in the command line by an
- argument. In these cases, the HANDLER-FUNCTION can find all the
- remaining command-line arguments in the variable
- `command-line-args-left'. (The entire list of command-line
- arguments is in `command-line-args'.)
- The command-line arguments are parsed by the `command-line-1'
- function in the `startup.el' file. See also *note Command Line
- Arguments for Emacs Invocation: (emacs)Emacs Invocation.
- -- Variable: command-line-args
- The value of this variable is the list of command-line arguments
- passed to Emacs.
- -- Variable: command-line-args-left
- The value of this variable is the list of command-line arguments
- that have not yet been processed.
- -- Variable: command-line-functions
- This variable's value is a list of functions for handling an
- unrecognized command-line argument. Each time the next argument
- to be processed has no special meaning, the functions in this list
- are called, in order of appearance, until one of them returns a
- non-`nil' value.
- These functions are called with no arguments. They can access the
- command-line argument under consideration through the variable
- `argi', which is bound temporarily at this point. The remaining
- arguments (not including the current one) are in the variable
- `command-line-args-left'.
- When a function recognizes and processes the argument in `argi', it
- should return a non-`nil' value to say it has dealt with that
- argument. If it has also dealt with some of the following
- arguments, it can indicate that by deleting them from
- `command-line-args-left'.
- If all of these functions return `nil', then the argument is
- treated as a file name to visit.
- File: elisp, Node: Getting Out, Next: System Environment, Prev: Starting Up, Up: System Interface
- 39.2 Getting Out of Emacs
- =========================
- There are two ways to get out of Emacs: you can kill the Emacs job,
- which exits permanently, or you can suspend it, which permits you to
- reenter the Emacs process later. (In a graphical environment, you can
- of course simply switch to another application without doing anything
- special to Emacs, then switch back to Emacs when you want.)
- * Menu:
- * Killing Emacs:: Exiting Emacs irreversibly.
- * Suspending Emacs:: Exiting Emacs reversibly.
- File: elisp, Node: Killing Emacs, Next: Suspending Emacs, Up: Getting Out
- 39.2.1 Killing Emacs
- --------------------
- Killing Emacs means ending the execution of the Emacs process. If you
- started Emacs from a terminal, the parent process normally resumes
- control. The low-level primitive for killing Emacs is `kill-emacs'.
- -- Command: kill-emacs &optional exit-data
- This command calls the hook `kill-emacs-hook', then exits the
- Emacs process and kills it.
- If EXIT-DATA is an integer, that is used as the exit status of the
- Emacs process. (This is useful primarily in batch operation; see
- *note Batch Mode::.)
- If EXIT-DATA is a string, its contents are stuffed into the
- terminal input buffer so that the shell (or whatever program next
- reads input) can read them.
- The `kill-emacs' function is normally called via the higher-level
- command `C-x C-c' (`save-buffers-kill-terminal'). *Note Exiting:
- (emacs)Exiting. It is also called automatically if Emacs receives a
- `SIGTERM' or `SIGHUP' operating system signal (e.g. when the
- controlling terminal is disconnected), or if it receives a `SIGINT'
- signal while running in batch mode (*note Batch Mode::).
- -- Variable: kill-emacs-hook
- This normal hook is run by `kill-emacs', before it kills Emacs.
- Because `kill-emacs' can be called in situations where user
- interaction is impossible (e.g. when the terminal is disconnected),
- functions on this hook should not attempt to interact with the
- user. If you want to interact with the user when Emacs is
- shutting down, use `kill-emacs-query-functions', described below.
- When Emacs is killed, all the information in the Emacs process,
- aside from files that have been saved, is lost. Because killing Emacs
- inadvertently can lose a lot of work, the `save-buffers-kill-terminal'
- command queries for confirmation if you have buffers that need saving
- or subprocesses that are running. It also runs the abnormal hook
- `kill-emacs-query-functions':
- -- Variable: kill-emacs-query-functions
- When `save-buffers-kill-terminal' is killing Emacs, it calls the
- functions in this hook, after asking the standard questions and
- before calling `kill-emacs'. The functions are called in order of
- appearance, with no arguments. Each function can ask for
- additional confirmation from the user. If any of them returns
- `nil', `save-buffers-kill-emacs' does not kill Emacs, and does not
- run the remaining functions in this hook. Calling `kill-emacs'
- directly does not run this hook.
- File: elisp, Node: Suspending Emacs, Prev: Killing Emacs, Up: Getting Out
- 39.2.2 Suspending Emacs
- -----------------------
- On text terminals, it is possible to "suspend Emacs", which means
- stopping Emacs temporarily and returning control to its superior
- process, which is usually the shell. This allows you to resume editing
- later in the same Emacs process, with the same buffers, the same kill
- ring, the same undo history, and so on. To resume Emacs, use the
- appropriate command in the parent shell--most likely `fg'.
- Suspending works only on a terminal device from which the Emacs
- session was started. We call that device the "controlling terminal" of
- the session. Suspending is not allowed if the controlling terminal is
- a graphical terminal. Suspending is usually not relevant in graphical
- environments, since you can simply switch to another application
- without doing anything special to Emacs.
- Some operating systems (those without `SIGTSTP', or MS-DOS) do not
- support suspension of jobs; on these systems, "suspension" actually
- creates a new shell temporarily as a subprocess of Emacs. Then you
- would exit the shell to return to Emacs.
- -- Command: suspend-emacs &optional string
- This function stops Emacs and returns control to the superior
- process. If and when the superior process resumes Emacs,
- `suspend-emacs' returns `nil' to its caller in Lisp.
- This function works only on the controlling terminal of the Emacs
- session; to relinquish control of other tty devices, use
- `suspend-tty' (see below). If the Emacs session uses more than
- one terminal, you must delete the frames on all the other terminals
- before suspending Emacs, or this function signals an error. *Note
- Multiple Terminals::.
- If STRING is non-`nil', its characters are sent to Emacs's
- superior shell, to be read as terminal input. The characters in
- STRING are not echoed by the superior shell; only the results
- appear.
- Before suspending, `suspend-emacs' runs the normal hook
- `suspend-hook'. After the user resumes Emacs, `suspend-emacs'
- runs the normal hook `suspend-resume-hook'. *Note Hooks::.
- The next redisplay after resumption will redraw the entire screen,
- unless the variable `no-redraw-on-reenter' is non-`nil'. *Note
- Refresh Screen::.
- Here is an example of how you could use these hooks:
- (add-hook 'suspend-hook
- (lambda () (or (y-or-n-p "Really suspend? ")
- (error "Suspend canceled"))))
- (add-hook 'suspend-resume-hook (lambda () (message "Resumed!")
- (sit-for 2)))
- Here is what you would see upon evaluating `(suspend-emacs "pwd")':
- ---------- Buffer: Minibuffer ----------
- Really suspend? y
- ---------- Buffer: Minibuffer ----------
- ---------- Parent Shell ----------
- bash$ /home/username
- bash$ fg
- ---------- Echo Area ----------
- Resumed!
- Note that `pwd' is not echoed after Emacs is suspended. But it is
- read and executed by the shell.
- -- Variable: suspend-hook
- This variable is a normal hook that Emacs runs before suspending.
- -- Variable: suspend-resume-hook
- This variable is a normal hook that Emacs runs on resuming after a
- suspension.
- -- Function: suspend-tty &optional tty
- If TTY specifies a terminal device used by Emacs, this function
- relinquishes the device and restores it to its prior state. Frames
- that used the device continue to exist, but are not updated and
- Emacs doesn't read input from them. TTY can be a terminal object,
- a frame (meaning the terminal for that frame), or `nil' (meaning
- the terminal for the selected frame). *Note Multiple Terminals::.
- If TTY is already suspended, this function does nothing.
- This function runs the hook `suspend-tty-functions', passing the
- terminal object as an argument to each function.
- -- Function: resume-tty &optional tty
- This function resumes the previously suspended terminal device
- TTY; where TTY has the same possible values as it does for
- `suspend-tty'.
- This function reopens the terminal device, re-initializes it, and
- redraws it with that terminal's selected frame. It then runs the
- hook `resume-tty-functions', passing the terminal object as an
- argument to each function.
- If the same device is already used by another Emacs terminal, this
- function signals an error. If TTY is not suspended, this function
- does nothing.
- -- Function: controlling-tty-p &optional tty
- This function returns non-`nil' if TTY is the controlling terminal
- of the Emacs session; TTY can be a terminal object, a frame
- (meaning the terminal for that frame), or `nil' (meaning the
- terminal for the selected frame).
- -- Command: suspend-frame
- This command "suspends" a frame. For GUI frames, it calls
- `iconify-frame' (*note Visibility of Frames::); for frames on text
- terminals, it calls either `suspend-emacs' or `suspend-tty',
- depending on whether the frame is displayed on the controlling
- terminal device or not.
- File: elisp, Node: System Environment, Next: User Identification, Prev: Getting Out, Up: System Interface
- 39.3 Operating System Environment
- =================================
- Emacs provides access to variables in the operating system environment
- through various functions. These variables include the name of the
- system, the user's UID, and so on.
- -- Variable: system-configuration
- This variable holds the standard GNU configuration name for the
- hardware/software configuration of your system, as a string. For
- example, a typical value for a 64-bit GNU/Linux system is
- `"x86_64-unknown-linux-gnu"'.
- -- Variable: system-type
- The value of this variable is a symbol indicating the type of
- operating system Emacs is running on. The possible values are:
- `aix'
- IBM's AIX.
- `berkeley-unix'
- Berkeley BSD and its variants.
- `cygwin'
- Cygwin, a Posix layer on top of MS-Windows.
- `darwin'
- Darwin (Mac OS X).
- `gnu'
- The GNU system (using the GNU kernel, which consists of the
- HURD and Mach).
- `gnu/linux'
- A GNU/Linux system--that is, a variant GNU system, using the
- Linux kernel. (These systems are the ones people often call
- "Linux", but actually Linux is just the kernel, not the whole
- system.)
- `gnu/kfreebsd'
- A GNU (glibc-based) system with a FreeBSD kernel.
- `hpux'
- Hewlett-Packard HPUX operating system.
- `irix'
- Silicon Graphics Irix system.
- `ms-dos'
- Microsoft's DOS. Emacs compiled with DJGPP for MS-DOS binds
- `system-type' to `ms-dos' even when you run it on MS-Windows.
- `usg-unix-v'
- AT&T Unix System V.
- `windows-nt'
- Microsoft Windows NT, 9X and later. The value of
- `system-type' is always `windows-nt', e.g. even on Windows 7.
- We do not wish to add new symbols to make finer distinctions
- unless it is absolutely necessary! In fact, we hope to eliminate
- some of these alternatives in the future. If you need to make a
- finer distinction than `system-type' allows for, you can test
- `system-configuration', e.g. against a regexp.
- -- Function: system-name
- This function returns the name of the machine you are running on,
- as a string.
- The symbol `system-name' is a variable as well as a function. In
- fact, the function returns whatever value the variable `system-name'
- currently holds. Thus, you can set the variable `system-name' in case
- Emacs is confused about the name of your system. The variable is also
- useful for constructing frame titles (*note Frame Titles::).
- -- User Option: mail-host-address
- If this variable is non-`nil', it is used instead of `system-name'
- for purposes of generating email addresses. For example, it is
- used when constructing the default value of `user-mail-address'.
- *Note User Identification::. (Since this is done when Emacs
- starts up, the value actually used is the one saved when Emacs was
- dumped. *Note Building Emacs::.)
- -- Command: getenv var &optional frame
- This function returns the value of the environment variable VAR,
- as a string. VAR should be a string. If VAR is undefined in the
- environment, `getenv' returns `nil'. It returns `""' if VAR is
- set but null. Within Emacs, a list of environment variables and
- their values is kept in the variable `process-environment'.
- (getenv "USER")
- => "lewis"
- The shell command `printenv' prints all or part of the environment:
- bash$ printenv
- PATH=/usr/local/bin:/usr/bin:/bin
- USER=lewis
- TERM=xterm
- SHELL=/bin/bash
- HOME=/home/lewis
- ...
- -- Command: setenv variable &optional value substitute
- This command sets the value of the environment variable named
- VARIABLE to VALUE. VARIABLE should be a string. Internally,
- Emacs Lisp can handle any string. However, normally VARIABLE
- should be a valid shell identifier, that is, a sequence of
- letters, digits and underscores, starting with a letter or
- underscore. Otherwise, errors may occur if subprocesses of Emacs
- try to access the value of VARIABLE. If VALUE is omitted or `nil'
- (or, interactively, with a prefix argument), `setenv' removes
- VARIABLE from the environment. Otherwise, VALUE should be a
- string.
- If the optional argument SUBSTITUTE is non-`nil', Emacs calls the
- function `substitute-env-vars' to expand any environment variables
- in VALUE.
- `setenv' works by modifying `process-environment'; binding that
- variable with `let' is also reasonable practice.
- `setenv' returns the new value of VARIABLE, or `nil' if it removed
- VARIABLE from the environment.
- -- Variable: process-environment
- This variable is a list of strings, each describing one environment
- variable. The functions `getenv' and `setenv' work by means of
- this variable.
- process-environment
- => ("PATH=/usr/local/bin:/usr/bin:/bin"
- "USER=lewis"
- "TERM=xterm"
- "SHELL=/bin/bash"
- "HOME=/home/lewis"
- ...)
- If `process-environment' contains "duplicate" elements that
- specify the same environment variable, the first of these elements
- specifies the variable, and the other "duplicates" are ignored.
- -- Variable: initial-environment
- This variable holds the list of environment variables Emacs
- inherited from its parent process when Emacs started.
- -- Variable: path-separator
- This variable holds a string that says which character separates
- directories in a search path (as found in an environment
- variable). Its value is `":"' for Unix and GNU systems, and `";"'
- for MS systems.
- -- Function: parse-colon-path path
- This function takes a search path string such as the value of the
- `PATH' environment variable, and splits it at the separators,
- returning a list of directory names. `nil' in this list means the
- current directory. Although the function's name says "colon", it
- actually uses the value of `path-separator'.
- (parse-colon-path ":/foo:/bar")
- => (nil "/foo/" "/bar/")
- -- Variable: invocation-name
- This variable holds the program name under which Emacs was
- invoked. The value is a string, and does not include a directory
- name.
- -- Variable: invocation-directory
- This variable holds the directory from which the Emacs executable
- was invoked, or `nil' if that directory cannot be determined.
- -- Variable: installation-directory
- If non-`nil', this is a directory within which to look for the
- `lib-src' and `etc' subdirectories. In an installed Emacs, it is
- normally `nil'. It is non-`nil' when Emacs can't find those
- directories in their standard installed locations, but can find
- them in a directory related somehow to the one containing the
- Emacs executable (i.e., `invocation-directory').
- -- Function: load-average &optional use-float
- This function returns the current 1-minute, 5-minute, and 15-minute
- system load averages, in a list. The load average indicates the
- number of processes trying to run on the system.
- By default, the values are integers that are 100 times the system
- load averages, but if USE-FLOAT is non-`nil', then they are
- returned as floating point numbers without multiplying by 100.
- If it is impossible to obtain the load average, this function
- signals an error. On some platforms, access to load averages
- requires installing Emacs as setuid or setgid so that it can read
- kernel information, and that usually isn't advisable.
- If the 1-minute load average is available, but the 5- or 15-minute
- averages are not, this function returns a shortened list containing
- the available averages.
- (load-average)
- => (169 48 36)
- (load-average t)
- => (1.69 0.48 0.36)
- The shell command `uptime' returns similar information.
- -- Function: emacs-pid
- This function returns the process ID of the Emacs process, as an
- integer.
- -- Variable: tty-erase-char
- This variable holds the erase character that was selected in the
- system's terminal driver, before Emacs was started.
- File: elisp, Node: User Identification, Next: Time of Day, Prev: System Environment, Up: System Interface
- 39.4 User Identification
- ========================
- -- Variable: init-file-user
- This variable says which user's init files should be used by
- Emacs--or `nil' if none. `""' stands for the user who originally
- logged in. The value reflects command-line options such as `-q'
- or `-u USER'.
- Lisp packages that load files of customizations, or any other sort
- of user profile, should obey this variable in deciding where to
- find it. They should load the profile of the user name found in
- this variable. If `init-file-user' is `nil', meaning that the `-q'
- option was used, then Lisp packages should not load any
- customization files or user profile.
- -- User Option: user-mail-address
- This holds the nominal email address of the user who is using
- Emacs. Emacs normally sets this variable to a default value after
- reading your init files, but not if you have already set it. So
- you can set the variable to some other value in your init file if
- you do not want to use the default value.
- -- Function: user-login-name &optional uid
- This function returns the name under which the user is logged in.
- It uses the environment variables `LOGNAME' or `USER' if either is
- set. Otherwise, the value is based on the effective UID, not the
- real UID.
- If you specify UID (a number), the result is the user name that
- corresponds to UID, or `nil' if there is no such user.
- -- Function: user-real-login-name
- This function returns the user name corresponding to Emacs's real
- UID. This ignores the effective UID, and the environment
- variables `LOGNAME' and `USER'.
- -- Function: user-full-name &optional uid
- This function returns the full name of the logged-in user--or the
- value of the environment variable `NAME', if that is set.
- If the Emacs process's user-id does not correspond to any known
- user (and provided `NAME' is not set), the result is `"unknown"'.
- If UID is non-`nil', then it should be a number (a user-id) or a
- string (a login name). Then `user-full-name' returns the full
- name corresponding to that user-id or login name. If you specify a
- user-id or login name that isn't defined, it returns `nil'.
- The symbols `user-login-name', `user-real-login-name' and
- `user-full-name' are variables as well as functions. The functions
- return the same values that the variables hold. These variables allow
- you to "fake out" Emacs by telling the functions what to return. The
- variables are also useful for constructing frame titles (*note Frame
- Titles::).
- -- Function: user-real-uid
- This function returns the real UID of the user. The value may be
- a floating point number, in the (unlikely) event that the UID is
- too large to fit in a Lisp integer.
- -- Function: user-uid
- This function returns the effective UID of the user. The value
- may be a floating point number.
- File: elisp, Node: Time of Day, Next: Time Conversion, Prev: User Identification, Up: System Interface
- 39.5 Time of Day
- ================
- This section explains how to determine the current time and time zone.
- Most of these functions represent time as a list of either three
- integers, `(SEC-HIGH SEC-LOW MICROSEC)', or of two integers, `(SEC-HIGH
- SEC-LOW)'. The integers SEC-HIGH and SEC-LOW give the high and low
- bits of an integer number of seconds. This integer number, HIGH *
- 2**16 + LOW, is the number of seconds from the "epoch" (0:00 January 1,
- 1970 UTC) to the specified time. The third list element MICROSEC, if
- present, gives the number of microseconds from the start of that second
- to the specified time.
- The return value of `current-time' represents time using three
- integers, while the timestamps in the return value of `file-attributes'
- use two integers (*note Definition of file-attributes::). In function
- arguments, e.g. the TIME-VALUE argument to `current-time-string', both
- two- and three-integer lists are accepted. You can convert times from
- the list representation into standard human-readable strings using
- `current-time', or to other forms using the `decode-time' and
- `format-time-string' functions documented in the following sections.
- -- Function: current-time-string &optional time-value
- This function returns the current time and date as a human-readable
- string. The format of the string is unvarying; the number of
- characters used for each part is always the same, so you can
- reliably use `substring' to extract pieces of it. You should count
- characters from the beginning of the string rather than from the
- end, as additional information may some day be added at the end.
- The argument TIME-VALUE, if given, specifies a time to format
- (represented as a list of integers), instead of the current time.
- (current-time-string)
- => "Wed Oct 14 22:21:05 1987"
- -- Function: current-time
- This function returns the current time, represented as a list of
- three integers `(SEC-HIGH SEC-LOW MICROSEC)'. On systems with
- only one-second time resolutions, MICROSEC is 0.
- -- Function: float-time &optional time-value
- This function returns the current time as a floating-point number
- of seconds since the epoch. The optional argument TIME-VALUE, if
- given, specifies a time (represented as a list of integers) to
- convert instead of the current time.
- _Warning_: Since the result is floating point, it may not be
- exact. Do not use this function if precise time stamps are
- required.
- -- Function: current-time-zone &optional time-value
- This function returns a list describing the time zone that the
- user is in.
- The value has the form `(OFFSET NAME)'. Here OFFSET is an integer
- giving the number of seconds ahead of UTC (east of Greenwich). A
- negative value means west of Greenwich. The second element, NAME,
- is a string giving the name of the time zone. Both elements
- change when daylight saving time begins or ends; if the user has
- specified a time zone that does not use a seasonal time
- adjustment, then the value is constant through time.
- If the operating system doesn't supply all the information
- necessary to compute the value, the unknown elements of the list
- are `nil'.
- The argument TIME-VALUE, if given, specifies a time (represented
- as a list of integers) to analyze instead of the current time.
- The current time zone is determined by the `TZ' environment
- variable. *Note System Environment::. For example, you can tell Emacs
- to use universal time with `(setenv "TZ" "UTC0")'. If `TZ' is not in
- the environment, Emacs uses a platform-dependent default time zone.
- File: elisp, Node: Time Conversion, Next: Time Parsing, Prev: Time of Day, Up: System Interface
- 39.6 Time Conversion
- ====================
- These functions convert time values (lists of two or three integers, as
- explained in the previous section) into calendrical information and
- vice versa.
- Many 32-bit operating systems are limited to time values containing
- 32 bits of information; these systems typically handle only the times
- from 1901-12-13 20:45:52 UTC through 2038-01-19 03:14:07 UTC. However,
- 64-bit and some 32-bit operating systems have larger time values, and
- can represent times far in the past or future.
- Time conversion functions always use the Gregorian calendar, even
- for dates before the Gregorian calendar was introduced. Year numbers
- count the number of years since the year 1 B.C., and do not skip zero
- as traditional Gregorian years do; for example, the year number -37
- represents the Gregorian year 38 B.C.
- -- Function: decode-time &optional time
- This function converts a time value into calendrical information.
- If you don't specify TIME, it decodes the current time. The return
- value is a list of nine elements, as follows:
- (SECONDS MINUTES HOUR DAY MONTH YEAR DOW DST ZONE)
- Here is what the elements mean:
- SECONDS
- The number of seconds past the minute, as an integer between
- 0 and 59. On some operating systems, this is 60 for leap
- seconds.
- MINUTES
- The number of minutes past the hour, as an integer between 0
- and 59.
- HOUR
- The hour of the day, as an integer between 0 and 23.
- DAY
- The day of the month, as an integer between 1 and 31.
- MONTH
- The month of the year, as an integer between 1 and 12.
- YEAR
- The year, an integer typically greater than 1900.
- DOW
- The day of week, as an integer between 0 and 6, where 0
- stands for Sunday.
- DST
- `t' if daylight saving time is effect, otherwise `nil'.
- ZONE
- An integer indicating the time zone, as the number of seconds
- east of Greenwich.
- *Common Lisp Note:* Common Lisp has different meanings for DOW and
- ZONE.
- -- Function: encode-time seconds minutes hour day month year &optional
- zone
- This function is the inverse of `decode-time'. It converts seven
- items of calendrical data into a time value. For the meanings of
- the arguments, see the table above under `decode-time'.
- Year numbers less than 100 are not treated specially. If you want
- them to stand for years above 1900, or years above 2000, you must
- alter them yourself before you call `encode-time'.
- The optional argument ZONE defaults to the current time zone and
- its daylight saving time rules. If specified, it can be either a
- list (as you would get from `current-time-zone'), a string as in
- the `TZ' environment variable, `t' for Universal Time, or an
- integer (as you would get from `decode-time'). The specified zone
- is used without any further alteration for daylight saving time.
- If you pass more than seven arguments to `encode-time', the first
- six are used as SECONDS through YEAR, the last argument is used as
- ZONE, and the arguments in between are ignored. This feature
- makes it possible to use the elements of a list returned by
- `decode-time' as the arguments to `encode-time', like this:
- (apply 'encode-time (decode-time ...))
- You can perform simple date arithmetic by using out-of-range
- values for the SECONDS, MINUTES, HOUR, DAY, and MONTH arguments;
- for example, day 0 means the day preceding the given month.
- The operating system puts limits on the range of possible time
- values; if you try to encode a time that is out of range, an error
- results. For instance, years before 1970 do not work on some
- systems; on others, years as early as 1901 do work.
- File: elisp, Node: Time Parsing, Next: Processor Run Time, Prev: Time Conversion, Up: System Interface
- 39.7 Parsing and Formatting Times
- =================================
- These functions convert time values (lists of two or three integers) to
- text in a string, and vice versa.
- -- Function: date-to-time string
- This function parses the time-string STRING and returns the
- corresponding time value.
- -- Function: format-time-string format-string &optional time universal
- This function converts TIME (or the current time, if TIME is
- omitted) to a string according to FORMAT-STRING. The argument
- FORMAT-STRING may contain `%'-sequences which say to substitute
- parts of the time. Here is a table of what the `%'-sequences mean:
- `%a'
- This stands for the abbreviated name of the day of week.
- `%A'
- This stands for the full name of the day of week.
- `%b'
- This stands for the abbreviated name of the month.
- `%B'
- This stands for the full name of the month.
- `%c'
- This is a synonym for `%x %X'.
- `%C'
- This has a locale-specific meaning. In the default locale
- (named C), it is equivalent to `%A, %B %e, %Y'.
- `%d'
- This stands for the day of month, zero-padded.
- `%D'
- This is a synonym for `%m/%d/%y'.
- `%e'
- This stands for the day of month, blank-padded.
- `%h'
- This is a synonym for `%b'.
- `%H'
- This stands for the hour (00-23).
- `%I'
- This stands for the hour (01-12).
- `%j'
- This stands for the day of the year (001-366).
- `%k'
- This stands for the hour (0-23), blank padded.
- `%l'
- This stands for the hour (1-12), blank padded.
- `%m'
- This stands for the month (01-12).
- `%M'
- This stands for the minute (00-59).
- `%n'
- This stands for a newline.
- `%N'
- This stands for the nanoseconds (000000000-999999999). To
- ask for fewer digits, use `%3N' for milliseconds, `%6N' for
- microseconds, etc. Any excess digits are discarded, without
- rounding. Currently Emacs time stamps are at best
- microsecond resolution so the last three digits generated by
- plain `%N' are always zero.
- `%p'
- This stands for `AM' or `PM', as appropriate.
- `%r'
- This is a synonym for `%I:%M:%S %p'.
- `%R'
- This is a synonym for `%H:%M'.
- `%S'
- This stands for the seconds (00-59).
- `%t'
- This stands for a tab character.
- `%T'
- This is a synonym for `%H:%M:%S'.
- `%U'
- This stands for the week of the year (01-52), assuming that
- weeks start on Sunday.
- `%w'
- This stands for the numeric day of week (0-6). Sunday is day
- 0.
- `%W'
- This stands for the week of the year (01-52), assuming that
- weeks start on Monday.
- `%x'
- This has a locale-specific meaning. In the default locale
- (named `C'), it is equivalent to `%D'.
- `%X'
- This has a locale-specific meaning. In the default locale
- (named `C'), it is equivalent to `%T'.
- `%y'
- This stands for the year without century (00-99).
- `%Y'
- This stands for the year with century.
- `%Z'
- This stands for the time zone abbreviation (e.g., `EST').
- `%z'
- This stands for the time zone numerical offset (e.g.,
- `-0500').
- You can also specify the field width and type of padding for any of
- these `%'-sequences. This works as in `printf': you write the
- field width as digits in the middle of a `%'-sequences. If you
- start the field width with `0', it means to pad with zeros. If you
- start the field width with `_', it means to pad with spaces.
- For example, `%S' specifies the number of seconds since the minute;
- `%03S' means to pad this with zeros to 3 positions, `%_3S' to pad
- with spaces to 3 positions. Plain `%3S' pads with zeros, because
- that is how `%S' normally pads to two positions.
- The characters `E' and `O' act as modifiers when used between `%'
- and one of the letters in the table above. `E' specifies using
- the current locale's "alternative" version of the date and time.
- In a Japanese locale, for example, `%Ex' might yield a date format
- based on the Japanese Emperors' reigns. `E' is allowed in `%Ec',
- `%EC', `%Ex', `%EX', `%Ey', and `%EY'.
- `O' means to use the current locale's "alternative" representation
- of numbers, instead of the ordinary decimal digits. This is
- allowed with most letters, all the ones that output numbers.
- If UNIVERSAL is non-`nil', that means to describe the time as
- Universal Time; `nil' means describe it using what Emacs believes
- is the local time zone (see `current-time-zone').
- This function uses the C library function `strftime' (*note
- Formatting Calendar Time: (libc)Formatting Calendar Time.) to do
- most of the work. In order to communicate with that function, it
- first encodes its argument using the coding system specified by
- `locale-coding-system' (*note Locales::); after `strftime' returns
- the resulting string, `format-time-string' decodes the string
- using that same coding system.
- -- Function: seconds-to-time seconds
- This function converts SECONDS, a floating point number of seconds
- since the epoch, to a time value and returns that. To perform the
- inverse conversion, use `float-time'.
- -- Function: format-seconds format-string seconds
- This function converts its argument SECONDS into a string of
- years, days, hours, etc., according to FORMAT-STRING. The
- argument FORMAT-STRING may contain `%'-sequences which control the
- conversion. Here is a table of what the `%'-sequences mean:
- `%y'
- `%Y'
- The integer number of 365-day years.
- `%d'
- `%D'
- The integer number of days.
- `%h'
- `%H'
- The integer number of hours.
- `%m'
- `%M'
- The integer number of minutes.
- `%s'
- `%S'
- The integer number of seconds.
- `%z'
- Non-printing control flag. When it is used, other specifiers
- must be given in the order of decreasing size, i.e. years
- before days, hours before minutes, etc. Nothing will be
- produced in the result string to the left of `%z' until the
- first non-zero conversion is encountered. For example, the
- default format used by `emacs-uptime' (*note emacs-uptime:
- Processor Run Time.) `"%Y, %D, %H, %M, %z%S"' means that the
- number of seconds will always be produced, but years, days,
- hours, and minutes will only be shown if they are non-zero.
- `%%'
- Produces a literal `%'.
- Upper-case format sequences produce the units in addition to the
- numbers, lower-case formats produce only the numbers.
- You can also specify the field width by following the `%' with a
- number; shorter numbers will be padded with blanks. An optional
- period before the width requests zero-padding instead. For
- example, `"%.3Y"' might produce `"004 years"'.
- _Warning:_ This function works only with values of SECONDS that
- don't exceed `most-positive-fixnum' (*note most-positive-fixnum:
- Integer Basics.).
- File: elisp, Node: Processor Run Time, Next: Time Calculations, Prev: Time Parsing, Up: System Interface
- 39.8 Processor Run time
- =======================
- Emacs provides several functions and primitives that return time, both
- elapsed and processor time, used by the Emacs process.
- -- Command: emacs-uptime &optional format
- This function returns a string representing the Emacs
- "uptime"--the elapsed wall-clock time this instance of Emacs is
- running. The string is formatted by `format-seconds' according to
- the optional argument FORMAT. For the available format
- descriptors, see *note format-seconds: Time Parsing. If FORMAT is
- `nil' or omitted, it defaults to `"%Y, %D, %H, %M, %z%S"'.
- When called interactively, it prints the uptime in the echo area.
- -- Function: get-internal-run-time
- This function returns the processor run time used by Emacs as a
- list of three integers: `(HIGH LOW MICROSEC)'. The integers HIGH
- and LOW combine to give the number of seconds, which is HIGH *
- 2**16 + LOW.
- The third element, MICROSEC, gives the microseconds (or 0 for
- systems that return time with the resolution of only one second).
- Note that the time returned by this function excludes the time
- Emacs was not using the processor, and if the Emacs process has
- several threads, the returned value is the sum of the processor
- times used up by all Emacs threads.
- If the system doesn't provide a way to determine the processor run
- time, `get-internal-run-time' returns the same time as
- `current-time'.
- -- Command: emacs-init-time
- This function returns the duration of the Emacs initialization
- (*note Startup Summary::) in seconds, as a string. When called
- interactively, it prints the duration in the echo area.
- File: elisp, Node: Time Calculations, Next: Timers, Prev: Processor Run Time, Up: System Interface
- 39.9 Time Calculations
- ======================
- These functions perform calendrical computations using time values (the
- kind of list that `current-time' returns).
- -- Function: time-less-p t1 t2
- This returns `t' if time value T1 is less than time value T2.
- -- Function: time-subtract t1 t2
- This returns the time difference T1 - T2 between two time values,
- in the same format as a time value.
- -- Function: time-add t1 t2
- This returns the sum of two time values, one of which ought to
- represent a time difference rather than a point in time. Here is
- how to add a number of seconds to a time value:
- (time-add TIME (seconds-to-time SECONDS))
- -- Function: time-to-days time
- This function returns the number of days between the beginning of
- year 1 and TIME.
- -- Function: time-to-day-in-year time
- This returns the day number within the year corresponding to TIME.
- -- Function: date-leap-year-p year
- This function returns `t' if YEAR is a leap year.
- File: elisp, Node: Timers, Next: Idle Timers, Prev: Time Calculations, Up: System Interface
- 39.10 Timers for Delayed Execution
- ==================================
- You can set up a "timer" to call a function at a specified future time
- or after a certain length of idleness.
- Emacs cannot run timers at any arbitrary point in a Lisp program; it
- can run them only when Emacs could accept output from a subprocess:
- namely, while waiting or inside certain primitive functions such as
- `sit-for' or `read-event' which _can_ wait. Therefore, a timer's
- execution may be delayed if Emacs is busy. However, the time of
- execution is very precise if Emacs is idle.
- Emacs binds `inhibit-quit' to `t' before calling the timer function,
- because quitting out of many timer functions can leave things in an
- inconsistent state. This is normally unproblematical because most
- timer functions don't do a lot of work. Indeed, for a timer to call a
- function that takes substantial time to run is likely to be annoying.
- If a timer function needs to allow quitting, it should use
- `with-local-quit' (*note Quitting::). For example, if a timer function
- calls `accept-process-output' to receive output from an external
- process, that call should be wrapped inside `with-local-quit', to
- ensure that `C-g' works if the external process hangs.
- It is usually a bad idea for timer functions to alter buffer
- contents. When they do, they usually should call `undo-boundary' both
- before and after changing the buffer, to separate the timer's changes
- from user commands' changes and prevent a single undo entry from
- growing to be quite large.
- Timer functions should also avoid calling functions that cause Emacs
- to wait, such as `sit-for' (*note Waiting::). This can lead to
- unpredictable effects, since other timers (or even the same timer) can
- run while waiting. If a timer function needs to perform an action
- after a certain time has elapsed, it can do this by scheduling a new
- timer.
- If a timer function calls functions that can change the match data,
- it should save and restore the match data. *Note Saving Match Data::.
- -- Command: run-at-time time repeat function &rest args
- This sets up a timer that calls the function FUNCTION with
- arguments ARGS at time TIME. If REPEAT is a number (integer or
- floating point), the timer is scheduled to run again every REPEAT
- seconds after TIME. If REPEAT is `nil', the timer runs only once.
- TIME may specify an absolute or a relative time.
- Absolute times may be specified using a string with a limited
- variety of formats, and are taken to be times _today_, even if
- already in the past. The recognized forms are `XXXX', `X:XX', or
- `XX:XX' (military time), and `XXam', `XXAM', `XXpm', `XXPM',
- `XX:XXam', `XX:XXAM', `XX:XXpm', or `XX:XXPM'. A period can be
- used instead of a colon to separate the hour and minute parts.
- To specify a relative time as a string, use numbers followed by
- units. For example:
- `1 min'
- denotes 1 minute from now.
- `1 min 5 sec'
- denotes 65 seconds from now.
- `1 min 2 sec 3 hour 4 day 5 week 6 fortnight 7 month 8 year'
- denotes exactly 103 months, 123 days, and 10862 seconds from
- now.
- For relative time values, Emacs considers a month to be exactly
- thirty days, and a year to be exactly 365.25 days.
- Not all convenient formats are strings. If TIME is a number
- (integer or floating point), that specifies a relative time
- measured in seconds. The result of `encode-time' can also be used
- to specify an absolute value for TIME.
- In most cases, REPEAT has no effect on when _first_ call takes
- place--TIME alone specifies that. There is one exception: if TIME
- is `t', then the timer runs whenever the time is a multiple of
- REPEAT seconds after the epoch. This is useful for functions like
- `display-time'.
- The function `run-at-time' returns a timer value that identifies
- the particular scheduled future action. You can use this value to
- call `cancel-timer' (see below).
- A repeating timer nominally ought to run every REPEAT seconds, but
- remember that any invocation of a timer can be late. Lateness of one
- repetition has no effect on the scheduled time of the next repetition.
- For instance, if Emacs is busy computing for long enough to cover three
- scheduled repetitions of the timer, and then starts to wait, it will
- immediately call the timer function three times in immediate succession
- (presuming no other timers trigger before or between them). If you
- want a timer to run again no less than N seconds after the last
- invocation, don't use the REPEAT argument. Instead, the timer function
- should explicitly reschedule the timer.
- -- Variable: timer-max-repeats
- This variable's value specifies the maximum number of times to
- repeat calling a timer function in a row, when many previously
- scheduled calls were unavoidably delayed.
- -- Macro: with-timeout (seconds timeout-forms...) body...
- Execute BODY, but give up after SECONDS seconds. If BODY finishes
- before the time is up, `with-timeout' returns the value of the
- last form in BODY. If, however, the execution of BODY is cut
- short by the timeout, then `with-timeout' executes all the
- TIMEOUT-FORMS and returns the value of the last of them.
- This macro works by setting a timer to run after SECONDS seconds.
- If BODY finishes before that time, it cancels the timer. If the
- timer actually runs, it terminates execution of BODY, then
- executes TIMEOUT-FORMS.
- Since timers can run within a Lisp program only when the program
- calls a primitive that can wait, `with-timeout' cannot stop
- executing BODY while it is in the midst of a computation--only
- when it calls one of those primitives. So use `with-timeout' only
- with a BODY that waits for input, not one that does a long
- computation.
- The function `y-or-n-p-with-timeout' provides a simple way to use a
- timer to avoid waiting too long for an answer. *Note Yes-or-No
- Queries::.
- -- Function: cancel-timer timer
- This cancels the requested action for TIMER, which should be a
- timer--usually, one previously returned by `run-at-time' or
- `run-with-idle-timer'. This cancels the effect of that call to
- one of these functions; the arrival of the specified time will not
- cause anything special to happen.
- File: elisp, Node: Idle Timers, Next: Terminal Input, Prev: Timers, Up: System Interface
- 39.11 Idle Timers
- =================
- Here is how to set up a timer that runs when Emacs is idle for a
- certain length of time. Aside from how to set them up, idle timers
- work just like ordinary timers.
- -- Command: run-with-idle-timer secs repeat function &rest args
- Set up a timer which runs the next time Emacs is idle for SECS
- seconds. The value of SECS may be an integer or a floating point
- number; a value of the type returned by `current-idle-time' is
- also allowed.
- If REPEAT is `nil', the timer runs just once, the first time Emacs
- remains idle for a long enough time. More often REPEAT is
- non-`nil', which means to run the timer _each time_ Emacs remains
- idle for SECS seconds.
- The function `run-with-idle-timer' returns a timer value which you
- can use in calling `cancel-timer' (*note Timers::).
- Emacs becomes "idle" when it starts waiting for user input, and it
- remains idle until the user provides some input. If a timer is set for
- five seconds of idleness, it runs approximately five seconds after
- Emacs first becomes idle. Even if REPEAT is non-`nil', this timer will
- not run again as long as Emacs remains idle, because the duration of
- idleness will continue to increase and will not go down to five seconds
- again.
- Emacs can do various things while idle: garbage collect, autosave or
- handle data from a subprocess. But these interludes during idleness do
- not interfere with idle timers, because they do not reset the clock of
- idleness to zero. An idle timer set for 600 seconds will run when ten
- minutes have elapsed since the last user command was finished, even if
- subprocess output has been accepted thousands of times within those ten
- minutes, and even if there have been garbage collections and autosaves.
- When the user supplies input, Emacs becomes non-idle while executing
- the input. Then it becomes idle again, and all the idle timers that are
- set up to repeat will subsequently run another time, one by one.
- -- Function: current-idle-time
- If Emacs is idle, this function returns the length of time Emacs
- has been idle, as a list of three integers: `(SEC-HIGH SEC-LOW
- MICROSEC)', where HIGH and LOW are the high and low bits for the
- number of seconds and MICROSEC is the additional number of
- microseconds (*note Time of Day::).
- When Emacs is not idle, `current-idle-time' returns `nil'. This
- is a convenient way to test whether Emacs is idle.
- The main use of this function is when an idle timer function wants
- to "take a break" for a while. It can set up another idle timer to
- call the same function again, after a few seconds more idleness.
- Here's an example:
- (defvar resume-timer nil
- "Timer that `timer-function' used to reschedule itself, or nil.")
- (defun timer-function ()
- ;; If the user types a command while `resume-timer'
- ;; is active, the next time this function is called from
- ;; its main idle timer, deactivate `resume-timer'.
- (when resume-timer
- (cancel-timer resume-timer))
- ...DO THE WORK FOR A WHILE...
- (when TAKING-A-BREAK
- (setq resume-timer
- (run-with-idle-timer
- ;; Compute an idle time BREAK-LENGTH
- ;; more than the current value.
- (time-add (current-idle-time)
- (seconds-to-time BREAK-LENGTH))
- nil
- 'timer-function))))
- Do not write an idle timer function containing a loop which does a
- certain amount of processing each time around, and exits when
- `(input-pending-p)' is non-`nil'. This approach seems very natural but
- has two problems:
- * It blocks out all process output (since Emacs accepts process
- output only while waiting).
- * It blocks out any idle timers that ought to run during that time.
- The correct approach is for the idle timer to reschedule itself after a
- brief pause, using the method in the `timer-function' example above.
- File: elisp, Node: Terminal Input, Next: Terminal Output, Prev: Idle Timers, Up: System Interface
- 39.12 Terminal Input
- ====================
- This section describes functions and variables for recording or
- manipulating terminal input. See *note Display::, for related
- functions.
- * Menu:
- * Input Modes:: Options for how input is processed.
- * Recording Input:: Saving histories of recent or all input events.
- File: elisp, Node: Input Modes, Next: Recording Input, Up: Terminal Input
- 39.12.1 Input Modes
- -------------------
- -- Function: set-input-mode interrupt flow meta &optional quit-char
- This function sets the mode for reading keyboard input. If
- INTERRUPT is non-null, then Emacs uses input interrupts. If it is
- `nil', then it uses CBREAK mode. The default setting is
- system-dependent. Some systems always use CBREAK mode regardless
- of what is specified.
- When Emacs communicates directly with X, it ignores this argument
- and uses interrupts if that is the way it knows how to communicate.
- If FLOW is non-`nil', then Emacs uses XON/XOFF (`C-q', `C-s') flow
- control for output to the terminal. This has no effect except in
- CBREAK mode.
- The argument META controls support for input character codes above
- 127. If META is `t', Emacs converts characters with the 8th bit
- set into Meta characters. If META is `nil', Emacs disregards the
- 8th bit; this is necessary when the terminal uses it as a parity
- bit. If META is neither `t' nor `nil', Emacs uses all 8 bits of
- input unchanged. This is good for terminals that use 8-bit
- character sets.
- If QUIT-CHAR is non-`nil', it specifies the character to use for
- quitting. Normally this character is `C-g'. *Note Quitting::.
- The `current-input-mode' function returns the input mode settings
- Emacs is currently using.
- -- Function: current-input-mode
- This function returns the current mode for reading keyboard input.
- It returns a list, corresponding to the arguments of
- `set-input-mode', of the form `(INTERRUPT FLOW META QUIT)' in
- which:
- INTERRUPT
- is non-`nil' when Emacs is using interrupt-driven input. If
- `nil', Emacs is using CBREAK mode.
- FLOW
- is non-`nil' if Emacs uses XON/XOFF (`C-q', `C-s') flow
- control for output to the terminal. This value is meaningful
- only when INTERRUPT is `nil'.
- META
- is `t' if Emacs treats the eighth bit of input characters as
- the meta bit; `nil' means Emacs clears the eighth bit of every
- input character; any other value means Emacs uses all eight
- bits as the basic character code.
- QUIT
- is the character Emacs currently uses for quitting, usually
- `C-g'.
- File: elisp, Node: Recording Input, Prev: Input Modes, Up: Terminal Input
- 39.12.2 Recording Input
- -----------------------
- -- Function: recent-keys
- This function returns a vector containing the last 300 input
- events from the keyboard or mouse. All input events are included,
- whether or not they were used as parts of key sequences. Thus,
- you always get the last 100 input events, not counting events
- generated by keyboard macros. (These are excluded because they
- are less interesting for debugging; it should be enough to see the
- events that invoked the macros.)
- A call to `clear-this-command-keys' (*note Command Loop Info::)
- causes this function to return an empty vector immediately
- afterward.
- -- Command: open-dribble-file filename
- This function opens a "dribble file" named FILENAME. When a
- dribble file is open, each input event from the keyboard or mouse
- (but not those from keyboard macros) is written in that file. A
- non-character event is expressed using its printed representation
- surrounded by `<...>'.
- You close the dribble file by calling this function with an
- argument of `nil'.
- This function is normally used to record the input necessary to
- trigger an Emacs bug, for the sake of a bug report.
- (open-dribble-file "~/dribble")
- => nil
- See also the `open-termscript' function (*note Terminal Output::).
- File: elisp, Node: Terminal Output, Next: Sound Output, Prev: Terminal Input, Up: System Interface
- 39.13 Terminal Output
- =====================
- The terminal output functions send output to a text terminal, or keep
- track of output sent to the terminal. The variable `baud-rate' tells
- you what Emacs thinks is the output speed of the terminal.
- -- User Option: baud-rate
- This variable's value is the output speed of the terminal, as far
- as Emacs knows. Setting this variable does not change the speed
- of actual data transmission, but the value is used for
- calculations such as padding.
- It also affects decisions about whether to scroll part of the
- screen or repaint on text terminals. *Note Forcing Redisplay::,
- for the corresponding functionality on graphical terminals.
- The value is measured in baud.
- If you are running across a network, and different parts of the
- network work at different baud rates, the value returned by Emacs may be
- different from the value used by your local terminal. Some network
- protocols communicate the local terminal speed to the remote machine, so
- that Emacs and other programs can get the proper value, but others do
- not. If Emacs has the wrong value, it makes decisions that are less
- than optimal. To fix the problem, set `baud-rate'.
- -- Function: send-string-to-terminal string &optional terminal
- This function sends STRING to TERMINAL without alteration.
- Control characters in STRING have terminal-dependent effects.
- This function operates only on text terminals. TERMINAL may be a
- terminal object, a frame, or `nil' for the selected frame's
- terminal. In batch mode, STRING is sent to `stdout' when TERMINAL
- is `nil'.
- One use of this function is to define function keys on terminals
- that have downloadable function key definitions. For example,
- this is how (on certain terminals) to define function key 4 to
- move forward four characters (by transmitting the characters `C-u
- C-f' to the computer):
- (send-string-to-terminal "\eF4\^U\^F")
- => nil
- -- Command: open-termscript filename
- This function is used to open a "termscript file" that will record
- all the characters sent by Emacs to the terminal. It returns
- `nil'. Termscript files are useful for investigating problems
- where Emacs garbles the screen, problems that are due to incorrect
- Termcap entries or to undesirable settings of terminal options more
- often than to actual Emacs bugs. Once you are certain which
- characters were actually output, you can determine reliably
- whether they correspond to the Termcap specifications in use.
- You close the termscript file by calling this function with an
- argument of `nil'.
- See also `open-dribble-file' in *note Recording Input::.
- (open-termscript "../junk/termscript")
- => nil
- File: elisp, Node: Sound Output, Next: X11 Keysyms, Prev: Terminal Output, Up: System Interface
- 39.14 Sound Output
- ==================
- To play sound using Emacs, use the function `play-sound'. Only certain
- systems are supported; if you call `play-sound' on a system which
- cannot really do the job, it gives an error.
- The sound must be stored as a file in RIFF-WAVE format (`.wav') or
- Sun Audio format (`.au').
- -- Function: play-sound sound
- This function plays a specified sound. The argument, SOUND, has
- the form `(sound PROPERTIES...)', where the PROPERTIES consist of
- alternating keywords (particular symbols recognized specially) and
- values corresponding to them.
- Here is a table of the keywords that are currently meaningful in
- SOUND, and their meanings:
- `:file FILE'
- This specifies the file containing the sound to play. If the
- file name is not absolute, it is expanded against the
- directory `data-directory'.
- `:data DATA'
- This specifies the sound to play without need to refer to a
- file. The value, DATA, should be a string containing the
- same bytes as a sound file. We recommend using a unibyte
- string.
- `:volume VOLUME'
- This specifies how loud to play the sound. It should be a
- number in the range of 0 to 1. The default is to use
- whatever volume has been specified before.
- `:device DEVICE'
- This specifies the system device on which to play the sound,
- as a string. The default device is system-dependent.
- Before actually playing the sound, `play-sound' calls the
- functions in the list `play-sound-functions'. Each function is
- called with one argument, SOUND.
- -- Command: play-sound-file file &optional volume device
- This function is an alternative interface to playing a sound FILE
- specifying an optional VOLUME and DEVICE.
- -- Variable: play-sound-functions
- A list of functions to be called before playing a sound. Each
- function is called with one argument, a property list that
- describes the sound.
- File: elisp, Node: X11 Keysyms, Next: Batch Mode, Prev: Sound Output, Up: System Interface
- 39.15 Operating on X11 Keysyms
- ==============================
- To define system-specific X11 keysyms, set the variable
- `system-key-alist'.
- -- Variable: system-key-alist
- This variable's value should be an alist with one element for each
- system-specific keysym. Each element has the form `(CODE .
- SYMBOL)', where CODE is the numeric keysym code (not including the
- "vendor specific" bit, -2**28), and SYMBOL is the name for the
- function key.
- For example `(168 . mute-acute)' defines a system-specific key
- (used by HP X servers) whose numeric code is -2**28 + 168.
- It is not crucial to exclude from the alist the keysyms of other X
- servers; those do no harm, as long as they don't conflict with the
- ones used by the X server actually in use.
- The variable is always local to the current terminal, and cannot be
- buffer-local. *Note Multiple Terminals::.
- You can specify which keysyms Emacs should use for the Meta, Alt,
- Hyper, and Super modifiers by setting these variables:
- -- Variable: x-alt-keysym
- -- Variable: x-meta-keysym
- -- Variable: x-hyper-keysym
- -- Variable: x-super-keysym
- The name of the keysym that should stand for the Alt modifier
- (respectively, for Meta, Hyper, and Super). For example, here is
- how to swap the Meta and Alt modifiers within Emacs:
- (setq x-alt-keysym 'meta)
- (setq x-meta-keysym 'alt)
- File: elisp, Node: Batch Mode, Next: Session Management, Prev: X11 Keysyms, Up: System Interface
- 39.16 Batch Mode
- ================
- The command-line option `-batch' causes Emacs to run noninteractively.
- In this mode, Emacs does not read commands from the terminal, it does
- not alter the terminal modes, and it does not expect to be outputting
- to an erasable screen. The idea is that you specify Lisp programs to
- run; when they are finished, Emacs should exit. The way to specify the
- programs to run is with `-l FILE', which loads the library named FILE,
- or `-f FUNCTION', which calls FUNCTION with no arguments, or `--eval
- FORM'.
- Any Lisp program output that would normally go to the echo area,
- either using `message', or using `prin1', etc., with `t' as the stream,
- goes instead to Emacs's standard error descriptor when in batch mode.
- Similarly, input that would normally come from the minibuffer is read
- from the standard input descriptor. Thus, Emacs behaves much like a
- noninteractive application program. (The echo area output that Emacs
- itself normally generates, such as command echoing, is suppressed
- entirely.)
- -- Variable: noninteractive
- This variable is non-`nil' when Emacs is running in batch mode.
- File: elisp, Node: Session Management, Next: Notifications, Prev: Batch Mode, Up: System Interface
- 39.17 Session Management
- ========================
- Emacs supports the X Session Management Protocol, which is used to
- suspend and restart applications. In the X Window System, a program
- called the "session manager" is responsible for keeping track of the
- applications that are running. When the X server shuts down, the
- session manager asks applications to save their state, and delays the
- actual shutdown until they respond. An application can also cancel the
- shutdown.
- When the session manager restarts a suspended session, it directs
- these applications to individually reload their saved state. It does
- this by specifying a special command-line argument that says what saved
- session to restore. For Emacs, this argument is `--smid SESSION'.
- -- Variable: emacs-save-session-functions
- Emacs supports saving state via a hook called
- `emacs-save-session-functions'. Emacs runs this hook when the
- session manager tells it that the window system is shutting down.
- The functions are called with no arguments, and with the current
- buffer set to a temporary buffer. Each function can use `insert'
- to add Lisp code to this buffer. At the end, Emacs saves the
- buffer in a file, called the "session file".
- Subsequently, when the session manager restarts Emacs, it loads the
- session file automatically (*note Loading::). This is performed
- by a function named `emacs-session-restore', which is called during
- startup. *Note Startup Summary::.
- If a function in `emacs-save-session-functions' returns non-`nil',
- Emacs tells the session manager to cancel the shutdown.
- Here is an example that just inserts some text into `*scratch*' when
- Emacs is restarted by the session manager.
- (add-hook 'emacs-save-session-functions 'save-yourself-test)
- (defun save-yourself-test ()
- (insert "(save-current-buffer
- (switch-to-buffer \"*scratch*\")
- (insert \"I am restored\"))")
- nil)
- File: elisp, Node: Notifications, Next: Dynamic Libraries, Prev: Session Management, Up: System Interface
- 39.18 Desktop Notifications
- ===========================
- Emacs is able to send "notifications" on systems that support the
- freedesktop.org Desktop Notifications Specification. In order to use
- this functionality, Emacs must have been compiled with D-Bus support,
- and the `notifications' library must be loaded.
- -- Function: notifications-notify &rest params
- This function sends a notification to the desktop via D-Bus,
- consisting of the parameters specified by the PARAMS arguments.
- These arguments should consist of alternating keyword and value
- pairs. The supported keywords and values are as follows:
- `:title TITLE'
- The notification title.
- `:body TEXT'
- The notification body text. Depending on the implementation
- of the notification server, the text could contain HTML
- markups, like `"<b>bold text</b>"', or hyperlinks.
- `:app-name NAME'
- The name of the application sending the notification. The
- default is `notifications-application-name'.
- `:replaces-id ID'
- The notification ID that this notification replaces. ID must
- be the result of a previous `notifications-notify' call.
- `:app-icon ICON-FILE'
- The file name of the notification icon. If set to `nil', no
- icon is displayed. The default is
- `notifications-application-icon'.
- `:actions (KEY TITLE KEY TITLE ...)'
- A list of actions to be applied. KEY and TITLE are both
- strings. The default action (usually invoked by clicking the
- notification) should have a key named `"default"'. The title
- can be anything, though implementations are free not to
- display it.
- `:timeout TIMEOUT'
- The timeout time in milliseconds since the display of the
- notification at which the notification should automatically
- close. If -1, the notification's expiration time is
- dependent on the notification server's settings, and may vary
- for the type of notification. If 0, the notification never
- expires. Default value is -1.
- `:urgency URGENCY'
- The urgency level. It can be `low', `normal', or `critical'.
- `:category CATEGORY'
- The type of notification this is, a string.
- `:desktop-entry FILENAME'
- This specifies the name of the desktop filename representing
- the calling program, like `"emacs"'.
- `:image-data (WIDTH HEIGHT ROWSTRIDE HAS-ALPHA BITS CHANNELS DATA)'
- This is a raw data image format that describes the width,
- height, rowstride, whether there is an alpha channel, bits
- per sample, channels and image data, respectively.
- `:image-path PATH'
- This is represented either as a URI (`file://' is the only URI
- schema supported right now) or a name in a
- freedesktop.org-compliant icon theme from
- `$XDG_DATA_DIRS/icons'.
- `:sound-file FILENAME'
- The path to a sound file to play when the notification pops
- up.
- `:sound-name NAME'
- A themable named sound from the freedesktop.org sound naming
- specification from `$XDG_DATA_DIRS/sounds', to play when the
- notification pops up. Similar to the icon name, only for
- sounds. An example would be `"message-new-instant"'.
- `:suppress-sound'
- Causes the server to suppress playing any sounds, if it has
- that ability.
- `:x POSITION'
- `:y POSITION'
- Specifies the X, Y location on the screen that the
- notification should point to. Both arguments must be used
- together.
- `:on-action FUNCTION'
- Function to call when an action is invoked. The notification
- ID and the KEY of the action are passed as arguments to the
- function.
- `:on-close FUNCTION'
- Function to call when the notification has been closed by
- timeout or by the user. The function receive the
- notification ID and the closing REASON as arguments:
- * `expired' if the notification has expired
- * `dismissed' if the notification was dismissed by the user
- * `close-notification' if the notification was closed by a
- call to `notifications-close-notification'
- * `undefined' if the notification server hasn't provided a
- reason
- This function returns a notification id, an integer, which can be
- used to manipulate the notification item with
- `notifications-close-notification' or the `:replaces-id' argument
- of another `notifications-notify' call. For example:
- (defun my-on-action-function (id key)
- (message "Message %d, key \"%s\" pressed" id key))
- => my-on-action-function
- (defun my-on-close-function (id reason)
- (message "Message %d, closed due to \"%s\"" id reason))
- => my-on-close-function
- (notifications-notify
- :title "Title"
- :body "This is <b>important</b>."
- :actions '("Confirm" "I agree" "Refuse" "I disagree")
- :on-action 'my-on-action-function
- :on-close 'my-on-close-function)
- => 22
- A message window opens on the desktop. Press "I agree"
- => Message 22, key "Confirm" pressed
- Message 22, closed due to "dismissed"
- -- Function: notifications-close-notification id
- This function closes a notification with identifier ID.
- File: elisp, Node: Dynamic Libraries, Prev: Notifications, Up: System Interface
- 39.19 Dynamically Loaded Libraries
- ==================================
- A "dynamically loaded library" is a library that is loaded on demand,
- when its facilities are first needed. Emacs supports such on-demand
- loading of support libraries for some of its features.
- -- Variable: dynamic-library-alist
- This is an alist of dynamic libraries and external library files
- implementing them.
- Each element is a list of the form `(LIBRARY FILES...)', where the
- `car' is a symbol representing a supported external library, and
- the rest are strings giving alternate filenames for that library.
- Emacs tries to load the library from the files in the order they
- appear in the list; if none is found, the Emacs session won't have
- access to that library, and the features it provides will be
- unavailable.
- Image support on some platforms uses this facility. Here's an
- example of setting this variable for supporting images on
- MS-Windows:
- (setq dynamic-library-alist
- '((xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll")
- (png "libpng12d.dll" "libpng12.dll" "libpng.dll"
- "libpng13d.dll" "libpng13.dll")
- (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll"
- "jpeg.dll")
- (tiff "libtiff3.dll" "libtiff.dll")
- (gif "giflib4.dll" "libungif4.dll" "libungif.dll")
- (svg "librsvg-2-2.dll")
- (gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
- (glib "libglib-2.0-0.dll")
- (gobject "libgobject-2.0-0.dll")))
- Note that image types `pbm' and `xbm' do not need entries in this
- variable because they do not depend on external libraries and are
- always available in Emacs.
- Also note that this variable is not meant to be a generic facility
- for accessing external libraries; only those already known by
- Emacs can be loaded through it.
- This variable is ignored if the given LIBRARY is statically linked
- into Emacs.
- File: elisp, Node: Packaging, Next: Antinews, Prev: System Interface, Up: Top
- 40 Preparing Lisp code for distribution
- ***************************************
- Emacs provides a standard way to distribute Emacs Lisp code to users.
- A "package" is a collection of one or more files, formatted and bundled
- in such a way that users can easily download, install, uninstall, and
- upgrade it.
- The following sections describe how to create a package, and how to
- put it in a "package archive" for others to download. *Note Packages:
- (emacs)Packages, for a description of user-level features of the
- packaging system.
- * Menu:
- * Packaging Basics:: The basic concepts of Emacs Lisp packages.
- * Simple Packages:: How to package a single .el file.
- * Multi-file Packages:: How to package multiple files.
- * Package Archives:: Maintaining package archives.
- File: elisp, Node: Packaging Basics, Next: Simple Packages, Up: Packaging
- 40.1 Packaging Basics
- =====================
- A package is either a "simple package" or a "multi-file package". A
- simple package is stored in a package archive as a single Emacs Lisp
- file, while a multi-file package is stored as a tar file (containing
- multiple Lisp files, and possibly non-Lisp files such as a manual).
- In ordinary usage, the difference between simple packages and
- multi-file packages is relatively unimportant; the Package Menu
- interface makes no distinction between them. However, the procedure
- for creating them differs, as explained in the following sections.
- Each package (whether simple or multi-file) has certain "attributes":
- Name
- A short word (e.g. `auctex'). This is usually also the symbol
- prefix used in the program (*note Coding Conventions::).
- Version
- A version number, in a form that the function `version-to-list'
- understands (e.g. `11.86'). Each release of a package should be
- accompanied by an increase in the version number.
- Brief description
- This is shown when the package is listed in the Package Menu. It
- should occupy a single line, ideally in 36 characters or less.
- Long description
- This is shown in the buffer created by `C-h P'
- (`describe-package'), following the package's brief description
- and installation status. It normally spans multiple lines, and
- should fully describe the package's capabilities and how to begin
- using it once it is installed.
- Dependencies
- A list of other packages (possibly including minimal acceptable
- version numbers) on which this package depends. The list may be
- empty, meaning this package has no dependencies. Otherwise,
- installing this package also automatically installs its
- dependencies; if any dependency cannot be found, the package
- cannot be installed.
- Installing a package, either via the command `package-install-file',
- or via the Package Menu, creates a subdirectory of `package-user-dir'
- named `NAME-VERSION', where NAME is the package's name and VERSION its
- version (e.g. `~/.emacs.d/elpa/auctex-11.86/'). We call this the
- package's "content directory". It is where Emacs puts the package's
- contents (the single Lisp file for a simple package, or the files
- extracted from a multi-file package).
- Emacs then searches every Lisp file in the content directory for
- autoload magic comments (*note Autoload::). These autoload definitions
- are saved to a file named `NAME-autoloads.el' in the content directory.
- They are typically used to autoload the principal user commands defined
- in the package, but they can also perform other tasks, such as adding
- an element to `auto-mode-alist' (*note Auto Major Mode::). Note that a
- package typically does _not_ autoload every function and variable
- defined within it--only the handful of commands typically called to
- begin using the package. Emacs then byte-compiles every Lisp file in
- the package.
- After installation, the installed package is "loaded": Emacs adds
- the package's content directory to `load-path', and evaluates the
- autoload definitions in `NAME-autoloads.el'.
- Whenever Emacs starts up, it automatically calls the function
- `package-initialize' to load installed packages. This is done after
- loading the init file and abbrev file (if any) and before running
- `after-init-hook' (*note Startup Summary::). Automatic package loading
- is disabled if the user option `package-enable-at-startup' is `nil'.
- -- Command: package-initialize &optional no-activate
- This function initializes Emacs' internal record of which packages
- are installed, and loads them. The user option `package-load-list'
- specifies which packages to load; by default, all installed
- packages are loaded. *Note Package Installation: (emacs)Package
- Installation.
- The optional argument NO-ACTIVATE, if non-`nil', causes Emacs to
- update its record of installed packages without actually loading
- them; it is for internal use only.
- File: elisp, Node: Simple Packages, Next: Multi-file Packages, Prev: Packaging Basics, Up: Packaging
- 40.2 Simple Packages
- ====================
- A simple package consists of a single Emacs Lisp source file. The file
- must conform to the Emacs Lisp library header conventions (*note
- Library Headers::). The package's attributes are taken from the
- various headers, as illustrated by the following example:
- ;;; superfrobnicator.el --- Frobnicate and bifurcate flanges
- ;; Copyright (C) 2011 Free Software Foundation, Inc.
- ;; Author: J. R. Hacker <jrh@example.com>
- ;; Version: 1.3
- ;; Package-Requires: ((flange "1.0"))
- ;; Keywords: frobnicate
- ...
- ;;; Commentary:
- ;; This package provides a minor mode to frobnicate and/or
- ;; bifurcate any flanges you desire. To activate it, just type
- ...
- ;;;###autoload
- (define-minor-mode superfrobnicator-mode
- ...
- The name of the package is the same as the base name of the file, as
- written on the first line. Here, it is `superfrobnicator'.
- The brief description is also taken from the first line. Here, it
- is `Frobnicate and bifurcate flanges'.
- The version number comes from the `Package-Version' header, if it
- exists, or from the `Version' header otherwise. One or the other
- _must_ be present. Here, the version number is 1.3.
- If the file has a `;;; Commentary:' section, this section is used as
- the long description. (When displaying the description, Emacs omits
- the `;;; Commentary:' line, as well as the leading comment characters
- in the commentary itself.)
- If the file has a `Package-Requires' header, that is used as the
- package dependencies. In the above example, the package depends on the
- `flange' package, version 1.0 or higher. *Note Library Headers::, for
- a description of the `Package-Requires' header. If the header is
- omitted, the package has no dependencies.
- The file ought to also contain one or more autoload magic comments,
- as explained in *note Packaging Basics::. In the above example, a magic
- comment autoloads `superfrobnicator-mode'.
- *Note Package Archives::, for a explanation of how to add a
- single-file package to a package archive.
- File: elisp, Node: Multi-file Packages, Next: Package Archives, Prev: Simple Packages, Up: Packaging
- 40.3 Multi-file Packages
- ========================
- A multi-file package is less convenient to create than a single-file
- package, but it offers more features: it can include multiple Emacs
- Lisp files, an Info manual, and other file types (such as images).
- Prior to installation, a multi-file package is stored in a package
- archive as a tar file. The tar file must be named `NAME-VERSION.tar',
- where NAME is the package name and VERSION is the version number. Its
- contents, once extracted, must all appear in a directory named
- `NAME-VERSION', the "content directory" (*note Packaging Basics::).
- Files may also extract into subdirectories of the content directory.
- One of the files in the content directory must be named
- `NAME-pkg.el'. It must contain a single Lisp form, consisting of a
- call to the function `define-package', described below. This defines
- the package's version, brief description, and requirements.
- For example, if we distribute version 1.3 of the superfrobnicator as
- a multi-file package, the tar file would be `superfrobnicator-1.3.tar'.
- Its contents would extract into the directory `superfrobnicator-1.3',
- and one of these would be the file `superfrobnicator-pkg.el'.
- -- Function: define-package name version &optional docstring
- requirements
- This function defines a package. NAME is the package name, a
- string. VERSION is the version, as a string of a form that can be
- understood by the function `version-to-list'. DOCSTRING is the
- brief description.
- REQUIREMENTS is a list of required packages and their versions.
- Each element in this list should have the form `(DEP-NAME
- DEP-VERSION)', where DEP-NAME is a symbol whose name is the
- dependency's package name, and DEP-VERSION is the dependency's
- version (a string).
- If the content directory contains a file named `README', this file
- is used as the long description.
- If the content directory contains a file named `dir', this is
- assumed to be an Info directory file made with `install-info'. *Note
- Invoking install-info: (texinfo)Invoking install-info. The relevant
- Info files should also be present in the content directory. In this
- case, Emacs will automatically add the content directory to
- `Info-directory-list' when the package is activated.
- Do not include any `.elc' files in the package. Those are created
- when the package is installed. Note that there is no way to control
- the order in which files are byte-compiled.
- Do not include any file named `NAME-autoloads.el'. This file is
- reserved for the package's autoload definitions (*note Packaging
- Basics::). It is created automatically when the package is installed,
- by searching all the Lisp files in the package for autoload magic
- comments.
- If the multi-file package contains auxiliary data files (such as
- images), the package's Lisp code can refer to these files via the
- variable `load-file-name' (*note Loading::). Here is an example:
- (defconst superfrobnicator-base (file-name-directory load-file-name))
- (defun superfrobnicator-fetch-image (file)
- (expand-file-name file superfrobnicator-base))
- File: elisp, Node: Package Archives, Prev: Multi-file Packages, Up: Packaging
- 40.4 Creating and Maintaining Package Archives
- ==============================================
- Via the Package Menu, users may download packages from "package
- archives". Such archives are specified by the variable
- `package-archives', whose default value contains a single entry: the
- archive hosted by the GNU project at `elpa.gnu.org'. This section
- describes how to set up and maintain a package archive.
- -- User Option: package-archives
- The value of this variable is an alist of package archives
- recognized by the Emacs package manager.
- Each alist element corresponds to one archive, and should have the
- form `(ID . LOCATION)', where ID is the name of the archive (a
- string) and LOCATION is its "base location" (a string).
- If the base location starts with `http:', it is treated as a HTTP
- URL, and packages are downloaded from this archive via HTTP (as is
- the case for the default GNU archive).
- Otherwise, the base location should be a directory name. In this
- case, Emacs retrieves packages from this archive via ordinary file
- access. Such "local" archives are mainly useful for testing.
- A package archive is simply a directory in which the package files,
- and associated files, are stored. If you want the archive to be
- reachable via HTTP, this directory must be accessible to a web server.
- How to accomplish this is beyond the scope of this manual.
- A convenient way to set up and update a package archive is via the
- `package-x' library. This is included with Emacs, but not loaded by
- default; type `M-x load-library <RET> package-x <RET>' to load it, or
- add `(require 'package-x)' to your init file. *Note Lisp Libraries:
- (emacs)Lisp Libraries. Once loaded, you can make use of the following:
- -- User Option: package-archive-upload-base
- The value of this variable is the base location of a package
- archive, as a directory name. The commands in the `package-x'
- library will use this base location.
- The directory name should be absolute. You may specify a remote
- name, such as `/ssh:foo@example.com:/var/www/packages/', if the
- package archive is on a different machine. *Note Remote Files:
- (emacs)Remote Files.
- -- Command: package-upload-file filename
- This command prompts for FILENAME, a file name, and uploads that
- file to `package-archive-upload-base'. The file must be either a
- simple package (a `.el' file) or a multi-file package (a `.tar'
- file); otherwise, an error is raised. The package attributes are
- automatically extracted, and the archive's contents list is
- updated with this information.
- If `package-archive-upload-base' does not specify a valid
- directory, the function prompts interactively for one. If the
- directory does not exist, it is created. The directory need not
- have any initial contents (i.e., you can use this command to
- populate an initially empty archive).
- -- Command: package-upload-buffer
- This command is similar to `package-upload-file', but instead of
- prompting for a package file, it uploads the contents of the
- current buffer. The current buffer must be visiting a simple
- package (a `.el' file) or a multi-file package (a `.tar' file);
- otherwise, an error is raised.
- After you create an archive, remember that it is not accessible in the
- Package Menu interface unless it is in `package-archives'.
- File: elisp, Node: Antinews, Next: GNU Free Documentation License, Prev: Packaging, Up: Top
- Appendix A Emacs 23 Antinews
- ****************************
- For those users who live backwards in time, here is information about
- downgrading to Emacs version 23.4. We hope you will enjoy the greater
- simplicity that results from the absence of many Emacs 24.2 features.
- A.1 Old Lisp Features in Emacs 23
- =================================
- * Support for lexical scoping has been removed; all variables are
- dynamically scoped. The `lexical-binding' variable has been
- removed, and so has the LEXICAL argument to `eval'. The `defvar'
- and `defconst' forms no longer mark variables as dynamic, since
- all variables are dynamic.
- Having only dynamic binding follows the spirit of Emacs
- extensibility, for it allows any Emacs code to access any defined
- variable with a minimum of fuss. But *Note Dynamic Binding
- Tips::, for tips to avoid making your programs hard to understand.
- * Calling a minor mode function from Lisp with a nil or omitted
- argument does not enable the minor mode unconditionally; instead,
- it toggles the minor mode--which is the straightforward thing to
- do, since that is the behavior when invoked interactively. One
- downside is that it is more troublesome to enable minor modes from
- hooks; you have to do something like
- (add-hook 'foo-hook (lambda () (bar-mode 1)))
- or define `turn-on-bar-mode' and call that from the hook.
- * The `prog-mode' dummy major mode has been removed. Instead of
- using it as a crutch to meet programming mode conventions, you
- should explicitly ensure that your mode follows those conventions.
- *Note Major Mode Conventions::.
- * Emacs no longer supports bidirectional display and editing. Since
- there is no need to worry about the insertion of right-to-left text
- messing up how lines and paragraphs are displayed, the function
- `bidi-string-mark-left-to-right' has been removed; so have many
- other functions and variables related to bidirectional display.
- Unicode directionality characters like `U+200E' ("left-to-right
- mark") have no special effect on display.
- * Emacs windows now have most of their internal state hidden from
- Lisp. Internal windows are no longer visible to Lisp; functions
- such as `window-parent', window parameters related to window
- arrangement, and window-local buffer lists have all been removed.
- Functions for resizing windows can delete windows if they become
- too small.
- The "action function" feature for controlling buffer display has
- been removed, including `display-buffer-overriding-action' and
- related variables, as well as the ACTION argument to
- `display-buffer' and other functions. The way to programmatically
- control how Emacs chooses a window to display a buffer is to bind
- the right combination of `special-display-regexps',
- `pop-up-frames', and other variables.
- * The standard completion interface has been simplified, eliminating
- the `completion-extra-properties' variable, the `metadata' action
- flag for completion functions, and the concept of "completion
- categories". Lisp programmers may now find the choice of methods
- for tuning completion less bewildering, but if a package finds the
- streamlined interface insufficient for its needs, it must
- implement its own specialized completion feature.
- * `copy-directory' now behaves the same whether or not the
- destination is an existing directory: if the destination exists,
- the _contents_ of the first directory are copied into it (with
- subdirectories handled recursively), rather than copying the first
- directory into a subdirectory.
- * The TRASH arguments for `delete-file' and `delete-directory' have
- been removed. The variable `delete-by-moving-to-trash' must now
- be used with care; whenever it is non-`nil', all calls to
- `delete-file' or `delete-directory' use the trash.
- * Because Emacs no longer supports SELinux file contexts, the
- PRESERVE-SELINUX-CONTEXT argument to `copy-file' has been removed.
- The return value of `backup-buffer' no longer has an entry for the
- SELinux file context.
- * For mouse click input events in the text area, the Y pixel
- coordinate in the POSITION list (*note Click Events::) now counts
- from the top of the header line, if there is one, rather than the
- top of the text area.
- * Bindings in menu keymaps (*note Format of Keymaps::) now sometimes
- get an additional CACHE entry in their definitions, like this:
- (TYPE ITEM-NAME CACHE . BINDING)
- The CACHE entry is used internally by Emacs to record equivalent
- keyboard key sequences for invoking the same command; Lisp programs
- should never use it.
- * The `gnutls' library has been removed, and the function
- `open-network-stream' correspondingly simplified. Lisp programs
- that want an encrypted network connection must now call external
- utilities such as `starttls' or `gnutls-cli'.
- * Tool bars can no longer display separators, which frees up several
- pixels of space on each graphical frame.
- * As part of the ongoing quest for simplicity, many other functions
- and variables have been eliminated.
- File: elisp, Node: GNU Free Documentation License, Next: GPL, Prev: Antinews, Up: Top
- Appendix B GNU Free Documentation License
- *****************************************
- Version 1.3, 3 November 2008
- Copyright (C) 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
- `http://fsf.org/'
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
- 0. PREAMBLE
- The purpose of this License is to make a manual, textbook, or other
- functional and useful document "free" in the sense of freedom: to
- assure everyone the effective freedom to copy and redistribute it,
- with or without modifying it, either commercially or
- noncommercially. Secondarily, this License preserves for the
- author and publisher a way to get credit for their work, while not
- being considered responsible for modifications made by others.
- This License is a kind of "copyleft", which means that derivative
- works of the document must themselves be free in the same sense.
- It complements the GNU General Public License, which is a copyleft
- license designed for free software.
- We have designed this License in order to use it for manuals for
- free software, because free software needs free documentation: a
- free program should come with manuals providing the same freedoms
- that the software does. But this License is not limited to
- software manuals; it can be used for any textual work, regardless
- of subject matter or whether it is published as a printed book.
- We recommend this License principally for works whose purpose is
- instruction or reference.
- 1. APPLICABILITY AND DEFINITIONS
- This License applies to any manual or other work, in any medium,
- that contains a notice placed by the copyright holder saying it
- can be distributed under the terms of this License. Such a notice
- grants a world-wide, royalty-free license, unlimited in duration,
- to use that work under the conditions stated herein. The
- "Document", below, refers to any such manual or work. Any member
- of the public is a licensee, and is addressed as "you". You
- accept the license if you copy, modify or distribute the work in a
- way requiring permission under copyright law.
- A "Modified Version" of the Document means any work containing the
- Document or a portion of it, either copied verbatim, or with
- modifications and/or translated into another language.
- A "Secondary Section" is a named appendix or a front-matter section
- of the Document that deals exclusively with the relationship of the
- publishers or authors of the Document to the Document's overall
- subject (or to related matters) and contains nothing that could
- fall directly within that overall subject. (Thus, if the Document
- is in part a textbook of mathematics, a Secondary Section may not
- explain any mathematics.) The relationship could be a matter of
- historical connection with the subject or with related matters, or
- of legal, commercial, philosophical, ethical or political position
- regarding them.
- The "Invariant Sections" are certain Secondary Sections whose
- titles are designated, as being those of Invariant Sections, in
- the notice that says that the Document is released under this
- License. If a section does not fit the above definition of
- Secondary then it is not allowed to be designated as Invariant.
- The Document may contain zero Invariant Sections. If the Document
- does not identify any Invariant Sections then there are none.
- The "Cover Texts" are certain short passages of text that are
- listed, as Front-Cover Texts or Back-Cover Texts, in the notice
- that says that the Document is released under this License. A
- Front-Cover Text may be at most 5 words, and a Back-Cover Text may
- be at most 25 words.
- A "Transparent" copy of the Document means a machine-readable copy,
- represented in a format whose specification is available to the
- general public, that is suitable for revising the document
- straightforwardly with generic text editors or (for images
- composed of pixels) generic paint programs or (for drawings) some
- widely available drawing editor, and that is suitable for input to
- text formatters or for automatic translation to a variety of
- formats suitable for input to text formatters. A copy made in an
- otherwise Transparent file format whose markup, or absence of
- markup, has been arranged to thwart or discourage subsequent
- modification by readers is not Transparent. An image format is
- not Transparent if used for any substantial amount of text. A
- copy that is not "Transparent" is called "Opaque".
- Examples of suitable formats for Transparent copies include plain
- ASCII without markup, Texinfo input format, LaTeX input format,
- SGML or XML using a publicly available DTD, and
- standard-conforming simple HTML, PostScript or PDF designed for
- human modification. Examples of transparent image formats include
- PNG, XCF and JPG. Opaque formats include proprietary formats that
- can be read and edited only by proprietary word processors, SGML or
- XML for which the DTD and/or processing tools are not generally
- available, and the machine-generated HTML, PostScript or PDF
- produced by some word processors for output purposes only.
- The "Title Page" means, for a printed book, the title page itself,
- plus such following pages as are needed to hold, legibly, the
- material this License requires to appear in the title page. For
- works in formats which do not have any title page as such, "Title
- Page" means the text near the most prominent appearance of the
- work's title, preceding the beginning of the body of the text.
- The "publisher" means any person or entity that distributes copies
- of the Document to the public.
- A section "Entitled XYZ" means a named subunit of the Document
- whose title either is precisely XYZ or contains XYZ in parentheses
- following text that translates XYZ in another language. (Here XYZ
- stands for a specific section name mentioned below, such as
- "Acknowledgements", "Dedications", "Endorsements", or "History".)
- To "Preserve the Title" of such a section when you modify the
- Document means that it remains a section "Entitled XYZ" according
- to this definition.
- The Document may include Warranty Disclaimers next to the notice
- which states that this License applies to the Document. These
- Warranty Disclaimers are considered to be included by reference in
- this License, but only as regards disclaiming warranties: any other
- implication that these Warranty Disclaimers may have is void and
- has no effect on the meaning of this License.
- 2. VERBATIM COPYING
- You may copy and distribute the Document in any medium, either
- commercially or noncommercially, provided that this License, the
- copyright notices, and the license notice saying this License
- applies to the Document are reproduced in all copies, and that you
- add no other conditions whatsoever to those of this License. You
- may not use technical measures to obstruct or control the reading
- or further copying of the copies you make or distribute. However,
- you may accept compensation in exchange for copies. If you
- distribute a large enough number of copies you must also follow
- the conditions in section 3.
- You may also lend copies, under the same conditions stated above,
- and you may publicly display copies.
- 3. COPYING IN QUANTITY
- If you publish printed copies (or copies in media that commonly
- have printed covers) of the Document, numbering more than 100, and
- the Document's license notice requires Cover Texts, you must
- enclose the copies in covers that carry, clearly and legibly, all
- these Cover Texts: Front-Cover Texts on the front cover, and
- Back-Cover Texts on the back cover. Both covers must also clearly
- and legibly identify you as the publisher of these copies. The
- front cover must present the full title with all words of the
- title equally prominent and visible. You may add other material
- on the covers in addition. Copying with changes limited to the
- covers, as long as they preserve the title of the Document and
- satisfy these conditions, can be treated as verbatim copying in
- other respects.
- If the required texts for either cover are too voluminous to fit
- legibly, you should put the first ones listed (as many as fit
- reasonably) on the actual cover, and continue the rest onto
- adjacent pages.
- If you publish or distribute Opaque copies of the Document
- numbering more than 100, you must either include a
- machine-readable Transparent copy along with each Opaque copy, or
- state in or with each Opaque copy a computer-network location from
- which the general network-using public has access to download
- using public-standard network protocols a complete Transparent
- copy of the Document, free of added material. If you use the
- latter option, you must take reasonably prudent steps, when you
- begin distribution of Opaque copies in quantity, to ensure that
- this Transparent copy will remain thus accessible at the stated
- location until at least one year after the last time you
- distribute an Opaque copy (directly or through your agents or
- retailers) of that edition to the public.
- It is requested, but not required, that you contact the authors of
- the Document well before redistributing any large number of
- copies, to give them a chance to provide you with an updated
- version of the Document.
- 4. MODIFICATIONS
- You may copy and distribute a Modified Version of the Document
- under the conditions of sections 2 and 3 above, provided that you
- release the Modified Version under precisely this License, with
- the Modified Version filling the role of the Document, thus
- licensing distribution and modification of the Modified Version to
- whoever possesses a copy of it. In addition, you must do these
- things in the Modified Version:
- A. Use in the Title Page (and on the covers, if any) a title
- distinct from that of the Document, and from those of
- previous versions (which should, if there were any, be listed
- in the History section of the Document). You may use the
- same title as a previous version if the original publisher of
- that version gives permission.
- B. List on the Title Page, as authors, one or more persons or
- entities responsible for authorship of the modifications in
- the Modified Version, together with at least five of the
- principal authors of the Document (all of its principal
- authors, if it has fewer than five), unless they release you
- from this requirement.
- C. State on the Title page the name of the publisher of the
- Modified Version, as the publisher.
- D. Preserve all the copyright notices of the Document.
- E. Add an appropriate copyright notice for your modifications
- adjacent to the other copyright notices.
- F. Include, immediately after the copyright notices, a license
- notice giving the public permission to use the Modified
- Version under the terms of this License, in the form shown in
- the Addendum below.
- G. Preserve in that license notice the full lists of Invariant
- Sections and required Cover Texts given in the Document's
- license notice.
- H. Include an unaltered copy of this License.
- I. Preserve the section Entitled "History", Preserve its Title,
- and add to it an item stating at least the title, year, new
- authors, and publisher of the Modified Version as given on
- the Title Page. If there is no section Entitled "History" in
- the Document, create one stating the title, year, authors,
- and publisher of the Document as given on its Title Page,
- then add an item describing the Modified Version as stated in
- the previous sentence.
- J. Preserve the network location, if any, given in the Document
- for public access to a Transparent copy of the Document, and
- likewise the network locations given in the Document for
- previous versions it was based on. These may be placed in
- the "History" section. You may omit a network location for a
- work that was published at least four years before the
- Document itself, or if the original publisher of the version
- it refers to gives permission.
- K. For any section Entitled "Acknowledgements" or "Dedications",
- Preserve the Title of the section, and preserve in the
- section all the substance and tone of each of the contributor
- acknowledgements and/or dedications given therein.
- L. Preserve all the Invariant Sections of the Document,
- unaltered in their text and in their titles. Section numbers
- or the equivalent are not considered part of the section
- titles.
- M. Delete any section Entitled "Endorsements". Such a section
- may not be included in the Modified Version.
- N. Do not retitle any existing section to be Entitled
- "Endorsements" or to conflict in title with any Invariant
- Section.
- O. Preserve any Warranty Disclaimers.
- If the Modified Version includes new front-matter sections or
- appendices that qualify as Secondary Sections and contain no
- material copied from the Document, you may at your option
- designate some or all of these sections as invariant. To do this,
- add their titles to the list of Invariant Sections in the Modified
- Version's license notice. These titles must be distinct from any
- other section titles.
- You may add a section Entitled "Endorsements", provided it contains
- nothing but endorsements of your Modified Version by various
- parties--for example, statements of peer review or that the text
- has been approved by an organization as the authoritative
- definition of a standard.
- You may add a passage of up to five words as a Front-Cover Text,
- and a passage of up to 25 words as a Back-Cover Text, to the end
- of the list of Cover Texts in the Modified Version. Only one
- passage of Front-Cover Text and one of Back-Cover Text may be
- added by (or through arrangements made by) any one entity. If the
- Document already includes a cover text for the same cover,
- previously added by you or by arrangement made by the same entity
- you are acting on behalf of, you may not add another; but you may
- replace the old one, on explicit permission from the previous
- publisher that added the old one.
- The author(s) and publisher(s) of the Document do not by this
- License give permission to use their names for publicity for or to
- assert or imply endorsement of any Modified Version.
- 5. COMBINING DOCUMENTS
- You may combine the Document with other documents released under
- this License, under the terms defined in section 4 above for
- modified versions, provided that you include in the combination
- all of the Invariant Sections of all of the original documents,
- unmodified, and list them all as Invariant Sections of your
- combined work in its license notice, and that you preserve all
- their Warranty Disclaimers.
- The combined work need only contain one copy of this License, and
- multiple identical Invariant Sections may be replaced with a single
- copy. If there are multiple Invariant Sections with the same name
- but different contents, make the title of each such section unique
- by adding at the end of it, in parentheses, the name of the
- original author or publisher of that section if known, or else a
- unique number. Make the same adjustment to the section titles in
- the list of Invariant Sections in the license notice of the
- combined work.
- In the combination, you must combine any sections Entitled
- "History" in the various original documents, forming one section
- Entitled "History"; likewise combine any sections Entitled
- "Acknowledgements", and any sections Entitled "Dedications". You
- must delete all sections Entitled "Endorsements."
- 6. COLLECTIONS OF DOCUMENTS
- You may make a collection consisting of the Document and other
- documents released under this License, and replace the individual
- copies of this License in the various documents with a single copy
- that is included in the collection, provided that you follow the
- rules of this License for verbatim copying of each of the
- documents in all other respects.
- You may extract a single document from such a collection, and
- distribute it individually under this License, provided you insert
- a copy of this License into the extracted document, and follow
- this License in all other respects regarding verbatim copying of
- that document.
- 7. AGGREGATION WITH INDEPENDENT WORKS
- A compilation of the Document or its derivatives with other
- separate and independent documents or works, in or on a volume of
- a storage or distribution medium, is called an "aggregate" if the
- copyright resulting from the compilation is not used to limit the
- legal rights of the compilation's users beyond what the individual
- works permit. When the Document is included in an aggregate, this
- License does not apply to the other works in the aggregate which
- are not themselves derivative works of the Document.
- If the Cover Text requirement of section 3 is applicable to these
- copies of the Document, then if the Document is less than one half
- of the entire aggregate, the Document's Cover Texts may be placed
- on covers that bracket the Document within the aggregate, or the
- electronic equivalent of covers if the Document is in electronic
- form. Otherwise they must appear on printed covers that bracket
- the whole aggregate.
- 8. TRANSLATION
- Translation is considered a kind of modification, so you may
- distribute translations of the Document under the terms of section
- 4. Replacing Invariant Sections with translations requires special
- permission from their copyright holders, but you may include
- translations of some or all Invariant Sections in addition to the
- original versions of these Invariant Sections. You may include a
- translation of this License, and all the license notices in the
- Document, and any Warranty Disclaimers, provided that you also
- include the original English version of this License and the
- original versions of those notices and disclaimers. In case of a
- disagreement between the translation and the original version of
- this License or a notice or disclaimer, the original version will
- prevail.
- If a section in the Document is Entitled "Acknowledgements",
- "Dedications", or "History", the requirement (section 4) to
- Preserve its Title (section 1) will typically require changing the
- actual title.
- 9. TERMINATION
- You may not copy, modify, sublicense, or distribute the Document
- except as expressly provided under this License. Any attempt
- otherwise to copy, modify, sublicense, or distribute it is void,
- and will automatically terminate your rights under this License.
- However, if you cease all violation of this License, then your
- license from a particular copyright holder is reinstated (a)
- provisionally, unless and until the copyright holder explicitly
- and finally terminates your license, and (b) permanently, if the
- copyright holder fails to notify you of the violation by some
- reasonable means prior to 60 days after the cessation.
- Moreover, your license from a particular copyright holder is
- reinstated permanently if the copyright holder notifies you of the
- violation by some reasonable means, this is the first time you have
- received notice of violation of this License (for any work) from
- that copyright holder, and you cure the violation prior to 30 days
- after your receipt of the notice.
- Termination of your rights under this section does not terminate
- the licenses of parties who have received copies or rights from
- you under this License. If your rights have been terminated and
- not permanently reinstated, receipt of a copy of some or all of
- the same material does not give you any rights to use it.
- 10. FUTURE REVISIONS OF THIS LICENSE
- The Free Software Foundation may publish new, revised versions of
- the GNU Free Documentation License from time to time. Such new
- versions will be similar in spirit to the present version, but may
- differ in detail to address new problems or concerns. See
- `http://www.gnu.org/copyleft/'.
- Each version of the License is given a distinguishing version
- number. If the Document specifies that a particular numbered
- version of this License "or any later version" applies to it, you
- have the option of following the terms and conditions either of
- that specified version or of any later version that has been
- published (not as a draft) by the Free Software Foundation. If
- the Document does not specify a version number of this License,
- you may choose any version ever published (not as a draft) by the
- Free Software Foundation. If the Document specifies that a proxy
- can decide which future versions of this License can be used, that
- proxy's public statement of acceptance of a version permanently
- authorizes you to choose that version for the Document.
- 11. RELICENSING
- "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
- World Wide Web server that publishes copyrightable works and also
- provides prominent facilities for anybody to edit those works. A
- public wiki that anybody can edit is an example of such a server.
- A "Massive Multiauthor Collaboration" (or "MMC") contained in the
- site means any set of copyrightable works thus published on the MMC
- site.
- "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
- license published by Creative Commons Corporation, a not-for-profit
- corporation with a principal place of business in San Francisco,
- California, as well as future copyleft versions of that license
- published by that same organization.
- "Incorporate" means to publish or republish a Document, in whole or
- in part, as part of another Document.
- An MMC is "eligible for relicensing" if it is licensed under this
- License, and if all works that were first published under this
- License somewhere other than this MMC, and subsequently
- incorporated in whole or in part into the MMC, (1) had no cover
- texts or invariant sections, and (2) were thus incorporated prior
- to November 1, 2008.
- The operator of an MMC Site may republish an MMC contained in the
- site under CC-BY-SA on the same site at any time before August 1,
- 2009, provided the MMC is eligible for relicensing.
- ADDENDUM: How to use this License for your documents
- ====================================================
- To use this License in a document you have written, include a copy of
- the License in the document and put the following copyright and license
- notices just after the title page:
- Copyright (C) YEAR YOUR NAME.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
- Texts. A copy of the license is included in the section entitled ``GNU
- Free Documentation License''.
- If you have Invariant Sections, Front-Cover Texts and Back-Cover
- Texts, replace the "with...Texts." line with this:
- with the Invariant Sections being LIST THEIR TITLES, with
- the Front-Cover Texts being LIST, and with the Back-Cover Texts
- being LIST.
- If you have Invariant Sections without Cover Texts, or some other
- combination of the three, merge those two alternatives to suit the
- situation.
- If your document contains nontrivial examples of program code, we
- recommend releasing these examples in parallel under your choice of
- free software license, such as the GNU General Public License, to
- permit their use in free software.
- File: elisp, Node: GPL, Next: Tips, Prev: GNU Free Documentation License, Up: Top
- Appendix C GNU General Public License
- *************************************
- Version 3, 29 June 2007
- Copyright (C) 2007 Free Software Foundation, Inc. `http://fsf.org/'
- Everyone is permitted to copy and distribute verbatim copies of this
- license document, but changing it is not allowed.
- Preamble
- ========
- The GNU General Public License is a free, copyleft license for software
- and other kinds of works.
- The licenses for most software and other practical works are designed
- to take away your freedom to share and change the works. By contrast,
- the GNU General Public License is intended to guarantee your freedom to
- share and change all versions of a program--to make sure it remains
- free software for all its users. We, the Free Software Foundation, use
- the GNU General Public License for most of our software; it applies
- also to any other work released this way by its authors. You can apply
- it to your programs, too.
- When we speak of free software, we are referring to freedom, not
- price. Our General Public Licenses are designed to make sure that you
- have the freedom to distribute copies of free software (and charge for
- them if you wish), that you receive source code or can get it if you
- want it, that you can change the software or use pieces of it in new
- free programs, and that you know you can do these things.
- To protect your rights, we need to prevent others from denying you
- these rights or asking you to surrender the rights. Therefore, you
- have certain responsibilities if you distribute copies of the software,
- or if you modify it: responsibilities to respect the freedom of others.
- For example, if you distribute copies of such a program, whether
- gratis or for a fee, you must pass on to the recipients the same
- freedoms that you received. You must make sure that they, too, receive
- or can get the source code. And you must show them these terms so they
- know their rights.
- Developers that use the GNU GPL protect your rights with two steps:
- (1) assert copyright on the software, and (2) offer you this License
- giving you legal permission to copy, distribute and/or modify it.
- For the developers' and authors' protection, the GPL clearly explains
- that there is no warranty for this free software. For both users' and
- authors' sake, the GPL requires that modified versions be marked as
- changed, so that their problems will not be attributed erroneously to
- authors of previous versions.
- Some devices are designed to deny users access to install or run
- modified versions of the software inside them, although the
- manufacturer can do so. This is fundamentally incompatible with the
- aim of protecting users' freedom to change the software. The
- systematic pattern of such abuse occurs in the area of products for
- individuals to use, which is precisely where it is most unacceptable.
- Therefore, we have designed this version of the GPL to prohibit the
- practice for those products. If such problems arise substantially in
- other domains, we stand ready to extend this provision to those domains
- in future versions of the GPL, as needed to protect the freedom of
- users.
- Finally, every program is threatened constantly by software patents.
- States should not allow patents to restrict development and use of
- software on general-purpose computers, but in those that do, we wish to
- avoid the special danger that patents applied to a free program could
- make it effectively proprietary. To prevent this, the GPL assures that
- patents cannot be used to render the program non-free.
- The precise terms and conditions for copying, distribution and
- modification follow.
- TERMS AND CONDITIONS
- ====================
- 0. Definitions.
- "This License" refers to version 3 of the GNU General Public
- License.
- "Copyright" also means copyright-like laws that apply to other
- kinds of works, such as semiconductor masks.
- "The Program" refers to any copyrightable work licensed under this
- License. Each licensee is addressed as "you". "Licensees" and
- "recipients" may be individuals or organizations.
- To "modify" a work means to copy from or adapt all or part of the
- work in a fashion requiring copyright permission, other than the
- making of an exact copy. The resulting work is called a "modified
- version" of the earlier work or a work "based on" the earlier work.
- A "covered work" means either the unmodified Program or a work
- based on the Program.
- To "propagate" a work means to do anything with it that, without
- permission, would make you directly or secondarily liable for
- infringement under applicable copyright law, except executing it
- on a computer or modifying a private copy. Propagation includes
- copying, distribution (with or without modification), making
- available to the public, and in some countries other activities as
- well.
- To "convey" a work means any kind of propagation that enables other
- parties to make or receive copies. Mere interaction with a user
- through a computer network, with no transfer of a copy, is not
- conveying.
- An interactive user interface displays "Appropriate Legal Notices"
- to the extent that it includes a convenient and prominently visible
- feature that (1) displays an appropriate copyright notice, and (2)
- tells the user that there is no warranty for the work (except to
- the extent that warranties are provided), that licensees may
- convey the work under this License, and how to view a copy of this
- License. If the interface presents a list of user commands or
- options, such as a menu, a prominent item in the list meets this
- criterion.
- 1. Source Code.
- The "source code" for a work means the preferred form of the work
- for making modifications to it. "Object code" means any
- non-source form of a work.
- A "Standard Interface" means an interface that either is an
- official standard defined by a recognized standards body, or, in
- the case of interfaces specified for a particular programming
- language, one that is widely used among developers working in that
- language.
- The "System Libraries" of an executable work include anything,
- other than the work as a whole, that (a) is included in the normal
- form of packaging a Major Component, but which is not part of that
- Major Component, and (b) serves only to enable use of the work
- with that Major Component, or to implement a Standard Interface
- for which an implementation is available to the public in source
- code form. A "Major Component", in this context, means a major
- essential component (kernel, window system, and so on) of the
- specific operating system (if any) on which the executable work
- runs, or a compiler used to produce the work, or an object code
- interpreter used to run it.
- The "Corresponding Source" for a work in object code form means all
- the source code needed to generate, install, and (for an executable
- work) run the object code and to modify the work, including
- scripts to control those activities. However, it does not include
- the work's System Libraries, or general-purpose tools or generally
- available free programs which are used unmodified in performing
- those activities but which are not part of the work. For example,
- Corresponding Source includes interface definition files
- associated with source files for the work, and the source code for
- shared libraries and dynamically linked subprograms that the work
- is specifically designed to require, such as by intimate data
- communication or control flow between those subprograms and other
- parts of the work.
- The Corresponding Source need not include anything that users can
- regenerate automatically from other parts of the Corresponding
- Source.
- The Corresponding Source for a work in source code form is that
- same work.
- 2. Basic Permissions.
- All rights granted under this License are granted for the term of
- copyright on the Program, and are irrevocable provided the stated
- conditions are met. This License explicitly affirms your unlimited
- permission to run the unmodified Program. The output from running
- a covered work is covered by this License only if the output,
- given its content, constitutes a covered work. This License
- acknowledges your rights of fair use or other equivalent, as
- provided by copyright law.
- You may make, run and propagate covered works that you do not
- convey, without conditions so long as your license otherwise
- remains in force. You may convey covered works to others for the
- sole purpose of having them make modifications exclusively for
- you, or provide you with facilities for running those works,
- provided that you comply with the terms of this License in
- conveying all material for which you do not control copyright.
- Those thus making or running the covered works for you must do so
- exclusively on your behalf, under your direction and control, on
- terms that prohibit them from making any copies of your
- copyrighted material outside their relationship with you.
- Conveying under any other circumstances is permitted solely under
- the conditions stated below. Sublicensing is not allowed; section
- 10 makes it unnecessary.
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
- No covered work shall be deemed part of an effective technological
- measure under any applicable law fulfilling obligations under
- article 11 of the WIPO copyright treaty adopted on 20 December
- 1996, or similar laws prohibiting or restricting circumvention of
- such measures.
- When you convey a covered work, you waive any legal power to forbid
- circumvention of technological measures to the extent such
- circumvention is effected by exercising rights under this License
- with respect to the covered work, and you disclaim any intention
- to limit operation or modification of the work as a means of
- enforcing, against the work's users, your or third parties' legal
- rights to forbid circumvention of technological measures.
- 4. Conveying Verbatim Copies.
- You may convey verbatim copies of the Program's source code as you
- receive it, in any medium, provided that you conspicuously and
- appropriately publish on each copy an appropriate copyright notice;
- keep intact all notices stating that this License and any
- non-permissive terms added in accord with section 7 apply to the
- code; keep intact all notices of the absence of any warranty; and
- give all recipients a copy of this License along with the Program.
- You may charge any price or no price for each copy that you convey,
- and you may offer support or warranty protection for a fee.
- 5. Conveying Modified Source Versions.
- You may convey a work based on the Program, or the modifications to
- produce it from the Program, in the form of source code under the
- terms of section 4, provided that you also meet all of these
- conditions:
- a. The work must carry prominent notices stating that you
- modified it, and giving a relevant date.
- b. The work must carry prominent notices stating that it is
- released under this License and any conditions added under
- section 7. This requirement modifies the requirement in
- section 4 to "keep intact all notices".
- c. You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable
- section 7 additional terms, to the whole of the work, and all
- its parts, regardless of how they are packaged. This License
- gives no permission to license the work in any other way, but
- it does not invalidate such permission if you have separately
- received it.
- d. If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has
- interactive interfaces that do not display Appropriate Legal
- Notices, your work need not make them do so.
- A compilation of a covered work with other separate and independent
- works, which are not by their nature extensions of the covered
- work, and which are not combined with it such as to form a larger
- program, in or on a volume of a storage or distribution medium, is
- called an "aggregate" if the compilation and its resulting
- copyright are not used to limit the access or legal rights of the
- compilation's users beyond what the individual works permit.
- Inclusion of a covered work in an aggregate does not cause this
- License to apply to the other parts of the aggregate.
- 6. Conveying Non-Source Forms.
- You may convey a covered work in object code form under the terms
- of sections 4 and 5, provided that you also convey the
- machine-readable Corresponding Source under the terms of this
- License, in one of these ways:
- a. Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
- b. Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for
- as long as you offer spare parts or customer support for that
- product model, to give anyone who possesses the object code
- either (1) a copy of the Corresponding Source for all the
- software in the product that is covered by this License, on a
- durable physical medium customarily used for software
- interchange, for a price no more than your reasonable cost of
- physically performing this conveying of source, or (2) access
- to copy the Corresponding Source from a network server at no
- charge.
- c. Convey individual copies of the object code with a copy of
- the written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially,
- and only if you received the object code with such an offer,
- in accord with subsection 6b.
- d. Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access
- to the Corresponding Source in the same way through the same
- place at no further charge. You need not require recipients
- to copy the Corresponding Source along with the object code.
- If the place to copy the object code is a network server, the
- Corresponding Source may be on a different server (operated
- by you or a third party) that supports equivalent copying
- facilities, provided you maintain clear directions next to
- the object code saying where to find the Corresponding Source.
- Regardless of what server hosts the Corresponding Source, you
- remain obligated to ensure that it is available for as long
- as needed to satisfy these requirements.
- e. Convey the object code using peer-to-peer transmission,
- provided you inform other peers where the object code and
- Corresponding Source of the work are being offered to the
- general public at no charge under subsection 6d.
- A separable portion of the object code, whose source code is
- excluded from the Corresponding Source as a System Library, need
- not be included in conveying the object code work.
- A "User Product" is either (1) a "consumer product", which means
- any tangible personal property which is normally used for personal,
- family, or household purposes, or (2) anything designed or sold for
- incorporation into a dwelling. In determining whether a product
- is a consumer product, doubtful cases shall be resolved in favor of
- coverage. For a particular product received by a particular user,
- "normally used" refers to a typical or common use of that class of
- product, regardless of the status of the particular user or of the
- way in which the particular user actually uses, or expects or is
- expected to use, the product. A product is a consumer product
- regardless of whether the product has substantial commercial,
- industrial or non-consumer uses, unless such uses represent the
- only significant mode of use of the product.
- "Installation Information" for a User Product means any methods,
- procedures, authorization keys, or other information required to
- install and execute modified versions of a covered work in that
- User Product from a modified version of its Corresponding Source.
- The information must suffice to ensure that the continued
- functioning of the modified object code is in no case prevented or
- interfered with solely because modification has been made.
- If you convey an object code work under this section in, or with,
- or specifically for use in, a User Product, and the conveying
- occurs as part of a transaction in which the right of possession
- and use of the User Product is transferred to the recipient in
- perpetuity or for a fixed term (regardless of how the transaction
- is characterized), the Corresponding Source conveyed under this
- section must be accompanied by the Installation Information. But
- this requirement does not apply if neither you nor any third party
- retains the ability to install modified object code on the User
- Product (for example, the work has been installed in ROM).
- The requirement to provide Installation Information does not
- include a requirement to continue to provide support service,
- warranty, or updates for a work that has been modified or
- installed by the recipient, or for the User Product in which it
- has been modified or installed. Access to a network may be denied
- when the modification itself materially and adversely affects the
- operation of the network or violates the rules and protocols for
- communication across the network.
- Corresponding Source conveyed, and Installation Information
- provided, in accord with this section must be in a format that is
- publicly documented (and with an implementation available to the
- public in source code form), and must require no special password
- or key for unpacking, reading or copying.
- 7. Additional Terms.
- "Additional permissions" are terms that supplement the terms of
- this License by making exceptions from one or more of its
- conditions. Additional permissions that are applicable to the
- entire Program shall be treated as though they were included in
- this License, to the extent that they are valid under applicable
- law. If additional permissions apply only to part of the Program,
- that part may be used separately under those permissions, but the
- entire Program remains governed by this License without regard to
- the additional permissions.
- When you convey a copy of a covered work, you may at your option
- remove any additional permissions from that copy, or from any part
- of it. (Additional permissions may be written to require their own
- removal in certain cases when you modify the work.) You may place
- additional permissions on material, added by you to a covered work,
- for which you have or can give appropriate copyright permission.
- Notwithstanding any other provision of this License, for material
- you add to a covered work, you may (if authorized by the copyright
- holders of that material) supplement the terms of this License
- with terms:
- a. Disclaiming warranty or limiting liability differently from
- the terms of sections 15 and 16 of this License; or
- b. Requiring preservation of specified reasonable legal notices
- or author attributions in that material or in the Appropriate
- Legal Notices displayed by works containing it; or
- c. Prohibiting misrepresentation of the origin of that material,
- or requiring that modified versions of such material be
- marked in reasonable ways as different from the original
- version; or
- d. Limiting the use for publicity purposes of names of licensors
- or authors of the material; or
- e. Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
- f. Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified
- versions of it) with contractual assumptions of liability to
- the recipient, for any liability that these contractual
- assumptions directly impose on those licensors and authors.
- All other non-permissive additional terms are considered "further
- restrictions" within the meaning of section 10. If the Program as
- you received it, or any part of it, contains a notice stating that
- it is governed by this License along with a term that is a further
- restriction, you may remove that term. If a license document
- contains a further restriction but permits relicensing or
- conveying under this License, you may add to a covered work
- material governed by the terms of that license document, provided
- that the further restriction does not survive such relicensing or
- conveying.
- If you add terms to a covered work in accord with this section, you
- must place, in the relevant source files, a statement of the
- additional terms that apply to those files, or a notice indicating
- where to find the applicable terms.
- Additional terms, permissive or non-permissive, may be stated in
- the form of a separately written license, or stated as exceptions;
- the above requirements apply either way.
- 8. Termination.
- You may not propagate or modify a covered work except as expressly
- provided under this License. Any attempt otherwise to propagate or
- modify it is void, and will automatically terminate your rights
- under this License (including any patent licenses granted under
- the third paragraph of section 11).
- However, if you cease all violation of this License, then your
- license from a particular copyright holder is reinstated (a)
- provisionally, unless and until the copyright holder explicitly
- and finally terminates your license, and (b) permanently, if the
- copyright holder fails to notify you of the violation by some
- reasonable means prior to 60 days after the cessation.
- Moreover, your license from a particular copyright holder is
- reinstated permanently if the copyright holder notifies you of the
- violation by some reasonable means, this is the first time you have
- received notice of violation of this License (for any work) from
- that copyright holder, and you cure the violation prior to 30 days
- after your receipt of the notice.
- Termination of your rights under this section does not terminate
- the licenses of parties who have received copies or rights from
- you under this License. If your rights have been terminated and
- not permanently reinstated, you do not qualify to receive new
- licenses for the same material under section 10.
- 9. Acceptance Not Required for Having Copies.
- You are not required to accept this License in order to receive or
- run a copy of the Program. Ancillary propagation of a covered work
- occurring solely as a consequence of using peer-to-peer
- transmission to receive a copy likewise does not require
- acceptance. However, nothing other than this License grants you
- permission to propagate or modify any covered work. These actions
- infringe copyright if you do not accept this License. Therefore,
- by modifying or propagating a covered work, you indicate your
- acceptance of this License to do so.
- 10. Automatic Licensing of Downstream Recipients.
- Each time you convey a covered work, the recipient automatically
- receives a license from the original licensors, to run, modify and
- propagate that work, subject to this License. You are not
- responsible for enforcing compliance by third parties with this
- License.
- An "entity transaction" is a transaction transferring control of an
- organization, or substantially all assets of one, or subdividing an
- organization, or merging organizations. If propagation of a
- covered work results from an entity transaction, each party to that
- transaction who receives a copy of the work also receives whatever
- licenses to the work the party's predecessor in interest had or
- could give under the previous paragraph, plus a right to
- possession of the Corresponding Source of the work from the
- predecessor in interest, if the predecessor has it or can get it
- with reasonable efforts.
- You may not impose any further restrictions on the exercise of the
- rights granted or affirmed under this License. For example, you
- may not impose a license fee, royalty, or other charge for
- exercise of rights granted under this License, and you may not
- initiate litigation (including a cross-claim or counterclaim in a
- lawsuit) alleging that any patent claim is infringed by making,
- using, selling, offering for sale, or importing the Program or any
- portion of it.
- 11. Patents.
- A "contributor" is a copyright holder who authorizes use under this
- License of the Program or a work on which the Program is based.
- The work thus licensed is called the contributor's "contributor
- version".
- A contributor's "essential patent claims" are all patent claims
- owned or controlled by the contributor, whether already acquired or
- hereafter acquired, that would be infringed by some manner,
- permitted by this License, of making, using, or selling its
- contributor version, but do not include claims that would be
- infringed only as a consequence of further modification of the
- contributor version. For purposes of this definition, "control"
- includes the right to grant patent sublicenses in a manner
- consistent with the requirements of this License.
- Each contributor grants you a non-exclusive, worldwide,
- royalty-free patent license under the contributor's essential
- patent claims, to make, use, sell, offer for sale, import and
- otherwise run, modify and propagate the contents of its
- contributor version.
- In the following three paragraphs, a "patent license" is any
- express agreement or commitment, however denominated, not to
- enforce a patent (such as an express permission to practice a
- patent or covenant not to sue for patent infringement). To
- "grant" such a patent license to a party means to make such an
- agreement or commitment not to enforce a patent against the party.
- If you convey a covered work, knowingly relying on a patent
- license, and the Corresponding Source of the work is not available
- for anyone to copy, free of charge and under the terms of this
- License, through a publicly available network server or other
- readily accessible means, then you must either (1) cause the
- Corresponding Source to be so available, or (2) arrange to deprive
- yourself of the benefit of the patent license for this particular
- work, or (3) arrange, in a manner consistent with the requirements
- of this License, to extend the patent license to downstream
- recipients. "Knowingly relying" means you have actual knowledge
- that, but for the patent license, your conveying the covered work
- in a country, or your recipient's use of the covered work in a
- country, would infringe one or more identifiable patents in that
- country that you have reason to believe are valid.
- If, pursuant to or in connection with a single transaction or
- arrangement, you convey, or propagate by procuring conveyance of, a
- covered work, and grant a patent license to some of the parties
- receiving the covered work authorizing them to use, propagate,
- modify or convey a specific copy of the covered work, then the
- patent license you grant is automatically extended to all
- recipients of the covered work and works based on it.
- A patent license is "discriminatory" if it does not include within
- the scope of its coverage, prohibits the exercise of, or is
- conditioned on the non-exercise of one or more of the rights that
- are specifically granted under this License. You may not convey a
- covered work if you are a party to an arrangement with a third
- party that is in the business of distributing software, under
- which you make payment to the third party based on the extent of
- your activity of conveying the work, and under which the third
- party grants, to any of the parties who would receive the covered
- work from you, a discriminatory patent license (a) in connection
- with copies of the covered work conveyed by you (or copies made
- from those copies), or (b) primarily for and in connection with
- specific products or compilations that contain the covered work,
- unless you entered into that arrangement, or that patent license
- was granted, prior to 28 March 2007.
- Nothing in this License shall be construed as excluding or limiting
- any implied license or other defenses to infringement that may
- otherwise be available to you under applicable patent law.
- 12. No Surrender of Others' Freedom.
- If conditions are imposed on you (whether by court order,
- agreement or otherwise) that contradict the conditions of this
- License, they do not excuse you from the conditions of this
- License. If you cannot convey a covered work so as to satisfy
- simultaneously your obligations under this License and any other
- pertinent obligations, then as a consequence you may not convey it
- at all. For example, if you agree to terms that obligate you to
- collect a royalty for further conveying from those to whom you
- convey the Program, the only way you could satisfy both those
- terms and this License would be to refrain entirely from conveying
- the Program.
- 13. Use with the GNU Affero General Public License.
- Notwithstanding any other provision of this License, you have
- permission to link or combine any covered work with a work licensed
- under version 3 of the GNU Affero General Public License into a
- single combined work, and to convey the resulting work. The terms
- of this License will continue to apply to the part which is the
- covered work, but the special requirements of the GNU Affero
- General Public License, section 13, concerning interaction through
- a network will apply to the combination as such.
- 14. Revised Versions of this License.
- The Free Software Foundation may publish revised and/or new
- versions of the GNU General Public License from time to time.
- Such new versions will be similar in spirit to the present
- version, but may differ in detail to address new problems or
- concerns.
- Each version is given a distinguishing version number. If the
- Program specifies that a certain numbered version of the GNU
- General Public License "or any later version" applies to it, you
- have the option of following the terms and conditions either of
- that numbered version or of any later version published by the
- Free Software Foundation. If the Program does not specify a
- version number of the GNU General Public License, you may choose
- any version ever published by the Free Software Foundation.
- If the Program specifies that a proxy can decide which future
- versions of the GNU General Public License can be used, that
- proxy's public statement of acceptance of a version permanently
- authorizes you to choose that version for the Program.
- Later license versions may give you additional or different
- permissions. However, no additional obligations are imposed on any
- author or copyright holder as a result of your choosing to follow a
- later version.
- 15. Disclaimer of Warranty.
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
- APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE
- COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS"
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE
- RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
- SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
- NECESSARY SERVICING, REPAIR OR CORRECTION.
- 16. Limitation of Liability.
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
- WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES
- AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
- FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
- CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
- THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
- BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
- PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
- PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
- THE POSSIBILITY OF SUCH DAMAGES.
- 17. Interpretation of Sections 15 and 16.
- If the disclaimer of warranty and limitation of liability provided
- above cannot be given local legal effect according to their terms,
- reviewing courts shall apply local law that most closely
- approximates an absolute waiver of all civil liability in
- connection with the Program, unless a warranty or assumption of
- liability accompanies a copy of the Program in return for a fee.
- END OF TERMS AND CONDITIONS
- ===========================
- How to Apply These Terms to Your New Programs
- =============================================
- If you develop a new program, and you want it to be of the greatest
- possible use to the public, the best way to achieve this is to make it
- free software which everyone can redistribute and change under these
- terms.
- To do so, attach the following notices to the program. It is safest
- to attach them to the start of each source file to most effectively
- state the exclusion of warranty; and each file should have at least the
- "copyright" line and a pointer to where the full notice is found.
- ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
- Copyright (C) YEAR NAME OF AUTHOR
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or (at
- your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see `http://www.gnu.org/licenses/'.
- Also add information on how to contact you by electronic and paper
- mail.
- If the program does terminal interaction, make it output a short
- notice like this when it starts in an interactive mode:
- PROGRAM Copyright (C) YEAR NAME OF AUTHOR
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
- The hypothetical commands `show w' and `show c' should show the
- appropriate parts of the General Public License. Of course, your
- program's commands might be different; for a GUI interface, you would
- use an "about box".
- You should also get your employer (if you work as a programmer) or
- school, if any, to sign a "copyright disclaimer" for the program, if
- necessary. For more information on this, and how to apply and follow
- the GNU GPL, see `http://www.gnu.org/licenses/'.
- The GNU General Public License does not permit incorporating your
- program into proprietary programs. If your program is a subroutine
- library, you may consider it more useful to permit linking proprietary
- applications with the library. If this is what you want to do, use the
- GNU Lesser General Public License instead of this License. But first,
- please read `http://www.gnu.org/philosophy/why-not-lgpl.html'.
- File: elisp, Node: Tips, Next: GNU Emacs Internals, Prev: GPL, Up: Top
- Appendix D Tips and Conventions
- *******************************
- This chapter describes no additional features of Emacs Lisp. Instead
- it gives advice on making effective use of the features described in the
- previous chapters, and describes conventions Emacs Lisp programmers
- should follow.
- You can automatically check some of the conventions described below
- by running the command `M-x checkdoc RET' when visiting a Lisp file.
- It cannot check all of the conventions, and not all the warnings it
- gives necessarily correspond to problems, but it is worth examining them
- all.
- * Menu:
- * Coding Conventions:: Conventions for clean and robust programs.
- * Key Binding Conventions:: Which keys should be bound by which programs.
- * Programming Tips:: Making Emacs code fit smoothly in Emacs.
- * Compilation Tips:: Making compiled code run fast.
- * Warning Tips:: Turning off compiler warnings.
- * Documentation Tips:: Writing readable documentation strings.
- * Comment Tips:: Conventions for writing comments.
- * Library Headers:: Standard headers for library packages.
- File: elisp, Node: Coding Conventions, Next: Key Binding Conventions, Up: Tips
- D.1 Emacs Lisp Coding Conventions
- =================================
- Here are conventions that you should follow when writing Emacs Lisp
- code intended for widespread use:
- * Simply loading a package should not change Emacs's editing
- behavior. Include a command or commands to enable and disable the
- feature, or to invoke it.
- This convention is mandatory for any file that includes custom
- definitions. If fixing such a file to follow this convention
- requires an incompatible change, go ahead and make the
- incompatible change; don't postpone it.
- * You should choose a short word to distinguish your program from
- other Lisp programs. The names of all global variables,
- constants, and functions in your program should begin with that
- chosen prefix. Separate the prefix from the rest of the name with
- a hyphen, `-'. This practice helps avoid name conflicts, since
- all global variables in Emacs Lisp share the same name space, and
- all functions share another name space(1).
- Occasionally, for a command name intended for users to use, it is
- more convenient if some words come before the package's name
- prefix. And constructs that define functions, variables, etc.,
- work better if they start with `defun' or `defvar', so put the
- name prefix later on in the name.
- This recommendation applies even to names for traditional Lisp
- primitives that are not primitives in Emacs Lisp--such as
- `copy-list'. Believe it or not, there is more than one plausible
- way to define `copy-list'. Play it safe; append your name prefix
- to produce a name like `foo-copy-list' or `mylib-copy-list'
- instead.
- If you write a function that you think ought to be added to Emacs
- under a certain name, such as `twiddle-files', don't call it by
- that name in your program. Call it `mylib-twiddle-files' in your
- program, and send mail to `bug-gnu-emacs@gnu.org' suggesting we add
- it to Emacs. If and when we do, we can change the name easily
- enough.
- If one prefix is insufficient, your package can use two or three
- alternative common prefixes, so long as they make sense.
- * Put a call to `provide' at the end of each separate Lisp file.
- *Note Named Features::.
- * If a file requires certain other Lisp programs to be loaded
- beforehand, then the comments at the beginning of the file should
- say so. Also, use `require' to make sure they are loaded. *Note
- Named Features::.
- * If a file FOO uses a macro defined in another file BAR, but does
- not use any functions or variables defined in BAR, then FOO should
- contain the following expression:
- (eval-when-compile (require 'BAR))
- This tells Emacs to load BAR just before byte-compiling FOO, so
- that the macro definition is available during compilation. Using
- `eval-when-compile' avoids loading BAR when the compiled version
- of FOO is _used_. It should be called before the first use of the
- macro in the file. *Note Compiling Macros::.
- * Avoid loading additional libraries at run time unless they are
- really needed. If your file simply cannot work without some other
- library, then just `require' that library at the top-level and be
- done with it. But if your file contains several independent
- features, and only one or two require the extra library, then
- consider putting `require' statements inside the relevant
- functions rather than at the top-level. Or use `autoload'
- statements to load the extra library when needed. This way people
- who don't use those aspects of your file do not need to load the
- extra library.
- * Please don't require the `cl' package of Common Lisp extensions at
- run time. Use of this package is optional, and it is not part of
- the standard Emacs namespace. If your package loads `cl' at run
- time, that could cause name clashes for users who don't use that
- package.
- However, there is no problem with using the `cl' package at
- compile time, with `(eval-when-compile (require 'cl))'. That's
- sufficient for using the macros in the `cl' package, because the
- compiler expands them before generating the byte-code.
- * When defining a major mode, please follow the major mode
- conventions. *Note Major Mode Conventions::.
- * When defining a minor mode, please follow the minor mode
- conventions. *Note Minor Mode Conventions::.
- * If the purpose of a function is to tell you whether a certain
- condition is true or false, give the function a name that ends in
- `p' (which stands for "predicate"). If the name is one word, add
- just `p'; if the name is multiple words, add `-p'. Examples are
- `framep' and `frame-live-p'.
- * If the purpose of a variable is to store a single function, give
- it a name that ends in `-function'. If the purpose of a variable
- is to store a list of functions (i.e., the variable is a hook),
- please follow the naming conventions for hooks. *Note Hooks::.
- * If loading the file adds functions to hooks, define a function
- `FEATURE-unload-hook', where FEATURE is the name of the feature
- the package provides, and make it undo any such changes. Using
- `unload-feature' to unload the file will run this function. *Note
- Unloading::.
- * It is a bad idea to define aliases for the Emacs primitives.
- Normally you should use the standard names instead. The case
- where an alias may be useful is where it facilitates backwards
- compatibility or portability.
- * If a package needs to define an alias or a new function for
- compatibility with some other version of Emacs, name it with the
- package prefix, not with the raw name with which it occurs in the
- other version. Here is an example from Gnus, which provides many
- examples of such compatibility issues.
- (defalias 'gnus-point-at-bol
- (if (fboundp 'point-at-bol)
- 'point-at-bol
- 'line-beginning-position))
- * Redefining or advising an Emacs primitive is a bad idea. It may do
- the right thing for a particular program, but there is no telling
- what other programs might break as a result.
- * It is likewise a bad idea for one Lisp package to advise a
- function in another Lisp package (*note Advising Functions::).
- * Avoid using `eval-after-load' in libraries and packages (*note
- Hooks for Loading::). This feature is meant for personal
- customizations; using it in a Lisp program is unclean, because it
- modifies the behavior of another Lisp file in a way that's not
- visible in that file. This is an obstacle for debugging, much
- like advising a function in the other package.
- * If a file does replace any of the standard functions or library
- programs of Emacs, prominent comments at the beginning of the file
- should say which functions are replaced, and how the behavior of
- the replacements differs from that of the originals.
- * Constructs that define a function or variable should be macros,
- not functions, and their names should start with `define-'. The
- macro should receive the name to be defined as the first argument.
- That will help various tools find the definition automatically.
- Avoid constructing the names in the macro itself, since that would
- confuse these tools.
- * In some other systems there is a convention of choosing variable
- names that begin and end with `*'. We don't use that convention
- in Emacs Lisp, so please don't use it in your programs. (Emacs
- uses such names only for special-purpose buffers.) People will
- find Emacs more coherent if all libraries use the same conventions.
- * If your program contains non-ASCII characters in string or
- character constants, you should make sure Emacs always decodes
- these characters the same way, regardless of the user's settings.
- The easiest way to do this is to use the coding system
- `utf-8-emacs' (*note Coding System Basics::), and specify that
- coding in the `-*-' line or the local variables list. *Note Local
- Variables in Files: (emacs)File Variables.
- ;; XXX.el -*- coding: utf-8-emacs; -*-
- * Indent the file using the default indentation parameters.
- * Don't make a habit of putting close-parentheses on lines by
- themselves; Lisp programmers find this disconcerting.
- * Please put a copyright notice and copying permission notice on the
- file if you distribute copies. *Note Library Headers::.
- ---------- Footnotes ----------
- (1) The benefits of a Common Lisp-style package system are
- considered not to outweigh the costs.
- File: elisp, Node: Key Binding Conventions, Next: Programming Tips, Prev: Coding Conventions, Up: Tips
- D.2 Key Binding Conventions
- ===========================
- * Many special major modes, like Dired, Info, Compilation, and Occur,
- are designed to handle read-only text that contains "hyper-links".
- Such a major mode should redefine `mouse-2' and <RET> to follow
- the links. It should also set up a `follow-link' condition, so
- that the link obeys `mouse-1-click-follows-link'. *Note Clickable
- Text::. *Note Buttons::, for an easy method of implementing such
- clickable links.
- * Don't define `C-c LETTER' as a key in Lisp programs. Sequences
- consisting of `C-c' and a letter (either upper or lower case) are
- reserved for users; they are the *only* sequences reserved for
- users, so do not block them.
- Changing all the Emacs major modes to respect this convention was a
- lot of work; abandoning this convention would make that work go to
- waste, and inconvenience users. Please comply with it.
- * Function keys <F5> through <F9> without modifier keys are also
- reserved for users to define.
- * Sequences consisting of `C-c' followed by a control character or a
- digit are reserved for major modes.
- * Sequences consisting of `C-c' followed by `{', `}', `<', `>', `:'
- or `;' are also reserved for major modes.
- * Sequences consisting of `C-c' followed by any other punctuation
- character are allocated for minor modes. Using them in a major
- mode is not absolutely prohibited, but if you do that, the major
- mode binding may be shadowed from time to time by minor modes.
- * Don't bind `C-h' following any prefix character (including `C-c').
- If you don't bind `C-h', it is automatically available as a help
- character for listing the subcommands of the prefix character.
- * Don't bind a key sequence ending in <ESC> except following another
- <ESC>. (That is, it is OK to bind a sequence ending in `<ESC>
- <ESC>'.)
- The reason for this rule is that a non-prefix binding for <ESC> in
- any context prevents recognition of escape sequences as function
- keys in that context.
- * Similarly, don't bind a key sequence ending in <C-g>, since that
- is commonly used to cancel a key sequence.
- * Anything that acts like a temporary mode or state that the user can
- enter and leave should define `<ESC> <ESC>' or `<ESC> <ESC> <ESC>'
- as a way to escape.
- For a state that accepts ordinary Emacs commands, or more
- generally any kind of state in which <ESC> followed by a function
- key or arrow key is potentially meaningful, then you must not
- define `<ESC> <ESC>', since that would preclude recognizing an
- escape sequence after <ESC>. In these states, you should define
- `<ESC> <ESC> <ESC>' as the way to escape. Otherwise, define
- `<ESC> <ESC>' instead.
- File: elisp, Node: Programming Tips, Next: Compilation Tips, Prev: Key Binding Conventions, Up: Tips
- D.3 Emacs Programming Tips
- ==========================
- Following these conventions will make your program fit better into
- Emacs when it runs.
- * Don't use `next-line' or `previous-line' in programs; nearly
- always, `forward-line' is more convenient as well as more
- predictable and robust. *Note Text Lines::.
- * Don't call functions that set the mark, unless setting the mark is
- one of the intended features of your program. The mark is a
- user-level feature, so it is incorrect to change the mark except
- to supply a value for the user's benefit. *Note The Mark::.
- In particular, don't use any of these functions:
- * `beginning-of-buffer', `end-of-buffer'
- * `replace-string', `replace-regexp'
- * `insert-file', `insert-buffer'
- If you just want to move point, or replace a certain string, or
- insert a file or buffer's contents, without any of the other
- features intended for interactive users, you can replace these
- functions with one or two lines of simple Lisp code.
- * Use lists rather than vectors, except when there is a particular
- reason to use a vector. Lisp has more facilities for manipulating
- lists than for vectors, and working with lists is usually more
- convenient.
- Vectors are advantageous for tables that are substantial in size
- and are accessed in random order (not searched front to back),
- provided there is no need to insert or delete elements (only lists
- allow that).
- * The recommended way to show a message in the echo area is with the
- `message' function, not `princ'. *Note The Echo Area::.
- * When you encounter an error condition, call the function `error'
- (or `signal'). The function `error' does not return. *Note
- Signaling Errors::.
- Don't use `message', `throw', `sleep-for', or `beep' to report
- errors.
- * An error message should start with a capital letter but should not
- end with a period.
- * A question asked in the minibuffer with `yes-or-no-p' or
- `y-or-n-p' should start with a capital letter and end with `? '.
- * When you mention a default value in a minibuffer prompt, put it
- and the word `default' inside parentheses. It should look like
- this:
- Enter the answer (default 42):
- * In `interactive', if you use a Lisp expression to produce a list
- of arguments, don't try to provide the "correct" default values for
- region or position arguments. Instead, provide `nil' for those
- arguments if they were not specified, and have the function body
- compute the default value when the argument is `nil'. For
- instance, write this:
- (defun foo (pos)
- (interactive
- (list (if SPECIFIED SPECIFIED-POS)))
- (unless pos (setq pos DEFAULT-POS))
- ...)
- rather than this:
- (defun foo (pos)
- (interactive
- (list (if SPECIFIED SPECIFIED-POS
- DEFAULT-POS)))
- ...)
- This is so that repetition of the command will recompute these
- defaults based on the current circumstances.
- You do not need to take such precautions when you use interactive
- specs `d', `m' and `r', because they make special arrangements to
- recompute the argument values on repetition of the command.
- * Many commands that take a long time to execute display a message
- that says something like `Operating...' when they start, and
- change it to `Operating...done' when they finish. Please keep the
- style of these messages uniform: _no_ space around the ellipsis,
- and _no_ period after `done'. *Note Progress::, for an easy way
- to generate such messages.
- * Try to avoid using recursive edits. Instead, do what the Rmail `e'
- command does: use a new local keymap that contains a command
- defined to switch back to the old local keymap. Or simply switch
- to another buffer and let the user switch back at will. *Note
- Recursive Editing::.
- File: elisp, Node: Compilation Tips, Next: Warning Tips, Prev: Programming Tips, Up: Tips
- D.4 Tips for Making Compiled Code Fast
- ======================================
- Here are ways of improving the execution speed of byte-compiled Lisp
- programs.
- * Profile your program with the `elp' library. See the file
- `elp.el' for instructions.
- * Check the speed of individual Emacs Lisp forms using the
- `benchmark' library. See the functions `benchmark-run' and
- `benchmark-run-compiled' in `benchmark.el'.
- * Use iteration rather than recursion whenever possible. Function
- calls are slow in Emacs Lisp even when a compiled function is
- calling another compiled function.
- * Using the primitive list-searching functions `memq', `member',
- `assq', or `assoc' is even faster than explicit iteration. It can
- be worth rearranging a data structure so that one of these
- primitive search functions can be used.
- * Certain built-in functions are handled specially in byte-compiled
- code, avoiding the need for an ordinary function call. It is a
- good idea to use these functions rather than alternatives. To see
- whether a function is handled specially by the compiler, examine
- its `byte-compile' property. If the property is non-`nil', then
- the function is handled specially.
- For example, the following input will show you that `aref' is
- compiled specially (*note Array Functions::):
- (get 'aref 'byte-compile)
- => byte-compile-two-args
- Note that in this case (and many others), you must first load the
- `bytecomp' library, which defines the `byte-compile' property.
- * If calling a small function accounts for a substantial part of your
- program's running time, make the function inline. This eliminates
- the function call overhead. Since making a function inline reduces
- the flexibility of changing the program, don't do it unless it
- gives a noticeable speedup in something slow enough that users
- care about the speed. *Note Inline Functions::.
- File: elisp, Node: Warning Tips, Next: Documentation Tips, Prev: Compilation Tips, Up: Tips
- D.5 Tips for Avoiding Compiler Warnings
- =======================================
- * Try to avoid compiler warnings about undefined free variables, by
- adding dummy `defvar' definitions for these variables, like this:
- (defvar foo)
- Such a definition has no effect except to tell the compiler not to
- warn about uses of the variable `foo' in this file.
- * Similarly, to avoid a compiler warning about an undefined function
- that you know _will_ be defined, use a `declare-function'
- statement (*note Declaring Functions::).
- * If you use many functions and variables from a certain file, you
- can add a `require' for that package to avoid compilation warnings
- for them. For instance,
- (eval-when-compile
- (require 'foo))
- * If you bind a variable in one function, and use it or set it in
- another function, the compiler warns about the latter function
- unless the variable has a definition. But adding a definition
- would be unclean if the variable has a short name, since Lisp
- packages should not define short variable names. The right thing
- to do is to rename this variable to start with the name prefix
- used for the other functions and variables in your package.
- * The last resort for avoiding a warning, when you want to do
- something that is usually a mistake but you know is not a mistake
- in your usage, is to put it inside `with-no-warnings'. *Note
- Compiler Errors::.
- File: elisp, Node: Documentation Tips, Next: Comment Tips, Prev: Warning Tips, Up: Tips
- D.6 Tips for Documentation Strings
- ==================================
- Here are some tips and conventions for the writing of documentation
- strings. You can check many of these conventions by running the command
- `M-x checkdoc-minor-mode'.
- * Every command, function, or variable intended for users to know
- about should have a documentation string.
- * An internal variable or subroutine of a Lisp program might as well
- have a documentation string. Documentation strings take up very
- little space in a running Emacs.
- * Format the documentation string so that it fits in an Emacs window
- on an 80-column screen. It is a good idea for most lines to be no
- wider than 60 characters. The first line should not be wider than
- 67 characters or it will look bad in the output of `apropos'.
- You can fill the text if that looks good. However, rather than
- blindly filling the entire documentation string, you can often
- make it much more readable by choosing certain line breaks with
- care. Use blank lines between sections if the documentation
- string is long.
- * The first line of the documentation string should consist of one
- or two complete sentences that stand on their own as a summary.
- `M-x apropos' displays just the first line, and if that line's
- contents don't stand on their own, the result looks bad. In
- particular, start the first line with a capital letter and end it
- with a period.
- For a function, the first line should briefly answer the question,
- "What does this function do?" For a variable, the first line
- should briefly answer the question, "What does this value mean?"
- Don't limit the documentation string to one line; use as many
- lines as you need to explain the details of how to use the
- function or variable. Please use complete sentences for the rest
- of the text too.
- * When the user tries to use a disabled command, Emacs displays just
- the first paragraph of its documentation string--everything
- through the first blank line. If you wish, you can choose which
- information to include before the first blank line so as to make
- this display useful.
- * The first line should mention all the important arguments of the
- function, and should mention them in the order that they are
- written in a function call. If the function has many arguments,
- then it is not feasible to mention them all in the first line; in
- that case, the first line should mention the first few arguments,
- including the most important arguments.
- * When a function's documentation string mentions the value of an
- argument of the function, use the argument name in capital letters
- as if it were a name for that value. Thus, the documentation
- string of the function `eval' refers to its first argument as
- `FORM', because the actual argument name is `form':
- Evaluate FORM and return its value.
- Also write metasyntactic variables in capital letters, such as
- when you show the decomposition of a list or vector into subunits,
- some of which may vary. `KEY' and `VALUE' in the following example
- illustrate this practice:
- The argument TABLE should be an alist whose elements
- have the form (KEY . VALUE). Here, KEY is ...
- * Never change the case of a Lisp symbol when you mention it in a doc
- string. If the symbol's name is `foo', write "foo", not "Foo"
- (which is a different symbol).
- This might appear to contradict the policy of writing function
- argument values, but there is no real contradiction; the argument
- _value_ is not the same thing as the _symbol_ that the function
- uses to hold the value.
- If this puts a lower-case letter at the beginning of a sentence
- and that annoys you, rewrite the sentence so that the symbol is
- not at the start of it.
- * Do not start or end a documentation string with whitespace.
- * *Do not* indent subsequent lines of a documentation string so that
- the text is lined up in the source code with the text of the first
- line. This looks nice in the source code, but looks bizarre when
- users view the documentation. Remember that the indentation
- before the starting double-quote is not part of the string!
- * When a documentation string refers to a Lisp symbol, write it as it
- would be printed (which usually means in lower case), with
- single-quotes around it. For example: `lambda'. There are two
- exceptions: write t and nil without single-quotes. (In this
- manual, we use a different convention, with single-quotes for all
- symbols.)
- Help mode automatically creates a hyperlink when a documentation
- string uses a symbol name inside single quotes, if the symbol has
- either a function or a variable definition. You do not need to do
- anything special to make use of this feature. However, when a
- symbol has both a function definition and a variable definition,
- and you want to refer to just one of them, you can specify which
- one by writing one of the words `variable', `option', `function',
- or `command', immediately before the symbol name. (Case makes no
- difference in recognizing these indicator words.) For example, if
- you write
- This function sets the variable `buffer-file-name'.
- then the hyperlink will refer only to the variable documentation of
- `buffer-file-name', and not to its function documentation.
- If a symbol has a function definition and/or a variable
- definition, but those are irrelevant to the use of the symbol that
- you are documenting, you can write the words `symbol' or `program'
- before the symbol name to prevent making any hyperlink. For
- example,
- If the argument KIND-OF-RESULT is the symbol `list',
- this function returns a list of all the objects
- that satisfy the criterion.
- does not make a hyperlink to the documentation, irrelevant here,
- of the function `list'.
- Normally, no hyperlink is made for a variable without variable
- documentation. You can force a hyperlink for such variables by
- preceding them with one of the words `variable' or `option'.
- Hyperlinks for faces are only made if the face name is preceded or
- followed by the word `face'. In that case, only the face
- documentation will be shown, even if the symbol is also defined as
- a variable or as a function.
- To make a hyperlink to Info documentation, write the name of the
- Info node (or anchor) in single quotes, preceded by `info node',
- `Info node', `info anchor' or `Info anchor'. The Info file name
- defaults to `emacs'. For example,
- See Info node `Font Lock' and Info node `(elisp)Font Lock Basics'.
- Finally, to create a hyperlink to URLs, write the URL in single
- quotes, preceded by `URL'. For example,
- The home page for the GNU project has more information (see URL
- `http://www.gnu.org/').
- * Don't write key sequences directly in documentation strings.
- Instead, use the `\\[...]' construct to stand for them. For
- example, instead of writing `C-f', write the construct
- `\\[forward-char]'. When Emacs displays the documentation string,
- it substitutes whatever key is currently bound to `forward-char'.
- (This is normally `C-f', but it may be some other character if the
- user has moved key bindings.) *Note Keys in Documentation::.
- * In documentation strings for a major mode, you will want to refer
- to the key bindings of that mode's local map, rather than global
- ones. Therefore, use the construct `\\<...>' once in the
- documentation string to specify which key map to use. Do this
- before the first use of `\\[...]'. The text inside the `\\<...>'
- should be the name of the variable containing the local keymap for
- the major mode.
- It is not practical to use `\\[...]' very many times, because
- display of the documentation string will become slow. So use this
- to describe the most important commands in your major mode, and
- then use `\\{...}' to display the rest of the mode's keymap.
- * For consistency, phrase the verb in the first sentence of a
- function's documentation string as an imperative--for instance,
- use "Return the cons of A and B." in preference to "Returns the
- cons of A and B." Usually it looks good to do likewise for the
- rest of the first paragraph. Subsequent paragraphs usually look
- better if each sentence is indicative and has a proper subject.
- * The documentation string for a function that is a yes-or-no
- predicate should start with words such as "Return t if", to
- indicate explicitly what constitutes "truth". The word "return"
- avoids starting the sentence with lower-case "t", which could be
- somewhat distracting.
- * If a line in a documentation string begins with an
- open-parenthesis, write a backslash before the open-parenthesis,
- like this:
- The argument FOO can be either a number
- \(a buffer position) or a string (a file name).
- This prevents the open-parenthesis from being treated as the start
- of a defun (*note Defuns: (emacs)Defuns.).
- * Write documentation strings in the active voice, not the passive,
- and in the present tense, not the future. For instance, use
- "Return a list containing A and B." instead of "A list containing
- A and B will be returned."
- * Avoid using the word "cause" (or its equivalents) unnecessarily.
- Instead of, "Cause Emacs to display text in boldface", write just
- "Display text in boldface".
- * Avoid using "iff" (a mathematics term meaning "if and only if"),
- since many people are unfamiliar with it and mistake it for a
- typo. In most cases, the meaning is clear with just "if".
- Otherwise, try to find an alternate phrasing that conveys the
- meaning.
- * When a command is meaningful only in a certain mode or situation,
- do mention that in the documentation string. For example, the
- documentation of `dired-find-file' is:
- In Dired, visit the file or directory named on this line.
- * When you define a variable that represents an option users might
- want to set, use `defcustom'. *Note Defining Variables::.
- * The documentation string for a variable that is a yes-or-no flag
- should start with words such as "Non-nil means", to make it clear
- that all non-`nil' values are equivalent and indicate explicitly
- what `nil' and non-`nil' mean.
- File: elisp, Node: Comment Tips, Next: Library Headers, Prev: Documentation Tips, Up: Tips
- D.7 Tips on Writing Comments
- ============================
- We recommend these conventions for comments:
- `;'
- Comments that start with a single semicolon, `;', should all be
- aligned to the same column on the right of the source code. Such
- comments usually explain how the code on that line does its job.
- For example:
- (setq base-version-list ; there was a base
- (assoc (substring fn 0 start-vn) ; version to which
- file-version-assoc-list)) ; this looks like
- ; a subversion
- `;;'
- Comments that start with two semicolons, `;;', should be aligned to
- the same level of indentation as the code. Such comments usually
- describe the purpose of the following lines or the state of the
- program at that point. For example:
- (prog1 (setq auto-fill-function
- ...
- ...
- ;; Update mode line.
- (force-mode-line-update)))
- We also normally use two semicolons for comments outside functions.
- ;; This Lisp code is run in Emacs when it is to operate as
- ;; a server for other processes.
- If a function has no documentation string, it should instead have a
- two-semicolon comment right before the function, explaining what
- the function does and how to call it properly. Explain precisely
- what each argument means and how the function interprets its
- possible values. It is much better to convert such comments to
- documentation strings, though.
- `;;;'
- Comments that start with three semicolons, `;;;', should start at
- the left margin. These are used, occasionally, for comments within
- functions that should start at the margin. We also use them
- sometimes for comments that are between functions--whether to use
- two or three semicolons depends on whether the comment should be
- considered a "heading" by Outline minor mode. By default,
- comments starting with at least three semicolons (followed by a
- single space and a non-whitespace character) are considered
- headings, comments starting with two or fewer are not.
- Another use for triple-semicolon comments is for commenting out
- lines within a function. We use three semicolons for this
- precisely so that they remain at the left margin. By default,
- Outline minor mode does not consider a comment to be a heading
- (even if it starts with at least three semicolons) if the
- semicolons are followed by at least two spaces. Thus, if you add
- an introductory comment to the commented out code, make sure to
- indent it by at least two spaces after the three semicolons.
- (defun foo (a)
- ;;; This is no longer necessary.
- ;;; (force-mode-line-update)
- (message "Finished with %s" a))
- When commenting out entire functions, use two semicolons.
- `;;;;'
- Comments that start with four semicolons, `;;;;', should be aligned
- to the left margin and are used for headings of major sections of a
- program. For example:
- ;;;; The kill ring
- Generally speaking, the `M-;' (`comment-dwim') command automatically
- starts a comment of the appropriate type; or indents an existing
- comment to the right place, depending on the number of semicolons.
- *Note Manipulating Comments: (emacs)Comments.
- File: elisp, Node: Library Headers, Prev: Comment Tips, Up: Tips
- D.8 Conventional Headers for Emacs Libraries
- ============================================
- Emacs has conventions for using special comments in Lisp libraries to
- divide them into sections and give information such as who wrote them.
- Using a standard format for these items makes it easier for tools (and
- people) to extract the relevant information. This section explains
- these conventions, starting with an example:
- ;;; foo.el --- Support for the Foo programming language
- ;; Copyright (C) 2010-2012 Your Name
- ;; Author: Your Name <yourname@example.com>
- ;; Maintainer: Someone Else <someone@example.com>
- ;; Created: 14 Jul 2010
- ;; Keywords: languages
- ;; This file is not part of GNU Emacs.
- ;; This file is free software...
- ...
- ;; along with this file. If not, see <http://www.gnu.org/licenses/>.
- The very first line should have this format:
- ;;; FILENAME --- DESCRIPTION
- The description should be contained in one line. If the file needs a
- `-*-' specification, put it after DESCRIPTION. If this would make the
- first line too long, use a Local Variables section at the end of the
- file.
- The copyright notice usually lists your name (if you wrote the
- file). If you have an employer who claims copyright on your work, you
- might need to list them instead. Do not say that the copyright holder
- is the Free Software Foundation (or that the file is part of GNU Emacs)
- unless your file has been accepted into the Emacs distribution. For
- more information on the form of copyright and license notices, see the
- guide on the GNU website (http://www.gnu.org/licenses/gpl-howto.html).
- After the copyright notice come several "header comment" lines, each
- beginning with `;; HEADER-NAME:'. Here is a table of the conventional
- possibilities for HEADER-NAME:
- `Author'
- This line states the name and email address of at least the
- principal author of the library. If there are multiple authors,
- list them on continuation lines led by `;;' and whitespace (this
- is easier for tools to parse than having more than one author on
- one line). We recommend including a contact email address, of the
- form `<...>'. For example:
- ;; Author: Your Name <yourname@example.com>
- ;; Someone Else <someone@example.com>
- ;; Another Person <another@example.com>
- `Maintainer'
- This header has the same format as the Author header. It lists the
- person(s) who currently maintain(s) the file (respond to bug
- reports, etc.).
- If there is no maintainer line, the person(s) in the Author field
- is/are presumed to be the maintainers. Some files in Emacs use
- `FSF' for the maintainer. This means that the original author is
- no longer responsible for the file, and that it is maintained as
- part of Emacs.
- `Created'
- This optional line gives the original creation date of the file,
- and is for historical interest only.
- `Version'
- If you wish to record version numbers for the individual Lisp
- program, put them in this line. Lisp files distributed with Emacs
- generally do not have a `Version' header, since the version number
- of Emacs itself serves the same purpose. If you are distributing
- a collection of multiple files, we recommend not writing the
- version in every file, but only the main one.
- `Keywords'
- This line lists keywords for the `finder-by-keyword' help command.
- Please use that command to see a list of the meaningful keywords.
- This field is how people will find your package when they're
- looking for things by topic. To separate the keywords, you can
- use spaces, commas, or both.
- The name of this field is unfortunate, since people often assume
- it is the place to write arbitrary keywords that describe their
- package, rather than just the relevant Finder keywords.
- `Package-Version'
- If `Version' is not suitable for use by the package manager, then
- a package can define `Package-Version'; it will be used instead.
- This is handy if `Version' is an RCS id or something else that
- cannot be parsed by `version-to-list'. *Note Packaging Basics::.
- `Package-Requires'
- If this exists, it names packages on which the current package
- depends for proper operation. *Note Packaging Basics::. This is
- used by the package manager both at download time (to ensure that
- a complete set of packages is downloaded) and at activation time
- (to ensure that a package is only activated if all its
- dependencies have been).
- Its format is a list of lists. The `car' of each sub-list is the
- name of a package, as a symbol. The `cadr' of each sub-list is
- the minimum acceptable version number, as a string. For instance:
- ;; Package-Requires: ((gnus "1.0") (bubbles "2.7.2"))
- The package code automatically defines a package named `emacs'
- with the version number of the currently running Emacs. This can
- be used to require a minimal version of Emacs for a package.
- Just about every Lisp library ought to have the `Author' and
- `Keywords' header comment lines. Use the others if they are
- appropriate. You can also put in header lines with other header
- names--they have no standard meanings, so they can't do any harm.
- We use additional stylized comments to subdivide the contents of the
- library file. These should be separated from anything else by blank
- lines. Here is a table of them:
- `;;; Commentary:'
- This begins introductory comments that explain how the library
- works. It should come right after the copying permissions,
- terminated by a `Change Log', `History' or `Code' comment line.
- This text is used by the Finder package, so it should make sense
- in that context.
- `;;; Change Log:'
- This begins an optional log of changes to the file over time.
- Don't put too much information in this section--it is better to
- keep the detailed logs in a separate `ChangeLog' file (as Emacs
- does), and/or to use a version control system. `History' is an
- alternative to `Change Log'.
- `;;; Code:'
- This begins the actual code of the program.
- `;;; FILENAME ends here'
- This is the "footer line"; it appears at the very end of the file.
- Its purpose is to enable people to detect truncated versions of
- the file from the lack of a footer line.
- File: elisp, Node: GNU Emacs Internals, Next: Standard Errors, Prev: Tips, Up: Top
- Appendix E GNU Emacs Internals
- ******************************
- This chapter describes how the runnable Emacs executable is dumped with
- the preloaded Lisp libraries in it, how storage is allocated, and some
- internal aspects of GNU Emacs that may be of interest to C programmers.
- * Menu:
- * Building Emacs:: How the dumped Emacs is made.
- * Pure Storage:: Kludge to make preloaded Lisp functions shareable.
- * Garbage Collection:: Reclaiming space for Lisp objects no longer used.
- * Memory Usage:: Info about total size of Lisp objects made so far.
- * Writing Emacs Primitives:: Writing C code for Emacs.
- * Object Internals:: Data formats of buffers, windows, processes.
- File: elisp, Node: Building Emacs, Next: Pure Storage, Up: GNU Emacs Internals
- E.1 Building Emacs
- ==================
- This section explains the steps involved in building the Emacs
- executable. You don't have to know this material to build and install
- Emacs, since the makefiles do all these things automatically. This
- information is pertinent to Emacs developers.
- Compilation of the C source files in the `src' directory produces an
- executable file called `temacs', also called a "bare impure Emacs". It
- contains the Emacs Lisp interpreter and I/O routines, but not the
- editing commands.
- The command `temacs -l loadup' would run `temacs' and direct it to
- load `loadup.el'. The `loadup' library loads additional Lisp
- libraries, which set up the normal Emacs editing environment. After
- this step, the Emacs executable is no longer "bare".
- Because it takes some time to load the standard Lisp files, the
- `temacs' executable usually isn't run directly by users. Instead, as
- one of the last steps of building Emacs, the command `temacs -batch -l
- loadup dump' is run. The special `dump' argument causes `temacs' to
- dump out an executable program, called `emacs', which has all the
- standard Lisp files preloaded. (The `-batch' argument prevents
- `temacs' from trying to initialize any of its data on the terminal, so
- that the tables of terminal information are empty in the dumped Emacs.)
- The dumped `emacs' executable (also called a "pure" Emacs) is the
- one which is installed. The variable `preloaded-file-list' stores a
- list of the Lisp files preloaded into the dumped Emacs. If you port
- Emacs to a new operating system, and are not able to implement dumping,
- then Emacs must load `loadup.el' each time it starts.
- You can specify additional files to preload by writing a library
- named `site-load.el' that loads them. You may need to rebuild Emacs
- with an added definition
- #define SITELOAD_PURESIZE_EXTRA N
- to make N added bytes of pure space to hold the additional files; see
- `src/puresize.h'. (Try adding increments of 20000 until it is big
- enough.) However, the advantage of preloading additional files
- decreases as machines get faster. On modern machines, it is usually
- not advisable.
- After `loadup.el' reads `site-load.el', it finds the documentation
- strings for primitive and preloaded functions (and variables) in the
- file `etc/DOC' where they are stored, by calling `Snarf-documentation'
- (*note Accessing Documentation: Definition of Snarf-documentation.).
- You can specify other Lisp expressions to execute just before dumping
- by putting them in a library named `site-init.el'. This file is
- executed after the documentation strings are found.
- If you want to preload function or variable definitions, there are
- three ways you can do this and make their documentation strings
- accessible when you subsequently run Emacs:
- * Arrange to scan these files when producing the `etc/DOC' file, and
- load them with `site-load.el'.
- * Load the files with `site-init.el', then copy the files into the
- installation directory for Lisp files when you install Emacs.
- * Specify a `nil' value for `byte-compile-dynamic-docstrings' as a
- local variable in each of these files, and load them with either
- `site-load.el' or `site-init.el'. (This method has the drawback
- that the documentation strings take up space in Emacs all the
- time.)
- It is not advisable to put anything in `site-load.el' or
- `site-init.el' that would alter any of the features that users expect
- in an ordinary unmodified Emacs. If you feel you must override normal
- features for your site, do it with `default.el', so that users can
- override your changes if they wish. *Note Startup Summary::.
- In a package that can be preloaded, it is sometimes necessary (or
- useful) to delay certain evaluations until Emacs subsequently starts
- up. The vast majority of such cases relate to the values of
- customizable variables. For example, `tutorial-directory' is a
- variable defined in `startup.el', which is preloaded. The default
- value is set based on `data-directory'. The variable needs to access
- the value of `data-directory' when Emacs starts, not when it is dumped,
- because the Emacs executable has probably been installed in a different
- location since it was dumped.
- -- Function: custom-initialize-delay symbol value
- This function delays the initialization of SYMBOL to the next
- Emacs start. You normally use this function by specifying it as
- the `:initialize' property of a customizable variable. (The
- argument VALUE is unused, and is provided only for compatibility
- with the form Custom expects.)
- In the unlikely event that you need a more general functionality than
- `custom-initialize-delay' provides, you can use `before-init-hook'
- (*note Startup Summary::).
- -- Function: dump-emacs to-file from-file
- This function dumps the current state of Emacs into an executable
- file TO-FILE. It takes symbols from FROM-FILE (this is normally
- the executable file `temacs').
- If you want to use this function in an Emacs that was already
- dumped, you must run Emacs with `-batch'.
- File: elisp, Node: Pure Storage, Next: Garbage Collection, Prev: Building Emacs, Up: GNU Emacs Internals
- E.2 Pure Storage
- ================
- Emacs Lisp uses two kinds of storage for user-created Lisp objects:
- "normal storage" and "pure storage". Normal storage is where all the
- new data created during an Emacs session are kept (*note Garbage
- Collection::). Pure storage is used for certain data in the preloaded
- standard Lisp files--data that should never change during actual use of
- Emacs.
- Pure storage is allocated only while `temacs' is loading the
- standard preloaded Lisp libraries. In the file `emacs', it is marked
- as read-only (on operating systems that permit this), so that the
- memory space can be shared by all the Emacs jobs running on the machine
- at once. Pure storage is not expandable; a fixed amount is allocated
- when Emacs is compiled, and if that is not sufficient for the preloaded
- libraries, `temacs' allocates dynamic memory for the part that didn't
- fit. The resulting image will work, but garbage collection (*note
- Garbage Collection::) is disabled in this situation, causing a memory
- leak. Such an overflow normally won't happen unless you try to preload
- additional libraries or add features to the standard ones. Emacs will
- display a warning about the overflow when it starts. If this happens,
- you should increase the compilation parameter `SYSTEM_PURESIZE_EXTRA'
- in the file `src/puresize.h' and rebuild Emacs.
- -- Function: purecopy object
- This function makes a copy in pure storage of OBJECT, and returns
- it. It copies a string by simply making a new string with the same
- characters, but without text properties, in pure storage. It
- recursively copies the contents of vectors and cons cells. It does
- not make copies of other objects such as symbols, but just returns
- them unchanged. It signals an error if asked to copy markers.
- This function is a no-op except while Emacs is being built and
- dumped; it is usually called only in preloaded Lisp files.
- -- Variable: pure-bytes-used
- The value of this variable is the number of bytes of pure storage
- allocated so far. Typically, in a dumped Emacs, this number is
- very close to the total amount of pure storage available--if it
- were not, we would preallocate less.
- -- Variable: purify-flag
- This variable determines whether `defun' should make a copy of the
- function definition in pure storage. If it is non-`nil', then the
- function definition is copied into pure storage.
- This flag is `t' while loading all of the basic functions for
- building Emacs initially (allowing those functions to be shareable
- and non-collectible). Dumping Emacs as an executable always writes
- `nil' in this variable, regardless of the value it actually has
- before and after dumping.
- You should not change this flag in a running Emacs.
- File: elisp, Node: Garbage Collection, Next: Memory Usage, Prev: Pure Storage, Up: GNU Emacs Internals
- E.3 Garbage Collection
- ======================
- When a program creates a list or the user defines a new function (such
- as by loading a library), that data is placed in normal storage. If
- normal storage runs low, then Emacs asks the operating system to
- allocate more memory. Different types of Lisp objects, such as
- symbols, cons cells, markers, etc., are segregated in distinct blocks
- in memory. (Vectors, long strings, buffers and certain other editing
- types, which are fairly large, are allocated in individual blocks, one
- per object, while small strings are packed into blocks of 8k bytes.)
- It is quite common to use some storage for a while, then release it
- by (for example) killing a buffer or deleting the last pointer to an
- object. Emacs provides a "garbage collector" to reclaim this abandoned
- storage. The garbage collector operates by finding and marking all
- Lisp objects that are still accessible to Lisp programs. To begin
- with, it assumes all the symbols, their values and associated function
- definitions, and any data presently on the stack, are accessible. Any
- objects that can be reached indirectly through other accessible objects
- are also accessible.
- When marking is finished, all objects still unmarked are garbage. No
- matter what the Lisp program or the user does, it is impossible to refer
- to them, since there is no longer a way to reach them. Their space
- might as well be reused, since no one will miss them. The second
- ("sweep") phase of the garbage collector arranges to reuse them.
- The sweep phase puts unused cons cells onto a "free list" for future
- allocation; likewise for symbols and markers. It compacts the
- accessible strings so they occupy fewer 8k blocks; then it frees the
- other 8k blocks. Vectors, buffers, windows, and other large objects are
- individually allocated and freed using `malloc' and `free'.
- Common Lisp note: Unlike other Lisps, GNU Emacs Lisp does not call
- the garbage collector when the free list is empty. Instead, it
- simply requests the operating system to allocate more storage, and
- processing continues until `gc-cons-threshold' bytes have been
- used.
- This means that you can make sure that the garbage collector will
- not run during a certain portion of a Lisp program by calling the
- garbage collector explicitly just before it (provided that portion
- of the program does not use so much space as to force a second
- garbage collection).
- -- Command: garbage-collect
- This command runs a garbage collection, and returns information on
- the amount of space in use. (Garbage collection can also occur
- spontaneously if you use more than `gc-cons-threshold' bytes of
- Lisp data since the previous garbage collection.)
- `garbage-collect' returns a list containing the following
- information:
- ((USED-CONSES . FREE-CONSES)
- (USED-SYMS . FREE-SYMS)
- (USED-MISCS . FREE-MISCS)
- USED-STRING-CHARS
- USED-VECTOR-SLOTS
- (USED-FLOATS . FREE-FLOATS)
- (USED-INTERVALS . FREE-INTERVALS)
- (USED-STRINGS . FREE-STRINGS))
- Here is an example:
- (garbage-collect)
- => ((106886 . 13184) (9769 . 0)
- (7731 . 4651) 347543 121628
- (31 . 94) (1273 . 168)
- (25474 . 3569))
- Here is a table explaining each element:
- USED-CONSES
- The number of cons cells in use.
- FREE-CONSES
- The number of cons cells for which space has been obtained
- from the operating system, but that are not currently being
- used.
- USED-SYMS
- The number of symbols in use.
- FREE-SYMS
- The number of symbols for which space has been obtained from
- the operating system, but that are not currently being used.
- USED-MISCS
- The number of miscellaneous objects in use. These include
- markers and overlays, plus certain objects not visible to
- users.
- FREE-MISCS
- The number of miscellaneous objects for which space has been
- obtained from the operating system, but that are not
- currently being used.
- USED-STRING-CHARS
- The total size of all strings, in characters.
- USED-VECTOR-SLOTS
- The total number of elements of existing vectors.
- USED-FLOATS
- The number of floats in use.
- FREE-FLOATS
- The number of floats for which space has been obtained from
- the operating system, but that are not currently being used.
- USED-INTERVALS
- The number of intervals in use. Intervals are an internal
- data structure used for representing text properties.
- FREE-INTERVALS
- The number of intervals for which space has been obtained
- from the operating system, but that are not currently being
- used.
- USED-STRINGS
- The number of strings in use.
- FREE-STRINGS
- The number of string headers for which the space was obtained
- from the operating system, but which are currently not in
- use. (A string object consists of a header and the storage
- for the string text itself; the latter is only allocated when
- the string is created.)
- If there was overflow in pure space (*note Pure Storage::),
- `garbage-collect' returns `nil', because a real garbage collection
- cannot be done.
- -- User Option: garbage-collection-messages
- If this variable is non-`nil', Emacs displays a message at the
- beginning and end of garbage collection. The default value is
- `nil'.
- -- Variable: post-gc-hook
- This is a normal hook that is run at the end of garbage collection.
- Garbage collection is inhibited while the hook functions run, so be
- careful writing them.
- -- User Option: gc-cons-threshold
- The value of this variable is the number of bytes of storage that
- must be allocated for Lisp objects after one garbage collection in
- order to trigger another garbage collection. A cons cell counts
- as eight bytes, a string as one byte per character plus a few
- bytes of overhead, and so on; space allocated to the contents of
- buffers does not count. Note that the subsequent garbage
- collection does not happen immediately when the threshold is
- exhausted, but only the next time the Lisp evaluator is called.
- The initial threshold value is 800,000. If you specify a larger
- value, garbage collection will happen less often. This reduces the
- amount of time spent garbage collecting, but increases total
- memory use. You may want to do this when running a program that
- creates lots of Lisp data.
- You can make collections more frequent by specifying a smaller
- value, down to 10,000. A value less than 10,000 will remain in
- effect only until the subsequent garbage collection, at which time
- `garbage-collect' will set the threshold back to 10,000.
- -- User Option: gc-cons-percentage
- The value of this variable specifies the amount of consing before a
- garbage collection occurs, as a fraction of the current heap size.
- This criterion and `gc-cons-threshold' apply in parallel, and
- garbage collection occurs only when both criteria are satisfied.
- As the heap size increases, the time to perform a garbage
- collection increases. Thus, it can be desirable to do them less
- frequently in proportion.
- The value returned by `garbage-collect' describes the amount of
- memory used by Lisp data, broken down by data type. By contrast, the
- function `memory-limit' provides information on the total amount of
- memory Emacs is currently using.
- -- Function: memory-limit
- This function returns the address of the last byte Emacs has
- allocated, divided by 1024. We divide the value by 1024 to make
- sure it fits in a Lisp integer.
- You can use this to get a general idea of how your actions affect
- the memory usage.
- -- Variable: memory-full
- This variable is `t' if Emacs is nearly out of memory for Lisp
- objects, and `nil' otherwise.
- -- Function: memory-use-counts
- This returns a list of numbers that count the number of objects
- created in this Emacs session. Each of these counters increments
- for a certain kind of object. See the documentation string for
- details.
- -- Variable: gcs-done
- This variable contains the total number of garbage collections
- done so far in this Emacs session.
- -- Variable: gc-elapsed
- This variable contains the total number of seconds of elapsed time
- during garbage collection so far in this Emacs session, as a
- floating point number.
- File: elisp, Node: Memory Usage, Next: Writing Emacs Primitives, Prev: Garbage Collection, Up: GNU Emacs Internals
- E.4 Memory Usage
- ================
- These functions and variables give information about the total amount
- of memory allocation that Emacs has done, broken down by data type.
- Note the difference between these and the values returned by
- `garbage-collect'; those count objects that currently exist, but these
- count the number or size of all allocations, including those for
- objects that have since been freed.
- -- Variable: cons-cells-consed
- The total number of cons cells that have been allocated so far in
- this Emacs session.
- -- Variable: floats-consed
- The total number of floats that have been allocated so far in this
- Emacs session.
- -- Variable: vector-cells-consed
- The total number of vector cells that have been allocated so far
- in this Emacs session.
- -- Variable: symbols-consed
- The total number of symbols that have been allocated so far in
- this Emacs session.
- -- Variable: string-chars-consed
- The total number of string characters that have been allocated so
- far in this session.
- -- Variable: misc-objects-consed
- The total number of miscellaneous objects that have been allocated
- so far in this session. These include markers and overlays, plus
- certain objects not visible to users.
- -- Variable: intervals-consed
- The total number of intervals that have been allocated so far in
- this Emacs session.
- -- Variable: strings-consed
- The total number of strings that have been allocated so far in this
- Emacs session.
- File: elisp, Node: Writing Emacs Primitives, Next: Object Internals, Prev: Memory Usage, Up: GNU Emacs Internals
- E.5 Writing Emacs Primitives
- ============================
- Lisp primitives are Lisp functions implemented in C. The details of
- interfacing the C function so that Lisp can call it are handled by a few
- C macros. The only way to really understand how to write new C code is
- to read the source, but we can explain some things here.
- An example of a special form is the definition of `or', from
- `eval.c'. (An ordinary function would have the same general
- appearance.)
- DEFUN ("or", For, Sor, 0, UNEVALLED, 0,
- doc: /* Eval args until one of them yields non-nil, then return
- that value.
- The remaining args are not evalled at all.
- If all args return nil, return nil.
- usage: (or CONDITIONS ...) */)
- (Lisp_Object args)
- {
- register Lisp_Object val = Qnil;
- struct gcpro gcpro1;
- GCPRO1 (args);
- while (CONSP (args))
- {
- val = eval_sub (XCAR (args));
- if (!NILP (val))
- break;
- args = XCDR (args);
- }
- UNGCPRO;
- return val;
- }
- Let's start with a precise explanation of the arguments to the
- `DEFUN' macro. Here is a template for them:
- DEFUN (LNAME, FNAME, SNAME, MIN, MAX, INTERACTIVE, DOC)
- LNAME
- This is the name of the Lisp symbol to define as the function
- name; in the example above, it is `or'.
- FNAME
- This is the C function name for this function. This is the name
- that is used in C code for calling the function. The name is, by
- convention, `F' prepended to the Lisp name, with all dashes (`-')
- in the Lisp name changed to underscores. Thus, to call this
- function from C code, call `For'.
- SNAME
- This is a C variable name to use for a structure that holds the
- data for the subr object that represents the function in Lisp.
- This structure conveys the Lisp symbol name to the initialization
- routine that will create the symbol and store the subr object as
- its definition. By convention, this name is always FNAME with `F'
- replaced with `S'.
- MIN
- This is the minimum number of arguments that the function
- requires. The function `or' allows a minimum of zero arguments.
- MAX
- This is the maximum number of arguments that the function accepts,
- if there is a fixed maximum. Alternatively, it can be `UNEVALLED',
- indicating a special form that receives unevaluated arguments, or
- `MANY', indicating an unlimited number of evaluated arguments (the
- equivalent of `&rest'). Both `UNEVALLED' and `MANY' are macros.
- If MAX is a number, it must be more than MIN but less than 8.
- INTERACTIVE
- This is an interactive specification, a string such as might be
- used as the argument of `interactive' in a Lisp function. In the
- case of `or', it is 0 (a null pointer), indicating that `or'
- cannot be called interactively. A value of `""' indicates a
- function that should receive no arguments when called
- interactively. If the value begins with a `(', the string is
- evaluated as a Lisp form. For examples of the last two forms, see
- `widen' and `narrow-to-region' in `editfns.c'.
- DOC
- This is the documentation string. It uses C comment syntax rather
- than C string syntax because comment syntax requires nothing
- special to include multiple lines. The `doc:' identifies the
- comment that follows as the documentation string. The `/*' and
- `*/' delimiters that begin and end the comment are not part of the
- documentation string.
- If the last line of the documentation string begins with the
- keyword `usage:', the rest of the line is treated as the argument
- list for documentation purposes. This way, you can use different
- argument names in the documentation string from the ones used in
- the C code. `usage:' is required if the function has an unlimited
- number of arguments.
- All the usual rules for documentation strings in Lisp code (*note
- Documentation Tips::) apply to C code documentation strings too.
- After the call to the `DEFUN' macro, you must write the argument
- list for the C function, including the types for the arguments. If the
- primitive accepts a fixed maximum number of Lisp arguments, there must
- be one C argument for each Lisp argument, and each argument must be of
- type `Lisp_Object'. (Various macros and functions for creating values
- of type `Lisp_Object' are declared in the file `lisp.h'.) If the
- primitive has no upper limit on the number of Lisp arguments, it must
- have exactly two C arguments: the first is the number of Lisp
- arguments, and the second is the address of a block containing their
- values. These have types `int' and `Lisp_Object *' respectively.
- Within the function `For' itself, note the use of the macros
- `GCPRO1' and `UNGCPRO'. These macros are defined for the sake of the
- few platforms which do not use Emacs' default stack-marking garbage
- collector. The `GCPRO1' macro "protects" a variable from garbage
- collection, explicitly informing the garbage collector that that
- variable and all its contents must be as accessible. GC protection is
- necessary in any function which can perform Lisp evaluation by calling
- `eval_sub' or `Feval' as a subroutine, either directly or indirectly.
- It suffices to ensure that at least one pointer to each object is
- GC-protected. Thus, a particular local variable can do without
- protection if it is certain that the object it points to will be
- preserved by some other pointer (such as another local variable that
- has a `GCPRO'). Otherwise, the local variable needs a `GCPRO'.
- The macro `GCPRO1' protects just one local variable. If you want to
- protect two variables, use `GCPRO2' instead; repeating `GCPRO1' will
- not work. Macros `GCPRO3', `GCPRO4', `GCPRO5', and `GCPRO6' also
- exist. All these macros implicitly use local variables such as
- `gcpro1'; you must declare these explicitly, with type `struct gcpro'.
- Thus, if you use `GCPRO2', you must declare `gcpro1' and `gcpro2'.
- `UNGCPRO' cancels the protection of the variables that are protected
- in the current function. It is necessary to do this explicitly.
- You must not use C initializers for static or global variables unless
- the variables are never written once Emacs is dumped. These variables
- with initializers are allocated in an area of memory that becomes
- read-only (on certain operating systems) as a result of dumping Emacs.
- *Note Pure Storage::.
- Defining the C function is not enough to make a Lisp primitive
- available; you must also create the Lisp symbol for the primitive and
- store a suitable subr object in its function cell. The code looks like
- this:
- defsubr (&SNAME);
- Here SNAME is the name you used as the third argument to `DEFUN'.
- If you add a new primitive to a file that already has Lisp primitives
- defined in it, find the function (near the end of the file) named
- `syms_of_SOMETHING', and add the call to `defsubr' there. If the file
- doesn't have this function, or if you create a new file, add to it a
- `syms_of_FILENAME' (e.g., `syms_of_myfile'). Then find the spot in
- `emacs.c' where all of these functions are called, and add a call to
- `syms_of_FILENAME' there.
- The function `syms_of_FILENAME' is also the place to define any C
- variables that are to be visible as Lisp variables. `DEFVAR_LISP'
- makes a C variable of type `Lisp_Object' visible in Lisp. `DEFVAR_INT'
- makes a C variable of type `int' visible in Lisp with a value that is
- always an integer. `DEFVAR_BOOL' makes a C variable of type `int'
- visible in Lisp with a value that is either `t' or `nil'. Note that
- variables defined with `DEFVAR_BOOL' are automatically added to the list
- `byte-boolean-vars' used by the byte compiler.
- If you want to make a Lisp variables that is defined in C behave
- like one declared with `defcustom', add an appropriate entry to
- `cus-start.el'.
- If you define a file-scope C variable of type `Lisp_Object', you
- must protect it from garbage-collection by calling `staticpro' in
- `syms_of_FILENAME', like this:
- staticpro (&VARIABLE);
- Here is another example function, with more complicated arguments.
- This comes from the code in `window.c', and it demonstrates the use of
- macros and functions to manipulate Lisp objects.
- DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
- Scoordinates_in_window_p, 2, 2, 0,
- doc: /* Return non-nil if COORDINATES are in WINDOW.
- ...
- or `right-margin' is returned. */)
- (register Lisp_Object coordinates, Lisp_Object window)
- {
- struct window *w;
- struct frame *f;
- int x, y;
- Lisp_Object lx, ly;
- CHECK_LIVE_WINDOW (window);
- w = XWINDOW (window);
- f = XFRAME (w->frame);
- CHECK_CONS (coordinates);
- lx = Fcar (coordinates);
- ly = Fcdr (coordinates);
- CHECK_NUMBER_OR_FLOAT (lx);
- CHECK_NUMBER_OR_FLOAT (ly);
- x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH(f);
- y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly) + FRAME_INTERNAL_BORDER_WIDTH(f);
- switch (coordinates_in_window (w, x, y))
- {
- case ON_NOTHING: /* NOT in window at all. */
- return Qnil;
- ...
- case ON_MODE_LINE: /* In mode line of window. */
- return Qmode_line;
- ...
- case ON_SCROLL_BAR: /* On scroll-bar of window. */
- /* Historically we are supposed to return nil in this case. */
- return Qnil;
- default:
- abort ();
- }
- }
- Note that C code cannot call functions by name unless they are
- defined in C. The way to call a function written in Lisp is to use
- `Ffuncall', which embodies the Lisp function `funcall'. Since the Lisp
- function `funcall' accepts an unlimited number of arguments, in C it
- takes two: the number of Lisp-level arguments, and a one-dimensional
- array containing their values. The first Lisp-level argument is the
- Lisp function to call, and the rest are the arguments to pass to it.
- Since `Ffuncall' can call the evaluator, you must protect pointers from
- garbage collection around the call to `Ffuncall'.
- The C functions `call0', `call1', `call2', and so on, provide handy
- ways to call a Lisp function conveniently with a fixed number of
- arguments. They work by calling `Ffuncall'.
- `eval.c' is a very good file to look through for examples; `lisp.h'
- contains the definitions for some important macros and functions.
- If you define a function which is side-effect free, update the code
- in `byte-opt.el' that binds `side-effect-free-fns' and
- `side-effect-and-error-free-fns' so that the compiler optimizer knows
- about it.
- File: elisp, Node: Object Internals, Prev: Writing Emacs Primitives, Up: GNU Emacs Internals
- E.6 Object Internals
- ====================
- GNU Emacs Lisp manipulates many different types of data. The actual
- data are stored in a heap and the only access that programs have to it
- is through pointers. Each pointer is 32 bits wide on 32-bit machines,
- and 64 bits wide on 64-bit machines; three of these bits are used for
- the tag that identifies the object's type, and the remainder are used
- to address the object.
- Because Lisp objects are represented as tagged pointers, it is always
- possible to determine the Lisp data type of any object. The C data type
- `Lisp_Object' can hold any Lisp object of any data type. Ordinary
- variables have type `Lisp_Object', which means they can hold any type
- of Lisp value; you can determine the actual data type only at run time.
- The same is true for function arguments; if you want a function to
- accept only a certain type of argument, you must check the type
- explicitly using a suitable predicate (*note Type Predicates::).
- * Menu:
- * Buffer Internals:: Components of a buffer structure.
- * Window Internals:: Components of a window structure.
- * Process Internals:: Components of a process structure.
- File: elisp, Node: Buffer Internals, Next: Window Internals, Up: Object Internals
- E.6.1 Buffer Internals
- ----------------------
- Two structures (see `buffer.h') are used to represent buffers in C.
- The `buffer_text' structure contains fields describing the text of a
- buffer; the `buffer' structure holds other fields. In the case of
- indirect buffers, two or more `buffer' structures reference the same
- `buffer_text' structure.
- Here are some of the fields in `struct buffer_text':
- `beg'
- The address of the buffer contents.
- `gpt'
- `gpt_byte'
- The character and byte positions of the buffer gap. *Note Buffer
- Gap::.
- `z'
- `z_byte'
- The character and byte positions of the end of the buffer text.
- `gap_size'
- The size of buffer's gap. *Note Buffer Gap::.
- `modiff'
- `save_modiff'
- `chars_modiff'
- `overlay_modiff'
- These fields count the number of buffer-modification events
- performed in this buffer. `modiff' is incremented after each
- buffer-modification event, and is never otherwise changed;
- `save_modiff' contains the value of `modiff' the last time the
- buffer was visited or saved; `chars_modiff' counts only
- modifications to the characters in the buffer, ignoring all other
- kinds of changes; and `overlay_modiff' counts only modifications
- to the overlays.
- `beg_unchanged'
- `end_unchanged'
- The number of characters at the start and end of the text that are
- known to be unchanged since the last complete redisplay.
- `unchanged_modified'
- `overlay_unchanged_modified'
- The values of `modiff' and `overlay_modiff', respectively, after
- the last complete redisplay. If their current values match
- `modiff' or `overlay_modiff', that means `beg_unchanged' and
- `end_unchanged' contain no useful information.
- `markers'
- The markers that refer to this buffer. This is actually a single
- marker, and successive elements in its marker `chain' are the other
- markers referring to this buffer text.
- `intervals'
- The interval tree which records the text properties of this buffer.
- Some of the fields of `struct buffer' are:
- `header'
- A `struct vectorlike_header' structure where `header.next' points
- to the next buffer, in the chain of all buffers (including killed
- buffers). This chain is used only for garbage collection, in
- order to collect killed buffers properly. Note that vectors, and
- most kinds of objects allocated as vectors, are all on one chain,
- but buffers are on a separate chain of their own.
- `own_text'
- A `struct buffer_text' structure that ordinarily holds the buffer
- contents. In indirect buffers, this field is not used.
- `text'
- A pointer to the `buffer_text' structure for this buffer. In an
- ordinary buffer, this is the `own_text' field above. In an
- indirect buffer, this is the `own_text' field of the base buffer.
- `pt'
- `pt_byte'
- The character and byte positions of point in a buffer.
- `begv'
- `begv_byte'
- The character and byte positions of the beginning of the accessible
- range of text in the buffer.
- `zv'
- `zv_byte'
- The character and byte positions of the end of the accessible
- range of text in the buffer.
- `base_buffer'
- In an indirect buffer, this points to the base buffer. In an
- ordinary buffer, it is null.
- `local_flags'
- This field contains flags indicating that certain variables are
- local in this buffer. Such variables are declared in the C code
- using `DEFVAR_PER_BUFFER', and their buffer-local bindings are
- stored in fields in the buffer structure itself. (Some of these
- fields are described in this table.)
- `modtime'
- The modification time of the visited file. It is set when the
- file is written or read. Before writing the buffer into a file,
- this field is compared to the modification time of the file to see
- if the file has changed on disk. *Note Buffer Modification::.
- `auto_save_modified'
- The time when the buffer was last auto-saved.
- `last_window_start'
- The `window-start' position in the buffer as of the last time the
- buffer was displayed in a window.
- `clip_changed'
- This flag indicates that narrowing has changed in the buffer.
- *Note Narrowing::.
- `prevent_redisplay_optimizations_p'
- This flag indicates that redisplay optimizations should not be
- used to display this buffer.
- `overlay_center'
- This field holds the current overlay center position. *Note
- Managing Overlays::.
- `overlays_before'
- `overlays_after'
- These fields hold, respectively, a list of overlays that end at or
- before the current overlay center, and a list of overlays that end
- after the current overlay center. *Note Managing Overlays::.
- `overlays_before' is sorted in order of decreasing end position,
- and `overlays_after' is sorted in order of increasing beginning
- position.
- `name'
- A Lisp string that names the buffer. It is guaranteed to be
- unique. *Note Buffer Names::.
- `save_length'
- The length of the file this buffer is visiting, when last read or
- saved. This and other fields concerned with saving are not kept in
- the `buffer_text' structure because indirect buffers are never
- saved.
- `directory'
- The directory for expanding relative file names. This is the
- value of the buffer-local variable `default-directory' (*note File
- Name Expansion::).
- `filename'
- The name of the file visited in this buffer, or `nil'. This is
- the value of the buffer-local variable `buffer-file-name' (*note
- Buffer File Name::).
- `undo_list'
- `backed_up'
- `auto_save_file_name'
- `auto_save_file_format'
- `read_only'
- `file_format'
- `file_truename'
- `invisibility_spec'
- `display_count'
- `display_time'
- These fields store the values of Lisp variables that are
- automatically buffer-local (*note Buffer-Local Variables::), whose
- corresponding variable names have the additional prefix `buffer-'
- and have underscores replaced with dashes. For instance,
- `undo_list' stores the value of `buffer-undo-list'.
- `mark'
- The mark for the buffer. The mark is a marker, hence it is also
- included on the list `markers'. *Note The Mark::.
- `local_var_alist'
- The association list describing the buffer-local variable bindings
- of this buffer, not including the built-in buffer-local bindings
- that have special slots in the buffer object. (Those slots are
- omitted from this table.) *Note Buffer-Local Variables::.
- `major_mode'
- Symbol naming the major mode of this buffer, e.g., `lisp-mode'.
- `mode_name'
- Pretty name of the major mode, e.g., `"Lisp"'.
- `keymap'
- `abbrev_table'
- `syntax_table'
- `category_table'
- `display_table'
- These fields store the buffer's local keymap (*note Keymaps::),
- abbrev table (*note Abbrev Tables::), syntax table (*note Syntax
- Tables::), category table (*note Categories::), and display table
- (*note Display Tables::).
- `downcase_table'
- `upcase_table'
- `case_canon_table'
- These fields store the conversion tables for converting text to
- lower case, upper case, and for canonicalizing text for case-fold
- search. *Note Case Tables::.
- `minor_modes'
- An alist of the minor modes of this buffer.
- `pt_marker'
- `begv_marker'
- `zv_marker'
- These fields are only used in an indirect buffer, or in a buffer
- that is the base of an indirect buffer. Each holds a marker that
- records `pt', `begv', and `zv' respectively, for this buffer when
- the buffer is not current.
- `mode_line_format'
- `header_line_format'
- `case_fold_search'
- `tab_width'
- `fill_column'
- `left_margin'
- `auto_fill_function'
- `truncate_lines'
- `word_wrap'
- `ctl_arrow'
- `bidi_display_reordering'
- `bidi_paragraph_direction'
- `selective_display'
- `selective_display_ellipses'
- `overwrite_mode'
- `abbrev_mode'
- `mark_active'
- `enable_multibyte_characters'
- `buffer_file_coding_system'
- `cache_long_line_scans'
- `point_before_scroll'
- `left_fringe_width'
- `right_fringe_width'
- `fringes_outside_margins'
- `scroll_bar_width'
- `indicate_empty_lines'
- `indicate_buffer_boundaries'
- `fringe_indicator_alist'
- `fringe_cursor_alist'
- `scroll_up_aggressively'
- `scroll_down_aggressively'
- `cursor_type'
- `cursor_in_non_selected_windows'
- These fields store the values of Lisp variables that are
- automatically buffer-local (*note Buffer-Local Variables::), whose
- corresponding variable names have underscores replaced with
- dashes. For instance, `mode_line_format' stores the value of
- `mode-line-format'.
- `last_selected_window'
- This is the last window that was selected with this buffer in it,
- or `nil' if that window no longer displays this buffer.
- File: elisp, Node: Window Internals, Next: Process Internals, Prev: Buffer Internals, Up: Object Internals
- E.6.2 Window Internals
- ----------------------
- The fields of a window (for a complete list, see the definition of
- `struct window' in `window.h') include:
- `frame'
- The frame that this window is on.
- `mini_p'
- Non-`nil' if this window is a minibuffer window.
- `parent'
- Internally, Emacs arranges windows in a tree; each group of
- siblings has a parent window whose area includes all the siblings.
- This field points to a window's parent.
- Parent windows do not display buffers, and play little role in
- display except to shape their child windows. Emacs Lisp programs
- usually have no access to the parent windows; they operate on the
- windows at the leaves of the tree, which actually display buffers.
- `hchild'
- `vchild'
- These fields contain the window's leftmost child and its topmost
- child respectively. `hchild' is used if the window is subdivided
- horizontally by child windows, and `vchild' if it is subdivided
- vertically. In a live window, only one of `hchild', `vchild', and
- `buffer' (q.v.) is non-`nil'.
- `next'
- `prev'
- The next sibling and previous sibling of this window. `next' is
- `nil' if the window is the right-most or bottom-most in its group;
- `prev' is `nil' if it is the left-most or top-most in its group.
- `left_col'
- The left-hand edge of the window, measured in columns, relative to
- the leftmost column in the frame (column 0).
- `top_line'
- The top edge of the window, measured in lines, relative to the
- topmost line in the frame (line 0).
- `total_cols'
- `total_lines'
- The width and height of the window, measured in columns and lines
- respectively. The width includes the scroll bar and fringes,
- and/or the separator line on the right of the window (if any).
- `buffer'
- The buffer that the window is displaying.
- `start'
- A marker pointing to the position in the buffer that is the first
- character displayed in the window.
- `pointm'
- This is the value of point in the current buffer when this window
- is selected; when it is not selected, it retains its previous
- value.
- `force_start'
- If this flag is non-`nil', it says that the window has been
- scrolled explicitly by the Lisp program. This affects what the
- next redisplay does if point is off the screen: instead of
- scrolling the window to show the text around point, it moves point
- to a location that is on the screen.
- `frozen_window_start_p'
- This field is set temporarily to 1 to indicate to redisplay that
- `start' of this window should not be changed, even if point gets
- invisible.
- `start_at_line_beg'
- Non-`nil' means current value of `start' was the beginning of a
- line when it was chosen.
- `use_time'
- This is the last time that the window was selected. The function
- `get-lru-window' uses this field.
- `sequence_number'
- A unique number assigned to this window when it was created.
- `last_modified'
- The `modiff' field of the window's buffer, as of the last time a
- redisplay completed in this window.
- `last_overlay_modified'
- The `overlay_modiff' field of the window's buffer, as of the last
- time a redisplay completed in this window.
- `last_point'
- The buffer's value of point, as of the last time a redisplay
- completed in this window.
- `last_had_star'
- A non-`nil' value means the window's buffer was "modified" when the
- window was last updated.
- `vertical_scroll_bar'
- This window's vertical scroll bar.
- `left_margin_cols'
- `right_margin_cols'
- The widths of the left and right margins in this window. A value
- of `nil' means no margin.
- `left_fringe_width'
- `right_fringe_width'
- The widths of the left and right fringes in this window. A value
- of `nil' or `t' means use the values of the frame.
- `fringes_outside_margins'
- A non-`nil' value means the fringes outside the display margins;
- othersize they are between the margin and the text.
- `window_end_pos'
- This is computed as `z' minus the buffer position of the last glyph
- in the current matrix of the window. The value is only valid if
- `window_end_valid' is not `nil'.
- `window_end_bytepos'
- The byte position corresponding to `window_end_pos'.
- `window_end_vpos'
- The window-relative vertical position of the line containing
- `window_end_pos'.
- `window_end_valid'
- This field is set to a non-`nil' value if `window_end_pos' is truly
- valid. This is `nil' if nontrivial redisplay is pre-empted, since
- in that case the display that `window_end_pos' was computed for
- did not get onto the screen.
- `cursor'
- A structure describing where the cursor is in this window.
- `last_cursor'
- The value of `cursor' as of the last redisplay that finished.
- `phys_cursor'
- A structure describing where the cursor of this window physically
- is.
- `phys_cursor_type'
- `phys_cursor_height'
- `phys_cursor_width'
- The type, height, and width of the cursor that was last displayed
- on this window.
- `phys_cursor_on_p'
- This field is non-zero if the cursor is physically on.
- `cursor_off_p'
- Non-zero means the cursor in this window is logically off. This is
- used for blinking the cursor.
- `last_cursor_off_p'
- This field contains the value of `cursor_off_p' as of the time of
- the last redisplay.
- `must_be_updated_p'
- This is set to 1 during redisplay when this window must be updated.
- `hscroll'
- This is the number of columns that the display in the window is
- scrolled horizontally to the left. Normally, this is 0.
- `vscroll'
- Vertical scroll amount, in pixels. Normally, this is 0.
- `dedicated'
- Non-`nil' if this window is dedicated to its buffer.
- `display_table'
- The window's display table, or `nil' if none is specified for it.
- `update_mode_line'
- Non-`nil' means this window's mode line needs to be updated.
- `base_line_number'
- The line number of a certain position in the buffer, or `nil'.
- This is used for displaying the line number of point in the mode
- line.
- `base_line_pos'
- The position in the buffer for which the line number is known, or
- `nil' meaning none is known. If it is a buffer, don't display the
- line number as long as the window shows that buffer.
- `region_showing'
- If the region (or part of it) is highlighted in this window, this
- field holds the mark position that made one end of that region.
- Otherwise, this field is `nil'.
- `column_number_displayed'
- The column number currently displayed in this window's mode line,
- or `nil' if column numbers are not being displayed.
- `current_matrix'
- `desired_matrix'
- Glyph matrices describing the current and desired display of this
- window.
- File: elisp, Node: Process Internals, Prev: Window Internals, Up: Object Internals
- E.6.3 Process Internals
- -----------------------
- The fields of a process (for a complete list, see the definition of
- `struct Lisp_Process' in `process.h') include:
- `name'
- A string, the name of the process.
- `command'
- A list containing the command arguments that were used to start
- this process. For a network or serial process, it is `nil' if the
- process is running or `t' if the process is stopped.
- `filter'
- If non-`nil', a function used to accept output from the process
- instead of a buffer.
- `sentinel'
- If non-`nil', a function called whenever the state of the process
- changes.
- `buffer'
- The associated buffer of the process.
- `pid'
- An integer, the operating system's process ID. Pseudo-processes
- such as network or serial connections use a value of 0.
- `childp'
- A flag, `t' if this is really a child process. For a network or
- serial connection, it is a plist based on the arguments to
- `make-network-process' or `make-serial-process'.
- `mark'
- A marker indicating the position of the end of the last output
- from this process inserted into the buffer. This is often but not
- always the end of the buffer.
- `kill_without_query'
- If this is non-zero, killing Emacs while this process is still
- running does not ask for confirmation about killing the process.
- `raw_status'
- The raw process status, as returned by the `wait' system call.
- `status'
- The process status, as `process-status' should return it.
- `tick'
- `update_tick'
- If these two fields are not equal, a change in the status of the
- process needs to be reported, either by running the sentinel or by
- inserting a message in the process buffer.
- `pty_flag'
- Non-`nil' if communication with the subprocess uses a PTY; `nil'
- if it uses a pipe.
- `infd'
- The file descriptor for input from the process.
- `outfd'
- The file descriptor for output to the process.
- `tty_name'
- The name of the terminal that the subprocess is using, or `nil' if
- it is using pipes.
- `decode_coding_system'
- Coding-system for decoding the input from this process.
- `decoding_buf'
- A working buffer for decoding.
- `decoding_carryover'
- Size of carryover in decoding.
- `encode_coding_system'
- Coding-system for encoding the output to this process.
- `encoding_buf'
- A working buffer for encoding.
- `inherit_coding_system_flag'
- Flag to set `coding-system' of the process buffer from the coding
- system used to decode process output.
- `type'
- Symbol indicating the type of process: `real', `network', `serial'.
- File: elisp, Node: Standard Errors, Next: Standard Keymaps, Prev: GNU Emacs Internals, Up: Top
- Appendix F Standard Errors
- **************************
- Here is a list of the more important error symbols in standard Emacs,
- grouped by concept. The list includes each symbol's message (on the
- `error-message' property of the symbol) and a cross reference to a
- description of how the error can occur.
- Each error symbol has an `error-conditions' property that is a list
- of symbols. Normally this list includes the error symbol itself and
- the symbol `error'. Occasionally it includes additional symbols, which
- are intermediate classifications, narrower than `error' but broader
- than a single error symbol. For example, all the errors in accessing
- files have the condition `file-error'. If we do not say here that a
- certain error symbol has additional error conditions, that means it has
- none.
- As a special exception, the error symbol `quit' does not have the
- condition `error', because quitting is not considered an error.
- Most of these error symbols are defined in C (mainly `data.c'), but
- some are defined in Lisp. For example, the file `userlock.el' defines
- the `file-locked' and `file-supersession' errors. Several of the
- specialized Lisp libraries distributed with Emacs define their own
- error symbols. We do not attempt to list of all those here.
- *Note Errors::, for an explanation of how errors are generated and
- handled.
- `error'
- `"error"'
- *Note Errors::.
- `quit'
- `"Quit"'
- *Note Quitting::.
- `args-out-of-range'
- `"Args out of range"'
- This happens when trying to access an element beyond the range of a
- sequence or buffer.
- *Note Sequences Arrays Vectors::, *Note Text::.
- `arith-error'
- `"Arithmetic error"'
- *Note Arithmetic Operations::.
- `beginning-of-buffer'
- `"Beginning of buffer"'
- *Note Character Motion::.
- `buffer-read-only'
- `"Buffer is read-only"'
- *Note Read Only Buffers::.
- `circular-list'
- `"List contains a loop"'
- This happens when some operations (e.g. resolving face names)
- encounter circular structures.
- *Note Circular Objects::.
- `cl-assertion-failed'
- `"Assertion failed"'
- This happens when the `assert' macro fails a test.
- *Note Assertions: (cl)Assertions.
- `coding-system-error'
- `"Invalid coding system"'
- *Note Lisp and Coding Systems::.
- `cyclic-function-indirection'
- `"Symbol's chain of function indirections contains a loop"'
- *Note Function Indirection::.
- `cyclic-variable-indirection'
- `"Symbol's chain of variable indirections contains a loop"'
- *Note Variable Aliases::.
- `dbus-error'
- `"D-Bus error"'
- This is only defined if Emacs was compiled with D-Bus support.
- *Note Errors and Events: (dbus)Errors and Events.
- `end-of-buffer'
- `"End of buffer"'
- *Note Character Motion::.
- `end-of-file'
- `"End of file during parsing"'
- Note that this is not a subcategory of `file-error', because it
- pertains to the Lisp reader, not to file I/O.
- *Note Input Functions::.
- `file-already-exists'
- This is a subcategory of `file-error'.
- *Note Writing to Files::.
- `file-date-error'
- This is a subcategory of `file-error'. It occurs when `copy-file'
- tries and fails to set the last-modification time of the output
- file.
- *Note Changing Files::.
- `file-error'
- We do not list the error-strings of this error and its
- subcategories, because the error message is normally constructed
- from the data items alone when the error condition `file-error' is
- present. Thus, the error-strings are not very relevant. However,
- these error symbols do have `error-message' properties, and if no
- data is provided, the `error-message' property _is_ used.
- *Note Files::.
- `compression-error'
- This is a subcategory of `file-error', which results from problems
- handling a compressed file.
- *Note How Programs Do Loading::.
- `file-locked'
- This is a subcategory of `file-error'.
- *Note File Locks::.
- `file-supersession'
- This is a subcategory of `file-error'.
- *Note Modification Time::.
- `ftp-error'
- This is a subcategory of `file-error', which results from problems
- in accessing a remote file using ftp.
- *Note Remote Files: (emacs)Remote Files.
- `invalid-function'
- `"Invalid function"'
- *Note Function Indirection::.
- `invalid-read-syntax'
- `"Invalid read syntax"'
- *Note Printed Representation::.
- `invalid-regexp'
- `"Invalid regexp"'
- *Note Regular Expressions::.
- `mark-inactive'
- `"The mark is not active now"'
- *Note The Mark::.
- `no-catch'
- `"No catch for tag"'
- *Note Catch and Throw::.
- `scan-error'
- `"Scan error"'
- This happens when certain syntax-parsing functions find invalid
- syntax or mismatched parentheses.
- *Note List Motion::, and *note Parsing Expressions::.
- `search-failed'
- `"Search failed"'
- *Note Searching and Matching::.
- `setting-constant'
- `"Attempt to set a constant symbol"'
- The values of the symbols `nil' and `t', and any symbols that
- start with `:', may not be changed.
- *Note Variables that Never Change: Constant Variables.
- `text-read-only'
- `"Text is read-only"'
- This is a subcategory of `buffer-read-only'.
- *Note Special Properties::.
- `undefined-color'
- `"Undefined color"'
- *Note Color Names::.
- `void-function'
- `"Symbol's function definition is void"'
- *Note Function Cells::.
- `void-variable'
- `"Symbol's value as variable is void"'
- *Note Accessing Variables::.
- `wrong-number-of-arguments'
- `"Wrong number of arguments"'
- *Note Classifying Lists::.
- `wrong-type-argument'
- `"Wrong type argument"'
- *Note Type Predicates::.
- The following kinds of error, which are classified as special cases
- of `arith-error', can occur on certain systems for invalid use of
- mathematical functions. *Note Math Functions::.
- `domain-error'
- `"Arithmetic domain error"'
- `overflow-error'
- `"Arithmetic overflow error"'
- This is a subcategory of `domain-error'.
- `range-error'
- `"Arithmetic range error"'
- `singularity-error'
- `"Arithmetic singularity error"'
- This is a subcategory of `domain-error'.
- `underflow-error'
- `"Arithmetic underflow error"'
- This is a subcategory of `domain-error'.
- File: elisp, Node: Standard Keymaps, Next: Standard Hooks, Prev: Standard Errors, Up: Top
- Appendix G Standard Keymaps
- ***************************
- In this section we list some of the more general keymaps. Many of
- these exist when Emacs is first started, but some are loaded only when
- the respective feature is accessed.
- There are many other, more specialized, maps than these; in
- particular those associated with major and minor modes. The minibuffer
- uses several keymaps (*note Completion Commands::). For more details on
- keymaps, *note Keymaps::.
- `2C-mode-map'
- A sparse keymap for subcommands of the prefix `C-x 6'.
- *Note Two-Column Editing: (emacs)Two-Column.
- `abbrev-map'
- A sparse keymap for subcommands of the prefix `C-x a'.
- *Note Defining Abbrevs: (emacs)Defining Abbrevs.
- `button-buffer-map'
- A sparse keymap useful for buffers containing buffers.
- You may want to use this as a parent keymap. *Note Buttons::.
- `button-map'
- A sparse keymap used by buttons.
- `ctl-x-4-map'
- A sparse keymap for subcommands of the prefix `C-x 4'.
- `ctl-x-5-map'
- A sparse keymap for subcommands of the prefix `C-x 5'.
- `ctl-x-map'
- A full keymap for `C-x' commands.
- `ctl-x-r-map'
- A sparse keymap for subcommands of the prefix `C-x r'.
- *Note Registers: (emacs)Registers.
- `esc-map'
- A full keymap for `ESC' (or `Meta') commands.
- `facemenu-keymap'
- A sparse keymap used for the `M-o' prefix key.
- `function-key-map'
- The parent keymap of all `local-function-key-map' (q.v.) instances.
- `global-map'
- The full keymap containing default global key bindings.
- Modes should not modify the Global map.
- `goto-map'
- A sparse keymap used for the `M-g' prefix key.
- `help-map'
- A sparse keymap for the keys following the help character `C-h'.
- *Note Help Functions::.
- `Helper-help-map'
- A full keymap used by the help utility package.
- It has the same keymap in its value cell and in its function cell.
- `input-decode-map'
- The keymap for translating keypad and function keys.
- If there are none, then it contains an empty sparse keymap. *Note
- Translation Keymaps::.
- `key-translation-map'
- A keymap for translating keys. This one overrides ordinary key
- bindings, unlike `local-function-key-map'. *Note Translation
- Keymaps::.
- `kmacro-keymap'
- A sparse keymap for keys that follows the `C-x C-k' prefix search.
- *Note Keyboard Macros: (emacs)Keyboard Macros.
- `local-function-key-map'
- The keymap for translating key sequences to preferred alternatives.
- If there are none, then it contains an empty sparse keymap. *Note
- Translation Keymaps::.
- `menu-bar-file-menu'
- `menu-bar-edit-menu'
- `menu-bar-options-menu'
- `global-buffers-menu-map'
- `menu-bar-tools-menu'
- `menu-bar-help-menu'
- These keymaps display the main, top-level menus in the menu bar.
- Some of them contain sub-menus. For example, the Edit menu
- contains `menu-bar-search-menu', etc. *Note Menu Bar::.
- `minibuffer-inactive-mode-map'
- A full keymap used in the minibuffer when it is not active.
- *Note Editing in the Minibuffer: (emacs)Minibuffer Edit.
- `mode-line-coding-system-map'
- `mode-line-input-method-map'
- `mode-line-column-line-number-mode-map'
- These keymaps control various areas of the mode line.
- *Note Mode Line Format::.
- `mode-specific-map'
- The keymap for characters following `C-c'. Note, this is in the
- global map. This map is not actually mode-specific: its name was
- chosen to be informative in `C-h b' (`display-bindings'), where it
- describes the main use of the `C-c' prefix key.
- `mouse-appearance-menu-map'
- A sparse keymap used for the `S-mouse-1' key.
- `mule-keymap'
- The global keymap used for the `C-x <RET>' prefix key.
- `narrow-map'
- A sparse keymap for subcommands of the prefix `C-x n'.
- `prog-mode-map'
- The keymap used by Prog mode.
- *Note Basic Major Modes::.
- `query-replace-map'
- `multi-query-replace-map'
- A sparse keymap used for responses in `query-replace' and related
- commands; also for `y-or-n-p' and `map-y-or-n-p'. The functions
- that use this map do not support prefix keys; they look up one
- event at a time. `multi-query-replace-map' extends
- `query-replace-map' for multi-buffer replacements. *Note
- query-replace-map: Search and Replace.
- `search-map'
- A sparse keymap that provides global bindings for search-related
- commands.
- `special-mode-map'
- The keymap used by Special mode.
- *Note Basic Major Modes::.
- `tool-bar-map'
- The keymap defining the contents of the tool bar.
- *Note Tool Bar::.
- `universal-argument-map'
- A sparse keymap used while processing `C-u'.
- *Note Prefix Command Arguments::.
- `vc-prefix-map'
- The global keymap used for the `C-x v' prefix key.
- `x-alternatives-map'
- A sparse keymap used to map certain keys under graphical frames.
- The function `x-setup-function-keys' uses this.
- File: elisp, Node: Standard Hooks, Next: Index, Prev: Standard Keymaps, Up: Top
- Appendix H Standard Hooks
- *************************
- The following is a list of some hook variables that let you provide
- functions to be called from within Emacs on suitable occasions.
- Most of these variables have names ending with `-hook'. They are
- "normal hooks", run by means of `run-hooks'. The value of such a hook
- is a list of functions; the functions are called with no arguments and
- their values are completely ignored. The recommended way to put a new
- function on such a hook is to call `add-hook'. *Note Hooks::, for more
- information about using hooks.
- The variables whose names end in `-hooks' or `-functions' are
- usually "abnormal hooks"; their values are lists of functions, but
- these functions are called in a special way (they are passed arguments,
- or their values are used). The variables whose names end in `-function'
- have single functions as their values.
- This is not an exhaustive list, it only covers the more general
- hooks. For example, every major mode defines a hook named
- `MODENAME-mode-hook'. The major mode command runs this normal hook
- with `run-mode-hooks' as the very last thing it does. *Note Mode
- Hooks::. Most minor modes have mode hooks too.
- A special feature allows you to specify expressions to evaluate if
- and when a file is loaded (*note Hooks for Loading::). That feature is
- not exactly a hook, but does a similar job.
- `activate-mark-hook'
- `deactivate-mark-hook'
- *Note The Mark::.
- `after-change-functions'
- `before-change-functions'
- `first-change-hook'
- *Note Change Hooks::.
- `after-change-major-mode-hook'
- `change-major-mode-after-body-hook'
- *Note Mode Hooks::.
- `after-init-hook'
- `before-init-hook'
- `emacs-startup-hook'
- *Note Init File::.
- `after-insert-file-functions'
- `write-region-annotate-functions'
- `write-region-post-annotation-function'
- *Note Format Conversion::.
- `after-make-frame-functions'
- `before-make-frame-hook'
- *Note Creating Frames::.
- `after-save-hook'
- `before-save-hook'
- `write-contents-functions'
- `write-file-functions'
- *Note Saving Buffers::.
- `after-setting-font-hook'
- Hook run after a frame's font changes.
- `auto-save-hook'
- *Note Auto-Saving::.
- `before-hack-local-variables-hook'
- `hack-local-variables-hook'
- *Note File Local Variables::.
- `buffer-access-fontify-functions'
- *Note Lazy Properties::.
- `buffer-list-update-hook'
- Hook run when the buffer list changes.
- `buffer-quit-function'
- Function to call to "quit" the current buffer.
- `change-major-mode-hook'
- *Note Creating Buffer-Local::.
- `command-line-functions'
- *Note Command-Line Arguments::.
- `delayed-warnings-hook'
- The command loop runs this soon after `post-command-hook' (q.v.).
- `delete-frame-functions'
- *Note Deleting Frames::.
- `delete-terminal-functions'
- *Note Multiple Terminals::.
- `display-buffer-function'
- `pop-up-frame-function'
- `special-display-function'
- `split-window-preferred-function'
- *Note Choosing Window Options::.
- `echo-area-clear-hook'
- *Note Echo Area Customization::.
- `find-file-hook'
- `find-file-not-found-functions'
- *Note Visiting Functions::.
- `font-lock-extend-after-change-region-function'
- *Note Region to Refontify::.
- `font-lock-extend-region-functions'
- *Note Multiline Font Lock::.
- `font-lock-fontify-buffer-function'
- `font-lock-fontify-region-function'
- `font-lock-mark-block-function'
- `font-lock-unfontify-buffer-function'
- `font-lock-unfontify-region-function'
- *Note Other Font Lock Variables::.
- `fontification-functions'
- *Note Automatic Face Assignment: Auto Faces.
- `frame-auto-hide-function'
- *Note Quitting Windows::.
- `kill-buffer-hook'
- `kill-buffer-query-functions'
- *Note Killing Buffers::.
- `kill-emacs-hook'
- `kill-emacs-query-functions'
- *Note Killing Emacs::.
- `menu-bar-update-hook'
- *Note Menu Bar::.
- `minibuffer-setup-hook'
- `minibuffer-exit-hook'
- *Note Minibuffer Misc::.
- `mouse-leave-buffer-hook'
- Hook run when about to switch windows with a mouse command.
- `mouse-position-function'
- *Note Mouse Position::.
- `post-command-hook'
- `pre-command-hook'
- *Note Command Overview::.
- `post-gc-hook'
- *Note Garbage Collection::.
- `post-self-insert-hook'
- *Note Keymaps and Minor Modes::.
- `suspend-hook'
- `suspend-resume-hook'
- `suspend-tty-functions'
- `resume-tty-functions'
- *Note Suspending Emacs::.
- `syntax-begin-function'
- `syntax-propertize-extend-region-functions'
- `syntax-propertize-function'
- `font-lock-syntactic-face-function'
- *Note Syntactic Font Lock::. *Note Syntax Properties::.
- `temp-buffer-setup-hook'
- `temp-buffer-show-function'
- `temp-buffer-show-hook'
- *Note Temporary Displays::.
- `term-setup-hook'
- *Note Terminal-Specific::.
- `window-configuration-change-hook'
- `window-scroll-functions'
- `window-size-change-functions'
- *Note Window Hooks::.
- `window-setup-hook'
- *Note Window Systems::.
- `window-text-change-functions'
- Functions to call in redisplay when text in the window might
- change.
- Local Variables:
- coding: iso-8859-1
- End:
|