gnus-sum.el 472 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126
  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. "m" gnus-summary-move-article
  1931. "r" gnus-summary-respool-article
  1932. "w" gnus-summary-edit-article
  1933. "c" gnus-summary-copy-article
  1934. "B" gnus-summary-crosspost-article
  1935. "q" gnus-summary-respool-query
  1936. "t" gnus-summary-respool-trace
  1937. "i" gnus-summary-import-article
  1938. "I" gnus-summary-create-article
  1939. "p" gnus-summary-article-posted-p)
  1940. (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
  1941. "o" gnus-summary-save-article
  1942. "m" gnus-summary-save-article-mail
  1943. "F" gnus-summary-write-article-file
  1944. "r" gnus-summary-save-article-rmail
  1945. "f" gnus-summary-save-article-file
  1946. "b" gnus-summary-save-article-body-file
  1947. "B" gnus-summary-write-article-body-file
  1948. "h" gnus-summary-save-article-folder
  1949. "v" gnus-summary-save-article-vm
  1950. "p" gnus-summary-pipe-output
  1951. "P" gnus-summary-muttprint)
  1952. (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
  1953. "b" gnus-summary-display-buttonized
  1954. "m" gnus-summary-repair-multipart
  1955. "v" gnus-article-view-part
  1956. "o" gnus-article-save-part
  1957. "O" gnus-article-save-part-and-strip
  1958. "r" gnus-article-replace-part
  1959. "d" gnus-article-delete-part
  1960. "t" gnus-article-view-part-as-type
  1961. "j" gnus-article-jump-to-part
  1962. "c" gnus-article-copy-part
  1963. "C" gnus-article-view-part-as-charset
  1964. "e" gnus-article-view-part-externally
  1965. "H" gnus-article-browse-html-article
  1966. "E" gnus-article-encrypt-body
  1967. "i" gnus-article-inline-part
  1968. "|" gnus-article-pipe-part)
  1969. (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
  1970. "p" gnus-summary-mark-as-processable
  1971. "u" gnus-summary-unmark-as-processable
  1972. "U" gnus-summary-unmark-all-processable
  1973. "v" gnus-uu-mark-over
  1974. "s" gnus-uu-mark-series
  1975. "r" gnus-uu-mark-region
  1976. "g" gnus-uu-unmark-region
  1977. "R" gnus-uu-mark-by-regexp
  1978. "G" gnus-uu-unmark-by-regexp
  1979. "t" gnus-uu-mark-thread
  1980. "T" gnus-uu-unmark-thread
  1981. "a" gnus-uu-mark-all
  1982. "b" gnus-uu-mark-buffer
  1983. "S" gnus-uu-mark-sparse
  1984. "k" gnus-summary-kill-process-mark
  1985. "y" gnus-summary-yank-process-mark
  1986. "w" gnus-summary-save-process-mark
  1987. "i" gnus-uu-invert-processable)
  1988. (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
  1989. ;;"x" gnus-uu-extract-any
  1990. "m" gnus-summary-save-parts
  1991. "u" gnus-uu-decode-uu
  1992. "U" gnus-uu-decode-uu-and-save
  1993. "s" gnus-uu-decode-unshar
  1994. "S" gnus-uu-decode-unshar-and-save
  1995. "o" gnus-uu-decode-save
  1996. "O" gnus-uu-decode-save
  1997. "b" gnus-uu-decode-binhex
  1998. "B" gnus-uu-decode-binhex
  1999. "Y" gnus-uu-decode-yenc
  2000. "p" gnus-uu-decode-postscript
  2001. "P" gnus-uu-decode-postscript-and-save)
  2002. (gnus-define-keys
  2003. (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
  2004. "u" gnus-uu-decode-uu-view
  2005. "U" gnus-uu-decode-uu-and-save-view
  2006. "s" gnus-uu-decode-unshar-view
  2007. "S" gnus-uu-decode-unshar-and-save-view
  2008. "o" gnus-uu-decode-save-view
  2009. "O" gnus-uu-decode-save-view
  2010. "b" gnus-uu-decode-binhex-view
  2011. "B" gnus-uu-decode-binhex-view
  2012. "p" gnus-uu-decode-postscript-view
  2013. "P" gnus-uu-decode-postscript-and-save-view)
  2014. (defvar gnus-article-post-menu nil)
  2015. (defconst gnus-summary-menu-maxlen 20)
  2016. (defun gnus-summary-menu-split (menu)
  2017. ;; If we have lots of elements, divide them into groups of 20
  2018. ;; and make a pane (or submenu) for each one.
  2019. (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
  2020. (let ((menu menu) sublists next
  2021. (i 1))
  2022. (while menu
  2023. ;; Pull off the next gnus-summary-menu-maxlen elements
  2024. ;; and make them the next element of sublist.
  2025. (setq next (nthcdr gnus-summary-menu-maxlen menu))
  2026. (if next
  2027. (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
  2028. nil))
  2029. (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
  2030. (aref (car (last menu)) 0)) menu)
  2031. sublists))
  2032. (setq i (1+ i))
  2033. (setq menu next))
  2034. (nreverse sublists))
  2035. ;; Few elements--put them all in one pane.
  2036. menu))
  2037. (defun gnus-summary-make-menu-bar ()
  2038. (gnus-turn-off-edit-menu 'summary)
  2039. (unless (boundp 'gnus-summary-misc-menu)
  2040. (easy-menu-define
  2041. gnus-summary-kill-menu gnus-summary-mode-map ""
  2042. (cons
  2043. "Score"
  2044. (nconc
  2045. (list
  2046. ["Customize" gnus-score-customize t])
  2047. (gnus-make-score-map 'increase)
  2048. (gnus-make-score-map 'lower)
  2049. '(("Mark"
  2050. ["Kill below" gnus-summary-kill-below t]
  2051. ["Mark above" gnus-summary-mark-above t]
  2052. ["Tick above" gnus-summary-tick-above t]
  2053. ["Clear above" gnus-summary-clear-above t])
  2054. ["Current article score" gnus-summary-current-score t]
  2055. ["Current thread score" (gnus-summary-current-score 'total) t]
  2056. ["Set score" gnus-summary-set-score t]
  2057. ["Switch current score file..." gnus-score-change-score-file t]
  2058. ["Set mark below..." gnus-score-set-mark-below t]
  2059. ["Set expunge below..." gnus-score-set-expunge-below t]
  2060. ["Edit current score file" gnus-score-edit-current-scores t]
  2061. ["Edit score file..." gnus-score-edit-file t]
  2062. ["Trace score" gnus-score-find-trace t]
  2063. ["Find words" gnus-score-find-favourite-words t]
  2064. ["Rescore buffer" gnus-summary-rescore t]
  2065. ["Increase score..." gnus-summary-increase-score t]
  2066. ["Lower score..." gnus-summary-lower-score t]))))
  2067. ;; Define both the Article menu in the summary buffer and the
  2068. ;; equivalent Commands menu in the article buffer here for
  2069. ;; consistency.
  2070. (let ((innards
  2071. `(("Hide"
  2072. ["All" gnus-article-hide t]
  2073. ["Headers" gnus-article-hide-headers t]
  2074. ["Signature" gnus-article-hide-signature t]
  2075. ["Citation" gnus-article-hide-citation t]
  2076. ["List identifiers" gnus-article-hide-list-identifiers t]
  2077. ["Banner" gnus-article-strip-banner t]
  2078. ["Boring headers" gnus-article-hide-boring-headers t])
  2079. ("Highlight"
  2080. ["All" gnus-article-highlight t]
  2081. ["Headers" gnus-article-highlight-headers t]
  2082. ["Signature" gnus-article-highlight-signature t]
  2083. ["Citation" gnus-article-highlight-citation t])
  2084. ("MIME"
  2085. ["Words" gnus-article-decode-mime-words t]
  2086. ["Charset" gnus-article-decode-charset t]
  2087. ["QP" gnus-article-de-quoted-unreadable t]
  2088. ["Base64" gnus-article-de-base64-unreadable t]
  2089. ["View MIME buttons" gnus-summary-display-buttonized t]
  2090. ["View MIME buttons in header"
  2091. gnus-mime-buttonize-attachments-in-header t]
  2092. ["View all" gnus-mime-view-all-parts t]
  2093. ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
  2094. ["Encrypt body" gnus-article-encrypt-body
  2095. :active (not (gnus-group-read-only-p))
  2096. ,@(if (featurep 'xemacs) nil
  2097. '(:help "Encrypt the message body on disk"))]
  2098. ["Extract all parts..." gnus-summary-save-parts t]
  2099. ("Multipart"
  2100. ["Repair multipart" gnus-summary-repair-multipart t]
  2101. ["Pipe part..." gnus-article-pipe-part t]
  2102. ["Inline part" gnus-article-inline-part t]
  2103. ["View part as type..." gnus-article-view-part-as-type t]
  2104. ["Encrypt body" gnus-article-encrypt-body
  2105. :active (not (gnus-group-read-only-p))
  2106. ,@(if (featurep 'xemacs) nil
  2107. '(:help "Encrypt the message body on disk"))]
  2108. ["View part externally" gnus-article-view-part-externally t]
  2109. ["View HTML parts in browser" gnus-article-browse-html-article t]
  2110. ["View part with charset..." gnus-article-view-part-as-charset t]
  2111. ["Copy part" gnus-article-copy-part t]
  2112. ["Save part..." gnus-article-save-part t]
  2113. ["View part" gnus-article-view-part t]))
  2114. ("Date"
  2115. ["Local" gnus-article-date-local t]
  2116. ["ISO8601" gnus-article-date-iso8601 t]
  2117. ["UT" gnus-article-date-ut t]
  2118. ["Original" gnus-article-date-original t]
  2119. ["Lapsed" gnus-article-date-lapsed t]
  2120. ["User-defined" gnus-article-date-user t])
  2121. ("Display"
  2122. ["Display HTML images" gnus-article-show-images t]
  2123. ["Remove images" gnus-article-remove-images t]
  2124. ["Toggle smiley" gnus-treat-smiley t]
  2125. ["Show X-Face" gnus-article-display-x-face t]
  2126. ["Show picons in From" gnus-treat-from-picon t]
  2127. ["Show picons in mail headers" gnus-treat-mail-picon t]
  2128. ["Show picons in news headers" gnus-treat-newsgroups-picon t]
  2129. ["Show Gravatars in From" gnus-treat-from-gravatar t]
  2130. ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
  2131. ("View as different encoding"
  2132. ,@(gnus-summary-menu-split
  2133. (mapcar
  2134. (lambda (cs)
  2135. ;; Since easymenu under Emacs doesn't allow
  2136. ;; lambda forms for menu commands, we should
  2137. ;; provide intern'ed function symbols.
  2138. (let ((command (intern (format "\
  2139. gnus-summary-show-article-from-menu-as-charset-%s" cs))))
  2140. (fset command
  2141. `(lambda ()
  2142. (interactive)
  2143. (let ((gnus-summary-show-article-charset-alist
  2144. '((1 . ,cs))))
  2145. (gnus-summary-show-article 1))))
  2146. `[,(symbol-name cs) ,command t]))
  2147. (sort (if (fboundp 'coding-system-list)
  2148. (coding-system-list)
  2149. (mapcar 'car mm-mime-mule-charset-alist))
  2150. 'string<)))))
  2151. ("Washing"
  2152. ("Remove Blanks"
  2153. ["Leading" gnus-article-strip-leading-blank-lines t]
  2154. ["Multiple" gnus-article-strip-multiple-blank-lines t]
  2155. ["Trailing" gnus-article-remove-trailing-blank-lines t]
  2156. ["All of the above" gnus-article-strip-blank-lines t]
  2157. ["All" gnus-article-strip-all-blank-lines t]
  2158. ["Leading space" gnus-article-strip-leading-space t]
  2159. ["Trailing space" gnus-article-strip-trailing-space t]
  2160. ["Leading space in headers"
  2161. gnus-article-remove-leading-whitespace t])
  2162. ["Overstrike" gnus-article-treat-overstrike t]
  2163. ["Dumb quotes" gnus-article-treat-dumbquotes t]
  2164. ["Non-ASCII" gnus-article-treat-non-ascii t]
  2165. ["Emphasis" gnus-article-emphasize t]
  2166. ["Word wrap" gnus-article-fill-cited-article t]
  2167. ["Fill long lines" gnus-article-fill-long-lines t]
  2168. ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
  2169. ["Capitalize sentences" gnus-article-capitalize-sentences t]
  2170. ["Remove CR" gnus-article-remove-cr t]
  2171. ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
  2172. ["Base64" gnus-article-de-base64-unreadable t]
  2173. ["Rot 13" gnus-summary-caesar-message
  2174. ,@(if (featurep 'xemacs) '(t)
  2175. '(:help "\"Caesar rotate\" article by 13"))]
  2176. ["De-IDNA" gnus-summary-idna-message t]
  2177. ["Morse decode" gnus-summary-morse-message t]
  2178. ["Unix pipe..." gnus-summary-pipe-message t]
  2179. ["Add buttons" gnus-article-add-buttons t]
  2180. ["Add buttons to head" gnus-article-add-buttons-to-head t]
  2181. ["Stop page breaking" gnus-summary-stop-page-breaking t]
  2182. ["Verbose header" gnus-summary-verbose-headers t]
  2183. ["Toggle header" gnus-summary-toggle-header t]
  2184. ["Unfold headers" gnus-article-treat-unfold-headers t]
  2185. ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
  2186. ["Html" gnus-article-wash-html t]
  2187. ["Unsplit URLs" gnus-article-unsplit-urls t]
  2188. ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
  2189. ["Decode HZ" gnus-article-decode-HZ t]
  2190. ["ANSI sequences" gnus-article-treat-ansi-sequences t]
  2191. ("(Outlook) Deuglify"
  2192. ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
  2193. ["Repair attribution" gnus-article-outlook-repair-attribution t]
  2194. ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
  2195. ["Full (Outlook) deuglify"
  2196. gnus-article-outlook-deuglify-article t])
  2197. )
  2198. ("Output"
  2199. ["Save in default format..." gnus-summary-save-article
  2200. ,@(if (featurep 'xemacs) '(t)
  2201. '(:help "Save article using default method"))]
  2202. ["Save in file..." gnus-summary-save-article-file
  2203. ,@(if (featurep 'xemacs) '(t)
  2204. '(:help "Save article in file"))]
  2205. ["Save in Unix mail format..." gnus-summary-save-article-mail t]
  2206. ["Save in MH folder..." gnus-summary-save-article-folder t]
  2207. ["Save in VM folder..." gnus-summary-save-article-vm t]
  2208. ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
  2209. ["Save body in file..." gnus-summary-save-article-body-file t]
  2210. ["Pipe through a filter..." gnus-summary-pipe-output t]
  2211. ["Print with Muttprint..." gnus-summary-muttprint t]
  2212. ["Print" gnus-summary-print-article
  2213. ,@(if (featurep 'xemacs) '(t)
  2214. '(:help "Generate and print a PostScript image"))])
  2215. ("Copy, move,... (Backend)"
  2216. ,@(if (featurep 'xemacs) nil
  2217. '(:help "Copying, moving, expiring articles..."))
  2218. ["Respool article..." gnus-summary-respool-article t]
  2219. ["Move article..." gnus-summary-move-article
  2220. (gnus-check-backend-function
  2221. 'request-move-article gnus-newsgroup-name)]
  2222. ["Copy article..." gnus-summary-copy-article t]
  2223. ["Crosspost article..." gnus-summary-crosspost-article
  2224. (gnus-check-backend-function
  2225. 'request-replace-article gnus-newsgroup-name)]
  2226. ["Import file..." gnus-summary-import-article
  2227. (gnus-check-backend-function
  2228. 'request-accept-article gnus-newsgroup-name)]
  2229. ["Create article..." gnus-summary-create-article
  2230. (gnus-check-backend-function
  2231. 'request-accept-article gnus-newsgroup-name)]
  2232. ["Check if posted" gnus-summary-article-posted-p t]
  2233. ["Edit article" gnus-summary-edit-article
  2234. (not (gnus-group-read-only-p))]
  2235. ["Delete article" gnus-summary-delete-article
  2236. (gnus-check-backend-function
  2237. 'request-expire-articles gnus-newsgroup-name)]
  2238. ["Query respool" gnus-summary-respool-query t]
  2239. ["Trace respool" gnus-summary-respool-trace t]
  2240. ["Delete expirable articles" gnus-summary-expire-articles-now
  2241. (gnus-check-backend-function
  2242. 'request-expire-articles gnus-newsgroup-name)])
  2243. ("Extract"
  2244. ["Uudecode" gnus-uu-decode-uu
  2245. ,@(if (featurep 'xemacs) '(t)
  2246. '(:help "Decode uuencoded article(s)"))]
  2247. ["Uudecode and save" gnus-uu-decode-uu-and-save t]
  2248. ["Unshar" gnus-uu-decode-unshar t]
  2249. ["Unshar and save" gnus-uu-decode-unshar-and-save t]
  2250. ["Save" gnus-uu-decode-save t]
  2251. ["Binhex" gnus-uu-decode-binhex t]
  2252. ["PostScript" gnus-uu-decode-postscript t]
  2253. ["All MIME parts" gnus-summary-save-parts t])
  2254. ("Cache"
  2255. ["Enter article" gnus-cache-enter-article t]
  2256. ["Remove article" gnus-cache-remove-article t])
  2257. ["Translate" gnus-article-babel t]
  2258. ["Select article buffer" gnus-summary-select-article-buffer t]
  2259. ["Make article buffer sticky" gnus-sticky-article t]
  2260. ["Enter digest buffer" gnus-summary-enter-digest-group t]
  2261. ["Isearch article..." gnus-summary-isearch-article t]
  2262. ["Beginning of the article" gnus-summary-beginning-of-article t]
  2263. ["End of the article" gnus-summary-end-of-article t]
  2264. ["Fetch parent of article" gnus-summary-refer-parent-article t]
  2265. ["Fetch referenced articles" gnus-summary-refer-references t]
  2266. ["Fetch current thread" gnus-summary-refer-thread t]
  2267. ["Fetch article with id..." gnus-summary-refer-article t]
  2268. ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
  2269. ["Redisplay" gnus-summary-show-article t]
  2270. ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
  2271. (easy-menu-define
  2272. gnus-summary-article-menu gnus-summary-mode-map ""
  2273. (cons "Article" innards))
  2274. (if (not (keymapp gnus-summary-article-menu))
  2275. (easy-menu-define
  2276. gnus-article-commands-menu gnus-article-mode-map ""
  2277. (cons "Commands" innards))
  2278. ;; in Emacs, don't share menu.
  2279. (setq gnus-article-commands-menu
  2280. (copy-keymap gnus-summary-article-menu))
  2281. (define-key gnus-article-mode-map [menu-bar commands]
  2282. (cons "Commands" gnus-article-commands-menu))))
  2283. (easy-menu-define
  2284. gnus-summary-thread-menu gnus-summary-mode-map ""
  2285. '("Threads"
  2286. ["Find all messages in thread" gnus-summary-refer-thread t]
  2287. ["Toggle threading" gnus-summary-toggle-threads t]
  2288. ["Hide threads" gnus-summary-hide-all-threads t]
  2289. ["Show threads" gnus-summary-show-all-threads t]
  2290. ["Hide thread" gnus-summary-hide-thread t]
  2291. ["Show thread" gnus-summary-show-thread t]
  2292. ["Go to next thread" gnus-summary-next-thread t]
  2293. ["Go to previous thread" gnus-summary-prev-thread t]
  2294. ["Go down thread" gnus-summary-down-thread t]
  2295. ["Go up thread" gnus-summary-up-thread t]
  2296. ["Top of thread" gnus-summary-top-thread t]
  2297. ["Mark thread as read" gnus-summary-kill-thread t]
  2298. ["Mark thread as expired" gnus-summary-expire-thread t]
  2299. ["Lower thread score" gnus-summary-lower-thread t]
  2300. ["Raise thread score" gnus-summary-raise-thread t]
  2301. ["Rethread current" gnus-summary-rethread-current t]))
  2302. (easy-menu-define
  2303. gnus-summary-post-menu gnus-summary-mode-map ""
  2304. `("Post"
  2305. ["Send a message (mail or news)" gnus-summary-post-news
  2306. ,@(if (featurep 'xemacs) '(t)
  2307. '(:help "Compose a new message (mail or news)"))]
  2308. ["Followup" gnus-summary-followup
  2309. ,@(if (featurep 'xemacs) '(t)
  2310. '(:help "Post followup to this article"))]
  2311. ["Followup and yank" gnus-summary-followup-with-original
  2312. ,@(if (featurep 'xemacs) '(t)
  2313. '(:help "Post followup to this article, quoting its contents"))]
  2314. ["Supersede article" gnus-summary-supersede-article t]
  2315. ["Cancel article" gnus-summary-cancel-article
  2316. ,@(if (featurep 'xemacs) '(t)
  2317. '(:help "Cancel an article you posted"))]
  2318. ["Reply" gnus-summary-reply t]
  2319. ["Reply and yank" gnus-summary-reply-with-original t]
  2320. ["Wide reply" gnus-summary-wide-reply t]
  2321. ["Wide reply and yank" gnus-summary-wide-reply-with-original
  2322. ,@(if (featurep 'xemacs) '(t)
  2323. '(:help "Mail a reply, quoting this article"))]
  2324. ["Very wide reply" gnus-summary-very-wide-reply t]
  2325. ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
  2326. ,@(if (featurep 'xemacs) '(t)
  2327. '(:help "Mail a very wide reply, quoting this article"))]
  2328. ["Mail forward" gnus-summary-mail-forward t]
  2329. ["Post forward" gnus-summary-post-forward t]
  2330. ["Digest and mail" gnus-uu-digest-mail-forward t]
  2331. ["Digest and post" gnus-uu-digest-post-forward t]
  2332. ["Resend message" gnus-summary-resend-message t]
  2333. ["Resend message edit" gnus-summary-resend-message-edit t]
  2334. ["Send bounced mail" gnus-summary-resend-bounced-mail t]
  2335. ["Send a mail" gnus-summary-mail-other-window t]
  2336. ["Create a local message" gnus-summary-news-other-window t]
  2337. ["Uuencode and post" gnus-uu-post-news
  2338. ,@(if (featurep 'xemacs) '(t)
  2339. '(:help "Post a uuencoded article"))]
  2340. ["Followup via news" gnus-summary-followup-to-mail t]
  2341. ["Followup via news and yank"
  2342. gnus-summary-followup-to-mail-with-original t]
  2343. ["Strip signature on reply"
  2344. (lambda ()
  2345. (interactive)
  2346. (if (not (memq message-cite-function
  2347. '(message-cite-original-without-signature
  2348. message-cite-original)))
  2349. ;; Stupid workaround for XEmacs not honoring :visible.
  2350. (message "Can't toggle this value of `message-cite-function'")
  2351. (setq message-cite-function
  2352. (if (eq message-cite-function
  2353. 'message-cite-original-without-signature)
  2354. 'message-cite-original
  2355. 'message-cite-original-without-signature))))
  2356. ;; XEmacs barfs on :visible.
  2357. ,@(if (featurep 'xemacs) nil
  2358. '(:visible (memq message-cite-function
  2359. '(message-cite-original-without-signature
  2360. message-cite-original))))
  2361. :style toggle
  2362. :selected (eq message-cite-function
  2363. 'message-cite-original-without-signature)
  2364. ,@(if (featurep 'xemacs) nil
  2365. '(:help "Strip signature from cited article when replying."))]
  2366. ;;("Draft"
  2367. ;;["Send" gnus-summary-send-draft t]
  2368. ;;["Send bounced" gnus-resend-bounced-mail t])
  2369. ))
  2370. (cond
  2371. ((not (keymapp gnus-summary-post-menu))
  2372. (setq gnus-article-post-menu gnus-summary-post-menu))
  2373. ((not gnus-article-post-menu)
  2374. ;; Don't share post menu.
  2375. (setq gnus-article-post-menu
  2376. (copy-keymap gnus-summary-post-menu))))
  2377. (define-key gnus-article-mode-map [menu-bar post]
  2378. (cons "Post" gnus-article-post-menu))
  2379. (easy-menu-define
  2380. gnus-summary-misc-menu gnus-summary-mode-map ""
  2381. `("Gnus"
  2382. ("Mark Read"
  2383. ["Mark as read" gnus-summary-mark-as-read-forward t]
  2384. ["Mark same subject and select"
  2385. gnus-summary-kill-same-subject-and-select t]
  2386. ["Mark same subject" gnus-summary-kill-same-subject t]
  2387. ["Catchup" gnus-summary-catchup
  2388. ,@(if (featurep 'xemacs) '(t)
  2389. '(:help "Mark unread articles in this group as read"))]
  2390. ["Catchup all" gnus-summary-catchup-all t]
  2391. ["Catchup to here" gnus-summary-catchup-to-here t]
  2392. ["Catchup from here" gnus-summary-catchup-from-here t]
  2393. ["Catchup region" gnus-summary-mark-region-as-read
  2394. (gnus-mark-active-p)]
  2395. ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
  2396. ("Mark Various"
  2397. ["Tick" gnus-summary-tick-article-forward t]
  2398. ["Mark as dormant" gnus-summary-mark-as-dormant t]
  2399. ["Remove marks" gnus-summary-clear-mark-forward t]
  2400. ["Set expirable mark" gnus-summary-mark-as-expirable t]
  2401. ["Set bookmark" gnus-summary-set-bookmark t]
  2402. ["Remove bookmark" gnus-summary-remove-bookmark t])
  2403. ("Limit to"
  2404. ["Marks..." gnus-summary-limit-to-marks t]
  2405. ["Subject..." gnus-summary-limit-to-subject t]
  2406. ["Author..." gnus-summary-limit-to-author t]
  2407. ["Recipient..." gnus-summary-limit-to-recipient t]
  2408. ["Address..." gnus-summary-limit-to-address t]
  2409. ["Age..." gnus-summary-limit-to-age t]
  2410. ["Extra..." gnus-summary-limit-to-extra t]
  2411. ["Score..." gnus-summary-limit-to-score t]
  2412. ["Display Predicate" gnus-summary-limit-to-display-predicate t]
  2413. ["Unread" gnus-summary-limit-to-unread t]
  2414. ["Unseen" gnus-summary-limit-to-unseen t]
  2415. ["Singletons" gnus-summary-limit-to-singletons t]
  2416. ["Replied" gnus-summary-limit-to-replied t]
  2417. ["Non-dormant" gnus-summary-limit-exclude-dormant t]
  2418. ["Next or process marked articles" gnus-summary-limit-to-articles t]
  2419. ["Pop limit" gnus-summary-pop-limit t]
  2420. ["Show dormant" gnus-summary-limit-include-dormant t]
  2421. ["Hide childless dormant"
  2422. gnus-summary-limit-exclude-childless-dormant t]
  2423. ;;["Hide thread" gnus-summary-limit-exclude-thread t]
  2424. ["Hide marked" gnus-summary-limit-exclude-marks t]
  2425. ["Show expunged" gnus-summary-limit-include-expunged t])
  2426. ("Process Mark"
  2427. ["Set mark" gnus-summary-mark-as-processable t]
  2428. ["Remove mark" gnus-summary-unmark-as-processable t]
  2429. ["Remove all marks" gnus-summary-unmark-all-processable t]
  2430. ["Invert marks" gnus-uu-invert-processable t]
  2431. ["Mark above" gnus-uu-mark-over t]
  2432. ["Mark series" gnus-uu-mark-series t]
  2433. ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
  2434. ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
  2435. ["Mark by regexp..." gnus-uu-mark-by-regexp t]
  2436. ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
  2437. ["Mark all" gnus-uu-mark-all t]
  2438. ["Mark buffer" gnus-uu-mark-buffer t]
  2439. ["Mark sparse" gnus-uu-mark-sparse t]
  2440. ["Mark thread" gnus-uu-mark-thread t]
  2441. ["Unmark thread" gnus-uu-unmark-thread t]
  2442. ("Process Mark Sets"
  2443. ["Kill" gnus-summary-kill-process-mark t]
  2444. ["Yank" gnus-summary-yank-process-mark
  2445. gnus-newsgroup-process-stack]
  2446. ["Save" gnus-summary-save-process-mark t]
  2447. ["Run command on marked..." gnus-summary-universal-argument t]))
  2448. ("Registry Marks")
  2449. ("Scroll article"
  2450. ["Page forward" gnus-summary-next-page
  2451. ,@(if (featurep 'xemacs) '(t)
  2452. '(:help "Show next page of article"))]
  2453. ["Page backward" gnus-summary-prev-page
  2454. ,@(if (featurep 'xemacs) '(t)
  2455. '(:help "Show previous page of article"))]
  2456. ["Line forward" gnus-summary-scroll-up t])
  2457. ("Move"
  2458. ["Next unread article" gnus-summary-next-unread-article t]
  2459. ["Previous unread article" gnus-summary-prev-unread-article t]
  2460. ["Next article" gnus-summary-next-article t]
  2461. ["Previous article" gnus-summary-prev-article t]
  2462. ["Next unread subject" gnus-summary-next-unread-subject t]
  2463. ["Previous unread subject" gnus-summary-prev-unread-subject t]
  2464. ["Next article same subject" gnus-summary-next-same-subject t]
  2465. ["Previous article same subject" gnus-summary-prev-same-subject t]
  2466. ["First unread article" gnus-summary-first-unread-article t]
  2467. ["Best unread article" gnus-summary-best-unread-article t]
  2468. ["Go to subject number..." gnus-summary-goto-subject t]
  2469. ["Go to article number..." gnus-summary-goto-article t]
  2470. ["Go to the last article" gnus-summary-goto-last-article t]
  2471. ["Pop article off history" gnus-summary-pop-article t])
  2472. ("Sort"
  2473. ["Sort by number" gnus-summary-sort-by-number t]
  2474. ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
  2475. ["Sort by author" gnus-summary-sort-by-author t]
  2476. ["Sort by recipient" gnus-summary-sort-by-recipient t]
  2477. ["Sort by subject" gnus-summary-sort-by-subject t]
  2478. ["Sort by date" gnus-summary-sort-by-date t]
  2479. ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
  2480. ["Sort by score" gnus-summary-sort-by-score t]
  2481. ["Sort by lines" gnus-summary-sort-by-lines t]
  2482. ["Sort by characters" gnus-summary-sort-by-chars t]
  2483. ["Randomize" gnus-summary-sort-by-random t]
  2484. ["Original sort" gnus-summary-sort-by-original t])
  2485. ("Help"
  2486. ["Describe group" gnus-summary-describe-group t]
  2487. ["Read manual" gnus-info-find-node t])
  2488. ("Modes"
  2489. ["Pick and read" gnus-pick-mode t]
  2490. ["Binary" gnus-binary-mode t])
  2491. ("Regeneration"
  2492. ["Regenerate" gnus-summary-prepare t]
  2493. ["Insert cached articles" gnus-summary-insert-cached-articles t]
  2494. ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
  2495. ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
  2496. ["Toggle threading" gnus-summary-toggle-threads t])
  2497. ["See old articles" gnus-summary-insert-old-articles t]
  2498. ["See new articles" gnus-summary-insert-new-articles t]
  2499. ["Filter articles..." gnus-summary-execute-command t]
  2500. ["Run command on articles..." gnus-summary-universal-argument t]
  2501. ["Search articles forward..." gnus-summary-search-article-forward t]
  2502. ["Search articles backward..." gnus-summary-search-article-backward t]
  2503. ["Toggle line truncation" gnus-summary-toggle-truncation t]
  2504. ["Expand window" gnus-summary-expand-window t]
  2505. ["Expire expirable articles" gnus-summary-expire-articles
  2506. (gnus-check-backend-function
  2507. 'request-expire-articles gnus-newsgroup-name)]
  2508. ["Edit local kill file" gnus-summary-edit-local-kill t]
  2509. ["Edit main kill file" gnus-summary-edit-global-kill t]
  2510. ["Edit group parameters" gnus-summary-edit-parameters t]
  2511. ["Customize group parameters" gnus-summary-customize-parameters t]
  2512. ["Send a bug report" gnus-bug t]
  2513. ("Exit"
  2514. ["Catchup and exit" gnus-summary-catchup-and-exit
  2515. ,@(if (featurep 'xemacs) '(t)
  2516. '(:help "Mark unread articles in this group as read, then exit"))]
  2517. ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
  2518. ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
  2519. ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
  2520. ["Exit group" gnus-summary-exit
  2521. ,@(if (featurep 'xemacs) '(t)
  2522. '(:help "Exit current group, return to group selection mode"))]
  2523. ["Exit group without updating" gnus-summary-exit-no-update t]
  2524. ["Exit and goto next group" gnus-summary-next-group t]
  2525. ["Exit and goto prev group" gnus-summary-prev-group t]
  2526. ["Reselect group" gnus-summary-reselect-current-group t]
  2527. ["Rescan group" gnus-summary-rescan-group t]
  2528. ["Update dribble" gnus-summary-save-newsrc t])))
  2529. (gnus-run-hooks 'gnus-summary-menu-hook)))
  2530. (defvar gnus-summary-tool-bar-map nil)
  2531. ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
  2532. ;; affect _new_ message buffers. We might add a function that walks thru all
  2533. ;; summary-mode buffers and force the update.
  2534. (defun gnus-summary-tool-bar-update (&optional symbol value)
  2535. "Update summary mode toolbar.
  2536. Setter function for custom variables."
  2537. (setq-default gnus-summary-tool-bar-map nil)
  2538. (when symbol
  2539. ;; When used as ":set" function:
  2540. (set-default symbol value))
  2541. (when (gnus-buffer-live-p gnus-summary-buffer)
  2542. (with-current-buffer gnus-summary-buffer
  2543. (gnus-summary-make-tool-bar))))
  2544. (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
  2545. 'gnus-summary-tool-bar-gnome
  2546. 'gnus-summary-tool-bar-retro)
  2547. "Specifies the Gnus summary tool bar.
  2548. It can be either a list or a symbol referring to a list. See
  2549. `gmm-tool-bar-from-list' for the format of the list. The
  2550. default key map is `gnus-summary-mode-map'.
  2551. Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
  2552. `gnus-summary-tool-bar-retro'."
  2553. :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
  2554. (const :tag "Retro look" gnus-summary-tool-bar-retro)
  2555. (repeat :tag "User defined list" gmm-tool-bar-item)
  2556. (symbol))
  2557. :version "23.1" ;; No Gnus
  2558. :initialize 'custom-initialize-default
  2559. :set 'gnus-summary-tool-bar-update
  2560. :group 'gnus-summary)
  2561. (defcustom gnus-summary-tool-bar-gnome
  2562. '((gnus-summary-post-news "mail/compose" nil)
  2563. (gnus-summary-insert-new-articles "mail/inbox" nil
  2564. :visible (or (not gnus-agent)
  2565. gnus-plugged))
  2566. (gnus-summary-reply-with-original "mail/reply")
  2567. (gnus-summary-reply "mail/reply" nil :visible nil)
  2568. (gnus-summary-followup-with-original "mail/reply-all")
  2569. (gnus-summary-followup "mail/reply-all" nil :visible nil)
  2570. (gnus-summary-mail-forward "mail/forward")
  2571. (gnus-summary-save-article "mail/save")
  2572. (gnus-summary-search-article-forward "search" nil :visible nil)
  2573. (gnus-summary-print-article "print")
  2574. (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
  2575. ;; Some new commands that may need more suitable icons:
  2576. (gnus-summary-save-newsrc "save" nil :visible nil)
  2577. ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
  2578. (gnus-summary-prev-article "left-arrow")
  2579. (gnus-summary-next-article "right-arrow")
  2580. (gnus-summary-next-page "next-page")
  2581. ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
  2582. ;;
  2583. ;; Maybe some sort-by-... could be added:
  2584. ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
  2585. ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
  2586. (gnus-summary-mark-as-expirable
  2587. "delete" nil
  2588. :visible (gnus-check-backend-function 'request-expire-articles
  2589. gnus-newsgroup-name))
  2590. (gnus-summary-mark-as-spam
  2591. "mail/spam" t
  2592. :visible (and (fboundp 'spam-group-ham-contents-p)
  2593. (spam-group-ham-contents-p gnus-newsgroup-name))
  2594. :help "Mark as spam")
  2595. (gnus-summary-mark-as-read-forward
  2596. "mail/not-spam" nil
  2597. :visible (and (fboundp 'spam-group-spam-contents-p)
  2598. (spam-group-spam-contents-p gnus-newsgroup-name)))
  2599. ;;
  2600. (gnus-summary-exit "exit")
  2601. (gmm-customize-mode "preferences" t :help "Edit mode preferences")
  2602. (gnus-info-find-node "help"))
  2603. "List of functions for the summary tool bar (GNOME style).
  2604. See `gmm-tool-bar-from-list' for the format of the list."
  2605. :type '(repeat gmm-tool-bar-item)
  2606. :version "23.1" ;; No Gnus
  2607. :initialize 'custom-initialize-default
  2608. :set 'gnus-summary-tool-bar-update
  2609. :group 'gnus-summary)
  2610. (defcustom gnus-summary-tool-bar-retro
  2611. '((gnus-summary-prev-unread-article "gnus/prev-ur")
  2612. (gnus-summary-next-unread-article "gnus/next-ur")
  2613. (gnus-summary-post-news "gnus/post")
  2614. (gnus-summary-followup-with-original "gnus/fuwo")
  2615. (gnus-summary-followup "gnus/followup")
  2616. (gnus-summary-reply-with-original "gnus/reply-wo")
  2617. (gnus-summary-reply "gnus/reply")
  2618. (gnus-summary-caesar-message "gnus/rot13")
  2619. (gnus-uu-decode-uu "gnus/uu-decode")
  2620. (gnus-summary-save-article-file "gnus/save-aif")
  2621. (gnus-summary-save-article "gnus/save-art")
  2622. (gnus-uu-post-news "gnus/uu-post")
  2623. (gnus-summary-catchup "gnus/catchup")
  2624. (gnus-summary-catchup-and-exit "gnus/cu-exit")
  2625. (gnus-summary-exit "gnus/exit-summ")
  2626. ;; Some new command that may need more suitable icons:
  2627. (gnus-summary-print-article "gnus/print" nil :visible nil)
  2628. (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
  2629. (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
  2630. ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
  2631. (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
  2632. ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
  2633. ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
  2634. ;;
  2635. (gnus-info-find-node "gnus/help" nil :visible nil))
  2636. "List of functions for the summary tool bar (retro look).
  2637. See `gmm-tool-bar-from-list' for the format of the list."
  2638. :type '(repeat gmm-tool-bar-item)
  2639. :version "23.1" ;; No Gnus
  2640. :initialize 'custom-initialize-default
  2641. :set 'gnus-summary-tool-bar-update
  2642. :group 'gnus-summary)
  2643. (defcustom gnus-summary-tool-bar-zap-list t
  2644. "List of icon items from the global tool bar.
  2645. These items are not displayed in the Gnus summary mode tool bar.
  2646. See `gmm-tool-bar-from-list' for the format of the list."
  2647. :type 'gmm-tool-bar-zap-list
  2648. :version "23.1" ;; No Gnus
  2649. :initialize 'custom-initialize-default
  2650. :set 'gnus-summary-tool-bar-update
  2651. :group 'gnus-summary)
  2652. (defvar image-load-path)
  2653. (defvar tool-bar-map)
  2654. (defun gnus-summary-make-tool-bar (&optional force)
  2655. "Make a summary mode tool bar from `gnus-summary-tool-bar'.
  2656. When FORCE, rebuild the tool bar."
  2657. (when (and (not (featurep 'xemacs))
  2658. (boundp 'tool-bar-mode)
  2659. tool-bar-mode
  2660. (or (not gnus-summary-tool-bar-map) force))
  2661. (let* ((load-path
  2662. (gmm-image-load-path-for-library "gnus"
  2663. "mail/save.xpm"
  2664. nil t))
  2665. (image-load-path (cons (car load-path)
  2666. (when (boundp 'image-load-path)
  2667. image-load-path)))
  2668. (map (gmm-tool-bar-from-list gnus-summary-tool-bar
  2669. gnus-summary-tool-bar-zap-list
  2670. 'gnus-summary-mode-map)))
  2671. (when map
  2672. ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
  2673. ;; uses its value.
  2674. (setq gnus-summary-tool-bar-map map))))
  2675. (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
  2676. (defun gnus-make-score-map (type)
  2677. "Make a summary score map of type TYPE."
  2678. (if t
  2679. nil
  2680. (let ((headers '(("author" "from" string)
  2681. ("subject" "subject" string)
  2682. ("article body" "body" string)
  2683. ("article head" "head" string)
  2684. ("xref" "xref" string)
  2685. ("extra header" "extra" string)
  2686. ("lines" "lines" number)
  2687. ("followups to author" "followup" string)))
  2688. (types '((number ("less than" <)
  2689. ("greater than" >)
  2690. ("equal" =))
  2691. (string ("substring" s)
  2692. ("exact string" e)
  2693. ("fuzzy string" f)
  2694. ("regexp" r))))
  2695. (perms '(("temporary" (current-time-string))
  2696. ("permanent" nil)
  2697. ("immediate" now)))
  2698. header)
  2699. (list
  2700. (apply
  2701. 'nconc
  2702. (list
  2703. (if (eq type 'lower)
  2704. "Lower score"
  2705. "Increase score"))
  2706. (let (outh)
  2707. (while headers
  2708. (setq header (car headers))
  2709. (setq outh
  2710. (cons
  2711. (apply
  2712. 'nconc
  2713. (list (car header))
  2714. (let ((ts (cdr (assoc (nth 2 header) types)))
  2715. outt)
  2716. (while ts
  2717. (setq outt
  2718. (cons
  2719. (apply
  2720. 'nconc
  2721. (list (caar ts))
  2722. (let ((ps perms)
  2723. outp)
  2724. (while ps
  2725. (setq outp
  2726. (cons
  2727. (vector
  2728. (caar ps)
  2729. (list
  2730. 'gnus-summary-score-entry
  2731. (nth 1 header)
  2732. (if (or (string= (nth 1 header)
  2733. "head")
  2734. (string= (nth 1 header)
  2735. "body"))
  2736. ""
  2737. (list 'gnus-summary-header
  2738. (nth 1 header)))
  2739. (list 'quote (nth 1 (car ts)))
  2740. (list 'gnus-score-delta-default
  2741. nil)
  2742. (nth 1 (car ps))
  2743. t)
  2744. t)
  2745. outp))
  2746. (setq ps (cdr ps)))
  2747. (list (nreverse outp))))
  2748. outt))
  2749. (setq ts (cdr ts)))
  2750. (list (nreverse outt))))
  2751. outh))
  2752. (setq headers (cdr headers)))
  2753. (list (nreverse outh))))))))
  2754. (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
  2755. (defvar bookmark-make-record-function)
  2756. (defvar bidi-paragraph-direction)
  2757. (defun gnus-summary-mode (&optional group)
  2758. "Major mode for reading articles.
  2759. All normal editing commands are switched off.
  2760. \\<gnus-summary-mode-map>
  2761. Each line in this buffer represents one article. To read an
  2762. article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
  2763. and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
  2764. respectively.
  2765. You can also post articles and send mail from this buffer. To
  2766. follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
  2767. of an article, type `\\[gnus-summary-reply]'.
  2768. There are approx. one gazillion commands you can execute in this
  2769. buffer; read the info pages for more information (`\\[gnus-info-find-node]').
  2770. The following commands are available:
  2771. \\{gnus-summary-mode-map}"
  2772. ;; FIXME: Use define-derived-mode.
  2773. (interactive)
  2774. (kill-all-local-variables)
  2775. (let ((gnus-summary-local-variables gnus-newsgroup-variables))
  2776. (gnus-summary-make-local-variables))
  2777. (gnus-summary-make-local-variables)
  2778. (setq gnus-newsgroup-name group)
  2779. (when (gnus-visual-p 'summary-menu 'menu)
  2780. (gnus-summary-make-menu-bar)
  2781. (gnus-summary-make-tool-bar))
  2782. (gnus-make-thread-indent-array)
  2783. (gnus-simplify-mode-line)
  2784. (setq major-mode 'gnus-summary-mode)
  2785. (setq mode-name "Summary")
  2786. (use-local-map gnus-summary-mode-map)
  2787. (buffer-disable-undo)
  2788. (setq buffer-read-only t ;Disable modification
  2789. show-trailing-whitespace nil)
  2790. (setq truncate-lines t)
  2791. ;; Force paragraph direction to be left-to-right. Don't make it
  2792. ;; bound globally in old Emacsen and XEmacsen.
  2793. (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
  2794. (add-to-invisibility-spec '(gnus-sum . t))
  2795. (gnus-summary-set-display-table)
  2796. (gnus-set-default-directory)
  2797. (make-local-variable 'gnus-summary-line-format)
  2798. (make-local-variable 'gnus-summary-line-format-spec)
  2799. (make-local-variable 'gnus-summary-dummy-line-format)
  2800. (make-local-variable 'gnus-summary-dummy-line-format-spec)
  2801. (make-local-variable 'gnus-summary-mark-positions)
  2802. (gnus-make-local-hook 'pre-command-hook)
  2803. (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
  2804. (gnus-run-mode-hooks 'gnus-summary-mode-hook)
  2805. (turn-on-gnus-mailing-list-mode)
  2806. (mm-enable-multibyte)
  2807. (set (make-local-variable 'bookmark-make-record-function)
  2808. 'gnus-summary-bookmark-make-record)
  2809. (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
  2810. (gnus-update-summary-mark-positions))
  2811. (defun gnus-summary-make-local-variables ()
  2812. "Make all the local summary buffer variables."
  2813. (let (global)
  2814. (dolist (local gnus-summary-local-variables)
  2815. (if (consp local)
  2816. (progn
  2817. (if (eq (cdr local) 'global)
  2818. ;; Copy the global value of the variable.
  2819. (setq global (symbol-value (car local)))
  2820. ;; Use the value from the list.
  2821. (setq global (eval (cdr local))))
  2822. (set (make-local-variable (car local)) global))
  2823. ;; Simple nil-valued local variable.
  2824. (set (make-local-variable local) nil)))))
  2825. ;; Summary data functions.
  2826. (defmacro gnus-data-number (data)
  2827. `(car ,data))
  2828. (defmacro gnus-data-set-number (data number)
  2829. `(setcar ,data ,number))
  2830. (defmacro gnus-data-mark (data)
  2831. `(nth 1 ,data))
  2832. (defmacro gnus-data-set-mark (data mark)
  2833. `(setcar (nthcdr 1 ,data) ,mark))
  2834. (defmacro gnus-data-pos (data)
  2835. `(nth 2 ,data))
  2836. (defmacro gnus-data-set-pos (data pos)
  2837. `(setcar (nthcdr 2 ,data) ,pos))
  2838. (defmacro gnus-data-header (data)
  2839. `(nth 3 ,data))
  2840. (defmacro gnus-data-set-header (data header)
  2841. `(setf (nth 3 ,data) ,header))
  2842. (defmacro gnus-data-level (data)
  2843. `(nth 4 ,data))
  2844. (defmacro gnus-data-unread-p (data)
  2845. `(= (nth 1 ,data) gnus-unread-mark))
  2846. (defmacro gnus-data-read-p (data)
  2847. `(/= (nth 1 ,data) gnus-unread-mark))
  2848. (defmacro gnus-data-pseudo-p (data)
  2849. `(consp (nth 3 ,data)))
  2850. (defmacro gnus-data-find (number)
  2851. `(assq ,number gnus-newsgroup-data))
  2852. (defmacro gnus-data-find-list (number &optional data)
  2853. `(let ((bdata ,(or data 'gnus-newsgroup-data)))
  2854. (memq (assq ,number bdata)
  2855. bdata)))
  2856. (defmacro gnus-data-make (number mark pos header level)
  2857. `(list ,number ,mark ,pos ,header ,level))
  2858. (defun gnus-data-enter (after-article number mark pos header level offset)
  2859. (let ((data (gnus-data-find-list after-article)))
  2860. (unless data
  2861. (error "No such article: %d" after-article))
  2862. (setcdr data (cons (gnus-data-make number mark pos header level)
  2863. (cdr data)))
  2864. (setq gnus-newsgroup-data-reverse nil)
  2865. (gnus-data-update-list (cddr data) offset)))
  2866. (defun gnus-data-enter-list (after-article list &optional offset)
  2867. (when list
  2868. (let ((data (and after-article (gnus-data-find-list after-article)))
  2869. (ilist list))
  2870. (if (not (or data
  2871. after-article))
  2872. (let ((odata gnus-newsgroup-data))
  2873. (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
  2874. (when offset
  2875. (gnus-data-update-list odata offset)))
  2876. ;; Find the last element in the list to be spliced into the main
  2877. ;; list.
  2878. (setq list (last list))
  2879. (if (not data)
  2880. (progn
  2881. (setcdr list gnus-newsgroup-data)
  2882. (setq gnus-newsgroup-data ilist)
  2883. (when offset
  2884. (gnus-data-update-list (cdr list) offset)))
  2885. (setcdr list (cdr data))
  2886. (setcdr data ilist)
  2887. (when offset
  2888. (gnus-data-update-list (cdr list) offset))))
  2889. (setq gnus-newsgroup-data-reverse nil))))
  2890. (defun gnus-data-remove (article &optional offset)
  2891. (let ((data gnus-newsgroup-data))
  2892. (if (= (gnus-data-number (car data)) article)
  2893. (progn
  2894. (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
  2895. gnus-newsgroup-data-reverse nil)
  2896. (when offset
  2897. (gnus-data-update-list gnus-newsgroup-data offset)))
  2898. (while (cdr data)
  2899. (when (= (gnus-data-number (cadr data)) article)
  2900. (setcdr data (cddr data))
  2901. (when offset
  2902. (gnus-data-update-list (cdr data) offset))
  2903. (setq data nil
  2904. gnus-newsgroup-data-reverse nil))
  2905. (setq data (cdr data))))))
  2906. (defmacro gnus-data-list (backward)
  2907. `(if ,backward
  2908. (or gnus-newsgroup-data-reverse
  2909. (setq gnus-newsgroup-data-reverse
  2910. (reverse gnus-newsgroup-data)))
  2911. gnus-newsgroup-data))
  2912. (defun gnus-data-update-list (data offset)
  2913. "Add OFFSET to the POS of all data entries in DATA."
  2914. (setq gnus-newsgroup-data-reverse nil)
  2915. (while data
  2916. (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
  2917. (setq data (cdr data))))
  2918. (defun gnus-summary-article-pseudo-p (article)
  2919. "Say whether this article is a pseudo article or not."
  2920. (not (vectorp (gnus-data-header (gnus-data-find article)))))
  2921. (defmacro gnus-summary-article-sparse-p (article)
  2922. "Say whether this article is a sparse article or not."
  2923. `(memq ,article gnus-newsgroup-sparse))
  2924. (defmacro gnus-summary-article-ancient-p (article)
  2925. "Say whether this article is a sparse article or not."
  2926. `(memq ,article gnus-newsgroup-ancient))
  2927. (defun gnus-article-children (number)
  2928. "Return a list of all children to NUMBER."
  2929. (let* ((data (gnus-data-find-list number))
  2930. (level (gnus-data-level (car data)))
  2931. children)
  2932. (setq data (cdr data))
  2933. (while (and data
  2934. (= (gnus-data-level (car data)) (1+ level)))
  2935. (push (gnus-data-number (car data)) children)
  2936. (setq data (cdr data)))
  2937. children))
  2938. (defmacro gnus-summary-skip-intangible ()
  2939. "If the current article is intangible, then jump to a different article."
  2940. '(let ((to (get-text-property (point) 'gnus-intangible)))
  2941. (and to (gnus-summary-goto-subject to))))
  2942. (defmacro gnus-summary-article-intangible-p ()
  2943. "Say whether this article is intangible or not."
  2944. '(get-text-property (point) 'gnus-intangible))
  2945. ;; Some summary mode macros.
  2946. (defmacro gnus-summary-article-number ()
  2947. "The article number of the article on the current line.
  2948. If there isn't an article number here, then we return the current
  2949. article number."
  2950. '(progn
  2951. (gnus-summary-skip-intangible)
  2952. (or (get-text-property (point) 'gnus-number)
  2953. (gnus-summary-last-subject))))
  2954. (defmacro gnus-summary-article-header (&optional number)
  2955. "Return the header of article NUMBER."
  2956. `(gnus-data-header (gnus-data-find
  2957. ,(or number '(gnus-summary-article-number)))))
  2958. (defmacro gnus-summary-thread-level (&optional number)
  2959. "Return the level of thread that starts with article NUMBER."
  2960. `(if (and (eq gnus-summary-make-false-root 'dummy)
  2961. (get-text-property (point) 'gnus-intangible))
  2962. 0
  2963. (gnus-data-level (gnus-data-find
  2964. ,(or number '(gnus-summary-article-number))))))
  2965. (defmacro gnus-summary-article-mark (&optional number)
  2966. "Return the mark of article NUMBER."
  2967. `(gnus-data-mark (gnus-data-find
  2968. ,(or number '(gnus-summary-article-number)))))
  2969. (defmacro gnus-summary-article-pos (&optional number)
  2970. "Return the position of the line of article NUMBER."
  2971. `(gnus-data-pos (gnus-data-find
  2972. ,(or number '(gnus-summary-article-number)))))
  2973. (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
  2974. (defmacro gnus-summary-article-subject (&optional number)
  2975. "Return current subject string or nil if nothing."
  2976. `(let ((headers
  2977. ,(if number
  2978. `(gnus-data-header (assq ,number gnus-newsgroup-data))
  2979. '(gnus-data-header (assq (gnus-summary-article-number)
  2980. gnus-newsgroup-data)))))
  2981. (and headers
  2982. (vectorp headers)
  2983. (mail-header-subject headers))))
  2984. (defmacro gnus-summary-article-score (&optional number)
  2985. "Return current article score."
  2986. `(or (cdr (assq ,(or number '(gnus-summary-article-number))
  2987. gnus-newsgroup-scored))
  2988. gnus-summary-default-score 0))
  2989. (defun gnus-summary-article-children (&optional number)
  2990. "Return a list of article numbers that are children of article NUMBER."
  2991. (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
  2992. (level (gnus-data-level (car data)))
  2993. l children)
  2994. (while (and (setq data (cdr data))
  2995. (> (setq l (gnus-data-level (car data))) level))
  2996. (and (= (1+ level) l)
  2997. (push (gnus-data-number (car data))
  2998. children)))
  2999. (nreverse children)))
  3000. (defun gnus-summary-article-parent (&optional number)
  3001. "Return the article number of the parent of article NUMBER."
  3002. (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
  3003. (gnus-data-list t)))
  3004. (level (gnus-data-level (car data))))
  3005. (if (zerop level)
  3006. () ; This is a root.
  3007. ;; We search until we find an article with a level less than
  3008. ;; this one. That function has to be the parent.
  3009. (while (and (setq data (cdr data))
  3010. (not (< (gnus-data-level (car data)) level))))
  3011. (and data (gnus-data-number (car data))))))
  3012. (defun gnus-unread-mark-p (mark)
  3013. "Say whether MARK is the unread mark."
  3014. (= mark gnus-unread-mark))
  3015. (defun gnus-read-mark-p (mark)
  3016. "Say whether MARK is one of the marks that mark as read.
  3017. This is all marks except unread, ticked, dormant, and expirable."
  3018. (not (or (= mark gnus-unread-mark)
  3019. (= mark gnus-ticked-mark)
  3020. (= mark gnus-spam-mark)
  3021. (= mark gnus-dormant-mark)
  3022. (= mark gnus-expirable-mark))))
  3023. (defmacro gnus-article-mark (number)
  3024. "Return the MARK of article NUMBER.
  3025. This macro should only be used when computing the mark the \"first\"
  3026. time; i.e., when generating the summary lines. After that,
  3027. `gnus-summary-article-mark' should be used to examine the
  3028. marks of articles."
  3029. `(cond
  3030. ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
  3031. ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
  3032. ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
  3033. ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
  3034. ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
  3035. ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
  3036. ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
  3037. (t (or (cdr (assq ,number gnus-newsgroup-reads))
  3038. gnus-ancient-mark))))
  3039. ;; Saving hidden threads.
  3040. (defmacro gnus-save-hidden-threads (&rest forms)
  3041. "Save hidden threads, eval FORMS, and restore the hidden threads."
  3042. (let ((config (make-symbol "config")))
  3043. `(let ((,config (gnus-hidden-threads-configuration)))
  3044. (unwind-protect
  3045. (save-excursion
  3046. ,@forms)
  3047. (gnus-restore-hidden-threads-configuration ,config)))))
  3048. (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
  3049. (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
  3050. (defun gnus-data-compute-positions ()
  3051. "Compute the positions of all articles."
  3052. (setq gnus-newsgroup-data-reverse nil)
  3053. (let ((data gnus-newsgroup-data))
  3054. (save-excursion
  3055. (gnus-save-hidden-threads
  3056. (gnus-summary-show-all-threads)
  3057. (goto-char (point-min))
  3058. (while data
  3059. (while (get-text-property (point) 'gnus-intangible)
  3060. (forward-line 1))
  3061. (gnus-data-set-pos (car data) (+ (point) 3))
  3062. (setq data (cdr data))
  3063. (forward-line 1))))))
  3064. (defun gnus-hidden-threads-configuration ()
  3065. "Return the current hidden threads configuration."
  3066. (save-excursion
  3067. (let (config)
  3068. (goto-char (point-min))
  3069. (while (not (eobp))
  3070. (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
  3071. (push (save-excursion (forward-line 0) (point)) config))
  3072. (forward-line 1))
  3073. config)))
  3074. (defun gnus-restore-hidden-threads-configuration (config)
  3075. "Restore hidden threads configuration from CONFIG."
  3076. (save-excursion
  3077. (let (point (inhibit-read-only t))
  3078. (while (setq point (pop config))
  3079. (goto-char point)
  3080. (gnus-summary-hide-thread)))))
  3081. ;; Various summary mode internalish functions.
  3082. (defun gnus-mouse-pick-article (e)
  3083. (interactive "e")
  3084. (mouse-set-point e)
  3085. (gnus-summary-next-page nil t))
  3086. (defun gnus-summary-set-display-table ()
  3087. "Change the display table.
  3088. Odd characters have a tendency to mess
  3089. up nicely formatted displays - we make all possible glyphs
  3090. display only a single character."
  3091. ;; We start from the standard display table, if any.
  3092. (let ((table (or (copy-sequence standard-display-table)
  3093. (make-display-table)))
  3094. (i 32))
  3095. ;; Nix out all the control chars...
  3096. (while (>= (setq i (1- i)) 0)
  3097. (gnus-put-display-table i [??] table))
  3098. ;; ... but not newline and cr, of course. (cr is necessary for the
  3099. ;; selective display).
  3100. (gnus-put-display-table ?\n nil table)
  3101. (gnus-put-display-table ?\r nil table)
  3102. ;; We keep TAB as well.
  3103. (gnus-put-display-table ?\t nil table)
  3104. ;; We nix out any glyphs 127 through 255, or 127 through 159 in
  3105. ;; Emacs 23 (unicode), that are not set already.
  3106. (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
  3107. 160
  3108. 256)))
  3109. (while (>= (setq i (1- i)) 127)
  3110. ;; Only modify if the entry is nil.
  3111. (unless (gnus-get-display-table i table)
  3112. (gnus-put-display-table i [??] table))))
  3113. (setq buffer-display-table table)))
  3114. (defun gnus-summary-set-article-display-arrow (pos)
  3115. "Update the overlay arrow to point to line at position POS."
  3116. (when gnus-summary-display-arrow
  3117. (make-local-variable 'overlay-arrow-position)
  3118. (make-local-variable 'overlay-arrow-string)
  3119. (save-excursion
  3120. (goto-char pos)
  3121. (beginning-of-line)
  3122. (unless overlay-arrow-position
  3123. (setq overlay-arrow-position (make-marker)))
  3124. (setq overlay-arrow-string "=>"
  3125. overlay-arrow-position (set-marker overlay-arrow-position
  3126. (point)
  3127. (current-buffer))))))
  3128. (defun gnus-summary-setup-buffer (group)
  3129. "Initialize summary buffer.
  3130. If the setup was successful, non-nil is returned."
  3131. (let ((buffer (gnus-summary-buffer-name group))
  3132. (dead-name (concat "*Dead Summary "
  3133. (gnus-group-decoded-name group) "*")))
  3134. ;; If a dead summary buffer exists, we kill it.
  3135. (when (gnus-buffer-live-p dead-name)
  3136. (gnus-kill-buffer dead-name))
  3137. (if (get-buffer buffer)
  3138. (progn
  3139. (set-buffer buffer)
  3140. (setq gnus-summary-buffer (current-buffer))
  3141. (not gnus-newsgroup-prepared))
  3142. (set-buffer (gnus-get-buffer-create buffer))
  3143. (setq gnus-summary-buffer (current-buffer))
  3144. (gnus-summary-mode group)
  3145. (when (gnus-group-quit-config group)
  3146. (set (make-local-variable 'gnus-single-article-buffer) nil))
  3147. (make-local-variable 'gnus-article-buffer)
  3148. (make-local-variable 'gnus-article-current)
  3149. (make-local-variable 'gnus-original-article-buffer)
  3150. (setq gnus-newsgroup-name group)
  3151. ;; Set any local variables in the group parameters.
  3152. (gnus-summary-set-local-parameters gnus-newsgroup-name)
  3153. t)))
  3154. (defun gnus-set-global-variables ()
  3155. "Set the global equivalents of the buffer-local variables.
  3156. They are set to the latest values they had. These reflect the summary
  3157. buffer that was in action when the last article was fetched."
  3158. (when (derived-mode-p 'gnus-summary-mode)
  3159. (setq gnus-summary-buffer (current-buffer))
  3160. (let ((name gnus-newsgroup-name)
  3161. (marked gnus-newsgroup-marked)
  3162. (spam gnus-newsgroup-spam-marked)
  3163. (unread gnus-newsgroup-unreads)
  3164. (headers gnus-current-headers)
  3165. (data gnus-newsgroup-data)
  3166. (summary gnus-summary-buffer)
  3167. (article-buffer gnus-article-buffer)
  3168. (original gnus-original-article-buffer)
  3169. (gac gnus-article-current)
  3170. (reffed gnus-reffed-article-number)
  3171. (score-file gnus-current-score-file)
  3172. (default-charset gnus-newsgroup-charset)
  3173. vlist)
  3174. (let ((locals gnus-newsgroup-variables))
  3175. (while locals
  3176. (if (consp (car locals))
  3177. (push (eval (caar locals)) vlist)
  3178. (push (eval (car locals)) vlist))
  3179. (setq locals (cdr locals)))
  3180. (setq vlist (nreverse vlist)))
  3181. (with-temp-buffer
  3182. (setq gnus-newsgroup-name name
  3183. gnus-newsgroup-marked marked
  3184. gnus-newsgroup-spam-marked spam
  3185. gnus-newsgroup-unreads unread
  3186. gnus-current-headers headers
  3187. gnus-newsgroup-data data
  3188. gnus-article-current gac
  3189. gnus-summary-buffer summary
  3190. gnus-article-buffer article-buffer
  3191. gnus-original-article-buffer original
  3192. gnus-reffed-article-number reffed
  3193. gnus-current-score-file score-file
  3194. gnus-newsgroup-charset default-charset)
  3195. (let ((locals gnus-newsgroup-variables))
  3196. (while locals
  3197. (if (consp (car locals))
  3198. (set (caar locals) (pop vlist))
  3199. (set (car locals) (pop vlist)))
  3200. (setq locals (cdr locals))))))))
  3201. (defun gnus-summary-article-unread-p (article)
  3202. "Say whether ARTICLE is unread or not."
  3203. (memq article gnus-newsgroup-unreads))
  3204. (defun gnus-summary-first-article-p (&optional article)
  3205. "Return whether ARTICLE is the first article in the buffer."
  3206. (if (not (setq article (or article (gnus-summary-article-number))))
  3207. nil
  3208. (eq article (caar gnus-newsgroup-data))))
  3209. (defun gnus-summary-last-article-p (&optional article)
  3210. "Return whether ARTICLE is the last article in the buffer."
  3211. (if (not (setq article (or article (gnus-summary-article-number))))
  3212. ;; All non-existent numbers are the last article. :-)
  3213. t
  3214. (not (cdr (gnus-data-find-list article)))))
  3215. (defun gnus-make-thread-indent-array (&optional n)
  3216. (when (or n
  3217. (progn (setq n 200) nil)
  3218. (null gnus-thread-indent-array)
  3219. (/= gnus-thread-indent-level gnus-thread-indent-array-level))
  3220. (setq gnus-thread-indent-array (make-vector (1+ n) "")
  3221. gnus-thread-indent-array-level gnus-thread-indent-level)
  3222. (while (>= n 0)
  3223. (aset gnus-thread-indent-array n
  3224. (make-string (* n gnus-thread-indent-level) ? ))
  3225. (setq n (1- n)))))
  3226. (defun gnus-update-summary-mark-positions ()
  3227. "Compute where the summary marks are to go."
  3228. (save-excursion
  3229. (when (gnus-buffer-exists-p gnus-summary-buffer)
  3230. (set-buffer gnus-summary-buffer))
  3231. (let ((spec gnus-summary-line-format-spec)
  3232. pos)
  3233. (save-excursion
  3234. (gnus-set-work-buffer)
  3235. (let ((gnus-tmp-unread ?Z)
  3236. (gnus-replied-mark ?Z)
  3237. (gnus-score-below-mark ?Z)
  3238. (gnus-score-over-mark ?Z)
  3239. (gnus-undownloaded-mark ?Z)
  3240. (gnus-summary-line-format-spec spec)
  3241. (gnus-newsgroup-downloadable '(0))
  3242. (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
  3243. case-fold-search ignores)
  3244. ;; Here, all marks are bound to Z.
  3245. (gnus-summary-insert-line header
  3246. 0 nil t gnus-tmp-unread t nil "" nil 1)
  3247. (goto-char (point-min))
  3248. ;; Memorize the positions of the same characters as dummy marks.
  3249. (while (re-search-forward "[A-D]" nil t)
  3250. (push (point) ignores))
  3251. (erase-buffer)
  3252. ;; We use A-D as dummy marks in order to know column positions
  3253. ;; where marks should be inserted.
  3254. (setq gnus-tmp-unread ?A
  3255. gnus-replied-mark ?B
  3256. gnus-score-below-mark ?C
  3257. gnus-score-over-mark ?C
  3258. gnus-undownloaded-mark ?D)
  3259. (gnus-summary-insert-line header
  3260. 0 nil t gnus-tmp-unread t nil "" nil 1)
  3261. ;; Ignore characters which aren't dummy marks.
  3262. (dolist (p ignores)
  3263. (delete-region (goto-char (1- p)) p)
  3264. (insert ?Z))
  3265. (goto-char (point-min))
  3266. (setq pos (list (cons 'unread
  3267. (and (search-forward "A" nil t)
  3268. (- (point) (point-min) 1)))))
  3269. (goto-char (point-min))
  3270. (push (cons 'replied (and (search-forward "B" nil t)
  3271. (- (point) (point-min) 1)))
  3272. pos)
  3273. (goto-char (point-min))
  3274. (push (cons 'score (and (search-forward "C" nil t)
  3275. (- (point) (point-min) 1)))
  3276. pos)
  3277. (goto-char (point-min))
  3278. (push (cons 'download (and (search-forward "D" nil t)
  3279. (- (point) (point-min) 1)))
  3280. pos)))
  3281. (setq gnus-summary-mark-positions pos))))
  3282. (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
  3283. "Insert a dummy root in the summary buffer."
  3284. (beginning-of-line)
  3285. (gnus-add-text-properties
  3286. (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
  3287. (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
  3288. (defun gnus-summary-extract-address-component (from)
  3289. (or (car (funcall gnus-extract-address-components from))
  3290. from))
  3291. (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
  3292. (let ((mail-parse-charset gnus-newsgroup-charset)
  3293. (ignored-from-addresses (gnus-ignored-from-addresses))
  3294. ;; Is it really necessary to do this next part for each summary line?
  3295. ;; Luckily, doesn't seem to slow things down much.
  3296. (mail-parse-ignored-charsets
  3297. (with-current-buffer gnus-summary-buffer
  3298. gnus-newsgroup-ignored-charsets)))
  3299. (or
  3300. (and ignored-from-addresses
  3301. (string-match ignored-from-addresses gnus-tmp-from)
  3302. (let ((extra-headers (mail-header-extra header))
  3303. to
  3304. newsgroups)
  3305. (cond
  3306. ((setq to (cdr (assq 'To extra-headers)))
  3307. (concat gnus-summary-to-prefix
  3308. (inline
  3309. (gnus-summary-extract-address-component
  3310. (funcall gnus-decode-encoded-address-function to)))))
  3311. ((setq newsgroups
  3312. (or
  3313. (cdr (assq 'Newsgroups extra-headers))
  3314. (and
  3315. (memq 'Newsgroups gnus-extra-headers)
  3316. (eq (car (gnus-find-method-for-group
  3317. gnus-newsgroup-name)) 'nntp)
  3318. (gnus-group-real-name gnus-newsgroup-name))))
  3319. (concat gnus-summary-newsgroup-prefix newsgroups)))))
  3320. (gnus-string-mark-left-to-right
  3321. (inline
  3322. (gnus-summary-extract-address-component gnus-tmp-from))))))
  3323. (defun gnus-summary-insert-line (gnus-tmp-header
  3324. gnus-tmp-level gnus-tmp-current
  3325. undownloaded gnus-tmp-unread gnus-tmp-replied
  3326. gnus-tmp-expirable gnus-tmp-subject-or-nil
  3327. &optional gnus-tmp-dummy gnus-tmp-score
  3328. gnus-tmp-process)
  3329. (if (>= gnus-tmp-level (length gnus-thread-indent-array))
  3330. (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
  3331. gnus-tmp-level)))
  3332. (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
  3333. (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
  3334. (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
  3335. (gnus-tmp-score-char
  3336. (if (or (null gnus-summary-default-score)
  3337. (<= (abs (- gnus-tmp-score gnus-summary-default-score))
  3338. gnus-summary-zcore-fuzz))
  3339. ? ;Whitespace
  3340. (if (< gnus-tmp-score gnus-summary-default-score)
  3341. gnus-score-below-mark gnus-score-over-mark)))
  3342. (gnus-tmp-number (mail-header-number gnus-tmp-header))
  3343. (gnus-tmp-replied
  3344. (cond (gnus-tmp-process gnus-process-mark)
  3345. ((memq gnus-tmp-current gnus-newsgroup-cached)
  3346. gnus-cached-mark)
  3347. (gnus-tmp-replied gnus-replied-mark)
  3348. ((memq gnus-tmp-current gnus-newsgroup-forwarded)
  3349. gnus-forwarded-mark)
  3350. ((memq gnus-tmp-current gnus-newsgroup-saved)
  3351. gnus-saved-mark)
  3352. ((memq gnus-tmp-number gnus-newsgroup-unseen)
  3353. gnus-unseen-mark)
  3354. (t gnus-no-mark)))
  3355. (gnus-tmp-downloaded
  3356. (cond (undownloaded
  3357. gnus-undownloaded-mark)
  3358. (gnus-newsgroup-agentized
  3359. gnus-downloaded-mark)
  3360. (t
  3361. gnus-no-mark)))
  3362. (gnus-tmp-from (mail-header-from gnus-tmp-header))
  3363. (gnus-tmp-name
  3364. (cond
  3365. ((string-match "<[^>]+> *$" gnus-tmp-from)
  3366. (let ((beg (match-beginning 0)))
  3367. (or (and (string-match "^\".+\"" gnus-tmp-from)
  3368. (substring gnus-tmp-from 1 (1- (match-end 0))))
  3369. (substring gnus-tmp-from 0 beg))))
  3370. ((string-match "(.+)" gnus-tmp-from)
  3371. (substring gnus-tmp-from
  3372. (1+ (match-beginning 0)) (1- (match-end 0))))
  3373. (t gnus-tmp-from)))
  3374. (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
  3375. (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
  3376. (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
  3377. (inhibit-read-only t))
  3378. (when (string= gnus-tmp-name "")
  3379. (setq gnus-tmp-name gnus-tmp-from))
  3380. (unless (numberp gnus-tmp-lines)
  3381. (setq gnus-tmp-lines -1))
  3382. (if (= gnus-tmp-lines -1)
  3383. (setq gnus-tmp-lines "?")
  3384. (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
  3385. (condition-case ()
  3386. (gnus-put-text-property
  3387. (point)
  3388. (progn (eval gnus-summary-line-format-spec) (point))
  3389. 'gnus-number gnus-tmp-number)
  3390. (error (gnus-message 5 "Error updating the summary line")))
  3391. (when (gnus-visual-p 'summary-highlight 'highlight)
  3392. (forward-line -1)
  3393. (gnus-summary-highlight-line)
  3394. (gnus-run-hooks 'gnus-summary-update-hook)
  3395. (forward-line 1))))
  3396. (defun gnus-summary-update-line (&optional dont-update)
  3397. "Update summary line after change."
  3398. (when (and gnus-summary-default-score
  3399. (not gnus-summary-inhibit-highlight))
  3400. (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
  3401. (article (gnus-summary-article-number))
  3402. (score (gnus-summary-article-score article)))
  3403. (unless dont-update
  3404. (if (and gnus-summary-mark-below
  3405. (< (gnus-summary-article-score)
  3406. gnus-summary-mark-below))
  3407. ;; This article has a low score, so we mark it as read.
  3408. (when (memq article gnus-newsgroup-unreads)
  3409. (gnus-summary-mark-article-as-read gnus-low-score-mark))
  3410. (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
  3411. ;; This article was previously marked as read on account
  3412. ;; of a low score, but now it has risen, so we mark it as
  3413. ;; unread.
  3414. (gnus-summary-mark-article-as-unread gnus-unread-mark)))
  3415. (gnus-summary-update-mark
  3416. (if (or (null gnus-summary-default-score)
  3417. (<= (abs (- score gnus-summary-default-score))
  3418. gnus-summary-zcore-fuzz))
  3419. ? ;Whitespace
  3420. (if (< score gnus-summary-default-score)
  3421. gnus-score-below-mark gnus-score-over-mark))
  3422. 'score))
  3423. ;; Do visual highlighting.
  3424. (when (gnus-visual-p 'summary-highlight 'highlight)
  3425. (gnus-summary-highlight-line)
  3426. (gnus-run-hooks 'gnus-summary-update-hook)))))
  3427. (defvar gnus-tmp-new-adopts nil)
  3428. (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
  3429. "Return the number of articles in THREAD.
  3430. This may be 0 in some cases -- if none of the articles in
  3431. the thread are to be displayed."
  3432. (let* ((number
  3433. ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
  3434. (cond
  3435. ((not (listp thread))
  3436. 1)
  3437. ((and (consp thread) (cdr thread))
  3438. (apply
  3439. '+ 1 (mapcar
  3440. 'gnus-summary-number-of-articles-in-thread (cdr thread))))
  3441. ((null thread)
  3442. 1)
  3443. ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
  3444. 1)
  3445. (t 0))))
  3446. (when (and level (zerop level) gnus-tmp-new-adopts)
  3447. (incf number
  3448. (apply '+ (mapcar
  3449. 'gnus-summary-number-of-articles-in-thread
  3450. gnus-tmp-new-adopts))))
  3451. (if char
  3452. (if (> number 1) gnus-not-empty-thread-mark
  3453. gnus-empty-thread-mark)
  3454. number)))
  3455. (defsubst gnus-summary-line-message-size (head)
  3456. "Return pretty-printed version of message size.
  3457. This function is intended to be used in
  3458. `gnus-summary-line-format-alist'."
  3459. (let ((c (or (mail-header-chars head) -1)))
  3460. (cond ((< c 0) "n/a") ; chars not available
  3461. ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
  3462. ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
  3463. ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
  3464. (t (format "%dM" (/ c (* 1024.0 1024)))))))
  3465. (defcustom gnus-user-date-format-alist
  3466. '(((gnus-seconds-today) . "Today, %H:%M")
  3467. ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
  3468. (604800 . "%A %H:%M") ; That's one week
  3469. ((gnus-seconds-month) . "%A %d")
  3470. ((gnus-seconds-year) . "%B %d")
  3471. (t . "%b %d %Y")) ; This one is used when no other
  3472. ; does match
  3473. "Specifies date format depending on age of article.
  3474. This is an alist of items (AGE . FORMAT). AGE can be a number (of
  3475. seconds) or a Lisp expression evaluating to a number. When the age of
  3476. the article is less than this number, then use `format-time-string'
  3477. with the corresponding FORMAT for displaying the date of the article.
  3478. If AGE is not a number or a Lisp expression evaluating to a
  3479. non-number, then the corresponding FORMAT is used as a default value.
  3480. Note that the list is processed from the beginning, so it should be
  3481. sorted by ascending AGE. Also note that items following the first
  3482. non-number AGE will be ignored.
  3483. You can use the functions `gnus-seconds-today', `gnus-seconds-month'
  3484. and `gnus-seconds-year' in the AGE spec. They return the number of
  3485. seconds passed since the start of today, of this month, of this year,
  3486. respectively."
  3487. :version "24.1"
  3488. :group 'gnus-summary-format
  3489. :type '(alist :key-type sexp :value-type string))
  3490. (defun gnus-user-date (messy-date)
  3491. "Format the messy-date according to `gnus-user-date-format-alist'.
  3492. Returns \" ? \" if there's bad input or if another error occurs.
  3493. Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
  3494. (condition-case ()
  3495. (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
  3496. (now (gnus-float-time))
  3497. ;;If we don't find something suitable we'll use this one
  3498. (my-format "%b %d '%y"))
  3499. (let* ((difference (- now messy-date))
  3500. (templist gnus-user-date-format-alist)
  3501. (top (eval (caar templist))))
  3502. (while (if (numberp top) (< top difference) (not top))
  3503. (progn
  3504. (setq templist (cdr templist))
  3505. (setq top (eval (caar templist)))))
  3506. (if (stringp (cdr (car templist)))
  3507. (setq my-format (cdr (car templist)))))
  3508. (format-time-string (eval my-format) (seconds-to-time messy-date)))
  3509. (error " ? ")))
  3510. (defun gnus-summary-set-local-parameters (group)
  3511. "Go through the local params of GROUP and set all variable specs in that list."
  3512. (let ((vars '(quit-config active))) ; Ignore things that aren't
  3513. ; really variables.
  3514. (dolist (elem (gnus-group-find-parameter group))
  3515. (and (consp elem) ; Has to be a cons.
  3516. (consp (cdr elem)) ; The cdr has to be a list.
  3517. (symbolp (car elem)) ; Has to be a symbol in there.
  3518. (not (memq (car elem) vars))
  3519. (ignore-errors
  3520. (push (car elem) vars)
  3521. ;; Variables like `gnus-show-threads' that are globally
  3522. ;; bound, if used as group parameters, need to get to be
  3523. ;; buffer-local, whereas just parameters like `gcc-self',
  3524. ;; `timestamp', etc. should not be bound as variables.
  3525. (if (boundp (car elem))
  3526. (set (make-local-variable (car elem)) (eval (nth 1 elem)))
  3527. (eval (nth 1 elem))))))))
  3528. (defun gnus-summary-read-group (group &optional show-all no-article
  3529. kill-buffer no-display backward
  3530. select-articles)
  3531. "Start reading news in newsgroup GROUP.
  3532. If SHOW-ALL is non-nil, already read articles are also listed.
  3533. If NO-ARTICLE is non-nil, no article is selected initially.
  3534. If NO-DISPLAY, don't generate the summary buffer contents.
  3535. If KILL-BUFFER, it should be a buffer that's killed once the new
  3536. summary buffer has been generated.
  3537. If BACKWARD, move point to the previous group in the group buffer
  3538. If SELECT-ARTICLES, only select those articles from GROUP."
  3539. (let (result)
  3540. (while (and group
  3541. (null (setq result
  3542. (let ((gnus-auto-select-next nil))
  3543. (or (gnus-summary-read-group-1
  3544. group show-all no-article
  3545. kill-buffer no-display
  3546. select-articles)
  3547. (setq show-all nil
  3548. select-articles nil)))))
  3549. (eq gnus-auto-select-next 'quietly))
  3550. (set-buffer gnus-group-buffer)
  3551. ;; The entry function called above goes to the next
  3552. ;; group automatically, so we go two groups back
  3553. ;; if we are searching for the previous group.
  3554. (when backward
  3555. (gnus-group-prev-unread-group 2))
  3556. (if (not (equal group (gnus-group-group-name)))
  3557. (setq group (gnus-group-group-name))
  3558. (setq group nil)))
  3559. result))
  3560. (defun gnus-summary-read-group-1 (group show-all no-article
  3561. kill-buffer no-display
  3562. &optional select-articles)
  3563. ;; Killed foreign groups can't be entered.
  3564. ;; (when (and (not (gnus-group-native-p group))
  3565. ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
  3566. ;; (error "Dead non-native groups can't be entered"))
  3567. (gnus-message 7 "Retrieving newsgroup: %s..."
  3568. (gnus-group-decoded-name group))
  3569. (let* ((new-group (gnus-summary-setup-buffer group))
  3570. (quit-config (gnus-group-quit-config group))
  3571. (did-select (and new-group (gnus-select-newsgroup
  3572. group show-all select-articles))))
  3573. (cond
  3574. ;; This summary buffer exists already, so we just select it.
  3575. ((not new-group)
  3576. (gnus-set-global-variables)
  3577. (when kill-buffer
  3578. (gnus-kill-or-deaden-summary kill-buffer))
  3579. (gnus-configure-windows 'summary 'force)
  3580. (gnus-set-mode-line 'summary)
  3581. (gnus-summary-position-point)
  3582. (message "")
  3583. t)
  3584. ;; We couldn't select this group.
  3585. ((null did-select)
  3586. (when (and (derived-mode-p 'gnus-summary-mode)
  3587. (not (equal (current-buffer) kill-buffer)))
  3588. (kill-buffer (current-buffer))
  3589. (if (not quit-config)
  3590. (progn
  3591. ;; Update the info -- marks might need to be removed,
  3592. ;; for instance.
  3593. (gnus-summary-update-info)
  3594. (set-buffer gnus-group-buffer)
  3595. (gnus-group-jump-to-group group)
  3596. (gnus-group-next-unread-group 1))
  3597. (gnus-handle-ephemeral-exit quit-config)))
  3598. (if (null (gnus-list-of-unread-articles group))
  3599. (gnus-message 3 "Group %s contains no messages" group)
  3600. (gnus-message 3 "Can't select group"))
  3601. nil)
  3602. ;; The user did a `C-g' while prompting for number of articles,
  3603. ;; so we exit this group.
  3604. ((eq did-select 'quit)
  3605. (and (derived-mode-p 'gnus-summary-mode)
  3606. (not (equal (current-buffer) kill-buffer))
  3607. (kill-buffer (current-buffer)))
  3608. (when kill-buffer
  3609. (gnus-kill-or-deaden-summary kill-buffer))
  3610. (if (not quit-config)
  3611. (progn
  3612. (set-buffer gnus-group-buffer)
  3613. (gnus-group-jump-to-group group)
  3614. (gnus-configure-windows 'group 'force))
  3615. (gnus-handle-ephemeral-exit quit-config))
  3616. ;; Finally signal the quit.
  3617. (signal 'quit nil))
  3618. ;; The group was successfully selected.
  3619. (t
  3620. (gnus-set-global-variables)
  3621. (when (boundp 'spam-install-hooks)
  3622. (spam-initialize))
  3623. ;; Save the active value in effect when the group was entered.
  3624. (setq gnus-newsgroup-active
  3625. (gnus-copy-sequence
  3626. (gnus-active gnus-newsgroup-name)))
  3627. (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
  3628. ;; You can change the summary buffer in some way with this hook.
  3629. (gnus-run-hooks 'gnus-select-group-hook)
  3630. (when (memq 'summary (gnus-update-format-specifications
  3631. nil 'summary 'summary-mode 'summary-dummy))
  3632. ;; The format specification for the summary line was updated,
  3633. ;; so we need to update the mark positions as well.
  3634. (gnus-update-summary-mark-positions))
  3635. ;; Do score processing.
  3636. (when gnus-use-scoring
  3637. (gnus-possibly-score-headers))
  3638. ;; Check whether to fill in the gaps in the threads.
  3639. (when gnus-build-sparse-threads
  3640. (gnus-build-sparse-threads))
  3641. ;; Find the initial limit.
  3642. (if show-all
  3643. (let ((gnus-newsgroup-dormant nil))
  3644. (gnus-summary-initial-limit show-all))
  3645. (gnus-summary-initial-limit show-all))
  3646. ;; Generate the summary buffer.
  3647. (unless no-display
  3648. (gnus-summary-prepare))
  3649. (when gnus-use-trees
  3650. (gnus-tree-open)
  3651. (setq gnus-summary-highlight-line-function
  3652. 'gnus-tree-highlight-article))
  3653. ;; If the summary buffer is empty, but there are some low-scored
  3654. ;; articles or some excluded dormants, we include these in the
  3655. ;; buffer.
  3656. (when (and (zerop (buffer-size))
  3657. (not no-display))
  3658. (cond (gnus-newsgroup-dormant
  3659. (gnus-summary-limit-include-dormant))
  3660. ((and gnus-newsgroup-scored show-all)
  3661. (gnus-summary-limit-include-expunged t))))
  3662. ;; Function `gnus-apply-kill-file' must be called in this hook.
  3663. (gnus-run-hooks 'gnus-apply-kill-hook)
  3664. (if (and (zerop (buffer-size))
  3665. (not no-display))
  3666. (progn
  3667. ;; This newsgroup is empty.
  3668. (gnus-summary-catchup-and-exit nil t)
  3669. (gnus-message 6 "No unread news")
  3670. (when kill-buffer
  3671. (gnus-kill-or-deaden-summary kill-buffer))
  3672. ;; Return nil from this function.
  3673. nil)
  3674. ;; Hide conversation thread subtrees. We cannot do this in
  3675. ;; gnus-summary-prepare-hook since kill processing may not
  3676. ;; work with hidden articles.
  3677. (gnus-summary-maybe-hide-threads)
  3678. (gnus-configure-windows 'summary)
  3679. (when kill-buffer
  3680. (gnus-kill-or-deaden-summary kill-buffer))
  3681. (gnus-summary-auto-select-subject)
  3682. ;; Show first unread article if requested.
  3683. (if (and (not no-article)
  3684. (not no-display)
  3685. gnus-newsgroup-unreads
  3686. gnus-auto-select-first)
  3687. (progn
  3688. (let ((art (gnus-summary-article-number)))
  3689. (when (and art
  3690. gnus-plugged
  3691. (not (memq art gnus-newsgroup-undownloaded))
  3692. (not (memq art gnus-newsgroup-downloadable)))
  3693. (gnus-summary-goto-article art))))
  3694. ;; Don't select any articles.
  3695. (gnus-summary-position-point)
  3696. (gnus-configure-windows 'summary 'force)
  3697. (gnus-set-mode-line 'summary))
  3698. (when (and gnus-auto-center-group
  3699. (get-buffer-window gnus-group-buffer t))
  3700. ;; Gotta use windows, because recenter does weird stuff if
  3701. ;; the current buffer ain't the displayed window.
  3702. (let ((owin (selected-window)))
  3703. (select-window (get-buffer-window gnus-group-buffer t))
  3704. (when (gnus-group-goto-group group)
  3705. (recenter))
  3706. (select-window owin)))
  3707. ;; Mark this buffer as "prepared".
  3708. (setq gnus-newsgroup-prepared t)
  3709. (gnus-run-hooks 'gnus-summary-prepared-hook)
  3710. (unless (gnus-ephemeral-group-p group)
  3711. (gnus-group-update-group group nil t))
  3712. t)))))
  3713. (defun gnus-summary-auto-select-subject ()
  3714. "Select the subject line on initial group entry."
  3715. (goto-char (point-min))
  3716. (cond
  3717. ((eq gnus-auto-select-subject 'best)
  3718. (gnus-summary-best-unread-subject))
  3719. ((eq gnus-auto-select-subject 'unread)
  3720. (gnus-summary-first-unread-subject))
  3721. ((eq gnus-auto-select-subject 'unseen)
  3722. (gnus-summary-first-unseen-subject))
  3723. ((eq gnus-auto-select-subject 'unseen-or-unread)
  3724. (gnus-summary-first-unseen-or-unread-subject))
  3725. ((eq gnus-auto-select-subject 'first)
  3726. ;; Do nothing.
  3727. )
  3728. ((functionp gnus-auto-select-subject)
  3729. (funcall gnus-auto-select-subject))))
  3730. (defun gnus-summary-prepare ()
  3731. "Generate the summary buffer."
  3732. (interactive)
  3733. (let ((inhibit-read-only t))
  3734. (erase-buffer)
  3735. (setq gnus-newsgroup-data nil
  3736. gnus-newsgroup-data-reverse nil)
  3737. (gnus-run-hooks 'gnus-summary-generate-hook)
  3738. ;; Generate the buffer, either with threads or without.
  3739. (when gnus-newsgroup-headers
  3740. (gnus-summary-prepare-threads
  3741. (if gnus-show-threads
  3742. (gnus-sort-gathered-threads
  3743. (funcall gnus-summary-thread-gathering-function
  3744. (gnus-sort-threads
  3745. (gnus-cut-threads (gnus-make-threads)))))
  3746. ;; Unthreaded display.
  3747. (gnus-sort-articles gnus-newsgroup-headers))))
  3748. (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
  3749. ;; Call hooks for modifying summary buffer.
  3750. (goto-char (point-min))
  3751. (gnus-run-hooks 'gnus-summary-prepare-hook)))
  3752. (defsubst gnus-general-simplify-subject (subject)
  3753. "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
  3754. (setq subject
  3755. (cond
  3756. ;; Truncate the subject.
  3757. (gnus-simplify-subject-functions
  3758. (gnus-map-function gnus-simplify-subject-functions subject))
  3759. ((numberp gnus-summary-gather-subject-limit)
  3760. (setq subject (gnus-simplify-subject-re subject))
  3761. (if (> (length subject) gnus-summary-gather-subject-limit)
  3762. (substring subject 0 gnus-summary-gather-subject-limit)
  3763. subject))
  3764. ;; Fuzzily simplify it.
  3765. ((eq 'fuzzy gnus-summary-gather-subject-limit)
  3766. (gnus-simplify-subject-fuzzy subject))
  3767. ;; Just remove the leading "Re:".
  3768. (t
  3769. (gnus-simplify-subject-re subject))))
  3770. (if (and gnus-summary-gather-exclude-subject
  3771. (string-match gnus-summary-gather-exclude-subject subject))
  3772. nil ; This article shouldn't be gathered
  3773. subject))
  3774. (defun gnus-summary-simplify-subject-query ()
  3775. "Query where the respool algorithm would put this article."
  3776. (interactive)
  3777. (gnus-summary-select-article)
  3778. (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
  3779. (defun gnus-gather-threads-by-subject (threads)
  3780. "Gather threads by looking at Subject headers."
  3781. (if (not gnus-summary-make-false-root)
  3782. threads
  3783. (let ((hashtb (gnus-make-hashtable 1024))
  3784. (prev threads)
  3785. (result threads)
  3786. subject hthread whole-subject)
  3787. (while threads
  3788. (setq subject (gnus-general-simplify-subject
  3789. (setq whole-subject (mail-header-subject
  3790. (caar threads)))))
  3791. (when subject
  3792. (if (setq hthread (gnus-gethash subject hashtb))
  3793. (progn
  3794. ;; We enter a dummy root into the thread, if we
  3795. ;; haven't done that already.
  3796. (unless (stringp (caar hthread))
  3797. (setcar hthread (list whole-subject (car hthread))))
  3798. ;; We add this new gathered thread to this gathered
  3799. ;; thread.
  3800. (setcdr (car hthread)
  3801. (nconc (cdar hthread) (list (car threads))))
  3802. ;; Remove it from the list of threads.
  3803. (setcdr prev (cdr threads))
  3804. (setq threads prev))
  3805. ;; Enter this thread into the hash table.
  3806. (gnus-sethash subject
  3807. (if gnus-summary-make-false-root-always
  3808. (progn
  3809. ;; If you want a dummy root above all
  3810. ;; threads...
  3811. (setcar threads (list whole-subject
  3812. (car threads)))
  3813. threads)
  3814. threads)
  3815. hashtb)))
  3816. (setq prev threads)
  3817. (setq threads (cdr threads)))
  3818. result)))
  3819. (defun gnus-gather-threads-by-references (threads)
  3820. "Gather threads by looking at References headers."
  3821. (let ((idhashtb (gnus-make-hashtable 1024))
  3822. (thhashtb (gnus-make-hashtable 1024))
  3823. (prev threads)
  3824. (result threads)
  3825. ids references id gthread gid entered ref)
  3826. (while threads
  3827. (when (setq references (mail-header-references (caar threads)))
  3828. (setq id (mail-header-id (caar threads))
  3829. ids (inline (gnus-split-references references))
  3830. entered nil)
  3831. (while (setq ref (pop ids))
  3832. (setq ids (delete ref ids))
  3833. (if (not (setq gid (gnus-gethash ref idhashtb)))
  3834. (progn
  3835. (gnus-sethash ref id idhashtb)
  3836. (gnus-sethash id threads thhashtb))
  3837. (setq gthread (gnus-gethash gid thhashtb))
  3838. (unless entered
  3839. ;; We enter a dummy root into the thread, if we
  3840. ;; haven't done that already.
  3841. (unless (stringp (caar gthread))
  3842. (setcar gthread (list (mail-header-subject (caar gthread))
  3843. (car gthread))))
  3844. ;; We add this new gathered thread to this gathered
  3845. ;; thread.
  3846. (setcdr (car gthread)
  3847. (nconc (cdar gthread) (list (car threads)))))
  3848. ;; Add it into the thread hash table.
  3849. (gnus-sethash id gthread thhashtb)
  3850. (setq entered t)
  3851. ;; Remove it from the list of threads.
  3852. (setcdr prev (cdr threads))
  3853. (setq threads prev))))
  3854. (setq prev threads)
  3855. (setq threads (cdr threads)))
  3856. result))
  3857. (defun gnus-sort-gathered-threads (threads)
  3858. "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
  3859. (let ((result threads))
  3860. (while threads
  3861. (when (stringp (caar threads))
  3862. (setcdr (car threads)
  3863. (sort (cdar threads) gnus-sort-gathered-threads-function)))
  3864. (setq threads (cdr threads)))
  3865. result))
  3866. (defun gnus-thread-loop-p (root thread)
  3867. "Say whether ROOT is in THREAD."
  3868. (let ((stack (list thread))
  3869. (infloop 0)
  3870. th)
  3871. (while (setq thread (pop stack))
  3872. (setq th (cdr thread))
  3873. (while (and th
  3874. (not (eq (caar th) root)))
  3875. (pop th))
  3876. (if th
  3877. ;; We have found a loop.
  3878. (let (ref-dep)
  3879. (setcdr thread (delq (car th) (cdr thread)))
  3880. (if (boundp (setq ref-dep (intern "none"
  3881. gnus-newsgroup-dependencies)))
  3882. (setcdr (symbol-value ref-dep)
  3883. (nconc (cdr (symbol-value ref-dep))
  3884. (list (car th))))
  3885. (set ref-dep (list nil (car th))))
  3886. (setq infloop 1
  3887. stack nil))
  3888. ;; Push all the subthreads onto the stack.
  3889. (push (cdr thread) stack)))
  3890. infloop))
  3891. (defun gnus-make-threads ()
  3892. "Go through the dependency hashtb and find the roots. Return all threads."
  3893. (let (threads)
  3894. (while (catch 'infloop
  3895. (mapatoms
  3896. (lambda (refs)
  3897. ;; Deal with self-referencing References loops.
  3898. (when (and (car (symbol-value refs))
  3899. (not (zerop
  3900. (apply
  3901. '+
  3902. (mapcar
  3903. (lambda (thread)
  3904. (gnus-thread-loop-p
  3905. (car (symbol-value refs)) thread))
  3906. (cdr (symbol-value refs)))))))
  3907. (setq threads nil)
  3908. (throw 'infloop t))
  3909. (unless (car (symbol-value refs))
  3910. ;; These threads do not refer back to any other
  3911. ;; articles, so they're roots.
  3912. (setq threads (append (cdr (symbol-value refs)) threads))))
  3913. gnus-newsgroup-dependencies)))
  3914. threads))
  3915. ;; Build the thread tree.
  3916. (defsubst gnus-dependencies-add-header (header dependencies force-new)
  3917. "Enter HEADER into the DEPENDENCIES table if it is not already there.
  3918. If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
  3919. if it was already present.
  3920. If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
  3921. will not be entered in the DEPENDENCIES table. Otherwise duplicate
  3922. Message-IDs will be renamed to a unique Message-ID before being
  3923. entered.
  3924. Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
  3925. (let* ((id (mail-header-id header))
  3926. (id-dep (and id (intern id dependencies)))
  3927. parent-id ref ref-dep ref-header replaced)
  3928. ;; Enter this `header' in the `dependencies' table.
  3929. (cond
  3930. ((not id-dep)
  3931. (setq header nil))
  3932. ;; The first two cases do the normal part: enter a new `header'
  3933. ;; in the `dependencies' table.
  3934. ((not (boundp id-dep))
  3935. (set id-dep (list header)))
  3936. ((null (car (symbol-value id-dep)))
  3937. (setcar (symbol-value id-dep) header))
  3938. ;; From here the `header' was already present in the
  3939. ;; `dependencies' table.
  3940. (force-new
  3941. ;; Overrides an existing entry;
  3942. ;; just set the header part of the entry.
  3943. (setcar (symbol-value id-dep) header)
  3944. (setq replaced t))
  3945. ;; Renames the existing `header' to a unique Message-ID.
  3946. ((not gnus-summary-ignore-duplicates)
  3947. ;; An article with this Message-ID has already been seen.
  3948. ;; We rename the Message-ID.
  3949. (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
  3950. (list header))
  3951. (mail-header-set-id header id))
  3952. ;; The last case ignores an existing entry, except it adds any
  3953. ;; additional Xrefs (in case the two articles came from different
  3954. ;; servers.
  3955. ;; Also sets `header' to nil meaning that the `dependencies'
  3956. ;; table was *not* modified.
  3957. (t
  3958. (mail-header-set-xref
  3959. (car (symbol-value id-dep))
  3960. (concat (or (mail-header-xref (car (symbol-value id-dep)))
  3961. "")
  3962. (or (mail-header-xref header) "")))
  3963. (setq header nil)))
  3964. (when (and header (not replaced))
  3965. ;; First check that we are not creating a References loop.
  3966. (setq parent-id (gnus-parent-id (mail-header-references header)))
  3967. (setq ref parent-id)
  3968. (while (and ref
  3969. (setq ref-dep (intern-soft ref dependencies))
  3970. (boundp ref-dep)
  3971. (setq ref-header (car (symbol-value ref-dep))))
  3972. (if (string= id ref)
  3973. ;; Yuk! This is a reference loop. Make the article be a
  3974. ;; root article.
  3975. (progn
  3976. (mail-header-set-references (car (symbol-value id-dep)) "none")
  3977. (setq ref nil)
  3978. (setq parent-id nil))
  3979. (setq ref (gnus-parent-id (mail-header-references ref-header)))))
  3980. (setq ref-dep (intern (or parent-id "none") dependencies))
  3981. (if (boundp ref-dep)
  3982. (setcdr (symbol-value ref-dep)
  3983. (nconc (cdr (symbol-value ref-dep))
  3984. (list (symbol-value id-dep))))
  3985. (set ref-dep (list nil (symbol-value id-dep)))))
  3986. header))
  3987. (defun gnus-extract-message-id-from-in-reply-to (string)
  3988. (if (string-match "<[^>]+>" string)
  3989. (substring string (match-beginning 0) (match-end 0))
  3990. nil))
  3991. (defun gnus-build-sparse-threads ()
  3992. (let ((headers gnus-newsgroup-headers)
  3993. (mail-parse-charset gnus-newsgroup-charset)
  3994. (gnus-summary-ignore-duplicates t)
  3995. header references generation relations
  3996. subject child end new-child date)
  3997. ;; First we create an alist of generations/relations, where
  3998. ;; generations is how much we trust the relation, and the relation
  3999. ;; is parent/child.
  4000. (gnus-message 7 "Making sparse threads...")
  4001. (save-excursion
  4002. (nnheader-set-temp-buffer " *gnus sparse threads*")
  4003. (while (setq header (pop headers))
  4004. (when (and (setq references (mail-header-references header))
  4005. (not (string= references "")))
  4006. (insert references)
  4007. (setq child (mail-header-id header)
  4008. subject (mail-header-subject header)
  4009. date (mail-header-date header)
  4010. generation 0)
  4011. (while (search-backward ">" nil t)
  4012. (setq end (1+ (point)))
  4013. (when (search-backward "<" nil t)
  4014. (setq new-child (buffer-substring (point) end))
  4015. (push (list (incf generation)
  4016. child (setq child new-child)
  4017. subject date)
  4018. relations)))
  4019. (when child
  4020. (push (list (1+ generation) child nil subject) relations))
  4021. (erase-buffer)))
  4022. (kill-buffer (current-buffer)))
  4023. ;; Sort over trustworthiness.
  4024. (dolist (relation (sort relations 'car-less-than-car))
  4025. (when (gnus-dependencies-add-header
  4026. (make-full-mail-header
  4027. gnus-reffed-article-number
  4028. (nth 3 relation) "" (or (nth 4 relation) "")
  4029. (nth 1 relation)
  4030. (or (nth 2 relation) "") 0 0 "")
  4031. gnus-newsgroup-dependencies nil)
  4032. (push gnus-reffed-article-number gnus-newsgroup-limit)
  4033. (push gnus-reffed-article-number gnus-newsgroup-sparse)
  4034. (push (cons gnus-reffed-article-number gnus-sparse-mark)
  4035. gnus-newsgroup-reads)
  4036. (decf gnus-reffed-article-number)))
  4037. (gnus-message 7 "Making sparse threads...done")))
  4038. (defun gnus-build-old-threads ()
  4039. ;; Look at all the articles that refer back to old articles, and
  4040. ;; fetch the headers for the articles that aren't there. This will
  4041. ;; build complete threads - if the roots haven't been expired by the
  4042. ;; server, that is.
  4043. (let ((mail-parse-charset gnus-newsgroup-charset)
  4044. id heads)
  4045. (mapatoms
  4046. (lambda (refs)
  4047. (when (not (car (symbol-value refs)))
  4048. (setq heads (cdr (symbol-value refs)))
  4049. (while heads
  4050. (if (memq (mail-header-number (caar heads))
  4051. gnus-newsgroup-dormant)
  4052. (setq heads (cdr heads))
  4053. (setq id (symbol-name refs))
  4054. (while (and (setq id (gnus-build-get-header id))
  4055. (not (car (gnus-id-to-thread id)))))
  4056. (setq heads nil)))))
  4057. gnus-newsgroup-dependencies)))
  4058. (defsubst gnus-remove-odd-characters (string)
  4059. "Translate STRING into something that doesn't contain weird characters."
  4060. (mm-subst-char-in-string
  4061. ?\r ?\-
  4062. (mm-subst-char-in-string ?\n ?\- string t) t))
  4063. ;; This function has to be called with point after the article number
  4064. ;; on the beginning of the line.
  4065. (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
  4066. (let ((eol (point-at-eol))
  4067. (buffer (current-buffer))
  4068. header references in-reply-to)
  4069. ;; overview: [num subject from date id refs chars lines misc]
  4070. (unwind-protect
  4071. (let (x)
  4072. (narrow-to-region (point) eol)
  4073. (unless (eobp)
  4074. (forward-char))
  4075. (setq header
  4076. (make-full-mail-header
  4077. number ; number
  4078. (condition-case () ; subject
  4079. (gnus-remove-odd-characters
  4080. (funcall gnus-decode-encoded-word-function
  4081. (setq x (nnheader-nov-field))))
  4082. (error x))
  4083. (condition-case () ; from
  4084. (gnus-remove-odd-characters
  4085. (funcall gnus-decode-encoded-address-function
  4086. (setq x (nnheader-nov-field))))
  4087. (error x))
  4088. (nnheader-nov-field) ; date
  4089. (nnheader-nov-read-message-id number) ; id
  4090. (setq references (nnheader-nov-field)) ; refs
  4091. (nnheader-nov-read-integer) ; chars
  4092. (nnheader-nov-read-integer) ; lines
  4093. (unless (eobp)
  4094. (if (looking-at "Xref: ")
  4095. (goto-char (match-end 0)))
  4096. (nnheader-nov-field)) ; Xref
  4097. (nnheader-nov-parse-extra)))) ; extra
  4098. (widen))
  4099. (when (and (string= references "")
  4100. (setq in-reply-to (mail-header-extra header))
  4101. (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
  4102. (mail-header-set-references
  4103. header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
  4104. (when gnus-alter-header-function
  4105. (funcall gnus-alter-header-function header))
  4106. (gnus-dependencies-add-header header dependencies force-new)))
  4107. (defun gnus-build-get-header (id)
  4108. "Look through the buffer of NOV lines and find the header to ID.
  4109. Enter this line into the dependencies hash table, and return
  4110. the id of the parent article (if any)."
  4111. (let ((deps gnus-newsgroup-dependencies)
  4112. found header)
  4113. (prog1
  4114. (with-current-buffer nntp-server-buffer
  4115. (let ((case-fold-search nil))
  4116. (goto-char (point-min))
  4117. (while (and (not found)
  4118. (search-forward id nil t))
  4119. (beginning-of-line)
  4120. (setq found (looking-at
  4121. (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
  4122. (regexp-quote id))))
  4123. (or found (beginning-of-line 2)))
  4124. (when found
  4125. (beginning-of-line)
  4126. (and
  4127. (setq header (gnus-nov-parse-line
  4128. (read (current-buffer)) deps))
  4129. (gnus-parent-id (mail-header-references header))))))
  4130. (when header
  4131. (let ((number (mail-header-number header)))
  4132. (push number gnus-newsgroup-limit)
  4133. (push header gnus-newsgroup-headers)
  4134. (if (memq number gnus-newsgroup-unselected)
  4135. (progn
  4136. (setq gnus-newsgroup-unreads
  4137. (gnus-add-to-sorted-list gnus-newsgroup-unreads
  4138. number))
  4139. (setq gnus-newsgroup-unselected
  4140. (delq number gnus-newsgroup-unselected)))
  4141. (push number gnus-newsgroup-ancient)))))))
  4142. (defun gnus-build-all-threads ()
  4143. "Read all the headers."
  4144. (let ((gnus-summary-ignore-duplicates t)
  4145. (mail-parse-charset gnus-newsgroup-charset)
  4146. (dependencies gnus-newsgroup-dependencies)
  4147. header article)
  4148. (with-current-buffer nntp-server-buffer
  4149. (let ((case-fold-search nil))
  4150. (goto-char (point-min))
  4151. (while (not (eobp))
  4152. (ignore-errors
  4153. (setq article (read (current-buffer))
  4154. header (gnus-nov-parse-line article dependencies t)))
  4155. (when header
  4156. (with-current-buffer gnus-summary-buffer
  4157. (push header gnus-newsgroup-headers)
  4158. (if (memq (setq article (mail-header-number header))
  4159. gnus-newsgroup-unselected)
  4160. (progn
  4161. (setq gnus-newsgroup-unreads
  4162. (gnus-add-to-sorted-list
  4163. gnus-newsgroup-unreads article))
  4164. (setq gnus-newsgroup-unselected
  4165. (delq article gnus-newsgroup-unselected)))
  4166. (push article gnus-newsgroup-ancient)))
  4167. (forward-line 1)))))))
  4168. (defun gnus-summary-update-article-line (article header)
  4169. "Update the line for ARTICLE using HEADER."
  4170. (let* ((id (mail-header-id header))
  4171. (thread (gnus-id-to-thread id)))
  4172. (unless thread
  4173. (error "Article in no thread"))
  4174. ;; Update the thread.
  4175. (setcar thread header)
  4176. (gnus-summary-goto-subject article)
  4177. (let* ((datal (gnus-data-find-list article))
  4178. (data (car datal))
  4179. (inhibit-read-only t)
  4180. (level (gnus-summary-thread-level)))
  4181. (gnus-delete-line)
  4182. (let ((inserted (- (point)
  4183. (progn
  4184. (gnus-summary-insert-line
  4185. header level nil
  4186. (memq article gnus-newsgroup-undownloaded)
  4187. (gnus-article-mark article)
  4188. (memq article gnus-newsgroup-replied)
  4189. (memq article gnus-newsgroup-expirable)
  4190. ;; Only insert the Subject string when it's different
  4191. ;; from the previous Subject string.
  4192. (if (and
  4193. gnus-show-threads
  4194. (gnus-subject-equal
  4195. (condition-case ()
  4196. (mail-header-subject
  4197. (gnus-data-header
  4198. (cadr
  4199. (gnus-data-find-list
  4200. article
  4201. (gnus-data-list t)))))
  4202. ;; Error on the side of excessive subjects.
  4203. (error ""))
  4204. (mail-header-subject header)))
  4205. ""
  4206. (mail-header-subject header))
  4207. nil (cdr (assq article gnus-newsgroup-scored))
  4208. (memq article gnus-newsgroup-processable))
  4209. (point)))))
  4210. (when (cdr datal)
  4211. (gnus-data-update-list
  4212. (cdr datal)
  4213. (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
  4214. (defun gnus-summary-update-article (article &optional iheader)
  4215. "Update ARTICLE in the summary buffer."
  4216. (set-buffer gnus-summary-buffer)
  4217. (let* ((header (gnus-summary-article-header article))
  4218. (id (mail-header-id header))
  4219. (data (gnus-data-find article))
  4220. (thread (gnus-id-to-thread id))
  4221. (references (mail-header-references header))
  4222. (parent
  4223. (gnus-id-to-thread
  4224. (or (gnus-parent-id
  4225. (when (and references
  4226. (not (equal "" references)))
  4227. references))
  4228. "none")))
  4229. (inhibit-read-only t)
  4230. (old (car thread)))
  4231. (when thread
  4232. (unless iheader
  4233. (setcar thread nil)
  4234. (when parent
  4235. (delq thread parent)))
  4236. (if (gnus-summary-insert-subject id header)
  4237. ;; Set the (possibly) new article number in the data structure.
  4238. (gnus-data-set-number data (gnus-id-to-article id))
  4239. (setcar thread old)
  4240. nil))))
  4241. (defun gnus-rebuild-thread (id &optional line)
  4242. "Rebuild the thread containing ID.
  4243. If LINE, insert the rebuilt thread starting on line LINE."
  4244. (let ((inhibit-read-only t)
  4245. old-pos current thread data)
  4246. (if (not gnus-show-threads)
  4247. (setq thread (list (car (gnus-id-to-thread id))))
  4248. ;; Get the thread this article is part of.
  4249. (setq thread (gnus-remove-thread id)))
  4250. (setq old-pos (point-at-bol))
  4251. (setq current (save-excursion
  4252. (and (re-search-backward "[\r\n]" nil t)
  4253. (gnus-summary-article-number))))
  4254. ;; If this is a gathered thread, we have to go some re-gathering.
  4255. (when (stringp (car thread))
  4256. (let ((subject (car thread))
  4257. roots thr)
  4258. (setq thread (cdr thread))
  4259. (while thread
  4260. (unless (memq (setq thr (gnus-id-to-thread
  4261. (gnus-root-id
  4262. (mail-header-id (caar thread)))))
  4263. roots)
  4264. (push thr roots))
  4265. (setq thread (cdr thread)))
  4266. ;; We now have all (unique) roots.
  4267. (if (= (length roots) 1)
  4268. ;; All the loose roots are now one solid root.
  4269. (setq thread (car roots))
  4270. (setq thread (cons subject (gnus-sort-threads roots))))))
  4271. (let (threads)
  4272. ;; We then insert this thread into the summary buffer.
  4273. (when line
  4274. (goto-char (point-min))
  4275. (forward-line (1- line)))
  4276. (let (gnus-newsgroup-data gnus-newsgroup-threads)
  4277. (if gnus-show-threads
  4278. (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
  4279. (gnus-summary-prepare-unthreaded thread))
  4280. (setq data (nreverse gnus-newsgroup-data))
  4281. (setq threads gnus-newsgroup-threads))
  4282. ;; We splice the new data into the data structure.
  4283. ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
  4284. ;;!!! then we want to insert at the beginning of the buffer.
  4285. ;;!!! That happens to be true with Gnus now, but that may
  4286. ;;!!! change in the future. Perhaps.
  4287. (gnus-data-enter-list
  4288. (if line nil current) data (- (point) old-pos))
  4289. (setq gnus-newsgroup-threads
  4290. (nconc threads gnus-newsgroup-threads))
  4291. (gnus-data-compute-positions))))
  4292. (defun gnus-number-to-header (number)
  4293. "Return the header for article NUMBER."
  4294. (let ((headers gnus-newsgroup-headers))
  4295. (while (and headers
  4296. (not (= number (mail-header-number (car headers)))))
  4297. (pop headers))
  4298. (when headers
  4299. (car headers))))
  4300. (defun gnus-parent-headers (in-headers &optional generation)
  4301. "Return the headers of the GENERATIONth parent of HEADERS."
  4302. (unless generation
  4303. (setq generation 1))
  4304. (let ((parent t)
  4305. (headers in-headers)
  4306. references)
  4307. (while (and parent
  4308. (not (zerop generation))
  4309. (setq references (mail-header-references headers)))
  4310. (setq headers (if (and references
  4311. (setq parent (gnus-parent-id references)))
  4312. (car (gnus-id-to-thread parent))
  4313. nil))
  4314. (decf generation))
  4315. (and (not (eq headers in-headers))
  4316. headers)))
  4317. (defun gnus-id-to-thread (id)
  4318. "Return the (sub-)thread where ID appears."
  4319. (gnus-gethash id gnus-newsgroup-dependencies))
  4320. (defun gnus-id-to-article (id)
  4321. "Return the article number of ID."
  4322. (let ((thread (gnus-id-to-thread id)))
  4323. (when (and thread
  4324. (car thread))
  4325. (mail-header-number (car thread)))))
  4326. (defun gnus-id-to-header (id)
  4327. "Return the article headers of ID."
  4328. (car (gnus-id-to-thread id)))
  4329. (defun gnus-article-displayed-root-p (article)
  4330. "Say whether ARTICLE is a root(ish) article."
  4331. (let ((level (gnus-summary-thread-level article))
  4332. (refs (mail-header-references (gnus-summary-article-header article)))
  4333. particle)
  4334. (cond
  4335. ((null level) nil)
  4336. ((zerop level) t)
  4337. ((null refs) t)
  4338. ((null (gnus-parent-id refs)) t)
  4339. ((and (= 1 level)
  4340. (null (setq particle (gnus-id-to-article
  4341. (gnus-parent-id refs))))
  4342. (null (gnus-summary-thread-level particle)))))))
  4343. (defun gnus-root-id (id)
  4344. "Return the id of the root of the thread where ID appears."
  4345. (let (last-id prev)
  4346. (while (and id (setq prev (car (gnus-id-to-thread id))))
  4347. (setq last-id id
  4348. id (gnus-parent-id (mail-header-references prev))))
  4349. last-id))
  4350. (defun gnus-articles-in-thread (thread)
  4351. "Return the list of articles in THREAD."
  4352. (cons (mail-header-number (car thread))
  4353. (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
  4354. (defun gnus-remove-thread (id &optional dont-remove)
  4355. "Remove the thread that has ID in it."
  4356. (let (headers thread last-id)
  4357. ;; First go up in this thread until we find the root.
  4358. (setq last-id (gnus-root-id id)
  4359. headers (message-flatten-list (gnus-id-to-thread last-id)))
  4360. ;; We have now found the real root of this thread. It might have
  4361. ;; been gathered into some loose thread, so we have to search
  4362. ;; through the threads to find the thread we wanted.
  4363. (let ((threads gnus-newsgroup-threads)
  4364. sub)
  4365. (while threads
  4366. (setq sub (car threads))
  4367. (if (stringp (car sub))
  4368. ;; This is a gathered thread, so we look at the roots
  4369. ;; below it to find whether this article is in this
  4370. ;; gathered root.
  4371. (progn
  4372. (setq sub (cdr sub))
  4373. (while sub
  4374. (when (member (caar sub) headers)
  4375. (setq thread (car threads)
  4376. threads nil
  4377. sub nil))
  4378. (setq sub (cdr sub))))
  4379. ;; It's an ordinary thread, so we check it.
  4380. (when (eq (car sub) (car headers))
  4381. (setq thread sub
  4382. threads nil)))
  4383. (setq threads (cdr threads)))
  4384. ;; If this article is in no thread, then it's a root.
  4385. (if thread
  4386. (unless dont-remove
  4387. (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
  4388. (setq thread (gnus-id-to-thread last-id)))
  4389. (when thread
  4390. (prog1
  4391. thread ; We return this thread.
  4392. (unless dont-remove
  4393. (if (stringp (car thread))
  4394. (progn
  4395. ;; If we use dummy roots, then we have to remove the
  4396. ;; dummy root as well.
  4397. (when (eq gnus-summary-make-false-root 'dummy)
  4398. ;; We go to the dummy root by going to
  4399. ;; the first sub-"thread", and then one line up.
  4400. (gnus-summary-goto-article
  4401. (mail-header-number (caadr thread)))
  4402. (forward-line -1)
  4403. (gnus-delete-line)
  4404. (gnus-data-compute-positions))
  4405. (setq thread (cdr thread))
  4406. (while thread
  4407. (gnus-remove-thread-1 (car thread))
  4408. (setq thread (cdr thread))))
  4409. (gnus-remove-thread-1 thread))))))))
  4410. (defun gnus-remove-thread-1 (thread)
  4411. "Remove the thread THREAD recursively."
  4412. (let ((number (mail-header-number (pop thread)))
  4413. d)
  4414. (setq thread (reverse thread))
  4415. (while thread
  4416. (gnus-remove-thread-1 (pop thread)))
  4417. (when (setq d (gnus-data-find number))
  4418. (goto-char (gnus-data-pos d))
  4419. (gnus-summary-show-thread)
  4420. (gnus-data-remove
  4421. number
  4422. (- (point-at-bol)
  4423. (prog1
  4424. (1+ (point-at-eol))
  4425. (gnus-delete-line)))))))
  4426. (defun gnus-sort-threads-recursive (threads func)
  4427. ;; Responsible for sorting the root articles of threads.
  4428. (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
  4429. 'gnus-thread-sort-functions)
  4430. func
  4431. (gnus-make-sort-function
  4432. gnus-subthread-sort-functions))))
  4433. (sort (mapcar (lambda (thread)
  4434. (cons (car thread)
  4435. (and (cdr thread)
  4436. (gnus-sort-subthreads-recursive
  4437. (cdr thread) subthread-sort-func))))
  4438. threads) func)))
  4439. (defun gnus-sort-subthreads-recursive (threads func)
  4440. ;; Responsible for sorting subthreads.
  4441. (sort (mapcar (lambda (thread)
  4442. (cons (car thread)
  4443. (and (cdr thread)
  4444. (gnus-sort-subthreads-recursive (cdr thread) func))))
  4445. threads) func))
  4446. (defun gnus-sort-threads-loop (threads func)
  4447. (let* ((superthread (cons nil threads))
  4448. (stack (list (cons superthread threads)))
  4449. remaining-threads thread)
  4450. (while stack
  4451. (setq remaining-threads (cdr (car stack)))
  4452. (if remaining-threads
  4453. (progn (setq thread (car remaining-threads))
  4454. (setcdr (car stack) (cdr remaining-threads))
  4455. (if (cdr thread)
  4456. (push (cons thread (cdr thread)) stack)))
  4457. (setq thread (caar stack))
  4458. (setcdr thread (sort (cdr thread) func))
  4459. (pop stack)))
  4460. (cdr superthread)))
  4461. (defun gnus-sort-threads (threads)
  4462. "Sort THREADS."
  4463. (if (not gnus-thread-sort-functions)
  4464. threads
  4465. (gnus-message 8 "Sorting threads...")
  4466. (prog1
  4467. (condition-case nil
  4468. (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
  4469. (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
  4470. (gnus-sort-threads-recursive threads sort-func))
  4471. ;; Even after binding max-lisp-eval-depth, the recursive
  4472. ;; sorter might fail for very long threads. In that case,
  4473. ;; try using a (less well-tested) non-recursive sorter.
  4474. (error (gnus-message 9 "Sorting threads with loop...")
  4475. (gnus-sort-threads-loop
  4476. threads (gnus-make-sort-function
  4477. gnus-thread-sort-functions))))
  4478. (gnus-message 8 "Sorting threads...done"))))
  4479. (defun gnus-sort-articles (articles)
  4480. "Sort ARTICLES."
  4481. (when gnus-article-sort-functions
  4482. (gnus-message 7 "Sorting articles...")
  4483. (prog1
  4484. (setq gnus-newsgroup-headers
  4485. (sort articles (gnus-make-sort-function
  4486. gnus-article-sort-functions)))
  4487. (gnus-message 7 "Sorting articles...done"))))
  4488. ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
  4489. (defmacro gnus-thread-header (thread)
  4490. "Return header of first article in THREAD.
  4491. Note that THREAD must never, ever be anything else than a variable -
  4492. using some other form will lead to serious barfage."
  4493. (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
  4494. ;; (8% speedup to gnus-summary-prepare, just for fun :-)
  4495. (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
  4496. (vector thread) 2))
  4497. (defsubst gnus-article-sort-by-number (h1 h2)
  4498. "Sort articles by article number."
  4499. (< (mail-header-number h1)
  4500. (mail-header-number h2)))
  4501. (defun gnus-thread-sort-by-number (h1 h2)
  4502. "Sort threads by root article number."
  4503. (gnus-article-sort-by-number
  4504. (gnus-thread-header h1) (gnus-thread-header h2)))
  4505. (defsubst gnus-article-sort-by-random (h1 h2)
  4506. "Sort articles randomly."
  4507. (zerop (random 2)))
  4508. (defun gnus-thread-sort-by-random (h1 h2)
  4509. "Sort threads randomly."
  4510. (gnus-article-sort-by-random
  4511. (gnus-thread-header h1) (gnus-thread-header h2)))
  4512. (defsubst gnus-article-sort-by-lines (h1 h2)
  4513. "Sort articles by article Lines header."
  4514. (< (mail-header-lines h1)
  4515. (mail-header-lines h2)))
  4516. (defun gnus-thread-sort-by-lines (h1 h2)
  4517. "Sort threads by root article Lines header."
  4518. (gnus-article-sort-by-lines
  4519. (gnus-thread-header h1) (gnus-thread-header h2)))
  4520. (defsubst gnus-article-sort-by-chars (h1 h2)
  4521. "Sort articles by octet length."
  4522. (< (mail-header-chars h1)
  4523. (mail-header-chars h2)))
  4524. (defun gnus-thread-sort-by-chars (h1 h2)
  4525. "Sort threads by root article octet length."
  4526. (gnus-article-sort-by-chars
  4527. (gnus-thread-header h1) (gnus-thread-header h2)))
  4528. (defsubst gnus-article-sort-by-author (h1 h2)
  4529. "Sort articles by root author."
  4530. (gnus-string<
  4531. (let ((extract (funcall
  4532. gnus-extract-address-components
  4533. (mail-header-from h1))))
  4534. (or (car extract) (cadr extract) ""))
  4535. (let ((extract (funcall
  4536. gnus-extract-address-components
  4537. (mail-header-from h2))))
  4538. (or (car extract) (cadr extract) ""))))
  4539. (defun gnus-thread-sort-by-author (h1 h2)
  4540. "Sort threads by root author."
  4541. (gnus-article-sort-by-author
  4542. (gnus-thread-header h1) (gnus-thread-header h2)))
  4543. (defsubst gnus-article-sort-by-recipient (h1 h2)
  4544. "Sort articles by recipient."
  4545. (gnus-string<
  4546. (let ((extract (funcall
  4547. gnus-extract-address-components
  4548. (or (cdr (assq 'To (mail-header-extra h1))) ""))))
  4549. (or (car extract) (cadr extract)))
  4550. (let ((extract (funcall
  4551. gnus-extract-address-components
  4552. (or (cdr (assq 'To (mail-header-extra h2))) ""))))
  4553. (or (car extract) (cadr extract)))))
  4554. (defun gnus-thread-sort-by-recipient (h1 h2)
  4555. "Sort threads by root recipient."
  4556. (gnus-article-sort-by-recipient
  4557. (gnus-thread-header h1) (gnus-thread-header h2)))
  4558. (defsubst gnus-article-sort-by-subject (h1 h2)
  4559. "Sort articles by root subject."
  4560. (gnus-string<
  4561. (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
  4562. (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
  4563. (defun gnus-thread-sort-by-subject (h1 h2)
  4564. "Sort threads by root subject."
  4565. (gnus-article-sort-by-subject
  4566. (gnus-thread-header h1) (gnus-thread-header h2)))
  4567. (defsubst gnus-article-sort-by-date (h1 h2)
  4568. "Sort articles by root article date."
  4569. (time-less-p
  4570. (gnus-date-get-time (mail-header-date h1))
  4571. (gnus-date-get-time (mail-header-date h2))))
  4572. (defun gnus-thread-sort-by-date (h1 h2)
  4573. "Sort threads by root article date."
  4574. (gnus-article-sort-by-date
  4575. (gnus-thread-header h1) (gnus-thread-header h2)))
  4576. (defsubst gnus-article-sort-by-score (h1 h2)
  4577. "Sort articles by root article score.
  4578. Unscored articles will be counted as having a score of zero."
  4579. (> (or (cdr (assq (mail-header-number h1)
  4580. gnus-newsgroup-scored))
  4581. gnus-summary-default-score 0)
  4582. (or (cdr (assq (mail-header-number h2)
  4583. gnus-newsgroup-scored))
  4584. gnus-summary-default-score 0)))
  4585. (defun gnus-thread-sort-by-score (h1 h2)
  4586. "Sort threads by root article score."
  4587. (gnus-article-sort-by-score
  4588. (gnus-thread-header h1) (gnus-thread-header h2)))
  4589. (defun gnus-thread-sort-by-total-score (h1 h2)
  4590. "Sort threads by the sum of all scores in the thread.
  4591. Unscored articles will be counted as having a score of zero."
  4592. (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
  4593. (defun gnus-thread-total-score (thread)
  4594. ;; This function find the total score of THREAD.
  4595. (cond
  4596. ((null thread)
  4597. 0)
  4598. ((consp thread)
  4599. (if (stringp (car thread))
  4600. (apply gnus-thread-score-function 0
  4601. (mapcar 'gnus-thread-total-score-1 (cdr thread)))
  4602. (gnus-thread-total-score-1 thread)))
  4603. (t
  4604. (gnus-thread-total-score-1 (list thread)))))
  4605. (defun gnus-article-sort-by-most-recent-number (h1 h2)
  4606. "Sort articles by number."
  4607. (gnus-article-sort-by-number h1 h2))
  4608. (defun gnus-thread-sort-by-most-recent-number (h1 h2)
  4609. "Sort threads such that the thread with the most recently arrived article comes first."
  4610. (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
  4611. (defun gnus-thread-highest-number (thread)
  4612. "Return the highest article number in THREAD."
  4613. (apply 'max (mapcar (lambda (header)
  4614. (mail-header-number header))
  4615. (message-flatten-list thread))))
  4616. (defun gnus-article-sort-by-most-recent-date (h1 h2)
  4617. "Sort articles by number."
  4618. (gnus-article-sort-by-date h1 h2))
  4619. (defun gnus-thread-sort-by-most-recent-date (h1 h2)
  4620. "Sort threads such that the thread with the most recently dated article comes first."
  4621. (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
  4622. ; Since this is called not only to sort the top-level threads, but
  4623. ; also in recursive sorts to order the articles within a thread, each
  4624. ; article will be processed many times. Thus it speeds things up
  4625. ; quite a bit to use gnus-date-get-time, which caches the time value.
  4626. (defun gnus-thread-latest-date (thread)
  4627. "Return the highest article date in THREAD."
  4628. (apply 'max
  4629. (mapcar (lambda (header) (gnus-float-time
  4630. (gnus-date-get-time
  4631. (mail-header-date header))))
  4632. (message-flatten-list thread))))
  4633. (defun gnus-thread-total-score-1 (root)
  4634. ;; This function find the total score of the thread below ROOT.
  4635. (setq root (car root))
  4636. (apply gnus-thread-score-function
  4637. (or (append
  4638. (mapcar 'gnus-thread-total-score
  4639. (cdr (gnus-id-to-thread (mail-header-id root))))
  4640. (when (> (mail-header-number root) 0)
  4641. (list (or (cdr (assq (mail-header-number root)
  4642. gnus-newsgroup-scored))
  4643. gnus-summary-default-score 0))))
  4644. (list gnus-summary-default-score)
  4645. '(0))))
  4646. ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
  4647. (defvar gnus-tmp-prev-subject nil)
  4648. (defvar gnus-tmp-false-parent nil)
  4649. (defvar gnus-tmp-root-expunged nil)
  4650. (defvar gnus-tmp-dummy-line nil)
  4651. (defun gnus-extra-header (type &optional header)
  4652. "Return the extra header of TYPE."
  4653. (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
  4654. ""))
  4655. (defvar gnus-tmp-thread-tree-header-string "")
  4656. (defcustom gnus-sum-thread-tree-root "> "
  4657. "With %B spec, used for the root of a thread.
  4658. If nil, use subject instead."
  4659. :version "22.1"
  4660. :type '(radio (const :format "%v " nil) string)
  4661. :group 'gnus-thread)
  4662. (defcustom gnus-sum-thread-tree-false-root "> "
  4663. "With %B spec, used for a false root of a thread.
  4664. If nil, use subject instead."
  4665. :version "22.1"
  4666. :type '(radio (const :format "%v " nil) string)
  4667. :group 'gnus-thread)
  4668. (defcustom gnus-sum-thread-tree-single-indent ""
  4669. "With %B spec, used for a thread with just one message.
  4670. If nil, use subject instead."
  4671. :version "22.1"
  4672. :type '(radio (const :format "%v " nil) string)
  4673. :group 'gnus-thread)
  4674. (defcustom gnus-sum-thread-tree-vertical "| "
  4675. "With %B spec, used for drawing a vertical line."
  4676. :version "22.1"
  4677. :type 'string
  4678. :group 'gnus-thread)
  4679. (defcustom gnus-sum-thread-tree-indent " "
  4680. "With %B spec, used for indenting."
  4681. :version "22.1"
  4682. :type 'string
  4683. :group 'gnus-thread)
  4684. (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
  4685. "With %B spec, used for a leaf with brothers."
  4686. :version "22.1"
  4687. :type 'string
  4688. :group 'gnus-thread)
  4689. (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
  4690. "With %B spec, used for a leaf without brothers."
  4691. :version "22.1"
  4692. :type 'string
  4693. :group 'gnus-thread)
  4694. (defcustom gnus-summary-display-while-building nil
  4695. "If non-nil, show and update the summary buffer as it's being built.
  4696. If the value is t, update the buffer after every line is inserted. If
  4697. the value is an integer (N), update the display every N lines."
  4698. :version "22.1"
  4699. :group 'gnus-thread
  4700. :type '(choice (const :tag "off" nil)
  4701. number
  4702. (const :tag "frequently" t)))
  4703. (defun gnus-summary-prepare-threads (threads)
  4704. "Prepare summary buffer from THREADS and indentation LEVEL.
  4705. THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
  4706. or a straight list of headers."
  4707. (gnus-message 7 "Generating summary...")
  4708. (setq gnus-newsgroup-threads threads)
  4709. (beginning-of-line)
  4710. (let ((gnus-tmp-level 0)
  4711. (default-score (or gnus-summary-default-score 0))
  4712. (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
  4713. (building-line-count gnus-summary-display-while-building)
  4714. (building-count (integerp gnus-summary-display-while-building))
  4715. thread number subject stack state gnus-tmp-gathered beg-match
  4716. new-roots gnus-tmp-new-adopts thread-end simp-subject
  4717. gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
  4718. gnus-tmp-replied gnus-tmp-subject-or-nil
  4719. gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
  4720. gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
  4721. gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
  4722. tree-stack)
  4723. (setq gnus-tmp-prev-subject nil
  4724. gnus-tmp-thread-tree-header-string "")
  4725. (if (vectorp (car threads))
  4726. ;; If this is a straight (sic) list of headers, then a
  4727. ;; threaded summary display isn't required, so we just create
  4728. ;; an unthreaded one.
  4729. (gnus-summary-prepare-unthreaded threads)
  4730. ;; Do the threaded display.
  4731. (if gnus-summary-display-while-building
  4732. (switch-to-buffer (buffer-name)))
  4733. (while (or threads stack gnus-tmp-new-adopts new-roots)
  4734. (if (and (= gnus-tmp-level 0)
  4735. (or (not stack)
  4736. (= (caar stack) 0))
  4737. (not gnus-tmp-false-parent)
  4738. (or gnus-tmp-new-adopts new-roots))
  4739. (if gnus-tmp-new-adopts
  4740. (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
  4741. thread (list (car gnus-tmp-new-adopts))
  4742. gnus-tmp-header (caar thread)
  4743. gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
  4744. (when new-roots
  4745. (setq thread (list (car new-roots))
  4746. gnus-tmp-header (caar thread)
  4747. new-roots (cdr new-roots))))
  4748. (if threads
  4749. ;; If there are some threads, we do them before the
  4750. ;; threads on the stack.
  4751. (setq thread threads
  4752. gnus-tmp-header (caar thread))
  4753. ;; There were no current threads, so we pop something off
  4754. ;; the stack.
  4755. (setq state (car stack)
  4756. gnus-tmp-level (car state)
  4757. tree-stack (cadr state)
  4758. thread (caddr state)
  4759. stack (cdr stack)
  4760. gnus-tmp-header (caar thread))))
  4761. (setq gnus-tmp-false-parent nil)
  4762. (setq gnus-tmp-root-expunged nil)
  4763. (setq thread-end nil)
  4764. (if (stringp gnus-tmp-header)
  4765. ;; The header is a dummy root.
  4766. (cond
  4767. ((eq gnus-summary-make-false-root 'adopt)
  4768. ;; We let the first article adopt the rest.
  4769. (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
  4770. (cddar thread)))
  4771. (setq gnus-tmp-gathered
  4772. (nconc (mapcar
  4773. (lambda (h) (mail-header-number (car h)))
  4774. (cddar thread))
  4775. gnus-tmp-gathered))
  4776. (setq thread (cons (list (caar thread)
  4777. (cadar thread))
  4778. (cdr thread)))
  4779. (setq gnus-tmp-level -1
  4780. gnus-tmp-false-parent t))
  4781. ((eq gnus-summary-make-false-root 'empty)
  4782. ;; We print adopted articles with empty subject fields.
  4783. (setq gnus-tmp-gathered
  4784. (nconc (mapcar
  4785. (lambda (h) (mail-header-number (car h)))
  4786. (cddar thread))
  4787. gnus-tmp-gathered))
  4788. (setq gnus-tmp-level -1))
  4789. ((eq gnus-summary-make-false-root 'dummy)
  4790. ;; We remember that we probably want to output a dummy
  4791. ;; root.
  4792. (setq gnus-tmp-dummy-line gnus-tmp-header)
  4793. (setq gnus-tmp-prev-subject gnus-tmp-header))
  4794. (t
  4795. ;; We do not make a root for the gathered
  4796. ;; sub-threads at all.
  4797. (setq gnus-tmp-level -1)))
  4798. (setq number (mail-header-number gnus-tmp-header)
  4799. subject (mail-header-subject gnus-tmp-header)
  4800. simp-subject (gnus-simplify-subject-fully subject))
  4801. (cond
  4802. ;; If the thread has changed subject, we might want to make
  4803. ;; this subthread into a root.
  4804. ((and (null gnus-thread-ignore-subject)
  4805. (not (zerop gnus-tmp-level))
  4806. gnus-tmp-prev-subject
  4807. (not (string= gnus-tmp-prev-subject simp-subject)))
  4808. (setq new-roots (nconc new-roots (list (car thread)))
  4809. thread-end t
  4810. gnus-tmp-header nil))
  4811. ;; If the article lies outside the current limit,
  4812. ;; then we do not display it.
  4813. ((not (memq number gnus-newsgroup-limit))
  4814. (setq gnus-tmp-gathered
  4815. (nconc (mapcar
  4816. (lambda (h) (mail-header-number (car h)))
  4817. (cdar thread))
  4818. gnus-tmp-gathered))
  4819. (setq gnus-tmp-new-adopts (if (cdar thread)
  4820. (append gnus-tmp-new-adopts
  4821. (cdar thread))
  4822. gnus-tmp-new-adopts)
  4823. thread-end t
  4824. gnus-tmp-header nil)
  4825. (when (zerop gnus-tmp-level)
  4826. (setq gnus-tmp-root-expunged t)))
  4827. ;; Perhaps this article is to be marked as read?
  4828. ((and gnus-summary-mark-below
  4829. (< (or (cdr (assq number gnus-newsgroup-scored))
  4830. default-score)
  4831. gnus-summary-mark-below)
  4832. ;; Don't touch sparse articles.
  4833. (not (gnus-summary-article-sparse-p number))
  4834. (not (gnus-summary-article-ancient-p number)))
  4835. (setq gnus-newsgroup-unreads
  4836. (delq number gnus-newsgroup-unreads))
  4837. (if gnus-newsgroup-auto-expire
  4838. (setq gnus-newsgroup-expirable
  4839. (gnus-add-to-sorted-list
  4840. gnus-newsgroup-expirable number))
  4841. (push (cons number gnus-low-score-mark)
  4842. gnus-newsgroup-reads))))
  4843. (when gnus-tmp-header
  4844. ;; We may have an old dummy line to output before this
  4845. ;; article.
  4846. (when (and gnus-tmp-dummy-line
  4847. (gnus-subject-equal
  4848. gnus-tmp-dummy-line
  4849. (mail-header-subject gnus-tmp-header)))
  4850. (gnus-summary-insert-dummy-line
  4851. gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
  4852. (setq gnus-tmp-dummy-line nil))
  4853. ;; Compute the mark.
  4854. (setq gnus-tmp-unread (gnus-article-mark number))
  4855. (push (gnus-data-make number gnus-tmp-unread (1+ (point))
  4856. gnus-tmp-header gnus-tmp-level)
  4857. gnus-newsgroup-data)
  4858. ;; Actually insert the line.
  4859. (setq
  4860. gnus-tmp-subject-or-nil
  4861. (cond
  4862. ((and gnus-thread-ignore-subject
  4863. gnus-tmp-prev-subject
  4864. (not (string= gnus-tmp-prev-subject simp-subject)))
  4865. subject)
  4866. ((zerop gnus-tmp-level)
  4867. (if (and (eq gnus-summary-make-false-root 'empty)
  4868. (memq number gnus-tmp-gathered)
  4869. gnus-tmp-prev-subject
  4870. (string= gnus-tmp-prev-subject simp-subject))
  4871. gnus-summary-same-subject
  4872. subject))
  4873. (t gnus-summary-same-subject)))
  4874. (if (and (eq gnus-summary-make-false-root 'adopt)
  4875. (= gnus-tmp-level 1)
  4876. (memq number gnus-tmp-gathered))
  4877. (setq gnus-tmp-opening-bracket ?\<
  4878. gnus-tmp-closing-bracket ?\>)
  4879. (setq gnus-tmp-opening-bracket ?\[
  4880. gnus-tmp-closing-bracket ?\]))
  4881. (if (>= gnus-tmp-level (length gnus-thread-indent-array))
  4882. (gnus-make-thread-indent-array
  4883. (max (* 2 (length gnus-thread-indent-array))
  4884. gnus-tmp-level)))
  4885. (setq
  4886. gnus-tmp-indentation
  4887. (aref gnus-thread-indent-array gnus-tmp-level)
  4888. gnus-tmp-lines (mail-header-lines gnus-tmp-header)
  4889. gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
  4890. gnus-summary-default-score 0)
  4891. gnus-tmp-score-char
  4892. (if (or (null gnus-summary-default-score)
  4893. (<= (abs (- gnus-tmp-score gnus-summary-default-score))
  4894. gnus-summary-zcore-fuzz))
  4895. ? ;Whitespace
  4896. (if (< gnus-tmp-score gnus-summary-default-score)
  4897. gnus-score-below-mark gnus-score-over-mark))
  4898. gnus-tmp-replied
  4899. (cond ((memq number gnus-newsgroup-processable)
  4900. gnus-process-mark)
  4901. ((memq number gnus-newsgroup-cached)
  4902. gnus-cached-mark)
  4903. ((memq number gnus-newsgroup-replied)
  4904. gnus-replied-mark)
  4905. ((memq number gnus-newsgroup-forwarded)
  4906. gnus-forwarded-mark)
  4907. ((memq number gnus-newsgroup-saved)
  4908. gnus-saved-mark)
  4909. ((memq number gnus-newsgroup-unseen)
  4910. gnus-unseen-mark)
  4911. (t gnus-no-mark))
  4912. gnus-tmp-downloaded
  4913. (cond ((memq number gnus-newsgroup-undownloaded)
  4914. gnus-undownloaded-mark)
  4915. (gnus-newsgroup-agentized
  4916. gnus-downloaded-mark)
  4917. (t
  4918. gnus-no-mark))
  4919. gnus-tmp-from (mail-header-from gnus-tmp-header)
  4920. gnus-tmp-name
  4921. (cond
  4922. ((string-match "<[^>]+> *$" gnus-tmp-from)
  4923. (setq beg-match (match-beginning 0))
  4924. (or (and (string-match "^\".+\"" gnus-tmp-from)
  4925. (substring gnus-tmp-from 1 (1- (match-end 0))))
  4926. (substring gnus-tmp-from 0 beg-match)))
  4927. ((string-match "(.+)" gnus-tmp-from)
  4928. (substring gnus-tmp-from
  4929. (1+ (match-beginning 0)) (1- (match-end 0))))
  4930. (t gnus-tmp-from))
  4931. ;; Do the %B string
  4932. gnus-tmp-thread-tree-header-string
  4933. (cond
  4934. ((not gnus-show-threads) "")
  4935. ((zerop gnus-tmp-level)
  4936. (cond ((cdar thread)
  4937. (or gnus-sum-thread-tree-root subject))
  4938. (gnus-tmp-new-adopts
  4939. (or gnus-sum-thread-tree-false-root subject))
  4940. (t
  4941. (or gnus-sum-thread-tree-single-indent subject))))
  4942. (t
  4943. (concat (apply 'concat
  4944. (mapcar (lambda (item)
  4945. (if (= item 1)
  4946. gnus-sum-thread-tree-vertical
  4947. gnus-sum-thread-tree-indent))
  4948. (cdr (reverse tree-stack))))
  4949. (if (nth 1 thread)
  4950. gnus-sum-thread-tree-leaf-with-other
  4951. gnus-sum-thread-tree-single-leaf)))))
  4952. (when (string= gnus-tmp-name "")
  4953. (setq gnus-tmp-name gnus-tmp-from))
  4954. (unless (numberp gnus-tmp-lines)
  4955. (setq gnus-tmp-lines -1))
  4956. (if (= gnus-tmp-lines -1)
  4957. (setq gnus-tmp-lines "?")
  4958. (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
  4959. (gnus-put-text-property
  4960. (point)
  4961. (progn (eval gnus-summary-line-format-spec) (point))
  4962. 'gnus-number number)
  4963. (when gnus-visual-p
  4964. (forward-line -1)
  4965. (gnus-summary-highlight-line)
  4966. (when gnus-summary-update-hook
  4967. (gnus-run-hooks 'gnus-summary-update-hook))
  4968. (forward-line 1))
  4969. (setq gnus-tmp-prev-subject simp-subject)))
  4970. (when (nth 1 thread)
  4971. (push (list (max 0 gnus-tmp-level)
  4972. (copy-sequence tree-stack)
  4973. (nthcdr 1 thread))
  4974. stack))
  4975. (push (if (nth 1 thread) 1 0) tree-stack)
  4976. (incf gnus-tmp-level)
  4977. (setq threads (if thread-end nil (cdar thread)))
  4978. (if gnus-summary-display-while-building
  4979. (if building-count
  4980. (progn
  4981. ;; use a set frequency
  4982. (setq building-line-count (1- building-line-count))
  4983. (when (= building-line-count 0)
  4984. (sit-for 0)
  4985. (setq building-line-count
  4986. gnus-summary-display-while-building)))
  4987. ;; always
  4988. (sit-for 0)))
  4989. (unless threads
  4990. (setq gnus-tmp-level 0)))))
  4991. (gnus-message 7 "Generating summary...done"))
  4992. (defun gnus-summary-prepare-unthreaded (headers)
  4993. "Generate an unthreaded summary buffer based on HEADERS."
  4994. (let (header number mark)
  4995. (beginning-of-line)
  4996. (while headers
  4997. ;; We may have to root out some bad articles...
  4998. (when (memq (setq number (mail-header-number
  4999. (setq header (pop headers))))
  5000. gnus-newsgroup-limit)
  5001. ;; Mark article as read when it has a low score.
  5002. (when (and gnus-summary-mark-below
  5003. (< (or (cdr (assq number gnus-newsgroup-scored))
  5004. gnus-summary-default-score 0)
  5005. gnus-summary-mark-below)
  5006. (not (gnus-summary-article-ancient-p number)))
  5007. (setq gnus-newsgroup-unreads
  5008. (delq number gnus-newsgroup-unreads))
  5009. (if gnus-newsgroup-auto-expire
  5010. (push number gnus-newsgroup-expirable)
  5011. (push (cons number gnus-low-score-mark)
  5012. gnus-newsgroup-reads)))
  5013. (setq mark (gnus-article-mark number))
  5014. (push (gnus-data-make number mark (1+ (point)) header 0)
  5015. gnus-newsgroup-data)
  5016. (gnus-summary-insert-line
  5017. header 0 number
  5018. (memq number gnus-newsgroup-undownloaded)
  5019. mark (memq number gnus-newsgroup-replied)
  5020. (memq number gnus-newsgroup-expirable)
  5021. (mail-header-subject header) nil
  5022. (cdr (assq number gnus-newsgroup-scored))
  5023. (memq number gnus-newsgroup-processable))))))
  5024. (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
  5025. (defun gnus-group-get-list-identifiers (group)
  5026. "Get list identifier regexp for GROUP."
  5027. (or (gnus-parameter-list-identifier group)
  5028. (if (consp gnus-list-identifiers)
  5029. (mapconcat 'identity gnus-list-identifiers " *\\|")
  5030. gnus-list-identifiers)))
  5031. (defun gnus-summary-remove-list-identifiers ()
  5032. "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
  5033. (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
  5034. changed subject)
  5035. (when regexp
  5036. (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
  5037. (dolist (header gnus-newsgroup-headers)
  5038. (setq subject (mail-header-subject header)
  5039. changed nil)
  5040. (while (string-match regexp subject)
  5041. (setq subject
  5042. (concat (substring subject 0 (match-beginning 1))
  5043. (substring subject (match-end 0)))
  5044. changed t))
  5045. (when changed
  5046. (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
  5047. (setq subject
  5048. (concat (substring subject 0 (match-beginning 1))
  5049. (substring subject (match-end 1)))))
  5050. (mail-header-set-subject header subject))))))
  5051. (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
  5052. "Fetch headers of ARTICLES."
  5053. (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
  5054. (gnus-message 7 "Fetching headers for %s..." name)
  5055. (prog1
  5056. (if (eq 'nov
  5057. (setq gnus-headers-retrieved-by
  5058. (gnus-retrieve-headers
  5059. articles gnus-newsgroup-name
  5060. (or limit
  5061. ;; We might want to fetch old headers, but
  5062. ;; not if there is only 1 article.
  5063. (and (or (and
  5064. (not (eq gnus-fetch-old-headers 'some))
  5065. (not (numberp gnus-fetch-old-headers)))
  5066. (> (length articles) 1))
  5067. gnus-fetch-old-headers)))))
  5068. (gnus-get-newsgroup-headers-xover
  5069. articles force-new dependencies gnus-newsgroup-name t)
  5070. (gnus-get-newsgroup-headers dependencies force-new))
  5071. (gnus-message 7 "Fetching headers for %s...done" name))))
  5072. (defun gnus-select-newsgroup (group &optional read-all select-articles)
  5073. "Select newsgroup GROUP.
  5074. If READ-ALL is non-nil, all articles in the group are selected.
  5075. If SELECT-ARTICLES, only select those articles from GROUP."
  5076. (let* ((entry (gnus-group-entry group))
  5077. ;;!!! Dirty hack; should be removed.
  5078. (gnus-summary-ignore-duplicates
  5079. (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
  5080. t
  5081. gnus-summary-ignore-duplicates))
  5082. (info (nth 2 entry))
  5083. charset articles fetched-articles cached)
  5084. (unless (gnus-check-server
  5085. (set (make-local-variable 'gnus-current-select-method)
  5086. (gnus-find-method-for-group group)))
  5087. (error "Couldn't open server"))
  5088. (setq charset (gnus-group-name-charset gnus-current-select-method group))
  5089. (or (and entry (not (eq (car entry) t))) ; Either it's active...
  5090. (gnus-activate-group group) ; Or we can activate it...
  5091. (progn ; Or we bug out.
  5092. (when (derived-mode-p 'gnus-summary-mode)
  5093. (gnus-kill-buffer (current-buffer)))
  5094. (error
  5095. "Couldn't activate group %s: %s"
  5096. (mm-decode-coding-string group charset)
  5097. (mm-decode-coding-string (gnus-status-message group) charset))))
  5098. (unless (gnus-request-group group t nil (gnus-get-info group))
  5099. (when (derived-mode-p 'gnus-summary-mode)
  5100. (gnus-kill-buffer (current-buffer)))
  5101. (error "Couldn't request group %s: %s"
  5102. (mm-decode-coding-string group charset)
  5103. (mm-decode-coding-string (gnus-status-message group) charset)))
  5104. (when (and gnus-agent
  5105. (gnus-active group))
  5106. (gnus-agent-possibly-alter-active group (gnus-active group) info)
  5107. (setq gnus-summary-use-undownloaded-faces
  5108. (gnus-agent-find-parameter
  5109. group
  5110. 'agent-enable-undownloaded-faces)))
  5111. (setq gnus-newsgroup-name group
  5112. gnus-newsgroup-unselected nil
  5113. gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
  5114. (let ((display (gnus-group-find-parameter group 'display)))
  5115. (setq gnus-newsgroup-display
  5116. (cond
  5117. ((not (zerop (or (car-safe read-all) 0)))
  5118. ;; The user entered the group with C-u SPC/RET, let's show
  5119. ;; all articles.
  5120. 'gnus-not-ignore)
  5121. ((eq display 'all)
  5122. 'gnus-not-ignore)
  5123. ((arrayp display)
  5124. (gnus-summary-display-make-predicate (mapcar 'identity display)))
  5125. ((numberp display)
  5126. ;; The following is probably the "correct" solution, but
  5127. ;; it makes Gnus fetch all headers and then limit the
  5128. ;; articles (which is slow), so instead we hack the
  5129. ;; select-articles parameter instead. -- Simon Josefsson
  5130. ;; <jas@kth.se>
  5131. ;;
  5132. ;; (gnus-byte-compile
  5133. ;; `(lambda () (> number ,(- (cdr (gnus-active group))
  5134. ;; display)))))
  5135. (setq select-articles
  5136. (gnus-uncompress-range
  5137. (cons (let ((tmp (- (cdr (gnus-active group)) display)))
  5138. (if (> tmp 0)
  5139. tmp
  5140. 1))
  5141. (cdr (gnus-active group)))))
  5142. nil)
  5143. (t
  5144. nil))))
  5145. (gnus-summary-setup-default-charset)
  5146. ;; Kludge to avoid having cached articles nixed out in virtual groups.
  5147. (when (gnus-virtual-group-p group)
  5148. (setq cached gnus-newsgroup-cached))
  5149. (setq gnus-newsgroup-unreads
  5150. (gnus-sorted-ndifference
  5151. (gnus-sorted-ndifference gnus-newsgroup-unreads
  5152. gnus-newsgroup-marked)
  5153. gnus-newsgroup-dormant))
  5154. (setq gnus-newsgroup-processable nil)
  5155. (gnus-update-read-articles group gnus-newsgroup-unreads t)
  5156. ;; Adjust and set lists of article marks.
  5157. (when info
  5158. (gnus-adjust-marked-articles info))
  5159. (if (setq articles select-articles)
  5160. (setq gnus-newsgroup-unselected
  5161. (gnus-sorted-difference gnus-newsgroup-unreads articles))
  5162. (setq articles (gnus-articles-to-read group read-all)))
  5163. (cond
  5164. ((null articles)
  5165. ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
  5166. 'quit)
  5167. ((eq articles 0) nil)
  5168. (t
  5169. ;; Init the dependencies hash table.
  5170. (setq gnus-newsgroup-dependencies
  5171. (gnus-make-hashtable (length articles)))
  5172. (if (gnus-buffer-live-p gnus-group-buffer)
  5173. (gnus-set-global-variables)
  5174. (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
  5175. ;; Retrieve the headers and read them in.
  5176. (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
  5177. ;; Kludge to avoid having cached articles nixed out in virtual groups.
  5178. (when cached
  5179. (setq gnus-newsgroup-cached cached))
  5180. ;; Suppress duplicates?
  5181. (when gnus-suppress-duplicates
  5182. (gnus-dup-suppress-articles))
  5183. ;; Set the initial limit.
  5184. (setq gnus-newsgroup-limit (copy-sequence articles))
  5185. ;; Remove canceled articles from the list of unread articles.
  5186. (setq fetched-articles
  5187. (mapcar (lambda (headers) (mail-header-number headers))
  5188. gnus-newsgroup-headers))
  5189. (setq gnus-newsgroup-articles fetched-articles)
  5190. (setq gnus-newsgroup-unreads
  5191. (gnus-sorted-nintersection
  5192. gnus-newsgroup-unreads fetched-articles))
  5193. (gnus-compute-unseen-list)
  5194. ;; Removed marked articles that do not exist.
  5195. (gnus-update-missing-marks
  5196. (gnus-sorted-difference articles fetched-articles))
  5197. ;; We might want to build some more threads first.
  5198. (when (and gnus-fetch-old-headers
  5199. (eq gnus-headers-retrieved-by 'nov))
  5200. (if (eq gnus-fetch-old-headers 'invisible)
  5201. (gnus-build-all-threads)
  5202. (gnus-build-old-threads)))
  5203. ;; Let the Gnus agent mark articles as read.
  5204. (when gnus-agent
  5205. (gnus-agent-get-undownloaded-list))
  5206. ;; Remove list identifiers from subject
  5207. (gnus-summary-remove-list-identifiers)
  5208. ;; Check whether auto-expire is to be done in this group.
  5209. (setq gnus-newsgroup-auto-expire
  5210. (and (gnus-group-auto-expirable-p group)
  5211. (not (gnus-group-read-only-p group))))
  5212. ;; Set up the article buffer now, if necessary.
  5213. (unless (and gnus-single-article-buffer
  5214. (equal gnus-article-buffer "*Article*"))
  5215. (gnus-article-setup-buffer))
  5216. ;; First and last article in this newsgroup.
  5217. (when gnus-newsgroup-headers
  5218. (setq gnus-newsgroup-begin
  5219. (mail-header-number (car gnus-newsgroup-headers))
  5220. gnus-newsgroup-end
  5221. (mail-header-number
  5222. (gnus-last-element gnus-newsgroup-headers))))
  5223. ;; GROUP is successfully selected.
  5224. (or gnus-newsgroup-headers t)))))
  5225. (defun gnus-compute-unseen-list ()
  5226. ;; The `seen' marks are treated specially.
  5227. (if (not gnus-newsgroup-seen)
  5228. (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
  5229. (setq gnus-newsgroup-unseen
  5230. (gnus-inverse-list-range-intersection
  5231. gnus-newsgroup-articles gnus-newsgroup-seen))))
  5232. (declare-function gnus-get-predicate "gnus-agent" (predicate))
  5233. (defun gnus-summary-display-make-predicate (display)
  5234. (require 'gnus-agent)
  5235. (when (= (length display) 1)
  5236. (setq display (car display)))
  5237. (unless gnus-summary-display-cache
  5238. (dolist (elem (append '((unread . unread)
  5239. (read . read)
  5240. (unseen . unseen))
  5241. gnus-article-mark-lists))
  5242. (push (cons (cdr elem)
  5243. (gnus-byte-compile ;Why bother?
  5244. `(lambda () (gnus-article-marked-p ',(cdr elem)))))
  5245. gnus-summary-display-cache)))
  5246. (let ((gnus-category-predicate-alist gnus-summary-display-cache)
  5247. (gnus-category-predicate-cache gnus-summary-display-cache))
  5248. (gnus-get-predicate display)))
  5249. ;; Uses the dynamically bound `gnus-number' variable.
  5250. (defvar gnus-number)
  5251. (defun gnus-article-marked-p (type &optional article)
  5252. (let ((article (or article gnus-number)))
  5253. (cond
  5254. ((eq type 'tick)
  5255. (memq article gnus-newsgroup-marked))
  5256. ((eq type 'spam)
  5257. (memq article gnus-newsgroup-spam-marked))
  5258. ((eq type 'unsend)
  5259. (memq article gnus-newsgroup-unsendable))
  5260. ((eq type 'undownload)
  5261. (memq article gnus-newsgroup-undownloaded))
  5262. ((eq type 'download)
  5263. (memq article gnus-newsgroup-downloadable))
  5264. ((eq type 'unread)
  5265. (memq article gnus-newsgroup-unreads))
  5266. ((eq type 'read)
  5267. (memq article gnus-newsgroup-reads))
  5268. ((eq type 'dormant)
  5269. (memq article gnus-newsgroup-dormant) )
  5270. ((eq type 'expire)
  5271. (memq article gnus-newsgroup-expirable))
  5272. ((eq type 'reply)
  5273. (memq article gnus-newsgroup-replied))
  5274. ((eq type 'killed)
  5275. (memq article gnus-newsgroup-killed))
  5276. ((eq type 'bookmark)
  5277. (assq article gnus-newsgroup-bookmarks))
  5278. ((eq type 'score)
  5279. (assq article gnus-newsgroup-scored))
  5280. ((eq type 'save)
  5281. (memq article gnus-newsgroup-saved))
  5282. ((eq type 'cache)
  5283. (memq article gnus-newsgroup-cached))
  5284. ((eq type 'forward)
  5285. (memq article gnus-newsgroup-forwarded))
  5286. ((eq type 'seen)
  5287. (not (memq article gnus-newsgroup-unseen)))
  5288. (t t))))
  5289. (defun gnus-articles-to-read (group &optional read-all)
  5290. "Find out what articles the user wants to read."
  5291. (let* ((only-read-p t)
  5292. (articles
  5293. (gnus-list-range-difference
  5294. ;; Select all articles if `read-all' is non-nil, or if there
  5295. ;; are no unread articles.
  5296. (if (or read-all
  5297. (and (zerop (length gnus-newsgroup-marked))
  5298. (zerop (length gnus-newsgroup-unreads)))
  5299. ;; Fetch all if the predicate is non-nil.
  5300. gnus-newsgroup-display)
  5301. ;; We want to select the headers for all the articles in
  5302. ;; the group, so we select either all the active
  5303. ;; articles in the group, or (if that's nil), the
  5304. ;; articles in the cache.
  5305. (or
  5306. (if gnus-newsgroup-maximum-articles
  5307. (let ((active (gnus-active group)))
  5308. (gnus-uncompress-range
  5309. (cons (max (car active)
  5310. (- (cdr active)
  5311. gnus-newsgroup-maximum-articles
  5312. -1))
  5313. (cdr active))))
  5314. (gnus-uncompress-range (gnus-active group)))
  5315. (gnus-cache-articles-in-group group))
  5316. ;; Select only the "normal" subset of articles.
  5317. (setq only-read-p nil)
  5318. (gnus-sorted-nunion
  5319. (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
  5320. gnus-newsgroup-unreads))
  5321. (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
  5322. (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
  5323. (scored (length scored-list))
  5324. (number (length articles))
  5325. (marked (+ (length gnus-newsgroup-marked)
  5326. (length gnus-newsgroup-dormant)))
  5327. (select
  5328. (cond
  5329. ((numberp read-all)
  5330. read-all)
  5331. ((numberp gnus-newsgroup-display)
  5332. gnus-newsgroup-display)
  5333. (t
  5334. (condition-case ()
  5335. (cond
  5336. ((and (or (<= scored marked) (= scored number))
  5337. (numberp gnus-large-newsgroup)
  5338. (> number gnus-large-newsgroup))
  5339. (let* ((cursor-in-echo-area nil)
  5340. (initial (gnus-parameter-large-newsgroup-initial
  5341. gnus-newsgroup-name))
  5342. (default (if only-read-p
  5343. (or initial gnus-large-newsgroup)
  5344. number))
  5345. (input
  5346. (read-string
  5347. (if only-read-p
  5348. (format
  5349. "How many articles from %s (available %d, default %d): "
  5350. (gnus-group-decoded-name
  5351. (gnus-group-real-name gnus-newsgroup-name))
  5352. number default)
  5353. (format
  5354. "How many articles from %s (%d default): "
  5355. (gnus-group-decoded-name
  5356. (gnus-group-real-name gnus-newsgroup-name))
  5357. default))
  5358. nil
  5359. nil
  5360. (number-to-string default))))
  5361. (if (string-match "^[ \t]*$" input) number input)))
  5362. ((and (> scored marked) (< scored number)
  5363. (> (- scored number) 20))
  5364. (let ((input
  5365. (read-string
  5366. (format "%s %s (%d scored, %d total): "
  5367. "How many articles from"
  5368. (gnus-group-decoded-name
  5369. (gnus-group-real-name gnus-newsgroup-name))
  5370. scored number))))
  5371. (if (string-match "^[ \t]*$" input)
  5372. number input)))
  5373. (t number))
  5374. (quit
  5375. (message "Quit getting the articles to read")
  5376. nil))))))
  5377. (setq select (if (stringp select) (string-to-number select) select))
  5378. (if (or (null select) (zerop select))
  5379. select
  5380. (if (and (not (zerop scored)) (<= (abs select) scored))
  5381. (progn
  5382. (setq articles (sort scored-list '<))
  5383. (setq number (length articles)))
  5384. (setq articles (copy-sequence articles)))
  5385. (when (< (abs select) number)
  5386. (if (< select 0)
  5387. ;; Select the N oldest articles.
  5388. (setcdr (nthcdr (1- (abs select)) articles) nil)
  5389. ;; Select the N most recent articles.
  5390. (setq articles (nthcdr (- number select) articles))))
  5391. (setq gnus-newsgroup-unselected
  5392. (gnus-sorted-difference gnus-newsgroup-unreads articles))
  5393. (when gnus-alter-articles-to-read-function
  5394. (setq articles
  5395. (sort
  5396. (funcall gnus-alter-articles-to-read-function
  5397. gnus-newsgroup-name articles)
  5398. '<)))
  5399. articles)))
  5400. (defun gnus-killed-articles (killed articles)
  5401. (let (out)
  5402. (while articles
  5403. (when (inline (gnus-member-of-range (car articles) killed))
  5404. (push (car articles) out))
  5405. (setq articles (cdr articles)))
  5406. out))
  5407. (defun gnus-article-mark-to-type (mark)
  5408. "Return the type of MARK."
  5409. (or (cadr (assq mark gnus-article-special-mark-lists))
  5410. 'list))
  5411. (defun gnus-article-unpropagatable-p (mark)
  5412. "Return whether MARK should be propagated to back end."
  5413. (memq mark gnus-article-unpropagated-mark-lists))
  5414. (defun gnus-adjust-marked-articles (info)
  5415. "Set all article lists and remove all marks that are no longer valid."
  5416. (let* ((marked-lists (gnus-info-marks info))
  5417. (active (gnus-active (gnus-info-group info)))
  5418. (min (car active))
  5419. (max (cdr active))
  5420. (types gnus-article-mark-lists)
  5421. marks var articles article mark mark-type
  5422. bgn end)
  5423. ;; Hack to avoid adjusting marks for imap.
  5424. (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
  5425. 'nnimap)
  5426. (setq min 1))
  5427. (dolist (marks marked-lists)
  5428. (setq mark (car marks)
  5429. mark-type (gnus-article-mark-to-type mark)
  5430. var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
  5431. ;; We set the variable according to the type of the marks list,
  5432. ;; and then adjust the marks to a subset of the active articles.
  5433. (cond
  5434. ;; Adjust "simple" lists - compressed yet unsorted
  5435. ((eq mark-type 'list)
  5436. ;; Simultaneously uncompress and clip to active range
  5437. ;; See gnus-uncompress-range for a description of possible marks
  5438. (let (l lh)
  5439. (if (not (cadr marks))
  5440. (set var nil)
  5441. (setq articles (if (numberp (cddr marks))
  5442. (list (cdr marks))
  5443. (cdr marks))
  5444. lh (cons nil nil)
  5445. l lh)
  5446. (while (setq article (pop articles))
  5447. (cond ((consp article)
  5448. (setq bgn (max (car article) min)
  5449. end (min (cdr article) max))
  5450. (while (<= bgn end)
  5451. (setq l (setcdr l (cons bgn nil))
  5452. bgn (1+ bgn))))
  5453. ((and (<= min article)
  5454. (>= max article))
  5455. (setq l (setcdr l (cons article nil))))))
  5456. (set var (cdr lh)))))
  5457. ;; Adjust assocs.
  5458. ((eq mark-type 'tuple)
  5459. (set var (setq articles (cdr marks)))
  5460. (when (not (listp (cdr (symbol-value var))))
  5461. (set var (list (symbol-value var))))
  5462. (when (not (listp (cdr articles)))
  5463. (setq articles (list articles)))
  5464. (while articles
  5465. (when (or (not (consp (setq article (pop articles))))
  5466. (< (car article) min)
  5467. (> (car article) max))
  5468. (set var (delq article (symbol-value var))))))
  5469. ;; Adjust ranges (sloppily).
  5470. ((eq mark-type 'range)
  5471. (cond
  5472. ((eq mark 'seen)
  5473. ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
  5474. ;; It should be (seen (NUM1 . NUM2)).
  5475. (when (numberp (cddr marks))
  5476. (setcdr marks (list (cdr marks))))
  5477. (setq articles (cdr marks))
  5478. (while (and articles
  5479. (or (and (consp (car articles))
  5480. (> min (cdar articles)))
  5481. (and (numberp (car articles))
  5482. (> min (car articles)))))
  5483. (pop articles))
  5484. (set var articles))
  5485. ((eq mark 'unexist)
  5486. (set var (cdr marks)))))))))
  5487. (defun gnus-update-missing-marks (missing)
  5488. "Go through the list of MISSING articles and remove them from the mark lists."
  5489. (when missing
  5490. (let (var m)
  5491. ;; Go through all types.
  5492. (dolist (elem gnus-article-mark-lists)
  5493. (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
  5494. (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
  5495. (when (symbol-value var)
  5496. ;; This list has articles. So we delete all missing
  5497. ;; articles from it.
  5498. (setq m missing)
  5499. (while m
  5500. (set var (delq (pop m) (symbol-value var))))))))))
  5501. (defun gnus-update-marks ()
  5502. "Enter the various lists of marked articles into the newsgroup info list."
  5503. (let ((types gnus-article-mark-lists)
  5504. (info (gnus-get-info gnus-newsgroup-name))
  5505. type list newmarked symbol delta-marks)
  5506. (when info
  5507. ;; Add all marks lists to the list of marks lists.
  5508. (while (setq type (pop types))
  5509. (setq list (symbol-value
  5510. (setq symbol
  5511. (intern (format "gnus-newsgroup-%s" (car type))))))
  5512. (when list
  5513. ;; Get rid of the entries of the articles that have the
  5514. ;; default score.
  5515. (when (and (eq (cdr type) 'score)
  5516. gnus-save-score
  5517. list)
  5518. (let* ((arts list)
  5519. (prev (cons nil list))
  5520. (all prev))
  5521. (while arts
  5522. (if (or (not (consp (car arts)))
  5523. (= (cdar arts) gnus-summary-default-score))
  5524. (setcdr prev (cdr arts))
  5525. (setq prev arts))
  5526. (setq arts (cdr arts)))
  5527. (setq list (cdr all)))))
  5528. (when (eq (cdr type) 'seen)
  5529. (setq list (gnus-range-add list gnus-newsgroup-unseen)))
  5530. (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
  5531. (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
  5532. (when (and (gnus-check-backend-function
  5533. 'request-set-mark gnus-newsgroup-name)
  5534. (not (gnus-article-unpropagatable-p (cdr type))))
  5535. (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
  5536. ;; Don't do anything about marks for articles we
  5537. ;; didn't actually get any headers for.
  5538. (del
  5539. (gnus-list-range-intersection
  5540. gnus-newsgroup-articles
  5541. (gnus-remove-from-range (gnus-copy-sequence old) list)))
  5542. (add
  5543. (gnus-list-range-intersection
  5544. gnus-newsgroup-articles
  5545. (gnus-remove-from-range
  5546. (gnus-copy-sequence list) old))))
  5547. (when add
  5548. (push (list add 'add (list (cdr type))) delta-marks))
  5549. (when del
  5550. ;; Don't delete marks from outside the active range.
  5551. ;; This shouldn't happen, but is a sanity check.
  5552. (setq del (gnus-sorted-range-intersection
  5553. (gnus-active gnus-newsgroup-name) del))
  5554. (push (list del 'del (list (cdr type))) delta-marks))))
  5555. (when (or list
  5556. (eq (cdr type) 'unexist))
  5557. (push (cons (cdr type) list) newmarked)))
  5558. (when delta-marks
  5559. (unless (gnus-check-group gnus-newsgroup-name)
  5560. (error "Can't open server for %s" gnus-newsgroup-name))
  5561. (gnus-request-set-mark gnus-newsgroup-name delta-marks))
  5562. ;; Enter these new marks into the info of the group.
  5563. (if (nthcdr 3 info)
  5564. (setcar (nthcdr 3 info) newmarked)
  5565. ;; Add the marks lists to the end of the info.
  5566. (when newmarked
  5567. (setcdr (nthcdr 2 info) (list newmarked))))
  5568. ;; Cut off the end of the info if there's nothing else there.
  5569. (let ((i 5))
  5570. (while (and (> i 2)
  5571. (not (nth i info)))
  5572. (when (nthcdr (decf i) info)
  5573. (setcdr (nthcdr i info) nil)))))))
  5574. (defun gnus-set-mode-line (where)
  5575. "Set the mode line of the article or summary buffers.
  5576. If WHERE is `summary', the summary mode line format will be used."
  5577. ;; Is this mode line one we keep updated?
  5578. (when (and (memq where gnus-updated-mode-lines)
  5579. (symbol-value
  5580. (intern (format "gnus-%s-mode-line-format-spec" where))))
  5581. (let (mode-string)
  5582. ;; We evaluate this in the summary buffer since these
  5583. ;; variables are buffer-local to that buffer.
  5584. (with-current-buffer gnus-summary-buffer
  5585. ;; We bind all these variables that are used in the `eval' form
  5586. ;; below.
  5587. (let* ((mformat (symbol-value
  5588. (intern
  5589. (format "gnus-%s-mode-line-format-spec" where))))
  5590. (gnus-tmp-group-name (gnus-mode-string-quote
  5591. (gnus-group-decoded-name
  5592. gnus-newsgroup-name)))
  5593. (gnus-tmp-article-number (or gnus-current-article 0))
  5594. (gnus-tmp-unread gnus-newsgroup-unreads)
  5595. (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
  5596. (gnus-tmp-unselected (length gnus-newsgroup-unselected))
  5597. (gnus-tmp-unread-and-unselected
  5598. (cond ((and (zerop gnus-tmp-unread-and-unticked)
  5599. (zerop gnus-tmp-unselected))
  5600. "")
  5601. ((zerop gnus-tmp-unselected)
  5602. (format "{%d more}" gnus-tmp-unread-and-unticked))
  5603. (t (format "{%d(+%d) more}"
  5604. gnus-tmp-unread-and-unticked
  5605. gnus-tmp-unselected))))
  5606. (gnus-tmp-subject
  5607. (if (and gnus-current-headers
  5608. (vectorp gnus-current-headers))
  5609. (gnus-mode-string-quote
  5610. (mail-header-subject gnus-current-headers))
  5611. ""))
  5612. bufname-length max-len
  5613. gnus-tmp-header) ;; passed as argument to any user-format-funcs
  5614. (setq mode-string (eval mformat))
  5615. (setq bufname-length (if (string-match "%b" mode-string)
  5616. (- (length
  5617. (buffer-name
  5618. (if (eq where 'summary)
  5619. nil
  5620. (get-buffer gnus-article-buffer))))
  5621. 2)
  5622. 0))
  5623. (setq max-len (max 4 (if gnus-mode-non-string-length
  5624. (- (window-width)
  5625. gnus-mode-non-string-length
  5626. bufname-length)
  5627. (length mode-string))))
  5628. ;; We might have to chop a bit of the string off...
  5629. (when (> (length mode-string) max-len)
  5630. (setq mode-string
  5631. (concat (truncate-string-to-width mode-string (- max-len 3))
  5632. "...")))))
  5633. ;; Update the mode line.
  5634. (setq mode-line-buffer-identification
  5635. (gnus-mode-line-buffer-identification (list mode-string)))
  5636. (set-buffer-modified-p t))))
  5637. (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
  5638. "Go through the HEADERS list and add all Xrefs to a hash table.
  5639. The resulting hash table is returned, or nil if no Xrefs were found."
  5640. (let* ((virtual (gnus-virtual-group-p from-newsgroup))
  5641. (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
  5642. (xref-hashtb (gnus-make-hashtable))
  5643. start group entry number xrefs header)
  5644. (while headers
  5645. (setq header (pop headers))
  5646. (when (and (setq xrefs (mail-header-xref header))
  5647. (not (memq (setq number (mail-header-number header))
  5648. unreads)))
  5649. (setq start 0)
  5650. (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
  5651. (setq start (match-end 0))
  5652. (setq group (if prefix
  5653. (concat prefix (substring xrefs (match-beginning 1)
  5654. (match-end 1)))
  5655. (substring xrefs (match-beginning 1) (match-end 1))))
  5656. (setq number
  5657. (string-to-number (substring xrefs (match-beginning 2)
  5658. (match-end 2))))
  5659. (if (setq entry (gnus-gethash group xref-hashtb))
  5660. (setcdr entry (cons number (cdr entry)))
  5661. (gnus-sethash group (cons number nil) xref-hashtb)))))
  5662. (and start xref-hashtb)))
  5663. (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
  5664. "Look through all the headers and mark the Xrefs as read."
  5665. (let ((virtual (gnus-virtual-group-p from-newsgroup))
  5666. name info xref-hashtb idlist method nth4)
  5667. (with-current-buffer gnus-group-buffer
  5668. (when (setq xref-hashtb
  5669. (gnus-create-xref-hashtb from-newsgroup headers unreads))
  5670. (mapatoms
  5671. (lambda (group)
  5672. (unless (string= from-newsgroup (setq name (symbol-name group)))
  5673. (setq idlist (symbol-value group))
  5674. ;; Dead groups are not updated.
  5675. (and (prog1
  5676. (setq info (gnus-get-info name))
  5677. (when (stringp (setq nth4 (gnus-info-method info)))
  5678. (setq nth4 (gnus-server-to-method nth4))))
  5679. ;; Only do the xrefs if the group has the same
  5680. ;; select method as the group we have just read.
  5681. (or (gnus-methods-equal-p
  5682. nth4 (gnus-find-method-for-group from-newsgroup))
  5683. virtual
  5684. (equal nth4 (setq method (gnus-find-method-for-group
  5685. from-newsgroup)))
  5686. (and (equal (car nth4) (car method))
  5687. (equal (nth 1 nth4) (nth 1 method))))
  5688. gnus-use-cross-reference
  5689. (or (not (eq gnus-use-cross-reference t))
  5690. virtual
  5691. ;; Only do cross-references on subscribed
  5692. ;; groups, if that is what is wanted.
  5693. (<= (gnus-info-level info) gnus-level-subscribed))
  5694. (gnus-group-make-articles-read name idlist))))
  5695. xref-hashtb)))))
  5696. (defun gnus-compute-read-articles (group articles)
  5697. (let* ((entry (gnus-group-entry group))
  5698. (info (nth 2 entry))
  5699. (active (gnus-active group))
  5700. ninfo)
  5701. (when entry
  5702. ;; First peel off all invalid article numbers.
  5703. (when active
  5704. (let ((ids articles)
  5705. id first)
  5706. (while (setq id (pop ids))
  5707. (when (and first (> id (cdr active)))
  5708. ;; We'll end up in this situation in one particular
  5709. ;; obscure situation. If you re-scan a group and get
  5710. ;; a new article that is cross-posted to a different
  5711. ;; group that has not been re-scanned, you might get
  5712. ;; crossposted article that has a higher number than
  5713. ;; Gnus believes possible. So we re-activate this
  5714. ;; group as well. This might mean doing the
  5715. ;; crossposting thingy will *increase* the number
  5716. ;; of articles in some groups. Tsk, tsk.
  5717. (setq active (or (gnus-activate-group group) active)))
  5718. (when (or (> id (cdr active))
  5719. (< id (car active)))
  5720. (setq articles (delq id articles))))))
  5721. ;; If the read list is nil, we init it.
  5722. (if (and active
  5723. (null (gnus-info-read info))
  5724. (> (car active) 1))
  5725. (setq ninfo (cons 1 (1- (car active))))
  5726. (setq ninfo (gnus-info-read info)))
  5727. ;; Then we add the read articles to the range.
  5728. (gnus-add-to-range
  5729. ninfo (setq articles (sort articles '<))))))
  5730. (defun gnus-group-make-articles-read (group articles)
  5731. "Update the info of GROUP to say that ARTICLES are read."
  5732. (let* ((num 0)
  5733. (entry (gnus-group-entry group))
  5734. (info (nth 2 entry))
  5735. (active (gnus-active group))
  5736. (set-marks
  5737. (gnus-method-option-p
  5738. (gnus-find-method-for-group group)
  5739. 'server-marks))
  5740. range)
  5741. (if (not entry)
  5742. ;; Group that Gnus doesn't know exists, but still allow the
  5743. ;; backend to set marks.
  5744. (when set-marks
  5745. (gnus-request-set-mark
  5746. group (list (list (gnus-compress-sequence (sort articles #'<))
  5747. 'add '(read)))))
  5748. ;; Normal, subscribed groups.
  5749. (setq range (gnus-compute-read-articles group articles))
  5750. (with-current-buffer gnus-group-buffer
  5751. (gnus-undo-register
  5752. `(progn
  5753. (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
  5754. (gnus-info-set-read ',info ',(gnus-info-read info))
  5755. (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
  5756. (when ,set-marks
  5757. (gnus-request-set-mark
  5758. ,group (list (list ',range 'del '(read)))))
  5759. (gnus-group-update-group ,group t))))
  5760. ;; Add the read articles to the range.
  5761. (gnus-info-set-read info range)
  5762. (when set-marks
  5763. (gnus-request-set-mark group (list (list range 'add '(read)))))
  5764. ;; Then we have to re-compute how many unread
  5765. ;; articles there are in this group.
  5766. (when active
  5767. (cond
  5768. ((not range)
  5769. (setq num (- (1+ (cdr active)) (car active))))
  5770. ((not (listp (cdr range)))
  5771. (setq num (- (cdr active) (- (1+ (cdr range))
  5772. (car range)))))
  5773. (t
  5774. (while range
  5775. (if (numberp (car range))
  5776. (setq num (1+ num))
  5777. (setq num (+ num (- (1+ (cdar range)) (caar range)))))
  5778. (setq range (cdr range)))
  5779. (setq num (- (cdr active) num))))
  5780. ;; Update the number of unread articles.
  5781. (setcar entry num)
  5782. ;; Update the group buffer.
  5783. (unless (gnus-ephemeral-group-p group)
  5784. (gnus-group-update-group group t))))))
  5785. (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
  5786. (let ((cur nntp-server-buffer)
  5787. (dependencies
  5788. (or dependencies
  5789. (with-current-buffer gnus-summary-buffer
  5790. gnus-newsgroup-dependencies)))
  5791. headers id end ref number
  5792. (mail-parse-charset gnus-newsgroup-charset)
  5793. (mail-parse-ignored-charsets
  5794. (save-current-buffer (condition-case nil
  5795. (set-buffer gnus-summary-buffer)
  5796. (error))
  5797. gnus-newsgroup-ignored-charsets)))
  5798. (with-current-buffer nntp-server-buffer
  5799. ;; Translate all TAB characters into SPACE characters.
  5800. (subst-char-in-region (point-min) (point-max) ?\t ? t)
  5801. (subst-char-in-region (point-min) (point-max) ?\r ? t)
  5802. (ietf-drums-unfold-fws)
  5803. (gnus-run-hooks 'gnus-parse-headers-hook)
  5804. (let ((case-fold-search t)
  5805. in-reply-to header p lines chars)
  5806. (goto-char (point-min))
  5807. ;; Search to the beginning of the next header. Error messages
  5808. ;; do not begin with 2 or 3.
  5809. (while (re-search-forward "^[23][0-9]+ " nil t)
  5810. (setq id nil
  5811. ref nil)
  5812. ;; This implementation of this function, with nine
  5813. ;; search-forwards instead of the one re-search-forward and
  5814. ;; a case (which basically was the old function) is actually
  5815. ;; about twice as fast, even though it looks messier. You
  5816. ;; can't have everything, I guess. Speed and elegance
  5817. ;; doesn't always go hand in hand.
  5818. (setq
  5819. header
  5820. (vector
  5821. ;; Number.
  5822. (prog1
  5823. (setq number (read cur))
  5824. (end-of-line)
  5825. (setq p (point))
  5826. (narrow-to-region (point)
  5827. (or (and (search-forward "\n.\n" nil t)
  5828. (- (point) 2))
  5829. (point))))
  5830. ;; Subject.
  5831. (progn
  5832. (goto-char p)
  5833. (if (search-forward "\nsubject:" nil t)
  5834. (funcall gnus-decode-encoded-word-function
  5835. (nnheader-header-value))
  5836. "(none)"))
  5837. ;; From.
  5838. (progn
  5839. (goto-char p)
  5840. (if (search-forward "\nfrom:" nil t)
  5841. (funcall gnus-decode-encoded-address-function
  5842. (nnheader-header-value))
  5843. "(nobody)"))
  5844. ;; Date.
  5845. (progn
  5846. (goto-char p)
  5847. (if (search-forward "\ndate:" nil t)
  5848. (nnheader-header-value) ""))
  5849. ;; Message-ID.
  5850. (progn
  5851. (goto-char p)
  5852. (setq id (if (re-search-forward
  5853. "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
  5854. ;; We do it this way to make sure the Message-ID
  5855. ;; is (somewhat) syntactically valid.
  5856. (buffer-substring (match-beginning 1)
  5857. (match-end 1))
  5858. ;; If there was no message-id, we just fake one
  5859. ;; to make subsequent routines simpler.
  5860. (nnheader-generate-fake-message-id number))))
  5861. ;; References.
  5862. (progn
  5863. (goto-char p)
  5864. (if (search-forward "\nreferences:" nil t)
  5865. (progn
  5866. (setq end (point))
  5867. (prog1
  5868. (nnheader-header-value)
  5869. (setq ref
  5870. (buffer-substring
  5871. (progn
  5872. (end-of-line)
  5873. (search-backward ">" end t)
  5874. (1+ (point)))
  5875. (progn
  5876. (search-backward "<" end t)
  5877. (point))))))
  5878. ;; Get the references from the in-reply-to header if there
  5879. ;; were no references and the in-reply-to header looks
  5880. ;; promising.
  5881. (if (and (search-forward "\nin-reply-to:" nil t)
  5882. (setq in-reply-to (nnheader-header-value))
  5883. (string-match "<[^>]+>" in-reply-to))
  5884. (let (ref2)
  5885. (setq ref (substring in-reply-to (match-beginning 0)
  5886. (match-end 0)))
  5887. (while (string-match "<[^>]+>" in-reply-to (match-end 0))
  5888. (setq ref2 (substring in-reply-to (match-beginning 0)
  5889. (match-end 0)))
  5890. (when (> (length ref2) (length ref))
  5891. (setq ref ref2)))
  5892. ref)
  5893. (setq ref nil))))
  5894. ;; Chars.
  5895. (progn
  5896. (goto-char p)
  5897. (if (search-forward "\nchars: " nil t)
  5898. (if (numberp (setq chars (ignore-errors (read cur))))
  5899. chars -1)
  5900. -1))
  5901. ;; Lines.
  5902. (progn
  5903. (goto-char p)
  5904. (if (search-forward "\nlines: " nil t)
  5905. (if (numberp (setq lines (ignore-errors (read cur))))
  5906. lines -1)
  5907. -1))
  5908. ;; Xref.
  5909. (progn
  5910. (goto-char p)
  5911. (and (search-forward "\nxref:" nil t)
  5912. (nnheader-header-value)))
  5913. ;; Extra.
  5914. (when gnus-extra-headers
  5915. (let ((extra gnus-extra-headers)
  5916. out)
  5917. (while extra
  5918. (goto-char p)
  5919. (when (search-forward
  5920. (concat "\n" (symbol-name (car extra)) ":") nil t)
  5921. (push (cons (car extra) (nnheader-header-value))
  5922. out))
  5923. (pop extra))
  5924. out))))
  5925. (when (equal id ref)
  5926. (setq ref nil))
  5927. (when gnus-alter-header-function
  5928. (funcall gnus-alter-header-function header)
  5929. (setq id (mail-header-id header)
  5930. ref (gnus-parent-id (mail-header-references header))))
  5931. (when (setq header
  5932. (gnus-dependencies-add-header
  5933. header dependencies force-new))
  5934. (push header headers))
  5935. (goto-char (point-max))
  5936. (widen))
  5937. (nreverse headers)))))
  5938. ;; Goes through the xover lines and returns a list of vectors
  5939. (defun gnus-get-newsgroup-headers-xover (sequence &optional
  5940. force-new dependencies
  5941. group also-fetch-heads)
  5942. "Parse the news overview data in the server buffer.
  5943. Return a list of headers that match SEQUENCE (see
  5944. `nntp-retrieve-headers')."
  5945. ;; Get the Xref when the users reads the articles since most/some
  5946. ;; NNTP servers do not include Xrefs when using XOVER.
  5947. (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
  5948. (let ((mail-parse-charset gnus-newsgroup-charset)
  5949. (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
  5950. (cur nntp-server-buffer)
  5951. (dependencies (or dependencies gnus-newsgroup-dependencies))
  5952. (allp (cond
  5953. ((eq gnus-read-all-available-headers t)
  5954. t)
  5955. ((and (stringp gnus-read-all-available-headers)
  5956. group)
  5957. (string-match gnus-read-all-available-headers group))
  5958. (t
  5959. nil)))
  5960. number headers header)
  5961. (with-current-buffer nntp-server-buffer
  5962. (subst-char-in-region (point-min) (point-max) ?\r ? t)
  5963. ;; Allow the user to mangle the headers before parsing them.
  5964. (gnus-run-hooks 'gnus-parse-headers-hook)
  5965. (goto-char (point-min))
  5966. (gnus-parse-without-error
  5967. (while (and (or sequence allp)
  5968. (not (eobp)))
  5969. (setq number (read cur))
  5970. (when (not allp)
  5971. (while (and sequence
  5972. (< (car sequence) number))
  5973. (setq sequence (cdr sequence))))
  5974. (when (and (or allp
  5975. (and sequence
  5976. (eq number (car sequence))))
  5977. (progn
  5978. (setq sequence (cdr sequence))
  5979. (setq header (inline
  5980. (gnus-nov-parse-line
  5981. number dependencies force-new)))))
  5982. (push header headers))
  5983. (forward-line 1)))
  5984. ;; A common bug in inn is that if you have posted an article and
  5985. ;; then retrieves the active file, it will answer correctly --
  5986. ;; the new article is included. However, a NOV entry for the
  5987. ;; article may not have been generated yet, so this may fail.
  5988. ;; We work around this problem by retrieving the last few
  5989. ;; headers using HEAD.
  5990. (if (or (not also-fetch-heads)
  5991. (not sequence))
  5992. ;; We (probably) got all the headers.
  5993. (nreverse headers)
  5994. (let ((gnus-nov-is-evil t))
  5995. (nconc
  5996. (nreverse headers)
  5997. (when (eq (gnus-retrieve-headers sequence group) 'headers)
  5998. (gnus-get-newsgroup-headers))))))))
  5999. (defun gnus-article-get-xrefs ()
  6000. "Fill in the Xref value in `gnus-current-headers', if necessary.
  6001. This is meant to be called in `gnus-article-internal-prepare-hook'."
  6002. (let ((headers (with-current-buffer gnus-summary-buffer
  6003. gnus-current-headers)))
  6004. (or (not gnus-use-cross-reference)
  6005. (not headers)
  6006. (and (mail-header-xref headers)
  6007. (not (string= (mail-header-xref headers) "")))
  6008. (let ((case-fold-search t)
  6009. xref)
  6010. (save-restriction
  6011. (nnheader-narrow-to-headers)
  6012. (goto-char (point-min))
  6013. (when (or (and (not (eobp))
  6014. (eq (downcase (char-after)) ?x)
  6015. (looking-at "Xref:"))
  6016. (search-forward "\nXref:" nil t))
  6017. (goto-char (1+ (match-end 0)))
  6018. (setq xref (buffer-substring (point) (point-at-eol)))
  6019. (mail-header-set-xref headers xref)))))))
  6020. (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
  6021. "Find article ID and insert the summary line for that article.
  6022. OLD-HEADER can either be a header or a line number to insert
  6023. the subject line on.
  6024. If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
  6025. and OLD-HEADER will be used when the summary line is inserted,
  6026. too, instead of trying to fetch new headers."
  6027. (let* ((line (and (numberp old-header) old-header))
  6028. (old-header (and (vectorp old-header) old-header))
  6029. (header (cond ((and old-header use-old-header)
  6030. old-header)
  6031. ((and (numberp id)
  6032. (gnus-number-to-header id))
  6033. (gnus-number-to-header id))
  6034. (t
  6035. (gnus-read-header id))))
  6036. (number (and (numberp id) id))
  6037. d)
  6038. (when header
  6039. ;; Rebuild the thread that this article is part of and go to the
  6040. ;; article we have fetched.
  6041. (when (and (not gnus-show-threads)
  6042. old-header)
  6043. (when (and number
  6044. (setq d (gnus-data-find (mail-header-number old-header))))
  6045. (goto-char (gnus-data-pos d))
  6046. (gnus-data-remove
  6047. number
  6048. (- (point-at-bol)
  6049. (prog1
  6050. (1+ (point-at-eol))
  6051. (gnus-delete-line))))))
  6052. ;; Remove list identifiers from subject.
  6053. (let ((gnus-newsgroup-headers (list header)))
  6054. (gnus-summary-remove-list-identifiers))
  6055. (when old-header
  6056. (mail-header-set-number header (mail-header-number old-header)))
  6057. (setq gnus-newsgroup-sparse
  6058. (delq (setq number (mail-header-number header))
  6059. gnus-newsgroup-sparse))
  6060. (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
  6061. (push number gnus-newsgroup-limit)
  6062. (gnus-rebuild-thread (mail-header-id header) line)
  6063. (gnus-summary-goto-subject number nil t))
  6064. (when (and (numberp number)
  6065. (> number 0))
  6066. ;; We have to update the boundaries even if we can't fetch the
  6067. ;; article if ID is a number -- so that the next `P' or `N'
  6068. ;; command will fetch the previous (or next) article even
  6069. ;; if the one we tried to fetch this time has been canceled.
  6070. (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
  6071. (setq gnus-newsgroup-end number))
  6072. (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
  6073. (setq gnus-newsgroup-begin number))
  6074. (setq gnus-newsgroup-unselected
  6075. (delq number gnus-newsgroup-unselected)))
  6076. ;; Report back a success?
  6077. (and header (mail-header-number header))))
  6078. ;;; Process/prefix in the summary buffer
  6079. (defun gnus-summary-work-articles (n)
  6080. "Return a list of articles to be worked upon.
  6081. The prefix argument, the list of process marked articles, and the
  6082. current article will be taken into consideration."
  6083. (with-current-buffer gnus-summary-buffer
  6084. (cond
  6085. (n
  6086. ;; A numerical prefix has been given.
  6087. (setq n (prefix-numeric-value n))
  6088. (let ((backward (< n 0))
  6089. (n (abs (prefix-numeric-value n)))
  6090. articles article)
  6091. (save-excursion
  6092. (while
  6093. (and (> n 0)
  6094. (push (setq article (gnus-summary-article-number))
  6095. articles)
  6096. (if backward
  6097. (gnus-summary-find-prev nil article)
  6098. (gnus-summary-find-next nil article)))
  6099. (decf n)))
  6100. (nreverse articles)))
  6101. ((and (gnus-region-active-p) (mark))
  6102. (message "region active")
  6103. ;; Work on the region between point and mark.
  6104. (let ((max (max (point) (mark)))
  6105. articles article)
  6106. (save-excursion
  6107. (goto-char (min (point) (mark)))
  6108. (while
  6109. (and
  6110. (push (setq article (gnus-summary-article-number)) articles)
  6111. (gnus-summary-find-next nil article)
  6112. (< (point) max)))
  6113. (nreverse articles))))
  6114. (gnus-newsgroup-processable
  6115. ;; There are process-marked articles present.
  6116. ;; Save current state.
  6117. (gnus-summary-save-process-mark)
  6118. ;; Return the list.
  6119. (reverse gnus-newsgroup-processable))
  6120. (t
  6121. ;; Just return the current article.
  6122. (list (gnus-summary-article-number))))))
  6123. (defmacro gnus-summary-iterate (arg &rest forms)
  6124. "Iterate over the process/prefixed articles and do FORMS.
  6125. ARG is the interactive prefix given to the command. FORMS will be
  6126. executed with point over the summary line of the articles."
  6127. (let ((articles (make-symbol "gnus-summary-iterate-articles")))
  6128. `(let ((,articles (gnus-summary-work-articles ,arg)))
  6129. (while ,articles
  6130. (gnus-summary-goto-subject (car ,articles))
  6131. ,@forms
  6132. (pop ,articles)))))
  6133. (put 'gnus-summary-iterate 'lisp-indent-function 1)
  6134. (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
  6135. (defun gnus-summary-save-process-mark ()
  6136. "Push the current set of process marked articles on the stack."
  6137. (interactive)
  6138. (push (copy-sequence gnus-newsgroup-processable)
  6139. gnus-newsgroup-process-stack))
  6140. (defun gnus-summary-kill-process-mark ()
  6141. "Push the current set of process marked articles on the stack and unmark."
  6142. (interactive)
  6143. (gnus-summary-save-process-mark)
  6144. (gnus-summary-unmark-all-processable))
  6145. (defun gnus-summary-yank-process-mark ()
  6146. "Pop the last process mark state off the stack and restore it."
  6147. (interactive)
  6148. (unless gnus-newsgroup-process-stack
  6149. (error "Empty mark stack"))
  6150. (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
  6151. (defun gnus-summary-process-mark-set (set)
  6152. "Make SET into the current process marked articles."
  6153. (gnus-summary-unmark-all-processable)
  6154. (mapc 'gnus-summary-set-process-mark set))
  6155. ;;; Searching and stuff
  6156. (defun gnus-summary-search-group (&optional backward use-level)
  6157. "Search for next unread newsgroup.
  6158. If optional argument BACKWARD is non-nil, search backward instead."
  6159. (with-current-buffer gnus-group-buffer
  6160. (when (gnus-group-search-forward
  6161. backward nil (if use-level (gnus-group-group-level) nil))
  6162. (gnus-group-group-name))))
  6163. (defun gnus-summary-best-group (&optional exclude-group)
  6164. "Find the name of the best unread group.
  6165. If EXCLUDE-GROUP, do not go to this group."
  6166. (with-current-buffer gnus-group-buffer
  6167. (save-excursion
  6168. (gnus-group-best-unread-group exclude-group))))
  6169. (defun gnus-summary-find-next (&optional unread article backward)
  6170. (if backward
  6171. (gnus-summary-find-prev unread article)
  6172. (let* ((dummy (gnus-summary-article-intangible-p))
  6173. (article (or article (gnus-summary-article-number)))
  6174. (data (gnus-data-find-list article))
  6175. result)
  6176. (when (and (not dummy)
  6177. (or (not gnus-summary-check-current)
  6178. (not unread)
  6179. (not (gnus-data-unread-p (car data)))))
  6180. (setq data (cdr data)))
  6181. (when (setq result
  6182. (if unread
  6183. (progn
  6184. (while data
  6185. (unless (memq (gnus-data-number (car data))
  6186. (cond
  6187. ((eq gnus-auto-goto-ignores
  6188. 'always-undownloaded)
  6189. gnus-newsgroup-undownloaded)
  6190. (gnus-plugged
  6191. nil)
  6192. ((eq gnus-auto-goto-ignores
  6193. 'unfetched)
  6194. gnus-newsgroup-unfetched)
  6195. ((eq gnus-auto-goto-ignores
  6196. 'undownloaded)
  6197. gnus-newsgroup-undownloaded)))
  6198. (when (gnus-data-unread-p (car data))
  6199. (setq result (car data)
  6200. data nil)))
  6201. (setq data (cdr data)))
  6202. result)
  6203. (car data)))
  6204. (goto-char (gnus-data-pos result))
  6205. (gnus-data-number result)))))
  6206. (defun gnus-summary-find-prev (&optional unread article)
  6207. (let* ((eobp (eobp))
  6208. (article (or article (gnus-summary-article-number)))
  6209. (data (gnus-data-find-list article (gnus-data-list 'rev)))
  6210. result)
  6211. (when (and (not eobp)
  6212. (or (not gnus-summary-check-current)
  6213. (not unread)
  6214. (not (gnus-data-unread-p (car data)))))
  6215. (setq data (cdr data)))
  6216. (when (setq result
  6217. (if unread
  6218. (progn
  6219. (while data
  6220. (unless (memq (gnus-data-number (car data))
  6221. (cond
  6222. ((eq gnus-auto-goto-ignores
  6223. 'always-undownloaded)
  6224. gnus-newsgroup-undownloaded)
  6225. (gnus-plugged
  6226. nil)
  6227. ((eq gnus-auto-goto-ignores
  6228. 'unfetched)
  6229. gnus-newsgroup-unfetched)
  6230. ((eq gnus-auto-goto-ignores
  6231. 'undownloaded)
  6232. gnus-newsgroup-undownloaded)))
  6233. (when (gnus-data-unread-p (car data))
  6234. (setq result (car data)
  6235. data nil)))
  6236. (setq data (cdr data)))
  6237. result)
  6238. (car data)))
  6239. (goto-char (gnus-data-pos result))
  6240. (gnus-data-number result))))
  6241. (defun gnus-summary-find-subject (subject &optional unread backward article)
  6242. (let* ((simp-subject (gnus-simplify-subject-fully subject))
  6243. (article (or article (gnus-summary-article-number)))
  6244. (articles (gnus-data-list backward))
  6245. (arts (gnus-data-find-list article articles))
  6246. result)
  6247. (when (or (not gnus-summary-check-current)
  6248. (not unread)
  6249. (not (gnus-data-unread-p (car arts))))
  6250. (setq arts (cdr arts)))
  6251. (while arts
  6252. (and (or (not unread)
  6253. (gnus-data-unread-p (car arts)))
  6254. (vectorp (gnus-data-header (car arts)))
  6255. (gnus-subject-equal
  6256. simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
  6257. (setq result (car arts)
  6258. arts nil))
  6259. (setq arts (cdr arts)))
  6260. (and result
  6261. (goto-char (gnus-data-pos result))
  6262. (gnus-data-number result))))
  6263. (defun gnus-summary-search-forward (&optional unread subject backward)
  6264. "Search forward for an article.
  6265. If UNREAD, look for unread articles. If SUBJECT, look for
  6266. articles with that subject. If BACKWARD, search backward instead."
  6267. (cond (subject (gnus-summary-find-subject subject unread backward))
  6268. (backward (gnus-summary-find-prev unread))
  6269. (t (gnus-summary-find-next unread))))
  6270. (defun gnus-recenter (&optional n)
  6271. "Center point in window and redisplay frame.
  6272. Also do horizontal recentering."
  6273. (interactive "P")
  6274. (when (and gnus-auto-center-summary
  6275. (not (eq gnus-auto-center-summary 'vertical)))
  6276. (gnus-horizontal-recenter))
  6277. (if (fboundp 'recenter-top-bottom)
  6278. (recenter-top-bottom n)
  6279. (recenter n)))
  6280. (put 'gnus-recenter 'isearch-scroll t)
  6281. (defun gnus-forward-line-ignore-invisible (n)
  6282. "Move N lines forward (backward if N is negative).
  6283. Like forward-line, but skip over (and don't count) invisible lines."
  6284. (let (done)
  6285. (while (and (> n 0) (not done))
  6286. ;; If the following character is currently invisible,
  6287. ;; skip all characters with that same `invisible' property value.
  6288. (while (gnus-invisible-p (point))
  6289. (goto-char (gnus-next-char-property-change (point))))
  6290. (forward-line 1)
  6291. (if (eobp)
  6292. (setq done t)
  6293. (setq n (1- n))))
  6294. (while (and (< n 0) (not done))
  6295. (forward-line -1)
  6296. (if (bobp) (setq done t)
  6297. (setq n (1+ n))
  6298. (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
  6299. (goto-char (gnus-previous-char-property-change (point))))))))
  6300. (defun gnus-summary-recenter ()
  6301. "Center point in the summary window.
  6302. If `gnus-auto-center-summary' is nil, or the article buffer isn't
  6303. displayed, no centering will be performed."
  6304. ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
  6305. ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
  6306. (interactive)
  6307. ;; The user has to want it.
  6308. (when gnus-auto-center-summary
  6309. (let* ((top (cond ((< (window-height) 4) 0)
  6310. ((< (window-height) 7) 1)
  6311. (t (if (numberp gnus-auto-center-summary)
  6312. gnus-auto-center-summary
  6313. (/ (1- (window-height)) 2)))))
  6314. (height (1- (window-height)))
  6315. (bottom (save-excursion
  6316. (goto-char (point-max))
  6317. (gnus-forward-line-ignore-invisible (- height))
  6318. (point)))
  6319. (window (get-buffer-window (current-buffer))))
  6320. (when (get-buffer-window gnus-article-buffer)
  6321. ;; Only do recentering when the article buffer is displayed,
  6322. ;; Set the window start to either `bottom', which is the biggest
  6323. ;; possible valid number, or the second line from the top,
  6324. ;; whichever is the least.
  6325. (let ((top-pos (save-excursion
  6326. (gnus-forward-line-ignore-invisible (- top))
  6327. (point))))
  6328. (if (> bottom top-pos)
  6329. ;; Keep the second line from the top visible
  6330. (set-window-start window top-pos)
  6331. ;; Try to keep the bottom line visible; if it's partially
  6332. ;; obscured, either scroll one more line to make it fully
  6333. ;; visible, or revert to using TOP-POS.
  6334. (save-excursion
  6335. (goto-char (point-max))
  6336. (gnus-forward-line-ignore-invisible -1)
  6337. (let ((last-line-start (point)))
  6338. (goto-char bottom)
  6339. (set-window-start window (point) t)
  6340. (when (not (pos-visible-in-window-p last-line-start window))
  6341. (gnus-forward-line-ignore-invisible 1)
  6342. (set-window-start window (min (point) top-pos) t)))))))
  6343. ;; Do horizontal recentering while we're at it.
  6344. (when (and (get-buffer-window (current-buffer) t)
  6345. (not (eq gnus-auto-center-summary 'vertical)))
  6346. (let ((selected (selected-window)))
  6347. (select-window (get-buffer-window (current-buffer) t))
  6348. (gnus-summary-position-point)
  6349. (gnus-horizontal-recenter)
  6350. (select-window selected))))))
  6351. (defun gnus-summary-jump-to-group (newsgroup)
  6352. "Move point to NEWSGROUP in group mode buffer."
  6353. ;; Keep update point of group mode buffer if visible.
  6354. (if (eq (current-buffer) (get-buffer gnus-group-buffer))
  6355. (save-window-excursion
  6356. ;; Take care of tree window mode.
  6357. (when (get-buffer-window gnus-group-buffer)
  6358. (pop-to-buffer gnus-group-buffer))
  6359. (gnus-group-jump-to-group newsgroup))
  6360. (save-excursion
  6361. ;; Take care of tree window mode.
  6362. (if (get-buffer-window gnus-group-buffer 0)
  6363. (pop-to-buffer gnus-group-buffer)
  6364. (set-buffer gnus-group-buffer))
  6365. (gnus-group-jump-to-group newsgroup))))
  6366. ;; This function returns a list of article numbers based on the
  6367. ;; difference between the ranges of read articles in this group and
  6368. ;; the range of active articles.
  6369. (defun gnus-list-of-unread-articles (group)
  6370. (let* ((read (gnus-info-read (gnus-get-info group)))
  6371. (active (or (gnus-active group) (gnus-activate-group group)))
  6372. (last (or (cdr active)
  6373. (error "Group %s couldn't be activated " group)))
  6374. (bottom (if gnus-newsgroup-maximum-articles
  6375. (max (car active)
  6376. (- last gnus-newsgroup-maximum-articles -1))
  6377. (car active)))
  6378. first nlast unread)
  6379. ;; If none are read, then all are unread.
  6380. (if (not read)
  6381. (setq first bottom)
  6382. ;; If the range of read articles is a single range, then the
  6383. ;; first unread article is the article after the last read
  6384. ;; article. Sounds logical, doesn't it?
  6385. (if (and (not (listp (cdr read)))
  6386. (or (< (car read) bottom)
  6387. (progn (setq read (list read))
  6388. nil)))
  6389. (setq first (max bottom (1+ (cdr read))))
  6390. ;; `read' is a list of ranges.
  6391. (when (/= (setq nlast (or (and (numberp (car read)) (car read))
  6392. (caar read)))
  6393. 1)
  6394. (setq first bottom))
  6395. (while read
  6396. (when first
  6397. (while (< first nlast)
  6398. (setq unread (cons first unread)
  6399. first (1+ first))))
  6400. (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
  6401. (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
  6402. (setq read (cdr read)))))
  6403. ;; And add the last unread articles.
  6404. (while (<= first last)
  6405. (setq unread (cons first unread)
  6406. first (1+ first)))
  6407. ;; Return the list of unread articles.
  6408. (delq 0 (nreverse unread))))
  6409. (defun gnus-list-of-read-articles (group)
  6410. "Return a list of unread, unticked and non-dormant articles."
  6411. (let* ((info (gnus-get-info group))
  6412. (marked (gnus-info-marks info))
  6413. (active (gnus-active group)))
  6414. (and info active
  6415. (gnus-list-range-difference
  6416. (gnus-list-range-difference
  6417. (gnus-sorted-complement
  6418. (gnus-uncompress-range
  6419. (if gnus-newsgroup-maximum-articles
  6420. (cons (max (car active)
  6421. (- (cdr active)
  6422. gnus-newsgroup-maximum-articles
  6423. -1))
  6424. (cdr active))
  6425. active))
  6426. (gnus-list-of-unread-articles group))
  6427. (cdr (assq 'dormant marked)))
  6428. (cdr (assq 'tick marked))))))
  6429. ;; This function returns a sequence of article numbers based on the
  6430. ;; difference between the ranges of read articles in this group and
  6431. ;; the range of active articles.
  6432. (defun gnus-sequence-of-unread-articles (group)
  6433. (let* ((read (gnus-info-read (gnus-get-info group)))
  6434. (active (or (gnus-active group) (gnus-activate-group group)))
  6435. (last (cdr active))
  6436. (bottom (if gnus-newsgroup-maximum-articles
  6437. (max (car active)
  6438. (- last gnus-newsgroup-maximum-articles -1))
  6439. (car active)))
  6440. first nlast unread)
  6441. ;; If none are read, then all are unread.
  6442. (if (not read)
  6443. (setq first bottom)
  6444. ;; If the range of read articles is a single range, then the
  6445. ;; first unread article is the article after the last read
  6446. ;; article. Sounds logical, doesn't it?
  6447. (if (and (not (listp (cdr read)))
  6448. (or (< (car read) bottom)
  6449. (progn (setq read (list read))
  6450. nil)))
  6451. (setq first (max bottom (1+ (cdr read))))
  6452. ;; `read' is a list of ranges.
  6453. (when (/= (setq nlast (or (and (numberp (car read)) (car read))
  6454. (caar read)))
  6455. 1)
  6456. (setq first bottom))
  6457. (while read
  6458. (when first
  6459. (push (cons first nlast) unread))
  6460. (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
  6461. (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
  6462. (setq read (cdr read)))))
  6463. ;; And add the last unread articles.
  6464. (cond ((not (and first last))
  6465. nil)
  6466. ((< first last)
  6467. (push (cons first last) unread))
  6468. ((= first last)
  6469. (push first unread)))
  6470. ;; Return the sequence of unread articles.
  6471. (delq 0 (nreverse unread))))
  6472. ;; Various summary commands
  6473. (defun gnus-summary-select-article-buffer ()
  6474. "Reconfigure windows to show the article buffer.
  6475. If `gnus-widen-article-window' is set, show only the article
  6476. buffer."
  6477. (interactive)
  6478. (if (not (gnus-buffer-live-p gnus-article-buffer))
  6479. (error "There is no article buffer for this summary buffer")
  6480. (unless (get-buffer-window gnus-article-buffer)
  6481. (gnus-summary-show-article))
  6482. (gnus-configure-windows
  6483. (if gnus-widen-article-window
  6484. 'only-article
  6485. 'article)
  6486. t)
  6487. (select-window (get-buffer-window gnus-article-buffer))))
  6488. (defun gnus-summary-universal-argument (arg)
  6489. "Perform any operation on all articles that are process/prefixed."
  6490. (interactive "P")
  6491. (let ((articles (gnus-summary-work-articles arg))
  6492. func article)
  6493. (if (eq
  6494. (setq
  6495. func
  6496. (key-binding
  6497. (read-key-sequence
  6498. (substitute-command-keys
  6499. "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
  6500. 'undefined)
  6501. (gnus-error 1 "Undefined key")
  6502. (save-excursion
  6503. (while articles
  6504. (gnus-summary-goto-subject (setq article (pop articles)))
  6505. (let (gnus-newsgroup-processable)
  6506. (command-execute func))
  6507. (gnus-summary-remove-process-mark article)))))
  6508. (gnus-summary-position-point))
  6509. (defun gnus-summary-toggle-truncation (&optional arg)
  6510. "Toggle truncation of summary lines.
  6511. With ARG, turn line truncation on if ARG is positive."
  6512. (interactive "P")
  6513. (setq truncate-lines
  6514. (if (null arg) (not truncate-lines)
  6515. (> (prefix-numeric-value arg) 0)))
  6516. (redraw-display))
  6517. (defun gnus-summary-find-for-reselect ()
  6518. "Return the number of an article to stay on across a reselect.
  6519. The current article is considered, then following articles, then previous
  6520. articles. An article is sought which is not canceled and isn't a temporary
  6521. insertion from another group. If there's no such then return a dummy 0."
  6522. (let (found)
  6523. (dolist (rev '(nil t))
  6524. (unless found ; don't demand the reverse list if we don't need it
  6525. (let ((data (gnus-data-find-list
  6526. (gnus-summary-article-number) (gnus-data-list rev))))
  6527. (while (and data (not found))
  6528. (if (and (< 0 (gnus-data-number (car data)))
  6529. (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
  6530. (setq found (gnus-data-number (car data))))
  6531. (setq data (cdr data))))))
  6532. (or found 0)))
  6533. (defun gnus-summary-reselect-current-group (&optional all rescan)
  6534. "Exit and then reselect the current newsgroup.
  6535. The prefix argument ALL means to select all articles."
  6536. (interactive "P")
  6537. (when (gnus-ephemeral-group-p gnus-newsgroup-name)
  6538. (error "Ephemeral groups can't be reselected"))
  6539. (let ((current-subject (gnus-summary-find-for-reselect))
  6540. (group gnus-newsgroup-name))
  6541. (setq gnus-newsgroup-begin nil)
  6542. (gnus-summary-exit nil 'leave-hidden)
  6543. ;; We have to adjust the point of group mode buffer because
  6544. ;; point was moved to the next unread newsgroup by exiting.
  6545. (gnus-summary-jump-to-group group)
  6546. (when rescan
  6547. (save-excursion
  6548. (gnus-group-get-new-news-this-group 1)))
  6549. (gnus-group-read-group all t)
  6550. (gnus-summary-goto-subject current-subject nil t)))
  6551. (defun gnus-summary-rescan-group (&optional all)
  6552. "Exit the newsgroup, ask for new articles, and select the newsgroup."
  6553. (interactive "P")
  6554. (let ((config gnus-current-window-configuration))
  6555. (gnus-summary-reselect-current-group all t)
  6556. (gnus-configure-windows config)
  6557. (when (eq config 'article)
  6558. (gnus-summary-select-article))))
  6559. (defun gnus-summary-update-info (&optional non-destructive)
  6560. (save-excursion
  6561. (let ((group gnus-newsgroup-name))
  6562. (when group
  6563. (when gnus-newsgroup-kill-headers
  6564. (setq gnus-newsgroup-killed
  6565. (gnus-compress-sequence
  6566. (gnus-sorted-union
  6567. (gnus-list-range-intersection
  6568. gnus-newsgroup-unselected gnus-newsgroup-killed)
  6569. gnus-newsgroup-unreads)
  6570. t)))
  6571. (unless (listp (cdr gnus-newsgroup-killed))
  6572. (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
  6573. (let ((headers gnus-newsgroup-headers)
  6574. (ephemeral-p (gnus-ephemeral-group-p group))
  6575. info)
  6576. (unless ephemeral-p
  6577. (setq info (copy-sequence (gnus-get-info group))
  6578. info (delq (gnus-info-params info) info)))
  6579. ;; Set the new ranges of read articles.
  6580. (with-current-buffer gnus-group-buffer
  6581. (gnus-undo-force-boundary))
  6582. (gnus-update-read-articles
  6583. group (gnus-sorted-union
  6584. gnus-newsgroup-unreads gnus-newsgroup-unselected))
  6585. ;; Set the current article marks.
  6586. (let ((gnus-newsgroup-scored
  6587. (if (and (not gnus-save-score)
  6588. (not non-destructive))
  6589. nil
  6590. gnus-newsgroup-scored)))
  6591. (save-excursion
  6592. (gnus-update-marks)))
  6593. ;; Do the cross-ref thing.
  6594. (when gnus-use-cross-reference
  6595. (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
  6596. ;; Do not switch windows but change the buffer to work.
  6597. (set-buffer gnus-group-buffer)
  6598. (unless ephemeral-p
  6599. (gnus-group-update-group
  6600. group nil
  6601. (equal info
  6602. (setq info (copy-sequence (gnus-get-info group))
  6603. info (delq (gnus-info-params info) info))))))))))
  6604. (defun gnus-summary-save-newsrc (&optional force)
  6605. "Save the current number of read/marked articles in the dribble buffer.
  6606. The dribble buffer will then be saved.
  6607. If FORCE (the prefix), also save the .newsrc file(s)."
  6608. (interactive "P")
  6609. (gnus-summary-update-info t)
  6610. (if force
  6611. (gnus-save-newsrc-file)
  6612. (gnus-dribble-save)))
  6613. (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
  6614. (declare-function gnus-article-stop-animations "gnus-art" ())
  6615. (defun gnus-summary-exit (&optional temporary leave-hidden)
  6616. "Exit reading current newsgroup, and then return to group selection mode.
  6617. `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
  6618. (interactive)
  6619. (gnus-set-global-variables)
  6620. (when (gnus-buffer-live-p gnus-article-buffer)
  6621. (with-current-buffer gnus-article-buffer
  6622. (mm-destroy-parts gnus-article-mime-handles)
  6623. ;; Set it to nil for safety reason.
  6624. (setq gnus-article-mime-handle-alist nil)
  6625. (setq gnus-article-mime-handles nil)))
  6626. (gnus-kill-save-kill-buffer)
  6627. (gnus-async-halt-prefetch)
  6628. (let* ((group gnus-newsgroup-name)
  6629. (quit-config (gnus-group-quit-config gnus-newsgroup-name))
  6630. (gnus-group-is-exiting-p t)
  6631. (article-buffer gnus-article-buffer)
  6632. (original-article-buffer gnus-original-article-buffer)
  6633. (mode major-mode)
  6634. (group-point nil)
  6635. (buf (current-buffer))
  6636. ;; `gnus-single-article-buffer' is nil buffer-locally in
  6637. ;; ephemeral group of which summary buffer will be killed,
  6638. ;; but the global value may be non-nil.
  6639. (single-article-buffer gnus-single-article-buffer))
  6640. (unless quit-config
  6641. ;; Do adaptive scoring, and possibly save score files.
  6642. (when gnus-newsgroup-adaptive
  6643. (gnus-score-adaptive))
  6644. (when gnus-use-scoring
  6645. (gnus-score-save)))
  6646. (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
  6647. (when gnus-use-cache
  6648. (gnus-cache-possibly-remove-articles)
  6649. (gnus-cache-save-buffers))
  6650. (gnus-async-prefetch-remove-group group)
  6651. (when gnus-suppress-duplicates
  6652. (gnus-dup-enter-articles))
  6653. (when gnus-use-trees
  6654. (gnus-tree-close))
  6655. (when gnus-use-cache
  6656. (gnus-cache-write-active))
  6657. ;; Remove entries for this group.
  6658. (nnmail-purge-split-history (gnus-group-real-name group))
  6659. ;; Make all changes in this group permanent.
  6660. (unless quit-config
  6661. (gnus-run-hooks 'gnus-exit-group-hook)
  6662. (gnus-summary-update-info))
  6663. (gnus-close-group group)
  6664. ;; Make sure where we were, and go to next newsgroup.
  6665. (when (buffer-live-p (get-buffer gnus-group-buffer))
  6666. (set-buffer gnus-group-buffer))
  6667. (unless quit-config
  6668. (gnus-group-jump-to-group group))
  6669. (gnus-run-hooks 'gnus-summary-exit-hook)
  6670. (unless (or quit-config
  6671. (not gnus-summary-next-group-on-exit)
  6672. ;; If this group has disappeared from the summary
  6673. ;; buffer, don't skip forwards.
  6674. (not (string= group (gnus-group-group-name))))
  6675. (gnus-group-next-unread-group 1))
  6676. (setq group-point (point))
  6677. (gnus-article-stop-animations)
  6678. (if temporary
  6679. nil ;Nothing to do.
  6680. (set-buffer buf)
  6681. (if (not gnus-kill-summary-on-exit)
  6682. (progn
  6683. (gnus-deaden-summary)
  6684. (setq mode nil))
  6685. (when (get-buffer gnus-article-buffer)
  6686. (bury-buffer gnus-article-buffer))
  6687. ;; Return to group mode buffer.
  6688. (when (eq mode 'gnus-summary-mode)
  6689. (gnus-kill-buffer buf)))
  6690. (setq gnus-current-select-method gnus-select-method)
  6691. (when (gnus-buffer-live-p gnus-group-buffer)
  6692. (set-buffer gnus-group-buffer))
  6693. (if quit-config
  6694. (gnus-handle-ephemeral-exit quit-config)
  6695. (goto-char group-point)
  6696. ;; If gnus-group-buffer is already displayed, make sure we also move
  6697. ;; the cursor in the window that displays it.
  6698. (let ((win (get-buffer-window (current-buffer) 0)))
  6699. (if win (set-window-point win (point))))
  6700. (unless leave-hidden
  6701. (gnus-configure-windows 'group 'force)))
  6702. ;; If we have several article buffers, we kill them at exit.
  6703. (unless single-article-buffer
  6704. (when (gnus-buffer-live-p article-buffer)
  6705. (with-current-buffer article-buffer
  6706. ;; Don't kill sticky article buffers
  6707. (unless (eq major-mode 'gnus-sticky-article-mode)
  6708. (gnus-kill-buffer article-buffer)
  6709. (setq gnus-article-current nil))))
  6710. (gnus-kill-buffer original-article-buffer))
  6711. ;; Clear the current group name.
  6712. (unless quit-config
  6713. (setq gnus-newsgroup-name nil)))))
  6714. (declare-function gnus-stop-downloads "gnus-art" ())
  6715. (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
  6716. (defun gnus-summary-exit-no-update (&optional no-questions)
  6717. "Quit reading current newsgroup without updating read article info."
  6718. (interactive)
  6719. (let* ((group gnus-newsgroup-name)
  6720. (gnus-group-is-exiting-p t)
  6721. (gnus-group-is-exiting-without-update-p t)
  6722. (quit-config (gnus-group-quit-config group)))
  6723. (when (or no-questions
  6724. (gnus-ephemeral-group-p group)
  6725. gnus-expert-user
  6726. (gnus-y-or-n-p "Discard changes to this group and exit? "))
  6727. (gnus-async-halt-prefetch)
  6728. (run-hooks 'gnus-summary-prepare-exit-hook)
  6729. (when (gnus-buffer-live-p gnus-article-buffer)
  6730. (with-current-buffer gnus-article-buffer
  6731. (gnus-article-stop-animations)
  6732. (gnus-stop-downloads)
  6733. (mm-destroy-parts gnus-article-mime-handles)
  6734. ;; Set it to nil for safety reason.
  6735. (setq gnus-article-mime-handle-alist nil)
  6736. (setq gnus-article-mime-handles nil)))
  6737. ;; If we have several article buffers, we kill them at exit.
  6738. (unless gnus-single-article-buffer
  6739. (gnus-kill-buffer gnus-article-buffer)
  6740. (gnus-kill-buffer gnus-original-article-buffer)
  6741. (setq gnus-article-current nil))
  6742. ;; Return to the group buffer.
  6743. (if (not gnus-kill-summary-on-exit)
  6744. (progn
  6745. (gnus-deaden-summary)
  6746. (gnus-configure-windows 'group 'force))
  6747. (gnus-configure-windows 'group 'force)
  6748. (gnus-close-group group)
  6749. (gnus-kill-buffer gnus-summary-buffer))
  6750. (unless gnus-single-article-buffer
  6751. (setq gnus-article-current nil))
  6752. (when gnus-use-trees
  6753. (gnus-tree-close))
  6754. (gnus-async-prefetch-remove-group group)
  6755. (when (get-buffer gnus-article-buffer)
  6756. (bury-buffer gnus-article-buffer))
  6757. ;; Clear the current group name.
  6758. (setq gnus-newsgroup-name nil)
  6759. (unless (gnus-ephemeral-group-p group)
  6760. (gnus-group-update-group group nil t))
  6761. (when (equal (gnus-group-group-name) group)
  6762. (gnus-group-next-unread-group 1))
  6763. (gnus-article-stop-animations)
  6764. (when quit-config
  6765. (gnus-handle-ephemeral-exit quit-config)))))
  6766. (defun gnus-handle-ephemeral-exit (quit-config)
  6767. "Handle movement when leaving an ephemeral group.
  6768. The state which existed when entering the ephemeral is reset."
  6769. (if (not (buffer-live-p (car quit-config)))
  6770. (when (gnus-buffer-live-p gnus-group-buffer)
  6771. (gnus-configure-windows 'group 'force))
  6772. (set-buffer (car quit-config))
  6773. (unless (eq (cdr quit-config) 'group)
  6774. (setq gnus-current-select-method
  6775. (gnus-find-method-for-group gnus-newsgroup-name)))
  6776. (cond ((derived-mode-p 'gnus-summary-mode)
  6777. (gnus-set-global-variables))
  6778. ((derived-mode-p 'gnus-article-mode)
  6779. (save-current-buffer
  6780. ;; The `gnus-summary-buffer' variable may point
  6781. ;; to the old summary buffer when using a single
  6782. ;; article buffer.
  6783. (unless (gnus-buffer-live-p gnus-summary-buffer)
  6784. (set-buffer gnus-group-buffer))
  6785. (set-buffer gnus-summary-buffer)
  6786. (gnus-set-global-variables))))
  6787. (if (or (eq (cdr quit-config) 'article)
  6788. (eq (cdr quit-config) 'pick))
  6789. (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
  6790. (gnus-configure-windows 'pick 'force)
  6791. (gnus-configure-windows (cdr quit-config) 'force))
  6792. (gnus-configure-windows (cdr quit-config) 'force))
  6793. (when (derived-mode-p 'gnus-summary-mode)
  6794. (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
  6795. next-unread-noselect))
  6796. (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
  6797. 'next-noselect)
  6798. (gnus-summary-next-subject 1 nil t))
  6799. ((eq gnus-auto-select-on-ephemeral-exit
  6800. 'next-unread-noselect)
  6801. (gnus-summary-next-subject 1 t t))))
  6802. ;; Hide the article buffer which displays the article different
  6803. ;; from the one that the cursor points to in the summary buffer.
  6804. (gnus-configure-windows 'summary 'force))
  6805. (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
  6806. (gnus-summary-next-subject 1))
  6807. ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
  6808. (gnus-summary-next-subject 1 t))))
  6809. (gnus-summary-recenter)
  6810. (gnus-summary-position-point))))
  6811. ;;; Dead summaries.
  6812. (defvar gnus-dead-summary-mode-map
  6813. (let ((map (make-keymap)))
  6814. (suppress-keymap map)
  6815. (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
  6816. (dolist (key '("\C-d" "\r" "\177" [delete]))
  6817. (define-key map key 'gnus-summary-wake-up-the-dead))
  6818. (dolist (key '("q" "Q"))
  6819. (define-key map key 'bury-buffer))
  6820. map))
  6821. (define-minor-mode gnus-dead-summary-mode
  6822. "Minor mode for Gnus summary buffers."
  6823. :lighter " Dead" :keymap gnus-dead-summary-mode-map
  6824. (unless (derived-mode-p 'gnus-summary-mode)
  6825. (setq gnus-dead-summary-mode nil)))
  6826. (defun gnus-deaden-summary ()
  6827. "Make the current summary buffer into a dead summary buffer."
  6828. ;; Kill any previous dead summary buffer.
  6829. (when (and gnus-dead-summary
  6830. (buffer-name gnus-dead-summary))
  6831. (with-current-buffer gnus-dead-summary
  6832. (when gnus-dead-summary-mode
  6833. (kill-buffer (current-buffer)))))
  6834. ;; Make this the current dead summary.
  6835. (setq gnus-dead-summary (current-buffer))
  6836. (gnus-dead-summary-mode 1)
  6837. (let ((name (buffer-name)))
  6838. (when (string-match "Summary" name)
  6839. (rename-buffer
  6840. (concat (substring name 0 (match-beginning 0)) "Dead "
  6841. (substring name (match-beginning 0)))
  6842. t)
  6843. (bury-buffer))))
  6844. (defun gnus-kill-or-deaden-summary (buffer)
  6845. "Kill or deaden the summary BUFFER."
  6846. (save-excursion
  6847. (when (and (buffer-name buffer)
  6848. (not gnus-single-article-buffer))
  6849. (with-current-buffer buffer
  6850. (gnus-kill-buffer gnus-article-buffer)
  6851. (gnus-kill-buffer gnus-original-article-buffer)))
  6852. (cond
  6853. ;; Kill the buffer.
  6854. (gnus-kill-summary-on-exit
  6855. (when (and gnus-use-trees
  6856. (gnus-buffer-exists-p buffer))
  6857. (with-current-buffer buffer
  6858. (gnus-tree-close)))
  6859. (gnus-kill-buffer buffer))
  6860. ;; Deaden the buffer.
  6861. ((gnus-buffer-exists-p buffer)
  6862. (with-current-buffer buffer
  6863. (gnus-deaden-summary))))))
  6864. (defun gnus-summary-wake-up-the-dead (&rest args)
  6865. "Wake up the dead summary buffer."
  6866. (interactive)
  6867. (gnus-dead-summary-mode -1)
  6868. (let ((name (buffer-name)))
  6869. (when (string-match "Dead " name)
  6870. (rename-buffer
  6871. (concat (substring name 0 (match-beginning 0))
  6872. (substring name (match-end 0)))
  6873. t)))
  6874. (gnus-message 3 "This dead summary is now alive again"))
  6875. ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
  6876. (defun gnus-summary-describe-group (&optional force)
  6877. "Describe the current newsgroup."
  6878. (interactive "P")
  6879. (gnus-group-describe-group force gnus-newsgroup-name))
  6880. (defun gnus-summary-describe-briefly ()
  6881. "Describe summary mode commands briefly."
  6882. (interactive)
  6883. (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")))
  6884. ;; Walking around group mode buffer from summary mode.
  6885. (defun gnus-summary-next-group (&optional no-article target-group backward)
  6886. "Exit current newsgroup and then select next unread newsgroup.
  6887. If prefix argument NO-ARTICLE is non-nil, no article is selected
  6888. initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
  6889. previous group instead."
  6890. (interactive "P")
  6891. ;; Stop pre-fetching.
  6892. (gnus-async-halt-prefetch)
  6893. (let ((current-group gnus-newsgroup-name)
  6894. (current-buffer (current-buffer))
  6895. entered)
  6896. ;; First we semi-exit this group to update Xrefs and all variables.
  6897. ;; We can't do a real exit, because the window conf must remain
  6898. ;; the same in case the user is prompted for info, and we don't
  6899. ;; want the window conf to change before that...
  6900. (gnus-summary-exit t)
  6901. (while (not entered)
  6902. ;; Then we find what group we are supposed to enter.
  6903. (set-buffer gnus-group-buffer)
  6904. (gnus-group-jump-to-group current-group)
  6905. (setq target-group
  6906. (or target-group
  6907. (if (eq gnus-keep-same-level 'best)
  6908. (gnus-summary-best-group gnus-newsgroup-name)
  6909. (gnus-summary-search-group backward gnus-keep-same-level))))
  6910. (if (not target-group)
  6911. ;; There are no further groups, so we return to the group
  6912. ;; buffer.
  6913. (progn
  6914. (gnus-message 5 "Returning to the group buffer")
  6915. (setq entered t)
  6916. (when (gnus-buffer-live-p current-buffer)
  6917. (set-buffer current-buffer)
  6918. (gnus-summary-exit))
  6919. (gnus-run-hooks 'gnus-group-no-more-groups-hook))
  6920. ;; We try to enter the target group.
  6921. (gnus-group-jump-to-group target-group)
  6922. (let ((unreads (gnus-group-group-unread)))
  6923. (if (and (or (eq t unreads)
  6924. (and unreads (not (zerop unreads))))
  6925. (gnus-summary-read-group
  6926. target-group nil no-article
  6927. (and (buffer-name current-buffer) current-buffer)
  6928. nil backward))
  6929. (setq entered t)
  6930. (setq current-group target-group
  6931. target-group nil)))))))
  6932. (defun gnus-summary-prev-group (&optional no-article)
  6933. "Exit current newsgroup and then select previous unread newsgroup.
  6934. If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
  6935. (interactive "P")
  6936. (gnus-summary-next-group no-article nil t))
  6937. ;; Walking around summary lines.
  6938. (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
  6939. "Go to the first subject satisfying any non-nil constraint.
  6940. If UNREAD is non-nil, the article should be unread.
  6941. If UNDOWNLOADED is non-nil, the article should be undownloaded.
  6942. If UNSEEN is non-nil, the article should be unseen as well as unread.
  6943. Returns the article selected or nil if there are no matching articles."
  6944. (interactive "P")
  6945. (cond
  6946. ;; Empty summary.
  6947. ((null gnus-newsgroup-data)
  6948. (gnus-message 3 "No articles in the group")
  6949. nil)
  6950. ;; Pick the first article.
  6951. ((not (or unread undownloaded unseen))
  6952. (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
  6953. (gnus-data-number (car gnus-newsgroup-data)))
  6954. ;; Find the first unread article.
  6955. (t
  6956. (let ((data gnus-newsgroup-data))
  6957. (while (and data
  6958. (let ((num (gnus-data-number (car data))))
  6959. (or (memq num gnus-newsgroup-unfetched)
  6960. (not (or (and unread
  6961. (memq num gnus-newsgroup-unreads))
  6962. (and undownloaded
  6963. (memq num gnus-newsgroup-undownloaded))
  6964. (and unseen
  6965. (memq num gnus-newsgroup-unseen)
  6966. (memq num gnus-newsgroup-unreads)))))))
  6967. (setq data (cdr data)))
  6968. (prog1
  6969. (if data
  6970. (progn
  6971. (goto-char (gnus-data-pos (car data)))
  6972. (gnus-data-number (car data)))
  6973. (gnus-message 3 "No more%s articles"
  6974. (let* ((r (when unread " unread"))
  6975. (d (when undownloaded " undownloaded"))
  6976. (s (when unseen " unseen"))
  6977. (l (delq nil (list r d s))))
  6978. (cond ((= 3 (length l))
  6979. (concat r "," d ", or" s))
  6980. ((= 2 (length l))
  6981. (concat (car l) ", or" (cadr l)))
  6982. ((= 1 (length l))
  6983. (car l))
  6984. (t
  6985. ""))))
  6986. nil
  6987. )
  6988. (gnus-summary-position-point))))))
  6989. (defun gnus-summary-next-subject (n &optional unread dont-display)
  6990. "Go to next N'th summary line.
  6991. If N is negative, go to the previous N'th subject line.
  6992. If UNREAD is non-nil, only unread articles are selected.
  6993. The difference between N and the actual number of steps taken is
  6994. returned."
  6995. (interactive "p")
  6996. (let ((backward (< n 0))
  6997. (n (abs n)))
  6998. (while (and (> n 0)
  6999. (if backward
  7000. (gnus-summary-find-prev unread)
  7001. (gnus-summary-find-next unread)))
  7002. (unless (zerop (setq n (1- n)))
  7003. (gnus-summary-show-thread)))
  7004. (when (/= 0 n)
  7005. (gnus-message 7 "No more%s articles"
  7006. (if unread " unread" "")))
  7007. (unless dont-display
  7008. (gnus-summary-recenter)
  7009. (gnus-summary-position-point))
  7010. n))
  7011. (defun gnus-summary-next-unread-subject (n)
  7012. "Go to next N'th unread summary line."
  7013. (interactive "p")
  7014. (gnus-summary-next-subject n t))
  7015. (defun gnus-summary-prev-subject (n &optional unread)
  7016. "Go to previous N'th summary line.
  7017. If optional argument UNREAD is non-nil, only unread article is selected."
  7018. (interactive "p")
  7019. (gnus-summary-next-subject (- n) unread))
  7020. (defun gnus-summary-prev-unread-subject (n)
  7021. "Go to previous N'th unread summary line."
  7022. (interactive "p")
  7023. (gnus-summary-next-subject (- n) t))
  7024. (defun gnus-summary-goto-subjects (articles)
  7025. "Insert the subject header for ARTICLES in the current buffer."
  7026. (save-excursion
  7027. (dolist (article articles)
  7028. (gnus-summary-goto-subject article t)))
  7029. (gnus-summary-limit (append articles gnus-newsgroup-limit))
  7030. (gnus-summary-position-point))
  7031. (defun gnus-summary-goto-subject (article &optional force silent)
  7032. "Go to the subject line of ARTICLE.
  7033. If FORCE, also allow jumping to articles not currently shown."
  7034. (interactive "nArticle number: ")
  7035. (unless (numberp article)
  7036. (error "Article %s is not a number" article))
  7037. (let ((b (point))
  7038. (data (gnus-data-find article)))
  7039. ;; We read in the article if we have to.
  7040. (and (not data)
  7041. force
  7042. (gnus-summary-insert-subject
  7043. article
  7044. (if (or (numberp force) (vectorp force)) force)
  7045. t)
  7046. (setq data (gnus-data-find article)))
  7047. (goto-char b)
  7048. (if (not data)
  7049. (progn
  7050. (unless silent
  7051. (gnus-message 3 "Can't find article %d" article))
  7052. nil)
  7053. (let ((pt (gnus-data-pos data)))
  7054. (goto-char pt)
  7055. (gnus-summary-set-article-display-arrow pt))
  7056. (gnus-summary-position-point)
  7057. article)))
  7058. ;; Walking around summary lines with displaying articles.
  7059. (defun gnus-summary-expand-window (&optional arg)
  7060. "Make the summary buffer take up the entire Emacs frame.
  7061. Given a prefix, will force an `article' buffer configuration."
  7062. (interactive "P")
  7063. (if arg
  7064. (gnus-configure-windows 'article 'force)
  7065. (gnus-configure-windows 'summary 'force)))
  7066. (defun gnus-summary-display-article (article &optional all-header)
  7067. "Display ARTICLE in article buffer."
  7068. (unless (and (gnus-buffer-live-p gnus-article-buffer)
  7069. (with-current-buffer gnus-article-buffer
  7070. (derived-mode-p 'gnus-article-mode)))
  7071. (gnus-article-setup-buffer))
  7072. (gnus-set-global-variables)
  7073. (with-current-buffer gnus-article-buffer
  7074. (setq gnus-article-charset gnus-newsgroup-charset)
  7075. (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
  7076. (mm-enable-multibyte))
  7077. (if (null article)
  7078. nil
  7079. (prog1
  7080. (if gnus-summary-display-article-function
  7081. (funcall gnus-summary-display-article-function article all-header)
  7082. (gnus-article-prepare article all-header))
  7083. (gnus-run-hooks 'gnus-select-article-hook)
  7084. (when (and gnus-current-article
  7085. (not (zerop gnus-current-article)))
  7086. (gnus-summary-goto-subject gnus-current-article))
  7087. (gnus-summary-recenter)
  7088. (when (and gnus-use-trees gnus-show-threads)
  7089. (gnus-possibly-generate-tree article)
  7090. (gnus-highlight-selected-tree article))
  7091. ;; Successfully display article.
  7092. (gnus-article-set-window-start
  7093. (cdr (assq article gnus-newsgroup-bookmarks))))))
  7094. (defun gnus-summary-select-article (&optional all-headers force pseudo article)
  7095. "Select the current article.
  7096. If ALL-HEADERS is non-nil, show all header fields. If FORCE is
  7097. non-nil, the article will be re-fetched even if it already present in
  7098. the article buffer. If PSEUDO is non-nil, pseudo-articles will also
  7099. be displayed."
  7100. ;; Make sure we are in the summary buffer to work around bbdb bug.
  7101. (unless (derived-mode-p 'gnus-summary-mode)
  7102. (set-buffer gnus-summary-buffer))
  7103. (let ((article (or article (gnus-summary-article-number)))
  7104. (all-headers (not (not all-headers))) ;Must be t or nil.
  7105. gnus-summary-display-article-function)
  7106. (and (not pseudo)
  7107. (gnus-summary-article-pseudo-p article)
  7108. (error "This is a pseudo-article"))
  7109. (with-current-buffer gnus-summary-buffer
  7110. (if (or (and gnus-single-article-buffer
  7111. (or (null gnus-current-article)
  7112. (null gnus-article-current)
  7113. (null (get-buffer gnus-article-buffer))
  7114. (not (eq article (cdr gnus-article-current)))
  7115. (not (equal (car gnus-article-current)
  7116. gnus-newsgroup-name))
  7117. (not (get-buffer gnus-original-article-buffer))))
  7118. (and (not gnus-single-article-buffer)
  7119. (or (null gnus-current-article)
  7120. (not (get-buffer gnus-original-article-buffer))
  7121. (not (eq gnus-current-article article))))
  7122. force)
  7123. ;; The requested article is different from the current article.
  7124. (progn
  7125. (gnus-summary-display-article article all-headers)
  7126. (when (gnus-buffer-live-p gnus-article-buffer)
  7127. (with-current-buffer gnus-article-buffer
  7128. (if (not gnus-article-decoded-p) ;; a local variable
  7129. (mm-disable-multibyte))))
  7130. (gnus-article-set-window-start
  7131. (cdr (assq article gnus-newsgroup-bookmarks)))
  7132. article)
  7133. 'old))))
  7134. (defun gnus-summary-force-verify-and-decrypt ()
  7135. "Display buttons for signed/encrypted parts and verify/decrypt them."
  7136. (interactive)
  7137. (let ((mm-verify-option 'known)
  7138. (mm-decrypt-option 'known)
  7139. (gnus-article-emulate-mime t)
  7140. (gnus-buttonized-mime-types (append (list "multipart/signed"
  7141. "multipart/encrypted")
  7142. gnus-buttonized-mime-types)))
  7143. (gnus-summary-select-article nil 'force)))
  7144. (defun gnus-summary-next-article (&optional unread subject backward push)
  7145. "Select the next article.
  7146. If UNREAD, only unread articles are selected.
  7147. If SUBJECT, only articles with SUBJECT are selected.
  7148. If BACKWARD, the previous article is selected instead of the next."
  7149. (interactive "P")
  7150. ;; Make sure we are in the summary buffer.
  7151. (unless (derived-mode-p 'gnus-summary-mode)
  7152. (set-buffer gnus-summary-buffer))
  7153. (cond
  7154. ;; Is there such an article?
  7155. ((and (gnus-summary-search-forward unread subject backward)
  7156. (or (gnus-summary-display-article (gnus-summary-article-number))
  7157. (eq (gnus-summary-article-mark) gnus-canceled-mark)))
  7158. (gnus-summary-position-point))
  7159. ;; If not, we try the first unread, if that is wanted.
  7160. ((and subject
  7161. gnus-auto-select-same
  7162. (gnus-summary-first-unread-article))
  7163. (gnus-summary-position-point)
  7164. (gnus-message 6 "Wrapped"))
  7165. ;; Try to get next/previous article not displayed in this group.
  7166. ((and gnus-auto-extend-newsgroup
  7167. (not unread) (not subject))
  7168. (gnus-summary-goto-article
  7169. (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
  7170. nil (count-lines (point-min) (point))))
  7171. ;; Go to next/previous group.
  7172. (t
  7173. (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
  7174. (gnus-summary-jump-to-group gnus-newsgroup-name))
  7175. (let ((cmd (if (featurep 'xemacs)
  7176. last-command-char
  7177. last-command-event))
  7178. (point
  7179. (with-current-buffer gnus-group-buffer
  7180. (point)))
  7181. (current-summary (current-buffer))
  7182. (group
  7183. (if (eq gnus-keep-same-level 'best)
  7184. (gnus-summary-best-group gnus-newsgroup-name)
  7185. (gnus-summary-search-group backward gnus-keep-same-level))))
  7186. ;; Select next unread newsgroup automagically.
  7187. (cond
  7188. ((or (not gnus-auto-select-next)
  7189. (not cmd))
  7190. (gnus-message 7 "No more%s articles" (if unread " unread" "")))
  7191. ((or (eq gnus-auto-select-next 'quietly)
  7192. (and (eq gnus-auto-select-next 'slightly-quietly)
  7193. push)
  7194. (and (eq gnus-auto-select-next 'almost-quietly)
  7195. (gnus-summary-last-article-p)))
  7196. ;; Select quietly.
  7197. (if (gnus-ephemeral-group-p gnus-newsgroup-name)
  7198. (gnus-summary-exit)
  7199. (gnus-message 7 "No more%s articles (%s)..."
  7200. (if unread " unread" "")
  7201. (if group (concat "selecting " group)
  7202. "exiting"))
  7203. (gnus-summary-next-group nil group backward)))
  7204. (t
  7205. (when (gnus-key-press-event-p last-input-event)
  7206. ;; Somehow or other, we may now have selected a different
  7207. ;; window. Make point go back to the summary buffer.
  7208. (when (eq current-summary (current-buffer))
  7209. ;; FIXME: This burps when get-buffer-window returns nil.
  7210. (select-window (get-buffer-window current-summary 0)))
  7211. (gnus-summary-walk-group-buffer
  7212. gnus-newsgroup-name cmd unread backward point))))))))
  7213. (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
  7214. (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
  7215. (?\C-p (gnus-group-prev-unread-group 1))))
  7216. (cursor-in-echo-area t)
  7217. keve key group ended prompt)
  7218. (with-current-buffer gnus-group-buffer
  7219. (goto-char start)
  7220. (setq group
  7221. (if (eq gnus-keep-same-level 'best)
  7222. (gnus-summary-best-group gnus-newsgroup-name)
  7223. (gnus-summary-search-group backward gnus-keep-same-level))))
  7224. (while (not ended)
  7225. (setq prompt
  7226. (format
  7227. "No more%s articles%s " (if unread " unread" "")
  7228. (if (and group
  7229. (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
  7230. (format " (Type %s for %s [%s])"
  7231. (single-key-description cmd)
  7232. (gnus-group-decoded-name group)
  7233. (gnus-group-unread group))
  7234. (format " (Type %s to exit %s)"
  7235. (single-key-description cmd)
  7236. (gnus-group-decoded-name gnus-newsgroup-name)))))
  7237. ;; Confirm auto selection.
  7238. (setq key (car (setq keve (gnus-read-event-char prompt)))
  7239. ended t)
  7240. (cond
  7241. ((assq key keystrokes)
  7242. (let ((obuf (current-buffer)))
  7243. (switch-to-buffer gnus-group-buffer)
  7244. (when group
  7245. (gnus-group-jump-to-group group))
  7246. (eval (cadr (assq key keystrokes)))
  7247. (setq group (gnus-group-group-name))
  7248. (switch-to-buffer obuf))
  7249. (setq ended nil))
  7250. ((equal key cmd)
  7251. (if (or (not group)
  7252. (gnus-ephemeral-group-p gnus-newsgroup-name))
  7253. (gnus-summary-exit)
  7254. (gnus-summary-next-group nil group backward)))
  7255. (t
  7256. (push (cdr keve) unread-command-events))))))
  7257. (defun gnus-summary-next-unread-article ()
  7258. "Select unread article after current one."
  7259. (interactive)
  7260. (gnus-summary-next-article
  7261. (or (not (eq gnus-summary-goto-unread 'never))
  7262. (gnus-summary-last-article-p (gnus-summary-article-number)))
  7263. (and gnus-auto-select-same
  7264. (gnus-summary-article-subject))))
  7265. (defun gnus-summary-prev-article (&optional unread subject)
  7266. "Select the article before the current one.
  7267. If UNREAD is non-nil, only unread articles are selected."
  7268. (interactive "P")
  7269. (gnus-summary-next-article unread subject t))
  7270. (defun gnus-summary-prev-unread-article ()
  7271. "Select unread article before current one."
  7272. (interactive)
  7273. (gnus-summary-prev-article
  7274. (or (not (eq gnus-summary-goto-unread 'never))
  7275. (gnus-summary-first-article-p (gnus-summary-article-number)))
  7276. (and gnus-auto-select-same
  7277. (gnus-summary-article-subject))))
  7278. (declare-function gnus-article-only-boring-p "gnus-art" ())
  7279. (defun gnus-summary-next-page (&optional lines circular stop)
  7280. "Show next page of the selected article.
  7281. If at the end of the current article, select the next article.
  7282. LINES says how many lines should be scrolled up.
  7283. If CIRCULAR is non-nil, go to the start of the article instead of
  7284. selecting the next article when reaching the end of the current
  7285. article.
  7286. If STOP is non-nil, just stop when reaching the end of the message.
  7287. Also see the variable `gnus-article-skip-boring'."
  7288. (interactive "P")
  7289. (gnus-set-global-variables)
  7290. (let ((article (gnus-summary-article-number))
  7291. (article-window (get-buffer-window gnus-article-buffer t))
  7292. endp)
  7293. ;; If the buffer is empty, we have no article.
  7294. (unless article
  7295. (error "No article to select"))
  7296. (gnus-configure-windows 'article)
  7297. (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
  7298. (if (and (eq gnus-summary-goto-unread 'never)
  7299. (not (gnus-summary-last-article-p article)))
  7300. (gnus-summary-next-article)
  7301. (gnus-summary-next-unread-article))
  7302. (if (or (null gnus-current-article)
  7303. (null gnus-article-current)
  7304. (/= article (cdr gnus-article-current))
  7305. (not (equal (car gnus-article-current) gnus-newsgroup-name)))
  7306. ;; Selected subject is different from current article's.
  7307. (gnus-summary-display-article article)
  7308. (when article-window
  7309. (gnus-eval-in-buffer-window gnus-article-buffer
  7310. (setq endp (or (gnus-article-next-page lines)
  7311. (gnus-article-only-boring-p))))
  7312. (when endp
  7313. (cond ((or stop gnus-summary-stop-at-end-of-message)
  7314. (gnus-message 3 "End of message"))
  7315. (circular
  7316. (gnus-summary-beginning-of-article))
  7317. (lines
  7318. (gnus-message 3 "End of message"))
  7319. ((null lines)
  7320. (if (and (eq gnus-summary-goto-unread 'never)
  7321. (not (gnus-summary-last-article-p article)))
  7322. (gnus-summary-next-article)
  7323. (gnus-summary-next-unread-article))))))))
  7324. (gnus-summary-recenter)
  7325. (gnus-summary-position-point)))
  7326. (defun gnus-summary-prev-page (&optional lines move)
  7327. "Show previous page of selected article.
  7328. Argument LINES specifies lines to be scrolled down.
  7329. If MOVE, move to the previous unread article if point is at
  7330. the beginning of the buffer."
  7331. (interactive "P")
  7332. (let ((article (gnus-summary-article-number))
  7333. (article-window (get-buffer-window gnus-article-buffer t))
  7334. endp)
  7335. (gnus-configure-windows 'article)
  7336. (if (or (null gnus-current-article)
  7337. (null gnus-article-current)
  7338. (/= article (cdr gnus-article-current))
  7339. (not (equal (car gnus-article-current) gnus-newsgroup-name)))
  7340. ;; Selected subject is different from current article's.
  7341. (gnus-summary-display-article article)
  7342. (gnus-summary-recenter)
  7343. (when article-window
  7344. (gnus-eval-in-buffer-window gnus-article-buffer
  7345. (setq endp (gnus-article-prev-page lines)))
  7346. (when (and move endp)
  7347. (cond (lines
  7348. (gnus-message 3 "Beginning of message"))
  7349. ((null lines)
  7350. (if (and (eq gnus-summary-goto-unread 'never)
  7351. (not (gnus-summary-first-article-p article)))
  7352. (gnus-summary-prev-article)
  7353. (gnus-summary-prev-unread-article))))))))
  7354. (gnus-summary-position-point))
  7355. (defun gnus-summary-prev-page-or-article (&optional lines)
  7356. "Show previous page of selected article.
  7357. Argument LINES specifies lines to be scrolled down.
  7358. If at the beginning of the article, go to the next article."
  7359. (interactive "P")
  7360. (gnus-summary-prev-page lines t))
  7361. (defun gnus-summary-scroll-up (lines)
  7362. "Scroll up (or down) one line current article.
  7363. Argument LINES specifies lines to be scrolled up (or down if negative).
  7364. If no article is selected, then the current article will be selected first."
  7365. (interactive "p")
  7366. (gnus-configure-windows 'article)
  7367. (gnus-summary-show-thread)
  7368. (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
  7369. (gnus-eval-in-buffer-window gnus-article-buffer
  7370. (cond ((> lines 0)
  7371. (when (gnus-article-next-page lines)
  7372. (gnus-message 3 "End of message")))
  7373. ((< lines 0)
  7374. (gnus-article-prev-page (- lines))))))
  7375. (gnus-summary-recenter)
  7376. (gnus-summary-position-point))
  7377. (defun gnus-summary-scroll-down (lines)
  7378. "Scroll down (or up) one line current article.
  7379. Argument LINES specifies lines to be scrolled down (or up if negative).
  7380. If no article is selected, then the current article will be selected first."
  7381. (interactive "p")
  7382. (gnus-summary-scroll-up (- lines)))
  7383. (defun gnus-summary-next-same-subject ()
  7384. "Select next article which has the same subject as current one."
  7385. (interactive)
  7386. (gnus-summary-next-article nil (gnus-summary-article-subject)))
  7387. (defun gnus-summary-prev-same-subject ()
  7388. "Select previous article which has the same subject as current one."
  7389. (interactive)
  7390. (gnus-summary-prev-article nil (gnus-summary-article-subject)))
  7391. (defun gnus-summary-next-unread-same-subject ()
  7392. "Select next unread article which has the same subject as current one."
  7393. (interactive)
  7394. (gnus-summary-next-article t (gnus-summary-article-subject)))
  7395. (defun gnus-summary-prev-unread-same-subject ()
  7396. "Select previous unread article which has the same subject as current one."
  7397. (interactive)
  7398. (gnus-summary-prev-article t (gnus-summary-article-subject)))
  7399. (defun gnus-summary-first-unread-article ()
  7400. "Select the first unread article.
  7401. Return nil if there are no unread articles."
  7402. (interactive)
  7403. (prog1
  7404. (when (gnus-summary-first-subject t)
  7405. (gnus-summary-show-thread)
  7406. (gnus-summary-first-subject t)
  7407. (gnus-summary-display-article (gnus-summary-article-number)))
  7408. (gnus-summary-position-point)))
  7409. (defun gnus-summary-first-unread-subject ()
  7410. "Place the point on the subject line of the first unread article.
  7411. Return nil if there are no unread articles."
  7412. (interactive)
  7413. (prog1
  7414. (when (gnus-summary-first-subject t)
  7415. (gnus-summary-show-thread)
  7416. (gnus-summary-first-subject t))
  7417. (gnus-summary-position-point)))
  7418. (defun gnus-summary-first-unseen-subject ()
  7419. "Place the point on the subject line of the first unseen article.
  7420. Return nil if there are no unseen articles."
  7421. (interactive)
  7422. (prog1
  7423. (when (gnus-summary-first-subject nil nil t)
  7424. (gnus-summary-show-thread)
  7425. (gnus-summary-first-subject nil nil t))
  7426. (gnus-summary-position-point)))
  7427. (defun gnus-summary-first-unseen-or-unread-subject ()
  7428. "Place the point on the subject line of the first unseen and unread article.
  7429. If all article have been seen, on the subject line of the first unread
  7430. article."
  7431. (interactive)
  7432. (prog1
  7433. (unless (when (gnus-summary-first-subject nil nil t)
  7434. (gnus-summary-show-thread)
  7435. (gnus-summary-first-subject nil nil t))
  7436. (when (gnus-summary-first-subject t)
  7437. (gnus-summary-show-thread)
  7438. (gnus-summary-first-subject t)))
  7439. (gnus-summary-position-point)))
  7440. (defun gnus-summary-first-article ()
  7441. "Select the first article.
  7442. Return nil if there are no articles."
  7443. (interactive)
  7444. (prog1
  7445. (when (gnus-summary-first-subject)
  7446. (gnus-summary-show-thread)
  7447. (gnus-summary-first-subject)
  7448. (gnus-summary-display-article (gnus-summary-article-number)))
  7449. (gnus-summary-position-point)))
  7450. (defun gnus-summary-best-unread-article (&optional arg)
  7451. "Select the unread article with the highest score.
  7452. If given a prefix argument, select the next unread article that has a
  7453. score higher than the default score."
  7454. (interactive "P")
  7455. (let ((article (if arg
  7456. (gnus-summary-better-unread-subject)
  7457. (gnus-summary-best-unread-subject))))
  7458. (if article
  7459. (gnus-summary-goto-article article)
  7460. (error "No unread articles"))))
  7461. (defun gnus-summary-best-unread-subject ()
  7462. "Select the unread subject with the highest score."
  7463. (interactive)
  7464. (let ((best -1000000)
  7465. (data gnus-newsgroup-data)
  7466. article score)
  7467. (while data
  7468. (and (gnus-data-unread-p (car data))
  7469. (> (setq score
  7470. (gnus-summary-article-score (gnus-data-number (car data))))
  7471. best)
  7472. (setq best score
  7473. article (gnus-data-number (car data))))
  7474. (setq data (cdr data)))
  7475. (when article
  7476. (gnus-summary-goto-subject article))
  7477. (gnus-summary-position-point)
  7478. article))
  7479. (defun gnus-summary-better-unread-subject ()
  7480. "Select the first unread subject that has a score over the default score."
  7481. (interactive)
  7482. (let ((data gnus-newsgroup-data)
  7483. article score)
  7484. (while (and (setq article (gnus-data-number (car data)))
  7485. (or (gnus-data-read-p (car data))
  7486. (not (> (gnus-summary-article-score article)
  7487. gnus-summary-default-score))))
  7488. (setq data (cdr data)))
  7489. (when article
  7490. (gnus-summary-goto-subject article))
  7491. (gnus-summary-position-point)
  7492. article))
  7493. (defun gnus-summary-last-subject ()
  7494. "Go to the last displayed subject line in the group."
  7495. (let ((article (gnus-data-number (car (gnus-data-list t)))))
  7496. (when article
  7497. (gnus-summary-goto-subject article))))
  7498. (defun gnus-summary-goto-article (article &optional all-headers force)
  7499. "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
  7500. If ALL-HEADERS is non-nil, no header lines are hidden.
  7501. If FORCE, go to the article even if it isn't displayed. If FORCE
  7502. is a number, it is the line the article is to be displayed on."
  7503. (interactive
  7504. (list
  7505. (gnus-completing-read
  7506. "Article number or Message-ID"
  7507. (mapcar 'int-to-string gnus-newsgroup-limit))
  7508. current-prefix-arg
  7509. t))
  7510. (prog1
  7511. (if (and (stringp article)
  7512. (string-match "@\\|%40" article))
  7513. (gnus-summary-refer-article article)
  7514. (when (stringp article)
  7515. (setq article (string-to-number article)))
  7516. (if (gnus-summary-goto-subject article force)
  7517. (gnus-summary-display-article article all-headers)
  7518. (gnus-message 4 "Couldn't go to article %s" article) nil))
  7519. (gnus-summary-position-point)))
  7520. (defun gnus-summary-goto-last-article ()
  7521. "Go to the previously read article."
  7522. (interactive)
  7523. (prog1
  7524. (when gnus-last-article
  7525. (gnus-summary-goto-article gnus-last-article nil t))
  7526. (gnus-summary-position-point)))
  7527. (defun gnus-summary-pop-article (number)
  7528. "Pop one article off the history and go to the previous.
  7529. NUMBER articles will be popped off."
  7530. (interactive "p")
  7531. (let (to)
  7532. (setq gnus-newsgroup-history
  7533. (cdr (setq to (nthcdr number gnus-newsgroup-history))))
  7534. (if to
  7535. (gnus-summary-goto-article (car to) nil t)
  7536. (error "Article history empty")))
  7537. (gnus-summary-position-point))
  7538. ;; Summary commands and functions for limiting the summary buffer.
  7539. (defun gnus-summary-limit-to-articles (n)
  7540. "Limit the summary buffer to the next N articles.
  7541. If not given a prefix, use the process marked articles instead."
  7542. (interactive "P")
  7543. (prog1
  7544. (let ((articles (gnus-summary-work-articles n)))
  7545. (setq gnus-newsgroup-processable nil)
  7546. (gnus-summary-limit articles))
  7547. (gnus-summary-position-point)))
  7548. (defun gnus-summary-pop-limit (&optional total)
  7549. "Restore the previous limit.
  7550. If given a prefix, remove all limits."
  7551. (interactive "P")
  7552. (when total
  7553. (setq gnus-newsgroup-limits
  7554. (list (mapcar (lambda (h) (mail-header-number h))
  7555. gnus-newsgroup-headers))))
  7556. (unless gnus-newsgroup-limits
  7557. (error "No limit to pop"))
  7558. (prog1
  7559. (gnus-summary-limit nil 'pop)
  7560. (gnus-summary-position-point)))
  7561. (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
  7562. "Limit the summary buffer to articles that have subjects that match a regexp.
  7563. If NOT-MATCHING, excluding articles that have subjects that match a regexp."
  7564. (interactive
  7565. (list (read-string (if current-prefix-arg
  7566. "Exclude subject (regexp): "
  7567. "Limit to subject (regexp): "))
  7568. nil current-prefix-arg))
  7569. (unless header
  7570. (setq header "subject"))
  7571. (when (not (equal "" subject))
  7572. (prog1
  7573. (let ((articles (gnus-summary-find-matching
  7574. (or header "subject") subject 'all nil nil
  7575. not-matching)))
  7576. (unless articles
  7577. (error "Found no matches for \"%s\"" subject))
  7578. (gnus-summary-limit articles))
  7579. (gnus-summary-position-point))))
  7580. (defun gnus-summary-limit-to-author (from &optional not-matching)
  7581. "Limit the summary buffer to articles that have authors that match a regexp.
  7582. If NOT-MATCHING, excluding articles that have authors that match a regexp."
  7583. (interactive
  7584. (list (let* ((header (gnus-summary-article-header))
  7585. (default (and header (car (mail-header-parse-address
  7586. (mail-header-from header))))))
  7587. (read-string (concat (if current-prefix-arg
  7588. "Exclude author (regexp"
  7589. "Limit to author (regexp")
  7590. (if default
  7591. (concat ", default \"" default "\"): ")
  7592. "): "))
  7593. nil nil
  7594. default))
  7595. current-prefix-arg))
  7596. (gnus-summary-limit-to-subject from "from" not-matching))
  7597. (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
  7598. "Limit the summary buffer to articles with the given RECIPIENT.
  7599. If NOT-MATCHING, exclude RECIPIENT.
  7600. To and Cc headers are checked. You need to include them in
  7601. `nnmail-extra-headers'."
  7602. ;; Unlike `rmail-summary-by-recipients', doesn't include From.
  7603. (interactive
  7604. (list (read-string (format "%s recipient (regexp): "
  7605. (if current-prefix-arg "Exclude" "Limit to")))
  7606. current-prefix-arg))
  7607. (when (not (equal "" recipient))
  7608. (prog1 (let* ((to
  7609. (if (memq 'To nnmail-extra-headers)
  7610. (gnus-summary-find-matching
  7611. (cons 'extra 'To) recipient 'all nil nil
  7612. not-matching)
  7613. (gnus-message
  7614. 1 "`To' isn't present in `nnmail-extra-headers'")
  7615. (sit-for 1)
  7616. nil))
  7617. (cc
  7618. (if (memq 'Cc nnmail-extra-headers)
  7619. (gnus-summary-find-matching
  7620. (cons 'extra 'Cc) recipient 'all nil nil
  7621. not-matching)
  7622. (gnus-message
  7623. 1 "`Cc' isn't present in `nnmail-extra-headers'")
  7624. (sit-for 1)
  7625. nil))
  7626. (articles
  7627. (if not-matching
  7628. ;; We need the numbers that are in both lists:
  7629. (mapcar (lambda (a)
  7630. (and (memq a to) a))
  7631. cc)
  7632. (nconc to cc))))
  7633. (unless articles
  7634. (error "Found no matches for \"%s\"" recipient))
  7635. (gnus-summary-limit articles))
  7636. (gnus-summary-position-point))))
  7637. (defun gnus-summary-limit-to-address (address &optional not-matching)
  7638. "Limit the summary buffer to articles with the given ADDRESS.
  7639. If NOT-MATCHING, exclude ADDRESS.
  7640. To, Cc and From headers are checked. You need to include `To' and `Cc'
  7641. in `nnmail-extra-headers'."
  7642. (interactive
  7643. (list (read-string (format "%s address (regexp): "
  7644. (if current-prefix-arg "Exclude" "Limit to")))
  7645. current-prefix-arg))
  7646. (when (not (equal "" address))
  7647. (prog1 (let* ((to
  7648. (if (memq 'To nnmail-extra-headers)
  7649. (gnus-summary-find-matching
  7650. (cons 'extra 'To) address 'all nil nil
  7651. not-matching)
  7652. (gnus-message
  7653. 1 "`To' isn't present in `nnmail-extra-headers'")
  7654. (sit-for 1)
  7655. t))
  7656. (cc
  7657. (if (memq 'Cc nnmail-extra-headers)
  7658. (gnus-summary-find-matching
  7659. (cons 'extra 'Cc) address 'all nil nil
  7660. not-matching)
  7661. (gnus-message
  7662. 1 "`Cc' isn't present in `nnmail-extra-headers'")
  7663. (sit-for 1)
  7664. t))
  7665. (from
  7666. (gnus-summary-find-matching "from" address
  7667. 'all nil nil not-matching))
  7668. (articles
  7669. (if not-matching
  7670. ;; We need the numbers that are in all lists:
  7671. (if (eq cc t)
  7672. (if (eq to t)
  7673. from
  7674. (mapcar (lambda (a) (car (memq a from))) to))
  7675. (if (eq to t)
  7676. (mapcar (lambda (a) (car (memq a from))) cc)
  7677. (mapcar (lambda (a) (car (memq a from)))
  7678. (mapcar (lambda (a) (car (memq a to)))
  7679. cc))))
  7680. (nconc (if (eq to t) nil to)
  7681. (if (eq cc t) nil cc)
  7682. from))))
  7683. (unless articles
  7684. (error "Found no matches for \"%s\"" address))
  7685. (gnus-summary-limit articles))
  7686. (gnus-summary-position-point))))
  7687. (defun gnus-summary-limit-strange-charsets-predicate (header)
  7688. (when (fboundp 'char-charset)
  7689. (let ((string (concat (mail-header-subject header)
  7690. (mail-header-from header)))
  7691. charset found)
  7692. (dotimes (i (1- (length string)))
  7693. (setq charset (format "%s" (char-charset (aref string (1+ i)))))
  7694. (when (string-match "unicode\\|big\\|japanese" charset)
  7695. (setq found t)))
  7696. found)))
  7697. (defun gnus-summary-limit-to-predicate (predicate)
  7698. "Limit to articles where PREDICATE returns non-nil.
  7699. PREDICATE will be called with the header structures of the
  7700. articles."
  7701. (let ((articles nil)
  7702. (case-fold-search t))
  7703. (dolist (header gnus-newsgroup-headers)
  7704. (when (funcall predicate header)
  7705. (push (mail-header-number header) articles)))
  7706. (gnus-summary-limit (nreverse articles))))
  7707. (defun gnus-summary-limit-to-age (age &optional younger-p)
  7708. "Limit the summary buffer to articles that are older than (or equal) AGE days.
  7709. If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
  7710. articles that are younger than AGE days."
  7711. (interactive
  7712. (let ((younger current-prefix-arg)
  7713. (days-got nil)
  7714. days)
  7715. (while (not days-got)
  7716. (setq days (if younger
  7717. (read-string "Limit to articles younger than (in days, older when negative): ")
  7718. (read-string
  7719. "Limit to articles older than (in days, younger when negative): ")))
  7720. (when (> (length days) 0)
  7721. (setq days (read days)))
  7722. (if (numberp days)
  7723. (progn
  7724. (setq days-got t)
  7725. (when (< days 0)
  7726. (setq younger (not younger))
  7727. (setq days (* days -1))))
  7728. (message "Please enter a number.")
  7729. (sleep-for 1)))
  7730. (list days younger)))
  7731. (prog1
  7732. (let ((data gnus-newsgroup-data)
  7733. (cutoff (days-to-time age))
  7734. articles d date is-younger)
  7735. (while (setq d (pop data))
  7736. (when (and (vectorp (gnus-data-header d))
  7737. (setq date (mail-header-date (gnus-data-header d))))
  7738. (setq is-younger (time-less-p
  7739. (time-since (gnus-date-get-time date))
  7740. cutoff))
  7741. (when (if younger-p
  7742. is-younger
  7743. (not is-younger))
  7744. (push (gnus-data-number d) articles))))
  7745. (gnus-summary-limit (nreverse articles)))
  7746. (gnus-summary-position-point)))
  7747. (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
  7748. "Limit the summary buffer to articles that match an `extra' header."
  7749. (interactive
  7750. (let ((header
  7751. (intern
  7752. (gnus-completing-read
  7753. (if current-prefix-arg
  7754. "Exclude extra header"
  7755. "Limit extra header")
  7756. (mapcar 'symbol-name gnus-extra-headers)
  7757. t nil nil
  7758. (symbol-name (car gnus-extra-headers))))))
  7759. (list header
  7760. (read-string (format "%s header %s (regexp): "
  7761. (if current-prefix-arg "Exclude" "Limit to")
  7762. header))
  7763. current-prefix-arg)))
  7764. (when (not (equal "" regexp))
  7765. (prog1
  7766. (let ((articles (gnus-summary-find-matching
  7767. (cons 'extra header) regexp 'all nil nil
  7768. not-matching)))
  7769. (unless articles
  7770. (error "Found no matches for \"%s\"" regexp))
  7771. (gnus-summary-limit articles))
  7772. (gnus-summary-position-point))))
  7773. (defun gnus-summary-limit-to-display-predicate ()
  7774. "Limit the summary buffer to the predicated in the `display' group parameter."
  7775. (interactive)
  7776. (unless gnus-newsgroup-display
  7777. (error "There is no `display' group parameter"))
  7778. (let (articles)
  7779. (dolist (gnus-number gnus-newsgroup-articles)
  7780. (when (funcall gnus-newsgroup-display)
  7781. (push gnus-number articles)))
  7782. (gnus-summary-limit articles))
  7783. (gnus-summary-position-point))
  7784. (defun gnus-summary-limit-to-unread (&optional all)
  7785. "Limit the summary buffer to articles that are not marked as read.
  7786. If ALL is non-nil, limit strictly to unread articles."
  7787. (interactive "P")
  7788. (if all
  7789. (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
  7790. (gnus-summary-limit-to-marks
  7791. ;; Concat all the marks that say that an article is read and have
  7792. ;; those removed.
  7793. (list gnus-del-mark gnus-read-mark gnus-ancient-mark
  7794. gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
  7795. gnus-low-score-mark gnus-expirable-mark
  7796. gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
  7797. gnus-duplicate-mark)
  7798. 'reverse)))
  7799. (defun gnus-summary-limit-to-headers (match &optional reverse)
  7800. "Limit the summary buffer to articles that have headers that match MATCH.
  7801. If REVERSE (the prefix), limit to articles that don't match."
  7802. (interactive "sMatch headers (regexp): \nP")
  7803. (gnus-summary-limit-to-bodies match reverse t))
  7804. (declare-function article-goto-body "gnus-art" ())
  7805. (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
  7806. "Limit the summary buffer to articles that have bodies that match MATCH.
  7807. If REVERSE (the prefix), limit to articles that don't match."
  7808. (interactive "sMatch body (regexp): \nP")
  7809. (let ((articles nil)
  7810. (gnus-select-article-hook nil) ;Disable hook.
  7811. (gnus-article-prepare-hook nil)
  7812. (gnus-use-article-prefetch nil)
  7813. (gnus-keep-backlog nil)
  7814. (gnus-break-pages nil)
  7815. (gnus-summary-display-arrow nil)
  7816. (gnus-updated-mode-lines nil)
  7817. (gnus-auto-center-summary nil)
  7818. (gnus-display-mime-function nil))
  7819. (dolist (data gnus-newsgroup-data)
  7820. (let (gnus-mark-article-hook)
  7821. (gnus-summary-select-article t t nil (gnus-data-number data)))
  7822. (with-current-buffer gnus-article-buffer
  7823. (article-goto-body)
  7824. (let* ((case-fold-search t)
  7825. (found (if headersp
  7826. (re-search-backward match nil t)
  7827. (re-search-forward match nil t))))
  7828. (when (or (and found
  7829. (not reverse))
  7830. (and (not found)
  7831. reverse))
  7832. (push (gnus-data-number data) articles)))))
  7833. (if (not articles)
  7834. (message "No messages matched")
  7835. (gnus-summary-limit articles)))
  7836. (gnus-summary-position-point))
  7837. (defun gnus-summary-limit-to-singletons (&optional threadsp)
  7838. "Limit the summary buffer to articles that aren't part on any thread.
  7839. If THREADSP (the prefix), limit to articles that are in threads."
  7840. (interactive "P")
  7841. (let ((articles nil)
  7842. thread-articles
  7843. threads)
  7844. (dolist (thread gnus-newsgroup-threads)
  7845. (if (stringp (car thread))
  7846. (dolist (thread (cdr thread))
  7847. (push thread threads))
  7848. (push thread threads)))
  7849. (dolist (thread threads)
  7850. (setq thread-articles (gnus-articles-in-thread thread))
  7851. (when (or (and threadsp
  7852. (> (length thread-articles) 1))
  7853. (and (not threadsp)
  7854. (= (length thread-articles) 1)))
  7855. (setq articles (nconc thread-articles articles))))
  7856. (if (not articles)
  7857. (message "No messages matched")
  7858. (gnus-summary-limit articles))
  7859. (gnus-summary-position-point)))
  7860. (defun gnus-summary-limit-to-replied (&optional unreplied)
  7861. "Limit the summary buffer to replied articles.
  7862. If UNREPLIED (the prefix), limit to unreplied articles."
  7863. (interactive "P")
  7864. (if unreplied
  7865. (gnus-summary-limit
  7866. (gnus-set-difference gnus-newsgroup-articles
  7867. gnus-newsgroup-replied))
  7868. (gnus-summary-limit gnus-newsgroup-replied))
  7869. (gnus-summary-position-point))
  7870. (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
  7871. "Exclude articles that are marked with MARKS (e.g. \"DK\").
  7872. If REVERSE, limit the summary buffer to articles that are marked
  7873. with MARKS. MARKS can either be a string of marks or a list of marks.
  7874. Returns how many articles were removed."
  7875. (interactive "sMarks: ")
  7876. (gnus-summary-limit-to-marks marks t))
  7877. (defun gnus-summary-limit-to-marks (marks &optional reverse)
  7878. "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
  7879. If REVERSE (the prefix), limit the summary buffer to articles that are
  7880. not marked with MARKS. MARKS can either be a string of marks or a
  7881. list of marks.
  7882. Returns how many articles were removed."
  7883. (interactive "sMarks: \nP")
  7884. (prog1
  7885. (let ((data gnus-newsgroup-data)
  7886. (marks (if (listp marks) marks
  7887. (append marks nil))) ; Transform to list.
  7888. articles)
  7889. (while data
  7890. (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
  7891. (memq (gnus-data-mark (car data)) marks))
  7892. (push (gnus-data-number (car data)) articles))
  7893. (setq data (cdr data)))
  7894. (gnus-summary-limit articles))
  7895. (gnus-summary-position-point)))
  7896. (defun gnus-summary-limit-to-score (score)
  7897. "Limit to articles with score at or above SCORE."
  7898. (interactive "NLimit to articles with score of at least: ")
  7899. (let ((data gnus-newsgroup-data)
  7900. articles)
  7901. (while data
  7902. (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
  7903. score)
  7904. (push (gnus-data-number (car data)) articles))
  7905. (setq data (cdr data)))
  7906. (prog1
  7907. (gnus-summary-limit articles)
  7908. (gnus-summary-position-point))))
  7909. (defun gnus-summary-limit-to-unseen ()
  7910. "Limit to unseen articles."
  7911. (interactive)
  7912. (prog1
  7913. (gnus-summary-limit gnus-newsgroup-unseen)
  7914. (gnus-summary-position-point)))
  7915. (defun gnus-summary-limit-include-thread (id)
  7916. "Display all the hidden articles that is in the thread with ID in it.
  7917. When called interactively, ID is the Message-ID of the current
  7918. article."
  7919. (interactive (list (mail-header-id (gnus-summary-article-header))))
  7920. (let ((articles (gnus-articles-in-thread
  7921. (gnus-id-to-thread (gnus-root-id id))))
  7922. ;;we REALLY want the whole thread---this prevents cut-threads
  7923. ;;from removing the thread we want to include.
  7924. (gnus-fetch-old-headers nil)
  7925. (gnus-build-sparse-threads nil))
  7926. (prog1
  7927. (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
  7928. (gnus-summary-limit-include-matching-articles
  7929. "subject"
  7930. (regexp-quote (gnus-simplify-subject-re
  7931. (mail-header-subject (gnus-id-to-header id)))))
  7932. (gnus-summary-position-point))))
  7933. (defun gnus-summary-limit-include-matching-articles (header regexp)
  7934. "Display all the hidden articles that have HEADERs that match REGEXP."
  7935. (interactive (list (read-string "Match on header: ")
  7936. (read-string "Regexp: ")))
  7937. (let ((articles (gnus-find-matching-articles header regexp)))
  7938. (prog1
  7939. (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
  7940. (gnus-summary-position-point))))
  7941. (defun gnus-summary-insert-dormant-articles ()
  7942. "Insert all the dormant articles for this group into the current buffer."
  7943. (interactive)
  7944. (let ((gnus-verbose (max 6 gnus-verbose)))
  7945. (if (not gnus-newsgroup-dormant)
  7946. (gnus-message 3 "No dormant articles for this group")
  7947. (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
  7948. (defun gnus-summary-insert-ticked-articles ()
  7949. "Insert ticked articles for this group into the current buffer."
  7950. (interactive)
  7951. (let ((gnus-verbose (max 6 gnus-verbose)))
  7952. (if (not gnus-newsgroup-marked)
  7953. (gnus-message 3 "No ticked articles for this group")
  7954. (gnus-summary-goto-subjects gnus-newsgroup-marked))))
  7955. (defun gnus-summary-limit-include-dormant ()
  7956. "Display all the hidden articles that are marked as dormant.
  7957. Note that this command only works on a subset of the articles currently
  7958. fetched for this group."
  7959. (interactive)
  7960. (unless gnus-newsgroup-dormant
  7961. (error "There are no dormant articles in this group"))
  7962. (prog1
  7963. (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
  7964. (gnus-summary-position-point)))
  7965. (defun gnus-summary-include-articles (articles)
  7966. "Fetch the headers for ARTICLES and then display the summary lines."
  7967. (let ((gnus-inhibit-demon t)
  7968. (gnus-agent nil)
  7969. (gnus-read-all-available-headers t))
  7970. (setq gnus-newsgroup-headers
  7971. (gnus-merge
  7972. 'list gnus-newsgroup-headers
  7973. (gnus-fetch-headers articles nil t)
  7974. 'gnus-article-sort-by-number))
  7975. (setq gnus-newsgroup-articles
  7976. (gnus-sorted-nunion gnus-newsgroup-articles articles))
  7977. (gnus-summary-limit (append articles gnus-newsgroup-limit))))
  7978. (defun gnus-summary-limit-exclude-dormant ()
  7979. "Hide all dormant articles."
  7980. (interactive)
  7981. (prog1
  7982. (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
  7983. (gnus-summary-position-point)))
  7984. (defun gnus-summary-limit-exclude-childless-dormant ()
  7985. "Hide all dormant articles that have no children."
  7986. (interactive)
  7987. (let ((data (gnus-data-list t))
  7988. articles d children)
  7989. ;; Find all articles that are either not dormant or have
  7990. ;; children.
  7991. (while (setq d (pop data))
  7992. (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
  7993. (and (setq children
  7994. (gnus-article-children (gnus-data-number d)))
  7995. (let (found)
  7996. (while children
  7997. (when (memq (car children) articles)
  7998. (setq children nil
  7999. found t))
  8000. (pop children))
  8001. found)))
  8002. (push (gnus-data-number d) articles)))
  8003. ;; Do the limiting.
  8004. (prog1
  8005. (gnus-summary-limit articles)
  8006. (gnus-summary-position-point))))
  8007. (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
  8008. "Mark all unread excluded articles as read.
  8009. If ALL, mark even excluded ticked and dormants as read."
  8010. (interactive "P")
  8011. (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
  8012. (let ((articles (gnus-sorted-ndifference
  8013. (sort
  8014. (mapcar (lambda (h) (mail-header-number h))
  8015. gnus-newsgroup-headers)
  8016. '<)
  8017. gnus-newsgroup-limit))
  8018. article)
  8019. (setq gnus-newsgroup-unreads
  8020. (gnus-sorted-intersection gnus-newsgroup-unreads
  8021. gnus-newsgroup-limit))
  8022. (if all
  8023. (setq gnus-newsgroup-dormant nil
  8024. gnus-newsgroup-marked nil
  8025. gnus-newsgroup-reads
  8026. (nconc
  8027. (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
  8028. gnus-newsgroup-reads))
  8029. (while (setq article (pop articles))
  8030. (unless (or (memq article gnus-newsgroup-dormant)
  8031. (memq article gnus-newsgroup-marked))
  8032. (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
  8033. (defun gnus-summary-limit (articles &optional pop)
  8034. (if pop
  8035. ;; We pop the previous limit off the stack and use that.
  8036. (setq articles (car gnus-newsgroup-limits)
  8037. gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
  8038. ;; We use the new limit, so we push the old limit on the stack.
  8039. (push gnus-newsgroup-limit gnus-newsgroup-limits))
  8040. ;; Set the limit.
  8041. (setq gnus-newsgroup-limit articles)
  8042. (let ((total (length gnus-newsgroup-data))
  8043. (data (gnus-data-find-list (gnus-summary-article-number)))
  8044. (gnus-summary-mark-below nil) ; Inhibit this.
  8045. found)
  8046. ;; This will do all the work of generating the new summary buffer
  8047. ;; according to the new limit.
  8048. (gnus-summary-prepare)
  8049. ;; Hide any threads, possibly.
  8050. (gnus-summary-maybe-hide-threads)
  8051. ;; Try to return to the article you were at, or one in the
  8052. ;; neighborhood.
  8053. (when data
  8054. ;; We try to find some article after the current one.
  8055. (while data
  8056. (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
  8057. (setq data nil
  8058. found t))
  8059. (setq data (cdr data))))
  8060. (unless found
  8061. ;; If there is no data, that means that we were after the last
  8062. ;; article. The same goes when we can't find any articles
  8063. ;; after the current one.
  8064. (goto-char (point-max))
  8065. (gnus-summary-find-prev))
  8066. (gnus-set-mode-line 'summary)
  8067. ;; We return how many articles were removed from the summary
  8068. ;; buffer as a result of the new limit.
  8069. (- total (length gnus-newsgroup-data))))
  8070. (defsubst gnus-invisible-cut-children (threads)
  8071. (let ((num 0))
  8072. (while threads
  8073. (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
  8074. (incf num))
  8075. (pop threads))
  8076. (< num 2)))
  8077. (defsubst gnus-cut-thread (thread)
  8078. "Go forwards in the thread until we find an article that we want to display."
  8079. (when (or (eq gnus-fetch-old-headers 'some)
  8080. (eq gnus-fetch-old-headers 'invisible)
  8081. (numberp gnus-fetch-old-headers)
  8082. (eq gnus-build-sparse-threads 'some)
  8083. (eq gnus-build-sparse-threads 'more))
  8084. ;; Deal with old-fetched headers and sparse threads.
  8085. (while (and
  8086. thread
  8087. (or
  8088. (gnus-summary-article-sparse-p (mail-header-number (car thread)))
  8089. (gnus-summary-article-ancient-p
  8090. (mail-header-number (car thread))))
  8091. (if (or (<= (length (cdr thread)) 1)
  8092. (eq gnus-fetch-old-headers 'invisible))
  8093. (setq gnus-newsgroup-limit
  8094. (delq (mail-header-number (car thread))
  8095. gnus-newsgroup-limit)
  8096. thread (cadr thread))
  8097. (when (gnus-invisible-cut-children (cdr thread))
  8098. (let ((th (cdr thread)))
  8099. (while th
  8100. (if (memq (mail-header-number (caar th))
  8101. gnus-newsgroup-limit)
  8102. (setq thread (car th)
  8103. th nil)
  8104. (setq th (cdr th))))))))))
  8105. thread)
  8106. (defun gnus-cut-threads (threads)
  8107. "Cut off all uninteresting articles from the beginning of THREADS."
  8108. (when (or (eq gnus-fetch-old-headers 'some)
  8109. (eq gnus-fetch-old-headers 'invisible)
  8110. (numberp gnus-fetch-old-headers)
  8111. (eq gnus-build-sparse-threads 'some)
  8112. (eq gnus-build-sparse-threads 'more))
  8113. (let ((th threads))
  8114. (while th
  8115. (setcar th (gnus-cut-thread (car th)))
  8116. (setq th (cdr th)))))
  8117. ;; Remove nixed out threads.
  8118. (delq nil threads))
  8119. (defun gnus-summary-initial-limit (&optional show-if-empty)
  8120. "Figure out what the initial limit is supposed to be on group entry.
  8121. This entails weeding out unwanted dormants, low-scored articles,
  8122. fetch-old-headers verbiage, and so on."
  8123. ;; Most groups have nothing to remove.
  8124. (unless (or gnus-inhibit-limiting
  8125. (and (null gnus-newsgroup-dormant)
  8126. (eq gnus-newsgroup-display 'gnus-not-ignore)
  8127. (not (eq gnus-fetch-old-headers 'some))
  8128. (not (numberp gnus-fetch-old-headers))
  8129. (not (eq gnus-fetch-old-headers 'invisible))
  8130. (null gnus-summary-expunge-below)
  8131. (not (eq gnus-build-sparse-threads 'some))
  8132. (not (eq gnus-build-sparse-threads 'more))
  8133. (null gnus-thread-expunge-below)))
  8134. (push gnus-newsgroup-limit gnus-newsgroup-limits)
  8135. (setq gnus-newsgroup-limit nil)
  8136. (mapatoms
  8137. (lambda (node)
  8138. (unless (car (symbol-value node))
  8139. ;; These threads have no parents -- they are roots.
  8140. (let ((nodes (cdr (symbol-value node)))
  8141. thread)
  8142. (while nodes
  8143. (if (and gnus-thread-expunge-below
  8144. (< (gnus-thread-total-score (car nodes))
  8145. gnus-thread-expunge-below))
  8146. (gnus-expunge-thread (pop nodes))
  8147. (setq thread (pop nodes))
  8148. (gnus-summary-limit-children thread))))))
  8149. gnus-newsgroup-dependencies)
  8150. ;; If this limitation resulted in an empty group, we might
  8151. ;; pop the previous limit and use it instead.
  8152. (when (and (not gnus-newsgroup-limit)
  8153. show-if-empty)
  8154. (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
  8155. gnus-newsgroup-limit))
  8156. (defun gnus-summary-limit-children (thread)
  8157. "Return 1 if this subthread is visible and 0 if it is not."
  8158. ;; First we get the number of visible children to this thread. This
  8159. ;; is done by recursing down the thread using this function, so this
  8160. ;; will really go down to a leaf article first, before slowly
  8161. ;; working its way up towards the root.
  8162. (when thread
  8163. (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
  8164. (children
  8165. (if (cdr thread)
  8166. (apply '+ (mapcar 'gnus-summary-limit-children
  8167. (cdr thread)))
  8168. 0))
  8169. (number (mail-header-number (car thread)))
  8170. score)
  8171. (if (and
  8172. (not (memq number gnus-newsgroup-marked))
  8173. (or
  8174. ;; If this article is dormant and has absolutely no visible
  8175. ;; children, then this article isn't visible.
  8176. (and (memq number gnus-newsgroup-dormant)
  8177. (zerop children))
  8178. ;; If this is "fetch-old-headered" and there is no
  8179. ;; visible children, then we don't want this article.
  8180. (and (or (eq gnus-fetch-old-headers 'some)
  8181. (numberp gnus-fetch-old-headers))
  8182. (gnus-summary-article-ancient-p number)
  8183. (zerop children))
  8184. ;; If this is "fetch-old-headered" and `invisible', then
  8185. ;; we don't want this article.
  8186. (and (eq gnus-fetch-old-headers 'invisible)
  8187. (gnus-summary-article-ancient-p number))
  8188. ;; If this is a sparsely inserted article with no children,
  8189. ;; we don't want it.
  8190. (and (eq gnus-build-sparse-threads 'some)
  8191. (gnus-summary-article-sparse-p number)
  8192. (zerop children))
  8193. ;; If we use expunging, and this article is really
  8194. ;; low-scored, then we don't want this article.
  8195. (when (and gnus-summary-expunge-below
  8196. (< (setq score
  8197. (or (cdr (assq number gnus-newsgroup-scored))
  8198. gnus-summary-default-score))
  8199. gnus-summary-expunge-below))
  8200. ;; We increase the expunge-tally here, but that has
  8201. ;; nothing to do with the limits, really.
  8202. (incf gnus-newsgroup-expunged-tally)
  8203. ;; We also mark as read here, if that's wanted.
  8204. (when (and gnus-summary-mark-below
  8205. (< score gnus-summary-mark-below))
  8206. (setq gnus-newsgroup-unreads
  8207. (delq number gnus-newsgroup-unreads))
  8208. (if gnus-newsgroup-auto-expire
  8209. (push number gnus-newsgroup-expirable)
  8210. (push (cons number gnus-low-score-mark)
  8211. gnus-newsgroup-reads)))
  8212. t)
  8213. ;; Do the `display' group parameter.
  8214. (and gnus-newsgroup-display
  8215. (let ((gnus-number number))
  8216. (not (funcall gnus-newsgroup-display))))))
  8217. ;; Nope, invisible article.
  8218. 0
  8219. ;; Ok, this article is to be visible, so we add it to the limit
  8220. ;; and return 1.
  8221. (push number gnus-newsgroup-limit)
  8222. 1))))
  8223. (defun gnus-expunge-thread (thread)
  8224. "Mark all articles in THREAD as read."
  8225. (let* ((number (mail-header-number (car thread))))
  8226. (incf gnus-newsgroup-expunged-tally)
  8227. ;; We also mark as read here, if that's wanted.
  8228. (setq gnus-newsgroup-unreads
  8229. (delq number gnus-newsgroup-unreads))
  8230. (if gnus-newsgroup-auto-expire
  8231. (push number gnus-newsgroup-expirable)
  8232. (push (cons number gnus-low-score-mark)
  8233. gnus-newsgroup-reads)))
  8234. ;; Go recursively through all subthreads.
  8235. (mapcar 'gnus-expunge-thread (cdr thread)))
  8236. ;; Summary article oriented commands
  8237. (defun gnus-summary-refer-parent-article (n)
  8238. "Refer parent article N times.
  8239. If N is negative, go to ancestor -N instead.
  8240. The difference between N and the number of articles fetched is returned."
  8241. (interactive "p")
  8242. (let ((skip 1)
  8243. error header ref)
  8244. (when (not (natnump n))
  8245. (setq skip (abs n)
  8246. n 1))
  8247. (while (and (> n 0)
  8248. (not error))
  8249. (setq header (gnus-summary-article-header))
  8250. (if (and (eq (mail-header-number header)
  8251. (cdr gnus-article-current))
  8252. (equal gnus-newsgroup-name
  8253. (car gnus-article-current)))
  8254. ;; If we try to find the parent of the currently
  8255. ;; displayed article, then we take a look at the actual
  8256. ;; References header, since this is slightly more
  8257. ;; reliable than the References field we got from the
  8258. ;; server.
  8259. (with-current-buffer gnus-original-article-buffer
  8260. (nnheader-narrow-to-headers)
  8261. (unless (setq ref (message-fetch-field "references"))
  8262. (when (setq ref (message-fetch-field "in-reply-to"))
  8263. (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
  8264. (widen))
  8265. (setq ref
  8266. ;; It's not the current article, so we take a bet on
  8267. ;; the value we got from the server.
  8268. (mail-header-references header)))
  8269. (if (and ref
  8270. (not (equal ref "")))
  8271. (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
  8272. (gnus-message 1 "Couldn't find parent"))
  8273. (gnus-message 1 "No references in article %d"
  8274. (gnus-summary-article-number))
  8275. (setq error t))
  8276. (decf n))
  8277. (gnus-summary-position-point)
  8278. n))
  8279. (defun gnus-summary-refer-references ()
  8280. "Fetch all articles mentioned in the References header.
  8281. Return the number of articles fetched."
  8282. (interactive)
  8283. (let ((ref (mail-header-references (gnus-summary-article-header)))
  8284. (current (gnus-summary-article-number))
  8285. (n 0))
  8286. (if (or (not ref)
  8287. (equal ref ""))
  8288. (error "No References in the current article")
  8289. ;; For each Message-ID in the References header...
  8290. (while (string-match "<[^>]*>" ref)
  8291. (incf n)
  8292. ;; ... fetch that article.
  8293. (gnus-summary-refer-article
  8294. (prog1 (match-string 0 ref)
  8295. (setq ref (substring ref (match-end 0))))))
  8296. (gnus-summary-goto-subject current)
  8297. (gnus-summary-position-point)
  8298. n)))
  8299. (defun gnus-delete-duplicate-headers (headers)
  8300. ;; First remove leading duplicates.
  8301. (while (and (> (length headers) 1)
  8302. (= (mail-header-number (car headers))
  8303. (mail-header-number (cadr headers))))
  8304. (pop headers))
  8305. ;; Then the rest.
  8306. (let ((result headers))
  8307. (while (> (length headers) 1)
  8308. (if (= (mail-header-number (car headers))
  8309. (mail-header-number (cadr headers)))
  8310. (setcdr headers (cddr headers))
  8311. (pop headers)))
  8312. result))
  8313. (defun gnus-summary-refer-thread (&optional limit)
  8314. "Fetch all articles in the current thread. For backends that
  8315. know how to search for threads (currently only 'nnimap) a
  8316. non-numeric prefix arg will use nnir to search the entire
  8317. server; without a prefix arg only the current group is
  8318. searched. If the variable `gnus-refer-thread-use-nnir' is
  8319. non-nil the prefix arg has the reverse meaning. If no
  8320. backend-specific 'request-thread function is available fetch
  8321. LIMIT (the numerical prefix) old headers. If LIMIT is
  8322. non-numeric or nil fetch the number specified by the
  8323. `gnus-refer-thread-limit' variable."
  8324. (interactive "P")
  8325. (gnus-warp-to-article)
  8326. (let* ((header (gnus-summary-article-header))
  8327. (id (mail-header-id header))
  8328. (gnus-inhibit-demon t)
  8329. (gnus-summary-ignore-duplicates t)
  8330. (gnus-read-all-available-headers t)
  8331. (gnus-refer-thread-use-nnir
  8332. (if (and (not (null limit)) (listp limit))
  8333. (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
  8334. (new-headers
  8335. (if (gnus-check-backend-function
  8336. 'request-thread gnus-newsgroup-name)
  8337. (gnus-request-thread header gnus-newsgroup-name)
  8338. (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
  8339. gnus-refer-thread-limit))
  8340. (last (if (numberp limit)
  8341. (min (+ (mail-header-number header)
  8342. limit)
  8343. gnus-newsgroup-highest)
  8344. gnus-newsgroup-highest))
  8345. (subject (gnus-simplify-subject
  8346. (mail-header-subject header)))
  8347. (refs (split-string (or (mail-header-references header)
  8348. "")))
  8349. (gnus-parse-headers-hook
  8350. `(lambda () (goto-char (point-min))
  8351. (keep-lines
  8352. (regexp-opt ',(append refs (list id subject)))))))
  8353. (gnus-fetch-headers (list last) (if (numberp limit)
  8354. (* 2 limit) limit) t))))
  8355. article-ids new-unreads)
  8356. (when (listp new-headers)
  8357. (dolist (header new-headers)
  8358. (push (mail-header-number header) article-ids))
  8359. (setq article-ids (nreverse article-ids))
  8360. (setq new-unreads
  8361. (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
  8362. (setq gnus-newsgroup-unselected
  8363. (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
  8364. (setq gnus-newsgroup-unreads
  8365. (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
  8366. (setq gnus-newsgroup-headers
  8367. (gnus-delete-duplicate-headers
  8368. (gnus-merge
  8369. 'list gnus-newsgroup-headers new-headers
  8370. 'gnus-article-sort-by-number)))
  8371. (setq gnus-newsgroup-articles
  8372. (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
  8373. (gnus-summary-limit-include-thread id)))
  8374. (gnus-summary-show-thread))
  8375. (defun gnus-summary-open-group-with-article (message-id)
  8376. "Open a group containing the article with the given MESSAGE-ID."
  8377. (interactive "sMessage-ID: ")
  8378. (require 'nndoc)
  8379. (with-temp-buffer
  8380. ;; Prepare a dummy article
  8381. (erase-buffer)
  8382. (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
  8383. ;; Prepare pretty modelines for summary and article buffers
  8384. (let ((gnus-summary-mode-line-format "Found %G")
  8385. (gnus-article-mode-line-format
  8386. ;; Group names just get in the way here, especially the
  8387. ;; abbreviated ones
  8388. (if (string-match "%[gG]" gnus-article-mode-line-format)
  8389. (concat (substring gnus-article-mode-line-format
  8390. 0 (match-beginning 0))
  8391. (substring gnus-article-mode-line-format (match-end 0)))
  8392. gnus-article-mode-line-format)))
  8393. ;; Build an ephemeral group containing the dummy article (hidden)
  8394. (gnus-group-read-ephemeral-group
  8395. message-id
  8396. `(nndoc ,message-id
  8397. (nndoc-address ,(current-buffer))
  8398. (nndoc-article-type mbox))
  8399. :activate
  8400. (cons (current-buffer) gnus-current-window-configuration)
  8401. (not :request-only)
  8402. '(-1) ; :select-articles
  8403. (not :parameters)
  8404. 0)) ; :number
  8405. ;; Fetch the desired article
  8406. (gnus-summary-refer-article message-id)))
  8407. (defun gnus-summary-refer-article (message-id)
  8408. "Fetch an article specified by MESSAGE-ID."
  8409. (interactive "sMessage-ID: ")
  8410. (gnus-warp-to-article)
  8411. (when (and (stringp message-id)
  8412. (not (zerop (length message-id))))
  8413. (setq message-id (gnus-replace-in-string message-id " " ""))
  8414. ;; Construct the correct Message-ID if necessary.
  8415. ;; Suggested by tale@pawl.rpi.edu.
  8416. (unless (string-match "^<" message-id)
  8417. (setq message-id (concat "<" message-id)))
  8418. (unless (string-match ">$" message-id)
  8419. (setq message-id (concat message-id ">")))
  8420. ;; People often post MIDs from URLs, so unhex it:
  8421. (unless (string-match "@" message-id)
  8422. (setq message-id (gnus-url-unhex-string message-id)))
  8423. (let* ((header (gnus-id-to-header message-id))
  8424. (sparse (and header
  8425. (gnus-summary-article-sparse-p
  8426. (mail-header-number header))
  8427. (memq (mail-header-number header)
  8428. gnus-newsgroup-limit)))
  8429. number)
  8430. (cond
  8431. ;; If the article is present in the buffer we just go to it.
  8432. ((and header
  8433. (or (not (gnus-summary-article-sparse-p
  8434. (mail-header-number header)))
  8435. sparse))
  8436. (prog1
  8437. (gnus-summary-goto-article
  8438. (mail-header-number header) nil t)
  8439. (when sparse
  8440. (gnus-summary-update-article (mail-header-number header)))))
  8441. (t
  8442. ;; We fetch the article.
  8443. (catch 'found
  8444. (dolist (gnus-override-method (gnus-refer-article-methods))
  8445. (when (and (gnus-check-server gnus-override-method)
  8446. ;; Fetch the header,
  8447. (setq number (gnus-summary-insert-subject message-id)))
  8448. ;; and display the article.
  8449. (gnus-summary-select-article nil nil nil number)
  8450. (throw 'found t)))
  8451. (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
  8452. (defun gnus-refer-article-methods ()
  8453. "Return a list of referable methods."
  8454. (cond
  8455. ;; No method, so we default to current and native.
  8456. ((null gnus-refer-article-method)
  8457. (list gnus-current-select-method gnus-select-method))
  8458. ;; Current.
  8459. ((eq 'current gnus-refer-article-method)
  8460. (list gnus-current-select-method))
  8461. ;; List of select methods.
  8462. ((not (and (symbolp (car gnus-refer-article-method))
  8463. (assq (car gnus-refer-article-method) nnoo-definition-alist)))
  8464. (let (out)
  8465. (dolist (method gnus-refer-article-method)
  8466. (push (if (eq 'current method)
  8467. gnus-current-select-method
  8468. (if (eq 'nnir (car method))
  8469. (list
  8470. 'nnir
  8471. (or (cadr method)
  8472. (gnus-method-to-server gnus-current-select-method)))
  8473. method))
  8474. out))
  8475. (nreverse out)))
  8476. ;; One single select method.
  8477. (t
  8478. (list gnus-refer-article-method))))
  8479. (defun gnus-summary-edit-parameters ()
  8480. "Edit the group parameters of the current group."
  8481. (interactive)
  8482. (gnus-group-edit-group gnus-newsgroup-name 'params))
  8483. (defun gnus-summary-customize-parameters ()
  8484. "Customize the group parameters of the current group."
  8485. (interactive)
  8486. (gnus-group-customize gnus-newsgroup-name))
  8487. (defun gnus-summary-enter-digest-group (&optional force)
  8488. "Enter an nndoc group based on the current article.
  8489. If FORCE, force a digest interpretation. If not, try to guess
  8490. what the document format is.
  8491. To control what happens when you exit the group, see the
  8492. `gnus-auto-select-on-ephemeral-exit' variable."
  8493. (interactive "P")
  8494. (let ((conf gnus-current-window-configuration))
  8495. (save-window-excursion
  8496. (save-excursion
  8497. (let (gnus-article-prepare-hook
  8498. gnus-display-mime-function
  8499. gnus-break-pages)
  8500. (gnus-summary-select-article))))
  8501. (setq gnus-current-window-configuration conf)
  8502. (let* ((name (format "%s-%d"
  8503. (gnus-group-prefixed-name
  8504. gnus-newsgroup-name (list 'nndoc ""))
  8505. (with-current-buffer gnus-summary-buffer
  8506. gnus-current-article)))
  8507. (ogroup gnus-newsgroup-name)
  8508. (params (append (gnus-info-params (gnus-get-info ogroup))
  8509. (list (cons 'to-group ogroup))
  8510. (list (cons 'parent-group ogroup))
  8511. (list (cons 'save-article-group ogroup))))
  8512. (case-fold-search t)
  8513. (buf (current-buffer))
  8514. dig to-address charset)
  8515. (with-current-buffer gnus-original-article-buffer
  8516. ;; Have the digest group inherit the main mail address of
  8517. ;; the parent article.
  8518. (when (setq to-address (or (gnus-fetch-field "reply-to")
  8519. (gnus-fetch-field "from")))
  8520. (setq params
  8521. (append
  8522. params
  8523. (list (cons 'to-address
  8524. (funcall gnus-decode-encoded-address-function
  8525. to-address))))))
  8526. (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
  8527. (insert-buffer-substring gnus-original-article-buffer)
  8528. (narrow-to-region
  8529. (goto-char (point-min))
  8530. (or (search-forward "\n\n" nil t) (point)))
  8531. ;; Remove lines that may lead nndoc to misinterpret the
  8532. ;; document type.
  8533. (goto-char (point-min))
  8534. (delete-matching-lines "^Path:\\|^From ")
  8535. ;; Parse charset, and decode content transfer encoding.
  8536. (setq charset (mail-content-type-get
  8537. (mail-header-parse-content-type
  8538. (or (gnus-fetch-field "content-type") ""))
  8539. 'charset))
  8540. (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
  8541. (when encoding
  8542. (message-remove-header "content-transfer-encoding")
  8543. (goto-char (point-max))
  8544. (widen)
  8545. (narrow-to-region (point) (point-max))
  8546. (mm-decode-content-transfer-encoding
  8547. (intern (downcase (mail-header-strip encoding))))))
  8548. (widen))
  8549. (unwind-protect
  8550. (if (let ((gnus-newsgroup-ephemeral-charset
  8551. (if charset
  8552. (intern (downcase (gnus-strip-whitespace charset)))
  8553. gnus-newsgroup-charset))
  8554. (gnus-newsgroup-ephemeral-ignored-charsets
  8555. gnus-newsgroup-ignored-charsets))
  8556. (gnus-group-read-ephemeral-group
  8557. name `(nndoc ,name (nndoc-address ,(get-buffer dig))
  8558. (nndoc-article-type
  8559. ,(if force 'mbox 'guess)))
  8560. t nil nil nil
  8561. `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
  8562. "ADAPT")))))
  8563. ;; Make all postings to this group go to the parent group.
  8564. (nconc (gnus-info-params (gnus-get-info name))
  8565. params)
  8566. ;; Couldn't select this doc group.
  8567. (switch-to-buffer buf)
  8568. (gnus-set-global-variables)
  8569. (gnus-configure-windows 'summary)
  8570. (gnus-message 3 "Article couldn't be entered?"))
  8571. (kill-buffer dig)))))
  8572. (defun gnus-summary-read-document (n)
  8573. "Open a new group based on the current article(s).
  8574. This will allow you to read digests and other similar
  8575. documents as newsgroups.
  8576. Obeys the standard process/prefix convention."
  8577. (interactive "P")
  8578. (let* ((ogroup gnus-newsgroup-name)
  8579. (params (append (gnus-info-params (gnus-get-info ogroup))
  8580. (list (cons 'to-group ogroup))))
  8581. group egroup groups vgroup)
  8582. (dolist (article (gnus-summary-work-articles n))
  8583. (setq group (format "%s-%d" gnus-newsgroup-name article))
  8584. (gnus-summary-remove-process-mark article)
  8585. (when (gnus-summary-display-article article)
  8586. (save-excursion ;;What for?
  8587. (with-temp-buffer
  8588. (insert-buffer-substring gnus-original-article-buffer)
  8589. ;; Remove some headers that may lead nndoc to make
  8590. ;; the wrong guess.
  8591. (message-narrow-to-head)
  8592. (goto-char (point-min))
  8593. (delete-matching-lines "^Path:\\|^From ")
  8594. (widen)
  8595. (if (setq egroup
  8596. (gnus-group-read-ephemeral-group
  8597. group `(nndoc ,group (nndoc-address ,(current-buffer))
  8598. (nndoc-article-type guess))
  8599. t nil t))
  8600. (progn
  8601. ;; Make all postings to this group go to the parent group.
  8602. (nconc (gnus-info-params (gnus-get-info egroup))
  8603. params)
  8604. (push egroup groups))
  8605. ;; Couldn't select this doc group.
  8606. (gnus-error 3 "Article couldn't be entered"))))))
  8607. ;; Now we have selected all the documents.
  8608. (cond
  8609. ((not groups)
  8610. (error "None of the articles could be interpreted as documents"))
  8611. ((gnus-group-read-ephemeral-group
  8612. (setq vgroup (format
  8613. "nnvirtual:%s-%s" gnus-newsgroup-name
  8614. (format-time-string "%Y%m%dT%H%M%S")))
  8615. `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
  8616. t
  8617. (cons (current-buffer) 'summary)))
  8618. (t
  8619. (error "Couldn't select virtual nndoc group")))))
  8620. (defun gnus-summary-widget-forward (arg)
  8621. "Move point to the next field or button in the article.
  8622. With optional ARG, move across that many fields."
  8623. (interactive "p")
  8624. (gnus-summary-select-article)
  8625. (gnus-configure-windows 'article)
  8626. (select-window (gnus-get-buffer-window gnus-article-buffer))
  8627. (widget-forward arg))
  8628. (defun gnus-summary-widget-backward (arg)
  8629. "Move point to the previous field or button in the article.
  8630. With optional ARG, move across that many fields."
  8631. (interactive "p")
  8632. (gnus-summary-select-article)
  8633. (gnus-configure-windows 'article)
  8634. (select-window (gnus-get-buffer-window gnus-article-buffer))
  8635. (unless (widget-at (point))
  8636. (goto-char (point-max)))
  8637. (widget-backward arg))
  8638. (defun gnus-summary-isearch-article (&optional regexp-p)
  8639. "Do incremental search forward on the current article.
  8640. If REGEXP-P (the prefix) is non-nil, do regexp isearch."
  8641. (interactive "P")
  8642. (gnus-summary-select-article)
  8643. (gnus-configure-windows 'article)
  8644. (gnus-eval-in-buffer-window gnus-article-buffer
  8645. (save-restriction
  8646. (widen)
  8647. (isearch-forward regexp-p))))
  8648. (defun gnus-summary-repeat-search-article-forward ()
  8649. "Repeat the previous search forwards."
  8650. (interactive)
  8651. (unless gnus-last-search-regexp
  8652. (error "No previous search"))
  8653. (gnus-summary-search-article-forward gnus-last-search-regexp))
  8654. (defun gnus-summary-repeat-search-article-backward ()
  8655. "Repeat the previous search backwards."
  8656. (interactive)
  8657. (unless gnus-last-search-regexp
  8658. (error "No previous search"))
  8659. (gnus-summary-search-article-forward gnus-last-search-regexp t))
  8660. (defun gnus-summary-search-article-forward (regexp &optional backward)
  8661. "Search for an article containing REGEXP forward.
  8662. If BACKWARD, search backward instead."
  8663. (interactive
  8664. (list (read-string
  8665. (format "Search article %s (regexp%s): "
  8666. (if current-prefix-arg "backward" "forward")
  8667. (if gnus-last-search-regexp
  8668. (concat ", default " gnus-last-search-regexp)
  8669. "")))
  8670. current-prefix-arg))
  8671. (if (string-equal regexp "")
  8672. (setq regexp (or gnus-last-search-regexp ""))
  8673. (setq gnus-last-search-regexp regexp)
  8674. (setq gnus-article-before-search gnus-current-article))
  8675. ;; Intentionally set gnus-last-article.
  8676. (setq gnus-last-article gnus-article-before-search)
  8677. (let ((gnus-last-article gnus-last-article))
  8678. (if (gnus-summary-search-article regexp backward)
  8679. (gnus-summary-show-thread)
  8680. (signal 'search-failed (list regexp)))))
  8681. (defun gnus-summary-search-article-backward (regexp)
  8682. "Search for an article containing REGEXP backward."
  8683. (interactive
  8684. (list (read-string
  8685. (format "Search article backward (regexp%s): "
  8686. (if gnus-last-search-regexp
  8687. (concat ", default " gnus-last-search-regexp)
  8688. "")))))
  8689. (gnus-summary-search-article-forward regexp 'backward))
  8690. (defun gnus-summary-search-article (regexp &optional backward)
  8691. "Search for an article containing REGEXP.
  8692. Optional argument BACKWARD means do search for backward.
  8693. `gnus-select-article-hook' is not called during the search."
  8694. ;; We have to require this here to make sure that the following
  8695. ;; dynamic binding isn't shadowed by autoloading.
  8696. (require 'gnus-async)
  8697. (require 'gnus-art)
  8698. (let ((gnus-select-article-hook nil) ;Disable hook.
  8699. (gnus-article-prepare-hook nil)
  8700. (gnus-mark-article-hook nil) ;Inhibit marking as read.
  8701. (gnus-use-article-prefetch nil)
  8702. (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
  8703. (gnus-use-trees nil) ;Inhibit updating tree buffer.
  8704. (gnus-visual nil)
  8705. (gnus-keep-backlog nil)
  8706. (gnus-break-pages nil)
  8707. (gnus-summary-display-arrow nil)
  8708. (gnus-updated-mode-lines nil)
  8709. (gnus-auto-center-summary nil)
  8710. (sum (current-buffer))
  8711. (gnus-display-mime-function nil)
  8712. (found nil)
  8713. point)
  8714. (gnus-save-hidden-threads
  8715. (gnus-summary-select-article)
  8716. (set-buffer gnus-article-buffer)
  8717. (goto-char (window-point (get-buffer-window (current-buffer))))
  8718. (when backward
  8719. (forward-line -1))
  8720. (while (not found)
  8721. (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
  8722. (if (if backward
  8723. (re-search-backward regexp nil t)
  8724. (re-search-forward regexp nil t))
  8725. ;; We found the regexp.
  8726. (progn
  8727. (setq found 'found)
  8728. (beginning-of-line)
  8729. (set-window-start
  8730. (get-buffer-window (current-buffer))
  8731. (point))
  8732. (forward-line 1)
  8733. (set-window-point
  8734. (get-buffer-window (current-buffer))
  8735. (point))
  8736. (set-buffer sum)
  8737. (setq point (point)))
  8738. ;; We didn't find it, so we go to the next article.
  8739. (set-buffer sum)
  8740. (setq found 'not)
  8741. (while (eq found 'not)
  8742. (if (not (if backward (gnus-summary-find-prev)
  8743. (gnus-summary-find-next)))
  8744. ;; No more articles.
  8745. (setq found t)
  8746. ;; Select the next article and adjust point.
  8747. (unless (gnus-summary-article-sparse-p
  8748. (gnus-summary-article-number))
  8749. (setq found nil)
  8750. (gnus-summary-select-article)
  8751. (set-buffer gnus-article-buffer)
  8752. (widen)
  8753. (goto-char (if backward (point-max) (point-min))))))))
  8754. (gnus-message 7 ""))
  8755. ;; Return whether we found the regexp.
  8756. (when (eq found 'found)
  8757. (goto-char point)
  8758. (gnus-summary-show-thread)
  8759. (gnus-summary-goto-subject gnus-current-article)
  8760. (gnus-summary-position-point)
  8761. t)))
  8762. (defun gnus-find-matching-articles (header regexp)
  8763. "Return a list of all articles that match REGEXP on HEADER.
  8764. This search includes all articles in the current group that Gnus has
  8765. fetched headers for, whether they are displayed or not."
  8766. (let ((articles nil)
  8767. ;; Can't eta-reduce because it's a macro.
  8768. (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
  8769. (case-fold-search t))
  8770. (dolist (header gnus-newsgroup-headers)
  8771. (when (string-match regexp (funcall func header))
  8772. (push (mail-header-number header) articles)))
  8773. (nreverse articles)))
  8774. (defun gnus-summary-find-matching (header regexp &optional backward unread
  8775. not-case-fold not-matching)
  8776. "Return a list of all articles that match REGEXP on HEADER.
  8777. The search stars on the current article and goes forwards unless
  8778. BACKWARD is non-nil. If BACKWARD is `all', do all articles.
  8779. If UNREAD is non-nil, only unread articles will
  8780. be taken into consideration. If NOT-CASE-FOLD, case won't be folded
  8781. in the comparisons. If NOT-MATCHING, return a list of all articles that
  8782. not match REGEXP on HEADER."
  8783. (let ((case-fold-search (not not-case-fold))
  8784. articles d func)
  8785. (if (consp header)
  8786. (if (eq (car header) 'extra)
  8787. (setq func
  8788. `(lambda (h)
  8789. (or (cdr (assq ',(cdr header) (mail-header-extra h)))
  8790. "")))
  8791. (error "%s is an invalid header" header))
  8792. (unless (fboundp (intern (concat "mail-header-" header)))
  8793. (error "%s is not a valid header" header))
  8794. (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
  8795. (dolist (d (if (eq backward 'all)
  8796. gnus-newsgroup-data
  8797. (gnus-data-find-list
  8798. (gnus-summary-article-number)
  8799. (gnus-data-list backward))))
  8800. (when (and (or (not unread) ; We want all articles...
  8801. (gnus-data-unread-p d)) ; Or just unreads.
  8802. (vectorp (gnus-data-header d)) ; It's not a pseudo.
  8803. (if not-matching
  8804. (not (string-match
  8805. regexp
  8806. (funcall func (gnus-data-header d))))
  8807. (string-match regexp
  8808. (funcall func (gnus-data-header d)))))
  8809. (push (gnus-data-number d) articles))) ; Success!
  8810. (nreverse articles)))
  8811. (defun gnus-summary-execute-command (header regexp command &optional backward)
  8812. "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
  8813. If HEADER is an empty string (or nil), the match is done on the entire
  8814. article. If BACKWARD (the prefix) is non-nil, search backward instead."
  8815. (interactive
  8816. (list (let ((completion-ignore-case t))
  8817. (gnus-completing-read
  8818. "Header name"
  8819. (mapcar 'symbol-name
  8820. (append
  8821. '(Number Subject From Lines Date
  8822. Message-ID Xref References Body)
  8823. gnus-extra-headers))
  8824. 'require-match))
  8825. (read-string "Regexp: ")
  8826. (read-key-sequence "Command: ")
  8827. current-prefix-arg))
  8828. (when (equal header "Body")
  8829. (setq header ""))
  8830. ;; Hidden thread subtrees must be searched as well.
  8831. (gnus-summary-show-all-threads)
  8832. ;; We don't want to change current point nor window configuration.
  8833. (save-excursion
  8834. (save-window-excursion
  8835. (let (gnus-visual
  8836. gnus-treat-strip-trailing-blank-lines
  8837. gnus-treat-strip-leading-blank-lines
  8838. gnus-treat-strip-multiple-blank-lines
  8839. gnus-treat-hide-boring-headers
  8840. gnus-treat-fold-newsgroups
  8841. gnus-article-prepare-hook)
  8842. (gnus-message 6 "Executing %s..." (key-description command))
  8843. ;; We'd like to execute COMMAND interactively so as to give arguments.
  8844. (gnus-execute header regexp
  8845. `(call-interactively ',(key-binding command))
  8846. backward)
  8847. (gnus-message 6 "Executing %s...done" (key-description command))))))
  8848. (defun gnus-summary-beginning-of-article ()
  8849. "Scroll the article back to the beginning."
  8850. (interactive)
  8851. (gnus-summary-select-article)
  8852. (gnus-configure-windows 'article)
  8853. (gnus-eval-in-buffer-window gnus-article-buffer
  8854. (widen)
  8855. (goto-char (point-min))
  8856. (when gnus-break-pages
  8857. (gnus-narrow-to-page))))
  8858. (defun gnus-summary-end-of-article ()
  8859. "Scroll to the end of the article."
  8860. (interactive)
  8861. (gnus-summary-select-article)
  8862. (gnus-configure-windows 'article)
  8863. (gnus-eval-in-buffer-window gnus-article-buffer
  8864. (widen)
  8865. (goto-char (point-max))
  8866. (recenter -3)
  8867. (when gnus-break-pages
  8868. (gnus-narrow-to-page))))
  8869. (defun gnus-summary-print-truncate-and-quote (string &optional len)
  8870. "Truncate to LEN and quote all \"(\"'s in STRING."
  8871. (gnus-replace-in-string (if (and len (> (length string) len))
  8872. (substring string 0 len)
  8873. string)
  8874. "[()]" "\\\\\\&"))
  8875. (defun gnus-summary-print-article (&optional filename n)
  8876. "Generate and print a PostScript image of the process-marked (mail) articles.
  8877. If used interactively, print the current article if none are
  8878. process-marked. With prefix arg, prompt the user for the name of the
  8879. file to save in.
  8880. When used from Lisp, accept two optional args FILENAME and N. N means
  8881. to print the next N articles. If N is negative, print the N previous
  8882. articles. If N is nil and articles have been marked with the process
  8883. mark, print these instead.
  8884. If the optional first argument FILENAME is nil, send the image to the
  8885. printer. If FILENAME is a string, save the PostScript image in a file with
  8886. that name. If FILENAME is a number, prompt the user for the name of the file
  8887. to save in."
  8888. (interactive (list (ps-print-preprint current-prefix-arg)))
  8889. (dolist (article (gnus-summary-work-articles n))
  8890. (gnus-summary-select-article nil nil 'pseudo article)
  8891. (gnus-eval-in-buffer-window gnus-article-buffer
  8892. (gnus-print-buffer))
  8893. (gnus-summary-remove-process-mark article))
  8894. (ps-despool filename))
  8895. (defun gnus-print-buffer ()
  8896. (let ((ps-left-header
  8897. (list
  8898. (concat "("
  8899. (gnus-summary-print-truncate-and-quote
  8900. (mail-header-subject gnus-current-headers)
  8901. 66) ")")
  8902. (concat "("
  8903. (gnus-summary-print-truncate-and-quote
  8904. (mail-header-from gnus-current-headers)
  8905. 45) ")")))
  8906. (ps-right-header
  8907. (list
  8908. "/pagenumberstring load"
  8909. (concat "("
  8910. (mail-header-date gnus-current-headers) ")"))))
  8911. (gnus-run-hooks 'gnus-ps-print-hook)
  8912. (save-excursion
  8913. (if ps-print-color-p
  8914. (ps-spool-buffer-with-faces)
  8915. (ps-spool-buffer)))))
  8916. (declare-function gnus-flush-original-article-buffer "gnus-art" ())
  8917. (defun gnus-summary-show-complete-article ()
  8918. "Show a complete version of the current article.
  8919. This is only useful if you're looking at a partial version of the
  8920. article currently."
  8921. (interactive)
  8922. (let ((gnus-keep-backlog nil)
  8923. (gnus-use-cache nil)
  8924. (gnus-agent nil)
  8925. (variable (intern
  8926. (format "%s-fetch-partial-articles"
  8927. (car (gnus-find-method-for-group
  8928. gnus-newsgroup-name)))
  8929. obarray))
  8930. old-val)
  8931. (unwind-protect
  8932. (progn
  8933. (setq old-val (symbol-value variable))
  8934. (set variable nil)
  8935. (gnus-flush-original-article-buffer)
  8936. (gnus-summary-show-article))
  8937. (set variable old-val))))
  8938. (defun gnus-summary-show-article (&optional arg)
  8939. "Force redisplaying of the current article.
  8940. If ARG (the prefix) is a number, show the article with the charset
  8941. defined in `gnus-summary-show-article-charset-alist', or the charset
  8942. input.
  8943. If ARG (the prefix) is non-nil and not a number, show the article,
  8944. but without running any of the article treatment functions
  8945. article. Normally, the keystroke is `C-u g'. When using `C-u
  8946. C-u g', show the raw article."
  8947. (interactive "P")
  8948. (cond
  8949. ((numberp arg)
  8950. (gnus-summary-show-article t)
  8951. (let ((gnus-newsgroup-charset
  8952. (or (cdr (assq arg gnus-summary-show-article-charset-alist))
  8953. (mm-read-coding-system
  8954. "View as charset: " ;; actually it is coding system.
  8955. (with-current-buffer gnus-article-buffer
  8956. (mm-detect-coding-region (point) (point-max))))))
  8957. (gnus-newsgroup-ignored-charsets 'gnus-all))
  8958. (gnus-summary-select-article nil 'force)
  8959. (let ((deps gnus-newsgroup-dependencies)
  8960. head header lines)
  8961. (with-current-buffer gnus-original-article-buffer
  8962. (save-restriction
  8963. (message-narrow-to-head)
  8964. (setq head (buffer-string))
  8965. (goto-char (point-min))
  8966. (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
  8967. (goto-char (point-max))
  8968. (widen)
  8969. (setq lines (1- (count-lines (point) (point-max))))))
  8970. (with-temp-buffer
  8971. (insert (format "211 %d Article retrieved.\n"
  8972. (cdr gnus-article-current)))
  8973. (insert head)
  8974. (if lines (insert (format "Lines: %d\n" lines)))
  8975. (insert ".\n")
  8976. (let ((nntp-server-buffer (current-buffer)))
  8977. (setq header (car (gnus-get-newsgroup-headers deps t))))))
  8978. (gnus-data-set-header
  8979. (gnus-data-find (cdr gnus-article-current))
  8980. header)
  8981. (gnus-summary-update-article-line
  8982. (cdr gnus-article-current) header)
  8983. (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
  8984. (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
  8985. ((not arg)
  8986. ;; Select the article the normal way.
  8987. (if (eq mm-text-html-renderer 'shr)
  8988. (progn
  8989. (require 'shr)
  8990. (let ((shr-ignore-cache t))
  8991. (gnus-summary-select-article nil 'force)))
  8992. (gnus-summary-select-article nil 'force)))
  8993. ((equal arg '(16))
  8994. ;; C-u C-u g
  8995. (let ((gnus-inhibit-article-treatments t))
  8996. (gnus-summary-select-article nil 'force)))
  8997. (t
  8998. ;; We have to require this here to make sure that the following
  8999. ;; dynamic binding isn't shadowed by autoloading.
  9000. (require 'gnus-async)
  9001. (require 'gnus-art)
  9002. ;; Bind the article treatment functions to nil.
  9003. (let ((gnus-have-all-headers t)
  9004. gnus-article-prepare-hook
  9005. gnus-article-decode-hook
  9006. gnus-display-mime-function
  9007. gnus-break-pages)
  9008. ;; Destroy any MIME parts.
  9009. (when (gnus-buffer-live-p gnus-article-buffer)
  9010. (with-current-buffer gnus-article-buffer
  9011. (gnus-article-stop-animations)
  9012. (gnus-stop-downloads)
  9013. (mm-destroy-parts gnus-article-mime-handles)
  9014. ;; Set it to nil for safety reason.
  9015. (setq gnus-article-mime-handle-alist nil)
  9016. (setq gnus-article-mime-handles nil)))
  9017. (gnus-summary-select-article nil 'force))))
  9018. (gnus-summary-goto-subject gnus-current-article)
  9019. (gnus-summary-position-point))
  9020. (defun gnus-summary-show-raw-article ()
  9021. "Show the raw article without any article massaging functions being run."
  9022. (interactive)
  9023. (gnus-summary-show-article t))
  9024. (defun gnus-summary-verbose-headers (&optional arg)
  9025. "Toggle permanent full header display.
  9026. If ARG is a positive number, turn header display on.
  9027. If ARG is a negative number, turn header display off."
  9028. (interactive "P")
  9029. (setq gnus-show-all-headers
  9030. (cond ((or (not (numberp arg))
  9031. (zerop arg))
  9032. (not gnus-show-all-headers))
  9033. ((natnump arg)
  9034. t)))
  9035. (gnus-summary-show-article))
  9036. (declare-function article-narrow-to-head "gnus-art" ())
  9037. (declare-function gnus-article-hidden-text-p "gnus-art" (type))
  9038. (declare-function gnus-delete-wash-type "gnus-art" (type))
  9039. (declare-function gnus-mime-buttonize-attachments-in-header
  9040. "gnus-art" (&optional interactive))
  9041. (defun gnus-summary-toggle-header (&optional arg)
  9042. "Show the headers if they are hidden, or hide them if they are shown.
  9043. If ARG is a positive number, show the entire header.
  9044. If ARG is a negative number, hide the unwanted header lines."
  9045. (interactive "P")
  9046. (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
  9047. (get-buffer-window gnus-article-buffer t))))
  9048. (with-current-buffer gnus-article-buffer
  9049. (widen)
  9050. (article-narrow-to-head)
  9051. (let* ((inhibit-read-only t)
  9052. (inhibit-point-motion-hooks t)
  9053. (hidden (if (numberp arg)
  9054. (>= arg 0)
  9055. (or (not (looking-at "[^ \t\n]+:"))
  9056. (gnus-article-hidden-text-p 'headers))))
  9057. s e)
  9058. (delete-region (point-min) (point-max))
  9059. (with-current-buffer gnus-original-article-buffer
  9060. (goto-char (setq s (point-min)))
  9061. (setq e (if (search-forward "\n\n" nil t)
  9062. (1- (point))
  9063. (point-max))))
  9064. (insert-buffer-substring gnus-original-article-buffer s e)
  9065. (run-hooks 'gnus-article-decode-hook)
  9066. (if hidden
  9067. (let ((gnus-treat-hide-headers nil)
  9068. (gnus-treat-hide-boring-headers nil))
  9069. (gnus-delete-wash-type 'headers)
  9070. (gnus-treat-article 'head))
  9071. (gnus-treat-article 'head)
  9072. ;; Add attachment buttons to the header.
  9073. (when gnus-mime-display-attachment-buttons-in-header
  9074. (gnus-mime-buttonize-attachments-in-header)))
  9075. (widen)
  9076. (if window
  9077. (set-window-start window (goto-char (point-min))))
  9078. (if gnus-break-pages
  9079. (gnus-narrow-to-page)
  9080. (when (gnus-visual-p 'page-marker)
  9081. (let ((inhibit-read-only t))
  9082. (gnus-remove-text-with-property 'gnus-prev)
  9083. (gnus-remove-text-with-property 'gnus-next))))
  9084. (gnus-set-mode-line 'article)))))
  9085. (defun gnus-summary-show-all-headers ()
  9086. "Make all header lines visible."
  9087. (interactive)
  9088. (gnus-summary-toggle-header 1))
  9089. (defun gnus-summary-caesar-message (&optional arg)
  9090. "Caesar rotate the current article by 13.
  9091. With a non-numerical prefix, also rotate headers. A numerical
  9092. prefix specifies how many places to rotate each letter forward."
  9093. (interactive "P")
  9094. (gnus-summary-select-article)
  9095. (let ((mail-header-separator ""))
  9096. (gnus-eval-in-buffer-window gnus-article-buffer
  9097. (save-restriction
  9098. (widen)
  9099. (let ((start (window-start))
  9100. (inhibit-read-only t))
  9101. (if (equal arg '(4))
  9102. (message-caesar-buffer-body nil t)
  9103. (message-caesar-buffer-body arg))
  9104. (set-window-start (get-buffer-window (current-buffer)) start)))))
  9105. ;; Create buttons and stuff...
  9106. (gnus-treat-article nil))
  9107. (declare-function idna-to-unicode "ext:idna" (str))
  9108. (defun gnus-summary-idna-message (&optional arg)
  9109. "Decode IDNA encoded domain names in the current articles.
  9110. IDNA encoded domain names looks like `xn--bar'. If a string
  9111. remain unencoded after running this function, it is likely an
  9112. invalid IDNA string (`xn--bar' is invalid).
  9113. You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
  9114. installed for this command to work."
  9115. (interactive "P")
  9116. (if (not (and (mm-coding-system-p 'utf-8)
  9117. (condition-case nil
  9118. (require 'idna)
  9119. (file-error)
  9120. (invalid-operation))
  9121. (symbol-value 'idna-program)
  9122. (executable-find (symbol-value 'idna-program))))
  9123. (gnus-message
  9124. 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
  9125. (gnus-summary-select-article)
  9126. (let ((mail-header-separator ""))
  9127. (gnus-eval-in-buffer-window gnus-article-buffer
  9128. (save-restriction
  9129. (widen)
  9130. (let ((start (window-start))
  9131. buffer-read-only)
  9132. (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
  9133. (replace-match (idna-to-unicode (match-string 1))))
  9134. (set-window-start (get-buffer-window (current-buffer)) start)))))))
  9135. (defun gnus-summary-morse-message (&optional arg)
  9136. "Morse decode the current article."
  9137. (interactive "P")
  9138. (gnus-summary-select-article)
  9139. (let ((mail-header-separator ""))
  9140. (gnus-eval-in-buffer-window gnus-article-buffer
  9141. (save-excursion
  9142. (save-restriction
  9143. (widen)
  9144. (let ((pos (window-start))
  9145. (inhibit-read-only t))
  9146. (goto-char (point-min))
  9147. (when (message-goto-body)
  9148. (gnus-narrow-to-body))
  9149. (goto-char (point-min))
  9150. (while (search-forward "·" (point-max) t)
  9151. (replace-match "."))
  9152. (unmorse-region (point-min) (point-max))
  9153. (widen)
  9154. (set-window-start (get-buffer-window (current-buffer)) pos)))))))
  9155. (defun gnus-summary-stop-page-breaking ()
  9156. "Stop page breaking in the current article."
  9157. (interactive)
  9158. (gnus-summary-select-article)
  9159. (gnus-eval-in-buffer-window gnus-article-buffer
  9160. (widen)
  9161. (when (gnus-visual-p 'page-marker)
  9162. (let ((inhibit-read-only t))
  9163. (gnus-remove-text-with-property 'gnus-prev)
  9164. (gnus-remove-text-with-property 'gnus-next))
  9165. (setq gnus-page-broken nil))))
  9166. (defun gnus-summary-move-article (&optional n to-newsgroup
  9167. select-method action)
  9168. "Move the current article to a different newsgroup.
  9169. If N is a positive number, move the N next articles.
  9170. If N is a negative number, move the N previous articles.
  9171. If N is nil and any articles have been marked with the process mark,
  9172. move those articles instead.
  9173. If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
  9174. If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
  9175. re-spool using this method.
  9176. When called interactively with TO-NEWSGROUP being nil, the value of
  9177. the variable `gnus-move-split-methods' is used for finding a default
  9178. for the target newsgroup.
  9179. For this function to work, both the current newsgroup and the
  9180. newsgroup that you want to move to have to support the `request-move'
  9181. and `request-accept' functions.
  9182. ACTION can be either `move' (the default), `crosspost' or `copy'."
  9183. (interactive "P")
  9184. (unless action
  9185. (setq action 'move))
  9186. ;; Check whether the source group supports the required functions.
  9187. (cond ((and (eq action 'move)
  9188. (not (gnus-check-backend-function
  9189. 'request-move-article gnus-newsgroup-name)))
  9190. (error "The current group does not support article moving"))
  9191. ((and (eq action 'crosspost)
  9192. (not (gnus-check-backend-function
  9193. 'request-replace-article gnus-newsgroup-name)))
  9194. (error "The current group does not support article editing")))
  9195. (let ((articles (gnus-summary-work-articles n))
  9196. (prefix (if (gnus-check-backend-function
  9197. 'request-move-article gnus-newsgroup-name)
  9198. (funcall gnus-move-group-prefix-function
  9199. gnus-newsgroup-name)
  9200. ""))
  9201. (names '((move "Move" "Moving")
  9202. (copy "Copy" "Copying")
  9203. (crosspost "Crosspost" "Crossposting")))
  9204. (copy-buf (save-excursion
  9205. (nnheader-set-temp-buffer " *copy article*")))
  9206. art-group to-method new-xref article to-groups
  9207. articles-to-update-marks encoded)
  9208. (unless (assq action names)
  9209. (error "Unknown action %s" action))
  9210. ;; Read the newsgroup name.
  9211. (when (and (not to-newsgroup)
  9212. (not select-method))
  9213. (if (and gnus-move-split-methods
  9214. (not
  9215. (and (memq gnus-current-article articles)
  9216. (gnus-buffer-live-p gnus-original-article-buffer))))
  9217. ;; When `gnus-move-split-methods' is non-nil, we have to
  9218. ;; select an article to give `gnus-read-move-group-name' an
  9219. ;; opportunity to suggest an appropriate default. However,
  9220. ;; we needn't render or mark the article.
  9221. (let ((gnus-display-mime-function nil)
  9222. (gnus-article-prepare-hook nil)
  9223. (gnus-mark-article-hook nil))
  9224. (gnus-summary-select-article nil nil nil (car articles))))
  9225. (setq to-newsgroup (gnus-read-move-group-name
  9226. (cadr (assq action names))
  9227. (symbol-value
  9228. (intern (format "gnus-current-%s-group" action)))
  9229. articles prefix)
  9230. encoded to-newsgroup
  9231. to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
  9232. (set (intern (format "gnus-current-%s-group" action))
  9233. (mm-decode-coding-string
  9234. to-newsgroup
  9235. (gnus-group-name-charset to-method to-newsgroup))))
  9236. (unless to-method
  9237. (setq to-method (or select-method
  9238. (gnus-server-to-method
  9239. (gnus-group-method to-newsgroup)))))
  9240. (setq to-newsgroup
  9241. (or encoded
  9242. (and to-newsgroup
  9243. (mm-encode-coding-string
  9244. to-newsgroup
  9245. (gnus-group-name-charset to-method to-newsgroup)))))
  9246. ;; Check the method we are to move this article to...
  9247. (unless (gnus-check-backend-function
  9248. 'request-accept-article (car to-method))
  9249. (error "%s does not support article copying" (car to-method)))
  9250. (unless (gnus-check-server to-method)
  9251. (error "Can't open server %s" (car to-method)))
  9252. (gnus-message 6 "%s to %s: %s..."
  9253. (caddr (assq action names))
  9254. (or (car select-method)
  9255. (gnus-group-decoded-name to-newsgroup))
  9256. articles)
  9257. (while articles
  9258. (setq article (pop articles))
  9259. ;; Set any marks that may have changed in the summary buffer.
  9260. (when gnus-preserve-marks
  9261. (gnus-summary-push-marks-to-backend article))
  9262. (setq
  9263. art-group
  9264. (cond
  9265. ;; Move the article.
  9266. ((eq action 'move)
  9267. ;; Remove this article from future suppression.
  9268. (gnus-dup-unsuppress-article article)
  9269. (let* ((from-method (gnus-find-method-for-group
  9270. gnus-newsgroup-name))
  9271. (to-method (or select-method
  9272. (gnus-find-method-for-group to-newsgroup)))
  9273. (move-is-internal (gnus-server-equal from-method to-method)))
  9274. (gnus-request-move-article
  9275. article ; Article to move
  9276. gnus-newsgroup-name ; From newsgroup
  9277. (nth 1 (gnus-find-method-for-group
  9278. gnus-newsgroup-name)) ; Server
  9279. (list 'gnus-request-accept-article
  9280. to-newsgroup (list 'quote select-method)
  9281. (not articles) t) ; Accept form
  9282. (not articles) ; Only save nov last time
  9283. (and move-is-internal
  9284. to-newsgroup ; Not respooling
  9285. ; Is this move internal?
  9286. (gnus-group-real-name to-newsgroup)))))
  9287. ;; Copy the article.
  9288. ((eq action 'copy)
  9289. (with-current-buffer copy-buf
  9290. (when (gnus-request-article-this-buffer article
  9291. gnus-newsgroup-name)
  9292. (save-restriction
  9293. (nnheader-narrow-to-headers)
  9294. (dolist (hdr gnus-copy-article-ignored-headers)
  9295. (message-remove-header hdr t)))
  9296. (gnus-request-accept-article
  9297. to-newsgroup select-method (not articles) t))))
  9298. ;; Crosspost the article.
  9299. ((eq action 'crosspost)
  9300. (let ((xref (message-tokenize-header
  9301. (mail-header-xref (gnus-summary-article-header
  9302. article))
  9303. " ")))
  9304. (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
  9305. ":" (number-to-string article)))
  9306. (unless xref
  9307. (setq xref (list (system-name))))
  9308. (setq new-xref
  9309. (concat
  9310. (mapconcat 'identity
  9311. (delete "Xref:" (delete new-xref xref))
  9312. " ")
  9313. " " new-xref))
  9314. (with-current-buffer copy-buf
  9315. ;; First put the article in the destination group.
  9316. (gnus-request-article-this-buffer article gnus-newsgroup-name)
  9317. (when (consp (setq art-group
  9318. (gnus-request-accept-article
  9319. to-newsgroup select-method (not articles)
  9320. t)))
  9321. (setq new-xref (concat new-xref " " (car art-group)
  9322. ":"
  9323. (number-to-string (cdr art-group))))
  9324. ;; Now we have the new Xrefs header, so we insert
  9325. ;; it and replace the new article.
  9326. (nnheader-replace-header "Xref" new-xref)
  9327. (gnus-request-replace-article
  9328. (cdr art-group) to-newsgroup (current-buffer) t)
  9329. art-group))))))
  9330. (cond
  9331. ((not art-group)
  9332. (gnus-message 1 "Couldn't %s article %s: %s"
  9333. (cadr (assq action names)) article
  9334. (nnheader-get-report (car to-method))))
  9335. ((eq art-group 'junk)
  9336. (when (eq action 'move)
  9337. (gnus-summary-mark-article article gnus-canceled-mark)
  9338. (gnus-message 4 "Deleted article %s" article)
  9339. ;; run the delete hook
  9340. (run-hook-with-args 'gnus-summary-article-delete-hook
  9341. action
  9342. (gnus-data-header
  9343. (assoc article (gnus-data-list nil)))
  9344. gnus-newsgroup-name nil
  9345. select-method)))
  9346. (t
  9347. (let* ((pto-group (gnus-group-prefixed-name
  9348. (car art-group) to-method))
  9349. (info (gnus-get-info pto-group))
  9350. (to-group (gnus-info-group info))
  9351. to-marks)
  9352. ;; Update the group that has been moved to.
  9353. (when (and info
  9354. (memq action '(move copy)))
  9355. (unless (member to-group to-groups)
  9356. (push to-group to-groups))
  9357. (when (and (not (memq article gnus-newsgroup-unreads))
  9358. (cdr art-group))
  9359. (push 'read to-marks)
  9360. (gnus-info-set-read
  9361. info (gnus-add-to-range (gnus-info-read info)
  9362. (list (cdr art-group)))))
  9363. ;; See whether the article is to be put in the cache.
  9364. (let* ((expirable (gnus-group-auto-expirable-p to-group))
  9365. (marks (if expirable
  9366. gnus-article-mark-lists
  9367. (delete '(expirable . expire)
  9368. (copy-sequence
  9369. gnus-article-mark-lists))))
  9370. (to-article (cdr art-group)))
  9371. ;; Enter the article into the cache in the new group,
  9372. ;; if that is required.
  9373. (when (and to-article
  9374. gnus-use-cache)
  9375. (gnus-cache-possibly-enter-article
  9376. to-group to-article
  9377. (memq article gnus-newsgroup-marked)
  9378. (memq article gnus-newsgroup-dormant)
  9379. (memq article gnus-newsgroup-unreads)))
  9380. (when (and gnus-preserve-marks
  9381. to-article)
  9382. ;; Copy any marks over to the new group.
  9383. (when (and (equal to-group gnus-newsgroup-name)
  9384. (not (memq article gnus-newsgroup-unreads)))
  9385. ;; Mark this article as read in this group.
  9386. (push (cons to-article gnus-read-mark)
  9387. gnus-newsgroup-reads)
  9388. ;; Increase the active status of this group.
  9389. (setcdr (gnus-active to-group) to-article)
  9390. (setcdr gnus-newsgroup-active to-article))
  9391. (while marks
  9392. (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
  9393. (when (memq article (symbol-value
  9394. (intern (format "gnus-newsgroup-%s"
  9395. (caar marks)))))
  9396. (push (cdar marks) to-marks)
  9397. ;; If the other group is the same as this group,
  9398. ;; then we have to add the mark to the list.
  9399. (when (equal to-group gnus-newsgroup-name)
  9400. (set (intern (format "gnus-newsgroup-%s"
  9401. (caar marks)))
  9402. (cons to-article
  9403. (symbol-value
  9404. (intern (format "gnus-newsgroup-%s"
  9405. (caar marks)))))))
  9406. ;; Copy the marks to other group.
  9407. (gnus-add-marked-articles
  9408. to-group (cdar marks) (list to-article) info)))
  9409. (setq marks (cdr marks)))
  9410. (when (and expirable
  9411. gnus-mark-copied-or-moved-articles-as-expirable
  9412. (not (memq 'expire to-marks)))
  9413. ;; Mark this article as expirable.
  9414. (push 'expire to-marks)
  9415. (when (equal to-group gnus-newsgroup-name)
  9416. (push to-article gnus-newsgroup-expirable))
  9417. ;; Copy the expirable mark to other group.
  9418. (gnus-add-marked-articles
  9419. to-group 'expire (list to-article) info))
  9420. (when (and to-marks
  9421. (gnus-method-option-p
  9422. (gnus-find-method-for-group to-group)
  9423. 'server-marks))
  9424. (gnus-request-set-mark
  9425. to-group (list (list (list to-article) 'add to-marks)))))
  9426. (gnus-dribble-enter
  9427. (concat "(gnus-group-set-info '"
  9428. (gnus-prin1-to-string (gnus-get-info to-group))
  9429. ")")
  9430. (concat "^(gnus-group-set-info '(\""
  9431. (regexp-quote to-group) "\""))))
  9432. ;; Update the Xref header in this article to point to
  9433. ;; the new crossposted article we have just created.
  9434. (when (eq action 'crosspost)
  9435. (with-current-buffer copy-buf
  9436. (gnus-request-article-this-buffer article gnus-newsgroup-name)
  9437. (nnheader-replace-header "Xref" new-xref)
  9438. (gnus-request-replace-article
  9439. article gnus-newsgroup-name (current-buffer) t)))
  9440. ;; run the move/copy/crosspost/respool hook
  9441. (run-hook-with-args 'gnus-summary-article-move-hook
  9442. action
  9443. (gnus-data-header
  9444. (assoc article (gnus-data-list nil)))
  9445. gnus-newsgroup-name
  9446. to-newsgroup
  9447. select-method))
  9448. ;;;!!!Why is this necessary?
  9449. (set-buffer gnus-summary-buffer)
  9450. (when (eq action 'move)
  9451. (save-excursion
  9452. (gnus-summary-goto-subject article)
  9453. (gnus-summary-mark-article article gnus-canceled-mark)))))
  9454. (push article articles-to-update-marks))
  9455. (save-excursion
  9456. (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
  9457. ;; Re-activate all groups that have been moved to.
  9458. (with-current-buffer gnus-group-buffer
  9459. (let ((gnus-group-marked to-groups))
  9460. (gnus-group-get-new-news-this-group nil t)))
  9461. (gnus-kill-buffer copy-buf)
  9462. (gnus-summary-position-point)
  9463. (gnus-set-mode-line 'summary)))
  9464. (defun gnus-summary-push-marks-to-backend (article)
  9465. (let ((set nil)
  9466. (del nil)
  9467. (marks gnus-article-mark-lists))
  9468. (unless (memq article gnus-newsgroup-unreads)
  9469. (push 'read set))
  9470. (while marks
  9471. (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
  9472. (memq article (symbol-value
  9473. (intern (format "gnus-newsgroup-%s"
  9474. (caar marks))))))
  9475. (push (cdar marks) set)
  9476. (push (cdar marks) del))
  9477. (pop marks))
  9478. (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
  9479. ((,article) del ,del)))))
  9480. (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
  9481. "Copy the current article to some other group.
  9482. If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
  9483. When called interactively, if TO-NEWSGROUP is nil, use the value of
  9484. the variable `gnus-move-split-methods' for finding a default target
  9485. newsgroup.
  9486. If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
  9487. re-spool using this method."
  9488. (interactive "P")
  9489. (gnus-summary-move-article n to-newsgroup select-method 'copy))
  9490. (defun gnus-summary-crosspost-article (&optional n)
  9491. "Crosspost the current article to some other group."
  9492. (interactive "P")
  9493. (gnus-summary-move-article n nil nil 'crosspost))
  9494. (defcustom gnus-summary-respool-default-method nil
  9495. "Default method type for respooling an article.
  9496. If nil, use to the current newsgroup method."
  9497. :type 'symbol
  9498. :group 'gnus-summary-mail)
  9499. (defun gnus-summary-respool-article (&optional n method)
  9500. "Respool the current article.
  9501. The article will be squeezed through the mail spooling process again,
  9502. which means that it will be put in some mail newsgroup or other
  9503. depending on `nnmail-split-methods'.
  9504. If N is a positive number, respool the N next articles.
  9505. If N is a negative number, respool the N previous articles.
  9506. If N is nil and any articles have been marked with the process mark,
  9507. respool those articles instead.
  9508. Respooling can be done both from mail groups and \"real\" newsgroups.
  9509. In the former case, the articles in question will be moved from the
  9510. current group into whatever groups they are destined to. In the
  9511. latter case, they will be copied into the relevant groups."
  9512. (interactive
  9513. (list current-prefix-arg
  9514. (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
  9515. (methname
  9516. (symbol-name (or gnus-summary-respool-default-method
  9517. (car (gnus-find-method-for-group
  9518. gnus-newsgroup-name)))))
  9519. (method
  9520. (gnus-completing-read
  9521. "Backend to use when respooling"
  9522. methods t nil 'gnus-mail-method-history methname))
  9523. ms)
  9524. (cond
  9525. ((zerop (length (setq ms (gnus-servers-using-backend
  9526. (intern method)))))
  9527. (list (intern method) ""))
  9528. ((= 1 (length ms))
  9529. (car ms))
  9530. (t
  9531. (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
  9532. (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
  9533. ms-alist))))))))
  9534. (unless method
  9535. (error "No method given for respooling"))
  9536. (if (assoc (symbol-name
  9537. (car (gnus-find-method-for-group gnus-newsgroup-name)))
  9538. (gnus-methods-using 'respool))
  9539. (gnus-summary-move-article n nil method)
  9540. (gnus-summary-copy-article n nil method)))
  9541. (defun gnus-summary-import-article (file &optional edit)
  9542. "Import an arbitrary file into a mail newsgroup."
  9543. (interactive "fImport file: \nP")
  9544. (let ((group gnus-newsgroup-name)
  9545. (now (current-time))
  9546. atts lines group-art)
  9547. (unless (gnus-check-backend-function 'request-accept-article group)
  9548. (error "%s does not support article importing" group))
  9549. (or (file-readable-p file)
  9550. (not (file-regular-p file))
  9551. (error "Can't read %s" file))
  9552. (with-current-buffer (gnus-get-buffer-create " *import file*")
  9553. (erase-buffer)
  9554. (nnheader-insert-file-contents file)
  9555. (goto-char (point-min))
  9556. (if (nnheader-article-p)
  9557. (save-restriction
  9558. (goto-char (point-min))
  9559. (search-forward "\n\n" nil t)
  9560. (narrow-to-region (point-min) (1- (point)))
  9561. (goto-char (point-min))
  9562. (unless (re-search-forward "^date:" nil t)
  9563. (goto-char (point-max))
  9564. (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
  9565. ;; This doesn't look like an article, so we fudge some headers.
  9566. (setq atts (file-attributes file)
  9567. lines (count-lines (point-min) (point-max)))
  9568. (insert "From: " (read-string "From: ") "\n"
  9569. "Subject: " (read-string "Subject: ") "\n"
  9570. "Date: " (message-make-date (nth 5 atts)) "\n"
  9571. "Message-ID: " (message-make-message-id) "\n"
  9572. "Lines: " (int-to-string lines) "\n"
  9573. "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
  9574. (setq group-art (gnus-request-accept-article group nil t))
  9575. (kill-buffer (current-buffer)))
  9576. (setq gnus-newsgroup-active (gnus-activate-group group))
  9577. (forward-line 1)
  9578. (gnus-summary-goto-article (cdr group-art) nil t)
  9579. (when edit
  9580. (gnus-summary-edit-article))))
  9581. (defun gnus-summary-create-article ()
  9582. "Create an article in a mail newsgroup."
  9583. (interactive)
  9584. (let ((group gnus-newsgroup-name)
  9585. (now (current-time))
  9586. group-art)
  9587. (unless (gnus-check-backend-function 'request-accept-article group)
  9588. (error "%s does not support article importing" group))
  9589. (with-current-buffer (gnus-get-buffer-create " *import file*")
  9590. (erase-buffer)
  9591. (goto-char (point-min))
  9592. ;; This doesn't look like an article, so we fudge some headers.
  9593. (insert "From: " (read-string "From: ") "\n"
  9594. "Subject: " (read-string "Subject: ") "\n"
  9595. "Date: " (message-make-date now) "\n"
  9596. "Message-ID: " (message-make-message-id) "\n")
  9597. (setq group-art (gnus-request-accept-article group nil t))
  9598. (kill-buffer (current-buffer)))
  9599. (setq gnus-newsgroup-active (gnus-activate-group group))
  9600. (forward-line 1)
  9601. (gnus-summary-goto-article (cdr group-art) nil t)
  9602. (gnus-summary-edit-article)))
  9603. (defun gnus-summary-article-posted-p ()
  9604. "Say whether the current (mail) article is available from news as well.
  9605. This will be the case if the article has both been mailed and posted."
  9606. (interactive)
  9607. (let ((id (mail-header-references (gnus-summary-article-header)))
  9608. (gnus-override-method (car (gnus-refer-article-methods))))
  9609. (if (gnus-request-head id "")
  9610. (gnus-message 2 "The current message was found on %s"
  9611. gnus-override-method)
  9612. (gnus-message 2 "The current message couldn't be found on %s"
  9613. gnus-override-method)
  9614. nil)))
  9615. (defun gnus-summary-expire-articles (&optional now)
  9616. "Expire all articles that are marked as expirable in the current group."
  9617. (interactive)
  9618. (when (and (not gnus-group-is-exiting-without-update-p)
  9619. (gnus-check-backend-function
  9620. 'request-expire-articles gnus-newsgroup-name))
  9621. ;; This backend supports expiry.
  9622. (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
  9623. (expirable
  9624. (gnus-list-range-difference
  9625. (if total
  9626. (progn
  9627. ;; We need to update the info for
  9628. ;; this group for `gnus-list-of-read-articles'
  9629. ;; to give us the right answer.
  9630. (gnus-run-hooks 'gnus-exit-group-hook)
  9631. (gnus-summary-update-info)
  9632. (gnus-list-of-read-articles gnus-newsgroup-name))
  9633. (setq gnus-newsgroup-expirable
  9634. (sort gnus-newsgroup-expirable '<)))
  9635. gnus-newsgroup-unexist))
  9636. (expiry-wait (if now 'immediate
  9637. (gnus-group-find-parameter
  9638. gnus-newsgroup-name 'expiry-wait)))
  9639. (nnmail-expiry-target
  9640. (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
  9641. nnmail-expiry-target))
  9642. es)
  9643. (when expirable
  9644. ;; There are expirable articles in this group, so we run them
  9645. ;; through the expiry process.
  9646. (gnus-message 6 "Expiring articles...")
  9647. (when (gnus-check-group gnus-newsgroup-name)
  9648. ;; The list of articles that weren't expired is returned.
  9649. (save-excursion
  9650. (if expiry-wait
  9651. (let ((nnmail-expiry-wait-function nil)
  9652. (nnmail-expiry-wait expiry-wait))
  9653. (setq es (gnus-request-expire-articles
  9654. expirable gnus-newsgroup-name)))
  9655. (setq es (gnus-request-expire-articles
  9656. expirable gnus-newsgroup-name)))
  9657. (unless total
  9658. (setq gnus-newsgroup-expirable es))
  9659. ;; We go through the old list of expirable, and mark all
  9660. ;; really expired articles as nonexistent.
  9661. (unless (eq es expirable) ;If nothing was expired, we don't mark.
  9662. (let ((gnus-use-cache nil))
  9663. (dolist (article expirable)
  9664. (when (and (not (memq article es))
  9665. (gnus-data-find article))
  9666. (gnus-summary-mark-article article gnus-canceled-mark)
  9667. (run-hook-with-args
  9668. 'gnus-summary-article-expire-hook
  9669. 'delete
  9670. (gnus-data-header (assoc article (gnus-data-list nil)))
  9671. gnus-newsgroup-name
  9672. (cond
  9673. ((stringp nnmail-expiry-target) nnmail-expiry-target)
  9674. ((eq nnmail-expiry-target 'delete) nil)
  9675. (t
  9676. (let ((rescall (funcall nnmail-expiry-target
  9677. gnus-newsgroup-name)))
  9678. (if (stringp rescall) rescall nil))))
  9679. nil)))))))
  9680. (gnus-message 6 "Expiring articles...done")))))
  9681. (defun gnus-summary-expire-articles-now ()
  9682. "Expunge all expirable articles in the current group.
  9683. This means that *all* articles that are marked as expirable will be
  9684. deleted forever, right now."
  9685. (interactive)
  9686. (or gnus-expert-user
  9687. (gnus-yes-or-no-p
  9688. "Are you really, really sure you want to delete all expirable messages? ")
  9689. (error "Phew!"))
  9690. (gnus-summary-expire-articles t))
  9691. ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
  9692. (defun gnus-summary-delete-article (&optional n)
  9693. "Delete the N next (mail) articles.
  9694. This command actually deletes articles. This is not a marking
  9695. command. The article will disappear forever from your life, never to
  9696. return.
  9697. If N is negative, delete backwards.
  9698. If N is nil and articles have been marked with the process mark,
  9699. delete these instead.
  9700. If `gnus-novice-user' is non-nil you will be asked for
  9701. confirmation before the articles are deleted."
  9702. (interactive "P")
  9703. (unless (gnus-check-backend-function 'request-expire-articles
  9704. gnus-newsgroup-name)
  9705. (error "The current newsgroup does not support article deletion"))
  9706. (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
  9707. (error "Couldn't open server"))
  9708. ;; Compute the list of articles to delete.
  9709. (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
  9710. (nnmail-expiry-target 'delete)
  9711. not-deleted)
  9712. (if (and gnus-novice-user
  9713. (not (gnus-yes-or-no-p
  9714. (format "Do you really want to delete %s forever? "
  9715. (if (> (length articles) 1)
  9716. (format "these %s articles" (length articles))
  9717. "this article")))))
  9718. ()
  9719. ;; Delete the articles.
  9720. (setq not-deleted (gnus-request-expire-articles
  9721. articles gnus-newsgroup-name 'force))
  9722. (save-excursion
  9723. (while articles
  9724. (gnus-summary-remove-process-mark (car articles))
  9725. ;; The backend might not have been able to delete the article
  9726. ;; after all.
  9727. (unless (memq (car articles) not-deleted)
  9728. (gnus-summary-mark-article (car articles) gnus-canceled-mark)
  9729. (let* ((article (car articles))
  9730. (ghead (gnus-data-header
  9731. (assoc article (gnus-data-list nil)))))
  9732. (run-hook-with-args 'gnus-summary-article-delete-hook
  9733. 'delete ghead gnus-newsgroup-name nil
  9734. nil)))
  9735. (setq articles (cdr articles))))
  9736. (when not-deleted
  9737. (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
  9738. (gnus-summary-position-point)
  9739. (gnus-set-mode-line 'summary)
  9740. not-deleted))
  9741. (defun gnus-summary-edit-article (&optional arg)
  9742. "Edit the current article.
  9743. This will have permanent effect only in mail groups.
  9744. If ARG is nil, edit the decoded articles.
  9745. If ARG is 1, edit the raw articles.
  9746. If ARG is 2, edit the raw articles even in read-only groups.
  9747. If ARG is 3, edit the articles with the current handles.
  9748. Otherwise, allow editing of articles even in read-only
  9749. groups."
  9750. (interactive "P")
  9751. (let (force raw current-handles)
  9752. (cond
  9753. ((null arg))
  9754. ((eq arg 1)
  9755. (setq raw t))
  9756. ((eq arg 2)
  9757. (setq raw t
  9758. force t))
  9759. ((eq arg 3)
  9760. (setq current-handles
  9761. (and (gnus-buffer-live-p gnus-article-buffer)
  9762. (with-current-buffer gnus-article-buffer
  9763. (prog1
  9764. gnus-article-mime-handles
  9765. (setq gnus-article-mime-handles nil))))))
  9766. (t
  9767. (setq force t)))
  9768. (when (and raw (not force)
  9769. (member gnus-newsgroup-name '("nndraft:delayed"
  9770. "nndraft:drafts"
  9771. "nndraft:queue")))
  9772. (error "Can't edit the raw article in group %s"
  9773. gnus-newsgroup-name))
  9774. (with-current-buffer gnus-summary-buffer
  9775. (let ((mail-parse-charset gnus-newsgroup-charset)
  9776. (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
  9777. (gnus-set-global-variables)
  9778. (when (and (not force)
  9779. (gnus-group-read-only-p))
  9780. (error "The current newsgroup does not support article editing"))
  9781. (gnus-summary-show-article t)
  9782. (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
  9783. (with-current-buffer gnus-article-buffer
  9784. (mm-enable-multibyte)))
  9785. (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
  9786. (setq raw t))
  9787. (gnus-article-edit-article
  9788. (if raw 'ignore
  9789. `(lambda ()
  9790. (let ((mbl mml-buffer-list))
  9791. (setq mml-buffer-list nil)
  9792. (let ((rfc2047-quote-decoded-words-containing-tspecials t))
  9793. (mime-to-mml ,'current-handles))
  9794. (let ((mbl1 mml-buffer-list))
  9795. (setq mml-buffer-list mbl)
  9796. (set (make-local-variable 'mml-buffer-list) mbl1))
  9797. (gnus-make-local-hook 'kill-buffer-hook)
  9798. (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
  9799. `(lambda (no-highlight)
  9800. (let ((mail-parse-charset ',gnus-newsgroup-charset)
  9801. (message-options message-options)
  9802. (message-options-set-recipient)
  9803. (mail-parse-ignored-charsets
  9804. ',gnus-newsgroup-ignored-charsets)
  9805. (rfc2047-header-encoding-alist
  9806. ',(let ((charset (gnus-group-name-charset
  9807. (gnus-find-method-for-group
  9808. gnus-newsgroup-name)
  9809. gnus-newsgroup-name)))
  9810. (append (list (cons "Newsgroups" charset)
  9811. (cons "Followup-To" charset)
  9812. (cons "Xref" charset))
  9813. rfc2047-header-encoding-alist))))
  9814. ,(if (not raw) '(progn
  9815. (mml-to-mime)
  9816. (mml-destroy-buffers)
  9817. (remove-hook 'kill-buffer-hook
  9818. 'mml-destroy-buffers t)
  9819. (kill-local-variable 'mml-buffer-list)))
  9820. (gnus-summary-edit-article-done
  9821. ,(or (mail-header-references gnus-current-headers) "")
  9822. ,(gnus-group-read-only-p)
  9823. ,gnus-summary-buffer no-highlight))))))))
  9824. (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
  9825. (defun gnus-summary-edit-article-done (&optional references read-only buffer
  9826. no-highlight)
  9827. "Make edits to the current article permanent."
  9828. (interactive)
  9829. (save-excursion
  9830. ;; The buffer restriction contains the entire article if it exists.
  9831. (when (article-goto-body)
  9832. (let ((lines (count-lines (point) (point-max)))
  9833. (length (- (point-max) (point)))
  9834. (case-fold-search t)
  9835. (body (point-marker)))
  9836. (goto-char (point-min))
  9837. (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
  9838. (delete-region (match-beginning 1) (match-end 1))
  9839. (insert (number-to-string length)))
  9840. (goto-char (point-min))
  9841. (when (re-search-forward
  9842. "^x-content-length:[ \t]\\([0-9]+\\)" body t)
  9843. (delete-region (match-beginning 1) (match-end 1))
  9844. (insert (number-to-string length)))
  9845. (goto-char (point-min))
  9846. (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
  9847. (delete-region (match-beginning 1) (match-end 1))
  9848. (insert (number-to-string lines))))))
  9849. ;; Replace the article.
  9850. (let ((buf (current-buffer))
  9851. (article (cdr gnus-article-current))
  9852. replace-result)
  9853. (with-temp-buffer
  9854. (insert-buffer-substring buf)
  9855. (if (and (not read-only)
  9856. (not (setq replace-result
  9857. (gnus-request-replace-article
  9858. article (car gnus-article-current)
  9859. (current-buffer) t))))
  9860. (error "Couldn't replace article")
  9861. ;; If we got a number back, then that's the new article number
  9862. ;; for this article. Otherwise, the article number didn't change.
  9863. (when (numberp replace-result)
  9864. (with-current-buffer gnus-summary-buffer
  9865. (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
  9866. (gnus-summary-limit gnus-newsgroup-limit)
  9867. (setq article replace-result)
  9868. (gnus-summary-goto-subject article t)))
  9869. ;; Update the summary buffer.
  9870. (if (and references
  9871. (equal (message-tokenize-header references " ")
  9872. (message-tokenize-header
  9873. (or (message-fetch-field "references") "") " ")))
  9874. ;; We only have to update this line.
  9875. (save-excursion
  9876. (save-restriction
  9877. (message-narrow-to-head)
  9878. (let ((head (buffer-substring-no-properties
  9879. (point-min) (point-max)))
  9880. header)
  9881. (with-temp-buffer
  9882. (insert (format "211 %d Article retrieved.\n" article))
  9883. (insert head)
  9884. (insert ".\n")
  9885. (let ((nntp-server-buffer (current-buffer)))
  9886. (setq header (car (gnus-get-newsgroup-headers nil t))))
  9887. (with-current-buffer gnus-summary-buffer
  9888. (gnus-data-set-header (gnus-data-find article) header)
  9889. (gnus-summary-update-article-line article header)
  9890. (if (gnus-summary-goto-subject article nil t)
  9891. (gnus-summary-update-secondary-mark article)))))))
  9892. ;; Update threads.
  9893. (set-buffer (or buffer gnus-summary-buffer))
  9894. (gnus-summary-update-article article)
  9895. (if (gnus-summary-goto-subject article nil t)
  9896. (gnus-summary-update-secondary-mark article)))
  9897. ;; Prettify the article buffer again.
  9898. (unless no-highlight
  9899. (with-current-buffer gnus-article-buffer
  9900. ;;!!! Fix this -- article should be rehighlighted.
  9901. ;;(gnus-run-hooks 'gnus-article-display-hook)
  9902. (set-buffer gnus-original-article-buffer)
  9903. (gnus-request-article
  9904. article (car gnus-article-current) (current-buffer))))
  9905. ;; Prettify the summary buffer line.
  9906. (when (gnus-visual-p 'summary-highlight 'highlight)
  9907. (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
  9908. (defun gnus-summary-edit-wash (key)
  9909. "Perform editing command KEY in the article buffer."
  9910. (interactive
  9911. (list
  9912. (progn
  9913. (message "%s" (concat (this-command-keys) "- "))
  9914. (read-char))))
  9915. (message "")
  9916. (gnus-summary-edit-article)
  9917. (execute-kbd-macro (concat (this-command-keys) key))
  9918. (gnus-article-edit-done))
  9919. ;;; Respooling
  9920. (defvar nnimap-split-fancy)
  9921. (defvar nnimap-split-methods)
  9922. (defun gnus-summary-respool-query (&optional silent trace)
  9923. "Query where the respool algorithm would put this article."
  9924. (interactive)
  9925. (let (gnus-mark-article-hook)
  9926. (gnus-summary-select-article)
  9927. (with-current-buffer gnus-original-article-buffer
  9928. (let ((groups
  9929. (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
  9930. 'nnimap)
  9931. ;; nnimap has its own splitting variables.
  9932. (let ((nnmail-split-methods
  9933. (cond
  9934. ((eq nnimap-split-methods 'default)
  9935. nnmail-split-methods)
  9936. (nnimap-split-methods
  9937. nnimap-split-methods)
  9938. (nnimap-split-fancy
  9939. 'nnmail-split-fancy)))
  9940. (nnmail-split-fancy (or nnimap-split-fancy
  9941. nnmail-split-fancy)))
  9942. (nnmail-article-group 'identity trace))
  9943. (nnmail-article-group 'identity trace))))
  9944. (unless silent
  9945. (if groups
  9946. (message "This message would go to %s"
  9947. (mapconcat 'car groups ", "))
  9948. (message "This message would go to no groups"))
  9949. groups)))))
  9950. (defun gnus-summary-respool-trace ()
  9951. "Trace where the respool algorithm would put this article.
  9952. Display a buffer showing all fancy splitting patterns which matched."
  9953. (interactive)
  9954. (gnus-summary-respool-query nil t))
  9955. ;; Summary marking commands.
  9956. (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
  9957. "Mark articles which has the same subject as read, and then select the next.
  9958. If UNMARK is positive, remove any kind of mark.
  9959. If UNMARK is negative, tick articles."
  9960. (interactive "P")
  9961. (when unmark
  9962. (setq unmark (prefix-numeric-value unmark)))
  9963. (let ((count
  9964. (gnus-summary-mark-same-subject
  9965. (gnus-summary-article-subject) unmark)))
  9966. ;; Select next unread article. If auto-select-same mode, should
  9967. ;; select the first unread article.
  9968. (gnus-summary-next-article t (and gnus-auto-select-same
  9969. (gnus-summary-article-subject)))
  9970. (gnus-message 7 "%d article%s marked as %s"
  9971. count (if (= count 1) " is" "s are")
  9972. (if unmark "unread" "read"))))
  9973. (defun gnus-summary-kill-same-subject (&optional unmark)
  9974. "Mark articles which has the same subject as read.
  9975. If UNMARK is positive, remove any kind of mark.
  9976. If UNMARK is negative, tick articles."
  9977. (interactive "P")
  9978. (when unmark
  9979. (setq unmark (prefix-numeric-value unmark)))
  9980. (let ((count
  9981. (gnus-summary-mark-same-subject
  9982. (gnus-summary-article-subject) unmark)))
  9983. ;; If marked as read, go to next unread subject.
  9984. (when (null unmark)
  9985. ;; Go to next unread subject.
  9986. (gnus-summary-next-subject 1 t))
  9987. (gnus-message 7 "%d articles are marked as %s"
  9988. count (if unmark "unread" "read"))))
  9989. (defun gnus-summary-mark-same-subject (subject &optional unmark)
  9990. "Mark articles with same SUBJECT as read, and return marked number.
  9991. If optional argument UNMARK is positive, remove any kinds of marks.
  9992. If optional argument UNMARK is negative, mark articles as unread instead."
  9993. (let ((count 1))
  9994. (save-excursion
  9995. (cond
  9996. ((null unmark) ; Mark as read.
  9997. (while (and
  9998. (progn
  9999. (gnus-summary-mark-article-as-read gnus-killed-mark)
  10000. (gnus-summary-show-thread) t)
  10001. (gnus-summary-find-subject subject))
  10002. (setq count (1+ count))))
  10003. ((> unmark 0) ; Tick.
  10004. (while (and
  10005. (progn
  10006. (gnus-summary-mark-article-as-unread gnus-ticked-mark)
  10007. (gnus-summary-show-thread) t)
  10008. (gnus-summary-find-subject subject))
  10009. (setq count (1+ count))))
  10010. (t ; Mark as unread.
  10011. (while (and
  10012. (progn
  10013. (gnus-summary-mark-article-as-unread gnus-unread-mark)
  10014. (gnus-summary-show-thread) t)
  10015. (gnus-summary-find-subject subject))
  10016. (setq count (1+ count)))))
  10017. (gnus-set-mode-line 'summary)
  10018. ;; Return the number of marked articles.
  10019. count)))
  10020. (defun gnus-summary-mark-as-processable (n &optional unmark)
  10021. "Set the process mark on the next N articles.
  10022. If N is negative, mark backward instead. If UNMARK is non-nil, remove
  10023. the process mark instead. The difference between N and the actual
  10024. number of articles marked is returned."
  10025. (interactive "P")
  10026. (if (and (null n) (gnus-region-active-p))
  10027. (gnus-uu-mark-region (region-beginning) (region-end) unmark)
  10028. (setq n (prefix-numeric-value n))
  10029. (let ((backward (< n 0))
  10030. (n (abs n)))
  10031. (while (and
  10032. (> n 0)
  10033. (if unmark
  10034. (gnus-summary-remove-process-mark
  10035. (gnus-summary-article-number))
  10036. (gnus-summary-set-process-mark (gnus-summary-article-number)))
  10037. (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
  10038. (setq n (1- n)))
  10039. (when (/= 0 n)
  10040. (gnus-message 7 "No more articles"))
  10041. (gnus-summary-recenter)
  10042. (gnus-summary-position-point)
  10043. n)))
  10044. (defun gnus-summary-unmark-as-processable (n)
  10045. "Remove the process mark from the next N articles.
  10046. If N is negative, unmark backward instead. The difference between N and
  10047. the actual number of articles unmarked is returned."
  10048. (interactive "P")
  10049. (gnus-summary-mark-as-processable n t))
  10050. (defun gnus-summary-unmark-all-processable ()
  10051. "Remove the process mark from all articles."
  10052. (interactive)
  10053. (save-excursion
  10054. (while gnus-newsgroup-processable
  10055. (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
  10056. (gnus-summary-position-point))
  10057. (defun gnus-summary-add-mark (article type)
  10058. "Mark ARTICLE with a mark of TYPE."
  10059. (let ((vtype (car (assq type gnus-article-mark-lists)))
  10060. var)
  10061. (if (not vtype)
  10062. (error "No such mark type: %s" type)
  10063. (setq var (intern (format "gnus-newsgroup-%s" type)))
  10064. (set var (cons article (symbol-value var)))
  10065. (if (memq type '(processable cached replied forwarded recent saved))
  10066. (gnus-summary-update-secondary-mark article)
  10067. ;;; !!! This is bogus. We should find out what primary
  10068. ;;; !!! mark we want to set.
  10069. (gnus-summary-update-mark gnus-del-mark 'unread)))))
  10070. (defun gnus-summary-mark-as-expirable (n)
  10071. "Mark N articles forward as expirable.
  10072. If N is negative, mark backward instead. The difference between N and
  10073. the actual number of articles marked is returned."
  10074. (interactive "p")
  10075. (gnus-summary-mark-forward n gnus-expirable-mark))
  10076. (defun gnus-summary-mark-as-spam (n)
  10077. "Mark N articles forward as spam.
  10078. If N is negative, mark backward instead. The difference between N and
  10079. the actual number of articles marked is returned."
  10080. (interactive "p")
  10081. (gnus-summary-mark-forward n gnus-spam-mark))
  10082. (defun gnus-summary-mark-article-as-replied (article)
  10083. "Mark ARTICLE as replied to and update the summary line.
  10084. ARTICLE can also be a list of articles."
  10085. (interactive (list (gnus-summary-article-number)))
  10086. (let ((articles (if (listp article) article (list article))))
  10087. (dolist (article articles)
  10088. (unless (numberp article)
  10089. (error "%s is not a number" article))
  10090. (push article gnus-newsgroup-replied)
  10091. (let ((inhibit-read-only t))
  10092. (when (gnus-summary-goto-subject article nil t)
  10093. (gnus-summary-update-secondary-mark article))))))
  10094. (defun gnus-summary-mark-article-as-forwarded (article)
  10095. "Mark ARTICLE as forwarded and update the summary line.
  10096. ARTICLE can also be a list of articles."
  10097. (let ((articles (if (listp article) article (list article))))
  10098. (dolist (article articles)
  10099. (push article gnus-newsgroup-forwarded)
  10100. (let ((inhibit-read-only t))
  10101. (when (gnus-summary-goto-subject article nil t)
  10102. (gnus-summary-update-secondary-mark article))))))
  10103. (defun gnus-summary-set-bookmark (article)
  10104. "Set a bookmark in current article."
  10105. (interactive (list (gnus-summary-article-number)))
  10106. (when (or (not (get-buffer gnus-article-buffer))
  10107. (not gnus-current-article)
  10108. (not gnus-article-current)
  10109. (not (equal gnus-newsgroup-name (car gnus-article-current))))
  10110. (error "No current article selected"))
  10111. ;; Remove old bookmark, if one exists.
  10112. (gnus-alist-pull article gnus-newsgroup-bookmarks)
  10113. ;; Set the new bookmark, which is on the form
  10114. ;; (article-number . line-number-in-body).
  10115. (push
  10116. (cons article
  10117. (with-current-buffer gnus-article-buffer
  10118. (count-lines
  10119. (min (point)
  10120. (save-excursion
  10121. (article-goto-body)
  10122. (point)))
  10123. (point))))
  10124. gnus-newsgroup-bookmarks)
  10125. (gnus-message 6 "A bookmark has been added to the current article."))
  10126. (defun gnus-summary-remove-bookmark (article)
  10127. "Remove the bookmark from the current article."
  10128. (interactive (list (gnus-summary-article-number)))
  10129. ;; Remove old bookmark, if one exists.
  10130. (if (not (assq article gnus-newsgroup-bookmarks))
  10131. (gnus-message 6 "No bookmark in current article.")
  10132. (gnus-alist-pull article gnus-newsgroup-bookmarks)
  10133. (gnus-message 6 "Removed bookmark.")))
  10134. ;; Suggested by Daniel Quinlan <quinlan@best.com>.
  10135. (defun gnus-summary-mark-as-dormant (n)
  10136. "Mark N articles forward as dormant.
  10137. If N is negative, mark backward instead. The difference between N and
  10138. the actual number of articles marked is returned."
  10139. (interactive "p")
  10140. (gnus-summary-mark-forward n gnus-dormant-mark))
  10141. (defun gnus-summary-set-process-mark (article)
  10142. "Set the process mark on ARTICLE and update the summary line."
  10143. (setq gnus-newsgroup-processable
  10144. (cons article
  10145. (delq article gnus-newsgroup-processable)))
  10146. (when (gnus-summary-goto-subject article)
  10147. (gnus-summary-show-thread)
  10148. (gnus-summary-goto-subject article)
  10149. (gnus-summary-update-secondary-mark article)))
  10150. (defun gnus-summary-remove-process-mark (&rest articles)
  10151. "Remove the process mark from ARTICLES and update the summary line."
  10152. (dolist (article articles)
  10153. (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
  10154. (when (gnus-summary-goto-subject article)
  10155. (gnus-summary-show-thread)
  10156. (gnus-summary-goto-subject article)
  10157. (gnus-summary-update-secondary-mark article)))
  10158. t)
  10159. (defun gnus-summary-set-saved-mark (article)
  10160. "Set the process mark on ARTICLE and update the summary line."
  10161. (push article gnus-newsgroup-saved)
  10162. (when (gnus-summary-goto-subject article)
  10163. (gnus-summary-update-secondary-mark article)))
  10164. (defun gnus-summary-mark-forward (n &optional mark no-expire)
  10165. "Mark N articles as read forwards.
  10166. If N is negative, mark backwards instead. Mark with MARK, ?r by default.
  10167. The difference between N and the actual number of articles marked is
  10168. returned.
  10169. If NO-EXPIRE, auto-expiry will be inhibited."
  10170. (interactive "p")
  10171. (gnus-summary-show-thread)
  10172. (let ((backward (< n 0))
  10173. (gnus-summary-goto-unread
  10174. (and gnus-summary-goto-unread
  10175. (not (eq gnus-summary-goto-unread 'never))
  10176. (not (memq mark (list gnus-unread-mark gnus-spam-mark
  10177. gnus-ticked-mark gnus-dormant-mark)))))
  10178. (n (abs n))
  10179. (mark (or mark gnus-del-mark)))
  10180. (while (and (> n 0)
  10181. (gnus-summary-mark-article nil mark no-expire)
  10182. (zerop (gnus-summary-next-subject
  10183. (if backward -1 1)
  10184. (and gnus-summary-goto-unread
  10185. (not (eq gnus-summary-goto-unread 'never)))
  10186. t)))
  10187. (setq n (1- n)))
  10188. (when (/= 0 n)
  10189. (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
  10190. (gnus-summary-recenter)
  10191. (gnus-summary-position-point)
  10192. (gnus-set-mode-line 'summary)
  10193. n))
  10194. (defun gnus-summary-mark-article-as-read (mark)
  10195. "Mark the current article quickly as read with MARK."
  10196. (let ((article (gnus-summary-article-number)))
  10197. (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10198. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
  10199. (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
  10200. (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
  10201. (push (cons article mark) gnus-newsgroup-reads)
  10202. ;; Possibly remove from cache, if that is used.
  10203. (when gnus-use-cache
  10204. (gnus-cache-enter-remove-article article))
  10205. ;; Allow the backend to change the mark.
  10206. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10207. ;; Check for auto-expiry.
  10208. (when (and gnus-newsgroup-auto-expire
  10209. (memq mark gnus-auto-expirable-marks))
  10210. (setq mark gnus-expirable-mark)
  10211. ;; Let the backend know about the mark change.
  10212. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10213. (push article gnus-newsgroup-expirable))
  10214. ;; Set the mark in the buffer.
  10215. (gnus-summary-update-mark mark 'unread)
  10216. t))
  10217. (defun gnus-summary-mark-article-as-unread (mark)
  10218. "Mark the current article quickly as unread with MARK."
  10219. (let* ((article (gnus-summary-article-number))
  10220. (old-mark (gnus-summary-article-mark article)))
  10221. ;; Allow the backend to change the mark.
  10222. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10223. (if (eq mark old-mark)
  10224. t
  10225. (if (<= article 0)
  10226. (progn
  10227. (gnus-error 1 "Can't mark negative article numbers")
  10228. nil)
  10229. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
  10230. (setq gnus-newsgroup-spam-marked
  10231. (delq article gnus-newsgroup-spam-marked))
  10232. (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
  10233. (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
  10234. (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
  10235. (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10236. (cond ((= mark gnus-ticked-mark)
  10237. (setq gnus-newsgroup-marked
  10238. (gnus-add-to-sorted-list gnus-newsgroup-marked
  10239. article)))
  10240. ((= mark gnus-spam-mark)
  10241. (setq gnus-newsgroup-spam-marked
  10242. (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
  10243. article)))
  10244. ((= mark gnus-dormant-mark)
  10245. (setq gnus-newsgroup-dormant
  10246. (gnus-add-to-sorted-list gnus-newsgroup-dormant
  10247. article)))
  10248. (t
  10249. (setq gnus-newsgroup-unreads
  10250. (gnus-add-to-sorted-list gnus-newsgroup-unreads
  10251. article))))
  10252. (gnus-alist-pull article gnus-newsgroup-reads)
  10253. ;; See whether the article is to be put in the cache.
  10254. (and gnus-use-cache
  10255. (vectorp (gnus-summary-article-header article))
  10256. (save-excursion
  10257. (gnus-cache-possibly-enter-article
  10258. gnus-newsgroup-name article
  10259. (= mark gnus-ticked-mark)
  10260. (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
  10261. ;; Fix the mark.
  10262. (gnus-summary-update-mark mark 'unread)
  10263. t))))
  10264. (defun gnus-summary-mark-article (&optional article mark no-expire)
  10265. "Mark ARTICLE with MARK. MARK can be any character.
  10266. Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
  10267. `??' (dormant) and `?E' (expirable).
  10268. If MARK is nil, then the default character `?r' is used.
  10269. If ARTICLE is nil, then the article on the current line will be
  10270. marked.
  10271. If NO-EXPIRE, auto-expiry will be inhibited."
  10272. ;; The mark might be a string.
  10273. (when (stringp mark)
  10274. (setq mark (aref mark 0)))
  10275. ;; If no mark is given, then we check auto-expiring.
  10276. (when (null mark)
  10277. (setq mark gnus-del-mark))
  10278. (when (and (not no-expire)
  10279. gnus-newsgroup-auto-expire
  10280. (memq mark gnus-auto-expirable-marks))
  10281. (setq mark gnus-expirable-mark))
  10282. (let ((article (or article (gnus-summary-article-number)))
  10283. (old-mark (gnus-summary-article-mark article)))
  10284. ;; Allow the backend to change the mark.
  10285. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10286. (if (eq mark old-mark)
  10287. t
  10288. (unless article
  10289. (error "No article on current line"))
  10290. (if (not (if (or (= mark gnus-unread-mark)
  10291. (= mark gnus-ticked-mark)
  10292. (= mark gnus-spam-mark)
  10293. (= mark gnus-dormant-mark))
  10294. (gnus-mark-article-as-unread article mark)
  10295. (gnus-mark-article-as-read article mark)))
  10296. t
  10297. ;; See whether the article is to be put in the cache.
  10298. (and gnus-use-cache
  10299. (not (= mark gnus-canceled-mark))
  10300. (vectorp (gnus-summary-article-header article))
  10301. (save-excursion
  10302. (gnus-cache-possibly-enter-article
  10303. gnus-newsgroup-name article
  10304. (= mark gnus-ticked-mark)
  10305. (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
  10306. (when (gnus-summary-goto-subject article nil t)
  10307. (let ((inhibit-read-only t))
  10308. (gnus-summary-show-thread)
  10309. ;; Fix the mark.
  10310. (gnus-summary-update-mark mark 'unread)
  10311. t))))))
  10312. (defun gnus-summary-update-secondary-mark (article)
  10313. "Update the secondary (read, process, cache) mark."
  10314. (gnus-summary-update-mark
  10315. (cond ((memq article gnus-newsgroup-processable)
  10316. gnus-process-mark)
  10317. ((memq article gnus-newsgroup-cached)
  10318. gnus-cached-mark)
  10319. ((memq article gnus-newsgroup-replied)
  10320. gnus-replied-mark)
  10321. ((memq article gnus-newsgroup-forwarded)
  10322. gnus-forwarded-mark)
  10323. ((memq article gnus-newsgroup-saved)
  10324. gnus-saved-mark)
  10325. ((memq article gnus-newsgroup-unseen)
  10326. gnus-unseen-mark)
  10327. (t gnus-no-mark))
  10328. 'replied)
  10329. (when (gnus-visual-p 'summary-highlight 'highlight)
  10330. (gnus-summary-highlight-line)
  10331. (gnus-run-hooks 'gnus-summary-update-hook))
  10332. t)
  10333. (defun gnus-summary-update-download-mark (article)
  10334. "Update the download mark."
  10335. (gnus-summary-update-mark
  10336. (cond ((memq article gnus-newsgroup-undownloaded)
  10337. gnus-undownloaded-mark)
  10338. (gnus-newsgroup-agentized
  10339. gnus-downloaded-mark)
  10340. (t
  10341. gnus-no-mark))
  10342. 'download)
  10343. (gnus-summary-update-line t)
  10344. t)
  10345. (defun gnus-summary-update-mark (mark type)
  10346. (let ((forward (cdr (assq type gnus-summary-mark-positions)))
  10347. (inhibit-read-only t))
  10348. (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
  10349. (when forward
  10350. (when (looking-at "\r")
  10351. (incf forward))
  10352. (when (<= (+ forward (point)) (point-max))
  10353. ;; Go to the right position on the line.
  10354. (goto-char (+ forward (point)))
  10355. ;; Replace the old mark with the new mark.
  10356. (let ((to-insert
  10357. (mm-subst-char-in-string
  10358. (char-after) mark
  10359. (buffer-substring (point) (1+ (point))))))
  10360. (delete-region (point) (1+ (point)))
  10361. (insert to-insert))
  10362. ;; Optionally update the marks by some user rule.
  10363. (when (eq type 'unread)
  10364. (gnus-data-set-mark
  10365. (gnus-data-find (gnus-summary-article-number)) mark)
  10366. (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
  10367. (defun gnus-mark-article-as-read (article &optional mark)
  10368. "Enter ARTICLE in the pertinent lists and remove it from others."
  10369. ;; Make the article expirable.
  10370. (let ((mark (or mark gnus-del-mark)))
  10371. (setq gnus-newsgroup-expirable
  10372. (if (= mark gnus-expirable-mark)
  10373. (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
  10374. (delq article gnus-newsgroup-expirable)))
  10375. ;; Remove from unread and marked lists.
  10376. (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10377. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
  10378. (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
  10379. (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
  10380. (push (cons article mark) gnus-newsgroup-reads)
  10381. ;; Possibly remove from cache, if that is used.
  10382. (when gnus-use-cache
  10383. (gnus-cache-enter-remove-article article))
  10384. t))
  10385. (defun gnus-mark-article-as-unread (article &optional mark)
  10386. "Enter ARTICLE in the pertinent lists and remove it from others."
  10387. (let ((mark (or mark gnus-ticked-mark)))
  10388. (if (<= article 0)
  10389. (progn
  10390. (gnus-error 1 "Can't mark negative article numbers")
  10391. nil)
  10392. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
  10393. gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
  10394. gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
  10395. gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
  10396. gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10397. ;; Unsuppress duplicates?
  10398. (when gnus-suppress-duplicates
  10399. (gnus-dup-unsuppress-article article))
  10400. (cond ((= mark gnus-ticked-mark)
  10401. (setq gnus-newsgroup-marked
  10402. (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
  10403. ((= mark gnus-spam-mark)
  10404. (setq gnus-newsgroup-spam-marked
  10405. (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
  10406. article)))
  10407. ((= mark gnus-dormant-mark)
  10408. (setq gnus-newsgroup-dormant
  10409. (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
  10410. (t
  10411. (setq gnus-newsgroup-unreads
  10412. (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
  10413. (gnus-alist-pull article gnus-newsgroup-reads)
  10414. t)))
  10415. (defun gnus-summary-tick-article-forward (n)
  10416. "Tick N articles forwards.
  10417. If N is negative, tick backwards instead.
  10418. The difference between N and the number of articles ticked is returned."
  10419. (interactive "p")
  10420. (gnus-summary-mark-forward n gnus-ticked-mark))
  10421. (defun gnus-summary-tick-article-backward (n)
  10422. "Tick N articles backwards.
  10423. The difference between N and the number of articles ticked is returned."
  10424. (interactive "p")
  10425. (gnus-summary-mark-forward (- n) gnus-ticked-mark))
  10426. (defun gnus-summary-tick-article (&optional article clear-mark)
  10427. "Mark current article as unread.
  10428. Optional 1st argument ARTICLE specifies article number to be marked as unread.
  10429. Optional 2nd argument CLEAR-MARK remove any kinds of mark."
  10430. (interactive)
  10431. (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
  10432. gnus-ticked-mark)))
  10433. (defun gnus-summary-mark-as-read-forward (n)
  10434. "Mark N articles as read forwards.
  10435. If N is negative, mark backwards instead.
  10436. The difference between N and the actual number of articles marked is
  10437. returned."
  10438. (interactive "p")
  10439. (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
  10440. (defun gnus-summary-mark-as-read-backward (n)
  10441. "Mark the N articles as read backwards.
  10442. The difference between N and the actual number of articles marked is
  10443. returned."
  10444. (interactive "p")
  10445. (gnus-summary-mark-forward
  10446. (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
  10447. (defun gnus-summary-mark-as-read (&optional article mark)
  10448. "Mark current article as read.
  10449. ARTICLE specifies the article to be marked as read.
  10450. MARK specifies a string to be inserted at the beginning of the line."
  10451. (gnus-summary-mark-article article mark))
  10452. (defun gnus-summary-clear-mark-forward (n)
  10453. "Clear marks from N articles forward.
  10454. If N is negative, clear backward instead.
  10455. The difference between N and the number of marks cleared is returned."
  10456. (interactive "p")
  10457. (gnus-summary-mark-forward n gnus-unread-mark))
  10458. (defun gnus-summary-clear-mark-backward (n)
  10459. "Clear marks from N articles backward.
  10460. The difference between N and the number of marks cleared is returned."
  10461. (interactive "p")
  10462. (gnus-summary-mark-forward (- n) gnus-unread-mark))
  10463. (defun gnus-summary-mark-unread-as-read ()
  10464. "Intended to be used by `gnus-mark-article-hook'."
  10465. (when (memq gnus-current-article gnus-newsgroup-unreads)
  10466. (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
  10467. (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
  10468. "Intended to be used by `gnus-mark-article-hook'."
  10469. (let ((mark (gnus-summary-article-mark)))
  10470. (when (or (gnus-unread-mark-p mark)
  10471. (gnus-read-mark-p mark))
  10472. (gnus-summary-mark-article gnus-current-article
  10473. (or new-mark gnus-read-mark)))))
  10474. (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
  10475. "Intended to be used by `gnus-mark-article-hook'."
  10476. (let ((mark (gnus-summary-article-mark)))
  10477. (when (or (gnus-unread-mark-p mark)
  10478. (gnus-read-mark-p mark))
  10479. (gnus-summary-mark-article (gnus-summary-article-number)
  10480. (or new-mark gnus-read-mark)))))
  10481. (defun gnus-summary-mark-unread-as-ticked ()
  10482. "Intended to be used by `gnus-mark-article-hook'."
  10483. (when (memq gnus-current-article gnus-newsgroup-unreads)
  10484. (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
  10485. (defun gnus-summary-mark-region-as-read (point mark all)
  10486. "Mark all unread articles between point and mark as read.
  10487. If given a prefix, mark all articles between point and mark as read,
  10488. even ticked and dormant ones."
  10489. (interactive "r\nP")
  10490. (save-excursion
  10491. (let (article)
  10492. (goto-char point)
  10493. (beginning-of-line)
  10494. (while (and
  10495. (< (point) mark)
  10496. (progn
  10497. (when (or all
  10498. (memq (setq article (gnus-summary-article-number))
  10499. gnus-newsgroup-unreads))
  10500. (gnus-summary-mark-article article gnus-del-mark))
  10501. t)
  10502. (gnus-summary-find-next))))))
  10503. (defun gnus-summary-mark-below (score mark)
  10504. "Mark articles with score less than SCORE with MARK."
  10505. (interactive "P\ncMark: ")
  10506. (setq score (if score
  10507. (prefix-numeric-value score)
  10508. (or gnus-summary-default-score 0)))
  10509. (with-current-buffer gnus-summary-buffer
  10510. (goto-char (point-min))
  10511. (while
  10512. (progn
  10513. (and (< (gnus-summary-article-score) score)
  10514. (gnus-summary-mark-article nil mark))
  10515. (gnus-summary-find-next)))))
  10516. (defun gnus-summary-kill-below (&optional score)
  10517. "Mark articles with score below SCORE as read."
  10518. (interactive "P")
  10519. (gnus-summary-mark-below score gnus-killed-mark))
  10520. (defun gnus-summary-clear-above (&optional score)
  10521. "Clear all marks from articles with score above SCORE."
  10522. (interactive "P")
  10523. (gnus-summary-mark-above score gnus-unread-mark))
  10524. (defun gnus-summary-tick-above (&optional score)
  10525. "Tick all articles with score above SCORE."
  10526. (interactive "P")
  10527. (gnus-summary-mark-above score gnus-ticked-mark))
  10528. (defun gnus-summary-mark-above (score mark)
  10529. "Mark articles with score over SCORE with MARK."
  10530. (interactive "P\ncMark: ")
  10531. (setq score (if score
  10532. (prefix-numeric-value score)
  10533. (or gnus-summary-default-score 0)))
  10534. (with-current-buffer gnus-summary-buffer
  10535. (goto-char (point-min))
  10536. (while (and (progn
  10537. (when (> (gnus-summary-article-score) score)
  10538. (gnus-summary-mark-article nil mark))
  10539. t)
  10540. (gnus-summary-find-next)))))
  10541. ;; Suggested by Daniel Quinlan <quinlan@best.com>.
  10542. (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
  10543. (defun gnus-summary-limit-include-expunged (&optional no-error)
  10544. "Display all the hidden articles that were expunged for low scores."
  10545. (interactive)
  10546. (let ((inhibit-read-only t))
  10547. (let ((scored gnus-newsgroup-scored)
  10548. headers h)
  10549. (while scored
  10550. (unless (gnus-summary-article-header (caar scored))
  10551. (and (setq h (gnus-number-to-header (caar scored)))
  10552. (< (cdar scored) gnus-summary-expunge-below)
  10553. (push h headers)))
  10554. (setq scored (cdr scored)))
  10555. (if (not headers)
  10556. (when (not no-error)
  10557. (error "No expunged articles hidden"))
  10558. (goto-char (point-min))
  10559. (push gnus-newsgroup-limit gnus-newsgroup-limits)
  10560. (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
  10561. (dolist (x headers)
  10562. (push (mail-header-number x) gnus-newsgroup-limit))
  10563. (gnus-summary-prepare-unthreaded (nreverse headers))
  10564. (goto-char (point-min))
  10565. (gnus-summary-position-point)
  10566. t))))
  10567. (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
  10568. "Mark all unread articles in this newsgroup as read.
  10569. If prefix argument ALL is non-nil, ticked and dormant articles will
  10570. also be marked as read.
  10571. If QUIETLY is non-nil, no questions will be asked.
  10572. If TO-HERE is non-nil, it should be a point in the buffer. All
  10573. articles before (after, if REVERSE is set) this point will be marked
  10574. as read.
  10575. Note that this function will only catch up the unread article
  10576. in the current summary buffer limitation.
  10577. The number of articles marked as read is returned."
  10578. (interactive "P")
  10579. (prog1
  10580. (save-excursion
  10581. (when (or quietly
  10582. (not gnus-interactive-catchup) ;Without confirmation?
  10583. gnus-expert-user
  10584. (gnus-y-or-n-p
  10585. (if all
  10586. "Mark absolutely all articles as read? "
  10587. "Mark all unread articles as read? ")))
  10588. (if (and not-mark
  10589. (not gnus-newsgroup-adaptive)
  10590. (not gnus-newsgroup-auto-expire)
  10591. (not gnus-suppress-duplicates)
  10592. (or (not gnus-use-cache)
  10593. (eq gnus-use-cache 'passive)))
  10594. (progn
  10595. (when all
  10596. (setq gnus-newsgroup-marked nil
  10597. gnus-newsgroup-spam-marked nil
  10598. gnus-newsgroup-dormant nil))
  10599. (setq gnus-newsgroup-unreads
  10600. (gnus-sorted-nunion
  10601. (gnus-sorted-intersection gnus-newsgroup-unreads
  10602. gnus-newsgroup-downloadable)
  10603. (gnus-sorted-difference gnus-newsgroup-unfetched
  10604. gnus-newsgroup-cached))))
  10605. ;; We actually mark all articles as canceled, which we
  10606. ;; have to do when using auto-expiry or adaptive scoring.
  10607. (gnus-summary-show-all-threads)
  10608. (if (and to-here reverse)
  10609. (progn
  10610. (goto-char to-here)
  10611. (gnus-summary-mark-current-read-and-unread-as-read
  10612. gnus-catchup-mark)
  10613. (while (gnus-summary-find-next (not all))
  10614. (gnus-summary-mark-article-as-read gnus-catchup-mark)))
  10615. (when (gnus-summary-first-subject (not all))
  10616. (while (and
  10617. (if to-here (< (point) to-here) t)
  10618. (gnus-summary-mark-article-as-read gnus-catchup-mark)
  10619. (gnus-summary-find-next (not all))))))
  10620. (gnus-set-mode-line 'summary))
  10621. t))
  10622. (gnus-summary-position-point)))
  10623. (defun gnus-summary-catchup-to-here (&optional all)
  10624. "Mark all unticked articles before the current one as read.
  10625. If ALL is non-nil, also mark ticked and dormant articles as read."
  10626. (interactive "P")
  10627. (save-excursion
  10628. (gnus-save-hidden-threads
  10629. (let ((beg (point)))
  10630. ;; We check that there are unread articles.
  10631. (when (or all (gnus-summary-find-prev))
  10632. (gnus-summary-catchup all t beg)))))
  10633. (gnus-summary-position-point))
  10634. (defun gnus-summary-catchup-from-here (&optional all)
  10635. "Mark all unticked articles after (and including) the current one as read.
  10636. If ALL is non-nil, also mark ticked and dormant articles as read."
  10637. (interactive "P")
  10638. (save-excursion
  10639. (gnus-save-hidden-threads
  10640. (let ((beg (point)))
  10641. ;; We check that there are unread articles.
  10642. (when (or all (gnus-summary-find-next))
  10643. (gnus-summary-catchup all t beg nil t)))))
  10644. (gnus-summary-position-point))
  10645. (defun gnus-summary-catchup-all (&optional quietly)
  10646. "Mark all articles in this newsgroup as read.
  10647. This command is dangerous. Normally, you want \\[gnus-summary-catchup]
  10648. instead, which marks only unread articles as read."
  10649. (interactive "P")
  10650. (gnus-summary-catchup t quietly))
  10651. (defun gnus-summary-catchup-and-exit (&optional all quietly)
  10652. "Mark all unread articles in this group as read, then exit.
  10653. If prefix argument ALL is non-nil, all articles are marked as read.
  10654. If QUIETLY is non-nil, no questions will be asked."
  10655. (interactive "P")
  10656. (when (gnus-summary-catchup all quietly nil 'fast)
  10657. ;; Select next newsgroup or exit.
  10658. (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
  10659. (eq gnus-auto-select-next 'quietly))
  10660. (gnus-summary-next-group nil)
  10661. (gnus-summary-exit))))
  10662. (defun gnus-summary-catchup-all-and-exit (&optional quietly)
  10663. "Mark all articles in this newsgroup as read, and then exit.
  10664. This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
  10665. instead, which marks only unread articles as read."
  10666. (interactive "P")
  10667. (gnus-summary-catchup-and-exit t quietly))
  10668. (defun gnus-summary-catchup-and-goto-next-group (&optional all)
  10669. "Mark all articles in this group as read and select the next group.
  10670. If given a prefix, mark all articles, unread as well as ticked, as
  10671. read."
  10672. (interactive "P")
  10673. (save-excursion
  10674. (gnus-summary-catchup all))
  10675. (gnus-summary-next-group))
  10676. (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
  10677. "Mark all articles in this group as read and select the previous group.
  10678. If given a prefix, mark all articles, unread as well as ticked, as
  10679. read."
  10680. (interactive "P")
  10681. (save-excursion
  10682. (gnus-summary-catchup all))
  10683. (gnus-summary-next-group nil nil t))
  10684. ;;;
  10685. ;;; with article
  10686. ;;;
  10687. (defmacro gnus-with-article (article &rest forms)
  10688. "Select ARTICLE and perform FORMS in the original article buffer.
  10689. Then replace the article with the result."
  10690. `(progn
  10691. ;; We don't want the article to be marked as read.
  10692. (let (gnus-mark-article-hook)
  10693. (gnus-summary-select-article t t nil ,article))
  10694. (set-buffer gnus-original-article-buffer)
  10695. ,@forms
  10696. (if (not (gnus-check-backend-function
  10697. 'request-replace-article (car gnus-article-current)))
  10698. (gnus-message 5 "Read-only group; not replacing")
  10699. (unless (gnus-request-replace-article
  10700. ,article (car gnus-article-current)
  10701. (current-buffer) t)
  10702. (error "Couldn't replace article")))
  10703. ;; The cache and backlog have to be flushed somewhat.
  10704. (when gnus-keep-backlog
  10705. (gnus-backlog-remove-article
  10706. (car gnus-article-current) (cdr gnus-article-current)))
  10707. (when gnus-use-cache
  10708. (gnus-cache-update-article
  10709. (car gnus-article-current) (cdr gnus-article-current)))))
  10710. (put 'gnus-with-article 'lisp-indent-function 1)
  10711. (put 'gnus-with-article 'edebug-form-spec '(form body))
  10712. ;; Thread-based commands.
  10713. (defun gnus-summary-articles-in-thread (&optional article)
  10714. "Return a list of all articles in the current thread.
  10715. If ARTICLE is non-nil, return all articles in the thread that starts
  10716. with that article."
  10717. (let* ((article (or article (gnus-summary-article-number)))
  10718. (data (gnus-data-find-list article))
  10719. (top-level (gnus-data-level (car data)))
  10720. (top-subject
  10721. (cond ((null gnus-thread-operation-ignore-subject)
  10722. (gnus-simplify-subject-re
  10723. (mail-header-subject (gnus-data-header (car data)))))
  10724. ((eq gnus-thread-operation-ignore-subject 'fuzzy)
  10725. (gnus-simplify-subject-fuzzy
  10726. (mail-header-subject (gnus-data-header (car data)))))
  10727. (t nil)))
  10728. (end-point (save-excursion
  10729. (goto-char (gnus-data-pos (car data)))
  10730. (if (gnus-summary-go-to-next-thread)
  10731. (point) (point-max))))
  10732. articles)
  10733. (while (and data
  10734. (< (gnus-data-pos (car data)) end-point))
  10735. (when (or (not top-subject)
  10736. (string= top-subject
  10737. (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
  10738. (gnus-simplify-subject-fuzzy
  10739. (mail-header-subject
  10740. (gnus-data-header (car data))))
  10741. (gnus-simplify-subject-re
  10742. (mail-header-subject
  10743. (gnus-data-header (car data)))))))
  10744. (push (gnus-data-number (car data)) articles))
  10745. (unless (and (setq data (cdr data))
  10746. (> (gnus-data-level (car data)) top-level))
  10747. (setq data nil)))
  10748. ;; Return the list of articles.
  10749. (nreverse articles)))
  10750. (defun gnus-summary-rethread-current ()
  10751. "Rethread the thread the current article is part of."
  10752. (interactive)
  10753. (let* ((gnus-show-threads t)
  10754. (article (gnus-summary-article-number))
  10755. (id (mail-header-id (gnus-summary-article-header)))
  10756. (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
  10757. (unless id
  10758. (error "No article on the current line"))
  10759. (gnus-rebuild-thread id)
  10760. (gnus-summary-goto-subject article)))
  10761. (defun gnus-summary-reparent-thread ()
  10762. "Make the current article child of the marked (or previous) article.
  10763. Note that the re-threading will only work if `gnus-thread-ignore-subject'
  10764. is non-nil or the Subject: of both articles are the same."
  10765. (interactive)
  10766. (unless (not (gnus-group-read-only-p))
  10767. (error "The current newsgroup does not support article editing"))
  10768. (unless (<= (length gnus-newsgroup-processable) 1)
  10769. (error "No more than one article may be marked"))
  10770. (let ((child (gnus-summary-article-number))
  10771. ;; First grab the marked article, otherwise one line up.
  10772. (parent (if (not (null gnus-newsgroup-processable))
  10773. (car gnus-newsgroup-processable)
  10774. (save-excursion
  10775. (if (eq (forward-line -1) 0)
  10776. (gnus-summary-article-number)
  10777. (error "Beginning of summary buffer"))))))
  10778. (gnus-summary-reparent-children parent (list child))))
  10779. (defun gnus-summary-reparent-children (parent children)
  10780. "Make PARENT the parent of CHILDREN.
  10781. When called interactively, PARENT is the current article and CHILDREN
  10782. are the process-marked articles."
  10783. (interactive
  10784. (list (gnus-summary-article-number)
  10785. (gnus-summary-work-articles nil)))
  10786. (dolist (child children)
  10787. (save-window-excursion
  10788. (let ((gnus-article-buffer " *reparent*"))
  10789. (unless (not (eq parent child))
  10790. (error "An article may not be self-referential"))
  10791. (let ((message-id (mail-header-id
  10792. (gnus-summary-article-header parent))))
  10793. (unless (and message-id (not (equal message-id "")))
  10794. (error "No message-id in desired parent"))
  10795. (gnus-with-article child
  10796. (save-restriction
  10797. (goto-char (point-min))
  10798. (message-narrow-to-head)
  10799. (if (re-search-forward "^References: " nil t)
  10800. (progn
  10801. (re-search-forward "^[^ \t]" nil t)
  10802. (forward-line -1)
  10803. (end-of-line)
  10804. (insert " " message-id))
  10805. (insert "References: " message-id "\n"))))
  10806. (set-buffer gnus-summary-buffer)
  10807. (gnus-summary-unmark-all-processable)
  10808. (gnus-summary-update-article child)
  10809. (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
  10810. (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
  10811. (gnus-summary-rethread-current)
  10812. (gnus-message 3 "Article %d is now the child of article %d"
  10813. child parent))))))
  10814. (defun gnus-summary-toggle-threads (&optional arg)
  10815. "Toggle showing conversation threads.
  10816. If ARG is positive number, turn showing conversation threads on."
  10817. (interactive "P")
  10818. (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
  10819. (setq gnus-show-threads
  10820. (if (null arg) (not gnus-show-threads)
  10821. (> (prefix-numeric-value arg) 0)))
  10822. (gnus-summary-prepare)
  10823. (gnus-summary-goto-subject current)
  10824. (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
  10825. (gnus-summary-position-point)))
  10826. (defun gnus-summary-show-all-threads ()
  10827. "Show all threads."
  10828. (interactive)
  10829. (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
  10830. (gnus-summary-position-point))
  10831. (defsubst gnus-summary--inv (p)
  10832. (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
  10833. (defun gnus-summary-show-thread ()
  10834. "Show thread subtrees.
  10835. Returns nil if no thread was there to be shown."
  10836. (interactive)
  10837. (let* ((orig (point))
  10838. (end (point-at-eol))
  10839. (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
  10840. ;; Leave point at bol
  10841. (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
  10842. (eoi (when end
  10843. (if (fboundp 'next-single-char-property-change)
  10844. ;; Note: XEmacs version of n-s-c-p-c may return nil
  10845. (or (next-single-char-property-change end 'invisible)
  10846. (point-max))
  10847. (while (progn
  10848. (end-of-line 2)
  10849. (and (not (eobp))
  10850. (eq (get-char-property (point) 'invisible)
  10851. 'gnus-sum))))
  10852. (point)))))
  10853. (when eoi
  10854. (remove-overlays beg eoi 'invisible 'gnus-sum)
  10855. (goto-char orig)
  10856. (gnus-summary-position-point)
  10857. eoi)))
  10858. (defun gnus-summary-maybe-hide-threads ()
  10859. "If requested, hide the threads that should be hidden."
  10860. (when (and gnus-show-threads
  10861. gnus-thread-hide-subtree)
  10862. (gnus-summary-hide-all-threads
  10863. (if (or (consp gnus-thread-hide-subtree)
  10864. (functionp gnus-thread-hide-subtree))
  10865. (gnus-make-predicate gnus-thread-hide-subtree)
  10866. nil))))
  10867. ;;; Hiding predicates.
  10868. (defun gnus-article-unread-p (header)
  10869. (memq (mail-header-number header) gnus-newsgroup-unreads))
  10870. (defun gnus-article-unseen-p (header)
  10871. (memq (mail-header-number header) gnus-newsgroup-unseen))
  10872. (defun gnus-map-articles (predicate articles)
  10873. "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
  10874. (apply 'gnus-or (mapcar predicate
  10875. (mapcar (lambda (number)
  10876. (gnus-summary-article-header number))
  10877. articles))))
  10878. (defun gnus-summary-hide-all-threads (&optional predicate)
  10879. "Hide all thread subtrees.
  10880. If PREDICATE is supplied, threads that satisfy this predicate
  10881. will not be hidden."
  10882. (interactive)
  10883. (save-excursion
  10884. (goto-char (point-min))
  10885. (let ((end nil)
  10886. (count 0))
  10887. (while (not end)
  10888. (incf count)
  10889. (when (zerop (mod count 1000))
  10890. (message "Hiding all threads... %d" count))
  10891. (when (or (not predicate)
  10892. (gnus-map-articles
  10893. predicate (gnus-summary-article-children)))
  10894. (gnus-summary-hide-thread))
  10895. (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
  10896. (gnus-summary-position-point))
  10897. (defun gnus-summary-hide-thread ()
  10898. "Hide thread subtrees.
  10899. If PREDICATE is supplied, threads that satisfy this predicate
  10900. will not be hidden.
  10901. Returns nil if no threads were there to be hidden."
  10902. (interactive)
  10903. (beginning-of-line)
  10904. (let ((start (point))
  10905. (starteol (line-end-position))
  10906. (article (gnus-summary-article-number)))
  10907. ;; Go forward until either the buffer ends or the subthread ends.
  10908. (when (and (not (eobp))
  10909. (or (zerop (gnus-summary-next-thread 1 t))
  10910. (goto-char (point-max))))
  10911. (if (and (> (point) start)
  10912. ;; FIXME: this should actually search for a non-invisible \n.
  10913. (search-backward "\n" start t))
  10914. (progn
  10915. (when (> (point) starteol)
  10916. (remove-overlays starteol (point) 'invisible 'gnus-sum)
  10917. (let ((ol (make-overlay starteol (point) nil t nil)))
  10918. (overlay-put ol 'invisible 'gnus-sum)
  10919. (overlay-put ol 'evaporate t)))
  10920. (gnus-summary-goto-subject article)
  10921. (when (> start (point))
  10922. (message "Hiding the thread moved us backwards, aborting!")
  10923. (goto-char (point-max))))
  10924. (goto-char start)
  10925. nil))))
  10926. (defun gnus-summary-go-to-next-thread (&optional previous)
  10927. "Go to the same level (or less) next thread.
  10928. If PREVIOUS is non-nil, go to previous thread instead.
  10929. Return the article number moved to, or nil if moving was impossible."
  10930. (let ((level (gnus-summary-thread-level))
  10931. (way (if previous -1 1))
  10932. (beg (point)))
  10933. (forward-line way)
  10934. (while (and (not (eobp))
  10935. (< level (gnus-summary-thread-level)))
  10936. (forward-line way))
  10937. (if (eobp)
  10938. (progn
  10939. (goto-char beg)
  10940. nil)
  10941. (setq beg (point))
  10942. (prog1
  10943. (gnus-summary-article-number)
  10944. (goto-char beg)))))
  10945. (defun gnus-summary-next-thread (n &optional silent)
  10946. "Go to the same level next N'th thread.
  10947. If N is negative, search backward instead.
  10948. Returns the difference between N and the number of skips actually
  10949. done.
  10950. If SILENT, don't output messages."
  10951. (interactive "p")
  10952. (let ((backward (< n 0))
  10953. (n (abs n)))
  10954. (while (and (> n 0)
  10955. (gnus-summary-go-to-next-thread backward))
  10956. (decf n))
  10957. (unless silent
  10958. (gnus-summary-position-point))
  10959. (when (and (not silent) (/= 0 n))
  10960. (gnus-message 7 "No more threads"))
  10961. n))
  10962. (defun gnus-summary-prev-thread (n)
  10963. "Go to the same level previous N'th thread.
  10964. Returns the difference between N and the number of skips actually
  10965. done."
  10966. (interactive "p")
  10967. (gnus-summary-next-thread (- n)))
  10968. (defun gnus-summary-go-down-thread ()
  10969. "Go down one level in the current thread."
  10970. (let ((children (gnus-summary-article-children)))
  10971. (when children
  10972. (gnus-summary-goto-subject (car children)))))
  10973. (defun gnus-summary-go-up-thread ()
  10974. "Go up one level in the current thread."
  10975. (let ((parent (gnus-summary-article-parent)))
  10976. (when parent
  10977. (gnus-summary-goto-subject parent))))
  10978. (defun gnus-summary-down-thread (n)
  10979. "Go down thread N steps.
  10980. If N is negative, go up instead.
  10981. Returns the difference between N and how many steps down that were
  10982. taken."
  10983. (interactive "p")
  10984. (let ((up (< n 0))
  10985. (n (abs n)))
  10986. (while (and (> n 0)
  10987. (if up (gnus-summary-go-up-thread)
  10988. (gnus-summary-go-down-thread)))
  10989. (setq n (1- n)))
  10990. (gnus-summary-position-point)
  10991. (when (/= 0 n)
  10992. (gnus-message 7 "Can't go further"))
  10993. n))
  10994. (defun gnus-summary-up-thread (n)
  10995. "Go up thread N steps.
  10996. If N is negative, go down instead.
  10997. Returns the difference between N and how many steps down that were
  10998. taken."
  10999. (interactive "p")
  11000. (gnus-summary-down-thread (- n)))
  11001. (defun gnus-summary-top-thread ()
  11002. "Go to the top of the thread."
  11003. (interactive)
  11004. (while (gnus-summary-go-up-thread))
  11005. (gnus-summary-article-number))
  11006. (defun gnus-summary-expire-thread ()
  11007. "Mark articles under current thread as expired."
  11008. (interactive)
  11009. (gnus-summary-kill-thread 0))
  11010. (defun gnus-summary-kill-thread (&optional unmark)
  11011. "Mark articles under current thread as read.
  11012. If the prefix argument is positive, remove any kinds of marks.
  11013. If the prefix argument is zero, mark thread as expired.
  11014. If the prefix argument is negative, tick articles instead."
  11015. (interactive "P")
  11016. (when unmark
  11017. (setq unmark (prefix-numeric-value unmark)))
  11018. (let ((articles (gnus-summary-articles-in-thread))
  11019. (hide (or (null unmark) (= unmark 0))))
  11020. (save-excursion
  11021. ;; Expand the thread.
  11022. (gnus-summary-show-thread)
  11023. ;; Mark all the articles.
  11024. (while articles
  11025. (gnus-summary-goto-subject (car articles))
  11026. (cond ((null unmark)
  11027. (gnus-summary-mark-article-as-read gnus-killed-mark))
  11028. ((> unmark 0)
  11029. (gnus-summary-mark-article-as-unread gnus-unread-mark))
  11030. ((= unmark 0)
  11031. (gnus-summary-mark-article nil gnus-expirable-mark))
  11032. (t
  11033. (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
  11034. (setq articles (cdr articles))))
  11035. ;; Hide killed subtrees when hide is true.
  11036. (and hide
  11037. gnus-thread-hide-killed
  11038. (gnus-summary-hide-thread))
  11039. ;; If hide is t, go to next unread subject.
  11040. (when hide
  11041. ;; Go to next unread subject.
  11042. (gnus-summary-next-subject 1 t)))
  11043. (gnus-set-mode-line 'summary))
  11044. ;; Summary sorting commands
  11045. (defun gnus-summary-sort-by-number (&optional reverse)
  11046. "Sort the summary buffer by article number.
  11047. Argument REVERSE means reverse order."
  11048. (interactive "P")
  11049. (gnus-summary-sort 'number reverse))
  11050. (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
  11051. "Sort the summary buffer by most recent article number.
  11052. Argument REVERSE means reverse order."
  11053. (interactive "P")
  11054. (gnus-summary-sort 'most-recent-number reverse))
  11055. (defun gnus-summary-sort-by-random (&optional reverse)
  11056. "Randomize the order in the summary buffer.
  11057. Argument REVERSE means to randomize in reverse order."
  11058. (interactive "P")
  11059. (gnus-summary-sort 'random reverse))
  11060. (defun gnus-summary-sort-by-author (&optional reverse)
  11061. "Sort the summary buffer by author name alphabetically.
  11062. If `case-fold-search' is non-nil, case of letters is ignored.
  11063. Argument REVERSE means reverse order."
  11064. (interactive "P")
  11065. (gnus-summary-sort 'author reverse))
  11066. (defun gnus-summary-sort-by-recipient (&optional reverse)
  11067. "Sort the summary buffer by recipient name alphabetically.
  11068. If `case-fold-search' is non-nil, case of letters is ignored.
  11069. Argument REVERSE means reverse order."
  11070. (interactive "P")
  11071. (gnus-summary-sort 'recipient reverse))
  11072. (defun gnus-summary-sort-by-subject (&optional reverse)
  11073. "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
  11074. If `case-fold-search' is non-nil, case of letters is ignored.
  11075. Argument REVERSE means reverse order."
  11076. (interactive "P")
  11077. (gnus-summary-sort 'subject reverse))
  11078. (defun gnus-summary-sort-by-date (&optional reverse)
  11079. "Sort the summary buffer by date.
  11080. Argument REVERSE means reverse order."
  11081. (interactive "P")
  11082. (gnus-summary-sort 'date reverse))
  11083. (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
  11084. "Sort the summary buffer by most recent date.
  11085. Argument REVERSE means reverse order."
  11086. (interactive "P")
  11087. (gnus-summary-sort 'most-recent-date reverse))
  11088. (defun gnus-summary-sort-by-score (&optional reverse)
  11089. "Sort the summary buffer by score.
  11090. Argument REVERSE means reverse order."
  11091. (interactive "P")
  11092. (gnus-summary-sort 'score reverse))
  11093. (defun gnus-summary-sort-by-lines (&optional reverse)
  11094. "Sort the summary buffer by the number of lines.
  11095. Argument REVERSE means reverse order."
  11096. (interactive "P")
  11097. (gnus-summary-sort 'lines reverse))
  11098. (defun gnus-summary-sort-by-chars (&optional reverse)
  11099. "Sort the summary buffer by article length.
  11100. Argument REVERSE means reverse order."
  11101. (interactive "P")
  11102. (gnus-summary-sort 'chars reverse))
  11103. (defun gnus-summary-sort-by-original (&optional reverse)
  11104. "Sort the summary buffer using the default sorting method.
  11105. Argument REVERSE means reverse order."
  11106. (interactive "P")
  11107. (let* ((inhibit-read-only t)
  11108. (gnus-summary-prepare-hook nil))
  11109. ;; We do the sorting by regenerating the threads.
  11110. (gnus-summary-prepare)
  11111. ;; Hide subthreads if needed.
  11112. (gnus-summary-maybe-hide-threads)))
  11113. (defun gnus-summary-sort (predicate reverse)
  11114. "Sort summary buffer by PREDICATE. REVERSE means reverse order."
  11115. (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
  11116. (article (intern (format "gnus-article-sort-by-%s" predicate)))
  11117. (gnus-thread-sort-functions
  11118. (if (not reverse)
  11119. thread
  11120. `(lambda (t1 t2)
  11121. (,thread t2 t1))))
  11122. (gnus-sort-gathered-threads-function
  11123. gnus-thread-sort-functions)
  11124. (gnus-article-sort-functions
  11125. (if (not reverse)
  11126. article
  11127. `(lambda (t1 t2)
  11128. (,article t2 t1))))
  11129. (inhibit-read-only t)
  11130. (gnus-summary-prepare-hook nil))
  11131. ;; We do the sorting by regenerating the threads.
  11132. (gnus-summary-prepare)
  11133. ;; Hide subthreads if needed.
  11134. (gnus-summary-maybe-hide-threads)))
  11135. ;; Summary saving commands.
  11136. (defun gnus-summary-save-article (&optional n not-saved)
  11137. "Save the current article using the default saver function.
  11138. If N is a positive number, save the N next articles.
  11139. If N is a negative number, save the N previous articles.
  11140. If N is nil and any articles have been marked with the process mark,
  11141. save those articles instead.
  11142. The variable `gnus-default-article-saver' specifies the saver function.
  11143. If the optional second argument NOT-SAVED is non-nil, articles saved
  11144. will not be marked as saved."
  11145. (interactive "P")
  11146. (require 'gnus-art)
  11147. (let* ((articles (gnus-summary-work-articles n))
  11148. (save-buffer (save-excursion
  11149. (nnheader-set-temp-buffer " *Gnus Save*")))
  11150. (num (length articles))
  11151. ;; Whether to save decoded articles or raw articles.
  11152. (decode (when gnus-article-save-coding-system
  11153. (get gnus-default-article-saver :decode)))
  11154. ;; When saving many articles in a single file, use the other
  11155. ;; function to save articles other than the first one.
  11156. (saver2 (get gnus-default-article-saver :function))
  11157. (gnus-prompt-before-saving (if saver2
  11158. t
  11159. gnus-prompt-before-saving))
  11160. (gnus-default-article-saver gnus-default-article-saver)
  11161. header file)
  11162. (dolist (article articles)
  11163. (setq header (gnus-summary-article-header article))
  11164. (if (not (vectorp header))
  11165. ;; This is a pseudo-article.
  11166. (if (assq 'name header)
  11167. (gnus-copy-file (cdr (assq 'name header)))
  11168. (gnus-message 1 "Article %d is unsavable" article))
  11169. ;; This is a real article.
  11170. (save-window-excursion
  11171. (gnus-summary-select-article decode decode nil article)
  11172. (gnus-summary-goto-subject article))
  11173. (with-current-buffer save-buffer
  11174. (erase-buffer)
  11175. (insert-buffer-substring (if decode
  11176. gnus-article-buffer
  11177. gnus-original-article-buffer)))
  11178. (setq file (gnus-article-save save-buffer file num))
  11179. (gnus-summary-remove-process-mark article)
  11180. (unless not-saved
  11181. (gnus-summary-set-saved-mark article)))
  11182. (when saver2
  11183. (setq gnus-default-article-saver saver2
  11184. saver2 nil)))
  11185. (gnus-kill-buffer save-buffer)
  11186. (gnus-summary-position-point)
  11187. (gnus-set-mode-line 'summary)
  11188. n))
  11189. (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
  11190. (defun gnus-summary-pipe-output (&optional n sym)
  11191. "Pipe the current article to a subprocess.
  11192. If N is a positive number, pipe the N next articles.
  11193. If N is a negative number, pipe the N previous articles.
  11194. If N is nil and any articles have been marked with the process mark,
  11195. pipe those articles instead.
  11196. The default command to which articles are piped is specified by the
  11197. variable `gnus-summary-pipe-output-default-command'; if it is nil, you
  11198. will be prompted for the command.
  11199. The properties `:decode' and `:headers' that are put to the function
  11200. symbol `gnus-summary-save-in-pipe' control whether this function
  11201. decodes articles and what headers to keep (see the doc string for the
  11202. `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
  11203. is neither omitted nor the symbol `r', force including all headers
  11204. regardless of the `:headers' property. If it is the symbol `r',
  11205. articles that are not decoded and include all headers will be piped
  11206. no matter what the properties `:decode' and `:headers' are."
  11207. (interactive (gnus-interactive "P\ny"))
  11208. (require 'gnus-art)
  11209. (let* ((articles (gnus-summary-work-articles n))
  11210. (result-buffer "*Shell Command Output*")
  11211. (all-headers (not (memq sym '(nil r))))
  11212. (gnus-save-all-headers (or all-headers gnus-save-all-headers))
  11213. (raw (eq sym 'r))
  11214. (headers (get 'gnus-summary-save-in-pipe :headers))
  11215. command result)
  11216. (unless (numberp (car articles))
  11217. (error "No article to pipe"))
  11218. (setq command (gnus-read-shell-command
  11219. (concat "Shell command on "
  11220. (if (cdr articles)
  11221. (format "these %d articles" (length articles))
  11222. "this article")
  11223. ": ")
  11224. gnus-summary-pipe-output-default-command))
  11225. (when (string-equal command "")
  11226. (error "A command is required"))
  11227. (when all-headers
  11228. (put 'gnus-summary-save-in-pipe :headers nil))
  11229. (unwind-protect
  11230. (while articles
  11231. (gnus-summary-goto-subject (pop articles))
  11232. (save-window-excursion (gnus-summary-save-in-pipe command raw))
  11233. (when (and (get-buffer result-buffer)
  11234. (not (zerop (buffer-size (get-buffer result-buffer)))))
  11235. (setq result (concat result (with-current-buffer result-buffer
  11236. (buffer-string))))))
  11237. (put 'gnus-summary-save-in-pipe :headers headers))
  11238. (unless (zerop (length result))
  11239. (if (with-current-buffer (get-buffer-create result-buffer)
  11240. (erase-buffer)
  11241. (insert result)
  11242. (prog1
  11243. (and (= (count-lines (point-min) (point)) 1)
  11244. (progn
  11245. (end-of-line 0)
  11246. (<= (current-column)
  11247. (window-width (minibuffer-window)))))
  11248. (goto-char (point-min))))
  11249. (message "%s" (substring result 0 -1))
  11250. (message nil)
  11251. (gnus-configure-windows 'pipe)))))
  11252. (defun gnus-summary-save-article-mail (&optional arg)
  11253. "Append the current article to a Unix mail box file.
  11254. If N is a positive number, save the N next articles.
  11255. If N is a negative number, save the N previous articles.
  11256. If N is nil and any articles have been marked with the process mark,
  11257. save those articles instead."
  11258. (interactive "P")
  11259. (require 'gnus-art)
  11260. (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
  11261. (gnus-summary-save-article arg)))
  11262. (defun gnus-summary-save-article-rmail (&optional arg)
  11263. "Append the current article to an rmail file.
  11264. If N is a positive number, save the N next articles.
  11265. If N is a negative number, save the N previous articles.
  11266. If N is nil and any articles have been marked with the process mark,
  11267. save those articles instead."
  11268. (interactive "P")
  11269. (require 'gnus-art)
  11270. (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
  11271. (gnus-summary-save-article arg)))
  11272. (defun gnus-summary-save-article-file (&optional arg)
  11273. "Append the current article to a file.
  11274. If N is a positive number, save the N next articles.
  11275. If N is a negative number, save the N previous articles.
  11276. If N is nil and any articles have been marked with the process mark,
  11277. save those articles instead."
  11278. (interactive "P")
  11279. (require 'gnus-art)
  11280. (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
  11281. (gnus-summary-save-article arg)))
  11282. (defun gnus-summary-write-article-file (&optional arg)
  11283. "Write the current article to a file, deleting the previous file.
  11284. If N is a positive number, save the N next articles.
  11285. If N is a negative number, save the N previous articles.
  11286. If N is nil and any articles have been marked with the process mark,
  11287. save those articles instead."
  11288. (interactive "P")
  11289. (require 'gnus-art)
  11290. (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
  11291. (gnus-summary-save-article arg)))
  11292. (defun gnus-summary-save-article-body-file (&optional arg)
  11293. "Append the current article body to a file.
  11294. If N is a positive number, save the N next articles.
  11295. If N is a negative number, save the N previous articles.
  11296. If N is nil and any articles have been marked with the process mark,
  11297. save those articles instead."
  11298. (interactive "P")
  11299. (require 'gnus-art)
  11300. (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
  11301. (gnus-summary-save-article arg)))
  11302. (defun gnus-summary-write-article-body-file (&optional arg)
  11303. "Write the current article body to a file, deleting the previous file.
  11304. If N is a positive number, save the N next articles.
  11305. If N is a negative number, save the N previous articles.
  11306. If N is nil and any articles have been marked with the process mark,
  11307. save those articles instead."
  11308. (interactive "P")
  11309. (require 'gnus-art)
  11310. (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
  11311. (gnus-summary-save-article arg)))
  11312. (defun gnus-summary-muttprint (&optional arg)
  11313. "Print the current article using Muttprint.
  11314. If N is a positive number, save the N next articles.
  11315. If N is a negative number, save the N previous articles.
  11316. If N is nil and any articles have been marked with the process mark,
  11317. save those articles instead."
  11318. (interactive "P")
  11319. (require 'gnus-art)
  11320. (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
  11321. (gnus-summary-save-article arg t)))
  11322. (defun gnus-summary-pipe-message (program)
  11323. "Pipe the current article through PROGRAM."
  11324. (interactive "sProgram: ")
  11325. (gnus-summary-select-article)
  11326. (let ((mail-header-separator ""))
  11327. (gnus-eval-in-buffer-window gnus-article-buffer
  11328. (save-restriction
  11329. (widen)
  11330. (let ((start (window-start))
  11331. (inhibit-read-only t))
  11332. (message-pipe-buffer-body program)
  11333. (set-window-start (get-buffer-window (current-buffer)) start))))))
  11334. (defun gnus-get-split-value (methods)
  11335. "Return a value based on the split METHODS."
  11336. (let (split-name method result match)
  11337. (when methods
  11338. (with-current-buffer gnus-original-article-buffer
  11339. (save-restriction
  11340. (nnheader-narrow-to-headers)
  11341. (while (and methods (not split-name))
  11342. (goto-char (point-min))
  11343. (setq method (pop methods))
  11344. (setq match (car method))
  11345. (when (cond
  11346. ((stringp match)
  11347. ;; Regular expression.
  11348. (ignore-errors
  11349. (re-search-forward match nil t)))
  11350. ((functionp match)
  11351. ;; Function.
  11352. (save-restriction
  11353. (widen)
  11354. (setq result (funcall match gnus-newsgroup-name))))
  11355. ((consp match)
  11356. ;; Form.
  11357. (save-restriction
  11358. (widen)
  11359. (setq result (eval match)))))
  11360. (setq split-name (cdr method))
  11361. (cond ((stringp result)
  11362. (push (expand-file-name
  11363. result gnus-article-save-directory)
  11364. split-name))
  11365. ((consp result)
  11366. (setq split-name (append result split-name)))))))))
  11367. (nreverse split-name)))
  11368. (defun gnus-valid-move-group-p (group)
  11369. (and (symbolp group)
  11370. (boundp group)
  11371. (symbol-name group)
  11372. (symbol-value group)
  11373. (gnus-get-function (gnus-find-method-for-group
  11374. (symbol-name group)) 'request-accept-article t)))
  11375. (defun gnus-read-move-group-name (prompt default articles prefix)
  11376. "Read a group name."
  11377. (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
  11378. (minibuffer-confirm-incomplete nil) ; XEmacs
  11379. (prom
  11380. (format "%s %s to"
  11381. prompt
  11382. (if (> (length articles) 1)
  11383. (format "these %d articles" (length articles))
  11384. "this article")))
  11385. (to-newsgroup
  11386. (cond
  11387. ((null split-name)
  11388. (gnus-group-completing-read
  11389. prom
  11390. (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
  11391. nil prefix nil default))
  11392. ((= 1 (length split-name))
  11393. (gnus-group-completing-read
  11394. prom
  11395. (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
  11396. nil prefix 'gnus-group-history (car split-name)))
  11397. (t
  11398. (gnus-completing-read
  11399. prom (nreverse split-name) nil nil 'gnus-group-history))))
  11400. (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
  11401. encoded)
  11402. (when to-newsgroup
  11403. (if (or (string= to-newsgroup "")
  11404. (string= to-newsgroup prefix))
  11405. (setq to-newsgroup default))
  11406. (unless to-newsgroup
  11407. (error "No group name entered"))
  11408. (setq encoded (mm-encode-coding-string
  11409. to-newsgroup
  11410. (gnus-group-name-charset to-method to-newsgroup)))
  11411. (or (gnus-active encoded)
  11412. (gnus-activate-group encoded nil nil to-method)
  11413. (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
  11414. to-newsgroup))
  11415. (or (and (gnus-request-create-group encoded to-method)
  11416. (gnus-activate-group encoded nil nil to-method)
  11417. (gnus-subscribe-group encoded))
  11418. (error "Couldn't create group %s" to-newsgroup)))
  11419. (error "No such group: %s" to-newsgroup))
  11420. encoded)))
  11421. (defvar gnus-summary-save-parts-counter)
  11422. (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
  11423. (defun gnus-summary-save-parts (type dir n &optional reverse)
  11424. "Save parts matching TYPE to DIR.
  11425. If REVERSE, save parts that do not match TYPE."
  11426. (interactive
  11427. (list (read-string "Save parts of type: "
  11428. (or (car gnus-summary-save-parts-type-history)
  11429. gnus-summary-save-parts-default-mime)
  11430. 'gnus-summary-save-parts-type-history)
  11431. (setq gnus-summary-save-parts-last-directory
  11432. (read-directory-name "Save to directory: "
  11433. gnus-summary-save-parts-last-directory
  11434. nil t))
  11435. current-prefix-arg))
  11436. (gnus-summary-iterate n
  11437. (let ((gnus-display-mime-function nil)
  11438. gnus-article-prepare-hook
  11439. gnus-article-decode-hook
  11440. gnus-display-mime-function
  11441. gnus-break-pages
  11442. (gnus-inhibit-treatment t))
  11443. (gnus-summary-select-article))
  11444. (with-current-buffer gnus-article-buffer
  11445. (let ((handles (or gnus-article-mime-handles
  11446. (mm-dissect-buffer nil gnus-article-loose-mime)
  11447. (and gnus-article-emulate-mime
  11448. (mm-uu-dissect))))
  11449. (gnus-summary-save-parts-counter 1))
  11450. (when handles
  11451. (gnus-summary-save-parts-1 type dir handles reverse)
  11452. (unless gnus-article-mime-handles ;; Don't destroy this case.
  11453. (mm-destroy-parts handles)))))))
  11454. (defun gnus-summary-save-parts-1 (type dir handle reverse)
  11455. (if (stringp (car handle))
  11456. (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
  11457. (cdr handle))
  11458. (when (if reverse
  11459. (not (string-match type (mm-handle-media-type handle)))
  11460. (string-match type (mm-handle-media-type handle)))
  11461. (let ((file (expand-file-name
  11462. (gnus-map-function
  11463. mm-file-name-rewrite-functions
  11464. (file-name-nondirectory
  11465. (or
  11466. (mm-handle-filename handle)
  11467. (format "%s.%d.%d" gnus-newsgroup-name
  11468. (cdr gnus-article-current)
  11469. gnus-summary-save-parts-counter))))
  11470. dir)))
  11471. (incf gnus-summary-save-parts-counter)
  11472. (unless (file-exists-p file)
  11473. (mm-save-part-to-file handle file))))))
  11474. ;; Summary extract commands
  11475. (defun gnus-summary-insert-pseudos (pslist &optional not-view)
  11476. (let ((inhibit-read-only t)
  11477. (article (gnus-summary-article-number))
  11478. after-article b e)
  11479. (unless (gnus-summary-goto-subject article)
  11480. (error "No such article: %d" article))
  11481. (gnus-summary-position-point)
  11482. ;; If all commands are to be bunched up on one line, we collect
  11483. ;; them here.
  11484. (unless gnus-view-pseudos-separately
  11485. (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
  11486. files action)
  11487. (while ps
  11488. (setq action (cdr (assq 'action (car ps))))
  11489. (setq files (list (cdr (assq 'name (car ps)))))
  11490. (while (and ps (cdr ps)
  11491. (string= (or action "1")
  11492. (or (cdr (assq 'action (cadr ps))) "2")))
  11493. (push (cdr (assq 'name (cadr ps))) files)
  11494. (setcdr ps (cddr ps)))
  11495. (when files
  11496. (when (not (string-match "%s" action))
  11497. (push " " files))
  11498. (push " " files)
  11499. (when (assq 'execute (car ps))
  11500. (setcdr (assq 'execute (car ps))
  11501. (funcall (if (string-match "%s" action)
  11502. 'format 'concat)
  11503. action
  11504. (mapconcat
  11505. (lambda (f)
  11506. (if (equal f " ")
  11507. f
  11508. (shell-quote-argument f)))
  11509. files " ")))))
  11510. (setq ps (cdr ps)))))
  11511. (if (and gnus-view-pseudos (not not-view))
  11512. (while pslist
  11513. (when (assq 'execute (car pslist))
  11514. (gnus-execute-command (cdr (assq 'execute (car pslist)))
  11515. (eq gnus-view-pseudos 'not-confirm)))
  11516. (setq pslist (cdr pslist)))
  11517. (save-excursion
  11518. (while pslist
  11519. (setq after-article (or (cdr (assq 'article (car pslist)))
  11520. (gnus-summary-article-number)))
  11521. (gnus-summary-goto-subject after-article)
  11522. (forward-line 1)
  11523. (setq b (point))
  11524. (insert " " (file-name-nondirectory
  11525. (cdr (assq 'name (car pslist))))
  11526. ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
  11527. (setq e (point))
  11528. (forward-line -1) ; back to `b'
  11529. (gnus-add-text-properties
  11530. b (1- e) (list 'gnus-number gnus-reffed-article-number
  11531. gnus-mouse-face-prop gnus-mouse-face))
  11532. (gnus-data-enter
  11533. after-article gnus-reffed-article-number
  11534. gnus-unread-mark b (car pslist) 0 (- e b))
  11535. (setq gnus-newsgroup-unreads
  11536. (gnus-add-to-sorted-list gnus-newsgroup-unreads
  11537. gnus-reffed-article-number))
  11538. (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
  11539. (setq pslist (cdr pslist)))))))
  11540. (defun gnus-pseudos< (p1 p2)
  11541. (let ((c1 (cdr (assq 'action p1)))
  11542. (c2 (cdr (assq 'action p2))))
  11543. (and c1 c2 (string< c1 c2))))
  11544. (defun gnus-request-pseudo-article (props)
  11545. (cond ((assq 'execute props)
  11546. (gnus-execute-command (cdr (assq 'execute props)))))
  11547. (let ((gnus-current-article (gnus-summary-article-number)))
  11548. (gnus-run-hooks 'gnus-mark-article-hook)))
  11549. (defun gnus-execute-command (command &optional automatic)
  11550. (save-excursion
  11551. (gnus-article-setup-buffer)
  11552. (set-buffer gnus-article-buffer)
  11553. (setq buffer-read-only nil)
  11554. (let ((command (if automatic command
  11555. (read-string "Command: " (cons command 0)))))
  11556. (erase-buffer)
  11557. (insert "$ " command "\n\n")
  11558. (if gnus-view-pseudo-asynchronously
  11559. (start-process "gnus-execute" (current-buffer) shell-file-name
  11560. shell-command-switch command)
  11561. (call-process shell-file-name nil t nil
  11562. shell-command-switch command)))))
  11563. ;; Summary kill commands.
  11564. (defun gnus-summary-edit-global-kill (article)
  11565. "Edit the \"global\" kill file."
  11566. (interactive (list (gnus-summary-article-number)))
  11567. (gnus-group-edit-global-kill article))
  11568. (defun gnus-summary-edit-local-kill ()
  11569. "Edit a local kill file applied to the current newsgroup."
  11570. (interactive)
  11571. (setq gnus-current-headers (gnus-summary-article-header))
  11572. (gnus-group-edit-local-kill
  11573. (gnus-summary-article-number) gnus-newsgroup-name))
  11574. ;;; Header reading.
  11575. (defun gnus-read-header (id &optional header)
  11576. "Read the headers of article ID and enter them into the Gnus system."
  11577. (let ((group gnus-newsgroup-name)
  11578. (gnus-override-method
  11579. (or
  11580. gnus-override-method
  11581. (and (gnus-news-group-p gnus-newsgroup-name)
  11582. (car (gnus-refer-article-methods)))))
  11583. where)
  11584. ;; First we check to see whether the header in question is already
  11585. ;; fetched.
  11586. (if (stringp id)
  11587. ;; This is a Message-ID.
  11588. (setq header (or header (gnus-id-to-header id)))
  11589. ;; This is an article number.
  11590. (setq header (or header (gnus-summary-article-header id))))
  11591. (if (and header
  11592. (not (gnus-summary-article-sparse-p (mail-header-number header))))
  11593. ;; We have found the header.
  11594. header
  11595. ;; We have to really fetch the header to this article.
  11596. (with-current-buffer nntp-server-buffer
  11597. (when (setq where (gnus-request-head id group))
  11598. (nnheader-fold-continuation-lines)
  11599. (goto-char (point-max))
  11600. (insert ".\n")
  11601. (goto-char (point-min))
  11602. (insert "211 ")
  11603. (princ (cond
  11604. ((numberp id) id)
  11605. ((cdr where) (cdr where))
  11606. (header (mail-header-number header))
  11607. (t gnus-reffed-article-number))
  11608. (current-buffer))
  11609. (insert " Article retrieved.\n"))
  11610. (if (or (not where)
  11611. (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
  11612. () ; Malformed head.
  11613. (unless (gnus-summary-article-sparse-p (mail-header-number header))
  11614. (when (and (bound-and-true-p gnus-registry-enabled)
  11615. (not (gnus-ephemeral-group-p (car where))))
  11616. (gnus-registry-handle-action
  11617. (mail-header-id header) nil
  11618. (gnus-group-prefixed-name
  11619. (car where)
  11620. (or gnus-override-method (gnus-find-method-for-group group)))
  11621. (mail-header-subject header)
  11622. (mail-header-from header)))
  11623. (when (and (stringp id)
  11624. (or
  11625. (not (string= (gnus-group-real-name group)
  11626. (car where)))
  11627. (not (gnus-server-equal gnus-override-method
  11628. (gnus-group-method group)))))
  11629. ;; If we fetched by Message-ID and the article came from
  11630. ;; a different group (or server), we fudge some bogus
  11631. ;; article numbers for this article.
  11632. (mail-header-set-number header gnus-reffed-article-number))
  11633. (with-current-buffer gnus-summary-buffer
  11634. (decf gnus-reffed-article-number)
  11635. (gnus-remove-header (mail-header-number header))
  11636. (push header gnus-newsgroup-headers)
  11637. (setq gnus-current-headers header)
  11638. (push (mail-header-number header) gnus-newsgroup-limit)))
  11639. header)))))
  11640. (defun gnus-remove-header (number)
  11641. "Remove header NUMBER from `gnus-newsgroup-headers'."
  11642. (if (and gnus-newsgroup-headers
  11643. (= number (mail-header-number (car gnus-newsgroup-headers))))
  11644. (pop gnus-newsgroup-headers)
  11645. (let ((headers gnus-newsgroup-headers))
  11646. (while (and (cdr headers)
  11647. (not (= number (mail-header-number (cadr headers)))))
  11648. (pop headers))
  11649. (when (cdr headers)
  11650. (setcdr headers (cddr headers))))))
  11651. ;;;
  11652. ;;; summary highlights
  11653. ;;;
  11654. (defun gnus-highlight-selected-summary ()
  11655. "Highlight selected article in summary buffer."
  11656. ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
  11657. (when gnus-summary-selected-face
  11658. (save-excursion
  11659. (let* ((beg (point-at-bol))
  11660. (end (point-at-eol))
  11661. ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
  11662. (from (if (get-text-property beg gnus-mouse-face-prop)
  11663. beg
  11664. (or (next-single-property-change
  11665. beg gnus-mouse-face-prop nil end)
  11666. beg)))
  11667. (to
  11668. (if (= from end)
  11669. (- from 2)
  11670. (or (next-single-property-change
  11671. from gnus-mouse-face-prop nil end)
  11672. end))))
  11673. ;; If no mouse-face prop on line we will have to = from = end,
  11674. ;; so we highlight the entire line instead.
  11675. (when (= (+ to 2) from)
  11676. (setq from beg)
  11677. (setq to end))
  11678. (if gnus-newsgroup-selected-overlay
  11679. ;; Move old overlay.
  11680. (move-overlay
  11681. gnus-newsgroup-selected-overlay from to (current-buffer))
  11682. ;; Create new overlay.
  11683. (overlay-put
  11684. (setq gnus-newsgroup-selected-overlay (make-overlay from to))
  11685. 'face gnus-summary-selected-face))))))
  11686. (defvar gnus-summary-highlight-line-cached nil)
  11687. (defvar gnus-summary-highlight-line-trigger nil)
  11688. (defun gnus-summary-highlight-line-0 ()
  11689. (if (and (eq gnus-summary-highlight-line-trigger
  11690. gnus-summary-highlight)
  11691. gnus-summary-highlight-line-cached)
  11692. gnus-summary-highlight-line-cached
  11693. (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
  11694. gnus-summary-highlight-line-cached
  11695. (let* ((cond (list 'cond))
  11696. (c cond)
  11697. (list gnus-summary-highlight))
  11698. (while list
  11699. (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
  11700. nil))
  11701. (setq c (cdr c)
  11702. list (cdr list)))
  11703. (gnus-byte-compile (list 'lambda nil cond))))))
  11704. (defun gnus-summary-highlight-line ()
  11705. "Highlight current line according to `gnus-summary-highlight'."
  11706. (let* ((beg (point-at-bol))
  11707. (article (or (gnus-summary-article-number) gnus-current-article))
  11708. (score (or (cdr (assq article
  11709. gnus-newsgroup-scored))
  11710. gnus-summary-default-score 0))
  11711. (mark (or (gnus-summary-article-mark) gnus-unread-mark))
  11712. (inhibit-read-only t)
  11713. (default gnus-summary-default-score)
  11714. (default-high gnus-summary-default-high-score)
  11715. (default-low gnus-summary-default-low-score)
  11716. (uncached (and gnus-summary-use-undownloaded-faces
  11717. (memq article gnus-newsgroup-undownloaded)
  11718. (not (memq article gnus-newsgroup-cached)))))
  11719. (let ((face (funcall (gnus-summary-highlight-line-0))))
  11720. (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
  11721. (gnus-put-text-property-excluding-characters-with-faces
  11722. beg (point-at-eol) 'face
  11723. (setq face (if (boundp face) (symbol-value face) face)))
  11724. (when gnus-summary-highlight-line-function
  11725. (funcall gnus-summary-highlight-line-function article face))))))
  11726. (defun gnus-update-read-articles (group unread &optional compute)
  11727. "Update the list of read articles in GROUP.
  11728. UNREAD is a sorted list."
  11729. (let ((active (or gnus-newsgroup-active (gnus-active group)))
  11730. (info (gnus-get-info group))
  11731. (prev 1)
  11732. read)
  11733. (if (or (not info) (not active))
  11734. ;; There is no info on this group if it was, in fact,
  11735. ;; killed. Gnus stores no information on killed groups, so
  11736. ;; there's nothing to be done.
  11737. ;; One could store the information somewhere temporarily,
  11738. ;; perhaps... Hmmm...
  11739. ()
  11740. ;; Remove any negative articles numbers.
  11741. (while (and unread (< (car unread) 0))
  11742. (setq unread (cdr unread)))
  11743. ;; Remove any expired article numbers
  11744. (while (and unread (< (car unread) (car active)))
  11745. (setq unread (cdr unread)))
  11746. ;; Compute the ranges of read articles by looking at the list of
  11747. ;; unread articles.
  11748. (while unread
  11749. (when (/= (car unread) prev)
  11750. (push (if (= prev (1- (car unread))) prev
  11751. (cons prev (1- (car unread))))
  11752. read))
  11753. (setq prev (1+ (car unread)))
  11754. (setq unread (cdr unread)))
  11755. (when (<= prev (cdr active))
  11756. (push (cons prev (cdr active)) read))
  11757. (setq read (if (> (length read) 1) (nreverse read) read))
  11758. (if compute
  11759. read
  11760. (save-excursion
  11761. (let (setmarkundo)
  11762. ;; Propagate the read marks to the backend.
  11763. (when (and (gnus-method-option-p
  11764. (gnus-find-method-for-group group)
  11765. 'server-marks)
  11766. (gnus-check-backend-function 'request-set-mark group))
  11767. (let ((del (gnus-remove-from-range (gnus-info-read info) read))
  11768. (add (gnus-remove-from-range read (gnus-info-read info))))
  11769. (when (or add del)
  11770. (unless (gnus-check-group group)
  11771. (error "Can't open server for %s" group))
  11772. (gnus-request-set-mark
  11773. group (delq nil (list (if add (list add 'add '(read)))
  11774. (if del (list del 'del '(read))))))
  11775. (setq setmarkundo
  11776. `(gnus-request-set-mark
  11777. ,group
  11778. ',(delq nil (list
  11779. (if del (list del 'add '(read)))
  11780. (if add (list add 'del '(read))))))))))
  11781. (set-buffer gnus-group-buffer)
  11782. (gnus-undo-register
  11783. `(progn
  11784. (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
  11785. (gnus-info-set-read ',info ',(gnus-info-read info))
  11786. (gnus-get-unread-articles-in-group ',info
  11787. (gnus-active ,group))
  11788. (gnus-group-update-group ,group t)
  11789. ,setmarkundo))))
  11790. ;; Enter this list into the group info.
  11791. (gnus-info-set-read info read)
  11792. ;; Set the number of unread articles in gnus-newsrc-hashtb.
  11793. (gnus-get-unread-articles-in-group info (gnus-active group))
  11794. t))))
  11795. (defun gnus-offer-save-summaries ()
  11796. "Offer to save all active summary buffers."
  11797. (let (buffers)
  11798. ;; Go through all buffers and find all summaries.
  11799. (dolist (buffer (buffer-list))
  11800. (when (and (setq buffer (buffer-name buffer))
  11801. (string-match "Summary" buffer)
  11802. (with-current-buffer buffer
  11803. ;; We check that this is, indeed, a summary buffer.
  11804. (and (derived-mode-p 'gnus-summary-mode)
  11805. ;; Also make sure this isn't bogus.
  11806. gnus-newsgroup-prepared
  11807. ;; Also make sure that this isn't a
  11808. ;; dead summary buffer.
  11809. (not gnus-dead-summary-mode))))
  11810. (push buffer buffers)))
  11811. ;; Go through all these summary buffers and offer to save them.
  11812. (when buffers
  11813. (save-excursion
  11814. (if (eq gnus-interactive-exit 'quiet)
  11815. (dolist (buffer buffers)
  11816. (switch-to-buffer buffer)
  11817. (gnus-summary-exit))
  11818. (map-y-or-n-p
  11819. "Update summary buffer %s? "
  11820. (lambda (buf)
  11821. (switch-to-buffer buf)
  11822. (gnus-summary-exit))
  11823. buffers))))))
  11824. (defun gnus-summary-setup-default-charset ()
  11825. "Setup newsgroup default charset."
  11826. (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
  11827. (setq gnus-newsgroup-charset nil)
  11828. (let* ((ignored-charsets
  11829. (or gnus-newsgroup-ephemeral-ignored-charsets
  11830. (append
  11831. (and gnus-newsgroup-name
  11832. (gnus-parameter-ignored-charsets gnus-newsgroup-name))
  11833. gnus-newsgroup-ignored-charsets))))
  11834. (setq gnus-newsgroup-charset
  11835. (or gnus-newsgroup-ephemeral-charset
  11836. (and gnus-newsgroup-name
  11837. (gnus-parameter-charset gnus-newsgroup-name))
  11838. gnus-default-charset))
  11839. (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
  11840. ignored-charsets))))
  11841. ;;;
  11842. ;;; Mime Commands
  11843. ;;;
  11844. (defun gnus-summary-display-buttonized (&optional show-all-parts)
  11845. "Display the current article buffer fully MIME-buttonized.
  11846. If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
  11847. treated as multipart/mixed."
  11848. (interactive "P")
  11849. (require 'gnus-art)
  11850. (let ((gnus-unbuttonized-mime-types nil)
  11851. (gnus-mime-display-multipart-as-mixed show-all-parts))
  11852. (gnus-summary-show-article)))
  11853. (defun gnus-summary-repair-multipart (article)
  11854. "Add a Content-Type header to a multipart article without one."
  11855. (interactive (list (gnus-summary-article-number)))
  11856. (gnus-with-article article
  11857. (message-narrow-to-head)
  11858. (message-remove-header "Mime-Version")
  11859. (goto-char (point-max))
  11860. (insert "Mime-Version: 1.0\n")
  11861. (widen)
  11862. (when (search-forward "\n--" nil t)
  11863. (let ((separator (buffer-substring (point) (point-at-eol))))
  11864. (message-narrow-to-head)
  11865. (message-remove-header "Content-Type")
  11866. (goto-char (point-max))
  11867. (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
  11868. separator))
  11869. (widen))))
  11870. (let (gnus-mark-article-hook)
  11871. (gnus-summary-select-article t t nil article)))
  11872. (defun gnus-summary-toggle-display-buttonized ()
  11873. "Toggle the buttonizing of the article buffer."
  11874. (interactive)
  11875. (require 'gnus-art)
  11876. (if (setq gnus-inhibit-mime-unbuttonizing
  11877. (not gnus-inhibit-mime-unbuttonizing))
  11878. (let ((gnus-unbuttonized-mime-types nil))
  11879. (gnus-summary-show-article))
  11880. (gnus-summary-show-article)))
  11881. ;;;
  11882. ;;; Generic summary marking commands
  11883. ;;;
  11884. (defvar gnus-summary-marking-alist
  11885. '((read gnus-del-mark "d")
  11886. (unread gnus-unread-mark "u")
  11887. (ticked gnus-ticked-mark "!")
  11888. (dormant gnus-dormant-mark "?")
  11889. (expirable gnus-expirable-mark "e"))
  11890. "An alist of names/marks/keystrokes.")
  11891. (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
  11892. (defvar gnus-summary-mark-map)
  11893. (defun gnus-summary-make-all-marking-commands ()
  11894. (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
  11895. (dolist (elem gnus-summary-marking-alist)
  11896. (apply 'gnus-summary-make-marking-command elem)))
  11897. (defun gnus-summary-make-marking-command (name mark keystroke)
  11898. (let ((map (make-sparse-keymap)))
  11899. (define-key gnus-summary-generic-mark-map keystroke map)
  11900. (dolist (lway `((next "next" next nil "n")
  11901. (next-unread "next unread" next t "N")
  11902. (prev "previous" prev nil "p")
  11903. (prev-unread "previous unread" prev t "P")
  11904. (nomove "" nil nil ,keystroke)))
  11905. (let ((func (gnus-summary-make-marking-command-1
  11906. mark (car lway) lway name)))
  11907. (setq func (eval func))
  11908. (define-key map (nth 4 lway) func)))))
  11909. (defun gnus-summary-make-marking-command-1 (mark way lway name)
  11910. `(defun ,(intern
  11911. (format "gnus-summary-put-mark-as-%s%s"
  11912. name (if (eq way 'nomove)
  11913. ""
  11914. (concat "-" (symbol-name way)))))
  11915. (n)
  11916. ,(format
  11917. "Mark the current article as %s%s.
  11918. If N, the prefix, then repeat N times.
  11919. If N is negative, move in reverse order.
  11920. The difference between N and the actual number of articles marked is
  11921. returned."
  11922. name (cadr lway))
  11923. (interactive "p")
  11924. (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
  11925. (defun gnus-summary-generic-mark (n mark move unread)
  11926. "Mark N articles with MARK."
  11927. (unless (derived-mode-p 'gnus-summary-mode)
  11928. (error "This command can only be used in the summary buffer"))
  11929. (gnus-summary-show-thread)
  11930. (let ((nummove
  11931. (cond
  11932. ((eq move 'next) 1)
  11933. ((eq move 'prev) -1)
  11934. (t 0))))
  11935. (if (zerop nummove)
  11936. (setq n 1)
  11937. (when (< n 0)
  11938. (setq n (abs n)
  11939. nummove (* -1 nummove))))
  11940. (while (and (> n 0)
  11941. (gnus-summary-mark-article nil mark)
  11942. (zerop (gnus-summary-next-subject nummove unread t)))
  11943. (setq n (1- n)))
  11944. (when (/= 0 n)
  11945. (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
  11946. (gnus-summary-recenter)
  11947. (gnus-summary-position-point)
  11948. (gnus-set-mode-line 'summary)
  11949. n))
  11950. (defun gnus-summary-insert-articles (articles)
  11951. (when (setq articles
  11952. (gnus-sorted-difference articles
  11953. (mapcar (lambda (h)
  11954. (mail-header-number h))
  11955. gnus-newsgroup-headers)))
  11956. (setq gnus-newsgroup-headers
  11957. (gnus-merge 'list
  11958. gnus-newsgroup-headers
  11959. (gnus-fetch-headers articles nil t)
  11960. 'gnus-article-sort-by-number))
  11961. (setq gnus-newsgroup-articles
  11962. (gnus-sorted-nunion gnus-newsgroup-articles articles))
  11963. ;; Suppress duplicates?
  11964. (when gnus-suppress-duplicates
  11965. (gnus-dup-suppress-articles))
  11966. (if (and gnus-fetch-old-headers
  11967. (eq gnus-headers-retrieved-by 'nov))
  11968. ;; We might want to build some more threads first.
  11969. (if (eq gnus-fetch-old-headers 'invisible)
  11970. (gnus-build-all-threads)
  11971. (gnus-build-old-threads))
  11972. ;; Mark the inserted articles that are unread as unread.
  11973. (setq gnus-newsgroup-unreads
  11974. (gnus-sorted-nunion
  11975. gnus-newsgroup-unreads
  11976. (gnus-sorted-nintersection
  11977. (gnus-list-of-unread-articles gnus-newsgroup-name)
  11978. articles)))
  11979. ;; Mark the inserted articles as selected so that the information
  11980. ;; of the marks having been changed by a user may be updated when
  11981. ;; exiting this group. See `gnus-summary-update-info'.
  11982. (dolist (art articles)
  11983. (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
  11984. ;; Let the Gnus agent mark articles as read.
  11985. (when gnus-agent
  11986. (gnus-agent-get-undownloaded-list))
  11987. ;; Remove list identifiers from subject
  11988. (gnus-summary-remove-list-identifiers)
  11989. ;; First and last article in this newsgroup.
  11990. (when gnus-newsgroup-headers
  11991. (setq gnus-newsgroup-begin
  11992. (mail-header-number (car gnus-newsgroup-headers))
  11993. gnus-newsgroup-end
  11994. (mail-header-number
  11995. (gnus-last-element gnus-newsgroup-headers))))
  11996. (when gnus-use-scoring
  11997. (gnus-possibly-score-headers))))
  11998. (defun gnus-summary-insert-old-articles (&optional all)
  11999. "Insert all old articles in this group.
  12000. If ALL is non-nil, already read articles become readable.
  12001. If ALL is a number, fetch this number of articles."
  12002. (interactive "P")
  12003. (prog1
  12004. (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
  12005. older len)
  12006. (setq older
  12007. ;; Some nntp servers lie about their active range. When
  12008. ;; this happens, the active range can be in the millions.
  12009. ;; Use a compressed range to avoid creating a huge list.
  12010. (gnus-range-difference
  12011. (gnus-range-difference (list gnus-newsgroup-active) old)
  12012. gnus-newsgroup-unexist))
  12013. (setq len (gnus-range-length older))
  12014. (cond
  12015. ((null older) nil)
  12016. ((numberp all)
  12017. (if (< all len)
  12018. (let ((older-range (nreverse older)))
  12019. (setq older nil)
  12020. (while (> all 0)
  12021. (let* ((r (pop older-range))
  12022. (min (if (numberp r) r (car r)))
  12023. (max (if (numberp r) r (cdr r))))
  12024. (while (and (<= min max)
  12025. (> all 0))
  12026. (push max older)
  12027. (setq all (1- all)
  12028. max (1- max))))))
  12029. (setq older (gnus-uncompress-range older))))
  12030. (all
  12031. (setq older (gnus-uncompress-range older)))
  12032. (t
  12033. (when (and (numberp gnus-large-newsgroup)
  12034. (> len gnus-large-newsgroup))
  12035. (let* ((cursor-in-echo-area nil)
  12036. (initial (gnus-parameter-large-newsgroup-initial
  12037. gnus-newsgroup-name))
  12038. (input
  12039. (read-string
  12040. (format
  12041. "How many articles from %s (%s %d): "
  12042. (gnus-group-decoded-name gnus-newsgroup-name)
  12043. (if initial "max" "default")
  12044. len)
  12045. nil nil
  12046. (and initial
  12047. (number-to-string initial)))))
  12048. (unless (string-match "^[ \t]*$" input)
  12049. (setq all (string-to-number input))
  12050. (if (< all len)
  12051. (let ((older-range (nreverse older)))
  12052. (setq older nil)
  12053. (while (> all 0)
  12054. (let* ((r (pop older-range))
  12055. (min (if (numberp r) r (car r)))
  12056. (max (if (numberp r) r (cdr r))))
  12057. (while (and (<= min max)
  12058. (> all 0))
  12059. (push max older)
  12060. (setq all (1- all)
  12061. max (1- max))))))))))
  12062. (setq older (gnus-uncompress-range older))))
  12063. (if (not older)
  12064. (message "No old news.")
  12065. (gnus-summary-insert-articles older)
  12066. (gnus-summary-limit (gnus-sorted-nunion old older))))
  12067. (gnus-summary-position-point)))
  12068. (defun gnus-summary-insert-new-articles ()
  12069. "Insert all new articles in this group."
  12070. (interactive)
  12071. (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
  12072. (old-high gnus-newsgroup-highest)
  12073. (nnmail-fetched-sources (list t))
  12074. (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
  12075. i new)
  12076. (unless new-active
  12077. (error "Couldn't fetch new data"))
  12078. (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
  12079. (setq i (cdr gnus-newsgroup-active)
  12080. gnus-newsgroup-highest i)
  12081. (while (> i old-high)
  12082. (push i new)
  12083. (decf i))
  12084. (if (not new)
  12085. (message "No gnus is bad news")
  12086. (gnus-summary-insert-articles new)
  12087. (setq gnus-newsgroup-unreads
  12088. (gnus-sorted-nunion gnus-newsgroup-unreads new))
  12089. (gnus-summary-limit (gnus-sorted-nunion old new))))
  12090. (gnus-summary-position-point))
  12091. ;;; Bookmark support for Gnus.
  12092. (declare-function gnus-article-show-summary "gnus-art" ())
  12093. (declare-function bookmark-make-record-default
  12094. "bookmark" (&optional no-file no-context posn))
  12095. (declare-function bookmark-prop-get "bookmark" (bookmark prop))
  12096. (declare-function bookmark-default-handler "bookmark" (bmk))
  12097. (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
  12098. (defvar bookmark-yank-point)
  12099. (defvar bookmark-current-buffer)
  12100. (defun gnus-summary-bookmark-make-record ()
  12101. "Make a bookmark entry for a Gnus summary buffer."
  12102. (let (pos buf)
  12103. (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
  12104. (save-restriction ; FIXME is it necessary to widen?
  12105. (widen) (setq pos (point))) ; Set position in gnus-article buffer.
  12106. (setq buf "art") ; We are recording bookmark from article buffer.
  12107. (setq bookmark-yank-point (point))
  12108. (setq bookmark-current-buffer (current-buffer))
  12109. (gnus-article-show-summary)) ; Go back in summary buffer.
  12110. ;; We are now recording bookmark from summary buffer.
  12111. (unless buf (setq buf "sum"))
  12112. (let* ((subject (elt (gnus-summary-article-header) 1))
  12113. (grp (car gnus-article-current))
  12114. (art (cdr gnus-article-current))
  12115. (head (gnus-summary-article-header art))
  12116. (id (mail-header-id head)))
  12117. `(,subject
  12118. ,@(condition-case nil
  12119. (bookmark-make-record-default 'no-file 'no-context pos)
  12120. (wrong-number-of-arguments
  12121. (bookmark-make-record-default 'point-only)))
  12122. (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
  12123. (group . ,grp) (article . ,art)
  12124. (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
  12125. ;;;###autoload
  12126. (defun gnus-summary-bookmark-jump (bookmark)
  12127. "Handler function for record returned by `gnus-summary-bookmark-make-record'.
  12128. BOOKMARK is a bookmark name or a bookmark record."
  12129. (let ((group (bookmark-prop-get bookmark 'group))
  12130. (article (bookmark-prop-get bookmark 'article))
  12131. (id (bookmark-prop-get bookmark 'message-id))
  12132. (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
  12133. (gnus-fetch-group group (list article))
  12134. (gnus-summary-insert-cached-articles)
  12135. (gnus-summary-goto-article id nil 'force)
  12136. ;; FIXME we have to wait article buffer is ready (only large buffer)
  12137. ;; Is there a better solution to know that?
  12138. ;; If we don't wait `bookmark-default-handler' will have no chance
  12139. ;; to set position. However there is no error, just wrong pos.
  12140. (sit-for 1)
  12141. (when (string= buf "Gnus-art")
  12142. (other-window 1))
  12143. (bookmark-default-handler
  12144. `(""
  12145. (buffer . ,(current-buffer))
  12146. . ,(bookmark-get-bookmark-record bookmark)))))
  12147. (gnus-summary-make-all-marking-commands)
  12148. (gnus-ems-redefine)
  12149. (provide 'gnus-sum)
  12150. (run-hooks 'gnus-sum-load-hook)
  12151. ;; Local Variables:
  12152. ;; coding: utf-8
  12153. ;; End:
  12154. ;;; gnus-sum.el ends here