123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508 |
- (require 'find-file nil t)
- (require 'align nil t)
- (require 'which-func nil t)
- (require 'compile nil t)
- (defvar ispell-check-comments)
- (defvar skeleton-further-elements)
- (defun ada-mode-version ()
- "Return Ada mode version."
- (interactive)
- (let ((version-string "4.00"))
- (if (called-interactively-p 'interactive)
- (message version-string)
- version-string)))
- (defvar ada-mode-hook nil
- "*List of functions to call when Ada mode is invoked.
- This hook is automatically executed after the `ada-mode' is
- fully loaded.
- This is a good place to add Ada environment specific bindings.")
- (defgroup ada nil
- "Major mode for editing and compiling Ada source in Emacs."
- :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
- :group 'languages)
- (defcustom ada-auto-case t
- "*Non-nil means automatically change case of preceding word while typing.
- Casing is done according to `ada-case-keyword', `ada-case-identifier'
- and `ada-case-attribute'."
- :type 'boolean :group 'ada)
- (defcustom ada-broken-decl-indent 0
- "*Number of columns to indent a broken declaration.
- An example is :
- declare
- A,
- >>>>>B : Integer;"
- :type 'integer :group 'ada)
- (defcustom ada-broken-indent 2
- "*Number of columns to indent the continuation of a broken line.
- An example is :
- My_Var : My_Type := (Field1 =>
- >>>>>>>>>Value);"
- :type 'integer :group 'ada)
- (defcustom ada-continuation-indent ada-broken-indent
- "*Number of columns to indent the continuation of broken lines in parenthesis.
- An example is :
- Func (Param1,
- >>>>>Param2);"
- :type 'integer :group 'ada)
- (defcustom ada-case-attribute 'ada-capitalize-word
- "*Function to call to adjust the case of Ada attributes.
- It may be `downcase-word', `upcase-word', `ada-loose-case-word',
- `ada-capitalize-word' or `ada-no-auto-case'."
- :type '(choice (const downcase-word)
- (const upcase-word)
- (const ada-capitalize-word)
- (const ada-loose-case-word)
- (const ada-no-auto-case))
- :group 'ada)
- (defcustom ada-case-exception-file
- (list (convert-standard-filename' "~/.emacs_case_exceptions"))
- "*List of special casing exceptions dictionaries for identifiers.
- The first file is the one where new exceptions will be saved by Emacs
- when you call `ada-create-case-exception'.
- These files should contain one word per line, that gives the casing
- to be used for that word in Ada files. If the line starts with the
- character *, then the exception will be used for substrings that either
- start at the beginning of a word or after a _ character, and end either
- at the end of the word or at a _ character. Each line can be terminated
- by a comment."
- :type '(repeat (file))
- :group 'ada)
- (defcustom ada-case-keyword 'downcase-word
- "*Function to call to adjust the case of an Ada keywords.
- It may be `downcase-word', `upcase-word', `ada-loose-case-word' or
- `ada-capitalize-word'."
- :type '(choice (const downcase-word)
- (const upcase-word)
- (const ada-capitalize-word)
- (const ada-loose-case-word)
- (const ada-no-auto-case))
- :group 'ada)
- (defcustom ada-case-identifier 'ada-loose-case-word
- "*Function to call to adjust the case of an Ada identifier.
- It may be `downcase-word', `upcase-word', `ada-loose-case-word' or
- `ada-capitalize-word'."
- :type '(choice (const downcase-word)
- (const upcase-word)
- (const ada-capitalize-word)
- (const ada-loose-case-word)
- (const ada-no-auto-case))
- :group 'ada)
- (defcustom ada-clean-buffer-before-saving t
- "*Non-nil means remove trailing spaces and untabify the buffer before saving."
- :type 'boolean :group 'ada)
- (make-obsolete-variable 'ada-clean-buffer-before-saving
- "use the `write-file-functions' hook."
- "23.2")
- (defcustom ada-indent 3
- "*Size of Ada indentation.
- An example is :
- procedure Foo is
- begin
- >>>>>>>>>>null;"
- :type 'integer :group 'ada)
- (defcustom ada-indent-after-return t
- "*Non-nil means automatically indent after RET or LFD."
- :type 'boolean :group 'ada)
- (defcustom ada-indent-align-comments t
- "*Non-nil means align comments on previous line comments, if any.
- If nil, indentation is calculated as usual.
- Note that indentation is calculated only if `ada-indent-comment-as-code' is t.
- For instance:
- A := 1; -- A multi-line comment
- -- aligned if `ada-indent-align-comments' is t"
- :type 'boolean :group 'ada)
- (defcustom ada-indent-comment-as-code t
- "*Non-nil means indent comment lines as code.
- A nil value means do not auto-indent comments."
- :type 'boolean :group 'ada)
- (defcustom ada-indent-handle-comment-special nil
- "*Non-nil if comment lines should be handled specially inside parenthesis.
- By default, if the line that contains the open parenthesis has some
- text following it, then the following lines will be indented in the
- same column as this text. This will not be true if the first line is
- a comment and `ada-indent-handle-comment-special' is t.
- type A is
- ( Value_1, -- common behavior, when not a comment
- Value_2);
- type A is
- ( -- `ada-indent-handle-comment-special' is nil
- Value_1,
- Value_2);
- type A is
- ( -- `ada-indent-handle-comment-special' is non-nil
- Value_1,
- Value_2);"
- :type 'boolean :group 'ada)
- (defcustom ada-indent-is-separate t
- "*Non-nil means indent 'is separate' or 'is abstract' if on a single line."
- :type 'boolean :group 'ada)
- (defcustom ada-indent-record-rel-type 3
- "*Indentation for 'record' relative to 'type' or 'use'.
- An example is:
- type A is
- >>>>>>>>>>>record"
- :type 'integer :group 'ada)
- (defcustom ada-indent-renames ada-broken-indent
- "*Indentation for renames relative to the matching function statement.
- If `ada-indent-return' is null or negative, the indentation is done relative to
- the open parenthesis (if there is no parenthesis, `ada-broken-indent' is used).
- An example is:
- function A (B : Integer)
- return C;
- >>>renames Foo;"
- :type 'integer :group 'ada)
- (defcustom ada-indent-return 0
- "*Indentation for 'return' relative to the matching 'function' statement.
- If `ada-indent-return' is null or negative, the indentation is done relative to
- the open parenthesis (if there is no parenthesis, `ada-broken-indent' is used).
- An example is:
- function A (B : Integer)
- >>>>>return C;"
- :type 'integer :group 'ada)
- (defcustom ada-indent-to-open-paren t
- "*Non-nil means indent according to the innermost open parenthesis."
- :type 'boolean :group 'ada)
- (defcustom ada-fill-comment-prefix "-- "
- "*Text inserted in the first columns when filling a comment paragraph.
- Note: if you modify this variable, you will have to invoke `ada-mode'
- again to take account of the new value."
- :type 'string :group 'ada)
- (defcustom ada-fill-comment-postfix " --"
- "*Text inserted at the end of each line when filling a comment paragraph.
- Used by `ada-fill-comment-paragraph-postfix'."
- :type 'string :group 'ada)
- (defcustom ada-label-indent -4
- "*Number of columns to indent a label.
- An example is:
- procedure Foo is
- begin
- >>>>Label:
- This is also used for <<..>> labels"
- :type 'integer :group 'ada)
- (defcustom ada-language-version 'ada95
- "*Ada language version; one of `ada83', `ada95', `ada2005'."
- :type '(choice (const ada83) (const ada95) (const ada2005)) :group 'ada)
- (defcustom ada-move-to-declaration nil
- "*Non-nil means `ada-move-to-start' moves to the subprogram declaration, not to 'begin'."
- :type 'boolean :group 'ada)
- (defcustom ada-popup-key '[down-mouse-3]
- "*Key used for binding the contextual menu.
- If nil, no contextual menu is available."
- :type '(restricted-sexp :match-alternatives (stringp vectorp))
- :group 'ada)
- (defcustom ada-search-directories
- (append '(".")
- (split-string (or (getenv "ADA_INCLUDE_PATH") "") ":")
- '("/usr/adainclude" "/usr/local/adainclude"
- "/opt/gnu/adainclude"))
- "*Default list of directories to search for Ada files.
- See the description for the `ff-search-directories' variable. This variable
- is the initial value of `ada-search-directories-internal'."
- :type '(repeat (choice :tag "Directory"
- (const :tag "default" nil)
- (directory :format "%v")))
- :group 'ada)
- (defvar ada-search-directories-internal ada-search-directories
- "Internal version of `ada-search-directories'.
- Its value is the concatenation of the search path as read in the project file
- and the standard runtime location, and the value of the user-defined
- `ada-search-directories'.")
- (defcustom ada-stmt-end-indent 0
- "*Number of columns to indent the end of a statement on a separate line.
- An example is:
- if A = B
- >>>>then"
- :type 'integer :group 'ada)
- (defcustom ada-tab-policy 'indent-auto
- "*Control the behavior of the TAB key.
- Must be one of :
- `indent-rigidly' : always adds `ada-indent' blanks at the beginning of the line.
- `indent-auto' : use indentation functions in this file.
- `always-tab' : do `indent-relative'."
- :type '(choice (const indent-auto)
- (const indent-rigidly)
- (const always-tab))
- :group 'ada)
- (defcustom ada-use-indent ada-broken-indent
- "*Indentation for the lines in a 'use' statement.
- An example is:
- use Ada.Text_IO,
- >>>>Ada.Numerics;"
- :type 'integer :group 'ada)
- (defcustom ada-when-indent 3
- "*Indentation for 'when' relative to 'exception' or 'case'.
- An example is:
- case A is
- >>>>when B =>"
- :type 'integer :group 'ada)
- (defcustom ada-with-indent ada-broken-indent
- "*Indentation for the lines in a 'with' statement.
- An example is:
- with Ada.Text_IO,
- >>>>Ada.Numerics;"
- :type 'integer :group 'ada)
- (defcustom ada-which-compiler 'gnat
- "*Name of the compiler to use.
- This will determine what features are made available through the Ada mode.
- The possible choices are:
- `gnat': Use Ada Core Technologies' GNAT compiler. Add some cross-referencing
- features.
- `generic': Use a generic compiler."
- :type '(choice (const gnat)
- (const generic))
- :group 'ada)
- (defvar ada-body-suffixes '(".adb")
- "List of possible suffixes for Ada body files.
- The extensions should include a `.' if needed.")
- (defvar ada-spec-suffixes '(".ads")
- "List of possible suffixes for Ada spec files.
- The extensions should include a `.' if needed.")
- (defvar ada-mode-menu (make-sparse-keymap "Ada")
- "Menu for Ada mode.")
- (defvar ada-mode-map (make-sparse-keymap)
- "Local keymap used for Ada mode.")
- (defvar ada-mode-extra-map (make-sparse-keymap)
- "Keymap used for non-standard keybindings.")
- (defvar ada-mode-extra-prefix "\C-c\C-q"
- "Prefix key to access `ada-mode-extra-map' functions.")
- (defvar ada-mode-abbrev-table nil
- "Local abbrev table for Ada mode.")
- (define-abbrev-table 'ada-mode-abbrev-table ())
- (defvar ada-mode-syntax-table nil
- "Syntax table to be used for editing Ada source code.")
- (defvar ada-mode-symbol-syntax-table nil
- "Syntax table for Ada, where `_' is a word constituent.")
- (eval-when-compile
-
- (defconst ada-83-string-keywords
- '("abort" "abs" "accept" "access" "all" "and" "array" "at" "begin"
- "body" "case" "constant" "declare" "delay" "delta" "digits" "do"
- "else" "elsif" "end" "entry" "exception" "exit" "for" "function"
- "generic" "goto" "if" "in" "is" "limited" "loop" "mod" "new"
- "not" "null" "of" "or" "others" "out" "package" "pragma" "private"
- "procedure" "raise" "range" "record" "rem" "renames" "return"
- "reverse" "select" "separate" "subtype" "task" "terminate" "then"
- "type" "use" "when" "while" "with" "xor")
- "List of Ada 83 keywords.
- Used to define `ada-*-keywords'.")
- (defconst ada-95-string-keywords
- '("abstract" "aliased" "protected" "requeue" "tagged" "until")
- "List of keywords new in Ada 95.
- Used to define `ada-*-keywords'.")
- (defconst ada-2005-string-keywords
- '("interface" "overriding" "synchronized")
- "List of keywords new in Ada 2005.
- Used to define `ada-*-keywords.'"))
- (defvar ada-ret-binding nil
- "Variable to save key binding of RET when casing is activated.")
- (defvar ada-case-exception '()
- "Alist of words (entities) that have special casing.")
- (defvar ada-case-exception-substring '()
- "Alist of substrings (entities) that have special casing.
- The substrings are detected for word constituent when the word
- is not itself in `ada-case-exception', and only for substrings that
- either are at the beginning or end of the word, or start after '_'.")
- (defvar ada-lfd-binding nil
- "Variable to save key binding of LFD when casing is activated.")
- (defvar ada-other-file-alist nil
- "Variable used by `find-file' to find the name of the other package.
- See `ff-other-file-alist'.")
- (defvar ada-align-list
- '(("[^:]\\(\\s-*\\):[^:]" 1 t)
- ("[^=]\\(\\s-+\\)=[^=]" 1 t)
- ("\\(\\s-*\\)use\\s-" 1)
- ("\\(\\s-*\\)--" 1))
- "Ada support for align.el <= 2.2.
- This variable provides regular expressions on which to align different lines.
- See `align-mode-alist' for more information.")
- (defvar ada-align-modes
- '((ada-declaration
- (regexp . "[^:]\\(\\s-*\\):[^:]")
- (valid . (lambda() (not (ada-in-comment-p))))
- (modes . '(ada-mode)))
- (ada-assignment
- (regexp . "[^=]\\(\\s-+\\)=[^=]")
- (valid . (lambda() (not (ada-in-comment-p))))
- (modes . '(ada-mode)))
- (ada-comment
- (regexp . "\\(\\s-*\\)--")
- (modes . '(ada-mode)))
- (ada-use
- (regexp . "\\(\\s-*\\)use\\s-")
- (valid . (lambda() (not (ada-in-comment-p))))
- (modes . '(ada-mode)))
- )
- "Ada support for align.el >= 2.8.
- This variable defines several rules to use to align different lines.")
- (defconst ada-align-region-separate
- (eval-when-compile
- (concat
- "^\\s-*\\($\\|\\("
- "begin\\|"
- "declare\\|"
- "else\\|"
- "end\\|"
- "exception\\|"
- "for\\|"
- "function\\|"
- "generic\\|"
- "if\\|"
- "is\\|"
- "procedure\\|"
- "record\\|"
- "return\\|"
- "type\\|"
- "when"
- "\\)\\>\\)"))
- "See the variable `align-region-separate' for more information.")
- (defconst ada-83-keywords
- (eval-when-compile
- (concat "\\<" (regexp-opt ada-83-string-keywords t) "\\>"))
- "Regular expression matching Ada83 keywords.")
- (defconst ada-95-keywords
- (eval-when-compile
- (concat "\\<" (regexp-opt
- (append
- ada-95-string-keywords
- ada-83-string-keywords) t) "\\>"))
- "Regular expression matching Ada95 keywords.")
- (defconst ada-2005-keywords
- (eval-when-compile
- (concat "\\<" (regexp-opt
- (append
- ada-2005-string-keywords
- ada-83-string-keywords
- ada-95-string-keywords) t) "\\>"))
- "Regular expression matching Ada2005 keywords.")
- (defvar ada-keywords ada-2005-keywords
- "Regular expression matching Ada keywords.")
- (defconst ada-ident-re
- "[[:alpha:]]\\(?:[_[:alnum:]]\\)*"
-
-
-
-
- "Regexp matching an Ada identifier.")
- (defconst ada-goto-label-re
- (concat "<<" ada-ident-re ">>")
- "Regexp matching a goto label.")
- (defconst ada-block-label-re
- (concat ada-ident-re "[ \t\n]*:[^=]")
- "Regexp matching a block label.
- Note that this also matches a variable declaration.")
- (defconst ada-label-re
- (concat "\\(?:" ada-block-label-re "\\)\\|\\(?:" ada-goto-label-re "\\)")
- "Regexp matching a goto or block label.")
- (defvar ada-procedure-start-regexp
- (concat
- "^[ \t]*\\(with[ \t]+\\)?\\(\\(not[ \t]+\\)?overriding[ \t]+\\)?\\(procedure\\|function\\|task\\)[ \t\n]+"
-
- "\\("
- "\\(\"[^\"]+\"\\)"
-
- "\\|"
- "\\(\\(\\sw\\|[_.]\\)+\\)"
- "\\)")
- "Regexp matching Ada subprogram start.
- The actual start is at (match-beginning 4). The name is in (match-string 5).")
- (defconst ada-name-regexp
- "\\([a-zA-Z][a-zA-Z0-9_.']*[a-zA-Z0-9]\\)"
- "Regexp matching a fully qualified name (including attribute).")
- (defconst ada-package-start-regexp
- (concat "^[ \t]*\\(private[ \t]+\\)?\\(package\\)[ \t\n]+\\(body[ \t]*\\)?" ada-name-regexp)
- "Regexp matching start of package.
- The package name is in (match-string 4).")
- (defconst ada-compile-goto-error-file-linenr-re
- "\\([-_.a-zA-Z0-9]+\\):\\([0-9]+\\)\\(:\\([0-9]+\\)\\)?"
- "Regexp matching filename:linenr[:column].")
- (defvar ada-block-start-re
- (eval-when-compile
- (concat "\\<\\(" (regexp-opt '("begin" "declare" "else"
- "exception" "generic" "loop" "or"
- "private" "select" ))
- "\\|\\(\\(limited\\|abstract\\|tagged\\)[ \t\n]+\\)*record\\)\\>"))
- "Regexp for keywords starting Ada blocks.")
- (defvar ada-end-stmt-re
- (eval-when-compile
- (concat "\\("
- ";" "\\|"
- "=>[ \t]*$" "\\|"
- "=>[ \t]*--.*$" "\\|"
- "^[ \t]*separate[ \t]*(\\(\\sw\\|[_.]\\)+)" "\\|"
- "\\<" (regexp-opt '("begin" "declare" "is" "do" "else" "generic"
- "loop" "private" "record" "select"
- "then abort" "then") t) "\\>" "\\|"
- "^[ \t]*" (regexp-opt '("function" "package" "procedure")
- t) "\\>\\(\\sw\\|[ \t_.]\\)+\\<is\\>" "\\|"
- "^[ \t]*exception\\>"
- "\\)") )
- "Regexp of possible ends for a non-broken statement.
- A new statement starts after these.")
- (defvar ada-matching-start-re
- (eval-when-compile
- (concat "\\<"
- (regexp-opt
- '("end" "loop" "select" "begin" "case" "do" "declare"
- "if" "task" "package" "procedure" "function" "record" "protected") t)
- "\\>"))
- "Regexp used in `ada-goto-matching-start'.")
- (defvar ada-loop-start-re
- "\\<\\(for\\|while\\|loop\\)\\>"
- "Regexp for the start of a loop.")
- (defvar ada-subprog-start-re
- (eval-when-compile
- (concat "\\<" (regexp-opt '("accept" "entry" "function" "overriding" "package" "procedure"
- "protected" "task") t) "\\>"))
- "Regexp for the start of a subprogram.")
- (defvar ada-contextual-menu-on-identifier nil
- "Set to true when the right mouse button was clicked on an identifier.")
- (defvar ada-contextual-menu-last-point nil
- "Position of point just before displaying the menu.
- This is a list (point buffer).
- Since `ada-popup-menu' moves the point where the user clicked, the region
- is modified. Therefore no command from the menu knows what the user selected
- before displaying the contextual menu.
- To get the original region, restore the point to this position before
- calling `region-end' and `region-beginning'.
- Modify this variable if you want to restore the point to another position.")
- (easy-menu-define ada-contextual-menu nil
- "Menu to use when the user presses the right mouse button.
- The variable `ada-contextual-menu-on-identifier' will be set to t before
- displaying the menu if point was on an identifier."
- '("Ada"
- ["Goto Declaration/Body" ada-point-and-xref
- :included ada-contextual-menu-on-identifier]
- ["Goto Body" ada-point-and-xref-body
- :included ada-contextual-menu-on-identifier]
- ["Goto Previous Reference" ada-xref-goto-previous-reference]
- ["List References" ada-find-references
- :included ada-contextual-menu-on-identifier]
- ["List Local References" ada-find-local-references
- :included ada-contextual-menu-on-identifier]
- ["-" nil nil]
- ["Other File" ff-find-other-file]
- ["Goto Parent Unit" ada-goto-parent]))
- (defconst ada-imenu-comment-re "\\([ \t]*--.*\\)?")
- (defconst ada-imenu-subprogram-menu-re
- (concat "^[ \t]*\\(overriding[ \t]*\\)?\\(procedure\\|function\\)[ \t\n]+"
- "\\(\\(\\sw\\|_\\)+\\)[ \t\n]*\\([ \t\n]\\|([^)]+)"
- ada-imenu-comment-re
- "\\)[ \t\n]*"
- "\\(return[ \t\n]+\\(\\sw\\|[_.]\\)+[ \t\n]*\\)?is[ \t\n]"))
- (defvar ada-imenu-generic-expression
- (list
- (list nil ada-imenu-subprogram-menu-re 3)
- (list "*Specs*"
- (concat
- "^[ \t]*\\(procedure\\|function\\)[ \t\n]+\\(\\(\\sw\\|_\\)+\\)"
- "\\("
- "\\(" ada-imenu-comment-re "[ \t\n]+\\|[ \t\n]*([^)]+)"
- ada-imenu-comment-re "\\)"
- "\\([ \t\n]*return[ \t\n]+\\(\\sw\\|[_.]\\)+[ \t\n]*\\)?"
- "\\)?;") 2)
- '("*Tasks*" "^[ \t]*task[ \t]+\\(type[ \t]+\\)?\\(\\(body[ \t]+\\)?\\(\\sw\\|_\\)+\\)" 2)
- '("*Type Defs*" "^[ \t]*\\(sub\\)?type[ \t]+\\(\\(\\sw\\|_\\)+\\)" 2)
- '("*Protected*"
- "^[ \t]*protected[ \t]+\\(type[ \t]+\\)?\\(\\(body[ \t]+\\)?\\(\\sw\\|_\\)+\\)" 2)
- '("*Packages*" "^[ \t]*package[ \t]+\\(\\(body[ \t]+\\)?\\(\\sw\\|[_.]\\)+\\)" 1))
- "Imenu generic expression for Ada mode.
- See `imenu-generic-expression'. This variable will create several submenus for
- each type of entity that can be found in an Ada file.")
- (defun ada-compile-mouse-goto-error ()
- "Mouse interface for `ada-compile-goto-error'."
- (interactive)
- (mouse-set-point last-input-event)
- (ada-compile-goto-error (point))
- )
- (defun ada-compile-goto-error (pos)
- "Replace `compile-goto-error' from compile.el.
- If POS is on a file and line location, go to this position. It adds
- to compile.el the capacity to go to a reference in an error message.
- For instance, on these lines:
- foo.adb:61:11: [...] in call to size declared at foo.ads:11
- foo.adb:61:11: [...] in call to local declared at line 20
- the 4 file locations can be clicked on and jumped to."
- (interactive "d")
- (goto-char pos)
- (skip-chars-backward "-a-zA-Z0-9_:./\\")
- (cond
-
-
- ((and (not (bolp))
- (or (looking-at ada-compile-goto-error-file-linenr-re)
- (and
- (save-excursion
- (beginning-of-line)
- (looking-at ada-compile-goto-error-file-linenr-re))
- (save-excursion
- (if (looking-at "\\([0-9]+\\)") (backward-word 1))
- (looking-at "line \\([0-9]+\\)"))))
- )
- (let ((line (if (match-beginning 2) (match-string 2) (match-string 1)))
- (file (if (match-beginning 2) (match-string 1)
- (save-excursion (beginning-of-line)
- (looking-at ada-compile-goto-error-file-linenr-re)
- (match-string 1))))
- (error-pos (point-marker))
- source)
-
- (save-excursion
- (compilation-find-file (point-marker) (match-string 1) "./")
- (set-buffer file)
- (when (stringp line)
- (goto-char (point-min))
- (forward-line (1- (string-to-number line))))
- (setq source (point-marker)))
- (compilation-goto-locus error-pos source nil)
- ))
-
- (t
- (compile-goto-error))
- )
- (recenter))
- (defun ada-create-syntax-table ()
- "Create the two syntax tables use in the Ada mode.
- The standard table declares `_' as a symbol constituent, the second one
- declares it as a word constituent."
- (interactive)
- (setq ada-mode-syntax-table (make-syntax-table))
-
-
-
- (modify-syntax-entry ?% "$" ada-mode-syntax-table)
- (modify-syntax-entry ?\" "\"" ada-mode-syntax-table)
- (modify-syntax-entry ?: "." ada-mode-syntax-table)
- (modify-syntax-entry ?\
- (modify-syntax-entry ?& "." ada-mode-syntax-table)
- (modify-syntax-entry ?\| "." ada-mode-syntax-table)
- (modify-syntax-entry ?+ "." ada-mode-syntax-table)
- (modify-syntax-entry ?* "." ada-mode-syntax-table)
- (modify-syntax-entry ?/ "." ada-mode-syntax-table)
- (modify-syntax-entry ?= "." ada-mode-syntax-table)
- (modify-syntax-entry ?< "." ada-mode-syntax-table)
- (modify-syntax-entry ?> "." ada-mode-syntax-table)
- (modify-syntax-entry ?$ "." ada-mode-syntax-table)
- (modify-syntax-entry ?\[ "." ada-mode-syntax-table)
- (modify-syntax-entry ?\] "." ada-mode-syntax-table)
- (modify-syntax-entry ?\{ "." ada-mode-syntax-table)
- (modify-syntax-entry ?\} "." ada-mode-syntax-table)
- (modify-syntax-entry ?. "." ada-mode-syntax-table)
- (modify-syntax-entry ?\\ "." ada-mode-syntax-table)
- (modify-syntax-entry ?\' "." ada-mode-syntax-table)
-
- (modify-syntax-entry ?- ". 12" ada-mode-syntax-table)
-
-
- (if (featurep 'xemacs)
- (modify-syntax-entry ?# "<" ada-mode-syntax-table)
- (modify-syntax-entry ?# "$" ada-mode-syntax-table))
-
- (modify-syntax-entry ?\f "> " ada-mode-syntax-table)
- (modify-syntax-entry ?\n "> " ada-mode-syntax-table)
-
- (modify-syntax-entry ?_ "_" ada-mode-syntax-table)
-
- (modify-syntax-entry ?\( "()" ada-mode-syntax-table)
- (modify-syntax-entry ?\) ")(" ada-mode-syntax-table)
- (setq ada-mode-symbol-syntax-table (copy-syntax-table ada-mode-syntax-table))
- (modify-syntax-entry ?_ "w" ada-mode-symbol-syntax-table)
- )
- (if (featurep 'xemacs)
- (defadvice parse-partial-sexp (around parse-partial-sexp-protect-constants)
- "Handles special character constants and gnatprep statements."
- (let (change)
- (if (< to from)
- (let ((tmp from))
- (setq from to to tmp)))
- (save-excursion
- (goto-char from)
- (while (re-search-forward "'\\([(\")#]\\)'" to t)
- (setq change (cons (list (match-beginning 1)
- 1
- (match-string 1))
- change))
- (replace-match "'A'"))
- (goto-char from)
- (while (re-search-forward "\\(#[0-9a-fA-F]*#\\)" to t)
- (setq change (cons (list (match-beginning 1)
- (length (match-string 1))
- (match-string 1))
- change))
- (replace-match (make-string (length (match-string 1)) ?@))))
- ad-do-it
- (save-excursion
- (while change
- (goto-char (caar change))
- (delete-char (cadar change))
- (insert (caddar change))
- (setq change (cdr change)))))))
- (unless (eval-when-compile (fboundp 'syntax-propertize-via-font-lock))
-
-
-
-
- (defun ada-set-syntax-table-properties ()
- "Assign `syntax-table' properties in accessible part of buffer.
- In particular, character constants are said to be strings, #...#
- are treated as numbers instead of gnatprep comments."
- (let ((modified (buffer-modified-p))
- (buffer-undo-list t)
- (inhibit-read-only t)
- (inhibit-point-motion-hooks t)
- (inhibit-modification-hooks t))
- (remove-text-properties (point-min) (point-max) '(syntax-table nil))
- (goto-char (point-min))
- (while (re-search-forward
-
-
- "^[ \t]*\\(#\\(?:if\\|else\\|elsif\\|end\\)\\)\\|[^a-zA-Z0-9)]\\('\\)[^'\n]\\('\\)"
- nil t)
- (if (match-beginning 1)
- (put-text-property
- (match-beginning 1) (match-end 1) 'syntax-table '(11 . ?\n))
- (put-text-property
- (match-beginning 2) (match-end 2) 'syntax-table '(7 . ?'))
- (put-text-property
- (match-beginning 3) (match-end 3) 'syntax-table '(7 . ?'))))
- (unless modified
- (restore-buffer-modified-p nil))))
- (defun ada-after-change-function (beg end _old-len)
- "Called when the region between BEG and END was changed in the buffer.
- OLD-LEN indicates what the length of the replaced text was."
- (save-excursion
- (save-restriction
- (let ((from (progn (goto-char beg) (line-beginning-position)))
- (to (progn (goto-char end) (line-end-position))))
- (narrow-to-region from to)
- (save-match-data
- (ada-set-syntax-table-properties))))))
- (defun ada-initialize-syntax-table-properties ()
- "Assign `syntax-table' properties in current buffer."
- (save-excursion
- (save-restriction
- (widen)
- (save-match-data
- (ada-set-syntax-table-properties))))
- (add-hook 'after-change-functions 'ada-after-change-function nil t))
- (defun ada-handle-syntax-table-properties ()
- "Handle `syntax-table' properties."
- (if font-lock-mode
-
- (remove-hook 'after-change-functions 'ada-after-change-function t)
-
- (ada-initialize-syntax-table-properties)))
- )
- (defsubst ada-in-comment-p (&optional parse-result)
- "Return t if inside a comment.
- If PARSE-RESULT is non-nil, use it instead of calling `parse-partial-sexp'."
- (nth 4 (or parse-result
- (parse-partial-sexp
- (line-beginning-position) (point)))))
- (defsubst ada-in-string-p (&optional parse-result)
- "Return t if point is inside a string.
- If PARSE-RESULT is non-nil, use it instead of calling `parse-partial-sexp'."
- (nth 3 (or parse-result
- (parse-partial-sexp
- (line-beginning-position) (point)))))
- (defsubst ada-in-string-or-comment-p (&optional parse-result)
- "Return t if inside a comment or string.
- If PARSE-RESULT is non-nil, use it instead of calling `parse-partial-sexp'."
- (setq parse-result (or parse-result
- (parse-partial-sexp
- (line-beginning-position) (point))))
- (or (ada-in-string-p parse-result) (ada-in-comment-p parse-result)))
- (defsubst ada-in-numeric-literal-p ()
- "Return t if point is after a prefix of a numeric literal."
- (looking-back "\\([0-9]+#[0-9a-fA-F_]+\\)"))
- (defun ada-call-from-contextual-menu (function)
- "Execute FUNCTION when called from the contextual menu.
- It forces Emacs to change the cursor position."
- (interactive)
- (funcall function)
- (setq ada-contextual-menu-last-point
- (list (point) (current-buffer))))
- (defun ada-popup-menu (position)
- "Pops up a contextual menu, depending on where the user clicked.
- POSITION is the location the mouse was clicked on.
- Sets `ada-contextual-menu-last-point' to the current position before
- displaying the menu. When a function from the menu is called, the
- point is where the mouse button was clicked."
- (interactive "e")
-
-
-
- (let ((deactivate-mark nil))
- (setq ada-contextual-menu-last-point
- (list (point) (current-buffer)))
- (mouse-set-point last-input-event)
- (setq ada-contextual-menu-on-identifier
- (and (char-after)
- (or (= (char-syntax (char-after)) ?w)
- (= (char-after) ?_))
- (not (ada-in-string-or-comment-p))
- (save-excursion (skip-syntax-forward "w")
- (not (ada-after-keyword-p)))
- ))
- (if (fboundp 'popup-menu)
- (funcall (symbol-function 'popup-menu) ada-contextual-menu)
- (let (choice)
- (setq choice (x-popup-menu position ada-contextual-menu))
- (if choice
- (funcall (lookup-key ada-contextual-menu (vector (car choice)))))))
- (set-buffer (cadr ada-contextual-menu-last-point))
- (goto-char (car ada-contextual-menu-last-point))
- ))
- (defun ada-add-extensions (spec body)
- "Define SPEC and BODY as being valid extensions for Ada files.
- Going from body to spec with `ff-find-other-file' used these
- extensions.
- SPEC and BODY are two regular expressions that must match against
- the file name."
- (let* ((reg (concat (regexp-quote body) "$"))
- (tmp (assoc reg ada-other-file-alist)))
- (if tmp
- (setcdr tmp (list (cons spec (cadr tmp))))
- (add-to-list 'ada-other-file-alist (list reg (list spec)))))
- (let* ((reg (concat (regexp-quote spec) "$"))
- (tmp (assoc reg ada-other-file-alist)))
- (if tmp
- (setcdr tmp (list (cons body (cadr tmp))))
- (add-to-list 'ada-other-file-alist (list reg (list body)))))
- (add-to-list 'auto-mode-alist
- (cons (concat (regexp-quote spec) "\\'") 'ada-mode))
- (add-to-list 'auto-mode-alist
- (cons (concat (regexp-quote body) "\\'") 'ada-mode))
- (add-to-list 'ada-spec-suffixes spec)
- (add-to-list 'ada-body-suffixes body)
-
-
- (if (fboundp 'speedbar-add-supported-extension)
- (progn
- (funcall (symbol-function 'speedbar-add-supported-extension)
- spec)
- (funcall (symbol-function 'speedbar-add-supported-extension)
- body))))
- (defvar ada-font-lock-syntactic-keywords)
- (define-derived-mode ada-mode prog-mode "Ada"
- "Ada mode is the major mode for editing Ada code."
-
-
- (set (make-local-variable 'paragraph-start) "[ \t\n\f]*$")
- (set (make-local-variable 'paragraph-separate) "[ \t\n\f]*$")
-
-
- (set (make-local-variable 'comment-end) "")
-
- (set (make-local-variable 'comment-start-skip) "---*[ \t]*")
-
-
-
-
-
- (set (make-local-variable 'comment-line-break-function)
- (lambda (&optional soft) (let ((fill-prefix nil))
- (indent-new-comment-line soft))))
- (set (make-local-variable 'indent-line-function)
- 'ada-indent-current-function)
- (set (make-local-variable 'comment-column) 40)
-
-
-
- (unless (featurep 'xemacs)
- (set (make-local-variable 'parse-sexp-ignore-comments) t)
- (set (make-local-variable 'comment-padding) 0)
- (set (make-local-variable 'parse-sexp-lookup-properties) t))
- (setq case-fold-search t)
- (if (boundp 'imenu-case-fold-search)
- (setq imenu-case-fold-search t))
- (set (make-local-variable 'fill-paragraph-function)
- 'ada-fill-comment-paragraph)
-
-
- (add-hook 'compilation-mode-hook
- (lambda()
-
- (define-key compilation-minor-mode-map [mouse-2]
- 'ada-compile-mouse-goto-error)
- (define-key compilation-minor-mode-map "\C-c\C-c"
- 'ada-compile-goto-error)
- (define-key compilation-minor-mode-map "\C-m"
- 'ada-compile-goto-error)))
-
- (set (make-local-variable 'font-lock-defaults)
- '(ada-font-lock-keywords
- nil t
- ((?\_ . "w") (?# . "."))
- beginning-of-line))
- (if (eval-when-compile (fboundp 'syntax-propertize-via-font-lock))
- (set (make-local-variable 'syntax-propertize-function)
- (syntax-propertize-via-font-lock ada-font-lock-syntactic-keywords))
- (set (make-local-variable 'font-lock-syntactic-keywords)
- ada-font-lock-syntactic-keywords))
-
- (set (make-local-variable 'ff-other-file-alist)
- 'ada-other-file-alist)
- (set (make-local-variable 'ff-search-directories)
- 'ada-search-directories-internal)
- (setq ff-post-load-hook 'ada-set-point-accordingly
- ff-file-created-hook 'ada-make-body)
- (add-hook 'ff-pre-load-hook 'ada-which-function-are-we-in)
- (make-local-variable 'ff-special-constructs)
- (mapc (lambda (pair) (add-to-list 'ff-special-constructs pair))
- (list
-
- (cons (eval-when-compile
- (concat "^\\(private[ \t]\\)?[ \t]*package[ \t]+"
- "\\(body[ \t]+\\)?"
- "\\(\\(\\sw\\|[_.]\\)+\\)\\.\\(\\sw\\|_\\)+[ \t\n]+is"))
- (lambda ()
- (ff-get-file
- ada-search-directories-internal
- (ada-make-filename-from-adaname (match-string 3))
- ada-spec-suffixes)))
-
- (cons "^separate[ \t\n]*(\\(\\(\\sw\\|[_.]\\)+\\))"
- (lambda ()
- (ff-get-file
- ada-search-directories-internal
- (ada-make-filename-from-adaname (match-string 1))
- ada-spec-suffixes)))
-
- (cons "^with[ \t]+\\([a-zA-Z0-9_\\.]+\\)"
- (lambda ()
- (ff-get-file
- ada-search-directories-internal
- (ada-make-filename-from-adaname (match-string 1))
- ada-spec-suffixes)))
- ))
-
- (set (make-local-variable 'outline-regexp)
- "\\([ \t]*\\(procedure\\|function\\|package\\|if\\|while\\|for\\|declare\\|case\\|end\\|begin\\|loop\\)\\|--\\)")
- (set (make-local-variable 'outline-level) 'ada-outline-level)
-
- (setq imenu-generic-expression ada-imenu-generic-expression)
- (setq imenu-sort-function 'imenu--sort-by-name)
-
- (set (make-local-variable 'ispell-check-comments) 'exclusive)
-
- (add-to-list 'align-dq-string-modes 'ada-mode)
- (add-to-list 'align-open-comment-modes 'ada-mode)
- (set (make-local-variable 'align-region-separate) ada-align-region-separate)
-
- (add-to-list 'align-exclude-rules-list
- '(ada-solo-comment
- (regexp . "^\\(\\s-*\\)--")
- (modes . '(ada-mode))))
- (add-to-list 'align-exclude-rules-list
- '(ada-solo-use
- (regexp . "^\\(\\s-*\\)\\<use\\>")
- (modes . '(ada-mode))))
- (setq ada-align-modes nil)
- (add-to-list 'ada-align-modes
- '(ada-declaration-assign
- (regexp . "[^:]\\(\\s-*\\):[^:]")
- (valid . (lambda() (not (ada-in-comment-p))))
- (repeat . t)
- (modes . '(ada-mode))))
- (add-to-list 'ada-align-modes
- '(ada-associate
- (regexp . "[^=]\\(\\s-*\\)=>")
- (valid . (lambda() (not (ada-in-comment-p))))
- (modes . '(ada-mode))))
- (add-to-list 'ada-align-modes
- '(ada-comment
- (regexp . "\\(\\s-*\\)--")
- (modes . '(ada-mode))))
- (add-to-list 'ada-align-modes
- '(ada-use
- (regexp . "\\(\\s-*\\)\\<use\\s-")
- (valid . (lambda() (not (ada-in-comment-p))))
- (modes . '(ada-mode))))
- (add-to-list 'ada-align-modes
- '(ada-at
- (regexp . "\\(\\s-+\\)at\\>")
- (modes . '(ada-mode))))
- (setq align-mode-rules-list ada-align-modes)
-
- (if ada-popup-key
- (define-key ada-mode-map ada-popup-key 'ada-popup-menu))
-
- (setq local-abbrev-table ada-mode-abbrev-table)
-
- (set (make-local-variable 'which-func-functions) '(ada-which-function))
-
- (set (make-local-variable 'comment-multi-line) nil)
-
- (set (make-local-variable 'add-log-current-defun-function)
- 'ada-which-function)
- (easy-menu-add ada-mode-menu ada-mode-map)
- (set (make-local-variable 'skeleton-further-elements)
- '((< '(backward-delete-char-untabify
- (min ada-indent (current-column))))))
- (add-hook 'skeleton-end-hook 'ada-adjust-case-skeleton nil t)
-
-
- (add-hook 'hack-local-variables-hook
- (lambda ()
- (set (make-local-variable 'comment-start)
- (or ada-fill-comment-prefix "-- "))
-
-
- (unless (or (eval-when-compile (fboundp 'syntax-propertize-via-font-lock))
- (featurep 'xemacs))
- (ada-initialize-syntax-table-properties)
- (add-hook 'font-lock-mode-hook
- 'ada-handle-syntax-table-properties nil t))
-
-
-
- (cond ((eq ada-language-version 'ada83)
- (setq ada-keywords ada-83-keywords))
- ((eq ada-language-version 'ada95)
- (setq ada-keywords ada-95-keywords))
- ((eq ada-language-version 'ada2005)
- (setq ada-keywords ada-2005-keywords)))
- (if ada-auto-case
- (ada-activate-keys-for-case)))
- nil 'local))
- (defun ada-adjust-case-skeleton ()
- "Adjust the case of the text inserted by a skeleton."
- (save-excursion
- (let ((aa-end (point)))
- (ada-adjust-case-region
- (progn (goto-char (symbol-value 'beg)) (forward-word -1) (point))
- (goto-char aa-end)))))
- (defun ada-region-selected ()
- "Should we operate on an active region?"
- (if (fboundp 'use-region-p)
- (use-region-p)
- (region-active-p)))
- (defun ada-save-exceptions-to-file (file-name)
- "Save the casing exception lists to the file FILE-NAME.
- Casing exception lists are `ada-case-exception' and `ada-case-exception-substring'."
- (find-file (expand-file-name file-name))
- (erase-buffer)
- (mapc (lambda (x) (insert (car x) "\n"))
- (sort (copy-sequence ada-case-exception)
- (lambda(a b) (string< (car a) (car b)))))
- (mapc (lambda (x) (insert "*" (car x) "\n"))
- (sort (copy-sequence ada-case-exception-substring)
- (lambda(a b) (string< (car a) (car b)))))
- (save-buffer)
- (kill-buffer nil)
- )
- (defun ada-create-case-exception (&optional word)
- "Define WORD as an exception for the casing system.
- If WORD is not given, then the current word in the buffer is used instead.
- The new word is added to the first file in `ada-case-exception-file'.
- The standard casing rules will no longer apply to this word."
- (interactive)
- (let ((file-name
- (cond ((stringp ada-case-exception-file)
- ada-case-exception-file)
- ((listp ada-case-exception-file)
- (car ada-case-exception-file))
- (t
- (error (concat "No exception file specified. "
- "See variable ada-case-exception-file"))))))
- (unless word
- (with-syntax-table ada-mode-symbol-syntax-table
- (save-excursion
- (skip-syntax-backward "w")
- (setq word (buffer-substring-no-properties
- (point) (save-excursion (forward-word 1) (point)))))))
-
- (ada-case-read-exceptions-from-file file-name)
-
-
- (if (and (not (equal ada-case-exception '()))
- (assoc-string word ada-case-exception t))
- (setcar (assoc-string word ada-case-exception t) word)
- (add-to-list 'ada-case-exception (cons word t)))
- (ada-save-exceptions-to-file file-name)))
- (defun ada-create-case-exception-substring (&optional word)
- "Define the substring WORD as an exception for the casing system.
- If WORD is not given, then the current word in the buffer is used instead,
- or the selected region if any is active.
- The new word is added to the first file in `ada-case-exception-file'.
- When auto-casing a word, this substring will be special-cased, unless the
- word itself has a special casing."
- (interactive)
- (let ((file-name
- (cond ((stringp ada-case-exception-file)
- ada-case-exception-file)
- ((listp ada-case-exception-file)
- (car ada-case-exception-file))
- (t
- (error (concat "No exception file specified. "
- "See variable ada-case-exception-file"))))))
-
-
- (cond
- (word nil)
- ((ada-region-selected)
- (setq word (buffer-substring-no-properties
- (region-beginning) (region-end))))
- (t
- (let ((underscore-syntax (char-syntax ?_)))
- (unwind-protect
- (progn
- (modify-syntax-entry ?_ "." (syntax-table))
- (save-excursion
- (skip-syntax-backward "w")
- (setq word (buffer-substring-no-properties
- (point)
- (save-excursion (forward-word 1) (point))))))
- (modify-syntax-entry ?_ (make-string 1 underscore-syntax)
- (syntax-table))))))
-
- (ada-case-read-exceptions-from-file file-name)
-
-
- (if (and (not (equal ada-case-exception-substring '()))
- (assoc-string word ada-case-exception-substring t))
- (setcar (assoc-string word ada-case-exception-substring t) word)
- (add-to-list 'ada-case-exception-substring (cons word t))
- )
- (ada-save-exceptions-to-file file-name)
- (message "%s" (concat "Defining " word " as a casing exception"))))
- (defun ada-case-read-exceptions-from-file (file-name)
- "Read the content of the casing exception file FILE-NAME."
- (if (file-readable-p (expand-file-name file-name))
- (let ((buffer (current-buffer)))
- (find-file (expand-file-name file-name))
- (set-syntax-table ada-mode-symbol-syntax-table)
- (widen)
- (goto-char (point-min))
- (while (not (eobp))
-
-
-
- (let ((word (buffer-substring-no-properties
- (point) (save-excursion (forward-word 1) (point)))))
-
- (if (char-equal (string-to-char word) ?*)
- (progn
- (setq word (substring word 1))
- (unless (assoc-string word ada-case-exception-substring t)
- (add-to-list 'ada-case-exception-substring (cons word t))))
- (unless (assoc-string word ada-case-exception t)
- (add-to-list 'ada-case-exception (cons word t)))))
- (forward-line 1))
- (kill-buffer nil)
- (set-buffer buffer)))
- )
- (defun ada-case-read-exceptions ()
- "Read all the casing exception files from `ada-case-exception-file'."
- (interactive)
-
- (setq ada-case-exception '()
- ada-case-exception-substring '())
- (cond ((stringp ada-case-exception-file)
- (ada-case-read-exceptions-from-file ada-case-exception-file))
- ((listp ada-case-exception-file)
- (mapcar 'ada-case-read-exceptions-from-file
- ada-case-exception-file))))
- (defun ada-adjust-case-substring ()
- "Adjust case of substrings in the previous word."
- (interactive)
- (let ((substrings ada-case-exception-substring)
- (max (point))
- (case-fold-search t)
- (underscore-syntax (char-syntax ?_))
- re)
- (save-excursion
- (forward-word -1)
- (unwind-protect
- (progn
- (modify-syntax-entry ?_ "." (syntax-table))
- (while substrings
- (setq re (concat "\\b" (regexp-quote (caar substrings)) "\\b"))
- (save-excursion
- (while (re-search-forward re max t)
- (replace-match (caar substrings) t)))
- (setq substrings (cdr substrings))
- )
- )
- (modify-syntax-entry ?_ (make-string 1 underscore-syntax) (syntax-table)))
- )))
- (defun ada-adjust-case-identifier ()
- "Adjust case of the previous identifier.
- The auto-casing is done according to the value of `ada-case-identifier'
- and the exceptions defined in `ada-case-exception-file'."
- (interactive)
- (if (or (equal ada-case-exception '())
- (equal (char-after) ?_))
- (progn
- (funcall ada-case-identifier -1)
- (ada-adjust-case-substring))
- (progn
- (let ((end (point))
- (start (save-excursion (skip-syntax-backward "w")
- (point)))
- match)
-
- (if (setq match (assoc-string (buffer-substring start end)
- ada-case-exception t))
- (progn
- (delete-region start end)
- (insert (car match)))
-
- (funcall ada-case-identifier -1)
- (ada-adjust-case-substring))))))
- (defun ada-after-keyword-p ()
- "Return t if cursor is after a keyword that is not an attribute."
- (save-excursion
- (forward-word -1)
- (and (not (and (char-before)
- (or (= (char-before) ?_)
- (= (char-before) ?'))))
- (looking-at (concat ada-keywords "[^_]")))))
- (defun ada-adjust-case (&optional force-identifier)
- "Adjust the case of the word before the character just typed.
- If FORCE-IDENTIFIER is non-nil then also adjust keyword as identifier."
- (if (not (bobp))
- (progn
- (forward-char -1)
- (if (and (not (bobp))
-
- (not (and (eq (following-char) ?')
- (eq (char-before (1- (point))) ?')))
-
- (eq (char-syntax (char-before)) ?w)
-
- (not (ada-in-string-or-comment-p))
-
- (not (ada-in-numeric-literal-p))
- )
- (if (save-excursion
- (forward-word -1)
- (or (= (point) (point-min))
- (backward-char 1))
- (= (following-char) ?'))
- (funcall ada-case-attribute -1)
- (if (and
- (not force-identifier)
- (ada-after-keyword-p))
- (funcall ada-case-keyword -1)
- (ada-adjust-case-identifier))))
- (forward-char 1)
- ))
- )
- (defun ada-adjust-case-interactive (arg)
- "Adjust the case of the previous word, and process the character just typed.
- ARG is the prefix the user entered with \\[universal-argument]."
- (interactive "P")
- (if ada-auto-case
- (let ((lastk last-command-event))
- (with-syntax-table ada-mode-symbol-syntax-table
- (cond ((or (eq lastk ?\n)
- (eq lastk ?\r))
-
- (insert " ")
- (ada-adjust-case)
-
- (delete-char -1)
-
- (cond
- ((eq lastk ?\n)
- (funcall ada-lfd-binding))
- ((eq lastk ?\r)
- (funcall ada-ret-binding))))
- ((eq lastk ?\C-i) (ada-tab))
-
- ((self-insert-command (prefix-numeric-value arg))))
-
-
- (if (eq lastk ?_)
- (ada-adjust-case t)
- (ada-adjust-case))))
-
- (cond
- ((eq last-command-event ?\n)
- (funcall ada-lfd-binding))
- ((eq last-command-event ?\r)
- (funcall ada-ret-binding))
- (t
- (self-insert-command (prefix-numeric-value arg))))))
- (defun ada-activate-keys-for-case ()
-
- "Modify the key bindings for all the keys that should readjust the casing."
- (interactive)
-
-
-
-
- (or ada-ret-binding (setq ada-ret-binding (key-binding "\C-M")))
- (or ada-lfd-binding (setq ada-lfd-binding (key-binding "\C-j")))
-
- (mapcar (function (lambda(key) (define-key
- ada-mode-map
- (char-to-string key)
- 'ada-adjust-case-interactive)))
- '( ?` ?_ ?# ?% ?& ?* ?( ?) ?- ?= ?+
- ?| ?\
- (defun ada-loose-case-word (&optional _arg)
- "Upcase first letter and letters following `_' in the following word.
- No other letter is modified.
- ARG is ignored, and is there for compatibility with `capitalize-word' only."
- (interactive)
- (save-excursion
- (let ((end (save-excursion (skip-syntax-forward "w") (point)))
- (first t))
- (skip-syntax-backward "w")
- (while (and (or first (search-forward "_" end t))
- (< (point) end))
- (and first
- (setq first nil))
- (insert-char (upcase (following-char)) 1)
- (delete-char 1)))))
- (defun ada-no-auto-case (&optional _arg)
- "Do nothing. ARG is ignored.
- This function can be used for the auto-casing variables in Ada mode, to
- adapt to unusual auto-casing schemes. Since it does nothing, you can for
- instance use it for `ada-case-identifier' if you don't want any special
- auto-casing for identifiers, whereas keywords have to be lower-cased.
- See also `ada-auto-case' to disable auto casing altogether."
- nil)
- (defun ada-capitalize-word (&optional _arg)
- "Upcase first letter and letters following '_', lower case other letters.
- ARG is ignored, and is there for compatibility with `capitalize-word' only."
- (interactive)
- (let ((end (save-excursion (skip-syntax-forward "w") (point)))
- (begin (save-excursion (skip-syntax-backward "w") (point))))
- (modify-syntax-entry ?_ "_")
- (capitalize-region begin end)
- (modify-syntax-entry ?_ "w")))
- (defun ada-adjust-case-region (from to)
- "Adjust the case of all words in the region between FROM and TO.
- Attention: This function might take very long for big regions!"
- (interactive "*r")
- (let ((begin nil)
- (end nil)
- (keywordp nil)
- (attribp nil))
- (message "Adjusting case ...")
- (with-syntax-table ada-mode-symbol-syntax-table
- (save-excursion
- (goto-char to)
-
-
-
- (while (re-search-backward "\\<\\(\\sw+\\)\\>" from t)
- (setq end (match-end 1))
- (setq attribp
- (and (> (point) from)
- (save-excursion
- (forward-char -1)
- (setq attribp (looking-at "'.[^']")))))
- (or
-
- (ada-in-string-or-comment-p)
- (progn
-
-
-
- (setq begin (point))
- (setq keywordp (looking-at ada-keywords))
- (goto-char end)
-
-
-
- (if attribp
- (funcall ada-case-attribute -1)
- (if keywordp
- (funcall ada-case-keyword -1)
- (ada-adjust-case-identifier)))
- (goto-char begin))))
- (message "Adjusting case ... Done")))))
- (defun ada-adjust-case-buffer ()
- "Adjust the case of all words in the whole buffer.
- ATTENTION: This function might take very long for big buffers!"
- (interactive "*")
- (ada-adjust-case-region (point-min) (point-max)))
- (defun ada-format-paramlist ()
- "Reformat the parameter list point is in."
- (interactive)
- (let ((begin nil)
- (end nil)
- (delend nil)
- (paramlist nil))
- (with-syntax-table ada-mode-symbol-syntax-table
-
- (or (ada-in-paramlist-p)
- (error "Not in parameter list"))
-
- (ada-search-ignore-string-comment
- (concat ada-subprog-start-re "\\|\\<body\\>" ) t nil)
- (down-list 1)
- (backward-char 1)
- (setq begin (point))
-
- (forward-sexp 1)
- (setq delend (point))
- (delete-char -1)
- (insert "\n")
-
- (forward-comment -1000)
- (setq end (point))
-
- (setq paramlist (ada-scan-paramlist (1+ begin) end))
-
- (delete-region begin delend)
-
- (goto-char begin)
- (ada-insert-paramlist paramlist))))
- (defun ada-scan-paramlist (begin end)
- "Scan the parameter list found in between BEGIN and END.
- Return the equivalent internal parameter list."
- (let ((paramlist (list))
- (param (list))
- (notend t)
- (apos nil)
- (epos nil)
- (semipos nil)
- (match-cons nil))
- (goto-char begin)
-
- (while notend
-
- (ada-goto-next-non-ws)
- (setq apos (point))
-
- (if (setq match-cons
- (ada-search-ignore-string-comment "[ \t\n]*;" nil end t))
- (progn
- (setq epos (car match-cons))
- (setq semipos (cdr match-cons)))
- (setq epos end))
-
- (goto-char apos)
- (looking-at "\\(\\(\\sw\\|[_, \t\n]\\)*\\(\\sw\\|_\\)\\)[ \t\n]*:[^=]")
- (setq param (list (match-string 1)))
- (ada-search-ignore-string-comment ":" nil epos t 'search-forward)
-
- (setq apos (point))
- (setq param
- (append param
- (list
- (consp
- (ada-search-ignore-string-comment
- "in" nil epos t 'word-search-forward)))))
-
- (goto-char apos)
- (setq param
- (append param
- (list
- (consp
- (ada-search-ignore-string-comment
- "out" nil epos t 'word-search-forward)))))
-
- (goto-char apos)
- (setq param
- (append param
- (list
- (consp
- (ada-search-ignore-string-comment
- "access" nil epos t 'word-search-forward)))))
-
- (goto-char apos)
- (ada-goto-next-non-ws)
- (while (looking-at "\\<\\(in\\|out\\|access\\)\\>")
- (forward-word 1)
- (ada-goto-next-non-ws))
-
-
-
- (looking-at "\\<\\(\\sw\\|[_.' \t]\\)+\\>")
- (setq param
- (append param
- (list (match-string 0))))
-
- (goto-char (setq apos (match-end 0)))
- (setq param
- (append param
- (list
- (if (setq match-cons
- (ada-search-ignore-string-comment
- ":=" nil epos t 'search-forward))
- (buffer-substring (car match-cons) epos)
- nil))))
-
- (setq paramlist (append paramlist (list param)))
-
- (if (eq epos end)
- (setq notend nil)
- (goto-char semipos))
- )
- (reverse paramlist)))
- (defun ada-insert-paramlist (paramlist)
- "Insert a formatted PARAMLIST in the buffer."
- (let ((i (length paramlist))
- (parlen 0)
- (typlen 0)
- (inp nil)
- (outp nil)
- (accessp nil)
- (column nil)
- (firstcol nil))
-
- (while (not (zerop i))
- (setq i (1- i))
-
- (setq parlen (max parlen (length (nth 0 (nth i paramlist)))))
-
- (setq typlen (max typlen (length (nth 4 (nth i paramlist)))))
-
- (setq inp (or inp (nth 1 (nth i paramlist))))
-
- (setq outp (or outp (nth 2 (nth i paramlist))))
-
- (setq accessp (or accessp (nth 3 (nth i paramlist))))
- )
-
- (if (save-excursion
- (re-search-backward "^.\\|[^ \t]" nil t)
- (looking-at "^."))
-
- (progn
- (ada-indent-current)
- (save-excursion
- (if (looking-at "\\(is\\|return\\)")
- (replace-match " \\1"))))
-
- (fixup-whitespace)
- (save-excursion
- (cond
- ((looking-at "[ \t]*\\(\n\\|;\\)")
- (replace-match "\\1"))
- ((looking-at "[ \t]*\\(is\\|return\\)")
- (replace-match " \\1"))))
- (insert " "))
- (insert "(")
- (ada-indent-current)
- (setq firstcol (current-column))
- (setq i (length paramlist))
-
- (while (not (zerop i))
- (setq i (1- i))
- (setq column firstcol)
-
- (insert (nth 0 (nth i paramlist)))
- (indent-to (+ column parlen 1))
- (insert ": ")
- (setq column (current-column))
-
- (if (nth 1 (nth i paramlist))
- (insert "in ")
- (if (and
- (or inp
- accessp)
- (not (nth 3 (nth i paramlist))))
- (insert " ")))
-
- (if (nth 2 (nth i paramlist))
- (insert "out ")
- (if (and
- (or outp
- accessp)
- (not (nth 3 (nth i paramlist))))
- (insert " ")))
-
- (if (nth 3 (nth i paramlist))
- (insert "access "))
- (setq column (current-column))
-
- (insert (nth 4 (nth i paramlist)))
- (if (nth 5 (nth i paramlist))
- (progn
- (indent-to (+ column typlen 1))
- (insert (nth 5 (nth i paramlist)))))
-
- (if (zerop i)
- (insert ")")
-
- (insert ";")
- (newline)
- (indent-to firstcol))
- )
-
-
- (unless (looking-at "[ \t]*\\(;\\|\n\\|is\\|return\\)")
- (ada-indent-newline-indent))
- ))
- (defun ada-indent-region (beg end)
- "Indent the region between BEG end END."
- (interactive "*r")
- (goto-char beg)
- (let ((block-done 0)
- (lines-remaining (count-lines beg end))
- (msg (format "%%4d out of %4d lines remaining ..."
- (count-lines beg end)))
- (endmark (copy-marker end)))
-
- (while (< (point) endmark)
- (if (> block-done 39)
- (progn
- (setq lines-remaining (- lines-remaining block-done)
- block-done 0)
- (message msg lines-remaining)))
- (if (= (char-after) ?\n) nil
- (ada-indent-current))
- (forward-line 1)
- (setq block-done (1+ block-done)))
- (message "Indenting ... done")))
- (defun ada-indent-newline-indent ()
- "Indent the current line, insert a newline and then indent the new line."
- (interactive "*")
- (ada-indent-current)
- (newline)
- (ada-indent-current))
- (defun ada-indent-newline-indent-conditional ()
- "Insert a newline and indent it.
- The original line is re-indented if `ada-indent-after-return' is non-nil."
- (interactive "*")
-
-
-
-
- (newline)
- (if ada-indent-after-return
- (progn
- (forward-char -1)
- (ada-indent-current)
- (forward-char 1)))
- (ada-indent-current))
- (defun ada-justified-indent-current ()
- "Indent the current line and explain how the calculation was done."
- (interactive)
- (let ((cur-indent (ada-indent-current)))
- (let ((line (save-excursion
- (goto-char (car cur-indent))
- (count-lines 1 (point)))))
- (if (equal (cdr cur-indent) '(0))
- (message (concat "same indentation as line " (number-to-string line)))
- (message "%s" (mapconcat (lambda(x)
- (cond
- ((symbolp x)
- (symbol-name x))
- ((numberp x)
- (number-to-string x))
- ((listp x)
- (concat "- " (symbol-name (cadr x))))
- ))
- (cdr cur-indent)
- " + "))))
- (save-excursion
- (goto-char (car cur-indent))
- (sit-for 1))))
- (defun ada-batch-reformat ()
- "Re-indent and re-case all the files found on the command line.
- This function should be used from the command line, with a
- command like:
- emacs -batch -l ada-mode -f ada-batch-reformat file1 file2 ..."
- (while command-line-args-left
- (let ((source (car command-line-args-left)))
- (message "Formatting %s" source)
- (find-file source)
- (ada-indent-region (point-min) (point-max))
- (ada-adjust-case-buffer)
- (write-file source))
- (setq command-line-args-left (cdr command-line-args-left)))
- (message "Done")
- (kill-emacs 0))
- (defsubst ada-goto-previous-word ()
- "Move point to the beginning of the previous word of Ada code.
- Return the new position of point or nil if not found."
- (ada-goto-next-word t))
- (defun ada-indent-current ()
- "Indent current line as Ada code.
- Return the calculation that was done, including the reference point
- and the offset."
- (interactive)
- (let ((orgpoint (point-marker))
- cur-indent tmp-indent
- prev-indent)
- (unwind-protect
- (with-syntax-table ada-mode-symbol-syntax-table
-
-
- (if (featurep 'xemacs)
- (ad-activate 'parse-partial-sexp t))
- (save-excursion
- (setq cur-indent
-
- (if (save-excursion (zerop (forward-line -1)))
- (progn
- (back-to-indentation)
- (ada-get-current-indent))
-
- (list (point-min) 0))))
-
-
- (if cur-indent
- (setq prev-indent (save-excursion (goto-char (car cur-indent))
- (current-column))
- tmp-indent (cdr cur-indent))
- (setq prev-indent 0 tmp-indent '()))
- (while (not (null tmp-indent))
- (cond
- ((numberp (car tmp-indent))
- (setq prev-indent (+ prev-indent (car tmp-indent))))
- (t
- (setq prev-indent (+ prev-indent (eval (car tmp-indent)))))
- )
- (setq tmp-indent (cdr tmp-indent)))
-
- (if (= (save-excursion (back-to-indentation) (current-column)) prev-indent)
- nil
- (beginning-of-line)
- (delete-horizontal-space)
- (indent-to prev-indent))
-
-
-
- (goto-char orgpoint)
- (if (< (current-column) (current-indentation))
- (back-to-indentation)))
- (if (featurep 'xemacs)
- (ad-deactivate 'parse-partial-sexp)))
- cur-indent))
- (defun ada-get-current-indent ()
- "Return the indentation to use for the current line."
- (let (column
- pos
- match-cons
- result
- (orgpoint (save-excursion
- (beginning-of-line)
- (forward-comment -10000)
- (forward-line 1)
- (point))))
- (setq result
- (cond
-
-
-
- ((and ada-indent-to-open-paren
- (not (ada-in-paramlist-p))
- (setq column (ada-in-open-paren-p)))
-
-
- (save-excursion
-
- (if (= (following-char) ?\))
- (save-excursion
- (goto-char column)
- (skip-chars-backward " \t")
- (list (1- (point)) 0))
- (if (and (skip-chars-backward " \t")
- (= (char-before) ?\n)
- (not (forward-comment -10000))
- (= (char-before) ?>))
-
- (list column 'ada-broken-indent)
-
-
-
-
-
-
-
-
-
-
- (if (= (char-before) ?\))
- (backward-sexp))
- (if (memq (char-before) '(?, ?\
- (list column 0)
- (list column 'ada-continuation-indent)
- )))))
-
-
-
- ((not (char-after))
- (ada-indent-on-previous-lines nil orgpoint orgpoint))
-
-
-
- ((= (downcase (char-after)) ?e)
- (cond
-
- ((looking-at "end\\>")
- (let ((label 0)
- limit)
- (save-excursion
- (ada-goto-matching-start 1)
-
-
-
-
-
- (if (save-excursion
- (beginning-of-line)
- (looking-at ".+\\<loop\\>"))
- (progn
- (save-excursion
- (setq limit (car (ada-search-ignore-string-comment ";" t))))
- (if (save-excursion
- (and
- (setq match-cons
- (ada-search-ignore-string-comment ada-loop-start-re t limit))
- (not (looking-at "\\<loop\\>"))))
- (progn
- (goto-char (car match-cons))
- (save-excursion
- (back-to-indentation)
- (if (looking-at ada-block-label-re)
- (setq label (- ada-label-indent))))))))
-
-
-
-
-
-
-
- (if (looking-at "record")
- (if (save-excursion
- (beginning-of-line)
- (looking-at "^[ \t]*\\(record\\|limited record\\)"))
- (list (save-excursion (back-to-indentation) (point)) 0)
- (list (save-excursion
- (car (ada-search-ignore-string-comment "\\<type\\>" t)))
- 0))
-
- (list (+ (save-excursion (back-to-indentation) (point)) label) 0)))))
-
- ((looking-at "exception\\>")
- (save-excursion
- (ada-goto-matching-start 1)
- (list (save-excursion (back-to-indentation) (point)) 0)))
-
- ((looking-at "else\\>")
- (if (save-excursion (ada-goto-previous-word)
- (looking-at "\\<or\\>"))
- (ada-indent-on-previous-lines nil orgpoint orgpoint)
- (save-excursion
- (ada-goto-matching-start 1 nil t)
- (list (progn (back-to-indentation) (point)) 0))))
-
- ((looking-at "elsif\\>")
- (save-excursion
- (ada-goto-matching-start 1 nil t)
- (list (progn (back-to-indentation) (point)) 0)))
- ))
-
-
-
- ((and (= (downcase (char-after)) ?w)
- (looking-at "when\\>"))
- (save-excursion
- (ada-goto-matching-start 1)
- (list (save-excursion (back-to-indentation) (point))
- 'ada-when-indent)))
-
-
-
- ((and (= (downcase (char-after)) ?t)
- (looking-at "then\\>"))
- (if (save-excursion (ada-goto-previous-word)
- (looking-at "and\\>"))
- (ada-indent-on-previous-lines nil orgpoint orgpoint)
- (save-excursion
-
- (ada-search-ignore-string-comment
- "\\<\\(elsif\\|if\\|select\\)\\>" t nil)
- (list (progn (back-to-indentation) (point))
- 'ada-stmt-end-indent))))
-
-
-
- ((and (= (downcase (char-after)) ?l)
- (looking-at "loop\\>"))
- (setq pos (point))
- (save-excursion
- (goto-char (match-end 0))
- (ada-goto-stmt-start)
- (if (looking-at "\\<\\(loop\\|if\\)\\>")
- (ada-indent-on-previous-lines nil orgpoint orgpoint)
- (unless (looking-at ada-loop-start-re)
- (ada-search-ignore-string-comment ada-loop-start-re
- nil pos))
- (if (looking-at "\\<loop\\>")
- (ada-indent-on-previous-lines nil orgpoint orgpoint)
- (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent)))))
-
-
-
- ((or (and (= (downcase (char-after)) ?l)
- (looking-at "limited\\>"))
- (and (= (downcase (char-after)) ?r)
- (looking-at "record\\>")))
- (save-excursion
- (ada-search-ignore-string-comment
- "\\<\\(type\\|use\\)\\>" t nil)
- (if (looking-at "\\<use\\>")
- (ada-search-ignore-string-comment "for" t nil nil
- 'word-search-backward))
- (list (progn (back-to-indentation) (point))
- 'ada-indent-record-rel-type)))
-
-
-
- ((and (= (downcase (char-after)) ?b)
- (looking-at "begin\\>"))
- (save-excursion
- (if (ada-goto-decl-start t)
- (list (progn (back-to-indentation) (point)) 0)
- (ada-indent-on-previous-lines nil orgpoint orgpoint))))
-
-
-
- ((and (= (downcase (char-after)) ?i)
- (looking-at "is\\>"))
- (if (and ada-indent-is-separate
- (save-excursion
- (goto-char (match-end 0))
- (ada-goto-next-non-ws (point-at-eol))
- (looking-at "\\<abstract\\>\\|\\<separate\\>")))
- (save-excursion
- (ada-goto-stmt-start)
- (list (progn (back-to-indentation) (point)) 'ada-indent))
- (save-excursion
- (ada-goto-stmt-start)
- (if (looking-at "\\<overriding\\|package\\|procedure\\|function\\>")
- (list (progn (back-to-indentation) (point)) 0)
- (list (progn (back-to-indentation) (point)) 'ada-indent)))))
-
-
-
- ((and (= (downcase (char-after)) ?r)
- (looking-at "re\\(turn\\|names\\)\\>"))
- (save-excursion
- (let ((var 'ada-indent-return))
-
- (if (looking-at "renames")
- (let (pos)
- (save-excursion
- (setq pos (ada-search-ignore-string-comment ";\\|return\\>" t)))
- (if (and pos
- (= (downcase (char-after (car pos))) ?r))
- (goto-char (car pos)))
- (setq var 'ada-indent-renames)))
- (forward-comment -1000)
- (if (= (char-before) ?\))
- (forward-sexp -1)
- (forward-word -1))
-
-
- (let ((num-back 1))
- (if (and (= (following-char) ?\()
- (save-excursion
- (or (progn
- (backward-word 1)
- (looking-at "\\(function\\|procedure\\)\\>"))
- (progn
- (backward-word 1)
- (setq num-back 2)
- (looking-at "\\(function\\|procedure\\)\\>")))))
-
- (if (<= (eval var) 0)
- (list (point) (list '- var))
- (list (progn (backward-word num-back) (point))
- var))
-
-
-
- (if (and (> (eval var) 0)
- (save-excursion (forward-word -1)
- (looking-at "function\\>")))
- (list (progn (forward-word -1) (point)) var)
-
- (ada-indent-on-previous-lines nil orgpoint orgpoint)))))))
-
-
-
-
-
- ((and (or (= (downcase (char-after)) ?o)
- (= (downcase (char-after)) ?p))
- (or (ada-looking-at-semi-or)
- (ada-looking-at-semi-private)))
- (save-excursion
-
- (ada-goto-matching-start 1)
- (list (progn (back-to-indentation) (point)) 0)))
-
-
-
- ((and (= (downcase (char-after)) ?d)
- (looking-at "do\\>"))
- (save-excursion
- (ada-goto-stmt-start)
- (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent)))
-
-
-
- ((= (char-after) ?-)
- (if ada-indent-comment-as-code
-
-
-
- (let (pos)
- (if (and ada-indent-align-comments
- (save-excursion
- (forward-line -1)
- (beginning-of-line)
- (while (and (not pos)
- (search-forward "--" (point-at-eol) t))
- (unless (ada-in-string-p)
- (setq pos (point))))
- pos))
- (list (- pos 2) 0)
-
- (ada-indent-on-previous-lines nil orgpoint orgpoint)))
-
- (list (save-excursion (back-to-indentation) (point)) 0)))
-
-
-
- ((and (= (char-after) ?#)
- (equal ada-which-compiler 'gnat)
- (looking-at "#[ \t]*\\(if\\|els\\(e\\|if\\)\\|end[ \t]*if\\)"))
- (list (point-at-bol) 0))
-
-
-
- ((and (not (eobp)) (= (char-after) ?\)))
- (save-excursion
- (forward-char 1)
- (backward-sexp 1)
- (list (point) 0)))
-
-
-
- ((looking-at "\\(new\\|abstract\\|separate\\)\\>")
- (ada-indent-on-previous-lines nil orgpoint orgpoint))
-
-
-
- ((and (or (= (downcase (char-after)) ?p) (= (downcase (char-after)) ?f))
- (looking-at "\\<\\(package\\|function\\|procedure\\)\\>"))
- (save-excursion
-
-
- (let (found)
- (while (and (not found)
- (ada-search-ignore-string-comment
- "\\<\\(generic\\|end\\|begin\\|overriding\\|package\\|procedure\\|function\\)\\>" t))
-
- (save-excursion
- (forward-word -1)
- (setq found (not (looking-at "with"))))))
- (cond
- ((looking-at "\\<generic\\|overriding\\>")
- (list (progn (back-to-indentation) (point)) 0))
- (t
- (ada-indent-on-previous-lines nil orgpoint orgpoint)))))
-
-
-
- ((looking-at ada-label-re)
- (if (ada-in-decl-p)
-
- (ada-indent-on-previous-lines nil orgpoint orgpoint)
- (append (ada-indent-on-previous-lines nil orgpoint orgpoint)
- '(ada-label-indent))))
- ))
-
-
-
- (or result (ada-indent-on-previous-lines nil orgpoint orgpoint))))
- (defun ada-indent-on-previous-lines (&optional nomove orgpoint initial-pos)
- "Calculate the indentation for the new line after ORGPOINT.
- The result list is based on the previous lines in the buffer.
- If NOMOVE is nil, moves point to the beginning of the current statement.
- if INITIAL-POS is non-nil, moves point to INITIAL-POS before calculation."
- (if initial-pos
- (goto-char initial-pos))
- (let ((oldpoint (point)))
-
- (if (ada-in-paramlist-p)
- (ada-get-indent-paramlist)
-
-
- (unless nomove
- (ada-goto-stmt-start t))
-
- (if (and (eq oldpoint (point))
- (not nomove))
- (ada-get-indent-nochange)
- (cond
-
- ((and
- ada-indent-to-open-paren
- (ada-in-open-paren-p))
- (ada-get-indent-open-paren))
-
- ((looking-at "end\\>")
- (ada-get-indent-end orgpoint))
-
- ((looking-at ada-loop-start-re)
- (ada-get-indent-loop orgpoint))
-
- ((looking-at ada-subprog-start-re)
- (ada-get-indent-subprog orgpoint))
-
- ((looking-at ada-block-start-re)
- (ada-get-indent-block-start orgpoint))
-
- ((looking-at ada-block-label-re)
- (ada-get-indent-block-label orgpoint))
-
- ((looking-at ada-goto-label-re)
- (ada-get-indent-goto-label orgpoint))
-
- ((looking-at "\\(sub\\)?type\\>")
- (ada-get-indent-type orgpoint))
-
-
-
-
- ((looking-at "\\(\\(els\\)?if\\>\\)\\|then abort\\\>")
- (ada-get-indent-if orgpoint))
-
- ((looking-at "case\\>")
- (ada-get-indent-case orgpoint))
-
- ((looking-at "when\\>")
- (ada-get-indent-when orgpoint))
-
- ((looking-at "separate\\>")
- (ada-get-indent-nochange))
-
- ((looking-at "with\\>\\|use\\>")
-
-
- (if (save-excursion (search-forward ";" oldpoint t))
- (list (progn (back-to-indentation) (point)) 0)
- (list (point) (if (looking-at "with")
- 'ada-with-indent
- 'ada-use-indent))))
-
- (t
- (ada-get-indent-noindent orgpoint)))))
- ))
- (defun ada-get-indent-open-paren ()
- "Calculate the indentation when point is behind an unclosed parenthesis."
- (list (ada-in-open-paren-p) 0))
- (defun ada-get-indent-nochange ()
- "Return the current indentation of the previous line."
- (save-excursion
- (forward-line -1)
- (back-to-indentation)
- (list (point) 0)))
- (defun ada-get-indent-paramlist ()
- "Calculate the indentation when point is inside a parameter list."
- (save-excursion
- (ada-search-ignore-string-comment "[^ \t\n]" t nil t)
- (cond
-
- ((= (char-after) ?\()
- (goto-char (match-end 0))
- (list (point) 0))
-
- ((= (char-after) ?\
- (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t)))
- (ada-goto-next-non-ws)
- (list (point) 0))
-
-
- ((and (= (following-char) ?=) (= (preceding-char) ?:))
- (back-to-indentation)
- (list (point) 'ada-broken-indent))
-
- (t
- (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t)))
- (ada-goto-next-non-ws)
- (list (point) 'ada-broken-indent)))))
- (defun ada-get-indent-end (orgpoint)
- "Calculate the indentation when point is just before an end statement.
- ORGPOINT is the limit position used in the calculation."
- (let ((defun-name nil)
- (indent nil))
-
- (if (save-excursion
- (ada-search-ignore-string-comment ";" nil orgpoint nil
- 'search-forward))
-
- (progn
- (forward-word 1)
- (ada-goto-next-non-ws)
- (cond
-
-
-
- ((looking-at "\\<\\(loop\\|select\\|if\\|case\\|return\\)\\>")
- (save-excursion (ada-check-matching-start (match-string 0)))
- (list (save-excursion (back-to-indentation) (point)) 0))
-
-
-
- ((looking-at "\\<record\\>")
- (save-excursion
- (ada-check-matching-start (match-string 0))
-
- (forward-word 1)
- (ada-goto-stmt-start)
-
- (unless (looking-at "\\(for\\|type\\)\\>")
- (ada-search-ignore-string-comment "\\<type\\>" t))
- (list (progn (back-to-indentation) (point)) 0)))
-
-
-
- ((looking-at ada-ident-re)
- (setq defun-name (match-string 0))
- (save-excursion
- (ada-goto-matching-start 0)
- (ada-check-defun-name defun-name))
- (list (progn (back-to-indentation) (point)) 0))
-
-
-
- ((= (char-after) ?\
- (save-excursion
- (ada-goto-matching-start 0)
- (if (looking-at "\\<begin\\>")
- (progn
- (setq indent (list (point) 0))
- (if (ada-goto-decl-start t)
- (list (progn (back-to-indentation) (point)) 0)
- indent))
- (list (progn (back-to-indentation) (point)) 0)
- )))
-
-
-
- (t
- (list (save-excursion (back-to-indentation) (point))
- 'ada-broken-indent))))
- (list (save-excursion (back-to-indentation) (point))
- 'ada-broken-indent))))
- (defun ada-get-indent-case (orgpoint)
- "Calculate the indentation when point is just before a case statement.
- ORGPOINT is the limit position used in the calculation."
- (let ((match-cons nil)
- (opos (point)))
- (cond
-
-
-
- ((save-excursion
- (setq match-cons (and
-
- (ada-search-ignore-string-comment
- "is" nil orgpoint nil 'word-search-forward)
- (ada-search-ignore-string-comment
- "[ \t\n]+=>" nil orgpoint))))
- (save-excursion
- (goto-char (car match-cons))
- (unless (ada-search-ignore-string-comment "when" t opos)
- (error "Missing 'when' between 'case' and '=>'"))
- (list (save-excursion (back-to-indentation) (point)) 'ada-indent)))
-
-
-
- ((save-excursion
- (setq match-cons (ada-search-ignore-string-comment
- "when" nil orgpoint nil 'word-search-forward)))
- (goto-char (cdr match-cons))
- (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent))
-
-
-
- ((save-excursion
- (setq match-cons (ada-search-ignore-string-comment
- "is" nil orgpoint nil 'word-search-forward)))
- (list (save-excursion (back-to-indentation) (point)) 'ada-when-indent))
-
-
-
- (t
- (list (save-excursion (back-to-indentation) (point))
- 'ada-broken-indent)))))
- (defun ada-get-indent-when (orgpoint)
- "Calculate the indentation when point is just before a when statement.
- ORGPOINT is the limit position used in the calculation."
- (let ((cur-indent (save-excursion (back-to-indentation) (point))))
- (if (ada-search-ignore-string-comment "[ \t\n]*=>" nil orgpoint)
- (list cur-indent 'ada-indent)
- (list cur-indent 'ada-broken-indent))))
- (defun ada-get-indent-if (orgpoint)
- "Calculate the indentation when point is just before an if statement.
- ORGPOINT is the limit position used in the calculation."
- (let ((cur-indent (save-excursion (back-to-indentation) (point)))
- (match-cons nil))
-
-
-
- (while (and (setq match-cons (ada-search-ignore-string-comment
- "\\<\\(then\\|and[ \t]*then\\)\\>"
- nil orgpoint))
- (= (downcase (char-after (car match-cons))) ?a)))
-
- (if match-cons
- (progn
-
-
-
-
-
- (if (save-excursion
- (back-to-indentation)
- (looking-at "\\<then\\>"))
- (setq cur-indent (save-excursion (back-to-indentation) (point))))
-
- (forward-word 1)
- (list cur-indent 'ada-indent))
- (list cur-indent 'ada-broken-indent))))
- (defun ada-get-indent-block-start (orgpoint)
- "Calculate the indentation when point is at the start of a block.
- ORGPOINT is the limit position used in the calculation."
- (let ((pos nil))
- (cond
- ((save-excursion
- (forward-word 1)
- (setq pos (ada-goto-next-non-ws orgpoint)))
- (goto-char pos)
- (save-excursion
- (ada-indent-on-previous-lines t orgpoint)))
-
-
-
-
- ((looking-at "record")
-
- (if (save-excursion
- (beginning-of-line)
- (looking-at "^[ \t]*\\(record\\|limited record\\)"))
- (list (save-excursion (back-to-indentation) (point)) 'ada-indent)
-
- (list (save-excursion
- (car (ada-search-ignore-string-comment "\\<type\\>" t)))
- 'ada-indent)))
-
- ((looking-at ada-block-label-re)
- (list (- (save-excursion (back-to-indentation) (point)) ada-label-indent) 'ada-indent))
-
- (t
- (list (save-excursion (back-to-indentation) (point)) 'ada-indent)))))
- (defun ada-get-indent-subprog (orgpoint)
- "Calculate the indentation when point is just before a subprogram.
- ORGPOINT is the limit position used in the calculation."
- (let ((match-cons nil)
- (cur-indent (save-excursion (back-to-indentation) (point)))
- (foundis nil))
-
-
-
- (if (save-excursion
- (setq match-cons
- (ada-search-ignore-string-comment
- "\\<\\(is\\|do\\)\\>" nil orgpoint)))
-
-
-
- (progn
- (setq foundis t)
- (goto-char (cdr match-cons)))
-
-
-
- (progn
- (unless (ada-goto-next-non-ws orgpoint)
- (goto-char orgpoint))))
- (cond
-
-
-
- ((and
- foundis
- (save-excursion
- (not (ada-search-ignore-string-comment
- "[^ \t\n]" nil orgpoint t))))
- (list cur-indent 'ada-indent))
-
-
-
- ((and
- foundis
- (save-excursion
- (setq match-cons
- (ada-search-ignore-string-comment
- "\\<\\(separate\\|new\\|abstract\\)\\>"
- nil orgpoint))))
- (goto-char (car match-cons))
- (ada-search-ignore-string-comment ada-subprog-start-re t)
- (ada-get-indent-noindent orgpoint))
-
-
-
- ((and
- foundis
- (save-excursion (setq match-cons (ada-goto-next-non-ws orgpoint)))
- (goto-char match-cons)
- (ada-indent-on-previous-lines t orgpoint)))
-
-
-
- ((save-excursion
- (ada-search-ignore-string-comment ";" nil orgpoint nil 'search-forward))
- (list cur-indent 0))
-
-
-
- (t
- (list cur-indent 'ada-broken-indent)))))
- (defun ada-get-indent-noindent (orgpoint)
- "Calculate the indentation when point is just before a 'noindent stmt'.
- ORGPOINT is the limit position used in the calculation."
- (let ((label 0))
- (save-excursion
- (beginning-of-line)
- (cond
-
-
-
- ((ada-in-paramlist-p)
- (ada-previous-procedure)
- (list (save-excursion (back-to-indentation) (point)) 0))
-
-
- ((looking-at "[ \t]*\\(\\sw\\|_\\)*[ \t]*,[ \t]*$")
- (list (save-excursion (back-to-indentation) (point))
- 'ada-broken-decl-indent))
-
-
- (t
- (if (looking-at (concat "[ \t]*" ada-block-label-re))
- (setq label (- ada-label-indent))
- (let (p)
-
- (if (or (save-excursion
- (and (ada-search-ignore-string-comment "\\<private\\>" nil orgpoint)
- (setq p (point))
- (save-excursion (forward-char -7)
- (ada-goto-previous-word)
- (looking-at "with"))))
- (save-excursion
- (and (ada-search-ignore-string-comment "\\<record\\>" nil orgpoint)
- (setq p (point))
- (save-excursion (forward-char -6)
- (ada-goto-previous-word)
- (looking-at "null")))))
- (progn
- (goto-char p)
- (re-search-backward "\\<\\(type\\|subtype\\)\\>" nil t)
- (list (save-excursion (back-to-indentation) (point)) 0)))))
- (if (save-excursion
- (ada-search-ignore-string-comment ";" nil orgpoint nil
- 'search-forward))
- (list (+ (save-excursion (back-to-indentation) (point)) label) 0)
- (list (+ (save-excursion (back-to-indentation) (point)) label)
- 'ada-broken-indent)))))))
- (defun ada-get-indent-block-label (orgpoint)
- "Calculate the indentation when before a label or variable declaration.
- ORGPOINT is the limit position used in the calculation."
- (let ((match-cons nil)
- (cur-indent (save-excursion (back-to-indentation) (point))))
- (ada-search-ignore-string-comment ":" nil)
- (cond
-
- ((save-excursion
- (setq match-cons (ada-search-ignore-string-comment
- ada-loop-start-re nil orgpoint)))
- (goto-char (car match-cons))
- (ada-get-indent-loop orgpoint))
-
- ((save-excursion
- (setq match-cons (ada-search-ignore-string-comment
- "\\<declare\\|begin\\>" nil orgpoint)))
- (goto-char (car match-cons))
- (list (save-excursion (back-to-indentation) (point)) 'ada-indent))
-
- ((ada-in-decl-p)
- (if (save-excursion
- (ada-search-ignore-string-comment ";" nil orgpoint))
- (list cur-indent 0)
- (list cur-indent 'ada-broken-indent)))
-
- (t
- (list cur-indent '(- ada-label-indent))))))
- (defun ada-get-indent-goto-label (orgpoint)
- "Calculate the indentation when at a goto label."
- (search-forward ">>")
- (ada-goto-next-non-ws)
- (if (>= (point) orgpoint)
-
- (list (- (point) ada-label-indent))
-
- (ada-indent-on-previous-lines t orgpoint)))
- (defun ada-get-indent-loop (orgpoint)
- "Calculate the indentation when just before a loop or a for ... use.
- ORGPOINT is the limit position used in the calculation."
- (let ((match-cons nil)
- (pos (point))
-
- (label (save-excursion
- (back-to-indentation)
- (if (looking-at ada-block-label-re)
- (- ada-label-indent)
- 0))))
- (cond
-
-
-
- ((save-excursion
- (ada-search-ignore-string-comment ";" nil orgpoint nil
- 'search-forward))
- (list (+ (save-excursion (back-to-indentation) (point)) label) 0))
-
-
-
- ((looking-at "loop\\>")
- (setq pos (ada-get-indent-block-start orgpoint))
- (if (equal label 0)
- pos
- (list (+ (car pos) label) (cadr pos))))
-
-
-
- ((looking-at "for\\>")
- (cond
-
-
-
- ((save-excursion
- (and
- (goto-char (match-end 0))
- (ada-goto-next-non-ws orgpoint)
- (forward-word 1)
- (if (= (char-after) ?') (forward-word 1) t)
- (ada-goto-next-non-ws orgpoint)
- (looking-at "\\<use\\>")
-
-
-
- (progn
- (setq match-cons (ada-search-ignore-string-comment
- "record" nil orgpoint nil 'word-search-forward))
- t)))
- (if match-cons
- (progn
- (goto-char (car match-cons))
- (list (save-excursion (back-to-indentation) (point)) 'ada-indent))
- (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent))
- )
-
-
-
- ((save-excursion
- (setq match-cons (ada-search-ignore-string-comment
- "loop" nil orgpoint nil 'word-search-forward)))
- (goto-char (car match-cons))
-
-
-
-
- (unless (save-excursion
- (back-to-indentation)
- (looking-at "\\<loop\\>"))
- (goto-char pos))
- (list (+ (save-excursion (back-to-indentation) (point)) label)
- 'ada-indent))
-
-
-
- (t
- (list (+ (save-excursion (back-to-indentation) (point)) label)
- 'ada-broken-indent))))
-
-
-
- ((looking-at "while\\>")
-
-
-
- (if (save-excursion
- (setq match-cons (ada-search-ignore-string-comment
- "loop" nil orgpoint nil 'word-search-forward)))
- (progn
- (goto-char (car match-cons))
-
-
-
-
- (unless (save-excursion
- (back-to-indentation)
- (looking-at "\\<loop\\>"))
- (goto-char pos))
- (list (+ (save-excursion (back-to-indentation) (point)) label)
- 'ada-indent))
- (list (+ (save-excursion (back-to-indentation) (point)) label)
- 'ada-broken-indent))))))
- (defun ada-get-indent-type (orgpoint)
- "Calculate the indentation when before a type statement.
- ORGPOINT is the limit position used in the calculation."
- (let ((match-dat nil))
- (cond
-
-
-
- ((save-excursion
- (and
- (setq match-dat (ada-search-ignore-string-comment
- "end" nil orgpoint nil 'word-search-forward))
- (ada-goto-next-non-ws)
- (looking-at "\\<record\\>")
- (forward-word 1)
- (ada-goto-next-non-ws)
- (= (char-after) ?\
- (goto-char (car match-dat))
- (list (save-excursion (back-to-indentation) (point)) 0))
-
-
-
- ((save-excursion
- (setq match-dat (ada-search-ignore-string-comment
- "record" nil orgpoint nil 'word-search-forward)))
- (goto-char (car match-dat))
- (list (save-excursion (back-to-indentation) (point)) 'ada-indent))
-
-
-
- ((save-excursion
- (ada-search-ignore-string-comment ";" nil orgpoint nil
- 'search-forward))
- (list (save-excursion (back-to-indentation) (point)) 0))
-
-
-
- ((save-excursion
- (and
- (ada-search-ignore-string-comment "is" nil orgpoint nil
- 'word-search-forward)
- (not (ada-goto-next-non-ws orgpoint))))
- (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent))
-
-
-
- (t
- (list (save-excursion (back-to-indentation) (point))
- 'ada-broken-indent)))))
- (defun ada-goto-stmt-start (&optional ignore-goto-label)
- "Move point to the beginning of the statement that point is in or after.
- Return the new position of point.
- As a special case, if we are looking at a closing parenthesis, skip to the
- open parenthesis."
- (let ((match-dat nil)
- (orgpoint (point)))
- (setq match-dat (ada-search-prev-end-stmt))
- (if match-dat
-
-
-
- (unless (looking-at "declare")
- (progn
- (unless (save-excursion
- (goto-char (cdr match-dat))
- (ada-goto-next-non-ws orgpoint ignore-goto-label))
-
-
-
-
- (setq match-dat (ada-search-prev-end-stmt)))
-
-
-
- (if match-dat
- (goto-char (cdr match-dat)))
- (ada-goto-next-non-ws)
- ))
-
-
-
-
- (progn
- (goto-char (point-min))
-
-
-
- (unless (ada-goto-next-non-ws orgpoint)
- (goto-char orgpoint))))
- (point)))
- (defun ada-search-prev-end-stmt ()
- "Move point to previous end statement.
- Return a cons cell whose car is the beginning and whose cdr
- is the end of the match."
- (let ((match-dat nil)
- (found nil))
-
- (while
- (and
- (not found)
- (setq match-dat (ada-search-ignore-string-comment
- ada-end-stmt-re t)))
- (goto-char (car match-dat))
- (unless (ada-in-open-paren-p)
- (cond
- ((and (looking-at
- "\\<\\(record\\|loop\\|select\\|else\\|then\\)\\>")
- (save-excursion
- (ada-goto-previous-word)
- (looking-at "\\<\\(end\\|or\\|and\\)\\>[ \t]*[^;]")))
- (forward-word -1))
- ((looking-at "is")
- (setq found
- (and (save-excursion (ada-goto-previous-word)
- (ada-goto-previous-word)
- (not (looking-at "subtype")))
- (save-excursion (goto-char (cdr match-dat))
- (ada-goto-next-non-ws)
-
- (not (looking-at
- (eval-when-compile
- (concat "\\<"
- (regexp-opt
- '("separate" "access" "array"
- "private" "abstract" "new") t)
- "\\>\\|("))))))))
- ((looking-at "private")
- (save-excursion
- (backward-word 1)
- (setq found (not (looking-at "is")))))
- (t
- (setq found t))
- )))
- (if found
- match-dat
- nil)))
- (defun ada-goto-next-non-ws (&optional limit skip-goto-label)
- "Skip to next non-whitespace character.
- Skips spaces, newlines and comments, and possibly goto labels.
- Return `point' if moved, nil if not.
- Stop the search at LIMIT.
- Do not call this function from within a string."
- (unless limit
- (setq limit (point-max)))
- (while (and (<= (point) limit)
- (or (progn (forward-comment 10000)
- (if (and (not (eobp))
- (save-excursion (forward-char 1)
- (ada-in-string-p)))
- (progn (forward-sexp 1) t)))
- (and skip-goto-label
- (looking-at ada-goto-label-re)
- (progn
- (goto-char (match-end 0))
- t)))))
- (if (< (point) limit)
- (point)
- nil)
- )
- (defun ada-goto-stmt-end (&optional limit)
- "Move point to the end of the statement that point is in or before.
- Return the new position of point or nil if not found.
- Stop the search at LIMIT."
- (if (ada-search-ignore-string-comment ada-end-stmt-re nil limit)
- (point)
- nil))
- (defun ada-goto-next-word (&optional backward)
- "Move point to the beginning of the next word of Ada code.
- If BACKWARD is non-nil, jump to the beginning of the previous word.
- Return the new position of point or nil if not found."
- (let ((match-cons nil)
- (orgpoint (point))
- (old-syntax (char-to-string (char-syntax ?_))))
- (modify-syntax-entry ?_ "w")
- (unless backward
- (skip-syntax-forward "w"))
- (if (setq match-cons
- (ada-search-ignore-string-comment "\\w" backward nil t))
-
-
-
- (progn
- (goto-char (car match-cons))
- (skip-syntax-backward "w")
- (point))
-
-
-
- (goto-char orgpoint)
- 'nil)
- (modify-syntax-entry ?_ old-syntax))
- )
- (defun ada-check-matching-start (keyword)
- "Signal an error if matching block start is not KEYWORD.
- Moves point to the matching block start."
- (ada-goto-matching-start 0)
- (unless (looking-at (concat "\\<" keyword "\\>"))
- (error "Matching start is not '%s'" keyword)))
- (defun ada-check-defun-name (defun-name)
- "Check if the name of the matching defun really is DEFUN-NAME.
- Assumes point to be already positioned by `ada-goto-matching-start'.
- Moves point to the beginning of the declaration."
-
-
- (if (save-excursion
- (ada-goto-previous-word)
- (looking-at (concat "\\<" defun-name "\\> *:")))
- t
-
-
-
-
- (unless (looking-at ada-subprog-start-re)
- (ada-goto-decl-start))
-
-
-
- (save-excursion
-
-
-
- (if (looking-at "\\<declare\\>")
- (progn
- (forward-comment -1)
- (backward-word 1))
-
-
-
- (progn
- (forward-word 2)
- (backward-word 1)
-
-
-
- (if (looking-at "\\<\\(body\\|type\\)\\>")
- (forward-word 1))
- (forward-sexp 1)
- (backward-sexp 1)))
-
-
-
- (unless (looking-at (concat "\\<" defun-name "\\>"))
- (error "Matching defun has different name: %s"
- (buffer-substring (point)
- (progn (forward-sexp 1) (point))))))))
- (defun ada-goto-decl-start (&optional noerror)
- "Move point to the declaration start of the current construct.
- If NOERROR is non-nil, return nil if no match was found;
- otherwise throw error."
- (let ((nest-count 1)
- (regexp (eval-when-compile
- (concat "\\<"
- (regexp-opt
- '("is" "separate" "end" "declare" "if" "new" "begin" "generic" "when") t)
- "\\>")))
-
-
- (first t)
- (count-generic nil)
- (stop-at-when nil)
- )
-
-
-
-
-
- (if (looking-at "begin")
- (setq stop-at-when t))
- (if (or
- (looking-at "\\<\\(package\\|procedure\\|function\\)\\>")
- (save-excursion
- (ada-search-ignore-string-comment
- "\\<\\(package\\|procedure\\|function\\|generic\\)\\>" t)
- (looking-at "generic")))
- (setq count-generic t))
-
- (while (and
- (not (zerop nest-count))
- (ada-search-ignore-string-comment regexp t))
-
-
-
- (cond
-
- ((looking-at "end")
- (ada-goto-matching-start 1 noerror)
-
-
-
-
-
-
-
-
- (if (looking-at "begin")
- (let ((loop-again t))
- (save-excursion
- (while loop-again
-
-
-
-
- (ada-search-ignore-string-comment
- "\\<\\(declare\\|begin\\|end\\|procedure\\|function\\|task\\|package\\)\\>"
- t)
- (if (looking-at "end")
- (ada-goto-matching-start 1 noerror t)
- (setq loop-again nil)
- (unless (looking-at "begin")
- (setq nest-count (1+ nest-count))))
- ))
- )))
-
- ((looking-at "generic")
- (if count-generic
- (progn
- (setq first nil)
- (setq nest-count (1- nest-count)))))
-
- ((looking-at "if")
- (save-excursion
- (forward-word -1)
- (unless (looking-at "\\<end[ \t\n]*if\\>")
- (progn
- (setq nest-count (1- nest-count))
- (setq first nil)))))
-
- ((looking-at "declare\\|generic")
- (setq nest-count (1- nest-count))
- (setq first t))
-
- ((looking-at "is")
-
- (if
- (or
-
- (looking-at "is[ t]+<>")
-
-
-
-
-
-
-
- (save-excursion
-
- (forward-comment -10000)
- (forward-char -1)
- (if (= (char-after) ?\))
- (progn
- (forward-char 1)
- (backward-sexp 1)
- (forward-comment -10000)
- ))
-
- (skip-chars-backward "a-zA-Z0-9_.'")
- (ada-goto-previous-word)
- (and
-
-
-
- (looking-at "\\<\\(sub\\)?type\\|case\\>")
- (save-match-data
- (ada-goto-previous-word)
- (not (looking-at "\\<protected\\>"))))
- )
-
- (save-excursion (ada-goto-next-word) (looking-at "\\<null\\>"))
- )
-
- nil
-
- (setq nest-count (1- nest-count))
- (setq first nil)))
-
- ((looking-at "new")
- (if (save-excursion
- (ada-goto-previous-word)
- (looking-at "is"))
- (goto-char (match-beginning 0))))
-
- ((and first
- (looking-at "begin"))
- (setq nest-count 0))
-
- ((looking-at "when")
- (save-excursion
- (forward-word -1)
- (unless (looking-at "\\<exit[ \t\n]*when\\>")
- (progn
- (if stop-at-when
- (setq nest-count (1- nest-count)))
- ))))
-
- ((looking-at "begin")
- (setq first nil))
-
- (t
- (setq nest-count (1+ nest-count))
- (setq first nil)))
- )
-
- (if (and
- (zerop nest-count)
- (if (looking-at "is")
- (ada-search-ignore-string-comment ada-subprog-start-re t)
- (looking-at "declare\\|generic")))
- t
- (if noerror nil
- (error "No matching proc/func/task/declare/package/protected")))
- ))
- (defun ada-goto-matching-start (&optional nest-level noerror gotothen)
- "Move point to the beginning of a block-start.
- Which block depends on the value of NEST-LEVEL, which defaults to zero.
- If NOERROR is non-nil, it only returns nil if no matching start was found.
- If GOTOTHEN is non-nil, point moves to the 'then' following 'if'."
- (let ((nest-count (if nest-level nest-level 0))
- (found nil)
- (last-was-begin '())
-
-
-
-
-
- (pos nil))
-
- (while (and
- (not found)
- (ada-search-ignore-string-comment ada-matching-start-re t))
- (unless (and (looking-at "\\<record\\>")
- (save-excursion
- (forward-word -1)
- (looking-at "\\<null\\>")))
- (progn
-
- (cond
-
- ((looking-at "end")
- (push nil last-was-begin)
- (setq nest-count (1+ nest-count)))
-
-
- ((looking-at "loop\\|select\\|record\\|case\\|if")
- (setq pos (point))
- (save-excursion
-
- (ada-goto-previous-word)
- (if (looking-at "\\<end\\>[ \t]*[^;]")
- (progn
-
- (setq nest-count (1+ nest-count)
- pos (point))
- (push nil last-was-begin))
-
- (setq nest-count (1- nest-count))
-
-
- (while (car last-was-begin)
- (setq last-was-begin (cdr (cdr last-was-begin))))
- (setq last-was-begin (cdr last-was-begin))
- ))
- (goto-char pos)
- )
-
- ((looking-at "package")
- (save-excursion
-
- (let ((current (point))
- (pos (ada-search-ignore-string-comment
- "\\<\\(is\\|renames\\|;\\)\\>" nil)))
- (if pos
- (goto-char (car pos))
- (error (concat
- "No matching 'is' or 'renames' for 'package' at"
- " line "
- (number-to-string (count-lines 1 (1+ current)))))))
- (unless (looking-at "renames")
- (progn
- (forward-word 1)
- (ada-goto-next-non-ws)
-
-
-
-
-
- (if (and (not (looking-at "\\<\\(new\\|separate\\|begin\\)\\>"))
- (not (car last-was-begin)))
- (setq nest-count (1- nest-count))))))
- (setq last-was-begin (cdr last-was-begin))
- )
-
- ((looking-at "task")
- (save-excursion
- (forward-word 1)
- (ada-goto-next-non-ws)
- (cond
- ((looking-at "\\<body\\>"))
- ((looking-at "\\<type\\>")
-
- (forward-word 2)
- (ada-goto-next-non-ws)
-
-
- (unless (looking-at ";")
- (progn
-
- (if (looking-at "(")
- (ada-search-ignore-string-comment ")" nil))
- (let ((tmp (ada-search-ignore-string-comment
- "\\<\\(is\\|;\\)\\>" nil)))
- (if tmp
- (progn
- (goto-char (car tmp))
- (if (looking-at "is")
- (setq nest-count (1- nest-count)))))))))
- (t
-
-
- (unless (progn (forward-word 1)
- (looking-at "[ \t]*;"))
- (setq nest-count (1- nest-count))))))
- (setq last-was-begin (cdr last-was-begin))
- )
- ((looking-at "declare")
-
-
- (setq last-was-begin (cdr last-was-begin))
- (let ((count 1))
- (while (and (> count 0))
- (if (equal (car last-was-begin) t)
- (setq count (1+ count))
- (setq count (1- count)))
- (setq last-was-begin (cdr last-was-begin))
- )))
- ((looking-at "protected")
-
- (save-excursion
- (let ((pos (ada-search-ignore-string-comment
- "\\(\\<is\\>\\|\\<renames\\>\\|;\\)" nil)))
- (if pos
- (goto-char (car pos)))
- (if (looking-at "is")
-
- (setq last-was-begin (cdr last-was-begin)))))
- (setq nest-count (1- nest-count)))
- ((or (looking-at "procedure")
- (looking-at "function"))
-
- (save-excursion
- (let ((pos (ada-search-ignore-string-comment
- "\\(\\<is\\>\\|\\<renames\\>\\|)[ \t]*;\\)" nil)))
- (if pos
- (goto-char (car pos)))
- (if (looking-at "is")
-
- (setq last-was-begin (cdr (cdr last-was-begin))))))
- )
-
- (t
- (push (looking-at "begin") last-was-begin)
- (setq nest-count (1- nest-count)))
- )
-
- (setq found (zerop nest-count)))))
- (if (bobp)
- (point)
- (if found
-
-
-
- (progn
- (cond
-
-
-
-
- ((and
- gotothen
- (looking-at "if")
- (save-excursion
- (ada-search-ignore-string-comment "then" nil nil nil
- 'word-search-forward)
- (back-to-indentation)
- (looking-at "\\<then\\>")))
- (goto-char (match-beginning 0)))
-
-
-
- ((looking-at "do")
- (unless (ada-search-ignore-string-comment
- "\\<accept\\|return\\>" t)
- (error "Missing 'accept' or 'return' in front of 'do'"))))
- (point))
- (if noerror
- nil
- (error "No matching start"))))))
- (defun ada-goto-matching-end (&optional nest-level noerror)
- "Move point to the end of a block.
- Which block depends on the value of NEST-LEVEL, which defaults to zero.
- If NOERROR is non-nil, it only returns nil if no matching start found."
- (let ((nest-count (or nest-level 0))
- (regex (eval-when-compile
- (concat "\\<"
- (regexp-opt '("end" "loop" "select" "begin" "case"
- "if" "task" "package" "record" "do"
- "procedure" "function") t)
- "\\>")))
- found
- pos
-
-
-
- (first (not (looking-at "declare"))))
-
-
-
-
- (if (looking-at "\\<if\\|loop\\|case\\|begin\\>")
- (forward-char 1))
-
-
-
- (while (and
- (not found)
- (ada-search-ignore-string-comment regex nil))
-
-
-
- (backward-word 1)
- (cond
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ((and (looking-at "\\<procedure\\|function\\>"))
- (if first
- (forward-word 1)
- (setq pos (point))
- (ada-search-ignore-string-comment "is\\|;")
- (if (= (char-before) ?s)
- (progn
- (ada-goto-next-non-ws)
- (unless (looking-at "\\<new\\>")
- (progn
- (goto-char pos)
- (ada-goto-matching-end 0 t)))))))
-
- ((looking-at "\\<end\\>")
- (setq nest-count (1- nest-count)
- found (<= nest-count 0))
-
- (if (progn
- (skip-chars-forward "end")
- (ada-goto-next-non-ws)
- (looking-at "\\<\\(loop\\|select\\|record\\|case\\|if\\)\\>"))
- (forward-word 1)))
-
-
- ((looking-at "\\<package\\>")
- (ada-search-ignore-string-comment "is" nil nil nil
- 'word-search-forward)
- (ada-goto-next-non-ws)
-
- (if (looking-at "\\<new\\>")
- (goto-char (match-end 0))
- (setq nest-count (1+ nest-count)
- found (<= nest-count 0))))
-
- (t
- (if (not first)
- (setq nest-count (1+ nest-count)))
- (setq found (<= nest-count 0))
- (forward-word 1)))
- (setq first nil))
- (if found
- t
- (if noerror
- nil
- (error "No matching end")))
- ))
- (defun ada-search-ignore-string-comment
- (search-re &optional backward limit paramlists search-func)
- "Regexp-search for SEARCH-RE, ignoring comments, strings.
- Returns a cons cell of begin and end of match data or nil, if not found.
- If BACKWARD is non-nil, search backward; search forward otherwise.
- The search stops at pos LIMIT.
- If PARAMLISTS is nil, ignore parameter lists.
- The search is done using SEARCH-FUNC. SEARCH-FUNC can be optimized
- in case we are searching for a constant string.
- Point is moved at the beginning of the SEARCH-RE."
- (let (found
- begin
- end
- parse-result)
-
- (unless search-func
- (setq search-func (if backward 're-search-backward 're-search-forward)))
-
-
-
-
- (with-syntax-table ada-mode-symbol-syntax-table
- (while (and (not found)
- (or (not limit)
- (or (and backward (<= limit (point)))
- (>= limit (point))))
- (funcall search-func search-re limit 1))
- (setq begin (match-beginning 0))
- (setq end (match-end 0))
- (setq parse-result (parse-partial-sexp (point-at-bol) (point)))
- (cond
-
-
-
- ((ada-in-string-p parse-result)
- (if (featurep 'xemacs)
- (search-backward "\"" nil t)
- (goto-char (nth 8 parse-result)))
- (unless backward (forward-sexp 1)))
-
-
-
-
- ((ada-in-comment-p parse-result)
- (if (featurep 'xemacs)
- (progn
- (forward-line 1)
- (beginning-of-line)
- (forward-comment -1))
- (goto-char (nth 8 parse-result)))
- (unless backward
-
-
- (if (forward-comment 1)
- (progn
- (forward-comment 1000)
- (beginning-of-line))
- (end-of-line))))
-
-
-
- ((and (= (char-after begin) ?-) (= (char-after (1+ begin)) ?-))
- (unless backward (progn (forward-char -1) (forward-comment 1000))))
-
-
-
- ((and (not paramlists) (ada-in-paramlist-p))
- (if backward
- (search-backward "(" nil t)
- (search-forward ")" nil t)))
-
-
-
- (t
- (setq found t)))))
- (if found
- (cons begin end)
- nil)))
- (defun ada-in-decl-p ()
- "Return t if point is inside a declarative part.
- Assumes point to be at the end of a statement."
- (or (ada-in-paramlist-p)
- (save-excursion
- (ada-goto-decl-start t))))
- (defun ada-looking-at-semi-or ()
- "Return t if looking at an 'or' following a semicolon."
- (save-excursion
- (and (looking-at "\\<or\\>")
- (progn
- (forward-word 1)
- (ada-goto-stmt-start)
- (looking-at "\\<or\\>")))))
- (defun ada-looking-at-semi-private ()
- "Return t if looking at the start of a private section in a package.
- Return nil if the private is part of the package name, as in
- 'private package A is...' (this can only happen at top level)."
- (save-excursion
- (and (looking-at "\\<private\\>")
- (not (looking-at "\\<private[ \t]*\\(package\\|generic\\)"))
-
-
-
-
-
-
-
- (progn (forward-comment -1000)
- (and (not (bobp))
- (or (= (char-before) ?\
- (and (forward-word -3)
- (looking-at "\\<package\\>"))))))))
- (defun ada-in-paramlist-p ()
- "Return t if point is inside the parameter-list of a declaration, but not a subprogram call or aggregate."
- (save-excursion
- (and
- (ada-search-ignore-string-comment "(\\|)" t nil t)
-
- (= (char-after) ?\()
-
-
-
-
- (progn
- (skip-chars-backward " \t\n")
- (if (= (char-before) ?\")
- (backward-char 3)
- (backward-word 1))
- t)
- ;; and now over the second one
- (backward-word 1)
- ;; We should ignore the case when the reserved keyword is in a
- ;; comment (for instance, when we have:
- ;; -- .... package
- ;; Test (A)
- ;; we should return nil
- (not (ada-in-string-or-comment-p))
- ;; right keyword two words before parenthesis ?
- ;; Type is in this list because of discriminants
- ;; pragma is not, because the syntax is that of a subprogram call.
- (looking-at (eval-when-compile
- (concat "\\<\\("
- "procedure\\|function\\|body\\|"
- "task\\|entry\\|accept\\|"
- "access[ \t]+procedure\\|"
- "access[ \t]+function\\|"
- "type\\)\\>"))))))
- (defun ada-search-ignore-complex-boolean (regexp backwardp)
- "Search for REGEXP, ignoring comments, strings, 'and then', 'or else'.
- If BACKWARDP is non-nil, search backward; search forward otherwise."
- (let (result)
- (while (and (setq result (ada-search-ignore-string-comment regexp backwardp))
- (save-excursion (forward-word -1)
- (looking-at "and then\\|or else"))))
- result))
- (defun ada-in-open-paren-p ()
- "Non-nil if in an open parenthesis.
- Return value is the position of the first non-ws behind the last unclosed
- parenthesis, or nil."
- (save-excursion
- (let ((parse (parse-partial-sexp
- (point)
- (or (car (ada-search-ignore-complex-boolean
- "\\<\\(
- t))
- (point-min)))))
- (if (nth 1 parse)
- (progn
- (goto-char (1+ (nth 1 parse)))
-
-
-
-
-
-
- (if (or (not ada-indent-handle-comment-special)
- (not (looking-at "[ \t]+--")))
- (skip-chars-forward " \t"))
- (point))))))
- (defun ada-tab ()
- "Do indenting or tabbing according to `ada-tab-policy'.
- In Transient Mark mode, if the mark is active, operate on the contents
- of the region. Otherwise, operate only on the current line."
- (interactive)
- (cond ((eq ada-tab-policy 'indent-rigidly) (ada-tab-hard))
- ((eq ada-tab-policy 'indent-auto)
- (if (ada-region-selected)
- (ada-indent-region (region-beginning) (region-end))
- (ada-indent-current)))
- ((eq ada-tab-policy 'always-tab) (error "Not implemented"))
- ))
- (defun ada-untab (_arg)
- "Delete leading indenting according to `ada-tab-policy'."
-
- (interactive "P")
- (cond ((eq ada-tab-policy 'indent-rigidly) (ada-untab-hard))
- ((eq ada-tab-policy 'indent-auto) (error "Not implemented"))
- ((eq ada-tab-policy 'always-tab) (error "Not implemented"))
- ))
- (defun ada-indent-current-function ()
- "Ada mode version of the `indent-line-function'."
- (interactive "*")
- (let ((starting-point (point-marker)))
- (beginning-of-line)
- (ada-tab)
- (if (< (point) starting-point)
- (goto-char starting-point))
- (set-marker starting-point nil)
- ))
- (defun ada-tab-hard ()
- "Indent current line to next tab stop."
- (interactive)
- (save-excursion
- (beginning-of-line)
- (insert-char ? ada-indent))
- (if (bolp) (forward-char ada-indent)))
- (defun ada-untab-hard ()
- "Indent current line to previous tab stop."
- (interactive)
- (indent-rigidly (point-at-bol) (point-at-eol) (- 0 ada-indent)))
- (defun ada-remove-trailing-spaces ()
- "Remove trailing spaces in the whole buffer."
- (interactive)
- (save-match-data
- (save-excursion
- (save-restriction
- (widen)
- (goto-char (point-min))
- (while (re-search-forward "[ \t]+$" (point-max) t)
- (replace-match "" nil nil))))))
- (defun ada-gnat-style ()
- "Clean up comments, `(' and `,' for GNAT style checking switch."
- (interactive)
- (save-excursion
-
-
- (goto-char (point-min))
- (while (re-search-forward "--[ \t]*\\([^-\n]\\)" nil t)
- (replace-match "-- \\1")
- (forward-line 1)
- (beginning-of-line))
- (goto-char (point-min))
- (while (re-search-forward "\\>(" nil t)
- (if (not (ada-in-string-or-comment-p))
- (replace-match " (")))
- (goto-char (point-min))
- (while (re-search-forward ";--" nil t)
- (forward-char -1)
- (if (not (ada-in-string-or-comment-p))
- (replace-match "; --")))
- (goto-char (point-min))
- (while (re-search-forward "([ \t]+" nil t)
- (if (not (ada-in-string-or-comment-p))
- (replace-match "(")))
- (goto-char (point-min))
- (while (re-search-forward ")[ \t]+)" nil t)
- (if (not (ada-in-string-or-comment-p))
- (replace-match "))")))
- (goto-char (point-min))
- (while (re-search-forward "\\>:" nil t)
- (if (not (ada-in-string-or-comment-p))
- (replace-match " :")))
-
-
-
- (goto-char (point-min))
- (while (re-search-forward ",[ \t]*\\(.\\)" nil t)
- (if (not (save-excursion
- (goto-char (match-beginning 0))
- (ada-in-string-or-comment-p)))
- (replace-match ", \\1")))
-
- (goto-char (point-min))
- (while (re-search-forward
- "[ \t]*\\(/=\\|\\*\\*\\|:=\\|\\.\\.\\|[-:+*/]\\)[ \t]*"
- nil t)
- (goto-char (match-beginning 1))
- (if (or (looking-at "--")
- (ada-in-string-or-comment-p))
- (progn
- (forward-line 1)
- (beginning-of-line))
- (cond
- ((string= (match-string 1) "/=")
- (replace-match " /= "))
- ((string= (match-string 1) "..")
- (replace-match " .. "))
- ((string= (match-string 1) "**")
- (replace-match " ** "))
- ((string= (match-string 1) ":=")
- (replace-match " := "))
- (t
- (replace-match " \\1 ")))
- (forward-char 1)))
- ))
- (defun ada-move-to-start ()
- "Move point to the matching start of the current Ada structure."
- (interactive)
- (let ((pos (point)))
- (with-syntax-table ada-mode-symbol-syntax-table
- (save-excursion
-
-
-
-
- (or
- (ada-in-string-or-comment-p)
- (and (progn
- (or (looking-at "[ \t]*\\<end\\>")
- (backward-word 1))
- (or (looking-at "[ \t]*\\<end\\>")
- (backward-word 1))
- (or (looking-at "[ \t]*\\<end\\>")
- (error "Not on end ...;")))
- (ada-goto-matching-start 1)
- (setq pos (point))
-
-
-
- ada-move-to-declaration
- (looking-at "\\<begin\\>")
- (ada-goto-decl-start)
- (setq pos (point))))
- )
-
- (goto-char pos))))
- (defun ada-move-to-end ()
- "Move point to the end of the block around point.
- Moves to 'begin' if in a declarative part."
- (interactive)
- (let ((pos (point))
- decl-start)
- (with-syntax-table ada-mode-symbol-syntax-table
- (save-excursion
- (cond
-
-
- ((save-excursion
- (skip-syntax-backward "w")
- (looking-at "\\<begin\\>"))
- (ada-goto-matching-end 1))
-
-
-
-
- ((save-excursion
- (and (skip-syntax-backward "w")
- (looking-at "\\<function\\>\\|\\<procedure\\>" )
- (ada-search-ignore-string-comment "is\\|;")
- (not (= (char-before) ?\
- ))
- (skip-syntax-backward "w")
- (ada-goto-matching-end 0 t))
-
- ((save-excursion
- (and (ada-goto-stmt-start)
- (looking-at "\\<task\\>" )
- (forward-word 1)
- (ada-goto-next-non-ws)
- (looking-at "\\<body\\>")))
- (ada-search-ignore-string-comment "begin" nil nil nil
- 'word-search-forward))
-
- ((save-excursion
- (and (ada-goto-stmt-start)
- (looking-at "\\<accept\\>" )))
- (ada-goto-matching-end 0))
-
- ((save-excursion
- (setq decl-start (and (ada-goto-decl-start t) (point)))
- (and decl-start (looking-at "\\<package\\>")))
- (ada-goto-matching-end 1))
-
- ((save-excursion
- (skip-syntax-backward "w")
- (looking-at "\\<declare\\>"))
- (ada-goto-matching-end 0 t))
-
- (decl-start
- (goto-char decl-start)
- (ada-goto-matching-end 0 t))
-
- (t
- (ada-goto-matching-end 1)))
- (setq pos (point))
- )
-
- (goto-char pos))))
- (defun ada-next-procedure ()
- "Move point to next procedure."
- (interactive)
- (end-of-line)
- (if (re-search-forward ada-procedure-start-regexp nil t)
- (goto-char (match-beginning 4))
- (error "No more functions/procedures/tasks")))
- (defun ada-previous-procedure ()
- "Move point to previous procedure."
- (interactive)
- (beginning-of-line)
- (if (re-search-backward ada-procedure-start-regexp nil t)
- (goto-char (match-beginning 4))
- (error "No more functions/procedures/tasks")))
- (defun ada-next-package ()
- "Move point to next package."
- (interactive)
- (end-of-line)
- (if (re-search-forward ada-package-start-regexp nil t)
- (goto-char (match-beginning 1))
- (error "No more packages")))
- (defun ada-previous-package ()
- "Move point to previous package."
- (interactive)
- (beginning-of-line)
- (if (re-search-backward ada-package-start-regexp nil t)
- (goto-char (match-beginning 1))
- (error "No more packages")))
- (defun ada-create-keymap ()
- "Create the keymap associated with the Ada mode."
-
- (define-key ada-mode-map ada-mode-extra-prefix ada-mode-extra-map)
-
- (define-key ada-mode-map "\C-j" 'ada-indent-newline-indent-conditional)
- (define-key ada-mode-map "\C-m" 'ada-indent-newline-indent-conditional)
- (define-key ada-mode-map "\t" 'ada-tab)
- (define-key ada-mode-map "\C-c\t" 'ada-justified-indent-current)
- (define-key ada-mode-map "\C-c\C-l" 'ada-indent-region)
- (define-key ada-mode-map [(shift tab)] 'ada-untab)
- (define-key ada-mode-map "\C-c\C-f" 'ada-format-paramlist)
-
-
- (define-key ada-mode-map "\M-\C-e" 'ada-next-procedure)
- (define-key ada-mode-map "\M-\C-a" 'ada-previous-procedure)
- (define-key ada-mode-map "\C-c\C-a" 'ada-move-to-start)
- (define-key ada-mode-map "\C-c\C-e" 'ada-move-to-end)
-
- (unless (lookup-key ada-mode-map "\C-c\C-c")
- (define-key ada-mode-map "\C-c\C-c" 'compile))
-
- (define-key ada-mode-map "\C-c\C-b" 'ada-adjust-case-buffer)
- (define-key ada-mode-map "\C-c\C-t" 'ada-case-read-exceptions)
- (define-key ada-mode-map "\C-c\C-y" 'ada-create-case-exception)
- (define-key ada-mode-map "\C-c\C-\M-y" 'ada-create-case-exception-substring)
-
-
-
- (define-key ada-mode-map
- (if (boundp 'delete-key-deletes-forward) [backspace] "\177")
- 'backward-delete-char-untabify)
-
- (define-key ada-mode-map "\C-c\C-n" 'ada-make-subprogram-body)
-
- (define-key ada-mode-map "\C-c;" 'comment-region)
- (define-key ada-mode-map "\C-c:" 'ada-uncomment-region)
-
-
-
- (define-key ada-mode-map (if (featurep 'xemacs) '(shift button3) [S-mouse-3])
- 'ada-point-and-xref)
- (define-key ada-mode-map [(control tab)] 'ada-complete-identifier)
- (define-key ada-mode-extra-map "o" 'ff-find-other-file)
- (define-key ada-mode-map "\C-c5\C-d" 'ada-goto-declaration-other-frame)
- (define-key ada-mode-map "\C-c\C-d" 'ada-goto-declaration)
- (define-key ada-mode-map "\C-c\C-s" 'ada-xref-goto-previous-reference)
- (define-key ada-mode-map "\C-c\C-c" 'ada-compile-application)
- (define-key ada-mode-extra-map "c" 'ada-change-prj)
- (define-key ada-mode-extra-map "d" 'ada-set-default-project-file)
- (define-key ada-mode-extra-map "g" 'ada-gdb-application)
- (define-key ada-mode-map "\C-c\C-m" 'ada-set-main-compile-application)
- (define-key ada-mode-extra-map "r" 'ada-run-application)
- (define-key ada-mode-map "\C-c\C-o" 'ada-goto-parent)
- (define-key ada-mode-map "\C-c\C-r" 'ada-find-references)
- (define-key ada-mode-extra-map "l" 'ada-find-local-references)
- (define-key ada-mode-map "\C-c\C-v" 'ada-check-current)
- (define-key ada-mode-extra-map "f" 'ada-find-file)
- (define-key ada-mode-extra-map "u" 'ada-prj-edit)
- (define-key ada-mode-map "\C-xnd" 'ada-narrow-to-defun)
-
- (let ((map (make-sparse-keymap)))
- (define-key map "h" 'ada-header)
- (define-key map "\C-a" 'ada-array)
- (define-key map "b" 'ada-exception-block)
- (define-key map "d" 'ada-declare-block)
- (define-key map "c" 'ada-case)
- (define-key map "\C-e" 'ada-elsif)
- (define-key map "e" 'ada-else)
- (define-key map "\C-k" 'ada-package-spec)
- (define-key map "k" 'ada-package-body)
- (define-key map "\C-p" 'ada-procedure-spec)
- (define-key map "p" 'ada-subprogram-body)
- (define-key map "\C-f" 'ada-function-spec)
- (define-key map "f" 'ada-for-loop)
- (define-key map "i" 'ada-if)
- (define-key map "l" 'ada-loop)
- (define-key map "\C-r" 'ada-record)
- (define-key map "\C-s" 'ada-subtype)
- (define-key map "S" 'ada-tabsize)
- (define-key map "\C-t" 'ada-task-spec)
- (define-key map "t" 'ada-task-body)
- (define-key map "\C-y" 'ada-type)
- (define-key map "\C-v" 'ada-private)
- (define-key map "u" 'ada-use)
- (define-key map "\C-u" 'ada-with)
- (define-key map "\C-w" 'ada-when)
- (define-key map "w" 'ada-while-loop)
- (define-key map "\C-x" 'ada-exception)
- (define-key map "x" 'ada-exit)
- (define-key ada-mode-extra-map "t" map))
- )
- (defun ada-create-menu ()
- "Create the Ada menu as shown in the menu bar."
- (let ((m '("Ada"
- ("Help"
- ["Ada Mode" (info "ada-mode") t]
- ["GNAT User's Guide" (info "gnat_ugn")
- (eq ada-which-compiler 'gnat)]
- ["GNAT Reference Manual" (info "gnat_rm")
- (eq ada-which-compiler 'gnat)]
- ["Gcc Documentation" (info "gcc")
- (eq ada-which-compiler 'gnat)]
- ["Gdb Documentation" (info "gdb")
- (eq ada-which-compiler 'gnat)]
- ["Ada95 Reference Manual" (info "arm95") t])
- ("Options" :included (derived-mode-p 'ada-mode)
- ["Auto Casing" (setq ada-auto-case (not ada-auto-case))
- :style toggle :selected ada-auto-case]
- ["Auto Indent After Return"
- (setq ada-indent-after-return (not ada-indent-after-return))
- :style toggle :selected ada-indent-after-return]
- ["Automatically Recompile For Cross-references"
- (setq ada-xref-create-ali (not ada-xref-create-ali))
- :style toggle :selected ada-xref-create-ali
- :included (eq ada-which-compiler 'gnat)]
- ["Confirm Commands"
- (setq ada-xref-confirm-compile (not ada-xref-confirm-compile))
- :style toggle :selected ada-xref-confirm-compile
- :included (eq ada-which-compiler 'gnat)]
- ["Show Cross-references In Other Buffer"
- (setq ada-xref-other-buffer (not ada-xref-other-buffer))
- :style toggle :selected ada-xref-other-buffer
- :included (eq ada-which-compiler 'gnat)]
- ["Tight Integration With GNU Visual Debugger"
- (setq ada-tight-gvd-integration (not ada-tight-gvd-integration))
- :style toggle :selected ada-tight-gvd-integration
- :included (string-match "gvd" ada-prj-default-debugger)])
- ["Customize" (customize-group 'ada)
- :included (fboundp 'customize-group)]
- ["Check file" ada-check-current t]
- ["Compile file" ada-compile-current t]
- ["Set main and Build" ada-set-main-compile-application t]
- ["Show main" ada-show-current-main t]
- ["Build" ada-compile-application t]
- ["Run" ada-run-application t]
- ["Debug" ada-gdb-application (eq ada-which-compiler 'gnat)]
- ["------" nil nil]
- ("Project"
- ["Show project" ada-show-current-project t]
- ["Load..." ada-set-default-project-file t]
- ["New..." ada-prj-new t]
- ["Edit..." ada-prj-edit t])
- ("Goto" :included (derived-mode-p 'ada-mode)
- ["Goto Declaration/Body" ada-goto-declaration
- (eq ada-which-compiler 'gnat)]
- ["Goto Body" ada-goto-body
- (eq ada-which-compiler 'gnat)]
- ["Goto Declaration Other Frame"
- ada-goto-declaration-other-frame
- (eq ada-which-compiler 'gnat)]
- ["Goto Previous Reference" ada-xref-goto-previous-reference
- (eq ada-which-compiler 'gnat)]
- ["List Local References" ada-find-local-references
- (eq ada-which-compiler 'gnat)]
- ["List References" ada-find-references
- (eq ada-which-compiler 'gnat)]
- ["Goto Reference To Any Entity" ada-find-any-references
- (eq ada-which-compiler 'gnat)]
- ["Goto Parent Unit" ada-goto-parent
- (eq ada-which-compiler 'gnat)]
- ["--" nil nil]
- ["Next compilation error" next-error t]
- ["Previous Package" ada-previous-package t]
- ["Next Package" ada-next-package t]
- ["Previous Procedure" ada-previous-procedure t]
- ["Next Procedure" ada-next-procedure t]
- ["Goto Start Of Statement" ada-move-to-start t]
- ["Goto End Of Statement" ada-move-to-end t]
- ["-" nil nil]
- ["Other File" ff-find-other-file t]
- ["Other File Other Window" ada-ff-other-window t])
- ("Edit" :included (derived-mode-p 'ada-mode)
- ["Search File On Source Path" ada-find-file t]
- ["------" nil nil]
- ["Complete Identifier" ada-complete-identifier t]
- ["-----" nil nil]
- ["Indent Line" ada-indent-current-function t]
- ["Justify Current Indentation" ada-justified-indent-current t]
- ["Indent Lines in Selection" ada-indent-region t]
- ["Indent Lines in File"
- (ada-indent-region (point-min) (point-max)) t]
- ["Format Parameter List" ada-format-paramlist t]
- ["-" nil nil]
- ["Comment Selection" comment-region t]
- ["Uncomment Selection" ada-uncomment-region t]
- ["--" nil nil]
- ["Fill Comment Paragraph" fill-paragraph t]
- ["Fill Comment Paragraph Justify"
- ada-fill-comment-paragraph-justify t]
- ["Fill Comment Paragraph Postfix"
- ada-fill-comment-paragraph-postfix t]
- ["---" nil nil]
- ["Adjust Case Selection" ada-adjust-case-region t]
- ["Adjust Case in File" ada-adjust-case-buffer t]
- ["Create Case Exception" ada-create-case-exception t]
- ["Create Case Exception Substring"
- ada-create-case-exception-substring t]
- ["Reload Case Exceptions" ada-case-read-exceptions t]
- ["----" nil nil]
- ["Make body for subprogram" ada-make-subprogram-body t]
- ["-----" nil nil]
- ["Narrow to subprogram" ada-narrow-to-defun t])
- ("Templates"
- :included (derived-mode-p 'ada-mode)
- ["Header" ada-header t]
- ["-" nil nil]
- ["Package Body" ada-package-body t]
- ["Package Spec" ada-package-spec t]
- ["Function Spec" ada-function-spec t]
- ["Procedure Spec" ada-procedure-spec t]
- ["Proc/func Body" ada-subprogram-body t]
- ["Task Body" ada-task-body t]
- ["Task Spec" ada-task-spec t]
- ["Declare Block" ada-declare-block t]
- ["Exception Block" ada-exception-block t]
- ["--" nil nil]
- ["Entry" ada-entry t]
- ["Entry family" ada-entry-family t]
- ["Select" ada-select t]
- ["Accept" ada-accept t]
- ["Or accept" ada-or-accept t]
- ["Or delay" ada-or-delay t]
- ["Or terminate" ada-or-terminate t]
- ["---" nil nil]
- ["Type" ada-type t]
- ["Private" ada-private t]
- ["Subtype" ada-subtype t]
- ["Record" ada-record t]
- ["Array" ada-array t]
- ["----" nil nil]
- ["If" ada-if t]
- ["Else" ada-else t]
- ["Elsif" ada-elsif t]
- ["Case" ada-case t]
- ["-----" nil nil]
- ["While Loop" ada-while-loop t]
- ["For Loop" ada-for-loop t]
- ["Loop" ada-loop t]
- ["------" nil nil]
- ["Exception" ada-exception t]
- ["Exit" ada-exit t]
- ["When" ada-when t])
- )))
- (easy-menu-define ada-mode-menu ada-mode-map "Menu keymap for Ada mode" m)
- (if (featurep 'xemacs)
- (progn
- (define-key ada-mode-map [menu-bar] ada-mode-menu)
- (setq mode-popup-menu (cons "Ada mode" ada-mode-menu))))))
- (defadvice comment-region (before ada-uncomment-anywhere disable)
- (if (and (consp arg)
-
- (derived-mode-p 'ada-mode))
- (save-excursion
- (let ((cs (concat "^[ \t]*" (regexp-quote comment-start))))
- (goto-char beg)
- (while (re-search-forward cs end t)
- (replace-match comment-start))
- ))))
- (defun ada-uncomment-region (beg end &optional arg)
- "Uncomment region BEG .. END.
- ARG gives number of comment characters."
- (interactive "r\nP")
-
-
- (if (or (<= emacs-major-version 20) (featurep 'xemacs))
- (progn
- (ad-activate 'comment-region)
- (-region beg end (- (or arg 2)))
- (ad-deactivate 'comment-region))
- (-region beg end (list (- (or arg 2))))
- (ada-indent-region beg end)))
- (defun ada-fill-comment-paragraph-justify ()
- "Fill current comment paragraph and justify each line as well."
- (interactive)
- (ada-fill-comment-paragraph 'full))
- (defun ada-fill-comment-paragraph-postfix ()
- "Fill current comment paragraph and justify each line as well.
- Adds `ada-fill-comment-postfix' at the end of each line."
- (interactive)
- (ada-fill-comment-paragraph 'full t))
- (defun ada-fill-comment-paragraph (&optional justify postfix)
- "Fill the current comment paragraph.
- If JUSTIFY is non-nil, each line is justified as well.
- If POSTFIX and JUSTIFY are non-nil, `ada-fill-comment-postfix' is appended
- to each line filled and justified.
- The paragraph is indented on the first line."
- (interactive "P")
-
- (if (and (not (ada-in-comment-p))
- (not (looking-at "[ \t]*--")))
- (error "Not inside comment"))
- (let* (indent from to
- (opos (point-marker))
-
-
- (parse-sexp-lookup-properties nil)
- fill-prefix
- (fill-column (current-fill-column)))
-
- (back-to-indentation)
- (while (and (not (eobp)) (looking-at ".*--[ \t]*[^ \t\n]"))
- (forward-line 1)
-
-
- (if (eobp)
- (insert "\n")
- (back-to-indentation)))
- (beginning-of-line)
- (setq to (point-marker))
- (goto-char opos)
-
- (back-to-indentation)
- (while (and (not (bobp)) (looking-at ".*--[ \t]*[^ \t\n]"))
- (forward-line -1)
- (back-to-indentation))
-
-
- (unless (bobp)
- (forward-line 1))
- (beginning-of-line)
- (setq from (point-marker))
-
- (back-to-indentation)
- (setq indent (current-column))
-
- (delete-region from (point))
-
- (goto-char from)
- (while (re-search-forward "--\n" to t)
- (replace-match "\n"))
- (goto-char (1- to))
- (setq to (point-marker))
-
- (setq fill-prefix ada-fill-comment-prefix)
- (set-left-margin from to indent)
- (if postfix
- (setq fill-column (- fill-column (length ada-fill-comment-postfix))))
- (fill-region-as-paragraph from to justify)
-
- (if postfix
- (save-restriction
- (goto-char from)
- (narrow-to-region from to)
- (while (not (eobp))
- (end-of-line)
- (insert-char ? (- fill-column (current-column)))
- (insert ada-fill-comment-postfix)
- (forward-line))
- ))
-
-
- (if (or (featurep 'xemacs)
- (<= emacs-major-version 19)
- (and (= emacs-major-version 20)
- (<= emacs-minor-version 2)))
- (progn
- (goto-char to)
- (end-of-line)
- (delete-char 1)))
- (goto-char opos)))
- (defun ada-make-filename-from-adaname (adaname)
- "Determine the filename in which ADANAME is found.
- This matches the GNAT default naming convention, except for
- pre-defined units."
- (while (string-match "\\." adaname)
- (setq adaname (replace-match "-" t t adaname)))
- (downcase adaname)
- )
- (defun ada-other-file-name ()
- "Return the name of the other file.
- The name returned is the body if `current-buffer' is the spec,
- or the spec otherwise."
- (let ((is-spec nil)
- (is-body nil)
- (suffixes ada-spec-suffixes)
- (name (buffer-file-name)))
-
-
-
- (while (and (not is-spec)
- suffixes)
- (if (string-match (concat "\\(.*\\)" (car suffixes) "$") name)
- (setq is-spec t
- name (match-string 1 name)))
- (setq suffixes (cdr suffixes)))
- (if (not is-spec)
- (progn
- (setq suffixes ada-body-suffixes)
- (while (and (not is-body)
- suffixes)
- (if (string-match (concat "\\(.*\\)" (car suffixes) "$") name)
- (setq is-body t
- name (match-string 1 name)))
- (setq suffixes (cdr suffixes)))))
-
- (if (not (or is-spec is-body))
- name
-
- (if is-spec
- (setq suffixes ada-body-suffixes)
- (setq suffixes ada-spec-suffixes))
- (setq is-spec name)
- (while suffixes
-
-
- (if (fboundp 'ada-find-src-file-in-dir)
- (let ((other
- (ada-find-src-file-in-dir
- (file-name-nondirectory (concat name (car suffixes))))))
- (if other
- (setq is-spec other)))
-
- (if (file-exists-p (concat name (car suffixes)))
- (setq is-spec (concat name (car suffixes)))))
- (setq suffixes (cdr suffixes)))
- is-spec)))
- (defun ada-which-function-are-we-in ()
- "Return the name of the function whose definition/declaration point is in.
- Used in `ff-pre-load-hook'."
- (setq ff-function-name nil)
- (save-excursion
- (end-of-line)
- (or (if (re-search-backward ada-procedure-start-regexp nil t)
- (setq ff-function-name (match-string 5)))
- (if (re-search-backward ada-package-start-regexp nil t)
- (setq ff-function-name (match-string 4))))
- ))
- (defvar ada-last-which-function-line -1
- "Last line on which `ada-which-function' was called.")
- (defvar ada-last-which-function-subprog 0
- "Last subprogram name returned by `ada-which-function'.")
- (make-variable-buffer-local 'ada-last-which-function-subprog)
- (make-variable-buffer-local 'ada-last-which-function-line)
- (defun ada-which-function ()
- "Return the name of the function whose body the point is in.
- This function works even in the case of nested subprograms, whereas the
- standard Emacs function `which-function' does not.
- Since the search can be long, the results are cached."
- (let ((line (count-lines 1 (point)))
- (pos (point))
- end-pos
- func-name indent
- found)
-
- (if (= line ada-last-which-function-line)
- ada-last-which-function-subprog
- (save-excursion
-
- (end-of-line)
-
- (skip-chars-forward " \t\n(")
- (condition-case nil
- (up-list 1)
- (error nil))
- (skip-chars-forward " \t\n")
- (if (looking-at "return")
- (progn
- (forward-word 1)
- (skip-chars-forward " \t\n")
- (skip-chars-forward "a-zA-Z0-9_'")))
-
-
- (skip-chars-forward "is \t\n")
-
-
-
-
- (while (and (not found)
- (re-search-backward ada-imenu-subprogram-menu-re nil t))
-
-
- (setq func-name (match-string-no-properties 3))
- (if (and (not (ada-in-comment-p))
- (not (save-excursion
- (goto-char (match-end 0))
- (looking-at "[ \t\n]*new"))))
- (save-excursion
- (back-to-indentation)
- (setq indent (current-column))
- (if (ada-search-ignore-string-comment
- (concat "end[ \t]+" func-name "[ \t]*;\\|^"
- (make-string indent ? ) "end;"))
- (setq end-pos (point))
- (setq end-pos (point-max)))
- (if (>= end-pos pos)
- (setq found func-name))))
- )
- (setq ada-last-which-function-line line
- ada-last-which-function-subprog found)
- found))))
- (defun ada-ff-other-window ()
- "Find other file in other window using `ff-find-other-file'."
- (interactive)
- (and (fboundp 'ff-find-other-file)
- (ff-find-other-file t)))
- (defun ada-set-point-accordingly ()
- "Move to the function declaration that was set by `ff-which-function-are-we-in'."
- (if ff-function-name
- (progn
- (goto-char (point-min))
- (unless (ada-search-ignore-string-comment
- (concat ff-function-name "\\b") nil)
- (goto-char (point-min))))))
- (defun ada-get-body-name (&optional spec-name)
- "Return the file name for the body of SPEC-NAME.
- If SPEC-NAME is nil, return the body for the current package.
- Return nil if no body was found."
- (interactive)
- (unless spec-name (setq spec-name (buffer-file-name)))
-
-
-
- (let ((suffixes ada-spec-suffixes)
- end)
- (while suffixes
- (setq end (- (length spec-name) (length (car suffixes))))
- (if (string-equal (car suffixes) (substring spec-name end))
- (setq spec-name (substring spec-name 0 end)))
- (setq suffixes (cdr suffixes))))
-
- (if (fboundp 'ff-get-file-name)
- (ff-get-file-name ada-search-directories-internal
- (ada-make-filename-from-adaname
- (file-name-nondirectory
- (file-name-sans-extension spec-name)))
- ada-body-suffixes)
-
- (concat (ada-make-filename-from-adaname
- (file-name-nondirectory
- (file-name-sans-extension spec-name)))
- ".adb")))
- (defconst ada-font-lock-syntactic-keywords
-
-
-
-
-
-
- '(("[^a-zA-Z0-9)]\\('\\)[^\n]\\('\\)" (1 (7 . ?')) (2 (7 . ?')))
- ("^[ \t]*\\(#\\(if\\|else\\|elsif\\|end\\)\\)" (1 (11 . ?\n)))))
- (defvar ada-font-lock-keywords
- (eval-when-compile
- (list
-
-
- (list "\\<\\(function[ \t]+return\\)\\>" '(1 font-lock-keyword-face) )
-
- (list "^[ \t]*\\(#.*\n\\)" '(1 font-lock-type-face t))
-
-
-
- (list (concat
- "\\<\\("
- "accept\\|"
- "entry\\|"
- "function\\|"
- "package[ \t]+body\\|"
- "package\\|"
- "pragma\\|"
- "procedure\\|"
- "protected[ \t]+body\\|"
- "protected[ \t]+type\\|"
- "protected\\|"
- "task[ \t]+body\\|"
- "task[ \t]+type\\|"
- "task"
- "\\)\\>[ \t]*"
- "\\(\\sw+\\(\\.\\sw*\\)*\\)?")
- '(1 font-lock-keyword-face) '(2 font-lock-function-name-face nil t))
-
-
- (list (concat
- "\\<\\(access[ \t]+all\\|access[ \t]+constant\\|access\\|constant\\|in[ \t]+reverse\\|\\|in[ \t]+out\\|in\\|out\\)\\>"
- "[ \t]*"
- "\\(\\sw+\\(\\.\\sw*\\)*\\)?")
- '(1 font-lock-keyword-face nil t) '(2 font-lock-type-face nil t))
-
-
- (concat "\\<"
- (regexp-opt
- '("abort" "abs" "abstract" "accept" "access" "aliased" "all"
- "and" "array" "at" "begin" "case" "declare" "delay" "delta"
- "digits" "do" "else" "elsif" "entry" "exception" "exit" "for"
- "generic" "if" "in" "interface" "is" "limited" "loop" "mod" "not"
- "null" "or" "others" "overriding" "private" "protected" "raise"
- "range" "record" "rem" "renames" "requeue" "return" "reverse"
- "select" "separate" "synchronized" "tagged" "task" "terminate"
- "then" "until" "when" "while" "with" "xor") t)
- "\\>")
-
-
- '("\\<\\(end\\)\\>\\([ \t]+\\)?\\(\\(\\sw\\|[_.]\\)+\\)?"
- (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
-
-
- (list (concat "\\<\\("
- "new\\|of\\|subtype\\|type"
- "\\)\\>[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?[ \t]*\\((\\)?")
- '(1 font-lock-keyword-face)
- '(2 (if (match-beginning 4)
- font-lock-function-name-face
- font-lock-type-face) nil t))
-
-
-
-
- (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)"
- "[ \t]+\\([a-zA-Z0-9_., \t]+\\)\\W")
- '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t))
-
-
- '("<<\\(\\sw+\\)>>" 1 font-lock-reference-face)
-
- (list "\\([0-9]+#[0-9a-fA-F_]+#\\)" '(1 font-lock-constant-face t))
-
- (list "\\W\\([-+]?[0-9._]+\\)\\>" '(1 font-lock-constant-face))
- ))
- "Default expressions to highlight in Ada mode.")
- (defun ada-outline-level ()
- "This is so that `current-column' DTRT in otherwise-hidden text."
-
- (let (buffer-invisibility-spec)
- (save-excursion
- (back-to-indentation)
- (current-column))))
- (defun ada-narrow-to-defun (&optional _arg)
- "Make text outside current subprogram invisible.
- The subprogram visible is the one that contains or follow point.
- Optional ARG is ignored.
- Use \\[widen] to go back to the full visibility for the buffer."
- (interactive)
- (save-excursion
- (let (end)
- (widen)
- (forward-line 1)
- (ada-previous-procedure)
- (setq end (point-at-bol))
- (ada-move-to-end)
- (end-of-line)
- (narrow-to-region end (point))
- (message
- "Use M-x widen to get back to full visibility in the buffer"))))
- (defun ada-gen-treat-proc (match)
- "Make dummy body of a procedure/function specification.
- MATCH is a cons cell containing the start and end locations of the last search
- for `ada-procedure-start-regexp'."
- (goto-char (car match))
- (let (func-found procname functype)
- (cond
- ((or (looking-at "^[ \t]*procedure")
- (setq func-found (looking-at "^[ \t]*function")))
-
- (forward-word 2)
- (forward-word -1)
- (setq procname (buffer-substring (point) (cdr match)))
-
- (goto-char (cdr match))
-
- (unless (looking-at "[ \t\n]*\\(;\\|return\\)")
- (forward-sexp))
-
- (if func-found
- (progn
- (forward-word 1)
- (skip-chars-forward " \t\n")
- (setq functype (buffer-substring (point)
- (progn
- (skip-chars-forward
- "a-zA-Z0-9_\.")
- (point))))))
-
- (cond
- ((looking-at "[ \t]*;")
- (delete-region (match-beginning 0) (match-end 0))
- (ada-indent-newline-indent)
- (insert "is")
- (ada-indent-newline-indent)
- (if func-found
- (progn
- (insert "Result : " functype ";")
- (ada-indent-newline-indent)))
- (insert "begin")
- (ada-indent-newline-indent)
- (if func-found
- (insert "return Result;")
- (insert "null;"))
- (ada-indent-newline-indent)
- (insert "end " procname ";")
- (ada-indent-newline-indent)
- )
- ((looking-at "[ \t\n]*is")
-
- )
- ((looking-at "[ \t\n]*rename")
-
- )
- (t
- (message "unknown syntax"))))
- (t
- (if (looking-at "^[ \t]*task")
- (progn
- (message "Task conversion is not yet implemented")
- (forward-word 2)
- (if (looking-at "[ \t]*;")
- (forward-line)
- (ada-move-to-end))
- ))))))
- (defun ada-make-body ()
- "Create an Ada package body in the current buffer.
- The spec must be the previously visited buffer.
- This function typically is to be hooked into `ff-file-created-hook'."
- (delete-region (point-min) (point-max))
- (insert-buffer-substring (car (cdr (buffer-list))))
- (goto-char (point-min))
- (ada-mode)
- (let (found ada-procedure-or-package-start-regexp)
- (if (setq found
- (ada-search-ignore-string-comment ada-package-start-regexp nil))
- (progn (goto-char (cdr found))
- (insert " body")
- )
- (error "No package"))
- (setq ada-procedure-or-package-start-regexp
- (concat ada-procedure-start-regexp
- "\\|"
- ada-package-start-regexp))
- (while (setq found
- (ada-search-ignore-string-comment
- ada-procedure-or-package-start-regexp nil))
- (progn
- (goto-char (car found))
- (if (looking-at ada-package-start-regexp)
- (progn (goto-char (cdr found))
- (insert " body"))
- (ada-gen-treat-proc found))))))
- (defun ada-make-subprogram-body ()
- "Create a dummy subprogram body in package body file from spec surrounding point."
- (interactive)
- (let* ((found (re-search-backward ada-procedure-start-regexp nil t))
- (spec (match-beginning 0))
- body-file)
- (if found
- (progn
- (goto-char spec)
- (if (and (re-search-forward "(\\|;" nil t)
- (= (char-before) ?\())
- (progn
- (ada-search-ignore-string-comment ")" nil)
- (ada-search-ignore-string-comment ";" nil)))
- (setq spec (buffer-substring spec (point)))
-
- (setq body-file (ada-get-body-name))
- (if body-file
- (find-file body-file)
- (error "No body found for the package. Create it first"))
- (save-restriction
- (widen)
- (goto-char (point-max))
- (forward-comment -10000)
- (re-search-backward "\\<end\\>" nil t)
-
- (re-search-backward "^begin" nil t)
- (newline)
- (forward-char -1)
- (insert spec)
- (re-search-backward ada-procedure-start-regexp nil t)
- (ada-gen-treat-proc (cons (match-beginning 0) (match-end 0)))
- ))
- (error "Not in subprogram spec"))))
- (ada-create-keymap)
- (ada-create-menu)
- (ada-create-syntax-table)
- (ada-add-extensions ".ads" ".adb")
- (if (equal ada-which-compiler 'gnat)
- (ada-add-extensions ".ads.dg" ".adb.dg"))
- (ada-case-read-exceptions)
- (autoload 'ada-change-prj "ada-xref" nil t)
- (autoload 'ada-check-current "ada-xref" nil t)
- (autoload 'ada-compile-application "ada-xref" nil t)
- (autoload 'ada-compile-current "ada-xref" nil t)
- (autoload 'ada-complete-identifier "ada-xref" nil t)
- (autoload 'ada-find-file "ada-xref" nil t)
- (autoload 'ada-find-any-references "ada-xref" nil t)
- (autoload 'ada-find-src-file-in-dir "ada-xref" nil t)
- (autoload 'ada-find-local-references "ada-xref" nil t)
- (autoload 'ada-find-references "ada-xref" nil t)
- (autoload 'ada-gdb-application "ada-xref" nil t)
- (autoload 'ada-goto-declaration "ada-xref" nil t)
- (autoload 'ada-goto-declaration-other-frame "ada-xref" nil t)
- (autoload 'ada-goto-parent "ada-xref" nil t)
- (autoload 'ada-make-body-gnatstub "ada-xref" nil t)
- (autoload 'ada-point-and-xref "ada-xref" nil t)
- (autoload 'ada-reread-prj-file "ada-xref" nil t)
- (autoload 'ada-run-application "ada-xref" nil t)
- (autoload 'ada-set-default-project-file "ada-xref" nil t)
- (autoload 'ada-xref-goto-previous-reference "ada-xref" nil t)
- (autoload 'ada-set-main-compile-application "ada-xref" nil t)
- (autoload 'ada-show-current-main "ada-xref" nil t)
- (autoload 'ada-customize "ada-prj" nil t)
- (autoload 'ada-prj-edit "ada-prj" nil t)
- (autoload 'ada-prj-new "ada-prj" nil t)
- (autoload 'ada-prj-save "ada-prj" nil t)
- (autoload 'ada-array "ada-stmt" nil t)
- (autoload 'ada-case "ada-stmt" nil t)
- (autoload 'ada-declare-block "ada-stmt" nil t)
- (autoload 'ada-else "ada-stmt" nil t)
- (autoload 'ada-elsif "ada-stmt" nil t)
- (autoload 'ada-exception "ada-stmt" nil t)
- (autoload 'ada-exception-block "ada-stmt" nil t)
- (autoload 'ada-exit "ada-stmt" nil t)
- (autoload 'ada-for-loop "ada-stmt" nil t)
- (autoload 'ada-function-spec "ada-stmt" nil t)
- (autoload 'ada-header "ada-stmt" nil t)
- (autoload 'ada-if "ada-stmt" nil t)
- (autoload 'ada-loop "ada-stmt" nil t)
- (autoload 'ada-package-body "ada-stmt" nil t)
- (autoload 'ada-package-spec "ada-stmt" nil t)
- (autoload 'ada-private "ada-stmt" nil t)
- (autoload 'ada-procedure-spec "ada-stmt" nil t)
- (autoload 'ada-record "ada-stmt" nil t)
- (autoload 'ada-subprogram-body "ada-stmt" nil t)
- (autoload 'ada-subtype "ada-stmt" nil t)
- (autoload 'ada-tabsize "ada-stmt" nil t)
- (autoload 'ada-task-body "ada-stmt" nil t)
- (autoload 'ada-task-spec "ada-stmt" nil t)
- (autoload 'ada-type "ada-stmt" nil t)
- (autoload 'ada-use "ada-stmt" nil t)
- (autoload 'ada-when "ada-stmt" nil t)
- (autoload 'ada-while-loop "ada-stmt" nil t)
- (autoload 'ada-with "ada-stmt" nil t)
- (provide 'ada-mode)
|