gnus-sum.el 472 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128
  1. ;;; gnus-sum.el --- summary mode commands for Gnus
  2. ;; Copyright (C) 1996-2015 Free Software Foundation, Inc.
  3. ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
  4. ;; Keywords: news
  5. ;; This file is part of GNU Emacs.
  6. ;; GNU Emacs is free software: you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation, either version 3 of the License, or
  9. ;; (at your option) any later version.
  10. ;; GNU Emacs is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;; GNU General Public License for more details.
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;;; Code:
  18. (eval-when-compile
  19. (require 'cl))
  20. (eval-when-compile
  21. (when (featurep 'xemacs)
  22. (require 'easy-mmode))) ; for `define-minor-mode'
  23. (defvar tool-bar-mode)
  24. (defvar gnus-tmp-header)
  25. (require 'gnus)
  26. (require 'gnus-group)
  27. (require 'gnus-spec)
  28. (require 'gnus-range)
  29. (require 'gnus-int)
  30. (require 'gnus-undo)
  31. (require 'gnus-util)
  32. (require 'gmm-utils)
  33. (require 'mm-decode)
  34. (require 'nnoo)
  35. (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
  36. (autoload 'gnus-cache-write-active "gnus-cache")
  37. (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
  38. (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
  39. (autoload 'gnus-pick-line-number "gnus-salt" nil t)
  40. (autoload 'mm-uu-dissect "mm-uu")
  41. (autoload 'gnus-article-outlook-deuglify-article "deuglify"
  42. "Deuglify broken Outlook (Express) articles and redisplay."
  43. t)
  44. (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
  45. (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
  46. (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
  47. (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
  48. (autoload 'nnir-article-group "nnir" nil nil 'macro)
  49. (defcustom gnus-kill-summary-on-exit t
  50. "*If non-nil, kill the summary buffer when you exit from it.
  51. If nil, the summary will become a \"*Dead Summary*\" buffer, and
  52. it will be killed sometime later."
  53. :group 'gnus-summary-exit
  54. :type 'boolean)
  55. (defcustom gnus-summary-next-group-on-exit t
  56. "If non-nil, go to the next unread newsgroup on summary exit.
  57. See `gnus-group-goto-unread'."
  58. :link '(custom-manual "(gnus)Group Maneuvering")
  59. :group 'gnus-summary-exit
  60. :version "23.1" ;; No Gnus
  61. :type 'boolean)
  62. (defcustom gnus-summary-stop-at-end-of-message nil
  63. "If non-nil, don't select the next message when using `SPC'."
  64. :link '(custom-manual "(gnus)Group Maneuvering")
  65. :group 'gnus-summary-maneuvering
  66. :version "24.1"
  67. :type 'boolean)
  68. (defcustom gnus-fetch-old-headers nil
  69. "*Non-nil means that Gnus will try to build threads by grabbing old headers.
  70. If an unread article in the group refers to an older, already
  71. read (or just marked as read) article, the old article will not
  72. normally be displayed in the Summary buffer. If this variable is
  73. t, Gnus will attempt to grab the headers to the old articles, and
  74. thereby build complete threads. If it has the value `some', all
  75. old headers will be fetched but only enough headers to connect
  76. otherwise loose threads will be displayed. This variable can
  77. also be a number. In that case, no more than that number of old
  78. headers will be fetched. If it has the value `invisible', all
  79. old headers will be fetched, but none will be displayed.
  80. The server has to support NOV for any of this to work.
  81. This feature can seriously impact performance it ignores all
  82. locally cached header entries. Setting it to t for groups for a
  83. server that doesn't expire articles (such as news.gmane.org),
  84. leads to very slow summary generation."
  85. :group 'gnus-thread
  86. :type '(choice (const :tag "off" nil)
  87. (const :tag "on" t)
  88. (const some)
  89. (const invisible)
  90. number
  91. (sexp :menu-tag "other" t)))
  92. (defcustom gnus-refer-thread-limit 500
  93. "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
  94. If t, fetch all the available old headers."
  95. :group 'gnus-thread
  96. :type '(choice number
  97. (sexp :menu-tag "other" t)))
  98. (defcustom gnus-refer-thread-use-nnir nil
  99. "*Use nnir to search an entire server when referring threads. A
  100. nil value will only search for thread-related articles in the
  101. current group."
  102. :version "24.1"
  103. :group 'gnus-thread
  104. :type 'boolean)
  105. (defcustom gnus-summary-make-false-root 'adopt
  106. "*nil means that Gnus won't gather loose threads.
  107. If the root of a thread has expired or been read in a previous
  108. session, the information necessary to build a complete thread has been
  109. lost. Instead of having many small sub-threads from this original thread
  110. scattered all over the summary buffer, Gnus can gather them.
  111. If non-nil, Gnus will try to gather all loose sub-threads from an
  112. original thread into one large thread.
  113. If this variable is non-nil, it should be one of `none', `adopt',
  114. `dummy' or `empty'.
  115. If this variable is `none', Gnus will not make a false root, but just
  116. present the sub-threads after another.
  117. If this variable is `dummy', Gnus will create a dummy root that will
  118. have all the sub-threads as children.
  119. If this variable is `adopt', Gnus will make one of the \"children\"
  120. the parent and mark all the step-children as such.
  121. If this variable is `empty', the \"children\" are printed with empty
  122. subject fields. (Or rather, they will be printed with a string
  123. given by the `gnus-summary-same-subject' variable.)"
  124. :group 'gnus-thread
  125. :type '(choice (const :tag "off" nil)
  126. (const none)
  127. (const dummy)
  128. (const adopt)
  129. (const empty)))
  130. (defcustom gnus-summary-make-false-root-always nil
  131. "Always make a false dummy root."
  132. :version "22.1"
  133. :group 'gnus-thread
  134. :type 'boolean)
  135. (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
  136. "*A regexp to match subjects to be excluded from loose thread gathering.
  137. As loose thread gathering is done on subjects only, that means that
  138. there can be many false gatherings performed. By rooting out certain
  139. common subjects, gathering might become saner."
  140. :group 'gnus-thread
  141. :type 'regexp)
  142. (defcustom gnus-summary-gather-subject-limit nil
  143. "*Maximum length of subject comparisons when gathering loose threads.
  144. Use nil to compare full subjects. Setting this variable to a low
  145. number will help gather threads that have been corrupted by
  146. newsreaders chopping off subject lines, but it might also mean that
  147. unrelated articles that have subject that happen to begin with the
  148. same few characters will be incorrectly gathered.
  149. If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
  150. comparing subjects."
  151. :group 'gnus-thread
  152. :type '(choice (const :tag "off" nil)
  153. (const fuzzy)
  154. (sexp :menu-tag "on" t)))
  155. (defcustom gnus-simplify-subject-functions nil
  156. "List of functions taking a string argument that simplify subjects.
  157. The functions are applied recursively.
  158. Useful functions to put in this list include:
  159. `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
  160. `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
  161. :group 'gnus-thread
  162. :type '(repeat function))
  163. (defcustom gnus-simplify-ignored-prefixes nil
  164. "*Remove matches for this regexp from subject lines when simplifying fuzzily."
  165. :group 'gnus-thread
  166. :type '(choice (const :tag "off" nil)
  167. regexp))
  168. (defcustom gnus-build-sparse-threads nil
  169. "*If non-nil, fill in the gaps in threads.
  170. If `some', only fill in the gaps that are needed to tie loose threads
  171. together. If `more', fill in all leaf nodes that Gnus can find. If
  172. non-nil and non-`some', fill in all gaps that Gnus manages to guess."
  173. :group 'gnus-thread
  174. :type '(choice (const :tag "off" nil)
  175. (const some)
  176. (const more)
  177. (sexp :menu-tag "all" t)))
  178. (defcustom gnus-summary-thread-gathering-function
  179. 'gnus-gather-threads-by-subject
  180. "*Function used for gathering loose threads.
  181. There are two pre-defined functions: `gnus-gather-threads-by-subject',
  182. which only takes Subjects into consideration; and
  183. `gnus-gather-threads-by-references', which compared the References
  184. headers of the articles to find matches."
  185. :group 'gnus-thread
  186. :type '(radio (function-item gnus-gather-threads-by-subject)
  187. (function-item gnus-gather-threads-by-references)
  188. (function :tag "other")))
  189. (defcustom gnus-summary-same-subject ""
  190. "*String indicating that the current article has the same subject as the previous.
  191. This variable will only be used if the value of
  192. `gnus-summary-make-false-root' is `empty'."
  193. :group 'gnus-summary-format
  194. :type 'string)
  195. (defcustom gnus-summary-goto-unread nil
  196. "*If t, many commands will go to the next unread article.
  197. This applies to marking commands as well as other commands that
  198. \"naturally\" select the next article, like, for instance, `SPC' at
  199. the end of an article.
  200. If nil, the marking commands do NOT go to the next unread article
  201. \(they go to the next article instead). If `never', commands that
  202. usually go to the next unread article, will go to the next article,
  203. whether it is read or not."
  204. :version "24.1"
  205. :group 'gnus-summary-marks
  206. :link '(custom-manual "(gnus)Setting Marks")
  207. :type '(choice (const :tag "off" nil)
  208. (const never)
  209. (sexp :menu-tag "on" t)))
  210. (defcustom gnus-summary-default-score 0
  211. "*Default article score level.
  212. All scores generated by the score files will be added to this score.
  213. If this variable is nil, scoring will be disabled."
  214. :group 'gnus-score-default
  215. :type '(choice (const :tag "disable")
  216. integer))
  217. (defcustom gnus-summary-default-high-score 0
  218. "*Default threshold for a high scored article.
  219. An article will be highlighted as high scored if its score is greater
  220. than this score."
  221. :version "22.1"
  222. :group 'gnus-score-default
  223. :type 'integer)
  224. (defcustom gnus-summary-default-low-score 0
  225. "*Default threshold for a low scored article.
  226. An article will be highlighted as low scored if its score is smaller
  227. than this score."
  228. :version "22.1"
  229. :group 'gnus-score-default
  230. :type 'integer)
  231. (defcustom gnus-summary-zcore-fuzz 0
  232. "*Fuzziness factor for the zcore in the summary buffer.
  233. Articles with scores closer than this to `gnus-summary-default-score'
  234. will not be marked."
  235. :group 'gnus-summary-format
  236. :type 'integer)
  237. (defcustom gnus-simplify-subject-fuzzy-regexp nil
  238. "*Strings to be removed when doing fuzzy matches.
  239. This can either be a regular expression or list of regular expressions
  240. that will be removed from subject strings if fuzzy subject
  241. simplification is selected."
  242. :group 'gnus-thread
  243. :type '(repeat regexp))
  244. (defcustom gnus-show-threads t
  245. "*If non-nil, display threads in summary mode."
  246. :group 'gnus-thread
  247. :type 'boolean)
  248. (defcustom gnus-thread-hide-subtree nil
  249. "*If non-nil, hide all threads initially.
  250. This can be a predicate specifier which says which threads to hide.
  251. If threads are hidden, you have to run the command
  252. `gnus-summary-show-thread' by hand or select an article."
  253. :group 'gnus-thread
  254. :type '(radio (sexp :format "Non-nil\n"
  255. :match (lambda (widget value)
  256. (not (or (consp value) (functionp value))))
  257. :value t)
  258. (const nil)
  259. (sexp :tag "Predicate specifier")))
  260. (defcustom gnus-thread-hide-killed t
  261. "*If non-nil, hide killed threads automatically."
  262. :group 'gnus-thread
  263. :type 'boolean)
  264. (defcustom gnus-thread-ignore-subject t
  265. "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
  266. If nil, articles that have different subjects from their parents will
  267. start separate threads."
  268. :group 'gnus-thread
  269. :type 'boolean)
  270. (defcustom gnus-thread-operation-ignore-subject t
  271. "*If non-nil, subjects will be ignored when doing thread commands.
  272. This affects commands like `gnus-summary-kill-thread' and
  273. `gnus-summary-lower-thread'.
  274. If this variable is nil, articles in the same thread with different
  275. subjects will not be included in the operation in question. If this
  276. variable is `fuzzy', only articles that have subjects that are fuzzily
  277. equal will be included."
  278. :group 'gnus-thread
  279. :type '(choice (const :tag "off" nil)
  280. (const fuzzy)
  281. (sexp :tag "on" t)))
  282. (defcustom gnus-thread-indent-level 4
  283. "*Number that says how much each sub-thread should be indented."
  284. :group 'gnus-thread
  285. :type 'integer)
  286. (defcustom gnus-auto-extend-newsgroup t
  287. "*If non-nil, extend newsgroup forward and backward when requested."
  288. :group 'gnus-summary-choose
  289. :type 'boolean)
  290. (defcustom gnus-auto-select-first t
  291. "If non-nil, select an article on group entry.
  292. An article is selected automatically when entering a group
  293. e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
  294. `gnus-summary-catchup-and-goto-next-group'.
  295. Which article is selected is controlled by the variable
  296. `gnus-auto-select-subject'.
  297. If you want to prevent automatic selection of articles in some
  298. newsgroups, set the variable to nil in `gnus-select-group-hook'."
  299. ;; Commands include...
  300. ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
  301. ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
  302. ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
  303. :group 'gnus-group-select
  304. :type '(choice (const :tag "none" nil)
  305. (sexp :menu-tag "first" t)))
  306. (defcustom gnus-auto-select-subject 'unseen-or-unread
  307. "*Says what subject to place under point when entering a group.
  308. This variable can either be the symbols `first' (place point on the
  309. first subject), `unread' (place point on the subject line of the first
  310. unread article), `best' (place point on the subject line of the
  311. highest-scored article), `unseen' (place point on the subject line of
  312. the first unseen article), `unseen-or-unread' (place point on the subject
  313. line of the first unseen article or, if all articles have been seen, on the
  314. subject line of the first unread article), or a function to be called to
  315. place point on some subject line."
  316. :version "24.1"
  317. :group 'gnus-group-select
  318. :type '(choice (const best)
  319. (const unread)
  320. (const first)
  321. (const unseen)
  322. (const unseen-or-unread)
  323. (function :tag "Function to call")))
  324. (defcustom gnus-auto-select-next t
  325. "*If non-nil, offer to go to the next group from the end of the previous.
  326. If the value is t and the next newsgroup is empty, Gnus will exit
  327. summary mode and go back to group mode. If the value is neither nil
  328. nor t, Gnus will select the following unread newsgroup. In
  329. particular, if the value is the symbol `quietly', the next unread
  330. newsgroup will be selected without any confirmation, and if it is
  331. `almost-quietly', the next group will be selected without any
  332. confirmation if you are located on the last article in the group.
  333. Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
  334. will go to the next group without confirmation."
  335. :group 'gnus-summary-maneuvering
  336. :type '(choice (const :tag "off" nil)
  337. (const quietly)
  338. (const almost-quietly)
  339. (const slightly-quietly)
  340. (sexp :menu-tag "on" t)))
  341. (defcustom gnus-auto-select-same nil
  342. "*If non-nil, select the next article with the same subject.
  343. If there are no more articles with the same subject, go to
  344. the first unread article."
  345. :group 'gnus-summary-maneuvering
  346. :type 'boolean)
  347. (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
  348. "What article should be selected after exiting an ephemeral group.
  349. Valid values include:
  350. `next'
  351. Select the next article.
  352. `next-unread'
  353. Select the next unread article.
  354. `next-noselect'
  355. Move the cursor to the next article. This is the default.
  356. `next-unread-noselect'
  357. Move the cursor to the next unread article.
  358. If it has any other value or there is no next (unread) article, the
  359. article selected before entering to the ephemeral group will appear."
  360. :version "23.1" ;; No Gnus
  361. :group 'gnus-summary-maneuvering
  362. :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
  363. (const next) (const next-unread)
  364. (const next-noselect) (const next-unread-noselect)
  365. (sexp :tag "other" :value nil)))
  366. (defcustom gnus-auto-goto-ignores 'unfetched
  367. "*Says how to handle unfetched articles when maneuvering.
  368. This variable can either be the symbols nil (maneuver to any
  369. article), `undownloaded' (maneuvering while unplugged ignores articles
  370. that have not been fetched), `always-undownloaded' (maneuvering always
  371. ignores articles that have not been fetched), `unfetched' (maneuvering
  372. ignores articles whose headers have not been fetched).
  373. NOTE: The list of unfetched articles will always be nil when plugged
  374. and, when unplugged, a subset of the undownloaded article list."
  375. :version "22.1"
  376. :group 'gnus-summary-maneuvering
  377. :type '(choice (const :tag "None" nil)
  378. (const :tag "Undownloaded when unplugged" undownloaded)
  379. (const :tag "Undownloaded" always-undownloaded)
  380. (const :tag "Unfetched" unfetched)))
  381. (defcustom gnus-summary-check-current nil
  382. "*If non-nil, consider the current article when moving.
  383. The \"unread\" movement commands will stay on the same line if the
  384. current article is unread."
  385. :group 'gnus-summary-maneuvering
  386. :type 'boolean)
  387. (defcustom gnus-auto-center-summary
  388. (max (or (bound-and-true-p scroll-margin) 0) 2)
  389. "*If non-nil, always center the current summary buffer.
  390. In particular, if `vertical' do only vertical recentering. If non-nil
  391. and non-`vertical', do both horizontal and vertical recentering."
  392. :group 'gnus-summary-maneuvering
  393. :type '(choice (const :tag "none" nil)
  394. (const vertical)
  395. (integer :tag "height")
  396. (sexp :menu-tag "both" t)))
  397. (defcustom gnus-auto-center-group t
  398. "If non-nil, always center the group buffer."
  399. :group 'gnus-summary-maneuvering
  400. :type 'boolean)
  401. (defcustom gnus-show-all-headers nil
  402. "*If non-nil, don't hide any headers."
  403. :group 'gnus-article-hiding
  404. :group 'gnus-article-headers
  405. :type 'boolean)
  406. (defcustom gnus-summary-ignore-duplicates nil
  407. "*If non-nil, ignore articles with identical Message-ID headers."
  408. :group 'gnus-summary
  409. :type 'boolean)
  410. (defcustom gnus-single-article-buffer nil
  411. "*If non-nil, display all articles in the same buffer.
  412. If nil, each group will get its own article buffer."
  413. :version "24.1"
  414. :group 'gnus-article-various
  415. :type 'boolean)
  416. (defcustom gnus-widen-article-window nil
  417. "If non-nil, selecting the article buffer will display only the article buffer."
  418. :version "24.1"
  419. :group 'gnus-article-various
  420. :type 'boolean)
  421. (defcustom gnus-break-pages t
  422. "*If non-nil, do page breaking on articles.
  423. The page delimiter is specified by the `gnus-page-delimiter'
  424. variable."
  425. :group 'gnus-article-various
  426. :type 'boolean)
  427. (defcustom gnus-move-split-methods nil
  428. "*Variable used to suggest where articles are to be moved to.
  429. It uses the same syntax as the `gnus-split-methods' variable.
  430. However, whereas `gnus-split-methods' specifies file names as targets,
  431. this variable specifies group names."
  432. :group 'gnus-summary-mail
  433. :type '(repeat (choice (list :value (fun) function)
  434. (cons :value ("" "") regexp (repeat string))
  435. (sexp :value nil))))
  436. (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
  437. "Function used to compute default prefix for article move/copy/etc prompts.
  438. The function should take one argument, a group name, and return a
  439. string with the suggested prefix."
  440. :group 'gnus-summary-mail
  441. :type 'function)
  442. ;; FIXME: Although the custom type is `character' for the following variables,
  443. ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
  444. (defcustom gnus-unread-mark ? ;Whitespace
  445. "*Mark used for unread articles."
  446. :group 'gnus-summary-marks
  447. :type 'character)
  448. (defcustom gnus-ticked-mark ?!
  449. "*Mark used for ticked articles."
  450. :group 'gnus-summary-marks
  451. :type 'character)
  452. (defcustom gnus-dormant-mark ??
  453. "*Mark used for dormant articles."
  454. :group 'gnus-summary-marks
  455. :type 'character)
  456. (defcustom gnus-del-mark ?r
  457. "*Mark used for del'd articles."
  458. :group 'gnus-summary-marks
  459. :type 'character)
  460. (defcustom gnus-read-mark ?R
  461. "*Mark used for read articles."
  462. :group 'gnus-summary-marks
  463. :type 'character)
  464. (defcustom gnus-expirable-mark ?E
  465. "*Mark used for expirable articles."
  466. :group 'gnus-summary-marks
  467. :type 'character)
  468. (defcustom gnus-killed-mark ?K
  469. "*Mark used for killed articles."
  470. :group 'gnus-summary-marks
  471. :type 'character)
  472. (defcustom gnus-spam-mark ?$
  473. "*Mark used for spam articles."
  474. :version "22.1"
  475. :group 'gnus-summary-marks
  476. :type 'character)
  477. (defcustom gnus-kill-file-mark ?X
  478. "*Mark used for articles killed by kill files."
  479. :group 'gnus-summary-marks
  480. :type 'character)
  481. (defcustom gnus-low-score-mark ?Y
  482. "*Mark used for articles with a low score."
  483. :group 'gnus-summary-marks
  484. :type 'character)
  485. (defcustom gnus-catchup-mark ?C
  486. "*Mark used for articles that are caught up."
  487. :group 'gnus-summary-marks
  488. :type 'character)
  489. (defcustom gnus-replied-mark ?A
  490. "*Mark used for articles that have been replied to."
  491. :group 'gnus-summary-marks
  492. :type 'character)
  493. (defcustom gnus-forwarded-mark ?F
  494. "*Mark used for articles that have been forwarded."
  495. :version "22.1"
  496. :group 'gnus-summary-marks
  497. :type 'character)
  498. (defcustom gnus-recent-mark ?N
  499. "*Mark used for articles that are recent."
  500. :version "22.1"
  501. :group 'gnus-summary-marks
  502. :type 'character)
  503. (defcustom gnus-cached-mark ?*
  504. "*Mark used for articles that are in the cache."
  505. :group 'gnus-summary-marks
  506. :type 'character)
  507. (defcustom gnus-saved-mark ?S
  508. "*Mark used for articles that have been saved."
  509. :group 'gnus-summary-marks
  510. :type 'character)
  511. (defcustom gnus-unseen-mark ?.
  512. "*Mark used for articles that haven't been seen."
  513. :version "22.1"
  514. :group 'gnus-summary-marks
  515. :type 'character)
  516. (defcustom gnus-no-mark ? ;Whitespace
  517. "*Mark used for articles that have no other secondary mark."
  518. :version "22.1"
  519. :group 'gnus-summary-marks
  520. :type 'character)
  521. (defcustom gnus-ancient-mark ?O
  522. "*Mark used for ancient articles."
  523. :group 'gnus-summary-marks
  524. :type 'character)
  525. (defcustom gnus-sparse-mark ?Q
  526. "*Mark used for sparsely reffed articles."
  527. :group 'gnus-summary-marks
  528. :type 'character)
  529. (defcustom gnus-canceled-mark ?G
  530. "*Mark used for canceled articles."
  531. :group 'gnus-summary-marks
  532. :type 'character)
  533. (defcustom gnus-duplicate-mark ?M
  534. "*Mark used for duplicate articles."
  535. :group 'gnus-summary-marks
  536. :type 'character)
  537. (defcustom gnus-undownloaded-mark ?-
  538. "*Mark used for articles that weren't downloaded."
  539. :version "22.1"
  540. :group 'gnus-summary-marks
  541. :type 'character)
  542. (defcustom gnus-downloaded-mark ?+
  543. "*Mark used for articles that were downloaded."
  544. :group 'gnus-summary-marks
  545. :type 'character)
  546. (defcustom gnus-downloadable-mark ?%
  547. "*Mark used for articles that are to be downloaded."
  548. :group 'gnus-summary-marks
  549. :type 'character)
  550. (defcustom gnus-unsendable-mark ?=
  551. "*Mark used for articles that won't be sent."
  552. :group 'gnus-summary-marks
  553. :type 'character)
  554. (defcustom gnus-score-over-mark ?+
  555. "*Score mark used for articles with high scores."
  556. :group 'gnus-summary-marks
  557. :type 'character)
  558. (defcustom gnus-score-below-mark ?-
  559. "*Score mark used for articles with low scores."
  560. :group 'gnus-summary-marks
  561. :type 'character)
  562. (defcustom gnus-empty-thread-mark ? ;Whitespace
  563. "*There is no thread under the article."
  564. :group 'gnus-summary-marks
  565. :type 'character)
  566. (defcustom gnus-not-empty-thread-mark ?=
  567. "*There is a thread under the article."
  568. :group 'gnus-summary-marks
  569. :type 'character)
  570. (defcustom gnus-view-pseudo-asynchronously nil
  571. "*If non-nil, Gnus will view pseudo-articles asynchronously."
  572. :group 'gnus-extract-view
  573. :type 'boolean)
  574. (defcustom gnus-auto-expirable-marks
  575. (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
  576. gnus-low-score-mark gnus-ancient-mark gnus-read-mark
  577. gnus-duplicate-mark)
  578. "*The list of marks converted into expiration if a group is auto-expirable."
  579. :version "24.1"
  580. :group 'gnus-summary
  581. :type '(repeat character))
  582. (defcustom gnus-inhibit-user-auto-expire t
  583. "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
  584. :version "21.1"
  585. :group 'gnus-summary
  586. :type 'boolean)
  587. (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
  588. "If non-nil, mark articles copied or moved to auto-expire group as expirable.
  589. If nil, the expirable marks will be unchanged except that the marks
  590. will be removed when copying or moving articles to a group that has
  591. not turned auto-expire on. If non-nil, articles that have been read
  592. will be marked as expirable when being copied or moved to a group in
  593. which auto-expire is turned on."
  594. :version "23.2"
  595. :type 'boolean
  596. :group 'gnus-summary-marks)
  597. (defcustom gnus-view-pseudos nil
  598. "*If `automatic', pseudo-articles will be viewed automatically.
  599. If `not-confirm', pseudos will be viewed automatically, and the user
  600. will not be asked to confirm the command."
  601. :group 'gnus-extract-view
  602. :type '(choice (const :tag "off" nil)
  603. (const automatic)
  604. (const not-confirm)))
  605. (defcustom gnus-view-pseudos-separately t
  606. "*If non-nil, one pseudo-article will be created for each file to be viewed.
  607. If nil, all files that use the same viewing command will be given as a
  608. list of parameters to that command."
  609. :group 'gnus-extract-view
  610. :type 'boolean)
  611. (defcustom gnus-insert-pseudo-articles t
  612. "*If non-nil, insert pseudo-articles when decoding articles."
  613. :group 'gnus-extract-view
  614. :type 'boolean)
  615. (defcustom gnus-summary-dummy-line-format
  616. " %(: :%) %S\n"
  617. "*The format specification for the dummy roots in the summary buffer.
  618. It works along the same lines as a normal formatting string,
  619. with some simple extensions.
  620. %S The subject
  621. General format specifiers can also be used.
  622. See `(gnus)Formatting Variables'."
  623. :link '(custom-manual "(gnus)Formatting Variables")
  624. :group 'gnus-threading
  625. :type 'string)
  626. (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
  627. "*The format specification for the summary mode line.
  628. It works along the same lines as a normal formatting string,
  629. with some simple extensions:
  630. %G Group name
  631. %p Unprefixed group name
  632. %A Current article number
  633. %z Current article score
  634. %V Gnus version
  635. %U Number of unread articles in the group
  636. %e Number of unselected articles in the group
  637. %Z A string with unread/unselected article counts
  638. %g Shortish group name
  639. %S Subject of the current article
  640. %u User-defined spec
  641. %s Current score file name
  642. %d Number of dormant articles
  643. %r Number of articles that have been marked as read in this session
  644. %E Number of articles expunged by the score files"
  645. :group 'gnus-summary-format
  646. :type 'string)
  647. (defcustom gnus-list-identifiers nil
  648. "Regexp that matches list identifiers to be removed from subject.
  649. This can also be a list of regexps."
  650. :version "21.1"
  651. :group 'gnus-summary-format
  652. :group 'gnus-article-hiding
  653. :type '(choice (const :tag "none" nil)
  654. (regexp :value ".*")
  655. (repeat :value (".*") regexp)))
  656. (defcustom gnus-summary-mark-below 0
  657. "*Mark all articles with a score below this variable as read.
  658. This variable is local to each summary buffer and usually set by the
  659. score file."
  660. :group 'gnus-score-default
  661. :type 'integer)
  662. (defun gnus-widget-reversible-match (widget value)
  663. "Ignoring WIDGET, convert VALUE to internal form.
  664. VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
  665. ;; (debug value)
  666. (or (symbolp value)
  667. (and (listp value)
  668. (eq (length value) 2)
  669. (eq (nth 0 value) 'not)
  670. (symbolp (nth 1 value)))))
  671. (defun gnus-widget-reversible-to-internal (widget value)
  672. "Ignoring WIDGET, convert VALUE to internal form.
  673. VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
  674. FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
  675. ;; (debug value)
  676. (if (atom value)
  677. (list value nil)
  678. (list (nth 1 value) t)))
  679. (defun gnus-widget-reversible-to-external (widget value)
  680. "Ignoring WIDGET, convert VALUE to external form.
  681. VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
  682. \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
  683. ;; (debug value)
  684. (if (nth 1 value)
  685. (list 'not (nth 0 value))
  686. (nth 0 value)))
  687. (define-widget 'gnus-widget-reversible 'group
  688. "A `group' that convert values."
  689. :match 'gnus-widget-reversible-match
  690. :value-to-internal 'gnus-widget-reversible-to-internal
  691. :value-to-external 'gnus-widget-reversible-to-external)
  692. (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
  693. "*List of functions used for sorting articles in the summary buffer.
  694. Each function takes two articles and returns non-nil if the first
  695. article should be sorted before the other. If you use more than one
  696. function, the primary sort function should be the last. You should
  697. probably always include `gnus-article-sort-by-number' in the list of
  698. sorting functions -- preferably first. Also note that sorting by date
  699. is often much slower than sorting by number, and the sorting order is
  700. very similar. (Sorting by date means sorting by the time the message
  701. was sent, sorting by number means sorting by arrival time.)
  702. Each item can also be a list `(not F)' where F is a function;
  703. this reverses the sort order.
  704. Ready-made functions include `gnus-article-sort-by-number',
  705. `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
  706. `gnus-article-sort-by-date', `gnus-article-sort-by-random'
  707. and `gnus-article-sort-by-score'.
  708. When threading is turned on, the variable `gnus-thread-sort-functions'
  709. controls how articles are sorted."
  710. :group 'gnus-summary-sort
  711. :type '(repeat (gnus-widget-reversible
  712. (choice (function-item gnus-article-sort-by-number)
  713. (function-item gnus-article-sort-by-author)
  714. (function-item gnus-article-sort-by-subject)
  715. (function-item gnus-article-sort-by-date)
  716. (function-item gnus-article-sort-by-score)
  717. (function-item gnus-article-sort-by-random)
  718. (function :tag "other"))
  719. (boolean :tag "Reverse order"))))
  720. (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
  721. "*List of functions used for sorting threads in the summary buffer.
  722. By default, threads are sorted by article number.
  723. Each function takes two threads and returns non-nil if the first
  724. thread should be sorted before the other. If you use more than one
  725. function, the primary sort function should be the last. You should
  726. probably always include `gnus-thread-sort-by-number' in the list of
  727. sorting functions -- preferably first. Also note that sorting by date
  728. is often much slower than sorting by number, and the sorting order is
  729. very similar. (Sorting by date means sorting by the time the message
  730. was sent, sorting by number means sorting by arrival time.)
  731. Each list item can also be a list `(not F)' where F is a
  732. function; this specifies reversed sort order.
  733. Ready-made functions include `gnus-thread-sort-by-number',
  734. `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
  735. `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
  736. `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
  737. `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
  738. and `gnus-thread-sort-by-total-score' (see
  739. `gnus-thread-score-function').
  740. When threading is turned off, the variable
  741. `gnus-article-sort-functions' controls how articles are sorted.
  742. By default, threads and their subthreads are sorted according to
  743. the value of this variable. To use a different sorting order for
  744. subthreads, customize `gnus-subthread-sort-functions'."
  745. :group 'gnus-summary-sort
  746. :type '(repeat
  747. (gnus-widget-reversible
  748. (choice (function-item gnus-thread-sort-by-number)
  749. (function-item gnus-thread-sort-by-author)
  750. (function-item gnus-thread-sort-by-recipient)
  751. (function-item gnus-thread-sort-by-subject)
  752. (function-item gnus-thread-sort-by-date)
  753. (function-item gnus-thread-sort-by-score)
  754. (function-item gnus-thread-sort-by-most-recent-number)
  755. (function-item gnus-thread-sort-by-most-recent-date)
  756. (function-item gnus-thread-sort-by-random)
  757. (function-item gnus-thread-sort-by-total-score)
  758. (function :tag "other"))
  759. (boolean :tag "Reverse order"))))
  760. (defcustom gnus-subthread-sort-functions 'gnus-thread-sort-functions
  761. "*List of functions used for sorting subthreads in the summary buffer.
  762. By default, subthreads are sorted the same as threads, i.e.,
  763. according to the value of `gnus-thread-sort-functions'."
  764. :version "24.4"
  765. :group 'gnus-summary-sort
  766. :type '(choice
  767. (const :tag "Sort subthreads like threads" gnus-thread-sort-functions)
  768. (repeat
  769. (gnus-widget-reversible
  770. (choice (function-item gnus-thread-sort-by-number)
  771. (function-item gnus-thread-sort-by-author)
  772. (function-item gnus-thread-sort-by-recipient)
  773. (function-item gnus-thread-sort-by-subject)
  774. (function-item gnus-thread-sort-by-date)
  775. (function-item gnus-thread-sort-by-score)
  776. (function-item gnus-thread-sort-by-most-recent-number)
  777. (function-item gnus-thread-sort-by-most-recent-date)
  778. (function-item gnus-thread-sort-by-random)
  779. (function-item gnus-thread-sort-by-total-score)
  780. (function :tag "other"))
  781. (boolean :tag "Reverse order")))))
  782. (defcustom gnus-thread-score-function '+
  783. "*Function used for calculating the total score of a thread.
  784. The function is called with the scores of the article and each
  785. subthread and should then return the score of the thread.
  786. Some functions you can use are `+', `max', or `min'."
  787. :group 'gnus-summary-sort
  788. :type 'function)
  789. (defcustom gnus-summary-expunge-below nil
  790. "All articles that have a score less than this variable will be expunged.
  791. This variable is local to the summary buffers."
  792. :group 'gnus-score-default
  793. :type '(choice (const :tag "off" nil)
  794. integer))
  795. (defcustom gnus-thread-expunge-below nil
  796. "All threads that have a total score less than this variable will be expunged.
  797. See `gnus-thread-score-function' for en explanation of what a
  798. \"thread score\" is.
  799. This variable is local to the summary buffers."
  800. :group 'gnus-threading
  801. :group 'gnus-score-default
  802. :type '(choice (const :tag "off" nil)
  803. integer))
  804. (defcustom gnus-summary-mode-hook nil
  805. "*A hook for Gnus summary mode.
  806. This hook is run before any variables are set in the summary buffer."
  807. :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
  808. :group 'gnus-summary-various
  809. :type 'hook)
  810. ;; Extracted from gnus-xmas-redefine in order to preserve user settings
  811. (when (featurep 'xemacs)
  812. (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
  813. (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
  814. (add-hook 'gnus-summary-mode-hook
  815. 'gnus-xmas-switch-horizontal-scrollbar-off))
  816. (defcustom gnus-summary-menu-hook nil
  817. "*Hook run after the creation of the summary mode menu."
  818. :group 'gnus-summary-visual
  819. :type 'hook)
  820. (defcustom gnus-summary-exit-hook nil
  821. "*A hook called on exit from the summary buffer.
  822. It will be called with point in the group buffer."
  823. :group 'gnus-summary-exit
  824. :type 'hook)
  825. (defcustom gnus-summary-prepare-hook nil
  826. "*A hook called after the summary buffer has been generated.
  827. If you want to modify the summary buffer, you can use this hook."
  828. :group 'gnus-summary-various
  829. :type 'hook)
  830. (defcustom gnus-summary-prepared-hook nil
  831. "*A hook called as the last thing after the summary buffer has been generated."
  832. :group 'gnus-summary-various
  833. :type 'hook)
  834. (defcustom gnus-summary-generate-hook nil
  835. "*A hook run just before generating the summary buffer.
  836. This hook is commonly used to customize threading variables and the
  837. like."
  838. :group 'gnus-summary-various
  839. :type 'hook)
  840. (defcustom gnus-select-group-hook nil
  841. "*A hook called when a newsgroup is selected.
  842. If you'd like to simplify subjects like the
  843. `gnus-summary-next-same-subject' command does, you can use the
  844. following hook:
  845. (add-hook gnus-select-group-hook
  846. (lambda ()
  847. (mapcar (lambda (header)
  848. (mail-header-set-subject
  849. header
  850. (gnus-simplify-subject
  851. (mail-header-subject header) \\='re-only)))
  852. gnus-newsgroup-headers)))"
  853. :group 'gnus-group-select
  854. :type 'hook)
  855. (defcustom gnus-select-article-hook nil
  856. "*A hook called when an article is selected."
  857. :group 'gnus-summary-choose
  858. :options '(gnus-agent-fetch-selected-article)
  859. :type 'hook)
  860. (defcustom gnus-visual-mark-article-hook
  861. (list 'gnus-highlight-selected-summary)
  862. "*Hook run after selecting an article in the summary buffer.
  863. It is meant to be used for highlighting the article in some way. It
  864. is not run if `gnus-visual' is nil."
  865. :group 'gnus-summary-visual
  866. :type 'hook)
  867. (defcustom gnus-parse-headers-hook nil
  868. "*A hook called before parsing the headers."
  869. :group 'gnus-various
  870. :type 'hook)
  871. (defcustom gnus-exit-group-hook nil
  872. "*A hook called when exiting summary mode.
  873. This hook is not called from the non-updating exit commands like `Q'."
  874. :group 'gnus-various
  875. :type 'hook)
  876. (defcustom gnus-summary-update-hook nil
  877. "*A hook called when a summary line is changed.
  878. The hook will not be called if `gnus-visual' is nil.
  879. The default function `gnus-summary-highlight-line' will
  880. highlight the line according to the `gnus-summary-highlight'
  881. variable."
  882. :group 'gnus-summary-visual
  883. :type 'hook)
  884. (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
  885. "*A hook called when an article is selected for the first time.
  886. The hook is intended to mark an article as read (or unread)
  887. automatically when it is selected."
  888. :group 'gnus-summary-choose
  889. :type 'hook)
  890. (defcustom gnus-group-no-more-groups-hook nil
  891. "*A hook run when returning to group mode having no more (unread) groups."
  892. :group 'gnus-group-select
  893. :type 'hook)
  894. (defcustom gnus-ps-print-hook nil
  895. "*A hook run before ps-printing something from Gnus."
  896. :group 'gnus-summary
  897. :type 'hook)
  898. (defcustom gnus-summary-article-move-hook nil
  899. "*A hook called after an article is moved, copied, respooled, or crossposted."
  900. :version "22.1"
  901. :group 'gnus-summary
  902. :type 'hook)
  903. (defcustom gnus-summary-article-delete-hook nil
  904. "*A hook called after an article is deleted."
  905. :version "22.1"
  906. :group 'gnus-summary
  907. :type 'hook)
  908. (defcustom gnus-summary-article-expire-hook nil
  909. "*A hook called after an article is expired."
  910. :version "22.1"
  911. :group 'gnus-summary
  912. :type 'hook)
  913. (defcustom gnus-summary-display-arrow
  914. (and (fboundp 'display-graphic-p)
  915. (display-graphic-p))
  916. "*If non-nil, display an arrow highlighting the current article."
  917. :version "22.1"
  918. :group 'gnus-summary
  919. :type 'boolean)
  920. (defcustom gnus-summary-selected-face 'gnus-summary-selected
  921. "Face used for highlighting the current article in the summary buffer."
  922. :group 'gnus-summary-visual
  923. :type 'face)
  924. (defvar gnus-tmp-downloaded nil)
  925. (defcustom gnus-summary-highlight
  926. '(((eq mark gnus-canceled-mark)
  927. . gnus-summary-cancelled)
  928. ((and uncached (> score default-high))
  929. . gnus-summary-high-undownloaded)
  930. ((and uncached (< score default-low))
  931. . gnus-summary-low-undownloaded)
  932. (uncached
  933. . gnus-summary-normal-undownloaded)
  934. ((and (> score default-high)
  935. (or (eq mark gnus-dormant-mark)
  936. (eq mark gnus-ticked-mark)))
  937. . gnus-summary-high-ticked)
  938. ((and (< score default-low)
  939. (or (eq mark gnus-dormant-mark)
  940. (eq mark gnus-ticked-mark)))
  941. . gnus-summary-low-ticked)
  942. ((or (eq mark gnus-dormant-mark)
  943. (eq mark gnus-ticked-mark))
  944. . gnus-summary-normal-ticked)
  945. ((and (> score default-high) (eq mark gnus-ancient-mark))
  946. . gnus-summary-high-ancient)
  947. ((and (< score default-low) (eq mark gnus-ancient-mark))
  948. . gnus-summary-low-ancient)
  949. ((eq mark gnus-ancient-mark)
  950. . gnus-summary-normal-ancient)
  951. ((and (> score default-high) (eq mark gnus-unread-mark))
  952. . gnus-summary-high-unread)
  953. ((and (< score default-low) (eq mark gnus-unread-mark))
  954. . gnus-summary-low-unread)
  955. ((eq mark gnus-unread-mark)
  956. . gnus-summary-normal-unread)
  957. ((> score default-high)
  958. . gnus-summary-high-read)
  959. ((< score default-low)
  960. . gnus-summary-low-read)
  961. (t
  962. . gnus-summary-normal-read))
  963. "*Controls the highlighting of summary buffer lines.
  964. A list of (FORM . FACE) pairs. When deciding how a particular
  965. summary line should be displayed, each form is evaluated. The content
  966. of the face field after the first true form is used. You can change
  967. how those summary lines are displayed, by editing the face field.
  968. You can use the following variables in the FORM field.
  969. score: The article's score.
  970. default: The default article score.
  971. default-high: The default score for high scored articles.
  972. default-low: The default score for low scored articles.
  973. mark: The article's mark.
  974. uncached: Non-nil if the article is uncached."
  975. :group 'gnus-summary-visual
  976. :type '(repeat (cons (sexp :tag "Form" nil)
  977. face)))
  978. (put 'gnus-summary-highlight 'risky-local-variable t)
  979. (defcustom gnus-alter-header-function nil
  980. "Function called to allow alteration of article header structures.
  981. The function is called with one parameter, the article header vector,
  982. which it may alter in any way."
  983. :type '(choice (const :tag "None" nil)
  984. function)
  985. :group 'gnus-summary)
  986. (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
  987. "Function used to decode a string with encoded words.")
  988. (defvar gnus-decode-encoded-address-function
  989. 'mail-decode-encoded-address-string
  990. "Function used to decode addresses with encoded words.")
  991. (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups X-GM-LABELS)
  992. "*Extra headers to parse."
  993. :version "25.1"
  994. :group 'gnus-summary
  995. :type '(repeat symbol))
  996. (defcustom gnus-ignored-from-addresses
  997. (and user-mail-address
  998. (not (string= user-mail-address ""))
  999. (regexp-quote user-mail-address))
  1000. "*From headers that may be suppressed in favor of To headers.
  1001. This can be a regexp or a list of regexps."
  1002. :version "21.1"
  1003. :group 'gnus-summary
  1004. :type '(choice regexp
  1005. (repeat :tag "Regexp List" regexp)))
  1006. (defsubst gnus-ignored-from-addresses ()
  1007. (gmm-regexp-concat gnus-ignored-from-addresses))
  1008. (defcustom gnus-summary-to-prefix "-> "
  1009. "*String prefixed to the To field in the summary line when
  1010. using `gnus-ignored-from-addresses'."
  1011. :version "22.1"
  1012. :group 'gnus-summary
  1013. :type 'string)
  1014. (defcustom gnus-summary-newsgroup-prefix "=> "
  1015. "*String prefixed to the Newsgroup field in the summary
  1016. line when using the option `gnus-ignored-from-addresses'."
  1017. :version "22.1"
  1018. :group 'gnus-summary
  1019. :type 'string)
  1020. (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
  1021. "List of charsets that should be ignored.
  1022. When these charsets are used in the \"charset\" parameter, the
  1023. default charset will be used instead."
  1024. :version "21.1"
  1025. :type '(repeat symbol)
  1026. :group 'gnus-charset)
  1027. (defcustom gnus-newsgroup-maximum-articles nil
  1028. "The maximum number of articles a newsgroup.
  1029. If this is a number, old articles in a newsgroup exceeding this number
  1030. are silently ignored. If it is nil, no article is ignored. Note that
  1031. setting this variable to a number might prevent you from reading very
  1032. old articles."
  1033. :group 'gnus-group-select
  1034. :version "22.2"
  1035. :type '(choice (const :tag "No limit" nil)
  1036. integer))
  1037. (gnus-define-group-parameter
  1038. ignored-charsets
  1039. :type list
  1040. :function-document
  1041. "Return the ignored charsets of GROUP."
  1042. :variable gnus-group-ignored-charsets-alist
  1043. :variable-default
  1044. '(("alt\\.chinese\\.text" iso-8859-1))
  1045. :variable-document
  1046. "Alist of regexps (to match group names) and charsets that should be ignored.
  1047. When these charsets are used in the \"charset\" parameter, the
  1048. default charset will be used instead."
  1049. :variable-group gnus-charset
  1050. :variable-type '(repeat (cons (regexp :tag "Group")
  1051. (repeat symbol)))
  1052. :parameter-type '(choice :tag "Ignored charsets"
  1053. :value nil
  1054. (repeat (symbol)))
  1055. :parameter-document "\
  1056. List of charsets that should be ignored.
  1057. When these charsets are used in the \"charset\" parameter, the
  1058. default charset will be used instead.")
  1059. (defcustom gnus-group-highlight-words-alist nil
  1060. "Alist of group regexps and highlight regexps.
  1061. This variable uses the same syntax as `gnus-emphasis-alist'."
  1062. :version "21.1"
  1063. :type '(repeat (cons (regexp :tag "Group")
  1064. (repeat (list (regexp :tag "Highlight regexp")
  1065. (number :tag "Group for entire word" 0)
  1066. (number :tag "Group for displayed part" 0)
  1067. (symbol :tag "Face"
  1068. gnus-emphasis-highlight-words)))))
  1069. :group 'gnus-summary-visual)
  1070. (defcustom gnus-summary-show-article-charset-alist
  1071. nil
  1072. "Alist of number and charset.
  1073. The article will be shown with the charset corresponding to the
  1074. numbered argument.
  1075. For example: ((1 . cn-gb-2312) (2 . big5))."
  1076. :version "21.1"
  1077. :type '(repeat (cons (number :tag "Argument" 1)
  1078. (symbol :tag "Charset")))
  1079. :group 'gnus-charset)
  1080. (defcustom gnus-preserve-marks t
  1081. "Whether marks are preserved when moving, copying and respooling messages."
  1082. :version "21.1"
  1083. :type 'boolean
  1084. :group 'gnus-summary-marks)
  1085. (defcustom gnus-alter-articles-to-read-function nil
  1086. "Function to be called to alter the list of articles to be selected."
  1087. :type '(choice (const nil) function)
  1088. :group 'gnus-summary)
  1089. (defcustom gnus-orphan-score nil
  1090. "*All orphans get this score added. Set in the score file."
  1091. :group 'gnus-score-default
  1092. :type '(choice (const nil)
  1093. integer))
  1094. (defcustom gnus-summary-save-parts-default-mime "image/.*"
  1095. "*A regexp to match MIME parts when saving multiple parts of a
  1096. message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
  1097. This regexp will be used by default when prompting the user for which
  1098. type of files to save."
  1099. :group 'gnus-summary
  1100. :type 'regexp)
  1101. (defcustom gnus-read-all-available-headers nil
  1102. "Whether Gnus should parse all headers made available to it.
  1103. This is mostly relevant for slow back ends where the user may
  1104. wish to widen the summary buffer to include all headers
  1105. that were fetched."
  1106. :version "22.1"
  1107. :group 'gnus-summary
  1108. :type '(choice boolean regexp))
  1109. (defcustom gnus-summary-pipe-output-default-command nil
  1110. "Command (and optional arguments) used to pipe article to subprocess.
  1111. This will be used as the default command if it is non-nil. The value
  1112. will be updated if you modify it when executing the command
  1113. `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
  1114. :version "23.1" ;; No Gnus
  1115. :group 'gnus-summary
  1116. :type '(radio (const :tag "None" nil) (string :tag "Command")))
  1117. (defcustom gnus-summary-muttprint-program "muttprint"
  1118. "Command (and optional arguments) used to run Muttprint.
  1119. The value will be updated if you modify it when executing the command
  1120. `gnus-summary-muttprint'."
  1121. :version "22.1"
  1122. :group 'gnus-summary
  1123. :type 'string)
  1124. (defcustom gnus-article-loose-mime t
  1125. "If non-nil, don't require MIME-Version header.
  1126. Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
  1127. supply the MIME-Version header or deliberately strip it from the mail.
  1128. If non-nil (the default), Gnus will treat some articles as MIME
  1129. even if the MIME-Version header is missing."
  1130. :version "22.1"
  1131. :type 'boolean
  1132. :group 'gnus-article-mime)
  1133. (defcustom gnus-article-emulate-mime t
  1134. "If non-nil, use MIME emulation for uuencode and the like.
  1135. This means that Gnus will search message bodies for text that look
  1136. like uuencoded bits, yEncoded bits, and so on, and present that using
  1137. the normal Gnus MIME machinery."
  1138. :version "22.1"
  1139. :type 'boolean
  1140. :group 'gnus-article-mime)
  1141. ;;; Internal variables
  1142. (defvar gnus-summary-display-cache nil)
  1143. (defvar gnus-article-mime-handles nil)
  1144. (defvar gnus-article-decoded-p nil)
  1145. (defvar gnus-article-charset nil)
  1146. (defvar gnus-article-ignored-charsets nil)
  1147. (defvar gnus-scores-exclude-files nil)
  1148. (defvar gnus-page-broken nil)
  1149. (defvar gnus-original-article nil)
  1150. (defvar gnus-article-internal-prepare-hook nil)
  1151. (defvar gnus-newsgroup-process-stack nil)
  1152. (defvar gnus-thread-indent-array nil)
  1153. (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
  1154. (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
  1155. "Function called to sort the articles within a thread after it has been gathered together.")
  1156. (defvar gnus-summary-save-parts-type-history nil)
  1157. (defvar gnus-summary-save-parts-last-directory mm-default-directory)
  1158. ;; Avoid highlighting in kill files.
  1159. (defvar gnus-summary-inhibit-highlight nil)
  1160. (defvar gnus-newsgroup-selected-overlay nil)
  1161. (defvar gnus-inhibit-limiting nil)
  1162. (defvar gnus-newsgroup-adaptive-score-file nil)
  1163. (defvar gnus-current-score-file nil)
  1164. (defvar gnus-current-move-group nil)
  1165. (defvar gnus-current-copy-group nil)
  1166. (defvar gnus-current-crosspost-group nil)
  1167. (defvar gnus-newsgroup-display nil)
  1168. (defvar gnus-newsgroup-dependencies nil)
  1169. (defvar gnus-newsgroup-adaptive nil)
  1170. (defvar gnus-summary-display-article-function nil)
  1171. (defvar gnus-summary-highlight-line-function nil
  1172. "Function called after highlighting a summary line.")
  1173. (defvar gnus-summary-line-format-alist
  1174. `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
  1175. (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
  1176. (?s gnus-tmp-subject-or-nil ?s)
  1177. (?n gnus-tmp-name ?s)
  1178. (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
  1179. ?s)
  1180. (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
  1181. gnus-tmp-from) ?s)
  1182. (?F gnus-tmp-from ?s)
  1183. (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
  1184. (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
  1185. (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
  1186. (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
  1187. (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
  1188. (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
  1189. (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
  1190. (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
  1191. (?L gnus-tmp-lines ?s)
  1192. (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
  1193. 0) ?d)
  1194. (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
  1195. "") ?s)
  1196. (?g (or (gnus-group-short-name
  1197. (nnir-article-group (mail-header-number gnus-tmp-header)))
  1198. "") ?s)
  1199. (?O gnus-tmp-downloaded ?c)
  1200. (?I gnus-tmp-indentation ?s)
  1201. (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
  1202. (?R gnus-tmp-replied ?c)
  1203. (?\[ gnus-tmp-opening-bracket ?c)
  1204. (?\] gnus-tmp-closing-bracket ?c)
  1205. (?\> (make-string gnus-tmp-level ? ) ?s)
  1206. (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
  1207. (?i gnus-tmp-score ?d)
  1208. (?z gnus-tmp-score-char ?c)
  1209. (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
  1210. (?U gnus-tmp-unread ?c)
  1211. (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
  1212. ?s)
  1213. (?t (gnus-summary-number-of-articles-in-thread
  1214. (and (boundp 'thread) (car thread)) gnus-tmp-level)
  1215. ?d)
  1216. (?e (gnus-summary-number-of-articles-in-thread
  1217. (and (boundp 'thread) (car thread)) gnus-tmp-level t)
  1218. ?c)
  1219. (?u gnus-tmp-user-defined ?s)
  1220. (?P (gnus-pick-line-number) ?d)
  1221. (?B gnus-tmp-thread-tree-header-string ?s)
  1222. (user-date (gnus-user-date
  1223. ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
  1224. "An alist of format specifications that can appear in summary lines.
  1225. These are paired with what variables they correspond with, along with
  1226. the type of the variable (string, integer, character, etc).")
  1227. (defvar gnus-summary-dummy-line-format-alist
  1228. `((?S gnus-tmp-subject ?s)
  1229. (?N gnus-tmp-number ?d)
  1230. (?u gnus-tmp-user-defined ?s)))
  1231. (defvar gnus-summary-mode-line-format-alist
  1232. `((?G gnus-tmp-group-name ?s)
  1233. (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
  1234. (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
  1235. (?A gnus-tmp-article-number ?d)
  1236. (?Z gnus-tmp-unread-and-unselected ?s)
  1237. (?V gnus-version ?s)
  1238. (?U gnus-tmp-unread-and-unticked ?d)
  1239. (?S gnus-tmp-subject ?s)
  1240. (?e gnus-tmp-unselected ?d)
  1241. (?u gnus-tmp-user-defined ?s)
  1242. (?d (length gnus-newsgroup-dormant) ?d)
  1243. (?t (length gnus-newsgroup-marked) ?d)
  1244. (?h (length gnus-newsgroup-spam-marked) ?d)
  1245. (?r (length gnus-newsgroup-reads) ?d)
  1246. (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
  1247. (?E gnus-newsgroup-expunged-tally ?d)
  1248. (?s (gnus-current-score-file-nondirectory) ?s)))
  1249. ;; This is here rather than in gnus-art for compilation reasons.
  1250. (defvar gnus-article-mode-line-format-alist
  1251. (nconc '((?w (gnus-article-wash-status) ?s)
  1252. (?m (gnus-article-mime-part-status) ?s))
  1253. gnus-summary-mode-line-format-alist))
  1254. (defvar gnus-last-search-regexp nil
  1255. "Default regexp for article search command.")
  1256. (defvar gnus-last-shell-command nil
  1257. "Default shell command on article.")
  1258. (defvar gnus-newsgroup-agentized nil
  1259. "Locally bound in each summary buffer to indicate whether the server has been agentized.")
  1260. (defvar gnus-newsgroup-begin nil)
  1261. (defvar gnus-newsgroup-end nil)
  1262. (defvar gnus-newsgroup-last-rmail nil)
  1263. (defvar gnus-newsgroup-last-mail nil)
  1264. (defvar gnus-newsgroup-last-folder nil)
  1265. (defvar gnus-newsgroup-last-file nil)
  1266. (defvar gnus-newsgroup-last-directory nil)
  1267. (defvar gnus-newsgroup-auto-expire nil)
  1268. (defvar gnus-newsgroup-active nil)
  1269. (defvar gnus-newsgroup-highest nil)
  1270. (defvar gnus-newsgroup-data nil)
  1271. (defvar gnus-newsgroup-data-reverse nil)
  1272. (defvar gnus-newsgroup-limit nil)
  1273. (defvar gnus-newsgroup-limits nil)
  1274. (defvar gnus-summary-use-undownloaded-faces nil)
  1275. (defvar gnus-newsgroup-unreads nil
  1276. "Sorted list of unread articles in the current newsgroup.")
  1277. (defvar gnus-newsgroup-unselected nil
  1278. "Sorted list of unselected unread articles in the current newsgroup.")
  1279. (defvar gnus-newsgroup-reads nil
  1280. "Alist of read articles and article marks in the current newsgroup.")
  1281. (defvar gnus-newsgroup-expunged-tally nil)
  1282. (defvar gnus-newsgroup-marked nil
  1283. "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
  1284. (defvar gnus-newsgroup-spam-marked nil
  1285. "List of ranges of articles that have been marked as spam.")
  1286. (defvar gnus-newsgroup-killed nil
  1287. "List of ranges of articles that have been through the scoring process.")
  1288. (defvar gnus-newsgroup-cached nil
  1289. "Sorted list of articles that come from the article cache.")
  1290. (defvar gnus-newsgroup-saved nil
  1291. "List of articles that have been saved.")
  1292. (defvar gnus-newsgroup-kill-headers nil)
  1293. (defvar gnus-newsgroup-replied nil
  1294. "List of articles that have been replied to in the current newsgroup.")
  1295. (defvar gnus-newsgroup-forwarded nil
  1296. "List of articles that have been forwarded in the current newsgroup.")
  1297. (defvar gnus-newsgroup-expirable nil
  1298. "Sorted list of articles in the current newsgroup that can be expired.")
  1299. (defvar gnus-newsgroup-processable nil
  1300. "List of articles in the current newsgroup that can be processed.")
  1301. (defvar gnus-newsgroup-downloadable nil
  1302. "Sorted list of articles in the current newsgroup that can be processed.")
  1303. (defvar gnus-newsgroup-unfetched nil
  1304. "Sorted list of articles in the current newsgroup whose headers have
  1305. not been fetched into the agent.
  1306. This list will always be a subset of gnus-newsgroup-undownloaded.")
  1307. (defvar gnus-newsgroup-undownloaded nil
  1308. "List of articles in the current newsgroup that haven't been downloaded.")
  1309. (defvar gnus-newsgroup-unsendable nil
  1310. "List of articles in the current newsgroup that won't be sent.")
  1311. (defvar gnus-newsgroup-bookmarks nil
  1312. "List of articles in the current newsgroup that have bookmarks.")
  1313. (defvar gnus-newsgroup-dormant nil
  1314. "Sorted list of dormant articles in the current newsgroup.")
  1315. (defvar gnus-newsgroup-unseen nil
  1316. "List of unseen articles in the current newsgroup.")
  1317. (defvar gnus-newsgroup-seen nil
  1318. "Range of seen articles in the current newsgroup.")
  1319. (defvar gnus-newsgroup-unexist nil
  1320. "Range of unexisting articles in the current newsgroup.")
  1321. (defvar gnus-newsgroup-articles nil
  1322. "List of articles in the current newsgroup.")
  1323. (defvar gnus-newsgroup-scored nil
  1324. "List of scored articles in the current newsgroup.")
  1325. (defvar gnus-newsgroup-headers nil
  1326. "List of article headers in the current newsgroup.")
  1327. (defvar gnus-newsgroup-threads nil)
  1328. (defvar gnus-newsgroup-prepared nil
  1329. "Whether the current group has been prepared properly.")
  1330. (defvar gnus-newsgroup-ancient nil
  1331. "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
  1332. (defvar gnus-newsgroup-sparse nil)
  1333. (defvar gnus-current-article nil)
  1334. (defvar gnus-article-current nil)
  1335. (defvar gnus-current-headers nil)
  1336. (defvar gnus-have-all-headers nil)
  1337. (defvar gnus-last-article nil)
  1338. (defvar gnus-newsgroup-history nil)
  1339. (defvar gnus-newsgroup-charset nil)
  1340. (defvar gnus-newsgroup-ephemeral-charset nil)
  1341. (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
  1342. (defvar gnus-article-before-search nil)
  1343. (defvar gnus-summary-local-variables
  1344. '(gnus-newsgroup-name
  1345. ;; Marks lists
  1346. gnus-newsgroup-unreads
  1347. gnus-newsgroup-unselected
  1348. gnus-newsgroup-marked
  1349. gnus-newsgroup-spam-marked
  1350. gnus-newsgroup-reads
  1351. gnus-newsgroup-saved
  1352. gnus-newsgroup-replied
  1353. gnus-newsgroup-forwarded
  1354. gnus-newsgroup-expirable
  1355. gnus-newsgroup-killed
  1356. gnus-newsgroup-unseen
  1357. gnus-newsgroup-seen
  1358. gnus-newsgroup-unexist
  1359. gnus-newsgroup-cached
  1360. gnus-newsgroup-downloadable
  1361. gnus-newsgroup-undownloaded
  1362. gnus-newsgroup-unsendable
  1363. gnus-newsgroup-begin gnus-newsgroup-end
  1364. gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
  1365. gnus-newsgroup-last-folder gnus-newsgroup-last-file
  1366. gnus-newsgroup-last-directory
  1367. gnus-newsgroup-auto-expire
  1368. gnus-newsgroup-processable
  1369. gnus-newsgroup-unfetched
  1370. gnus-newsgroup-articles
  1371. gnus-newsgroup-bookmarks gnus-newsgroup-dormant
  1372. gnus-newsgroup-headers gnus-newsgroup-threads
  1373. gnus-newsgroup-prepared gnus-summary-highlight-line-function
  1374. gnus-current-article gnus-current-headers gnus-have-all-headers
  1375. gnus-last-article gnus-article-internal-prepare-hook
  1376. (gnus-summary-article-delete-hook . global)
  1377. (gnus-summary-article-move-hook . global)
  1378. gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
  1379. gnus-newsgroup-scored gnus-newsgroup-kill-headers
  1380. gnus-thread-expunge-below
  1381. gnus-score-alist gnus-current-score-file
  1382. (gnus-summary-expunge-below . global)
  1383. (gnus-summary-mark-below . global)
  1384. (gnus-orphan-score . global)
  1385. gnus-newsgroup-active gnus-scores-exclude-files
  1386. gnus-newsgroup-highest
  1387. gnus-newsgroup-history gnus-newsgroup-ancient
  1388. gnus-newsgroup-sparse gnus-newsgroup-process-stack
  1389. (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
  1390. gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
  1391. (gnus-newsgroup-expunged-tally . 0)
  1392. gnus-cache-removable-articles
  1393. gnus-newsgroup-data gnus-newsgroup-data-reverse
  1394. gnus-newsgroup-limit gnus-newsgroup-limits
  1395. gnus-newsgroup-charset gnus-newsgroup-display
  1396. gnus-summary-use-undownloaded-faces)
  1397. "Variables that are buffer-local to the summary buffers.")
  1398. (defvar gnus-newsgroup-variables nil
  1399. "A list of variables that have separate values in different newsgroups.
  1400. A list of newsgroup (summary buffer) local variables, or cons of
  1401. variables and their default expressions to be evalled (when the default
  1402. values are not nil), that should be made global while the summary buffer
  1403. is active.
  1404. Note: The default expressions will be evaluated (using function `eval')
  1405. before assignment to the local variable rather than just assigned to it.
  1406. If the default expression is the symbol `global', that symbol will not
  1407. be evaluated but the global value of the local variable will be used
  1408. instead.
  1409. These variables can be used to set variables in the group parameters
  1410. while still allowing them to affect operations done in other buffers.
  1411. For example:
  1412. \(setq gnus-newsgroup-variables
  1413. \\='(message-use-followup-to
  1414. (gnus-visible-headers .
  1415. \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
  1416. ")
  1417. (eval-when-compile
  1418. ;; Bind features so that require will believe that gnus-sum has
  1419. ;; already been loaded (avoids infinite recursion)
  1420. (let ((features (cons 'gnus-sum features)))
  1421. (require 'gnus-art)))
  1422. ;; MIME stuff.
  1423. (defvar gnus-decode-encoded-word-methods
  1424. '(mail-decode-encoded-word-string)
  1425. "List of methods used to decode encoded words.
  1426. This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
  1427. is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
  1428. \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
  1429. whose names match REGEXP.
  1430. For example:
  1431. \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
  1432. mail-decode-encoded-word-string
  1433. (\"chinese\" . rfc1843-decode-string))")
  1434. (defvar gnus-decode-encoded-word-methods-cache nil)
  1435. (defun gnus-multi-decode-encoded-word-string (string)
  1436. "Apply the functions from `gnus-encoded-word-methods' that match."
  1437. (unless (and gnus-decode-encoded-word-methods-cache
  1438. (eq gnus-newsgroup-name
  1439. (car gnus-decode-encoded-word-methods-cache)))
  1440. (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
  1441. (dolist (method gnus-decode-encoded-word-methods)
  1442. (if (symbolp method)
  1443. (nconc gnus-decode-encoded-word-methods-cache (list method))
  1444. (if (and gnus-newsgroup-name
  1445. (string-match (car method) gnus-newsgroup-name))
  1446. (nconc gnus-decode-encoded-word-methods-cache
  1447. (list (cdr method)))))))
  1448. (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
  1449. (setq string (funcall method string))))
  1450. ;; Subject simplification.
  1451. (defun gnus-simplify-whitespace (str)
  1452. "Remove excessive whitespace from STR."
  1453. ;; Multiple spaces.
  1454. (while (string-match "[ \t][ \t]+" str)
  1455. (setq str (concat (substring str 0 (match-beginning 0))
  1456. " "
  1457. (substring str (match-end 0)))))
  1458. ;; Leading spaces.
  1459. (when (string-match "^[ \t]+" str)
  1460. (setq str (substring str (match-end 0))))
  1461. ;; Trailing spaces.
  1462. (when (string-match "[ \t]+$" str)
  1463. (setq str (substring str 0 (match-beginning 0))))
  1464. str)
  1465. (defun gnus-simplify-all-whitespace (str)
  1466. "Remove all whitespace from STR."
  1467. (while (string-match "[ \t\n]+" str)
  1468. (setq str (replace-match "" nil nil str)))
  1469. str)
  1470. (defsubst gnus-simplify-subject-re (subject)
  1471. "Remove \"Re:\" from subject lines."
  1472. (if (string-match message-subject-re-regexp subject)
  1473. (substring subject (match-end 0))
  1474. subject))
  1475. (defun gnus-simplify-subject (subject &optional re-only)
  1476. "Remove `Re:' and words in parentheses.
  1477. If RE-ONLY is non-nil, strip leading `Re:'s only."
  1478. (let ((case-fold-search t)) ;Ignore case.
  1479. ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
  1480. (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
  1481. (setq subject (substring subject (match-end 0))))
  1482. ;; Remove uninteresting prefixes.
  1483. (when (and (not re-only)
  1484. gnus-simplify-ignored-prefixes
  1485. (string-match gnus-simplify-ignored-prefixes subject))
  1486. (setq subject (substring subject (match-end 0))))
  1487. ;; Remove words in parentheses from end.
  1488. (unless re-only
  1489. (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
  1490. (setq subject (substring subject 0 (match-beginning 0)))))
  1491. ;; Return subject string.
  1492. subject))
  1493. ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
  1494. ;; all whitespace.
  1495. (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
  1496. (goto-char (point-min))
  1497. (while (re-search-forward regexp nil t)
  1498. (replace-match (or newtext ""))))
  1499. (defun gnus-simplify-buffer-fuzzy (regexp)
  1500. "Simplify string in the buffer fuzzily.
  1501. The string in the accessible portion of the current buffer is simplified.
  1502. It is assumed to be a single-line subject.
  1503. Whitespace is generally cleaned up, and miscellaneous leading/trailing
  1504. matter is removed. Additional things can be deleted by setting
  1505. `gnus-simplify-subject-fuzzy-regexp'."
  1506. (let ((case-fold-search t)
  1507. (modified-tick))
  1508. (gnus-simplify-buffer-fuzzy-step "\t" " ")
  1509. (while (not (eq modified-tick (buffer-modified-tick)))
  1510. (setq modified-tick (buffer-modified-tick))
  1511. (cond
  1512. ((listp regexp)
  1513. (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
  1514. (regexp
  1515. (gnus-simplify-buffer-fuzzy-step regexp)))
  1516. (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
  1517. (gnus-simplify-buffer-fuzzy-step
  1518. "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
  1519. (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
  1520. (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
  1521. (gnus-simplify-buffer-fuzzy-step " +" " ")
  1522. (gnus-simplify-buffer-fuzzy-step " $")
  1523. (gnus-simplify-buffer-fuzzy-step "^ +")))
  1524. (defun gnus-simplify-subject-fuzzy (subject)
  1525. "Simplify a subject string fuzzily.
  1526. See `gnus-simplify-buffer-fuzzy' for details."
  1527. (save-excursion
  1528. (let ((regexp gnus-simplify-subject-fuzzy-regexp))
  1529. (gnus-set-work-buffer)
  1530. (let ((case-fold-search t))
  1531. ;; Remove uninteresting prefixes.
  1532. (when (and gnus-simplify-ignored-prefixes
  1533. (string-match gnus-simplify-ignored-prefixes subject))
  1534. (setq subject (substring subject (match-end 0))))
  1535. (insert subject)
  1536. (inline (gnus-simplify-buffer-fuzzy regexp))
  1537. (buffer-string)))))
  1538. (defsubst gnus-simplify-subject-fully (subject)
  1539. "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
  1540. (cond
  1541. (gnus-simplify-subject-functions
  1542. (gnus-map-function gnus-simplify-subject-functions subject))
  1543. ((null gnus-summary-gather-subject-limit)
  1544. (gnus-simplify-subject-re subject))
  1545. ((eq gnus-summary-gather-subject-limit 'fuzzy)
  1546. (gnus-simplify-subject-fuzzy subject))
  1547. ((numberp gnus-summary-gather-subject-limit)
  1548. (truncate-string-to-width (gnus-simplify-subject-re subject)
  1549. gnus-summary-gather-subject-limit))
  1550. (t
  1551. subject)))
  1552. (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
  1553. "Check whether two subjects are equal.
  1554. If optional argument SIMPLE-FIRST is t, first argument is already
  1555. simplified."
  1556. (cond
  1557. ((null simple-first)
  1558. (equal (gnus-simplify-subject-fully s1)
  1559. (gnus-simplify-subject-fully s2)))
  1560. (t
  1561. (equal s1
  1562. (gnus-simplify-subject-fully s2)))))
  1563. (defun gnus-summary-bubble-group ()
  1564. "Increase the score of the current group.
  1565. This is a handy function to add to `gnus-summary-exit-hook' to
  1566. increase the score of each group you read."
  1567. (gnus-group-add-score gnus-newsgroup-name))
  1568. ;;;
  1569. ;;; Gnus summary mode
  1570. ;;;
  1571. (put 'gnus-summary-mode 'mode-class 'special)
  1572. (defvar gnus-article-commands-menu)
  1573. ;; Non-orthogonal keys
  1574. (gnus-define-keys gnus-summary-mode-map
  1575. " " gnus-summary-next-page
  1576. [?\S-\ ] gnus-summary-prev-page
  1577. "\177" gnus-summary-prev-page
  1578. [delete] gnus-summary-prev-page
  1579. "\r" gnus-summary-scroll-up
  1580. "\M-\r" gnus-summary-scroll-down
  1581. "n" gnus-summary-next-unread-article
  1582. "p" gnus-summary-prev-unread-article
  1583. "N" gnus-summary-next-article
  1584. "P" gnus-summary-prev-article
  1585. "\M-\C-n" gnus-summary-next-same-subject
  1586. "\M-\C-p" gnus-summary-prev-same-subject
  1587. "\M-n" gnus-summary-next-unread-subject
  1588. "\M-p" gnus-summary-prev-unread-subject
  1589. "." gnus-summary-first-unread-article
  1590. "," gnus-summary-best-unread-article
  1591. "\M-s" gnus-summary-search-article-forward
  1592. "\M-r" gnus-summary-search-article-backward
  1593. "\M-S" gnus-summary-repeat-search-article-forward
  1594. "\M-R" gnus-summary-repeat-search-article-backward
  1595. "<" gnus-summary-beginning-of-article
  1596. ">" gnus-summary-end-of-article
  1597. "j" gnus-summary-goto-article
  1598. "^" gnus-summary-refer-parent-article
  1599. "\M-^" gnus-summary-refer-article
  1600. "u" gnus-summary-tick-article-forward
  1601. "!" gnus-summary-tick-article-forward
  1602. "U" gnus-summary-tick-article-backward
  1603. "d" gnus-summary-mark-as-read-forward
  1604. "D" gnus-summary-mark-as-read-backward
  1605. "E" gnus-summary-mark-as-expirable
  1606. "\M-u" gnus-summary-clear-mark-forward
  1607. "\M-U" gnus-summary-clear-mark-backward
  1608. "k" gnus-summary-kill-same-subject-and-select
  1609. "\C-k" gnus-summary-kill-same-subject
  1610. "\M-\C-k" gnus-summary-kill-thread
  1611. "\M-\C-l" gnus-summary-lower-thread
  1612. "e" gnus-summary-edit-article
  1613. "#" gnus-summary-mark-as-processable
  1614. "\M-#" gnus-summary-unmark-as-processable
  1615. "\M-\C-t" gnus-summary-toggle-threads
  1616. "\M-\C-s" gnus-summary-show-thread
  1617. "\M-\C-h" gnus-summary-hide-thread
  1618. "\M-\C-f" gnus-summary-next-thread
  1619. "\M-\C-b" gnus-summary-prev-thread
  1620. [(meta down)] gnus-summary-next-thread
  1621. [(meta up)] gnus-summary-prev-thread
  1622. "\M-\C-u" gnus-summary-up-thread
  1623. "\M-\C-d" gnus-summary-down-thread
  1624. "&" gnus-summary-execute-command
  1625. "c" gnus-summary-catchup-and-exit
  1626. "\C-w" gnus-summary-mark-region-as-read
  1627. "\C-t" gnus-summary-toggle-truncation
  1628. "?" gnus-summary-mark-as-dormant
  1629. "\C-c\M-\C-s" gnus-summary-limit-include-expunged
  1630. "\C-c\C-s\C-n" gnus-summary-sort-by-number
  1631. "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
  1632. "\C-c\C-s\C-l" gnus-summary-sort-by-lines
  1633. "\C-c\C-s\C-c" gnus-summary-sort-by-chars
  1634. "\C-c\C-s\C-a" gnus-summary-sort-by-author
  1635. "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
  1636. "\C-c\C-s\C-s" gnus-summary-sort-by-subject
  1637. "\C-c\C-s\C-d" gnus-summary-sort-by-date
  1638. "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
  1639. "\C-c\C-s\C-i" gnus-summary-sort-by-score
  1640. "\C-c\C-s\C-o" gnus-summary-sort-by-original
  1641. "\C-c\C-s\C-r" gnus-summary-sort-by-random
  1642. "=" gnus-summary-expand-window
  1643. "\C-x\C-s" gnus-summary-reselect-current-group
  1644. "\M-g" gnus-summary-rescan-group
  1645. "\C-c\C-r" gnus-summary-caesar-message
  1646. "f" gnus-summary-followup
  1647. "F" gnus-summary-followup-with-original
  1648. "C" gnus-summary-cancel-article
  1649. "r" gnus-summary-reply
  1650. "R" gnus-summary-reply-with-original
  1651. "\C-c\C-f" gnus-summary-mail-forward
  1652. "o" gnus-summary-save-article
  1653. "\C-o" gnus-summary-save-article-mail
  1654. "|" gnus-summary-pipe-output
  1655. "\M-k" gnus-summary-edit-local-kill
  1656. "\M-K" gnus-summary-edit-global-kill
  1657. ;; "V" gnus-version
  1658. "\C-c\C-d" gnus-summary-describe-group
  1659. "q" gnus-summary-exit
  1660. "Q" gnus-summary-exit-no-update
  1661. "\C-c\C-i" gnus-info-find-node
  1662. gnus-mouse-2 gnus-mouse-pick-article
  1663. [follow-link] mouse-face
  1664. "m" gnus-summary-mail-other-window
  1665. "a" gnus-summary-post-news
  1666. "x" gnus-summary-limit-to-unread
  1667. "s" gnus-summary-isearch-article
  1668. "\t" gnus-summary-widget-forward
  1669. [backtab] gnus-summary-widget-backward
  1670. "t" gnus-summary-toggle-header
  1671. "g" gnus-summary-show-article
  1672. "l" gnus-summary-goto-last-article
  1673. "\C-c\C-v\C-v" gnus-uu-decode-uu-view
  1674. "\C-d" gnus-summary-enter-digest-group
  1675. "\M-\C-d" gnus-summary-read-document
  1676. "\M-\C-e" gnus-summary-edit-parameters
  1677. "\M-\C-a" gnus-summary-customize-parameters
  1678. "\C-c\C-b" gnus-bug
  1679. "*" gnus-cache-enter-article
  1680. "\M-*" gnus-cache-remove-article
  1681. "\M-&" gnus-summary-universal-argument
  1682. "\C-l" gnus-recenter
  1683. "I" gnus-summary-increase-score
  1684. "L" gnus-summary-lower-score
  1685. "\M-i" gnus-symbolic-argument
  1686. "h" gnus-summary-select-article-buffer
  1687. "b" gnus-article-view-part
  1688. "\M-t" gnus-summary-toggle-display-buttonized
  1689. "V" gnus-summary-score-map
  1690. "X" gnus-uu-extract-map
  1691. "S" gnus-summary-send-map)
  1692. ;; Sort of orthogonal keymap
  1693. (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
  1694. "t" gnus-summary-tick-article-forward
  1695. "!" gnus-summary-tick-article-forward
  1696. "d" gnus-summary-mark-as-read-forward
  1697. "r" gnus-summary-mark-as-read-forward
  1698. "c" gnus-summary-clear-mark-forward
  1699. " " gnus-summary-clear-mark-forward
  1700. "e" gnus-summary-mark-as-expirable
  1701. "x" gnus-summary-mark-as-expirable
  1702. "?" gnus-summary-mark-as-dormant
  1703. "b" gnus-summary-set-bookmark
  1704. "B" gnus-summary-remove-bookmark
  1705. "#" gnus-summary-mark-as-processable
  1706. "\M-#" gnus-summary-unmark-as-processable
  1707. "S" gnus-summary-limit-include-expunged
  1708. "C" gnus-summary-catchup
  1709. "H" gnus-summary-catchup-to-here
  1710. "h" gnus-summary-catchup-from-here
  1711. "\C-c" gnus-summary-catchup-all
  1712. "k" gnus-summary-kill-same-subject-and-select
  1713. "K" gnus-summary-kill-same-subject
  1714. "P" gnus-uu-mark-map)
  1715. (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
  1716. "c" gnus-summary-clear-above
  1717. "u" gnus-summary-tick-above
  1718. "m" gnus-summary-mark-above
  1719. "k" gnus-summary-kill-below)
  1720. (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
  1721. "/" gnus-summary-limit-to-subject
  1722. "n" gnus-summary-limit-to-articles
  1723. "b" gnus-summary-limit-to-bodies
  1724. "h" gnus-summary-limit-to-headers
  1725. "w" gnus-summary-pop-limit
  1726. "s" gnus-summary-limit-to-subject
  1727. "a" gnus-summary-limit-to-author
  1728. "u" gnus-summary-limit-to-unread
  1729. "m" gnus-summary-limit-to-marks
  1730. "M" gnus-summary-limit-exclude-marks
  1731. "v" gnus-summary-limit-to-score
  1732. "*" gnus-summary-limit-include-cached
  1733. "D" gnus-summary-limit-include-dormant
  1734. "T" gnus-summary-limit-include-thread
  1735. "d" gnus-summary-limit-exclude-dormant
  1736. "t" gnus-summary-limit-to-age
  1737. "." gnus-summary-limit-to-unseen
  1738. "x" gnus-summary-limit-to-extra
  1739. "p" gnus-summary-limit-to-display-predicate
  1740. "E" gnus-summary-limit-include-expunged
  1741. "c" gnus-summary-limit-exclude-childless-dormant
  1742. "C" gnus-summary-limit-mark-excluded-as-read
  1743. "o" gnus-summary-insert-old-articles
  1744. "N" gnus-summary-insert-new-articles
  1745. "S" gnus-summary-limit-to-singletons
  1746. "r" gnus-summary-limit-to-replied
  1747. "R" gnus-summary-limit-to-recipient
  1748. "A" gnus-summary-limit-to-address)
  1749. (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
  1750. "n" gnus-summary-next-unread-article
  1751. "p" gnus-summary-prev-unread-article
  1752. "N" gnus-summary-next-article
  1753. "P" gnus-summary-prev-article
  1754. "\C-n" gnus-summary-next-same-subject
  1755. "\C-p" gnus-summary-prev-same-subject
  1756. "\M-n" gnus-summary-next-unread-subject
  1757. "\M-p" gnus-summary-prev-unread-subject
  1758. "f" gnus-summary-first-unread-article
  1759. "b" gnus-summary-best-unread-article
  1760. "j" gnus-summary-goto-article
  1761. "g" gnus-summary-goto-subject
  1762. "l" gnus-summary-goto-last-article
  1763. "o" gnus-summary-pop-article)
  1764. (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
  1765. "k" gnus-summary-kill-thread
  1766. "E" gnus-summary-expire-thread
  1767. "l" gnus-summary-lower-thread
  1768. "i" gnus-summary-raise-thread
  1769. "T" gnus-summary-toggle-threads
  1770. "t" gnus-summary-rethread-current
  1771. "^" gnus-summary-reparent-thread
  1772. "\M-^" gnus-summary-reparent-children
  1773. "s" gnus-summary-show-thread
  1774. "S" gnus-summary-show-all-threads
  1775. "h" gnus-summary-hide-thread
  1776. "H" gnus-summary-hide-all-threads
  1777. "n" gnus-summary-next-thread
  1778. "p" gnus-summary-prev-thread
  1779. "u" gnus-summary-up-thread
  1780. "o" gnus-summary-top-thread
  1781. "d" gnus-summary-down-thread
  1782. "#" gnus-uu-mark-thread
  1783. "\M-#" gnus-uu-unmark-thread)
  1784. (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
  1785. "g" gnus-summary-prepare
  1786. "c" gnus-summary-insert-cached-articles
  1787. "d" gnus-summary-insert-dormant-articles
  1788. "t" gnus-summary-insert-ticked-articles)
  1789. (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
  1790. "c" gnus-summary-catchup-and-exit
  1791. "C" gnus-summary-catchup-all-and-exit
  1792. "E" gnus-summary-exit-no-update
  1793. "Q" gnus-summary-exit
  1794. "Z" gnus-summary-exit
  1795. "n" gnus-summary-catchup-and-goto-next-group
  1796. "p" gnus-summary-catchup-and-goto-prev-group
  1797. "R" gnus-summary-reselect-current-group
  1798. "G" gnus-summary-rescan-group
  1799. "N" gnus-summary-next-group
  1800. "s" gnus-summary-save-newsrc
  1801. "P" gnus-summary-prev-group)
  1802. (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
  1803. " " gnus-summary-next-page
  1804. "n" gnus-summary-next-page
  1805. [?\S-\ ] gnus-summary-prev-page
  1806. "\177" gnus-summary-prev-page
  1807. [delete] gnus-summary-prev-page
  1808. "p" gnus-summary-prev-page
  1809. "\r" gnus-summary-scroll-up
  1810. "\M-\r" gnus-summary-scroll-down
  1811. "<" gnus-summary-beginning-of-article
  1812. ">" gnus-summary-end-of-article
  1813. "b" gnus-summary-beginning-of-article
  1814. "e" gnus-summary-end-of-article
  1815. "^" gnus-summary-refer-parent-article
  1816. "r" gnus-summary-refer-parent-article
  1817. "C" gnus-summary-show-complete-article
  1818. "D" gnus-summary-enter-digest-group
  1819. "R" gnus-summary-refer-references
  1820. "T" gnus-summary-refer-thread
  1821. "W" gnus-warp-to-article
  1822. "g" gnus-summary-show-article
  1823. "s" gnus-summary-isearch-article
  1824. "\t" gnus-summary-widget-forward
  1825. [backtab] gnus-summary-widget-backward
  1826. "P" gnus-summary-print-article
  1827. "S" gnus-sticky-article
  1828. "M" gnus-mailing-list-insinuate
  1829. "t" gnus-article-babel)
  1830. (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
  1831. "b" gnus-article-add-buttons
  1832. "B" gnus-article-add-buttons-to-head
  1833. "o" gnus-article-treat-overstrike
  1834. "e" gnus-article-emphasize
  1835. "w" gnus-article-fill-cited-article
  1836. "Q" gnus-article-fill-long-lines
  1837. "L" gnus-article-toggle-truncate-lines
  1838. "C" gnus-article-capitalize-sentences
  1839. "c" gnus-article-remove-cr
  1840. "q" gnus-article-de-quoted-unreadable
  1841. "6" gnus-article-de-base64-unreadable
  1842. "Z" gnus-article-decode-HZ
  1843. "A" gnus-article-treat-ansi-sequences
  1844. "h" gnus-article-wash-html
  1845. "u" gnus-article-unsplit-urls
  1846. "s" gnus-summary-force-verify-and-decrypt
  1847. "f" gnus-article-display-x-face
  1848. "l" gnus-summary-stop-page-breaking
  1849. "r" gnus-summary-caesar-message
  1850. "m" gnus-summary-morse-message
  1851. "t" gnus-summary-toggle-header
  1852. "g" gnus-treat-smiley
  1853. "v" gnus-summary-verbose-headers
  1854. "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
  1855. "p" gnus-article-verify-x-pgp-sig
  1856. "d" gnus-article-treat-dumbquotes
  1857. "U" gnus-article-treat-non-ascii
  1858. "i" gnus-summary-idna-message)
  1859. (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
  1860. ;; mnemonic: deuglif*Y*
  1861. "u" gnus-article-outlook-unwrap-lines
  1862. "a" gnus-article-outlook-repair-attribution
  1863. "c" gnus-article-outlook-rearrange-citation
  1864. "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
  1865. (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
  1866. "a" gnus-article-hide
  1867. "h" gnus-article-hide-headers
  1868. "b" gnus-article-hide-boring-headers
  1869. "s" gnus-article-hide-signature
  1870. "c" gnus-article-hide-citation
  1871. "C" gnus-article-hide-citation-in-followups
  1872. "l" gnus-article-hide-list-identifiers
  1873. "B" gnus-article-strip-banner
  1874. "P" gnus-article-hide-pem
  1875. "\C-c" gnus-article-hide-citation-maybe)
  1876. (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
  1877. "a" gnus-article-highlight
  1878. "h" gnus-article-highlight-headers
  1879. "c" gnus-article-highlight-citation
  1880. "s" gnus-article-highlight-signature)
  1881. (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
  1882. "f" gnus-article-treat-fold-headers
  1883. "u" gnus-article-treat-unfold-headers
  1884. "n" gnus-article-treat-fold-newsgroups)
  1885. (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
  1886. "x" gnus-article-display-x-face
  1887. "d" gnus-article-display-face
  1888. "s" gnus-treat-smiley
  1889. "D" gnus-article-remove-images
  1890. "W" gnus-article-show-images
  1891. "f" gnus-treat-from-picon
  1892. "m" gnus-treat-mail-picon
  1893. "n" gnus-treat-newsgroups-picon
  1894. "g" gnus-treat-from-gravatar
  1895. "h" gnus-treat-mail-gravatar)
  1896. (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
  1897. "w" gnus-article-decode-mime-words
  1898. "c" gnus-article-decode-charset
  1899. "h" gnus-mime-buttonize-attachments-in-header
  1900. "v" gnus-mime-view-all-parts
  1901. "b" gnus-article-view-part)
  1902. (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
  1903. "z" gnus-article-date-ut
  1904. "u" gnus-article-date-ut
  1905. "l" gnus-article-date-local
  1906. "p" gnus-article-date-english
  1907. "e" gnus-article-date-lapsed
  1908. "o" gnus-article-date-original
  1909. "i" gnus-article-date-iso8601
  1910. "s" gnus-article-date-user)
  1911. (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
  1912. "t" gnus-article-remove-trailing-blank-lines
  1913. "l" gnus-article-strip-leading-blank-lines
  1914. "m" gnus-article-strip-multiple-blank-lines
  1915. "a" gnus-article-strip-blank-lines
  1916. "A" gnus-article-strip-all-blank-lines
  1917. "s" gnus-article-strip-leading-space
  1918. "e" gnus-article-strip-trailing-space
  1919. "w" gnus-article-remove-leading-whitespace)
  1920. (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
  1921. "v" gnus-version
  1922. "d" gnus-summary-describe-group
  1923. "h" gnus-summary-describe-briefly
  1924. "i" gnus-info-find-node)
  1925. (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
  1926. "e" gnus-summary-expire-articles
  1927. "\M-\C-e" gnus-summary-expire-articles-now
  1928. "\177" gnus-summary-delete-article
  1929. [delete] gnus-summary-delete-article
  1930. [backspace] gnus-summary-delete-article
  1931. "m" gnus-summary-move-article
  1932. "r" gnus-summary-respool-article
  1933. "w" gnus-summary-edit-article
  1934. "c" gnus-summary-copy-article
  1935. "B" gnus-summary-crosspost-article
  1936. "q" gnus-summary-respool-query
  1937. "t" gnus-summary-respool-trace
  1938. "i" gnus-summary-import-article
  1939. "I" gnus-summary-create-article
  1940. "p" gnus-summary-article-posted-p)
  1941. (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
  1942. "o" gnus-summary-save-article
  1943. "m" gnus-summary-save-article-mail
  1944. "F" gnus-summary-write-article-file
  1945. "r" gnus-summary-save-article-rmail
  1946. "f" gnus-summary-save-article-file
  1947. "b" gnus-summary-save-article-body-file
  1948. "B" gnus-summary-write-article-body-file
  1949. "h" gnus-summary-save-article-folder
  1950. "v" gnus-summary-save-article-vm
  1951. "p" gnus-summary-pipe-output
  1952. "P" gnus-summary-muttprint)
  1953. (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
  1954. "b" gnus-summary-display-buttonized
  1955. "m" gnus-summary-repair-multipart
  1956. "v" gnus-article-view-part
  1957. "o" gnus-article-save-part
  1958. "O" gnus-article-save-part-and-strip
  1959. "r" gnus-article-replace-part
  1960. "d" gnus-article-delete-part
  1961. "t" gnus-article-view-part-as-type
  1962. "j" gnus-article-jump-to-part
  1963. "c" gnus-article-copy-part
  1964. "C" gnus-article-view-part-as-charset
  1965. "e" gnus-article-view-part-externally
  1966. "H" gnus-article-browse-html-article
  1967. "E" gnus-article-encrypt-body
  1968. "i" gnus-article-inline-part
  1969. "|" gnus-article-pipe-part)
  1970. (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
  1971. "p" gnus-summary-mark-as-processable
  1972. "u" gnus-summary-unmark-as-processable
  1973. "U" gnus-summary-unmark-all-processable
  1974. "v" gnus-uu-mark-over
  1975. "s" gnus-uu-mark-series
  1976. "r" gnus-uu-mark-region
  1977. "g" gnus-uu-unmark-region
  1978. "R" gnus-uu-mark-by-regexp
  1979. "G" gnus-uu-unmark-by-regexp
  1980. "t" gnus-uu-mark-thread
  1981. "T" gnus-uu-unmark-thread
  1982. "a" gnus-uu-mark-all
  1983. "b" gnus-uu-mark-buffer
  1984. "S" gnus-uu-mark-sparse
  1985. "k" gnus-summary-kill-process-mark
  1986. "y" gnus-summary-yank-process-mark
  1987. "w" gnus-summary-save-process-mark
  1988. "i" gnus-uu-invert-processable)
  1989. (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
  1990. ;;"x" gnus-uu-extract-any
  1991. "m" gnus-summary-save-parts
  1992. "u" gnus-uu-decode-uu
  1993. "U" gnus-uu-decode-uu-and-save
  1994. "s" gnus-uu-decode-unshar
  1995. "S" gnus-uu-decode-unshar-and-save
  1996. "o" gnus-uu-decode-save
  1997. "O" gnus-uu-decode-save
  1998. "b" gnus-uu-decode-binhex
  1999. "B" gnus-uu-decode-binhex
  2000. "Y" gnus-uu-decode-yenc
  2001. "p" gnus-uu-decode-postscript
  2002. "P" gnus-uu-decode-postscript-and-save)
  2003. (gnus-define-keys
  2004. (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
  2005. "u" gnus-uu-decode-uu-view
  2006. "U" gnus-uu-decode-uu-and-save-view
  2007. "s" gnus-uu-decode-unshar-view
  2008. "S" gnus-uu-decode-unshar-and-save-view
  2009. "o" gnus-uu-decode-save-view
  2010. "O" gnus-uu-decode-save-view
  2011. "b" gnus-uu-decode-binhex-view
  2012. "B" gnus-uu-decode-binhex-view
  2013. "p" gnus-uu-decode-postscript-view
  2014. "P" gnus-uu-decode-postscript-and-save-view)
  2015. (defvar gnus-article-post-menu nil)
  2016. (defconst gnus-summary-menu-maxlen 20)
  2017. (defun gnus-summary-menu-split (menu)
  2018. ;; If we have lots of elements, divide them into groups of 20
  2019. ;; and make a pane (or submenu) for each one.
  2020. (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
  2021. (let ((menu menu) sublists next
  2022. (i 1))
  2023. (while menu
  2024. ;; Pull off the next gnus-summary-menu-maxlen elements
  2025. ;; and make them the next element of sublist.
  2026. (setq next (nthcdr gnus-summary-menu-maxlen menu))
  2027. (if next
  2028. (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
  2029. nil))
  2030. (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
  2031. (aref (car (last menu)) 0)) menu)
  2032. sublists))
  2033. (setq i (1+ i))
  2034. (setq menu next))
  2035. (nreverse sublists))
  2036. ;; Few elements--put them all in one pane.
  2037. menu))
  2038. (defun gnus-summary-make-menu-bar ()
  2039. (gnus-turn-off-edit-menu 'summary)
  2040. (unless (boundp 'gnus-summary-misc-menu)
  2041. (easy-menu-define
  2042. gnus-summary-kill-menu gnus-summary-mode-map ""
  2043. (cons
  2044. "Score"
  2045. (nconc
  2046. (list
  2047. ["Customize" gnus-score-customize t])
  2048. (gnus-make-score-map 'increase)
  2049. (gnus-make-score-map 'lower)
  2050. '(("Mark"
  2051. ["Kill below" gnus-summary-kill-below t]
  2052. ["Mark above" gnus-summary-mark-above t]
  2053. ["Tick above" gnus-summary-tick-above t]
  2054. ["Clear above" gnus-summary-clear-above t])
  2055. ["Current article score" gnus-summary-current-score t]
  2056. ["Current thread score" (gnus-summary-current-score 'total) t]
  2057. ["Set score" gnus-summary-set-score t]
  2058. ["Switch current score file..." gnus-score-change-score-file t]
  2059. ["Set mark below..." gnus-score-set-mark-below t]
  2060. ["Set expunge below..." gnus-score-set-expunge-below t]
  2061. ["Edit current score file" gnus-score-edit-current-scores t]
  2062. ["Edit score file..." gnus-score-edit-file t]
  2063. ["Trace score" gnus-score-find-trace t]
  2064. ["Find words" gnus-score-find-favourite-words t]
  2065. ["Rescore buffer" gnus-summary-rescore t]
  2066. ["Increase score..." gnus-summary-increase-score t]
  2067. ["Lower score..." gnus-summary-lower-score t]))))
  2068. ;; Define both the Article menu in the summary buffer and the
  2069. ;; equivalent Commands menu in the article buffer here for
  2070. ;; consistency.
  2071. (let ((innards
  2072. `(("Hide"
  2073. ["All" gnus-article-hide t]
  2074. ["Headers" gnus-article-hide-headers t]
  2075. ["Signature" gnus-article-hide-signature t]
  2076. ["Citation" gnus-article-hide-citation t]
  2077. ["List identifiers" gnus-article-hide-list-identifiers t]
  2078. ["Banner" gnus-article-strip-banner t]
  2079. ["Boring headers" gnus-article-hide-boring-headers t])
  2080. ("Highlight"
  2081. ["All" gnus-article-highlight t]
  2082. ["Headers" gnus-article-highlight-headers t]
  2083. ["Signature" gnus-article-highlight-signature t]
  2084. ["Citation" gnus-article-highlight-citation t])
  2085. ("MIME"
  2086. ["Words" gnus-article-decode-mime-words t]
  2087. ["Charset" gnus-article-decode-charset t]
  2088. ["QP" gnus-article-de-quoted-unreadable t]
  2089. ["Base64" gnus-article-de-base64-unreadable t]
  2090. ["View MIME buttons" gnus-summary-display-buttonized t]
  2091. ["View MIME buttons in header"
  2092. gnus-mime-buttonize-attachments-in-header t]
  2093. ["View all" gnus-mime-view-all-parts t]
  2094. ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
  2095. ["Encrypt body" gnus-article-encrypt-body
  2096. :active (not (gnus-group-read-only-p))
  2097. ,@(if (featurep 'xemacs) nil
  2098. '(:help "Encrypt the message body on disk"))]
  2099. ["Extract all parts..." gnus-summary-save-parts t]
  2100. ("Multipart"
  2101. ["Repair multipart" gnus-summary-repair-multipart t]
  2102. ["Pipe part..." gnus-article-pipe-part t]
  2103. ["Inline part" gnus-article-inline-part t]
  2104. ["View part as type..." gnus-article-view-part-as-type t]
  2105. ["Encrypt body" gnus-article-encrypt-body
  2106. :active (not (gnus-group-read-only-p))
  2107. ,@(if (featurep 'xemacs) nil
  2108. '(:help "Encrypt the message body on disk"))]
  2109. ["View part externally" gnus-article-view-part-externally t]
  2110. ["View HTML parts in browser" gnus-article-browse-html-article t]
  2111. ["View part with charset..." gnus-article-view-part-as-charset t]
  2112. ["Copy part" gnus-article-copy-part t]
  2113. ["Save part..." gnus-article-save-part t]
  2114. ["View part" gnus-article-view-part t]))
  2115. ("Date"
  2116. ["Local" gnus-article-date-local t]
  2117. ["ISO8601" gnus-article-date-iso8601 t]
  2118. ["UT" gnus-article-date-ut t]
  2119. ["Original" gnus-article-date-original t]
  2120. ["Lapsed" gnus-article-date-lapsed t]
  2121. ["User-defined" gnus-article-date-user t])
  2122. ("Display"
  2123. ["Display HTML images" gnus-article-show-images t]
  2124. ["Remove images" gnus-article-remove-images t]
  2125. ["Toggle smiley" gnus-treat-smiley t]
  2126. ["Show X-Face" gnus-article-display-x-face t]
  2127. ["Show picons in From" gnus-treat-from-picon t]
  2128. ["Show picons in mail headers" gnus-treat-mail-picon t]
  2129. ["Show picons in news headers" gnus-treat-newsgroups-picon t]
  2130. ["Show Gravatars in From" gnus-treat-from-gravatar t]
  2131. ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
  2132. ("View as different encoding"
  2133. ,@(gnus-summary-menu-split
  2134. (mapcar
  2135. (lambda (cs)
  2136. ;; Since easymenu under Emacs doesn't allow
  2137. ;; lambda forms for menu commands, we should
  2138. ;; provide intern'ed function symbols.
  2139. (let ((command (intern (format "\
  2140. gnus-summary-show-article-from-menu-as-charset-%s" cs))))
  2141. (fset command
  2142. `(lambda ()
  2143. (interactive)
  2144. (let ((gnus-summary-show-article-charset-alist
  2145. '((1 . ,cs))))
  2146. (gnus-summary-show-article 1))))
  2147. `[,(symbol-name cs) ,command t]))
  2148. (sort (if (fboundp 'coding-system-list)
  2149. (coding-system-list)
  2150. (mapcar 'car mm-mime-mule-charset-alist))
  2151. 'string<)))))
  2152. ("Washing"
  2153. ("Remove Blanks"
  2154. ["Leading" gnus-article-strip-leading-blank-lines t]
  2155. ["Multiple" gnus-article-strip-multiple-blank-lines t]
  2156. ["Trailing" gnus-article-remove-trailing-blank-lines t]
  2157. ["All of the above" gnus-article-strip-blank-lines t]
  2158. ["All" gnus-article-strip-all-blank-lines t]
  2159. ["Leading space" gnus-article-strip-leading-space t]
  2160. ["Trailing space" gnus-article-strip-trailing-space t]
  2161. ["Leading space in headers"
  2162. gnus-article-remove-leading-whitespace t])
  2163. ["Overstrike" gnus-article-treat-overstrike t]
  2164. ["Dumb quotes" gnus-article-treat-dumbquotes t]
  2165. ["Non-ASCII" gnus-article-treat-non-ascii t]
  2166. ["Emphasis" gnus-article-emphasize t]
  2167. ["Word wrap" gnus-article-fill-cited-article t]
  2168. ["Fill long lines" gnus-article-fill-long-lines t]
  2169. ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
  2170. ["Capitalize sentences" gnus-article-capitalize-sentences t]
  2171. ["Remove CR" gnus-article-remove-cr t]
  2172. ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
  2173. ["Base64" gnus-article-de-base64-unreadable t]
  2174. ["Rot 13" gnus-summary-caesar-message
  2175. ,@(if (featurep 'xemacs) '(t)
  2176. '(:help "\"Caesar rotate\" article by 13"))]
  2177. ["De-IDNA" gnus-summary-idna-message t]
  2178. ["Morse decode" gnus-summary-morse-message t]
  2179. ["Unix pipe..." gnus-summary-pipe-message t]
  2180. ["Add buttons" gnus-article-add-buttons t]
  2181. ["Add buttons to head" gnus-article-add-buttons-to-head t]
  2182. ["Stop page breaking" gnus-summary-stop-page-breaking t]
  2183. ["Verbose header" gnus-summary-verbose-headers t]
  2184. ["Toggle header" gnus-summary-toggle-header t]
  2185. ["Unfold headers" gnus-article-treat-unfold-headers t]
  2186. ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
  2187. ["Html" gnus-article-wash-html t]
  2188. ["Unsplit URLs" gnus-article-unsplit-urls t]
  2189. ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
  2190. ["Decode HZ" gnus-article-decode-HZ t]
  2191. ["ANSI sequences" gnus-article-treat-ansi-sequences t]
  2192. ("(Outlook) Deuglify"
  2193. ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
  2194. ["Repair attribution" gnus-article-outlook-repair-attribution t]
  2195. ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
  2196. ["Full (Outlook) deuglify"
  2197. gnus-article-outlook-deuglify-article t])
  2198. )
  2199. ("Output"
  2200. ["Save in default format..." gnus-summary-save-article
  2201. ,@(if (featurep 'xemacs) '(t)
  2202. '(:help "Save article using default method"))]
  2203. ["Save in file..." gnus-summary-save-article-file
  2204. ,@(if (featurep 'xemacs) '(t)
  2205. '(:help "Save article in file"))]
  2206. ["Save in Unix mail format..." gnus-summary-save-article-mail t]
  2207. ["Save in MH folder..." gnus-summary-save-article-folder t]
  2208. ["Save in VM folder..." gnus-summary-save-article-vm t]
  2209. ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
  2210. ["Save body in file..." gnus-summary-save-article-body-file t]
  2211. ["Pipe through a filter..." gnus-summary-pipe-output t]
  2212. ["Print with Muttprint..." gnus-summary-muttprint t]
  2213. ["Print" gnus-summary-print-article
  2214. ,@(if (featurep 'xemacs) '(t)
  2215. '(:help "Generate and print a PostScript image"))])
  2216. ("Copy, move,... (Backend)"
  2217. ,@(if (featurep 'xemacs) nil
  2218. '(:help "Copying, moving, expiring articles..."))
  2219. ["Respool article..." gnus-summary-respool-article t]
  2220. ["Move article..." gnus-summary-move-article
  2221. (gnus-check-backend-function
  2222. 'request-move-article gnus-newsgroup-name)]
  2223. ["Copy article..." gnus-summary-copy-article t]
  2224. ["Crosspost article..." gnus-summary-crosspost-article
  2225. (gnus-check-backend-function
  2226. 'request-replace-article gnus-newsgroup-name)]
  2227. ["Import file..." gnus-summary-import-article
  2228. (gnus-check-backend-function
  2229. 'request-accept-article gnus-newsgroup-name)]
  2230. ["Create article..." gnus-summary-create-article
  2231. (gnus-check-backend-function
  2232. 'request-accept-article gnus-newsgroup-name)]
  2233. ["Check if posted" gnus-summary-article-posted-p t]
  2234. ["Edit article" gnus-summary-edit-article
  2235. (not (gnus-group-read-only-p))]
  2236. ["Delete article" gnus-summary-delete-article
  2237. (gnus-check-backend-function
  2238. 'request-expire-articles gnus-newsgroup-name)]
  2239. ["Query respool" gnus-summary-respool-query t]
  2240. ["Trace respool" gnus-summary-respool-trace t]
  2241. ["Delete expirable articles" gnus-summary-expire-articles-now
  2242. (gnus-check-backend-function
  2243. 'request-expire-articles gnus-newsgroup-name)])
  2244. ("Extract"
  2245. ["Uudecode" gnus-uu-decode-uu
  2246. ,@(if (featurep 'xemacs) '(t)
  2247. '(:help "Decode uuencoded article(s)"))]
  2248. ["Uudecode and save" gnus-uu-decode-uu-and-save t]
  2249. ["Unshar" gnus-uu-decode-unshar t]
  2250. ["Unshar and save" gnus-uu-decode-unshar-and-save t]
  2251. ["Save" gnus-uu-decode-save t]
  2252. ["Binhex" gnus-uu-decode-binhex t]
  2253. ["PostScript" gnus-uu-decode-postscript t]
  2254. ["All MIME parts" gnus-summary-save-parts t])
  2255. ("Cache"
  2256. ["Enter article" gnus-cache-enter-article t]
  2257. ["Remove article" gnus-cache-remove-article t])
  2258. ["Translate" gnus-article-babel t]
  2259. ["Select article buffer" gnus-summary-select-article-buffer t]
  2260. ["Make article buffer sticky" gnus-sticky-article t]
  2261. ["Enter digest buffer" gnus-summary-enter-digest-group t]
  2262. ["Isearch article..." gnus-summary-isearch-article t]
  2263. ["Beginning of the article" gnus-summary-beginning-of-article t]
  2264. ["End of the article" gnus-summary-end-of-article t]
  2265. ["Fetch parent of article" gnus-summary-refer-parent-article t]
  2266. ["Fetch referenced articles" gnus-summary-refer-references t]
  2267. ["Fetch current thread" gnus-summary-refer-thread t]
  2268. ["Fetch article with id..." gnus-summary-refer-article t]
  2269. ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
  2270. ["Redisplay" gnus-summary-show-article t]
  2271. ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
  2272. (easy-menu-define
  2273. gnus-summary-article-menu gnus-summary-mode-map ""
  2274. (cons "Article" innards))
  2275. (if (not (keymapp gnus-summary-article-menu))
  2276. (easy-menu-define
  2277. gnus-article-commands-menu gnus-article-mode-map ""
  2278. (cons "Commands" innards))
  2279. ;; in Emacs, don't share menu.
  2280. (setq gnus-article-commands-menu
  2281. (copy-keymap gnus-summary-article-menu))
  2282. (define-key gnus-article-mode-map [menu-bar commands]
  2283. (cons "Commands" gnus-article-commands-menu))))
  2284. (easy-menu-define
  2285. gnus-summary-thread-menu gnus-summary-mode-map ""
  2286. '("Threads"
  2287. ["Find all messages in thread" gnus-summary-refer-thread t]
  2288. ["Toggle threading" gnus-summary-toggle-threads t]
  2289. ["Hide threads" gnus-summary-hide-all-threads t]
  2290. ["Show threads" gnus-summary-show-all-threads t]
  2291. ["Hide thread" gnus-summary-hide-thread t]
  2292. ["Show thread" gnus-summary-show-thread t]
  2293. ["Go to next thread" gnus-summary-next-thread t]
  2294. ["Go to previous thread" gnus-summary-prev-thread t]
  2295. ["Go down thread" gnus-summary-down-thread t]
  2296. ["Go up thread" gnus-summary-up-thread t]
  2297. ["Top of thread" gnus-summary-top-thread t]
  2298. ["Mark thread as read" gnus-summary-kill-thread t]
  2299. ["Mark thread as expired" gnus-summary-expire-thread t]
  2300. ["Lower thread score" gnus-summary-lower-thread t]
  2301. ["Raise thread score" gnus-summary-raise-thread t]
  2302. ["Rethread current" gnus-summary-rethread-current t]))
  2303. (easy-menu-define
  2304. gnus-summary-post-menu gnus-summary-mode-map ""
  2305. `("Post"
  2306. ["Send a message (mail or news)" gnus-summary-post-news
  2307. ,@(if (featurep 'xemacs) '(t)
  2308. '(:help "Compose a new message (mail or news)"))]
  2309. ["Followup" gnus-summary-followup
  2310. ,@(if (featurep 'xemacs) '(t)
  2311. '(:help "Post followup to this article"))]
  2312. ["Followup and yank" gnus-summary-followup-with-original
  2313. ,@(if (featurep 'xemacs) '(t)
  2314. '(:help "Post followup to this article, quoting its contents"))]
  2315. ["Supersede article" gnus-summary-supersede-article t]
  2316. ["Cancel article" gnus-summary-cancel-article
  2317. ,@(if (featurep 'xemacs) '(t)
  2318. '(:help "Cancel an article you posted"))]
  2319. ["Reply" gnus-summary-reply t]
  2320. ["Reply and yank" gnus-summary-reply-with-original t]
  2321. ["Wide reply" gnus-summary-wide-reply t]
  2322. ["Wide reply and yank" gnus-summary-wide-reply-with-original
  2323. ,@(if (featurep 'xemacs) '(t)
  2324. '(:help "Mail a reply, quoting this article"))]
  2325. ["Very wide reply" gnus-summary-very-wide-reply t]
  2326. ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
  2327. ,@(if (featurep 'xemacs) '(t)
  2328. '(:help "Mail a very wide reply, quoting this article"))]
  2329. ["Mail forward" gnus-summary-mail-forward t]
  2330. ["Post forward" gnus-summary-post-forward t]
  2331. ["Digest and mail" gnus-uu-digest-mail-forward t]
  2332. ["Digest and post" gnus-uu-digest-post-forward t]
  2333. ["Resend message" gnus-summary-resend-message t]
  2334. ["Resend message edit" gnus-summary-resend-message-edit t]
  2335. ["Send bounced mail" gnus-summary-resend-bounced-mail t]
  2336. ["Send a mail" gnus-summary-mail-other-window t]
  2337. ["Create a local message" gnus-summary-news-other-window t]
  2338. ["Uuencode and post" gnus-uu-post-news
  2339. ,@(if (featurep 'xemacs) '(t)
  2340. '(:help "Post a uuencoded article"))]
  2341. ["Followup via news" gnus-summary-followup-to-mail t]
  2342. ["Followup via news and yank"
  2343. gnus-summary-followup-to-mail-with-original t]
  2344. ["Strip signature on reply"
  2345. (lambda ()
  2346. (interactive)
  2347. (if (not (memq message-cite-function
  2348. '(message-cite-original-without-signature
  2349. message-cite-original)))
  2350. ;; Stupid workaround for XEmacs not honoring :visible.
  2351. (message "Can't toggle this value of `message-cite-function'")
  2352. (setq message-cite-function
  2353. (if (eq message-cite-function
  2354. 'message-cite-original-without-signature)
  2355. 'message-cite-original
  2356. 'message-cite-original-without-signature))))
  2357. ;; XEmacs barfs on :visible.
  2358. ,@(if (featurep 'xemacs) nil
  2359. '(:visible (memq message-cite-function
  2360. '(message-cite-original-without-signature
  2361. message-cite-original))))
  2362. :style toggle
  2363. :selected (eq message-cite-function
  2364. 'message-cite-original-without-signature)
  2365. ,@(if (featurep 'xemacs) nil
  2366. '(:help "Strip signature from cited article when replying."))]
  2367. ;;("Draft"
  2368. ;;["Send" gnus-summary-send-draft t]
  2369. ;;["Send bounced" gnus-resend-bounced-mail t])
  2370. ))
  2371. (cond
  2372. ((not (keymapp gnus-summary-post-menu))
  2373. (setq gnus-article-post-menu gnus-summary-post-menu))
  2374. ((not gnus-article-post-menu)
  2375. ;; Don't share post menu.
  2376. (setq gnus-article-post-menu
  2377. (copy-keymap gnus-summary-post-menu))))
  2378. (define-key gnus-article-mode-map [menu-bar post]
  2379. (cons "Post" gnus-article-post-menu))
  2380. (easy-menu-define
  2381. gnus-summary-misc-menu gnus-summary-mode-map ""
  2382. `("Gnus"
  2383. ("Mark Read"
  2384. ["Mark as read" gnus-summary-mark-as-read-forward t]
  2385. ["Mark same subject and select"
  2386. gnus-summary-kill-same-subject-and-select t]
  2387. ["Mark same subject" gnus-summary-kill-same-subject t]
  2388. ["Catchup" gnus-summary-catchup
  2389. ,@(if (featurep 'xemacs) '(t)
  2390. '(:help "Mark unread articles in this group as read"))]
  2391. ["Catchup all" gnus-summary-catchup-all t]
  2392. ["Catchup to here" gnus-summary-catchup-to-here t]
  2393. ["Catchup from here" gnus-summary-catchup-from-here t]
  2394. ["Catchup region" gnus-summary-mark-region-as-read
  2395. (gnus-mark-active-p)]
  2396. ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
  2397. ("Mark Various"
  2398. ["Tick" gnus-summary-tick-article-forward t]
  2399. ["Mark as dormant" gnus-summary-mark-as-dormant t]
  2400. ["Remove marks" gnus-summary-clear-mark-forward t]
  2401. ["Set expirable mark" gnus-summary-mark-as-expirable t]
  2402. ["Set bookmark" gnus-summary-set-bookmark t]
  2403. ["Remove bookmark" gnus-summary-remove-bookmark t])
  2404. ("Limit to"
  2405. ["Marks..." gnus-summary-limit-to-marks t]
  2406. ["Subject..." gnus-summary-limit-to-subject t]
  2407. ["Author..." gnus-summary-limit-to-author t]
  2408. ["Recipient..." gnus-summary-limit-to-recipient t]
  2409. ["Address..." gnus-summary-limit-to-address t]
  2410. ["Age..." gnus-summary-limit-to-age t]
  2411. ["Extra..." gnus-summary-limit-to-extra t]
  2412. ["Score..." gnus-summary-limit-to-score t]
  2413. ["Display Predicate" gnus-summary-limit-to-display-predicate t]
  2414. ["Unread" gnus-summary-limit-to-unread t]
  2415. ["Unseen" gnus-summary-limit-to-unseen t]
  2416. ["Singletons" gnus-summary-limit-to-singletons t]
  2417. ["Replied" gnus-summary-limit-to-replied t]
  2418. ["Non-dormant" gnus-summary-limit-exclude-dormant t]
  2419. ["Next or process marked articles" gnus-summary-limit-to-articles t]
  2420. ["Pop limit" gnus-summary-pop-limit t]
  2421. ["Show dormant" gnus-summary-limit-include-dormant t]
  2422. ["Hide childless dormant"
  2423. gnus-summary-limit-exclude-childless-dormant t]
  2424. ;;["Hide thread" gnus-summary-limit-exclude-thread t]
  2425. ["Hide marked" gnus-summary-limit-exclude-marks t]
  2426. ["Show expunged" gnus-summary-limit-include-expunged t])
  2427. ("Process Mark"
  2428. ["Set mark" gnus-summary-mark-as-processable t]
  2429. ["Remove mark" gnus-summary-unmark-as-processable t]
  2430. ["Remove all marks" gnus-summary-unmark-all-processable t]
  2431. ["Invert marks" gnus-uu-invert-processable t]
  2432. ["Mark above" gnus-uu-mark-over t]
  2433. ["Mark series" gnus-uu-mark-series t]
  2434. ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
  2435. ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
  2436. ["Mark by regexp..." gnus-uu-mark-by-regexp t]
  2437. ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
  2438. ["Mark all" gnus-uu-mark-all t]
  2439. ["Mark buffer" gnus-uu-mark-buffer t]
  2440. ["Mark sparse" gnus-uu-mark-sparse t]
  2441. ["Mark thread" gnus-uu-mark-thread t]
  2442. ["Unmark thread" gnus-uu-unmark-thread t]
  2443. ("Process Mark Sets"
  2444. ["Kill" gnus-summary-kill-process-mark t]
  2445. ["Yank" gnus-summary-yank-process-mark
  2446. gnus-newsgroup-process-stack]
  2447. ["Save" gnus-summary-save-process-mark t]
  2448. ["Run command on marked..." gnus-summary-universal-argument t]))
  2449. ("Registry Marks")
  2450. ("Scroll article"
  2451. ["Page forward" gnus-summary-next-page
  2452. ,@(if (featurep 'xemacs) '(t)
  2453. '(:help "Show next page of article"))]
  2454. ["Page backward" gnus-summary-prev-page
  2455. ,@(if (featurep 'xemacs) '(t)
  2456. '(:help "Show previous page of article"))]
  2457. ["Line forward" gnus-summary-scroll-up t])
  2458. ("Move"
  2459. ["Next unread article" gnus-summary-next-unread-article t]
  2460. ["Previous unread article" gnus-summary-prev-unread-article t]
  2461. ["Next article" gnus-summary-next-article t]
  2462. ["Previous article" gnus-summary-prev-article t]
  2463. ["Next unread subject" gnus-summary-next-unread-subject t]
  2464. ["Previous unread subject" gnus-summary-prev-unread-subject t]
  2465. ["Next article same subject" gnus-summary-next-same-subject t]
  2466. ["Previous article same subject" gnus-summary-prev-same-subject t]
  2467. ["First unread article" gnus-summary-first-unread-article t]
  2468. ["Best unread article" gnus-summary-best-unread-article t]
  2469. ["Go to subject number..." gnus-summary-goto-subject t]
  2470. ["Go to article number..." gnus-summary-goto-article t]
  2471. ["Go to the last article" gnus-summary-goto-last-article t]
  2472. ["Pop article off history" gnus-summary-pop-article t])
  2473. ("Sort"
  2474. ["Sort by number" gnus-summary-sort-by-number t]
  2475. ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
  2476. ["Sort by author" gnus-summary-sort-by-author t]
  2477. ["Sort by recipient" gnus-summary-sort-by-recipient t]
  2478. ["Sort by subject" gnus-summary-sort-by-subject t]
  2479. ["Sort by date" gnus-summary-sort-by-date t]
  2480. ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
  2481. ["Sort by score" gnus-summary-sort-by-score t]
  2482. ["Sort by lines" gnus-summary-sort-by-lines t]
  2483. ["Sort by characters" gnus-summary-sort-by-chars t]
  2484. ["Randomize" gnus-summary-sort-by-random t]
  2485. ["Original sort" gnus-summary-sort-by-original t])
  2486. ("Help"
  2487. ["Describe group" gnus-summary-describe-group t]
  2488. ["Read manual" gnus-info-find-node t])
  2489. ("Modes"
  2490. ["Pick and read" gnus-pick-mode t]
  2491. ["Binary" gnus-binary-mode t])
  2492. ("Regeneration"
  2493. ["Regenerate" gnus-summary-prepare t]
  2494. ["Insert cached articles" gnus-summary-insert-cached-articles t]
  2495. ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
  2496. ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
  2497. ["Toggle threading" gnus-summary-toggle-threads t])
  2498. ["See old articles" gnus-summary-insert-old-articles t]
  2499. ["See new articles" gnus-summary-insert-new-articles t]
  2500. ["Filter articles..." gnus-summary-execute-command t]
  2501. ["Run command on articles..." gnus-summary-universal-argument t]
  2502. ["Search articles forward..." gnus-summary-search-article-forward t]
  2503. ["Search articles backward..." gnus-summary-search-article-backward t]
  2504. ["Toggle line truncation" gnus-summary-toggle-truncation t]
  2505. ["Expand window" gnus-summary-expand-window t]
  2506. ["Expire expirable articles" gnus-summary-expire-articles
  2507. (gnus-check-backend-function
  2508. 'request-expire-articles gnus-newsgroup-name)]
  2509. ["Edit local kill file" gnus-summary-edit-local-kill t]
  2510. ["Edit main kill file" gnus-summary-edit-global-kill t]
  2511. ["Edit group parameters" gnus-summary-edit-parameters t]
  2512. ["Customize group parameters" gnus-summary-customize-parameters t]
  2513. ["Send a bug report" gnus-bug t]
  2514. ("Exit"
  2515. ["Catchup and exit" gnus-summary-catchup-and-exit
  2516. ,@(if (featurep 'xemacs) '(t)
  2517. '(:help "Mark unread articles in this group as read, then exit"))]
  2518. ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
  2519. ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
  2520. ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
  2521. ["Exit group" gnus-summary-exit
  2522. ,@(if (featurep 'xemacs) '(t)
  2523. '(:help "Exit current group, return to group selection mode"))]
  2524. ["Exit group without updating" gnus-summary-exit-no-update t]
  2525. ["Exit and goto next group" gnus-summary-next-group t]
  2526. ["Exit and goto prev group" gnus-summary-prev-group t]
  2527. ["Reselect group" gnus-summary-reselect-current-group t]
  2528. ["Rescan group" gnus-summary-rescan-group t]
  2529. ["Update dribble" gnus-summary-save-newsrc t])))
  2530. (gnus-run-hooks 'gnus-summary-menu-hook)))
  2531. (defvar gnus-summary-tool-bar-map nil)
  2532. ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
  2533. ;; affect _new_ message buffers. We might add a function that walks thru all
  2534. ;; summary-mode buffers and force the update.
  2535. (defun gnus-summary-tool-bar-update (&optional symbol value)
  2536. "Update summary mode toolbar.
  2537. Setter function for custom variables."
  2538. (setq-default gnus-summary-tool-bar-map nil)
  2539. (when symbol
  2540. ;; When used as ":set" function:
  2541. (set-default symbol value))
  2542. (when (gnus-buffer-live-p gnus-summary-buffer)
  2543. (with-current-buffer gnus-summary-buffer
  2544. (gnus-summary-make-tool-bar))))
  2545. (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
  2546. 'gnus-summary-tool-bar-gnome
  2547. 'gnus-summary-tool-bar-retro)
  2548. "Specifies the Gnus summary tool bar.
  2549. It can be either a list or a symbol referring to a list. See
  2550. `gmm-tool-bar-from-list' for the format of the list. The
  2551. default key map is `gnus-summary-mode-map'.
  2552. Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
  2553. `gnus-summary-tool-bar-retro'."
  2554. :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
  2555. (const :tag "Retro look" gnus-summary-tool-bar-retro)
  2556. (repeat :tag "User defined list" gmm-tool-bar-item)
  2557. (symbol))
  2558. :version "23.1" ;; No Gnus
  2559. :initialize 'custom-initialize-default
  2560. :set 'gnus-summary-tool-bar-update
  2561. :group 'gnus-summary)
  2562. (defcustom gnus-summary-tool-bar-gnome
  2563. '((gnus-summary-post-news "mail/compose" nil)
  2564. (gnus-summary-insert-new-articles "mail/inbox" nil
  2565. :visible (or (not gnus-agent)
  2566. gnus-plugged))
  2567. (gnus-summary-reply-with-original "mail/reply")
  2568. (gnus-summary-reply "mail/reply" nil :visible nil)
  2569. (gnus-summary-followup-with-original "mail/reply-all")
  2570. (gnus-summary-followup "mail/reply-all" nil :visible nil)
  2571. (gnus-summary-mail-forward "mail/forward")
  2572. (gnus-summary-save-article "mail/save")
  2573. (gnus-summary-search-article-forward "search" nil :visible nil)
  2574. (gnus-summary-print-article "print")
  2575. (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
  2576. ;; Some new commands that may need more suitable icons:
  2577. (gnus-summary-save-newsrc "save" nil :visible nil)
  2578. ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
  2579. (gnus-summary-prev-article "left-arrow")
  2580. (gnus-summary-next-article "right-arrow")
  2581. (gnus-summary-next-page "next-page")
  2582. ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
  2583. ;;
  2584. ;; Maybe some sort-by-... could be added:
  2585. ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
  2586. ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
  2587. (gnus-summary-mark-as-expirable
  2588. "delete" nil
  2589. :visible (gnus-check-backend-function 'request-expire-articles
  2590. gnus-newsgroup-name))
  2591. (gnus-summary-mark-as-spam
  2592. "mail/spam" t
  2593. :visible (and (fboundp 'spam-group-ham-contents-p)
  2594. (spam-group-ham-contents-p gnus-newsgroup-name))
  2595. :help "Mark as spam")
  2596. (gnus-summary-mark-as-read-forward
  2597. "mail/not-spam" nil
  2598. :visible (and (fboundp 'spam-group-spam-contents-p)
  2599. (spam-group-spam-contents-p gnus-newsgroup-name)))
  2600. ;;
  2601. (gnus-summary-exit "exit")
  2602. (gmm-customize-mode "preferences" t :help "Edit mode preferences")
  2603. (gnus-info-find-node "help"))
  2604. "List of functions for the summary tool bar (GNOME style).
  2605. See `gmm-tool-bar-from-list' for the format of the list."
  2606. :type '(repeat gmm-tool-bar-item)
  2607. :version "23.1" ;; No Gnus
  2608. :initialize 'custom-initialize-default
  2609. :set 'gnus-summary-tool-bar-update
  2610. :group 'gnus-summary)
  2611. (defcustom gnus-summary-tool-bar-retro
  2612. '((gnus-summary-prev-unread-article "gnus/prev-ur")
  2613. (gnus-summary-next-unread-article "gnus/next-ur")
  2614. (gnus-summary-post-news "gnus/post")
  2615. (gnus-summary-followup-with-original "gnus/fuwo")
  2616. (gnus-summary-followup "gnus/followup")
  2617. (gnus-summary-reply-with-original "gnus/reply-wo")
  2618. (gnus-summary-reply "gnus/reply")
  2619. (gnus-summary-caesar-message "gnus/rot13")
  2620. (gnus-uu-decode-uu "gnus/uu-decode")
  2621. (gnus-summary-save-article-file "gnus/save-aif")
  2622. (gnus-summary-save-article "gnus/save-art")
  2623. (gnus-uu-post-news "gnus/uu-post")
  2624. (gnus-summary-catchup "gnus/catchup")
  2625. (gnus-summary-catchup-and-exit "gnus/cu-exit")
  2626. (gnus-summary-exit "gnus/exit-summ")
  2627. ;; Some new command that may need more suitable icons:
  2628. (gnus-summary-print-article "gnus/print" nil :visible nil)
  2629. (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
  2630. (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
  2631. ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
  2632. (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
  2633. ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
  2634. ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
  2635. ;;
  2636. (gnus-info-find-node "gnus/help" nil :visible nil))
  2637. "List of functions for the summary tool bar (retro look).
  2638. See `gmm-tool-bar-from-list' for the format of the list."
  2639. :type '(repeat gmm-tool-bar-item)
  2640. :version "23.1" ;; No Gnus
  2641. :initialize 'custom-initialize-default
  2642. :set 'gnus-summary-tool-bar-update
  2643. :group 'gnus-summary)
  2644. (defcustom gnus-summary-tool-bar-zap-list t
  2645. "List of icon items from the global tool bar.
  2646. These items are not displayed in the Gnus summary mode tool bar.
  2647. See `gmm-tool-bar-from-list' for the format of the list."
  2648. :type 'gmm-tool-bar-zap-list
  2649. :version "23.1" ;; No Gnus
  2650. :initialize 'custom-initialize-default
  2651. :set 'gnus-summary-tool-bar-update
  2652. :group 'gnus-summary)
  2653. (defvar image-load-path)
  2654. (defvar tool-bar-map)
  2655. (defun gnus-summary-make-tool-bar (&optional force)
  2656. "Make a summary mode tool bar from `gnus-summary-tool-bar'.
  2657. When FORCE, rebuild the tool bar."
  2658. (when (and (not (featurep 'xemacs))
  2659. (boundp 'tool-bar-mode)
  2660. tool-bar-mode
  2661. (or (not gnus-summary-tool-bar-map) force))
  2662. (let* ((load-path
  2663. (gmm-image-load-path-for-library "gnus"
  2664. "mail/save.xpm"
  2665. nil t))
  2666. (image-load-path (cons (car load-path)
  2667. (when (boundp 'image-load-path)
  2668. image-load-path)))
  2669. (map (gmm-tool-bar-from-list gnus-summary-tool-bar
  2670. gnus-summary-tool-bar-zap-list
  2671. 'gnus-summary-mode-map)))
  2672. (when map
  2673. ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
  2674. ;; uses its value.
  2675. (setq gnus-summary-tool-bar-map map))))
  2676. (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
  2677. (defun gnus-make-score-map (type)
  2678. "Make a summary score map of type TYPE."
  2679. (if t
  2680. nil
  2681. (let ((headers '(("author" "from" string)
  2682. ("subject" "subject" string)
  2683. ("article body" "body" string)
  2684. ("article head" "head" string)
  2685. ("xref" "xref" string)
  2686. ("extra header" "extra" string)
  2687. ("lines" "lines" number)
  2688. ("followups to author" "followup" string)))
  2689. (types '((number ("less than" <)
  2690. ("greater than" >)
  2691. ("equal" =))
  2692. (string ("substring" s)
  2693. ("exact string" e)
  2694. ("fuzzy string" f)
  2695. ("regexp" r))))
  2696. (perms '(("temporary" (current-time-string))
  2697. ("permanent" nil)
  2698. ("immediate" now)))
  2699. header)
  2700. (list
  2701. (apply
  2702. 'nconc
  2703. (list
  2704. (if (eq type 'lower)
  2705. "Lower score"
  2706. "Increase score"))
  2707. (let (outh)
  2708. (while headers
  2709. (setq header (car headers))
  2710. (setq outh
  2711. (cons
  2712. (apply
  2713. 'nconc
  2714. (list (car header))
  2715. (let ((ts (cdr (assoc (nth 2 header) types)))
  2716. outt)
  2717. (while ts
  2718. (setq outt
  2719. (cons
  2720. (apply
  2721. 'nconc
  2722. (list (caar ts))
  2723. (let ((ps perms)
  2724. outp)
  2725. (while ps
  2726. (setq outp
  2727. (cons
  2728. (vector
  2729. (caar ps)
  2730. (list
  2731. 'gnus-summary-score-entry
  2732. (nth 1 header)
  2733. (if (or (string= (nth 1 header)
  2734. "head")
  2735. (string= (nth 1 header)
  2736. "body"))
  2737. ""
  2738. (list 'gnus-summary-header
  2739. (nth 1 header)))
  2740. (list 'quote (nth 1 (car ts)))
  2741. (list 'gnus-score-delta-default
  2742. nil)
  2743. (nth 1 (car ps))
  2744. t)
  2745. t)
  2746. outp))
  2747. (setq ps (cdr ps)))
  2748. (list (nreverse outp))))
  2749. outt))
  2750. (setq ts (cdr ts)))
  2751. (list (nreverse outt))))
  2752. outh))
  2753. (setq headers (cdr headers)))
  2754. (list (nreverse outh))))))))
  2755. (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
  2756. (defvar bookmark-make-record-function)
  2757. (defvar bidi-paragraph-direction)
  2758. (defun gnus-summary-mode (&optional group)
  2759. "Major mode for reading articles.
  2760. All normal editing commands are switched off.
  2761. \\<gnus-summary-mode-map>
  2762. Each line in this buffer represents one article. To read an
  2763. article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
  2764. and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
  2765. respectively.
  2766. You can also post articles and send mail from this buffer. To
  2767. follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
  2768. of an article, type `\\[gnus-summary-reply]'.
  2769. There are approx. one gazillion commands you can execute in this
  2770. buffer; read the info pages for more information (`\\[gnus-info-find-node]').
  2771. The following commands are available:
  2772. \\{gnus-summary-mode-map}"
  2773. ;; FIXME: Use define-derived-mode.
  2774. (interactive)
  2775. (kill-all-local-variables)
  2776. (let ((gnus-summary-local-variables gnus-newsgroup-variables))
  2777. (gnus-summary-make-local-variables))
  2778. (gnus-summary-make-local-variables)
  2779. (setq gnus-newsgroup-name group)
  2780. (when (gnus-visual-p 'summary-menu 'menu)
  2781. (gnus-summary-make-menu-bar)
  2782. (gnus-summary-make-tool-bar))
  2783. (gnus-make-thread-indent-array)
  2784. (gnus-simplify-mode-line)
  2785. (setq major-mode 'gnus-summary-mode)
  2786. (setq mode-name "Summary")
  2787. (use-local-map gnus-summary-mode-map)
  2788. (buffer-disable-undo)
  2789. (setq buffer-read-only t ;Disable modification
  2790. show-trailing-whitespace nil)
  2791. (setq truncate-lines t)
  2792. ;; Force paragraph direction to be left-to-right. Don't make it
  2793. ;; bound globally in old Emacsen and XEmacsen.
  2794. (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
  2795. (add-to-invisibility-spec '(gnus-sum . t))
  2796. (gnus-summary-set-display-table)
  2797. (gnus-set-default-directory)
  2798. (make-local-variable 'gnus-summary-line-format)
  2799. (make-local-variable 'gnus-summary-line-format-spec)
  2800. (make-local-variable 'gnus-summary-dummy-line-format)
  2801. (make-local-variable 'gnus-summary-dummy-line-format-spec)
  2802. (make-local-variable 'gnus-summary-mark-positions)
  2803. (gnus-make-local-hook 'pre-command-hook)
  2804. (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
  2805. (gnus-run-mode-hooks 'gnus-summary-mode-hook)
  2806. (turn-on-gnus-mailing-list-mode)
  2807. (mm-enable-multibyte)
  2808. (set (make-local-variable 'bookmark-make-record-function)
  2809. 'gnus-summary-bookmark-make-record)
  2810. (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
  2811. (gnus-update-summary-mark-positions))
  2812. (defun gnus-summary-make-local-variables ()
  2813. "Make all the local summary buffer variables."
  2814. (let (global)
  2815. (dolist (local gnus-summary-local-variables)
  2816. (if (consp local)
  2817. (progn
  2818. (if (eq (cdr local) 'global)
  2819. ;; Copy the global value of the variable.
  2820. (setq global (symbol-value (car local)))
  2821. ;; Use the value from the list.
  2822. (setq global (eval (cdr local))))
  2823. (set (make-local-variable (car local)) global))
  2824. ;; Simple nil-valued local variable.
  2825. (set (make-local-variable local) nil)))))
  2826. ;; Summary data functions.
  2827. (defmacro gnus-data-number (data)
  2828. `(car ,data))
  2829. (defmacro gnus-data-set-number (data number)
  2830. `(setcar ,data ,number))
  2831. (defmacro gnus-data-mark (data)
  2832. `(nth 1 ,data))
  2833. (defmacro gnus-data-set-mark (data mark)
  2834. `(setcar (nthcdr 1 ,data) ,mark))
  2835. (defmacro gnus-data-pos (data)
  2836. `(nth 2 ,data))
  2837. (defmacro gnus-data-set-pos (data pos)
  2838. `(setcar (nthcdr 2 ,data) ,pos))
  2839. (defmacro gnus-data-header (data)
  2840. `(nth 3 ,data))
  2841. (defmacro gnus-data-set-header (data header)
  2842. `(setf (nth 3 ,data) ,header))
  2843. (defmacro gnus-data-level (data)
  2844. `(nth 4 ,data))
  2845. (defmacro gnus-data-unread-p (data)
  2846. `(= (nth 1 ,data) gnus-unread-mark))
  2847. (defmacro gnus-data-read-p (data)
  2848. `(/= (nth 1 ,data) gnus-unread-mark))
  2849. (defmacro gnus-data-pseudo-p (data)
  2850. `(consp (nth 3 ,data)))
  2851. (defmacro gnus-data-find (number)
  2852. `(assq ,number gnus-newsgroup-data))
  2853. (defmacro gnus-data-find-list (number &optional data)
  2854. `(let ((bdata ,(or data 'gnus-newsgroup-data)))
  2855. (memq (assq ,number bdata)
  2856. bdata)))
  2857. (defmacro gnus-data-make (number mark pos header level)
  2858. `(list ,number ,mark ,pos ,header ,level))
  2859. (defun gnus-data-enter (after-article number mark pos header level offset)
  2860. (let ((data (gnus-data-find-list after-article)))
  2861. (unless data
  2862. (error "No such article: %d" after-article))
  2863. (setcdr data (cons (gnus-data-make number mark pos header level)
  2864. (cdr data)))
  2865. (setq gnus-newsgroup-data-reverse nil)
  2866. (gnus-data-update-list (cddr data) offset)))
  2867. (defun gnus-data-enter-list (after-article list &optional offset)
  2868. (when list
  2869. (let ((data (and after-article (gnus-data-find-list after-article)))
  2870. (ilist list))
  2871. (if (not (or data
  2872. after-article))
  2873. (let ((odata gnus-newsgroup-data))
  2874. (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
  2875. (when offset
  2876. (gnus-data-update-list odata offset)))
  2877. ;; Find the last element in the list to be spliced into the main
  2878. ;; list.
  2879. (setq list (last list))
  2880. (if (not data)
  2881. (progn
  2882. (setcdr list gnus-newsgroup-data)
  2883. (setq gnus-newsgroup-data ilist)
  2884. (when offset
  2885. (gnus-data-update-list (cdr list) offset)))
  2886. (setcdr list (cdr data))
  2887. (setcdr data ilist)
  2888. (when offset
  2889. (gnus-data-update-list (cdr list) offset))))
  2890. (setq gnus-newsgroup-data-reverse nil))))
  2891. (defun gnus-data-remove (article &optional offset)
  2892. (let ((data gnus-newsgroup-data))
  2893. (if (= (gnus-data-number (car data)) article)
  2894. (progn
  2895. (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
  2896. gnus-newsgroup-data-reverse nil)
  2897. (when offset
  2898. (gnus-data-update-list gnus-newsgroup-data offset)))
  2899. (while (cdr data)
  2900. (when (= (gnus-data-number (cadr data)) article)
  2901. (setcdr data (cddr data))
  2902. (when offset
  2903. (gnus-data-update-list (cdr data) offset))
  2904. (setq data nil
  2905. gnus-newsgroup-data-reverse nil))
  2906. (setq data (cdr data))))))
  2907. (defmacro gnus-data-list (backward)
  2908. `(if ,backward
  2909. (or gnus-newsgroup-data-reverse
  2910. (setq gnus-newsgroup-data-reverse
  2911. (reverse gnus-newsgroup-data)))
  2912. gnus-newsgroup-data))
  2913. (defun gnus-data-update-list (data offset)
  2914. "Add OFFSET to the POS of all data entries in DATA."
  2915. (setq gnus-newsgroup-data-reverse nil)
  2916. (while data
  2917. (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
  2918. (setq data (cdr data))))
  2919. (defun gnus-summary-article-pseudo-p (article)
  2920. "Say whether this article is a pseudo article or not."
  2921. (not (vectorp (gnus-data-header (gnus-data-find article)))))
  2922. (defmacro gnus-summary-article-sparse-p (article)
  2923. "Say whether this article is a sparse article or not."
  2924. `(memq ,article gnus-newsgroup-sparse))
  2925. (defmacro gnus-summary-article-ancient-p (article)
  2926. "Say whether this article is a sparse article or not."
  2927. `(memq ,article gnus-newsgroup-ancient))
  2928. (defun gnus-article-children (number)
  2929. "Return a list of all children to NUMBER."
  2930. (let* ((data (gnus-data-find-list number))
  2931. (level (gnus-data-level (car data)))
  2932. children)
  2933. (setq data (cdr data))
  2934. (while (and data
  2935. (= (gnus-data-level (car data)) (1+ level)))
  2936. (push (gnus-data-number (car data)) children)
  2937. (setq data (cdr data)))
  2938. children))
  2939. (defmacro gnus-summary-skip-intangible ()
  2940. "If the current article is intangible, then jump to a different article."
  2941. '(let ((to (get-text-property (point) 'gnus-intangible)))
  2942. (and to (gnus-summary-goto-subject to))))
  2943. (defmacro gnus-summary-article-intangible-p ()
  2944. "Say whether this article is intangible or not."
  2945. '(get-text-property (point) 'gnus-intangible))
  2946. ;; Some summary mode macros.
  2947. (defmacro gnus-summary-article-number ()
  2948. "The article number of the article on the current line.
  2949. If there isn't an article number here, then we return the current
  2950. article number."
  2951. '(progn
  2952. (gnus-summary-skip-intangible)
  2953. (or (get-text-property (point) 'gnus-number)
  2954. (gnus-summary-last-subject))))
  2955. (defmacro gnus-summary-article-header (&optional number)
  2956. "Return the header of article NUMBER."
  2957. `(gnus-data-header (gnus-data-find
  2958. ,(or number '(gnus-summary-article-number)))))
  2959. (defmacro gnus-summary-thread-level (&optional number)
  2960. "Return the level of thread that starts with article NUMBER."
  2961. `(if (and (eq gnus-summary-make-false-root 'dummy)
  2962. (get-text-property (point) 'gnus-intangible))
  2963. 0
  2964. (gnus-data-level (gnus-data-find
  2965. ,(or number '(gnus-summary-article-number))))))
  2966. (defmacro gnus-summary-article-mark (&optional number)
  2967. "Return the mark of article NUMBER."
  2968. `(gnus-data-mark (gnus-data-find
  2969. ,(or number '(gnus-summary-article-number)))))
  2970. (defmacro gnus-summary-article-pos (&optional number)
  2971. "Return the position of the line of article NUMBER."
  2972. `(gnus-data-pos (gnus-data-find
  2973. ,(or number '(gnus-summary-article-number)))))
  2974. (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
  2975. (defmacro gnus-summary-article-subject (&optional number)
  2976. "Return current subject string or nil if nothing."
  2977. `(let ((headers
  2978. ,(if number
  2979. `(gnus-data-header (assq ,number gnus-newsgroup-data))
  2980. '(gnus-data-header (assq (gnus-summary-article-number)
  2981. gnus-newsgroup-data)))))
  2982. (and headers
  2983. (vectorp headers)
  2984. (mail-header-subject headers))))
  2985. (defmacro gnus-summary-article-score (&optional number)
  2986. "Return current article score."
  2987. `(or (cdr (assq ,(or number '(gnus-summary-article-number))
  2988. gnus-newsgroup-scored))
  2989. gnus-summary-default-score 0))
  2990. (defun gnus-summary-article-children (&optional number)
  2991. "Return a list of article numbers that are children of article NUMBER."
  2992. (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
  2993. (level (gnus-data-level (car data)))
  2994. l children)
  2995. (while (and (setq data (cdr data))
  2996. (> (setq l (gnus-data-level (car data))) level))
  2997. (and (= (1+ level) l)
  2998. (push (gnus-data-number (car data))
  2999. children)))
  3000. (nreverse children)))
  3001. (defun gnus-summary-article-parent (&optional number)
  3002. "Return the article number of the parent of article NUMBER."
  3003. (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
  3004. (gnus-data-list t)))
  3005. (level (gnus-data-level (car data))))
  3006. (if (zerop level)
  3007. () ; This is a root.
  3008. ;; We search until we find an article with a level less than
  3009. ;; this one. That function has to be the parent.
  3010. (while (and (setq data (cdr data))
  3011. (not (< (gnus-data-level (car data)) level))))
  3012. (and data (gnus-data-number (car data))))))
  3013. (defun gnus-unread-mark-p (mark)
  3014. "Say whether MARK is the unread mark."
  3015. (= mark gnus-unread-mark))
  3016. (defun gnus-read-mark-p (mark)
  3017. "Say whether MARK is one of the marks that mark as read.
  3018. This is all marks except unread, ticked, dormant, and expirable."
  3019. (not (or (= mark gnus-unread-mark)
  3020. (= mark gnus-ticked-mark)
  3021. (= mark gnus-spam-mark)
  3022. (= mark gnus-dormant-mark)
  3023. (= mark gnus-expirable-mark))))
  3024. (defmacro gnus-article-mark (number)
  3025. "Return the MARK of article NUMBER.
  3026. This macro should only be used when computing the mark the \"first\"
  3027. time; i.e., when generating the summary lines. After that,
  3028. `gnus-summary-article-mark' should be used to examine the
  3029. marks of articles."
  3030. `(cond
  3031. ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
  3032. ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
  3033. ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
  3034. ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
  3035. ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
  3036. ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
  3037. ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
  3038. (t (or (cdr (assq ,number gnus-newsgroup-reads))
  3039. gnus-ancient-mark))))
  3040. ;; Saving hidden threads.
  3041. (defmacro gnus-save-hidden-threads (&rest forms)
  3042. "Save hidden threads, eval FORMS, and restore the hidden threads."
  3043. (let ((config (make-symbol "config")))
  3044. `(let ((,config (gnus-hidden-threads-configuration)))
  3045. (unwind-protect
  3046. (save-excursion
  3047. ,@forms)
  3048. (gnus-restore-hidden-threads-configuration ,config)))))
  3049. (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
  3050. (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
  3051. (defun gnus-data-compute-positions ()
  3052. "Compute the positions of all articles."
  3053. (setq gnus-newsgroup-data-reverse nil)
  3054. (let ((data gnus-newsgroup-data))
  3055. (save-excursion
  3056. (gnus-save-hidden-threads
  3057. (gnus-summary-show-all-threads)
  3058. (goto-char (point-min))
  3059. (while data
  3060. (while (get-text-property (point) 'gnus-intangible)
  3061. (forward-line 1))
  3062. (gnus-data-set-pos (car data) (+ (point) 3))
  3063. (setq data (cdr data))
  3064. (forward-line 1))))))
  3065. (defun gnus-hidden-threads-configuration ()
  3066. "Return the current hidden threads configuration."
  3067. (save-excursion
  3068. (let (config)
  3069. (goto-char (point-min))
  3070. (while (not (eobp))
  3071. (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
  3072. (push (save-excursion (forward-line 0) (point)) config))
  3073. (forward-line 1))
  3074. config)))
  3075. (defun gnus-restore-hidden-threads-configuration (config)
  3076. "Restore hidden threads configuration from CONFIG."
  3077. (save-excursion
  3078. (let (point (inhibit-read-only t))
  3079. (while (setq point (pop config))
  3080. (goto-char point)
  3081. (gnus-summary-hide-thread)))))
  3082. ;; Various summary mode internalish functions.
  3083. (defun gnus-mouse-pick-article (e)
  3084. (interactive "e")
  3085. (mouse-set-point e)
  3086. (gnus-summary-next-page nil t))
  3087. (defun gnus-summary-set-display-table ()
  3088. "Change the display table.
  3089. Odd characters have a tendency to mess
  3090. up nicely formatted displays - we make all possible glyphs
  3091. display only a single character."
  3092. ;; We start from the standard display table, if any.
  3093. (let ((table (or (copy-sequence standard-display-table)
  3094. (make-display-table)))
  3095. (i 32))
  3096. ;; Nix out all the control chars...
  3097. (while (>= (setq i (1- i)) 0)
  3098. (gnus-put-display-table i [??] table))
  3099. ;; ... but not newline and cr, of course. (cr is necessary for the
  3100. ;; selective display).
  3101. (gnus-put-display-table ?\n nil table)
  3102. (gnus-put-display-table ?\r nil table)
  3103. ;; We keep TAB as well.
  3104. (gnus-put-display-table ?\t nil table)
  3105. ;; We nix out any glyphs 127 through 255, or 127 through 159 in
  3106. ;; Emacs 23 (unicode), that are not set already.
  3107. (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
  3108. 160
  3109. 256)))
  3110. (while (>= (setq i (1- i)) 127)
  3111. ;; Only modify if the entry is nil.
  3112. (unless (gnus-get-display-table i table)
  3113. (gnus-put-display-table i [??] table))))
  3114. (setq buffer-display-table table)))
  3115. (defun gnus-summary-set-article-display-arrow (pos)
  3116. "Update the overlay arrow to point to line at position POS."
  3117. (when gnus-summary-display-arrow
  3118. (make-local-variable 'overlay-arrow-position)
  3119. (make-local-variable 'overlay-arrow-string)
  3120. (save-excursion
  3121. (goto-char pos)
  3122. (beginning-of-line)
  3123. (unless overlay-arrow-position
  3124. (setq overlay-arrow-position (make-marker)))
  3125. (setq overlay-arrow-string "=>"
  3126. overlay-arrow-position (set-marker overlay-arrow-position
  3127. (point)
  3128. (current-buffer))))))
  3129. (defun gnus-summary-setup-buffer (group)
  3130. "Initialize summary buffer.
  3131. If the setup was successful, non-nil is returned."
  3132. (let ((buffer (gnus-summary-buffer-name group))
  3133. (dead-name (concat "*Dead Summary "
  3134. (gnus-group-decoded-name group) "*")))
  3135. ;; If a dead summary buffer exists, we kill it.
  3136. (when (gnus-buffer-live-p dead-name)
  3137. (gnus-kill-buffer dead-name))
  3138. (if (get-buffer buffer)
  3139. (progn
  3140. (set-buffer buffer)
  3141. (setq gnus-summary-buffer (current-buffer))
  3142. (not gnus-newsgroup-prepared))
  3143. (set-buffer (gnus-get-buffer-create buffer))
  3144. (setq gnus-summary-buffer (current-buffer))
  3145. (gnus-summary-mode group)
  3146. (when (gnus-group-quit-config group)
  3147. (set (make-local-variable 'gnus-single-article-buffer) nil))
  3148. (make-local-variable 'gnus-article-buffer)
  3149. (make-local-variable 'gnus-article-current)
  3150. (make-local-variable 'gnus-original-article-buffer)
  3151. (setq gnus-newsgroup-name group)
  3152. ;; Set any local variables in the group parameters.
  3153. (gnus-summary-set-local-parameters gnus-newsgroup-name)
  3154. t)))
  3155. (defun gnus-set-global-variables ()
  3156. "Set the global equivalents of the buffer-local variables.
  3157. They are set to the latest values they had. These reflect the summary
  3158. buffer that was in action when the last article was fetched."
  3159. (when (derived-mode-p 'gnus-summary-mode)
  3160. (setq gnus-summary-buffer (current-buffer))
  3161. (let ((name gnus-newsgroup-name)
  3162. (marked gnus-newsgroup-marked)
  3163. (spam gnus-newsgroup-spam-marked)
  3164. (unread gnus-newsgroup-unreads)
  3165. (headers gnus-current-headers)
  3166. (data gnus-newsgroup-data)
  3167. (summary gnus-summary-buffer)
  3168. (article-buffer gnus-article-buffer)
  3169. (original gnus-original-article-buffer)
  3170. (gac gnus-article-current)
  3171. (reffed gnus-reffed-article-number)
  3172. (score-file gnus-current-score-file)
  3173. (default-charset gnus-newsgroup-charset)
  3174. vlist)
  3175. (let ((locals gnus-newsgroup-variables))
  3176. (while locals
  3177. (if (consp (car locals))
  3178. (push (eval (caar locals)) vlist)
  3179. (push (eval (car locals)) vlist))
  3180. (setq locals (cdr locals)))
  3181. (setq vlist (nreverse vlist)))
  3182. (with-temp-buffer
  3183. (setq gnus-newsgroup-name name
  3184. gnus-newsgroup-marked marked
  3185. gnus-newsgroup-spam-marked spam
  3186. gnus-newsgroup-unreads unread
  3187. gnus-current-headers headers
  3188. gnus-newsgroup-data data
  3189. gnus-article-current gac
  3190. gnus-summary-buffer summary
  3191. gnus-article-buffer article-buffer
  3192. gnus-original-article-buffer original
  3193. gnus-reffed-article-number reffed
  3194. gnus-current-score-file score-file
  3195. gnus-newsgroup-charset default-charset)
  3196. (let ((locals gnus-newsgroup-variables))
  3197. (while locals
  3198. (if (consp (car locals))
  3199. (set (caar locals) (pop vlist))
  3200. (set (car locals) (pop vlist)))
  3201. (setq locals (cdr locals))))))))
  3202. (defun gnus-summary-article-unread-p (article)
  3203. "Say whether ARTICLE is unread or not."
  3204. (memq article gnus-newsgroup-unreads))
  3205. (defun gnus-summary-first-article-p (&optional article)
  3206. "Return whether ARTICLE is the first article in the buffer."
  3207. (if (not (setq article (or article (gnus-summary-article-number))))
  3208. nil
  3209. (eq article (caar gnus-newsgroup-data))))
  3210. (defun gnus-summary-last-article-p (&optional article)
  3211. "Return whether ARTICLE is the last article in the buffer."
  3212. (if (not (setq article (or article (gnus-summary-article-number))))
  3213. ;; All non-existent numbers are the last article. :-)
  3214. t
  3215. (not (cdr (gnus-data-find-list article)))))
  3216. (defun gnus-make-thread-indent-array (&optional n)
  3217. (when (or n
  3218. (progn (setq n 200) nil)
  3219. (null gnus-thread-indent-array)
  3220. (/= gnus-thread-indent-level gnus-thread-indent-array-level))
  3221. (setq gnus-thread-indent-array (make-vector (1+ n) "")
  3222. gnus-thread-indent-array-level gnus-thread-indent-level)
  3223. (while (>= n 0)
  3224. (aset gnus-thread-indent-array n
  3225. (make-string (* n gnus-thread-indent-level) ? ))
  3226. (setq n (1- n)))))
  3227. (defun gnus-update-summary-mark-positions ()
  3228. "Compute where the summary marks are to go."
  3229. (save-excursion
  3230. (when (gnus-buffer-exists-p gnus-summary-buffer)
  3231. (set-buffer gnus-summary-buffer))
  3232. (let ((spec gnus-summary-line-format-spec)
  3233. pos)
  3234. (save-excursion
  3235. (gnus-set-work-buffer)
  3236. (let ((gnus-tmp-unread ?Z)
  3237. (gnus-replied-mark ?Z)
  3238. (gnus-score-below-mark ?Z)
  3239. (gnus-score-over-mark ?Z)
  3240. (gnus-undownloaded-mark ?Z)
  3241. (gnus-summary-line-format-spec spec)
  3242. (gnus-newsgroup-downloadable '(0))
  3243. (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
  3244. case-fold-search ignores)
  3245. ;; Here, all marks are bound to Z.
  3246. (gnus-summary-insert-line header
  3247. 0 nil t gnus-tmp-unread t nil "" nil 1)
  3248. (goto-char (point-min))
  3249. ;; Memorize the positions of the same characters as dummy marks.
  3250. (while (re-search-forward "[A-D]" nil t)
  3251. (push (point) ignores))
  3252. (erase-buffer)
  3253. ;; We use A-D as dummy marks in order to know column positions
  3254. ;; where marks should be inserted.
  3255. (setq gnus-tmp-unread ?A
  3256. gnus-replied-mark ?B
  3257. gnus-score-below-mark ?C
  3258. gnus-score-over-mark ?C
  3259. gnus-undownloaded-mark ?D)
  3260. (gnus-summary-insert-line header
  3261. 0 nil t gnus-tmp-unread t nil "" nil 1)
  3262. ;; Ignore characters which aren't dummy marks.
  3263. (dolist (p ignores)
  3264. (delete-region (goto-char (1- p)) p)
  3265. (insert ?Z))
  3266. (goto-char (point-min))
  3267. (setq pos (list (cons 'unread
  3268. (and (search-forward "A" nil t)
  3269. (- (point) (point-min) 1)))))
  3270. (goto-char (point-min))
  3271. (push (cons 'replied (and (search-forward "B" nil t)
  3272. (- (point) (point-min) 1)))
  3273. pos)
  3274. (goto-char (point-min))
  3275. (push (cons 'score (and (search-forward "C" nil t)
  3276. (- (point) (point-min) 1)))
  3277. pos)
  3278. (goto-char (point-min))
  3279. (push (cons 'download (and (search-forward "D" nil t)
  3280. (- (point) (point-min) 1)))
  3281. pos)))
  3282. (setq gnus-summary-mark-positions pos))))
  3283. (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
  3284. "Insert a dummy root in the summary buffer."
  3285. (beginning-of-line)
  3286. (gnus-add-text-properties
  3287. (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
  3288. (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
  3289. (defun gnus-summary-extract-address-component (from)
  3290. (or (car (funcall gnus-extract-address-components from))
  3291. from))
  3292. (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
  3293. (let ((mail-parse-charset gnus-newsgroup-charset)
  3294. (ignored-from-addresses (gnus-ignored-from-addresses))
  3295. ;; Is it really necessary to do this next part for each summary line?
  3296. ;; Luckily, doesn't seem to slow things down much.
  3297. (mail-parse-ignored-charsets
  3298. (with-current-buffer gnus-summary-buffer
  3299. gnus-newsgroup-ignored-charsets)))
  3300. (or
  3301. (and ignored-from-addresses
  3302. (string-match ignored-from-addresses gnus-tmp-from)
  3303. (let ((extra-headers (mail-header-extra header))
  3304. to
  3305. newsgroups)
  3306. (cond
  3307. ((setq to (cdr (assq 'To extra-headers)))
  3308. (concat gnus-summary-to-prefix
  3309. (inline
  3310. (gnus-summary-extract-address-component
  3311. (funcall gnus-decode-encoded-address-function to)))))
  3312. ((setq newsgroups
  3313. (or
  3314. (cdr (assq 'Newsgroups extra-headers))
  3315. (and
  3316. (memq 'Newsgroups gnus-extra-headers)
  3317. (eq (car (gnus-find-method-for-group
  3318. gnus-newsgroup-name)) 'nntp)
  3319. (gnus-group-real-name gnus-newsgroup-name))))
  3320. (concat gnus-summary-newsgroup-prefix newsgroups)))))
  3321. (gnus-string-mark-left-to-right
  3322. (inline
  3323. (gnus-summary-extract-address-component gnus-tmp-from))))))
  3324. (defun gnus-summary-insert-line (gnus-tmp-header
  3325. gnus-tmp-level gnus-tmp-current
  3326. undownloaded gnus-tmp-unread gnus-tmp-replied
  3327. gnus-tmp-expirable gnus-tmp-subject-or-nil
  3328. &optional gnus-tmp-dummy gnus-tmp-score
  3329. gnus-tmp-process)
  3330. (if (>= gnus-tmp-level (length gnus-thread-indent-array))
  3331. (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
  3332. gnus-tmp-level)))
  3333. (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
  3334. (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
  3335. (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
  3336. (gnus-tmp-score-char
  3337. (if (or (null gnus-summary-default-score)
  3338. (<= (abs (- gnus-tmp-score gnus-summary-default-score))
  3339. gnus-summary-zcore-fuzz))
  3340. ? ;Whitespace
  3341. (if (< gnus-tmp-score gnus-summary-default-score)
  3342. gnus-score-below-mark gnus-score-over-mark)))
  3343. (gnus-tmp-number (mail-header-number gnus-tmp-header))
  3344. (gnus-tmp-replied
  3345. (cond (gnus-tmp-process gnus-process-mark)
  3346. ((memq gnus-tmp-current gnus-newsgroup-cached)
  3347. gnus-cached-mark)
  3348. (gnus-tmp-replied gnus-replied-mark)
  3349. ((memq gnus-tmp-current gnus-newsgroup-forwarded)
  3350. gnus-forwarded-mark)
  3351. ((memq gnus-tmp-current gnus-newsgroup-saved)
  3352. gnus-saved-mark)
  3353. ((memq gnus-tmp-number gnus-newsgroup-unseen)
  3354. gnus-unseen-mark)
  3355. (t gnus-no-mark)))
  3356. (gnus-tmp-downloaded
  3357. (cond (undownloaded
  3358. gnus-undownloaded-mark)
  3359. (gnus-newsgroup-agentized
  3360. gnus-downloaded-mark)
  3361. (t
  3362. gnus-no-mark)))
  3363. (gnus-tmp-from (mail-header-from gnus-tmp-header))
  3364. (gnus-tmp-name
  3365. (cond
  3366. ((string-match "<[^>]+> *$" gnus-tmp-from)
  3367. (let ((beg (match-beginning 0)))
  3368. (or (and (string-match "^\".+\"" gnus-tmp-from)
  3369. (substring gnus-tmp-from 1 (1- (match-end 0))))
  3370. (substring gnus-tmp-from 0 beg))))
  3371. ((string-match "(.+)" gnus-tmp-from)
  3372. (substring gnus-tmp-from
  3373. (1+ (match-beginning 0)) (1- (match-end 0))))
  3374. (t gnus-tmp-from)))
  3375. (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
  3376. (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
  3377. (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
  3378. (inhibit-read-only t))
  3379. (when (string= gnus-tmp-name "")
  3380. (setq gnus-tmp-name gnus-tmp-from))
  3381. (unless (numberp gnus-tmp-lines)
  3382. (setq gnus-tmp-lines -1))
  3383. (if (= gnus-tmp-lines -1)
  3384. (setq gnus-tmp-lines "?")
  3385. (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
  3386. (condition-case ()
  3387. (gnus-put-text-property
  3388. (point)
  3389. (progn (eval gnus-summary-line-format-spec) (point))
  3390. 'gnus-number gnus-tmp-number)
  3391. (error (gnus-message 5 "Error updating the summary line")))
  3392. (when (gnus-visual-p 'summary-highlight 'highlight)
  3393. (forward-line -1)
  3394. (gnus-summary-highlight-line)
  3395. (gnus-run-hooks 'gnus-summary-update-hook)
  3396. (forward-line 1))))
  3397. (defun gnus-summary-update-line (&optional dont-update)
  3398. "Update summary line after change."
  3399. (when (and gnus-summary-default-score
  3400. (not gnus-summary-inhibit-highlight))
  3401. (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
  3402. (article (gnus-summary-article-number))
  3403. (score (gnus-summary-article-score article)))
  3404. (unless dont-update
  3405. (if (and gnus-summary-mark-below
  3406. (< (gnus-summary-article-score)
  3407. gnus-summary-mark-below))
  3408. ;; This article has a low score, so we mark it as read.
  3409. (when (memq article gnus-newsgroup-unreads)
  3410. (gnus-summary-mark-article-as-read gnus-low-score-mark))
  3411. (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
  3412. ;; This article was previously marked as read on account
  3413. ;; of a low score, but now it has risen, so we mark it as
  3414. ;; unread.
  3415. (gnus-summary-mark-article-as-unread gnus-unread-mark)))
  3416. (gnus-summary-update-mark
  3417. (if (or (null gnus-summary-default-score)
  3418. (<= (abs (- score gnus-summary-default-score))
  3419. gnus-summary-zcore-fuzz))
  3420. ? ;Whitespace
  3421. (if (< score gnus-summary-default-score)
  3422. gnus-score-below-mark gnus-score-over-mark))
  3423. 'score))
  3424. ;; Do visual highlighting.
  3425. (when (gnus-visual-p 'summary-highlight 'highlight)
  3426. (gnus-summary-highlight-line)
  3427. (gnus-run-hooks 'gnus-summary-update-hook)))))
  3428. (defvar gnus-tmp-new-adopts nil)
  3429. (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
  3430. "Return the number of articles in THREAD.
  3431. This may be 0 in some cases -- if none of the articles in
  3432. the thread are to be displayed."
  3433. (let* ((number
  3434. ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
  3435. (cond
  3436. ((not (listp thread))
  3437. 1)
  3438. ((and (consp thread) (cdr thread))
  3439. (apply
  3440. '+ 1 (mapcar
  3441. 'gnus-summary-number-of-articles-in-thread (cdr thread))))
  3442. ((null thread)
  3443. 1)
  3444. ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
  3445. 1)
  3446. (t 0))))
  3447. (when (and level (zerop level) gnus-tmp-new-adopts)
  3448. (incf number
  3449. (apply '+ (mapcar
  3450. 'gnus-summary-number-of-articles-in-thread
  3451. gnus-tmp-new-adopts))))
  3452. (if char
  3453. (if (> number 1) gnus-not-empty-thread-mark
  3454. gnus-empty-thread-mark)
  3455. number)))
  3456. (defsubst gnus-summary-line-message-size (head)
  3457. "Return pretty-printed version of message size.
  3458. This function is intended to be used in
  3459. `gnus-summary-line-format-alist'."
  3460. (let ((c (or (mail-header-chars head) -1)))
  3461. (cond ((< c 0) "n/a") ; chars not available
  3462. ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
  3463. ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
  3464. ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
  3465. (t (format "%dM" (/ c (* 1024.0 1024)))))))
  3466. (defcustom gnus-user-date-format-alist
  3467. '(((gnus-seconds-today) . "Today, %H:%M")
  3468. ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
  3469. (604800 . "%A %H:%M") ; That's one week
  3470. ((gnus-seconds-month) . "%A %d")
  3471. ((gnus-seconds-year) . "%B %d")
  3472. (t . "%b %d %Y")) ; This one is used when no other
  3473. ; does match
  3474. "Specifies date format depending on age of article.
  3475. This is an alist of items (AGE . FORMAT). AGE can be a number (of
  3476. seconds) or a Lisp expression evaluating to a number. When the age of
  3477. the article is less than this number, then use `format-time-string'
  3478. with the corresponding FORMAT for displaying the date of the article.
  3479. If AGE is not a number or a Lisp expression evaluating to a
  3480. non-number, then the corresponding FORMAT is used as a default value.
  3481. Note that the list is processed from the beginning, so it should be
  3482. sorted by ascending AGE. Also note that items following the first
  3483. non-number AGE will be ignored.
  3484. You can use the functions `gnus-seconds-today', `gnus-seconds-month'
  3485. and `gnus-seconds-year' in the AGE spec. They return the number of
  3486. seconds passed since the start of today, of this month, of this year,
  3487. respectively."
  3488. :version "24.1"
  3489. :group 'gnus-summary-format
  3490. :type '(alist :key-type sexp :value-type string))
  3491. (defun gnus-user-date (messy-date)
  3492. "Format the messy-date according to `gnus-user-date-format-alist'.
  3493. Returns \" ? \" if there's bad input or if another error occurs.
  3494. Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
  3495. (condition-case ()
  3496. (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
  3497. (now (gnus-float-time))
  3498. ;;If we don't find something suitable we'll use this one
  3499. (my-format "%b %d '%y"))
  3500. (let* ((difference (- now messy-date))
  3501. (templist gnus-user-date-format-alist)
  3502. (top (eval (caar templist))))
  3503. (while (if (numberp top) (< top difference) (not top))
  3504. (progn
  3505. (setq templist (cdr templist))
  3506. (setq top (eval (caar templist)))))
  3507. (if (stringp (cdr (car templist)))
  3508. (setq my-format (cdr (car templist)))))
  3509. (format-time-string (eval my-format) (seconds-to-time messy-date)))
  3510. (error " ? ")))
  3511. (defun gnus-summary-set-local-parameters (group)
  3512. "Go through the local params of GROUP and set all variable specs in that list."
  3513. (let ((vars '(quit-config active))) ; Ignore things that aren't
  3514. ; really variables.
  3515. (dolist (elem (gnus-group-find-parameter group))
  3516. (and (consp elem) ; Has to be a cons.
  3517. (consp (cdr elem)) ; The cdr has to be a list.
  3518. (symbolp (car elem)) ; Has to be a symbol in there.
  3519. (not (memq (car elem) vars))
  3520. (ignore-errors
  3521. (push (car elem) vars)
  3522. ;; Variables like `gnus-show-threads' that are globally
  3523. ;; bound, if used as group parameters, need to get to be
  3524. ;; buffer-local, whereas just parameters like `gcc-self',
  3525. ;; `timestamp', etc. should not be bound as variables.
  3526. (if (boundp (car elem))
  3527. (set (make-local-variable (car elem)) (eval (nth 1 elem)))
  3528. (eval (nth 1 elem))))))))
  3529. (defun gnus-summary-read-group (group &optional show-all no-article
  3530. kill-buffer no-display backward
  3531. select-articles)
  3532. "Start reading news in newsgroup GROUP.
  3533. If SHOW-ALL is non-nil, already read articles are also listed.
  3534. If NO-ARTICLE is non-nil, no article is selected initially.
  3535. If NO-DISPLAY, don't generate the summary buffer contents.
  3536. If KILL-BUFFER, it should be a buffer that's killed once the new
  3537. summary buffer has been generated.
  3538. If BACKWARD, move point to the previous group in the group buffer
  3539. If SELECT-ARTICLES, only select those articles from GROUP."
  3540. (let (result)
  3541. (while (and group
  3542. (null (setq result
  3543. (let ((gnus-auto-select-next nil))
  3544. (or (gnus-summary-read-group-1
  3545. group show-all no-article
  3546. kill-buffer no-display
  3547. select-articles)
  3548. (setq show-all nil
  3549. select-articles nil)))))
  3550. (eq gnus-auto-select-next 'quietly))
  3551. (set-buffer gnus-group-buffer)
  3552. ;; The entry function called above goes to the next
  3553. ;; group automatically, so we go two groups back
  3554. ;; if we are searching for the previous group.
  3555. (when backward
  3556. (gnus-group-prev-unread-group 2))
  3557. (if (not (equal group (gnus-group-group-name)))
  3558. (setq group (gnus-group-group-name))
  3559. (setq group nil)))
  3560. result))
  3561. (defun gnus-summary-read-group-1 (group show-all no-article
  3562. kill-buffer no-display
  3563. &optional select-articles)
  3564. ;; Killed foreign groups can't be entered.
  3565. ;; (when (and (not (gnus-group-native-p group))
  3566. ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
  3567. ;; (error "Dead non-native groups can't be entered"))
  3568. (gnus-message 7 "Retrieving newsgroup: %s..."
  3569. (gnus-group-decoded-name group))
  3570. (let* ((new-group (gnus-summary-setup-buffer group))
  3571. (quit-config (gnus-group-quit-config group))
  3572. (did-select (and new-group (gnus-select-newsgroup
  3573. group show-all select-articles))))
  3574. (cond
  3575. ;; This summary buffer exists already, so we just select it.
  3576. ((not new-group)
  3577. (gnus-set-global-variables)
  3578. (when kill-buffer
  3579. (gnus-kill-or-deaden-summary kill-buffer))
  3580. (gnus-configure-windows 'summary 'force)
  3581. (gnus-set-mode-line 'summary)
  3582. (gnus-summary-position-point)
  3583. (message "")
  3584. t)
  3585. ;; We couldn't select this group.
  3586. ((null did-select)
  3587. (when (and (derived-mode-p 'gnus-summary-mode)
  3588. (not (equal (current-buffer) kill-buffer)))
  3589. (kill-buffer (current-buffer))
  3590. (if (not quit-config)
  3591. (progn
  3592. ;; Update the info -- marks might need to be removed,
  3593. ;; for instance.
  3594. (gnus-summary-update-info)
  3595. (set-buffer gnus-group-buffer)
  3596. (gnus-group-jump-to-group group)
  3597. (gnus-group-next-unread-group 1))
  3598. (gnus-handle-ephemeral-exit quit-config)))
  3599. (if (null (gnus-list-of-unread-articles group))
  3600. (gnus-message 3 "Group %s contains no messages" group)
  3601. (gnus-message 3 "Can't select group"))
  3602. nil)
  3603. ;; The user did a `C-g' while prompting for number of articles,
  3604. ;; so we exit this group.
  3605. ((eq did-select 'quit)
  3606. (and (derived-mode-p 'gnus-summary-mode)
  3607. (not (equal (current-buffer) kill-buffer))
  3608. (kill-buffer (current-buffer)))
  3609. (when kill-buffer
  3610. (gnus-kill-or-deaden-summary kill-buffer))
  3611. (if (not quit-config)
  3612. (progn
  3613. (set-buffer gnus-group-buffer)
  3614. (gnus-group-jump-to-group group)
  3615. (gnus-configure-windows 'group 'force))
  3616. (gnus-handle-ephemeral-exit quit-config))
  3617. ;; Finally signal the quit.
  3618. (signal 'quit nil))
  3619. ;; The group was successfully selected.
  3620. (t
  3621. (gnus-set-global-variables)
  3622. (when (boundp 'spam-install-hooks)
  3623. (spam-initialize))
  3624. ;; Save the active value in effect when the group was entered.
  3625. (setq gnus-newsgroup-active
  3626. (gnus-copy-sequence
  3627. (gnus-active gnus-newsgroup-name)))
  3628. (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
  3629. ;; You can change the summary buffer in some way with this hook.
  3630. (gnus-run-hooks 'gnus-select-group-hook)
  3631. (when (memq 'summary (gnus-update-format-specifications
  3632. nil 'summary 'summary-mode 'summary-dummy))
  3633. ;; The format specification for the summary line was updated,
  3634. ;; so we need to update the mark positions as well.
  3635. (gnus-update-summary-mark-positions))
  3636. ;; Do score processing.
  3637. (when gnus-use-scoring
  3638. (gnus-possibly-score-headers))
  3639. ;; Check whether to fill in the gaps in the threads.
  3640. (when gnus-build-sparse-threads
  3641. (gnus-build-sparse-threads))
  3642. ;; Find the initial limit.
  3643. (if show-all
  3644. (let ((gnus-newsgroup-dormant nil))
  3645. (gnus-summary-initial-limit show-all))
  3646. (gnus-summary-initial-limit show-all))
  3647. ;; Generate the summary buffer.
  3648. (unless no-display
  3649. (gnus-summary-prepare))
  3650. (when gnus-use-trees
  3651. (gnus-tree-open)
  3652. (setq gnus-summary-highlight-line-function
  3653. 'gnus-tree-highlight-article))
  3654. ;; If the summary buffer is empty, but there are some low-scored
  3655. ;; articles or some excluded dormants, we include these in the
  3656. ;; buffer.
  3657. (when (and (zerop (buffer-size))
  3658. (not no-display))
  3659. (cond (gnus-newsgroup-dormant
  3660. (gnus-summary-limit-include-dormant))
  3661. ((and gnus-newsgroup-scored show-all)
  3662. (gnus-summary-limit-include-expunged t))))
  3663. ;; Function `gnus-apply-kill-file' must be called in this hook.
  3664. (gnus-run-hooks 'gnus-apply-kill-hook)
  3665. (if (and (zerop (buffer-size))
  3666. (not no-display))
  3667. (progn
  3668. ;; This newsgroup is empty.
  3669. (gnus-summary-catchup-and-exit nil t)
  3670. (gnus-message 6 "No unread news")
  3671. (when kill-buffer
  3672. (gnus-kill-or-deaden-summary kill-buffer))
  3673. ;; Return nil from this function.
  3674. nil)
  3675. ;; Hide conversation thread subtrees. We cannot do this in
  3676. ;; gnus-summary-prepare-hook since kill processing may not
  3677. ;; work with hidden articles.
  3678. (gnus-summary-maybe-hide-threads)
  3679. (gnus-configure-windows 'summary)
  3680. (when kill-buffer
  3681. (gnus-kill-or-deaden-summary kill-buffer))
  3682. (gnus-summary-auto-select-subject)
  3683. ;; Show first unread article if requested.
  3684. (if (and (not no-article)
  3685. (not no-display)
  3686. gnus-newsgroup-unreads
  3687. gnus-auto-select-first)
  3688. (progn
  3689. (let ((art (gnus-summary-article-number)))
  3690. (when (and art
  3691. gnus-plugged
  3692. (not (memq art gnus-newsgroup-undownloaded))
  3693. (not (memq art gnus-newsgroup-downloadable)))
  3694. (gnus-summary-goto-article art))))
  3695. ;; Don't select any articles.
  3696. (gnus-summary-position-point)
  3697. (gnus-configure-windows 'summary 'force)
  3698. (gnus-set-mode-line 'summary))
  3699. (when (and gnus-auto-center-group
  3700. (get-buffer-window gnus-group-buffer t))
  3701. ;; Gotta use windows, because recenter does weird stuff if
  3702. ;; the current buffer ain't the displayed window.
  3703. (let ((owin (selected-window)))
  3704. (select-window (get-buffer-window gnus-group-buffer t))
  3705. (when (gnus-group-goto-group group)
  3706. (recenter))
  3707. (select-window owin)))
  3708. ;; Mark this buffer as "prepared".
  3709. (setq gnus-newsgroup-prepared t)
  3710. (gnus-run-hooks 'gnus-summary-prepared-hook)
  3711. (unless (gnus-ephemeral-group-p group)
  3712. (gnus-group-update-group group nil t))
  3713. t)))))
  3714. (defun gnus-summary-auto-select-subject ()
  3715. "Select the subject line on initial group entry."
  3716. (goto-char (point-min))
  3717. (cond
  3718. ((eq gnus-auto-select-subject 'best)
  3719. (gnus-summary-best-unread-subject))
  3720. ((eq gnus-auto-select-subject 'unread)
  3721. (gnus-summary-first-unread-subject))
  3722. ((eq gnus-auto-select-subject 'unseen)
  3723. (gnus-summary-first-unseen-subject))
  3724. ((eq gnus-auto-select-subject 'unseen-or-unread)
  3725. (gnus-summary-first-unseen-or-unread-subject))
  3726. ((eq gnus-auto-select-subject 'first)
  3727. ;; Do nothing.
  3728. )
  3729. ((functionp gnus-auto-select-subject)
  3730. (funcall gnus-auto-select-subject))))
  3731. (defun gnus-summary-prepare ()
  3732. "Generate the summary buffer."
  3733. (interactive)
  3734. (let ((inhibit-read-only t))
  3735. (erase-buffer)
  3736. (setq gnus-newsgroup-data nil
  3737. gnus-newsgroup-data-reverse nil)
  3738. (gnus-run-hooks 'gnus-summary-generate-hook)
  3739. ;; Generate the buffer, either with threads or without.
  3740. (when gnus-newsgroup-headers
  3741. (gnus-summary-prepare-threads
  3742. (if gnus-show-threads
  3743. (gnus-sort-gathered-threads
  3744. (funcall gnus-summary-thread-gathering-function
  3745. (gnus-sort-threads
  3746. (gnus-cut-threads (gnus-make-threads)))))
  3747. ;; Unthreaded display.
  3748. (gnus-sort-articles gnus-newsgroup-headers))))
  3749. (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
  3750. ;; Call hooks for modifying summary buffer.
  3751. (goto-char (point-min))
  3752. (gnus-run-hooks 'gnus-summary-prepare-hook)))
  3753. (defsubst gnus-general-simplify-subject (subject)
  3754. "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
  3755. (setq subject
  3756. (cond
  3757. ;; Truncate the subject.
  3758. (gnus-simplify-subject-functions
  3759. (gnus-map-function gnus-simplify-subject-functions subject))
  3760. ((numberp gnus-summary-gather-subject-limit)
  3761. (setq subject (gnus-simplify-subject-re subject))
  3762. (if (> (length subject) gnus-summary-gather-subject-limit)
  3763. (substring subject 0 gnus-summary-gather-subject-limit)
  3764. subject))
  3765. ;; Fuzzily simplify it.
  3766. ((eq 'fuzzy gnus-summary-gather-subject-limit)
  3767. (gnus-simplify-subject-fuzzy subject))
  3768. ;; Just remove the leading "Re:".
  3769. (t
  3770. (gnus-simplify-subject-re subject))))
  3771. (if (and gnus-summary-gather-exclude-subject
  3772. (string-match gnus-summary-gather-exclude-subject subject))
  3773. nil ; This article shouldn't be gathered
  3774. subject))
  3775. (defun gnus-summary-simplify-subject-query ()
  3776. "Query where the respool algorithm would put this article."
  3777. (interactive)
  3778. (gnus-summary-select-article)
  3779. (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
  3780. (defun gnus-gather-threads-by-subject (threads)
  3781. "Gather threads by looking at Subject headers."
  3782. (if (not gnus-summary-make-false-root)
  3783. threads
  3784. (let ((hashtb (gnus-make-hashtable 1024))
  3785. (prev threads)
  3786. (result threads)
  3787. subject hthread whole-subject)
  3788. (while threads
  3789. (setq subject (gnus-general-simplify-subject
  3790. (setq whole-subject (mail-header-subject
  3791. (caar threads)))))
  3792. (when subject
  3793. (if (setq hthread (gnus-gethash subject hashtb))
  3794. (progn
  3795. ;; We enter a dummy root into the thread, if we
  3796. ;; haven't done that already.
  3797. (unless (stringp (caar hthread))
  3798. (setcar hthread (list whole-subject (car hthread))))
  3799. ;; We add this new gathered thread to this gathered
  3800. ;; thread.
  3801. (setcdr (car hthread)
  3802. (nconc (cdar hthread) (list (car threads))))
  3803. ;; Remove it from the list of threads.
  3804. (setcdr prev (cdr threads))
  3805. (setq threads prev))
  3806. ;; Enter this thread into the hash table.
  3807. (gnus-sethash subject
  3808. (if gnus-summary-make-false-root-always
  3809. (progn
  3810. ;; If you want a dummy root above all
  3811. ;; threads...
  3812. (setcar threads (list whole-subject
  3813. (car threads)))
  3814. threads)
  3815. threads)
  3816. hashtb)))
  3817. (setq prev threads)
  3818. (setq threads (cdr threads)))
  3819. result)))
  3820. (defun gnus-gather-threads-by-references (threads)
  3821. "Gather threads by looking at References headers."
  3822. (let ((idhashtb (gnus-make-hashtable 1024))
  3823. (thhashtb (gnus-make-hashtable 1024))
  3824. (prev threads)
  3825. (result threads)
  3826. ids references id gthread gid entered ref)
  3827. (while threads
  3828. (when (setq references (mail-header-references (caar threads)))
  3829. (setq id (mail-header-id (caar threads))
  3830. ids (inline (gnus-split-references references))
  3831. entered nil)
  3832. (while (setq ref (pop ids))
  3833. (setq ids (delete ref ids))
  3834. (if (not (setq gid (gnus-gethash ref idhashtb)))
  3835. (progn
  3836. (gnus-sethash ref id idhashtb)
  3837. (gnus-sethash id threads thhashtb))
  3838. (setq gthread (gnus-gethash gid thhashtb))
  3839. (unless entered
  3840. ;; We enter a dummy root into the thread, if we
  3841. ;; haven't done that already.
  3842. (unless (stringp (caar gthread))
  3843. (setcar gthread (list (mail-header-subject (caar gthread))
  3844. (car gthread))))
  3845. ;; We add this new gathered thread to this gathered
  3846. ;; thread.
  3847. (setcdr (car gthread)
  3848. (nconc (cdar gthread) (list (car threads)))))
  3849. ;; Add it into the thread hash table.
  3850. (gnus-sethash id gthread thhashtb)
  3851. (setq entered t)
  3852. ;; Remove it from the list of threads.
  3853. (setcdr prev (cdr threads))
  3854. (setq threads prev))))
  3855. (setq prev threads)
  3856. (setq threads (cdr threads)))
  3857. result))
  3858. (defun gnus-sort-gathered-threads (threads)
  3859. "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
  3860. (let ((result threads))
  3861. (while threads
  3862. (when (stringp (caar threads))
  3863. (setcdr (car threads)
  3864. (sort (cdar threads) gnus-sort-gathered-threads-function)))
  3865. (setq threads (cdr threads)))
  3866. result))
  3867. (defun gnus-thread-loop-p (root thread)
  3868. "Say whether ROOT is in THREAD."
  3869. (let ((stack (list thread))
  3870. (infloop 0)
  3871. th)
  3872. (while (setq thread (pop stack))
  3873. (setq th (cdr thread))
  3874. (while (and th
  3875. (not (eq (caar th) root)))
  3876. (pop th))
  3877. (if th
  3878. ;; We have found a loop.
  3879. (let (ref-dep)
  3880. (setcdr thread (delq (car th) (cdr thread)))
  3881. (if (boundp (setq ref-dep (intern "none"
  3882. gnus-newsgroup-dependencies)))
  3883. (setcdr (symbol-value ref-dep)
  3884. (nconc (cdr (symbol-value ref-dep))
  3885. (list (car th))))
  3886. (set ref-dep (list nil (car th))))
  3887. (setq infloop 1
  3888. stack nil))
  3889. ;; Push all the subthreads onto the stack.
  3890. (push (cdr thread) stack)))
  3891. infloop))
  3892. (defun gnus-make-threads ()
  3893. "Go through the dependency hashtb and find the roots. Return all threads."
  3894. (let (threads)
  3895. (while (catch 'infloop
  3896. (mapatoms
  3897. (lambda (refs)
  3898. ;; Deal with self-referencing References loops.
  3899. (when (and (car (symbol-value refs))
  3900. (not (zerop
  3901. (apply
  3902. '+
  3903. (mapcar
  3904. (lambda (thread)
  3905. (gnus-thread-loop-p
  3906. (car (symbol-value refs)) thread))
  3907. (cdr (symbol-value refs)))))))
  3908. (setq threads nil)
  3909. (throw 'infloop t))
  3910. (unless (car (symbol-value refs))
  3911. ;; These threads do not refer back to any other
  3912. ;; articles, so they're roots.
  3913. (setq threads (append (cdr (symbol-value refs)) threads))))
  3914. gnus-newsgroup-dependencies)))
  3915. threads))
  3916. ;; Build the thread tree.
  3917. (defsubst gnus-dependencies-add-header (header dependencies force-new)
  3918. "Enter HEADER into the DEPENDENCIES table if it is not already there.
  3919. If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
  3920. if it was already present.
  3921. If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
  3922. will not be entered in the DEPENDENCIES table. Otherwise duplicate
  3923. Message-IDs will be renamed to a unique Message-ID before being
  3924. entered.
  3925. Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
  3926. (let* ((id (mail-header-id header))
  3927. (id-dep (and id (intern id dependencies)))
  3928. parent-id ref ref-dep ref-header replaced)
  3929. ;; Enter this `header' in the `dependencies' table.
  3930. (cond
  3931. ((not id-dep)
  3932. (setq header nil))
  3933. ;; The first two cases do the normal part: enter a new `header'
  3934. ;; in the `dependencies' table.
  3935. ((not (boundp id-dep))
  3936. (set id-dep (list header)))
  3937. ((null (car (symbol-value id-dep)))
  3938. (setcar (symbol-value id-dep) header))
  3939. ;; From here the `header' was already present in the
  3940. ;; `dependencies' table.
  3941. (force-new
  3942. ;; Overrides an existing entry;
  3943. ;; just set the header part of the entry.
  3944. (setcar (symbol-value id-dep) header)
  3945. (setq replaced t))
  3946. ;; Renames the existing `header' to a unique Message-ID.
  3947. ((not gnus-summary-ignore-duplicates)
  3948. ;; An article with this Message-ID has already been seen.
  3949. ;; We rename the Message-ID.
  3950. (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
  3951. (list header))
  3952. (mail-header-set-id header id))
  3953. ;; The last case ignores an existing entry, except it adds any
  3954. ;; additional Xrefs (in case the two articles came from different
  3955. ;; servers.
  3956. ;; Also sets `header' to nil meaning that the `dependencies'
  3957. ;; table was *not* modified.
  3958. (t
  3959. (mail-header-set-xref
  3960. (car (symbol-value id-dep))
  3961. (concat (or (mail-header-xref (car (symbol-value id-dep)))
  3962. "")
  3963. (or (mail-header-xref header) "")))
  3964. (setq header nil)))
  3965. (when (and header (not replaced))
  3966. ;; First check that we are not creating a References loop.
  3967. (setq parent-id (gnus-parent-id (mail-header-references header)))
  3968. (setq ref parent-id)
  3969. (while (and ref
  3970. (setq ref-dep (intern-soft ref dependencies))
  3971. (boundp ref-dep)
  3972. (setq ref-header (car (symbol-value ref-dep))))
  3973. (if (string= id ref)
  3974. ;; Yuk! This is a reference loop. Make the article be a
  3975. ;; root article.
  3976. (progn
  3977. (mail-header-set-references (car (symbol-value id-dep)) "none")
  3978. (setq ref nil)
  3979. (setq parent-id nil))
  3980. (setq ref (gnus-parent-id (mail-header-references ref-header)))))
  3981. (setq ref-dep (intern (or parent-id "none") dependencies))
  3982. (if (boundp ref-dep)
  3983. (setcdr (symbol-value ref-dep)
  3984. (nconc (cdr (symbol-value ref-dep))
  3985. (list (symbol-value id-dep))))
  3986. (set ref-dep (list nil (symbol-value id-dep)))))
  3987. header))
  3988. (defun gnus-extract-message-id-from-in-reply-to (string)
  3989. (if (string-match "<[^>]+>" string)
  3990. (substring string (match-beginning 0) (match-end 0))
  3991. nil))
  3992. (defun gnus-build-sparse-threads ()
  3993. (let ((headers gnus-newsgroup-headers)
  3994. (mail-parse-charset gnus-newsgroup-charset)
  3995. (gnus-summary-ignore-duplicates t)
  3996. header references generation relations
  3997. subject child end new-child date)
  3998. ;; First we create an alist of generations/relations, where
  3999. ;; generations is how much we trust the relation, and the relation
  4000. ;; is parent/child.
  4001. (gnus-message 7 "Making sparse threads...")
  4002. (save-excursion
  4003. (nnheader-set-temp-buffer " *gnus sparse threads*")
  4004. (while (setq header (pop headers))
  4005. (when (and (setq references (mail-header-references header))
  4006. (not (string= references "")))
  4007. (insert references)
  4008. (setq child (mail-header-id header)
  4009. subject (mail-header-subject header)
  4010. date (mail-header-date header)
  4011. generation 0)
  4012. (while (search-backward ">" nil t)
  4013. (setq end (1+ (point)))
  4014. (when (search-backward "<" nil t)
  4015. (setq new-child (buffer-substring (point) end))
  4016. (push (list (incf generation)
  4017. child (setq child new-child)
  4018. subject date)
  4019. relations)))
  4020. (when child
  4021. (push (list (1+ generation) child nil subject) relations))
  4022. (erase-buffer)))
  4023. (kill-buffer (current-buffer)))
  4024. ;; Sort over trustworthiness.
  4025. (dolist (relation (sort relations 'car-less-than-car))
  4026. (when (gnus-dependencies-add-header
  4027. (make-full-mail-header
  4028. gnus-reffed-article-number
  4029. (nth 3 relation) "" (or (nth 4 relation) "")
  4030. (nth 1 relation)
  4031. (or (nth 2 relation) "") 0 0 "")
  4032. gnus-newsgroup-dependencies nil)
  4033. (push gnus-reffed-article-number gnus-newsgroup-limit)
  4034. (push gnus-reffed-article-number gnus-newsgroup-sparse)
  4035. (push (cons gnus-reffed-article-number gnus-sparse-mark)
  4036. gnus-newsgroup-reads)
  4037. (decf gnus-reffed-article-number)))
  4038. (gnus-message 7 "Making sparse threads...done")))
  4039. (defun gnus-build-old-threads ()
  4040. ;; Look at all the articles that refer back to old articles, and
  4041. ;; fetch the headers for the articles that aren't there. This will
  4042. ;; build complete threads - if the roots haven't been expired by the
  4043. ;; server, that is.
  4044. (let ((mail-parse-charset gnus-newsgroup-charset)
  4045. id heads)
  4046. (mapatoms
  4047. (lambda (refs)
  4048. (when (not (car (symbol-value refs)))
  4049. (setq heads (cdr (symbol-value refs)))
  4050. (while heads
  4051. (if (memq (mail-header-number (caar heads))
  4052. gnus-newsgroup-dormant)
  4053. (setq heads (cdr heads))
  4054. (setq id (symbol-name refs))
  4055. (while (and (setq id (gnus-build-get-header id))
  4056. (not (car (gnus-id-to-thread id)))))
  4057. (setq heads nil)))))
  4058. gnus-newsgroup-dependencies)))
  4059. (defsubst gnus-remove-odd-characters (string)
  4060. "Translate STRING into something that doesn't contain weird characters."
  4061. (mm-subst-char-in-string
  4062. ?\r ?\-
  4063. (mm-subst-char-in-string ?\n ?\- string t) t))
  4064. ;; This function has to be called with point after the article number
  4065. ;; on the beginning of the line.
  4066. (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
  4067. (let ((eol (point-at-eol))
  4068. (buffer (current-buffer))
  4069. header references in-reply-to)
  4070. ;; overview: [num subject from date id refs chars lines misc]
  4071. (unwind-protect
  4072. (let (x)
  4073. (narrow-to-region (point) eol)
  4074. (unless (eobp)
  4075. (forward-char))
  4076. (setq header
  4077. (make-full-mail-header
  4078. number ; number
  4079. (condition-case () ; subject
  4080. (gnus-remove-odd-characters
  4081. (funcall gnus-decode-encoded-word-function
  4082. (setq x (nnheader-nov-field))))
  4083. (error x))
  4084. (condition-case () ; from
  4085. (gnus-remove-odd-characters
  4086. (funcall gnus-decode-encoded-address-function
  4087. (setq x (nnheader-nov-field))))
  4088. (error x))
  4089. (nnheader-nov-field) ; date
  4090. (nnheader-nov-read-message-id number) ; id
  4091. (setq references (nnheader-nov-field)) ; refs
  4092. (nnheader-nov-read-integer) ; chars
  4093. (nnheader-nov-read-integer) ; lines
  4094. (unless (eobp)
  4095. (if (looking-at "Xref: ")
  4096. (goto-char (match-end 0)))
  4097. (nnheader-nov-field)) ; Xref
  4098. (nnheader-nov-parse-extra)))) ; extra
  4099. (widen))
  4100. (when (and (string= references "")
  4101. (setq in-reply-to (mail-header-extra header))
  4102. (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
  4103. (mail-header-set-references
  4104. header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
  4105. (when gnus-alter-header-function
  4106. (funcall gnus-alter-header-function header))
  4107. (gnus-dependencies-add-header header dependencies force-new)))
  4108. (defun gnus-build-get-header (id)
  4109. "Look through the buffer of NOV lines and find the header to ID.
  4110. Enter this line into the dependencies hash table, and return
  4111. the id of the parent article (if any)."
  4112. (let ((deps gnus-newsgroup-dependencies)
  4113. found header)
  4114. (prog1
  4115. (with-current-buffer nntp-server-buffer
  4116. (let ((case-fold-search nil))
  4117. (goto-char (point-min))
  4118. (while (and (not found)
  4119. (search-forward id nil t))
  4120. (beginning-of-line)
  4121. (setq found (looking-at
  4122. (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
  4123. (regexp-quote id))))
  4124. (or found (beginning-of-line 2)))
  4125. (when found
  4126. (beginning-of-line)
  4127. (and
  4128. (setq header (gnus-nov-parse-line
  4129. (read (current-buffer)) deps))
  4130. (gnus-parent-id (mail-header-references header))))))
  4131. (when header
  4132. (let ((number (mail-header-number header)))
  4133. (push number gnus-newsgroup-limit)
  4134. (push header gnus-newsgroup-headers)
  4135. (if (memq number gnus-newsgroup-unselected)
  4136. (progn
  4137. (setq gnus-newsgroup-unreads
  4138. (gnus-add-to-sorted-list gnus-newsgroup-unreads
  4139. number))
  4140. (setq gnus-newsgroup-unselected
  4141. (delq number gnus-newsgroup-unselected)))
  4142. (push number gnus-newsgroup-ancient)))))))
  4143. (defun gnus-build-all-threads ()
  4144. "Read all the headers."
  4145. (let ((gnus-summary-ignore-duplicates t)
  4146. (mail-parse-charset gnus-newsgroup-charset)
  4147. (dependencies gnus-newsgroup-dependencies)
  4148. header article)
  4149. (with-current-buffer nntp-server-buffer
  4150. (let ((case-fold-search nil))
  4151. (goto-char (point-min))
  4152. (while (not (eobp))
  4153. (ignore-errors
  4154. (setq article (read (current-buffer))
  4155. header (gnus-nov-parse-line article dependencies t)))
  4156. (when header
  4157. (with-current-buffer gnus-summary-buffer
  4158. (push header gnus-newsgroup-headers)
  4159. (if (memq (setq article (mail-header-number header))
  4160. gnus-newsgroup-unselected)
  4161. (progn
  4162. (setq gnus-newsgroup-unreads
  4163. (gnus-add-to-sorted-list
  4164. gnus-newsgroup-unreads article))
  4165. (setq gnus-newsgroup-unselected
  4166. (delq article gnus-newsgroup-unselected)))
  4167. (push article gnus-newsgroup-ancient)))
  4168. (forward-line 1)))))))
  4169. (defun gnus-summary-update-article-line (article header)
  4170. "Update the line for ARTICLE using HEADER."
  4171. (let* ((id (mail-header-id header))
  4172. (thread (gnus-id-to-thread id)))
  4173. (unless thread
  4174. (error "Article in no thread"))
  4175. ;; Update the thread.
  4176. (setcar thread header)
  4177. (gnus-summary-goto-subject article)
  4178. (let* ((datal (gnus-data-find-list article))
  4179. (data (car datal))
  4180. (inhibit-read-only t)
  4181. (level (gnus-summary-thread-level)))
  4182. (gnus-delete-line)
  4183. (let ((inserted (- (point)
  4184. (progn
  4185. (gnus-summary-insert-line
  4186. header level nil
  4187. (memq article gnus-newsgroup-undownloaded)
  4188. (gnus-article-mark article)
  4189. (memq article gnus-newsgroup-replied)
  4190. (memq article gnus-newsgroup-expirable)
  4191. ;; Only insert the Subject string when it's different
  4192. ;; from the previous Subject string.
  4193. (if (and
  4194. gnus-show-threads
  4195. (gnus-subject-equal
  4196. (condition-case ()
  4197. (mail-header-subject
  4198. (gnus-data-header
  4199. (cadr
  4200. (gnus-data-find-list
  4201. article
  4202. (gnus-data-list t)))))
  4203. ;; Error on the side of excessive subjects.
  4204. (error ""))
  4205. (mail-header-subject header)))
  4206. ""
  4207. (mail-header-subject header))
  4208. nil (cdr (assq article gnus-newsgroup-scored))
  4209. (memq article gnus-newsgroup-processable))
  4210. (point)))))
  4211. (when (cdr datal)
  4212. (gnus-data-update-list
  4213. (cdr datal)
  4214. (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
  4215. (defun gnus-summary-update-article (article &optional iheader)
  4216. "Update ARTICLE in the summary buffer."
  4217. (set-buffer gnus-summary-buffer)
  4218. (let* ((header (gnus-summary-article-header article))
  4219. (id (mail-header-id header))
  4220. (data (gnus-data-find article))
  4221. (thread (gnus-id-to-thread id))
  4222. (references (mail-header-references header))
  4223. (parent
  4224. (gnus-id-to-thread
  4225. (or (gnus-parent-id
  4226. (when (and references
  4227. (not (equal "" references)))
  4228. references))
  4229. "none")))
  4230. (inhibit-read-only t)
  4231. (old (car thread)))
  4232. (when thread
  4233. (unless iheader
  4234. (setcar thread nil)
  4235. (when parent
  4236. (delq thread parent)))
  4237. (if (gnus-summary-insert-subject id header)
  4238. ;; Set the (possibly) new article number in the data structure.
  4239. (gnus-data-set-number data (gnus-id-to-article id))
  4240. (setcar thread old)
  4241. nil))))
  4242. (defun gnus-rebuild-thread (id &optional line)
  4243. "Rebuild the thread containing ID.
  4244. If LINE, insert the rebuilt thread starting on line LINE."
  4245. (let ((inhibit-read-only t)
  4246. old-pos current thread data)
  4247. (if (not gnus-show-threads)
  4248. (setq thread (list (car (gnus-id-to-thread id))))
  4249. ;; Get the thread this article is part of.
  4250. (setq thread (gnus-remove-thread id)))
  4251. (setq old-pos (point-at-bol))
  4252. (setq current (save-excursion
  4253. (and (re-search-backward "[\r\n]" nil t)
  4254. (gnus-summary-article-number))))
  4255. ;; If this is a gathered thread, we have to go some re-gathering.
  4256. (when (stringp (car thread))
  4257. (let ((subject (car thread))
  4258. roots thr)
  4259. (setq thread (cdr thread))
  4260. (while thread
  4261. (unless (memq (setq thr (gnus-id-to-thread
  4262. (gnus-root-id
  4263. (mail-header-id (caar thread)))))
  4264. roots)
  4265. (push thr roots))
  4266. (setq thread (cdr thread)))
  4267. ;; We now have all (unique) roots.
  4268. (if (= (length roots) 1)
  4269. ;; All the loose roots are now one solid root.
  4270. (setq thread (car roots))
  4271. (setq thread (cons subject (gnus-sort-threads roots))))))
  4272. (let (threads)
  4273. ;; We then insert this thread into the summary buffer.
  4274. (when line
  4275. (goto-char (point-min))
  4276. (forward-line (1- line)))
  4277. (let (gnus-newsgroup-data gnus-newsgroup-threads)
  4278. (if gnus-show-threads
  4279. (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
  4280. (gnus-summary-prepare-unthreaded thread))
  4281. (setq data (nreverse gnus-newsgroup-data))
  4282. (setq threads gnus-newsgroup-threads))
  4283. ;; We splice the new data into the data structure.
  4284. ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
  4285. ;;!!! then we want to insert at the beginning of the buffer.
  4286. ;;!!! That happens to be true with Gnus now, but that may
  4287. ;;!!! change in the future. Perhaps.
  4288. (gnus-data-enter-list
  4289. (if line nil current) data (- (point) old-pos))
  4290. (setq gnus-newsgroup-threads
  4291. (nconc threads gnus-newsgroup-threads))
  4292. (gnus-data-compute-positions))))
  4293. (defun gnus-number-to-header (number)
  4294. "Return the header for article NUMBER."
  4295. (let ((headers gnus-newsgroup-headers))
  4296. (while (and headers
  4297. (not (= number (mail-header-number (car headers)))))
  4298. (pop headers))
  4299. (when headers
  4300. (car headers))))
  4301. (defun gnus-parent-headers (in-headers &optional generation)
  4302. "Return the headers of the GENERATIONth parent of HEADERS."
  4303. (unless generation
  4304. (setq generation 1))
  4305. (let ((parent t)
  4306. (headers in-headers)
  4307. references)
  4308. (while (and parent
  4309. (not (zerop generation))
  4310. (setq references (mail-header-references headers)))
  4311. (setq headers (if (and references
  4312. (setq parent (gnus-parent-id references)))
  4313. (car (gnus-id-to-thread parent))
  4314. nil))
  4315. (decf generation))
  4316. (and (not (eq headers in-headers))
  4317. headers)))
  4318. (defun gnus-id-to-thread (id)
  4319. "Return the (sub-)thread where ID appears."
  4320. (gnus-gethash id gnus-newsgroup-dependencies))
  4321. (defun gnus-id-to-article (id)
  4322. "Return the article number of ID."
  4323. (let ((thread (gnus-id-to-thread id)))
  4324. (when (and thread
  4325. (car thread))
  4326. (mail-header-number (car thread)))))
  4327. (defun gnus-id-to-header (id)
  4328. "Return the article headers of ID."
  4329. (car (gnus-id-to-thread id)))
  4330. (defun gnus-article-displayed-root-p (article)
  4331. "Say whether ARTICLE is a root(ish) article."
  4332. (let ((level (gnus-summary-thread-level article))
  4333. (refs (mail-header-references (gnus-summary-article-header article)))
  4334. particle)
  4335. (cond
  4336. ((null level) nil)
  4337. ((zerop level) t)
  4338. ((null refs) t)
  4339. ((null (gnus-parent-id refs)) t)
  4340. ((and (= 1 level)
  4341. (null (setq particle (gnus-id-to-article
  4342. (gnus-parent-id refs))))
  4343. (null (gnus-summary-thread-level particle)))))))
  4344. (defun gnus-root-id (id)
  4345. "Return the id of the root of the thread where ID appears."
  4346. (let (last-id prev)
  4347. (while (and id (setq prev (car (gnus-id-to-thread id))))
  4348. (setq last-id id
  4349. id (gnus-parent-id (mail-header-references prev))))
  4350. last-id))
  4351. (defun gnus-articles-in-thread (thread)
  4352. "Return the list of articles in THREAD."
  4353. (cons (mail-header-number (car thread))
  4354. (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
  4355. (defun gnus-remove-thread (id &optional dont-remove)
  4356. "Remove the thread that has ID in it."
  4357. (let (headers thread last-id)
  4358. ;; First go up in this thread until we find the root.
  4359. (setq last-id (gnus-root-id id)
  4360. headers (message-flatten-list (gnus-id-to-thread last-id)))
  4361. ;; We have now found the real root of this thread. It might have
  4362. ;; been gathered into some loose thread, so we have to search
  4363. ;; through the threads to find the thread we wanted.
  4364. (let ((threads gnus-newsgroup-threads)
  4365. sub)
  4366. (while threads
  4367. (setq sub (car threads))
  4368. (if (stringp (car sub))
  4369. ;; This is a gathered thread, so we look at the roots
  4370. ;; below it to find whether this article is in this
  4371. ;; gathered root.
  4372. (progn
  4373. (setq sub (cdr sub))
  4374. (while sub
  4375. (when (member (caar sub) headers)
  4376. (setq thread (car threads)
  4377. threads nil
  4378. sub nil))
  4379. (setq sub (cdr sub))))
  4380. ;; It's an ordinary thread, so we check it.
  4381. (when (eq (car sub) (car headers))
  4382. (setq thread sub
  4383. threads nil)))
  4384. (setq threads (cdr threads)))
  4385. ;; If this article is in no thread, then it's a root.
  4386. (if thread
  4387. (unless dont-remove
  4388. (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
  4389. (setq thread (gnus-id-to-thread last-id)))
  4390. (when thread
  4391. (prog1
  4392. thread ; We return this thread.
  4393. (unless dont-remove
  4394. (if (stringp (car thread))
  4395. (progn
  4396. ;; If we use dummy roots, then we have to remove the
  4397. ;; dummy root as well.
  4398. (when (eq gnus-summary-make-false-root 'dummy)
  4399. ;; We go to the dummy root by going to
  4400. ;; the first sub-"thread", and then one line up.
  4401. (gnus-summary-goto-article
  4402. (mail-header-number (caadr thread)))
  4403. (forward-line -1)
  4404. (gnus-delete-line)
  4405. (gnus-data-compute-positions))
  4406. (setq thread (cdr thread))
  4407. (while thread
  4408. (gnus-remove-thread-1 (car thread))
  4409. (setq thread (cdr thread))))
  4410. (gnus-remove-thread-1 thread))))))))
  4411. (defun gnus-remove-thread-1 (thread)
  4412. "Remove the thread THREAD recursively."
  4413. (let ((number (mail-header-number (pop thread)))
  4414. d)
  4415. (setq thread (reverse thread))
  4416. (while thread
  4417. (gnus-remove-thread-1 (pop thread)))
  4418. (when (setq d (gnus-data-find number))
  4419. (goto-char (gnus-data-pos d))
  4420. (gnus-summary-show-thread)
  4421. (gnus-data-remove
  4422. number
  4423. (- (point-at-bol)
  4424. (prog1
  4425. (1+ (point-at-eol))
  4426. (gnus-delete-line)))))))
  4427. (defun gnus-sort-threads-recursive (threads func)
  4428. ;; Responsible for sorting the root articles of threads.
  4429. (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
  4430. 'gnus-thread-sort-functions)
  4431. func
  4432. (gnus-make-sort-function
  4433. gnus-subthread-sort-functions))))
  4434. (sort (mapcar (lambda (thread)
  4435. (cons (car thread)
  4436. (and (cdr thread)
  4437. (gnus-sort-subthreads-recursive
  4438. (cdr thread) subthread-sort-func))))
  4439. threads) func)))
  4440. (defun gnus-sort-subthreads-recursive (threads func)
  4441. ;; Responsible for sorting subthreads.
  4442. (sort (mapcar (lambda (thread)
  4443. (cons (car thread)
  4444. (and (cdr thread)
  4445. (gnus-sort-subthreads-recursive (cdr thread) func))))
  4446. threads) func))
  4447. (defun gnus-sort-threads-loop (threads func)
  4448. (let* ((superthread (cons nil threads))
  4449. (stack (list (cons superthread threads)))
  4450. remaining-threads thread)
  4451. (while stack
  4452. (setq remaining-threads (cdr (car stack)))
  4453. (if remaining-threads
  4454. (progn (setq thread (car remaining-threads))
  4455. (setcdr (car stack) (cdr remaining-threads))
  4456. (if (cdr thread)
  4457. (push (cons thread (cdr thread)) stack)))
  4458. (setq thread (caar stack))
  4459. (setcdr thread (sort (cdr thread) func))
  4460. (pop stack)))
  4461. (cdr superthread)))
  4462. (defun gnus-sort-threads (threads)
  4463. "Sort THREADS."
  4464. (if (not gnus-thread-sort-functions)
  4465. threads
  4466. (gnus-message 8 "Sorting threads...")
  4467. (prog1
  4468. (condition-case nil
  4469. (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
  4470. (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
  4471. (gnus-sort-threads-recursive threads sort-func))
  4472. ;; Even after binding max-lisp-eval-depth, the recursive
  4473. ;; sorter might fail for very long threads. In that case,
  4474. ;; try using a (less well-tested) non-recursive sorter.
  4475. (error (gnus-message 9 "Sorting threads with loop...")
  4476. (gnus-sort-threads-loop
  4477. threads (gnus-make-sort-function
  4478. gnus-thread-sort-functions))))
  4479. (gnus-message 8 "Sorting threads...done"))))
  4480. (defun gnus-sort-articles (articles)
  4481. "Sort ARTICLES."
  4482. (when gnus-article-sort-functions
  4483. (gnus-message 7 "Sorting articles...")
  4484. (prog1
  4485. (setq gnus-newsgroup-headers
  4486. (sort articles (gnus-make-sort-function
  4487. gnus-article-sort-functions)))
  4488. (gnus-message 7 "Sorting articles...done"))))
  4489. ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
  4490. (defmacro gnus-thread-header (thread)
  4491. "Return header of first article in THREAD.
  4492. Note that THREAD must never, ever be anything else than a variable -
  4493. using some other form will lead to serious barfage."
  4494. (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
  4495. ;; (8% speedup to gnus-summary-prepare, just for fun :-)
  4496. (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
  4497. (vector thread) 2))
  4498. (defsubst gnus-article-sort-by-number (h1 h2)
  4499. "Sort articles by article number."
  4500. (< (mail-header-number h1)
  4501. (mail-header-number h2)))
  4502. (defun gnus-thread-sort-by-number (h1 h2)
  4503. "Sort threads by root article number."
  4504. (gnus-article-sort-by-number
  4505. (gnus-thread-header h1) (gnus-thread-header h2)))
  4506. (defsubst gnus-article-sort-by-random (h1 h2)
  4507. "Sort articles randomly."
  4508. (zerop (random 2)))
  4509. (defun gnus-thread-sort-by-random (h1 h2)
  4510. "Sort threads randomly."
  4511. (gnus-article-sort-by-random
  4512. (gnus-thread-header h1) (gnus-thread-header h2)))
  4513. (defsubst gnus-article-sort-by-lines (h1 h2)
  4514. "Sort articles by article Lines header."
  4515. (< (mail-header-lines h1)
  4516. (mail-header-lines h2)))
  4517. (defun gnus-thread-sort-by-lines (h1 h2)
  4518. "Sort threads by root article Lines header."
  4519. (gnus-article-sort-by-lines
  4520. (gnus-thread-header h1) (gnus-thread-header h2)))
  4521. (defsubst gnus-article-sort-by-chars (h1 h2)
  4522. "Sort articles by octet length."
  4523. (< (mail-header-chars h1)
  4524. (mail-header-chars h2)))
  4525. (defun gnus-thread-sort-by-chars (h1 h2)
  4526. "Sort threads by root article octet length."
  4527. (gnus-article-sort-by-chars
  4528. (gnus-thread-header h1) (gnus-thread-header h2)))
  4529. (defsubst gnus-article-sort-by-author (h1 h2)
  4530. "Sort articles by root author."
  4531. (gnus-string<
  4532. (let ((extract (funcall
  4533. gnus-extract-address-components
  4534. (mail-header-from h1))))
  4535. (or (car extract) (cadr extract) ""))
  4536. (let ((extract (funcall
  4537. gnus-extract-address-components
  4538. (mail-header-from h2))))
  4539. (or (car extract) (cadr extract) ""))))
  4540. (defun gnus-thread-sort-by-author (h1 h2)
  4541. "Sort threads by root author."
  4542. (gnus-article-sort-by-author
  4543. (gnus-thread-header h1) (gnus-thread-header h2)))
  4544. (defsubst gnus-article-sort-by-recipient (h1 h2)
  4545. "Sort articles by recipient."
  4546. (gnus-string<
  4547. (let ((extract (funcall
  4548. gnus-extract-address-components
  4549. (or (cdr (assq 'To (mail-header-extra h1))) ""))))
  4550. (or (car extract) (cadr extract)))
  4551. (let ((extract (funcall
  4552. gnus-extract-address-components
  4553. (or (cdr (assq 'To (mail-header-extra h2))) ""))))
  4554. (or (car extract) (cadr extract)))))
  4555. (defun gnus-thread-sort-by-recipient (h1 h2)
  4556. "Sort threads by root recipient."
  4557. (gnus-article-sort-by-recipient
  4558. (gnus-thread-header h1) (gnus-thread-header h2)))
  4559. (defsubst gnus-article-sort-by-subject (h1 h2)
  4560. "Sort articles by root subject."
  4561. (gnus-string<
  4562. (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
  4563. (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
  4564. (defun gnus-thread-sort-by-subject (h1 h2)
  4565. "Sort threads by root subject."
  4566. (gnus-article-sort-by-subject
  4567. (gnus-thread-header h1) (gnus-thread-header h2)))
  4568. (defsubst gnus-article-sort-by-date (h1 h2)
  4569. "Sort articles by root article date."
  4570. (time-less-p
  4571. (gnus-date-get-time (mail-header-date h1))
  4572. (gnus-date-get-time (mail-header-date h2))))
  4573. (defun gnus-thread-sort-by-date (h1 h2)
  4574. "Sort threads by root article date."
  4575. (gnus-article-sort-by-date
  4576. (gnus-thread-header h1) (gnus-thread-header h2)))
  4577. (defsubst gnus-article-sort-by-score (h1 h2)
  4578. "Sort articles by root article score.
  4579. Unscored articles will be counted as having a score of zero."
  4580. (> (or (cdr (assq (mail-header-number h1)
  4581. gnus-newsgroup-scored))
  4582. gnus-summary-default-score 0)
  4583. (or (cdr (assq (mail-header-number h2)
  4584. gnus-newsgroup-scored))
  4585. gnus-summary-default-score 0)))
  4586. (defun gnus-thread-sort-by-score (h1 h2)
  4587. "Sort threads by root article score."
  4588. (gnus-article-sort-by-score
  4589. (gnus-thread-header h1) (gnus-thread-header h2)))
  4590. (defun gnus-thread-sort-by-total-score (h1 h2)
  4591. "Sort threads by the sum of all scores in the thread.
  4592. Unscored articles will be counted as having a score of zero."
  4593. (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
  4594. (defun gnus-thread-total-score (thread)
  4595. ;; This function find the total score of THREAD.
  4596. (cond
  4597. ((null thread)
  4598. 0)
  4599. ((consp thread)
  4600. (if (stringp (car thread))
  4601. (apply gnus-thread-score-function 0
  4602. (mapcar 'gnus-thread-total-score-1 (cdr thread)))
  4603. (gnus-thread-total-score-1 thread)))
  4604. (t
  4605. (gnus-thread-total-score-1 (list thread)))))
  4606. (defun gnus-article-sort-by-most-recent-number (h1 h2)
  4607. "Sort articles by number."
  4608. (gnus-article-sort-by-number h1 h2))
  4609. (defun gnus-thread-sort-by-most-recent-number (h1 h2)
  4610. "Sort threads such that the thread with the most recently arrived article comes first."
  4611. (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
  4612. (defun gnus-thread-highest-number (thread)
  4613. "Return the highest article number in THREAD."
  4614. (apply 'max (mapcar (lambda (header)
  4615. (mail-header-number header))
  4616. (message-flatten-list thread))))
  4617. (defun gnus-article-sort-by-most-recent-date (h1 h2)
  4618. "Sort articles by number."
  4619. (gnus-article-sort-by-date h1 h2))
  4620. (defun gnus-thread-sort-by-most-recent-date (h1 h2)
  4621. "Sort threads such that the thread with the most recently dated article comes first."
  4622. (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
  4623. ; Since this is called not only to sort the top-level threads, but
  4624. ; also in recursive sorts to order the articles within a thread, each
  4625. ; article will be processed many times. Thus it speeds things up
  4626. ; quite a bit to use gnus-date-get-time, which caches the time value.
  4627. (defun gnus-thread-latest-date (thread)
  4628. "Return the highest article date in THREAD."
  4629. (apply 'max
  4630. (mapcar (lambda (header) (gnus-float-time
  4631. (gnus-date-get-time
  4632. (mail-header-date header))))
  4633. (message-flatten-list thread))))
  4634. (defun gnus-thread-total-score-1 (root)
  4635. ;; This function find the total score of the thread below ROOT.
  4636. (setq root (car root))
  4637. (apply gnus-thread-score-function
  4638. (or (append
  4639. (mapcar 'gnus-thread-total-score
  4640. (cdr (gnus-id-to-thread (mail-header-id root))))
  4641. (when (> (mail-header-number root) 0)
  4642. (list (or (cdr (assq (mail-header-number root)
  4643. gnus-newsgroup-scored))
  4644. gnus-summary-default-score 0))))
  4645. (list gnus-summary-default-score)
  4646. '(0))))
  4647. ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
  4648. (defvar gnus-tmp-prev-subject nil)
  4649. (defvar gnus-tmp-false-parent nil)
  4650. (defvar gnus-tmp-root-expunged nil)
  4651. (defvar gnus-tmp-dummy-line nil)
  4652. (defun gnus-extra-header (type &optional header)
  4653. "Return the extra header of TYPE."
  4654. (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
  4655. ""))
  4656. (defvar gnus-tmp-thread-tree-header-string "")
  4657. (defcustom gnus-sum-thread-tree-root "> "
  4658. "With %B spec, used for the root of a thread.
  4659. If nil, use subject instead."
  4660. :version "22.1"
  4661. :type '(radio (const :format "%v " nil) string)
  4662. :group 'gnus-thread)
  4663. (defcustom gnus-sum-thread-tree-false-root "> "
  4664. "With %B spec, used for a false root of a thread.
  4665. If nil, use subject instead."
  4666. :version "22.1"
  4667. :type '(radio (const :format "%v " nil) string)
  4668. :group 'gnus-thread)
  4669. (defcustom gnus-sum-thread-tree-single-indent ""
  4670. "With %B spec, used for a thread with just one message.
  4671. If nil, use subject instead."
  4672. :version "22.1"
  4673. :type '(radio (const :format "%v " nil) string)
  4674. :group 'gnus-thread)
  4675. (defcustom gnus-sum-thread-tree-vertical "| "
  4676. "With %B spec, used for drawing a vertical line."
  4677. :version "22.1"
  4678. :type 'string
  4679. :group 'gnus-thread)
  4680. (defcustom gnus-sum-thread-tree-indent " "
  4681. "With %B spec, used for indenting."
  4682. :version "22.1"
  4683. :type 'string
  4684. :group 'gnus-thread)
  4685. (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
  4686. "With %B spec, used for a leaf with brothers."
  4687. :version "22.1"
  4688. :type 'string
  4689. :group 'gnus-thread)
  4690. (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
  4691. "With %B spec, used for a leaf without brothers."
  4692. :version "22.1"
  4693. :type 'string
  4694. :group 'gnus-thread)
  4695. (defcustom gnus-summary-display-while-building nil
  4696. "If non-nil, show and update the summary buffer as it's being built.
  4697. If the value is t, update the buffer after every line is inserted. If
  4698. the value is an integer (N), update the display every N lines."
  4699. :version "22.1"
  4700. :group 'gnus-thread
  4701. :type '(choice (const :tag "off" nil)
  4702. number
  4703. (const :tag "frequently" t)))
  4704. (defun gnus-summary-prepare-threads (threads)
  4705. "Prepare summary buffer from THREADS and indentation LEVEL.
  4706. THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
  4707. or a straight list of headers."
  4708. (gnus-message 7 "Generating summary...")
  4709. (setq gnus-newsgroup-threads threads)
  4710. (beginning-of-line)
  4711. (let ((gnus-tmp-level 0)
  4712. (default-score (or gnus-summary-default-score 0))
  4713. (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
  4714. (building-line-count gnus-summary-display-while-building)
  4715. (building-count (integerp gnus-summary-display-while-building))
  4716. thread number subject stack state gnus-tmp-gathered beg-match
  4717. new-roots gnus-tmp-new-adopts thread-end simp-subject
  4718. gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
  4719. gnus-tmp-replied gnus-tmp-subject-or-nil
  4720. gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
  4721. gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
  4722. gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
  4723. tree-stack)
  4724. (setq gnus-tmp-prev-subject nil
  4725. gnus-tmp-thread-tree-header-string "")
  4726. (if (vectorp (car threads))
  4727. ;; If this is a straight (sic) list of headers, then a
  4728. ;; threaded summary display isn't required, so we just create
  4729. ;; an unthreaded one.
  4730. (gnus-summary-prepare-unthreaded threads)
  4731. ;; Do the threaded display.
  4732. (if gnus-summary-display-while-building
  4733. (switch-to-buffer (buffer-name)))
  4734. (while (or threads stack gnus-tmp-new-adopts new-roots)
  4735. (if (and (= gnus-tmp-level 0)
  4736. (or (not stack)
  4737. (= (caar stack) 0))
  4738. (not gnus-tmp-false-parent)
  4739. (or gnus-tmp-new-adopts new-roots))
  4740. (if gnus-tmp-new-adopts
  4741. (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
  4742. thread (list (car gnus-tmp-new-adopts))
  4743. gnus-tmp-header (caar thread)
  4744. gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
  4745. (when new-roots
  4746. (setq thread (list (car new-roots))
  4747. gnus-tmp-header (caar thread)
  4748. new-roots (cdr new-roots))))
  4749. (if threads
  4750. ;; If there are some threads, we do them before the
  4751. ;; threads on the stack.
  4752. (setq thread threads
  4753. gnus-tmp-header (caar thread))
  4754. ;; There were no current threads, so we pop something off
  4755. ;; the stack.
  4756. (setq state (car stack)
  4757. gnus-tmp-level (car state)
  4758. tree-stack (cadr state)
  4759. thread (caddr state)
  4760. stack (cdr stack)
  4761. gnus-tmp-header (caar thread))))
  4762. (setq gnus-tmp-false-parent nil)
  4763. (setq gnus-tmp-root-expunged nil)
  4764. (setq thread-end nil)
  4765. (if (stringp gnus-tmp-header)
  4766. ;; The header is a dummy root.
  4767. (cond
  4768. ((eq gnus-summary-make-false-root 'adopt)
  4769. ;; We let the first article adopt the rest.
  4770. (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
  4771. (cddar thread)))
  4772. (setq gnus-tmp-gathered
  4773. (nconc (mapcar
  4774. (lambda (h) (mail-header-number (car h)))
  4775. (cddar thread))
  4776. gnus-tmp-gathered))
  4777. (setq thread (cons (list (caar thread)
  4778. (cadar thread))
  4779. (cdr thread)))
  4780. (setq gnus-tmp-level -1
  4781. gnus-tmp-false-parent t))
  4782. ((eq gnus-summary-make-false-root 'empty)
  4783. ;; We print adopted articles with empty subject fields.
  4784. (setq gnus-tmp-gathered
  4785. (nconc (mapcar
  4786. (lambda (h) (mail-header-number (car h)))
  4787. (cddar thread))
  4788. gnus-tmp-gathered))
  4789. (setq gnus-tmp-level -1))
  4790. ((eq gnus-summary-make-false-root 'dummy)
  4791. ;; We remember that we probably want to output a dummy
  4792. ;; root.
  4793. (setq gnus-tmp-dummy-line gnus-tmp-header)
  4794. (setq gnus-tmp-prev-subject gnus-tmp-header))
  4795. (t
  4796. ;; We do not make a root for the gathered
  4797. ;; sub-threads at all.
  4798. (setq gnus-tmp-level -1)))
  4799. (setq number (mail-header-number gnus-tmp-header)
  4800. subject (mail-header-subject gnus-tmp-header)
  4801. simp-subject (gnus-simplify-subject-fully subject))
  4802. (cond
  4803. ;; If the thread has changed subject, we might want to make
  4804. ;; this subthread into a root.
  4805. ((and (null gnus-thread-ignore-subject)
  4806. (not (zerop gnus-tmp-level))
  4807. gnus-tmp-prev-subject
  4808. (not (string= gnus-tmp-prev-subject simp-subject)))
  4809. (setq new-roots (nconc new-roots (list (car thread)))
  4810. thread-end t
  4811. gnus-tmp-header nil))
  4812. ;; If the article lies outside the current limit,
  4813. ;; then we do not display it.
  4814. ((not (memq number gnus-newsgroup-limit))
  4815. (setq gnus-tmp-gathered
  4816. (nconc (mapcar
  4817. (lambda (h) (mail-header-number (car h)))
  4818. (cdar thread))
  4819. gnus-tmp-gathered))
  4820. (setq gnus-tmp-new-adopts (if (cdar thread)
  4821. (append gnus-tmp-new-adopts
  4822. (cdar thread))
  4823. gnus-tmp-new-adopts)
  4824. thread-end t
  4825. gnus-tmp-header nil)
  4826. (when (zerop gnus-tmp-level)
  4827. (setq gnus-tmp-root-expunged t)))
  4828. ;; Perhaps this article is to be marked as read?
  4829. ((and gnus-summary-mark-below
  4830. (< (or (cdr (assq number gnus-newsgroup-scored))
  4831. default-score)
  4832. gnus-summary-mark-below)
  4833. ;; Don't touch sparse articles.
  4834. (not (gnus-summary-article-sparse-p number))
  4835. (not (gnus-summary-article-ancient-p number)))
  4836. (setq gnus-newsgroup-unreads
  4837. (delq number gnus-newsgroup-unreads))
  4838. (if gnus-newsgroup-auto-expire
  4839. (setq gnus-newsgroup-expirable
  4840. (gnus-add-to-sorted-list
  4841. gnus-newsgroup-expirable number))
  4842. (push (cons number gnus-low-score-mark)
  4843. gnus-newsgroup-reads))))
  4844. (when gnus-tmp-header
  4845. ;; We may have an old dummy line to output before this
  4846. ;; article.
  4847. (when (and gnus-tmp-dummy-line
  4848. (gnus-subject-equal
  4849. gnus-tmp-dummy-line
  4850. (mail-header-subject gnus-tmp-header)))
  4851. (gnus-summary-insert-dummy-line
  4852. gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
  4853. (setq gnus-tmp-dummy-line nil))
  4854. ;; Compute the mark.
  4855. (setq gnus-tmp-unread (gnus-article-mark number))
  4856. (push (gnus-data-make number gnus-tmp-unread (1+ (point))
  4857. gnus-tmp-header gnus-tmp-level)
  4858. gnus-newsgroup-data)
  4859. ;; Actually insert the line.
  4860. (setq
  4861. gnus-tmp-subject-or-nil
  4862. (cond
  4863. ((and gnus-thread-ignore-subject
  4864. gnus-tmp-prev-subject
  4865. (not (string= gnus-tmp-prev-subject simp-subject)))
  4866. subject)
  4867. ((zerop gnus-tmp-level)
  4868. (if (and (eq gnus-summary-make-false-root 'empty)
  4869. (memq number gnus-tmp-gathered)
  4870. gnus-tmp-prev-subject
  4871. (string= gnus-tmp-prev-subject simp-subject))
  4872. gnus-summary-same-subject
  4873. subject))
  4874. (t gnus-summary-same-subject)))
  4875. (if (and (eq gnus-summary-make-false-root 'adopt)
  4876. (= gnus-tmp-level 1)
  4877. (memq number gnus-tmp-gathered))
  4878. (setq gnus-tmp-opening-bracket ?\<
  4879. gnus-tmp-closing-bracket ?\>)
  4880. (setq gnus-tmp-opening-bracket ?\[
  4881. gnus-tmp-closing-bracket ?\]))
  4882. (if (>= gnus-tmp-level (length gnus-thread-indent-array))
  4883. (gnus-make-thread-indent-array
  4884. (max (* 2 (length gnus-thread-indent-array))
  4885. gnus-tmp-level)))
  4886. (setq
  4887. gnus-tmp-indentation
  4888. (aref gnus-thread-indent-array gnus-tmp-level)
  4889. gnus-tmp-lines (mail-header-lines gnus-tmp-header)
  4890. gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
  4891. gnus-summary-default-score 0)
  4892. gnus-tmp-score-char
  4893. (if (or (null gnus-summary-default-score)
  4894. (<= (abs (- gnus-tmp-score gnus-summary-default-score))
  4895. gnus-summary-zcore-fuzz))
  4896. ? ;Whitespace
  4897. (if (< gnus-tmp-score gnus-summary-default-score)
  4898. gnus-score-below-mark gnus-score-over-mark))
  4899. gnus-tmp-replied
  4900. (cond ((memq number gnus-newsgroup-processable)
  4901. gnus-process-mark)
  4902. ((memq number gnus-newsgroup-cached)
  4903. gnus-cached-mark)
  4904. ((memq number gnus-newsgroup-replied)
  4905. gnus-replied-mark)
  4906. ((memq number gnus-newsgroup-forwarded)
  4907. gnus-forwarded-mark)
  4908. ((memq number gnus-newsgroup-saved)
  4909. gnus-saved-mark)
  4910. ((memq number gnus-newsgroup-unseen)
  4911. gnus-unseen-mark)
  4912. (t gnus-no-mark))
  4913. gnus-tmp-downloaded
  4914. (cond ((memq number gnus-newsgroup-undownloaded)
  4915. gnus-undownloaded-mark)
  4916. (gnus-newsgroup-agentized
  4917. gnus-downloaded-mark)
  4918. (t
  4919. gnus-no-mark))
  4920. gnus-tmp-from (mail-header-from gnus-tmp-header)
  4921. gnus-tmp-name
  4922. (cond
  4923. ((string-match "<[^>]+> *$" gnus-tmp-from)
  4924. (setq beg-match (match-beginning 0))
  4925. (or (and (string-match "^\".+\"" gnus-tmp-from)
  4926. (substring gnus-tmp-from 1 (1- (match-end 0))))
  4927. (substring gnus-tmp-from 0 beg-match)))
  4928. ((string-match "(.+)" gnus-tmp-from)
  4929. (substring gnus-tmp-from
  4930. (1+ (match-beginning 0)) (1- (match-end 0))))
  4931. (t gnus-tmp-from))
  4932. ;; Do the %B string
  4933. gnus-tmp-thread-tree-header-string
  4934. (cond
  4935. ((not gnus-show-threads) "")
  4936. ((zerop gnus-tmp-level)
  4937. (cond ((cdar thread)
  4938. (or gnus-sum-thread-tree-root subject))
  4939. (gnus-tmp-new-adopts
  4940. (or gnus-sum-thread-tree-false-root subject))
  4941. (t
  4942. (or gnus-sum-thread-tree-single-indent subject))))
  4943. (t
  4944. (concat (apply 'concat
  4945. (mapcar (lambda (item)
  4946. (if (= item 1)
  4947. gnus-sum-thread-tree-vertical
  4948. gnus-sum-thread-tree-indent))
  4949. (cdr (reverse tree-stack))))
  4950. (if (nth 1 thread)
  4951. gnus-sum-thread-tree-leaf-with-other
  4952. gnus-sum-thread-tree-single-leaf)))))
  4953. (when (string= gnus-tmp-name "")
  4954. (setq gnus-tmp-name gnus-tmp-from))
  4955. (unless (numberp gnus-tmp-lines)
  4956. (setq gnus-tmp-lines -1))
  4957. (if (= gnus-tmp-lines -1)
  4958. (setq gnus-tmp-lines "?")
  4959. (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
  4960. (gnus-put-text-property
  4961. (point)
  4962. (progn (eval gnus-summary-line-format-spec) (point))
  4963. 'gnus-number number)
  4964. (when gnus-visual-p
  4965. (forward-line -1)
  4966. (gnus-summary-highlight-line)
  4967. (when gnus-summary-update-hook
  4968. (gnus-run-hooks 'gnus-summary-update-hook))
  4969. (forward-line 1))
  4970. (setq gnus-tmp-prev-subject simp-subject)))
  4971. (when (nth 1 thread)
  4972. (push (list (max 0 gnus-tmp-level)
  4973. (copy-sequence tree-stack)
  4974. (nthcdr 1 thread))
  4975. stack))
  4976. (push (if (nth 1 thread) 1 0) tree-stack)
  4977. (incf gnus-tmp-level)
  4978. (setq threads (if thread-end nil (cdar thread)))
  4979. (if gnus-summary-display-while-building
  4980. (if building-count
  4981. (progn
  4982. ;; use a set frequency
  4983. (setq building-line-count (1- building-line-count))
  4984. (when (= building-line-count 0)
  4985. (sit-for 0)
  4986. (setq building-line-count
  4987. gnus-summary-display-while-building)))
  4988. ;; always
  4989. (sit-for 0)))
  4990. (unless threads
  4991. (setq gnus-tmp-level 0)))))
  4992. (gnus-message 7 "Generating summary...done"))
  4993. (defun gnus-summary-prepare-unthreaded (headers)
  4994. "Generate an unthreaded summary buffer based on HEADERS."
  4995. (let (header number mark)
  4996. (beginning-of-line)
  4997. (while headers
  4998. ;; We may have to root out some bad articles...
  4999. (when (memq (setq number (mail-header-number
  5000. (setq header (pop headers))))
  5001. gnus-newsgroup-limit)
  5002. ;; Mark article as read when it has a low score.
  5003. (when (and gnus-summary-mark-below
  5004. (< (or (cdr (assq number gnus-newsgroup-scored))
  5005. gnus-summary-default-score 0)
  5006. gnus-summary-mark-below)
  5007. (not (gnus-summary-article-ancient-p number)))
  5008. (setq gnus-newsgroup-unreads
  5009. (delq number gnus-newsgroup-unreads))
  5010. (if gnus-newsgroup-auto-expire
  5011. (push number gnus-newsgroup-expirable)
  5012. (push (cons number gnus-low-score-mark)
  5013. gnus-newsgroup-reads)))
  5014. (setq mark (gnus-article-mark number))
  5015. (push (gnus-data-make number mark (1+ (point)) header 0)
  5016. gnus-newsgroup-data)
  5017. (gnus-summary-insert-line
  5018. header 0 number
  5019. (memq number gnus-newsgroup-undownloaded)
  5020. mark (memq number gnus-newsgroup-replied)
  5021. (memq number gnus-newsgroup-expirable)
  5022. (mail-header-subject header) nil
  5023. (cdr (assq number gnus-newsgroup-scored))
  5024. (memq number gnus-newsgroup-processable))))))
  5025. (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
  5026. (defun gnus-group-get-list-identifiers (group)
  5027. "Get list identifier regexp for GROUP."
  5028. (or (gnus-parameter-list-identifier group)
  5029. (if (consp gnus-list-identifiers)
  5030. (mapconcat 'identity gnus-list-identifiers " *\\|")
  5031. gnus-list-identifiers)))
  5032. (defun gnus-summary-remove-list-identifiers ()
  5033. "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
  5034. (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
  5035. changed subject)
  5036. (when regexp
  5037. (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
  5038. (dolist (header gnus-newsgroup-headers)
  5039. (setq subject (mail-header-subject header)
  5040. changed nil)
  5041. (while (string-match regexp subject)
  5042. (setq subject
  5043. (concat (substring subject 0 (match-beginning 1))
  5044. (substring subject (match-end 0)))
  5045. changed t))
  5046. (when changed
  5047. (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
  5048. (setq subject
  5049. (concat (substring subject 0 (match-beginning 1))
  5050. (substring subject (match-end 1)))))
  5051. (mail-header-set-subject header subject))))))
  5052. (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
  5053. "Fetch headers of ARTICLES."
  5054. (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
  5055. (gnus-message 7 "Fetching headers for %s..." name)
  5056. (prog1
  5057. (if (eq 'nov
  5058. (setq gnus-headers-retrieved-by
  5059. (gnus-retrieve-headers
  5060. articles gnus-newsgroup-name
  5061. (or limit
  5062. ;; We might want to fetch old headers, but
  5063. ;; not if there is only 1 article.
  5064. (and (or (and
  5065. (not (eq gnus-fetch-old-headers 'some))
  5066. (not (numberp gnus-fetch-old-headers)))
  5067. (> (length articles) 1))
  5068. gnus-fetch-old-headers)))))
  5069. (gnus-get-newsgroup-headers-xover
  5070. articles force-new dependencies gnus-newsgroup-name t)
  5071. (gnus-get-newsgroup-headers dependencies force-new))
  5072. (gnus-message 7 "Fetching headers for %s...done" name))))
  5073. (defun gnus-select-newsgroup (group &optional read-all select-articles)
  5074. "Select newsgroup GROUP.
  5075. If READ-ALL is non-nil, all articles in the group are selected.
  5076. If SELECT-ARTICLES, only select those articles from GROUP."
  5077. (let* ((entry (gnus-group-entry group))
  5078. ;;!!! Dirty hack; should be removed.
  5079. (gnus-summary-ignore-duplicates
  5080. (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
  5081. t
  5082. gnus-summary-ignore-duplicates))
  5083. (info (nth 2 entry))
  5084. charset articles fetched-articles cached)
  5085. (unless (gnus-check-server
  5086. (set (make-local-variable 'gnus-current-select-method)
  5087. (gnus-find-method-for-group group)))
  5088. (error "Couldn't open server"))
  5089. (setq charset (gnus-group-name-charset gnus-current-select-method group))
  5090. (or (and entry (not (eq (car entry) t))) ; Either it's active...
  5091. (gnus-activate-group group) ; Or we can activate it...
  5092. (progn ; Or we bug out.
  5093. (when (derived-mode-p 'gnus-summary-mode)
  5094. (gnus-kill-buffer (current-buffer)))
  5095. (error
  5096. "Couldn't activate group %s: %s"
  5097. (mm-decode-coding-string group charset)
  5098. (mm-decode-coding-string (gnus-status-message group) charset))))
  5099. (unless (gnus-request-group group t nil (gnus-get-info group))
  5100. (when (derived-mode-p 'gnus-summary-mode)
  5101. (gnus-kill-buffer (current-buffer)))
  5102. (error "Couldn't request group %s: %s"
  5103. (mm-decode-coding-string group charset)
  5104. (mm-decode-coding-string (gnus-status-message group) charset)))
  5105. (when (and gnus-agent
  5106. (gnus-active group))
  5107. (gnus-agent-possibly-alter-active group (gnus-active group) info)
  5108. (setq gnus-summary-use-undownloaded-faces
  5109. (gnus-agent-find-parameter
  5110. group
  5111. 'agent-enable-undownloaded-faces)))
  5112. (setq gnus-newsgroup-name group
  5113. gnus-newsgroup-unselected nil
  5114. gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
  5115. (let ((display (gnus-group-find-parameter group 'display)))
  5116. (setq gnus-newsgroup-display
  5117. (cond
  5118. ((not (zerop (or (car-safe read-all) 0)))
  5119. ;; The user entered the group with C-u SPC/RET, let's show
  5120. ;; all articles.
  5121. 'gnus-not-ignore)
  5122. ((eq display 'all)
  5123. 'gnus-not-ignore)
  5124. ((arrayp display)
  5125. (gnus-summary-display-make-predicate (mapcar 'identity display)))
  5126. ((numberp display)
  5127. ;; The following is probably the "correct" solution, but
  5128. ;; it makes Gnus fetch all headers and then limit the
  5129. ;; articles (which is slow), so instead we hack the
  5130. ;; select-articles parameter instead. -- Simon Josefsson
  5131. ;; <jas@kth.se>
  5132. ;;
  5133. ;; (gnus-byte-compile
  5134. ;; `(lambda () (> number ,(- (cdr (gnus-active group))
  5135. ;; display)))))
  5136. (setq select-articles
  5137. (gnus-uncompress-range
  5138. (cons (let ((tmp (- (cdr (gnus-active group)) display)))
  5139. (if (> tmp 0)
  5140. tmp
  5141. 1))
  5142. (cdr (gnus-active group)))))
  5143. nil)
  5144. (t
  5145. nil))))
  5146. (gnus-summary-setup-default-charset)
  5147. ;; Kludge to avoid having cached articles nixed out in virtual groups.
  5148. (when (gnus-virtual-group-p group)
  5149. (setq cached gnus-newsgroup-cached))
  5150. (setq gnus-newsgroup-unreads
  5151. (gnus-sorted-ndifference
  5152. (gnus-sorted-ndifference gnus-newsgroup-unreads
  5153. gnus-newsgroup-marked)
  5154. gnus-newsgroup-dormant))
  5155. (setq gnus-newsgroup-processable nil)
  5156. (gnus-update-read-articles group gnus-newsgroup-unreads t)
  5157. ;; Adjust and set lists of article marks.
  5158. (when info
  5159. (gnus-adjust-marked-articles info))
  5160. (if (setq articles select-articles)
  5161. (setq gnus-newsgroup-unselected
  5162. (gnus-sorted-difference gnus-newsgroup-unreads articles))
  5163. (setq articles (gnus-articles-to-read group read-all)))
  5164. (cond
  5165. ((null articles)
  5166. ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
  5167. 'quit)
  5168. ((eq articles 0) nil)
  5169. (t
  5170. ;; Init the dependencies hash table.
  5171. (setq gnus-newsgroup-dependencies
  5172. (gnus-make-hashtable (length articles)))
  5173. (if (gnus-buffer-live-p gnus-group-buffer)
  5174. (gnus-set-global-variables)
  5175. (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
  5176. ;; Retrieve the headers and read them in.
  5177. (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
  5178. ;; Kludge to avoid having cached articles nixed out in virtual groups.
  5179. (when cached
  5180. (setq gnus-newsgroup-cached cached))
  5181. ;; Suppress duplicates?
  5182. (when gnus-suppress-duplicates
  5183. (gnus-dup-suppress-articles))
  5184. ;; Set the initial limit.
  5185. (setq gnus-newsgroup-limit (copy-sequence articles))
  5186. ;; Remove canceled articles from the list of unread articles.
  5187. (setq fetched-articles
  5188. (mapcar (lambda (headers) (mail-header-number headers))
  5189. gnus-newsgroup-headers))
  5190. (setq gnus-newsgroup-articles fetched-articles)
  5191. (setq gnus-newsgroup-unreads
  5192. (gnus-sorted-nintersection
  5193. gnus-newsgroup-unreads fetched-articles))
  5194. (gnus-compute-unseen-list)
  5195. ;; Removed marked articles that do not exist.
  5196. (gnus-update-missing-marks
  5197. (gnus-sorted-difference articles fetched-articles))
  5198. ;; We might want to build some more threads first.
  5199. (when (and gnus-fetch-old-headers
  5200. (eq gnus-headers-retrieved-by 'nov))
  5201. (if (eq gnus-fetch-old-headers 'invisible)
  5202. (gnus-build-all-threads)
  5203. (gnus-build-old-threads)))
  5204. ;; Let the Gnus agent mark articles as read.
  5205. (when gnus-agent
  5206. (gnus-agent-get-undownloaded-list))
  5207. ;; Remove list identifiers from subject
  5208. (gnus-summary-remove-list-identifiers)
  5209. ;; Check whether auto-expire is to be done in this group.
  5210. (setq gnus-newsgroup-auto-expire
  5211. (and (gnus-group-auto-expirable-p group)
  5212. (not (gnus-group-read-only-p group))))
  5213. ;; Set up the article buffer now, if necessary.
  5214. (unless (and gnus-single-article-buffer
  5215. (equal gnus-article-buffer "*Article*"))
  5216. (gnus-article-setup-buffer))
  5217. ;; First and last article in this newsgroup.
  5218. (when gnus-newsgroup-headers
  5219. (setq gnus-newsgroup-begin
  5220. (mail-header-number (car gnus-newsgroup-headers))
  5221. gnus-newsgroup-end
  5222. (mail-header-number
  5223. (gnus-last-element gnus-newsgroup-headers))))
  5224. ;; GROUP is successfully selected.
  5225. (or gnus-newsgroup-headers t)))))
  5226. (defun gnus-compute-unseen-list ()
  5227. ;; The `seen' marks are treated specially.
  5228. (if (not gnus-newsgroup-seen)
  5229. (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
  5230. (setq gnus-newsgroup-unseen
  5231. (gnus-inverse-list-range-intersection
  5232. gnus-newsgroup-articles gnus-newsgroup-seen))))
  5233. (declare-function gnus-get-predicate "gnus-agent" (predicate))
  5234. (defun gnus-summary-display-make-predicate (display)
  5235. (require 'gnus-agent)
  5236. (when (= (length display) 1)
  5237. (setq display (car display)))
  5238. (unless gnus-summary-display-cache
  5239. (dolist (elem (append '((unread . unread)
  5240. (read . read)
  5241. (unseen . unseen))
  5242. gnus-article-mark-lists))
  5243. (push (cons (cdr elem)
  5244. (gnus-byte-compile ;Why bother?
  5245. `(lambda () (gnus-article-marked-p ',(cdr elem)))))
  5246. gnus-summary-display-cache)))
  5247. (let ((gnus-category-predicate-alist gnus-summary-display-cache)
  5248. (gnus-category-predicate-cache gnus-summary-display-cache))
  5249. (gnus-get-predicate display)))
  5250. ;; Uses the dynamically bound `gnus-number' variable.
  5251. (defvar gnus-number)
  5252. (defun gnus-article-marked-p (type &optional article)
  5253. (let ((article (or article gnus-number)))
  5254. (cond
  5255. ((eq type 'tick)
  5256. (memq article gnus-newsgroup-marked))
  5257. ((eq type 'spam)
  5258. (memq article gnus-newsgroup-spam-marked))
  5259. ((eq type 'unsend)
  5260. (memq article gnus-newsgroup-unsendable))
  5261. ((eq type 'undownload)
  5262. (memq article gnus-newsgroup-undownloaded))
  5263. ((eq type 'download)
  5264. (memq article gnus-newsgroup-downloadable))
  5265. ((eq type 'unread)
  5266. (memq article gnus-newsgroup-unreads))
  5267. ((eq type 'read)
  5268. (memq article gnus-newsgroup-reads))
  5269. ((eq type 'dormant)
  5270. (memq article gnus-newsgroup-dormant) )
  5271. ((eq type 'expire)
  5272. (memq article gnus-newsgroup-expirable))
  5273. ((eq type 'reply)
  5274. (memq article gnus-newsgroup-replied))
  5275. ((eq type 'killed)
  5276. (memq article gnus-newsgroup-killed))
  5277. ((eq type 'bookmark)
  5278. (assq article gnus-newsgroup-bookmarks))
  5279. ((eq type 'score)
  5280. (assq article gnus-newsgroup-scored))
  5281. ((eq type 'save)
  5282. (memq article gnus-newsgroup-saved))
  5283. ((eq type 'cache)
  5284. (memq article gnus-newsgroup-cached))
  5285. ((eq type 'forward)
  5286. (memq article gnus-newsgroup-forwarded))
  5287. ((eq type 'seen)
  5288. (not (memq article gnus-newsgroup-unseen)))
  5289. (t t))))
  5290. (defun gnus-articles-to-read (group &optional read-all)
  5291. "Find out what articles the user wants to read."
  5292. (let* ((only-read-p t)
  5293. (articles
  5294. (gnus-list-range-difference
  5295. ;; Select all articles if `read-all' is non-nil, or if there
  5296. ;; are no unread articles.
  5297. (if (or read-all
  5298. (and (zerop (length gnus-newsgroup-marked))
  5299. (zerop (length gnus-newsgroup-unreads)))
  5300. ;; Fetch all if the predicate is non-nil.
  5301. gnus-newsgroup-display)
  5302. ;; We want to select the headers for all the articles in
  5303. ;; the group, so we select either all the active
  5304. ;; articles in the group, or (if that's nil), the
  5305. ;; articles in the cache.
  5306. (or
  5307. (if gnus-newsgroup-maximum-articles
  5308. (let ((active (gnus-active group)))
  5309. (gnus-uncompress-range
  5310. (cons (max (car active)
  5311. (- (cdr active)
  5312. gnus-newsgroup-maximum-articles
  5313. -1))
  5314. (cdr active))))
  5315. (gnus-uncompress-range (gnus-active group)))
  5316. (gnus-cache-articles-in-group group))
  5317. ;; Select only the "normal" subset of articles.
  5318. (setq only-read-p nil)
  5319. (gnus-sorted-nunion
  5320. (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
  5321. gnus-newsgroup-unreads))
  5322. (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
  5323. (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
  5324. (scored (length scored-list))
  5325. (number (length articles))
  5326. (marked (+ (length gnus-newsgroup-marked)
  5327. (length gnus-newsgroup-dormant)))
  5328. (select
  5329. (cond
  5330. ((numberp read-all)
  5331. read-all)
  5332. ((numberp gnus-newsgroup-display)
  5333. gnus-newsgroup-display)
  5334. (t
  5335. (condition-case ()
  5336. (cond
  5337. ((and (or (<= scored marked) (= scored number))
  5338. (numberp gnus-large-newsgroup)
  5339. (> number gnus-large-newsgroup))
  5340. (let* ((cursor-in-echo-area nil)
  5341. (initial (gnus-parameter-large-newsgroup-initial
  5342. gnus-newsgroup-name))
  5343. (default (if only-read-p
  5344. (or initial gnus-large-newsgroup)
  5345. number))
  5346. (input
  5347. (read-string
  5348. (if only-read-p
  5349. (format
  5350. "How many articles from %s (available %d, default %d): "
  5351. (gnus-group-decoded-name
  5352. (gnus-group-real-name gnus-newsgroup-name))
  5353. number default)
  5354. (format
  5355. "How many articles from %s (%d default): "
  5356. (gnus-group-decoded-name
  5357. (gnus-group-real-name gnus-newsgroup-name))
  5358. default))
  5359. nil
  5360. nil
  5361. (number-to-string default))))
  5362. (if (string-match "^[ \t]*$" input) number input)))
  5363. ((and (> scored marked) (< scored number)
  5364. (> (- scored number) 20))
  5365. (let ((input
  5366. (read-string
  5367. (format "%s %s (%d scored, %d total): "
  5368. "How many articles from"
  5369. (gnus-group-decoded-name
  5370. (gnus-group-real-name gnus-newsgroup-name))
  5371. scored number))))
  5372. (if (string-match "^[ \t]*$" input)
  5373. number input)))
  5374. (t number))
  5375. (quit
  5376. (message "Quit getting the articles to read")
  5377. nil))))))
  5378. (setq select (if (stringp select) (string-to-number select) select))
  5379. (if (or (null select) (zerop select))
  5380. select
  5381. (if (and (not (zerop scored)) (<= (abs select) scored))
  5382. (progn
  5383. (setq articles (sort scored-list '<))
  5384. (setq number (length articles)))
  5385. (setq articles (copy-sequence articles)))
  5386. (when (< (abs select) number)
  5387. (if (< select 0)
  5388. ;; Select the N oldest articles.
  5389. (setcdr (nthcdr (1- (abs select)) articles) nil)
  5390. ;; Select the N most recent articles.
  5391. (setq articles (nthcdr (- number select) articles))))
  5392. (setq gnus-newsgroup-unselected
  5393. (gnus-sorted-difference gnus-newsgroup-unreads articles))
  5394. (when gnus-alter-articles-to-read-function
  5395. (setq articles
  5396. (sort
  5397. (funcall gnus-alter-articles-to-read-function
  5398. gnus-newsgroup-name articles)
  5399. '<)))
  5400. articles)))
  5401. (defun gnus-killed-articles (killed articles)
  5402. (let (out)
  5403. (while articles
  5404. (when (inline (gnus-member-of-range (car articles) killed))
  5405. (push (car articles) out))
  5406. (setq articles (cdr articles)))
  5407. out))
  5408. (defun gnus-article-mark-to-type (mark)
  5409. "Return the type of MARK."
  5410. (or (cadr (assq mark gnus-article-special-mark-lists))
  5411. 'list))
  5412. (defun gnus-article-unpropagatable-p (mark)
  5413. "Return whether MARK should be propagated to back end."
  5414. (memq mark gnus-article-unpropagated-mark-lists))
  5415. (defun gnus-adjust-marked-articles (info)
  5416. "Set all article lists and remove all marks that are no longer valid."
  5417. (let* ((marked-lists (gnus-info-marks info))
  5418. (active (gnus-active (gnus-info-group info)))
  5419. (min (car active))
  5420. (max (cdr active))
  5421. (types gnus-article-mark-lists)
  5422. marks var articles article mark mark-type
  5423. bgn end)
  5424. ;; Hack to avoid adjusting marks for imap.
  5425. (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
  5426. 'nnimap)
  5427. (setq min 1))
  5428. (dolist (marks marked-lists)
  5429. (setq mark (car marks)
  5430. mark-type (gnus-article-mark-to-type mark)
  5431. var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
  5432. ;; We set the variable according to the type of the marks list,
  5433. ;; and then adjust the marks to a subset of the active articles.
  5434. (cond
  5435. ;; Adjust "simple" lists - compressed yet unsorted
  5436. ((eq mark-type 'list)
  5437. ;; Simultaneously uncompress and clip to active range
  5438. ;; See gnus-uncompress-range for a description of possible marks
  5439. (let (l lh)
  5440. (if (not (cadr marks))
  5441. (set var nil)
  5442. (setq articles (if (numberp (cddr marks))
  5443. (list (cdr marks))
  5444. (cdr marks))
  5445. lh (cons nil nil)
  5446. l lh)
  5447. (while (setq article (pop articles))
  5448. (cond ((consp article)
  5449. (setq bgn (max (car article) min)
  5450. end (min (cdr article) max))
  5451. (while (<= bgn end)
  5452. (setq l (setcdr l (cons bgn nil))
  5453. bgn (1+ bgn))))
  5454. ((and (<= min article)
  5455. (>= max article))
  5456. (setq l (setcdr l (cons article nil))))))
  5457. (set var (cdr lh)))))
  5458. ;; Adjust assocs.
  5459. ((eq mark-type 'tuple)
  5460. (set var (setq articles (cdr marks)))
  5461. (when (not (listp (cdr (symbol-value var))))
  5462. (set var (list (symbol-value var))))
  5463. (when (not (listp (cdr articles)))
  5464. (setq articles (list articles)))
  5465. (while articles
  5466. (when (or (not (consp (setq article (pop articles))))
  5467. (< (car article) min)
  5468. (> (car article) max))
  5469. (set var (delq article (symbol-value var))))))
  5470. ;; Adjust ranges (sloppily).
  5471. ((eq mark-type 'range)
  5472. (cond
  5473. ((eq mark 'seen)
  5474. ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
  5475. ;; It should be (seen (NUM1 . NUM2)).
  5476. (when (numberp (cddr marks))
  5477. (setcdr marks (list (cdr marks))))
  5478. (setq articles (cdr marks))
  5479. (while (and articles
  5480. (or (and (consp (car articles))
  5481. (> min (cdar articles)))
  5482. (and (numberp (car articles))
  5483. (> min (car articles)))))
  5484. (pop articles))
  5485. (set var articles))
  5486. ((eq mark 'unexist)
  5487. (set var (cdr marks)))))))))
  5488. (defun gnus-update-missing-marks (missing)
  5489. "Go through the list of MISSING articles and remove them from the mark lists."
  5490. (when missing
  5491. (let (var m)
  5492. ;; Go through all types.
  5493. (dolist (elem gnus-article-mark-lists)
  5494. (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
  5495. (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
  5496. (when (symbol-value var)
  5497. ;; This list has articles. So we delete all missing
  5498. ;; articles from it.
  5499. (setq m missing)
  5500. (while m
  5501. (set var (delq (pop m) (symbol-value var))))))))))
  5502. (defun gnus-update-marks ()
  5503. "Enter the various lists of marked articles into the newsgroup info list."
  5504. (let ((types gnus-article-mark-lists)
  5505. (info (gnus-get-info gnus-newsgroup-name))
  5506. type list newmarked symbol delta-marks)
  5507. (when info
  5508. ;; Add all marks lists to the list of marks lists.
  5509. (while (setq type (pop types))
  5510. (setq list (symbol-value
  5511. (setq symbol
  5512. (intern (format "gnus-newsgroup-%s" (car type))))))
  5513. (when list
  5514. ;; Get rid of the entries of the articles that have the
  5515. ;; default score.
  5516. (when (and (eq (cdr type) 'score)
  5517. gnus-save-score
  5518. list)
  5519. (let* ((arts list)
  5520. (prev (cons nil list))
  5521. (all prev))
  5522. (while arts
  5523. (if (or (not (consp (car arts)))
  5524. (= (cdar arts) gnus-summary-default-score))
  5525. (setcdr prev (cdr arts))
  5526. (setq prev arts))
  5527. (setq arts (cdr arts)))
  5528. (setq list (cdr all)))))
  5529. (when (eq (cdr type) 'seen)
  5530. (setq list (gnus-range-add list gnus-newsgroup-unseen)))
  5531. (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
  5532. (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
  5533. (when (and (gnus-check-backend-function
  5534. 'request-set-mark gnus-newsgroup-name)
  5535. (not (gnus-article-unpropagatable-p (cdr type))))
  5536. (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
  5537. ;; Don't do anything about marks for articles we
  5538. ;; didn't actually get any headers for.
  5539. (del
  5540. (gnus-list-range-intersection
  5541. gnus-newsgroup-articles
  5542. (gnus-remove-from-range (gnus-copy-sequence old) list)))
  5543. (add
  5544. (gnus-list-range-intersection
  5545. gnus-newsgroup-articles
  5546. (gnus-remove-from-range
  5547. (gnus-copy-sequence list) old))))
  5548. (when add
  5549. (push (list add 'add (list (cdr type))) delta-marks))
  5550. (when del
  5551. ;; Don't delete marks from outside the active range.
  5552. ;; This shouldn't happen, but is a sanity check.
  5553. (setq del (gnus-sorted-range-intersection
  5554. (gnus-active gnus-newsgroup-name) del))
  5555. (push (list del 'del (list (cdr type))) delta-marks))))
  5556. (when (or list
  5557. (eq (cdr type) 'unexist))
  5558. (push (cons (cdr type) list) newmarked)))
  5559. (when delta-marks
  5560. (unless (gnus-check-group gnus-newsgroup-name)
  5561. (error "Can't open server for %s" gnus-newsgroup-name))
  5562. (gnus-request-set-mark gnus-newsgroup-name delta-marks))
  5563. ;; Enter these new marks into the info of the group.
  5564. (if (nthcdr 3 info)
  5565. (setcar (nthcdr 3 info) newmarked)
  5566. ;; Add the marks lists to the end of the info.
  5567. (when newmarked
  5568. (setcdr (nthcdr 2 info) (list newmarked))))
  5569. ;; Cut off the end of the info if there's nothing else there.
  5570. (let ((i 5))
  5571. (while (and (> i 2)
  5572. (not (nth i info)))
  5573. (when (nthcdr (decf i) info)
  5574. (setcdr (nthcdr i info) nil)))))))
  5575. (defun gnus-set-mode-line (where)
  5576. "Set the mode line of the article or summary buffers.
  5577. If WHERE is `summary', the summary mode line format will be used."
  5578. ;; Is this mode line one we keep updated?
  5579. (when (and (memq where gnus-updated-mode-lines)
  5580. (symbol-value
  5581. (intern (format "gnus-%s-mode-line-format-spec" where))))
  5582. (let (mode-string)
  5583. ;; We evaluate this in the summary buffer since these
  5584. ;; variables are buffer-local to that buffer.
  5585. (with-current-buffer gnus-summary-buffer
  5586. ;; We bind all these variables that are used in the `eval' form
  5587. ;; below.
  5588. (let* ((mformat (symbol-value
  5589. (intern
  5590. (format "gnus-%s-mode-line-format-spec" where))))
  5591. (gnus-tmp-group-name (gnus-mode-string-quote
  5592. (gnus-group-decoded-name
  5593. gnus-newsgroup-name)))
  5594. (gnus-tmp-article-number (or gnus-current-article 0))
  5595. (gnus-tmp-unread gnus-newsgroup-unreads)
  5596. (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
  5597. (gnus-tmp-unselected (length gnus-newsgroup-unselected))
  5598. (gnus-tmp-unread-and-unselected
  5599. (cond ((and (zerop gnus-tmp-unread-and-unticked)
  5600. (zerop gnus-tmp-unselected))
  5601. "")
  5602. ((zerop gnus-tmp-unselected)
  5603. (format "{%d more}" gnus-tmp-unread-and-unticked))
  5604. (t (format "{%d(+%d) more}"
  5605. gnus-tmp-unread-and-unticked
  5606. gnus-tmp-unselected))))
  5607. (gnus-tmp-subject
  5608. (if (and gnus-current-headers
  5609. (vectorp gnus-current-headers))
  5610. (gnus-mode-string-quote
  5611. (mail-header-subject gnus-current-headers))
  5612. ""))
  5613. bufname-length max-len
  5614. gnus-tmp-header) ;; passed as argument to any user-format-funcs
  5615. (setq mode-string (eval mformat))
  5616. (setq bufname-length (if (string-match "%b" mode-string)
  5617. (- (length
  5618. (buffer-name
  5619. (if (eq where 'summary)
  5620. nil
  5621. (get-buffer gnus-article-buffer))))
  5622. 2)
  5623. 0))
  5624. (setq max-len (max 4 (if gnus-mode-non-string-length
  5625. (- (window-width)
  5626. gnus-mode-non-string-length
  5627. bufname-length)
  5628. (length mode-string))))
  5629. ;; We might have to chop a bit of the string off...
  5630. (when (> (length mode-string) max-len)
  5631. (setq mode-string
  5632. (concat (truncate-string-to-width mode-string (- max-len 3))
  5633. "...")))))
  5634. ;; Update the mode line.
  5635. (setq mode-line-buffer-identification
  5636. (gnus-mode-line-buffer-identification (list mode-string)))
  5637. (set-buffer-modified-p t))))
  5638. (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
  5639. "Go through the HEADERS list and add all Xrefs to a hash table.
  5640. The resulting hash table is returned, or nil if no Xrefs were found."
  5641. (let* ((virtual (gnus-virtual-group-p from-newsgroup))
  5642. (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
  5643. (xref-hashtb (gnus-make-hashtable))
  5644. start group entry number xrefs header)
  5645. (while headers
  5646. (setq header (pop headers))
  5647. (when (and (setq xrefs (mail-header-xref header))
  5648. (not (memq (setq number (mail-header-number header))
  5649. unreads)))
  5650. (setq start 0)
  5651. (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
  5652. (setq start (match-end 0))
  5653. (setq group (if prefix
  5654. (concat prefix (substring xrefs (match-beginning 1)
  5655. (match-end 1)))
  5656. (substring xrefs (match-beginning 1) (match-end 1))))
  5657. (setq number
  5658. (string-to-number (substring xrefs (match-beginning 2)
  5659. (match-end 2))))
  5660. (if (setq entry (gnus-gethash group xref-hashtb))
  5661. (setcdr entry (cons number (cdr entry)))
  5662. (gnus-sethash group (cons number nil) xref-hashtb)))))
  5663. (and start xref-hashtb)))
  5664. (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
  5665. "Look through all the headers and mark the Xrefs as read."
  5666. (let ((virtual (gnus-virtual-group-p from-newsgroup))
  5667. name info xref-hashtb idlist method nth4)
  5668. (with-current-buffer gnus-group-buffer
  5669. (when (setq xref-hashtb
  5670. (gnus-create-xref-hashtb from-newsgroup headers unreads))
  5671. (mapatoms
  5672. (lambda (group)
  5673. (unless (string= from-newsgroup (setq name (symbol-name group)))
  5674. (setq idlist (symbol-value group))
  5675. ;; Dead groups are not updated.
  5676. (and (prog1
  5677. (setq info (gnus-get-info name))
  5678. (when (stringp (setq nth4 (gnus-info-method info)))
  5679. (setq nth4 (gnus-server-to-method nth4))))
  5680. ;; Only do the xrefs if the group has the same
  5681. ;; select method as the group we have just read.
  5682. (or (gnus-methods-equal-p
  5683. nth4 (gnus-find-method-for-group from-newsgroup))
  5684. virtual
  5685. (equal nth4 (setq method (gnus-find-method-for-group
  5686. from-newsgroup)))
  5687. (and (equal (car nth4) (car method))
  5688. (equal (nth 1 nth4) (nth 1 method))))
  5689. gnus-use-cross-reference
  5690. (or (not (eq gnus-use-cross-reference t))
  5691. virtual
  5692. ;; Only do cross-references on subscribed
  5693. ;; groups, if that is what is wanted.
  5694. (<= (gnus-info-level info) gnus-level-subscribed))
  5695. (gnus-group-make-articles-read name idlist))))
  5696. xref-hashtb)))))
  5697. (defun gnus-compute-read-articles (group articles)
  5698. (let* ((entry (gnus-group-entry group))
  5699. (info (nth 2 entry))
  5700. (active (gnus-active group))
  5701. ninfo)
  5702. (when entry
  5703. ;; First peel off all invalid article numbers.
  5704. (when active
  5705. (let ((ids articles)
  5706. id first)
  5707. (while (setq id (pop ids))
  5708. (when (and first (> id (cdr active)))
  5709. ;; We'll end up in this situation in one particular
  5710. ;; obscure situation. If you re-scan a group and get
  5711. ;; a new article that is cross-posted to a different
  5712. ;; group that has not been re-scanned, you might get
  5713. ;; crossposted article that has a higher number than
  5714. ;; Gnus believes possible. So we re-activate this
  5715. ;; group as well. This might mean doing the
  5716. ;; crossposting thingy will *increase* the number
  5717. ;; of articles in some groups. Tsk, tsk.
  5718. (setq active (or (gnus-activate-group group) active)))
  5719. (when (or (> id (cdr active))
  5720. (< id (car active)))
  5721. (setq articles (delq id articles))))))
  5722. ;; If the read list is nil, we init it.
  5723. (if (and active
  5724. (null (gnus-info-read info))
  5725. (> (car active) 1))
  5726. (setq ninfo (cons 1 (1- (car active))))
  5727. (setq ninfo (gnus-info-read info)))
  5728. ;; Then we add the read articles to the range.
  5729. (gnus-add-to-range
  5730. ninfo (setq articles (sort articles '<))))))
  5731. (defun gnus-group-make-articles-read (group articles)
  5732. "Update the info of GROUP to say that ARTICLES are read."
  5733. (let* ((num 0)
  5734. (entry (gnus-group-entry group))
  5735. (info (nth 2 entry))
  5736. (active (gnus-active group))
  5737. (set-marks
  5738. (gnus-method-option-p
  5739. (gnus-find-method-for-group group)
  5740. 'server-marks))
  5741. range)
  5742. (if (not entry)
  5743. ;; Group that Gnus doesn't know exists, but still allow the
  5744. ;; backend to set marks.
  5745. (when set-marks
  5746. (gnus-request-set-mark
  5747. group (list (list (gnus-compress-sequence (sort articles #'<))
  5748. 'add '(read)))))
  5749. ;; Normal, subscribed groups.
  5750. (setq range (gnus-compute-read-articles group articles))
  5751. (with-current-buffer gnus-group-buffer
  5752. (gnus-undo-register
  5753. `(progn
  5754. (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
  5755. (gnus-info-set-read ',info ',(gnus-info-read info))
  5756. (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
  5757. (when ,set-marks
  5758. (gnus-request-set-mark
  5759. ,group (list (list ',range 'del '(read)))))
  5760. (gnus-group-update-group ,group t))))
  5761. ;; Add the read articles to the range.
  5762. (gnus-info-set-read info range)
  5763. (when set-marks
  5764. (gnus-request-set-mark group (list (list range 'add '(read)))))
  5765. ;; Then we have to re-compute how many unread
  5766. ;; articles there are in this group.
  5767. (when active
  5768. (cond
  5769. ((not range)
  5770. (setq num (- (1+ (cdr active)) (car active))))
  5771. ((not (listp (cdr range)))
  5772. (setq num (- (cdr active) (- (1+ (cdr range))
  5773. (car range)))))
  5774. (t
  5775. (while range
  5776. (if (numberp (car range))
  5777. (setq num (1+ num))
  5778. (setq num (+ num (- (1+ (cdar range)) (caar range)))))
  5779. (setq range (cdr range)))
  5780. (setq num (- (cdr active) num))))
  5781. ;; Update the number of unread articles.
  5782. (setcar entry num)
  5783. ;; Update the group buffer.
  5784. (unless (gnus-ephemeral-group-p group)
  5785. (gnus-group-update-group group t))))))
  5786. (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
  5787. (let ((cur nntp-server-buffer)
  5788. (dependencies
  5789. (or dependencies
  5790. (with-current-buffer gnus-summary-buffer
  5791. gnus-newsgroup-dependencies)))
  5792. headers id end ref number
  5793. (mail-parse-charset gnus-newsgroup-charset)
  5794. (mail-parse-ignored-charsets
  5795. (save-current-buffer (condition-case nil
  5796. (set-buffer gnus-summary-buffer)
  5797. (error))
  5798. gnus-newsgroup-ignored-charsets)))
  5799. (with-current-buffer nntp-server-buffer
  5800. ;; Translate all TAB characters into SPACE characters.
  5801. (subst-char-in-region (point-min) (point-max) ?\t ? t)
  5802. (subst-char-in-region (point-min) (point-max) ?\r ? t)
  5803. (ietf-drums-unfold-fws)
  5804. (gnus-run-hooks 'gnus-parse-headers-hook)
  5805. (let ((case-fold-search t)
  5806. in-reply-to header p lines chars)
  5807. (goto-char (point-min))
  5808. ;; Search to the beginning of the next header. Error messages
  5809. ;; do not begin with 2 or 3.
  5810. (while (re-search-forward "^[23][0-9]+ " nil t)
  5811. (setq id nil
  5812. ref nil)
  5813. ;; This implementation of this function, with nine
  5814. ;; search-forwards instead of the one re-search-forward and
  5815. ;; a case (which basically was the old function) is actually
  5816. ;; about twice as fast, even though it looks messier. You
  5817. ;; can't have everything, I guess. Speed and elegance
  5818. ;; doesn't always go hand in hand.
  5819. (setq
  5820. header
  5821. (vector
  5822. ;; Number.
  5823. (prog1
  5824. (setq number (read cur))
  5825. (end-of-line)
  5826. (setq p (point))
  5827. (narrow-to-region (point)
  5828. (or (and (search-forward "\n.\n" nil t)
  5829. (- (point) 2))
  5830. (point))))
  5831. ;; Subject.
  5832. (progn
  5833. (goto-char p)
  5834. (if (search-forward "\nsubject:" nil t)
  5835. (funcall gnus-decode-encoded-word-function
  5836. (nnheader-header-value))
  5837. "(none)"))
  5838. ;; From.
  5839. (progn
  5840. (goto-char p)
  5841. (if (search-forward "\nfrom:" nil t)
  5842. (funcall gnus-decode-encoded-address-function
  5843. (nnheader-header-value))
  5844. "(nobody)"))
  5845. ;; Date.
  5846. (progn
  5847. (goto-char p)
  5848. (if (search-forward "\ndate:" nil t)
  5849. (nnheader-header-value) ""))
  5850. ;; Message-ID.
  5851. (progn
  5852. (goto-char p)
  5853. (setq id (if (re-search-forward
  5854. "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
  5855. ;; We do it this way to make sure the Message-ID
  5856. ;; is (somewhat) syntactically valid.
  5857. (buffer-substring (match-beginning 1)
  5858. (match-end 1))
  5859. ;; If there was no message-id, we just fake one
  5860. ;; to make subsequent routines simpler.
  5861. (nnheader-generate-fake-message-id number))))
  5862. ;; References.
  5863. (progn
  5864. (goto-char p)
  5865. (if (search-forward "\nreferences:" nil t)
  5866. (progn
  5867. (setq end (point))
  5868. (prog1
  5869. (nnheader-header-value)
  5870. (setq ref
  5871. (buffer-substring
  5872. (progn
  5873. (end-of-line)
  5874. (search-backward ">" end t)
  5875. (1+ (point)))
  5876. (progn
  5877. (search-backward "<" end t)
  5878. (point))))))
  5879. ;; Get the references from the in-reply-to header if there
  5880. ;; were no references and the in-reply-to header looks
  5881. ;; promising.
  5882. (if (and (search-forward "\nin-reply-to:" nil t)
  5883. (setq in-reply-to (nnheader-header-value))
  5884. (string-match "<[^>]+>" in-reply-to))
  5885. (let (ref2)
  5886. (setq ref (substring in-reply-to (match-beginning 0)
  5887. (match-end 0)))
  5888. (while (string-match "<[^>]+>" in-reply-to (match-end 0))
  5889. (setq ref2 (substring in-reply-to (match-beginning 0)
  5890. (match-end 0)))
  5891. (when (> (length ref2) (length ref))
  5892. (setq ref ref2)))
  5893. ref)
  5894. (setq ref nil))))
  5895. ;; Chars.
  5896. (progn
  5897. (goto-char p)
  5898. (if (search-forward "\nchars: " nil t)
  5899. (if (numberp (setq chars (ignore-errors (read cur))))
  5900. chars -1)
  5901. -1))
  5902. ;; Lines.
  5903. (progn
  5904. (goto-char p)
  5905. (if (search-forward "\nlines: " nil t)
  5906. (if (numberp (setq lines (ignore-errors (read cur))))
  5907. lines -1)
  5908. -1))
  5909. ;; Xref.
  5910. (progn
  5911. (goto-char p)
  5912. (and (search-forward "\nxref:" nil t)
  5913. (nnheader-header-value)))
  5914. ;; Extra.
  5915. (when gnus-extra-headers
  5916. (let ((extra gnus-extra-headers)
  5917. out)
  5918. (while extra
  5919. (goto-char p)
  5920. (when (search-forward
  5921. (concat "\n" (symbol-name (car extra)) ":") nil t)
  5922. (push (cons (car extra) (nnheader-header-value))
  5923. out))
  5924. (pop extra))
  5925. out))))
  5926. (when (equal id ref)
  5927. (setq ref nil))
  5928. (when gnus-alter-header-function
  5929. (funcall gnus-alter-header-function header)
  5930. (setq id (mail-header-id header)
  5931. ref (gnus-parent-id (mail-header-references header))))
  5932. (when (setq header
  5933. (gnus-dependencies-add-header
  5934. header dependencies force-new))
  5935. (push header headers))
  5936. (goto-char (point-max))
  5937. (widen))
  5938. (nreverse headers)))))
  5939. ;; Goes through the xover lines and returns a list of vectors
  5940. (defun gnus-get-newsgroup-headers-xover (sequence &optional
  5941. force-new dependencies
  5942. group also-fetch-heads)
  5943. "Parse the news overview data in the server buffer.
  5944. Return a list of headers that match SEQUENCE (see
  5945. `nntp-retrieve-headers')."
  5946. ;; Get the Xref when the users reads the articles since most/some
  5947. ;; NNTP servers do not include Xrefs when using XOVER.
  5948. (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
  5949. (let ((mail-parse-charset gnus-newsgroup-charset)
  5950. (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
  5951. (cur nntp-server-buffer)
  5952. (dependencies (or dependencies gnus-newsgroup-dependencies))
  5953. (allp (cond
  5954. ((eq gnus-read-all-available-headers t)
  5955. t)
  5956. ((and (stringp gnus-read-all-available-headers)
  5957. group)
  5958. (string-match gnus-read-all-available-headers group))
  5959. (t
  5960. nil)))
  5961. number headers header)
  5962. (with-current-buffer nntp-server-buffer
  5963. (subst-char-in-region (point-min) (point-max) ?\r ? t)
  5964. ;; Allow the user to mangle the headers before parsing them.
  5965. (gnus-run-hooks 'gnus-parse-headers-hook)
  5966. (goto-char (point-min))
  5967. (gnus-parse-without-error
  5968. (while (and (or sequence allp)
  5969. (not (eobp)))
  5970. (setq number (read cur))
  5971. (when (not allp)
  5972. (while (and sequence
  5973. (< (car sequence) number))
  5974. (setq sequence (cdr sequence))))
  5975. (when (and (or allp
  5976. (and sequence
  5977. (eq number (car sequence))))
  5978. (progn
  5979. (setq sequence (cdr sequence))
  5980. (setq header (inline
  5981. (gnus-nov-parse-line
  5982. number dependencies force-new)))))
  5983. (push header headers))
  5984. (forward-line 1)))
  5985. ;; A common bug in inn is that if you have posted an article and
  5986. ;; then retrieves the active file, it will answer correctly --
  5987. ;; the new article is included. However, a NOV entry for the
  5988. ;; article may not have been generated yet, so this may fail.
  5989. ;; We work around this problem by retrieving the last few
  5990. ;; headers using HEAD.
  5991. (if (or (not also-fetch-heads)
  5992. (not sequence))
  5993. ;; We (probably) got all the headers.
  5994. (nreverse headers)
  5995. (let ((gnus-nov-is-evil t))
  5996. (nconc
  5997. (nreverse headers)
  5998. (when (eq (gnus-retrieve-headers sequence group) 'headers)
  5999. (gnus-get-newsgroup-headers))))))))
  6000. (defun gnus-article-get-xrefs ()
  6001. "Fill in the Xref value in `gnus-current-headers', if necessary.
  6002. This is meant to be called in `gnus-article-internal-prepare-hook'."
  6003. (let ((headers (with-current-buffer gnus-summary-buffer
  6004. gnus-current-headers)))
  6005. (or (not gnus-use-cross-reference)
  6006. (not headers)
  6007. (and (mail-header-xref headers)
  6008. (not (string= (mail-header-xref headers) "")))
  6009. (let ((case-fold-search t)
  6010. xref)
  6011. (save-restriction
  6012. (nnheader-narrow-to-headers)
  6013. (goto-char (point-min))
  6014. (when (or (and (not (eobp))
  6015. (eq (downcase (char-after)) ?x)
  6016. (looking-at "Xref:"))
  6017. (search-forward "\nXref:" nil t))
  6018. (goto-char (1+ (match-end 0)))
  6019. (setq xref (buffer-substring (point) (point-at-eol)))
  6020. (mail-header-set-xref headers xref)))))))
  6021. (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
  6022. "Find article ID and insert the summary line for that article.
  6023. OLD-HEADER can either be a header or a line number to insert
  6024. the subject line on.
  6025. If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
  6026. and OLD-HEADER will be used when the summary line is inserted,
  6027. too, instead of trying to fetch new headers."
  6028. (let* ((line (and (numberp old-header) old-header))
  6029. (old-header (and (vectorp old-header) old-header))
  6030. (header (cond ((and old-header use-old-header)
  6031. old-header)
  6032. ((and (numberp id)
  6033. (gnus-number-to-header id))
  6034. (gnus-number-to-header id))
  6035. (t
  6036. (gnus-read-header id))))
  6037. (number (and (numberp id) id))
  6038. d)
  6039. (when header
  6040. ;; Rebuild the thread that this article is part of and go to the
  6041. ;; article we have fetched.
  6042. (when (and (not gnus-show-threads)
  6043. old-header)
  6044. (when (and number
  6045. (setq d (gnus-data-find (mail-header-number old-header))))
  6046. (goto-char (gnus-data-pos d))
  6047. (gnus-data-remove
  6048. number
  6049. (- (point-at-bol)
  6050. (prog1
  6051. (1+ (point-at-eol))
  6052. (gnus-delete-line))))))
  6053. ;; Remove list identifiers from subject.
  6054. (let ((gnus-newsgroup-headers (list header)))
  6055. (gnus-summary-remove-list-identifiers))
  6056. (when old-header
  6057. (mail-header-set-number header (mail-header-number old-header)))
  6058. (setq gnus-newsgroup-sparse
  6059. (delq (setq number (mail-header-number header))
  6060. gnus-newsgroup-sparse))
  6061. (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
  6062. (push number gnus-newsgroup-limit)
  6063. (gnus-rebuild-thread (mail-header-id header) line)
  6064. (gnus-summary-goto-subject number nil t))
  6065. (when (and (numberp number)
  6066. (> number 0))
  6067. ;; We have to update the boundaries even if we can't fetch the
  6068. ;; article if ID is a number -- so that the next `P' or `N'
  6069. ;; command will fetch the previous (or next) article even
  6070. ;; if the one we tried to fetch this time has been canceled.
  6071. (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
  6072. (setq gnus-newsgroup-end number))
  6073. (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
  6074. (setq gnus-newsgroup-begin number))
  6075. (setq gnus-newsgroup-unselected
  6076. (delq number gnus-newsgroup-unselected)))
  6077. ;; Report back a success?
  6078. (and header (mail-header-number header))))
  6079. ;;; Process/prefix in the summary buffer
  6080. (defun gnus-summary-work-articles (n)
  6081. "Return a list of articles to be worked upon.
  6082. The prefix argument, the list of process marked articles, and the
  6083. current article will be taken into consideration."
  6084. (with-current-buffer gnus-summary-buffer
  6085. (cond
  6086. (n
  6087. ;; A numerical prefix has been given.
  6088. (setq n (prefix-numeric-value n))
  6089. (let ((backward (< n 0))
  6090. (n (abs (prefix-numeric-value n)))
  6091. articles article)
  6092. (save-excursion
  6093. (while
  6094. (and (> n 0)
  6095. (push (setq article (gnus-summary-article-number))
  6096. articles)
  6097. (if backward
  6098. (gnus-summary-find-prev nil article)
  6099. (gnus-summary-find-next nil article)))
  6100. (decf n)))
  6101. (nreverse articles)))
  6102. ((and (gnus-region-active-p) (mark))
  6103. (message "region active")
  6104. ;; Work on the region between point and mark.
  6105. (let ((max (max (point) (mark)))
  6106. articles article)
  6107. (save-excursion
  6108. (goto-char (min (point) (mark)))
  6109. (while
  6110. (and
  6111. (push (setq article (gnus-summary-article-number)) articles)
  6112. (gnus-summary-find-next nil article)
  6113. (< (point) max)))
  6114. (nreverse articles))))
  6115. (gnus-newsgroup-processable
  6116. ;; There are process-marked articles present.
  6117. ;; Save current state.
  6118. (gnus-summary-save-process-mark)
  6119. ;; Return the list.
  6120. (reverse gnus-newsgroup-processable))
  6121. (t
  6122. ;; Just return the current article.
  6123. (list (gnus-summary-article-number))))))
  6124. (defmacro gnus-summary-iterate (arg &rest forms)
  6125. "Iterate over the process/prefixed articles and do FORMS.
  6126. ARG is the interactive prefix given to the command. FORMS will be
  6127. executed with point over the summary line of the articles."
  6128. (let ((articles (make-symbol "gnus-summary-iterate-articles")))
  6129. `(let ((,articles (gnus-summary-work-articles ,arg)))
  6130. (while ,articles
  6131. (gnus-summary-goto-subject (car ,articles))
  6132. ,@forms
  6133. (pop ,articles)))))
  6134. (put 'gnus-summary-iterate 'lisp-indent-function 1)
  6135. (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
  6136. (defun gnus-summary-save-process-mark ()
  6137. "Push the current set of process marked articles on the stack."
  6138. (interactive)
  6139. (push (copy-sequence gnus-newsgroup-processable)
  6140. gnus-newsgroup-process-stack))
  6141. (defun gnus-summary-kill-process-mark ()
  6142. "Push the current set of process marked articles on the stack and unmark."
  6143. (interactive)
  6144. (gnus-summary-save-process-mark)
  6145. (gnus-summary-unmark-all-processable))
  6146. (defun gnus-summary-yank-process-mark ()
  6147. "Pop the last process mark state off the stack and restore it."
  6148. (interactive)
  6149. (unless gnus-newsgroup-process-stack
  6150. (error "Empty mark stack"))
  6151. (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
  6152. (defun gnus-summary-process-mark-set (set)
  6153. "Make SET into the current process marked articles."
  6154. (gnus-summary-unmark-all-processable)
  6155. (mapc 'gnus-summary-set-process-mark set))
  6156. ;;; Searching and stuff
  6157. (defun gnus-summary-search-group (&optional backward use-level)
  6158. "Search for next unread newsgroup.
  6159. If optional argument BACKWARD is non-nil, search backward instead."
  6160. (with-current-buffer gnus-group-buffer
  6161. (when (gnus-group-search-forward
  6162. backward nil (if use-level (gnus-group-group-level) nil))
  6163. (gnus-group-group-name))))
  6164. (defun gnus-summary-best-group (&optional exclude-group)
  6165. "Find the name of the best unread group.
  6166. If EXCLUDE-GROUP, do not go to this group."
  6167. (with-current-buffer gnus-group-buffer
  6168. (save-excursion
  6169. (gnus-group-best-unread-group exclude-group))))
  6170. (defun gnus-summary-find-next (&optional unread article backward)
  6171. (if backward
  6172. (gnus-summary-find-prev unread article)
  6173. (let* ((dummy (gnus-summary-article-intangible-p))
  6174. (article (or article (gnus-summary-article-number)))
  6175. (data (gnus-data-find-list article))
  6176. result)
  6177. (when (and (not dummy)
  6178. (or (not gnus-summary-check-current)
  6179. (not unread)
  6180. (not (gnus-data-unread-p (car data)))))
  6181. (setq data (cdr data)))
  6182. (when (setq result
  6183. (if unread
  6184. (progn
  6185. (while data
  6186. (unless (memq (gnus-data-number (car data))
  6187. (cond
  6188. ((eq gnus-auto-goto-ignores
  6189. 'always-undownloaded)
  6190. gnus-newsgroup-undownloaded)
  6191. (gnus-plugged
  6192. nil)
  6193. ((eq gnus-auto-goto-ignores
  6194. 'unfetched)
  6195. gnus-newsgroup-unfetched)
  6196. ((eq gnus-auto-goto-ignores
  6197. 'undownloaded)
  6198. gnus-newsgroup-undownloaded)))
  6199. (when (gnus-data-unread-p (car data))
  6200. (setq result (car data)
  6201. data nil)))
  6202. (setq data (cdr data)))
  6203. result)
  6204. (car data)))
  6205. (goto-char (gnus-data-pos result))
  6206. (gnus-data-number result)))))
  6207. (defun gnus-summary-find-prev (&optional unread article)
  6208. (let* ((eobp (eobp))
  6209. (article (or article (gnus-summary-article-number)))
  6210. (data (gnus-data-find-list article (gnus-data-list 'rev)))
  6211. result)
  6212. (when (and (not eobp)
  6213. (or (not gnus-summary-check-current)
  6214. (not unread)
  6215. (not (gnus-data-unread-p (car data)))))
  6216. (setq data (cdr data)))
  6217. (when (setq result
  6218. (if unread
  6219. (progn
  6220. (while data
  6221. (unless (memq (gnus-data-number (car data))
  6222. (cond
  6223. ((eq gnus-auto-goto-ignores
  6224. 'always-undownloaded)
  6225. gnus-newsgroup-undownloaded)
  6226. (gnus-plugged
  6227. nil)
  6228. ((eq gnus-auto-goto-ignores
  6229. 'unfetched)
  6230. gnus-newsgroup-unfetched)
  6231. ((eq gnus-auto-goto-ignores
  6232. 'undownloaded)
  6233. gnus-newsgroup-undownloaded)))
  6234. (when (gnus-data-unread-p (car data))
  6235. (setq result (car data)
  6236. data nil)))
  6237. (setq data (cdr data)))
  6238. result)
  6239. (car data)))
  6240. (goto-char (gnus-data-pos result))
  6241. (gnus-data-number result))))
  6242. (defun gnus-summary-find-subject (subject &optional unread backward article)
  6243. (let* ((simp-subject (gnus-simplify-subject-fully subject))
  6244. (article (or article (gnus-summary-article-number)))
  6245. (articles (gnus-data-list backward))
  6246. (arts (gnus-data-find-list article articles))
  6247. result)
  6248. (when (or (not gnus-summary-check-current)
  6249. (not unread)
  6250. (not (gnus-data-unread-p (car arts))))
  6251. (setq arts (cdr arts)))
  6252. (while arts
  6253. (and (or (not unread)
  6254. (gnus-data-unread-p (car arts)))
  6255. (vectorp (gnus-data-header (car arts)))
  6256. (gnus-subject-equal
  6257. simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
  6258. (setq result (car arts)
  6259. arts nil))
  6260. (setq arts (cdr arts)))
  6261. (and result
  6262. (goto-char (gnus-data-pos result))
  6263. (gnus-data-number result))))
  6264. (defun gnus-summary-search-forward (&optional unread subject backward)
  6265. "Search forward for an article.
  6266. If UNREAD, look for unread articles. If SUBJECT, look for
  6267. articles with that subject. If BACKWARD, search backward instead."
  6268. (cond (subject (gnus-summary-find-subject subject unread backward))
  6269. (backward (gnus-summary-find-prev unread))
  6270. (t (gnus-summary-find-next unread))))
  6271. (defun gnus-recenter (&optional n)
  6272. "Center point in window and redisplay frame.
  6273. Also do horizontal recentering."
  6274. (interactive "P")
  6275. (when (and gnus-auto-center-summary
  6276. (not (eq gnus-auto-center-summary 'vertical)))
  6277. (gnus-horizontal-recenter))
  6278. (if (fboundp 'recenter-top-bottom)
  6279. (recenter-top-bottom n)
  6280. (recenter n)))
  6281. (put 'gnus-recenter 'isearch-scroll t)
  6282. (defun gnus-forward-line-ignore-invisible (n)
  6283. "Move N lines forward (backward if N is negative).
  6284. Like forward-line, but skip over (and don't count) invisible lines."
  6285. (let (done)
  6286. (while (and (> n 0) (not done))
  6287. ;; If the following character is currently invisible,
  6288. ;; skip all characters with that same `invisible' property value.
  6289. (while (gnus-invisible-p (point))
  6290. (goto-char (gnus-next-char-property-change (point))))
  6291. (forward-line 1)
  6292. (if (eobp)
  6293. (setq done t)
  6294. (setq n (1- n))))
  6295. (while (and (< n 0) (not done))
  6296. (forward-line -1)
  6297. (if (bobp) (setq done t)
  6298. (setq n (1+ n))
  6299. (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
  6300. (goto-char (gnus-previous-char-property-change (point))))))))
  6301. (defun gnus-summary-recenter ()
  6302. "Center point in the summary window.
  6303. If `gnus-auto-center-summary' is nil, or the article buffer isn't
  6304. displayed, no centering will be performed."
  6305. ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
  6306. ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
  6307. (interactive)
  6308. ;; The user has to want it.
  6309. (when gnus-auto-center-summary
  6310. (let* ((top (cond ((< (window-height) 4) 0)
  6311. ((< (window-height) 7) 1)
  6312. (t (if (numberp gnus-auto-center-summary)
  6313. gnus-auto-center-summary
  6314. (/ (1- (window-height)) 2)))))
  6315. (height (1- (window-height)))
  6316. (bottom (save-excursion
  6317. (goto-char (point-max))
  6318. (gnus-forward-line-ignore-invisible (- height))
  6319. (point)))
  6320. (window (get-buffer-window (current-buffer))))
  6321. (when (get-buffer-window gnus-article-buffer)
  6322. ;; Only do recentering when the article buffer is displayed,
  6323. ;; Set the window start to either `bottom', which is the biggest
  6324. ;; possible valid number, or the second line from the top,
  6325. ;; whichever is the least.
  6326. (let ((top-pos (save-excursion
  6327. (gnus-forward-line-ignore-invisible (- top))
  6328. (point))))
  6329. (if (> bottom top-pos)
  6330. ;; Keep the second line from the top visible
  6331. (set-window-start window top-pos)
  6332. ;; Try to keep the bottom line visible; if it's partially
  6333. ;; obscured, either scroll one more line to make it fully
  6334. ;; visible, or revert to using TOP-POS.
  6335. (save-excursion
  6336. (goto-char (point-max))
  6337. (gnus-forward-line-ignore-invisible -1)
  6338. (let ((last-line-start (point)))
  6339. (goto-char bottom)
  6340. (set-window-start window (point) t)
  6341. (when (not (pos-visible-in-window-p last-line-start window))
  6342. (gnus-forward-line-ignore-invisible 1)
  6343. (set-window-start window (min (point) top-pos) t)))))))
  6344. ;; Do horizontal recentering while we're at it.
  6345. (when (and (get-buffer-window (current-buffer) t)
  6346. (not (eq gnus-auto-center-summary 'vertical)))
  6347. (let ((selected (selected-window)))
  6348. (select-window (get-buffer-window (current-buffer) t))
  6349. (gnus-summary-position-point)
  6350. (gnus-horizontal-recenter)
  6351. (select-window selected))))))
  6352. (defun gnus-summary-jump-to-group (newsgroup)
  6353. "Move point to NEWSGROUP in group mode buffer."
  6354. ;; Keep update point of group mode buffer if visible.
  6355. (if (eq (current-buffer) (get-buffer gnus-group-buffer))
  6356. (save-window-excursion
  6357. ;; Take care of tree window mode.
  6358. (when (get-buffer-window gnus-group-buffer)
  6359. (pop-to-buffer gnus-group-buffer))
  6360. (gnus-group-jump-to-group newsgroup))
  6361. (save-excursion
  6362. ;; Take care of tree window mode.
  6363. (if (get-buffer-window gnus-group-buffer 0)
  6364. (pop-to-buffer gnus-group-buffer)
  6365. (set-buffer gnus-group-buffer))
  6366. (gnus-group-jump-to-group newsgroup))))
  6367. ;; This function returns a list of article numbers based on the
  6368. ;; difference between the ranges of read articles in this group and
  6369. ;; the range of active articles.
  6370. (defun gnus-list-of-unread-articles (group)
  6371. (let* ((read (gnus-info-read (gnus-get-info group)))
  6372. (active (or (gnus-active group) (gnus-activate-group group)))
  6373. (last (or (cdr active)
  6374. (error "Group %s couldn't be activated " group)))
  6375. (bottom (if gnus-newsgroup-maximum-articles
  6376. (max (car active)
  6377. (- last gnus-newsgroup-maximum-articles -1))
  6378. (car active)))
  6379. first nlast unread)
  6380. ;; If none are read, then all are unread.
  6381. (if (not read)
  6382. (setq first bottom)
  6383. ;; If the range of read articles is a single range, then the
  6384. ;; first unread article is the article after the last read
  6385. ;; article. Sounds logical, doesn't it?
  6386. (if (and (not (listp (cdr read)))
  6387. (or (< (car read) bottom)
  6388. (progn (setq read (list read))
  6389. nil)))
  6390. (setq first (max bottom (1+ (cdr read))))
  6391. ;; `read' is a list of ranges.
  6392. (when (/= (setq nlast (or (and (numberp (car read)) (car read))
  6393. (caar read)))
  6394. 1)
  6395. (setq first bottom))
  6396. (while read
  6397. (when first
  6398. (while (< first nlast)
  6399. (setq unread (cons first unread)
  6400. first (1+ first))))
  6401. (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
  6402. (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
  6403. (setq read (cdr read)))))
  6404. ;; And add the last unread articles.
  6405. (while (<= first last)
  6406. (setq unread (cons first unread)
  6407. first (1+ first)))
  6408. ;; Return the list of unread articles.
  6409. (delq 0 (nreverse unread))))
  6410. (defun gnus-list-of-read-articles (group)
  6411. "Return a list of unread, unticked and non-dormant articles."
  6412. (let* ((info (gnus-get-info group))
  6413. (marked (gnus-info-marks info))
  6414. (active (gnus-active group)))
  6415. (and info active
  6416. (gnus-list-range-difference
  6417. (gnus-list-range-difference
  6418. (gnus-sorted-complement
  6419. (gnus-uncompress-range
  6420. (if gnus-newsgroup-maximum-articles
  6421. (cons (max (car active)
  6422. (- (cdr active)
  6423. gnus-newsgroup-maximum-articles
  6424. -1))
  6425. (cdr active))
  6426. active))
  6427. (gnus-list-of-unread-articles group))
  6428. (cdr (assq 'dormant marked)))
  6429. (cdr (assq 'tick marked))))))
  6430. ;; This function returns a sequence of article numbers based on the
  6431. ;; difference between the ranges of read articles in this group and
  6432. ;; the range of active articles.
  6433. (defun gnus-sequence-of-unread-articles (group)
  6434. (let* ((read (gnus-info-read (gnus-get-info group)))
  6435. (active (or (gnus-active group) (gnus-activate-group group)))
  6436. (last (cdr active))
  6437. (bottom (if gnus-newsgroup-maximum-articles
  6438. (max (car active)
  6439. (- last gnus-newsgroup-maximum-articles -1))
  6440. (car active)))
  6441. first nlast unread)
  6442. ;; If none are read, then all are unread.
  6443. (if (not read)
  6444. (setq first bottom)
  6445. ;; If the range of read articles is a single range, then the
  6446. ;; first unread article is the article after the last read
  6447. ;; article. Sounds logical, doesn't it?
  6448. (if (and (not (listp (cdr read)))
  6449. (or (< (car read) bottom)
  6450. (progn (setq read (list read))
  6451. nil)))
  6452. (setq first (max bottom (1+ (cdr read))))
  6453. ;; `read' is a list of ranges.
  6454. (when (/= (setq nlast (or (and (numberp (car read)) (car read))
  6455. (caar read)))
  6456. 1)
  6457. (setq first bottom))
  6458. (while read
  6459. (when first
  6460. (push (cons first nlast) unread))
  6461. (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
  6462. (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
  6463. (setq read (cdr read)))))
  6464. ;; And add the last unread articles.
  6465. (cond ((not (and first last))
  6466. nil)
  6467. ((< first last)
  6468. (push (cons first last) unread))
  6469. ((= first last)
  6470. (push first unread)))
  6471. ;; Return the sequence of unread articles.
  6472. (delq 0 (nreverse unread))))
  6473. ;; Various summary commands
  6474. (defun gnus-summary-select-article-buffer ()
  6475. "Reconfigure windows to show the article buffer.
  6476. If `gnus-widen-article-window' is set, show only the article
  6477. buffer."
  6478. (interactive)
  6479. (if (not (gnus-buffer-live-p gnus-article-buffer))
  6480. (error "There is no article buffer for this summary buffer")
  6481. (unless (get-buffer-window gnus-article-buffer)
  6482. (gnus-summary-show-article))
  6483. (gnus-configure-windows
  6484. (if gnus-widen-article-window
  6485. 'only-article
  6486. 'article)
  6487. t)
  6488. (select-window (get-buffer-window gnus-article-buffer))))
  6489. (defun gnus-summary-universal-argument (arg)
  6490. "Perform any operation on all articles that are process/prefixed."
  6491. (interactive "P")
  6492. (let ((articles (gnus-summary-work-articles arg))
  6493. func article)
  6494. (if (eq
  6495. (setq
  6496. func
  6497. (key-binding
  6498. (read-key-sequence
  6499. (substitute-command-keys
  6500. "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
  6501. 'undefined)
  6502. (gnus-error 1 "Undefined key")
  6503. (save-excursion
  6504. (while articles
  6505. (gnus-summary-goto-subject (setq article (pop articles)))
  6506. (let (gnus-newsgroup-processable)
  6507. (command-execute func))
  6508. (gnus-summary-remove-process-mark article)))))
  6509. (gnus-summary-position-point))
  6510. (defun gnus-summary-toggle-truncation (&optional arg)
  6511. "Toggle truncation of summary lines.
  6512. With ARG, turn line truncation on if ARG is positive."
  6513. (interactive "P")
  6514. (setq truncate-lines
  6515. (if (null arg) (not truncate-lines)
  6516. (> (prefix-numeric-value arg) 0)))
  6517. (redraw-display))
  6518. (defun gnus-summary-find-for-reselect ()
  6519. "Return the number of an article to stay on across a reselect.
  6520. The current article is considered, then following articles, then previous
  6521. articles. An article is sought which is not canceled and isn't a temporary
  6522. insertion from another group. If there's no such then return a dummy 0."
  6523. (let (found)
  6524. (dolist (rev '(nil t))
  6525. (unless found ; don't demand the reverse list if we don't need it
  6526. (let ((data (gnus-data-find-list
  6527. (gnus-summary-article-number) (gnus-data-list rev))))
  6528. (while (and data (not found))
  6529. (if (and (< 0 (gnus-data-number (car data)))
  6530. (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
  6531. (setq found (gnus-data-number (car data))))
  6532. (setq data (cdr data))))))
  6533. (or found 0)))
  6534. (defun gnus-summary-reselect-current-group (&optional all rescan)
  6535. "Exit and then reselect the current newsgroup.
  6536. The prefix argument ALL means to select all articles."
  6537. (interactive "P")
  6538. (when (gnus-ephemeral-group-p gnus-newsgroup-name)
  6539. (error "Ephemeral groups can't be reselected"))
  6540. (let ((current-subject (gnus-summary-find-for-reselect))
  6541. (group gnus-newsgroup-name))
  6542. (setq gnus-newsgroup-begin nil)
  6543. (gnus-summary-exit nil 'leave-hidden)
  6544. ;; We have to adjust the point of group mode buffer because
  6545. ;; point was moved to the next unread newsgroup by exiting.
  6546. (gnus-summary-jump-to-group group)
  6547. (when rescan
  6548. (save-excursion
  6549. (gnus-group-get-new-news-this-group 1)))
  6550. (gnus-group-read-group all t)
  6551. (gnus-summary-goto-subject current-subject nil t)))
  6552. (defun gnus-summary-rescan-group (&optional all)
  6553. "Exit the newsgroup, ask for new articles, and select the newsgroup."
  6554. (interactive "P")
  6555. (let ((config gnus-current-window-configuration))
  6556. (gnus-summary-reselect-current-group all t)
  6557. (gnus-configure-windows config)
  6558. (when (eq config 'article)
  6559. (gnus-summary-select-article))))
  6560. (defun gnus-summary-update-info (&optional non-destructive)
  6561. (save-excursion
  6562. (let ((group gnus-newsgroup-name))
  6563. (when group
  6564. (when gnus-newsgroup-kill-headers
  6565. (setq gnus-newsgroup-killed
  6566. (gnus-compress-sequence
  6567. (gnus-sorted-union
  6568. (gnus-list-range-intersection
  6569. gnus-newsgroup-unselected gnus-newsgroup-killed)
  6570. gnus-newsgroup-unreads)
  6571. t)))
  6572. (unless (listp (cdr gnus-newsgroup-killed))
  6573. (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
  6574. (let ((headers gnus-newsgroup-headers)
  6575. (ephemeral-p (gnus-ephemeral-group-p group))
  6576. info)
  6577. (unless ephemeral-p
  6578. (setq info (copy-sequence (gnus-get-info group))
  6579. info (delq (gnus-info-params info) info)))
  6580. ;; Set the new ranges of read articles.
  6581. (with-current-buffer gnus-group-buffer
  6582. (gnus-undo-force-boundary))
  6583. (gnus-update-read-articles
  6584. group (gnus-sorted-union
  6585. gnus-newsgroup-unreads gnus-newsgroup-unselected))
  6586. ;; Set the current article marks.
  6587. (let ((gnus-newsgroup-scored
  6588. (if (and (not gnus-save-score)
  6589. (not non-destructive))
  6590. nil
  6591. gnus-newsgroup-scored)))
  6592. (save-excursion
  6593. (gnus-update-marks)))
  6594. ;; Do the cross-ref thing.
  6595. (when gnus-use-cross-reference
  6596. (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
  6597. ;; Do not switch windows but change the buffer to work.
  6598. (set-buffer gnus-group-buffer)
  6599. (unless ephemeral-p
  6600. (gnus-group-update-group
  6601. group nil
  6602. (equal info
  6603. (setq info (copy-sequence (gnus-get-info group))
  6604. info (delq (gnus-info-params info) info))))))))))
  6605. (defun gnus-summary-save-newsrc (&optional force)
  6606. "Save the current number of read/marked articles in the dribble buffer.
  6607. The dribble buffer will then be saved.
  6608. If FORCE (the prefix), also save the .newsrc file(s)."
  6609. (interactive "P")
  6610. (gnus-summary-update-info t)
  6611. (if force
  6612. (gnus-save-newsrc-file)
  6613. (gnus-dribble-save)))
  6614. (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
  6615. (declare-function gnus-article-stop-animations "gnus-art" ())
  6616. (defun gnus-summary-exit (&optional temporary leave-hidden)
  6617. "Exit reading current newsgroup, and then return to group selection mode.
  6618. `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
  6619. (interactive)
  6620. (gnus-set-global-variables)
  6621. (when (gnus-buffer-live-p gnus-article-buffer)
  6622. (with-current-buffer gnus-article-buffer
  6623. (mm-destroy-parts gnus-article-mime-handles)
  6624. ;; Set it to nil for safety reason.
  6625. (setq gnus-article-mime-handle-alist nil)
  6626. (setq gnus-article-mime-handles nil)))
  6627. (gnus-kill-save-kill-buffer)
  6628. (gnus-async-halt-prefetch)
  6629. (let* ((group gnus-newsgroup-name)
  6630. (quit-config (gnus-group-quit-config gnus-newsgroup-name))
  6631. (gnus-group-is-exiting-p t)
  6632. (article-buffer gnus-article-buffer)
  6633. (original-article-buffer gnus-original-article-buffer)
  6634. (mode major-mode)
  6635. (group-point nil)
  6636. (buf (current-buffer))
  6637. ;; `gnus-single-article-buffer' is nil buffer-locally in
  6638. ;; ephemeral group of which summary buffer will be killed,
  6639. ;; but the global value may be non-nil.
  6640. (single-article-buffer gnus-single-article-buffer))
  6641. (unless quit-config
  6642. ;; Do adaptive scoring, and possibly save score files.
  6643. (when gnus-newsgroup-adaptive
  6644. (gnus-score-adaptive))
  6645. (when gnus-use-scoring
  6646. (gnus-score-save)))
  6647. (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
  6648. (when gnus-use-cache
  6649. (gnus-cache-possibly-remove-articles)
  6650. (gnus-cache-save-buffers))
  6651. (gnus-async-prefetch-remove-group group)
  6652. (when gnus-suppress-duplicates
  6653. (gnus-dup-enter-articles))
  6654. (when gnus-use-trees
  6655. (gnus-tree-close))
  6656. (when gnus-use-cache
  6657. (gnus-cache-write-active))
  6658. ;; Remove entries for this group.
  6659. (nnmail-purge-split-history (gnus-group-real-name group))
  6660. ;; Make all changes in this group permanent.
  6661. (unless quit-config
  6662. (gnus-run-hooks 'gnus-exit-group-hook)
  6663. (gnus-summary-update-info))
  6664. (gnus-close-group group)
  6665. ;; Make sure where we were, and go to next newsgroup.
  6666. (when (buffer-live-p (get-buffer gnus-group-buffer))
  6667. (set-buffer gnus-group-buffer))
  6668. (unless quit-config
  6669. (gnus-group-jump-to-group group))
  6670. (gnus-run-hooks 'gnus-summary-exit-hook)
  6671. (unless (or quit-config
  6672. (not gnus-summary-next-group-on-exit)
  6673. ;; If this group has disappeared from the summary
  6674. ;; buffer, don't skip forwards.
  6675. (not (string= group (gnus-group-group-name))))
  6676. (gnus-group-next-unread-group 1))
  6677. (setq group-point (point))
  6678. (gnus-article-stop-animations)
  6679. (if temporary
  6680. nil ;Nothing to do.
  6681. (set-buffer buf)
  6682. (if (not gnus-kill-summary-on-exit)
  6683. (progn
  6684. (gnus-deaden-summary)
  6685. (setq mode nil))
  6686. (when (get-buffer gnus-article-buffer)
  6687. (bury-buffer gnus-article-buffer))
  6688. ;; Return to group mode buffer.
  6689. (when (eq mode 'gnus-summary-mode)
  6690. (gnus-kill-buffer buf)))
  6691. (setq gnus-current-select-method gnus-select-method)
  6692. (when (gnus-buffer-live-p gnus-group-buffer)
  6693. (set-buffer gnus-group-buffer))
  6694. (if quit-config
  6695. (gnus-handle-ephemeral-exit quit-config)
  6696. (goto-char group-point)
  6697. ;; If gnus-group-buffer is already displayed, make sure we also move
  6698. ;; the cursor in the window that displays it.
  6699. (let ((win (get-buffer-window (current-buffer) 0)))
  6700. (if win (set-window-point win (point))))
  6701. (unless leave-hidden
  6702. (gnus-configure-windows 'group 'force)))
  6703. ;; If we have several article buffers, we kill them at exit.
  6704. (unless single-article-buffer
  6705. (when (gnus-buffer-live-p article-buffer)
  6706. (with-current-buffer article-buffer
  6707. ;; Don't kill sticky article buffers
  6708. (unless (eq major-mode 'gnus-sticky-article-mode)
  6709. (gnus-kill-buffer article-buffer)
  6710. (setq gnus-article-current nil))))
  6711. (gnus-kill-buffer original-article-buffer))
  6712. ;; Clear the current group name.
  6713. (unless quit-config
  6714. (setq gnus-newsgroup-name nil)))))
  6715. (declare-function gnus-stop-downloads "gnus-art" ())
  6716. (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
  6717. (defun gnus-summary-exit-no-update (&optional no-questions)
  6718. "Quit reading current newsgroup without updating read article info."
  6719. (interactive)
  6720. (let* ((group gnus-newsgroup-name)
  6721. (gnus-group-is-exiting-p t)
  6722. (gnus-group-is-exiting-without-update-p t)
  6723. (quit-config (gnus-group-quit-config group)))
  6724. (when (or no-questions
  6725. (gnus-ephemeral-group-p group)
  6726. gnus-expert-user
  6727. (gnus-y-or-n-p "Discard changes to this group and exit? "))
  6728. (gnus-async-halt-prefetch)
  6729. (run-hooks 'gnus-summary-prepare-exit-hook)
  6730. (when (gnus-buffer-live-p gnus-article-buffer)
  6731. (with-current-buffer gnus-article-buffer
  6732. (gnus-article-stop-animations)
  6733. (gnus-stop-downloads)
  6734. (mm-destroy-parts gnus-article-mime-handles)
  6735. ;; Set it to nil for safety reason.
  6736. (setq gnus-article-mime-handle-alist nil)
  6737. (setq gnus-article-mime-handles nil)))
  6738. ;; If we have several article buffers, we kill them at exit.
  6739. (unless gnus-single-article-buffer
  6740. (gnus-kill-buffer gnus-article-buffer)
  6741. (gnus-kill-buffer gnus-original-article-buffer)
  6742. (setq gnus-article-current nil))
  6743. ;; Return to the group buffer.
  6744. (if (not gnus-kill-summary-on-exit)
  6745. (progn
  6746. (gnus-deaden-summary)
  6747. (gnus-configure-windows 'group 'force))
  6748. (gnus-configure-windows 'group 'force)
  6749. (gnus-close-group group)
  6750. (gnus-kill-buffer gnus-summary-buffer))
  6751. (unless gnus-single-article-buffer
  6752. (setq gnus-article-current nil))
  6753. (when gnus-use-trees
  6754. (gnus-tree-close))
  6755. (gnus-async-prefetch-remove-group group)
  6756. (when (get-buffer gnus-article-buffer)
  6757. (bury-buffer gnus-article-buffer))
  6758. ;; Clear the current group name.
  6759. (setq gnus-newsgroup-name nil)
  6760. (unless (gnus-ephemeral-group-p group)
  6761. (gnus-group-update-group group nil t))
  6762. (when (equal (gnus-group-group-name) group)
  6763. (gnus-group-next-unread-group 1))
  6764. (gnus-article-stop-animations)
  6765. (when quit-config
  6766. (gnus-handle-ephemeral-exit quit-config)))))
  6767. (defun gnus-handle-ephemeral-exit (quit-config)
  6768. "Handle movement when leaving an ephemeral group.
  6769. The state which existed when entering the ephemeral is reset."
  6770. (if (not (buffer-live-p (car quit-config)))
  6771. (when (gnus-buffer-live-p gnus-group-buffer)
  6772. (gnus-configure-windows 'group 'force))
  6773. (set-buffer (car quit-config))
  6774. (unless (eq (cdr quit-config) 'group)
  6775. (setq gnus-current-select-method
  6776. (gnus-find-method-for-group gnus-newsgroup-name)))
  6777. (cond ((derived-mode-p 'gnus-summary-mode)
  6778. (gnus-set-global-variables))
  6779. ((derived-mode-p 'gnus-article-mode)
  6780. (save-current-buffer
  6781. ;; The `gnus-summary-buffer' variable may point
  6782. ;; to the old summary buffer when using a single
  6783. ;; article buffer.
  6784. (unless (gnus-buffer-live-p gnus-summary-buffer)
  6785. (set-buffer gnus-group-buffer))
  6786. (set-buffer gnus-summary-buffer)
  6787. (gnus-set-global-variables))))
  6788. (if (or (eq (cdr quit-config) 'article)
  6789. (eq (cdr quit-config) 'pick))
  6790. (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
  6791. (gnus-configure-windows 'pick 'force)
  6792. (gnus-configure-windows (cdr quit-config) 'force))
  6793. (gnus-configure-windows (cdr quit-config) 'force))
  6794. (when (derived-mode-p 'gnus-summary-mode)
  6795. (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
  6796. next-unread-noselect))
  6797. (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
  6798. 'next-noselect)
  6799. (gnus-summary-next-subject 1 nil t))
  6800. ((eq gnus-auto-select-on-ephemeral-exit
  6801. 'next-unread-noselect)
  6802. (gnus-summary-next-subject 1 t t))))
  6803. ;; Hide the article buffer which displays the article different
  6804. ;; from the one that the cursor points to in the summary buffer.
  6805. (gnus-configure-windows 'summary 'force))
  6806. (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
  6807. (gnus-summary-next-subject 1))
  6808. ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
  6809. (gnus-summary-next-subject 1 t))))
  6810. (gnus-summary-recenter)
  6811. (gnus-summary-position-point))))
  6812. ;;; Dead summaries.
  6813. (defvar gnus-dead-summary-mode-map
  6814. (let ((map (make-keymap)))
  6815. (suppress-keymap map)
  6816. (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
  6817. (dolist (key '("\C-d" "\r" "\177" [delete]))
  6818. (define-key map key 'gnus-summary-wake-up-the-dead))
  6819. (dolist (key '("q" "Q"))
  6820. (define-key map key 'bury-buffer))
  6821. map))
  6822. (define-minor-mode gnus-dead-summary-mode
  6823. "Minor mode for Gnus summary buffers."
  6824. :lighter " Dead" :keymap gnus-dead-summary-mode-map
  6825. (unless (derived-mode-p 'gnus-summary-mode)
  6826. (setq gnus-dead-summary-mode nil)))
  6827. (defun gnus-deaden-summary ()
  6828. "Make the current summary buffer into a dead summary buffer."
  6829. ;; Kill any previous dead summary buffer.
  6830. (when (and gnus-dead-summary
  6831. (buffer-name gnus-dead-summary))
  6832. (with-current-buffer gnus-dead-summary
  6833. (when gnus-dead-summary-mode
  6834. (kill-buffer (current-buffer)))))
  6835. ;; Make this the current dead summary.
  6836. (setq gnus-dead-summary (current-buffer))
  6837. (gnus-dead-summary-mode 1)
  6838. (let ((name (buffer-name)))
  6839. (when (string-match "Summary" name)
  6840. (rename-buffer
  6841. (concat (substring name 0 (match-beginning 0)) "Dead "
  6842. (substring name (match-beginning 0)))
  6843. t)
  6844. (bury-buffer))))
  6845. (defun gnus-kill-or-deaden-summary (buffer)
  6846. "Kill or deaden the summary BUFFER."
  6847. (save-excursion
  6848. (when (and (buffer-name buffer)
  6849. (not gnus-single-article-buffer))
  6850. (with-current-buffer buffer
  6851. (gnus-kill-buffer gnus-article-buffer)
  6852. (gnus-kill-buffer gnus-original-article-buffer)))
  6853. (cond
  6854. ;; Kill the buffer.
  6855. (gnus-kill-summary-on-exit
  6856. (when (and gnus-use-trees
  6857. (gnus-buffer-exists-p buffer))
  6858. (with-current-buffer buffer
  6859. (gnus-tree-close)))
  6860. (gnus-kill-buffer buffer))
  6861. ;; Deaden the buffer.
  6862. ((gnus-buffer-exists-p buffer)
  6863. (with-current-buffer buffer
  6864. (gnus-deaden-summary))))))
  6865. (defun gnus-summary-wake-up-the-dead (&rest args)
  6866. "Wake up the dead summary buffer."
  6867. (interactive)
  6868. (gnus-dead-summary-mode -1)
  6869. (let ((name (buffer-name)))
  6870. (when (string-match "Dead " name)
  6871. (rename-buffer
  6872. (concat (substring name 0 (match-beginning 0))
  6873. (substring name (match-end 0)))
  6874. t)))
  6875. (gnus-message 3 "This dead summary is now alive again"))
  6876. ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
  6877. (defun gnus-summary-describe-group (&optional force)
  6878. "Describe the current newsgroup."
  6879. (interactive "P")
  6880. (gnus-group-describe-group force gnus-newsgroup-name))
  6881. (defun gnus-summary-describe-briefly ()
  6882. "Describe summary mode commands briefly."
  6883. (interactive)
  6884. (gnus-message 6 "%s" (substitute-command-keys "\\<gnus-summary-mode-map>\\[gnus-summary-next-page]:Select \\[gnus-summary-next-unread-article]:Forward \\[gnus-summary-prev-unread-article]:Backward \\[gnus-summary-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-summary-describe-briefly]:This help")))
  6885. ;; Walking around group mode buffer from summary mode.
  6886. (defun gnus-summary-next-group (&optional no-article target-group backward)
  6887. "Exit current newsgroup and then select next unread newsgroup.
  6888. If prefix argument NO-ARTICLE is non-nil, no article is selected
  6889. initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
  6890. previous group instead."
  6891. (interactive "P")
  6892. ;; Stop pre-fetching.
  6893. (gnus-async-halt-prefetch)
  6894. (let ((current-group gnus-newsgroup-name)
  6895. (current-buffer (current-buffer))
  6896. entered)
  6897. ;; First we semi-exit this group to update Xrefs and all variables.
  6898. ;; We can't do a real exit, because the window conf must remain
  6899. ;; the same in case the user is prompted for info, and we don't
  6900. ;; want the window conf to change before that...
  6901. (gnus-summary-exit t)
  6902. (while (not entered)
  6903. ;; Then we find what group we are supposed to enter.
  6904. (set-buffer gnus-group-buffer)
  6905. (gnus-group-jump-to-group current-group)
  6906. (setq target-group
  6907. (or target-group
  6908. (if (eq gnus-keep-same-level 'best)
  6909. (gnus-summary-best-group gnus-newsgroup-name)
  6910. (gnus-summary-search-group backward gnus-keep-same-level))))
  6911. (if (not target-group)
  6912. ;; There are no further groups, so we return to the group
  6913. ;; buffer.
  6914. (progn
  6915. (gnus-message 5 "Returning to the group buffer")
  6916. (setq entered t)
  6917. (when (gnus-buffer-live-p current-buffer)
  6918. (set-buffer current-buffer)
  6919. (gnus-summary-exit))
  6920. (gnus-run-hooks 'gnus-group-no-more-groups-hook))
  6921. ;; We try to enter the target group.
  6922. (gnus-group-jump-to-group target-group)
  6923. (let ((unreads (gnus-group-group-unread)))
  6924. (if (and (or (eq t unreads)
  6925. (and unreads (not (zerop unreads))))
  6926. (gnus-summary-read-group
  6927. target-group nil no-article
  6928. (and (buffer-name current-buffer) current-buffer)
  6929. nil backward))
  6930. (setq entered t)
  6931. (setq current-group target-group
  6932. target-group nil)))))))
  6933. (defun gnus-summary-prev-group (&optional no-article)
  6934. "Exit current newsgroup and then select previous unread newsgroup.
  6935. If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
  6936. (interactive "P")
  6937. (gnus-summary-next-group no-article nil t))
  6938. ;; Walking around summary lines.
  6939. (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
  6940. "Go to the first subject satisfying any non-nil constraint.
  6941. If UNREAD is non-nil, the article should be unread.
  6942. If UNDOWNLOADED is non-nil, the article should be undownloaded.
  6943. If UNSEEN is non-nil, the article should be unseen as well as unread.
  6944. Returns the article selected or nil if there are no matching articles."
  6945. (interactive "P")
  6946. (cond
  6947. ;; Empty summary.
  6948. ((null gnus-newsgroup-data)
  6949. (gnus-message 3 "No articles in the group")
  6950. nil)
  6951. ;; Pick the first article.
  6952. ((not (or unread undownloaded unseen))
  6953. (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
  6954. (gnus-data-number (car gnus-newsgroup-data)))
  6955. ;; Find the first unread article.
  6956. (t
  6957. (let ((data gnus-newsgroup-data))
  6958. (while (and data
  6959. (let ((num (gnus-data-number (car data))))
  6960. (or (memq num gnus-newsgroup-unfetched)
  6961. (not (or (and unread
  6962. (memq num gnus-newsgroup-unreads))
  6963. (and undownloaded
  6964. (memq num gnus-newsgroup-undownloaded))
  6965. (and unseen
  6966. (memq num gnus-newsgroup-unseen)
  6967. (memq num gnus-newsgroup-unreads)))))))
  6968. (setq data (cdr data)))
  6969. (prog1
  6970. (if data
  6971. (progn
  6972. (goto-char (gnus-data-pos (car data)))
  6973. (gnus-data-number (car data)))
  6974. (gnus-message 3 "No more%s articles"
  6975. (let* ((r (when unread " unread"))
  6976. (d (when undownloaded " undownloaded"))
  6977. (s (when unseen " unseen"))
  6978. (l (delq nil (list r d s))))
  6979. (cond ((= 3 (length l))
  6980. (concat r "," d ", or" s))
  6981. ((= 2 (length l))
  6982. (concat (car l) ", or" (cadr l)))
  6983. ((= 1 (length l))
  6984. (car l))
  6985. (t
  6986. ""))))
  6987. nil
  6988. )
  6989. (gnus-summary-position-point))))))
  6990. (defun gnus-summary-next-subject (n &optional unread dont-display)
  6991. "Go to next N'th summary line.
  6992. If N is negative, go to the previous N'th subject line.
  6993. If UNREAD is non-nil, only unread articles are selected.
  6994. The difference between N and the actual number of steps taken is
  6995. returned."
  6996. (interactive "p")
  6997. (let ((backward (< n 0))
  6998. (n (abs n)))
  6999. (while (and (> n 0)
  7000. (if backward
  7001. (gnus-summary-find-prev unread)
  7002. (gnus-summary-find-next unread)))
  7003. (unless (zerop (setq n (1- n)))
  7004. (gnus-summary-show-thread)))
  7005. (when (/= 0 n)
  7006. (gnus-message 7 "No more%s articles"
  7007. (if unread " unread" "")))
  7008. (unless dont-display
  7009. (gnus-summary-recenter)
  7010. (gnus-summary-position-point))
  7011. n))
  7012. (defun gnus-summary-next-unread-subject (n)
  7013. "Go to next N'th unread summary line."
  7014. (interactive "p")
  7015. (gnus-summary-next-subject n t))
  7016. (defun gnus-summary-prev-subject (n &optional unread)
  7017. "Go to previous N'th summary line.
  7018. If optional argument UNREAD is non-nil, only unread article is selected."
  7019. (interactive "p")
  7020. (gnus-summary-next-subject (- n) unread))
  7021. (defun gnus-summary-prev-unread-subject (n)
  7022. "Go to previous N'th unread summary line."
  7023. (interactive "p")
  7024. (gnus-summary-next-subject (- n) t))
  7025. (defun gnus-summary-goto-subjects (articles)
  7026. "Insert the subject header for ARTICLES in the current buffer."
  7027. (save-excursion
  7028. (dolist (article articles)
  7029. (gnus-summary-goto-subject article t)))
  7030. (gnus-summary-limit (append articles gnus-newsgroup-limit))
  7031. (gnus-summary-position-point))
  7032. (defun gnus-summary-goto-subject (article &optional force silent)
  7033. "Go to the subject line of ARTICLE.
  7034. If FORCE, also allow jumping to articles not currently shown."
  7035. (interactive "nArticle number: ")
  7036. (unless (numberp article)
  7037. (error "Article %s is not a number" article))
  7038. (let ((b (point))
  7039. (data (gnus-data-find article)))
  7040. ;; We read in the article if we have to.
  7041. (and (not data)
  7042. force
  7043. (gnus-summary-insert-subject
  7044. article
  7045. (if (or (numberp force) (vectorp force)) force)
  7046. t)
  7047. (setq data (gnus-data-find article)))
  7048. (goto-char b)
  7049. (if (not data)
  7050. (progn
  7051. (unless silent
  7052. (gnus-message 3 "Can't find article %d" article))
  7053. nil)
  7054. (let ((pt (gnus-data-pos data)))
  7055. (goto-char pt)
  7056. (gnus-summary-set-article-display-arrow pt))
  7057. (gnus-summary-position-point)
  7058. article)))
  7059. ;; Walking around summary lines with displaying articles.
  7060. (defun gnus-summary-expand-window (&optional arg)
  7061. "Make the summary buffer take up the entire Emacs frame.
  7062. Given a prefix, will force an `article' buffer configuration."
  7063. (interactive "P")
  7064. (if arg
  7065. (gnus-configure-windows 'article 'force)
  7066. (gnus-configure-windows 'summary 'force)))
  7067. (defun gnus-summary-display-article (article &optional all-header)
  7068. "Display ARTICLE in article buffer."
  7069. (unless (and (gnus-buffer-live-p gnus-article-buffer)
  7070. (with-current-buffer gnus-article-buffer
  7071. (derived-mode-p 'gnus-article-mode)))
  7072. (gnus-article-setup-buffer))
  7073. (gnus-set-global-variables)
  7074. (with-current-buffer gnus-article-buffer
  7075. (setq gnus-article-charset gnus-newsgroup-charset)
  7076. (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
  7077. (mm-enable-multibyte))
  7078. (if (null article)
  7079. nil
  7080. (prog1
  7081. (if gnus-summary-display-article-function
  7082. (funcall gnus-summary-display-article-function article all-header)
  7083. (gnus-article-prepare article all-header))
  7084. (gnus-run-hooks 'gnus-select-article-hook)
  7085. (when (and gnus-current-article
  7086. (not (zerop gnus-current-article)))
  7087. (gnus-summary-goto-subject gnus-current-article))
  7088. (gnus-summary-recenter)
  7089. (when (and gnus-use-trees gnus-show-threads)
  7090. (gnus-possibly-generate-tree article)
  7091. (gnus-highlight-selected-tree article))
  7092. ;; Successfully display article.
  7093. (gnus-article-set-window-start
  7094. (cdr (assq article gnus-newsgroup-bookmarks))))))
  7095. (defun gnus-summary-select-article (&optional all-headers force pseudo article)
  7096. "Select the current article.
  7097. If ALL-HEADERS is non-nil, show all header fields. If FORCE is
  7098. non-nil, the article will be re-fetched even if it already present in
  7099. the article buffer. If PSEUDO is non-nil, pseudo-articles will also
  7100. be displayed."
  7101. ;; Make sure we are in the summary buffer to work around bbdb bug.
  7102. (unless (derived-mode-p 'gnus-summary-mode)
  7103. (set-buffer gnus-summary-buffer))
  7104. (let ((article (or article (gnus-summary-article-number)))
  7105. (all-headers (not (not all-headers))) ;Must be t or nil.
  7106. gnus-summary-display-article-function)
  7107. (and (not pseudo)
  7108. (gnus-summary-article-pseudo-p article)
  7109. (error "This is a pseudo-article"))
  7110. (with-current-buffer gnus-summary-buffer
  7111. (if (or (and gnus-single-article-buffer
  7112. (or (null gnus-current-article)
  7113. (null gnus-article-current)
  7114. (null (get-buffer gnus-article-buffer))
  7115. (not (eq article (cdr gnus-article-current)))
  7116. (not (equal (car gnus-article-current)
  7117. gnus-newsgroup-name))
  7118. (not (get-buffer gnus-original-article-buffer))))
  7119. (and (not gnus-single-article-buffer)
  7120. (or (null gnus-current-article)
  7121. (not (get-buffer gnus-original-article-buffer))
  7122. (not (eq gnus-current-article article))))
  7123. force)
  7124. ;; The requested article is different from the current article.
  7125. (progn
  7126. (gnus-summary-display-article article all-headers)
  7127. (when (gnus-buffer-live-p gnus-article-buffer)
  7128. (with-current-buffer gnus-article-buffer
  7129. (if (not gnus-article-decoded-p) ;; a local variable
  7130. (mm-disable-multibyte))))
  7131. (gnus-article-set-window-start
  7132. (cdr (assq article gnus-newsgroup-bookmarks)))
  7133. article)
  7134. 'old))))
  7135. (defun gnus-summary-force-verify-and-decrypt ()
  7136. "Display buttons for signed/encrypted parts and verify/decrypt them."
  7137. (interactive)
  7138. (let ((mm-verify-option 'known)
  7139. (mm-decrypt-option 'known)
  7140. (gnus-article-emulate-mime t)
  7141. (gnus-buttonized-mime-types (append (list "multipart/signed"
  7142. "multipart/encrypted")
  7143. gnus-buttonized-mime-types)))
  7144. (gnus-summary-select-article nil 'force)))
  7145. (defun gnus-summary-next-article (&optional unread subject backward push)
  7146. "Select the next article.
  7147. If UNREAD, only unread articles are selected.
  7148. If SUBJECT, only articles with SUBJECT are selected.
  7149. If BACKWARD, the previous article is selected instead of the next."
  7150. (interactive "P")
  7151. ;; Make sure we are in the summary buffer.
  7152. (unless (derived-mode-p 'gnus-summary-mode)
  7153. (set-buffer gnus-summary-buffer))
  7154. (cond
  7155. ;; Is there such an article?
  7156. ((and (gnus-summary-search-forward unread subject backward)
  7157. (or (gnus-summary-display-article (gnus-summary-article-number))
  7158. (eq (gnus-summary-article-mark) gnus-canceled-mark)))
  7159. (gnus-summary-position-point))
  7160. ;; If not, we try the first unread, if that is wanted.
  7161. ((and subject
  7162. gnus-auto-select-same
  7163. (gnus-summary-first-unread-article))
  7164. (gnus-summary-position-point)
  7165. (gnus-message 6 "Wrapped"))
  7166. ;; Try to get next/previous article not displayed in this group.
  7167. ((and gnus-auto-extend-newsgroup
  7168. (not unread) (not subject))
  7169. (gnus-summary-goto-article
  7170. (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
  7171. nil (count-lines (point-min) (point))))
  7172. ;; Go to next/previous group.
  7173. (t
  7174. (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
  7175. (gnus-summary-jump-to-group gnus-newsgroup-name))
  7176. (let ((cmd (if (featurep 'xemacs)
  7177. last-command-char
  7178. last-command-event))
  7179. (point
  7180. (with-current-buffer gnus-group-buffer
  7181. (point)))
  7182. (current-summary (current-buffer))
  7183. (group
  7184. (if (eq gnus-keep-same-level 'best)
  7185. (gnus-summary-best-group gnus-newsgroup-name)
  7186. (gnus-summary-search-group backward gnus-keep-same-level))))
  7187. ;; Select next unread newsgroup automagically.
  7188. (cond
  7189. ((or (not gnus-auto-select-next)
  7190. (not cmd))
  7191. (gnus-message 7 "No more%s articles" (if unread " unread" "")))
  7192. ((or (eq gnus-auto-select-next 'quietly)
  7193. (and (eq gnus-auto-select-next 'slightly-quietly)
  7194. push)
  7195. (and (eq gnus-auto-select-next 'almost-quietly)
  7196. (gnus-summary-last-article-p)))
  7197. ;; Select quietly.
  7198. (if (gnus-ephemeral-group-p gnus-newsgroup-name)
  7199. (gnus-summary-exit)
  7200. (gnus-message 7 "No more%s articles (%s)..."
  7201. (if unread " unread" "")
  7202. (if group (concat "selecting " group)
  7203. "exiting"))
  7204. (gnus-summary-next-group nil group backward)))
  7205. (t
  7206. (when (gnus-key-press-event-p last-input-event)
  7207. ;; Somehow or other, we may now have selected a different
  7208. ;; window. Make point go back to the summary buffer.
  7209. (when (eq current-summary (current-buffer))
  7210. ;; FIXME: This burps when get-buffer-window returns nil.
  7211. (select-window (get-buffer-window current-summary 0)))
  7212. (gnus-summary-walk-group-buffer
  7213. gnus-newsgroup-name cmd unread backward point))))))))
  7214. (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
  7215. (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
  7216. (?\C-p (gnus-group-prev-unread-group 1))))
  7217. (cursor-in-echo-area t)
  7218. keve key group ended prompt)
  7219. (with-current-buffer gnus-group-buffer
  7220. (goto-char start)
  7221. (setq group
  7222. (if (eq gnus-keep-same-level 'best)
  7223. (gnus-summary-best-group gnus-newsgroup-name)
  7224. (gnus-summary-search-group backward gnus-keep-same-level))))
  7225. (while (not ended)
  7226. (setq prompt
  7227. (format
  7228. "No more%s articles%s " (if unread " unread" "")
  7229. (if (and group
  7230. (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
  7231. (format " (Type %s for %s [%s])"
  7232. (single-key-description cmd)
  7233. (gnus-group-decoded-name group)
  7234. (gnus-group-unread group))
  7235. (format " (Type %s to exit %s)"
  7236. (single-key-description cmd)
  7237. (gnus-group-decoded-name gnus-newsgroup-name)))))
  7238. ;; Confirm auto selection.
  7239. (setq key (car (setq keve (gnus-read-event-char prompt)))
  7240. ended t)
  7241. (cond
  7242. ((assq key keystrokes)
  7243. (let ((obuf (current-buffer)))
  7244. (switch-to-buffer gnus-group-buffer)
  7245. (when group
  7246. (gnus-group-jump-to-group group))
  7247. (eval (cadr (assq key keystrokes)))
  7248. (setq group (gnus-group-group-name))
  7249. (switch-to-buffer obuf))
  7250. (setq ended nil))
  7251. ((equal key cmd)
  7252. (if (or (not group)
  7253. (gnus-ephemeral-group-p gnus-newsgroup-name))
  7254. (gnus-summary-exit)
  7255. (gnus-summary-next-group nil group backward)))
  7256. (t
  7257. (push (cdr keve) unread-command-events))))))
  7258. (defun gnus-summary-next-unread-article ()
  7259. "Select unread article after current one."
  7260. (interactive)
  7261. (gnus-summary-next-article
  7262. (or (not (eq gnus-summary-goto-unread 'never))
  7263. (gnus-summary-last-article-p (gnus-summary-article-number)))
  7264. (and gnus-auto-select-same
  7265. (gnus-summary-article-subject))))
  7266. (defun gnus-summary-prev-article (&optional unread subject)
  7267. "Select the article before the current one.
  7268. If UNREAD is non-nil, only unread articles are selected."
  7269. (interactive "P")
  7270. (gnus-summary-next-article unread subject t))
  7271. (defun gnus-summary-prev-unread-article ()
  7272. "Select unread article before current one."
  7273. (interactive)
  7274. (gnus-summary-prev-article
  7275. (or (not (eq gnus-summary-goto-unread 'never))
  7276. (gnus-summary-first-article-p (gnus-summary-article-number)))
  7277. (and gnus-auto-select-same
  7278. (gnus-summary-article-subject))))
  7279. (declare-function gnus-article-only-boring-p "gnus-art" ())
  7280. (defun gnus-summary-next-page (&optional lines circular stop)
  7281. "Show next page of the selected article.
  7282. If at the end of the current article, select the next article.
  7283. LINES says how many lines should be scrolled up.
  7284. If CIRCULAR is non-nil, go to the start of the article instead of
  7285. selecting the next article when reaching the end of the current
  7286. article.
  7287. If STOP is non-nil, just stop when reaching the end of the message.
  7288. Also see the variable `gnus-article-skip-boring'."
  7289. (interactive "P")
  7290. (gnus-set-global-variables)
  7291. (let ((article (gnus-summary-article-number))
  7292. (article-window (get-buffer-window gnus-article-buffer t))
  7293. endp)
  7294. ;; If the buffer is empty, we have no article.
  7295. (unless article
  7296. (error "No article to select"))
  7297. (gnus-configure-windows 'article)
  7298. (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
  7299. (if (and (eq gnus-summary-goto-unread 'never)
  7300. (not (gnus-summary-last-article-p article)))
  7301. (gnus-summary-next-article)
  7302. (gnus-summary-next-unread-article))
  7303. (if (or (null gnus-current-article)
  7304. (null gnus-article-current)
  7305. (/= article (cdr gnus-article-current))
  7306. (not (equal (car gnus-article-current) gnus-newsgroup-name)))
  7307. ;; Selected subject is different from current article's.
  7308. (gnus-summary-display-article article)
  7309. (when article-window
  7310. (gnus-eval-in-buffer-window gnus-article-buffer
  7311. (setq endp (or (gnus-article-next-page lines)
  7312. (gnus-article-only-boring-p))))
  7313. (when endp
  7314. (cond ((or stop gnus-summary-stop-at-end-of-message)
  7315. (gnus-message 3 "End of message"))
  7316. (circular
  7317. (gnus-summary-beginning-of-article))
  7318. (lines
  7319. (gnus-message 3 "End of message"))
  7320. ((null lines)
  7321. (if (and (eq gnus-summary-goto-unread 'never)
  7322. (not (gnus-summary-last-article-p article)))
  7323. (gnus-summary-next-article)
  7324. (gnus-summary-next-unread-article))))))))
  7325. (gnus-summary-recenter)
  7326. (gnus-summary-position-point)))
  7327. (defun gnus-summary-prev-page (&optional lines move)
  7328. "Show previous page of selected article.
  7329. Argument LINES specifies lines to be scrolled down.
  7330. If MOVE, move to the previous unread article if point is at
  7331. the beginning of the buffer."
  7332. (interactive "P")
  7333. (let ((article (gnus-summary-article-number))
  7334. (article-window (get-buffer-window gnus-article-buffer t))
  7335. endp)
  7336. (gnus-configure-windows 'article)
  7337. (if (or (null gnus-current-article)
  7338. (null gnus-article-current)
  7339. (/= article (cdr gnus-article-current))
  7340. (not (equal (car gnus-article-current) gnus-newsgroup-name)))
  7341. ;; Selected subject is different from current article's.
  7342. (gnus-summary-display-article article)
  7343. (gnus-summary-recenter)
  7344. (when article-window
  7345. (gnus-eval-in-buffer-window gnus-article-buffer
  7346. (setq endp (gnus-article-prev-page lines)))
  7347. (when (and move endp)
  7348. (cond (lines
  7349. (gnus-message 3 "Beginning of message"))
  7350. ((null lines)
  7351. (if (and (eq gnus-summary-goto-unread 'never)
  7352. (not (gnus-summary-first-article-p article)))
  7353. (gnus-summary-prev-article)
  7354. (gnus-summary-prev-unread-article))))))))
  7355. (gnus-summary-position-point))
  7356. (defun gnus-summary-prev-page-or-article (&optional lines)
  7357. "Show previous page of selected article.
  7358. Argument LINES specifies lines to be scrolled down.
  7359. If at the beginning of the article, go to the next article."
  7360. (interactive "P")
  7361. (gnus-summary-prev-page lines t))
  7362. (defun gnus-summary-scroll-up (lines)
  7363. "Scroll up (or down) one line current article.
  7364. Argument LINES specifies lines to be scrolled up (or down if negative).
  7365. If no article is selected, then the current article will be selected first."
  7366. (interactive "p")
  7367. (gnus-configure-windows 'article)
  7368. (gnus-summary-show-thread)
  7369. (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
  7370. (gnus-eval-in-buffer-window gnus-article-buffer
  7371. (cond ((> lines 0)
  7372. (when (gnus-article-next-page lines)
  7373. (gnus-message 3 "End of message")))
  7374. ((< lines 0)
  7375. (gnus-article-prev-page (- lines))))))
  7376. (gnus-summary-recenter)
  7377. (gnus-summary-position-point))
  7378. (defun gnus-summary-scroll-down (lines)
  7379. "Scroll down (or up) one line current article.
  7380. Argument LINES specifies lines to be scrolled down (or up if negative).
  7381. If no article is selected, then the current article will be selected first."
  7382. (interactive "p")
  7383. (gnus-summary-scroll-up (- lines)))
  7384. (defun gnus-summary-next-same-subject ()
  7385. "Select next article which has the same subject as current one."
  7386. (interactive)
  7387. (gnus-summary-next-article nil (gnus-summary-article-subject)))
  7388. (defun gnus-summary-prev-same-subject ()
  7389. "Select previous article which has the same subject as current one."
  7390. (interactive)
  7391. (gnus-summary-prev-article nil (gnus-summary-article-subject)))
  7392. (defun gnus-summary-next-unread-same-subject ()
  7393. "Select next unread article which has the same subject as current one."
  7394. (interactive)
  7395. (gnus-summary-next-article t (gnus-summary-article-subject)))
  7396. (defun gnus-summary-prev-unread-same-subject ()
  7397. "Select previous unread article which has the same subject as current one."
  7398. (interactive)
  7399. (gnus-summary-prev-article t (gnus-summary-article-subject)))
  7400. (defun gnus-summary-first-unread-article ()
  7401. "Select the first unread article.
  7402. Return nil if there are no unread articles."
  7403. (interactive)
  7404. (prog1
  7405. (when (gnus-summary-first-subject t)
  7406. (gnus-summary-show-thread)
  7407. (gnus-summary-first-subject t)
  7408. (gnus-summary-display-article (gnus-summary-article-number)))
  7409. (gnus-summary-position-point)))
  7410. (defun gnus-summary-first-unread-subject ()
  7411. "Place the point on the subject line of the first unread article.
  7412. Return nil if there are no unread articles."
  7413. (interactive)
  7414. (prog1
  7415. (when (gnus-summary-first-subject t)
  7416. (gnus-summary-show-thread)
  7417. (gnus-summary-first-subject t))
  7418. (gnus-summary-position-point)))
  7419. (defun gnus-summary-first-unseen-subject ()
  7420. "Place the point on the subject line of the first unseen article.
  7421. Return nil if there are no unseen articles."
  7422. (interactive)
  7423. (prog1
  7424. (when (gnus-summary-first-subject nil nil t)
  7425. (gnus-summary-show-thread)
  7426. (gnus-summary-first-subject nil nil t))
  7427. (gnus-summary-position-point)))
  7428. (defun gnus-summary-first-unseen-or-unread-subject ()
  7429. "Place the point on the subject line of the first unseen and unread article.
  7430. If all article have been seen, on the subject line of the first unread
  7431. article."
  7432. (interactive)
  7433. (prog1
  7434. (unless (when (gnus-summary-first-subject nil nil t)
  7435. (gnus-summary-show-thread)
  7436. (gnus-summary-first-subject nil nil t))
  7437. (when (gnus-summary-first-subject t)
  7438. (gnus-summary-show-thread)
  7439. (gnus-summary-first-subject t)))
  7440. (gnus-summary-position-point)))
  7441. (defun gnus-summary-first-article ()
  7442. "Select the first article.
  7443. Return nil if there are no articles."
  7444. (interactive)
  7445. (prog1
  7446. (when (gnus-summary-first-subject)
  7447. (gnus-summary-show-thread)
  7448. (gnus-summary-first-subject)
  7449. (gnus-summary-display-article (gnus-summary-article-number)))
  7450. (gnus-summary-position-point)))
  7451. (defun gnus-summary-best-unread-article (&optional arg)
  7452. "Select the unread article with the highest score.
  7453. If given a prefix argument, select the next unread article that has a
  7454. score higher than the default score."
  7455. (interactive "P")
  7456. (let ((article (if arg
  7457. (gnus-summary-better-unread-subject)
  7458. (gnus-summary-best-unread-subject))))
  7459. (if article
  7460. (gnus-summary-goto-article article)
  7461. (error "No unread articles"))))
  7462. (defun gnus-summary-best-unread-subject ()
  7463. "Select the unread subject with the highest score."
  7464. (interactive)
  7465. (let ((best -1000000)
  7466. (data gnus-newsgroup-data)
  7467. article score)
  7468. (while data
  7469. (and (gnus-data-unread-p (car data))
  7470. (> (setq score
  7471. (gnus-summary-article-score (gnus-data-number (car data))))
  7472. best)
  7473. (setq best score
  7474. article (gnus-data-number (car data))))
  7475. (setq data (cdr data)))
  7476. (when article
  7477. (gnus-summary-goto-subject article))
  7478. (gnus-summary-position-point)
  7479. article))
  7480. (defun gnus-summary-better-unread-subject ()
  7481. "Select the first unread subject that has a score over the default score."
  7482. (interactive)
  7483. (let ((data gnus-newsgroup-data)
  7484. article score)
  7485. (while (and (setq article (gnus-data-number (car data)))
  7486. (or (gnus-data-read-p (car data))
  7487. (not (> (gnus-summary-article-score article)
  7488. gnus-summary-default-score))))
  7489. (setq data (cdr data)))
  7490. (when article
  7491. (gnus-summary-goto-subject article))
  7492. (gnus-summary-position-point)
  7493. article))
  7494. (defun gnus-summary-last-subject ()
  7495. "Go to the last displayed subject line in the group."
  7496. (let ((article (gnus-data-number (car (gnus-data-list t)))))
  7497. (when article
  7498. (gnus-summary-goto-subject article))))
  7499. (defun gnus-summary-goto-article (article &optional all-headers force)
  7500. "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
  7501. If ALL-HEADERS is non-nil, no header lines are hidden.
  7502. If FORCE, go to the article even if it isn't displayed. If FORCE
  7503. is a number, it is the line the article is to be displayed on."
  7504. (interactive
  7505. (list
  7506. (gnus-completing-read
  7507. "Article number or Message-ID"
  7508. (mapcar 'int-to-string gnus-newsgroup-limit))
  7509. current-prefix-arg
  7510. t))
  7511. (prog1
  7512. (if (and (stringp article)
  7513. (string-match "@\\|%40" article))
  7514. (gnus-summary-refer-article article)
  7515. (when (stringp article)
  7516. (setq article (string-to-number article)))
  7517. (if (gnus-summary-goto-subject article force)
  7518. (gnus-summary-display-article article all-headers)
  7519. (gnus-message 4 "Couldn't go to article %s" article) nil))
  7520. (gnus-summary-position-point)))
  7521. (defun gnus-summary-goto-last-article ()
  7522. "Go to the previously read article."
  7523. (interactive)
  7524. (prog1
  7525. (when gnus-last-article
  7526. (gnus-summary-goto-article gnus-last-article nil t))
  7527. (gnus-summary-position-point)))
  7528. (defun gnus-summary-pop-article (number)
  7529. "Pop one article off the history and go to the previous.
  7530. NUMBER articles will be popped off."
  7531. (interactive "p")
  7532. (let (to)
  7533. (setq gnus-newsgroup-history
  7534. (cdr (setq to (nthcdr number gnus-newsgroup-history))))
  7535. (if to
  7536. (gnus-summary-goto-article (car to) nil t)
  7537. (error "Article history empty")))
  7538. (gnus-summary-position-point))
  7539. ;; Summary commands and functions for limiting the summary buffer.
  7540. (defun gnus-summary-limit-to-articles (n)
  7541. "Limit the summary buffer to the next N articles.
  7542. If not given a prefix, use the process marked articles instead."
  7543. (interactive "P")
  7544. (prog1
  7545. (let ((articles (gnus-summary-work-articles n)))
  7546. (setq gnus-newsgroup-processable nil)
  7547. (gnus-summary-limit articles))
  7548. (gnus-summary-position-point)))
  7549. (defun gnus-summary-pop-limit (&optional total)
  7550. "Restore the previous limit.
  7551. If given a prefix, remove all limits."
  7552. (interactive "P")
  7553. (when total
  7554. (setq gnus-newsgroup-limits
  7555. (list (mapcar (lambda (h) (mail-header-number h))
  7556. gnus-newsgroup-headers))))
  7557. (unless gnus-newsgroup-limits
  7558. (error "No limit to pop"))
  7559. (prog1
  7560. (gnus-summary-limit nil 'pop)
  7561. (gnus-summary-position-point)))
  7562. (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
  7563. "Limit the summary buffer to articles that have subjects that match a regexp.
  7564. If NOT-MATCHING, excluding articles that have subjects that match a regexp."
  7565. (interactive
  7566. (list (read-string (if current-prefix-arg
  7567. "Exclude subject (regexp): "
  7568. "Limit to subject (regexp): "))
  7569. nil current-prefix-arg))
  7570. (unless header
  7571. (setq header "subject"))
  7572. (when (not (equal "" subject))
  7573. (prog1
  7574. (let ((articles (gnus-summary-find-matching
  7575. (or header "subject") subject 'all nil nil
  7576. not-matching)))
  7577. (unless articles
  7578. (error "Found no matches for \"%s\"" subject))
  7579. (gnus-summary-limit articles))
  7580. (gnus-summary-position-point))))
  7581. (defun gnus-summary-limit-to-author (from &optional not-matching)
  7582. "Limit the summary buffer to articles that have authors that match a regexp.
  7583. If NOT-MATCHING, excluding articles that have authors that match a regexp."
  7584. (interactive
  7585. (list (let* ((header (gnus-summary-article-header))
  7586. (default (and header (car (mail-header-parse-address
  7587. (mail-header-from header))))))
  7588. (read-string (concat (if current-prefix-arg
  7589. "Exclude author (regexp"
  7590. "Limit to author (regexp")
  7591. (if default
  7592. (concat ", default \"" default "\"): ")
  7593. "): "))
  7594. nil nil
  7595. default))
  7596. current-prefix-arg))
  7597. (gnus-summary-limit-to-subject from "from" not-matching))
  7598. (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
  7599. "Limit the summary buffer to articles with the given RECIPIENT.
  7600. If NOT-MATCHING, exclude RECIPIENT.
  7601. To and Cc headers are checked. You need to include them in
  7602. `nnmail-extra-headers'."
  7603. ;; Unlike `rmail-summary-by-recipients', doesn't include From.
  7604. (interactive
  7605. (list (read-string (format "%s recipient (regexp): "
  7606. (if current-prefix-arg "Exclude" "Limit to")))
  7607. current-prefix-arg))
  7608. (when (not (equal "" recipient))
  7609. (prog1 (let* ((to
  7610. (if (memq 'To nnmail-extra-headers)
  7611. (gnus-summary-find-matching
  7612. (cons 'extra 'To) recipient 'all nil nil
  7613. not-matching)
  7614. (gnus-message
  7615. 1 "`To' isn't present in `nnmail-extra-headers'")
  7616. (sit-for 1)
  7617. nil))
  7618. (cc
  7619. (if (memq 'Cc nnmail-extra-headers)
  7620. (gnus-summary-find-matching
  7621. (cons 'extra 'Cc) recipient 'all nil nil
  7622. not-matching)
  7623. (gnus-message
  7624. 1 "`Cc' isn't present in `nnmail-extra-headers'")
  7625. (sit-for 1)
  7626. nil))
  7627. (articles
  7628. (if not-matching
  7629. ;; We need the numbers that are in both lists:
  7630. (mapcar (lambda (a)
  7631. (and (memq a to) a))
  7632. cc)
  7633. (nconc to cc))))
  7634. (unless articles
  7635. (error "Found no matches for \"%s\"" recipient))
  7636. (gnus-summary-limit articles))
  7637. (gnus-summary-position-point))))
  7638. (defun gnus-summary-limit-to-address (address &optional not-matching)
  7639. "Limit the summary buffer to articles with the given ADDRESS.
  7640. If NOT-MATCHING, exclude ADDRESS.
  7641. To, Cc and From headers are checked. You need to include `To' and `Cc'
  7642. in `nnmail-extra-headers'."
  7643. (interactive
  7644. (list (read-string (format "%s address (regexp): "
  7645. (if current-prefix-arg "Exclude" "Limit to")))
  7646. current-prefix-arg))
  7647. (when (not (equal "" address))
  7648. (prog1 (let* ((to
  7649. (if (memq 'To nnmail-extra-headers)
  7650. (gnus-summary-find-matching
  7651. (cons 'extra 'To) address 'all nil nil
  7652. not-matching)
  7653. (gnus-message
  7654. 1 "`To' isn't present in `nnmail-extra-headers'")
  7655. (sit-for 1)
  7656. t))
  7657. (cc
  7658. (if (memq 'Cc nnmail-extra-headers)
  7659. (gnus-summary-find-matching
  7660. (cons 'extra 'Cc) address 'all nil nil
  7661. not-matching)
  7662. (gnus-message
  7663. 1 "`Cc' isn't present in `nnmail-extra-headers'")
  7664. (sit-for 1)
  7665. t))
  7666. (from
  7667. (gnus-summary-find-matching "from" address
  7668. 'all nil nil not-matching))
  7669. (articles
  7670. (if not-matching
  7671. ;; We need the numbers that are in all lists:
  7672. (if (eq cc t)
  7673. (if (eq to t)
  7674. from
  7675. (mapcar (lambda (a) (car (memq a from))) to))
  7676. (if (eq to t)
  7677. (mapcar (lambda (a) (car (memq a from))) cc)
  7678. (mapcar (lambda (a) (car (memq a from)))
  7679. (mapcar (lambda (a) (car (memq a to)))
  7680. cc))))
  7681. (nconc (if (eq to t) nil to)
  7682. (if (eq cc t) nil cc)
  7683. from))))
  7684. (unless articles
  7685. (error "Found no matches for \"%s\"" address))
  7686. (gnus-summary-limit articles))
  7687. (gnus-summary-position-point))))
  7688. (defun gnus-summary-limit-strange-charsets-predicate (header)
  7689. (when (fboundp 'char-charset)
  7690. (let ((string (concat (mail-header-subject header)
  7691. (mail-header-from header)))
  7692. charset found)
  7693. (dotimes (i (1- (length string)))
  7694. (setq charset (format "%s" (char-charset (aref string (1+ i)))))
  7695. (when (string-match "unicode\\|big\\|japanese" charset)
  7696. (setq found t)))
  7697. found)))
  7698. (defun gnus-summary-limit-to-predicate (predicate)
  7699. "Limit to articles where PREDICATE returns non-nil.
  7700. PREDICATE will be called with the header structures of the
  7701. articles."
  7702. (let ((articles nil)
  7703. (case-fold-search t))
  7704. (dolist (header gnus-newsgroup-headers)
  7705. (when (funcall predicate header)
  7706. (push (mail-header-number header) articles)))
  7707. (gnus-summary-limit (nreverse articles))))
  7708. (defun gnus-summary-limit-to-age (age &optional younger-p)
  7709. "Limit the summary buffer to articles that are older than (or equal) AGE days.
  7710. If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
  7711. articles that are younger than AGE days."
  7712. (interactive
  7713. (let ((younger current-prefix-arg)
  7714. (days-got nil)
  7715. days)
  7716. (while (not days-got)
  7717. (setq days (if younger
  7718. (read-string "Limit to articles younger than (in days, older when negative): ")
  7719. (read-string
  7720. "Limit to articles older than (in days, younger when negative): ")))
  7721. (when (> (length days) 0)
  7722. (setq days (read days)))
  7723. (if (numberp days)
  7724. (progn
  7725. (setq days-got t)
  7726. (when (< days 0)
  7727. (setq younger (not younger))
  7728. (setq days (* days -1))))
  7729. (message "Please enter a number.")
  7730. (sleep-for 1)))
  7731. (list days younger)))
  7732. (prog1
  7733. (let ((data gnus-newsgroup-data)
  7734. (cutoff (days-to-time age))
  7735. articles d date is-younger)
  7736. (while (setq d (pop data))
  7737. (when (and (vectorp (gnus-data-header d))
  7738. (setq date (mail-header-date (gnus-data-header d))))
  7739. (setq is-younger (time-less-p
  7740. (time-since (gnus-date-get-time date))
  7741. cutoff))
  7742. (when (if younger-p
  7743. is-younger
  7744. (not is-younger))
  7745. (push (gnus-data-number d) articles))))
  7746. (gnus-summary-limit (nreverse articles)))
  7747. (gnus-summary-position-point)))
  7748. (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
  7749. "Limit the summary buffer to articles that match an `extra' header."
  7750. (interactive
  7751. (let ((header
  7752. (intern
  7753. (gnus-completing-read
  7754. (if current-prefix-arg
  7755. "Exclude extra header"
  7756. "Limit extra header")
  7757. (mapcar 'symbol-name gnus-extra-headers)
  7758. t nil nil
  7759. (symbol-name (car gnus-extra-headers))))))
  7760. (list header
  7761. (read-string (format "%s header %s (regexp): "
  7762. (if current-prefix-arg "Exclude" "Limit to")
  7763. header))
  7764. current-prefix-arg)))
  7765. (when (not (equal "" regexp))
  7766. (prog1
  7767. (let ((articles (gnus-summary-find-matching
  7768. (cons 'extra header) regexp 'all nil nil
  7769. not-matching)))
  7770. (unless articles
  7771. (error "Found no matches for \"%s\"" regexp))
  7772. (gnus-summary-limit articles))
  7773. (gnus-summary-position-point))))
  7774. (defun gnus-summary-limit-to-display-predicate ()
  7775. "Limit the summary buffer to the predicated in the `display' group parameter."
  7776. (interactive)
  7777. (unless gnus-newsgroup-display
  7778. (error "There is no `display' group parameter"))
  7779. (let (articles)
  7780. (dolist (gnus-number gnus-newsgroup-articles)
  7781. (when (funcall gnus-newsgroup-display)
  7782. (push gnus-number articles)))
  7783. (gnus-summary-limit articles))
  7784. (gnus-summary-position-point))
  7785. (defun gnus-summary-limit-to-unread (&optional all)
  7786. "Limit the summary buffer to articles that are not marked as read.
  7787. If ALL is non-nil, limit strictly to unread articles."
  7788. (interactive "P")
  7789. (if all
  7790. (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
  7791. (gnus-summary-limit-to-marks
  7792. ;; Concat all the marks that say that an article is read and have
  7793. ;; those removed.
  7794. (list gnus-del-mark gnus-read-mark gnus-ancient-mark
  7795. gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
  7796. gnus-low-score-mark gnus-expirable-mark
  7797. gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
  7798. gnus-duplicate-mark)
  7799. 'reverse)))
  7800. (defun gnus-summary-limit-to-headers (match &optional reverse)
  7801. "Limit the summary buffer to articles that have headers that match MATCH.
  7802. If REVERSE (the prefix), limit to articles that don't match."
  7803. (interactive "sMatch headers (regexp): \nP")
  7804. (gnus-summary-limit-to-bodies match reverse t))
  7805. (declare-function article-goto-body "gnus-art" ())
  7806. (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
  7807. "Limit the summary buffer to articles that have bodies that match MATCH.
  7808. If REVERSE (the prefix), limit to articles that don't match."
  7809. (interactive "sMatch body (regexp): \nP")
  7810. (let ((articles nil)
  7811. (gnus-select-article-hook nil) ;Disable hook.
  7812. (gnus-article-prepare-hook nil)
  7813. (gnus-use-article-prefetch nil)
  7814. (gnus-keep-backlog nil)
  7815. (gnus-break-pages nil)
  7816. (gnus-summary-display-arrow nil)
  7817. (gnus-updated-mode-lines nil)
  7818. (gnus-auto-center-summary nil)
  7819. (gnus-display-mime-function nil))
  7820. (dolist (data gnus-newsgroup-data)
  7821. (let (gnus-mark-article-hook)
  7822. (gnus-summary-select-article t t nil (gnus-data-number data)))
  7823. (with-current-buffer gnus-article-buffer
  7824. (article-goto-body)
  7825. (let* ((case-fold-search t)
  7826. (found (if headersp
  7827. (re-search-backward match nil t)
  7828. (re-search-forward match nil t))))
  7829. (when (or (and found
  7830. (not reverse))
  7831. (and (not found)
  7832. reverse))
  7833. (push (gnus-data-number data) articles)))))
  7834. (if (not articles)
  7835. (message "No messages matched")
  7836. (gnus-summary-limit articles)))
  7837. (gnus-summary-position-point))
  7838. (defun gnus-summary-limit-to-singletons (&optional threadsp)
  7839. "Limit the summary buffer to articles that aren't part on any thread.
  7840. If THREADSP (the prefix), limit to articles that are in threads."
  7841. (interactive "P")
  7842. (let ((articles nil)
  7843. thread-articles
  7844. threads)
  7845. (dolist (thread gnus-newsgroup-threads)
  7846. (if (stringp (car thread))
  7847. (dolist (thread (cdr thread))
  7848. (push thread threads))
  7849. (push thread threads)))
  7850. (dolist (thread threads)
  7851. (setq thread-articles (gnus-articles-in-thread thread))
  7852. (when (or (and threadsp
  7853. (> (length thread-articles) 1))
  7854. (and (not threadsp)
  7855. (= (length thread-articles) 1)))
  7856. (setq articles (nconc thread-articles articles))))
  7857. (if (not articles)
  7858. (message "No messages matched")
  7859. (gnus-summary-limit articles))
  7860. (gnus-summary-position-point)))
  7861. (defun gnus-summary-limit-to-replied (&optional unreplied)
  7862. "Limit the summary buffer to replied articles.
  7863. If UNREPLIED (the prefix), limit to unreplied articles."
  7864. (interactive "P")
  7865. (if unreplied
  7866. (gnus-summary-limit
  7867. (gnus-set-difference gnus-newsgroup-articles
  7868. gnus-newsgroup-replied))
  7869. (gnus-summary-limit gnus-newsgroup-replied))
  7870. (gnus-summary-position-point))
  7871. (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
  7872. "Exclude articles that are marked with MARKS (e.g. \"DK\").
  7873. If REVERSE, limit the summary buffer to articles that are marked
  7874. with MARKS. MARKS can either be a string of marks or a list of marks.
  7875. Returns how many articles were removed."
  7876. (interactive "sMarks: ")
  7877. (gnus-summary-limit-to-marks marks t))
  7878. (defun gnus-summary-limit-to-marks (marks &optional reverse)
  7879. "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
  7880. If REVERSE (the prefix), limit the summary buffer to articles that are
  7881. not marked with MARKS. MARKS can either be a string of marks or a
  7882. list of marks.
  7883. Returns how many articles were removed."
  7884. (interactive "sMarks: \nP")
  7885. (prog1
  7886. (let ((data gnus-newsgroup-data)
  7887. (marks (if (listp marks) marks
  7888. (append marks nil))) ; Transform to list.
  7889. articles)
  7890. (while data
  7891. (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
  7892. (memq (gnus-data-mark (car data)) marks))
  7893. (push (gnus-data-number (car data)) articles))
  7894. (setq data (cdr data)))
  7895. (gnus-summary-limit articles))
  7896. (gnus-summary-position-point)))
  7897. (defun gnus-summary-limit-to-score (score)
  7898. "Limit to articles with score at or above SCORE."
  7899. (interactive "NLimit to articles with score of at least: ")
  7900. (let ((data gnus-newsgroup-data)
  7901. articles)
  7902. (while data
  7903. (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
  7904. score)
  7905. (push (gnus-data-number (car data)) articles))
  7906. (setq data (cdr data)))
  7907. (prog1
  7908. (gnus-summary-limit articles)
  7909. (gnus-summary-position-point))))
  7910. (defun gnus-summary-limit-to-unseen ()
  7911. "Limit to unseen articles."
  7912. (interactive)
  7913. (prog1
  7914. (gnus-summary-limit gnus-newsgroup-unseen)
  7915. (gnus-summary-position-point)))
  7916. (defun gnus-summary-limit-include-thread (id)
  7917. "Display all the hidden articles that is in the thread with ID in it.
  7918. When called interactively, ID is the Message-ID of the current
  7919. article."
  7920. (interactive (list (mail-header-id (gnus-summary-article-header))))
  7921. (let ((articles (gnus-articles-in-thread
  7922. (gnus-id-to-thread (gnus-root-id id))))
  7923. ;;we REALLY want the whole thread---this prevents cut-threads
  7924. ;;from removing the thread we want to include.
  7925. (gnus-fetch-old-headers nil)
  7926. (gnus-build-sparse-threads nil))
  7927. (prog1
  7928. (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
  7929. (gnus-summary-limit-include-matching-articles
  7930. "subject"
  7931. (regexp-quote (gnus-simplify-subject-re
  7932. (mail-header-subject (gnus-id-to-header id)))))
  7933. (gnus-summary-position-point))))
  7934. (defun gnus-summary-limit-include-matching-articles (header regexp)
  7935. "Display all the hidden articles that have HEADERs that match REGEXP."
  7936. (interactive (list (read-string "Match on header: ")
  7937. (read-string "Regexp: ")))
  7938. (let ((articles (gnus-find-matching-articles header regexp)))
  7939. (prog1
  7940. (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
  7941. (gnus-summary-position-point))))
  7942. (defun gnus-summary-insert-dormant-articles ()
  7943. "Insert all the dormant articles for this group into the current buffer."
  7944. (interactive)
  7945. (let ((gnus-verbose (max 6 gnus-verbose)))
  7946. (if (not gnus-newsgroup-dormant)
  7947. (gnus-message 3 "No dormant articles for this group")
  7948. (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
  7949. (defun gnus-summary-insert-ticked-articles ()
  7950. "Insert ticked articles for this group into the current buffer."
  7951. (interactive)
  7952. (let ((gnus-verbose (max 6 gnus-verbose)))
  7953. (if (not gnus-newsgroup-marked)
  7954. (gnus-message 3 "No ticked articles for this group")
  7955. (gnus-summary-goto-subjects gnus-newsgroup-marked))))
  7956. (defun gnus-summary-limit-include-dormant ()
  7957. "Display all the hidden articles that are marked as dormant.
  7958. Note that this command only works on a subset of the articles currently
  7959. fetched for this group."
  7960. (interactive)
  7961. (unless gnus-newsgroup-dormant
  7962. (error "There are no dormant articles in this group"))
  7963. (prog1
  7964. (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
  7965. (gnus-summary-position-point)))
  7966. (defun gnus-summary-include-articles (articles)
  7967. "Fetch the headers for ARTICLES and then display the summary lines."
  7968. (let ((gnus-inhibit-demon t)
  7969. (gnus-agent nil)
  7970. (gnus-read-all-available-headers t))
  7971. (setq gnus-newsgroup-headers
  7972. (gnus-merge
  7973. 'list gnus-newsgroup-headers
  7974. (gnus-fetch-headers articles nil t)
  7975. 'gnus-article-sort-by-number))
  7976. (setq gnus-newsgroup-articles
  7977. (gnus-sorted-nunion gnus-newsgroup-articles articles))
  7978. (gnus-summary-limit (append articles gnus-newsgroup-limit))))
  7979. (defun gnus-summary-limit-exclude-dormant ()
  7980. "Hide all dormant articles."
  7981. (interactive)
  7982. (prog1
  7983. (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
  7984. (gnus-summary-position-point)))
  7985. (defun gnus-summary-limit-exclude-childless-dormant ()
  7986. "Hide all dormant articles that have no children."
  7987. (interactive)
  7988. (let ((data (gnus-data-list t))
  7989. articles d children)
  7990. ;; Find all articles that are either not dormant or have
  7991. ;; children.
  7992. (while (setq d (pop data))
  7993. (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
  7994. (and (setq children
  7995. (gnus-article-children (gnus-data-number d)))
  7996. (let (found)
  7997. (while children
  7998. (when (memq (car children) articles)
  7999. (setq children nil
  8000. found t))
  8001. (pop children))
  8002. found)))
  8003. (push (gnus-data-number d) articles)))
  8004. ;; Do the limiting.
  8005. (prog1
  8006. (gnus-summary-limit articles)
  8007. (gnus-summary-position-point))))
  8008. (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
  8009. "Mark all unread excluded articles as read.
  8010. If ALL, mark even excluded ticked and dormants as read."
  8011. (interactive "P")
  8012. (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
  8013. (let ((articles (gnus-sorted-ndifference
  8014. (sort
  8015. (mapcar (lambda (h) (mail-header-number h))
  8016. gnus-newsgroup-headers)
  8017. '<)
  8018. gnus-newsgroup-limit))
  8019. article)
  8020. (setq gnus-newsgroup-unreads
  8021. (gnus-sorted-intersection gnus-newsgroup-unreads
  8022. gnus-newsgroup-limit))
  8023. (if all
  8024. (setq gnus-newsgroup-dormant nil
  8025. gnus-newsgroup-marked nil
  8026. gnus-newsgroup-reads
  8027. (nconc
  8028. (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
  8029. gnus-newsgroup-reads))
  8030. (while (setq article (pop articles))
  8031. (unless (or (memq article gnus-newsgroup-dormant)
  8032. (memq article gnus-newsgroup-marked))
  8033. (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
  8034. (defun gnus-summary-limit (articles &optional pop)
  8035. (if pop
  8036. ;; We pop the previous limit off the stack and use that.
  8037. (setq articles (car gnus-newsgroup-limits)
  8038. gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
  8039. ;; We use the new limit, so we push the old limit on the stack.
  8040. (push gnus-newsgroup-limit gnus-newsgroup-limits))
  8041. ;; Set the limit.
  8042. (setq gnus-newsgroup-limit articles)
  8043. (let ((total (length gnus-newsgroup-data))
  8044. (data (gnus-data-find-list (gnus-summary-article-number)))
  8045. (gnus-summary-mark-below nil) ; Inhibit this.
  8046. found)
  8047. ;; This will do all the work of generating the new summary buffer
  8048. ;; according to the new limit.
  8049. (gnus-summary-prepare)
  8050. ;; Hide any threads, possibly.
  8051. (gnus-summary-maybe-hide-threads)
  8052. ;; Try to return to the article you were at, or one in the
  8053. ;; neighborhood.
  8054. (when data
  8055. ;; We try to find some article after the current one.
  8056. (while data
  8057. (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
  8058. (setq data nil
  8059. found t))
  8060. (setq data (cdr data))))
  8061. (unless found
  8062. ;; If there is no data, that means that we were after the last
  8063. ;; article. The same goes when we can't find any articles
  8064. ;; after the current one.
  8065. (goto-char (point-max))
  8066. (gnus-summary-find-prev))
  8067. (gnus-set-mode-line 'summary)
  8068. ;; We return how many articles were removed from the summary
  8069. ;; buffer as a result of the new limit.
  8070. (- total (length gnus-newsgroup-data))))
  8071. (defsubst gnus-invisible-cut-children (threads)
  8072. (let ((num 0))
  8073. (while threads
  8074. (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
  8075. (incf num))
  8076. (pop threads))
  8077. (< num 2)))
  8078. (defsubst gnus-cut-thread (thread)
  8079. "Go forwards in the thread until we find an article that we want to display."
  8080. (when (or (eq gnus-fetch-old-headers 'some)
  8081. (eq gnus-fetch-old-headers 'invisible)
  8082. (numberp gnus-fetch-old-headers)
  8083. (eq gnus-build-sparse-threads 'some)
  8084. (eq gnus-build-sparse-threads 'more))
  8085. ;; Deal with old-fetched headers and sparse threads.
  8086. (while (and
  8087. thread
  8088. (or
  8089. (gnus-summary-article-sparse-p (mail-header-number (car thread)))
  8090. (gnus-summary-article-ancient-p
  8091. (mail-header-number (car thread))))
  8092. (if (or (<= (length (cdr thread)) 1)
  8093. (eq gnus-fetch-old-headers 'invisible))
  8094. (setq gnus-newsgroup-limit
  8095. (delq (mail-header-number (car thread))
  8096. gnus-newsgroup-limit)
  8097. thread (cadr thread))
  8098. (when (gnus-invisible-cut-children (cdr thread))
  8099. (let ((th (cdr thread)))
  8100. (while th
  8101. (if (memq (mail-header-number (caar th))
  8102. gnus-newsgroup-limit)
  8103. (setq thread (car th)
  8104. th nil)
  8105. (setq th (cdr th))))))))))
  8106. thread)
  8107. (defun gnus-cut-threads (threads)
  8108. "Cut off all uninteresting articles from the beginning of THREADS."
  8109. (when (or (eq gnus-fetch-old-headers 'some)
  8110. (eq gnus-fetch-old-headers 'invisible)
  8111. (numberp gnus-fetch-old-headers)
  8112. (eq gnus-build-sparse-threads 'some)
  8113. (eq gnus-build-sparse-threads 'more))
  8114. (let ((th threads))
  8115. (while th
  8116. (setcar th (gnus-cut-thread (car th)))
  8117. (setq th (cdr th)))))
  8118. ;; Remove nixed out threads.
  8119. (delq nil threads))
  8120. (defun gnus-summary-initial-limit (&optional show-if-empty)
  8121. "Figure out what the initial limit is supposed to be on group entry.
  8122. This entails weeding out unwanted dormants, low-scored articles,
  8123. fetch-old-headers verbiage, and so on."
  8124. ;; Most groups have nothing to remove.
  8125. (unless (or gnus-inhibit-limiting
  8126. (and (null gnus-newsgroup-dormant)
  8127. (eq gnus-newsgroup-display 'gnus-not-ignore)
  8128. (not (eq gnus-fetch-old-headers 'some))
  8129. (not (numberp gnus-fetch-old-headers))
  8130. (not (eq gnus-fetch-old-headers 'invisible))
  8131. (null gnus-summary-expunge-below)
  8132. (not (eq gnus-build-sparse-threads 'some))
  8133. (not (eq gnus-build-sparse-threads 'more))
  8134. (null gnus-thread-expunge-below)))
  8135. (push gnus-newsgroup-limit gnus-newsgroup-limits)
  8136. (setq gnus-newsgroup-limit nil)
  8137. (mapatoms
  8138. (lambda (node)
  8139. (unless (car (symbol-value node))
  8140. ;; These threads have no parents -- they are roots.
  8141. (let ((nodes (cdr (symbol-value node)))
  8142. thread)
  8143. (while nodes
  8144. (if (and gnus-thread-expunge-below
  8145. (< (gnus-thread-total-score (car nodes))
  8146. gnus-thread-expunge-below))
  8147. (gnus-expunge-thread (pop nodes))
  8148. (setq thread (pop nodes))
  8149. (gnus-summary-limit-children thread))))))
  8150. gnus-newsgroup-dependencies)
  8151. ;; If this limitation resulted in an empty group, we might
  8152. ;; pop the previous limit and use it instead.
  8153. (when (and (not gnus-newsgroup-limit)
  8154. show-if-empty)
  8155. (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
  8156. gnus-newsgroup-limit))
  8157. (defun gnus-summary-limit-children (thread)
  8158. "Return 1 if this subthread is visible and 0 if it is not."
  8159. ;; First we get the number of visible children to this thread. This
  8160. ;; is done by recursing down the thread using this function, so this
  8161. ;; will really go down to a leaf article first, before slowly
  8162. ;; working its way up towards the root.
  8163. (when thread
  8164. (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
  8165. (children
  8166. (if (cdr thread)
  8167. (apply '+ (mapcar 'gnus-summary-limit-children
  8168. (cdr thread)))
  8169. 0))
  8170. (number (mail-header-number (car thread)))
  8171. score)
  8172. (if (and
  8173. (not (memq number gnus-newsgroup-marked))
  8174. (or
  8175. ;; If this article is dormant and has absolutely no visible
  8176. ;; children, then this article isn't visible.
  8177. (and (memq number gnus-newsgroup-dormant)
  8178. (zerop children))
  8179. ;; If this is "fetch-old-headered" and there is no
  8180. ;; visible children, then we don't want this article.
  8181. (and (or (eq gnus-fetch-old-headers 'some)
  8182. (numberp gnus-fetch-old-headers))
  8183. (gnus-summary-article-ancient-p number)
  8184. (zerop children))
  8185. ;; If this is "fetch-old-headered" and `invisible', then
  8186. ;; we don't want this article.
  8187. (and (eq gnus-fetch-old-headers 'invisible)
  8188. (gnus-summary-article-ancient-p number))
  8189. ;; If this is a sparsely inserted article with no children,
  8190. ;; we don't want it.
  8191. (and (eq gnus-build-sparse-threads 'some)
  8192. (gnus-summary-article-sparse-p number)
  8193. (zerop children))
  8194. ;; If we use expunging, and this article is really
  8195. ;; low-scored, then we don't want this article.
  8196. (when (and gnus-summary-expunge-below
  8197. (< (setq score
  8198. (or (cdr (assq number gnus-newsgroup-scored))
  8199. gnus-summary-default-score))
  8200. gnus-summary-expunge-below))
  8201. ;; We increase the expunge-tally here, but that has
  8202. ;; nothing to do with the limits, really.
  8203. (incf gnus-newsgroup-expunged-tally)
  8204. ;; We also mark as read here, if that's wanted.
  8205. (when (and gnus-summary-mark-below
  8206. (< score gnus-summary-mark-below))
  8207. (setq gnus-newsgroup-unreads
  8208. (delq number gnus-newsgroup-unreads))
  8209. (if gnus-newsgroup-auto-expire
  8210. (push number gnus-newsgroup-expirable)
  8211. (push (cons number gnus-low-score-mark)
  8212. gnus-newsgroup-reads)))
  8213. t)
  8214. ;; Do the `display' group parameter.
  8215. (and gnus-newsgroup-display
  8216. (let ((gnus-number number))
  8217. (not (funcall gnus-newsgroup-display))))))
  8218. ;; Nope, invisible article.
  8219. 0
  8220. ;; Ok, this article is to be visible, so we add it to the limit
  8221. ;; and return 1.
  8222. (push number gnus-newsgroup-limit)
  8223. 1))))
  8224. (defun gnus-expunge-thread (thread)
  8225. "Mark all articles in THREAD as read."
  8226. (let* ((number (mail-header-number (car thread))))
  8227. (incf gnus-newsgroup-expunged-tally)
  8228. ;; We also mark as read here, if that's wanted.
  8229. (setq gnus-newsgroup-unreads
  8230. (delq number gnus-newsgroup-unreads))
  8231. (if gnus-newsgroup-auto-expire
  8232. (push number gnus-newsgroup-expirable)
  8233. (push (cons number gnus-low-score-mark)
  8234. gnus-newsgroup-reads)))
  8235. ;; Go recursively through all subthreads.
  8236. (mapcar 'gnus-expunge-thread (cdr thread)))
  8237. ;; Summary article oriented commands
  8238. (defun gnus-summary-refer-parent-article (n)
  8239. "Refer parent article N times.
  8240. If N is negative, go to ancestor -N instead.
  8241. The difference between N and the number of articles fetched is returned."
  8242. (interactive "p")
  8243. (let ((skip 1)
  8244. error header ref)
  8245. (when (not (natnump n))
  8246. (setq skip (abs n)
  8247. n 1))
  8248. (while (and (> n 0)
  8249. (not error))
  8250. (setq header (gnus-summary-article-header))
  8251. (if (and (eq (mail-header-number header)
  8252. (cdr gnus-article-current))
  8253. (equal gnus-newsgroup-name
  8254. (car gnus-article-current)))
  8255. ;; If we try to find the parent of the currently
  8256. ;; displayed article, then we take a look at the actual
  8257. ;; References header, since this is slightly more
  8258. ;; reliable than the References field we got from the
  8259. ;; server.
  8260. (with-current-buffer gnus-original-article-buffer
  8261. (nnheader-narrow-to-headers)
  8262. (unless (setq ref (message-fetch-field "references"))
  8263. (when (setq ref (message-fetch-field "in-reply-to"))
  8264. (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
  8265. (widen))
  8266. (setq ref
  8267. ;; It's not the current article, so we take a bet on
  8268. ;; the value we got from the server.
  8269. (mail-header-references header)))
  8270. (if (and ref
  8271. (not (equal ref "")))
  8272. (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
  8273. (gnus-message 1 "Couldn't find parent"))
  8274. (gnus-message 1 "No references in article %d"
  8275. (gnus-summary-article-number))
  8276. (setq error t))
  8277. (decf n))
  8278. (gnus-summary-position-point)
  8279. n))
  8280. (defun gnus-summary-refer-references ()
  8281. "Fetch all articles mentioned in the References header.
  8282. Return the number of articles fetched."
  8283. (interactive)
  8284. (let ((ref (mail-header-references (gnus-summary-article-header)))
  8285. (current (gnus-summary-article-number))
  8286. (n 0))
  8287. (if (or (not ref)
  8288. (equal ref ""))
  8289. (error "No References in the current article")
  8290. ;; For each Message-ID in the References header...
  8291. (while (string-match "<[^>]*>" ref)
  8292. (incf n)
  8293. ;; ... fetch that article.
  8294. (gnus-summary-refer-article
  8295. (prog1 (match-string 0 ref)
  8296. (setq ref (substring ref (match-end 0))))))
  8297. (gnus-summary-goto-subject current)
  8298. (gnus-summary-position-point)
  8299. n)))
  8300. (defun gnus-delete-duplicate-headers (headers)
  8301. ;; First remove leading duplicates.
  8302. (while (and (> (length headers) 1)
  8303. (= (mail-header-number (car headers))
  8304. (mail-header-number (cadr headers))))
  8305. (pop headers))
  8306. ;; Then the rest.
  8307. (let ((result headers))
  8308. (while (> (length headers) 1)
  8309. (if (= (mail-header-number (car headers))
  8310. (mail-header-number (cadr headers)))
  8311. (setcdr headers (cddr headers))
  8312. (pop headers)))
  8313. result))
  8314. (defun gnus-summary-refer-thread (&optional limit)
  8315. "Fetch all articles in the current thread. For backends that
  8316. know how to search for threads (currently only 'nnimap) a
  8317. non-numeric prefix arg will use nnir to search the entire
  8318. server; without a prefix arg only the current group is
  8319. searched. If the variable `gnus-refer-thread-use-nnir' is
  8320. non-nil the prefix arg has the reverse meaning. If no
  8321. backend-specific 'request-thread function is available fetch
  8322. LIMIT (the numerical prefix) old headers. If LIMIT is
  8323. non-numeric or nil fetch the number specified by the
  8324. `gnus-refer-thread-limit' variable."
  8325. (interactive "P")
  8326. (gnus-warp-to-article)
  8327. (let* ((header (gnus-summary-article-header))
  8328. (id (mail-header-id header))
  8329. (gnus-inhibit-demon t)
  8330. (gnus-summary-ignore-duplicates t)
  8331. (gnus-read-all-available-headers t)
  8332. (gnus-refer-thread-use-nnir
  8333. (if (and (not (null limit)) (listp limit))
  8334. (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
  8335. (new-headers
  8336. (if (gnus-check-backend-function
  8337. 'request-thread gnus-newsgroup-name)
  8338. (gnus-request-thread header gnus-newsgroup-name)
  8339. (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
  8340. gnus-refer-thread-limit))
  8341. (last (if (numberp limit)
  8342. (min (+ (mail-header-number header)
  8343. limit)
  8344. gnus-newsgroup-highest)
  8345. gnus-newsgroup-highest))
  8346. (subject (gnus-simplify-subject
  8347. (mail-header-subject header)))
  8348. (refs (split-string (or (mail-header-references header)
  8349. "")))
  8350. (gnus-parse-headers-hook
  8351. `(lambda () (goto-char (point-min))
  8352. (keep-lines
  8353. (regexp-opt ',(append refs (list id subject)))))))
  8354. (gnus-fetch-headers (list last) (if (numberp limit)
  8355. (* 2 limit) limit) t))))
  8356. article-ids new-unreads)
  8357. (when (listp new-headers)
  8358. (dolist (header new-headers)
  8359. (push (mail-header-number header) article-ids))
  8360. (setq article-ids (nreverse article-ids))
  8361. (setq new-unreads
  8362. (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
  8363. (setq gnus-newsgroup-unselected
  8364. (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
  8365. (setq gnus-newsgroup-unreads
  8366. (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
  8367. (setq gnus-newsgroup-headers
  8368. (gnus-delete-duplicate-headers
  8369. (gnus-merge
  8370. 'list gnus-newsgroup-headers new-headers
  8371. 'gnus-article-sort-by-number)))
  8372. (setq gnus-newsgroup-articles
  8373. (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
  8374. (gnus-summary-limit-include-thread id)))
  8375. (gnus-summary-show-thread))
  8376. (defun gnus-summary-open-group-with-article (message-id)
  8377. "Open a group containing the article with the given MESSAGE-ID."
  8378. (interactive "sMessage-ID: ")
  8379. (require 'nndoc)
  8380. (with-temp-buffer
  8381. ;; Prepare a dummy article
  8382. (erase-buffer)
  8383. (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
  8384. ;; Prepare pretty modelines for summary and article buffers
  8385. (let ((gnus-summary-mode-line-format "Found %G")
  8386. (gnus-article-mode-line-format
  8387. ;; Group names just get in the way here, especially the
  8388. ;; abbreviated ones
  8389. (if (string-match "%[gG]" gnus-article-mode-line-format)
  8390. (concat (substring gnus-article-mode-line-format
  8391. 0 (match-beginning 0))
  8392. (substring gnus-article-mode-line-format (match-end 0)))
  8393. gnus-article-mode-line-format)))
  8394. ;; Build an ephemeral group containing the dummy article (hidden)
  8395. (gnus-group-read-ephemeral-group
  8396. message-id
  8397. `(nndoc ,message-id
  8398. (nndoc-address ,(current-buffer))
  8399. (nndoc-article-type mbox))
  8400. :activate
  8401. (cons (current-buffer) gnus-current-window-configuration)
  8402. (not :request-only)
  8403. '(-1) ; :select-articles
  8404. (not :parameters)
  8405. 0)) ; :number
  8406. ;; Fetch the desired article
  8407. (gnus-summary-refer-article message-id)))
  8408. (defun gnus-summary-refer-article (message-id)
  8409. "Fetch an article specified by MESSAGE-ID."
  8410. (interactive "sMessage-ID: ")
  8411. (gnus-warp-to-article)
  8412. (when (and (stringp message-id)
  8413. (not (zerop (length message-id))))
  8414. (setq message-id (gnus-replace-in-string message-id " " ""))
  8415. ;; Construct the correct Message-ID if necessary.
  8416. ;; Suggested by tale@pawl.rpi.edu.
  8417. (unless (string-match "^<" message-id)
  8418. (setq message-id (concat "<" message-id)))
  8419. (unless (string-match ">$" message-id)
  8420. (setq message-id (concat message-id ">")))
  8421. ;; People often post MIDs from URLs, so unhex it:
  8422. (unless (string-match "@" message-id)
  8423. (setq message-id (gnus-url-unhex-string message-id)))
  8424. (let* ((header (gnus-id-to-header message-id))
  8425. (sparse (and header
  8426. (gnus-summary-article-sparse-p
  8427. (mail-header-number header))
  8428. (memq (mail-header-number header)
  8429. gnus-newsgroup-limit)))
  8430. number)
  8431. (cond
  8432. ;; If the article is present in the buffer we just go to it.
  8433. ((and header
  8434. (or (not (gnus-summary-article-sparse-p
  8435. (mail-header-number header)))
  8436. sparse))
  8437. (prog1
  8438. (gnus-summary-goto-article
  8439. (mail-header-number header) nil t)
  8440. (when sparse
  8441. (gnus-summary-update-article (mail-header-number header)))))
  8442. (t
  8443. ;; We fetch the article.
  8444. (catch 'found
  8445. (dolist (gnus-override-method (gnus-refer-article-methods))
  8446. (when (and (gnus-check-server gnus-override-method)
  8447. ;; Fetch the header,
  8448. (setq number (gnus-summary-insert-subject message-id)))
  8449. ;; and display the article.
  8450. (gnus-summary-select-article nil nil nil number)
  8451. (throw 'found t)))
  8452. (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
  8453. (defun gnus-refer-article-methods ()
  8454. "Return a list of referable methods."
  8455. (cond
  8456. ;; No method, so we default to current and native.
  8457. ((null gnus-refer-article-method)
  8458. (list gnus-current-select-method gnus-select-method))
  8459. ;; Current.
  8460. ((eq 'current gnus-refer-article-method)
  8461. (list gnus-current-select-method))
  8462. ;; List of select methods.
  8463. ((not (and (symbolp (car gnus-refer-article-method))
  8464. (assq (car gnus-refer-article-method) nnoo-definition-alist)))
  8465. (let (out)
  8466. (dolist (method gnus-refer-article-method)
  8467. (push (if (eq 'current method)
  8468. gnus-current-select-method
  8469. (if (eq 'nnir (car method))
  8470. (list
  8471. 'nnir
  8472. (or (cadr method)
  8473. (gnus-method-to-server gnus-current-select-method)))
  8474. method))
  8475. out))
  8476. (nreverse out)))
  8477. ;; One single select method.
  8478. (t
  8479. (list gnus-refer-article-method))))
  8480. (defun gnus-summary-edit-parameters ()
  8481. "Edit the group parameters of the current group."
  8482. (interactive)
  8483. (gnus-group-edit-group gnus-newsgroup-name 'params))
  8484. (defun gnus-summary-customize-parameters ()
  8485. "Customize the group parameters of the current group."
  8486. (interactive)
  8487. (gnus-group-customize gnus-newsgroup-name))
  8488. (defun gnus-summary-enter-digest-group (&optional force)
  8489. "Enter an nndoc group based on the current article.
  8490. If FORCE, force a digest interpretation. If not, try to guess
  8491. what the document format is.
  8492. To control what happens when you exit the group, see the
  8493. `gnus-auto-select-on-ephemeral-exit' variable."
  8494. (interactive "P")
  8495. (let ((conf gnus-current-window-configuration))
  8496. (save-window-excursion
  8497. (save-excursion
  8498. (let (gnus-article-prepare-hook
  8499. gnus-display-mime-function
  8500. gnus-break-pages)
  8501. (gnus-summary-select-article))))
  8502. (setq gnus-current-window-configuration conf)
  8503. (let* ((name (format "%s-%d"
  8504. (gnus-group-prefixed-name
  8505. gnus-newsgroup-name (list 'nndoc ""))
  8506. (with-current-buffer gnus-summary-buffer
  8507. gnus-current-article)))
  8508. (ogroup gnus-newsgroup-name)
  8509. (params (append (gnus-info-params (gnus-get-info ogroup))
  8510. (list (cons 'to-group ogroup))
  8511. (list (cons 'parent-group ogroup))
  8512. (list (cons 'save-article-group ogroup))))
  8513. (case-fold-search t)
  8514. (buf (current-buffer))
  8515. dig to-address charset)
  8516. (with-current-buffer gnus-original-article-buffer
  8517. ;; Have the digest group inherit the main mail address of
  8518. ;; the parent article.
  8519. (when (setq to-address (or (gnus-fetch-field "reply-to")
  8520. (gnus-fetch-field "from")))
  8521. (setq params
  8522. (append
  8523. params
  8524. (list (cons 'to-address
  8525. (funcall gnus-decode-encoded-address-function
  8526. to-address))))))
  8527. (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
  8528. (insert-buffer-substring gnus-original-article-buffer)
  8529. (narrow-to-region
  8530. (goto-char (point-min))
  8531. (or (search-forward "\n\n" nil t) (point)))
  8532. ;; Remove lines that may lead nndoc to misinterpret the
  8533. ;; document type.
  8534. (goto-char (point-min))
  8535. (delete-matching-lines "^Path:\\|^From ")
  8536. ;; Parse charset, and decode content transfer encoding.
  8537. (setq charset (mail-content-type-get
  8538. (mail-header-parse-content-type
  8539. (or (gnus-fetch-field "content-type") ""))
  8540. 'charset))
  8541. (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
  8542. (when encoding
  8543. (message-remove-header "content-transfer-encoding")
  8544. (goto-char (point-max))
  8545. (widen)
  8546. (narrow-to-region (point) (point-max))
  8547. (mm-decode-content-transfer-encoding
  8548. (intern (downcase (mail-header-strip encoding))))))
  8549. (widen))
  8550. (unwind-protect
  8551. (if (let ((gnus-newsgroup-ephemeral-charset
  8552. (if charset
  8553. (intern (downcase (gnus-strip-whitespace charset)))
  8554. gnus-newsgroup-charset))
  8555. (gnus-newsgroup-ephemeral-ignored-charsets
  8556. gnus-newsgroup-ignored-charsets))
  8557. (gnus-group-read-ephemeral-group
  8558. name `(nndoc ,name (nndoc-address ,(get-buffer dig))
  8559. (nndoc-article-type
  8560. ,(if force 'mbox 'guess)))
  8561. t nil nil nil
  8562. `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
  8563. "ADAPT")))))
  8564. ;; Make all postings to this group go to the parent group.
  8565. (nconc (gnus-info-params (gnus-get-info name))
  8566. params)
  8567. ;; Couldn't select this doc group.
  8568. (switch-to-buffer buf)
  8569. (gnus-set-global-variables)
  8570. (gnus-configure-windows 'summary)
  8571. (gnus-message 3 "Article couldn't be entered?"))
  8572. (kill-buffer dig)))))
  8573. (defun gnus-summary-read-document (n)
  8574. "Open a new group based on the current article(s).
  8575. This will allow you to read digests and other similar
  8576. documents as newsgroups.
  8577. Obeys the standard process/prefix convention."
  8578. (interactive "P")
  8579. (let* ((ogroup gnus-newsgroup-name)
  8580. (params (append (gnus-info-params (gnus-get-info ogroup))
  8581. (list (cons 'to-group ogroup))))
  8582. group egroup groups vgroup)
  8583. (dolist (article (gnus-summary-work-articles n))
  8584. (setq group (format "%s-%d" gnus-newsgroup-name article))
  8585. (gnus-summary-remove-process-mark article)
  8586. (when (gnus-summary-display-article article)
  8587. (save-excursion ;;What for?
  8588. (with-temp-buffer
  8589. (insert-buffer-substring gnus-original-article-buffer)
  8590. ;; Remove some headers that may lead nndoc to make
  8591. ;; the wrong guess.
  8592. (message-narrow-to-head)
  8593. (goto-char (point-min))
  8594. (delete-matching-lines "^Path:\\|^From ")
  8595. (widen)
  8596. (if (setq egroup
  8597. (gnus-group-read-ephemeral-group
  8598. group `(nndoc ,group (nndoc-address ,(current-buffer))
  8599. (nndoc-article-type guess))
  8600. t nil t))
  8601. (progn
  8602. ;; Make all postings to this group go to the parent group.
  8603. (nconc (gnus-info-params (gnus-get-info egroup))
  8604. params)
  8605. (push egroup groups))
  8606. ;; Couldn't select this doc group.
  8607. (gnus-error 3 "Article couldn't be entered"))))))
  8608. ;; Now we have selected all the documents.
  8609. (cond
  8610. ((not groups)
  8611. (error "None of the articles could be interpreted as documents"))
  8612. ((gnus-group-read-ephemeral-group
  8613. (setq vgroup (format
  8614. "nnvirtual:%s-%s" gnus-newsgroup-name
  8615. (format-time-string "%Y%m%dT%H%M%S")))
  8616. `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
  8617. t
  8618. (cons (current-buffer) 'summary)))
  8619. (t
  8620. (error "Couldn't select virtual nndoc group")))))
  8621. (defun gnus-summary-widget-forward (arg)
  8622. "Move point to the next field or button in the article.
  8623. With optional ARG, move across that many fields."
  8624. (interactive "p")
  8625. (gnus-summary-select-article)
  8626. (gnus-configure-windows 'article)
  8627. (select-window (gnus-get-buffer-window gnus-article-buffer))
  8628. (widget-forward arg))
  8629. (defun gnus-summary-widget-backward (arg)
  8630. "Move point to the previous field or button in the article.
  8631. With optional ARG, move across that many fields."
  8632. (interactive "p")
  8633. (gnus-summary-select-article)
  8634. (gnus-configure-windows 'article)
  8635. (select-window (gnus-get-buffer-window gnus-article-buffer))
  8636. (unless (widget-at (point))
  8637. (goto-char (point-max)))
  8638. (widget-backward arg))
  8639. (defun gnus-summary-isearch-article (&optional regexp-p)
  8640. "Do incremental search forward on the current article.
  8641. If REGEXP-P (the prefix) is non-nil, do regexp isearch."
  8642. (interactive "P")
  8643. (gnus-summary-select-article)
  8644. (gnus-configure-windows 'article)
  8645. (gnus-eval-in-buffer-window gnus-article-buffer
  8646. (save-restriction
  8647. (widen)
  8648. (isearch-forward regexp-p))))
  8649. (defun gnus-summary-repeat-search-article-forward ()
  8650. "Repeat the previous search forwards."
  8651. (interactive)
  8652. (unless gnus-last-search-regexp
  8653. (error "No previous search"))
  8654. (gnus-summary-search-article-forward gnus-last-search-regexp))
  8655. (defun gnus-summary-repeat-search-article-backward ()
  8656. "Repeat the previous search backwards."
  8657. (interactive)
  8658. (unless gnus-last-search-regexp
  8659. (error "No previous search"))
  8660. (gnus-summary-search-article-forward gnus-last-search-regexp t))
  8661. (defun gnus-summary-search-article-forward (regexp &optional backward)
  8662. "Search for an article containing REGEXP forward.
  8663. If BACKWARD, search backward instead."
  8664. (interactive
  8665. (list (read-string
  8666. (format "Search article %s (regexp%s): "
  8667. (if current-prefix-arg "backward" "forward")
  8668. (if gnus-last-search-regexp
  8669. (concat ", default " gnus-last-search-regexp)
  8670. "")))
  8671. current-prefix-arg))
  8672. (if (string-equal regexp "")
  8673. (setq regexp (or gnus-last-search-regexp ""))
  8674. (setq gnus-last-search-regexp regexp)
  8675. (setq gnus-article-before-search gnus-current-article))
  8676. ;; Intentionally set gnus-last-article.
  8677. (setq gnus-last-article gnus-article-before-search)
  8678. (let ((gnus-last-article gnus-last-article))
  8679. (if (gnus-summary-search-article regexp backward)
  8680. (gnus-summary-show-thread)
  8681. (signal 'search-failed (list regexp)))))
  8682. (defun gnus-summary-search-article-backward (regexp)
  8683. "Search for an article containing REGEXP backward."
  8684. (interactive
  8685. (list (read-string
  8686. (format "Search article backward (regexp%s): "
  8687. (if gnus-last-search-regexp
  8688. (concat ", default " gnus-last-search-regexp)
  8689. "")))))
  8690. (gnus-summary-search-article-forward regexp 'backward))
  8691. (defun gnus-summary-search-article (regexp &optional backward)
  8692. "Search for an article containing REGEXP.
  8693. Optional argument BACKWARD means do search for backward.
  8694. `gnus-select-article-hook' is not called during the search."
  8695. ;; We have to require this here to make sure that the following
  8696. ;; dynamic binding isn't shadowed by autoloading.
  8697. (require 'gnus-async)
  8698. (require 'gnus-art)
  8699. (let ((gnus-select-article-hook nil) ;Disable hook.
  8700. (gnus-article-prepare-hook nil)
  8701. (gnus-mark-article-hook nil) ;Inhibit marking as read.
  8702. (gnus-use-article-prefetch nil)
  8703. (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
  8704. (gnus-use-trees nil) ;Inhibit updating tree buffer.
  8705. (gnus-visual nil)
  8706. (gnus-keep-backlog nil)
  8707. (gnus-break-pages nil)
  8708. (gnus-summary-display-arrow nil)
  8709. (gnus-updated-mode-lines nil)
  8710. (gnus-auto-center-summary nil)
  8711. (sum (current-buffer))
  8712. (gnus-display-mime-function nil)
  8713. (found nil)
  8714. point)
  8715. (gnus-save-hidden-threads
  8716. (gnus-summary-select-article)
  8717. (set-buffer gnus-article-buffer)
  8718. (goto-char (window-point (get-buffer-window (current-buffer))))
  8719. (when backward
  8720. (forward-line -1))
  8721. (while (not found)
  8722. (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
  8723. (if (if backward
  8724. (re-search-backward regexp nil t)
  8725. (re-search-forward regexp nil t))
  8726. ;; We found the regexp.
  8727. (progn
  8728. (setq found 'found)
  8729. (beginning-of-line)
  8730. (set-window-start
  8731. (get-buffer-window (current-buffer))
  8732. (point))
  8733. (forward-line 1)
  8734. (set-window-point
  8735. (get-buffer-window (current-buffer))
  8736. (point))
  8737. (set-buffer sum)
  8738. (setq point (point)))
  8739. ;; We didn't find it, so we go to the next article.
  8740. (set-buffer sum)
  8741. (setq found 'not)
  8742. (while (eq found 'not)
  8743. (if (not (if backward (gnus-summary-find-prev)
  8744. (gnus-summary-find-next)))
  8745. ;; No more articles.
  8746. (setq found t)
  8747. ;; Select the next article and adjust point.
  8748. (unless (gnus-summary-article-sparse-p
  8749. (gnus-summary-article-number))
  8750. (setq found nil)
  8751. (gnus-summary-select-article)
  8752. (set-buffer gnus-article-buffer)
  8753. (widen)
  8754. (goto-char (if backward (point-max) (point-min))))))))
  8755. (gnus-message 7 ""))
  8756. ;; Return whether we found the regexp.
  8757. (when (eq found 'found)
  8758. (goto-char point)
  8759. (sit-for 0) ;; Ensure that the point is visible in the summary window.
  8760. (gnus-summary-show-thread)
  8761. (gnus-summary-goto-subject gnus-current-article)
  8762. (gnus-summary-position-point)
  8763. t)))
  8764. (defun gnus-find-matching-articles (header regexp)
  8765. "Return a list of all articles that match REGEXP on HEADER.
  8766. This search includes all articles in the current group that Gnus has
  8767. fetched headers for, whether they are displayed or not."
  8768. (let ((articles nil)
  8769. ;; Can't eta-reduce because it's a macro.
  8770. (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
  8771. (case-fold-search t))
  8772. (dolist (header gnus-newsgroup-headers)
  8773. (when (string-match regexp (funcall func header))
  8774. (push (mail-header-number header) articles)))
  8775. (nreverse articles)))
  8776. (defun gnus-summary-find-matching (header regexp &optional backward unread
  8777. not-case-fold not-matching)
  8778. "Return a list of all articles that match REGEXP on HEADER.
  8779. The search stars on the current article and goes forwards unless
  8780. BACKWARD is non-nil. If BACKWARD is `all', do all articles.
  8781. If UNREAD is non-nil, only unread articles will
  8782. be taken into consideration. If NOT-CASE-FOLD, case won't be folded
  8783. in the comparisons. If NOT-MATCHING, return a list of all articles that
  8784. not match REGEXP on HEADER."
  8785. (let ((case-fold-search (not not-case-fold))
  8786. articles d func)
  8787. (if (consp header)
  8788. (if (eq (car header) 'extra)
  8789. (setq func
  8790. `(lambda (h)
  8791. (or (cdr (assq ',(cdr header) (mail-header-extra h)))
  8792. "")))
  8793. (error "%s is an invalid header" header))
  8794. (unless (fboundp (intern (concat "mail-header-" header)))
  8795. (error "%s is not a valid header" header))
  8796. (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
  8797. (dolist (d (if (eq backward 'all)
  8798. gnus-newsgroup-data
  8799. (gnus-data-find-list
  8800. (gnus-summary-article-number)
  8801. (gnus-data-list backward))))
  8802. (when (and (or (not unread) ; We want all articles...
  8803. (gnus-data-unread-p d)) ; Or just unreads.
  8804. (vectorp (gnus-data-header d)) ; It's not a pseudo.
  8805. (if not-matching
  8806. (not (string-match
  8807. regexp
  8808. (funcall func (gnus-data-header d))))
  8809. (string-match regexp
  8810. (funcall func (gnus-data-header d)))))
  8811. (push (gnus-data-number d) articles))) ; Success!
  8812. (nreverse articles)))
  8813. (defun gnus-summary-execute-command (header regexp command &optional backward)
  8814. "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
  8815. If HEADER is an empty string (or nil), the match is done on the entire
  8816. article. If BACKWARD (the prefix) is non-nil, search backward instead."
  8817. (interactive
  8818. (list (let ((completion-ignore-case t))
  8819. (gnus-completing-read
  8820. "Header name"
  8821. (mapcar 'symbol-name
  8822. (append
  8823. '(Number Subject From Lines Date
  8824. Message-ID Xref References Body)
  8825. gnus-extra-headers))
  8826. 'require-match))
  8827. (read-string "Regexp: ")
  8828. (read-key-sequence "Command: ")
  8829. current-prefix-arg))
  8830. (when (equal header "Body")
  8831. (setq header ""))
  8832. ;; Hidden thread subtrees must be searched as well.
  8833. (gnus-summary-show-all-threads)
  8834. ;; We don't want to change current point nor window configuration.
  8835. (save-excursion
  8836. (save-window-excursion
  8837. (let (gnus-visual
  8838. gnus-treat-strip-trailing-blank-lines
  8839. gnus-treat-strip-leading-blank-lines
  8840. gnus-treat-strip-multiple-blank-lines
  8841. gnus-treat-hide-boring-headers
  8842. gnus-treat-fold-newsgroups
  8843. gnus-article-prepare-hook)
  8844. (gnus-message 6 "Executing %s..." (key-description command))
  8845. ;; We'd like to execute COMMAND interactively so as to give arguments.
  8846. (gnus-execute header regexp
  8847. `(call-interactively ',(key-binding command))
  8848. backward)
  8849. (gnus-message 6 "Executing %s...done" (key-description command))))))
  8850. (defun gnus-summary-beginning-of-article ()
  8851. "Scroll the article back to the beginning."
  8852. (interactive)
  8853. (gnus-summary-select-article)
  8854. (gnus-configure-windows 'article)
  8855. (gnus-eval-in-buffer-window gnus-article-buffer
  8856. (widen)
  8857. (goto-char (point-min))
  8858. (when gnus-break-pages
  8859. (gnus-narrow-to-page))))
  8860. (defun gnus-summary-end-of-article ()
  8861. "Scroll to the end of the article."
  8862. (interactive)
  8863. (gnus-summary-select-article)
  8864. (gnus-configure-windows 'article)
  8865. (gnus-eval-in-buffer-window gnus-article-buffer
  8866. (widen)
  8867. (goto-char (point-max))
  8868. (recenter -3)
  8869. (when gnus-break-pages
  8870. (gnus-narrow-to-page))))
  8871. (defun gnus-summary-print-truncate-and-quote (string &optional len)
  8872. "Truncate to LEN and quote all \"(\"'s in STRING."
  8873. (gnus-replace-in-string (if (and len (> (length string) len))
  8874. (substring string 0 len)
  8875. string)
  8876. "[()]" "\\\\\\&"))
  8877. (defun gnus-summary-print-article (&optional filename n)
  8878. "Generate and print a PostScript image of the process-marked (mail) articles.
  8879. If used interactively, print the current article if none are
  8880. process-marked. With prefix arg, prompt the user for the name of the
  8881. file to save in.
  8882. When used from Lisp, accept two optional args FILENAME and N. N means
  8883. to print the next N articles. If N is negative, print the N previous
  8884. articles. If N is nil and articles have been marked with the process
  8885. mark, print these instead.
  8886. If the optional first argument FILENAME is nil, send the image to the
  8887. printer. If FILENAME is a string, save the PostScript image in a file with
  8888. that name. If FILENAME is a number, prompt the user for the name of the file
  8889. to save in."
  8890. (interactive (list (ps-print-preprint current-prefix-arg)))
  8891. (dolist (article (gnus-summary-work-articles n))
  8892. (gnus-summary-select-article nil nil 'pseudo article)
  8893. (gnus-eval-in-buffer-window gnus-article-buffer
  8894. (gnus-print-buffer))
  8895. (gnus-summary-remove-process-mark article))
  8896. (ps-despool filename))
  8897. (defun gnus-print-buffer ()
  8898. (let ((ps-left-header
  8899. (list
  8900. (concat "("
  8901. (gnus-summary-print-truncate-and-quote
  8902. (mail-header-subject gnus-current-headers)
  8903. 66) ")")
  8904. (concat "("
  8905. (gnus-summary-print-truncate-and-quote
  8906. (mail-header-from gnus-current-headers)
  8907. 45) ")")))
  8908. (ps-right-header
  8909. (list
  8910. "/pagenumberstring load"
  8911. (concat "("
  8912. (mail-header-date gnus-current-headers) ")"))))
  8913. (gnus-run-hooks 'gnus-ps-print-hook)
  8914. (save-excursion
  8915. (if ps-print-color-p
  8916. (ps-spool-buffer-with-faces)
  8917. (ps-spool-buffer)))))
  8918. (declare-function gnus-flush-original-article-buffer "gnus-art" ())
  8919. (defun gnus-summary-show-complete-article ()
  8920. "Show a complete version of the current article.
  8921. This is only useful if you're looking at a partial version of the
  8922. article currently."
  8923. (interactive)
  8924. (let ((gnus-keep-backlog nil)
  8925. (gnus-use-cache nil)
  8926. (gnus-agent nil)
  8927. (variable (intern
  8928. (format "%s-fetch-partial-articles"
  8929. (car (gnus-find-method-for-group
  8930. gnus-newsgroup-name)))
  8931. obarray))
  8932. old-val)
  8933. (unwind-protect
  8934. (progn
  8935. (setq old-val (symbol-value variable))
  8936. (set variable nil)
  8937. (gnus-flush-original-article-buffer)
  8938. (gnus-summary-show-article))
  8939. (set variable old-val))))
  8940. (defun gnus-summary-show-article (&optional arg)
  8941. "Force redisplaying of the current article.
  8942. If ARG (the prefix) is a number, show the article with the charset
  8943. defined in `gnus-summary-show-article-charset-alist', or the charset
  8944. input.
  8945. If ARG (the prefix) is non-nil and not a number, show the article,
  8946. but without running any of the article treatment functions
  8947. article. Normally, the keystroke is `C-u g'. When using `C-u
  8948. C-u g', show the raw article."
  8949. (interactive "P")
  8950. (cond
  8951. ((numberp arg)
  8952. (gnus-summary-show-article t)
  8953. (let ((gnus-newsgroup-charset
  8954. (or (cdr (assq arg gnus-summary-show-article-charset-alist))
  8955. (mm-read-coding-system
  8956. "View as charset: " ;; actually it is coding system.
  8957. (with-current-buffer gnus-article-buffer
  8958. (mm-detect-coding-region (point) (point-max))))))
  8959. (gnus-newsgroup-ignored-charsets 'gnus-all))
  8960. (gnus-summary-select-article nil 'force)
  8961. (let ((deps gnus-newsgroup-dependencies)
  8962. head header lines)
  8963. (with-current-buffer gnus-original-article-buffer
  8964. (save-restriction
  8965. (message-narrow-to-head)
  8966. (setq head (buffer-string))
  8967. (goto-char (point-min))
  8968. (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
  8969. (goto-char (point-max))
  8970. (widen)
  8971. (setq lines (1- (count-lines (point) (point-max))))))
  8972. (with-temp-buffer
  8973. (insert (format "211 %d Article retrieved.\n"
  8974. (cdr gnus-article-current)))
  8975. (insert head)
  8976. (if lines (insert (format "Lines: %d\n" lines)))
  8977. (insert ".\n")
  8978. (let ((nntp-server-buffer (current-buffer)))
  8979. (setq header (car (gnus-get-newsgroup-headers deps t))))))
  8980. (gnus-data-set-header
  8981. (gnus-data-find (cdr gnus-article-current))
  8982. header)
  8983. (gnus-summary-update-article-line
  8984. (cdr gnus-article-current) header)
  8985. (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
  8986. (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
  8987. ((not arg)
  8988. ;; Select the article the normal way.
  8989. (if (eq mm-text-html-renderer 'shr)
  8990. (progn
  8991. (require 'shr)
  8992. (let ((shr-ignore-cache t))
  8993. (gnus-summary-select-article nil 'force)))
  8994. (gnus-summary-select-article nil 'force)))
  8995. ((equal arg '(16))
  8996. ;; C-u C-u g
  8997. (let ((gnus-inhibit-article-treatments t))
  8998. (gnus-summary-select-article nil 'force)))
  8999. (t
  9000. ;; We have to require this here to make sure that the following
  9001. ;; dynamic binding isn't shadowed by autoloading.
  9002. (require 'gnus-async)
  9003. (require 'gnus-art)
  9004. ;; Bind the article treatment functions to nil.
  9005. (let ((gnus-have-all-headers t)
  9006. gnus-article-prepare-hook
  9007. gnus-article-decode-hook
  9008. gnus-display-mime-function
  9009. gnus-break-pages)
  9010. ;; Destroy any MIME parts.
  9011. (when (gnus-buffer-live-p gnus-article-buffer)
  9012. (with-current-buffer gnus-article-buffer
  9013. (gnus-article-stop-animations)
  9014. (gnus-stop-downloads)
  9015. (mm-destroy-parts gnus-article-mime-handles)
  9016. ;; Set it to nil for safety reason.
  9017. (setq gnus-article-mime-handle-alist nil)
  9018. (setq gnus-article-mime-handles nil)))
  9019. (gnus-summary-select-article nil 'force))))
  9020. (gnus-summary-goto-subject gnus-current-article)
  9021. (gnus-summary-position-point))
  9022. (defun gnus-summary-show-raw-article ()
  9023. "Show the raw article without any article massaging functions being run."
  9024. (interactive)
  9025. (gnus-summary-show-article t))
  9026. (defun gnus-summary-verbose-headers (&optional arg)
  9027. "Toggle permanent full header display.
  9028. If ARG is a positive number, turn header display on.
  9029. If ARG is a negative number, turn header display off."
  9030. (interactive "P")
  9031. (setq gnus-show-all-headers
  9032. (cond ((or (not (numberp arg))
  9033. (zerop arg))
  9034. (not gnus-show-all-headers))
  9035. ((natnump arg)
  9036. t)))
  9037. (gnus-summary-show-article))
  9038. (declare-function article-narrow-to-head "gnus-art" ())
  9039. (declare-function gnus-article-hidden-text-p "gnus-art" (type))
  9040. (declare-function gnus-delete-wash-type "gnus-art" (type))
  9041. (declare-function gnus-mime-buttonize-attachments-in-header
  9042. "gnus-art" (&optional interactive))
  9043. (defun gnus-summary-toggle-header (&optional arg)
  9044. "Show the headers if they are hidden, or hide them if they are shown.
  9045. If ARG is a positive number, show the entire header.
  9046. If ARG is a negative number, hide the unwanted header lines."
  9047. (interactive "P")
  9048. (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
  9049. (get-buffer-window gnus-article-buffer t))))
  9050. (with-current-buffer gnus-article-buffer
  9051. (widen)
  9052. (article-narrow-to-head)
  9053. (let* ((inhibit-read-only t)
  9054. (inhibit-point-motion-hooks t)
  9055. (hidden (if (numberp arg)
  9056. (>= arg 0)
  9057. (or (not (looking-at "[^ \t\n]+:"))
  9058. (gnus-article-hidden-text-p 'headers))))
  9059. s e)
  9060. (delete-region (point-min) (point-max))
  9061. (with-current-buffer gnus-original-article-buffer
  9062. (goto-char (setq s (point-min)))
  9063. (setq e (if (search-forward "\n\n" nil t)
  9064. (1- (point))
  9065. (point-max))))
  9066. (insert-buffer-substring gnus-original-article-buffer s e)
  9067. (run-hooks 'gnus-article-decode-hook)
  9068. (if hidden
  9069. (let ((gnus-treat-hide-headers nil)
  9070. (gnus-treat-hide-boring-headers nil))
  9071. (gnus-delete-wash-type 'headers)
  9072. (gnus-treat-article 'head))
  9073. (gnus-treat-article 'head)
  9074. ;; Add attachment buttons to the header.
  9075. (when gnus-mime-display-attachment-buttons-in-header
  9076. (gnus-mime-buttonize-attachments-in-header)))
  9077. (widen)
  9078. (if window
  9079. (set-window-start window (goto-char (point-min))))
  9080. (if gnus-break-pages
  9081. (gnus-narrow-to-page)
  9082. (when (gnus-visual-p 'page-marker)
  9083. (let ((inhibit-read-only t))
  9084. (gnus-remove-text-with-property 'gnus-prev)
  9085. (gnus-remove-text-with-property 'gnus-next))))
  9086. (gnus-set-mode-line 'article)))))
  9087. (defun gnus-summary-show-all-headers ()
  9088. "Make all header lines visible."
  9089. (interactive)
  9090. (gnus-summary-toggle-header 1))
  9091. (defun gnus-summary-caesar-message (&optional arg)
  9092. "Caesar rotate the current article by 13.
  9093. With a non-numerical prefix, also rotate headers. A numerical
  9094. prefix specifies how many places to rotate each letter forward."
  9095. (interactive "P")
  9096. (gnus-summary-select-article)
  9097. (let ((mail-header-separator ""))
  9098. (gnus-eval-in-buffer-window gnus-article-buffer
  9099. (save-restriction
  9100. (widen)
  9101. (let ((start (window-start))
  9102. (inhibit-read-only t))
  9103. (if (equal arg '(4))
  9104. (message-caesar-buffer-body nil t)
  9105. (message-caesar-buffer-body arg))
  9106. (set-window-start (get-buffer-window (current-buffer)) start)))))
  9107. ;; Create buttons and stuff...
  9108. (gnus-treat-article nil))
  9109. (declare-function idna-to-unicode "ext:idna" (str))
  9110. (defun gnus-summary-idna-message (&optional arg)
  9111. "Decode IDNA encoded domain names in the current articles.
  9112. IDNA encoded domain names looks like `xn--bar'. If a string
  9113. remain unencoded after running this function, it is likely an
  9114. invalid IDNA string (`xn--bar' is invalid).
  9115. You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
  9116. installed for this command to work."
  9117. (interactive "P")
  9118. (if (not (and (mm-coding-system-p 'utf-8)
  9119. (condition-case nil
  9120. (require 'idna)
  9121. (file-error)
  9122. (invalid-operation))
  9123. (symbol-value 'idna-program)
  9124. (executable-find (symbol-value 'idna-program))))
  9125. (gnus-message
  9126. 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
  9127. (gnus-summary-select-article)
  9128. (let ((mail-header-separator ""))
  9129. (gnus-eval-in-buffer-window gnus-article-buffer
  9130. (save-restriction
  9131. (widen)
  9132. (let ((start (window-start))
  9133. buffer-read-only)
  9134. (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
  9135. (replace-match (idna-to-unicode (match-string 1))))
  9136. (set-window-start (get-buffer-window (current-buffer)) start)))))))
  9137. (defun gnus-summary-morse-message (&optional arg)
  9138. "Morse decode the current article."
  9139. (interactive "P")
  9140. (gnus-summary-select-article)
  9141. (let ((mail-header-separator ""))
  9142. (gnus-eval-in-buffer-window gnus-article-buffer
  9143. (save-excursion
  9144. (save-restriction
  9145. (widen)
  9146. (let ((pos (window-start))
  9147. (inhibit-read-only t))
  9148. (goto-char (point-min))
  9149. (when (message-goto-body)
  9150. (gnus-narrow-to-body))
  9151. (goto-char (point-min))
  9152. (while (search-forward "·" (point-max) t)
  9153. (replace-match "."))
  9154. (unmorse-region (point-min) (point-max))
  9155. (widen)
  9156. (set-window-start (get-buffer-window (current-buffer)) pos)))))))
  9157. (defun gnus-summary-stop-page-breaking ()
  9158. "Stop page breaking in the current article."
  9159. (interactive)
  9160. (gnus-summary-select-article)
  9161. (gnus-eval-in-buffer-window gnus-article-buffer
  9162. (widen)
  9163. (when (gnus-visual-p 'page-marker)
  9164. (let ((inhibit-read-only t))
  9165. (gnus-remove-text-with-property 'gnus-prev)
  9166. (gnus-remove-text-with-property 'gnus-next))
  9167. (setq gnus-page-broken nil))))
  9168. (defun gnus-summary-move-article (&optional n to-newsgroup
  9169. select-method action)
  9170. "Move the current article to a different newsgroup.
  9171. If N is a positive number, move the N next articles.
  9172. If N is a negative number, move the N previous articles.
  9173. If N is nil and any articles have been marked with the process mark,
  9174. move those articles instead.
  9175. If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
  9176. If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
  9177. re-spool using this method.
  9178. When called interactively with TO-NEWSGROUP being nil, the value of
  9179. the variable `gnus-move-split-methods' is used for finding a default
  9180. for the target newsgroup.
  9181. For this function to work, both the current newsgroup and the
  9182. newsgroup that you want to move to have to support the `request-move'
  9183. and `request-accept' functions.
  9184. ACTION can be either `move' (the default), `crosspost' or `copy'."
  9185. (interactive "P")
  9186. (unless action
  9187. (setq action 'move))
  9188. ;; Check whether the source group supports the required functions.
  9189. (cond ((and (eq action 'move)
  9190. (not (gnus-check-backend-function
  9191. 'request-move-article gnus-newsgroup-name)))
  9192. (error "The current group does not support article moving"))
  9193. ((and (eq action 'crosspost)
  9194. (not (gnus-check-backend-function
  9195. 'request-replace-article gnus-newsgroup-name)))
  9196. (error "The current group does not support article editing")))
  9197. (let ((articles (gnus-summary-work-articles n))
  9198. (prefix (if (gnus-check-backend-function
  9199. 'request-move-article gnus-newsgroup-name)
  9200. (funcall gnus-move-group-prefix-function
  9201. gnus-newsgroup-name)
  9202. ""))
  9203. (names '((move "Move" "Moving")
  9204. (copy "Copy" "Copying")
  9205. (crosspost "Crosspost" "Crossposting")))
  9206. (copy-buf (save-excursion
  9207. (nnheader-set-temp-buffer " *copy article*")))
  9208. art-group to-method new-xref article to-groups
  9209. articles-to-update-marks encoded)
  9210. (unless (assq action names)
  9211. (error "Unknown action %s" action))
  9212. ;; Read the newsgroup name.
  9213. (when (and (not to-newsgroup)
  9214. (not select-method))
  9215. (if (and gnus-move-split-methods
  9216. (not
  9217. (and (memq gnus-current-article articles)
  9218. (gnus-buffer-live-p gnus-original-article-buffer))))
  9219. ;; When `gnus-move-split-methods' is non-nil, we have to
  9220. ;; select an article to give `gnus-read-move-group-name' an
  9221. ;; opportunity to suggest an appropriate default. However,
  9222. ;; we needn't render or mark the article.
  9223. (let ((gnus-display-mime-function nil)
  9224. (gnus-article-prepare-hook nil)
  9225. (gnus-mark-article-hook nil))
  9226. (gnus-summary-select-article nil nil nil (car articles))))
  9227. (setq to-newsgroup (gnus-read-move-group-name
  9228. (cadr (assq action names))
  9229. (symbol-value
  9230. (intern (format "gnus-current-%s-group" action)))
  9231. articles prefix)
  9232. encoded to-newsgroup
  9233. to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
  9234. (set (intern (format "gnus-current-%s-group" action))
  9235. (mm-decode-coding-string
  9236. to-newsgroup
  9237. (gnus-group-name-charset to-method to-newsgroup))))
  9238. (unless to-method
  9239. (setq to-method (or select-method
  9240. (gnus-server-to-method
  9241. (gnus-group-method to-newsgroup)))))
  9242. (setq to-newsgroup
  9243. (or encoded
  9244. (and to-newsgroup
  9245. (mm-encode-coding-string
  9246. to-newsgroup
  9247. (gnus-group-name-charset to-method to-newsgroup)))))
  9248. ;; Check the method we are to move this article to...
  9249. (unless (gnus-check-backend-function
  9250. 'request-accept-article (car to-method))
  9251. (error "%s does not support article copying" (car to-method)))
  9252. (unless (gnus-check-server to-method)
  9253. (error "Can't open server %s" (car to-method)))
  9254. (gnus-message 6 "%s to %s: %s..."
  9255. (caddr (assq action names))
  9256. (or (car select-method)
  9257. (gnus-group-decoded-name to-newsgroup))
  9258. articles)
  9259. (while articles
  9260. (setq article (pop articles))
  9261. ;; Set any marks that may have changed in the summary buffer.
  9262. (when gnus-preserve-marks
  9263. (gnus-summary-push-marks-to-backend article))
  9264. (setq
  9265. art-group
  9266. (cond
  9267. ;; Move the article.
  9268. ((eq action 'move)
  9269. ;; Remove this article from future suppression.
  9270. (gnus-dup-unsuppress-article article)
  9271. (let* ((from-method (gnus-find-method-for-group
  9272. gnus-newsgroup-name))
  9273. (to-method (or select-method
  9274. (gnus-find-method-for-group to-newsgroup)))
  9275. (move-is-internal (gnus-server-equal from-method to-method)))
  9276. (gnus-request-move-article
  9277. article ; Article to move
  9278. gnus-newsgroup-name ; From newsgroup
  9279. (nth 1 (gnus-find-method-for-group
  9280. gnus-newsgroup-name)) ; Server
  9281. (list 'gnus-request-accept-article
  9282. to-newsgroup (list 'quote select-method)
  9283. (not articles) t) ; Accept form
  9284. (not articles) ; Only save nov last time
  9285. (and move-is-internal
  9286. to-newsgroup ; Not respooling
  9287. ; Is this move internal?
  9288. (gnus-group-real-name to-newsgroup)))))
  9289. ;; Copy the article.
  9290. ((eq action 'copy)
  9291. (with-current-buffer copy-buf
  9292. (when (gnus-request-article-this-buffer article
  9293. gnus-newsgroup-name)
  9294. (save-restriction
  9295. (nnheader-narrow-to-headers)
  9296. (dolist (hdr gnus-copy-article-ignored-headers)
  9297. (message-remove-header hdr t)))
  9298. (gnus-request-accept-article
  9299. to-newsgroup select-method (not articles) t))))
  9300. ;; Crosspost the article.
  9301. ((eq action 'crosspost)
  9302. (let ((xref (message-tokenize-header
  9303. (mail-header-xref (gnus-summary-article-header
  9304. article))
  9305. " ")))
  9306. (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
  9307. ":" (number-to-string article)))
  9308. (unless xref
  9309. (setq xref (list (system-name))))
  9310. (setq new-xref
  9311. (concat
  9312. (mapconcat 'identity
  9313. (delete "Xref:" (delete new-xref xref))
  9314. " ")
  9315. " " new-xref))
  9316. (with-current-buffer copy-buf
  9317. ;; First put the article in the destination group.
  9318. (gnus-request-article-this-buffer article gnus-newsgroup-name)
  9319. (when (consp (setq art-group
  9320. (gnus-request-accept-article
  9321. to-newsgroup select-method (not articles)
  9322. t)))
  9323. (setq new-xref (concat new-xref " " (car art-group)
  9324. ":"
  9325. (number-to-string (cdr art-group))))
  9326. ;; Now we have the new Xrefs header, so we insert
  9327. ;; it and replace the new article.
  9328. (nnheader-replace-header "Xref" new-xref)
  9329. (gnus-request-replace-article
  9330. (cdr art-group) to-newsgroup (current-buffer) t)
  9331. art-group))))))
  9332. (cond
  9333. ((not art-group)
  9334. (gnus-message 1 "Couldn't %s article %s: %s"
  9335. (cadr (assq action names)) article
  9336. (nnheader-get-report (car to-method))))
  9337. ((eq art-group 'junk)
  9338. (when (eq action 'move)
  9339. (gnus-summary-mark-article article gnus-canceled-mark)
  9340. (gnus-message 4 "Deleted article %s" article)
  9341. ;; run the delete hook
  9342. (run-hook-with-args 'gnus-summary-article-delete-hook
  9343. action
  9344. (gnus-data-header
  9345. (assoc article (gnus-data-list nil)))
  9346. gnus-newsgroup-name nil
  9347. select-method)))
  9348. (t
  9349. (let* ((pto-group (gnus-group-prefixed-name
  9350. (car art-group) to-method))
  9351. (info (gnus-get-info pto-group))
  9352. (to-group (gnus-info-group info))
  9353. to-marks)
  9354. ;; Update the group that has been moved to.
  9355. (when (and info
  9356. (memq action '(move copy)))
  9357. (unless (member to-group to-groups)
  9358. (push to-group to-groups))
  9359. (when (and (not (memq article gnus-newsgroup-unreads))
  9360. (cdr art-group))
  9361. (push 'read to-marks)
  9362. (gnus-info-set-read
  9363. info (gnus-add-to-range (gnus-info-read info)
  9364. (list (cdr art-group)))))
  9365. ;; See whether the article is to be put in the cache.
  9366. (let* ((expirable (gnus-group-auto-expirable-p to-group))
  9367. (marks (if expirable
  9368. gnus-article-mark-lists
  9369. (delete '(expirable . expire)
  9370. (copy-sequence
  9371. gnus-article-mark-lists))))
  9372. (to-article (cdr art-group)))
  9373. ;; Enter the article into the cache in the new group,
  9374. ;; if that is required.
  9375. (when (and to-article
  9376. gnus-use-cache)
  9377. (gnus-cache-possibly-enter-article
  9378. to-group to-article
  9379. (memq article gnus-newsgroup-marked)
  9380. (memq article gnus-newsgroup-dormant)
  9381. (memq article gnus-newsgroup-unreads)))
  9382. (when (and gnus-preserve-marks
  9383. to-article)
  9384. ;; Copy any marks over to the new group.
  9385. (when (and (equal to-group gnus-newsgroup-name)
  9386. (not (memq article gnus-newsgroup-unreads)))
  9387. ;; Mark this article as read in this group.
  9388. (push (cons to-article gnus-read-mark)
  9389. gnus-newsgroup-reads)
  9390. ;; Increase the active status of this group.
  9391. (setcdr (gnus-active to-group) to-article)
  9392. (setcdr gnus-newsgroup-active to-article))
  9393. (while marks
  9394. (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
  9395. (when (memq article (symbol-value
  9396. (intern (format "gnus-newsgroup-%s"
  9397. (caar marks)))))
  9398. (push (cdar marks) to-marks)
  9399. ;; If the other group is the same as this group,
  9400. ;; then we have to add the mark to the list.
  9401. (when (equal to-group gnus-newsgroup-name)
  9402. (set (intern (format "gnus-newsgroup-%s"
  9403. (caar marks)))
  9404. (cons to-article
  9405. (symbol-value
  9406. (intern (format "gnus-newsgroup-%s"
  9407. (caar marks)))))))
  9408. ;; Copy the marks to other group.
  9409. (gnus-add-marked-articles
  9410. to-group (cdar marks) (list to-article) info)))
  9411. (setq marks (cdr marks)))
  9412. (when (and expirable
  9413. gnus-mark-copied-or-moved-articles-as-expirable
  9414. (not (memq 'expire to-marks)))
  9415. ;; Mark this article as expirable.
  9416. (push 'expire to-marks)
  9417. (when (equal to-group gnus-newsgroup-name)
  9418. (push to-article gnus-newsgroup-expirable))
  9419. ;; Copy the expirable mark to other group.
  9420. (gnus-add-marked-articles
  9421. to-group 'expire (list to-article) info))
  9422. (when (and to-marks
  9423. (gnus-method-option-p
  9424. (gnus-find-method-for-group to-group)
  9425. 'server-marks))
  9426. (gnus-request-set-mark
  9427. to-group (list (list (list to-article) 'add to-marks)))))
  9428. (gnus-dribble-enter
  9429. (concat "(gnus-group-set-info '"
  9430. (gnus-prin1-to-string (gnus-get-info to-group))
  9431. ")")
  9432. (concat "^(gnus-group-set-info '(\""
  9433. (regexp-quote to-group) "\""))))
  9434. ;; Update the Xref header in this article to point to
  9435. ;; the new crossposted article we have just created.
  9436. (when (eq action 'crosspost)
  9437. (with-current-buffer copy-buf
  9438. (gnus-request-article-this-buffer article gnus-newsgroup-name)
  9439. (nnheader-replace-header "Xref" new-xref)
  9440. (gnus-request-replace-article
  9441. article gnus-newsgroup-name (current-buffer) t)))
  9442. ;; run the move/copy/crosspost/respool hook
  9443. (run-hook-with-args 'gnus-summary-article-move-hook
  9444. action
  9445. (gnus-data-header
  9446. (assoc article (gnus-data-list nil)))
  9447. gnus-newsgroup-name
  9448. to-newsgroup
  9449. select-method))
  9450. ;;;!!!Why is this necessary?
  9451. (set-buffer gnus-summary-buffer)
  9452. (when (eq action 'move)
  9453. (save-excursion
  9454. (gnus-summary-goto-subject article)
  9455. (gnus-summary-mark-article article gnus-canceled-mark)))))
  9456. (push article articles-to-update-marks))
  9457. (save-excursion
  9458. (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
  9459. ;; Re-activate all groups that have been moved to.
  9460. (with-current-buffer gnus-group-buffer
  9461. (let ((gnus-group-marked to-groups))
  9462. (gnus-group-get-new-news-this-group nil t)))
  9463. (gnus-kill-buffer copy-buf)
  9464. (gnus-summary-position-point)
  9465. (gnus-set-mode-line 'summary)))
  9466. (defun gnus-summary-push-marks-to-backend (article)
  9467. (let ((set nil)
  9468. (del nil)
  9469. (marks gnus-article-mark-lists))
  9470. (unless (memq article gnus-newsgroup-unreads)
  9471. (push 'read set))
  9472. (while marks
  9473. (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
  9474. (memq article (symbol-value
  9475. (intern (format "gnus-newsgroup-%s"
  9476. (caar marks))))))
  9477. (push (cdar marks) set)
  9478. (push (cdar marks) del))
  9479. (pop marks))
  9480. (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
  9481. ((,article) del ,del)))))
  9482. (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
  9483. "Copy the current article to some other group.
  9484. If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
  9485. When called interactively, if TO-NEWSGROUP is nil, use the value of
  9486. the variable `gnus-move-split-methods' for finding a default target
  9487. newsgroup.
  9488. If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
  9489. re-spool using this method."
  9490. (interactive "P")
  9491. (gnus-summary-move-article n to-newsgroup select-method 'copy))
  9492. (defun gnus-summary-crosspost-article (&optional n)
  9493. "Crosspost the current article to some other group."
  9494. (interactive "P")
  9495. (gnus-summary-move-article n nil nil 'crosspost))
  9496. (defcustom gnus-summary-respool-default-method nil
  9497. "Default method type for respooling an article.
  9498. If nil, use to the current newsgroup method."
  9499. :type 'symbol
  9500. :group 'gnus-summary-mail)
  9501. (defun gnus-summary-respool-article (&optional n method)
  9502. "Respool the current article.
  9503. The article will be squeezed through the mail spooling process again,
  9504. which means that it will be put in some mail newsgroup or other
  9505. depending on `nnmail-split-methods'.
  9506. If N is a positive number, respool the N next articles.
  9507. If N is a negative number, respool the N previous articles.
  9508. If N is nil and any articles have been marked with the process mark,
  9509. respool those articles instead.
  9510. Respooling can be done both from mail groups and \"real\" newsgroups.
  9511. In the former case, the articles in question will be moved from the
  9512. current group into whatever groups they are destined to. In the
  9513. latter case, they will be copied into the relevant groups."
  9514. (interactive
  9515. (list current-prefix-arg
  9516. (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
  9517. (methname
  9518. (symbol-name (or gnus-summary-respool-default-method
  9519. (car (gnus-find-method-for-group
  9520. gnus-newsgroup-name)))))
  9521. (method
  9522. (gnus-completing-read
  9523. "Backend to use when respooling"
  9524. methods t nil 'gnus-mail-method-history methname))
  9525. ms)
  9526. (cond
  9527. ((zerop (length (setq ms (gnus-servers-using-backend
  9528. (intern method)))))
  9529. (list (intern method) ""))
  9530. ((= 1 (length ms))
  9531. (car ms))
  9532. (t
  9533. (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
  9534. (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
  9535. ms-alist))))))))
  9536. (unless method
  9537. (error "No method given for respooling"))
  9538. (if (assoc (symbol-name
  9539. (car (gnus-find-method-for-group gnus-newsgroup-name)))
  9540. (gnus-methods-using 'respool))
  9541. (gnus-summary-move-article n nil method)
  9542. (gnus-summary-copy-article n nil method)))
  9543. (defun gnus-summary-import-article (file &optional edit)
  9544. "Import an arbitrary file into a mail newsgroup."
  9545. (interactive "fImport file: \nP")
  9546. (let ((group gnus-newsgroup-name)
  9547. (now (current-time))
  9548. atts lines group-art)
  9549. (unless (gnus-check-backend-function 'request-accept-article group)
  9550. (error "%s does not support article importing" group))
  9551. (or (file-readable-p file)
  9552. (not (file-regular-p file))
  9553. (error "Can't read %s" file))
  9554. (with-current-buffer (gnus-get-buffer-create " *import file*")
  9555. (erase-buffer)
  9556. (nnheader-insert-file-contents file)
  9557. (goto-char (point-min))
  9558. (if (nnheader-article-p)
  9559. (save-restriction
  9560. (goto-char (point-min))
  9561. (search-forward "\n\n" nil t)
  9562. (narrow-to-region (point-min) (1- (point)))
  9563. (goto-char (point-min))
  9564. (unless (re-search-forward "^date:" nil t)
  9565. (goto-char (point-max))
  9566. (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
  9567. ;; This doesn't look like an article, so we fudge some headers.
  9568. (setq atts (file-attributes file)
  9569. lines (count-lines (point-min) (point-max)))
  9570. (insert "From: " (read-string "From: ") "\n"
  9571. "Subject: " (read-string "Subject: ") "\n"
  9572. "Date: " (message-make-date (nth 5 atts)) "\n"
  9573. "Message-ID: " (message-make-message-id) "\n"
  9574. "Lines: " (int-to-string lines) "\n"
  9575. "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
  9576. (setq group-art (gnus-request-accept-article group nil t))
  9577. (kill-buffer (current-buffer)))
  9578. (setq gnus-newsgroup-active (gnus-activate-group group))
  9579. (forward-line 1)
  9580. (gnus-summary-goto-article (cdr group-art) nil t)
  9581. (when edit
  9582. (gnus-summary-edit-article))))
  9583. (defun gnus-summary-create-article ()
  9584. "Create an article in a mail newsgroup."
  9585. (interactive)
  9586. (let ((group gnus-newsgroup-name)
  9587. (now (current-time))
  9588. group-art)
  9589. (unless (gnus-check-backend-function 'request-accept-article group)
  9590. (error "%s does not support article importing" group))
  9591. (with-current-buffer (gnus-get-buffer-create " *import file*")
  9592. (erase-buffer)
  9593. (goto-char (point-min))
  9594. ;; This doesn't look like an article, so we fudge some headers.
  9595. (insert "From: " (read-string "From: ") "\n"
  9596. "Subject: " (read-string "Subject: ") "\n"
  9597. "Date: " (message-make-date now) "\n"
  9598. "Message-ID: " (message-make-message-id) "\n")
  9599. (setq group-art (gnus-request-accept-article group nil t))
  9600. (kill-buffer (current-buffer)))
  9601. (setq gnus-newsgroup-active (gnus-activate-group group))
  9602. (forward-line 1)
  9603. (gnus-summary-goto-article (cdr group-art) nil t)
  9604. (gnus-summary-edit-article)))
  9605. (defun gnus-summary-article-posted-p ()
  9606. "Say whether the current (mail) article is available from news as well.
  9607. This will be the case if the article has both been mailed and posted."
  9608. (interactive)
  9609. (let ((id (mail-header-references (gnus-summary-article-header)))
  9610. (gnus-override-method (car (gnus-refer-article-methods))))
  9611. (if (gnus-request-head id "")
  9612. (gnus-message 2 "The current message was found on %s"
  9613. gnus-override-method)
  9614. (gnus-message 2 "The current message couldn't be found on %s"
  9615. gnus-override-method)
  9616. nil)))
  9617. (defun gnus-summary-expire-articles (&optional now)
  9618. "Expire all articles that are marked as expirable in the current group."
  9619. (interactive)
  9620. (when (and (not gnus-group-is-exiting-without-update-p)
  9621. (gnus-check-backend-function
  9622. 'request-expire-articles gnus-newsgroup-name))
  9623. ;; This backend supports expiry.
  9624. (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
  9625. (expirable
  9626. (gnus-list-range-difference
  9627. (if total
  9628. (progn
  9629. ;; We need to update the info for
  9630. ;; this group for `gnus-list-of-read-articles'
  9631. ;; to give us the right answer.
  9632. (gnus-run-hooks 'gnus-exit-group-hook)
  9633. (gnus-summary-update-info)
  9634. (gnus-list-of-read-articles gnus-newsgroup-name))
  9635. (setq gnus-newsgroup-expirable
  9636. (sort gnus-newsgroup-expirable '<)))
  9637. gnus-newsgroup-unexist))
  9638. (expiry-wait (if now 'immediate
  9639. (gnus-group-find-parameter
  9640. gnus-newsgroup-name 'expiry-wait)))
  9641. (nnmail-expiry-target
  9642. (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
  9643. nnmail-expiry-target))
  9644. es)
  9645. (when expirable
  9646. ;; There are expirable articles in this group, so we run them
  9647. ;; through the expiry process.
  9648. (gnus-message 6 "Expiring articles...")
  9649. (when (gnus-check-group gnus-newsgroup-name)
  9650. ;; The list of articles that weren't expired is returned.
  9651. (save-excursion
  9652. (if expiry-wait
  9653. (let ((nnmail-expiry-wait-function nil)
  9654. (nnmail-expiry-wait expiry-wait))
  9655. (setq es (gnus-request-expire-articles
  9656. expirable gnus-newsgroup-name)))
  9657. (setq es (gnus-request-expire-articles
  9658. expirable gnus-newsgroup-name)))
  9659. (unless total
  9660. (setq gnus-newsgroup-expirable es))
  9661. ;; We go through the old list of expirable, and mark all
  9662. ;; really expired articles as nonexistent.
  9663. (unless (eq es expirable) ;If nothing was expired, we don't mark.
  9664. (let ((gnus-use-cache nil))
  9665. (dolist (article expirable)
  9666. (when (and (not (memq article es))
  9667. (gnus-data-find article))
  9668. (gnus-summary-mark-article article gnus-canceled-mark)
  9669. (run-hook-with-args
  9670. 'gnus-summary-article-expire-hook
  9671. 'delete
  9672. (gnus-data-header (assoc article (gnus-data-list nil)))
  9673. gnus-newsgroup-name
  9674. (cond
  9675. ((stringp nnmail-expiry-target) nnmail-expiry-target)
  9676. ((eq nnmail-expiry-target 'delete) nil)
  9677. (t
  9678. (let ((rescall (funcall nnmail-expiry-target
  9679. gnus-newsgroup-name)))
  9680. (if (stringp rescall) rescall nil))))
  9681. nil)))))))
  9682. (gnus-message 6 "Expiring articles...done")))))
  9683. (defun gnus-summary-expire-articles-now ()
  9684. "Expunge all expirable articles in the current group.
  9685. This means that *all* articles that are marked as expirable will be
  9686. deleted forever, right now."
  9687. (interactive)
  9688. (or gnus-expert-user
  9689. (gnus-yes-or-no-p
  9690. "Are you really, really sure you want to delete all expirable messages? ")
  9691. (error "Phew!"))
  9692. (gnus-summary-expire-articles t))
  9693. ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
  9694. (defun gnus-summary-delete-article (&optional n)
  9695. "Delete the N next (mail) articles.
  9696. This command actually deletes articles. This is not a marking
  9697. command. The article will disappear forever from your life, never to
  9698. return.
  9699. If N is negative, delete backwards.
  9700. If N is nil and articles have been marked with the process mark,
  9701. delete these instead.
  9702. If `gnus-novice-user' is non-nil you will be asked for
  9703. confirmation before the articles are deleted."
  9704. (interactive "P")
  9705. (unless (gnus-check-backend-function 'request-expire-articles
  9706. gnus-newsgroup-name)
  9707. (error "The current newsgroup does not support article deletion"))
  9708. (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
  9709. (error "Couldn't open server"))
  9710. ;; Compute the list of articles to delete.
  9711. (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
  9712. (nnmail-expiry-target 'delete)
  9713. not-deleted)
  9714. (if (and gnus-novice-user
  9715. (not (gnus-yes-or-no-p
  9716. (format "Do you really want to delete %s forever? "
  9717. (if (> (length articles) 1)
  9718. (format "these %s articles" (length articles))
  9719. "this article")))))
  9720. ()
  9721. ;; Delete the articles.
  9722. (setq not-deleted (gnus-request-expire-articles
  9723. articles gnus-newsgroup-name 'force))
  9724. (save-excursion
  9725. (while articles
  9726. (gnus-summary-remove-process-mark (car articles))
  9727. ;; The backend might not have been able to delete the article
  9728. ;; after all.
  9729. (unless (memq (car articles) not-deleted)
  9730. (gnus-summary-mark-article (car articles) gnus-canceled-mark)
  9731. (let* ((article (car articles))
  9732. (ghead (gnus-data-header
  9733. (assoc article (gnus-data-list nil)))))
  9734. (run-hook-with-args 'gnus-summary-article-delete-hook
  9735. 'delete ghead gnus-newsgroup-name nil
  9736. nil)))
  9737. (setq articles (cdr articles))))
  9738. (when not-deleted
  9739. (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
  9740. (gnus-summary-position-point)
  9741. (gnus-set-mode-line 'summary)
  9742. not-deleted))
  9743. (defun gnus-summary-edit-article (&optional arg)
  9744. "Edit the current article.
  9745. This will have permanent effect only in mail groups.
  9746. If ARG is nil, edit the decoded articles.
  9747. If ARG is 1, edit the raw articles.
  9748. If ARG is 2, edit the raw articles even in read-only groups.
  9749. If ARG is 3, edit the articles with the current handles.
  9750. Otherwise, allow editing of articles even in read-only
  9751. groups."
  9752. (interactive "P")
  9753. (let (force raw current-handles)
  9754. (cond
  9755. ((null arg))
  9756. ((eq arg 1)
  9757. (setq raw t))
  9758. ((eq arg 2)
  9759. (setq raw t
  9760. force t))
  9761. ((eq arg 3)
  9762. (setq current-handles
  9763. (and (gnus-buffer-live-p gnus-article-buffer)
  9764. (with-current-buffer gnus-article-buffer
  9765. (prog1
  9766. gnus-article-mime-handles
  9767. (setq gnus-article-mime-handles nil))))))
  9768. (t
  9769. (setq force t)))
  9770. (when (and raw (not force)
  9771. (member gnus-newsgroup-name '("nndraft:delayed"
  9772. "nndraft:drafts"
  9773. "nndraft:queue")))
  9774. (error "Can't edit the raw article in group %s"
  9775. gnus-newsgroup-name))
  9776. (with-current-buffer gnus-summary-buffer
  9777. (let ((mail-parse-charset gnus-newsgroup-charset)
  9778. (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
  9779. (gnus-set-global-variables)
  9780. (when (and (not force)
  9781. (gnus-group-read-only-p))
  9782. (error "The current newsgroup does not support article editing"))
  9783. (gnus-summary-show-article t)
  9784. (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
  9785. (with-current-buffer gnus-article-buffer
  9786. (mm-enable-multibyte)))
  9787. (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
  9788. (setq raw t))
  9789. (gnus-article-edit-article
  9790. (if raw 'ignore
  9791. `(lambda ()
  9792. (let ((mbl mml-buffer-list))
  9793. (setq mml-buffer-list nil)
  9794. (let ((rfc2047-quote-decoded-words-containing-tspecials t))
  9795. (mime-to-mml ,'current-handles))
  9796. (let ((mbl1 mml-buffer-list))
  9797. (setq mml-buffer-list mbl)
  9798. (set (make-local-variable 'mml-buffer-list) mbl1))
  9799. (gnus-make-local-hook 'kill-buffer-hook)
  9800. (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
  9801. `(lambda (no-highlight)
  9802. (let ((mail-parse-charset ',gnus-newsgroup-charset)
  9803. (message-options message-options)
  9804. (message-options-set-recipient)
  9805. (mail-parse-ignored-charsets
  9806. ',gnus-newsgroup-ignored-charsets)
  9807. (rfc2047-header-encoding-alist
  9808. ',(let ((charset (gnus-group-name-charset
  9809. (gnus-find-method-for-group
  9810. gnus-newsgroup-name)
  9811. gnus-newsgroup-name)))
  9812. (append (list (cons "Newsgroups" charset)
  9813. (cons "Followup-To" charset)
  9814. (cons "Xref" charset))
  9815. rfc2047-header-encoding-alist))))
  9816. ,(if (not raw) '(progn
  9817. (mml-to-mime)
  9818. (mml-destroy-buffers)
  9819. (remove-hook 'kill-buffer-hook
  9820. 'mml-destroy-buffers t)
  9821. (kill-local-variable 'mml-buffer-list)))
  9822. (gnus-summary-edit-article-done
  9823. ,(or (mail-header-references gnus-current-headers) "")
  9824. ,(gnus-group-read-only-p)
  9825. ,gnus-summary-buffer no-highlight))))))))
  9826. (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
  9827. (defun gnus-summary-edit-article-done (&optional references read-only buffer
  9828. no-highlight)
  9829. "Make edits to the current article permanent."
  9830. (interactive)
  9831. (save-excursion
  9832. ;; The buffer restriction contains the entire article if it exists.
  9833. (when (article-goto-body)
  9834. (let ((lines (count-lines (point) (point-max)))
  9835. (length (- (point-max) (point)))
  9836. (case-fold-search t)
  9837. (body (point-marker)))
  9838. (goto-char (point-min))
  9839. (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
  9840. (delete-region (match-beginning 1) (match-end 1))
  9841. (insert (number-to-string length)))
  9842. (goto-char (point-min))
  9843. (when (re-search-forward
  9844. "^x-content-length:[ \t]\\([0-9]+\\)" body t)
  9845. (delete-region (match-beginning 1) (match-end 1))
  9846. (insert (number-to-string length)))
  9847. (goto-char (point-min))
  9848. (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
  9849. (delete-region (match-beginning 1) (match-end 1))
  9850. (insert (number-to-string lines))))))
  9851. ;; Replace the article.
  9852. (let ((buf (current-buffer))
  9853. (article (cdr gnus-article-current))
  9854. replace-result)
  9855. (with-temp-buffer
  9856. (insert-buffer-substring buf)
  9857. (if (and (not read-only)
  9858. (not (setq replace-result
  9859. (gnus-request-replace-article
  9860. article (car gnus-article-current)
  9861. (current-buffer) t))))
  9862. (error "Couldn't replace article")
  9863. ;; If we got a number back, then that's the new article number
  9864. ;; for this article. Otherwise, the article number didn't change.
  9865. (when (numberp replace-result)
  9866. (with-current-buffer gnus-summary-buffer
  9867. (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
  9868. (gnus-summary-limit gnus-newsgroup-limit)
  9869. (setq article replace-result)
  9870. (gnus-summary-goto-subject article t)))
  9871. ;; Update the summary buffer.
  9872. (if (and references
  9873. (equal (message-tokenize-header references " ")
  9874. (message-tokenize-header
  9875. (or (message-fetch-field "references") "") " ")))
  9876. ;; We only have to update this line.
  9877. (save-excursion
  9878. (save-restriction
  9879. (message-narrow-to-head)
  9880. (let ((head (buffer-substring-no-properties
  9881. (point-min) (point-max)))
  9882. header)
  9883. (with-temp-buffer
  9884. (insert (format "211 %d Article retrieved.\n" article))
  9885. (insert head)
  9886. (insert ".\n")
  9887. (let ((nntp-server-buffer (current-buffer)))
  9888. (setq header (car (gnus-get-newsgroup-headers nil t))))
  9889. (with-current-buffer gnus-summary-buffer
  9890. (gnus-data-set-header (gnus-data-find article) header)
  9891. (gnus-summary-update-article-line article header)
  9892. (if (gnus-summary-goto-subject article nil t)
  9893. (gnus-summary-update-secondary-mark article)))))))
  9894. ;; Update threads.
  9895. (set-buffer (or buffer gnus-summary-buffer))
  9896. (gnus-summary-update-article article)
  9897. (if (gnus-summary-goto-subject article nil t)
  9898. (gnus-summary-update-secondary-mark article)))
  9899. ;; Prettify the article buffer again.
  9900. (unless no-highlight
  9901. (with-current-buffer gnus-article-buffer
  9902. ;;!!! Fix this -- article should be rehighlighted.
  9903. ;;(gnus-run-hooks 'gnus-article-display-hook)
  9904. (set-buffer gnus-original-article-buffer)
  9905. (gnus-request-article
  9906. article (car gnus-article-current) (current-buffer))))
  9907. ;; Prettify the summary buffer line.
  9908. (when (gnus-visual-p 'summary-highlight 'highlight)
  9909. (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
  9910. (defun gnus-summary-edit-wash (key)
  9911. "Perform editing command KEY in the article buffer."
  9912. (interactive
  9913. (list
  9914. (progn
  9915. (message "%s" (concat (this-command-keys) "- "))
  9916. (read-char))))
  9917. (message "")
  9918. (gnus-summary-edit-article)
  9919. (execute-kbd-macro (concat (this-command-keys) key))
  9920. (gnus-article-edit-done))
  9921. ;;; Respooling
  9922. (defvar nnimap-split-fancy)
  9923. (defvar nnimap-split-methods)
  9924. (defun gnus-summary-respool-query (&optional silent trace)
  9925. "Query where the respool algorithm would put this article."
  9926. (interactive)
  9927. (let (gnus-mark-article-hook)
  9928. (gnus-summary-select-article)
  9929. (with-current-buffer gnus-original-article-buffer
  9930. (let ((groups
  9931. (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
  9932. 'nnimap)
  9933. ;; nnimap has its own splitting variables.
  9934. (let ((nnmail-split-methods
  9935. (cond
  9936. ((eq nnimap-split-methods 'default)
  9937. nnmail-split-methods)
  9938. (nnimap-split-methods
  9939. nnimap-split-methods)
  9940. (nnimap-split-fancy
  9941. 'nnmail-split-fancy)))
  9942. (nnmail-split-fancy (or nnimap-split-fancy
  9943. nnmail-split-fancy)))
  9944. (nnmail-article-group 'identity trace))
  9945. (nnmail-article-group 'identity trace))))
  9946. (unless silent
  9947. (if groups
  9948. (message "This message would go to %s"
  9949. (mapconcat 'car groups ", "))
  9950. (message "This message would go to no groups"))
  9951. groups)))))
  9952. (defun gnus-summary-respool-trace ()
  9953. "Trace where the respool algorithm would put this article.
  9954. Display a buffer showing all fancy splitting patterns which matched."
  9955. (interactive)
  9956. (gnus-summary-respool-query nil t))
  9957. ;; Summary marking commands.
  9958. (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
  9959. "Mark articles which has the same subject as read, and then select the next.
  9960. If UNMARK is positive, remove any kind of mark.
  9961. If UNMARK is negative, tick articles."
  9962. (interactive "P")
  9963. (when unmark
  9964. (setq unmark (prefix-numeric-value unmark)))
  9965. (let ((count
  9966. (gnus-summary-mark-same-subject
  9967. (gnus-summary-article-subject) unmark)))
  9968. ;; Select next unread article. If auto-select-same mode, should
  9969. ;; select the first unread article.
  9970. (gnus-summary-next-article t (and gnus-auto-select-same
  9971. (gnus-summary-article-subject)))
  9972. (gnus-message 7 "%d article%s marked as %s"
  9973. count (if (= count 1) " is" "s are")
  9974. (if unmark "unread" "read"))))
  9975. (defun gnus-summary-kill-same-subject (&optional unmark)
  9976. "Mark articles which has the same subject as read.
  9977. If UNMARK is positive, remove any kind of mark.
  9978. If UNMARK is negative, tick articles."
  9979. (interactive "P")
  9980. (when unmark
  9981. (setq unmark (prefix-numeric-value unmark)))
  9982. (let ((count
  9983. (gnus-summary-mark-same-subject
  9984. (gnus-summary-article-subject) unmark)))
  9985. ;; If marked as read, go to next unread subject.
  9986. (when (null unmark)
  9987. ;; Go to next unread subject.
  9988. (gnus-summary-next-subject 1 t))
  9989. (gnus-message 7 "%d articles are marked as %s"
  9990. count (if unmark "unread" "read"))))
  9991. (defun gnus-summary-mark-same-subject (subject &optional unmark)
  9992. "Mark articles with same SUBJECT as read, and return marked number.
  9993. If optional argument UNMARK is positive, remove any kinds of marks.
  9994. If optional argument UNMARK is negative, mark articles as unread instead."
  9995. (let ((count 1))
  9996. (save-excursion
  9997. (cond
  9998. ((null unmark) ; Mark as read.
  9999. (while (and
  10000. (progn
  10001. (gnus-summary-mark-article-as-read gnus-killed-mark)
  10002. (gnus-summary-show-thread) t)
  10003. (gnus-summary-find-subject subject))
  10004. (setq count (1+ count))))
  10005. ((> unmark 0) ; Tick.
  10006. (while (and
  10007. (progn
  10008. (gnus-summary-mark-article-as-unread gnus-ticked-mark)
  10009. (gnus-summary-show-thread) t)
  10010. (gnus-summary-find-subject subject))
  10011. (setq count (1+ count))))
  10012. (t ; Mark as unread.
  10013. (while (and
  10014. (progn
  10015. (gnus-summary-mark-article-as-unread gnus-unread-mark)
  10016. (gnus-summary-show-thread) t)
  10017. (gnus-summary-find-subject subject))
  10018. (setq count (1+ count)))))
  10019. (gnus-set-mode-line 'summary)
  10020. ;; Return the number of marked articles.
  10021. count)))
  10022. (defun gnus-summary-mark-as-processable (n &optional unmark)
  10023. "Set the process mark on the next N articles.
  10024. If N is negative, mark backward instead. If UNMARK is non-nil, remove
  10025. the process mark instead. The difference between N and the actual
  10026. number of articles marked is returned."
  10027. (interactive "P")
  10028. (if (and (null n) (gnus-region-active-p))
  10029. (gnus-uu-mark-region (region-beginning) (region-end) unmark)
  10030. (setq n (prefix-numeric-value n))
  10031. (let ((backward (< n 0))
  10032. (n (abs n)))
  10033. (while (and
  10034. (> n 0)
  10035. (if unmark
  10036. (gnus-summary-remove-process-mark
  10037. (gnus-summary-article-number))
  10038. (gnus-summary-set-process-mark (gnus-summary-article-number)))
  10039. (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
  10040. (setq n (1- n)))
  10041. (when (/= 0 n)
  10042. (gnus-message 7 "No more articles"))
  10043. (gnus-summary-recenter)
  10044. (gnus-summary-position-point)
  10045. n)))
  10046. (defun gnus-summary-unmark-as-processable (n)
  10047. "Remove the process mark from the next N articles.
  10048. If N is negative, unmark backward instead. The difference between N and
  10049. the actual number of articles unmarked is returned."
  10050. (interactive "P")
  10051. (gnus-summary-mark-as-processable n t))
  10052. (defun gnus-summary-unmark-all-processable ()
  10053. "Remove the process mark from all articles."
  10054. (interactive)
  10055. (save-excursion
  10056. (while gnus-newsgroup-processable
  10057. (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
  10058. (gnus-summary-position-point))
  10059. (defun gnus-summary-add-mark (article type)
  10060. "Mark ARTICLE with a mark of TYPE."
  10061. (let ((vtype (car (assq type gnus-article-mark-lists)))
  10062. var)
  10063. (if (not vtype)
  10064. (error "No such mark type: %s" type)
  10065. (setq var (intern (format "gnus-newsgroup-%s" type)))
  10066. (set var (cons article (symbol-value var)))
  10067. (if (memq type '(processable cached replied forwarded recent saved))
  10068. (gnus-summary-update-secondary-mark article)
  10069. ;;; !!! This is bogus. We should find out what primary
  10070. ;;; !!! mark we want to set.
  10071. (gnus-summary-update-mark gnus-del-mark 'unread)))))
  10072. (defun gnus-summary-mark-as-expirable (n)
  10073. "Mark N articles forward as expirable.
  10074. If N is negative, mark backward instead. The difference between N and
  10075. the actual number of articles marked is returned."
  10076. (interactive "p")
  10077. (gnus-summary-mark-forward n gnus-expirable-mark))
  10078. (defun gnus-summary-mark-as-spam (n)
  10079. "Mark N articles forward as spam.
  10080. If N is negative, mark backward instead. The difference between N and
  10081. the actual number of articles marked is returned."
  10082. (interactive "p")
  10083. (gnus-summary-mark-forward n gnus-spam-mark))
  10084. (defun gnus-summary-mark-article-as-replied (article)
  10085. "Mark ARTICLE as replied to and update the summary line.
  10086. ARTICLE can also be a list of articles."
  10087. (interactive (list (gnus-summary-article-number)))
  10088. (let ((articles (if (listp article) article (list article))))
  10089. (dolist (article articles)
  10090. (unless (numberp article)
  10091. (error "%s is not a number" article))
  10092. (push article gnus-newsgroup-replied)
  10093. (let ((inhibit-read-only t))
  10094. (when (gnus-summary-goto-subject article nil t)
  10095. (gnus-summary-update-secondary-mark article))))))
  10096. (defun gnus-summary-mark-article-as-forwarded (article)
  10097. "Mark ARTICLE as forwarded and update the summary line.
  10098. ARTICLE can also be a list of articles."
  10099. (let ((articles (if (listp article) article (list article))))
  10100. (dolist (article articles)
  10101. (push article gnus-newsgroup-forwarded)
  10102. (let ((inhibit-read-only t))
  10103. (when (gnus-summary-goto-subject article nil t)
  10104. (gnus-summary-update-secondary-mark article))))))
  10105. (defun gnus-summary-set-bookmark (article)
  10106. "Set a bookmark in current article."
  10107. (interactive (list (gnus-summary-article-number)))
  10108. (when (or (not (get-buffer gnus-article-buffer))
  10109. (not gnus-current-article)
  10110. (not gnus-article-current)
  10111. (not (equal gnus-newsgroup-name (car gnus-article-current))))
  10112. (error "No current article selected"))
  10113. ;; Remove old bookmark, if one exists.
  10114. (gnus-alist-pull article gnus-newsgroup-bookmarks)
  10115. ;; Set the new bookmark, which is on the form
  10116. ;; (article-number . line-number-in-body).
  10117. (push
  10118. (cons article
  10119. (with-current-buffer gnus-article-buffer
  10120. (count-lines
  10121. (min (point)
  10122. (save-excursion
  10123. (article-goto-body)
  10124. (point)))
  10125. (point))))
  10126. gnus-newsgroup-bookmarks)
  10127. (gnus-message 6 "A bookmark has been added to the current article."))
  10128. (defun gnus-summary-remove-bookmark (article)
  10129. "Remove the bookmark from the current article."
  10130. (interactive (list (gnus-summary-article-number)))
  10131. ;; Remove old bookmark, if one exists.
  10132. (if (not (assq article gnus-newsgroup-bookmarks))
  10133. (gnus-message 6 "No bookmark in current article.")
  10134. (gnus-alist-pull article gnus-newsgroup-bookmarks)
  10135. (gnus-message 6 "Removed bookmark.")))
  10136. ;; Suggested by Daniel Quinlan <quinlan@best.com>.
  10137. (defun gnus-summary-mark-as-dormant (n)
  10138. "Mark N articles forward as dormant.
  10139. If N is negative, mark backward instead. The difference between N and
  10140. the actual number of articles marked is returned."
  10141. (interactive "p")
  10142. (gnus-summary-mark-forward n gnus-dormant-mark))
  10143. (defun gnus-summary-set-process-mark (article)
  10144. "Set the process mark on ARTICLE and update the summary line."
  10145. (setq gnus-newsgroup-processable
  10146. (cons article
  10147. (delq article gnus-newsgroup-processable)))
  10148. (when (gnus-summary-goto-subject article)
  10149. (gnus-summary-show-thread)
  10150. (gnus-summary-goto-subject article)
  10151. (gnus-summary-update-secondary-mark article)))
  10152. (defun gnus-summary-remove-process-mark (&rest articles)
  10153. "Remove the process mark from ARTICLES and update the summary line."
  10154. (dolist (article articles)
  10155. (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
  10156. (when (gnus-summary-goto-subject article)
  10157. (gnus-summary-show-thread)
  10158. (gnus-summary-goto-subject article)
  10159. (gnus-summary-update-secondary-mark article)))
  10160. t)
  10161. (defun gnus-summary-set-saved-mark (article)
  10162. "Set the process mark on ARTICLE and update the summary line."
  10163. (push article gnus-newsgroup-saved)
  10164. (when (gnus-summary-goto-subject article)
  10165. (gnus-summary-update-secondary-mark article)))
  10166. (defun gnus-summary-mark-forward (n &optional mark no-expire)
  10167. "Mark N articles as read forwards.
  10168. If N is negative, mark backwards instead. Mark with MARK, ?r by default.
  10169. The difference between N and the actual number of articles marked is
  10170. returned.
  10171. If NO-EXPIRE, auto-expiry will be inhibited."
  10172. (interactive "p")
  10173. (gnus-summary-show-thread)
  10174. (let ((backward (< n 0))
  10175. (gnus-summary-goto-unread
  10176. (and gnus-summary-goto-unread
  10177. (not (eq gnus-summary-goto-unread 'never))
  10178. (not (memq mark (list gnus-unread-mark gnus-spam-mark
  10179. gnus-ticked-mark gnus-dormant-mark)))))
  10180. (n (abs n))
  10181. (mark (or mark gnus-del-mark)))
  10182. (while (and (> n 0)
  10183. (gnus-summary-mark-article nil mark no-expire)
  10184. (zerop (gnus-summary-next-subject
  10185. (if backward -1 1)
  10186. (and gnus-summary-goto-unread
  10187. (not (eq gnus-summary-goto-unread 'never)))
  10188. t)))
  10189. (setq n (1- n)))
  10190. (when (/= 0 n)
  10191. (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
  10192. (gnus-summary-recenter)
  10193. (gnus-summary-position-point)
  10194. (gnus-set-mode-line 'summary)
  10195. n))
  10196. (defun gnus-summary-mark-article-as-read (mark)
  10197. "Mark the current article quickly as read with MARK."
  10198. (let ((article (gnus-summary-article-number)))
  10199. (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10200. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
  10201. (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
  10202. (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
  10203. (push (cons article mark) gnus-newsgroup-reads)
  10204. ;; Possibly remove from cache, if that is used.
  10205. (when gnus-use-cache
  10206. (gnus-cache-enter-remove-article article))
  10207. ;; Allow the backend to change the mark.
  10208. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10209. ;; Check for auto-expiry.
  10210. (when (and gnus-newsgroup-auto-expire
  10211. (memq mark gnus-auto-expirable-marks))
  10212. (setq mark gnus-expirable-mark)
  10213. ;; Let the backend know about the mark change.
  10214. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10215. (push article gnus-newsgroup-expirable))
  10216. ;; Set the mark in the buffer.
  10217. (gnus-summary-update-mark mark 'unread)
  10218. t))
  10219. (defun gnus-summary-mark-article-as-unread (mark)
  10220. "Mark the current article quickly as unread with MARK."
  10221. (let* ((article (gnus-summary-article-number))
  10222. (old-mark (gnus-summary-article-mark article)))
  10223. ;; Allow the backend to change the mark.
  10224. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10225. (if (eq mark old-mark)
  10226. t
  10227. (if (<= article 0)
  10228. (progn
  10229. (gnus-error 1 "Can't mark negative article numbers")
  10230. nil)
  10231. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
  10232. (setq gnus-newsgroup-spam-marked
  10233. (delq article gnus-newsgroup-spam-marked))
  10234. (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
  10235. (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
  10236. (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
  10237. (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10238. (cond ((= mark gnus-ticked-mark)
  10239. (setq gnus-newsgroup-marked
  10240. (gnus-add-to-sorted-list gnus-newsgroup-marked
  10241. article)))
  10242. ((= mark gnus-spam-mark)
  10243. (setq gnus-newsgroup-spam-marked
  10244. (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
  10245. article)))
  10246. ((= mark gnus-dormant-mark)
  10247. (setq gnus-newsgroup-dormant
  10248. (gnus-add-to-sorted-list gnus-newsgroup-dormant
  10249. article)))
  10250. (t
  10251. (setq gnus-newsgroup-unreads
  10252. (gnus-add-to-sorted-list gnus-newsgroup-unreads
  10253. article))))
  10254. (gnus-alist-pull article gnus-newsgroup-reads)
  10255. ;; See whether the article is to be put in the cache.
  10256. (and gnus-use-cache
  10257. (vectorp (gnus-summary-article-header article))
  10258. (save-excursion
  10259. (gnus-cache-possibly-enter-article
  10260. gnus-newsgroup-name article
  10261. (= mark gnus-ticked-mark)
  10262. (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
  10263. ;; Fix the mark.
  10264. (gnus-summary-update-mark mark 'unread)
  10265. t))))
  10266. (defun gnus-summary-mark-article (&optional article mark no-expire)
  10267. "Mark ARTICLE with MARK. MARK can be any character.
  10268. Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
  10269. `??' (dormant) and `?E' (expirable).
  10270. If MARK is nil, then the default character `?r' is used.
  10271. If ARTICLE is nil, then the article on the current line will be
  10272. marked.
  10273. If NO-EXPIRE, auto-expiry will be inhibited."
  10274. ;; The mark might be a string.
  10275. (when (stringp mark)
  10276. (setq mark (aref mark 0)))
  10277. ;; If no mark is given, then we check auto-expiring.
  10278. (when (null mark)
  10279. (setq mark gnus-del-mark))
  10280. (when (and (not no-expire)
  10281. gnus-newsgroup-auto-expire
  10282. (memq mark gnus-auto-expirable-marks))
  10283. (setq mark gnus-expirable-mark))
  10284. (let ((article (or article (gnus-summary-article-number)))
  10285. (old-mark (gnus-summary-article-mark article)))
  10286. ;; Allow the backend to change the mark.
  10287. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10288. (if (eq mark old-mark)
  10289. t
  10290. (unless article
  10291. (error "No article on current line"))
  10292. (if (not (if (or (= mark gnus-unread-mark)
  10293. (= mark gnus-ticked-mark)
  10294. (= mark gnus-spam-mark)
  10295. (= mark gnus-dormant-mark))
  10296. (gnus-mark-article-as-unread article mark)
  10297. (gnus-mark-article-as-read article mark)))
  10298. t
  10299. ;; See whether the article is to be put in the cache.
  10300. (and gnus-use-cache
  10301. (not (= mark gnus-canceled-mark))
  10302. (vectorp (gnus-summary-article-header article))
  10303. (save-excursion
  10304. (gnus-cache-possibly-enter-article
  10305. gnus-newsgroup-name article
  10306. (= mark gnus-ticked-mark)
  10307. (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
  10308. (when (gnus-summary-goto-subject article nil t)
  10309. (let ((inhibit-read-only t))
  10310. (gnus-summary-show-thread)
  10311. ;; Fix the mark.
  10312. (gnus-summary-update-mark mark 'unread)
  10313. t))))))
  10314. (defun gnus-summary-update-secondary-mark (article)
  10315. "Update the secondary (read, process, cache) mark."
  10316. (gnus-summary-update-mark
  10317. (cond ((memq article gnus-newsgroup-processable)
  10318. gnus-process-mark)
  10319. ((memq article gnus-newsgroup-cached)
  10320. gnus-cached-mark)
  10321. ((memq article gnus-newsgroup-replied)
  10322. gnus-replied-mark)
  10323. ((memq article gnus-newsgroup-forwarded)
  10324. gnus-forwarded-mark)
  10325. ((memq article gnus-newsgroup-saved)
  10326. gnus-saved-mark)
  10327. ((memq article gnus-newsgroup-unseen)
  10328. gnus-unseen-mark)
  10329. (t gnus-no-mark))
  10330. 'replied)
  10331. (when (gnus-visual-p 'summary-highlight 'highlight)
  10332. (gnus-summary-highlight-line)
  10333. (gnus-run-hooks 'gnus-summary-update-hook))
  10334. t)
  10335. (defun gnus-summary-update-download-mark (article)
  10336. "Update the download mark."
  10337. (gnus-summary-update-mark
  10338. (cond ((memq article gnus-newsgroup-undownloaded)
  10339. gnus-undownloaded-mark)
  10340. (gnus-newsgroup-agentized
  10341. gnus-downloaded-mark)
  10342. (t
  10343. gnus-no-mark))
  10344. 'download)
  10345. (gnus-summary-update-line t)
  10346. t)
  10347. (defun gnus-summary-update-mark (mark type)
  10348. (let ((forward (cdr (assq type gnus-summary-mark-positions)))
  10349. (inhibit-read-only t))
  10350. (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
  10351. (when forward
  10352. (when (looking-at "\r")
  10353. (incf forward))
  10354. (when (<= (+ forward (point)) (point-max))
  10355. ;; Go to the right position on the line.
  10356. (goto-char (+ forward (point)))
  10357. ;; Replace the old mark with the new mark.
  10358. (let ((to-insert
  10359. (mm-subst-char-in-string
  10360. (char-after) mark
  10361. (buffer-substring (point) (1+ (point))))))
  10362. (delete-region (point) (1+ (point)))
  10363. (insert to-insert))
  10364. ;; Optionally update the marks by some user rule.
  10365. (when (eq type 'unread)
  10366. (gnus-data-set-mark
  10367. (gnus-data-find (gnus-summary-article-number)) mark)
  10368. (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
  10369. (defun gnus-mark-article-as-read (article &optional mark)
  10370. "Enter ARTICLE in the pertinent lists and remove it from others."
  10371. ;; Make the article expirable.
  10372. (let ((mark (or mark gnus-del-mark)))
  10373. (setq gnus-newsgroup-expirable
  10374. (if (= mark gnus-expirable-mark)
  10375. (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
  10376. (delq article gnus-newsgroup-expirable)))
  10377. ;; Remove from unread and marked lists.
  10378. (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10379. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
  10380. (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
  10381. (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
  10382. (push (cons article mark) gnus-newsgroup-reads)
  10383. ;; Possibly remove from cache, if that is used.
  10384. (when gnus-use-cache
  10385. (gnus-cache-enter-remove-article article))
  10386. t))
  10387. (defun gnus-mark-article-as-unread (article &optional mark)
  10388. "Enter ARTICLE in the pertinent lists and remove it from others."
  10389. (let ((mark (or mark gnus-ticked-mark)))
  10390. (if (<= article 0)
  10391. (progn
  10392. (gnus-error 1 "Can't mark negative article numbers")
  10393. nil)
  10394. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
  10395. gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
  10396. gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
  10397. gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
  10398. gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10399. ;; Unsuppress duplicates?
  10400. (when gnus-suppress-duplicates
  10401. (gnus-dup-unsuppress-article article))
  10402. (cond ((= mark gnus-ticked-mark)
  10403. (setq gnus-newsgroup-marked
  10404. (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
  10405. ((= mark gnus-spam-mark)
  10406. (setq gnus-newsgroup-spam-marked
  10407. (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
  10408. article)))
  10409. ((= mark gnus-dormant-mark)
  10410. (setq gnus-newsgroup-dormant
  10411. (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
  10412. (t
  10413. (setq gnus-newsgroup-unreads
  10414. (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
  10415. (gnus-alist-pull article gnus-newsgroup-reads)
  10416. t)))
  10417. (defun gnus-summary-tick-article-forward (n)
  10418. "Tick N articles forwards.
  10419. If N is negative, tick backwards instead.
  10420. The difference between N and the number of articles ticked is returned."
  10421. (interactive "p")
  10422. (gnus-summary-mark-forward n gnus-ticked-mark))
  10423. (defun gnus-summary-tick-article-backward (n)
  10424. "Tick N articles backwards.
  10425. The difference between N and the number of articles ticked is returned."
  10426. (interactive "p")
  10427. (gnus-summary-mark-forward (- n) gnus-ticked-mark))
  10428. (defun gnus-summary-tick-article (&optional article clear-mark)
  10429. "Mark current article as unread.
  10430. Optional 1st argument ARTICLE specifies article number to be marked as unread.
  10431. Optional 2nd argument CLEAR-MARK remove any kinds of mark."
  10432. (interactive)
  10433. (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
  10434. gnus-ticked-mark)))
  10435. (defun gnus-summary-mark-as-read-forward (n)
  10436. "Mark N articles as read forwards.
  10437. If N is negative, mark backwards instead.
  10438. The difference between N and the actual number of articles marked is
  10439. returned."
  10440. (interactive "p")
  10441. (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
  10442. (defun gnus-summary-mark-as-read-backward (n)
  10443. "Mark the N articles as read backwards.
  10444. The difference between N and the actual number of articles marked is
  10445. returned."
  10446. (interactive "p")
  10447. (gnus-summary-mark-forward
  10448. (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
  10449. (defun gnus-summary-mark-as-read (&optional article mark)
  10450. "Mark current article as read.
  10451. ARTICLE specifies the article to be marked as read.
  10452. MARK specifies a string to be inserted at the beginning of the line."
  10453. (gnus-summary-mark-article article mark))
  10454. (defun gnus-summary-clear-mark-forward (n)
  10455. "Clear marks from N articles forward.
  10456. If N is negative, clear backward instead.
  10457. The difference between N and the number of marks cleared is returned."
  10458. (interactive "p")
  10459. (gnus-summary-mark-forward n gnus-unread-mark))
  10460. (defun gnus-summary-clear-mark-backward (n)
  10461. "Clear marks from N articles backward.
  10462. The difference between N and the number of marks cleared is returned."
  10463. (interactive "p")
  10464. (gnus-summary-mark-forward (- n) gnus-unread-mark))
  10465. (defun gnus-summary-mark-unread-as-read ()
  10466. "Intended to be used by `gnus-mark-article-hook'."
  10467. (when (memq gnus-current-article gnus-newsgroup-unreads)
  10468. (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
  10469. (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
  10470. "Intended to be used by `gnus-mark-article-hook'."
  10471. (let ((mark (gnus-summary-article-mark)))
  10472. (when (or (gnus-unread-mark-p mark)
  10473. (gnus-read-mark-p mark))
  10474. (gnus-summary-mark-article gnus-current-article
  10475. (or new-mark gnus-read-mark)))))
  10476. (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
  10477. "Intended to be used by `gnus-mark-article-hook'."
  10478. (let ((mark (gnus-summary-article-mark)))
  10479. (when (or (gnus-unread-mark-p mark)
  10480. (gnus-read-mark-p mark))
  10481. (gnus-summary-mark-article (gnus-summary-article-number)
  10482. (or new-mark gnus-read-mark)))))
  10483. (defun gnus-summary-mark-unread-as-ticked ()
  10484. "Intended to be used by `gnus-mark-article-hook'."
  10485. (when (memq gnus-current-article gnus-newsgroup-unreads)
  10486. (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
  10487. (defun gnus-summary-mark-region-as-read (point mark all)
  10488. "Mark all unread articles between point and mark as read.
  10489. If given a prefix, mark all articles between point and mark as read,
  10490. even ticked and dormant ones."
  10491. (interactive "r\nP")
  10492. (save-excursion
  10493. (let (article)
  10494. (goto-char point)
  10495. (beginning-of-line)
  10496. (while (and
  10497. (< (point) mark)
  10498. (progn
  10499. (when (or all
  10500. (memq (setq article (gnus-summary-article-number))
  10501. gnus-newsgroup-unreads))
  10502. (gnus-summary-mark-article article gnus-del-mark))
  10503. t)
  10504. (gnus-summary-find-next))))))
  10505. (defun gnus-summary-mark-below (score mark)
  10506. "Mark articles with score less than SCORE with MARK."
  10507. (interactive "P\ncMark: ")
  10508. (setq score (if score
  10509. (prefix-numeric-value score)
  10510. (or gnus-summary-default-score 0)))
  10511. (with-current-buffer gnus-summary-buffer
  10512. (goto-char (point-min))
  10513. (while
  10514. (progn
  10515. (and (< (gnus-summary-article-score) score)
  10516. (gnus-summary-mark-article nil mark))
  10517. (gnus-summary-find-next)))))
  10518. (defun gnus-summary-kill-below (&optional score)
  10519. "Mark articles with score below SCORE as read."
  10520. (interactive "P")
  10521. (gnus-summary-mark-below score gnus-killed-mark))
  10522. (defun gnus-summary-clear-above (&optional score)
  10523. "Clear all marks from articles with score above SCORE."
  10524. (interactive "P")
  10525. (gnus-summary-mark-above score gnus-unread-mark))
  10526. (defun gnus-summary-tick-above (&optional score)
  10527. "Tick all articles with score above SCORE."
  10528. (interactive "P")
  10529. (gnus-summary-mark-above score gnus-ticked-mark))
  10530. (defun gnus-summary-mark-above (score mark)
  10531. "Mark articles with score over SCORE with MARK."
  10532. (interactive "P\ncMark: ")
  10533. (setq score (if score
  10534. (prefix-numeric-value score)
  10535. (or gnus-summary-default-score 0)))
  10536. (with-current-buffer gnus-summary-buffer
  10537. (goto-char (point-min))
  10538. (while (and (progn
  10539. (when (> (gnus-summary-article-score) score)
  10540. (gnus-summary-mark-article nil mark))
  10541. t)
  10542. (gnus-summary-find-next)))))
  10543. ;; Suggested by Daniel Quinlan <quinlan@best.com>.
  10544. (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
  10545. (defun gnus-summary-limit-include-expunged (&optional no-error)
  10546. "Display all the hidden articles that were expunged for low scores."
  10547. (interactive)
  10548. (let ((inhibit-read-only t))
  10549. (let ((scored gnus-newsgroup-scored)
  10550. headers h)
  10551. (while scored
  10552. (unless (gnus-summary-article-header (caar scored))
  10553. (and (setq h (gnus-number-to-header (caar scored)))
  10554. (< (cdar scored) gnus-summary-expunge-below)
  10555. (push h headers)))
  10556. (setq scored (cdr scored)))
  10557. (if (not headers)
  10558. (when (not no-error)
  10559. (error "No expunged articles hidden"))
  10560. (goto-char (point-min))
  10561. (push gnus-newsgroup-limit gnus-newsgroup-limits)
  10562. (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
  10563. (dolist (x headers)
  10564. (push (mail-header-number x) gnus-newsgroup-limit))
  10565. (gnus-summary-prepare-unthreaded (nreverse headers))
  10566. (goto-char (point-min))
  10567. (gnus-summary-position-point)
  10568. t))))
  10569. (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
  10570. "Mark all unread articles in this newsgroup as read.
  10571. If prefix argument ALL is non-nil, ticked and dormant articles will
  10572. also be marked as read.
  10573. If QUIETLY is non-nil, no questions will be asked.
  10574. If TO-HERE is non-nil, it should be a point in the buffer. All
  10575. articles before (after, if REVERSE is set) this point will be marked
  10576. as read.
  10577. Note that this function will only catch up the unread article
  10578. in the current summary buffer limitation.
  10579. The number of articles marked as read is returned."
  10580. (interactive "P")
  10581. (prog1
  10582. (save-excursion
  10583. (when (or quietly
  10584. (not gnus-interactive-catchup) ;Without confirmation?
  10585. gnus-expert-user
  10586. (gnus-y-or-n-p
  10587. (if all
  10588. "Mark absolutely all articles as read? "
  10589. "Mark all unread articles as read? ")))
  10590. (if (and not-mark
  10591. (not gnus-newsgroup-adaptive)
  10592. (not gnus-newsgroup-auto-expire)
  10593. (not gnus-suppress-duplicates)
  10594. (or (not gnus-use-cache)
  10595. (eq gnus-use-cache 'passive)))
  10596. (progn
  10597. (when all
  10598. (setq gnus-newsgroup-marked nil
  10599. gnus-newsgroup-spam-marked nil
  10600. gnus-newsgroup-dormant nil))
  10601. (setq gnus-newsgroup-unreads
  10602. (gnus-sorted-nunion
  10603. (gnus-sorted-intersection gnus-newsgroup-unreads
  10604. gnus-newsgroup-downloadable)
  10605. (gnus-sorted-difference gnus-newsgroup-unfetched
  10606. gnus-newsgroup-cached))))
  10607. ;; We actually mark all articles as canceled, which we
  10608. ;; have to do when using auto-expiry or adaptive scoring.
  10609. (gnus-summary-show-all-threads)
  10610. (if (and to-here reverse)
  10611. (progn
  10612. (goto-char to-here)
  10613. (gnus-summary-mark-current-read-and-unread-as-read
  10614. gnus-catchup-mark)
  10615. (while (gnus-summary-find-next (not all))
  10616. (gnus-summary-mark-article-as-read gnus-catchup-mark)))
  10617. (when (gnus-summary-first-subject (not all))
  10618. (while (and
  10619. (if to-here (< (point) to-here) t)
  10620. (gnus-summary-mark-article-as-read gnus-catchup-mark)
  10621. (gnus-summary-find-next (not all))))))
  10622. (gnus-set-mode-line 'summary))
  10623. t))
  10624. (gnus-summary-position-point)))
  10625. (defun gnus-summary-catchup-to-here (&optional all)
  10626. "Mark all unticked articles before the current one as read.
  10627. If ALL is non-nil, also mark ticked and dormant articles as read."
  10628. (interactive "P")
  10629. (save-excursion
  10630. (gnus-save-hidden-threads
  10631. (let ((beg (point)))
  10632. ;; We check that there are unread articles.
  10633. (when (or all (gnus-summary-find-prev))
  10634. (gnus-summary-catchup all t beg)))))
  10635. (gnus-summary-position-point))
  10636. (defun gnus-summary-catchup-from-here (&optional all)
  10637. "Mark all unticked articles after (and including) the current one as read.
  10638. If ALL is non-nil, also mark ticked and dormant articles as read."
  10639. (interactive "P")
  10640. (save-excursion
  10641. (gnus-save-hidden-threads
  10642. (let ((beg (point)))
  10643. ;; We check that there are unread articles.
  10644. (when (or all (gnus-summary-find-next))
  10645. (gnus-summary-catchup all t beg nil t)))))
  10646. (gnus-summary-position-point))
  10647. (defun gnus-summary-catchup-all (&optional quietly)
  10648. "Mark all articles in this newsgroup as read.
  10649. This command is dangerous. Normally, you want \\[gnus-summary-catchup]
  10650. instead, which marks only unread articles as read."
  10651. (interactive "P")
  10652. (gnus-summary-catchup t quietly))
  10653. (defun gnus-summary-catchup-and-exit (&optional all quietly)
  10654. "Mark all unread articles in this group as read, then exit.
  10655. If prefix argument ALL is non-nil, all articles are marked as read.
  10656. If QUIETLY is non-nil, no questions will be asked."
  10657. (interactive "P")
  10658. (when (gnus-summary-catchup all quietly nil 'fast)
  10659. ;; Select next newsgroup or exit.
  10660. (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
  10661. (eq gnus-auto-select-next 'quietly))
  10662. (gnus-summary-next-group nil)
  10663. (gnus-summary-exit))))
  10664. (defun gnus-summary-catchup-all-and-exit (&optional quietly)
  10665. "Mark all articles in this newsgroup as read, and then exit.
  10666. This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
  10667. instead, which marks only unread articles as read."
  10668. (interactive "P")
  10669. (gnus-summary-catchup-and-exit t quietly))
  10670. (defun gnus-summary-catchup-and-goto-next-group (&optional all)
  10671. "Mark all articles in this group as read and select the next group.
  10672. If given a prefix, mark all articles, unread as well as ticked, as
  10673. read."
  10674. (interactive "P")
  10675. (save-excursion
  10676. (gnus-summary-catchup all))
  10677. (gnus-summary-next-group))
  10678. (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
  10679. "Mark all articles in this group as read and select the previous group.
  10680. If given a prefix, mark all articles, unread as well as ticked, as
  10681. read."
  10682. (interactive "P")
  10683. (save-excursion
  10684. (gnus-summary-catchup all))
  10685. (gnus-summary-next-group nil nil t))
  10686. ;;;
  10687. ;;; with article
  10688. ;;;
  10689. (defmacro gnus-with-article (article &rest forms)
  10690. "Select ARTICLE and perform FORMS in the original article buffer.
  10691. Then replace the article with the result."
  10692. `(progn
  10693. ;; We don't want the article to be marked as read.
  10694. (let (gnus-mark-article-hook)
  10695. (gnus-summary-select-article t t nil ,article))
  10696. (set-buffer gnus-original-article-buffer)
  10697. ,@forms
  10698. (if (not (gnus-check-backend-function
  10699. 'request-replace-article (car gnus-article-current)))
  10700. (gnus-message 5 "Read-only group; not replacing")
  10701. (unless (gnus-request-replace-article
  10702. ,article (car gnus-article-current)
  10703. (current-buffer) t)
  10704. (error "Couldn't replace article")))
  10705. ;; The cache and backlog have to be flushed somewhat.
  10706. (when gnus-keep-backlog
  10707. (gnus-backlog-remove-article
  10708. (car gnus-article-current) (cdr gnus-article-current)))
  10709. (when gnus-use-cache
  10710. (gnus-cache-update-article
  10711. (car gnus-article-current) (cdr gnus-article-current)))))
  10712. (put 'gnus-with-article 'lisp-indent-function 1)
  10713. (put 'gnus-with-article 'edebug-form-spec '(form body))
  10714. ;; Thread-based commands.
  10715. (defun gnus-summary-articles-in-thread (&optional article)
  10716. "Return a list of all articles in the current thread.
  10717. If ARTICLE is non-nil, return all articles in the thread that starts
  10718. with that article."
  10719. (let* ((article (or article (gnus-summary-article-number)))
  10720. (data (gnus-data-find-list article))
  10721. (top-level (gnus-data-level (car data)))
  10722. (top-subject
  10723. (cond ((null gnus-thread-operation-ignore-subject)
  10724. (gnus-simplify-subject-re
  10725. (mail-header-subject (gnus-data-header (car data)))))
  10726. ((eq gnus-thread-operation-ignore-subject 'fuzzy)
  10727. (gnus-simplify-subject-fuzzy
  10728. (mail-header-subject (gnus-data-header (car data)))))
  10729. (t nil)))
  10730. (end-point (save-excursion
  10731. (goto-char (gnus-data-pos (car data)))
  10732. (if (gnus-summary-go-to-next-thread)
  10733. (point) (point-max))))
  10734. articles)
  10735. (while (and data
  10736. (< (gnus-data-pos (car data)) end-point))
  10737. (when (or (not top-subject)
  10738. (string= top-subject
  10739. (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
  10740. (gnus-simplify-subject-fuzzy
  10741. (mail-header-subject
  10742. (gnus-data-header (car data))))
  10743. (gnus-simplify-subject-re
  10744. (mail-header-subject
  10745. (gnus-data-header (car data)))))))
  10746. (push (gnus-data-number (car data)) articles))
  10747. (unless (and (setq data (cdr data))
  10748. (> (gnus-data-level (car data)) top-level))
  10749. (setq data nil)))
  10750. ;; Return the list of articles.
  10751. (nreverse articles)))
  10752. (defun gnus-summary-rethread-current ()
  10753. "Rethread the thread the current article is part of."
  10754. (interactive)
  10755. (let* ((gnus-show-threads t)
  10756. (article (gnus-summary-article-number))
  10757. (id (mail-header-id (gnus-summary-article-header)))
  10758. (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
  10759. (unless id
  10760. (error "No article on the current line"))
  10761. (gnus-rebuild-thread id)
  10762. (gnus-summary-goto-subject article)))
  10763. (defun gnus-summary-reparent-thread ()
  10764. "Make the current article child of the marked (or previous) article.
  10765. Note that the re-threading will only work if `gnus-thread-ignore-subject'
  10766. is non-nil or the Subject: of both articles are the same."
  10767. (interactive)
  10768. (unless (not (gnus-group-read-only-p))
  10769. (error "The current newsgroup does not support article editing"))
  10770. (unless (<= (length gnus-newsgroup-processable) 1)
  10771. (error "No more than one article may be marked"))
  10772. (let ((child (gnus-summary-article-number))
  10773. ;; First grab the marked article, otherwise one line up.
  10774. (parent (if (not (null gnus-newsgroup-processable))
  10775. (car gnus-newsgroup-processable)
  10776. (save-excursion
  10777. (if (eq (forward-line -1) 0)
  10778. (gnus-summary-article-number)
  10779. (error "Beginning of summary buffer"))))))
  10780. (gnus-summary-reparent-children parent (list child))))
  10781. (defun gnus-summary-reparent-children (parent children)
  10782. "Make PARENT the parent of CHILDREN.
  10783. When called interactively, PARENT is the current article and CHILDREN
  10784. are the process-marked articles."
  10785. (interactive
  10786. (list (gnus-summary-article-number)
  10787. (gnus-summary-work-articles nil)))
  10788. (dolist (child children)
  10789. (save-window-excursion
  10790. (let ((gnus-article-buffer " *reparent*"))
  10791. (unless (not (eq parent child))
  10792. (error "An article may not be self-referential"))
  10793. (let ((message-id (mail-header-id
  10794. (gnus-summary-article-header parent))))
  10795. (unless (and message-id (not (equal message-id "")))
  10796. (error "No message-id in desired parent"))
  10797. (gnus-with-article child
  10798. (save-restriction
  10799. (goto-char (point-min))
  10800. (message-narrow-to-head)
  10801. (if (re-search-forward "^References: " nil t)
  10802. (progn
  10803. (re-search-forward "^[^ \t]" nil t)
  10804. (forward-line -1)
  10805. (end-of-line)
  10806. (insert " " message-id))
  10807. (insert "References: " message-id "\n"))))
  10808. (set-buffer gnus-summary-buffer)
  10809. (gnus-summary-unmark-all-processable)
  10810. (gnus-summary-update-article child)
  10811. (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
  10812. (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
  10813. (gnus-summary-rethread-current)
  10814. (gnus-message 3 "Article %d is now the child of article %d"
  10815. child parent))))))
  10816. (defun gnus-summary-toggle-threads (&optional arg)
  10817. "Toggle showing conversation threads.
  10818. If ARG is positive number, turn showing conversation threads on."
  10819. (interactive "P")
  10820. (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
  10821. (setq gnus-show-threads
  10822. (if (null arg) (not gnus-show-threads)
  10823. (> (prefix-numeric-value arg) 0)))
  10824. (gnus-summary-prepare)
  10825. (gnus-summary-goto-subject current)
  10826. (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
  10827. (gnus-summary-position-point)))
  10828. (defun gnus-summary-show-all-threads ()
  10829. "Show all threads."
  10830. (interactive)
  10831. (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
  10832. (gnus-summary-position-point))
  10833. (defsubst gnus-summary--inv (p)
  10834. (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
  10835. (defun gnus-summary-show-thread ()
  10836. "Show thread subtrees.
  10837. Returns nil if no thread was there to be shown."
  10838. (interactive)
  10839. (let* ((orig (point))
  10840. (end (point-at-eol))
  10841. (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
  10842. ;; Leave point at bol
  10843. (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
  10844. (eoi (when end
  10845. (if (fboundp 'next-single-char-property-change)
  10846. ;; Note: XEmacs version of n-s-c-p-c may return nil
  10847. (or (next-single-char-property-change end 'invisible)
  10848. (point-max))
  10849. (while (progn
  10850. (end-of-line 2)
  10851. (and (not (eobp))
  10852. (eq (get-char-property (point) 'invisible)
  10853. 'gnus-sum))))
  10854. (point)))))
  10855. (when eoi
  10856. (remove-overlays beg eoi 'invisible 'gnus-sum)
  10857. (goto-char orig)
  10858. (gnus-summary-position-point)
  10859. eoi)))
  10860. (defun gnus-summary-maybe-hide-threads ()
  10861. "If requested, hide the threads that should be hidden."
  10862. (when (and gnus-show-threads
  10863. gnus-thread-hide-subtree)
  10864. (gnus-summary-hide-all-threads
  10865. (if (or (consp gnus-thread-hide-subtree)
  10866. (functionp gnus-thread-hide-subtree))
  10867. (gnus-make-predicate gnus-thread-hide-subtree)
  10868. nil))))
  10869. ;;; Hiding predicates.
  10870. (defun gnus-article-unread-p (header)
  10871. (memq (mail-header-number header) gnus-newsgroup-unreads))
  10872. (defun gnus-article-unseen-p (header)
  10873. (memq (mail-header-number header) gnus-newsgroup-unseen))
  10874. (defun gnus-map-articles (predicate articles)
  10875. "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
  10876. (apply 'gnus-or (mapcar predicate
  10877. (mapcar (lambda (number)
  10878. (gnus-summary-article-header number))
  10879. articles))))
  10880. (defun gnus-summary-hide-all-threads (&optional predicate)
  10881. "Hide all thread subtrees.
  10882. If PREDICATE is supplied, threads that satisfy this predicate
  10883. will not be hidden."
  10884. (interactive)
  10885. (save-excursion
  10886. (goto-char (point-min))
  10887. (let ((end nil)
  10888. (count 0))
  10889. (while (not end)
  10890. (incf count)
  10891. (when (zerop (mod count 1000))
  10892. (message "Hiding all threads... %d" count))
  10893. (when (or (not predicate)
  10894. (gnus-map-articles
  10895. predicate (gnus-summary-article-children)))
  10896. (gnus-summary-hide-thread))
  10897. (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
  10898. (gnus-summary-position-point))
  10899. (defun gnus-summary-hide-thread ()
  10900. "Hide thread subtrees.
  10901. If PREDICATE is supplied, threads that satisfy this predicate
  10902. will not be hidden.
  10903. Returns nil if no threads were there to be hidden."
  10904. (interactive)
  10905. (beginning-of-line)
  10906. (let ((start (point))
  10907. (starteol (line-end-position))
  10908. (article (gnus-summary-article-number)))
  10909. ;; Go forward until either the buffer ends or the subthread ends.
  10910. (when (and (not (eobp))
  10911. (or (zerop (gnus-summary-next-thread 1 t))
  10912. (goto-char (point-max))))
  10913. (if (and (> (point) start)
  10914. ;; FIXME: this should actually search for a non-invisible \n.
  10915. (search-backward "\n" start t))
  10916. (progn
  10917. (when (> (point) starteol)
  10918. (remove-overlays starteol (point) 'invisible 'gnus-sum)
  10919. (let ((ol (make-overlay starteol (point) nil t nil)))
  10920. (overlay-put ol 'invisible 'gnus-sum)
  10921. (overlay-put ol 'evaporate t)))
  10922. (gnus-summary-goto-subject article)
  10923. (when (> start (point))
  10924. (message "Hiding the thread moved us backwards, aborting!")
  10925. (goto-char (point-max))))
  10926. (goto-char start)
  10927. nil))))
  10928. (defun gnus-summary-go-to-next-thread (&optional previous)
  10929. "Go to the same level (or less) next thread.
  10930. If PREVIOUS is non-nil, go to previous thread instead.
  10931. Return the article number moved to, or nil if moving was impossible."
  10932. (let ((level (gnus-summary-thread-level))
  10933. (way (if previous -1 1))
  10934. (beg (point)))
  10935. (forward-line way)
  10936. (while (and (not (eobp))
  10937. (< level (gnus-summary-thread-level)))
  10938. (forward-line way))
  10939. (if (eobp)
  10940. (progn
  10941. (goto-char beg)
  10942. nil)
  10943. (setq beg (point))
  10944. (prog1
  10945. (gnus-summary-article-number)
  10946. (goto-char beg)))))
  10947. (defun gnus-summary-next-thread (n &optional silent)
  10948. "Go to the same level next N'th thread.
  10949. If N is negative, search backward instead.
  10950. Returns the difference between N and the number of skips actually
  10951. done.
  10952. If SILENT, don't output messages."
  10953. (interactive "p")
  10954. (let ((backward (< n 0))
  10955. (n (abs n)))
  10956. (while (and (> n 0)
  10957. (gnus-summary-go-to-next-thread backward))
  10958. (decf n))
  10959. (unless silent
  10960. (gnus-summary-position-point))
  10961. (when (and (not silent) (/= 0 n))
  10962. (gnus-message 7 "No more threads"))
  10963. n))
  10964. (defun gnus-summary-prev-thread (n)
  10965. "Go to the same level previous N'th thread.
  10966. Returns the difference between N and the number of skips actually
  10967. done."
  10968. (interactive "p")
  10969. (gnus-summary-next-thread (- n)))
  10970. (defun gnus-summary-go-down-thread ()
  10971. "Go down one level in the current thread."
  10972. (let ((children (gnus-summary-article-children)))
  10973. (when children
  10974. (gnus-summary-goto-subject (car children)))))
  10975. (defun gnus-summary-go-up-thread ()
  10976. "Go up one level in the current thread."
  10977. (let ((parent (gnus-summary-article-parent)))
  10978. (when parent
  10979. (gnus-summary-goto-subject parent))))
  10980. (defun gnus-summary-down-thread (n)
  10981. "Go down thread N steps.
  10982. If N is negative, go up instead.
  10983. Returns the difference between N and how many steps down that were
  10984. taken."
  10985. (interactive "p")
  10986. (let ((up (< n 0))
  10987. (n (abs n)))
  10988. (while (and (> n 0)
  10989. (if up (gnus-summary-go-up-thread)
  10990. (gnus-summary-go-down-thread)))
  10991. (setq n (1- n)))
  10992. (gnus-summary-position-point)
  10993. (when (/= 0 n)
  10994. (gnus-message 7 "Can't go further"))
  10995. n))
  10996. (defun gnus-summary-up-thread (n)
  10997. "Go up thread N steps.
  10998. If N is negative, go down instead.
  10999. Returns the difference between N and how many steps down that were
  11000. taken."
  11001. (interactive "p")
  11002. (gnus-summary-down-thread (- n)))
  11003. (defun gnus-summary-top-thread ()
  11004. "Go to the top of the thread."
  11005. (interactive)
  11006. (while (gnus-summary-go-up-thread))
  11007. (gnus-summary-article-number))
  11008. (defun gnus-summary-expire-thread ()
  11009. "Mark articles under current thread as expired."
  11010. (interactive)
  11011. (gnus-summary-kill-thread 0))
  11012. (defun gnus-summary-kill-thread (&optional unmark)
  11013. "Mark articles under current thread as read.
  11014. If the prefix argument is positive, remove any kinds of marks.
  11015. If the prefix argument is zero, mark thread as expired.
  11016. If the prefix argument is negative, tick articles instead."
  11017. (interactive "P")
  11018. (when unmark
  11019. (setq unmark (prefix-numeric-value unmark)))
  11020. (let ((articles (gnus-summary-articles-in-thread))
  11021. (hide (or (null unmark) (= unmark 0))))
  11022. (save-excursion
  11023. ;; Expand the thread.
  11024. (gnus-summary-show-thread)
  11025. ;; Mark all the articles.
  11026. (while articles
  11027. (gnus-summary-goto-subject (car articles))
  11028. (cond ((null unmark)
  11029. (gnus-summary-mark-article-as-read gnus-killed-mark))
  11030. ((> unmark 0)
  11031. (gnus-summary-mark-article-as-unread gnus-unread-mark))
  11032. ((= unmark 0)
  11033. (gnus-summary-mark-article nil gnus-expirable-mark))
  11034. (t
  11035. (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
  11036. (setq articles (cdr articles))))
  11037. ;; Hide killed subtrees when hide is true.
  11038. (and hide
  11039. gnus-thread-hide-killed
  11040. (gnus-summary-hide-thread))
  11041. ;; If hide is t, go to next unread subject.
  11042. (when hide
  11043. ;; Go to next unread subject.
  11044. (gnus-summary-next-subject 1 t)))
  11045. (gnus-set-mode-line 'summary))
  11046. ;; Summary sorting commands
  11047. (defun gnus-summary-sort-by-number (&optional reverse)
  11048. "Sort the summary buffer by article number.
  11049. Argument REVERSE means reverse order."
  11050. (interactive "P")
  11051. (gnus-summary-sort 'number reverse))
  11052. (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
  11053. "Sort the summary buffer by most recent article number.
  11054. Argument REVERSE means reverse order."
  11055. (interactive "P")
  11056. (gnus-summary-sort 'most-recent-number reverse))
  11057. (defun gnus-summary-sort-by-random (&optional reverse)
  11058. "Randomize the order in the summary buffer.
  11059. Argument REVERSE means to randomize in reverse order."
  11060. (interactive "P")
  11061. (gnus-summary-sort 'random reverse))
  11062. (defun gnus-summary-sort-by-author (&optional reverse)
  11063. "Sort the summary buffer by author name alphabetically.
  11064. If `case-fold-search' is non-nil, case of letters is ignored.
  11065. Argument REVERSE means reverse order."
  11066. (interactive "P")
  11067. (gnus-summary-sort 'author reverse))
  11068. (defun gnus-summary-sort-by-recipient (&optional reverse)
  11069. "Sort the summary buffer by recipient name alphabetically.
  11070. If `case-fold-search' is non-nil, case of letters is ignored.
  11071. Argument REVERSE means reverse order."
  11072. (interactive "P")
  11073. (gnus-summary-sort 'recipient reverse))
  11074. (defun gnus-summary-sort-by-subject (&optional reverse)
  11075. "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
  11076. If `case-fold-search' is non-nil, case of letters is ignored.
  11077. Argument REVERSE means reverse order."
  11078. (interactive "P")
  11079. (gnus-summary-sort 'subject reverse))
  11080. (defun gnus-summary-sort-by-date (&optional reverse)
  11081. "Sort the summary buffer by date.
  11082. Argument REVERSE means reverse order."
  11083. (interactive "P")
  11084. (gnus-summary-sort 'date reverse))
  11085. (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
  11086. "Sort the summary buffer by most recent date.
  11087. Argument REVERSE means reverse order."
  11088. (interactive "P")
  11089. (gnus-summary-sort 'most-recent-date reverse))
  11090. (defun gnus-summary-sort-by-score (&optional reverse)
  11091. "Sort the summary buffer by score.
  11092. Argument REVERSE means reverse order."
  11093. (interactive "P")
  11094. (gnus-summary-sort 'score reverse))
  11095. (defun gnus-summary-sort-by-lines (&optional reverse)
  11096. "Sort the summary buffer by the number of lines.
  11097. Argument REVERSE means reverse order."
  11098. (interactive "P")
  11099. (gnus-summary-sort 'lines reverse))
  11100. (defun gnus-summary-sort-by-chars (&optional reverse)
  11101. "Sort the summary buffer by article length.
  11102. Argument REVERSE means reverse order."
  11103. (interactive "P")
  11104. (gnus-summary-sort 'chars reverse))
  11105. (defun gnus-summary-sort-by-original (&optional reverse)
  11106. "Sort the summary buffer using the default sorting method.
  11107. Argument REVERSE means reverse order."
  11108. (interactive "P")
  11109. (let* ((inhibit-read-only t)
  11110. (gnus-summary-prepare-hook nil))
  11111. ;; We do the sorting by regenerating the threads.
  11112. (gnus-summary-prepare)
  11113. ;; Hide subthreads if needed.
  11114. (gnus-summary-maybe-hide-threads)))
  11115. (defun gnus-summary-sort (predicate reverse)
  11116. "Sort summary buffer by PREDICATE. REVERSE means reverse order."
  11117. (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
  11118. (article (intern (format "gnus-article-sort-by-%s" predicate)))
  11119. (gnus-thread-sort-functions
  11120. (if (not reverse)
  11121. thread
  11122. `(lambda (t1 t2)
  11123. (,thread t2 t1))))
  11124. (gnus-sort-gathered-threads-function
  11125. gnus-thread-sort-functions)
  11126. (gnus-article-sort-functions
  11127. (if (not reverse)
  11128. article
  11129. `(lambda (t1 t2)
  11130. (,article t2 t1))))
  11131. (inhibit-read-only t)
  11132. (gnus-summary-prepare-hook nil))
  11133. ;; We do the sorting by regenerating the threads.
  11134. (gnus-summary-prepare)
  11135. ;; Hide subthreads if needed.
  11136. (gnus-summary-maybe-hide-threads)))
  11137. ;; Summary saving commands.
  11138. (defun gnus-summary-save-article (&optional n not-saved)
  11139. "Save the current article using the default saver function.
  11140. If N is a positive number, save the N next articles.
  11141. If N is a negative number, save the N previous articles.
  11142. If N is nil and any articles have been marked with the process mark,
  11143. save those articles instead.
  11144. The variable `gnus-default-article-saver' specifies the saver function.
  11145. If the optional second argument NOT-SAVED is non-nil, articles saved
  11146. will not be marked as saved."
  11147. (interactive "P")
  11148. (require 'gnus-art)
  11149. (let* ((articles (gnus-summary-work-articles n))
  11150. (save-buffer (save-excursion
  11151. (nnheader-set-temp-buffer " *Gnus Save*")))
  11152. (num (length articles))
  11153. ;; Whether to save decoded articles or raw articles.
  11154. (decode (when gnus-article-save-coding-system
  11155. (get gnus-default-article-saver :decode)))
  11156. ;; When saving many articles in a single file, use the other
  11157. ;; function to save articles other than the first one.
  11158. (saver2 (get gnus-default-article-saver :function))
  11159. (gnus-prompt-before-saving (if saver2
  11160. t
  11161. gnus-prompt-before-saving))
  11162. (gnus-default-article-saver gnus-default-article-saver)
  11163. header file)
  11164. (dolist (article articles)
  11165. (setq header (gnus-summary-article-header article))
  11166. (if (not (vectorp header))
  11167. ;; This is a pseudo-article.
  11168. (if (assq 'name header)
  11169. (gnus-copy-file (cdr (assq 'name header)))
  11170. (gnus-message 1 "Article %d is unsavable" article))
  11171. ;; This is a real article.
  11172. (save-window-excursion
  11173. (gnus-summary-select-article decode decode nil article)
  11174. (gnus-summary-goto-subject article))
  11175. (with-current-buffer save-buffer
  11176. (erase-buffer)
  11177. (insert-buffer-substring (if decode
  11178. gnus-article-buffer
  11179. gnus-original-article-buffer)))
  11180. (setq file (gnus-article-save save-buffer file num))
  11181. (gnus-summary-remove-process-mark article)
  11182. (unless not-saved
  11183. (gnus-summary-set-saved-mark article)))
  11184. (when saver2
  11185. (setq gnus-default-article-saver saver2
  11186. saver2 nil)))
  11187. (gnus-kill-buffer save-buffer)
  11188. (gnus-summary-position-point)
  11189. (gnus-set-mode-line 'summary)
  11190. n))
  11191. (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
  11192. (defun gnus-summary-pipe-output (&optional n sym)
  11193. "Pipe the current article to a subprocess.
  11194. If N is a positive number, pipe the N next articles.
  11195. If N is a negative number, pipe the N previous articles.
  11196. If N is nil and any articles have been marked with the process mark,
  11197. pipe those articles instead.
  11198. The default command to which articles are piped is specified by the
  11199. variable `gnus-summary-pipe-output-default-command'; if it is nil, you
  11200. will be prompted for the command.
  11201. The properties `:decode' and `:headers' that are put to the function
  11202. symbol `gnus-summary-save-in-pipe' control whether this function
  11203. decodes articles and what headers to keep (see the doc string for the
  11204. `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
  11205. is neither omitted nor the symbol `r', force including all headers
  11206. regardless of the `:headers' property. If it is the symbol `r',
  11207. articles that are not decoded and include all headers will be piped
  11208. no matter what the properties `:decode' and `:headers' are."
  11209. (interactive (gnus-interactive "P\ny"))
  11210. (require 'gnus-art)
  11211. (let* ((articles (gnus-summary-work-articles n))
  11212. (result-buffer "*Shell Command Output*")
  11213. (all-headers (not (memq sym '(nil r))))
  11214. (gnus-save-all-headers (or all-headers gnus-save-all-headers))
  11215. (raw (eq sym 'r))
  11216. (headers (get 'gnus-summary-save-in-pipe :headers))
  11217. command result)
  11218. (unless (numberp (car articles))
  11219. (error "No article to pipe"))
  11220. (setq command (gnus-read-shell-command
  11221. (concat "Shell command on "
  11222. (if (cdr articles)
  11223. (format "these %d articles" (length articles))
  11224. "this article")
  11225. ": ")
  11226. gnus-summary-pipe-output-default-command))
  11227. (when (string-equal command "")
  11228. (error "A command is required"))
  11229. (when all-headers
  11230. (put 'gnus-summary-save-in-pipe :headers nil))
  11231. (unwind-protect
  11232. (while articles
  11233. (gnus-summary-goto-subject (pop articles))
  11234. (save-window-excursion (gnus-summary-save-in-pipe command raw))
  11235. (when (and (get-buffer result-buffer)
  11236. (not (zerop (buffer-size (get-buffer result-buffer)))))
  11237. (setq result (concat result (with-current-buffer result-buffer
  11238. (buffer-string))))))
  11239. (put 'gnus-summary-save-in-pipe :headers headers))
  11240. (unless (zerop (length result))
  11241. (if (with-current-buffer (get-buffer-create result-buffer)
  11242. (erase-buffer)
  11243. (insert result)
  11244. (prog1
  11245. (and (= (count-lines (point-min) (point)) 1)
  11246. (progn
  11247. (end-of-line 0)
  11248. (<= (current-column)
  11249. (window-width (minibuffer-window)))))
  11250. (goto-char (point-min))))
  11251. (message "%s" (substring result 0 -1))
  11252. (message nil)
  11253. (gnus-configure-windows 'pipe)))))
  11254. (defun gnus-summary-save-article-mail (&optional arg)
  11255. "Append the current article to a Unix mail box file.
  11256. If N is a positive number, save the N next articles.
  11257. If N is a negative number, save the N previous articles.
  11258. If N is nil and any articles have been marked with the process mark,
  11259. save those articles instead."
  11260. (interactive "P")
  11261. (require 'gnus-art)
  11262. (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
  11263. (gnus-summary-save-article arg)))
  11264. (defun gnus-summary-save-article-rmail (&optional arg)
  11265. "Append the current article to an rmail file.
  11266. If N is a positive number, save the N next articles.
  11267. If N is a negative number, save the N previous articles.
  11268. If N is nil and any articles have been marked with the process mark,
  11269. save those articles instead."
  11270. (interactive "P")
  11271. (require 'gnus-art)
  11272. (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
  11273. (gnus-summary-save-article arg)))
  11274. (defun gnus-summary-save-article-file (&optional arg)
  11275. "Append the current article to a file.
  11276. If N is a positive number, save the N next articles.
  11277. If N is a negative number, save the N previous articles.
  11278. If N is nil and any articles have been marked with the process mark,
  11279. save those articles instead."
  11280. (interactive "P")
  11281. (require 'gnus-art)
  11282. (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
  11283. (gnus-summary-save-article arg)))
  11284. (defun gnus-summary-write-article-file (&optional arg)
  11285. "Write the current article to a file, deleting the previous file.
  11286. If N is a positive number, save the N next articles.
  11287. If N is a negative number, save the N previous articles.
  11288. If N is nil and any articles have been marked with the process mark,
  11289. save those articles instead."
  11290. (interactive "P")
  11291. (require 'gnus-art)
  11292. (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
  11293. (gnus-summary-save-article arg)))
  11294. (defun gnus-summary-save-article-body-file (&optional arg)
  11295. "Append the current article body to a file.
  11296. If N is a positive number, save the N next articles.
  11297. If N is a negative number, save the N previous articles.
  11298. If N is nil and any articles have been marked with the process mark,
  11299. save those articles instead."
  11300. (interactive "P")
  11301. (require 'gnus-art)
  11302. (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
  11303. (gnus-summary-save-article arg)))
  11304. (defun gnus-summary-write-article-body-file (&optional arg)
  11305. "Write the current article body to a file, deleting the previous file.
  11306. If N is a positive number, save the N next articles.
  11307. If N is a negative number, save the N previous articles.
  11308. If N is nil and any articles have been marked with the process mark,
  11309. save those articles instead."
  11310. (interactive "P")
  11311. (require 'gnus-art)
  11312. (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
  11313. (gnus-summary-save-article arg)))
  11314. (defun gnus-summary-muttprint (&optional arg)
  11315. "Print the current article using Muttprint.
  11316. If N is a positive number, save the N next articles.
  11317. If N is a negative number, save the N previous articles.
  11318. If N is nil and any articles have been marked with the process mark,
  11319. save those articles instead."
  11320. (interactive "P")
  11321. (require 'gnus-art)
  11322. (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
  11323. (gnus-summary-save-article arg t)))
  11324. (defun gnus-summary-pipe-message (program)
  11325. "Pipe the current article through PROGRAM."
  11326. (interactive "sProgram: ")
  11327. (gnus-summary-select-article)
  11328. (let ((mail-header-separator ""))
  11329. (gnus-eval-in-buffer-window gnus-article-buffer
  11330. (save-restriction
  11331. (widen)
  11332. (let ((start (window-start))
  11333. (inhibit-read-only t))
  11334. (message-pipe-buffer-body program)
  11335. (set-window-start (get-buffer-window (current-buffer)) start))))))
  11336. (defun gnus-get-split-value (methods)
  11337. "Return a value based on the split METHODS."
  11338. (let (split-name method result match)
  11339. (when methods
  11340. (with-current-buffer gnus-original-article-buffer
  11341. (save-restriction
  11342. (nnheader-narrow-to-headers)
  11343. (while (and methods (not split-name))
  11344. (goto-char (point-min))
  11345. (setq method (pop methods))
  11346. (setq match (car method))
  11347. (when (cond
  11348. ((stringp match)
  11349. ;; Regular expression.
  11350. (ignore-errors
  11351. (re-search-forward match nil t)))
  11352. ((functionp match)
  11353. ;; Function.
  11354. (save-restriction
  11355. (widen)
  11356. (setq result (funcall match gnus-newsgroup-name))))
  11357. ((consp match)
  11358. ;; Form.
  11359. (save-restriction
  11360. (widen)
  11361. (setq result (eval match)))))
  11362. (setq split-name (cdr method))
  11363. (cond ((stringp result)
  11364. (push (expand-file-name
  11365. result gnus-article-save-directory)
  11366. split-name))
  11367. ((consp result)
  11368. (setq split-name (append result split-name)))))))))
  11369. (nreverse split-name)))
  11370. (defun gnus-valid-move-group-p (group)
  11371. (and (symbolp group)
  11372. (boundp group)
  11373. (symbol-name group)
  11374. (symbol-value group)
  11375. (gnus-get-function (gnus-find-method-for-group
  11376. (symbol-name group)) 'request-accept-article t)))
  11377. (defun gnus-read-move-group-name (prompt default articles prefix)
  11378. "Read a group name."
  11379. (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
  11380. (minibuffer-confirm-incomplete nil) ; XEmacs
  11381. (prom
  11382. (format "%s %s to"
  11383. prompt
  11384. (if (> (length articles) 1)
  11385. (format "these %d articles" (length articles))
  11386. "this article")))
  11387. (to-newsgroup
  11388. (cond
  11389. ((null split-name)
  11390. (gnus-group-completing-read
  11391. prom
  11392. (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
  11393. nil prefix nil default))
  11394. ((= 1 (length split-name))
  11395. (gnus-group-completing-read
  11396. prom
  11397. (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
  11398. nil prefix 'gnus-group-history (car split-name)))
  11399. (t
  11400. (gnus-completing-read
  11401. prom (nreverse split-name) nil nil 'gnus-group-history))))
  11402. (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
  11403. encoded)
  11404. (when to-newsgroup
  11405. (if (or (string= to-newsgroup "")
  11406. (string= to-newsgroup prefix))
  11407. (setq to-newsgroup default))
  11408. (unless to-newsgroup
  11409. (error "No group name entered"))
  11410. (setq encoded (mm-encode-coding-string
  11411. to-newsgroup
  11412. (gnus-group-name-charset to-method to-newsgroup)))
  11413. (or (gnus-active encoded)
  11414. (gnus-activate-group encoded nil nil to-method)
  11415. (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
  11416. to-newsgroup))
  11417. (or (and (gnus-request-create-group encoded to-method)
  11418. (gnus-activate-group encoded nil nil to-method)
  11419. (gnus-subscribe-group encoded))
  11420. (error "Couldn't create group %s" to-newsgroup)))
  11421. (error "No such group: %s" to-newsgroup))
  11422. encoded)))
  11423. (defvar gnus-summary-save-parts-counter)
  11424. (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
  11425. (defun gnus-summary-save-parts (type dir n &optional reverse)
  11426. "Save parts matching TYPE to DIR.
  11427. If REVERSE, save parts that do not match TYPE."
  11428. (interactive
  11429. (list (read-string "Save parts of type: "
  11430. (or (car gnus-summary-save-parts-type-history)
  11431. gnus-summary-save-parts-default-mime)
  11432. 'gnus-summary-save-parts-type-history)
  11433. (setq gnus-summary-save-parts-last-directory
  11434. (read-directory-name "Save to directory: "
  11435. gnus-summary-save-parts-last-directory
  11436. nil t))
  11437. current-prefix-arg))
  11438. (gnus-summary-iterate n
  11439. (let ((gnus-display-mime-function nil)
  11440. gnus-article-prepare-hook
  11441. gnus-article-decode-hook
  11442. gnus-display-mime-function
  11443. gnus-break-pages
  11444. (gnus-inhibit-treatment t))
  11445. (gnus-summary-select-article))
  11446. (with-current-buffer gnus-article-buffer
  11447. (let ((handles (or gnus-article-mime-handles
  11448. (mm-dissect-buffer nil gnus-article-loose-mime)
  11449. (and gnus-article-emulate-mime
  11450. (mm-uu-dissect))))
  11451. (gnus-summary-save-parts-counter 1))
  11452. (when handles
  11453. (gnus-summary-save-parts-1 type dir handles reverse)
  11454. (unless gnus-article-mime-handles ;; Don't destroy this case.
  11455. (mm-destroy-parts handles)))))))
  11456. (defun gnus-summary-save-parts-1 (type dir handle reverse)
  11457. (if (stringp (car handle))
  11458. (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
  11459. (cdr handle))
  11460. (when (if reverse
  11461. (not (string-match type (mm-handle-media-type handle)))
  11462. (string-match type (mm-handle-media-type handle)))
  11463. (let ((file (expand-file-name
  11464. (gnus-map-function
  11465. mm-file-name-rewrite-functions
  11466. (file-name-nondirectory
  11467. (or
  11468. (mm-handle-filename handle)
  11469. (format "%s.%d.%d" gnus-newsgroup-name
  11470. (cdr gnus-article-current)
  11471. gnus-summary-save-parts-counter))))
  11472. dir)))
  11473. (incf gnus-summary-save-parts-counter)
  11474. (unless (file-exists-p file)
  11475. (mm-save-part-to-file handle file))))))
  11476. ;; Summary extract commands
  11477. (defun gnus-summary-insert-pseudos (pslist &optional not-view)
  11478. (let ((inhibit-read-only t)
  11479. (article (gnus-summary-article-number))
  11480. after-article b e)
  11481. (unless (gnus-summary-goto-subject article)
  11482. (error "No such article: %d" article))
  11483. (gnus-summary-position-point)
  11484. ;; If all commands are to be bunched up on one line, we collect
  11485. ;; them here.
  11486. (unless gnus-view-pseudos-separately
  11487. (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
  11488. files action)
  11489. (while ps
  11490. (setq action (cdr (assq 'action (car ps))))
  11491. (setq files (list (cdr (assq 'name (car ps)))))
  11492. (while (and ps (cdr ps)
  11493. (string= (or action "1")
  11494. (or (cdr (assq 'action (cadr ps))) "2")))
  11495. (push (cdr (assq 'name (cadr ps))) files)
  11496. (setcdr ps (cddr ps)))
  11497. (when files
  11498. (when (not (string-match "%s" action))
  11499. (push " " files))
  11500. (push " " files)
  11501. (when (assq 'execute (car ps))
  11502. (setcdr (assq 'execute (car ps))
  11503. (funcall (if (string-match "%s" action)
  11504. 'format 'concat)
  11505. action
  11506. (mapconcat
  11507. (lambda (f)
  11508. (if (equal f " ")
  11509. f
  11510. (shell-quote-argument f)))
  11511. files " ")))))
  11512. (setq ps (cdr ps)))))
  11513. (if (and gnus-view-pseudos (not not-view))
  11514. (while pslist
  11515. (when (assq 'execute (car pslist))
  11516. (gnus-execute-command (cdr (assq 'execute (car pslist)))
  11517. (eq gnus-view-pseudos 'not-confirm)))
  11518. (setq pslist (cdr pslist)))
  11519. (save-excursion
  11520. (while pslist
  11521. (setq after-article (or (cdr (assq 'article (car pslist)))
  11522. (gnus-summary-article-number)))
  11523. (gnus-summary-goto-subject after-article)
  11524. (forward-line 1)
  11525. (setq b (point))
  11526. (insert " " (file-name-nondirectory
  11527. (cdr (assq 'name (car pslist))))
  11528. ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
  11529. (setq e (point))
  11530. (forward-line -1) ; back to `b'
  11531. (gnus-add-text-properties
  11532. b (1- e) (list 'gnus-number gnus-reffed-article-number
  11533. gnus-mouse-face-prop gnus-mouse-face))
  11534. (gnus-data-enter
  11535. after-article gnus-reffed-article-number
  11536. gnus-unread-mark b (car pslist) 0 (- e b))
  11537. (setq gnus-newsgroup-unreads
  11538. (gnus-add-to-sorted-list gnus-newsgroup-unreads
  11539. gnus-reffed-article-number))
  11540. (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
  11541. (setq pslist (cdr pslist)))))))
  11542. (defun gnus-pseudos< (p1 p2)
  11543. (let ((c1 (cdr (assq 'action p1)))
  11544. (c2 (cdr (assq 'action p2))))
  11545. (and c1 c2 (string< c1 c2))))
  11546. (defun gnus-request-pseudo-article (props)
  11547. (cond ((assq 'execute props)
  11548. (gnus-execute-command (cdr (assq 'execute props)))))
  11549. (let ((gnus-current-article (gnus-summary-article-number)))
  11550. (gnus-run-hooks 'gnus-mark-article-hook)))
  11551. (defun gnus-execute-command (command &optional automatic)
  11552. (save-excursion
  11553. (gnus-article-setup-buffer)
  11554. (set-buffer gnus-article-buffer)
  11555. (setq buffer-read-only nil)
  11556. (let ((command (if automatic command
  11557. (read-string "Command: " (cons command 0)))))
  11558. (erase-buffer)
  11559. (insert "$ " command "\n\n")
  11560. (if gnus-view-pseudo-asynchronously
  11561. (start-process "gnus-execute" (current-buffer) shell-file-name
  11562. shell-command-switch command)
  11563. (call-process shell-file-name nil t nil
  11564. shell-command-switch command)))))
  11565. ;; Summary kill commands.
  11566. (defun gnus-summary-edit-global-kill (article)
  11567. "Edit the \"global\" kill file."
  11568. (interactive (list (gnus-summary-article-number)))
  11569. (gnus-group-edit-global-kill article))
  11570. (defun gnus-summary-edit-local-kill ()
  11571. "Edit a local kill file applied to the current newsgroup."
  11572. (interactive)
  11573. (setq gnus-current-headers (gnus-summary-article-header))
  11574. (gnus-group-edit-local-kill
  11575. (gnus-summary-article-number) gnus-newsgroup-name))
  11576. ;;; Header reading.
  11577. (defun gnus-read-header (id &optional header)
  11578. "Read the headers of article ID and enter them into the Gnus system."
  11579. (let ((group gnus-newsgroup-name)
  11580. (gnus-override-method
  11581. (or
  11582. gnus-override-method
  11583. (and (gnus-news-group-p gnus-newsgroup-name)
  11584. (car (gnus-refer-article-methods)))))
  11585. where)
  11586. ;; First we check to see whether the header in question is already
  11587. ;; fetched.
  11588. (if (stringp id)
  11589. ;; This is a Message-ID.
  11590. (setq header (or header (gnus-id-to-header id)))
  11591. ;; This is an article number.
  11592. (setq header (or header (gnus-summary-article-header id))))
  11593. (if (and header
  11594. (not (gnus-summary-article-sparse-p (mail-header-number header))))
  11595. ;; We have found the header.
  11596. header
  11597. ;; We have to really fetch the header to this article.
  11598. (with-current-buffer nntp-server-buffer
  11599. (when (setq where (gnus-request-head id group))
  11600. (nnheader-fold-continuation-lines)
  11601. (goto-char (point-max))
  11602. (insert ".\n")
  11603. (goto-char (point-min))
  11604. (insert "211 ")
  11605. (princ (cond
  11606. ((numberp id) id)
  11607. ((cdr where) (cdr where))
  11608. (header (mail-header-number header))
  11609. (t gnus-reffed-article-number))
  11610. (current-buffer))
  11611. (insert " Article retrieved.\n"))
  11612. (if (or (not where)
  11613. (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
  11614. () ; Malformed head.
  11615. (unless (gnus-summary-article-sparse-p (mail-header-number header))
  11616. (when (and (bound-and-true-p gnus-registry-enabled)
  11617. (not (gnus-ephemeral-group-p (car where))))
  11618. (gnus-registry-handle-action
  11619. (mail-header-id header) nil
  11620. (gnus-group-prefixed-name
  11621. (car where)
  11622. (or gnus-override-method (gnus-find-method-for-group group)))
  11623. (mail-header-subject header)
  11624. (mail-header-from header)))
  11625. (when (and (stringp id)
  11626. (or
  11627. (not (string= (gnus-group-real-name group)
  11628. (car where)))
  11629. (not (gnus-server-equal gnus-override-method
  11630. (gnus-group-method group)))))
  11631. ;; If we fetched by Message-ID and the article came from
  11632. ;; a different group (or server), we fudge some bogus
  11633. ;; article numbers for this article.
  11634. (mail-header-set-number header gnus-reffed-article-number))
  11635. (with-current-buffer gnus-summary-buffer
  11636. (decf gnus-reffed-article-number)
  11637. (gnus-remove-header (mail-header-number header))
  11638. (push header gnus-newsgroup-headers)
  11639. (setq gnus-current-headers header)
  11640. (push (mail-header-number header) gnus-newsgroup-limit)))
  11641. header)))))
  11642. (defun gnus-remove-header (number)
  11643. "Remove header NUMBER from `gnus-newsgroup-headers'."
  11644. (if (and gnus-newsgroup-headers
  11645. (= number (mail-header-number (car gnus-newsgroup-headers))))
  11646. (pop gnus-newsgroup-headers)
  11647. (let ((headers gnus-newsgroup-headers))
  11648. (while (and (cdr headers)
  11649. (not (= number (mail-header-number (cadr headers)))))
  11650. (pop headers))
  11651. (when (cdr headers)
  11652. (setcdr headers (cddr headers))))))
  11653. ;;;
  11654. ;;; summary highlights
  11655. ;;;
  11656. (defun gnus-highlight-selected-summary ()
  11657. "Highlight selected article in summary buffer."
  11658. ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
  11659. (when gnus-summary-selected-face
  11660. (save-excursion
  11661. (let* ((beg (point-at-bol))
  11662. (end (point-at-eol))
  11663. ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
  11664. (from (if (get-text-property beg gnus-mouse-face-prop)
  11665. beg
  11666. (or (next-single-property-change
  11667. beg gnus-mouse-face-prop nil end)
  11668. beg)))
  11669. (to
  11670. (if (= from end)
  11671. (- from 2)
  11672. (or (next-single-property-change
  11673. from gnus-mouse-face-prop nil end)
  11674. end))))
  11675. ;; If no mouse-face prop on line we will have to = from = end,
  11676. ;; so we highlight the entire line instead.
  11677. (when (= (+ to 2) from)
  11678. (setq from beg)
  11679. (setq to end))
  11680. (if gnus-newsgroup-selected-overlay
  11681. ;; Move old overlay.
  11682. (move-overlay
  11683. gnus-newsgroup-selected-overlay from to (current-buffer))
  11684. ;; Create new overlay.
  11685. (overlay-put
  11686. (setq gnus-newsgroup-selected-overlay (make-overlay from to))
  11687. 'face gnus-summary-selected-face))))))
  11688. (defvar gnus-summary-highlight-line-cached nil)
  11689. (defvar gnus-summary-highlight-line-trigger nil)
  11690. (defun gnus-summary-highlight-line-0 ()
  11691. (if (and (eq gnus-summary-highlight-line-trigger
  11692. gnus-summary-highlight)
  11693. gnus-summary-highlight-line-cached)
  11694. gnus-summary-highlight-line-cached
  11695. (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
  11696. gnus-summary-highlight-line-cached
  11697. (let* ((cond (list 'cond))
  11698. (c cond)
  11699. (list gnus-summary-highlight))
  11700. (while list
  11701. (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
  11702. nil))
  11703. (setq c (cdr c)
  11704. list (cdr list)))
  11705. (gnus-byte-compile (list 'lambda nil cond))))))
  11706. (defun gnus-summary-highlight-line ()
  11707. "Highlight current line according to `gnus-summary-highlight'."
  11708. (let* ((beg (point-at-bol))
  11709. (article (or (gnus-summary-article-number) gnus-current-article))
  11710. (score (or (cdr (assq article
  11711. gnus-newsgroup-scored))
  11712. gnus-summary-default-score 0))
  11713. (mark (or (gnus-summary-article-mark) gnus-unread-mark))
  11714. (inhibit-read-only t)
  11715. (default gnus-summary-default-score)
  11716. (default-high gnus-summary-default-high-score)
  11717. (default-low gnus-summary-default-low-score)
  11718. (uncached (and gnus-summary-use-undownloaded-faces
  11719. (memq article gnus-newsgroup-undownloaded)
  11720. (not (memq article gnus-newsgroup-cached)))))
  11721. (let ((face (funcall (gnus-summary-highlight-line-0))))
  11722. (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
  11723. (gnus-put-text-property-excluding-characters-with-faces
  11724. beg (point-at-eol) 'face
  11725. (setq face (if (boundp face) (symbol-value face) face)))
  11726. (when gnus-summary-highlight-line-function
  11727. (funcall gnus-summary-highlight-line-function article face))))))
  11728. (defun gnus-update-read-articles (group unread &optional compute)
  11729. "Update the list of read articles in GROUP.
  11730. UNREAD is a sorted list."
  11731. (let ((active (or gnus-newsgroup-active (gnus-active group)))
  11732. (info (gnus-get-info group))
  11733. (prev 1)
  11734. read)
  11735. (if (or (not info) (not active))
  11736. ;; There is no info on this group if it was, in fact,
  11737. ;; killed. Gnus stores no information on killed groups, so
  11738. ;; there's nothing to be done.
  11739. ;; One could store the information somewhere temporarily,
  11740. ;; perhaps... Hmmm...
  11741. ()
  11742. ;; Remove any negative articles numbers.
  11743. (while (and unread (< (car unread) 0))
  11744. (setq unread (cdr unread)))
  11745. ;; Remove any expired article numbers
  11746. (while (and unread (< (car unread) (car active)))
  11747. (setq unread (cdr unread)))
  11748. ;; Compute the ranges of read articles by looking at the list of
  11749. ;; unread articles.
  11750. (while unread
  11751. (when (/= (car unread) prev)
  11752. (push (if (= prev (1- (car unread))) prev
  11753. (cons prev (1- (car unread))))
  11754. read))
  11755. (setq prev (1+ (car unread)))
  11756. (setq unread (cdr unread)))
  11757. (when (<= prev (cdr active))
  11758. (push (cons prev (cdr active)) read))
  11759. (setq read (if (> (length read) 1) (nreverse read) read))
  11760. (if compute
  11761. read
  11762. (save-excursion
  11763. (let (setmarkundo)
  11764. ;; Propagate the read marks to the backend.
  11765. (when (and (gnus-method-option-p
  11766. (gnus-find-method-for-group group)
  11767. 'server-marks)
  11768. (gnus-check-backend-function 'request-set-mark group))
  11769. (let ((del (gnus-remove-from-range (gnus-info-read info) read))
  11770. (add (gnus-remove-from-range read (gnus-info-read info))))
  11771. (when (or add del)
  11772. (unless (gnus-check-group group)
  11773. (error "Can't open server for %s" group))
  11774. (gnus-request-set-mark
  11775. group (delq nil (list (if add (list add 'add '(read)))
  11776. (if del (list del 'del '(read))))))
  11777. (setq setmarkundo
  11778. `(gnus-request-set-mark
  11779. ,group
  11780. ',(delq nil (list
  11781. (if del (list del 'add '(read)))
  11782. (if add (list add 'del '(read))))))))))
  11783. (set-buffer gnus-group-buffer)
  11784. (gnus-undo-register
  11785. `(progn
  11786. (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
  11787. (gnus-info-set-read ',info ',(gnus-info-read info))
  11788. (gnus-get-unread-articles-in-group ',info
  11789. (gnus-active ,group))
  11790. (gnus-group-update-group ,group t)
  11791. ,setmarkundo))))
  11792. ;; Enter this list into the group info.
  11793. (gnus-info-set-read info read)
  11794. ;; Set the number of unread articles in gnus-newsrc-hashtb.
  11795. (gnus-get-unread-articles-in-group info (gnus-active group))
  11796. t))))
  11797. (defun gnus-offer-save-summaries ()
  11798. "Offer to save all active summary buffers."
  11799. (let (buffers)
  11800. ;; Go through all buffers and find all summaries.
  11801. (dolist (buffer (buffer-list))
  11802. (when (and (setq buffer (buffer-name buffer))
  11803. (string-match "Summary" buffer)
  11804. (with-current-buffer buffer
  11805. ;; We check that this is, indeed, a summary buffer.
  11806. (and (derived-mode-p 'gnus-summary-mode)
  11807. ;; Also make sure this isn't bogus.
  11808. gnus-newsgroup-prepared
  11809. ;; Also make sure that this isn't a
  11810. ;; dead summary buffer.
  11811. (not gnus-dead-summary-mode))))
  11812. (push buffer buffers)))
  11813. ;; Go through all these summary buffers and offer to save them.
  11814. (when buffers
  11815. (save-excursion
  11816. (if (eq gnus-interactive-exit 'quiet)
  11817. (dolist (buffer buffers)
  11818. (switch-to-buffer buffer)
  11819. (gnus-summary-exit))
  11820. (map-y-or-n-p
  11821. "Update summary buffer %s? "
  11822. (lambda (buf)
  11823. (switch-to-buffer buf)
  11824. (gnus-summary-exit))
  11825. buffers))))))
  11826. (defun gnus-summary-setup-default-charset ()
  11827. "Setup newsgroup default charset."
  11828. (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
  11829. (setq gnus-newsgroup-charset nil)
  11830. (let* ((ignored-charsets
  11831. (or gnus-newsgroup-ephemeral-ignored-charsets
  11832. (append
  11833. (and gnus-newsgroup-name
  11834. (gnus-parameter-ignored-charsets gnus-newsgroup-name))
  11835. gnus-newsgroup-ignored-charsets))))
  11836. (setq gnus-newsgroup-charset
  11837. (or gnus-newsgroup-ephemeral-charset
  11838. (and gnus-newsgroup-name
  11839. (gnus-parameter-charset gnus-newsgroup-name))
  11840. gnus-default-charset))
  11841. (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
  11842. ignored-charsets))))
  11843. ;;;
  11844. ;;; Mime Commands
  11845. ;;;
  11846. (defun gnus-summary-display-buttonized (&optional show-all-parts)
  11847. "Display the current article buffer fully MIME-buttonized.
  11848. If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
  11849. treated as multipart/mixed."
  11850. (interactive "P")
  11851. (require 'gnus-art)
  11852. (let ((gnus-unbuttonized-mime-types nil)
  11853. (gnus-mime-display-multipart-as-mixed show-all-parts))
  11854. (gnus-summary-show-article)))
  11855. (defun gnus-summary-repair-multipart (article)
  11856. "Add a Content-Type header to a multipart article without one."
  11857. (interactive (list (gnus-summary-article-number)))
  11858. (gnus-with-article article
  11859. (message-narrow-to-head)
  11860. (message-remove-header "Mime-Version")
  11861. (goto-char (point-max))
  11862. (insert "Mime-Version: 1.0\n")
  11863. (widen)
  11864. (when (search-forward "\n--" nil t)
  11865. (let ((separator (buffer-substring (point) (point-at-eol))))
  11866. (message-narrow-to-head)
  11867. (message-remove-header "Content-Type")
  11868. (goto-char (point-max))
  11869. (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
  11870. separator))
  11871. (widen))))
  11872. (let (gnus-mark-article-hook)
  11873. (gnus-summary-select-article t t nil article)))
  11874. (defun gnus-summary-toggle-display-buttonized ()
  11875. "Toggle the buttonizing of the article buffer."
  11876. (interactive)
  11877. (require 'gnus-art)
  11878. (if (setq gnus-inhibit-mime-unbuttonizing
  11879. (not gnus-inhibit-mime-unbuttonizing))
  11880. (let ((gnus-unbuttonized-mime-types nil))
  11881. (gnus-summary-show-article))
  11882. (gnus-summary-show-article)))
  11883. ;;;
  11884. ;;; Generic summary marking commands
  11885. ;;;
  11886. (defvar gnus-summary-marking-alist
  11887. '((read gnus-del-mark "d")
  11888. (unread gnus-unread-mark "u")
  11889. (ticked gnus-ticked-mark "!")
  11890. (dormant gnus-dormant-mark "?")
  11891. (expirable gnus-expirable-mark "e"))
  11892. "An alist of names/marks/keystrokes.")
  11893. (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
  11894. (defvar gnus-summary-mark-map)
  11895. (defun gnus-summary-make-all-marking-commands ()
  11896. (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
  11897. (dolist (elem gnus-summary-marking-alist)
  11898. (apply 'gnus-summary-make-marking-command elem)))
  11899. (defun gnus-summary-make-marking-command (name mark keystroke)
  11900. (let ((map (make-sparse-keymap)))
  11901. (define-key gnus-summary-generic-mark-map keystroke map)
  11902. (dolist (lway `((next "next" next nil "n")
  11903. (next-unread "next unread" next t "N")
  11904. (prev "previous" prev nil "p")
  11905. (prev-unread "previous unread" prev t "P")
  11906. (nomove "" nil nil ,keystroke)))
  11907. (let ((func (gnus-summary-make-marking-command-1
  11908. mark (car lway) lway name)))
  11909. (setq func (eval func))
  11910. (define-key map (nth 4 lway) func)))))
  11911. (defun gnus-summary-make-marking-command-1 (mark way lway name)
  11912. `(defun ,(intern
  11913. (format "gnus-summary-put-mark-as-%s%s"
  11914. name (if (eq way 'nomove)
  11915. ""
  11916. (concat "-" (symbol-name way)))))
  11917. (n)
  11918. ,(format
  11919. "Mark the current article as %s%s.
  11920. If N, the prefix, then repeat N times.
  11921. If N is negative, move in reverse order.
  11922. The difference between N and the actual number of articles marked is
  11923. returned."
  11924. name (cadr lway))
  11925. (interactive "p")
  11926. (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
  11927. (defun gnus-summary-generic-mark (n mark move unread)
  11928. "Mark N articles with MARK."
  11929. (unless (derived-mode-p 'gnus-summary-mode)
  11930. (error "This command can only be used in the summary buffer"))
  11931. (gnus-summary-show-thread)
  11932. (let ((nummove
  11933. (cond
  11934. ((eq move 'next) 1)
  11935. ((eq move 'prev) -1)
  11936. (t 0))))
  11937. (if (zerop nummove)
  11938. (setq n 1)
  11939. (when (< n 0)
  11940. (setq n (abs n)
  11941. nummove (* -1 nummove))))
  11942. (while (and (> n 0)
  11943. (gnus-summary-mark-article nil mark)
  11944. (zerop (gnus-summary-next-subject nummove unread t)))
  11945. (setq n (1- n)))
  11946. (when (/= 0 n)
  11947. (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
  11948. (gnus-summary-recenter)
  11949. (gnus-summary-position-point)
  11950. (gnus-set-mode-line 'summary)
  11951. n))
  11952. (defun gnus-summary-insert-articles (articles)
  11953. (when (setq articles
  11954. (gnus-sorted-difference articles
  11955. (mapcar (lambda (h)
  11956. (mail-header-number h))
  11957. gnus-newsgroup-headers)))
  11958. (setq gnus-newsgroup-headers
  11959. (gnus-merge 'list
  11960. gnus-newsgroup-headers
  11961. (gnus-fetch-headers articles nil t)
  11962. 'gnus-article-sort-by-number))
  11963. (setq gnus-newsgroup-articles
  11964. (gnus-sorted-nunion gnus-newsgroup-articles articles))
  11965. ;; Suppress duplicates?
  11966. (when gnus-suppress-duplicates
  11967. (gnus-dup-suppress-articles))
  11968. (if (and gnus-fetch-old-headers
  11969. (eq gnus-headers-retrieved-by 'nov))
  11970. ;; We might want to build some more threads first.
  11971. (if (eq gnus-fetch-old-headers 'invisible)
  11972. (gnus-build-all-threads)
  11973. (gnus-build-old-threads))
  11974. ;; Mark the inserted articles that are unread as unread.
  11975. (setq gnus-newsgroup-unreads
  11976. (gnus-sorted-nunion
  11977. gnus-newsgroup-unreads
  11978. (gnus-sorted-nintersection
  11979. (gnus-list-of-unread-articles gnus-newsgroup-name)
  11980. articles)))
  11981. ;; Mark the inserted articles as selected so that the information
  11982. ;; of the marks having been changed by a user may be updated when
  11983. ;; exiting this group. See `gnus-summary-update-info'.
  11984. (dolist (art articles)
  11985. (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
  11986. ;; Let the Gnus agent mark articles as read.
  11987. (when gnus-agent
  11988. (gnus-agent-get-undownloaded-list))
  11989. ;; Remove list identifiers from subject
  11990. (gnus-summary-remove-list-identifiers)
  11991. ;; First and last article in this newsgroup.
  11992. (when gnus-newsgroup-headers
  11993. (setq gnus-newsgroup-begin
  11994. (mail-header-number (car gnus-newsgroup-headers))
  11995. gnus-newsgroup-end
  11996. (mail-header-number
  11997. (gnus-last-element gnus-newsgroup-headers))))
  11998. (when gnus-use-scoring
  11999. (gnus-possibly-score-headers))))
  12000. (defun gnus-summary-insert-old-articles (&optional all)
  12001. "Insert all old articles in this group.
  12002. If ALL is non-nil, already read articles become readable.
  12003. If ALL is a number, fetch this number of articles."
  12004. (interactive "P")
  12005. (prog1
  12006. (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
  12007. older len)
  12008. (setq older
  12009. ;; Some nntp servers lie about their active range. When
  12010. ;; this happens, the active range can be in the millions.
  12011. ;; Use a compressed range to avoid creating a huge list.
  12012. (gnus-range-difference
  12013. (gnus-range-difference (list gnus-newsgroup-active) old)
  12014. gnus-newsgroup-unexist))
  12015. (setq len (gnus-range-length older))
  12016. (cond
  12017. ((null older) nil)
  12018. ((numberp all)
  12019. (if (< all len)
  12020. (let ((older-range (nreverse older)))
  12021. (setq older nil)
  12022. (while (> all 0)
  12023. (let* ((r (pop older-range))
  12024. (min (if (numberp r) r (car r)))
  12025. (max (if (numberp r) r (cdr r))))
  12026. (while (and (<= min max)
  12027. (> all 0))
  12028. (push max older)
  12029. (setq all (1- all)
  12030. max (1- max))))))
  12031. (setq older (gnus-uncompress-range older))))
  12032. (all
  12033. (setq older (gnus-uncompress-range older)))
  12034. (t
  12035. (when (and (numberp gnus-large-newsgroup)
  12036. (> len gnus-large-newsgroup))
  12037. (let* ((cursor-in-echo-area nil)
  12038. (initial (gnus-parameter-large-newsgroup-initial
  12039. gnus-newsgroup-name))
  12040. (input
  12041. (read-string
  12042. (format
  12043. "How many articles from %s (%s %d): "
  12044. (gnus-group-decoded-name gnus-newsgroup-name)
  12045. (if initial "max" "default")
  12046. len)
  12047. nil nil
  12048. (and initial
  12049. (number-to-string initial)))))
  12050. (unless (string-match "^[ \t]*$" input)
  12051. (setq all (string-to-number input))
  12052. (if (< all len)
  12053. (let ((older-range (nreverse older)))
  12054. (setq older nil)
  12055. (while (> all 0)
  12056. (let* ((r (pop older-range))
  12057. (min (if (numberp r) r (car r)))
  12058. (max (if (numberp r) r (cdr r))))
  12059. (while (and (<= min max)
  12060. (> all 0))
  12061. (push max older)
  12062. (setq all (1- all)
  12063. max (1- max))))))))))
  12064. (setq older (gnus-uncompress-range older))))
  12065. (if (not older)
  12066. (message "No old news.")
  12067. (gnus-summary-insert-articles older)
  12068. (gnus-summary-limit (gnus-sorted-nunion old older))))
  12069. (gnus-summary-position-point)))
  12070. (defun gnus-summary-insert-new-articles ()
  12071. "Insert all new articles in this group."
  12072. (interactive)
  12073. (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
  12074. (old-high gnus-newsgroup-highest)
  12075. (nnmail-fetched-sources (list t))
  12076. (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
  12077. i new)
  12078. (unless new-active
  12079. (error "Couldn't fetch new data"))
  12080. (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
  12081. (setq i (cdr gnus-newsgroup-active)
  12082. gnus-newsgroup-highest i)
  12083. (while (> i old-high)
  12084. (push i new)
  12085. (decf i))
  12086. (if (not new)
  12087. (message "No gnus is bad news")
  12088. (gnus-summary-insert-articles new)
  12089. (setq gnus-newsgroup-unreads
  12090. (gnus-sorted-nunion gnus-newsgroup-unreads new))
  12091. (gnus-summary-limit (gnus-sorted-nunion old new))))
  12092. (gnus-summary-position-point))
  12093. ;;; Bookmark support for Gnus.
  12094. (declare-function gnus-article-show-summary "gnus-art" ())
  12095. (declare-function bookmark-make-record-default
  12096. "bookmark" (&optional no-file no-context posn))
  12097. (declare-function bookmark-prop-get "bookmark" (bookmark prop))
  12098. (declare-function bookmark-default-handler "bookmark" (bmk))
  12099. (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
  12100. (defvar bookmark-yank-point)
  12101. (defvar bookmark-current-buffer)
  12102. (defun gnus-summary-bookmark-make-record ()
  12103. "Make a bookmark entry for a Gnus summary buffer."
  12104. (let (pos buf)
  12105. (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
  12106. (save-restriction ; FIXME is it necessary to widen?
  12107. (widen) (setq pos (point))) ; Set position in gnus-article buffer.
  12108. (setq buf "art") ; We are recording bookmark from article buffer.
  12109. (setq bookmark-yank-point (point))
  12110. (setq bookmark-current-buffer (current-buffer))
  12111. (gnus-article-show-summary)) ; Go back in summary buffer.
  12112. ;; We are now recording bookmark from summary buffer.
  12113. (unless buf (setq buf "sum"))
  12114. (let* ((subject (elt (gnus-summary-article-header) 1))
  12115. (grp (car gnus-article-current))
  12116. (art (cdr gnus-article-current))
  12117. (head (gnus-summary-article-header art))
  12118. (id (mail-header-id head)))
  12119. `(,subject
  12120. ,@(condition-case nil
  12121. (bookmark-make-record-default 'no-file 'no-context pos)
  12122. (wrong-number-of-arguments
  12123. (bookmark-make-record-default 'point-only)))
  12124. (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
  12125. (group . ,grp) (article . ,art)
  12126. (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
  12127. ;;;###autoload
  12128. (defun gnus-summary-bookmark-jump (bookmark)
  12129. "Handler function for record returned by `gnus-summary-bookmark-make-record'.
  12130. BOOKMARK is a bookmark name or a bookmark record."
  12131. (let ((group (bookmark-prop-get bookmark 'group))
  12132. (article (bookmark-prop-get bookmark 'article))
  12133. (id (bookmark-prop-get bookmark 'message-id))
  12134. (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
  12135. (gnus-fetch-group group (list article))
  12136. (gnus-summary-insert-cached-articles)
  12137. (gnus-summary-goto-article id nil 'force)
  12138. ;; FIXME we have to wait article buffer is ready (only large buffer)
  12139. ;; Is there a better solution to know that?
  12140. ;; If we don't wait `bookmark-default-handler' will have no chance
  12141. ;; to set position. However there is no error, just wrong pos.
  12142. (sit-for 1)
  12143. (when (string= buf "Gnus-art")
  12144. (other-window 1))
  12145. (bookmark-default-handler
  12146. `(""
  12147. (buffer . ,(current-buffer))
  12148. . ,(bookmark-get-bookmark-record bookmark)))))
  12149. (gnus-summary-make-all-marking-commands)
  12150. (gnus-ems-redefine)
  12151. (provide 'gnus-sum)
  12152. (run-hooks 'gnus-sum-load-hook)
  12153. ;; Local Variables:
  12154. ;; coding: utf-8
  12155. ;; End:
  12156. ;;; gnus-sum.el ends here