gnus-sum.el 467 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986
  1. ;;; gnus-sum.el --- summary mode commands for Gnus
  2. ;; Copyright (C) 1996-2012 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. ;; For Emacs <22.2 and XEmacs.
  19. (eval-and-compile
  20. (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
  21. (eval-when-compile
  22. (require 'cl))
  23. (eval-when-compile
  24. (when (featurep 'xemacs)
  25. (require 'easy-mmode))) ; for `define-minor-mode'
  26. (defvar tool-bar-mode)
  27. (defvar gnus-tmp-header)
  28. (require 'gnus)
  29. (require 'gnus-group)
  30. (require 'gnus-spec)
  31. (require 'gnus-range)
  32. (require 'gnus-int)
  33. (require 'gnus-undo)
  34. (require 'gnus-util)
  35. (require 'gmm-utils)
  36. (require 'mm-decode)
  37. (require 'nnoo)
  38. (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
  39. (autoload 'gnus-cache-write-active "gnus-cache")
  40. (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
  41. (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
  42. (autoload 'gnus-pick-line-number "gnus-salt" nil t)
  43. (autoload 'mm-uu-dissect "mm-uu")
  44. (autoload 'gnus-article-outlook-deuglify-article "deuglify"
  45. "Deuglify broken Outlook (Express) articles and redisplay."
  46. t)
  47. (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
  48. (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
  49. (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
  50. (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
  51. (autoload 'nnir-article-group "nnir" nil nil 'macro)
  52. (defcustom gnus-kill-summary-on-exit t
  53. "*If non-nil, kill the summary buffer when you exit from it.
  54. If nil, the summary will become a \"*Dead Summary*\" buffer, and
  55. it will be killed sometime later."
  56. :group 'gnus-summary-exit
  57. :type 'boolean)
  58. (defcustom gnus-summary-next-group-on-exit t
  59. "If non-nil, go to the next unread newsgroup on summary exit.
  60. See `gnus-group-goto-unread'."
  61. :link '(custom-manual "(gnus)Group Maneuvering")
  62. :group 'gnus-summary-exit
  63. :version "23.1" ;; No Gnus
  64. :type 'boolean)
  65. (defcustom gnus-summary-stop-at-end-of-message nil
  66. "If non-nil, don't select the next message when using `SPC'."
  67. :link '(custom-manual "(gnus)Group Maneuvering")
  68. :group 'gnus-summary-maneuvering
  69. :version "24.1"
  70. :type 'boolean)
  71. (defcustom gnus-fetch-old-headers nil
  72. "*Non-nil means that Gnus will try to build threads by grabbing old headers.
  73. If an unread article in the group refers to an older, already
  74. read (or just marked as read) article, the old article will not
  75. normally be displayed in the Summary buffer. If this variable is
  76. t, Gnus will attempt to grab the headers to the old articles, and
  77. thereby build complete threads. If it has the value `some', all
  78. old headers will be fetched but only enough headers to connect
  79. otherwise loose threads will be displayed. This variable can
  80. also be a number. In that case, no more than that number of old
  81. headers will be fetched. If it has the value `invisible', all
  82. old headers will be fetched, but none will be displayed.
  83. The server has to support NOV for any of this to work.
  84. This feature can seriously impact performance it ignores all
  85. locally cached header entries. Setting it to t for groups for a
  86. server that doesn't expire articles (such as news.gmane.org),
  87. leads to very slow summary generation."
  88. :group 'gnus-thread
  89. :type '(choice (const :tag "off" nil)
  90. (const :tag "on" t)
  91. (const some)
  92. (const invisible)
  93. number
  94. (sexp :menu-tag "other" t)))
  95. (defcustom gnus-refer-thread-limit 500
  96. "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
  97. If t, fetch all the available old headers."
  98. :group 'gnus-thread
  99. :type '(choice number
  100. (sexp :menu-tag "other" t)))
  101. (defcustom gnus-refer-thread-use-nnir nil
  102. "*Use nnir to search an entire server when referring threads. A
  103. nil value will only search for thread-related articles in the
  104. current group."
  105. :version "24.1"
  106. :group 'gnus-thread
  107. :type 'boolean)
  108. (defcustom gnus-summary-make-false-root 'adopt
  109. "*nil means that Gnus won't gather loose threads.
  110. If the root of a thread has expired or been read in a previous
  111. session, the information necessary to build a complete thread has been
  112. lost. Instead of having many small sub-threads from this original thread
  113. scattered all over the summary buffer, Gnus can gather them.
  114. If non-nil, Gnus will try to gather all loose sub-threads from an
  115. original thread into one large thread.
  116. If this variable is non-nil, it should be one of `none', `adopt',
  117. `dummy' or `empty'.
  118. If this variable is `none', Gnus will not make a false root, but just
  119. present the sub-threads after another.
  120. If this variable is `dummy', Gnus will create a dummy root that will
  121. have all the sub-threads as children.
  122. If this variable is `adopt', Gnus will make one of the \"children\"
  123. the parent and mark all the step-children as such.
  124. If this variable is `empty', the \"children\" are printed with empty
  125. subject fields. (Or rather, they will be printed with a string
  126. given by the `gnus-summary-same-subject' variable.)"
  127. :group 'gnus-thread
  128. :type '(choice (const :tag "off" nil)
  129. (const none)
  130. (const dummy)
  131. (const adopt)
  132. (const empty)))
  133. (defcustom gnus-summary-make-false-root-always nil
  134. "Always make a false dummy root."
  135. :version "22.1"
  136. :group 'gnus-thread
  137. :type 'boolean)
  138. (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
  139. "*A regexp to match subjects to be excluded from loose thread gathering.
  140. As loose thread gathering is done on subjects only, that means that
  141. there can be many false gatherings performed. By rooting out certain
  142. common subjects, gathering might become saner."
  143. :group 'gnus-thread
  144. :type 'regexp)
  145. (defcustom gnus-summary-gather-subject-limit nil
  146. "*Maximum length of subject comparisons when gathering loose threads.
  147. Use nil to compare full subjects. Setting this variable to a low
  148. number will help gather threads that have been corrupted by
  149. newsreaders chopping off subject lines, but it might also mean that
  150. unrelated articles that have subject that happen to begin with the
  151. same few characters will be incorrectly gathered.
  152. If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
  153. comparing subjects."
  154. :group 'gnus-thread
  155. :type '(choice (const :tag "off" nil)
  156. (const fuzzy)
  157. (sexp :menu-tag "on" t)))
  158. (defcustom gnus-simplify-subject-functions nil
  159. "List of functions taking a string argument that simplify subjects.
  160. The functions are applied recursively.
  161. Useful functions to put in this list include:
  162. `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
  163. `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
  164. :group 'gnus-thread
  165. :type '(repeat function))
  166. (defcustom gnus-simplify-ignored-prefixes nil
  167. "*Remove matches for this regexp from subject lines when simplifying fuzzily."
  168. :group 'gnus-thread
  169. :type '(choice (const :tag "off" nil)
  170. regexp))
  171. (defcustom gnus-build-sparse-threads nil
  172. "*If non-nil, fill in the gaps in threads.
  173. If `some', only fill in the gaps that are needed to tie loose threads
  174. together. If `more', fill in all leaf nodes that Gnus can find. If
  175. non-nil and non-`some', fill in all gaps that Gnus manages to guess."
  176. :group 'gnus-thread
  177. :type '(choice (const :tag "off" nil)
  178. (const some)
  179. (const more)
  180. (sexp :menu-tag "all" t)))
  181. (defcustom gnus-summary-thread-gathering-function
  182. 'gnus-gather-threads-by-subject
  183. "*Function used for gathering loose threads.
  184. There are two pre-defined functions: `gnus-gather-threads-by-subject',
  185. which only takes Subjects into consideration; and
  186. `gnus-gather-threads-by-references', which compared the References
  187. headers of the articles to find matches."
  188. :group 'gnus-thread
  189. :type '(radio (function-item gnus-gather-threads-by-subject)
  190. (function-item gnus-gather-threads-by-references)
  191. (function :tag "other")))
  192. (defcustom gnus-summary-same-subject ""
  193. "*String indicating that the current article has the same subject as the previous.
  194. This variable will only be used if the value of
  195. `gnus-summary-make-false-root' is `empty'."
  196. :group 'gnus-summary-format
  197. :type 'string)
  198. (defcustom gnus-summary-goto-unread nil
  199. "*If t, many commands will go to the next unread article.
  200. This applies to marking commands as well as other commands that
  201. \"naturally\" select the next article, like, for instance, `SPC' at
  202. the end of an article.
  203. If nil, the marking commands do NOT go to the next unread article
  204. \(they go to the next article instead). If `never', commands that
  205. usually go to the next unread article, will go to the next article,
  206. whether it is read or not."
  207. :version "24.1"
  208. :group 'gnus-summary-marks
  209. :link '(custom-manual "(gnus)Setting Marks")
  210. :type '(choice (const :tag "off" nil)
  211. (const never)
  212. (sexp :menu-tag "on" t)))
  213. (defcustom gnus-summary-default-score 0
  214. "*Default article score level.
  215. All scores generated by the score files will be added to this score.
  216. If this variable is nil, scoring will be disabled."
  217. :group 'gnus-score-default
  218. :type '(choice (const :tag "disable")
  219. integer))
  220. (defcustom gnus-summary-default-high-score 0
  221. "*Default threshold for a high scored article.
  222. An article will be highlighted as high scored if its score is greater
  223. than this score."
  224. :version "22.1"
  225. :group 'gnus-score-default
  226. :type 'integer)
  227. (defcustom gnus-summary-default-low-score 0
  228. "*Default threshold for a low scored article.
  229. An article will be highlighted as low scored if its score is smaller
  230. than this score."
  231. :version "22.1"
  232. :group 'gnus-score-default
  233. :type 'integer)
  234. (defcustom gnus-summary-zcore-fuzz 0
  235. "*Fuzziness factor for the zcore in the summary buffer.
  236. Articles with scores closer than this to `gnus-summary-default-score'
  237. will not be marked."
  238. :group 'gnus-summary-format
  239. :type 'integer)
  240. (defcustom gnus-simplify-subject-fuzzy-regexp nil
  241. "*Strings to be removed when doing fuzzy matches.
  242. This can either be a regular expression or list of regular expressions
  243. that will be removed from subject strings if fuzzy subject
  244. simplification is selected."
  245. :group 'gnus-thread
  246. :type '(repeat regexp))
  247. (defcustom gnus-show-threads t
  248. "*If non-nil, display threads in summary mode."
  249. :group 'gnus-thread
  250. :type 'boolean)
  251. (defcustom gnus-thread-hide-subtree nil
  252. "*If non-nil, hide all threads initially.
  253. This can be a predicate specifier which says which threads to hide.
  254. If threads are hidden, you have to run the command
  255. `gnus-summary-show-thread' by hand or select an article."
  256. :group 'gnus-thread
  257. :type '(radio (sexp :format "Non-nil\n"
  258. :match (lambda (widget value)
  259. (not (or (consp value) (functionp value))))
  260. :value t)
  261. (const nil)
  262. (sexp :tag "Predicate specifier")))
  263. (defcustom gnus-thread-hide-killed t
  264. "*If non-nil, hide killed threads automatically."
  265. :group 'gnus-thread
  266. :type 'boolean)
  267. (defcustom gnus-thread-ignore-subject t
  268. "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
  269. If nil, articles that have different subjects from their parents will
  270. start separate threads."
  271. :group 'gnus-thread
  272. :type 'boolean)
  273. (defcustom gnus-thread-operation-ignore-subject t
  274. "*If non-nil, subjects will be ignored when doing thread commands.
  275. This affects commands like `gnus-summary-kill-thread' and
  276. `gnus-summary-lower-thread'.
  277. If this variable is nil, articles in the same thread with different
  278. subjects will not be included in the operation in question. If this
  279. variable is `fuzzy', only articles that have subjects that are fuzzily
  280. equal will be included."
  281. :group 'gnus-thread
  282. :type '(choice (const :tag "off" nil)
  283. (const fuzzy)
  284. (sexp :tag "on" t)))
  285. (defcustom gnus-thread-indent-level 4
  286. "*Number that says how much each sub-thread should be indented."
  287. :group 'gnus-thread
  288. :type 'integer)
  289. (defcustom gnus-auto-extend-newsgroup t
  290. "*If non-nil, extend newsgroup forward and backward when requested."
  291. :group 'gnus-summary-choose
  292. :type 'boolean)
  293. (defcustom gnus-auto-select-first t
  294. "If non-nil, select an article on group entry.
  295. An article is selected automatically when entering a group
  296. e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
  297. `gnus-summary-catchup-and-goto-next-group'.
  298. Which article is selected is controlled by the variable
  299. `gnus-auto-select-subject'.
  300. If you want to prevent automatic selection of articles in some
  301. newsgroups, set the variable to nil in `gnus-select-group-hook'."
  302. ;; Commands include...
  303. ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
  304. ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
  305. ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
  306. :group 'gnus-group-select
  307. :type '(choice (const :tag "none" nil)
  308. (sexp :menu-tag "first" t)))
  309. (defcustom gnus-auto-select-subject 'unseen-or-unread
  310. "*Says what subject to place under point when entering a group.
  311. This variable can either be the symbols `first' (place point on the
  312. first subject), `unread' (place point on the subject line of the first
  313. unread article), `best' (place point on the subject line of the
  314. highest-scored article), `unseen' (place point on the subject line of
  315. the first unseen article), `unseen-or-unread' (place point on the subject
  316. line of the first unseen article or, if all articles have been seen, on the
  317. subject line of the first unread article), or a function to be called to
  318. place point on some subject line."
  319. :version "24.1"
  320. :group 'gnus-group-select
  321. :type '(choice (const best)
  322. (const unread)
  323. (const first)
  324. (const unseen)
  325. (const unseen-or-unread)
  326. (function :tag "Function to call")))
  327. (defcustom gnus-auto-select-next t
  328. "*If non-nil, offer to go to the next group from the end of the previous.
  329. If the value is t and the next newsgroup is empty, Gnus will exit
  330. summary mode and go back to group mode. If the value is neither nil
  331. nor t, Gnus will select the following unread newsgroup. In
  332. particular, if the value is the symbol `quietly', the next unread
  333. newsgroup will be selected without any confirmation, and if it is
  334. `almost-quietly', the next group will be selected without any
  335. confirmation if you are located on the last article in the group.
  336. Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
  337. will go to the next group without confirmation."
  338. :group 'gnus-summary-maneuvering
  339. :type '(choice (const :tag "off" nil)
  340. (const quietly)
  341. (const almost-quietly)
  342. (const slightly-quietly)
  343. (sexp :menu-tag "on" t)))
  344. (defcustom gnus-auto-select-same nil
  345. "*If non-nil, select the next article with the same subject.
  346. If there are no more articles with the same subject, go to
  347. the first unread article."
  348. :group 'gnus-summary-maneuvering
  349. :type 'boolean)
  350. (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
  351. "What article should be selected after exiting an ephemeral group.
  352. Valid values include:
  353. `next'
  354. Select the next article.
  355. `next-unread'
  356. Select the next unread article.
  357. `next-noselect'
  358. Move the cursor to the next article. This is the default.
  359. `next-unread-noselect'
  360. Move the cursor to the next unread article.
  361. If it has any other value or there is no next (unread) article, the
  362. article selected before entering to the ephemeral group will appear."
  363. :version "23.1" ;; No Gnus
  364. :group 'gnus-summary-maneuvering
  365. :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
  366. (const next) (const next-unread)
  367. (const next-noselect) (const next-unread-noselect)
  368. (sexp :tag "other" :value nil)))
  369. (defcustom gnus-auto-goto-ignores 'unfetched
  370. "*Says how to handle unfetched articles when maneuvering.
  371. This variable can either be the symbols nil (maneuver to any
  372. article), `undownloaded' (maneuvering while unplugged ignores articles
  373. that have not been fetched), `always-undownloaded' (maneuvering always
  374. ignores articles that have not been fetched), `unfetched' (maneuvering
  375. ignores articles whose headers have not been fetched).
  376. NOTE: The list of unfetched articles will always be nil when plugged
  377. and, when unplugged, a subset of the undownloaded article list."
  378. :version "22.1"
  379. :group 'gnus-summary-maneuvering
  380. :type '(choice (const :tag "None" nil)
  381. (const :tag "Undownloaded when unplugged" undownloaded)
  382. (const :tag "Undownloaded" always-undownloaded)
  383. (const :tag "Unfetched" unfetched)))
  384. (defcustom gnus-summary-check-current nil
  385. "*If non-nil, consider the current article when moving.
  386. The \"unread\" movement commands will stay on the same line if the
  387. current article is unread."
  388. :group 'gnus-summary-maneuvering
  389. :type 'boolean)
  390. (defcustom gnus-auto-center-summary 2
  391. "*If non-nil, always center the current summary buffer.
  392. In particular, if `vertical' do only vertical recentering. If non-nil
  393. and non-`vertical', do both horizontal and vertical recentering."
  394. :group 'gnus-summary-maneuvering
  395. :type '(choice (const :tag "none" nil)
  396. (const vertical)
  397. (integer :tag "height")
  398. (sexp :menu-tag "both" t)))
  399. (defcustom gnus-auto-center-group t
  400. "If non-nil, always center the group buffer."
  401. :group 'gnus-summary-maneuvering
  402. :type 'boolean)
  403. (defcustom gnus-show-all-headers nil
  404. "*If non-nil, don't hide any headers."
  405. :group 'gnus-article-hiding
  406. :group 'gnus-article-headers
  407. :type 'boolean)
  408. (defcustom gnus-summary-ignore-duplicates nil
  409. "*If non-nil, ignore articles with identical Message-ID headers."
  410. :group 'gnus-summary
  411. :type 'boolean)
  412. (defcustom gnus-single-article-buffer nil
  413. "*If non-nil, display all articles in the same buffer.
  414. If nil, each group will get its own article buffer."
  415. :version "24.1"
  416. :group 'gnus-article-various
  417. :type 'boolean)
  418. (defcustom gnus-widen-article-window nil
  419. "If non-nil, selecting the article buffer will display only the article buffer."
  420. :version "24.1"
  421. :group 'gnus-article-various
  422. :type 'boolean)
  423. (defcustom gnus-break-pages t
  424. "*If non-nil, do page breaking on articles.
  425. The page delimiter is specified by the `gnus-page-delimiter'
  426. variable."
  427. :group 'gnus-article-various
  428. :type 'boolean)
  429. (defcustom gnus-move-split-methods nil
  430. "*Variable used to suggest where articles are to be moved to.
  431. It uses the same syntax as the `gnus-split-methods' variable.
  432. However, whereas `gnus-split-methods' specifies file names as targets,
  433. this variable specifies group names."
  434. :group 'gnus-summary-mail
  435. :type '(repeat (choice (list :value (fun) function)
  436. (cons :value ("" "") regexp (repeat string))
  437. (sexp :value nil))))
  438. (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
  439. "Function used to compute default prefix for article move/copy/etc prompts.
  440. The function should take one argument, a group name, and return a
  441. string with the suggested prefix."
  442. :group 'gnus-summary-mail
  443. :type 'function)
  444. ;; FIXME: Although the custom type is `character' for the following variables,
  445. ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
  446. (defcustom gnus-unread-mark ? ;Whitespace
  447. "*Mark used for unread articles."
  448. :group 'gnus-summary-marks
  449. :type 'character)
  450. (defcustom gnus-ticked-mark ?!
  451. "*Mark used for ticked articles."
  452. :group 'gnus-summary-marks
  453. :type 'character)
  454. (defcustom gnus-dormant-mark ??
  455. "*Mark used for dormant articles."
  456. :group 'gnus-summary-marks
  457. :type 'character)
  458. (defcustom gnus-del-mark ?r
  459. "*Mark used for del'd articles."
  460. :group 'gnus-summary-marks
  461. :type 'character)
  462. (defcustom gnus-read-mark ?R
  463. "*Mark used for read articles."
  464. :group 'gnus-summary-marks
  465. :type 'character)
  466. (defcustom gnus-expirable-mark ?E
  467. "*Mark used for expirable articles."
  468. :group 'gnus-summary-marks
  469. :type 'character)
  470. (defcustom gnus-killed-mark ?K
  471. "*Mark used for killed articles."
  472. :group 'gnus-summary-marks
  473. :type 'character)
  474. (defcustom gnus-spam-mark ?$
  475. "*Mark used for spam articles."
  476. :version "22.1"
  477. :group 'gnus-summary-marks
  478. :type 'character)
  479. (defcustom gnus-kill-file-mark ?X
  480. "*Mark used for articles killed by kill files."
  481. :group 'gnus-summary-marks
  482. :type 'character)
  483. (defcustom gnus-low-score-mark ?Y
  484. "*Mark used for articles with a low score."
  485. :group 'gnus-summary-marks
  486. :type 'character)
  487. (defcustom gnus-catchup-mark ?C
  488. "*Mark used for articles that are caught up."
  489. :group 'gnus-summary-marks
  490. :type 'character)
  491. (defcustom gnus-replied-mark ?A
  492. "*Mark used for articles that have been replied to."
  493. :group 'gnus-summary-marks
  494. :type 'character)
  495. (defcustom gnus-forwarded-mark ?F
  496. "*Mark used for articles that have been forwarded."
  497. :version "22.1"
  498. :group 'gnus-summary-marks
  499. :type 'character)
  500. (defcustom gnus-recent-mark ?N
  501. "*Mark used for articles that are recent."
  502. :version "22.1"
  503. :group 'gnus-summary-marks
  504. :type 'character)
  505. (defcustom gnus-cached-mark ?*
  506. "*Mark used for articles that are in the cache."
  507. :group 'gnus-summary-marks
  508. :type 'character)
  509. (defcustom gnus-saved-mark ?S
  510. "*Mark used for articles that have been saved."
  511. :group 'gnus-summary-marks
  512. :type 'character)
  513. (defcustom gnus-unseen-mark ?.
  514. "*Mark used for articles that haven't been seen."
  515. :version "22.1"
  516. :group 'gnus-summary-marks
  517. :type 'character)
  518. (defcustom gnus-no-mark ? ;Whitespace
  519. "*Mark used for articles that have no other secondary mark."
  520. :version "22.1"
  521. :group 'gnus-summary-marks
  522. :type 'character)
  523. (defcustom gnus-ancient-mark ?O
  524. "*Mark used for ancient articles."
  525. :group 'gnus-summary-marks
  526. :type 'character)
  527. (defcustom gnus-sparse-mark ?Q
  528. "*Mark used for sparsely reffed articles."
  529. :group 'gnus-summary-marks
  530. :type 'character)
  531. (defcustom gnus-canceled-mark ?G
  532. "*Mark used for canceled articles."
  533. :group 'gnus-summary-marks
  534. :type 'character)
  535. (defcustom gnus-duplicate-mark ?M
  536. "*Mark used for duplicate articles."
  537. :group 'gnus-summary-marks
  538. :type 'character)
  539. (defcustom gnus-undownloaded-mark ?-
  540. "*Mark used for articles that weren't downloaded."
  541. :version "22.1"
  542. :group 'gnus-summary-marks
  543. :type 'character)
  544. (defcustom gnus-downloaded-mark ?+
  545. "*Mark used for articles that were downloaded."
  546. :group 'gnus-summary-marks
  547. :type 'character)
  548. (defcustom gnus-downloadable-mark ?%
  549. "*Mark used for articles that are to be downloaded."
  550. :group 'gnus-summary-marks
  551. :type 'character)
  552. (defcustom gnus-unsendable-mark ?=
  553. "*Mark used for articles that won't be sent."
  554. :group 'gnus-summary-marks
  555. :type 'character)
  556. (defcustom gnus-score-over-mark ?+
  557. "*Score mark used for articles with high scores."
  558. :group 'gnus-summary-marks
  559. :type 'character)
  560. (defcustom gnus-score-below-mark ?-
  561. "*Score mark used for articles with low scores."
  562. :group 'gnus-summary-marks
  563. :type 'character)
  564. (defcustom gnus-empty-thread-mark ? ;Whitespace
  565. "*There is no thread under the article."
  566. :group 'gnus-summary-marks
  567. :type 'character)
  568. (defcustom gnus-not-empty-thread-mark ?=
  569. "*There is a thread under the article."
  570. :group 'gnus-summary-marks
  571. :type 'character)
  572. (defcustom gnus-view-pseudo-asynchronously nil
  573. "*If non-nil, Gnus will view pseudo-articles asynchronously."
  574. :group 'gnus-extract-view
  575. :type 'boolean)
  576. (defcustom gnus-auto-expirable-marks
  577. (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
  578. gnus-low-score-mark gnus-ancient-mark gnus-read-mark
  579. gnus-duplicate-mark)
  580. "*The list of marks converted into expiration if a group is auto-expirable."
  581. :version "24.1"
  582. :group 'gnus-summary
  583. :type '(repeat character))
  584. (defcustom gnus-inhibit-user-auto-expire t
  585. "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
  586. :version "21.1"
  587. :group 'gnus-summary
  588. :type 'boolean)
  589. (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
  590. "If non-nil, mark articles copied or moved to auto-expire group as expirable.
  591. If nil, the expirable marks will be unchanged except that the marks
  592. will be removed when copying or moving articles to a group that has
  593. not turned auto-expire on. If non-nil, articles that have been read
  594. will be marked as expirable when being copied or moved to a group in
  595. which auto-expire is turned on."
  596. :version "23.2"
  597. :type 'boolean
  598. :group 'gnus-summary-marks)
  599. (defcustom gnus-view-pseudos nil
  600. "*If `automatic', pseudo-articles will be viewed automatically.
  601. If `not-confirm', pseudos will be viewed automatically, and the user
  602. will not be asked to confirm the command."
  603. :group 'gnus-extract-view
  604. :type '(choice (const :tag "off" nil)
  605. (const automatic)
  606. (const not-confirm)))
  607. (defcustom gnus-view-pseudos-separately t
  608. "*If non-nil, one pseudo-article will be created for each file to be viewed.
  609. If nil, all files that use the same viewing command will be given as a
  610. list of parameters to that command."
  611. :group 'gnus-extract-view
  612. :type 'boolean)
  613. (defcustom gnus-insert-pseudo-articles t
  614. "*If non-nil, insert pseudo-articles when decoding articles."
  615. :group 'gnus-extract-view
  616. :type 'boolean)
  617. (defcustom gnus-summary-dummy-line-format
  618. " %(: :%) %S\n"
  619. "*The format specification for the dummy roots in the summary buffer.
  620. It works along the same lines as a normal formatting string,
  621. with some simple extensions.
  622. %S The subject
  623. General format specifiers can also be used.
  624. See `(gnus)Formatting Variables'."
  625. :link '(custom-manual "(gnus)Formatting Variables")
  626. :group 'gnus-threading
  627. :type 'string)
  628. (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
  629. "*The format specification for the summary mode line.
  630. It works along the same lines as a normal formatting string,
  631. with some simple extensions:
  632. %G Group name
  633. %p Unprefixed group name
  634. %A Current article number
  635. %z Current article score
  636. %V Gnus version
  637. %U Number of unread articles in the group
  638. %e Number of unselected articles in the group
  639. %Z A string with unread/unselected article counts
  640. %g Shortish group name
  641. %S Subject of the current article
  642. %u User-defined spec
  643. %s Current score file name
  644. %d Number of dormant articles
  645. %r Number of articles that have been marked as read in this session
  646. %E Number of articles expunged by the score files"
  647. :group 'gnus-summary-format
  648. :type 'string)
  649. (defcustom gnus-list-identifiers nil
  650. "Regexp that matches list identifiers to be removed from subject.
  651. This can also be a list of regexps."
  652. :version "21.1"
  653. :group 'gnus-summary-format
  654. :group 'gnus-article-hiding
  655. :type '(choice (const :tag "none" nil)
  656. (regexp :value ".*")
  657. (repeat :value (".*") regexp)))
  658. (defcustom gnus-summary-mark-below 0
  659. "*Mark all articles with a score below this variable as read.
  660. This variable is local to each summary buffer and usually set by the
  661. score file."
  662. :group 'gnus-score-default
  663. :type 'integer)
  664. (defun gnus-widget-reversible-match (widget value)
  665. "Ignoring WIDGET, convert VALUE to internal form.
  666. VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
  667. ;; (debug value)
  668. (or (symbolp value)
  669. (and (listp value)
  670. (eq (length value) 2)
  671. (eq (nth 0 value) 'not)
  672. (symbolp (nth 1 value)))))
  673. (defun gnus-widget-reversible-to-internal (widget value)
  674. "Ignoring WIDGET, convert VALUE to internal form.
  675. VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
  676. FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
  677. ;; (debug value)
  678. (if (atom value)
  679. (list value nil)
  680. (list (nth 1 value) t)))
  681. (defun gnus-widget-reversible-to-external (widget value)
  682. "Ignoring WIDGET, convert VALUE to external form.
  683. VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
  684. \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
  685. ;; (debug value)
  686. (if (nth 1 value)
  687. (list 'not (nth 0 value))
  688. (nth 0 value)))
  689. (define-widget 'gnus-widget-reversible 'group
  690. "A `group' that convert values."
  691. :match 'gnus-widget-reversible-match
  692. :value-to-internal 'gnus-widget-reversible-to-internal
  693. :value-to-external 'gnus-widget-reversible-to-external)
  694. (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
  695. "*List of functions used for sorting articles in the summary buffer.
  696. Each function takes two articles and returns non-nil if the first
  697. article should be sorted before the other. If you use more than one
  698. function, the primary sort function should be the last. You should
  699. probably always include `gnus-article-sort-by-number' in the list of
  700. sorting functions -- preferably first. Also note that sorting by date
  701. is often much slower than sorting by number, and the sorting order is
  702. very similar. (Sorting by date means sorting by the time the message
  703. was sent, sorting by number means sorting by arrival time.)
  704. Each item can also be a list `(not F)' where F is a function;
  705. this reverses the sort order.
  706. Ready-made functions include `gnus-article-sort-by-number',
  707. `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
  708. `gnus-article-sort-by-date', `gnus-article-sort-by-random'
  709. and `gnus-article-sort-by-score'.
  710. When threading is turned on, the variable `gnus-thread-sort-functions'
  711. controls how articles are sorted."
  712. :group 'gnus-summary-sort
  713. :type '(repeat (gnus-widget-reversible
  714. (choice (function-item gnus-article-sort-by-number)
  715. (function-item gnus-article-sort-by-author)
  716. (function-item gnus-article-sort-by-subject)
  717. (function-item gnus-article-sort-by-date)
  718. (function-item gnus-article-sort-by-score)
  719. (function-item gnus-article-sort-by-random)
  720. (function :tag "other"))
  721. (boolean :tag "Reverse order"))))
  722. (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
  723. "*List of functions used for sorting threads in the summary buffer.
  724. By default, threads are sorted by article number.
  725. Each function takes two threads and returns non-nil if the first
  726. thread should be sorted before the other. If you use more than one
  727. function, the primary sort function should be the last. You should
  728. probably always include `gnus-thread-sort-by-number' in the list of
  729. sorting functions -- preferably first. Also note that sorting by date
  730. is often much slower than sorting by number, and the sorting order is
  731. very similar. (Sorting by date means sorting by the time the message
  732. was sent, sorting by number means sorting by arrival time.)
  733. Each list item can also be a list `(not F)' where F is a
  734. function; this specifies reversed sort order.
  735. Ready-made functions include `gnus-thread-sort-by-number',
  736. `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
  737. `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
  738. `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
  739. `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
  740. and `gnus-thread-sort-by-total-score' (see
  741. `gnus-thread-score-function').
  742. When threading is turned off, the variable
  743. `gnus-article-sort-functions' controls how articles are sorted."
  744. :group 'gnus-summary-sort
  745. :type '(repeat
  746. (gnus-widget-reversible
  747. (choice (function-item gnus-thread-sort-by-number)
  748. (function-item gnus-thread-sort-by-author)
  749. (function-item gnus-thread-sort-by-recipient)
  750. (function-item gnus-thread-sort-by-subject)
  751. (function-item gnus-thread-sort-by-date)
  752. (function-item gnus-thread-sort-by-score)
  753. (function-item gnus-thread-sort-by-most-recent-number)
  754. (function-item gnus-thread-sort-by-most-recent-date)
  755. (function-item gnus-thread-sort-by-random)
  756. (function-item gnus-thread-sort-by-total-score)
  757. (function :tag "other"))
  758. (boolean :tag "Reverse order"))))
  759. (defcustom gnus-thread-score-function '+
  760. "*Function used for calculating the total score of a thread.
  761. The function is called with the scores of the article and each
  762. subthread and should then return the score of the thread.
  763. Some functions you can use are `+', `max', or `min'."
  764. :group 'gnus-summary-sort
  765. :type 'function)
  766. (defcustom gnus-summary-expunge-below nil
  767. "All articles that have a score less than this variable will be expunged.
  768. This variable is local to the summary buffers."
  769. :group 'gnus-score-default
  770. :type '(choice (const :tag "off" nil)
  771. integer))
  772. (defcustom gnus-thread-expunge-below nil
  773. "All threads that have a total score less than this variable will be expunged.
  774. See `gnus-thread-score-function' for en explanation of what a
  775. \"thread score\" is.
  776. This variable is local to the summary buffers."
  777. :group 'gnus-threading
  778. :group 'gnus-score-default
  779. :type '(choice (const :tag "off" nil)
  780. integer))
  781. (defcustom gnus-summary-mode-hook nil
  782. "*A hook for Gnus summary mode.
  783. This hook is run before any variables are set in the summary buffer."
  784. :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
  785. :group 'gnus-summary-various
  786. :type 'hook)
  787. ;; Extracted from gnus-xmas-redefine in order to preserve user settings
  788. (when (featurep 'xemacs)
  789. (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
  790. (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
  791. (add-hook 'gnus-summary-mode-hook
  792. 'gnus-xmas-switch-horizontal-scrollbar-off))
  793. (defcustom gnus-summary-menu-hook nil
  794. "*Hook run after the creation of the summary mode menu."
  795. :group 'gnus-summary-visual
  796. :type 'hook)
  797. (defcustom gnus-summary-exit-hook nil
  798. "*A hook called on exit from the summary buffer.
  799. It will be called with point in the group buffer."
  800. :group 'gnus-summary-exit
  801. :type 'hook)
  802. (defcustom gnus-summary-prepare-hook nil
  803. "*A hook called after the summary buffer has been generated.
  804. If you want to modify the summary buffer, you can use this hook."
  805. :group 'gnus-summary-various
  806. :type 'hook)
  807. (defcustom gnus-summary-prepared-hook nil
  808. "*A hook called as the last thing after the summary buffer has been generated."
  809. :group 'gnus-summary-various
  810. :type 'hook)
  811. (defcustom gnus-summary-generate-hook nil
  812. "*A hook run just before generating the summary buffer.
  813. This hook is commonly used to customize threading variables and the
  814. like."
  815. :group 'gnus-summary-various
  816. :type 'hook)
  817. (defcustom gnus-select-group-hook nil
  818. "*A hook called when a newsgroup is selected.
  819. If you'd like to simplify subjects like the
  820. `gnus-summary-next-same-subject' command does, you can use the
  821. following hook:
  822. (add-hook gnus-select-group-hook
  823. (lambda ()
  824. (mapcar (lambda (header)
  825. (mail-header-set-subject
  826. header
  827. (gnus-simplify-subject
  828. (mail-header-subject header) 're-only)))
  829. gnus-newsgroup-headers)))"
  830. :group 'gnus-group-select
  831. :type 'hook)
  832. (defcustom gnus-select-article-hook nil
  833. "*A hook called when an article is selected."
  834. :group 'gnus-summary-choose
  835. :options '(gnus-agent-fetch-selected-article)
  836. :type 'hook)
  837. (defcustom gnus-visual-mark-article-hook
  838. (list 'gnus-highlight-selected-summary)
  839. "*Hook run after selecting an article in the summary buffer.
  840. It is meant to be used for highlighting the article in some way. It
  841. is not run if `gnus-visual' is nil."
  842. :group 'gnus-summary-visual
  843. :type 'hook)
  844. (defcustom gnus-parse-headers-hook nil
  845. "*A hook called before parsing the headers."
  846. :group 'gnus-various
  847. :type 'hook)
  848. (defcustom gnus-exit-group-hook nil
  849. "*A hook called when exiting summary mode.
  850. This hook is not called from the non-updating exit commands like `Q'."
  851. :group 'gnus-various
  852. :type 'hook)
  853. (defcustom gnus-summary-update-hook nil
  854. "*A hook called when a summary line is changed.
  855. The hook will not be called if `gnus-visual' is nil.
  856. The default function `gnus-summary-highlight-line' will
  857. highlight the line according to the `gnus-summary-highlight'
  858. variable."
  859. :group 'gnus-summary-visual
  860. :type 'hook)
  861. (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
  862. "*A hook called when an article is selected for the first time.
  863. The hook is intended to mark an article as read (or unread)
  864. automatically when it is selected."
  865. :group 'gnus-summary-choose
  866. :type 'hook)
  867. (defcustom gnus-group-no-more-groups-hook nil
  868. "*A hook run when returning to group mode having no more (unread) groups."
  869. :group 'gnus-group-select
  870. :type 'hook)
  871. (defcustom gnus-ps-print-hook nil
  872. "*A hook run before ps-printing something from Gnus."
  873. :group 'gnus-summary
  874. :type 'hook)
  875. (defcustom gnus-summary-article-move-hook nil
  876. "*A hook called after an article is moved, copied, respooled, or crossposted."
  877. :version "22.1"
  878. :group 'gnus-summary
  879. :type 'hook)
  880. (defcustom gnus-summary-article-delete-hook nil
  881. "*A hook called after an article is deleted."
  882. :version "22.1"
  883. :group 'gnus-summary
  884. :type 'hook)
  885. (defcustom gnus-summary-article-expire-hook nil
  886. "*A hook called after an article is expired."
  887. :version "22.1"
  888. :group 'gnus-summary
  889. :type 'hook)
  890. (defcustom gnus-summary-display-arrow
  891. (and (fboundp 'display-graphic-p)
  892. (display-graphic-p))
  893. "*If non-nil, display an arrow highlighting the current article."
  894. :version "22.1"
  895. :group 'gnus-summary
  896. :type 'boolean)
  897. (defcustom gnus-summary-selected-face 'gnus-summary-selected
  898. "Face used for highlighting the current article in the summary buffer."
  899. :group 'gnus-summary-visual
  900. :type 'face)
  901. (defvar gnus-tmp-downloaded nil)
  902. (defcustom gnus-summary-highlight
  903. '(((eq mark gnus-canceled-mark)
  904. . gnus-summary-cancelled)
  905. ((and uncached (> score default-high))
  906. . gnus-summary-high-undownloaded)
  907. ((and uncached (< score default-low))
  908. . gnus-summary-low-undownloaded)
  909. (uncached
  910. . gnus-summary-normal-undownloaded)
  911. ((and (> score default-high)
  912. (or (eq mark gnus-dormant-mark)
  913. (eq mark gnus-ticked-mark)))
  914. . gnus-summary-high-ticked)
  915. ((and (< score default-low)
  916. (or (eq mark gnus-dormant-mark)
  917. (eq mark gnus-ticked-mark)))
  918. . gnus-summary-low-ticked)
  919. ((or (eq mark gnus-dormant-mark)
  920. (eq mark gnus-ticked-mark))
  921. . gnus-summary-normal-ticked)
  922. ((and (> score default-high) (eq mark gnus-ancient-mark))
  923. . gnus-summary-high-ancient)
  924. ((and (< score default-low) (eq mark gnus-ancient-mark))
  925. . gnus-summary-low-ancient)
  926. ((eq mark gnus-ancient-mark)
  927. . gnus-summary-normal-ancient)
  928. ((and (> score default-high) (eq mark gnus-unread-mark))
  929. . gnus-summary-high-unread)
  930. ((and (< score default-low) (eq mark gnus-unread-mark))
  931. . gnus-summary-low-unread)
  932. ((eq mark gnus-unread-mark)
  933. . gnus-summary-normal-unread)
  934. ((> score default-high)
  935. . gnus-summary-high-read)
  936. ((< score default-low)
  937. . gnus-summary-low-read)
  938. (t
  939. . gnus-summary-normal-read))
  940. "*Controls the highlighting of summary buffer lines.
  941. A list of (FORM . FACE) pairs. When deciding how a particular
  942. summary line should be displayed, each form is evaluated. The content
  943. of the face field after the first true form is used. You can change
  944. how those summary lines are displayed, by editing the face field.
  945. You can use the following variables in the FORM field.
  946. score: The article's score.
  947. default: The default article score.
  948. default-high: The default score for high scored articles.
  949. default-low: The default score for low scored articles.
  950. below: The score below which articles are automatically marked as read.
  951. mark: The article's mark.
  952. uncached: Non-nil if the article is uncached."
  953. :group 'gnus-summary-visual
  954. :type '(repeat (cons (sexp :tag "Form" nil)
  955. face)))
  956. (put 'gnus-summary-highlight 'risky-local-variable t)
  957. (defcustom gnus-alter-header-function nil
  958. "Function called to allow alteration of article header structures.
  959. The function is called with one parameter, the article header vector,
  960. which it may alter in any way."
  961. :type '(choice (const :tag "None" nil)
  962. function)
  963. :group 'gnus-summary)
  964. (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
  965. "Function used to decode a string with encoded words.")
  966. (defvar gnus-decode-encoded-address-function
  967. 'mail-decode-encoded-address-string
  968. "Function used to decode addresses with encoded words.")
  969. (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups)
  970. "*Extra headers to parse."
  971. :version "24.1" ; added Cc Keywords Gcc
  972. :group 'gnus-summary
  973. :type '(repeat symbol))
  974. (defcustom gnus-ignored-from-addresses
  975. (and user-mail-address
  976. (not (string= user-mail-address ""))
  977. (regexp-quote user-mail-address))
  978. "*From headers that may be suppressed in favor of To headers.
  979. This can be a regexp or a list of regexps."
  980. :version "21.1"
  981. :group 'gnus-summary
  982. :type '(choice regexp
  983. (repeat :tag "Regexp List" regexp)))
  984. (defsubst gnus-ignored-from-addresses ()
  985. (gmm-regexp-concat gnus-ignored-from-addresses))
  986. (defcustom gnus-summary-to-prefix "-> "
  987. "*String prefixed to the To field in the summary line when
  988. using `gnus-ignored-from-addresses'."
  989. :version "22.1"
  990. :group 'gnus-summary
  991. :type 'string)
  992. (defcustom gnus-summary-newsgroup-prefix "=> "
  993. "*String prefixed to the Newsgroup field in the summary
  994. line when using `gnus-ignored-from-addresses'."
  995. :version "22.1"
  996. :group 'gnus-summary
  997. :type 'string)
  998. (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
  999. "List of charsets that should be ignored.
  1000. When these charsets are used in the \"charset\" parameter, the
  1001. default charset will be used instead."
  1002. :version "21.1"
  1003. :type '(repeat symbol)
  1004. :group 'gnus-charset)
  1005. (defcustom gnus-newsgroup-maximum-articles nil
  1006. "The maximum number of articles a newsgroup.
  1007. If this is a number, old articles in a newsgroup exceeding this number
  1008. are silently ignored. If it is nil, no article is ignored. Note that
  1009. setting this variable to a number might prevent you from reading very
  1010. old articles."
  1011. :group 'gnus-group-select
  1012. :version "22.2"
  1013. :type '(choice (const :tag "No limit" nil)
  1014. integer))
  1015. (gnus-define-group-parameter
  1016. ignored-charsets
  1017. :type list
  1018. :function-document
  1019. "Return the ignored charsets of GROUP."
  1020. :variable gnus-group-ignored-charsets-alist
  1021. :variable-default
  1022. '(("alt\\.chinese\\.text" iso-8859-1))
  1023. :variable-document
  1024. "Alist of regexps (to match group names) and charsets that should be ignored.
  1025. When these charsets are used in the \"charset\" parameter, the
  1026. default charset will be used instead."
  1027. :variable-group gnus-charset
  1028. :variable-type '(repeat (cons (regexp :tag "Group")
  1029. (repeat symbol)))
  1030. :parameter-type '(choice :tag "Ignored charsets"
  1031. :value nil
  1032. (repeat (symbol)))
  1033. :parameter-document "\
  1034. List of charsets that should be ignored.
  1035. When these charsets are used in the \"charset\" parameter, the
  1036. default charset will be used instead.")
  1037. (defcustom gnus-group-highlight-words-alist nil
  1038. "Alist of group regexps and highlight regexps.
  1039. This variable uses the same syntax as `gnus-emphasis-alist'."
  1040. :version "21.1"
  1041. :type '(repeat (cons (regexp :tag "Group")
  1042. (repeat (list (regexp :tag "Highlight regexp")
  1043. (number :tag "Group for entire word" 0)
  1044. (number :tag "Group for displayed part" 0)
  1045. (symbol :tag "Face"
  1046. gnus-emphasis-highlight-words)))))
  1047. :group 'gnus-summary-visual)
  1048. (defcustom gnus-summary-show-article-charset-alist
  1049. nil
  1050. "Alist of number and charset.
  1051. The article will be shown with the charset corresponding to the
  1052. numbered argument.
  1053. For example: ((1 . cn-gb-2312) (2 . big5))."
  1054. :version "21.1"
  1055. :type '(repeat (cons (number :tag "Argument" 1)
  1056. (symbol :tag "Charset")))
  1057. :group 'gnus-charset)
  1058. (defcustom gnus-preserve-marks t
  1059. "Whether marks are preserved when moving, copying and respooling messages."
  1060. :version "21.1"
  1061. :type 'boolean
  1062. :group 'gnus-summary-marks)
  1063. (defcustom gnus-propagate-marks nil
  1064. "If non-nil, Gnus will store and retrieve marks from the backends.
  1065. This means that marks will be stored both in .newsrc.eld and in
  1066. the backend, and will slow operation down somewhat."
  1067. :type 'boolean
  1068. :group 'gnus-summary-marks)
  1069. (defcustom gnus-alter-articles-to-read-function nil
  1070. "Function to be called to alter the list of articles to be selected."
  1071. :type '(choice (const nil) function)
  1072. :group 'gnus-summary)
  1073. (defcustom gnus-orphan-score nil
  1074. "*All orphans get this score added. Set in the score file."
  1075. :group 'gnus-score-default
  1076. :type '(choice (const nil)
  1077. integer))
  1078. (defcustom gnus-summary-save-parts-default-mime "image/.*"
  1079. "*A regexp to match MIME parts when saving multiple parts of a
  1080. message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
  1081. This regexp will be used by default when prompting the user for which
  1082. type of files to save."
  1083. :group 'gnus-summary
  1084. :type 'regexp)
  1085. (defcustom gnus-read-all-available-headers nil
  1086. "Whether Gnus should parse all headers made available to it.
  1087. This is mostly relevant for slow back ends where the user may
  1088. wish to widen the summary buffer to include all headers
  1089. that were fetched."
  1090. :version "22.1"
  1091. :group 'gnus-summary
  1092. :type '(choice boolean regexp))
  1093. (defcustom gnus-summary-pipe-output-default-command nil
  1094. "Command (and optional arguments) used to pipe article to subprocess.
  1095. This will be used as the default command if it is non-nil. The value
  1096. will be updated if you modify it when executing the command
  1097. `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
  1098. :version "23.1" ;; No Gnus
  1099. :group 'gnus-summary
  1100. :type '(radio (const :tag "None" nil) (string :tag "Command")))
  1101. (defcustom gnus-summary-muttprint-program "muttprint"
  1102. "Command (and optional arguments) used to run Muttprint.
  1103. The value will be updated if you modify it when executing the command
  1104. `gnus-summary-muttprint'."
  1105. :version "22.1"
  1106. :group 'gnus-summary
  1107. :type 'string)
  1108. (defcustom gnus-article-loose-mime t
  1109. "If non-nil, don't require MIME-Version header.
  1110. Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
  1111. supply the MIME-Version header or deliberately strip it from the mail.
  1112. If non-nil (the default), Gnus will treat some articles as MIME
  1113. even if the MIME-Version header is missing."
  1114. :version "22.1"
  1115. :type 'boolean
  1116. :group 'gnus-article-mime)
  1117. (defcustom gnus-article-emulate-mime t
  1118. "If non-nil, use MIME emulation for uuencode and the like.
  1119. This means that Gnus will search message bodies for text that look
  1120. like uuencoded bits, yEncoded bits, and so on, and present that using
  1121. the normal Gnus MIME machinery."
  1122. :version "22.1"
  1123. :type 'boolean
  1124. :group 'gnus-article-mime)
  1125. ;;; Internal variables
  1126. (defvar gnus-summary-display-cache nil)
  1127. (defvar gnus-article-mime-handles nil)
  1128. (defvar gnus-article-decoded-p nil)
  1129. (defvar gnus-article-charset nil)
  1130. (defvar gnus-article-ignored-charsets nil)
  1131. (defvar gnus-scores-exclude-files nil)
  1132. (defvar gnus-page-broken nil)
  1133. (defvar gnus-original-article nil)
  1134. (defvar gnus-article-internal-prepare-hook nil)
  1135. (defvar gnus-newsgroup-process-stack nil)
  1136. (defvar gnus-thread-indent-array nil)
  1137. (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
  1138. (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
  1139. "Function called to sort the articles within a thread after it has been gathered together.")
  1140. (defvar gnus-summary-save-parts-type-history nil)
  1141. (defvar gnus-summary-save-parts-last-directory mm-default-directory)
  1142. ;; Avoid highlighting in kill files.
  1143. (defvar gnus-summary-inhibit-highlight nil)
  1144. (defvar gnus-newsgroup-selected-overlay nil)
  1145. (defvar gnus-inhibit-limiting nil)
  1146. (defvar gnus-newsgroup-adaptive-score-file nil)
  1147. (defvar gnus-current-score-file nil)
  1148. (defvar gnus-current-move-group nil)
  1149. (defvar gnus-current-copy-group nil)
  1150. (defvar gnus-current-crosspost-group nil)
  1151. (defvar gnus-newsgroup-display nil)
  1152. (defvar gnus-newsgroup-dependencies nil)
  1153. (defvar gnus-newsgroup-adaptive nil)
  1154. (defvar gnus-summary-display-article-function nil)
  1155. (defvar gnus-summary-highlight-line-function nil
  1156. "Function called after highlighting a summary line.")
  1157. (defvar gnus-summary-line-format-alist
  1158. `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
  1159. (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
  1160. (?s gnus-tmp-subject-or-nil ?s)
  1161. (?n gnus-tmp-name ?s)
  1162. (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
  1163. ?s)
  1164. (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
  1165. gnus-tmp-from) ?s)
  1166. (?F gnus-tmp-from ?s)
  1167. (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
  1168. (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
  1169. (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
  1170. (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
  1171. (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
  1172. (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
  1173. (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
  1174. (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
  1175. (?L gnus-tmp-lines ?s)
  1176. (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
  1177. 0) ?d)
  1178. (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
  1179. "") ?s)
  1180. (?g (or (gnus-group-short-name
  1181. (nnir-article-group (mail-header-number gnus-tmp-header)))
  1182. "") ?s)
  1183. (?O gnus-tmp-downloaded ?c)
  1184. (?I gnus-tmp-indentation ?s)
  1185. (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
  1186. (?R gnus-tmp-replied ?c)
  1187. (?\[ gnus-tmp-opening-bracket ?c)
  1188. (?\] gnus-tmp-closing-bracket ?c)
  1189. (?\> (make-string gnus-tmp-level ? ) ?s)
  1190. (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
  1191. (?i gnus-tmp-score ?d)
  1192. (?z gnus-tmp-score-char ?c)
  1193. (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
  1194. (?U gnus-tmp-unread ?c)
  1195. (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
  1196. ?s)
  1197. (?t (gnus-summary-number-of-articles-in-thread
  1198. (and (boundp 'thread) (car thread)) gnus-tmp-level)
  1199. ?d)
  1200. (?e (gnus-summary-number-of-articles-in-thread
  1201. (and (boundp 'thread) (car thread)) gnus-tmp-level t)
  1202. ?c)
  1203. (?u gnus-tmp-user-defined ?s)
  1204. (?P (gnus-pick-line-number) ?d)
  1205. (?B gnus-tmp-thread-tree-header-string ?s)
  1206. (user-date (gnus-user-date
  1207. ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
  1208. "An alist of format specifications that can appear in summary lines.
  1209. These are paired with what variables they correspond with, along with
  1210. the type of the variable (string, integer, character, etc).")
  1211. (defvar gnus-summary-dummy-line-format-alist
  1212. `((?S gnus-tmp-subject ?s)
  1213. (?N gnus-tmp-number ?d)
  1214. (?u gnus-tmp-user-defined ?s)))
  1215. (defvar gnus-summary-mode-line-format-alist
  1216. `((?G gnus-tmp-group-name ?s)
  1217. (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
  1218. (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
  1219. (?A gnus-tmp-article-number ?d)
  1220. (?Z gnus-tmp-unread-and-unselected ?s)
  1221. (?V gnus-version ?s)
  1222. (?U gnus-tmp-unread-and-unticked ?d)
  1223. (?S gnus-tmp-subject ?s)
  1224. (?e gnus-tmp-unselected ?d)
  1225. (?u gnus-tmp-user-defined ?s)
  1226. (?d (length gnus-newsgroup-dormant) ?d)
  1227. (?t (length gnus-newsgroup-marked) ?d)
  1228. (?h (length gnus-newsgroup-spam-marked) ?d)
  1229. (?r (length gnus-newsgroup-reads) ?d)
  1230. (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
  1231. (?E gnus-newsgroup-expunged-tally ?d)
  1232. (?s (gnus-current-score-file-nondirectory) ?s)))
  1233. ;; This is here rather than in gnus-art for compilation reasons.
  1234. (defvar gnus-article-mode-line-format-alist
  1235. (nconc '((?w (gnus-article-wash-status) ?s)
  1236. (?m (gnus-article-mime-part-status) ?s))
  1237. gnus-summary-mode-line-format-alist))
  1238. (defvar gnus-last-search-regexp nil
  1239. "Default regexp for article search command.")
  1240. (defvar gnus-last-shell-command nil
  1241. "Default shell command on article.")
  1242. (defvar gnus-newsgroup-agentized nil
  1243. "Locally bound in each summary buffer to indicate whether the server has been agentized.")
  1244. (defvar gnus-newsgroup-begin nil)
  1245. (defvar gnus-newsgroup-end nil)
  1246. (defvar gnus-newsgroup-last-rmail nil)
  1247. (defvar gnus-newsgroup-last-mail nil)
  1248. (defvar gnus-newsgroup-last-folder nil)
  1249. (defvar gnus-newsgroup-last-file nil)
  1250. (defvar gnus-newsgroup-last-directory nil)
  1251. (defvar gnus-newsgroup-auto-expire nil)
  1252. (defvar gnus-newsgroup-active nil)
  1253. (defvar gnus-newsgroup-highest nil)
  1254. (defvar gnus-newsgroup-data nil)
  1255. (defvar gnus-newsgroup-data-reverse nil)
  1256. (defvar gnus-newsgroup-limit nil)
  1257. (defvar gnus-newsgroup-limits nil)
  1258. (defvar gnus-summary-use-undownloaded-faces nil)
  1259. (defvar gnus-newsgroup-unreads nil
  1260. "Sorted list of unread articles in the current newsgroup.")
  1261. (defvar gnus-newsgroup-unselected nil
  1262. "Sorted list of unselected unread articles in the current newsgroup.")
  1263. (defvar gnus-newsgroup-reads nil
  1264. "Alist of read articles and article marks in the current newsgroup.")
  1265. (defvar gnus-newsgroup-expunged-tally nil)
  1266. (defvar gnus-newsgroup-marked nil
  1267. "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
  1268. (defvar gnus-newsgroup-spam-marked nil
  1269. "List of ranges of articles that have been marked as spam.")
  1270. (defvar gnus-newsgroup-killed nil
  1271. "List of ranges of articles that have been through the scoring process.")
  1272. (defvar gnus-newsgroup-cached nil
  1273. "Sorted list of articles that come from the article cache.")
  1274. (defvar gnus-newsgroup-saved nil
  1275. "List of articles that have been saved.")
  1276. (defvar gnus-newsgroup-kill-headers nil)
  1277. (defvar gnus-newsgroup-replied nil
  1278. "List of articles that have been replied to in the current newsgroup.")
  1279. (defvar gnus-newsgroup-forwarded nil
  1280. "List of articles that have been forwarded in the current newsgroup.")
  1281. (defvar gnus-newsgroup-expirable nil
  1282. "Sorted list of articles in the current newsgroup that can be expired.")
  1283. (defvar gnus-newsgroup-processable nil
  1284. "List of articles in the current newsgroup that can be processed.")
  1285. (defvar gnus-newsgroup-downloadable nil
  1286. "Sorted list of articles in the current newsgroup that can be processed.")
  1287. (defvar gnus-newsgroup-unfetched nil
  1288. "Sorted list of articles in the current newsgroup whose headers have
  1289. not been fetched into the agent.
  1290. This list will always be a subset of gnus-newsgroup-undownloaded.")
  1291. (defvar gnus-newsgroup-undownloaded nil
  1292. "List of articles in the current newsgroup that haven't been downloaded.")
  1293. (defvar gnus-newsgroup-unsendable nil
  1294. "List of articles in the current newsgroup that won't be sent.")
  1295. (defvar gnus-newsgroup-bookmarks nil
  1296. "List of articles in the current newsgroup that have bookmarks.")
  1297. (defvar gnus-newsgroup-dormant nil
  1298. "Sorted list of dormant articles in the current newsgroup.")
  1299. (defvar gnus-newsgroup-unseen nil
  1300. "List of unseen articles in the current newsgroup.")
  1301. (defvar gnus-newsgroup-seen nil
  1302. "Range of seen articles in the current newsgroup.")
  1303. (defvar gnus-newsgroup-articles nil
  1304. "List of articles in the current newsgroup.")
  1305. (defvar gnus-newsgroup-scored nil
  1306. "List of scored articles in the current newsgroup.")
  1307. (defvar gnus-newsgroup-headers nil
  1308. "List of article headers in the current newsgroup.")
  1309. (defvar gnus-newsgroup-threads nil)
  1310. (defvar gnus-newsgroup-prepared nil
  1311. "Whether the current group has been prepared properly.")
  1312. (defvar gnus-newsgroup-ancient nil
  1313. "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
  1314. (defvar gnus-newsgroup-sparse nil)
  1315. (defvar gnus-current-article nil)
  1316. (defvar gnus-article-current nil)
  1317. (defvar gnus-current-headers nil)
  1318. (defvar gnus-have-all-headers nil)
  1319. (defvar gnus-last-article nil)
  1320. (defvar gnus-newsgroup-history nil)
  1321. (defvar gnus-newsgroup-charset nil)
  1322. (defvar gnus-newsgroup-ephemeral-charset nil)
  1323. (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
  1324. (defvar gnus-article-before-search nil)
  1325. (defvar gnus-summary-local-variables
  1326. '(gnus-newsgroup-name
  1327. ;; Marks lists
  1328. gnus-newsgroup-unreads
  1329. gnus-newsgroup-unselected
  1330. gnus-newsgroup-marked
  1331. gnus-newsgroup-spam-marked
  1332. gnus-newsgroup-reads
  1333. gnus-newsgroup-saved
  1334. gnus-newsgroup-replied
  1335. gnus-newsgroup-forwarded
  1336. gnus-newsgroup-expirable
  1337. gnus-newsgroup-killed
  1338. gnus-newsgroup-unseen
  1339. gnus-newsgroup-seen
  1340. gnus-newsgroup-cached
  1341. gnus-newsgroup-downloadable
  1342. gnus-newsgroup-undownloaded
  1343. gnus-newsgroup-unsendable
  1344. gnus-newsgroup-begin gnus-newsgroup-end
  1345. gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
  1346. gnus-newsgroup-last-folder gnus-newsgroup-last-file
  1347. gnus-newsgroup-last-directory
  1348. gnus-newsgroup-auto-expire
  1349. gnus-newsgroup-processable
  1350. gnus-newsgroup-unfetched
  1351. gnus-newsgroup-articles
  1352. gnus-newsgroup-bookmarks gnus-newsgroup-dormant
  1353. gnus-newsgroup-headers gnus-newsgroup-threads
  1354. gnus-newsgroup-prepared gnus-summary-highlight-line-function
  1355. gnus-current-article gnus-current-headers gnus-have-all-headers
  1356. gnus-last-article gnus-article-internal-prepare-hook
  1357. (gnus-summary-article-delete-hook . global)
  1358. (gnus-summary-article-move-hook . global)
  1359. gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
  1360. gnus-newsgroup-scored gnus-newsgroup-kill-headers
  1361. gnus-thread-expunge-below
  1362. gnus-score-alist gnus-current-score-file
  1363. (gnus-summary-expunge-below . global)
  1364. (gnus-summary-mark-below . global)
  1365. (gnus-orphan-score . global)
  1366. gnus-newsgroup-active gnus-scores-exclude-files
  1367. gnus-newsgroup-highest
  1368. gnus-newsgroup-history gnus-newsgroup-ancient
  1369. gnus-newsgroup-sparse gnus-newsgroup-process-stack
  1370. (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
  1371. gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
  1372. (gnus-newsgroup-expunged-tally . 0)
  1373. gnus-cache-removable-articles
  1374. gnus-newsgroup-data gnus-newsgroup-data-reverse
  1375. gnus-newsgroup-limit gnus-newsgroup-limits
  1376. gnus-newsgroup-charset gnus-newsgroup-display
  1377. gnus-summary-use-undownloaded-faces)
  1378. "Variables that are buffer-local to the summary buffers.")
  1379. (defvar gnus-newsgroup-variables nil
  1380. "A list of variables that have separate values in different newsgroups.
  1381. A list of newsgroup (summary buffer) local variables, or cons of
  1382. variables and their default expressions to be evalled (when the default
  1383. values are not nil), that should be made global while the summary buffer
  1384. is active.
  1385. Note: The default expressions will be evaluated (using function `eval')
  1386. before assignment to the local variable rather than just assigned to it.
  1387. If the default expression is the symbol `global', that symbol will not
  1388. be evaluated but the global value of the local variable will be used
  1389. instead.
  1390. These variables can be used to set variables in the group parameters
  1391. while still allowing them to affect operations done in other buffers.
  1392. For example:
  1393. \(setq gnus-newsgroup-variables
  1394. '(message-use-followup-to
  1395. (gnus-visible-headers .
  1396. \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
  1397. ")
  1398. (eval-when-compile
  1399. ;; Bind features so that require will believe that gnus-sum has
  1400. ;; already been loaded (avoids infinite recursion)
  1401. (let ((features (cons 'gnus-sum features)))
  1402. (require 'gnus-art)))
  1403. ;; MIME stuff.
  1404. (defvar gnus-decode-encoded-word-methods
  1405. '(mail-decode-encoded-word-string)
  1406. "List of methods used to decode encoded words.
  1407. This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
  1408. is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
  1409. \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
  1410. whose names match REGEXP.
  1411. For example:
  1412. \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
  1413. mail-decode-encoded-word-string
  1414. (\"chinese\" . rfc1843-decode-string))")
  1415. (defvar gnus-decode-encoded-word-methods-cache nil)
  1416. (defun gnus-multi-decode-encoded-word-string (string)
  1417. "Apply the functions from `gnus-encoded-word-methods' that match."
  1418. (unless (and gnus-decode-encoded-word-methods-cache
  1419. (eq gnus-newsgroup-name
  1420. (car gnus-decode-encoded-word-methods-cache)))
  1421. (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
  1422. (dolist (method gnus-decode-encoded-word-methods)
  1423. (if (symbolp method)
  1424. (nconc gnus-decode-encoded-word-methods-cache (list method))
  1425. (if (and gnus-newsgroup-name
  1426. (string-match (car method) gnus-newsgroup-name))
  1427. (nconc gnus-decode-encoded-word-methods-cache
  1428. (list (cdr method)))))))
  1429. (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
  1430. (setq string (funcall method string))))
  1431. ;; Subject simplification.
  1432. (defun gnus-simplify-whitespace (str)
  1433. "Remove excessive whitespace from STR."
  1434. ;; Multiple spaces.
  1435. (while (string-match "[ \t][ \t]+" str)
  1436. (setq str (concat (substring str 0 (match-beginning 0))
  1437. " "
  1438. (substring str (match-end 0)))))
  1439. ;; Leading spaces.
  1440. (when (string-match "^[ \t]+" str)
  1441. (setq str (substring str (match-end 0))))
  1442. ;; Trailing spaces.
  1443. (when (string-match "[ \t]+$" str)
  1444. (setq str (substring str 0 (match-beginning 0))))
  1445. str)
  1446. (defun gnus-simplify-all-whitespace (str)
  1447. "Remove all whitespace from STR."
  1448. (while (string-match "[ \t\n]+" str)
  1449. (setq str (replace-match "" nil nil str)))
  1450. str)
  1451. (defsubst gnus-simplify-subject-re (subject)
  1452. "Remove \"Re:\" from subject lines."
  1453. (if (string-match message-subject-re-regexp subject)
  1454. (substring subject (match-end 0))
  1455. subject))
  1456. (defun gnus-simplify-subject (subject &optional re-only)
  1457. "Remove `Re:' and words in parentheses.
  1458. If RE-ONLY is non-nil, strip leading `Re:'s only."
  1459. (let ((case-fold-search t)) ;Ignore case.
  1460. ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
  1461. (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
  1462. (setq subject (substring subject (match-end 0))))
  1463. ;; Remove uninteresting prefixes.
  1464. (when (and (not re-only)
  1465. gnus-simplify-ignored-prefixes
  1466. (string-match gnus-simplify-ignored-prefixes subject))
  1467. (setq subject (substring subject (match-end 0))))
  1468. ;; Remove words in parentheses from end.
  1469. (unless re-only
  1470. (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
  1471. (setq subject (substring subject 0 (match-beginning 0)))))
  1472. ;; Return subject string.
  1473. subject))
  1474. ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
  1475. ;; all whitespace.
  1476. (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
  1477. (goto-char (point-min))
  1478. (while (re-search-forward regexp nil t)
  1479. (replace-match (or newtext ""))))
  1480. (defun gnus-simplify-buffer-fuzzy (regexp)
  1481. "Simplify string in the buffer fuzzily.
  1482. The string in the accessible portion of the current buffer is simplified.
  1483. It is assumed to be a single-line subject.
  1484. Whitespace is generally cleaned up, and miscellaneous leading/trailing
  1485. matter is removed. Additional things can be deleted by setting
  1486. `gnus-simplify-subject-fuzzy-regexp'."
  1487. (let ((case-fold-search t)
  1488. (modified-tick))
  1489. (gnus-simplify-buffer-fuzzy-step "\t" " ")
  1490. (while (not (eq modified-tick (buffer-modified-tick)))
  1491. (setq modified-tick (buffer-modified-tick))
  1492. (cond
  1493. ((listp regexp)
  1494. (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
  1495. (regexp
  1496. (gnus-simplify-buffer-fuzzy-step regexp)))
  1497. (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
  1498. (gnus-simplify-buffer-fuzzy-step
  1499. "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
  1500. (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
  1501. (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
  1502. (gnus-simplify-buffer-fuzzy-step " +" " ")
  1503. (gnus-simplify-buffer-fuzzy-step " $")
  1504. (gnus-simplify-buffer-fuzzy-step "^ +")))
  1505. (defun gnus-simplify-subject-fuzzy (subject)
  1506. "Simplify a subject string fuzzily.
  1507. See `gnus-simplify-buffer-fuzzy' for details."
  1508. (save-excursion
  1509. (let ((regexp gnus-simplify-subject-fuzzy-regexp))
  1510. (gnus-set-work-buffer)
  1511. (let ((case-fold-search t))
  1512. ;; Remove uninteresting prefixes.
  1513. (when (and gnus-simplify-ignored-prefixes
  1514. (string-match gnus-simplify-ignored-prefixes subject))
  1515. (setq subject (substring subject (match-end 0))))
  1516. (insert subject)
  1517. (inline (gnus-simplify-buffer-fuzzy regexp))
  1518. (buffer-string)))))
  1519. (defsubst gnus-simplify-subject-fully (subject)
  1520. "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
  1521. (cond
  1522. (gnus-simplify-subject-functions
  1523. (gnus-map-function gnus-simplify-subject-functions subject))
  1524. ((null gnus-summary-gather-subject-limit)
  1525. (gnus-simplify-subject-re subject))
  1526. ((eq gnus-summary-gather-subject-limit 'fuzzy)
  1527. (gnus-simplify-subject-fuzzy subject))
  1528. ((numberp gnus-summary-gather-subject-limit)
  1529. (truncate-string-to-width (gnus-simplify-subject-re subject)
  1530. gnus-summary-gather-subject-limit))
  1531. (t
  1532. subject)))
  1533. (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
  1534. "Check whether two subjects are equal.
  1535. If optional argument SIMPLE-FIRST is t, first argument is already
  1536. simplified."
  1537. (cond
  1538. ((null simple-first)
  1539. (equal (gnus-simplify-subject-fully s1)
  1540. (gnus-simplify-subject-fully s2)))
  1541. (t
  1542. (equal s1
  1543. (gnus-simplify-subject-fully s2)))))
  1544. (defun gnus-summary-bubble-group ()
  1545. "Increase the score of the current group.
  1546. This is a handy function to add to `gnus-summary-exit-hook' to
  1547. increase the score of each group you read."
  1548. (gnus-group-add-score gnus-newsgroup-name))
  1549. ;;;
  1550. ;;; Gnus summary mode
  1551. ;;;
  1552. (put 'gnus-summary-mode 'mode-class 'special)
  1553. (defvar gnus-article-commands-menu)
  1554. ;; Non-orthogonal keys
  1555. (gnus-define-keys gnus-summary-mode-map
  1556. " " gnus-summary-next-page
  1557. "\177" gnus-summary-prev-page
  1558. [delete] gnus-summary-prev-page
  1559. [backspace] gnus-summary-prev-page
  1560. "\r" gnus-summary-scroll-up
  1561. "\M-\r" gnus-summary-scroll-down
  1562. "n" gnus-summary-next-unread-article
  1563. "p" gnus-summary-prev-unread-article
  1564. "N" gnus-summary-next-article
  1565. "P" gnus-summary-prev-article
  1566. "\M-\C-n" gnus-summary-next-same-subject
  1567. "\M-\C-p" gnus-summary-prev-same-subject
  1568. "\M-n" gnus-summary-next-unread-subject
  1569. "\M-p" gnus-summary-prev-unread-subject
  1570. "." gnus-summary-first-unread-article
  1571. "," gnus-summary-best-unread-article
  1572. "\M-s" gnus-summary-search-article-forward
  1573. "\M-r" gnus-summary-search-article-backward
  1574. "\M-S" gnus-summary-repeat-search-article-forward
  1575. "\M-R" gnus-summary-repeat-search-article-backward
  1576. "<" gnus-summary-beginning-of-article
  1577. ">" gnus-summary-end-of-article
  1578. "j" gnus-summary-goto-article
  1579. "^" gnus-summary-refer-parent-article
  1580. "\M-^" gnus-summary-refer-article
  1581. "u" gnus-summary-tick-article-forward
  1582. "!" gnus-summary-tick-article-forward
  1583. "U" gnus-summary-tick-article-backward
  1584. "d" gnus-summary-mark-as-read-forward
  1585. "D" gnus-summary-mark-as-read-backward
  1586. "E" gnus-summary-mark-as-expirable
  1587. "\M-u" gnus-summary-clear-mark-forward
  1588. "\M-U" gnus-summary-clear-mark-backward
  1589. "k" gnus-summary-kill-same-subject-and-select
  1590. "\C-k" gnus-summary-kill-same-subject
  1591. "\M-\C-k" gnus-summary-kill-thread
  1592. "\M-\C-l" gnus-summary-lower-thread
  1593. "e" gnus-summary-edit-article
  1594. "#" gnus-summary-mark-as-processable
  1595. "\M-#" gnus-summary-unmark-as-processable
  1596. "\M-\C-t" gnus-summary-toggle-threads
  1597. "\M-\C-s" gnus-summary-show-thread
  1598. "\M-\C-h" gnus-summary-hide-thread
  1599. "\M-\C-f" gnus-summary-next-thread
  1600. "\M-\C-b" gnus-summary-prev-thread
  1601. [(meta down)] gnus-summary-next-thread
  1602. [(meta up)] gnus-summary-prev-thread
  1603. "\M-\C-u" gnus-summary-up-thread
  1604. "\M-\C-d" gnus-summary-down-thread
  1605. "&" gnus-summary-execute-command
  1606. "c" gnus-summary-catchup-and-exit
  1607. "\C-w" gnus-summary-mark-region-as-read
  1608. "\C-t" gnus-summary-toggle-truncation
  1609. "?" gnus-summary-mark-as-dormant
  1610. "\C-c\M-\C-s" gnus-summary-limit-include-expunged
  1611. "\C-c\C-s\C-n" gnus-summary-sort-by-number
  1612. "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
  1613. "\C-c\C-s\C-l" gnus-summary-sort-by-lines
  1614. "\C-c\C-s\C-c" gnus-summary-sort-by-chars
  1615. "\C-c\C-s\C-a" gnus-summary-sort-by-author
  1616. "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
  1617. "\C-c\C-s\C-s" gnus-summary-sort-by-subject
  1618. "\C-c\C-s\C-d" gnus-summary-sort-by-date
  1619. "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
  1620. "\C-c\C-s\C-i" gnus-summary-sort-by-score
  1621. "\C-c\C-s\C-o" gnus-summary-sort-by-original
  1622. "\C-c\C-s\C-r" gnus-summary-sort-by-random
  1623. "=" gnus-summary-expand-window
  1624. "\C-x\C-s" gnus-summary-reselect-current-group
  1625. "\M-g" gnus-summary-rescan-group
  1626. "\C-c\C-r" gnus-summary-caesar-message
  1627. "f" gnus-summary-followup
  1628. "F" gnus-summary-followup-with-original
  1629. "C" gnus-summary-cancel-article
  1630. "r" gnus-summary-reply
  1631. "R" gnus-summary-reply-with-original
  1632. "\C-c\C-f" gnus-summary-mail-forward
  1633. "o" gnus-summary-save-article
  1634. "\C-o" gnus-summary-save-article-mail
  1635. "|" gnus-summary-pipe-output
  1636. "\M-k" gnus-summary-edit-local-kill
  1637. "\M-K" gnus-summary-edit-global-kill
  1638. ;; "V" gnus-version
  1639. "\C-c\C-d" gnus-summary-describe-group
  1640. "q" gnus-summary-exit
  1641. "Q" gnus-summary-exit-no-update
  1642. "\C-c\C-i" gnus-info-find-node
  1643. gnus-mouse-2 gnus-mouse-pick-article
  1644. [follow-link] mouse-face
  1645. "m" gnus-summary-mail-other-window
  1646. "a" gnus-summary-post-news
  1647. "x" gnus-summary-limit-to-unread
  1648. "s" gnus-summary-isearch-article
  1649. [tab] gnus-summary-widget-forward
  1650. "t" gnus-summary-toggle-header
  1651. "g" gnus-summary-show-article
  1652. "l" gnus-summary-goto-last-article
  1653. "\C-c\C-v\C-v" gnus-uu-decode-uu-view
  1654. "\C-d" gnus-summary-enter-digest-group
  1655. "\M-\C-d" gnus-summary-read-document
  1656. "\M-\C-e" gnus-summary-edit-parameters
  1657. "\M-\C-a" gnus-summary-customize-parameters
  1658. "\C-c\C-b" gnus-bug
  1659. "*" gnus-cache-enter-article
  1660. "\M-*" gnus-cache-remove-article
  1661. "\M-&" gnus-summary-universal-argument
  1662. "\C-l" gnus-recenter
  1663. "I" gnus-summary-increase-score
  1664. "L" gnus-summary-lower-score
  1665. "\M-i" gnus-symbolic-argument
  1666. "h" gnus-summary-select-article-buffer
  1667. "b" gnus-article-view-part
  1668. "\M-t" gnus-summary-toggle-display-buttonized
  1669. "V" gnus-summary-score-map
  1670. "X" gnus-uu-extract-map
  1671. "S" gnus-summary-send-map)
  1672. ;; Sort of orthogonal keymap
  1673. (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
  1674. "t" gnus-summary-tick-article-forward
  1675. "!" gnus-summary-tick-article-forward
  1676. "d" gnus-summary-mark-as-read-forward
  1677. "r" gnus-summary-mark-as-read-forward
  1678. "c" gnus-summary-clear-mark-forward
  1679. " " gnus-summary-clear-mark-forward
  1680. "e" gnus-summary-mark-as-expirable
  1681. "x" gnus-summary-mark-as-expirable
  1682. "?" gnus-summary-mark-as-dormant
  1683. "b" gnus-summary-set-bookmark
  1684. "B" gnus-summary-remove-bookmark
  1685. "#" gnus-summary-mark-as-processable
  1686. "\M-#" gnus-summary-unmark-as-processable
  1687. "S" gnus-summary-limit-include-expunged
  1688. "C" gnus-summary-catchup
  1689. "H" gnus-summary-catchup-to-here
  1690. "h" gnus-summary-catchup-from-here
  1691. "\C-c" gnus-summary-catchup-all
  1692. "k" gnus-summary-kill-same-subject-and-select
  1693. "K" gnus-summary-kill-same-subject
  1694. "P" gnus-uu-mark-map)
  1695. (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
  1696. "c" gnus-summary-clear-above
  1697. "u" gnus-summary-tick-above
  1698. "m" gnus-summary-mark-above
  1699. "k" gnus-summary-kill-below)
  1700. (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
  1701. "/" gnus-summary-limit-to-subject
  1702. "n" gnus-summary-limit-to-articles
  1703. "b" gnus-summary-limit-to-bodies
  1704. "h" gnus-summary-limit-to-headers
  1705. "w" gnus-summary-pop-limit
  1706. "s" gnus-summary-limit-to-subject
  1707. "a" gnus-summary-limit-to-author
  1708. "u" gnus-summary-limit-to-unread
  1709. "m" gnus-summary-limit-to-marks
  1710. "M" gnus-summary-limit-exclude-marks
  1711. "v" gnus-summary-limit-to-score
  1712. "*" gnus-summary-limit-include-cached
  1713. "D" gnus-summary-limit-include-dormant
  1714. "T" gnus-summary-limit-include-thread
  1715. "d" gnus-summary-limit-exclude-dormant
  1716. "t" gnus-summary-limit-to-age
  1717. "." gnus-summary-limit-to-unseen
  1718. "x" gnus-summary-limit-to-extra
  1719. "p" gnus-summary-limit-to-display-predicate
  1720. "E" gnus-summary-limit-include-expunged
  1721. "c" gnus-summary-limit-exclude-childless-dormant
  1722. "C" gnus-summary-limit-mark-excluded-as-read
  1723. "o" gnus-summary-insert-old-articles
  1724. "N" gnus-summary-insert-new-articles
  1725. "S" gnus-summary-limit-to-singletons
  1726. "r" gnus-summary-limit-to-replied
  1727. "R" gnus-summary-limit-to-recipient
  1728. "A" gnus-summary-limit-to-address)
  1729. (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
  1730. "n" gnus-summary-next-unread-article
  1731. "p" gnus-summary-prev-unread-article
  1732. "N" gnus-summary-next-article
  1733. "P" gnus-summary-prev-article
  1734. "\C-n" gnus-summary-next-same-subject
  1735. "\C-p" gnus-summary-prev-same-subject
  1736. "\M-n" gnus-summary-next-unread-subject
  1737. "\M-p" gnus-summary-prev-unread-subject
  1738. "f" gnus-summary-first-unread-article
  1739. "b" gnus-summary-best-unread-article
  1740. "j" gnus-summary-goto-article
  1741. "g" gnus-summary-goto-subject
  1742. "l" gnus-summary-goto-last-article
  1743. "o" gnus-summary-pop-article)
  1744. (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
  1745. "k" gnus-summary-kill-thread
  1746. "E" gnus-summary-expire-thread
  1747. "l" gnus-summary-lower-thread
  1748. "i" gnus-summary-raise-thread
  1749. "T" gnus-summary-toggle-threads
  1750. "t" gnus-summary-rethread-current
  1751. "^" gnus-summary-reparent-thread
  1752. "\M-^" gnus-summary-reparent-children
  1753. "s" gnus-summary-show-thread
  1754. "S" gnus-summary-show-all-threads
  1755. "h" gnus-summary-hide-thread
  1756. "H" gnus-summary-hide-all-threads
  1757. "n" gnus-summary-next-thread
  1758. "p" gnus-summary-prev-thread
  1759. "u" gnus-summary-up-thread
  1760. "o" gnus-summary-top-thread
  1761. "d" gnus-summary-down-thread
  1762. "#" gnus-uu-mark-thread
  1763. "\M-#" gnus-uu-unmark-thread)
  1764. (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
  1765. "g" gnus-summary-prepare
  1766. "c" gnus-summary-insert-cached-articles
  1767. "d" gnus-summary-insert-dormant-articles
  1768. "t" gnus-summary-insert-ticked-articles)
  1769. (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
  1770. "c" gnus-summary-catchup-and-exit
  1771. "C" gnus-summary-catchup-all-and-exit
  1772. "E" gnus-summary-exit-no-update
  1773. "Q" gnus-summary-exit
  1774. "Z" gnus-summary-exit
  1775. "n" gnus-summary-catchup-and-goto-next-group
  1776. "p" gnus-summary-catchup-and-goto-prev-group
  1777. "R" gnus-summary-reselect-current-group
  1778. "G" gnus-summary-rescan-group
  1779. "N" gnus-summary-next-group
  1780. "s" gnus-summary-save-newsrc
  1781. "P" gnus-summary-prev-group)
  1782. (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
  1783. " " gnus-summary-next-page
  1784. "n" gnus-summary-next-page
  1785. "\177" gnus-summary-prev-page
  1786. [delete] gnus-summary-prev-page
  1787. "p" gnus-summary-prev-page
  1788. "\r" gnus-summary-scroll-up
  1789. "\M-\r" gnus-summary-scroll-down
  1790. "<" gnus-summary-beginning-of-article
  1791. ">" gnus-summary-end-of-article
  1792. "b" gnus-summary-beginning-of-article
  1793. "e" gnus-summary-end-of-article
  1794. "^" gnus-summary-refer-parent-article
  1795. "r" gnus-summary-refer-parent-article
  1796. "C" gnus-summary-show-complete-article
  1797. "D" gnus-summary-enter-digest-group
  1798. "R" gnus-summary-refer-references
  1799. "T" gnus-summary-refer-thread
  1800. "W" gnus-warp-to-article
  1801. "g" gnus-summary-show-article
  1802. "s" gnus-summary-isearch-article
  1803. [tab] gnus-summary-widget-forward
  1804. "P" gnus-summary-print-article
  1805. "S" gnus-sticky-article
  1806. "M" gnus-mailing-list-insinuate
  1807. "t" gnus-article-babel)
  1808. (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
  1809. "b" gnus-article-add-buttons
  1810. "B" gnus-article-add-buttons-to-head
  1811. "o" gnus-article-treat-overstrike
  1812. "e" gnus-article-emphasize
  1813. "w" gnus-article-fill-cited-article
  1814. "Q" gnus-article-fill-long-lines
  1815. "L" gnus-article-toggle-truncate-lines
  1816. "C" gnus-article-capitalize-sentences
  1817. "c" gnus-article-remove-cr
  1818. "q" gnus-article-de-quoted-unreadable
  1819. "6" gnus-article-de-base64-unreadable
  1820. "Z" gnus-article-decode-HZ
  1821. "A" gnus-article-treat-ansi-sequences
  1822. "h" gnus-article-wash-html
  1823. "u" gnus-article-unsplit-urls
  1824. "s" gnus-summary-force-verify-and-decrypt
  1825. "f" gnus-article-display-x-face
  1826. "l" gnus-summary-stop-page-breaking
  1827. "r" gnus-summary-caesar-message
  1828. "m" gnus-summary-morse-message
  1829. "t" gnus-summary-toggle-header
  1830. "g" gnus-treat-smiley
  1831. "v" gnus-summary-verbose-headers
  1832. "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
  1833. "p" gnus-article-verify-x-pgp-sig
  1834. "d" gnus-article-treat-dumbquotes
  1835. "U" gnus-article-treat-non-ascii
  1836. "i" gnus-summary-idna-message)
  1837. (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
  1838. ;; mnemonic: deuglif*Y*
  1839. "u" gnus-article-outlook-unwrap-lines
  1840. "a" gnus-article-outlook-repair-attribution
  1841. "c" gnus-article-outlook-rearrange-citation
  1842. "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
  1843. (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
  1844. "a" gnus-article-hide
  1845. "h" gnus-article-hide-headers
  1846. "b" gnus-article-hide-boring-headers
  1847. "s" gnus-article-hide-signature
  1848. "c" gnus-article-hide-citation
  1849. "C" gnus-article-hide-citation-in-followups
  1850. "l" gnus-article-hide-list-identifiers
  1851. "B" gnus-article-strip-banner
  1852. "P" gnus-article-hide-pem
  1853. "\C-c" gnus-article-hide-citation-maybe)
  1854. (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
  1855. "a" gnus-article-highlight
  1856. "h" gnus-article-highlight-headers
  1857. "c" gnus-article-highlight-citation
  1858. "s" gnus-article-highlight-signature)
  1859. (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
  1860. "f" gnus-article-treat-fold-headers
  1861. "u" gnus-article-treat-unfold-headers
  1862. "n" gnus-article-treat-fold-newsgroups)
  1863. (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
  1864. "x" gnus-article-display-x-face
  1865. "d" gnus-article-display-face
  1866. "s" gnus-treat-smiley
  1867. "D" gnus-article-remove-images
  1868. "W" gnus-article-show-images
  1869. "f" gnus-treat-from-picon
  1870. "m" gnus-treat-mail-picon
  1871. "n" gnus-treat-newsgroups-picon
  1872. "g" gnus-treat-from-gravatar
  1873. "h" gnus-treat-mail-gravatar)
  1874. (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
  1875. "w" gnus-article-decode-mime-words
  1876. "c" gnus-article-decode-charset
  1877. "v" gnus-mime-view-all-parts
  1878. "b" gnus-article-view-part)
  1879. (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
  1880. "z" gnus-article-date-ut
  1881. "u" gnus-article-date-ut
  1882. "l" gnus-article-date-local
  1883. "p" gnus-article-date-english
  1884. "e" gnus-article-date-lapsed
  1885. "o" gnus-article-date-original
  1886. "i" gnus-article-date-iso8601
  1887. "s" gnus-article-date-user)
  1888. (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
  1889. "t" gnus-article-remove-trailing-blank-lines
  1890. "l" gnus-article-strip-leading-blank-lines
  1891. "m" gnus-article-strip-multiple-blank-lines
  1892. "a" gnus-article-strip-blank-lines
  1893. "A" gnus-article-strip-all-blank-lines
  1894. "s" gnus-article-strip-leading-space
  1895. "e" gnus-article-strip-trailing-space
  1896. "w" gnus-article-remove-leading-whitespace)
  1897. (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
  1898. "v" gnus-version
  1899. "d" gnus-summary-describe-group
  1900. "h" gnus-summary-describe-briefly
  1901. "i" gnus-info-find-node)
  1902. (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
  1903. "e" gnus-summary-expire-articles
  1904. "\M-\C-e" gnus-summary-expire-articles-now
  1905. "\177" gnus-summary-delete-article
  1906. [delete] gnus-summary-delete-article
  1907. [backspace] gnus-summary-delete-article
  1908. "m" gnus-summary-move-article
  1909. "r" gnus-summary-respool-article
  1910. "w" gnus-summary-edit-article
  1911. "c" gnus-summary-copy-article
  1912. "B" gnus-summary-crosspost-article
  1913. "q" gnus-summary-respool-query
  1914. "t" gnus-summary-respool-trace
  1915. "i" gnus-summary-import-article
  1916. "I" gnus-summary-create-article
  1917. "p" gnus-summary-article-posted-p)
  1918. (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
  1919. "o" gnus-summary-save-article
  1920. "m" gnus-summary-save-article-mail
  1921. "F" gnus-summary-write-article-file
  1922. "r" gnus-summary-save-article-rmail
  1923. "f" gnus-summary-save-article-file
  1924. "b" gnus-summary-save-article-body-file
  1925. "B" gnus-summary-write-article-body-file
  1926. "h" gnus-summary-save-article-folder
  1927. "v" gnus-summary-save-article-vm
  1928. "p" gnus-summary-pipe-output
  1929. "P" gnus-summary-muttprint)
  1930. (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
  1931. "b" gnus-summary-display-buttonized
  1932. "m" gnus-summary-repair-multipart
  1933. "v" gnus-article-view-part
  1934. "o" gnus-article-save-part
  1935. "O" gnus-article-save-part-and-strip
  1936. "r" gnus-article-replace-part
  1937. "d" gnus-article-delete-part
  1938. "t" gnus-article-view-part-as-type
  1939. "j" gnus-article-jump-to-part
  1940. "c" gnus-article-copy-part
  1941. "C" gnus-article-view-part-as-charset
  1942. "e" gnus-article-view-part-externally
  1943. "H" gnus-article-browse-html-article
  1944. "E" gnus-article-encrypt-body
  1945. "i" gnus-article-inline-part
  1946. "|" gnus-article-pipe-part)
  1947. (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
  1948. "p" gnus-summary-mark-as-processable
  1949. "u" gnus-summary-unmark-as-processable
  1950. "U" gnus-summary-unmark-all-processable
  1951. "v" gnus-uu-mark-over
  1952. "s" gnus-uu-mark-series
  1953. "r" gnus-uu-mark-region
  1954. "g" gnus-uu-unmark-region
  1955. "R" gnus-uu-mark-by-regexp
  1956. "G" gnus-uu-unmark-by-regexp
  1957. "t" gnus-uu-mark-thread
  1958. "T" gnus-uu-unmark-thread
  1959. "a" gnus-uu-mark-all
  1960. "b" gnus-uu-mark-buffer
  1961. "S" gnus-uu-mark-sparse
  1962. "k" gnus-summary-kill-process-mark
  1963. "y" gnus-summary-yank-process-mark
  1964. "w" gnus-summary-save-process-mark
  1965. "i" gnus-uu-invert-processable)
  1966. (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
  1967. ;;"x" gnus-uu-extract-any
  1968. "m" gnus-summary-save-parts
  1969. "u" gnus-uu-decode-uu
  1970. "U" gnus-uu-decode-uu-and-save
  1971. "s" gnus-uu-decode-unshar
  1972. "S" gnus-uu-decode-unshar-and-save
  1973. "o" gnus-uu-decode-save
  1974. "O" gnus-uu-decode-save
  1975. "b" gnus-uu-decode-binhex
  1976. "B" gnus-uu-decode-binhex
  1977. "Y" gnus-uu-decode-yenc
  1978. "p" gnus-uu-decode-postscript
  1979. "P" gnus-uu-decode-postscript-and-save)
  1980. (gnus-define-keys
  1981. (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
  1982. "u" gnus-uu-decode-uu-view
  1983. "U" gnus-uu-decode-uu-and-save-view
  1984. "s" gnus-uu-decode-unshar-view
  1985. "S" gnus-uu-decode-unshar-and-save-view
  1986. "o" gnus-uu-decode-save-view
  1987. "O" gnus-uu-decode-save-view
  1988. "b" gnus-uu-decode-binhex-view
  1989. "B" gnus-uu-decode-binhex-view
  1990. "p" gnus-uu-decode-postscript-view
  1991. "P" gnus-uu-decode-postscript-and-save-view)
  1992. (defvar gnus-article-post-menu nil)
  1993. (defconst gnus-summary-menu-maxlen 20)
  1994. (defun gnus-summary-menu-split (menu)
  1995. ;; If we have lots of elements, divide them into groups of 20
  1996. ;; and make a pane (or submenu) for each one.
  1997. (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
  1998. (let ((menu menu) sublists next
  1999. (i 1))
  2000. (while menu
  2001. ;; Pull off the next gnus-summary-menu-maxlen elements
  2002. ;; and make them the next element of sublist.
  2003. (setq next (nthcdr gnus-summary-menu-maxlen menu))
  2004. (if next
  2005. (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
  2006. nil))
  2007. (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
  2008. (aref (car (last menu)) 0)) menu)
  2009. sublists))
  2010. (setq i (1+ i))
  2011. (setq menu next))
  2012. (nreverse sublists))
  2013. ;; Few elements--put them all in one pane.
  2014. menu))
  2015. (defun gnus-summary-make-menu-bar ()
  2016. (gnus-turn-off-edit-menu 'summary)
  2017. (unless (boundp 'gnus-summary-misc-menu)
  2018. (easy-menu-define
  2019. gnus-summary-kill-menu gnus-summary-mode-map ""
  2020. (cons
  2021. "Score"
  2022. (nconc
  2023. (list
  2024. ["Customize" gnus-score-customize t])
  2025. (gnus-make-score-map 'increase)
  2026. (gnus-make-score-map 'lower)
  2027. '(("Mark"
  2028. ["Kill below" gnus-summary-kill-below t]
  2029. ["Mark above" gnus-summary-mark-above t]
  2030. ["Tick above" gnus-summary-tick-above t]
  2031. ["Clear above" gnus-summary-clear-above t])
  2032. ["Current score" gnus-summary-current-score t]
  2033. ["Set score" gnus-summary-set-score t]
  2034. ["Switch current score file..." gnus-score-change-score-file t]
  2035. ["Set mark below..." gnus-score-set-mark-below t]
  2036. ["Set expunge below..." gnus-score-set-expunge-below t]
  2037. ["Edit current score file" gnus-score-edit-current-scores t]
  2038. ["Edit score file..." gnus-score-edit-file t]
  2039. ["Trace score" gnus-score-find-trace t]
  2040. ["Find words" gnus-score-find-favourite-words t]
  2041. ["Rescore buffer" gnus-summary-rescore t]
  2042. ["Increase score..." gnus-summary-increase-score t]
  2043. ["Lower score..." gnus-summary-lower-score t]))))
  2044. ;; Define both the Article menu in the summary buffer and the
  2045. ;; equivalent Commands menu in the article buffer here for
  2046. ;; consistency.
  2047. (let ((innards
  2048. `(("Hide"
  2049. ["All" gnus-article-hide t]
  2050. ["Headers" gnus-article-hide-headers t]
  2051. ["Signature" gnus-article-hide-signature t]
  2052. ["Citation" gnus-article-hide-citation t]
  2053. ["List identifiers" gnus-article-hide-list-identifiers t]
  2054. ["Banner" gnus-article-strip-banner t]
  2055. ["Boring headers" gnus-article-hide-boring-headers t])
  2056. ("Highlight"
  2057. ["All" gnus-article-highlight t]
  2058. ["Headers" gnus-article-highlight-headers t]
  2059. ["Signature" gnus-article-highlight-signature t]
  2060. ["Citation" gnus-article-highlight-citation t])
  2061. ("MIME"
  2062. ["Words" gnus-article-decode-mime-words t]
  2063. ["Charset" gnus-article-decode-charset t]
  2064. ["QP" gnus-article-de-quoted-unreadable t]
  2065. ["Base64" gnus-article-de-base64-unreadable t]
  2066. ["View MIME buttons" gnus-summary-display-buttonized t]
  2067. ["View all" gnus-mime-view-all-parts t]
  2068. ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
  2069. ["Encrypt body" gnus-article-encrypt-body
  2070. :active (not (gnus-group-read-only-p))
  2071. ,@(if (featurep 'xemacs) nil
  2072. '(:help "Encrypt the message body on disk"))]
  2073. ["Extract all parts..." gnus-summary-save-parts t]
  2074. ("Multipart"
  2075. ["Repair multipart" gnus-summary-repair-multipart t]
  2076. ["Pipe part..." gnus-article-pipe-part t]
  2077. ["Inline part" gnus-article-inline-part t]
  2078. ["View part as type..." gnus-article-view-part-as-type t]
  2079. ["Encrypt body" gnus-article-encrypt-body
  2080. :active (not (gnus-group-read-only-p))
  2081. ,@(if (featurep 'xemacs) nil
  2082. '(:help "Encrypt the message body on disk"))]
  2083. ["View part externally" gnus-article-view-part-externally t]
  2084. ["View HTML parts in browser" gnus-article-browse-html-article t]
  2085. ["View part with charset..." gnus-article-view-part-as-charset t]
  2086. ["Copy part" gnus-article-copy-part t]
  2087. ["Save part..." gnus-article-save-part t]
  2088. ["View part" gnus-article-view-part t]))
  2089. ("Date"
  2090. ["Local" gnus-article-date-local t]
  2091. ["ISO8601" gnus-article-date-iso8601 t]
  2092. ["UT" gnus-article-date-ut t]
  2093. ["Original" gnus-article-date-original t]
  2094. ["Lapsed" gnus-article-date-lapsed t]
  2095. ["User-defined" gnus-article-date-user t])
  2096. ("Display"
  2097. ["Remove images" gnus-article-remove-images t]
  2098. ["Toggle smiley" gnus-treat-smiley t]
  2099. ["Show X-Face" gnus-article-display-x-face t]
  2100. ["Show picons in From" gnus-treat-from-picon t]
  2101. ["Show picons in mail headers" gnus-treat-mail-picon t]
  2102. ["Show picons in news headers" gnus-treat-newsgroups-picon t]
  2103. ["Show Gravatars in From" gnus-treat-from-gravatar t]
  2104. ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
  2105. ("View as different encoding"
  2106. ,@(gnus-summary-menu-split
  2107. (mapcar
  2108. (lambda (cs)
  2109. ;; Since easymenu under Emacs doesn't allow
  2110. ;; lambda forms for menu commands, we should
  2111. ;; provide intern'ed function symbols.
  2112. (let ((command (intern (format "\
  2113. gnus-summary-show-article-from-menu-as-charset-%s" cs))))
  2114. (fset command
  2115. `(lambda ()
  2116. (interactive)
  2117. (let ((gnus-summary-show-article-charset-alist
  2118. '((1 . ,cs))))
  2119. (gnus-summary-show-article 1))))
  2120. `[,(symbol-name cs) ,command t]))
  2121. (sort (if (fboundp 'coding-system-list)
  2122. (coding-system-list)
  2123. (mapcar 'car mm-mime-mule-charset-alist))
  2124. 'string<)))))
  2125. ("Washing"
  2126. ("Remove Blanks"
  2127. ["Leading" gnus-article-strip-leading-blank-lines t]
  2128. ["Multiple" gnus-article-strip-multiple-blank-lines t]
  2129. ["Trailing" gnus-article-remove-trailing-blank-lines t]
  2130. ["All of the above" gnus-article-strip-blank-lines t]
  2131. ["All" gnus-article-strip-all-blank-lines t]
  2132. ["Leading space" gnus-article-strip-leading-space t]
  2133. ["Trailing space" gnus-article-strip-trailing-space t]
  2134. ["Leading space in headers"
  2135. gnus-article-remove-leading-whitespace t])
  2136. ["Overstrike" gnus-article-treat-overstrike t]
  2137. ["Dumb quotes" gnus-article-treat-dumbquotes t]
  2138. ["Non-ASCII" gnus-article-treat-non-ascii t]
  2139. ["Emphasis" gnus-article-emphasize t]
  2140. ["Word wrap" gnus-article-fill-cited-article t]
  2141. ["Fill long lines" gnus-article-fill-long-lines t]
  2142. ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
  2143. ["Capitalize sentences" gnus-article-capitalize-sentences t]
  2144. ["Remove CR" gnus-article-remove-cr t]
  2145. ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
  2146. ["Base64" gnus-article-de-base64-unreadable t]
  2147. ["Rot 13" gnus-summary-caesar-message
  2148. ,@(if (featurep 'xemacs) '(t)
  2149. '(:help "\"Caesar rotate\" article by 13"))]
  2150. ["De-IDNA" gnus-summary-idna-message t]
  2151. ["Morse decode" gnus-summary-morse-message t]
  2152. ["Unix pipe..." gnus-summary-pipe-message t]
  2153. ["Add buttons" gnus-article-add-buttons t]
  2154. ["Add buttons to head" gnus-article-add-buttons-to-head t]
  2155. ["Stop page breaking" gnus-summary-stop-page-breaking t]
  2156. ["Verbose header" gnus-summary-verbose-headers t]
  2157. ["Toggle header" gnus-summary-toggle-header t]
  2158. ["Unfold headers" gnus-article-treat-unfold-headers t]
  2159. ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
  2160. ["Html" gnus-article-wash-html t]
  2161. ["Unsplit URLs" gnus-article-unsplit-urls t]
  2162. ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
  2163. ["Decode HZ" gnus-article-decode-HZ t]
  2164. ["ANSI sequences" gnus-article-treat-ansi-sequences t]
  2165. ("(Outlook) Deuglify"
  2166. ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
  2167. ["Repair attribution" gnus-article-outlook-repair-attribution t]
  2168. ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
  2169. ["Full (Outlook) deuglify"
  2170. gnus-article-outlook-deuglify-article t])
  2171. )
  2172. ("Output"
  2173. ["Save in default format..." gnus-summary-save-article
  2174. ,@(if (featurep 'xemacs) '(t)
  2175. '(:help "Save article using default method"))]
  2176. ["Save in file..." gnus-summary-save-article-file
  2177. ,@(if (featurep 'xemacs) '(t)
  2178. '(:help "Save article in file"))]
  2179. ["Save in Unix mail format..." gnus-summary-save-article-mail t]
  2180. ["Save in MH folder..." gnus-summary-save-article-folder t]
  2181. ["Save in VM folder..." gnus-summary-save-article-vm t]
  2182. ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
  2183. ["Save body in file..." gnus-summary-save-article-body-file t]
  2184. ["Pipe through a filter..." gnus-summary-pipe-output t]
  2185. ["Print with Muttprint..." gnus-summary-muttprint t]
  2186. ["Print" gnus-summary-print-article
  2187. ,@(if (featurep 'xemacs) '(t)
  2188. '(:help "Generate and print a PostScript image"))])
  2189. ("Copy, move,... (Backend)"
  2190. ,@(if (featurep 'xemacs) nil
  2191. '(:help "Copying, moving, expiring articles..."))
  2192. ["Respool article..." gnus-summary-respool-article t]
  2193. ["Move article..." gnus-summary-move-article
  2194. (gnus-check-backend-function
  2195. 'request-move-article gnus-newsgroup-name)]
  2196. ["Copy article..." gnus-summary-copy-article t]
  2197. ["Crosspost article..." gnus-summary-crosspost-article
  2198. (gnus-check-backend-function
  2199. 'request-replace-article gnus-newsgroup-name)]
  2200. ["Import file..." gnus-summary-import-article
  2201. (gnus-check-backend-function
  2202. 'request-accept-article gnus-newsgroup-name)]
  2203. ["Create article..." gnus-summary-create-article
  2204. (gnus-check-backend-function
  2205. 'request-accept-article gnus-newsgroup-name)]
  2206. ["Check if posted" gnus-summary-article-posted-p t]
  2207. ["Edit article" gnus-summary-edit-article
  2208. (not (gnus-group-read-only-p))]
  2209. ["Delete article" gnus-summary-delete-article
  2210. (gnus-check-backend-function
  2211. 'request-expire-articles gnus-newsgroup-name)]
  2212. ["Query respool" gnus-summary-respool-query t]
  2213. ["Trace respool" gnus-summary-respool-trace t]
  2214. ["Delete expirable articles" gnus-summary-expire-articles-now
  2215. (gnus-check-backend-function
  2216. 'request-expire-articles gnus-newsgroup-name)])
  2217. ("Extract"
  2218. ["Uudecode" gnus-uu-decode-uu
  2219. ,@(if (featurep 'xemacs) '(t)
  2220. '(:help "Decode uuencoded article(s)"))]
  2221. ["Uudecode and save" gnus-uu-decode-uu-and-save t]
  2222. ["Unshar" gnus-uu-decode-unshar t]
  2223. ["Unshar and save" gnus-uu-decode-unshar-and-save t]
  2224. ["Save" gnus-uu-decode-save t]
  2225. ["Binhex" gnus-uu-decode-binhex t]
  2226. ["PostScript" gnus-uu-decode-postscript t]
  2227. ["All MIME parts" gnus-summary-save-parts t])
  2228. ("Cache"
  2229. ["Enter article" gnus-cache-enter-article t]
  2230. ["Remove article" gnus-cache-remove-article t])
  2231. ["Translate" gnus-article-babel t]
  2232. ["Select article buffer" gnus-summary-select-article-buffer t]
  2233. ["Make article buffer sticky" gnus-sticky-article t]
  2234. ["Enter digest buffer" gnus-summary-enter-digest-group t]
  2235. ["Isearch article..." gnus-summary-isearch-article t]
  2236. ["Beginning of the article" gnus-summary-beginning-of-article t]
  2237. ["End of the article" gnus-summary-end-of-article t]
  2238. ["Fetch parent of article" gnus-summary-refer-parent-article t]
  2239. ["Fetch referenced articles" gnus-summary-refer-references t]
  2240. ["Fetch current thread" gnus-summary-refer-thread t]
  2241. ["Fetch article with id..." gnus-summary-refer-article t]
  2242. ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
  2243. ["Redisplay" gnus-summary-show-article t]
  2244. ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
  2245. (easy-menu-define
  2246. gnus-summary-article-menu gnus-summary-mode-map ""
  2247. (cons "Article" innards))
  2248. (if (not (keymapp gnus-summary-article-menu))
  2249. (easy-menu-define
  2250. gnus-article-commands-menu gnus-article-mode-map ""
  2251. (cons "Commands" innards))
  2252. ;; in Emacs, don't share menu.
  2253. (setq gnus-article-commands-menu
  2254. (copy-keymap gnus-summary-article-menu))
  2255. (define-key gnus-article-mode-map [menu-bar commands]
  2256. (cons "Commands" gnus-article-commands-menu))))
  2257. (easy-menu-define
  2258. gnus-summary-thread-menu gnus-summary-mode-map ""
  2259. '("Threads"
  2260. ["Find all messages in thread" gnus-summary-refer-thread t]
  2261. ["Toggle threading" gnus-summary-toggle-threads t]
  2262. ["Hide threads" gnus-summary-hide-all-threads t]
  2263. ["Show threads" gnus-summary-show-all-threads t]
  2264. ["Hide thread" gnus-summary-hide-thread t]
  2265. ["Show thread" gnus-summary-show-thread t]
  2266. ["Go to next thread" gnus-summary-next-thread t]
  2267. ["Go to previous thread" gnus-summary-prev-thread t]
  2268. ["Go down thread" gnus-summary-down-thread t]
  2269. ["Go up thread" gnus-summary-up-thread t]
  2270. ["Top of thread" gnus-summary-top-thread t]
  2271. ["Mark thread as read" gnus-summary-kill-thread t]
  2272. ["Mark thread as expired" gnus-summary-expire-thread t]
  2273. ["Lower thread score" gnus-summary-lower-thread t]
  2274. ["Raise thread score" gnus-summary-raise-thread t]
  2275. ["Rethread current" gnus-summary-rethread-current t]))
  2276. (easy-menu-define
  2277. gnus-summary-post-menu gnus-summary-mode-map ""
  2278. `("Post"
  2279. ["Send a message (mail or news)" gnus-summary-post-news
  2280. ,@(if (featurep 'xemacs) '(t)
  2281. '(:help "Compose a new message (mail or news)"))]
  2282. ["Followup" gnus-summary-followup
  2283. ,@(if (featurep 'xemacs) '(t)
  2284. '(:help "Post followup to this article"))]
  2285. ["Followup and yank" gnus-summary-followup-with-original
  2286. ,@(if (featurep 'xemacs) '(t)
  2287. '(:help "Post followup to this article, quoting its contents"))]
  2288. ["Supersede article" gnus-summary-supersede-article t]
  2289. ["Cancel article" gnus-summary-cancel-article
  2290. ,@(if (featurep 'xemacs) '(t)
  2291. '(:help "Cancel an article you posted"))]
  2292. ["Reply" gnus-summary-reply t]
  2293. ["Reply and yank" gnus-summary-reply-with-original t]
  2294. ["Wide reply" gnus-summary-wide-reply t]
  2295. ["Wide reply and yank" gnus-summary-wide-reply-with-original
  2296. ,@(if (featurep 'xemacs) '(t)
  2297. '(:help "Mail a reply, quoting this article"))]
  2298. ["Very wide reply" gnus-summary-very-wide-reply t]
  2299. ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
  2300. ,@(if (featurep 'xemacs) '(t)
  2301. '(:help "Mail a very wide reply, quoting this article"))]
  2302. ["Mail forward" gnus-summary-mail-forward t]
  2303. ["Post forward" gnus-summary-post-forward t]
  2304. ["Digest and mail" gnus-uu-digest-mail-forward t]
  2305. ["Digest and post" gnus-uu-digest-post-forward t]
  2306. ["Resend message" gnus-summary-resend-message t]
  2307. ["Resend message edit" gnus-summary-resend-message-edit t]
  2308. ["Send bounced mail" gnus-summary-resend-bounced-mail t]
  2309. ["Send a mail" gnus-summary-mail-other-window t]
  2310. ["Create a local message" gnus-summary-news-other-window t]
  2311. ["Uuencode and post" gnus-uu-post-news
  2312. ,@(if (featurep 'xemacs) '(t)
  2313. '(:help "Post a uuencoded article"))]
  2314. ["Followup via news" gnus-summary-followup-to-mail t]
  2315. ["Followup via news and yank"
  2316. gnus-summary-followup-to-mail-with-original t]
  2317. ["Strip signature on reply"
  2318. (lambda ()
  2319. (interactive)
  2320. (if (not (memq message-cite-function
  2321. '(message-cite-original-without-signature
  2322. message-cite-original)))
  2323. ;; Stupid workaround for XEmacs not honoring :visible.
  2324. (message "Can't toggle this value of `message-cite-function'")
  2325. (setq message-cite-function
  2326. (if (eq message-cite-function
  2327. 'message-cite-original-without-signature)
  2328. 'message-cite-original
  2329. 'message-cite-original-without-signature))))
  2330. ;; XEmacs barfs on :visible.
  2331. ,@(if (featurep 'xemacs) nil
  2332. '(:visible (memq message-cite-function
  2333. '(message-cite-original-without-signature
  2334. message-cite-original))))
  2335. :style toggle
  2336. :selected (eq message-cite-function
  2337. 'message-cite-original-without-signature)
  2338. ,@(if (featurep 'xemacs) nil
  2339. '(:help "Strip signature from cited article when replying."))]
  2340. ;;("Draft"
  2341. ;;["Send" gnus-summary-send-draft t]
  2342. ;;["Send bounced" gnus-resend-bounced-mail t])
  2343. ))
  2344. (cond
  2345. ((not (keymapp gnus-summary-post-menu))
  2346. (setq gnus-article-post-menu gnus-summary-post-menu))
  2347. ((not gnus-article-post-menu)
  2348. ;; Don't share post menu.
  2349. (setq gnus-article-post-menu
  2350. (copy-keymap gnus-summary-post-menu))))
  2351. (define-key gnus-article-mode-map [menu-bar post]
  2352. (cons "Post" gnus-article-post-menu))
  2353. (easy-menu-define
  2354. gnus-summary-misc-menu gnus-summary-mode-map ""
  2355. `("Gnus"
  2356. ("Mark Read"
  2357. ["Mark as read" gnus-summary-mark-as-read-forward t]
  2358. ["Mark same subject and select"
  2359. gnus-summary-kill-same-subject-and-select t]
  2360. ["Mark same subject" gnus-summary-kill-same-subject t]
  2361. ["Catchup" gnus-summary-catchup
  2362. ,@(if (featurep 'xemacs) '(t)
  2363. '(:help "Mark unread articles in this group as read"))]
  2364. ["Catchup all" gnus-summary-catchup-all t]
  2365. ["Catchup to here" gnus-summary-catchup-to-here t]
  2366. ["Catchup from here" gnus-summary-catchup-from-here t]
  2367. ["Catchup region" gnus-summary-mark-region-as-read
  2368. (gnus-mark-active-p)]
  2369. ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
  2370. ("Mark Various"
  2371. ["Tick" gnus-summary-tick-article-forward t]
  2372. ["Mark as dormant" gnus-summary-mark-as-dormant t]
  2373. ["Remove marks" gnus-summary-clear-mark-forward t]
  2374. ["Set expirable mark" gnus-summary-mark-as-expirable t]
  2375. ["Set bookmark" gnus-summary-set-bookmark t]
  2376. ["Remove bookmark" gnus-summary-remove-bookmark t])
  2377. ("Limit to"
  2378. ["Marks..." gnus-summary-limit-to-marks t]
  2379. ["Subject..." gnus-summary-limit-to-subject t]
  2380. ["Author..." gnus-summary-limit-to-author t]
  2381. ["Recipient..." gnus-summary-limit-to-recipient t]
  2382. ["Address..." gnus-summary-limit-to-address t]
  2383. ["Age..." gnus-summary-limit-to-age t]
  2384. ["Extra..." gnus-summary-limit-to-extra t]
  2385. ["Score..." gnus-summary-limit-to-score t]
  2386. ["Display Predicate" gnus-summary-limit-to-display-predicate t]
  2387. ["Unread" gnus-summary-limit-to-unread t]
  2388. ["Unseen" gnus-summary-limit-to-unseen t]
  2389. ["Singletons" gnus-summary-limit-to-singletons t]
  2390. ["Replied" gnus-summary-limit-to-replied t]
  2391. ["Non-dormant" gnus-summary-limit-exclude-dormant t]
  2392. ["Next or process marked articles" gnus-summary-limit-to-articles t]
  2393. ["Pop limit" gnus-summary-pop-limit t]
  2394. ["Show dormant" gnus-summary-limit-include-dormant t]
  2395. ["Hide childless dormant"
  2396. gnus-summary-limit-exclude-childless-dormant t]
  2397. ;;["Hide thread" gnus-summary-limit-exclude-thread t]
  2398. ["Hide marked" gnus-summary-limit-exclude-marks t]
  2399. ["Show expunged" gnus-summary-limit-include-expunged t])
  2400. ("Process Mark"
  2401. ["Set mark" gnus-summary-mark-as-processable t]
  2402. ["Remove mark" gnus-summary-unmark-as-processable t]
  2403. ["Remove all marks" gnus-summary-unmark-all-processable t]
  2404. ["Invert marks" gnus-uu-invert-processable t]
  2405. ["Mark above" gnus-uu-mark-over t]
  2406. ["Mark series" gnus-uu-mark-series t]
  2407. ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
  2408. ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
  2409. ["Mark by regexp..." gnus-uu-mark-by-regexp t]
  2410. ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
  2411. ["Mark all" gnus-uu-mark-all t]
  2412. ["Mark buffer" gnus-uu-mark-buffer t]
  2413. ["Mark sparse" gnus-uu-mark-sparse t]
  2414. ["Mark thread" gnus-uu-mark-thread t]
  2415. ["Unmark thread" gnus-uu-unmark-thread t]
  2416. ("Process Mark Sets"
  2417. ["Kill" gnus-summary-kill-process-mark t]
  2418. ["Yank" gnus-summary-yank-process-mark
  2419. gnus-newsgroup-process-stack]
  2420. ["Save" gnus-summary-save-process-mark t]
  2421. ["Run command on marked..." gnus-summary-universal-argument t]))
  2422. ("Registry Marks")
  2423. ("Scroll article"
  2424. ["Page forward" gnus-summary-next-page
  2425. ,@(if (featurep 'xemacs) '(t)
  2426. '(:help "Show next page of article"))]
  2427. ["Page backward" gnus-summary-prev-page
  2428. ,@(if (featurep 'xemacs) '(t)
  2429. '(:help "Show previous page of article"))]
  2430. ["Line forward" gnus-summary-scroll-up t])
  2431. ("Move"
  2432. ["Next unread article" gnus-summary-next-unread-article t]
  2433. ["Previous unread article" gnus-summary-prev-unread-article t]
  2434. ["Next article" gnus-summary-next-article t]
  2435. ["Previous article" gnus-summary-prev-article t]
  2436. ["Next unread subject" gnus-summary-next-unread-subject t]
  2437. ["Previous unread subject" gnus-summary-prev-unread-subject t]
  2438. ["Next article same subject" gnus-summary-next-same-subject t]
  2439. ["Previous article same subject" gnus-summary-prev-same-subject t]
  2440. ["First unread article" gnus-summary-first-unread-article t]
  2441. ["Best unread article" gnus-summary-best-unread-article t]
  2442. ["Go to subject number..." gnus-summary-goto-subject t]
  2443. ["Go to article number..." gnus-summary-goto-article t]
  2444. ["Go to the last article" gnus-summary-goto-last-article t]
  2445. ["Pop article off history" gnus-summary-pop-article t])
  2446. ("Sort"
  2447. ["Sort by number" gnus-summary-sort-by-number t]
  2448. ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
  2449. ["Sort by author" gnus-summary-sort-by-author t]
  2450. ["Sort by recipient" gnus-summary-sort-by-recipient t]
  2451. ["Sort by subject" gnus-summary-sort-by-subject t]
  2452. ["Sort by date" gnus-summary-sort-by-date t]
  2453. ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
  2454. ["Sort by score" gnus-summary-sort-by-score t]
  2455. ["Sort by lines" gnus-summary-sort-by-lines t]
  2456. ["Sort by characters" gnus-summary-sort-by-chars t]
  2457. ["Randomize" gnus-summary-sort-by-random t]
  2458. ["Original sort" gnus-summary-sort-by-original t])
  2459. ("Help"
  2460. ["Describe group" gnus-summary-describe-group t]
  2461. ["Read manual" gnus-info-find-node t])
  2462. ("Modes"
  2463. ["Pick and read" gnus-pick-mode t]
  2464. ["Binary" gnus-binary-mode t])
  2465. ("Regeneration"
  2466. ["Regenerate" gnus-summary-prepare t]
  2467. ["Insert cached articles" gnus-summary-insert-cached-articles t]
  2468. ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
  2469. ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
  2470. ["Toggle threading" gnus-summary-toggle-threads t])
  2471. ["See old articles" gnus-summary-insert-old-articles t]
  2472. ["See new articles" gnus-summary-insert-new-articles t]
  2473. ["Filter articles..." gnus-summary-execute-command t]
  2474. ["Run command on articles..." gnus-summary-universal-argument t]
  2475. ["Search articles forward..." gnus-summary-search-article-forward t]
  2476. ["Search articles backward..." gnus-summary-search-article-backward t]
  2477. ["Toggle line truncation" gnus-summary-toggle-truncation t]
  2478. ["Expand window" gnus-summary-expand-window t]
  2479. ["Expire expirable articles" gnus-summary-expire-articles
  2480. (gnus-check-backend-function
  2481. 'request-expire-articles gnus-newsgroup-name)]
  2482. ["Edit local kill file" gnus-summary-edit-local-kill t]
  2483. ["Edit main kill file" gnus-summary-edit-global-kill t]
  2484. ["Edit group parameters" gnus-summary-edit-parameters t]
  2485. ["Customize group parameters" gnus-summary-customize-parameters t]
  2486. ["Send a bug report" gnus-bug t]
  2487. ("Exit"
  2488. ["Catchup and exit" gnus-summary-catchup-and-exit
  2489. ,@(if (featurep 'xemacs) '(t)
  2490. '(:help "Mark unread articles in this group as read, then exit"))]
  2491. ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
  2492. ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
  2493. ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
  2494. ["Exit group" gnus-summary-exit
  2495. ,@(if (featurep 'xemacs) '(t)
  2496. '(:help "Exit current group, return to group selection mode"))]
  2497. ["Exit group without updating" gnus-summary-exit-no-update t]
  2498. ["Exit and goto next group" gnus-summary-next-group t]
  2499. ["Exit and goto prev group" gnus-summary-prev-group t]
  2500. ["Reselect group" gnus-summary-reselect-current-group t]
  2501. ["Rescan group" gnus-summary-rescan-group t]
  2502. ["Update dribble" gnus-summary-save-newsrc t])))
  2503. (gnus-run-hooks 'gnus-summary-menu-hook)))
  2504. (defvar gnus-summary-tool-bar-map nil)
  2505. ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
  2506. ;; affect _new_ message buffers. We might add a function that walks thru all
  2507. ;; summary-mode buffers and force the update.
  2508. (defun gnus-summary-tool-bar-update (&optional symbol value)
  2509. "Update summary mode toolbar.
  2510. Setter function for custom variables."
  2511. (setq-default gnus-summary-tool-bar-map nil)
  2512. (when symbol
  2513. ;; When used as ":set" function:
  2514. (set-default symbol value))
  2515. (when (gnus-buffer-live-p gnus-summary-buffer)
  2516. (with-current-buffer gnus-summary-buffer
  2517. (gnus-summary-make-tool-bar))))
  2518. (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
  2519. 'gnus-summary-tool-bar-gnome
  2520. 'gnus-summary-tool-bar-retro)
  2521. "Specifies the Gnus summary tool bar.
  2522. It can be either a list or a symbol referring to a list. See
  2523. `gmm-tool-bar-from-list' for the format of the list. The
  2524. default key map is `gnus-summary-mode-map'.
  2525. Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
  2526. `gnus-summary-tool-bar-retro'."
  2527. :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
  2528. (const :tag "Retro look" gnus-summary-tool-bar-retro)
  2529. (repeat :tag "User defined list" gmm-tool-bar-item)
  2530. (symbol))
  2531. :version "23.1" ;; No Gnus
  2532. :initialize 'custom-initialize-default
  2533. :set 'gnus-summary-tool-bar-update
  2534. :group 'gnus-summary)
  2535. (defcustom gnus-summary-tool-bar-gnome
  2536. '((gnus-summary-post-news "mail/compose" nil)
  2537. (gnus-summary-insert-new-articles "mail/inbox" nil
  2538. :visible (or (not gnus-agent)
  2539. gnus-plugged))
  2540. (gnus-summary-reply-with-original "mail/reply")
  2541. (gnus-summary-reply "mail/reply" nil :visible nil)
  2542. (gnus-summary-followup-with-original "mail/reply-all")
  2543. (gnus-summary-followup "mail/reply-all" nil :visible nil)
  2544. (gnus-summary-mail-forward "mail/forward")
  2545. (gnus-summary-save-article "mail/save")
  2546. (gnus-summary-search-article-forward "search" nil :visible nil)
  2547. (gnus-summary-print-article "print")
  2548. (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
  2549. ;; Some new commands that may need more suitable icons:
  2550. (gnus-summary-save-newsrc "save" nil :visible nil)
  2551. ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
  2552. (gnus-summary-prev-article "left-arrow")
  2553. (gnus-summary-next-article "right-arrow")
  2554. (gnus-summary-next-page "next-page")
  2555. ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
  2556. ;;
  2557. ;; Maybe some sort-by-... could be added:
  2558. ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
  2559. ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
  2560. (gnus-summary-mark-as-expirable
  2561. "delete" nil
  2562. :visible (gnus-check-backend-function 'request-expire-articles
  2563. gnus-newsgroup-name))
  2564. (gnus-summary-mark-as-spam
  2565. "mail/spam" t
  2566. :visible (and (fboundp 'spam-group-ham-contents-p)
  2567. (spam-group-ham-contents-p gnus-newsgroup-name))
  2568. :help "Mark as spam")
  2569. (gnus-summary-mark-as-read-forward
  2570. "mail/not-spam" nil
  2571. :visible (and (fboundp 'spam-group-spam-contents-p)
  2572. (spam-group-spam-contents-p gnus-newsgroup-name)))
  2573. ;;
  2574. (gnus-summary-exit "exit")
  2575. (gmm-customize-mode "preferences" t :help "Edit mode preferences")
  2576. (gnus-info-find-node "help"))
  2577. "List of functions for the summary tool bar (GNOME style).
  2578. See `gmm-tool-bar-from-list' for the format of the list."
  2579. :type '(repeat gmm-tool-bar-item)
  2580. :version "23.1" ;; No Gnus
  2581. :initialize 'custom-initialize-default
  2582. :set 'gnus-summary-tool-bar-update
  2583. :group 'gnus-summary)
  2584. (defcustom gnus-summary-tool-bar-retro
  2585. '((gnus-summary-prev-unread-article "gnus/prev-ur")
  2586. (gnus-summary-next-unread-article "gnus/next-ur")
  2587. (gnus-summary-post-news "gnus/post")
  2588. (gnus-summary-followup-with-original "gnus/fuwo")
  2589. (gnus-summary-followup "gnus/followup")
  2590. (gnus-summary-reply-with-original "gnus/reply-wo")
  2591. (gnus-summary-reply "gnus/reply")
  2592. (gnus-summary-caesar-message "gnus/rot13")
  2593. (gnus-uu-decode-uu "gnus/uu-decode")
  2594. (gnus-summary-save-article-file "gnus/save-aif")
  2595. (gnus-summary-save-article "gnus/save-art")
  2596. (gnus-uu-post-news "gnus/uu-post")
  2597. (gnus-summary-catchup "gnus/catchup")
  2598. (gnus-summary-catchup-and-exit "gnus/cu-exit")
  2599. (gnus-summary-exit "gnus/exit-summ")
  2600. ;; Some new command that may need more suitable icons:
  2601. (gnus-summary-print-article "gnus/print" nil :visible nil)
  2602. (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
  2603. (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
  2604. ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
  2605. (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
  2606. ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
  2607. ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
  2608. ;;
  2609. (gnus-info-find-node "gnus/help" nil :visible nil))
  2610. "List of functions for the summary tool bar (retro look).
  2611. See `gmm-tool-bar-from-list' for the format of the list."
  2612. :type '(repeat gmm-tool-bar-item)
  2613. :version "23.1" ;; No Gnus
  2614. :initialize 'custom-initialize-default
  2615. :set 'gnus-summary-tool-bar-update
  2616. :group 'gnus-summary)
  2617. (defcustom gnus-summary-tool-bar-zap-list t
  2618. "List of icon items from the global tool bar.
  2619. These items are not displayed in the Gnus summary mode tool bar.
  2620. See `gmm-tool-bar-from-list' for the format of the list."
  2621. :type 'gmm-tool-bar-zap-list
  2622. :version "23.1" ;; No Gnus
  2623. :initialize 'custom-initialize-default
  2624. :set 'gnus-summary-tool-bar-update
  2625. :group 'gnus-summary)
  2626. (defvar image-load-path)
  2627. (defvar tool-bar-map)
  2628. (defun gnus-summary-make-tool-bar (&optional force)
  2629. "Make a summary mode tool bar from `gnus-summary-tool-bar'.
  2630. When FORCE, rebuild the tool bar."
  2631. (when (and (not (featurep 'xemacs))
  2632. (boundp 'tool-bar-mode)
  2633. tool-bar-mode
  2634. (or (not gnus-summary-tool-bar-map) force))
  2635. (let* ((load-path
  2636. (gmm-image-load-path-for-library "gnus"
  2637. "mail/save.xpm"
  2638. nil t))
  2639. (image-load-path (cons (car load-path)
  2640. (when (boundp 'image-load-path)
  2641. image-load-path)))
  2642. (map (gmm-tool-bar-from-list gnus-summary-tool-bar
  2643. gnus-summary-tool-bar-zap-list
  2644. 'gnus-summary-mode-map)))
  2645. (when map
  2646. ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
  2647. ;; uses its value.
  2648. (setq gnus-summary-tool-bar-map map))))
  2649. (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
  2650. (defun gnus-score-set-default (var value)
  2651. "A version of set that updates the GNU Emacs menu-bar."
  2652. (set var value)
  2653. ;; It is the message that forces the active status to be updated.
  2654. (message ""))
  2655. (defun gnus-make-score-map (type)
  2656. "Make a summary score map of type TYPE."
  2657. (if t
  2658. nil
  2659. (let ((headers '(("author" "from" string)
  2660. ("subject" "subject" string)
  2661. ("article body" "body" string)
  2662. ("article head" "head" string)
  2663. ("xref" "xref" string)
  2664. ("extra header" "extra" string)
  2665. ("lines" "lines" number)
  2666. ("followups to author" "followup" string)))
  2667. (types '((number ("less than" <)
  2668. ("greater than" >)
  2669. ("equal" =))
  2670. (string ("substring" s)
  2671. ("exact string" e)
  2672. ("fuzzy string" f)
  2673. ("regexp" r))))
  2674. (perms '(("temporary" (current-time-string))
  2675. ("permanent" nil)
  2676. ("immediate" now)))
  2677. header)
  2678. (list
  2679. (apply
  2680. 'nconc
  2681. (list
  2682. (if (eq type 'lower)
  2683. "Lower score"
  2684. "Increase score"))
  2685. (let (outh)
  2686. (while headers
  2687. (setq header (car headers))
  2688. (setq outh
  2689. (cons
  2690. (apply
  2691. 'nconc
  2692. (list (car header))
  2693. (let ((ts (cdr (assoc (nth 2 header) types)))
  2694. outt)
  2695. (while ts
  2696. (setq outt
  2697. (cons
  2698. (apply
  2699. 'nconc
  2700. (list (caar ts))
  2701. (let ((ps perms)
  2702. outp)
  2703. (while ps
  2704. (setq outp
  2705. (cons
  2706. (vector
  2707. (caar ps)
  2708. (list
  2709. 'gnus-summary-score-entry
  2710. (nth 1 header)
  2711. (if (or (string= (nth 1 header)
  2712. "head")
  2713. (string= (nth 1 header)
  2714. "body"))
  2715. ""
  2716. (list 'gnus-summary-header
  2717. (nth 1 header)))
  2718. (list 'quote (nth 1 (car ts)))
  2719. (list 'gnus-score-delta-default
  2720. nil)
  2721. (nth 1 (car ps))
  2722. t)
  2723. t)
  2724. outp))
  2725. (setq ps (cdr ps)))
  2726. (list (nreverse outp))))
  2727. outt))
  2728. (setq ts (cdr ts)))
  2729. (list (nreverse outt))))
  2730. outh))
  2731. (setq headers (cdr headers)))
  2732. (list (nreverse outh))))))))
  2733. (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
  2734. (defvar bookmark-make-record-function)
  2735. (defvar bidi-paragraph-direction)
  2736. (defun gnus-summary-mode (&optional group)
  2737. "Major mode for reading articles.
  2738. All normal editing commands are switched off.
  2739. \\<gnus-summary-mode-map>
  2740. Each line in this buffer represents one article. To read an
  2741. article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
  2742. and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
  2743. respectively.
  2744. You can also post articles and send mail from this buffer. To
  2745. follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
  2746. of an article, type `\\[gnus-summary-reply]'.
  2747. There are approx. one gazillion commands you can execute in this
  2748. buffer; read the info pages for more information (`\\[gnus-info-find-node]').
  2749. The following commands are available:
  2750. \\{gnus-summary-mode-map}"
  2751. (interactive)
  2752. (kill-all-local-variables)
  2753. (let ((gnus-summary-local-variables gnus-newsgroup-variables))
  2754. (gnus-summary-make-local-variables))
  2755. (gnus-summary-make-local-variables)
  2756. (setq gnus-newsgroup-name group)
  2757. (when (gnus-visual-p 'summary-menu 'menu)
  2758. (gnus-summary-make-menu-bar)
  2759. (gnus-summary-make-tool-bar))
  2760. (gnus-make-thread-indent-array)
  2761. (gnus-simplify-mode-line)
  2762. (setq major-mode 'gnus-summary-mode)
  2763. (setq mode-name "Summary")
  2764. (use-local-map gnus-summary-mode-map)
  2765. (buffer-disable-undo)
  2766. (setq buffer-read-only t ;Disable modification
  2767. show-trailing-whitespace nil)
  2768. (setq truncate-lines t)
  2769. ;; Force paragraph direction to be left-to-right. Don't make it
  2770. ;; bound globally in old Emacsen and XEmacsen.
  2771. (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
  2772. (add-to-invisibility-spec '(gnus-sum . t))
  2773. (gnus-summary-set-display-table)
  2774. (gnus-set-default-directory)
  2775. (make-local-variable 'gnus-summary-line-format)
  2776. (make-local-variable 'gnus-summary-line-format-spec)
  2777. (make-local-variable 'gnus-summary-dummy-line-format)
  2778. (make-local-variable 'gnus-summary-dummy-line-format-spec)
  2779. (make-local-variable 'gnus-summary-mark-positions)
  2780. (gnus-make-local-hook 'pre-command-hook)
  2781. (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
  2782. (gnus-run-mode-hooks 'gnus-summary-mode-hook)
  2783. (turn-on-gnus-mailing-list-mode)
  2784. (mm-enable-multibyte)
  2785. (set (make-local-variable 'bookmark-make-record-function)
  2786. 'gnus-summary-bookmark-make-record)
  2787. (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
  2788. (gnus-update-summary-mark-positions))
  2789. (defun gnus-summary-make-local-variables ()
  2790. "Make all the local summary buffer variables."
  2791. (let (global)
  2792. (dolist (local gnus-summary-local-variables)
  2793. (if (consp local)
  2794. (progn
  2795. (if (eq (cdr local) 'global)
  2796. ;; Copy the global value of the variable.
  2797. (setq global (symbol-value (car local)))
  2798. ;; Use the value from the list.
  2799. (setq global (eval (cdr local))))
  2800. (set (make-local-variable (car local)) global))
  2801. ;; Simple nil-valued local variable.
  2802. (set (make-local-variable local) nil)))))
  2803. ;; Summary data functions.
  2804. (defmacro gnus-data-number (data)
  2805. `(car ,data))
  2806. (defmacro gnus-data-set-number (data number)
  2807. `(setcar ,data ,number))
  2808. (defmacro gnus-data-mark (data)
  2809. `(nth 1 ,data))
  2810. (defmacro gnus-data-set-mark (data mark)
  2811. `(setcar (nthcdr 1 ,data) ,mark))
  2812. (defmacro gnus-data-pos (data)
  2813. `(nth 2 ,data))
  2814. (defmacro gnus-data-set-pos (data pos)
  2815. `(setcar (nthcdr 2 ,data) ,pos))
  2816. (defmacro gnus-data-header (data)
  2817. `(nth 3 ,data))
  2818. (defmacro gnus-data-set-header (data header)
  2819. `(setf (nth 3 ,data) ,header))
  2820. (defmacro gnus-data-level (data)
  2821. `(nth 4 ,data))
  2822. (defmacro gnus-data-unread-p (data)
  2823. `(= (nth 1 ,data) gnus-unread-mark))
  2824. (defmacro gnus-data-read-p (data)
  2825. `(/= (nth 1 ,data) gnus-unread-mark))
  2826. (defmacro gnus-data-pseudo-p (data)
  2827. `(consp (nth 3 ,data)))
  2828. (defmacro gnus-data-find (number)
  2829. `(assq ,number gnus-newsgroup-data))
  2830. (defmacro gnus-data-find-list (number &optional data)
  2831. `(let ((bdata ,(or data 'gnus-newsgroup-data)))
  2832. (memq (assq ,number bdata)
  2833. bdata)))
  2834. (defmacro gnus-data-make (number mark pos header level)
  2835. `(list ,number ,mark ,pos ,header ,level))
  2836. (defun gnus-data-enter (after-article number mark pos header level offset)
  2837. (let ((data (gnus-data-find-list after-article)))
  2838. (unless data
  2839. (error "No such article: %d" after-article))
  2840. (setcdr data (cons (gnus-data-make number mark pos header level)
  2841. (cdr data)))
  2842. (setq gnus-newsgroup-data-reverse nil)
  2843. (gnus-data-update-list (cddr data) offset)))
  2844. (defun gnus-data-enter-list (after-article list &optional offset)
  2845. (when list
  2846. (let ((data (and after-article (gnus-data-find-list after-article)))
  2847. (ilist list))
  2848. (if (not (or data
  2849. after-article))
  2850. (let ((odata gnus-newsgroup-data))
  2851. (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
  2852. (when offset
  2853. (gnus-data-update-list odata offset)))
  2854. ;; Find the last element in the list to be spliced into the main
  2855. ;; list.
  2856. (setq list (last list))
  2857. (if (not data)
  2858. (progn
  2859. (setcdr list gnus-newsgroup-data)
  2860. (setq gnus-newsgroup-data ilist)
  2861. (when offset
  2862. (gnus-data-update-list (cdr list) offset)))
  2863. (setcdr list (cdr data))
  2864. (setcdr data ilist)
  2865. (when offset
  2866. (gnus-data-update-list (cdr list) offset))))
  2867. (setq gnus-newsgroup-data-reverse nil))))
  2868. (defun gnus-data-remove (article &optional offset)
  2869. (let ((data gnus-newsgroup-data))
  2870. (if (= (gnus-data-number (car data)) article)
  2871. (progn
  2872. (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
  2873. gnus-newsgroup-data-reverse nil)
  2874. (when offset
  2875. (gnus-data-update-list gnus-newsgroup-data offset)))
  2876. (while (cdr data)
  2877. (when (= (gnus-data-number (cadr data)) article)
  2878. (setcdr data (cddr data))
  2879. (when offset
  2880. (gnus-data-update-list (cdr data) offset))
  2881. (setq data nil
  2882. gnus-newsgroup-data-reverse nil))
  2883. (setq data (cdr data))))))
  2884. (defmacro gnus-data-list (backward)
  2885. `(if ,backward
  2886. (or gnus-newsgroup-data-reverse
  2887. (setq gnus-newsgroup-data-reverse
  2888. (reverse gnus-newsgroup-data)))
  2889. gnus-newsgroup-data))
  2890. (defun gnus-data-update-list (data offset)
  2891. "Add OFFSET to the POS of all data entries in DATA."
  2892. (setq gnus-newsgroup-data-reverse nil)
  2893. (while data
  2894. (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
  2895. (setq data (cdr data))))
  2896. (defun gnus-summary-article-pseudo-p (article)
  2897. "Say whether this article is a pseudo article or not."
  2898. (not (vectorp (gnus-data-header (gnus-data-find article)))))
  2899. (defmacro gnus-summary-article-sparse-p (article)
  2900. "Say whether this article is a sparse article or not."
  2901. `(memq ,article gnus-newsgroup-sparse))
  2902. (defmacro gnus-summary-article-ancient-p (article)
  2903. "Say whether this article is a sparse article or not."
  2904. `(memq ,article gnus-newsgroup-ancient))
  2905. (defun gnus-article-parent-p (number)
  2906. "Say whether this article is a parent or not."
  2907. (let ((data (gnus-data-find-list number)))
  2908. (and (cdr data) ; There has to be an article after...
  2909. (< (gnus-data-level (car data)) ; And it has to have a higher level.
  2910. (gnus-data-level (nth 1 data))))))
  2911. (defun gnus-article-children (number)
  2912. "Return a list of all children to NUMBER."
  2913. (let* ((data (gnus-data-find-list number))
  2914. (level (gnus-data-level (car data)))
  2915. children)
  2916. (setq data (cdr data))
  2917. (while (and data
  2918. (= (gnus-data-level (car data)) (1+ level)))
  2919. (push (gnus-data-number (car data)) children)
  2920. (setq data (cdr data)))
  2921. children))
  2922. (defmacro gnus-summary-skip-intangible ()
  2923. "If the current article is intangible, then jump to a different article."
  2924. '(let ((to (get-text-property (point) 'gnus-intangible)))
  2925. (and to (gnus-summary-goto-subject to))))
  2926. (defmacro gnus-summary-article-intangible-p ()
  2927. "Say whether this article is intangible or not."
  2928. '(get-text-property (point) 'gnus-intangible))
  2929. (defun gnus-article-read-p (article)
  2930. "Say whether ARTICLE is read or not."
  2931. (not (or (memq article gnus-newsgroup-marked)
  2932. (memq article gnus-newsgroup-spam-marked)
  2933. (memq article gnus-newsgroup-unreads)
  2934. (memq article gnus-newsgroup-unselected)
  2935. (memq article gnus-newsgroup-dormant))))
  2936. ;; Some summary mode macros.
  2937. (defmacro gnus-summary-article-number ()
  2938. "The article number of the article on the current line.
  2939. If there isn't an article number here, then we return the current
  2940. article number."
  2941. '(progn
  2942. (gnus-summary-skip-intangible)
  2943. (or (get-text-property (point) 'gnus-number)
  2944. (gnus-summary-last-subject))))
  2945. (defmacro gnus-summary-article-header (&optional number)
  2946. "Return the header of article NUMBER."
  2947. `(gnus-data-header (gnus-data-find
  2948. ,(or number '(gnus-summary-article-number)))))
  2949. (defmacro gnus-summary-thread-level (&optional number)
  2950. "Return the level of thread that starts with article NUMBER."
  2951. `(if (and (eq gnus-summary-make-false-root 'dummy)
  2952. (get-text-property (point) 'gnus-intangible))
  2953. 0
  2954. (gnus-data-level (gnus-data-find
  2955. ,(or number '(gnus-summary-article-number))))))
  2956. (defmacro gnus-summary-article-mark (&optional number)
  2957. "Return the mark of article NUMBER."
  2958. `(gnus-data-mark (gnus-data-find
  2959. ,(or number '(gnus-summary-article-number)))))
  2960. (defmacro gnus-summary-article-pos (&optional number)
  2961. "Return the position of the line of article NUMBER."
  2962. `(gnus-data-pos (gnus-data-find
  2963. ,(or number '(gnus-summary-article-number)))))
  2964. (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
  2965. (defmacro gnus-summary-article-subject (&optional number)
  2966. "Return current subject string or nil if nothing."
  2967. `(let ((headers
  2968. ,(if number
  2969. `(gnus-data-header (assq ,number gnus-newsgroup-data))
  2970. '(gnus-data-header (assq (gnus-summary-article-number)
  2971. gnus-newsgroup-data)))))
  2972. (and headers
  2973. (vectorp headers)
  2974. (mail-header-subject headers))))
  2975. (defmacro gnus-summary-article-score (&optional number)
  2976. "Return current article score."
  2977. `(or (cdr (assq ,(or number '(gnus-summary-article-number))
  2978. gnus-newsgroup-scored))
  2979. gnus-summary-default-score 0))
  2980. (defun gnus-summary-article-children (&optional number)
  2981. "Return a list of article numbers that are children of article NUMBER."
  2982. (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
  2983. (level (gnus-data-level (car data)))
  2984. l children)
  2985. (while (and (setq data (cdr data))
  2986. (> (setq l (gnus-data-level (car data))) level))
  2987. (and (= (1+ level) l)
  2988. (push (gnus-data-number (car data))
  2989. children)))
  2990. (nreverse children)))
  2991. (defun gnus-summary-article-parent (&optional number)
  2992. "Return the article number of the parent of article NUMBER."
  2993. (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
  2994. (gnus-data-list t)))
  2995. (level (gnus-data-level (car data))))
  2996. (if (zerop level)
  2997. () ; This is a root.
  2998. ;; We search until we find an article with a level less than
  2999. ;; this one. That function has to be the parent.
  3000. (while (and (setq data (cdr data))
  3001. (not (< (gnus-data-level (car data)) level))))
  3002. (and data (gnus-data-number (car data))))))
  3003. (defun gnus-unread-mark-p (mark)
  3004. "Say whether MARK is the unread mark."
  3005. (= mark gnus-unread-mark))
  3006. (defun gnus-read-mark-p (mark)
  3007. "Say whether MARK is one of the marks that mark as read.
  3008. This is all marks except unread, ticked, dormant, and expirable."
  3009. (not (or (= mark gnus-unread-mark)
  3010. (= mark gnus-ticked-mark)
  3011. (= mark gnus-spam-mark)
  3012. (= mark gnus-dormant-mark)
  3013. (= mark gnus-expirable-mark))))
  3014. (defmacro gnus-article-mark (number)
  3015. "Return the MARK of article NUMBER.
  3016. This macro should only be used when computing the mark the \"first\"
  3017. time; i.e., when generating the summary lines. After that,
  3018. `gnus-summary-article-mark' should be used to examine the
  3019. marks of articles."
  3020. `(cond
  3021. ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
  3022. ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
  3023. ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
  3024. ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
  3025. ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
  3026. ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
  3027. ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
  3028. (t (or (cdr (assq ,number gnus-newsgroup-reads))
  3029. gnus-ancient-mark))))
  3030. ;; Saving hidden threads.
  3031. (defmacro gnus-save-hidden-threads (&rest forms)
  3032. "Save hidden threads, eval FORMS, and restore the hidden threads."
  3033. (let ((config (make-symbol "config")))
  3034. `(let ((,config (gnus-hidden-threads-configuration)))
  3035. (unwind-protect
  3036. (save-excursion
  3037. ,@forms)
  3038. (gnus-restore-hidden-threads-configuration ,config)))))
  3039. (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
  3040. (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
  3041. (defun gnus-data-compute-positions ()
  3042. "Compute the positions of all articles."
  3043. (setq gnus-newsgroup-data-reverse nil)
  3044. (let ((data gnus-newsgroup-data))
  3045. (save-excursion
  3046. (gnus-save-hidden-threads
  3047. (gnus-summary-show-all-threads)
  3048. (goto-char (point-min))
  3049. (while data
  3050. (while (get-text-property (point) 'gnus-intangible)
  3051. (forward-line 1))
  3052. (gnus-data-set-pos (car data) (+ (point) 3))
  3053. (setq data (cdr data))
  3054. (forward-line 1))))))
  3055. (defun gnus-hidden-threads-configuration ()
  3056. "Return the current hidden threads configuration."
  3057. (save-excursion
  3058. (let (config)
  3059. (goto-char (point-min))
  3060. (while (not (eobp))
  3061. (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
  3062. (push (save-excursion (forward-line 0) (point)) config))
  3063. (forward-line 1))
  3064. config)))
  3065. (defun gnus-restore-hidden-threads-configuration (config)
  3066. "Restore hidden threads configuration from CONFIG."
  3067. (save-excursion
  3068. (let (point (inhibit-read-only t))
  3069. (while (setq point (pop config))
  3070. (goto-char point)
  3071. (gnus-summary-hide-thread)))))
  3072. ;; Various summary mode internalish functions.
  3073. (defun gnus-mouse-pick-article (e)
  3074. (interactive "e")
  3075. (mouse-set-point e)
  3076. (gnus-summary-next-page nil t))
  3077. (defun gnus-summary-set-display-table ()
  3078. "Change the display table.
  3079. Odd characters have a tendency to mess
  3080. up nicely formatted displays - we make all possible glyphs
  3081. display only a single character."
  3082. ;; We start from the standard display table, if any.
  3083. (let ((table (or (copy-sequence standard-display-table)
  3084. (make-display-table)))
  3085. (i 32))
  3086. ;; Nix out all the control chars...
  3087. (while (>= (setq i (1- i)) 0)
  3088. (gnus-put-display-table i [??] table))
  3089. ;; ... but not newline and cr, of course. (cr is necessary for the
  3090. ;; selective display).
  3091. (gnus-put-display-table ?\n nil table)
  3092. (gnus-put-display-table ?\r nil table)
  3093. ;; We keep TAB as well.
  3094. (gnus-put-display-table ?\t nil table)
  3095. ;; We nix out any glyphs 127 through 255, or 127 through 159 in
  3096. ;; Emacs 23 (unicode), that are not set already.
  3097. (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
  3098. 160
  3099. 256)))
  3100. (while (>= (setq i (1- i)) 127)
  3101. ;; Only modify if the entry is nil.
  3102. (unless (gnus-get-display-table i table)
  3103. (gnus-put-display-table i [??] table))))
  3104. (setq buffer-display-table table)))
  3105. (defun gnus-summary-set-article-display-arrow (pos)
  3106. "Update the overlay arrow to point to line at position POS."
  3107. (when gnus-summary-display-arrow
  3108. (make-local-variable 'overlay-arrow-position)
  3109. (make-local-variable 'overlay-arrow-string)
  3110. (save-excursion
  3111. (goto-char pos)
  3112. (beginning-of-line)
  3113. (unless overlay-arrow-position
  3114. (setq overlay-arrow-position (make-marker)))
  3115. (setq overlay-arrow-string "=>"
  3116. overlay-arrow-position (set-marker overlay-arrow-position
  3117. (point)
  3118. (current-buffer))))))
  3119. (defun gnus-summary-setup-buffer (group)
  3120. "Initialize summary buffer.
  3121. If the setup was successful, non-nil is returned."
  3122. (let ((buffer (gnus-summary-buffer-name group))
  3123. (dead-name (concat "*Dead Summary "
  3124. (gnus-group-decoded-name group) "*")))
  3125. ;; If a dead summary buffer exists, we kill it.
  3126. (when (gnus-buffer-live-p dead-name)
  3127. (gnus-kill-buffer dead-name))
  3128. (if (get-buffer buffer)
  3129. (progn
  3130. (set-buffer buffer)
  3131. (setq gnus-summary-buffer (current-buffer))
  3132. (not gnus-newsgroup-prepared))
  3133. ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
  3134. (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
  3135. (gnus-summary-mode group)
  3136. (when (gnus-group-quit-config group)
  3137. (set (make-local-variable 'gnus-single-article-buffer) nil))
  3138. (make-local-variable 'gnus-article-buffer)
  3139. (make-local-variable 'gnus-article-current)
  3140. (make-local-variable 'gnus-original-article-buffer)
  3141. (setq gnus-newsgroup-name group)
  3142. ;; Set any local variables in the group parameters.
  3143. (gnus-summary-set-local-parameters gnus-newsgroup-name)
  3144. t)))
  3145. (defun gnus-set-global-variables ()
  3146. "Set the global equivalents of the buffer-local variables.
  3147. They are set to the latest values they had. These reflect the summary
  3148. buffer that was in action when the last article was fetched."
  3149. (when (eq major-mode 'gnus-summary-mode)
  3150. (setq gnus-summary-buffer (current-buffer))
  3151. (let ((name gnus-newsgroup-name)
  3152. (marked gnus-newsgroup-marked)
  3153. (spam gnus-newsgroup-spam-marked)
  3154. (unread gnus-newsgroup-unreads)
  3155. (headers gnus-current-headers)
  3156. (data gnus-newsgroup-data)
  3157. (summary gnus-summary-buffer)
  3158. (article-buffer gnus-article-buffer)
  3159. (original gnus-original-article-buffer)
  3160. (gac gnus-article-current)
  3161. (reffed gnus-reffed-article-number)
  3162. (score-file gnus-current-score-file)
  3163. (default-charset gnus-newsgroup-charset)
  3164. vlist)
  3165. (let ((locals gnus-newsgroup-variables))
  3166. (while locals
  3167. (if (consp (car locals))
  3168. (push (eval (caar locals)) vlist)
  3169. (push (eval (car locals)) vlist))
  3170. (setq locals (cdr locals)))
  3171. (setq vlist (nreverse vlist)))
  3172. (with-current-buffer gnus-group-buffer
  3173. (setq gnus-newsgroup-name name
  3174. gnus-newsgroup-marked marked
  3175. gnus-newsgroup-spam-marked spam
  3176. gnus-newsgroup-unreads unread
  3177. gnus-current-headers headers
  3178. gnus-newsgroup-data data
  3179. gnus-article-current gac
  3180. gnus-summary-buffer summary
  3181. gnus-article-buffer article-buffer
  3182. gnus-original-article-buffer original
  3183. gnus-reffed-article-number reffed
  3184. gnus-current-score-file score-file
  3185. gnus-newsgroup-charset default-charset)
  3186. (let ((locals gnus-newsgroup-variables))
  3187. (while locals
  3188. (if (consp (car locals))
  3189. (set (caar locals) (pop vlist))
  3190. (set (car locals) (pop vlist)))
  3191. (setq locals (cdr locals))))
  3192. ;; The article buffer also has local variables.
  3193. (when (gnus-buffer-live-p gnus-article-buffer)
  3194. (set-buffer gnus-article-buffer)
  3195. (setq gnus-summary-buffer summary))))))
  3196. (defun gnus-summary-article-unread-p (article)
  3197. "Say whether ARTICLE is unread or not."
  3198. (memq article gnus-newsgroup-unreads))
  3199. (defun gnus-summary-first-article-p (&optional article)
  3200. "Return whether ARTICLE is the first article in the buffer."
  3201. (if (not (setq article (or article (gnus-summary-article-number))))
  3202. nil
  3203. (eq article (caar gnus-newsgroup-data))))
  3204. (defun gnus-summary-last-article-p (&optional article)
  3205. "Return whether ARTICLE is the last article in the buffer."
  3206. (if (not (setq article (or article (gnus-summary-article-number))))
  3207. ;; All non-existent numbers are the last article. :-)
  3208. t
  3209. (not (cdr (gnus-data-find-list article)))))
  3210. (defun gnus-make-thread-indent-array (&optional n)
  3211. (when (or n
  3212. (progn (setq n 200) nil)
  3213. (null gnus-thread-indent-array)
  3214. (/= gnus-thread-indent-level gnus-thread-indent-array-level))
  3215. (setq gnus-thread-indent-array (make-vector (1+ n) "")
  3216. gnus-thread-indent-array-level gnus-thread-indent-level)
  3217. (while (>= n 0)
  3218. (aset gnus-thread-indent-array n
  3219. (make-string (* n gnus-thread-indent-level) ? ))
  3220. (setq n (1- n)))))
  3221. (defun gnus-update-summary-mark-positions ()
  3222. "Compute where the summary marks are to go."
  3223. (save-excursion
  3224. (when (gnus-buffer-exists-p gnus-summary-buffer)
  3225. (set-buffer gnus-summary-buffer))
  3226. (let ((spec gnus-summary-line-format-spec)
  3227. pos)
  3228. (save-excursion
  3229. (gnus-set-work-buffer)
  3230. (let ((gnus-tmp-unread ?Z)
  3231. (gnus-replied-mark ?Z)
  3232. (gnus-score-below-mark ?Z)
  3233. (gnus-score-over-mark ?Z)
  3234. (gnus-undownloaded-mark ?Z)
  3235. (gnus-summary-line-format-spec spec)
  3236. (gnus-newsgroup-downloadable '(0))
  3237. (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
  3238. case-fold-search ignores)
  3239. ;; Here, all marks are bound to Z.
  3240. (gnus-summary-insert-line header
  3241. 0 nil t gnus-tmp-unread t nil "" nil 1)
  3242. (goto-char (point-min))
  3243. ;; Memorize the positions of the same characters as dummy marks.
  3244. (while (re-search-forward "[A-D]" nil t)
  3245. (push (point) ignores))
  3246. (erase-buffer)
  3247. ;; We use A-D as dummy marks in order to know column positions
  3248. ;; where marks should be inserted.
  3249. (setq gnus-tmp-unread ?A
  3250. gnus-replied-mark ?B
  3251. gnus-score-below-mark ?C
  3252. gnus-score-over-mark ?C
  3253. gnus-undownloaded-mark ?D)
  3254. (gnus-summary-insert-line header
  3255. 0 nil t gnus-tmp-unread t nil "" nil 1)
  3256. ;; Ignore characters which aren't dummy marks.
  3257. (dolist (p ignores)
  3258. (delete-region (goto-char (1- p)) p)
  3259. (insert ?Z))
  3260. (goto-char (point-min))
  3261. (setq pos (list (cons 'unread
  3262. (and (search-forward "A" nil t)
  3263. (- (point) (point-min) 1)))))
  3264. (goto-char (point-min))
  3265. (push (cons 'replied (and (search-forward "B" nil t)
  3266. (- (point) (point-min) 1)))
  3267. pos)
  3268. (goto-char (point-min))
  3269. (push (cons 'score (and (search-forward "C" nil t)
  3270. (- (point) (point-min) 1)))
  3271. pos)
  3272. (goto-char (point-min))
  3273. (push (cons 'download (and (search-forward "D" nil t)
  3274. (- (point) (point-min) 1)))
  3275. pos)))
  3276. (setq gnus-summary-mark-positions pos))))
  3277. (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
  3278. "Insert a dummy root in the summary buffer."
  3279. (beginning-of-line)
  3280. (gnus-add-text-properties
  3281. (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
  3282. (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
  3283. (defun gnus-summary-extract-address-component (from)
  3284. (or (car (funcall gnus-extract-address-components from))
  3285. from))
  3286. (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
  3287. (let ((mail-parse-charset gnus-newsgroup-charset)
  3288. (ignored-from-addresses (gnus-ignored-from-addresses))
  3289. ; Is it really necessary to do this next part for each summary line?
  3290. ; Luckily, doesn't seem to slow things down much.
  3291. (mail-parse-ignored-charsets
  3292. (with-current-buffer gnus-summary-buffer
  3293. gnus-newsgroup-ignored-charsets)))
  3294. (or
  3295. (and ignored-from-addresses
  3296. (string-match ignored-from-addresses gnus-tmp-from)
  3297. (let ((extra-headers (mail-header-extra header))
  3298. to
  3299. newsgroups)
  3300. (cond
  3301. ((setq to (cdr (assq 'To extra-headers)))
  3302. (concat gnus-summary-to-prefix
  3303. (inline
  3304. (gnus-summary-extract-address-component
  3305. (funcall gnus-decode-encoded-address-function to)))))
  3306. ((setq newsgroups
  3307. (or
  3308. (cdr (assq 'Newsgroups extra-headers))
  3309. (and
  3310. (memq 'Newsgroups gnus-extra-headers)
  3311. (eq (car (gnus-find-method-for-group
  3312. gnus-newsgroup-name)) 'nntp)
  3313. (gnus-group-real-name gnus-newsgroup-name))))
  3314. (concat gnus-summary-newsgroup-prefix newsgroups)))))
  3315. (gnus-string-mark-left-to-right
  3316. (inline
  3317. (gnus-summary-extract-address-component gnus-tmp-from))))))
  3318. (defun gnus-summary-insert-line (gnus-tmp-header
  3319. gnus-tmp-level gnus-tmp-current
  3320. undownloaded gnus-tmp-unread gnus-tmp-replied
  3321. gnus-tmp-expirable gnus-tmp-subject-or-nil
  3322. &optional gnus-tmp-dummy gnus-tmp-score
  3323. gnus-tmp-process)
  3324. (if (>= gnus-tmp-level (length gnus-thread-indent-array))
  3325. (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
  3326. gnus-tmp-level)))
  3327. (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
  3328. (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
  3329. (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
  3330. (gnus-tmp-score-char
  3331. (if (or (null gnus-summary-default-score)
  3332. (<= (abs (- gnus-tmp-score gnus-summary-default-score))
  3333. gnus-summary-zcore-fuzz))
  3334. ? ;Whitespace
  3335. (if (< gnus-tmp-score gnus-summary-default-score)
  3336. gnus-score-below-mark gnus-score-over-mark)))
  3337. (gnus-tmp-number (mail-header-number gnus-tmp-header))
  3338. (gnus-tmp-replied
  3339. (cond (gnus-tmp-process gnus-process-mark)
  3340. ((memq gnus-tmp-current gnus-newsgroup-cached)
  3341. gnus-cached-mark)
  3342. (gnus-tmp-replied gnus-replied-mark)
  3343. ((memq gnus-tmp-current gnus-newsgroup-forwarded)
  3344. gnus-forwarded-mark)
  3345. ((memq gnus-tmp-current gnus-newsgroup-saved)
  3346. gnus-saved-mark)
  3347. ((memq gnus-tmp-number gnus-newsgroup-unseen)
  3348. gnus-unseen-mark)
  3349. (t gnus-no-mark)))
  3350. (gnus-tmp-downloaded
  3351. (cond (undownloaded
  3352. gnus-undownloaded-mark)
  3353. (gnus-newsgroup-agentized
  3354. gnus-downloaded-mark)
  3355. (t
  3356. gnus-no-mark)))
  3357. (gnus-tmp-from (mail-header-from gnus-tmp-header))
  3358. (gnus-tmp-name
  3359. (cond
  3360. ((string-match "<[^>]+> *$" gnus-tmp-from)
  3361. (let ((beg (match-beginning 0)))
  3362. (or (and (string-match "^\".+\"" gnus-tmp-from)
  3363. (substring gnus-tmp-from 1 (1- (match-end 0))))
  3364. (substring gnus-tmp-from 0 beg))))
  3365. ((string-match "(.+)" gnus-tmp-from)
  3366. (substring gnus-tmp-from
  3367. (1+ (match-beginning 0)) (1- (match-end 0))))
  3368. (t gnus-tmp-from)))
  3369. (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
  3370. (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
  3371. (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
  3372. (inhibit-read-only t))
  3373. (when (string= gnus-tmp-name "")
  3374. (setq gnus-tmp-name gnus-tmp-from))
  3375. (unless (numberp gnus-tmp-lines)
  3376. (setq gnus-tmp-lines -1))
  3377. (if (= gnus-tmp-lines -1)
  3378. (setq gnus-tmp-lines "?")
  3379. (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
  3380. (condition-case ()
  3381. (gnus-put-text-property
  3382. (point)
  3383. (progn (eval gnus-summary-line-format-spec) (point))
  3384. 'gnus-number gnus-tmp-number)
  3385. (error (gnus-message 5 "Error updating the summary line")))
  3386. (when (gnus-visual-p 'summary-highlight 'highlight)
  3387. (forward-line -1)
  3388. (gnus-summary-highlight-line)
  3389. (gnus-run-hooks 'gnus-summary-update-hook)
  3390. (forward-line 1))))
  3391. (defun gnus-summary-update-line (&optional dont-update)
  3392. "Update summary line after change."
  3393. (when (and gnus-summary-default-score
  3394. (not gnus-summary-inhibit-highlight))
  3395. (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
  3396. (article (gnus-summary-article-number))
  3397. (score (gnus-summary-article-score article)))
  3398. (unless dont-update
  3399. (if (and gnus-summary-mark-below
  3400. (< (gnus-summary-article-score)
  3401. gnus-summary-mark-below))
  3402. ;; This article has a low score, so we mark it as read.
  3403. (when (memq article gnus-newsgroup-unreads)
  3404. (gnus-summary-mark-article-as-read gnus-low-score-mark))
  3405. (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
  3406. ;; This article was previously marked as read on account
  3407. ;; of a low score, but now it has risen, so we mark it as
  3408. ;; unread.
  3409. (gnus-summary-mark-article-as-unread gnus-unread-mark)))
  3410. (gnus-summary-update-mark
  3411. (if (or (null gnus-summary-default-score)
  3412. (<= (abs (- score gnus-summary-default-score))
  3413. gnus-summary-zcore-fuzz))
  3414. ? ;Whitespace
  3415. (if (< score gnus-summary-default-score)
  3416. gnus-score-below-mark gnus-score-over-mark))
  3417. 'score))
  3418. ;; Do visual highlighting.
  3419. (when (gnus-visual-p 'summary-highlight 'highlight)
  3420. (gnus-summary-highlight-line)
  3421. (gnus-run-hooks 'gnus-summary-update-hook)))))
  3422. (defvar gnus-tmp-new-adopts nil)
  3423. (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
  3424. "Return the number of articles in THREAD.
  3425. This may be 0 in some cases -- if none of the articles in
  3426. the thread are to be displayed."
  3427. (let* ((number
  3428. ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
  3429. (cond
  3430. ((not (listp thread))
  3431. 1)
  3432. ((and (consp thread) (cdr thread))
  3433. (apply
  3434. '+ 1 (mapcar
  3435. 'gnus-summary-number-of-articles-in-thread (cdr thread))))
  3436. ((null thread)
  3437. 1)
  3438. ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
  3439. 1)
  3440. (t 0))))
  3441. (when (and level (zerop level) gnus-tmp-new-adopts)
  3442. (incf number
  3443. (apply '+ (mapcar
  3444. 'gnus-summary-number-of-articles-in-thread
  3445. gnus-tmp-new-adopts))))
  3446. (if char
  3447. (if (> number 1) gnus-not-empty-thread-mark
  3448. gnus-empty-thread-mark)
  3449. number)))
  3450. (defsubst gnus-summary-line-message-size (head)
  3451. "Return pretty-printed version of message size.
  3452. This function is intended to be used in
  3453. `gnus-summary-line-format-alist'."
  3454. (let ((c (or (mail-header-chars head) -1)))
  3455. (cond ((< c 0) "n/a") ; chars not available
  3456. ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
  3457. ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
  3458. ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
  3459. (t (format "%dM" (/ c (* 1024.0 1024)))))))
  3460. (defcustom gnus-user-date-format-alist
  3461. '(((gnus-seconds-today) . "Today, %H:%M")
  3462. ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
  3463. (604800 . "%A %H:%M") ; That's one week
  3464. ((gnus-seconds-month) . "%A %d")
  3465. ((gnus-seconds-year) . "%B %d")
  3466. (t . "%b %d %Y")) ; This one is used when no other
  3467. ; does match
  3468. "Specifies date format depending on age of article.
  3469. This is an alist of items (AGE . FORMAT). AGE can be a number (of
  3470. seconds) or a Lisp expression evaluating to a number. When the age of
  3471. the article is less than this number, then use `format-time-string'
  3472. with the corresponding FORMAT for displaying the date of the article.
  3473. If AGE is not a number or a Lisp expression evaluating to a
  3474. non-number, then the corresponding FORMAT is used as a default value.
  3475. Note that the list is processed from the beginning, so it should be
  3476. sorted by ascending AGE. Also note that items following the first
  3477. non-number AGE will be ignored.
  3478. You can use the functions `gnus-seconds-today', `gnus-seconds-month'
  3479. and `gnus-seconds-year' in the AGE spec. They return the number of
  3480. seconds passed since the start of today, of this month, of this year,
  3481. respectively."
  3482. :version "24.1"
  3483. :group 'gnus-summary-format
  3484. :type '(alist :key-type sexp :value-type string))
  3485. (defun gnus-user-date (messy-date)
  3486. "Format the messy-date according to `gnus-user-date-format-alist'.
  3487. Returns \" ? \" if there's bad input or if another error occurs.
  3488. Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
  3489. (condition-case ()
  3490. (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
  3491. (now (gnus-float-time))
  3492. ;;If we don't find something suitable we'll use this one
  3493. (my-format "%b %d '%y"))
  3494. (let* ((difference (- now messy-date))
  3495. (templist gnus-user-date-format-alist)
  3496. (top (eval (caar templist))))
  3497. (while (if (numberp top) (< top difference) (not top))
  3498. (progn
  3499. (setq templist (cdr templist))
  3500. (setq top (eval (caar templist)))))
  3501. (if (stringp (cdr (car templist)))
  3502. (setq my-format (cdr (car templist)))))
  3503. (format-time-string (eval my-format) (seconds-to-time messy-date)))
  3504. (error " ? ")))
  3505. (defun gnus-summary-set-local-parameters (group)
  3506. "Go through the local params of GROUP and set all variable specs in that list."
  3507. (let ((vars '(quit-config active))) ; Ignore things that aren't
  3508. ; really variables.
  3509. (dolist (elem (gnus-group-find-parameter group))
  3510. (and (consp elem) ; Has to be a cons.
  3511. (consp (cdr elem)) ; The cdr has to be a list.
  3512. (symbolp (car elem)) ; Has to be a symbol in there.
  3513. (not (memq (car elem) vars))
  3514. (ignore-errors
  3515. (push (car elem) vars)
  3516. ;; Variables like `gnus-show-threads' that are globally
  3517. ;; bound, if used as group parameters, need to get to be
  3518. ;; buffer-local, whereas just parameters like `gcc-self',
  3519. ;; `timestamp', etc. should not be bound as variables.
  3520. (if (boundp (car elem))
  3521. (set (make-local-variable (car elem)) (eval (nth 1 elem)))
  3522. (eval (nth 1 elem))))))))
  3523. (defun gnus-summary-read-group (group &optional show-all no-article
  3524. kill-buffer no-display backward
  3525. select-articles)
  3526. "Start reading news in newsgroup GROUP.
  3527. If SHOW-ALL is non-nil, already read articles are also listed.
  3528. If NO-ARTICLE is non-nil, no article is selected initially.
  3529. If NO-DISPLAY, don't generate the summary buffer contents.
  3530. If KILL-BUFFER, it should be a buffer that's killed once the new
  3531. summary buffer has been generated.
  3532. If BACKWARD, move point to the previous group in the group buffer
  3533. If SELECT-ARTICLES, only select those articles from GROUP."
  3534. (let (result)
  3535. (while (and group
  3536. (null (setq result
  3537. (let ((gnus-auto-select-next nil))
  3538. (or (gnus-summary-read-group-1
  3539. group show-all no-article
  3540. kill-buffer no-display
  3541. select-articles)
  3542. (setq show-all nil
  3543. select-articles nil)))))
  3544. (eq gnus-auto-select-next 'quietly))
  3545. (set-buffer gnus-group-buffer)
  3546. ;; The entry function called above goes to the next
  3547. ;; group automatically, so we go two groups back
  3548. ;; if we are searching for the previous group.
  3549. (when backward
  3550. (gnus-group-prev-unread-group 2))
  3551. (if (not (equal group (gnus-group-group-name)))
  3552. (setq group (gnus-group-group-name))
  3553. (setq group nil)))
  3554. result))
  3555. (defun gnus-summary-read-group-1 (group show-all no-article
  3556. kill-buffer no-display
  3557. &optional select-articles)
  3558. ;; Killed foreign groups can't be entered.
  3559. ;; (when (and (not (gnus-group-native-p group))
  3560. ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
  3561. ;; (error "Dead non-native groups can't be entered"))
  3562. (gnus-message 7 "Retrieving newsgroup: %s..."
  3563. (gnus-group-decoded-name group))
  3564. (let* ((new-group (gnus-summary-setup-buffer group))
  3565. (quit-config (gnus-group-quit-config group))
  3566. (did-select (and new-group (gnus-select-newsgroup
  3567. group show-all select-articles))))
  3568. (cond
  3569. ;; This summary buffer exists already, so we just select it.
  3570. ((not new-group)
  3571. (gnus-set-global-variables)
  3572. (when kill-buffer
  3573. (gnus-kill-or-deaden-summary kill-buffer))
  3574. (gnus-configure-windows 'summary 'force)
  3575. (gnus-set-mode-line 'summary)
  3576. (gnus-summary-position-point)
  3577. (message "")
  3578. t)
  3579. ;; We couldn't select this group.
  3580. ((null did-select)
  3581. (when (and (eq major-mode 'gnus-summary-mode)
  3582. (not (equal (current-buffer) kill-buffer)))
  3583. (kill-buffer (current-buffer))
  3584. (if (not quit-config)
  3585. (progn
  3586. ;; Update the info -- marks might need to be removed,
  3587. ;; for instance.
  3588. (gnus-summary-update-info)
  3589. (set-buffer gnus-group-buffer)
  3590. (gnus-group-jump-to-group group)
  3591. (gnus-group-next-unread-group 1))
  3592. (gnus-handle-ephemeral-exit quit-config)))
  3593. (if (null (gnus-list-of-unread-articles group))
  3594. (gnus-message 3 "Group %s contains no messages" group)
  3595. (gnus-message 3 "Can't select group"))
  3596. nil)
  3597. ;; The user did a `C-g' while prompting for number of articles,
  3598. ;; so we exit this group.
  3599. ((eq did-select 'quit)
  3600. (and (eq major-mode 'gnus-summary-mode)
  3601. (not (equal (current-buffer) kill-buffer))
  3602. (kill-buffer (current-buffer)))
  3603. (when kill-buffer
  3604. (gnus-kill-or-deaden-summary kill-buffer))
  3605. (if (not quit-config)
  3606. (progn
  3607. (set-buffer gnus-group-buffer)
  3608. (gnus-group-jump-to-group group)
  3609. (gnus-configure-windows 'group 'force))
  3610. (gnus-handle-ephemeral-exit quit-config))
  3611. ;; Finally signal the quit.
  3612. (signal 'quit nil))
  3613. ;; The group was successfully selected.
  3614. (t
  3615. (gnus-set-global-variables)
  3616. ;; Save the active value in effect when the group was entered.
  3617. (setq gnus-newsgroup-active
  3618. (gnus-copy-sequence
  3619. (gnus-active gnus-newsgroup-name)))
  3620. (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
  3621. ;; You can change the summary buffer in some way with this hook.
  3622. (gnus-run-hooks 'gnus-select-group-hook)
  3623. (when (memq 'summary (gnus-update-format-specifications
  3624. nil 'summary 'summary-mode 'summary-dummy))
  3625. ;; The format specification for the summary line was updated,
  3626. ;; so we need to update the mark positions as well.
  3627. (gnus-update-summary-mark-positions))
  3628. ;; Do score processing.
  3629. (when gnus-use-scoring
  3630. (gnus-possibly-score-headers))
  3631. ;; Check whether to fill in the gaps in the threads.
  3632. (when gnus-build-sparse-threads
  3633. (gnus-build-sparse-threads))
  3634. ;; Find the initial limit.
  3635. (if show-all
  3636. (let ((gnus-newsgroup-dormant nil))
  3637. (gnus-summary-initial-limit show-all))
  3638. (gnus-summary-initial-limit show-all))
  3639. ;; Generate the summary buffer.
  3640. (unless no-display
  3641. (gnus-summary-prepare))
  3642. (when gnus-use-trees
  3643. (gnus-tree-open group)
  3644. (setq gnus-summary-highlight-line-function
  3645. 'gnus-tree-highlight-article))
  3646. ;; If the summary buffer is empty, but there are some low-scored
  3647. ;; articles or some excluded dormants, we include these in the
  3648. ;; buffer.
  3649. (when (and (zerop (buffer-size))
  3650. (not no-display))
  3651. (cond (gnus-newsgroup-dormant
  3652. (gnus-summary-limit-include-dormant))
  3653. ((and gnus-newsgroup-scored show-all)
  3654. (gnus-summary-limit-include-expunged t))))
  3655. ;; Function `gnus-apply-kill-file' must be called in this hook.
  3656. (gnus-run-hooks 'gnus-apply-kill-hook)
  3657. (if (and (zerop (buffer-size))
  3658. (not no-display))
  3659. (progn
  3660. ;; This newsgroup is empty.
  3661. (gnus-summary-catchup-and-exit nil t)
  3662. (gnus-message 6 "No unread news")
  3663. (when kill-buffer
  3664. (gnus-kill-or-deaden-summary kill-buffer))
  3665. ;; Return nil from this function.
  3666. nil)
  3667. ;; Hide conversation thread subtrees. We cannot do this in
  3668. ;; gnus-summary-prepare-hook since kill processing may not
  3669. ;; work with hidden articles.
  3670. (gnus-summary-maybe-hide-threads)
  3671. (gnus-configure-windows 'summary)
  3672. (when kill-buffer
  3673. (gnus-kill-or-deaden-summary kill-buffer))
  3674. (gnus-summary-auto-select-subject)
  3675. ;; Show first unread article if requested.
  3676. (if (and (not no-article)
  3677. (not no-display)
  3678. gnus-newsgroup-unreads
  3679. gnus-auto-select-first)
  3680. (progn
  3681. (let ((art (gnus-summary-article-number)))
  3682. (unless (and (not gnus-plugged)
  3683. (or (memq art gnus-newsgroup-undownloaded)
  3684. (memq art gnus-newsgroup-downloadable)))
  3685. (gnus-summary-goto-article art))))
  3686. ;; Don't select any articles.
  3687. (gnus-summary-position-point)
  3688. (gnus-configure-windows 'summary 'force)
  3689. (gnus-set-mode-line 'summary))
  3690. (when (and gnus-auto-center-group
  3691. (get-buffer-window gnus-group-buffer t))
  3692. ;; Gotta use windows, because recenter does weird stuff if
  3693. ;; the current buffer ain't the displayed window.
  3694. (let ((owin (selected-window)))
  3695. (select-window (get-buffer-window gnus-group-buffer t))
  3696. (when (gnus-group-goto-group group)
  3697. (recenter))
  3698. (select-window owin)))
  3699. ;; Mark this buffer as "prepared".
  3700. (setq gnus-newsgroup-prepared t)
  3701. (gnus-run-hooks 'gnus-summary-prepared-hook)
  3702. (unless (gnus-ephemeral-group-p group)
  3703. (gnus-group-update-group group nil t))
  3704. t)))))
  3705. (defun gnus-summary-auto-select-subject ()
  3706. "Select the subject line on initial group entry."
  3707. (goto-char (point-min))
  3708. (cond
  3709. ((eq gnus-auto-select-subject 'best)
  3710. (gnus-summary-best-unread-subject))
  3711. ((eq gnus-auto-select-subject 'unread)
  3712. (gnus-summary-first-unread-subject))
  3713. ((eq gnus-auto-select-subject 'unseen)
  3714. (gnus-summary-first-unseen-subject))
  3715. ((eq gnus-auto-select-subject 'unseen-or-unread)
  3716. (gnus-summary-first-unseen-or-unread-subject))
  3717. ((eq gnus-auto-select-subject 'first)
  3718. ;; Do nothing.
  3719. )
  3720. ((functionp gnus-auto-select-subject)
  3721. (funcall gnus-auto-select-subject))))
  3722. (defun gnus-summary-prepare ()
  3723. "Generate the summary buffer."
  3724. (interactive)
  3725. (let ((inhibit-read-only t))
  3726. (erase-buffer)
  3727. (setq gnus-newsgroup-data nil
  3728. gnus-newsgroup-data-reverse nil)
  3729. (gnus-run-hooks 'gnus-summary-generate-hook)
  3730. ;; Generate the buffer, either with threads or without.
  3731. (when gnus-newsgroup-headers
  3732. (gnus-summary-prepare-threads
  3733. (if gnus-show-threads
  3734. (gnus-sort-gathered-threads
  3735. (funcall gnus-summary-thread-gathering-function
  3736. (gnus-sort-threads
  3737. (gnus-cut-threads (gnus-make-threads)))))
  3738. ;; Unthreaded display.
  3739. (gnus-sort-articles gnus-newsgroup-headers))))
  3740. (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
  3741. ;; Call hooks for modifying summary buffer.
  3742. (goto-char (point-min))
  3743. (gnus-run-hooks 'gnus-summary-prepare-hook)))
  3744. (defsubst gnus-general-simplify-subject (subject)
  3745. "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
  3746. (setq subject
  3747. (cond
  3748. ;; Truncate the subject.
  3749. (gnus-simplify-subject-functions
  3750. (gnus-map-function gnus-simplify-subject-functions subject))
  3751. ((numberp gnus-summary-gather-subject-limit)
  3752. (setq subject (gnus-simplify-subject-re subject))
  3753. (if (> (length subject) gnus-summary-gather-subject-limit)
  3754. (substring subject 0 gnus-summary-gather-subject-limit)
  3755. subject))
  3756. ;; Fuzzily simplify it.
  3757. ((eq 'fuzzy gnus-summary-gather-subject-limit)
  3758. (gnus-simplify-subject-fuzzy subject))
  3759. ;; Just remove the leading "Re:".
  3760. (t
  3761. (gnus-simplify-subject-re subject))))
  3762. (if (and gnus-summary-gather-exclude-subject
  3763. (string-match gnus-summary-gather-exclude-subject subject))
  3764. nil ; This article shouldn't be gathered
  3765. subject))
  3766. (defun gnus-summary-simplify-subject-query ()
  3767. "Query where the respool algorithm would put this article."
  3768. (interactive)
  3769. (gnus-summary-select-article)
  3770. (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
  3771. (defun gnus-gather-threads-by-subject (threads)
  3772. "Gather threads by looking at Subject headers."
  3773. (if (not gnus-summary-make-false-root)
  3774. threads
  3775. (let ((hashtb (gnus-make-hashtable 1024))
  3776. (prev threads)
  3777. (result threads)
  3778. subject hthread whole-subject)
  3779. (while threads
  3780. (setq subject (gnus-general-simplify-subject
  3781. (setq whole-subject (mail-header-subject
  3782. (caar threads)))))
  3783. (when subject
  3784. (if (setq hthread (gnus-gethash subject hashtb))
  3785. (progn
  3786. ;; We enter a dummy root into the thread, if we
  3787. ;; haven't done that already.
  3788. (unless (stringp (caar hthread))
  3789. (setcar hthread (list whole-subject (car hthread))))
  3790. ;; We add this new gathered thread to this gathered
  3791. ;; thread.
  3792. (setcdr (car hthread)
  3793. (nconc (cdar hthread) (list (car threads))))
  3794. ;; Remove it from the list of threads.
  3795. (setcdr prev (cdr threads))
  3796. (setq threads prev))
  3797. ;; Enter this thread into the hash table.
  3798. (gnus-sethash subject
  3799. (if gnus-summary-make-false-root-always
  3800. (progn
  3801. ;; If you want a dummy root above all
  3802. ;; threads...
  3803. (setcar threads (list whole-subject
  3804. (car threads)))
  3805. threads)
  3806. threads)
  3807. hashtb)))
  3808. (setq prev threads)
  3809. (setq threads (cdr threads)))
  3810. result)))
  3811. (defun gnus-gather-threads-by-references (threads)
  3812. "Gather threads by looking at References headers."
  3813. (let ((idhashtb (gnus-make-hashtable 1024))
  3814. (thhashtb (gnus-make-hashtable 1024))
  3815. (prev threads)
  3816. (result threads)
  3817. ids references id gthread gid entered ref)
  3818. (while threads
  3819. (when (setq references (mail-header-references (caar threads)))
  3820. (setq id (mail-header-id (caar threads))
  3821. ids (inline (gnus-split-references references))
  3822. entered nil)
  3823. (while (setq ref (pop ids))
  3824. (setq ids (delete ref ids))
  3825. (if (not (setq gid (gnus-gethash ref idhashtb)))
  3826. (progn
  3827. (gnus-sethash ref id idhashtb)
  3828. (gnus-sethash id threads thhashtb))
  3829. (setq gthread (gnus-gethash gid thhashtb))
  3830. (unless entered
  3831. ;; We enter a dummy root into the thread, if we
  3832. ;; haven't done that already.
  3833. (unless (stringp (caar gthread))
  3834. (setcar gthread (list (mail-header-subject (caar gthread))
  3835. (car gthread))))
  3836. ;; We add this new gathered thread to this gathered
  3837. ;; thread.
  3838. (setcdr (car gthread)
  3839. (nconc (cdar gthread) (list (car threads)))))
  3840. ;; Add it into the thread hash table.
  3841. (gnus-sethash id gthread thhashtb)
  3842. (setq entered t)
  3843. ;; Remove it from the list of threads.
  3844. (setcdr prev (cdr threads))
  3845. (setq threads prev))))
  3846. (setq prev threads)
  3847. (setq threads (cdr threads)))
  3848. result))
  3849. (defun gnus-sort-gathered-threads (threads)
  3850. "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
  3851. (let ((result threads))
  3852. (while threads
  3853. (when (stringp (caar threads))
  3854. (setcdr (car threads)
  3855. (sort (cdar threads) gnus-sort-gathered-threads-function)))
  3856. (setq threads (cdr threads)))
  3857. result))
  3858. (defun gnus-thread-loop-p (root thread)
  3859. "Say whether ROOT is in THREAD."
  3860. (let ((stack (list thread))
  3861. (infloop 0)
  3862. th)
  3863. (while (setq thread (pop stack))
  3864. (setq th (cdr thread))
  3865. (while (and th
  3866. (not (eq (caar th) root)))
  3867. (pop th))
  3868. (if th
  3869. ;; We have found a loop.
  3870. (let (ref-dep)
  3871. (setcdr thread (delq (car th) (cdr thread)))
  3872. (if (boundp (setq ref-dep (intern "none"
  3873. gnus-newsgroup-dependencies)))
  3874. (setcdr (symbol-value ref-dep)
  3875. (nconc (cdr (symbol-value ref-dep))
  3876. (list (car th))))
  3877. (set ref-dep (list nil (car th))))
  3878. (setq infloop 1
  3879. stack nil))
  3880. ;; Push all the subthreads onto the stack.
  3881. (push (cdr thread) stack)))
  3882. infloop))
  3883. (defun gnus-make-threads ()
  3884. "Go through the dependency hashtb and find the roots. Return all threads."
  3885. (let (threads)
  3886. (while (catch 'infloop
  3887. (mapatoms
  3888. (lambda (refs)
  3889. ;; Deal with self-referencing References loops.
  3890. (when (and (car (symbol-value refs))
  3891. (not (zerop
  3892. (apply
  3893. '+
  3894. (mapcar
  3895. (lambda (thread)
  3896. (gnus-thread-loop-p
  3897. (car (symbol-value refs)) thread))
  3898. (cdr (symbol-value refs)))))))
  3899. (setq threads nil)
  3900. (throw 'infloop t))
  3901. (unless (car (symbol-value refs))
  3902. ;; These threads do not refer back to any other
  3903. ;; articles, so they're roots.
  3904. (setq threads (append (cdr (symbol-value refs)) threads))))
  3905. gnus-newsgroup-dependencies)))
  3906. threads))
  3907. ;; Build the thread tree.
  3908. (defsubst gnus-dependencies-add-header (header dependencies force-new)
  3909. "Enter HEADER into the DEPENDENCIES table if it is not already there.
  3910. If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
  3911. if it was already present.
  3912. If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
  3913. will not be entered in the DEPENDENCIES table. Otherwise duplicate
  3914. Message-IDs will be renamed to a unique Message-ID before being
  3915. entered.
  3916. Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
  3917. (let* ((id (mail-header-id header))
  3918. (id-dep (and id (intern id dependencies)))
  3919. parent-id ref ref-dep ref-header replaced)
  3920. ;; Enter this `header' in the `dependencies' table.
  3921. (cond
  3922. ((not id-dep)
  3923. (setq header nil))
  3924. ;; The first two cases do the normal part: enter a new `header'
  3925. ;; in the `dependencies' table.
  3926. ((not (boundp id-dep))
  3927. (set id-dep (list header)))
  3928. ((null (car (symbol-value id-dep)))
  3929. (setcar (symbol-value id-dep) header))
  3930. ;; From here the `header' was already present in the
  3931. ;; `dependencies' table.
  3932. (force-new
  3933. ;; Overrides an existing entry;
  3934. ;; just set the header part of the entry.
  3935. (setcar (symbol-value id-dep) header)
  3936. (setq replaced t))
  3937. ;; Renames the existing `header' to a unique Message-ID.
  3938. ((not gnus-summary-ignore-duplicates)
  3939. ;; An article with this Message-ID has already been seen.
  3940. ;; We rename the Message-ID.
  3941. (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
  3942. (list header))
  3943. (mail-header-set-id header id))
  3944. ;; The last case ignores an existing entry, except it adds any
  3945. ;; additional Xrefs (in case the two articles came from different
  3946. ;; servers.
  3947. ;; Also sets `header' to `nil' meaning that the `dependencies'
  3948. ;; table was *not* modified.
  3949. (t
  3950. (mail-header-set-xref
  3951. (car (symbol-value id-dep))
  3952. (concat (or (mail-header-xref (car (symbol-value id-dep)))
  3953. "")
  3954. (or (mail-header-xref header) "")))
  3955. (setq header nil)))
  3956. (when (and header (not replaced))
  3957. ;; First check that we are not creating a References loop.
  3958. (setq parent-id (gnus-parent-id (mail-header-references header)))
  3959. (setq ref parent-id)
  3960. (while (and ref
  3961. (setq ref-dep (intern-soft ref dependencies))
  3962. (boundp ref-dep)
  3963. (setq ref-header (car (symbol-value ref-dep))))
  3964. (if (string= id ref)
  3965. ;; Yuk! This is a reference loop. Make the article be a
  3966. ;; root article.
  3967. (progn
  3968. (mail-header-set-references (car (symbol-value id-dep)) "none")
  3969. (setq ref nil)
  3970. (setq parent-id nil))
  3971. (setq ref (gnus-parent-id (mail-header-references ref-header)))))
  3972. (setq ref-dep (intern (or parent-id "none") dependencies))
  3973. (if (boundp ref-dep)
  3974. (setcdr (symbol-value ref-dep)
  3975. (nconc (cdr (symbol-value ref-dep))
  3976. (list (symbol-value id-dep))))
  3977. (set ref-dep (list nil (symbol-value id-dep)))))
  3978. header))
  3979. (defun gnus-extract-message-id-from-in-reply-to (string)
  3980. (if (string-match "<[^>]+>" string)
  3981. (substring string (match-beginning 0) (match-end 0))
  3982. nil))
  3983. (defun gnus-build-sparse-threads ()
  3984. (let ((headers gnus-newsgroup-headers)
  3985. (mail-parse-charset gnus-newsgroup-charset)
  3986. (gnus-summary-ignore-duplicates t)
  3987. header references generation relations
  3988. subject child end new-child date)
  3989. ;; First we create an alist of generations/relations, where
  3990. ;; generations is how much we trust the relation, and the relation
  3991. ;; is parent/child.
  3992. (gnus-message 7 "Making sparse threads...")
  3993. (save-excursion
  3994. (nnheader-set-temp-buffer " *gnus sparse threads*")
  3995. (while (setq header (pop headers))
  3996. (when (and (setq references (mail-header-references header))
  3997. (not (string= references "")))
  3998. (insert references)
  3999. (setq child (mail-header-id header)
  4000. subject (mail-header-subject header)
  4001. date (mail-header-date header)
  4002. generation 0)
  4003. (while (search-backward ">" nil t)
  4004. (setq end (1+ (point)))
  4005. (when (search-backward "<" nil t)
  4006. (setq new-child (buffer-substring (point) end))
  4007. (push (list (incf generation)
  4008. child (setq child new-child)
  4009. subject date)
  4010. relations)))
  4011. (when child
  4012. (push (list (1+ generation) child nil subject) relations))
  4013. (erase-buffer)))
  4014. (kill-buffer (current-buffer)))
  4015. ;; Sort over trustworthiness.
  4016. (dolist (relation (sort relations 'car-less-than-car))
  4017. (when (gnus-dependencies-add-header
  4018. (make-full-mail-header
  4019. gnus-reffed-article-number
  4020. (nth 3 relation) "" (or (nth 4 relation) "")
  4021. (nth 1 relation)
  4022. (or (nth 2 relation) "") 0 0 "")
  4023. gnus-newsgroup-dependencies nil)
  4024. (push gnus-reffed-article-number gnus-newsgroup-limit)
  4025. (push gnus-reffed-article-number gnus-newsgroup-sparse)
  4026. (push (cons gnus-reffed-article-number gnus-sparse-mark)
  4027. gnus-newsgroup-reads)
  4028. (decf gnus-reffed-article-number)))
  4029. (gnus-message 7 "Making sparse threads...done")))
  4030. (defun gnus-build-old-threads ()
  4031. ;; Look at all the articles that refer back to old articles, and
  4032. ;; fetch the headers for the articles that aren't there. This will
  4033. ;; build complete threads - if the roots haven't been expired by the
  4034. ;; server, that is.
  4035. (let ((mail-parse-charset gnus-newsgroup-charset)
  4036. id heads)
  4037. (mapatoms
  4038. (lambda (refs)
  4039. (when (not (car (symbol-value refs)))
  4040. (setq heads (cdr (symbol-value refs)))
  4041. (while heads
  4042. (if (memq (mail-header-number (caar heads))
  4043. gnus-newsgroup-dormant)
  4044. (setq heads (cdr heads))
  4045. (setq id (symbol-name refs))
  4046. (while (and (setq id (gnus-build-get-header id))
  4047. (not (car (gnus-id-to-thread id)))))
  4048. (setq heads nil)))))
  4049. gnus-newsgroup-dependencies)))
  4050. (defsubst gnus-remove-odd-characters (string)
  4051. "Translate STRING into something that doesn't contain weird characters."
  4052. (mm-subst-char-in-string
  4053. ?\r ?\-
  4054. (mm-subst-char-in-string ?\n ?\- string t) t))
  4055. ;; This function has to be called with point after the article number
  4056. ;; on the beginning of the line.
  4057. (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
  4058. (let ((eol (point-at-eol))
  4059. (buffer (current-buffer))
  4060. header references in-reply-to)
  4061. ;; overview: [num subject from date id refs chars lines misc]
  4062. (unwind-protect
  4063. (let (x)
  4064. (narrow-to-region (point) eol)
  4065. (unless (eobp)
  4066. (forward-char))
  4067. (setq header
  4068. (make-full-mail-header
  4069. number ; number
  4070. (condition-case () ; subject
  4071. (gnus-remove-odd-characters
  4072. (funcall gnus-decode-encoded-word-function
  4073. (setq x (nnheader-nov-field))))
  4074. (error x))
  4075. (condition-case () ; from
  4076. (gnus-remove-odd-characters
  4077. (funcall gnus-decode-encoded-address-function
  4078. (setq x (nnheader-nov-field))))
  4079. (error x))
  4080. (nnheader-nov-field) ; date
  4081. (nnheader-nov-read-message-id number) ; id
  4082. (setq references (nnheader-nov-field)) ; refs
  4083. (nnheader-nov-read-integer) ; chars
  4084. (nnheader-nov-read-integer) ; lines
  4085. (unless (eobp)
  4086. (if (looking-at "Xref: ")
  4087. (goto-char (match-end 0)))
  4088. (nnheader-nov-field)) ; Xref
  4089. (nnheader-nov-parse-extra)))) ; extra
  4090. (widen))
  4091. (when (and (string= references "")
  4092. (setq in-reply-to (mail-header-extra header))
  4093. (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
  4094. (mail-header-set-references
  4095. header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
  4096. (when gnus-alter-header-function
  4097. (funcall gnus-alter-header-function header))
  4098. (gnus-dependencies-add-header header dependencies force-new)))
  4099. (defun gnus-build-get-header (id)
  4100. "Look through the buffer of NOV lines and find the header to ID.
  4101. Enter this line into the dependencies hash table, and return
  4102. the id of the parent article (if any)."
  4103. (let ((deps gnus-newsgroup-dependencies)
  4104. found header)
  4105. (prog1
  4106. (with-current-buffer nntp-server-buffer
  4107. (let ((case-fold-search nil))
  4108. (goto-char (point-min))
  4109. (while (and (not found)
  4110. (search-forward id nil t))
  4111. (beginning-of-line)
  4112. (setq found (looking-at
  4113. (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
  4114. (regexp-quote id))))
  4115. (or found (beginning-of-line 2)))
  4116. (when found
  4117. (beginning-of-line)
  4118. (and
  4119. (setq header (gnus-nov-parse-line
  4120. (read (current-buffer)) deps))
  4121. (gnus-parent-id (mail-header-references header))))))
  4122. (when header
  4123. (let ((number (mail-header-number header)))
  4124. (push number gnus-newsgroup-limit)
  4125. (push header gnus-newsgroup-headers)
  4126. (if (memq number gnus-newsgroup-unselected)
  4127. (progn
  4128. (setq gnus-newsgroup-unreads
  4129. (gnus-add-to-sorted-list gnus-newsgroup-unreads
  4130. number))
  4131. (setq gnus-newsgroup-unselected
  4132. (delq number gnus-newsgroup-unselected)))
  4133. (push number gnus-newsgroup-ancient)))))))
  4134. (defun gnus-build-all-threads ()
  4135. "Read all the headers."
  4136. (let ((gnus-summary-ignore-duplicates t)
  4137. (mail-parse-charset gnus-newsgroup-charset)
  4138. (dependencies gnus-newsgroup-dependencies)
  4139. header article)
  4140. (with-current-buffer nntp-server-buffer
  4141. (let ((case-fold-search nil))
  4142. (goto-char (point-min))
  4143. (while (not (eobp))
  4144. (ignore-errors
  4145. (setq article (read (current-buffer))
  4146. header (gnus-nov-parse-line article dependencies t)))
  4147. (when header
  4148. (with-current-buffer gnus-summary-buffer
  4149. (push header gnus-newsgroup-headers)
  4150. (if (memq (setq article (mail-header-number header))
  4151. gnus-newsgroup-unselected)
  4152. (progn
  4153. (setq gnus-newsgroup-unreads
  4154. (gnus-add-to-sorted-list
  4155. gnus-newsgroup-unreads article))
  4156. (setq gnus-newsgroup-unselected
  4157. (delq article gnus-newsgroup-unselected)))
  4158. (push article gnus-newsgroup-ancient)))
  4159. (forward-line 1)))))))
  4160. (defun gnus-summary-update-article-line (article header)
  4161. "Update the line for ARTICLE using HEADER."
  4162. (let* ((id (mail-header-id header))
  4163. (thread (gnus-id-to-thread id)))
  4164. (unless thread
  4165. (error "Article in no thread"))
  4166. ;; Update the thread.
  4167. (setcar thread header)
  4168. (gnus-summary-goto-subject article)
  4169. (let* ((datal (gnus-data-find-list article))
  4170. (data (car datal))
  4171. (inhibit-read-only t)
  4172. (level (gnus-summary-thread-level)))
  4173. (gnus-delete-line)
  4174. (let ((inserted (- (point)
  4175. (progn
  4176. (gnus-summary-insert-line
  4177. header level nil
  4178. (memq article gnus-newsgroup-undownloaded)
  4179. (gnus-article-mark article)
  4180. (memq article gnus-newsgroup-replied)
  4181. (memq article gnus-newsgroup-expirable)
  4182. ;; Only insert the Subject string when it's different
  4183. ;; from the previous Subject string.
  4184. (if (and
  4185. gnus-show-threads
  4186. (gnus-subject-equal
  4187. (condition-case ()
  4188. (mail-header-subject
  4189. (gnus-data-header
  4190. (cadr
  4191. (gnus-data-find-list
  4192. article
  4193. (gnus-data-list t)))))
  4194. ;; Error on the side of excessive subjects.
  4195. (error ""))
  4196. (mail-header-subject header)))
  4197. ""
  4198. (mail-header-subject header))
  4199. nil (cdr (assq article gnus-newsgroup-scored))
  4200. (memq article gnus-newsgroup-processable))
  4201. (point)))))
  4202. (when (cdr datal)
  4203. (gnus-data-update-list
  4204. (cdr datal)
  4205. (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
  4206. (defun gnus-summary-update-article (article &optional iheader)
  4207. "Update ARTICLE in the summary buffer."
  4208. (set-buffer gnus-summary-buffer)
  4209. (let* ((header (gnus-summary-article-header article))
  4210. (id (mail-header-id header))
  4211. (data (gnus-data-find article))
  4212. (thread (gnus-id-to-thread id))
  4213. (references (mail-header-references header))
  4214. (parent
  4215. (gnus-id-to-thread
  4216. (or (gnus-parent-id
  4217. (when (and references
  4218. (not (equal "" references)))
  4219. references))
  4220. "none")))
  4221. (inhibit-read-only t)
  4222. (old (car thread)))
  4223. (when thread
  4224. (unless iheader
  4225. (setcar thread nil)
  4226. (when parent
  4227. (delq thread parent)))
  4228. (if (gnus-summary-insert-subject id header)
  4229. ;; Set the (possibly) new article number in the data structure.
  4230. (gnus-data-set-number data (gnus-id-to-article id))
  4231. (setcar thread old)
  4232. nil))))
  4233. (defun gnus-rebuild-thread (id &optional line)
  4234. "Rebuild the thread containing ID.
  4235. If LINE, insert the rebuilt thread starting on line LINE."
  4236. (let ((inhibit-read-only t)
  4237. old-pos current thread data)
  4238. (if (not gnus-show-threads)
  4239. (setq thread (list (car (gnus-id-to-thread id))))
  4240. ;; Get the thread this article is part of.
  4241. (setq thread (gnus-remove-thread id)))
  4242. (setq old-pos (point-at-bol))
  4243. (setq current (save-excursion
  4244. (and (re-search-backward "[\r\n]" nil t)
  4245. (gnus-summary-article-number))))
  4246. ;; If this is a gathered thread, we have to go some re-gathering.
  4247. (when (stringp (car thread))
  4248. (let ((subject (car thread))
  4249. roots thr)
  4250. (setq thread (cdr thread))
  4251. (while thread
  4252. (unless (memq (setq thr (gnus-id-to-thread
  4253. (gnus-root-id
  4254. (mail-header-id (caar thread)))))
  4255. roots)
  4256. (push thr roots))
  4257. (setq thread (cdr thread)))
  4258. ;; We now have all (unique) roots.
  4259. (if (= (length roots) 1)
  4260. ;; All the loose roots are now one solid root.
  4261. (setq thread (car roots))
  4262. (setq thread (cons subject (gnus-sort-threads roots))))))
  4263. (let (threads)
  4264. ;; We then insert this thread into the summary buffer.
  4265. (when line
  4266. (goto-char (point-min))
  4267. (forward-line (1- line)))
  4268. (let (gnus-newsgroup-data gnus-newsgroup-threads)
  4269. (if gnus-show-threads
  4270. (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
  4271. (gnus-summary-prepare-unthreaded thread))
  4272. (setq data (nreverse gnus-newsgroup-data))
  4273. (setq threads gnus-newsgroup-threads))
  4274. ;; We splice the new data into the data structure.
  4275. ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
  4276. ;;!!! then we want to insert at the beginning of the buffer.
  4277. ;;!!! That happens to be true with Gnus now, but that may
  4278. ;;!!! change in the future. Perhaps.
  4279. (gnus-data-enter-list
  4280. (if line nil current) data (- (point) old-pos))
  4281. (setq gnus-newsgroup-threads
  4282. (nconc threads gnus-newsgroup-threads))
  4283. (gnus-data-compute-positions))))
  4284. (defun gnus-number-to-header (number)
  4285. "Return the header for article NUMBER."
  4286. (let ((headers gnus-newsgroup-headers))
  4287. (while (and headers
  4288. (not (= number (mail-header-number (car headers)))))
  4289. (pop headers))
  4290. (when headers
  4291. (car headers))))
  4292. (defun gnus-parent-headers (in-headers &optional generation)
  4293. "Return the headers of the GENERATIONth parent of HEADERS."
  4294. (unless generation
  4295. (setq generation 1))
  4296. (let ((parent t)
  4297. (headers in-headers)
  4298. references)
  4299. (while (and parent
  4300. (not (zerop generation))
  4301. (setq references (mail-header-references headers)))
  4302. (setq headers (if (and references
  4303. (setq parent (gnus-parent-id references)))
  4304. (car (gnus-id-to-thread parent))
  4305. nil))
  4306. (decf generation))
  4307. (and (not (eq headers in-headers))
  4308. headers)))
  4309. (defun gnus-id-to-thread (id)
  4310. "Return the (sub-)thread where ID appears."
  4311. (gnus-gethash id gnus-newsgroup-dependencies))
  4312. (defun gnus-id-to-article (id)
  4313. "Return the article number of ID."
  4314. (let ((thread (gnus-id-to-thread id)))
  4315. (when (and thread
  4316. (car thread))
  4317. (mail-header-number (car thread)))))
  4318. (defun gnus-id-to-header (id)
  4319. "Return the article headers of ID."
  4320. (car (gnus-id-to-thread id)))
  4321. (defun gnus-article-displayed-root-p (article)
  4322. "Say whether ARTICLE is a root(ish) article."
  4323. (let ((level (gnus-summary-thread-level article))
  4324. (refs (mail-header-references (gnus-summary-article-header article)))
  4325. particle)
  4326. (cond
  4327. ((null level) nil)
  4328. ((zerop level) t)
  4329. ((null refs) t)
  4330. ((null (gnus-parent-id refs)) t)
  4331. ((and (= 1 level)
  4332. (null (setq particle (gnus-id-to-article
  4333. (gnus-parent-id refs))))
  4334. (null (gnus-summary-thread-level particle)))))))
  4335. (defun gnus-root-id (id)
  4336. "Return the id of the root of the thread where ID appears."
  4337. (let (last-id prev)
  4338. (while (and id (setq prev (car (gnus-id-to-thread id))))
  4339. (setq last-id id
  4340. id (gnus-parent-id (mail-header-references prev))))
  4341. last-id))
  4342. (defun gnus-articles-in-thread (thread)
  4343. "Return the list of articles in THREAD."
  4344. (cons (mail-header-number (car thread))
  4345. (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
  4346. (defun gnus-remove-thread (id &optional dont-remove)
  4347. "Remove the thread that has ID in it."
  4348. (let (headers thread last-id)
  4349. ;; First go up in this thread until we find the root.
  4350. (setq last-id (gnus-root-id id)
  4351. headers (message-flatten-list (gnus-id-to-thread last-id)))
  4352. ;; We have now found the real root of this thread. It might have
  4353. ;; been gathered into some loose thread, so we have to search
  4354. ;; through the threads to find the thread we wanted.
  4355. (let ((threads gnus-newsgroup-threads)
  4356. sub)
  4357. (while threads
  4358. (setq sub (car threads))
  4359. (if (stringp (car sub))
  4360. ;; This is a gathered thread, so we look at the roots
  4361. ;; below it to find whether this article is in this
  4362. ;; gathered root.
  4363. (progn
  4364. (setq sub (cdr sub))
  4365. (while sub
  4366. (when (member (caar sub) headers)
  4367. (setq thread (car threads)
  4368. threads nil
  4369. sub nil))
  4370. (setq sub (cdr sub))))
  4371. ;; It's an ordinary thread, so we check it.
  4372. (when (eq (car sub) (car headers))
  4373. (setq thread sub
  4374. threads nil)))
  4375. (setq threads (cdr threads)))
  4376. ;; If this article is in no thread, then it's a root.
  4377. (if thread
  4378. (unless dont-remove
  4379. (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
  4380. (setq thread (gnus-id-to-thread last-id)))
  4381. (when thread
  4382. (prog1
  4383. thread ; We return this thread.
  4384. (unless dont-remove
  4385. (if (stringp (car thread))
  4386. (progn
  4387. ;; If we use dummy roots, then we have to remove the
  4388. ;; dummy root as well.
  4389. (when (eq gnus-summary-make-false-root 'dummy)
  4390. ;; We go to the dummy root by going to
  4391. ;; the first sub-"thread", and then one line up.
  4392. (gnus-summary-goto-article
  4393. (mail-header-number (caadr thread)))
  4394. (forward-line -1)
  4395. (gnus-delete-line)
  4396. (gnus-data-compute-positions))
  4397. (setq thread (cdr thread))
  4398. (while thread
  4399. (gnus-remove-thread-1 (car thread))
  4400. (setq thread (cdr thread))))
  4401. (gnus-remove-thread-1 thread))))))))
  4402. (defun gnus-remove-thread-1 (thread)
  4403. "Remove the thread THREAD recursively."
  4404. (let ((number (mail-header-number (pop thread)))
  4405. d)
  4406. (setq thread (reverse thread))
  4407. (while thread
  4408. (gnus-remove-thread-1 (pop thread)))
  4409. (when (setq d (gnus-data-find number))
  4410. (goto-char (gnus-data-pos d))
  4411. (gnus-summary-show-thread)
  4412. (gnus-data-remove
  4413. number
  4414. (- (point-at-bol)
  4415. (prog1
  4416. (1+ (point-at-eol))
  4417. (gnus-delete-line)))))))
  4418. (defun gnus-sort-threads-recursive (threads func)
  4419. (sort (mapcar (lambda (thread)
  4420. (cons (car thread)
  4421. (and (cdr thread)
  4422. (gnus-sort-threads-recursive (cdr thread) func))))
  4423. threads) func))
  4424. (defun gnus-sort-threads-loop (threads func)
  4425. (let* ((superthread (cons nil threads))
  4426. (stack (list (cons superthread threads)))
  4427. remaining-threads thread)
  4428. (while stack
  4429. (setq remaining-threads (cdr (car stack)))
  4430. (if remaining-threads
  4431. (progn (setq thread (car remaining-threads))
  4432. (setcdr (car stack) (cdr remaining-threads))
  4433. (if (cdr thread)
  4434. (push (cons thread (cdr thread)) stack)))
  4435. (setq thread (caar stack))
  4436. (setcdr thread (sort (cdr thread) func))
  4437. (pop stack)))
  4438. (cdr superthread)))
  4439. (defun gnus-sort-threads (threads)
  4440. "Sort THREADS."
  4441. (if (not gnus-thread-sort-functions)
  4442. threads
  4443. (gnus-message 8 "Sorting threads...")
  4444. (prog1
  4445. (condition-case nil
  4446. (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
  4447. (gnus-sort-threads-recursive
  4448. threads (gnus-make-sort-function gnus-thread-sort-functions)))
  4449. ;; Even after binding max-lisp-eval-depth, the recursive
  4450. ;; sorter might fail for very long threads. In that case,
  4451. ;; try using a (less well-tested) non-recursive sorter.
  4452. (error (gnus-message 9 "Sorting threads with loop...")
  4453. (gnus-sort-threads-loop
  4454. threads (gnus-make-sort-function
  4455. gnus-thread-sort-functions))))
  4456. (gnus-message 8 "Sorting threads...done"))))
  4457. (defun gnus-sort-articles (articles)
  4458. "Sort ARTICLES."
  4459. (when gnus-article-sort-functions
  4460. (gnus-message 7 "Sorting articles...")
  4461. (prog1
  4462. (setq gnus-newsgroup-headers
  4463. (sort articles (gnus-make-sort-function
  4464. gnus-article-sort-functions)))
  4465. (gnus-message 7 "Sorting articles...done"))))
  4466. ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
  4467. (defmacro gnus-thread-header (thread)
  4468. "Return header of first article in THREAD.
  4469. Note that THREAD must never, ever be anything else than a variable -
  4470. using some other form will lead to serious barfage."
  4471. (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
  4472. ;; (8% speedup to gnus-summary-prepare, just for fun :-)
  4473. (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
  4474. (vector thread) 2))
  4475. (defsubst gnus-article-sort-by-number (h1 h2)
  4476. "Sort articles by article number."
  4477. (< (mail-header-number h1)
  4478. (mail-header-number h2)))
  4479. (defun gnus-thread-sort-by-number (h1 h2)
  4480. "Sort threads by root article number."
  4481. (gnus-article-sort-by-number
  4482. (gnus-thread-header h1) (gnus-thread-header h2)))
  4483. (defsubst gnus-article-sort-by-random (h1 h2)
  4484. "Sort articles randomly."
  4485. (zerop (random 2)))
  4486. (defun gnus-thread-sort-by-random (h1 h2)
  4487. "Sort threads randomly."
  4488. (gnus-article-sort-by-random
  4489. (gnus-thread-header h1) (gnus-thread-header h2)))
  4490. (defsubst gnus-article-sort-by-lines (h1 h2)
  4491. "Sort articles by article Lines header."
  4492. (< (mail-header-lines h1)
  4493. (mail-header-lines h2)))
  4494. (defun gnus-thread-sort-by-lines (h1 h2)
  4495. "Sort threads by root article Lines header."
  4496. (gnus-article-sort-by-lines
  4497. (gnus-thread-header h1) (gnus-thread-header h2)))
  4498. (defsubst gnus-article-sort-by-chars (h1 h2)
  4499. "Sort articles by octet length."
  4500. (< (mail-header-chars h1)
  4501. (mail-header-chars h2)))
  4502. (defun gnus-thread-sort-by-chars (h1 h2)
  4503. "Sort threads by root article octet length."
  4504. (gnus-article-sort-by-chars
  4505. (gnus-thread-header h1) (gnus-thread-header h2)))
  4506. (defsubst gnus-article-sort-by-author (h1 h2)
  4507. "Sort articles by root author."
  4508. (gnus-string<
  4509. (let ((extract (funcall
  4510. gnus-extract-address-components
  4511. (mail-header-from h1))))
  4512. (or (car extract) (cadr extract) ""))
  4513. (let ((extract (funcall
  4514. gnus-extract-address-components
  4515. (mail-header-from h2))))
  4516. (or (car extract) (cadr extract) ""))))
  4517. (defun gnus-thread-sort-by-author (h1 h2)
  4518. "Sort threads by root author."
  4519. (gnus-article-sort-by-author
  4520. (gnus-thread-header h1) (gnus-thread-header h2)))
  4521. (defsubst gnus-article-sort-by-recipient (h1 h2)
  4522. "Sort articles by recipient."
  4523. (gnus-string<
  4524. (let ((extract (funcall
  4525. gnus-extract-address-components
  4526. (or (cdr (assq 'To (mail-header-extra h1))) ""))))
  4527. (or (car extract) (cadr extract)))
  4528. (let ((extract (funcall
  4529. gnus-extract-address-components
  4530. (or (cdr (assq 'To (mail-header-extra h2))) ""))))
  4531. (or (car extract) (cadr extract)))))
  4532. (defun gnus-thread-sort-by-recipient (h1 h2)
  4533. "Sort threads by root recipient."
  4534. (gnus-article-sort-by-recipient
  4535. (gnus-thread-header h1) (gnus-thread-header h2)))
  4536. (defsubst gnus-article-sort-by-subject (h1 h2)
  4537. "Sort articles by root subject."
  4538. (gnus-string<
  4539. (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
  4540. (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
  4541. (defun gnus-thread-sort-by-subject (h1 h2)
  4542. "Sort threads by root subject."
  4543. (gnus-article-sort-by-subject
  4544. (gnus-thread-header h1) (gnus-thread-header h2)))
  4545. (defsubst gnus-article-sort-by-date (h1 h2)
  4546. "Sort articles by root article date."
  4547. (time-less-p
  4548. (gnus-date-get-time (mail-header-date h1))
  4549. (gnus-date-get-time (mail-header-date h2))))
  4550. (defun gnus-thread-sort-by-date (h1 h2)
  4551. "Sort threads by root article date."
  4552. (gnus-article-sort-by-date
  4553. (gnus-thread-header h1) (gnus-thread-header h2)))
  4554. (defsubst gnus-article-sort-by-score (h1 h2)
  4555. "Sort articles by root article score.
  4556. Unscored articles will be counted as having a score of zero."
  4557. (> (or (cdr (assq (mail-header-number h1)
  4558. gnus-newsgroup-scored))
  4559. gnus-summary-default-score 0)
  4560. (or (cdr (assq (mail-header-number h2)
  4561. gnus-newsgroup-scored))
  4562. gnus-summary-default-score 0)))
  4563. (defun gnus-thread-sort-by-score (h1 h2)
  4564. "Sort threads by root article score."
  4565. (gnus-article-sort-by-score
  4566. (gnus-thread-header h1) (gnus-thread-header h2)))
  4567. (defun gnus-thread-sort-by-total-score (h1 h2)
  4568. "Sort threads by the sum of all scores in the thread.
  4569. Unscored articles will be counted as having a score of zero."
  4570. (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
  4571. (defun gnus-thread-total-score (thread)
  4572. ;; This function find the total score of THREAD.
  4573. (cond
  4574. ((null thread)
  4575. 0)
  4576. ((consp thread)
  4577. (if (stringp (car thread))
  4578. (apply gnus-thread-score-function 0
  4579. (mapcar 'gnus-thread-total-score-1 (cdr thread)))
  4580. (gnus-thread-total-score-1 thread)))
  4581. (t
  4582. (gnus-thread-total-score-1 (list thread)))))
  4583. (defun gnus-article-sort-by-most-recent-number (h1 h2)
  4584. "Sort articles by number."
  4585. (gnus-article-sort-by-number h1 h2))
  4586. (defun gnus-thread-sort-by-most-recent-number (h1 h2)
  4587. "Sort threads such that the thread with the most recently arrived article comes first."
  4588. (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
  4589. (defun gnus-thread-highest-number (thread)
  4590. "Return the highest article number in THREAD."
  4591. (apply 'max (mapcar (lambda (header)
  4592. (mail-header-number header))
  4593. (message-flatten-list thread))))
  4594. (defun gnus-article-sort-by-most-recent-date (h1 h2)
  4595. "Sort articles by number."
  4596. (gnus-article-sort-by-date h1 h2))
  4597. (defun gnus-thread-sort-by-most-recent-date (h1 h2)
  4598. "Sort threads such that the thread with the most recently dated article comes first."
  4599. (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
  4600. ; Since this is called not only to sort the top-level threads, but
  4601. ; also in recursive sorts to order the articles within a thread, each
  4602. ; article will be processed many times. Thus it speeds things up
  4603. ; quite a bit to use gnus-date-get-time, which caches the time value.
  4604. (defun gnus-thread-latest-date (thread)
  4605. "Return the highest article date in THREAD."
  4606. (apply 'max
  4607. (mapcar (lambda (header) (gnus-float-time
  4608. (gnus-date-get-time
  4609. (mail-header-date header))))
  4610. (message-flatten-list thread))))
  4611. (defun gnus-thread-total-score-1 (root)
  4612. ;; This function find the total score of the thread below ROOT.
  4613. (setq root (car root))
  4614. (apply gnus-thread-score-function
  4615. (or (append
  4616. (mapcar 'gnus-thread-total-score
  4617. (cdr (gnus-id-to-thread (mail-header-id root))))
  4618. (when (> (mail-header-number root) 0)
  4619. (list (or (cdr (assq (mail-header-number root)
  4620. gnus-newsgroup-scored))
  4621. gnus-summary-default-score 0))))
  4622. (list gnus-summary-default-score)
  4623. '(0))))
  4624. ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
  4625. (defvar gnus-tmp-prev-subject nil)
  4626. (defvar gnus-tmp-false-parent nil)
  4627. (defvar gnus-tmp-root-expunged nil)
  4628. (defvar gnus-tmp-dummy-line nil)
  4629. (defun gnus-extra-header (type &optional header)
  4630. "Return the extra header of TYPE."
  4631. (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
  4632. ""))
  4633. (defvar gnus-tmp-thread-tree-header-string "")
  4634. (defcustom gnus-sum-thread-tree-root "> "
  4635. "With %B spec, used for the root of a thread.
  4636. If nil, use subject instead."
  4637. :version "22.1"
  4638. :type '(radio (const :format "%v " nil) string)
  4639. :group 'gnus-thread)
  4640. (defcustom gnus-sum-thread-tree-false-root "> "
  4641. "With %B spec, used for a false root of a thread.
  4642. If nil, use subject instead."
  4643. :version "22.1"
  4644. :type '(radio (const :format "%v " nil) string)
  4645. :group 'gnus-thread)
  4646. (defcustom gnus-sum-thread-tree-single-indent ""
  4647. "With %B spec, used for a thread with just one message.
  4648. If nil, use subject instead."
  4649. :version "22.1"
  4650. :type '(radio (const :format "%v " nil) string)
  4651. :group 'gnus-thread)
  4652. (defcustom gnus-sum-thread-tree-vertical "| "
  4653. "With %B spec, used for drawing a vertical line."
  4654. :version "22.1"
  4655. :type 'string
  4656. :group 'gnus-thread)
  4657. (defcustom gnus-sum-thread-tree-indent " "
  4658. "With %B spec, used for indenting."
  4659. :version "22.1"
  4660. :type 'string
  4661. :group 'gnus-thread)
  4662. (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
  4663. "With %B spec, used for a leaf with brothers."
  4664. :version "22.1"
  4665. :type 'string
  4666. :group 'gnus-thread)
  4667. (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
  4668. "With %B spec, used for a leaf without brothers."
  4669. :version "22.1"
  4670. :type 'string
  4671. :group 'gnus-thread)
  4672. (defcustom gnus-summary-display-while-building nil
  4673. "If non-nil, show and update the summary buffer as it's being built.
  4674. If the value is t, update the buffer after every line is inserted. If
  4675. the value is an integer (N), update the display every N lines."
  4676. :version "22.1"
  4677. :group 'gnus-thread
  4678. :type '(choice (const :tag "off" nil)
  4679. number
  4680. (const :tag "frequently" t)))
  4681. (defun gnus-summary-prepare-threads (threads)
  4682. "Prepare summary buffer from THREADS and indentation LEVEL.
  4683. THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
  4684. or a straight list of headers."
  4685. (gnus-message 7 "Generating summary...")
  4686. (setq gnus-newsgroup-threads threads)
  4687. (beginning-of-line)
  4688. (let ((gnus-tmp-level 0)
  4689. (default-score (or gnus-summary-default-score 0))
  4690. (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
  4691. (building-line-count gnus-summary-display-while-building)
  4692. (building-count (integerp gnus-summary-display-while-building))
  4693. thread number subject stack state gnus-tmp-gathered beg-match
  4694. new-roots gnus-tmp-new-adopts thread-end simp-subject
  4695. gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
  4696. gnus-tmp-replied gnus-tmp-subject-or-nil
  4697. gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
  4698. gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
  4699. gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
  4700. tree-stack)
  4701. (setq gnus-tmp-prev-subject nil
  4702. gnus-tmp-thread-tree-header-string "")
  4703. (if (vectorp (car threads))
  4704. ;; If this is a straight (sic) list of headers, then a
  4705. ;; threaded summary display isn't required, so we just create
  4706. ;; an unthreaded one.
  4707. (gnus-summary-prepare-unthreaded threads)
  4708. ;; Do the threaded display.
  4709. (if gnus-summary-display-while-building
  4710. (switch-to-buffer (buffer-name)))
  4711. (while (or threads stack gnus-tmp-new-adopts new-roots)
  4712. (if (and (= gnus-tmp-level 0)
  4713. (or (not stack)
  4714. (= (caar stack) 0))
  4715. (not gnus-tmp-false-parent)
  4716. (or gnus-tmp-new-adopts new-roots))
  4717. (if gnus-tmp-new-adopts
  4718. (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
  4719. thread (list (car gnus-tmp-new-adopts))
  4720. gnus-tmp-header (caar thread)
  4721. gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
  4722. (when new-roots
  4723. (setq thread (list (car new-roots))
  4724. gnus-tmp-header (caar thread)
  4725. new-roots (cdr new-roots))))
  4726. (if threads
  4727. ;; If there are some threads, we do them before the
  4728. ;; threads on the stack.
  4729. (setq thread threads
  4730. gnus-tmp-header (caar thread))
  4731. ;; There were no current threads, so we pop something off
  4732. ;; the stack.
  4733. (setq state (car stack)
  4734. gnus-tmp-level (car state)
  4735. tree-stack (cadr state)
  4736. thread (caddr state)
  4737. stack (cdr stack)
  4738. gnus-tmp-header (caar thread))))
  4739. (setq gnus-tmp-false-parent nil)
  4740. (setq gnus-tmp-root-expunged nil)
  4741. (setq thread-end nil)
  4742. (if (stringp gnus-tmp-header)
  4743. ;; The header is a dummy root.
  4744. (cond
  4745. ((eq gnus-summary-make-false-root 'adopt)
  4746. ;; We let the first article adopt the rest.
  4747. (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
  4748. (cddar thread)))
  4749. (setq gnus-tmp-gathered
  4750. (nconc (mapcar
  4751. (lambda (h) (mail-header-number (car h)))
  4752. (cddar thread))
  4753. gnus-tmp-gathered))
  4754. (setq thread (cons (list (caar thread)
  4755. (cadar thread))
  4756. (cdr thread)))
  4757. (setq gnus-tmp-level -1
  4758. gnus-tmp-false-parent t))
  4759. ((eq gnus-summary-make-false-root 'empty)
  4760. ;; We print adopted articles with empty subject fields.
  4761. (setq gnus-tmp-gathered
  4762. (nconc (mapcar
  4763. (lambda (h) (mail-header-number (car h)))
  4764. (cddar thread))
  4765. gnus-tmp-gathered))
  4766. (setq gnus-tmp-level -1))
  4767. ((eq gnus-summary-make-false-root 'dummy)
  4768. ;; We remember that we probably want to output a dummy
  4769. ;; root.
  4770. (setq gnus-tmp-dummy-line gnus-tmp-header)
  4771. (setq gnus-tmp-prev-subject gnus-tmp-header))
  4772. (t
  4773. ;; We do not make a root for the gathered
  4774. ;; sub-threads at all.
  4775. (setq gnus-tmp-level -1)))
  4776. (setq number (mail-header-number gnus-tmp-header)
  4777. subject (mail-header-subject gnus-tmp-header)
  4778. simp-subject (gnus-simplify-subject-fully subject))
  4779. (cond
  4780. ;; If the thread has changed subject, we might want to make
  4781. ;; this subthread into a root.
  4782. ((and (null gnus-thread-ignore-subject)
  4783. (not (zerop gnus-tmp-level))
  4784. gnus-tmp-prev-subject
  4785. (not (string= gnus-tmp-prev-subject simp-subject)))
  4786. (setq new-roots (nconc new-roots (list (car thread)))
  4787. thread-end t
  4788. gnus-tmp-header nil))
  4789. ;; If the article lies outside the current limit,
  4790. ;; then we do not display it.
  4791. ((not (memq number gnus-newsgroup-limit))
  4792. (setq gnus-tmp-gathered
  4793. (nconc (mapcar
  4794. (lambda (h) (mail-header-number (car h)))
  4795. (cdar thread))
  4796. gnus-tmp-gathered))
  4797. (setq gnus-tmp-new-adopts (if (cdar thread)
  4798. (append gnus-tmp-new-adopts
  4799. (cdar thread))
  4800. gnus-tmp-new-adopts)
  4801. thread-end t
  4802. gnus-tmp-header nil)
  4803. (when (zerop gnus-tmp-level)
  4804. (setq gnus-tmp-root-expunged t)))
  4805. ;; Perhaps this article is to be marked as read?
  4806. ((and gnus-summary-mark-below
  4807. (< (or (cdr (assq number gnus-newsgroup-scored))
  4808. default-score)
  4809. gnus-summary-mark-below)
  4810. ;; Don't touch sparse articles.
  4811. (not (gnus-summary-article-sparse-p number))
  4812. (not (gnus-summary-article-ancient-p number)))
  4813. (setq gnus-newsgroup-unreads
  4814. (delq number gnus-newsgroup-unreads))
  4815. (if gnus-newsgroup-auto-expire
  4816. (setq gnus-newsgroup-expirable
  4817. (gnus-add-to-sorted-list
  4818. gnus-newsgroup-expirable number))
  4819. (push (cons number gnus-low-score-mark)
  4820. gnus-newsgroup-reads))))
  4821. (when gnus-tmp-header
  4822. ;; We may have an old dummy line to output before this
  4823. ;; article.
  4824. (when (and gnus-tmp-dummy-line
  4825. (gnus-subject-equal
  4826. gnus-tmp-dummy-line
  4827. (mail-header-subject gnus-tmp-header)))
  4828. (gnus-summary-insert-dummy-line
  4829. gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
  4830. (setq gnus-tmp-dummy-line nil))
  4831. ;; Compute the mark.
  4832. (setq gnus-tmp-unread (gnus-article-mark number))
  4833. (push (gnus-data-make number gnus-tmp-unread (1+ (point))
  4834. gnus-tmp-header gnus-tmp-level)
  4835. gnus-newsgroup-data)
  4836. ;; Actually insert the line.
  4837. (setq
  4838. gnus-tmp-subject-or-nil
  4839. (cond
  4840. ((and gnus-thread-ignore-subject
  4841. gnus-tmp-prev-subject
  4842. (not (string= gnus-tmp-prev-subject simp-subject)))
  4843. subject)
  4844. ((zerop gnus-tmp-level)
  4845. (if (and (eq gnus-summary-make-false-root 'empty)
  4846. (memq number gnus-tmp-gathered)
  4847. gnus-tmp-prev-subject
  4848. (string= gnus-tmp-prev-subject simp-subject))
  4849. gnus-summary-same-subject
  4850. subject))
  4851. (t gnus-summary-same-subject)))
  4852. (if (and (eq gnus-summary-make-false-root 'adopt)
  4853. (= gnus-tmp-level 1)
  4854. (memq number gnus-tmp-gathered))
  4855. (setq gnus-tmp-opening-bracket ?\<
  4856. gnus-tmp-closing-bracket ?\>)
  4857. (setq gnus-tmp-opening-bracket ?\[
  4858. gnus-tmp-closing-bracket ?\]))
  4859. (if (>= gnus-tmp-level (length gnus-thread-indent-array))
  4860. (gnus-make-thread-indent-array
  4861. (max (* 2 (length gnus-thread-indent-array))
  4862. gnus-tmp-level)))
  4863. (setq
  4864. gnus-tmp-indentation
  4865. (aref gnus-thread-indent-array gnus-tmp-level)
  4866. gnus-tmp-lines (mail-header-lines gnus-tmp-header)
  4867. gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
  4868. gnus-summary-default-score 0)
  4869. gnus-tmp-score-char
  4870. (if (or (null gnus-summary-default-score)
  4871. (<= (abs (- gnus-tmp-score gnus-summary-default-score))
  4872. gnus-summary-zcore-fuzz))
  4873. ? ;Whitespace
  4874. (if (< gnus-tmp-score gnus-summary-default-score)
  4875. gnus-score-below-mark gnus-score-over-mark))
  4876. gnus-tmp-replied
  4877. (cond ((memq number gnus-newsgroup-processable)
  4878. gnus-process-mark)
  4879. ((memq number gnus-newsgroup-cached)
  4880. gnus-cached-mark)
  4881. ((memq number gnus-newsgroup-replied)
  4882. gnus-replied-mark)
  4883. ((memq number gnus-newsgroup-forwarded)
  4884. gnus-forwarded-mark)
  4885. ((memq number gnus-newsgroup-saved)
  4886. gnus-saved-mark)
  4887. ((memq number gnus-newsgroup-unseen)
  4888. gnus-unseen-mark)
  4889. (t gnus-no-mark))
  4890. gnus-tmp-downloaded
  4891. (cond ((memq number gnus-newsgroup-undownloaded)
  4892. gnus-undownloaded-mark)
  4893. (gnus-newsgroup-agentized
  4894. gnus-downloaded-mark)
  4895. (t
  4896. gnus-no-mark))
  4897. gnus-tmp-from (mail-header-from gnus-tmp-header)
  4898. gnus-tmp-name
  4899. (cond
  4900. ((string-match "<[^>]+> *$" gnus-tmp-from)
  4901. (setq beg-match (match-beginning 0))
  4902. (or (and (string-match "^\".+\"" gnus-tmp-from)
  4903. (substring gnus-tmp-from 1 (1- (match-end 0))))
  4904. (substring gnus-tmp-from 0 beg-match)))
  4905. ((string-match "(.+)" gnus-tmp-from)
  4906. (substring gnus-tmp-from
  4907. (1+ (match-beginning 0)) (1- (match-end 0))))
  4908. (t gnus-tmp-from))
  4909. ;; Do the %B string
  4910. gnus-tmp-thread-tree-header-string
  4911. (cond
  4912. ((not gnus-show-threads) "")
  4913. ((zerop gnus-tmp-level)
  4914. (cond ((cdar thread)
  4915. (or gnus-sum-thread-tree-root subject))
  4916. (gnus-tmp-new-adopts
  4917. (or gnus-sum-thread-tree-false-root subject))
  4918. (t
  4919. (or gnus-sum-thread-tree-single-indent subject))))
  4920. (t
  4921. (concat (apply 'concat
  4922. (mapcar (lambda (item)
  4923. (if (= item 1)
  4924. gnus-sum-thread-tree-vertical
  4925. gnus-sum-thread-tree-indent))
  4926. (cdr (reverse tree-stack))))
  4927. (if (nth 1 thread)
  4928. gnus-sum-thread-tree-leaf-with-other
  4929. gnus-sum-thread-tree-single-leaf)))))
  4930. (when (string= gnus-tmp-name "")
  4931. (setq gnus-tmp-name gnus-tmp-from))
  4932. (unless (numberp gnus-tmp-lines)
  4933. (setq gnus-tmp-lines -1))
  4934. (if (= gnus-tmp-lines -1)
  4935. (setq gnus-tmp-lines "?")
  4936. (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
  4937. (gnus-put-text-property
  4938. (point)
  4939. (progn (eval gnus-summary-line-format-spec) (point))
  4940. 'gnus-number number)
  4941. (when gnus-visual-p
  4942. (forward-line -1)
  4943. (gnus-summary-highlight-line)
  4944. (when gnus-summary-update-hook
  4945. (gnus-run-hooks 'gnus-summary-update-hook))
  4946. (forward-line 1))
  4947. (setq gnus-tmp-prev-subject simp-subject)))
  4948. (when (nth 1 thread)
  4949. (push (list (max 0 gnus-tmp-level)
  4950. (copy-sequence tree-stack)
  4951. (nthcdr 1 thread))
  4952. stack))
  4953. (push (if (nth 1 thread) 1 0) tree-stack)
  4954. (incf gnus-tmp-level)
  4955. (setq threads (if thread-end nil (cdar thread)))
  4956. (if gnus-summary-display-while-building
  4957. (if building-count
  4958. (progn
  4959. ;; use a set frequency
  4960. (setq building-line-count (1- building-line-count))
  4961. (when (= building-line-count 0)
  4962. (sit-for 0)
  4963. (setq building-line-count
  4964. gnus-summary-display-while-building)))
  4965. ;; always
  4966. (sit-for 0)))
  4967. (unless threads
  4968. (setq gnus-tmp-level 0)))))
  4969. (gnus-message 7 "Generating summary...done"))
  4970. (defun gnus-summary-prepare-unthreaded (headers)
  4971. "Generate an unthreaded summary buffer based on HEADERS."
  4972. (let (header number mark)
  4973. (beginning-of-line)
  4974. (while headers
  4975. ;; We may have to root out some bad articles...
  4976. (when (memq (setq number (mail-header-number
  4977. (setq header (pop headers))))
  4978. gnus-newsgroup-limit)
  4979. ;; Mark article as read when it has a low score.
  4980. (when (and gnus-summary-mark-below
  4981. (< (or (cdr (assq number gnus-newsgroup-scored))
  4982. gnus-summary-default-score 0)
  4983. gnus-summary-mark-below)
  4984. (not (gnus-summary-article-ancient-p number)))
  4985. (setq gnus-newsgroup-unreads
  4986. (delq number gnus-newsgroup-unreads))
  4987. (if gnus-newsgroup-auto-expire
  4988. (push number gnus-newsgroup-expirable)
  4989. (push (cons number gnus-low-score-mark)
  4990. gnus-newsgroup-reads)))
  4991. (setq mark (gnus-article-mark number))
  4992. (push (gnus-data-make number mark (1+ (point)) header 0)
  4993. gnus-newsgroup-data)
  4994. (gnus-summary-insert-line
  4995. header 0 number
  4996. (memq number gnus-newsgroup-undownloaded)
  4997. mark (memq number gnus-newsgroup-replied)
  4998. (memq number gnus-newsgroup-expirable)
  4999. (mail-header-subject header) nil
  5000. (cdr (assq number gnus-newsgroup-scored))
  5001. (memq number gnus-newsgroup-processable))))))
  5002. (defun gnus-group-get-list-identifiers (group)
  5003. "Get list identifier regexp for GROUP."
  5004. (or (gnus-parameter-list-identifier group)
  5005. (if (consp gnus-list-identifiers)
  5006. (mapconcat 'identity gnus-list-identifiers " *\\|")
  5007. gnus-list-identifiers)))
  5008. (defun gnus-summary-remove-list-identifiers ()
  5009. "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
  5010. (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
  5011. changed subject)
  5012. (when regexp
  5013. (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
  5014. (dolist (header gnus-newsgroup-headers)
  5015. (setq subject (mail-header-subject header)
  5016. changed nil)
  5017. (while (string-match regexp subject)
  5018. (setq subject
  5019. (concat (substring subject 0 (match-beginning 1))
  5020. (substring subject (match-end 0)))
  5021. changed t))
  5022. (when changed
  5023. (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
  5024. (setq subject
  5025. (concat (substring subject 0 (match-beginning 1))
  5026. (substring subject (match-end 1)))))
  5027. (mail-header-set-subject header subject))))))
  5028. (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
  5029. "Fetch headers of ARTICLES."
  5030. (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
  5031. (gnus-message 7 "Fetching headers for %s..." name)
  5032. (prog1
  5033. (if (eq 'nov
  5034. (setq gnus-headers-retrieved-by
  5035. (gnus-retrieve-headers
  5036. articles gnus-newsgroup-name
  5037. (or limit
  5038. ;; We might want to fetch old headers, but
  5039. ;; not if there is only 1 article.
  5040. (and (or (and
  5041. (not (eq gnus-fetch-old-headers 'some))
  5042. (not (numberp gnus-fetch-old-headers)))
  5043. (> (length articles) 1))
  5044. gnus-fetch-old-headers)))))
  5045. (gnus-get-newsgroup-headers-xover
  5046. articles force-new dependencies gnus-newsgroup-name t)
  5047. (gnus-get-newsgroup-headers dependencies force-new))
  5048. (gnus-message 7 "Fetching headers for %s...done" name))))
  5049. (defun gnus-select-newsgroup (group &optional read-all select-articles)
  5050. "Select newsgroup GROUP.
  5051. If READ-ALL is non-nil, all articles in the group are selected.
  5052. If SELECT-ARTICLES, only select those articles from GROUP."
  5053. (let* ((entry (gnus-group-entry group))
  5054. ;;!!! Dirty hack; should be removed.
  5055. (gnus-summary-ignore-duplicates
  5056. (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
  5057. t
  5058. gnus-summary-ignore-duplicates))
  5059. (info (nth 2 entry))
  5060. charset articles fetched-articles cached)
  5061. (unless (gnus-check-server
  5062. (set (make-local-variable 'gnus-current-select-method)
  5063. (gnus-find-method-for-group group)))
  5064. (error "Couldn't open server"))
  5065. (setq charset (gnus-group-name-charset gnus-current-select-method group))
  5066. (or (and entry (not (eq (car entry) t))) ; Either it's active...
  5067. (gnus-activate-group group) ; Or we can activate it...
  5068. (progn ; Or we bug out.
  5069. (when (equal major-mode 'gnus-summary-mode)
  5070. (gnus-kill-buffer (current-buffer)))
  5071. (error
  5072. "Couldn't activate group %s: %s"
  5073. (mm-decode-coding-string group charset)
  5074. (mm-decode-coding-string (gnus-status-message group) charset))))
  5075. (unless (gnus-request-group group t)
  5076. (when (equal major-mode 'gnus-summary-mode)
  5077. (gnus-kill-buffer (current-buffer)))
  5078. (error "Couldn't request group %s: %s"
  5079. (mm-decode-coding-string group charset)
  5080. (mm-decode-coding-string (gnus-status-message group) charset)))
  5081. (when (and gnus-agent
  5082. (gnus-active group))
  5083. (gnus-agent-possibly-alter-active group (gnus-active group) info)
  5084. (setq gnus-summary-use-undownloaded-faces
  5085. (gnus-agent-find-parameter
  5086. group
  5087. 'agent-enable-undownloaded-faces)))
  5088. (setq gnus-newsgroup-name group
  5089. gnus-newsgroup-unselected nil
  5090. gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
  5091. (let ((display (gnus-group-find-parameter group 'display)))
  5092. (setq gnus-newsgroup-display
  5093. (cond
  5094. ((not (zerop (or (car-safe read-all) 0)))
  5095. ;; The user entered the group with C-u SPC/RET, let's show
  5096. ;; all articles.
  5097. 'gnus-not-ignore)
  5098. ((eq display 'all)
  5099. 'gnus-not-ignore)
  5100. ((arrayp display)
  5101. (gnus-summary-display-make-predicate (mapcar 'identity display)))
  5102. ((numberp display)
  5103. ;; The following is probably the "correct" solution, but
  5104. ;; it makes Gnus fetch all headers and then limit the
  5105. ;; articles (which is slow), so instead we hack the
  5106. ;; select-articles parameter instead. -- Simon Josefsson
  5107. ;; <jas@kth.se>
  5108. ;;
  5109. ;; (gnus-byte-compile
  5110. ;; `(lambda () (> number ,(- (cdr (gnus-active group))
  5111. ;; display)))))
  5112. (setq select-articles
  5113. (gnus-uncompress-range
  5114. (cons (let ((tmp (- (cdr (gnus-active group)) display)))
  5115. (if (> tmp 0)
  5116. tmp
  5117. 1))
  5118. (cdr (gnus-active group)))))
  5119. nil)
  5120. (t
  5121. nil))))
  5122. (gnus-summary-setup-default-charset)
  5123. ;; Kludge to avoid having cached articles nixed out in virtual groups.
  5124. (when (gnus-virtual-group-p group)
  5125. (setq cached gnus-newsgroup-cached))
  5126. (setq gnus-newsgroup-unreads
  5127. (gnus-sorted-ndifference
  5128. (gnus-sorted-ndifference gnus-newsgroup-unreads
  5129. gnus-newsgroup-marked)
  5130. gnus-newsgroup-dormant))
  5131. (setq gnus-newsgroup-processable nil)
  5132. (gnus-update-read-articles group gnus-newsgroup-unreads t)
  5133. ;; Adjust and set lists of article marks.
  5134. (when info
  5135. (gnus-adjust-marked-articles info))
  5136. (if (setq articles select-articles)
  5137. (setq gnus-newsgroup-unselected
  5138. (gnus-sorted-difference gnus-newsgroup-unreads articles))
  5139. (setq articles (gnus-articles-to-read group read-all)))
  5140. (cond
  5141. ((null articles)
  5142. ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
  5143. 'quit)
  5144. ((eq articles 0) nil)
  5145. (t
  5146. ;; Init the dependencies hash table.
  5147. (setq gnus-newsgroup-dependencies
  5148. (gnus-make-hashtable (length articles)))
  5149. (gnus-set-global-variables)
  5150. ;; Retrieve the headers and read them in.
  5151. (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
  5152. ;; Kludge to avoid having cached articles nixed out in virtual groups.
  5153. (when cached
  5154. (setq gnus-newsgroup-cached cached))
  5155. ;; Suppress duplicates?
  5156. (when gnus-suppress-duplicates
  5157. (gnus-dup-suppress-articles))
  5158. ;; Set the initial limit.
  5159. (setq gnus-newsgroup-limit (copy-sequence articles))
  5160. ;; Remove canceled articles from the list of unread articles.
  5161. (setq fetched-articles
  5162. (mapcar (lambda (headers) (mail-header-number headers))
  5163. gnus-newsgroup-headers))
  5164. (setq gnus-newsgroup-articles fetched-articles)
  5165. (setq gnus-newsgroup-unreads
  5166. (gnus-sorted-nintersection
  5167. gnus-newsgroup-unreads fetched-articles))
  5168. (gnus-compute-unseen-list)
  5169. ;; Removed marked articles that do not exist.
  5170. (gnus-update-missing-marks
  5171. (gnus-sorted-difference articles fetched-articles))
  5172. ;; We might want to build some more threads first.
  5173. (when (and gnus-fetch-old-headers
  5174. (eq gnus-headers-retrieved-by 'nov))
  5175. (if (eq gnus-fetch-old-headers 'invisible)
  5176. (gnus-build-all-threads)
  5177. (gnus-build-old-threads)))
  5178. ;; Let the Gnus agent mark articles as read.
  5179. (when gnus-agent
  5180. (gnus-agent-get-undownloaded-list))
  5181. ;; Remove list identifiers from subject
  5182. (gnus-summary-remove-list-identifiers)
  5183. ;; Check whether auto-expire is to be done in this group.
  5184. (setq gnus-newsgroup-auto-expire
  5185. (and (gnus-group-auto-expirable-p group)
  5186. (not (gnus-group-read-only-p group))))
  5187. ;; Set up the article buffer now, if necessary.
  5188. (unless (and gnus-single-article-buffer
  5189. (equal gnus-article-buffer "*Article*"))
  5190. (gnus-article-setup-buffer))
  5191. ;; First and last article in this newsgroup.
  5192. (when gnus-newsgroup-headers
  5193. (setq gnus-newsgroup-begin
  5194. (mail-header-number (car gnus-newsgroup-headers))
  5195. gnus-newsgroup-end
  5196. (mail-header-number
  5197. (gnus-last-element gnus-newsgroup-headers))))
  5198. ;; GROUP is successfully selected.
  5199. (or gnus-newsgroup-headers t)))))
  5200. (defun gnus-compute-unseen-list ()
  5201. ;; The `seen' marks are treated specially.
  5202. (if (not gnus-newsgroup-seen)
  5203. (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
  5204. (setq gnus-newsgroup-unseen
  5205. (gnus-inverse-list-range-intersection
  5206. gnus-newsgroup-articles gnus-newsgroup-seen))))
  5207. (declare-function gnus-get-predicate "gnus-agent" (predicate))
  5208. (defun gnus-summary-display-make-predicate (display)
  5209. (require 'gnus-agent)
  5210. (when (= (length display) 1)
  5211. (setq display (car display)))
  5212. (unless gnus-summary-display-cache
  5213. (dolist (elem (append '((unread . unread)
  5214. (read . read)
  5215. (unseen . unseen))
  5216. gnus-article-mark-lists))
  5217. (push (cons (cdr elem)
  5218. (gnus-byte-compile ;Why bother?
  5219. `(lambda () (gnus-article-marked-p ',(cdr elem)))))
  5220. gnus-summary-display-cache)))
  5221. (let ((gnus-category-predicate-alist gnus-summary-display-cache)
  5222. (gnus-category-predicate-cache gnus-summary-display-cache))
  5223. (gnus-get-predicate display)))
  5224. ;; Uses the dynamically bound `gnus-number' variable.
  5225. (defvar gnus-number)
  5226. (defun gnus-article-marked-p (type &optional article)
  5227. (let ((article (or article gnus-number)))
  5228. (cond
  5229. ((eq type 'tick)
  5230. (memq article gnus-newsgroup-marked))
  5231. ((eq type 'spam)
  5232. (memq article gnus-newsgroup-spam-marked))
  5233. ((eq type 'unsend)
  5234. (memq article gnus-newsgroup-unsendable))
  5235. ((eq type 'undownload)
  5236. (memq article gnus-newsgroup-undownloaded))
  5237. ((eq type 'download)
  5238. (memq article gnus-newsgroup-downloadable))
  5239. ((eq type 'unread)
  5240. (memq article gnus-newsgroup-unreads))
  5241. ((eq type 'read)
  5242. (memq article gnus-newsgroup-reads))
  5243. ((eq type 'dormant)
  5244. (memq article gnus-newsgroup-dormant) )
  5245. ((eq type 'expire)
  5246. (memq article gnus-newsgroup-expirable))
  5247. ((eq type 'reply)
  5248. (memq article gnus-newsgroup-replied))
  5249. ((eq type 'killed)
  5250. (memq article gnus-newsgroup-killed))
  5251. ((eq type 'bookmark)
  5252. (assq article gnus-newsgroup-bookmarks))
  5253. ((eq type 'score)
  5254. (assq article gnus-newsgroup-scored))
  5255. ((eq type 'save)
  5256. (memq article gnus-newsgroup-saved))
  5257. ((eq type 'cache)
  5258. (memq article gnus-newsgroup-cached))
  5259. ((eq type 'forward)
  5260. (memq article gnus-newsgroup-forwarded))
  5261. ((eq type 'seen)
  5262. (not (memq article gnus-newsgroup-unseen)))
  5263. (t t))))
  5264. (defun gnus-articles-to-read (group &optional read-all)
  5265. "Find out what articles the user wants to read."
  5266. (let* ((only-read-p t)
  5267. (articles
  5268. ;; Select all articles if `read-all' is non-nil, or if there
  5269. ;; are no unread articles.
  5270. (if (or read-all
  5271. (and (zerop (length gnus-newsgroup-marked))
  5272. (zerop (length gnus-newsgroup-unreads)))
  5273. ;; Fetch all if the predicate is non-nil.
  5274. gnus-newsgroup-display)
  5275. ;; We want to select the headers for all the articles in
  5276. ;; the group, so we select either all the active
  5277. ;; articles in the group, or (if that's nil), the
  5278. ;; articles in the cache.
  5279. (or
  5280. (if gnus-newsgroup-maximum-articles
  5281. (let ((active (gnus-active group)))
  5282. (gnus-uncompress-range
  5283. (cons (max (car active)
  5284. (- (cdr active)
  5285. gnus-newsgroup-maximum-articles
  5286. -1))
  5287. (cdr active))))
  5288. (gnus-uncompress-range (gnus-active group)))
  5289. (gnus-cache-articles-in-group group))
  5290. ;; Select only the "normal" subset of articles.
  5291. (setq only-read-p nil)
  5292. (gnus-sorted-nunion
  5293. (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
  5294. gnus-newsgroup-unreads)))
  5295. (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
  5296. (scored (length scored-list))
  5297. (number (length articles))
  5298. (marked (+ (length gnus-newsgroup-marked)
  5299. (length gnus-newsgroup-dormant)))
  5300. (select
  5301. (cond
  5302. ((numberp read-all)
  5303. read-all)
  5304. ((numberp gnus-newsgroup-display)
  5305. gnus-newsgroup-display)
  5306. (t
  5307. (condition-case ()
  5308. (cond
  5309. ((and (or (<= scored marked) (= scored number))
  5310. (numberp gnus-large-newsgroup)
  5311. (> number gnus-large-newsgroup))
  5312. (let* ((cursor-in-echo-area nil)
  5313. (initial (gnus-parameter-large-newsgroup-initial
  5314. gnus-newsgroup-name))
  5315. (default (if only-read-p
  5316. (or initial gnus-large-newsgroup)
  5317. number))
  5318. (input
  5319. (read-string
  5320. (if only-read-p
  5321. (format
  5322. "How many articles from %s (available %d, default %d): "
  5323. (gnus-group-decoded-name
  5324. (gnus-group-real-name gnus-newsgroup-name))
  5325. number default)
  5326. (format
  5327. "How many articles from %s (%d default): "
  5328. (gnus-group-decoded-name
  5329. (gnus-group-real-name gnus-newsgroup-name))
  5330. default))
  5331. nil
  5332. nil
  5333. (number-to-string default))))
  5334. (if (string-match "^[ \t]*$" input) number input)))
  5335. ((and (> scored marked) (< scored number)
  5336. (> (- scored number) 20))
  5337. (let ((input
  5338. (read-string
  5339. (format "%s %s (%d scored, %d total): "
  5340. "How many articles from"
  5341. (gnus-group-decoded-name
  5342. (gnus-group-real-name gnus-newsgroup-name))
  5343. scored number))))
  5344. (if (string-match "^[ \t]*$" input)
  5345. number input)))
  5346. (t number))
  5347. (quit
  5348. (message "Quit getting the articles to read")
  5349. nil))))))
  5350. (setq select (if (stringp select) (string-to-number select) select))
  5351. (if (or (null select) (zerop select))
  5352. select
  5353. (if (and (not (zerop scored)) (<= (abs select) scored))
  5354. (progn
  5355. (setq articles (sort scored-list '<))
  5356. (setq number (length articles)))
  5357. (setq articles (copy-sequence articles)))
  5358. (when (< (abs select) number)
  5359. (if (< select 0)
  5360. ;; Select the N oldest articles.
  5361. (setcdr (nthcdr (1- (abs select)) articles) nil)
  5362. ;; Select the N most recent articles.
  5363. (setq articles (nthcdr (- number select) articles))))
  5364. (setq gnus-newsgroup-unselected
  5365. (gnus-sorted-difference gnus-newsgroup-unreads articles))
  5366. (when gnus-alter-articles-to-read-function
  5367. (setq articles
  5368. (sort
  5369. (funcall gnus-alter-articles-to-read-function
  5370. gnus-newsgroup-name articles)
  5371. '<)))
  5372. articles)))
  5373. (defun gnus-killed-articles (killed articles)
  5374. (let (out)
  5375. (while articles
  5376. (when (inline (gnus-member-of-range (car articles) killed))
  5377. (push (car articles) out))
  5378. (setq articles (cdr articles)))
  5379. out))
  5380. (defun gnus-uncompress-marks (marks)
  5381. "Uncompress the mark ranges in MARKS."
  5382. (let ((uncompressed '(score bookmark))
  5383. out)
  5384. (while marks
  5385. (if (memq (caar marks) uncompressed)
  5386. (push (car marks) out)
  5387. (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
  5388. (setq marks (cdr marks)))
  5389. out))
  5390. (defun gnus-article-mark-to-type (mark)
  5391. "Return the type of MARK."
  5392. (or (cadr (assq mark gnus-article-special-mark-lists))
  5393. 'list))
  5394. (defun gnus-article-unpropagatable-p (mark)
  5395. "Return whether MARK should be propagated to back end."
  5396. (memq mark gnus-article-unpropagated-mark-lists))
  5397. (defun gnus-adjust-marked-articles (info)
  5398. "Set all article lists and remove all marks that are no longer valid."
  5399. (let* ((marked-lists (gnus-info-marks info))
  5400. (active (gnus-active (gnus-info-group info)))
  5401. (min (car active))
  5402. (max (cdr active))
  5403. (types gnus-article-mark-lists)
  5404. marks var articles article mark mark-type
  5405. bgn end)
  5406. ;; Hack to avoid adjusting marks for imap.
  5407. (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
  5408. 'nnimap)
  5409. (setq min 1))
  5410. (dolist (marks marked-lists)
  5411. (setq mark (car marks)
  5412. mark-type (gnus-article-mark-to-type mark)
  5413. var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
  5414. ;; We set the variable according to the type of the marks list,
  5415. ;; and then adjust the marks to a subset of the active articles.
  5416. (cond
  5417. ;; Adjust "simple" lists - compressed yet unsorted
  5418. ((eq mark-type 'list)
  5419. ;; Simultaneously uncompress and clip to active range
  5420. ;; See gnus-uncompress-range for a description of possible marks
  5421. (let (l lh)
  5422. (if (not (cadr marks))
  5423. (set var nil)
  5424. (setq articles (if (numberp (cddr marks))
  5425. (list (cdr marks))
  5426. (cdr marks))
  5427. lh (cons nil nil)
  5428. l lh)
  5429. (while (setq article (pop articles))
  5430. (cond ((consp article)
  5431. (setq bgn (max (car article) min)
  5432. end (min (cdr article) max))
  5433. (while (<= bgn end)
  5434. (setq l (setcdr l (cons bgn nil))
  5435. bgn (1+ bgn))))
  5436. ((and (<= min article)
  5437. (>= max article))
  5438. (setq l (setcdr l (cons article nil))))))
  5439. (set var (cdr lh)))))
  5440. ;; Adjust assocs.
  5441. ((eq mark-type 'tuple)
  5442. (set var (setq articles (cdr marks)))
  5443. (when (not (listp (cdr (symbol-value var))))
  5444. (set var (list (symbol-value var))))
  5445. (when (not (listp (cdr articles)))
  5446. (setq articles (list articles)))
  5447. (while articles
  5448. (when (or (not (consp (setq article (pop articles))))
  5449. (< (car article) min)
  5450. (> (car article) max))
  5451. (set var (delq article (symbol-value var))))))
  5452. ;; Adjust ranges (sloppily).
  5453. ((eq mark-type 'range)
  5454. (cond
  5455. ((eq mark 'seen)
  5456. ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
  5457. ;; It should be (seen (NUM1 . NUM2)).
  5458. (when (numberp (cddr marks))
  5459. (setcdr marks (list (cdr marks))))
  5460. (setq articles (cdr marks))
  5461. (while (and articles
  5462. (or (and (consp (car articles))
  5463. (> min (cdar articles)))
  5464. (and (numberp (car articles))
  5465. (> min (car articles)))))
  5466. (pop articles))
  5467. (set var articles))))))))
  5468. (defun gnus-update-missing-marks (missing)
  5469. "Go through the list of MISSING articles and remove them from the mark lists."
  5470. (when missing
  5471. (let (var m)
  5472. ;; Go through all types.
  5473. (dolist (elem gnus-article-mark-lists)
  5474. (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
  5475. (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
  5476. (when (symbol-value var)
  5477. ;; This list has articles. So we delete all missing
  5478. ;; articles from it.
  5479. (setq m missing)
  5480. (while m
  5481. (set var (delq (pop m) (symbol-value var))))))))))
  5482. (defun gnus-update-marks ()
  5483. "Enter the various lists of marked articles into the newsgroup info list."
  5484. (let ((types gnus-article-mark-lists)
  5485. (info (gnus-get-info gnus-newsgroup-name))
  5486. type list newmarked symbol delta-marks)
  5487. (when info
  5488. ;; Add all marks lists to the list of marks lists.
  5489. (while (setq type (pop types))
  5490. (setq list (symbol-value
  5491. (setq symbol
  5492. (intern (format "gnus-newsgroup-%s" (car type))))))
  5493. (when list
  5494. ;; Get rid of the entries of the articles that have the
  5495. ;; default score.
  5496. (when (and (eq (cdr type) 'score)
  5497. gnus-save-score
  5498. list)
  5499. (let* ((arts list)
  5500. (prev (cons nil list))
  5501. (all prev))
  5502. (while arts
  5503. (if (or (not (consp (car arts)))
  5504. (= (cdar arts) gnus-summary-default-score))
  5505. (setcdr prev (cdr arts))
  5506. (setq prev arts))
  5507. (setq arts (cdr arts)))
  5508. (setq list (cdr all)))))
  5509. (when (eq (cdr type) 'seen)
  5510. (setq list (gnus-range-add list gnus-newsgroup-unseen)))
  5511. (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
  5512. (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
  5513. (when (and (gnus-check-backend-function
  5514. 'request-set-mark gnus-newsgroup-name)
  5515. (or gnus-propagate-marks
  5516. (gnus-method-option-p
  5517. (gnus-find-method-for-group gnus-newsgroup-name)
  5518. 'server-marks))
  5519. (not (gnus-article-unpropagatable-p (cdr type))))
  5520. (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
  5521. ;; Don't do anything about marks for articles we
  5522. ;; didn't actually get any headers for.
  5523. (del
  5524. (gnus-list-range-intersection
  5525. gnus-newsgroup-articles
  5526. (gnus-remove-from-range (gnus-copy-sequence old) list)))
  5527. (add
  5528. (gnus-list-range-intersection
  5529. gnus-newsgroup-articles
  5530. (gnus-remove-from-range
  5531. (gnus-copy-sequence list) old))))
  5532. (when add
  5533. (push (list add 'add (list (cdr type))) delta-marks))
  5534. (when del
  5535. ;; Don't delete marks from outside the active range.
  5536. ;; This shouldn't happen, but is a sanity check.
  5537. (setq del (gnus-sorted-range-intersection
  5538. (gnus-active gnus-newsgroup-name) del))
  5539. (push (list del 'del (list (cdr type))) delta-marks))))
  5540. (when list
  5541. (push (cons (cdr type) list) newmarked)))
  5542. (when delta-marks
  5543. (unless (gnus-check-group gnus-newsgroup-name)
  5544. (error "Can't open server for %s" gnus-newsgroup-name))
  5545. (gnus-request-set-mark gnus-newsgroup-name delta-marks))
  5546. ;; Enter these new marks into the info of the group.
  5547. (if (nthcdr 3 info)
  5548. (setcar (nthcdr 3 info) newmarked)
  5549. ;; Add the marks lists to the end of the info.
  5550. (when newmarked
  5551. (setcdr (nthcdr 2 info) (list newmarked))))
  5552. ;; Cut off the end of the info if there's nothing else there.
  5553. (let ((i 5))
  5554. (while (and (> i 2)
  5555. (not (nth i info)))
  5556. (when (nthcdr (decf i) info)
  5557. (setcdr (nthcdr i info) nil)))))))
  5558. (defun gnus-set-mode-line (where)
  5559. "Set the mode line of the article or summary buffers.
  5560. If WHERE is `summary', the summary mode line format will be used."
  5561. ;; Is this mode line one we keep updated?
  5562. (when (and (memq where gnus-updated-mode-lines)
  5563. (symbol-value
  5564. (intern (format "gnus-%s-mode-line-format-spec" where))))
  5565. (let (mode-string)
  5566. ;; We evaluate this in the summary buffer since these
  5567. ;; variables are buffer-local to that buffer.
  5568. (with-current-buffer gnus-summary-buffer
  5569. ;; We bind all these variables that are used in the `eval' form
  5570. ;; below.
  5571. (let* ((mformat (symbol-value
  5572. (intern
  5573. (format "gnus-%s-mode-line-format-spec" where))))
  5574. (gnus-tmp-group-name (gnus-mode-string-quote
  5575. (gnus-group-decoded-name
  5576. gnus-newsgroup-name)))
  5577. (gnus-tmp-article-number (or gnus-current-article 0))
  5578. (gnus-tmp-unread gnus-newsgroup-unreads)
  5579. (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
  5580. (gnus-tmp-unselected (length gnus-newsgroup-unselected))
  5581. (gnus-tmp-unread-and-unselected
  5582. (cond ((and (zerop gnus-tmp-unread-and-unticked)
  5583. (zerop gnus-tmp-unselected))
  5584. "")
  5585. ((zerop gnus-tmp-unselected)
  5586. (format "{%d more}" gnus-tmp-unread-and-unticked))
  5587. (t (format "{%d(+%d) more}"
  5588. gnus-tmp-unread-and-unticked
  5589. gnus-tmp-unselected))))
  5590. (gnus-tmp-subject
  5591. (if (and gnus-current-headers
  5592. (vectorp gnus-current-headers))
  5593. (gnus-mode-string-quote
  5594. (mail-header-subject gnus-current-headers))
  5595. ""))
  5596. bufname-length max-len
  5597. gnus-tmp-header) ;; passed as argument to any user-format-funcs
  5598. (setq mode-string (eval mformat))
  5599. (setq bufname-length (if (string-match "%b" mode-string)
  5600. (- (length
  5601. (buffer-name
  5602. (if (eq where 'summary)
  5603. nil
  5604. (get-buffer gnus-article-buffer))))
  5605. 2)
  5606. 0))
  5607. (setq max-len (max 4 (if gnus-mode-non-string-length
  5608. (- (window-width)
  5609. gnus-mode-non-string-length
  5610. bufname-length)
  5611. (length mode-string))))
  5612. ;; We might have to chop a bit of the string off...
  5613. (when (> (length mode-string) max-len)
  5614. (setq mode-string
  5615. (concat (truncate-string-to-width mode-string (- max-len 3))
  5616. "...")))))
  5617. ;; Update the mode line.
  5618. (setq mode-line-buffer-identification
  5619. (gnus-mode-line-buffer-identification (list mode-string)))
  5620. (set-buffer-modified-p t))))
  5621. (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
  5622. "Go through the HEADERS list and add all Xrefs to a hash table.
  5623. The resulting hash table is returned, or nil if no Xrefs were found."
  5624. (let* ((virtual (gnus-virtual-group-p from-newsgroup))
  5625. (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
  5626. (xref-hashtb (gnus-make-hashtable))
  5627. start group entry number xrefs header)
  5628. (while headers
  5629. (setq header (pop headers))
  5630. (when (and (setq xrefs (mail-header-xref header))
  5631. (not (memq (setq number (mail-header-number header))
  5632. unreads)))
  5633. (setq start 0)
  5634. (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
  5635. (setq start (match-end 0))
  5636. (setq group (if prefix
  5637. (concat prefix (substring xrefs (match-beginning 1)
  5638. (match-end 1)))
  5639. (substring xrefs (match-beginning 1) (match-end 1))))
  5640. (setq number
  5641. (string-to-number (substring xrefs (match-beginning 2)
  5642. (match-end 2))))
  5643. (if (setq entry (gnus-gethash group xref-hashtb))
  5644. (setcdr entry (cons number (cdr entry)))
  5645. (gnus-sethash group (cons number nil) xref-hashtb)))))
  5646. (and start xref-hashtb)))
  5647. (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
  5648. "Look through all the headers and mark the Xrefs as read."
  5649. (let ((virtual (gnus-virtual-group-p from-newsgroup))
  5650. name info xref-hashtb idlist method nth4)
  5651. (with-current-buffer gnus-group-buffer
  5652. (when (setq xref-hashtb
  5653. (gnus-create-xref-hashtb from-newsgroup headers unreads))
  5654. (mapatoms
  5655. (lambda (group)
  5656. (unless (string= from-newsgroup (setq name (symbol-name group)))
  5657. (setq idlist (symbol-value group))
  5658. ;; Dead groups are not updated.
  5659. (and (prog1
  5660. (setq info (gnus-get-info name))
  5661. (when (stringp (setq nth4 (gnus-info-method info)))
  5662. (setq nth4 (gnus-server-to-method nth4))))
  5663. ;; Only do the xrefs if the group has the same
  5664. ;; select method as the group we have just read.
  5665. (or (gnus-methods-equal-p
  5666. nth4 (gnus-find-method-for-group from-newsgroup))
  5667. virtual
  5668. (equal nth4 (setq method (gnus-find-method-for-group
  5669. from-newsgroup)))
  5670. (and (equal (car nth4) (car method))
  5671. (equal (nth 1 nth4) (nth 1 method))))
  5672. gnus-use-cross-reference
  5673. (or (not (eq gnus-use-cross-reference t))
  5674. virtual
  5675. ;; Only do cross-references on subscribed
  5676. ;; groups, if that is what is wanted.
  5677. (<= (gnus-info-level info) gnus-level-subscribed))
  5678. (gnus-group-make-articles-read name idlist))))
  5679. xref-hashtb)))))
  5680. (defun gnus-compute-read-articles (group articles)
  5681. (let* ((entry (gnus-group-entry group))
  5682. (info (nth 2 entry))
  5683. (active (gnus-active group))
  5684. ninfo)
  5685. (when entry
  5686. ;; First peel off all invalid article numbers.
  5687. (when active
  5688. (let ((ids articles)
  5689. id first)
  5690. (while (setq id (pop ids))
  5691. (when (and first (> id (cdr active)))
  5692. ;; We'll end up in this situation in one particular
  5693. ;; obscure situation. If you re-scan a group and get
  5694. ;; a new article that is cross-posted to a different
  5695. ;; group that has not been re-scanned, you might get
  5696. ;; crossposted article that has a higher number than
  5697. ;; Gnus believes possible. So we re-activate this
  5698. ;; group as well. This might mean doing the
  5699. ;; crossposting thingy will *increase* the number
  5700. ;; of articles in some groups. Tsk, tsk.
  5701. (setq active (or (gnus-activate-group group) active)))
  5702. (when (or (> id (cdr active))
  5703. (< id (car active)))
  5704. (setq articles (delq id articles))))))
  5705. ;; If the read list is nil, we init it.
  5706. (if (and active
  5707. (null (gnus-info-read info))
  5708. (> (car active) 1))
  5709. (setq ninfo (cons 1 (1- (car active))))
  5710. (setq ninfo (gnus-info-read info)))
  5711. ;; Then we add the read articles to the range.
  5712. (gnus-add-to-range
  5713. ninfo (setq articles (sort articles '<))))))
  5714. (defun gnus-group-make-articles-read (group articles)
  5715. "Update the info of GROUP to say that ARTICLES are read."
  5716. (let* ((num 0)
  5717. (entry (gnus-group-entry group))
  5718. (info (nth 2 entry))
  5719. (active (gnus-active group))
  5720. (set-marks
  5721. (or gnus-propagate-marks
  5722. (gnus-method-option-p
  5723. (gnus-find-method-for-group group)
  5724. 'server-marks)))
  5725. range)
  5726. (if (not entry)
  5727. ;; Group that Gnus doesn't know exists, but still allow the
  5728. ;; backend to set marks.
  5729. (when set-marks
  5730. (gnus-request-set-mark
  5731. group (list (list (gnus-compress-sequence (sort articles #'<))
  5732. 'add '(read)))))
  5733. ;; Normal, subscribed groups.
  5734. (setq range (gnus-compute-read-articles group articles))
  5735. (with-current-buffer gnus-group-buffer
  5736. (gnus-undo-register
  5737. `(progn
  5738. (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
  5739. (gnus-info-set-read ',info ',(gnus-info-read info))
  5740. (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
  5741. (when ,set-marks
  5742. (gnus-request-set-mark
  5743. ,group (list (list ',range 'del '(read)))))
  5744. (gnus-group-update-group ,group t))))
  5745. ;; Add the read articles to the range.
  5746. (gnus-info-set-read info range)
  5747. (when set-marks
  5748. (gnus-request-set-mark group (list (list range 'add '(read)))))
  5749. ;; Then we have to re-compute how many unread
  5750. ;; articles there are in this group.
  5751. (when active
  5752. (cond
  5753. ((not range)
  5754. (setq num (- (1+ (cdr active)) (car active))))
  5755. ((not (listp (cdr range)))
  5756. (setq num (- (cdr active) (- (1+ (cdr range))
  5757. (car range)))))
  5758. (t
  5759. (while range
  5760. (if (numberp (car range))
  5761. (setq num (1+ num))
  5762. (setq num (+ num (- (1+ (cdar range)) (caar range)))))
  5763. (setq range (cdr range)))
  5764. (setq num (- (cdr active) num))))
  5765. ;; Update the number of unread articles.
  5766. (setcar entry num)
  5767. ;; Update the group buffer.
  5768. (unless (gnus-ephemeral-group-p group)
  5769. (gnus-group-update-group group t))))))
  5770. (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
  5771. (let ((cur nntp-server-buffer)
  5772. (dependencies
  5773. (or dependencies
  5774. (with-current-buffer gnus-summary-buffer
  5775. gnus-newsgroup-dependencies)))
  5776. headers id end ref number
  5777. (mail-parse-charset gnus-newsgroup-charset)
  5778. (mail-parse-ignored-charsets
  5779. (save-current-buffer (condition-case nil
  5780. (set-buffer gnus-summary-buffer)
  5781. (error))
  5782. gnus-newsgroup-ignored-charsets)))
  5783. (with-current-buffer nntp-server-buffer
  5784. ;; Translate all TAB characters into SPACE characters.
  5785. (subst-char-in-region (point-min) (point-max) ?\t ? t)
  5786. (subst-char-in-region (point-min) (point-max) ?\r ? t)
  5787. (ietf-drums-unfold-fws)
  5788. (gnus-run-hooks 'gnus-parse-headers-hook)
  5789. (let ((case-fold-search t)
  5790. in-reply-to header p lines chars)
  5791. (goto-char (point-min))
  5792. ;; Search to the beginning of the next header. Error messages
  5793. ;; do not begin with 2 or 3.
  5794. (while (re-search-forward "^[23][0-9]+ " nil t)
  5795. (setq id nil
  5796. ref nil)
  5797. ;; This implementation of this function, with nine
  5798. ;; search-forwards instead of the one re-search-forward and
  5799. ;; a case (which basically was the old function) is actually
  5800. ;; about twice as fast, even though it looks messier. You
  5801. ;; can't have everything, I guess. Speed and elegance
  5802. ;; doesn't always go hand in hand.
  5803. (setq
  5804. header
  5805. (vector
  5806. ;; Number.
  5807. (prog1
  5808. (setq number (read cur))
  5809. (end-of-line)
  5810. (setq p (point))
  5811. (narrow-to-region (point)
  5812. (or (and (search-forward "\n.\n" nil t)
  5813. (- (point) 2))
  5814. (point))))
  5815. ;; Subject.
  5816. (progn
  5817. (goto-char p)
  5818. (if (search-forward "\nsubject:" nil t)
  5819. (funcall gnus-decode-encoded-word-function
  5820. (nnheader-header-value))
  5821. "(none)"))
  5822. ;; From.
  5823. (progn
  5824. (goto-char p)
  5825. (if (search-forward "\nfrom:" nil t)
  5826. (funcall gnus-decode-encoded-address-function
  5827. (nnheader-header-value))
  5828. "(nobody)"))
  5829. ;; Date.
  5830. (progn
  5831. (goto-char p)
  5832. (if (search-forward "\ndate:" nil t)
  5833. (nnheader-header-value) ""))
  5834. ;; Message-ID.
  5835. (progn
  5836. (goto-char p)
  5837. (setq id (if (re-search-forward
  5838. "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
  5839. ;; We do it this way to make sure the Message-ID
  5840. ;; is (somewhat) syntactically valid.
  5841. (buffer-substring (match-beginning 1)
  5842. (match-end 1))
  5843. ;; If there was no message-id, we just fake one
  5844. ;; to make subsequent routines simpler.
  5845. (nnheader-generate-fake-message-id number))))
  5846. ;; References.
  5847. (progn
  5848. (goto-char p)
  5849. (if (search-forward "\nreferences:" nil t)
  5850. (progn
  5851. (setq end (point))
  5852. (prog1
  5853. (nnheader-header-value)
  5854. (setq ref
  5855. (buffer-substring
  5856. (progn
  5857. (end-of-line)
  5858. (search-backward ">" end t)
  5859. (1+ (point)))
  5860. (progn
  5861. (search-backward "<" end t)
  5862. (point))))))
  5863. ;; Get the references from the in-reply-to header if there
  5864. ;; were no references and the in-reply-to header looks
  5865. ;; promising.
  5866. (if (and (search-forward "\nin-reply-to:" nil t)
  5867. (setq in-reply-to (nnheader-header-value))
  5868. (string-match "<[^>]+>" in-reply-to))
  5869. (let (ref2)
  5870. (setq ref (substring in-reply-to (match-beginning 0)
  5871. (match-end 0)))
  5872. (while (string-match "<[^>]+>" in-reply-to (match-end 0))
  5873. (setq ref2 (substring in-reply-to (match-beginning 0)
  5874. (match-end 0)))
  5875. (when (> (length ref2) (length ref))
  5876. (setq ref ref2)))
  5877. ref)
  5878. (setq ref nil))))
  5879. ;; Chars.
  5880. (progn
  5881. (goto-char p)
  5882. (if (search-forward "\nchars: " nil t)
  5883. (if (numberp (setq chars (ignore-errors (read cur))))
  5884. chars -1)
  5885. -1))
  5886. ;; Lines.
  5887. (progn
  5888. (goto-char p)
  5889. (if (search-forward "\nlines: " nil t)
  5890. (if (numberp (setq lines (ignore-errors (read cur))))
  5891. lines -1)
  5892. -1))
  5893. ;; Xref.
  5894. (progn
  5895. (goto-char p)
  5896. (and (search-forward "\nxref:" nil t)
  5897. (nnheader-header-value)))
  5898. ;; Extra.
  5899. (when gnus-extra-headers
  5900. (let ((extra gnus-extra-headers)
  5901. out)
  5902. (while extra
  5903. (goto-char p)
  5904. (when (search-forward
  5905. (concat "\n" (symbol-name (car extra)) ":") nil t)
  5906. (push (cons (car extra) (nnheader-header-value))
  5907. out))
  5908. (pop extra))
  5909. out))))
  5910. (when (equal id ref)
  5911. (setq ref nil))
  5912. (when gnus-alter-header-function
  5913. (funcall gnus-alter-header-function header)
  5914. (setq id (mail-header-id header)
  5915. ref (gnus-parent-id (mail-header-references header))))
  5916. (when (setq header
  5917. (gnus-dependencies-add-header
  5918. header dependencies force-new))
  5919. (push header headers))
  5920. (goto-char (point-max))
  5921. (widen))
  5922. (nreverse headers)))))
  5923. ;; Goes through the xover lines and returns a list of vectors
  5924. (defun gnus-get-newsgroup-headers-xover (sequence &optional
  5925. force-new dependencies
  5926. group also-fetch-heads)
  5927. "Parse the news overview data in the server buffer.
  5928. Return a list of headers that match SEQUENCE (see
  5929. `nntp-retrieve-headers')."
  5930. ;; Get the Xref when the users reads the articles since most/some
  5931. ;; NNTP servers do not include Xrefs when using XOVER.
  5932. (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
  5933. (let ((mail-parse-charset gnus-newsgroup-charset)
  5934. (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
  5935. (cur nntp-server-buffer)
  5936. (dependencies (or dependencies gnus-newsgroup-dependencies))
  5937. (allp (cond
  5938. ((eq gnus-read-all-available-headers t)
  5939. t)
  5940. ((and (stringp gnus-read-all-available-headers)
  5941. group)
  5942. (string-match gnus-read-all-available-headers group))
  5943. (t
  5944. nil)))
  5945. number headers header)
  5946. (with-current-buffer nntp-server-buffer
  5947. (subst-char-in-region (point-min) (point-max) ?\r ? t)
  5948. ;; Allow the user to mangle the headers before parsing them.
  5949. (gnus-run-hooks 'gnus-parse-headers-hook)
  5950. (goto-char (point-min))
  5951. (gnus-parse-without-error
  5952. (while (and (or sequence allp)
  5953. (not (eobp)))
  5954. (setq number (read cur))
  5955. (when (not allp)
  5956. (while (and sequence
  5957. (< (car sequence) number))
  5958. (setq sequence (cdr sequence))))
  5959. (when (and (or allp
  5960. (and sequence
  5961. (eq number (car sequence))))
  5962. (progn
  5963. (setq sequence (cdr sequence))
  5964. (setq header (inline
  5965. (gnus-nov-parse-line
  5966. number dependencies force-new)))))
  5967. (push header headers))
  5968. (forward-line 1)))
  5969. ;; A common bug in inn is that if you have posted an article and
  5970. ;; then retrieves the active file, it will answer correctly --
  5971. ;; the new article is included. However, a NOV entry for the
  5972. ;; article may not have been generated yet, so this may fail.
  5973. ;; We work around this problem by retrieving the last few
  5974. ;; headers using HEAD.
  5975. (if (or (not also-fetch-heads)
  5976. (not sequence))
  5977. ;; We (probably) got all the headers.
  5978. (nreverse headers)
  5979. (let ((gnus-nov-is-evil t))
  5980. (nconc
  5981. (nreverse headers)
  5982. (when (eq (gnus-retrieve-headers sequence group) 'headers)
  5983. (gnus-get-newsgroup-headers))))))))
  5984. (defun gnus-article-get-xrefs ()
  5985. "Fill in the Xref value in `gnus-current-headers', if necessary.
  5986. This is meant to be called in `gnus-article-internal-prepare-hook'."
  5987. (let ((headers (with-current-buffer gnus-summary-buffer
  5988. gnus-current-headers)))
  5989. (or (not gnus-use-cross-reference)
  5990. (not headers)
  5991. (and (mail-header-xref headers)
  5992. (not (string= (mail-header-xref headers) "")))
  5993. (let ((case-fold-search t)
  5994. xref)
  5995. (save-restriction
  5996. (nnheader-narrow-to-headers)
  5997. (goto-char (point-min))
  5998. (when (or (and (not (eobp))
  5999. (eq (downcase (char-after)) ?x)
  6000. (looking-at "Xref:"))
  6001. (search-forward "\nXref:" nil t))
  6002. (goto-char (1+ (match-end 0)))
  6003. (setq xref (buffer-substring (point) (point-at-eol)))
  6004. (mail-header-set-xref headers xref)))))))
  6005. (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
  6006. "Find article ID and insert the summary line for that article.
  6007. OLD-HEADER can either be a header or a line number to insert
  6008. the subject line on.
  6009. If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
  6010. and OLD-HEADER will be used when the summary line is inserted,
  6011. too, instead of trying to fetch new headers."
  6012. (let* ((line (and (numberp old-header) old-header))
  6013. (old-header (and (vectorp old-header) old-header))
  6014. (header (cond ((and old-header use-old-header)
  6015. old-header)
  6016. ((and (numberp id)
  6017. (gnus-number-to-header id))
  6018. (gnus-number-to-header id))
  6019. (t
  6020. (gnus-read-header id))))
  6021. (number (and (numberp id) id))
  6022. d)
  6023. (when header
  6024. ;; Rebuild the thread that this article is part of and go to the
  6025. ;; article we have fetched.
  6026. (when (and (not gnus-show-threads)
  6027. old-header)
  6028. (when (and number
  6029. (setq d (gnus-data-find (mail-header-number old-header))))
  6030. (goto-char (gnus-data-pos d))
  6031. (gnus-data-remove
  6032. number
  6033. (- (point-at-bol)
  6034. (prog1
  6035. (1+ (point-at-eol))
  6036. (gnus-delete-line))))))
  6037. ;; Remove list identifiers from subject.
  6038. (let ((gnus-newsgroup-headers (list header)))
  6039. (gnus-summary-remove-list-identifiers))
  6040. (when old-header
  6041. (mail-header-set-number header (mail-header-number old-header)))
  6042. (setq gnus-newsgroup-sparse
  6043. (delq (setq number (mail-header-number header))
  6044. gnus-newsgroup-sparse))
  6045. (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
  6046. (push number gnus-newsgroup-limit)
  6047. (gnus-rebuild-thread (mail-header-id header) line)
  6048. (gnus-summary-goto-subject number nil t))
  6049. (when (and (numberp number)
  6050. (> number 0))
  6051. ;; We have to update the boundaries even if we can't fetch the
  6052. ;; article if ID is a number -- so that the next `P' or `N'
  6053. ;; command will fetch the previous (or next) article even
  6054. ;; if the one we tried to fetch this time has been canceled.
  6055. (when (> number gnus-newsgroup-end)
  6056. (setq gnus-newsgroup-end number))
  6057. (when (< number gnus-newsgroup-begin)
  6058. (setq gnus-newsgroup-begin number))
  6059. (setq gnus-newsgroup-unselected
  6060. (delq number gnus-newsgroup-unselected)))
  6061. ;; Report back a success?
  6062. (and header (mail-header-number header))))
  6063. ;;; Process/prefix in the summary buffer
  6064. (defun gnus-summary-work-articles (n)
  6065. "Return a list of articles to be worked upon.
  6066. The prefix argument, the list of process marked articles, and the
  6067. current article will be taken into consideration."
  6068. (with-current-buffer gnus-summary-buffer
  6069. (cond
  6070. (n
  6071. ;; A numerical prefix has been given.
  6072. (setq n (prefix-numeric-value n))
  6073. (let ((backward (< n 0))
  6074. (n (abs (prefix-numeric-value n)))
  6075. articles article)
  6076. (save-excursion
  6077. (while
  6078. (and (> n 0)
  6079. (push (setq article (gnus-summary-article-number))
  6080. articles)
  6081. (if backward
  6082. (gnus-summary-find-prev nil article)
  6083. (gnus-summary-find-next nil article)))
  6084. (decf n)))
  6085. (nreverse articles)))
  6086. ((and (gnus-region-active-p) (mark))
  6087. (message "region active")
  6088. ;; Work on the region between point and mark.
  6089. (let ((max (max (point) (mark)))
  6090. articles article)
  6091. (save-excursion
  6092. (goto-char (min (point) (mark)))
  6093. (while
  6094. (and
  6095. (push (setq article (gnus-summary-article-number)) articles)
  6096. (gnus-summary-find-next nil article)
  6097. (< (point) max)))
  6098. (nreverse articles))))
  6099. (gnus-newsgroup-processable
  6100. ;; There are process-marked articles present.
  6101. ;; Save current state.
  6102. (gnus-summary-save-process-mark)
  6103. ;; Return the list.
  6104. (reverse gnus-newsgroup-processable))
  6105. (t
  6106. ;; Just return the current article.
  6107. (list (gnus-summary-article-number))))))
  6108. (defmacro gnus-summary-iterate (arg &rest forms)
  6109. "Iterate over the process/prefixed articles and do FORMS.
  6110. ARG is the interactive prefix given to the command. FORMS will be
  6111. executed with point over the summary line of the articles."
  6112. (let ((articles (make-symbol "gnus-summary-iterate-articles")))
  6113. `(let ((,articles (gnus-summary-work-articles ,arg)))
  6114. (while ,articles
  6115. (gnus-summary-goto-subject (car ,articles))
  6116. ,@forms
  6117. (pop ,articles)))))
  6118. (put 'gnus-summary-iterate 'lisp-indent-function 1)
  6119. (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
  6120. (defun gnus-summary-save-process-mark ()
  6121. "Push the current set of process marked articles on the stack."
  6122. (interactive)
  6123. (push (copy-sequence gnus-newsgroup-processable)
  6124. gnus-newsgroup-process-stack))
  6125. (defun gnus-summary-kill-process-mark ()
  6126. "Push the current set of process marked articles on the stack and unmark."
  6127. (interactive)
  6128. (gnus-summary-save-process-mark)
  6129. (gnus-summary-unmark-all-processable))
  6130. (defun gnus-summary-yank-process-mark ()
  6131. "Pop the last process mark state off the stack and restore it."
  6132. (interactive)
  6133. (unless gnus-newsgroup-process-stack
  6134. (error "Empty mark stack"))
  6135. (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
  6136. (defun gnus-summary-process-mark-set (set)
  6137. "Make SET into the current process marked articles."
  6138. (gnus-summary-unmark-all-processable)
  6139. (mapc 'gnus-summary-set-process-mark set))
  6140. ;;; Searching and stuff
  6141. (defun gnus-summary-search-group (&optional backward use-level)
  6142. "Search for next unread newsgroup.
  6143. If optional argument BACKWARD is non-nil, search backward instead."
  6144. (with-current-buffer gnus-group-buffer
  6145. (when (gnus-group-search-forward
  6146. backward nil (if use-level (gnus-group-group-level) nil))
  6147. (gnus-group-group-name))))
  6148. (defun gnus-summary-best-group (&optional exclude-group)
  6149. "Find the name of the best unread group.
  6150. If EXCLUDE-GROUP, do not go to this group."
  6151. (with-current-buffer gnus-group-buffer
  6152. (save-excursion
  6153. (gnus-group-best-unread-group exclude-group))))
  6154. (defun gnus-summary-find-next (&optional unread article backward)
  6155. (if backward
  6156. (gnus-summary-find-prev unread article)
  6157. (let* ((dummy (gnus-summary-article-intangible-p))
  6158. (article (or article (gnus-summary-article-number)))
  6159. (data (gnus-data-find-list article))
  6160. result)
  6161. (when (and (not dummy)
  6162. (or (not gnus-summary-check-current)
  6163. (not unread)
  6164. (not (gnus-data-unread-p (car data)))))
  6165. (setq data (cdr data)))
  6166. (when (setq result
  6167. (if unread
  6168. (progn
  6169. (while data
  6170. (unless (memq (gnus-data-number (car data))
  6171. (cond
  6172. ((eq gnus-auto-goto-ignores
  6173. 'always-undownloaded)
  6174. gnus-newsgroup-undownloaded)
  6175. (gnus-plugged
  6176. nil)
  6177. ((eq gnus-auto-goto-ignores
  6178. 'unfetched)
  6179. gnus-newsgroup-unfetched)
  6180. ((eq gnus-auto-goto-ignores
  6181. 'undownloaded)
  6182. gnus-newsgroup-undownloaded)))
  6183. (when (gnus-data-unread-p (car data))
  6184. (setq result (car data)
  6185. data nil)))
  6186. (setq data (cdr data)))
  6187. result)
  6188. (car data)))
  6189. (goto-char (gnus-data-pos result))
  6190. (gnus-data-number result)))))
  6191. (defun gnus-summary-find-prev (&optional unread article)
  6192. (let* ((eobp (eobp))
  6193. (article (or article (gnus-summary-article-number)))
  6194. (data (gnus-data-find-list article (gnus-data-list 'rev)))
  6195. result)
  6196. (when (and (not eobp)
  6197. (or (not gnus-summary-check-current)
  6198. (not unread)
  6199. (not (gnus-data-unread-p (car data)))))
  6200. (setq data (cdr data)))
  6201. (when (setq result
  6202. (if unread
  6203. (progn
  6204. (while data
  6205. (unless (memq (gnus-data-number (car data))
  6206. (cond
  6207. ((eq gnus-auto-goto-ignores
  6208. 'always-undownloaded)
  6209. gnus-newsgroup-undownloaded)
  6210. (gnus-plugged
  6211. nil)
  6212. ((eq gnus-auto-goto-ignores
  6213. 'unfetched)
  6214. gnus-newsgroup-unfetched)
  6215. ((eq gnus-auto-goto-ignores
  6216. 'undownloaded)
  6217. gnus-newsgroup-undownloaded)))
  6218. (when (gnus-data-unread-p (car data))
  6219. (setq result (car data)
  6220. data nil)))
  6221. (setq data (cdr data)))
  6222. result)
  6223. (car data)))
  6224. (goto-char (gnus-data-pos result))
  6225. (gnus-data-number result))))
  6226. (defun gnus-summary-find-subject (subject &optional unread backward article)
  6227. (let* ((simp-subject (gnus-simplify-subject-fully subject))
  6228. (article (or article (gnus-summary-article-number)))
  6229. (articles (gnus-data-list backward))
  6230. (arts (gnus-data-find-list article articles))
  6231. result)
  6232. (when (or (not gnus-summary-check-current)
  6233. (not unread)
  6234. (not (gnus-data-unread-p (car arts))))
  6235. (setq arts (cdr arts)))
  6236. (while arts
  6237. (and (or (not unread)
  6238. (gnus-data-unread-p (car arts)))
  6239. (vectorp (gnus-data-header (car arts)))
  6240. (gnus-subject-equal
  6241. simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
  6242. (setq result (car arts)
  6243. arts nil))
  6244. (setq arts (cdr arts)))
  6245. (and result
  6246. (goto-char (gnus-data-pos result))
  6247. (gnus-data-number result))))
  6248. (defun gnus-summary-search-forward (&optional unread subject backward)
  6249. "Search forward for an article.
  6250. If UNREAD, look for unread articles. If SUBJECT, look for
  6251. articles with that subject. If BACKWARD, search backward instead."
  6252. (cond (subject (gnus-summary-find-subject subject unread backward))
  6253. (backward (gnus-summary-find-prev unread))
  6254. (t (gnus-summary-find-next unread))))
  6255. (defun gnus-recenter (&optional n)
  6256. "Center point in window and redisplay frame.
  6257. Also do horizontal recentering."
  6258. (interactive "P")
  6259. (when (and gnus-auto-center-summary
  6260. (not (eq gnus-auto-center-summary 'vertical)))
  6261. (gnus-horizontal-recenter))
  6262. (if (fboundp 'recenter-top-bottom)
  6263. (recenter-top-bottom n)
  6264. (recenter n)))
  6265. (put 'gnus-recenter 'isearch-scroll t)
  6266. (defun gnus-forward-line-ignore-invisible (n)
  6267. "Move N lines forward (backward if N is negative).
  6268. Like forward-line, but skip over (and don't count) invisible lines."
  6269. (let (done)
  6270. (while (and (> n 0) (not done))
  6271. ;; If the following character is currently invisible,
  6272. ;; skip all characters with that same `invisible' property value.
  6273. (while (gnus-invisible-p (point))
  6274. (goto-char (gnus-next-char-property-change (point))))
  6275. (forward-line 1)
  6276. (if (eobp)
  6277. (setq done t)
  6278. (setq n (1- n))))
  6279. (while (and (< n 0) (not done))
  6280. (forward-line -1)
  6281. (if (bobp) (setq done t)
  6282. (setq n (1+ n))
  6283. (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
  6284. (goto-char (gnus-previous-char-property-change (point))))))))
  6285. (defun gnus-summary-recenter ()
  6286. "Center point in the summary window.
  6287. If `gnus-auto-center-summary' is nil, or the article buffer isn't
  6288. displayed, no centering will be performed."
  6289. ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
  6290. ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
  6291. (interactive)
  6292. ;; The user has to want it.
  6293. (when gnus-auto-center-summary
  6294. (let* ((top (cond ((< (window-height) 4) 0)
  6295. ((< (window-height) 7) 1)
  6296. (t (if (numberp gnus-auto-center-summary)
  6297. gnus-auto-center-summary
  6298. (/ (1- (window-height)) 2)))))
  6299. (height (1- (window-height)))
  6300. (bottom (save-excursion
  6301. (goto-char (point-max))
  6302. (gnus-forward-line-ignore-invisible (- height))
  6303. (point)))
  6304. (window (get-buffer-window (current-buffer))))
  6305. (when (get-buffer-window gnus-article-buffer)
  6306. ;; Only do recentering when the article buffer is displayed,
  6307. ;; Set the window start to either `bottom', which is the biggest
  6308. ;; possible valid number, or the second line from the top,
  6309. ;; whichever is the least.
  6310. (let ((top-pos (save-excursion
  6311. (gnus-forward-line-ignore-invisible (- top))
  6312. (point))))
  6313. (if (> bottom top-pos)
  6314. ;; Keep the second line from the top visible
  6315. (set-window-start window top-pos)
  6316. ;; Try to keep the bottom line visible; if it's partially
  6317. ;; obscured, either scroll one more line to make it fully
  6318. ;; visible, or revert to using TOP-POS.
  6319. (save-excursion
  6320. (goto-char (point-max))
  6321. (gnus-forward-line-ignore-invisible -1)
  6322. (let ((last-line-start (point)))
  6323. (goto-char bottom)
  6324. (set-window-start window (point) t)
  6325. (when (not (pos-visible-in-window-p last-line-start window))
  6326. (gnus-forward-line-ignore-invisible 1)
  6327. (set-window-start window (min (point) top-pos) t)))))))
  6328. ;; Do horizontal recentering while we're at it.
  6329. (when (and (get-buffer-window (current-buffer) t)
  6330. (not (eq gnus-auto-center-summary 'vertical)))
  6331. (let ((selected (selected-window)))
  6332. (select-window (get-buffer-window (current-buffer) t))
  6333. (gnus-summary-position-point)
  6334. (gnus-horizontal-recenter)
  6335. (select-window selected))))))
  6336. (defun gnus-summary-jump-to-group (newsgroup)
  6337. "Move point to NEWSGROUP in group mode buffer."
  6338. ;; Keep update point of group mode buffer if visible.
  6339. (if (eq (current-buffer) (get-buffer gnus-group-buffer))
  6340. (save-window-excursion
  6341. ;; Take care of tree window mode.
  6342. (when (get-buffer-window gnus-group-buffer)
  6343. (pop-to-buffer gnus-group-buffer))
  6344. (gnus-group-jump-to-group newsgroup))
  6345. (save-excursion
  6346. ;; Take care of tree window mode.
  6347. (if (get-buffer-window gnus-group-buffer 0)
  6348. (pop-to-buffer gnus-group-buffer)
  6349. (set-buffer gnus-group-buffer))
  6350. (gnus-group-jump-to-group newsgroup))))
  6351. ;; This function returns a list of article numbers based on the
  6352. ;; difference between the ranges of read articles in this group and
  6353. ;; the range of active articles.
  6354. (defun gnus-list-of-unread-articles (group)
  6355. (let* ((read (gnus-info-read (gnus-get-info group)))
  6356. (active (or (gnus-active group) (gnus-activate-group group)))
  6357. (last (or (cdr active)
  6358. (error "Group %s couldn't be activated " group)))
  6359. (bottom (if gnus-newsgroup-maximum-articles
  6360. (max (car active)
  6361. (- last gnus-newsgroup-maximum-articles -1))
  6362. (car active)))
  6363. first nlast unread)
  6364. ;; If none are read, then all are unread.
  6365. (if (not read)
  6366. (setq first bottom)
  6367. ;; If the range of read articles is a single range, then the
  6368. ;; first unread article is the article after the last read
  6369. ;; article. Sounds logical, doesn't it?
  6370. (if (and (not (listp (cdr read)))
  6371. (or (< (car read) bottom)
  6372. (progn (setq read (list read))
  6373. nil)))
  6374. (setq first (max bottom (1+ (cdr read))))
  6375. ;; `read' is a list of ranges.
  6376. (when (/= (setq nlast (or (and (numberp (car read)) (car read))
  6377. (caar read)))
  6378. 1)
  6379. (setq first bottom))
  6380. (while read
  6381. (when first
  6382. (while (< first nlast)
  6383. (setq unread (cons first unread)
  6384. first (1+ first))))
  6385. (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
  6386. (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
  6387. (setq read (cdr read)))))
  6388. ;; And add the last unread articles.
  6389. (while (<= first last)
  6390. (setq unread (cons first unread)
  6391. first (1+ first)))
  6392. ;; Return the list of unread articles.
  6393. (delq 0 (nreverse unread))))
  6394. (defun gnus-list-of-read-articles (group)
  6395. "Return a list of unread, unticked and non-dormant articles."
  6396. (let* ((info (gnus-get-info group))
  6397. (marked (gnus-info-marks info))
  6398. (active (gnus-active group)))
  6399. (and info active
  6400. (gnus-list-range-difference
  6401. (gnus-list-range-difference
  6402. (gnus-sorted-complement
  6403. (gnus-uncompress-range
  6404. (if gnus-newsgroup-maximum-articles
  6405. (cons (max (car active)
  6406. (- (cdr active)
  6407. gnus-newsgroup-maximum-articles
  6408. -1))
  6409. (cdr active))
  6410. active))
  6411. (gnus-list-of-unread-articles group))
  6412. (cdr (assq 'dormant marked)))
  6413. (cdr (assq 'tick marked))))))
  6414. ;; This function returns a sequence of article numbers based on the
  6415. ;; difference between the ranges of read articles in this group and
  6416. ;; the range of active articles.
  6417. (defun gnus-sequence-of-unread-articles (group)
  6418. (let* ((read (gnus-info-read (gnus-get-info group)))
  6419. (active (or (gnus-active group) (gnus-activate-group group)))
  6420. (last (cdr active))
  6421. (bottom (if gnus-newsgroup-maximum-articles
  6422. (max (car active)
  6423. (- last gnus-newsgroup-maximum-articles -1))
  6424. (car active)))
  6425. first nlast unread)
  6426. ;; If none are read, then all are unread.
  6427. (if (not read)
  6428. (setq first bottom)
  6429. ;; If the range of read articles is a single range, then the
  6430. ;; first unread article is the article after the last read
  6431. ;; article. Sounds logical, doesn't it?
  6432. (if (and (not (listp (cdr read)))
  6433. (or (< (car read) bottom)
  6434. (progn (setq read (list read))
  6435. nil)))
  6436. (setq first (max bottom (1+ (cdr read))))
  6437. ;; `read' is a list of ranges.
  6438. (when (/= (setq nlast (or (and (numberp (car read)) (car read))
  6439. (caar read)))
  6440. 1)
  6441. (setq first bottom))
  6442. (while read
  6443. (when first
  6444. (push (cons first nlast) unread))
  6445. (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
  6446. (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
  6447. (setq read (cdr read)))))
  6448. ;; And add the last unread articles.
  6449. (cond ((not (and first last))
  6450. nil)
  6451. ((< first last)
  6452. (push (cons first last) unread))
  6453. ((= first last)
  6454. (push first unread)))
  6455. ;; Return the sequence of unread articles.
  6456. (delq 0 (nreverse unread))))
  6457. ;; Various summary commands
  6458. (defun gnus-summary-select-article-buffer ()
  6459. "Reconfigure windows to show the article buffer.
  6460. If `gnus-widen-article-window' is set, show only the article
  6461. buffer."
  6462. (interactive)
  6463. (if (not (gnus-buffer-live-p gnus-article-buffer))
  6464. (error "There is no article buffer for this summary buffer")
  6465. (unless (get-buffer-window gnus-article-buffer)
  6466. (gnus-summary-show-article))
  6467. (gnus-configure-windows
  6468. (if gnus-widen-article-window
  6469. 'only-article
  6470. 'article)
  6471. t)
  6472. (select-window (get-buffer-window gnus-article-buffer))))
  6473. (defun gnus-summary-universal-argument (arg)
  6474. "Perform any operation on all articles that are process/prefixed."
  6475. (interactive "P")
  6476. (let ((articles (gnus-summary-work-articles arg))
  6477. func article)
  6478. (if (eq
  6479. (setq
  6480. func
  6481. (key-binding
  6482. (read-key-sequence
  6483. (substitute-command-keys
  6484. "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
  6485. 'undefined)
  6486. (gnus-error 1 "Undefined key")
  6487. (save-excursion
  6488. (while articles
  6489. (gnus-summary-goto-subject (setq article (pop articles)))
  6490. (let (gnus-newsgroup-processable)
  6491. (command-execute func))
  6492. (gnus-summary-remove-process-mark article)))))
  6493. (gnus-summary-position-point))
  6494. (defun gnus-summary-toggle-truncation (&optional arg)
  6495. "Toggle truncation of summary lines.
  6496. With ARG, turn line truncation on if ARG is positive."
  6497. (interactive "P")
  6498. (setq truncate-lines
  6499. (if (null arg) (not truncate-lines)
  6500. (> (prefix-numeric-value arg) 0)))
  6501. (redraw-display))
  6502. (defun gnus-summary-find-for-reselect ()
  6503. "Return the number of an article to stay on across a reselect.
  6504. The current article is considered, then following articles, then previous
  6505. articles. An article is sought which is not canceled and isn't a temporary
  6506. insertion from another group. If there's no such then return a dummy 0."
  6507. (let (found)
  6508. (dolist (rev '(nil t))
  6509. (unless found ; don't demand the reverse list if we don't need it
  6510. (let ((data (gnus-data-find-list
  6511. (gnus-summary-article-number) (gnus-data-list rev))))
  6512. (while (and data (not found))
  6513. (if (and (< 0 (gnus-data-number (car data)))
  6514. (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
  6515. (setq found (gnus-data-number (car data))))
  6516. (setq data (cdr data))))))
  6517. (or found 0)))
  6518. (defun gnus-summary-reselect-current-group (&optional all rescan)
  6519. "Exit and then reselect the current newsgroup.
  6520. The prefix argument ALL means to select all articles."
  6521. (interactive "P")
  6522. (when (gnus-ephemeral-group-p gnus-newsgroup-name)
  6523. (error "Ephemeral groups can't be reselected"))
  6524. (let ((current-subject (gnus-summary-find-for-reselect))
  6525. (group gnus-newsgroup-name))
  6526. (setq gnus-newsgroup-begin nil)
  6527. (gnus-summary-exit nil 'leave-hidden)
  6528. ;; We have to adjust the point of group mode buffer because
  6529. ;; point was moved to the next unread newsgroup by exiting.
  6530. (gnus-summary-jump-to-group group)
  6531. (when rescan
  6532. (save-excursion
  6533. (gnus-group-get-new-news-this-group 1)))
  6534. (gnus-group-read-group all t)
  6535. (gnus-summary-goto-subject current-subject nil t)))
  6536. (defun gnus-summary-rescan-group (&optional all)
  6537. "Exit the newsgroup, ask for new articles, and select the newsgroup."
  6538. (interactive "P")
  6539. (let ((config gnus-current-window-configuration))
  6540. (gnus-summary-reselect-current-group all t)
  6541. (gnus-configure-windows config)
  6542. (when (eq config 'article)
  6543. (gnus-summary-select-article))))
  6544. (defun gnus-summary-update-info (&optional non-destructive)
  6545. (save-excursion
  6546. (let ((group gnus-newsgroup-name))
  6547. (when group
  6548. (when gnus-newsgroup-kill-headers
  6549. (setq gnus-newsgroup-killed
  6550. (gnus-compress-sequence
  6551. (gnus-sorted-union
  6552. (gnus-list-range-intersection
  6553. gnus-newsgroup-unselected gnus-newsgroup-killed)
  6554. gnus-newsgroup-unreads)
  6555. t)))
  6556. (unless (listp (cdr gnus-newsgroup-killed))
  6557. (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
  6558. (let ((headers gnus-newsgroup-headers)
  6559. (ephemeral-p (gnus-ephemeral-group-p group))
  6560. info)
  6561. (unless ephemeral-p
  6562. (setq info (copy-sequence (gnus-get-info group))
  6563. info (delq (gnus-info-params info) info)))
  6564. ;; Set the new ranges of read articles.
  6565. (with-current-buffer gnus-group-buffer
  6566. (gnus-undo-force-boundary))
  6567. (gnus-update-read-articles
  6568. group (gnus-sorted-union
  6569. gnus-newsgroup-unreads gnus-newsgroup-unselected))
  6570. ;; Set the current article marks.
  6571. (let ((gnus-newsgroup-scored
  6572. (if (and (not gnus-save-score)
  6573. (not non-destructive))
  6574. nil
  6575. gnus-newsgroup-scored)))
  6576. (save-excursion
  6577. (gnus-update-marks)))
  6578. ;; Do the cross-ref thing.
  6579. (when gnus-use-cross-reference
  6580. (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
  6581. ;; Do not switch windows but change the buffer to work.
  6582. (set-buffer gnus-group-buffer)
  6583. (unless ephemeral-p
  6584. (gnus-group-update-group
  6585. group nil
  6586. (equal info
  6587. (setq info (copy-sequence (gnus-get-info group))
  6588. info (delq (gnus-info-params info) info))))))))))
  6589. (defun gnus-summary-save-newsrc (&optional force)
  6590. "Save the current number of read/marked articles in the dribble buffer.
  6591. The dribble buffer will then be saved.
  6592. If FORCE (the prefix), also save the .newsrc file(s)."
  6593. (interactive "P")
  6594. (gnus-summary-update-info t)
  6595. (if force
  6596. (gnus-save-newsrc-file)
  6597. (gnus-dribble-save)))
  6598. (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
  6599. (defun gnus-summary-exit (&optional temporary leave-hidden)
  6600. "Exit reading current newsgroup, and then return to group selection mode.
  6601. `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
  6602. (interactive)
  6603. (gnus-set-global-variables)
  6604. (when (gnus-buffer-live-p gnus-article-buffer)
  6605. (with-current-buffer gnus-article-buffer
  6606. (mm-destroy-parts gnus-article-mime-handles)
  6607. ;; Set it to nil for safety reason.
  6608. (setq gnus-article-mime-handle-alist nil)
  6609. (setq gnus-article-mime-handles nil)))
  6610. (gnus-kill-save-kill-buffer)
  6611. (gnus-async-halt-prefetch)
  6612. (let* ((group gnus-newsgroup-name)
  6613. (quit-config (gnus-group-quit-config gnus-newsgroup-name))
  6614. (gnus-group-is-exiting-p t)
  6615. (article-buffer gnus-article-buffer)
  6616. (original-article-buffer gnus-original-article-buffer)
  6617. (mode major-mode)
  6618. (group-point nil)
  6619. (buf (current-buffer))
  6620. ;; `gnus-single-article-buffer' is nil buffer-locally in
  6621. ;; ephemeral group of which summary buffer will be killed,
  6622. ;; but the global value may be non-nil.
  6623. (single-article-buffer gnus-single-article-buffer))
  6624. (unless quit-config
  6625. ;; Do adaptive scoring, and possibly save score files.
  6626. (when gnus-newsgroup-adaptive
  6627. (gnus-score-adaptive))
  6628. (when gnus-use-scoring
  6629. (gnus-score-save)))
  6630. (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
  6631. (when gnus-use-cache
  6632. (gnus-cache-possibly-remove-articles)
  6633. (gnus-cache-save-buffers))
  6634. (gnus-async-prefetch-remove-group group)
  6635. (when gnus-suppress-duplicates
  6636. (gnus-dup-enter-articles))
  6637. (when gnus-use-trees
  6638. (gnus-tree-close group))
  6639. (when gnus-use-cache
  6640. (gnus-cache-write-active))
  6641. ;; Remove entries for this group.
  6642. (nnmail-purge-split-history (gnus-group-real-name group))
  6643. ;; Make all changes in this group permanent.
  6644. (unless quit-config
  6645. (gnus-run-hooks 'gnus-exit-group-hook)
  6646. (gnus-summary-update-info))
  6647. (gnus-close-group group)
  6648. ;; Make sure where we were, and go to next newsgroup.
  6649. (set-buffer gnus-group-buffer)
  6650. (unless quit-config
  6651. (gnus-group-jump-to-group group))
  6652. (gnus-run-hooks 'gnus-summary-exit-hook)
  6653. (unless (or quit-config
  6654. (not gnus-summary-next-group-on-exit)
  6655. ;; If this group has disappeared from the summary
  6656. ;; buffer, don't skip forwards.
  6657. (not (string= group (gnus-group-group-name))))
  6658. (gnus-group-next-unread-group 1))
  6659. (setq group-point (point))
  6660. (if temporary
  6661. nil ;Nothing to do.
  6662. (set-buffer buf)
  6663. (if (not gnus-kill-summary-on-exit)
  6664. (progn
  6665. (gnus-deaden-summary)
  6666. (setq mode nil))
  6667. (when (get-buffer gnus-article-buffer)
  6668. (bury-buffer gnus-article-buffer))
  6669. ;; Return to group mode buffer.
  6670. (when (eq mode 'gnus-summary-mode)
  6671. (gnus-kill-buffer buf)))
  6672. (setq gnus-current-select-method gnus-select-method)
  6673. (set-buffer gnus-group-buffer)
  6674. (if quit-config
  6675. (gnus-handle-ephemeral-exit quit-config)
  6676. (goto-char group-point)
  6677. ;; If gnus-group-buffer is already displayed, make sure we also move
  6678. ;; the cursor in the window that displays it.
  6679. (let ((win (get-buffer-window (current-buffer) 0)))
  6680. (if win (set-window-point win (point))))
  6681. (unless leave-hidden
  6682. (gnus-configure-windows 'group 'force)))
  6683. ;; If we have several article buffers, we kill them at exit.
  6684. (unless single-article-buffer
  6685. (when (gnus-buffer-live-p article-buffer)
  6686. (with-current-buffer article-buffer
  6687. ;; Don't kill sticky article buffers
  6688. (unless (eq major-mode 'gnus-sticky-article-mode)
  6689. (gnus-kill-buffer article-buffer)
  6690. (setq gnus-article-current nil))))
  6691. (gnus-kill-buffer original-article-buffer))
  6692. ;; Clear the current group name.
  6693. (unless quit-config
  6694. (setq gnus-newsgroup-name nil)))))
  6695. (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
  6696. (defun gnus-summary-exit-no-update (&optional no-questions)
  6697. "Quit reading current newsgroup without updating read article info."
  6698. (interactive)
  6699. (let* ((group gnus-newsgroup-name)
  6700. (gnus-group-is-exiting-p t)
  6701. (gnus-group-is-exiting-without-update-p t)
  6702. (quit-config (gnus-group-quit-config group)))
  6703. (when (or no-questions
  6704. gnus-expert-user
  6705. (gnus-y-or-n-p "Discard changes to this group and exit? "))
  6706. (gnus-async-halt-prefetch)
  6707. (run-hooks 'gnus-summary-prepare-exit-hook)
  6708. (when (gnus-buffer-live-p gnus-article-buffer)
  6709. (with-current-buffer gnus-article-buffer
  6710. (gnus-article-stop-animations)
  6711. (gnus-stop-downloads)
  6712. (mm-destroy-parts gnus-article-mime-handles)
  6713. ;; Set it to nil for safety reason.
  6714. (setq gnus-article-mime-handle-alist nil)
  6715. (setq gnus-article-mime-handles nil)))
  6716. ;; If we have several article buffers, we kill them at exit.
  6717. (unless gnus-single-article-buffer
  6718. (gnus-kill-buffer gnus-article-buffer)
  6719. (gnus-kill-buffer gnus-original-article-buffer)
  6720. (setq gnus-article-current nil))
  6721. ;; Return to the group buffer.
  6722. (if (not gnus-kill-summary-on-exit)
  6723. (progn
  6724. (gnus-deaden-summary)
  6725. (gnus-configure-windows 'group 'force))
  6726. (gnus-configure-windows 'group 'force)
  6727. (gnus-close-group group)
  6728. (gnus-kill-buffer gnus-summary-buffer))
  6729. (unless gnus-single-article-buffer
  6730. (setq gnus-article-current nil))
  6731. (when gnus-use-trees
  6732. (gnus-tree-close group))
  6733. (gnus-async-prefetch-remove-group group)
  6734. (when (get-buffer gnus-article-buffer)
  6735. (bury-buffer gnus-article-buffer))
  6736. ;; Clear the current group name.
  6737. (setq gnus-newsgroup-name nil)
  6738. (unless (gnus-ephemeral-group-p group)
  6739. (gnus-group-update-group group nil t))
  6740. (when (equal (gnus-group-group-name) group)
  6741. (gnus-group-next-unread-group 1))
  6742. (when quit-config
  6743. (gnus-handle-ephemeral-exit quit-config)))))
  6744. (defun gnus-handle-ephemeral-exit (quit-config)
  6745. "Handle movement when leaving an ephemeral group.
  6746. The state which existed when entering the ephemeral is reset."
  6747. (if (not (buffer-live-p (car quit-config)))
  6748. (gnus-configure-windows 'group 'force)
  6749. (set-buffer (car quit-config))
  6750. (unless (eq (cdr quit-config) 'group)
  6751. (setq gnus-current-select-method
  6752. (gnus-find-method-for-group gnus-newsgroup-name)))
  6753. (cond ((eq major-mode 'gnus-summary-mode)
  6754. (gnus-set-global-variables))
  6755. ((eq major-mode 'gnus-article-mode)
  6756. (save-current-buffer
  6757. ;; The `gnus-summary-buffer' variable may point
  6758. ;; to the old summary buffer when using a single
  6759. ;; article buffer.
  6760. (unless (gnus-buffer-live-p gnus-summary-buffer)
  6761. (set-buffer gnus-group-buffer))
  6762. (set-buffer gnus-summary-buffer)
  6763. (gnus-set-global-variables))))
  6764. (if (or (eq (cdr quit-config) 'article)
  6765. (eq (cdr quit-config) 'pick))
  6766. (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
  6767. (gnus-configure-windows 'pick 'force)
  6768. (gnus-configure-windows (cdr quit-config) 'force))
  6769. (gnus-configure-windows (cdr quit-config) 'force))
  6770. (when (eq major-mode 'gnus-summary-mode)
  6771. (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
  6772. next-unread-noselect))
  6773. (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
  6774. 'next-noselect)
  6775. (gnus-summary-next-subject 1 nil t))
  6776. ((eq gnus-auto-select-on-ephemeral-exit
  6777. 'next-unread-noselect)
  6778. (gnus-summary-next-subject 1 t t))))
  6779. ;; Hide the article buffer which displays the article different
  6780. ;; from the one that the cursor points to in the summary buffer.
  6781. (gnus-configure-windows 'summary 'force))
  6782. (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
  6783. (gnus-summary-next-subject 1))
  6784. ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
  6785. (gnus-summary-next-subject 1 t))))
  6786. (gnus-summary-recenter)
  6787. (gnus-summary-position-point))))
  6788. ;;; Dead summaries.
  6789. (defvar gnus-dead-summary-mode-map
  6790. (let ((map (make-keymap)))
  6791. (suppress-keymap map)
  6792. (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
  6793. (dolist (key '("\C-d" "\r" "\177" [delete]))
  6794. (define-key map key 'gnus-summary-wake-up-the-dead))
  6795. (dolist (key '("q" "Q"))
  6796. (define-key map key 'bury-buffer))
  6797. map))
  6798. (define-minor-mode gnus-dead-summary-mode
  6799. "Minor mode for Gnus summary buffers."
  6800. :lighter " Dead" :keymap gnus-dead-summary-mode-map
  6801. (unless (derived-mode-p 'gnus-summary-mode)
  6802. (setq gnus-dead-summary-mode nil)))
  6803. (defun gnus-deaden-summary ()
  6804. "Make the current summary buffer into a dead summary buffer."
  6805. ;; Kill any previous dead summary buffer.
  6806. (when (and gnus-dead-summary
  6807. (buffer-name gnus-dead-summary))
  6808. (with-current-buffer gnus-dead-summary
  6809. (when gnus-dead-summary-mode
  6810. (kill-buffer (current-buffer)))))
  6811. ;; Make this the current dead summary.
  6812. (setq gnus-dead-summary (current-buffer))
  6813. (gnus-dead-summary-mode 1)
  6814. (let ((name (buffer-name)))
  6815. (when (string-match "Summary" name)
  6816. (rename-buffer
  6817. (concat (substring name 0 (match-beginning 0)) "Dead "
  6818. (substring name (match-beginning 0)))
  6819. t)
  6820. (bury-buffer))))
  6821. (defun gnus-kill-or-deaden-summary (buffer)
  6822. "Kill or deaden the summary BUFFER."
  6823. (save-excursion
  6824. (when (and (buffer-name buffer)
  6825. (not gnus-single-article-buffer))
  6826. (with-current-buffer buffer
  6827. (gnus-kill-buffer gnus-article-buffer)
  6828. (gnus-kill-buffer gnus-original-article-buffer)))
  6829. (cond
  6830. ;; Kill the buffer.
  6831. (gnus-kill-summary-on-exit
  6832. (when (and gnus-use-trees
  6833. (gnus-buffer-exists-p buffer))
  6834. (with-current-buffer buffer
  6835. (gnus-tree-close gnus-newsgroup-name)))
  6836. (gnus-kill-buffer buffer))
  6837. ;; Deaden the buffer.
  6838. ((gnus-buffer-exists-p buffer)
  6839. (with-current-buffer buffer
  6840. (gnus-deaden-summary))))))
  6841. (defun gnus-summary-wake-up-the-dead (&rest args)
  6842. "Wake up the dead summary buffer."
  6843. (interactive)
  6844. (gnus-dead-summary-mode -1)
  6845. (let ((name (buffer-name)))
  6846. (when (string-match "Dead " name)
  6847. (rename-buffer
  6848. (concat (substring name 0 (match-beginning 0))
  6849. (substring name (match-end 0)))
  6850. t)))
  6851. (gnus-message 3 "This dead summary is now alive again"))
  6852. ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
  6853. (defun gnus-summary-describe-group (&optional force)
  6854. "Describe the current newsgroup."
  6855. (interactive "P")
  6856. (gnus-group-describe-group force gnus-newsgroup-name))
  6857. (defun gnus-summary-describe-briefly ()
  6858. "Describe summary mode commands briefly."
  6859. (interactive)
  6860. (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")))
  6861. ;; Walking around group mode buffer from summary mode.
  6862. (defun gnus-summary-next-group (&optional no-article target-group backward)
  6863. "Exit current newsgroup and then select next unread newsgroup.
  6864. If prefix argument NO-ARTICLE is non-nil, no article is selected
  6865. initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
  6866. previous group instead."
  6867. (interactive "P")
  6868. ;; Stop pre-fetching.
  6869. (gnus-async-halt-prefetch)
  6870. (let ((current-group gnus-newsgroup-name)
  6871. (current-buffer (current-buffer))
  6872. entered)
  6873. ;; First we semi-exit this group to update Xrefs and all variables.
  6874. ;; We can't do a real exit, because the window conf must remain
  6875. ;; the same in case the user is prompted for info, and we don't
  6876. ;; want the window conf to change before that...
  6877. (gnus-summary-exit t)
  6878. (while (not entered)
  6879. ;; Then we find what group we are supposed to enter.
  6880. (set-buffer gnus-group-buffer)
  6881. (gnus-group-jump-to-group current-group)
  6882. (setq target-group
  6883. (or target-group
  6884. (if (eq gnus-keep-same-level 'best)
  6885. (gnus-summary-best-group gnus-newsgroup-name)
  6886. (gnus-summary-search-group backward gnus-keep-same-level))))
  6887. (if (not target-group)
  6888. ;; There are no further groups, so we return to the group
  6889. ;; buffer.
  6890. (progn
  6891. (gnus-message 5 "Returning to the group buffer")
  6892. (setq entered t)
  6893. (when (gnus-buffer-live-p current-buffer)
  6894. (set-buffer current-buffer)
  6895. (gnus-summary-exit))
  6896. (gnus-run-hooks 'gnus-group-no-more-groups-hook))
  6897. ;; We try to enter the target group.
  6898. (gnus-group-jump-to-group target-group)
  6899. (let ((unreads (gnus-group-group-unread)))
  6900. (if (and (or (eq t unreads)
  6901. (and unreads (not (zerop unreads))))
  6902. (gnus-summary-read-group
  6903. target-group nil no-article
  6904. (and (buffer-name current-buffer) current-buffer)
  6905. nil backward))
  6906. (setq entered t)
  6907. (setq current-group target-group
  6908. target-group nil)))))))
  6909. (defun gnus-summary-prev-group (&optional no-article)
  6910. "Exit current newsgroup and then select previous unread newsgroup.
  6911. If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
  6912. (interactive "P")
  6913. (gnus-summary-next-group no-article nil t))
  6914. ;; Walking around summary lines.
  6915. (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
  6916. "Go to the first subject satisfying any non-nil constraint.
  6917. If UNREAD is non-nil, the article should be unread.
  6918. If UNDOWNLOADED is non-nil, the article should be undownloaded.
  6919. If UNSEEN is non-nil, the article should be unseen as well as unread.
  6920. Returns the article selected or nil if there are no matching articles."
  6921. (interactive "P")
  6922. (cond
  6923. ;; Empty summary.
  6924. ((null gnus-newsgroup-data)
  6925. (gnus-message 3 "No articles in the group")
  6926. nil)
  6927. ;; Pick the first article.
  6928. ((not (or unread undownloaded unseen))
  6929. (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
  6930. (gnus-data-number (car gnus-newsgroup-data)))
  6931. ;; Find the first unread article.
  6932. (t
  6933. (let ((data gnus-newsgroup-data))
  6934. (while (and data
  6935. (let ((num (gnus-data-number (car data))))
  6936. (or (memq num gnus-newsgroup-unfetched)
  6937. (not (or (and unread
  6938. (memq num gnus-newsgroup-unreads))
  6939. (and undownloaded
  6940. (memq num gnus-newsgroup-undownloaded))
  6941. (and unseen
  6942. (memq num gnus-newsgroup-unseen)
  6943. (memq num gnus-newsgroup-unreads)))))))
  6944. (setq data (cdr data)))
  6945. (prog1
  6946. (if data
  6947. (progn
  6948. (goto-char (gnus-data-pos (car data)))
  6949. (gnus-data-number (car data)))
  6950. (gnus-message 3 "No more%s articles"
  6951. (let* ((r (when unread " unread"))
  6952. (d (when undownloaded " undownloaded"))
  6953. (s (when unseen " unseen"))
  6954. (l (delq nil (list r d s))))
  6955. (cond ((= 3 (length l))
  6956. (concat r "," d ", or" s))
  6957. ((= 2 (length l))
  6958. (concat (car l) ", or" (cadr l)))
  6959. ((= 1 (length l))
  6960. (car l))
  6961. (t
  6962. ""))))
  6963. nil
  6964. )
  6965. (gnus-summary-position-point))))))
  6966. (defun gnus-summary-next-subject (n &optional unread dont-display)
  6967. "Go to next N'th summary line.
  6968. If N is negative, go to the previous N'th subject line.
  6969. If UNREAD is non-nil, only unread articles are selected.
  6970. The difference between N and the actual number of steps taken is
  6971. returned."
  6972. (interactive "p")
  6973. (let ((backward (< n 0))
  6974. (n (abs n)))
  6975. (while (and (> n 0)
  6976. (if backward
  6977. (gnus-summary-find-prev unread)
  6978. (gnus-summary-find-next unread)))
  6979. (unless (zerop (setq n (1- n)))
  6980. (gnus-summary-show-thread)))
  6981. (when (/= 0 n)
  6982. (gnus-message 7 "No more%s articles"
  6983. (if unread " unread" "")))
  6984. (unless dont-display
  6985. (gnus-summary-recenter)
  6986. (gnus-summary-position-point))
  6987. n))
  6988. (defun gnus-summary-next-unread-subject (n)
  6989. "Go to next N'th unread summary line."
  6990. (interactive "p")
  6991. (gnus-summary-next-subject n t))
  6992. (defun gnus-summary-prev-subject (n &optional unread)
  6993. "Go to previous N'th summary line.
  6994. If optional argument UNREAD is non-nil, only unread article is selected."
  6995. (interactive "p")
  6996. (gnus-summary-next-subject (- n) unread))
  6997. (defun gnus-summary-prev-unread-subject (n)
  6998. "Go to previous N'th unread summary line."
  6999. (interactive "p")
  7000. (gnus-summary-next-subject (- n) t))
  7001. (defun gnus-summary-goto-subjects (articles)
  7002. "Insert the subject header for ARTICLES in the current buffer."
  7003. (save-excursion
  7004. (dolist (article articles)
  7005. (gnus-summary-goto-subject article t)))
  7006. (gnus-summary-limit (append articles gnus-newsgroup-limit))
  7007. (gnus-summary-position-point))
  7008. (defun gnus-summary-goto-subject (article &optional force silent)
  7009. "Go to the subject line of ARTICLE.
  7010. If FORCE, also allow jumping to articles not currently shown."
  7011. (interactive "nArticle number: ")
  7012. (unless (numberp article)
  7013. (error "Article %s is not a number" article))
  7014. (let ((b (point))
  7015. (data (gnus-data-find article)))
  7016. ;; We read in the article if we have to.
  7017. (and (not data)
  7018. force
  7019. (gnus-summary-insert-subject
  7020. article
  7021. (if (or (numberp force) (vectorp force)) force)
  7022. t)
  7023. (setq data (gnus-data-find article)))
  7024. (goto-char b)
  7025. (if (not data)
  7026. (progn
  7027. (unless silent
  7028. (gnus-message 3 "Can't find article %d" article))
  7029. nil)
  7030. (let ((pt (gnus-data-pos data)))
  7031. (goto-char pt)
  7032. (gnus-summary-set-article-display-arrow pt))
  7033. (gnus-summary-position-point)
  7034. article)))
  7035. ;; Walking around summary lines with displaying articles.
  7036. (defun gnus-summary-expand-window (&optional arg)
  7037. "Make the summary buffer take up the entire Emacs frame.
  7038. Given a prefix, will force an `article' buffer configuration."
  7039. (interactive "P")
  7040. (if arg
  7041. (gnus-configure-windows 'article 'force)
  7042. (gnus-configure-windows 'summary 'force)))
  7043. (defun gnus-summary-display-article (article &optional all-header)
  7044. "Display ARTICLE in article buffer."
  7045. (unless (and (gnus-buffer-live-p gnus-article-buffer)
  7046. (with-current-buffer gnus-article-buffer
  7047. (eq major-mode 'gnus-article-mode)))
  7048. (gnus-article-setup-buffer))
  7049. (gnus-set-global-variables)
  7050. (with-current-buffer gnus-article-buffer
  7051. (setq gnus-article-charset gnus-newsgroup-charset)
  7052. (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
  7053. (mm-enable-multibyte))
  7054. (if (null article)
  7055. nil
  7056. (prog1
  7057. (if gnus-summary-display-article-function
  7058. (funcall gnus-summary-display-article-function article all-header)
  7059. (gnus-article-prepare article all-header))
  7060. (gnus-run-hooks 'gnus-select-article-hook)
  7061. (when (and gnus-current-article
  7062. (not (zerop gnus-current-article)))
  7063. (gnus-summary-goto-subject gnus-current-article))
  7064. (gnus-summary-recenter)
  7065. (when (and gnus-use-trees gnus-show-threads)
  7066. (gnus-possibly-generate-tree article)
  7067. (gnus-highlight-selected-tree article))
  7068. ;; Successfully display article.
  7069. (gnus-article-set-window-start
  7070. (cdr (assq article gnus-newsgroup-bookmarks))))))
  7071. (defun gnus-summary-select-article (&optional all-headers force pseudo article)
  7072. "Select the current article.
  7073. If ALL-HEADERS is non-nil, show all header fields. If FORCE is
  7074. non-nil, the article will be re-fetched even if it already present in
  7075. the article buffer. If PSEUDO is non-nil, pseudo-articles will also
  7076. be displayed."
  7077. ;; Make sure we are in the summary buffer to work around bbdb bug.
  7078. (unless (eq major-mode 'gnus-summary-mode)
  7079. (set-buffer gnus-summary-buffer))
  7080. (let ((article (or article (gnus-summary-article-number)))
  7081. (all-headers (not (not all-headers))) ;Must be t or nil.
  7082. gnus-summary-display-article-function)
  7083. (and (not pseudo)
  7084. (gnus-summary-article-pseudo-p article)
  7085. (error "This is a pseudo-article"))
  7086. (with-current-buffer gnus-summary-buffer
  7087. (if (or (and gnus-single-article-buffer
  7088. (or (null gnus-current-article)
  7089. (null gnus-article-current)
  7090. (null (get-buffer gnus-article-buffer))
  7091. (not (eq article (cdr gnus-article-current)))
  7092. (not (equal (car gnus-article-current)
  7093. gnus-newsgroup-name))
  7094. (not (get-buffer gnus-original-article-buffer))))
  7095. (and (not gnus-single-article-buffer)
  7096. (or (null gnus-current-article)
  7097. (not (get-buffer gnus-original-article-buffer))
  7098. (not (eq gnus-current-article article))))
  7099. force)
  7100. ;; The requested article is different from the current article.
  7101. (progn
  7102. (gnus-summary-display-article article all-headers)
  7103. (when (gnus-buffer-live-p gnus-article-buffer)
  7104. (with-current-buffer gnus-article-buffer
  7105. (if (not gnus-article-decoded-p) ;; a local variable
  7106. (mm-disable-multibyte))))
  7107. (gnus-article-set-window-start
  7108. (cdr (assq article gnus-newsgroup-bookmarks)))
  7109. article)
  7110. 'old))))
  7111. (defun gnus-summary-force-verify-and-decrypt ()
  7112. "Display buttons for signed/encrypted parts and verify/decrypt them."
  7113. (interactive)
  7114. (let ((mm-verify-option 'known)
  7115. (mm-decrypt-option 'known)
  7116. (gnus-article-emulate-mime t)
  7117. (gnus-buttonized-mime-types (append (list "multipart/signed"
  7118. "multipart/encrypted")
  7119. gnus-buttonized-mime-types)))
  7120. (gnus-summary-select-article nil 'force)))
  7121. (defun gnus-summary-set-current-mark (&optional current-mark)
  7122. "Obsolete function."
  7123. nil)
  7124. (defun gnus-summary-next-article (&optional unread subject backward push)
  7125. "Select the next article.
  7126. If UNREAD, only unread articles are selected.
  7127. If SUBJECT, only articles with SUBJECT are selected.
  7128. If BACKWARD, the previous article is selected instead of the next."
  7129. (interactive "P")
  7130. ;; Make sure we are in the summary buffer.
  7131. (unless (eq major-mode 'gnus-summary-mode)
  7132. (set-buffer gnus-summary-buffer))
  7133. (cond
  7134. ;; Is there such an article?
  7135. ((and (gnus-summary-search-forward unread subject backward)
  7136. (or (gnus-summary-display-article (gnus-summary-article-number))
  7137. (eq (gnus-summary-article-mark) gnus-canceled-mark)))
  7138. (gnus-summary-position-point))
  7139. ;; If not, we try the first unread, if that is wanted.
  7140. ((and subject
  7141. gnus-auto-select-same
  7142. (gnus-summary-first-unread-article))
  7143. (gnus-summary-position-point)
  7144. (gnus-message 6 "Wrapped"))
  7145. ;; Try to get next/previous article not displayed in this group.
  7146. ((and gnus-auto-extend-newsgroup
  7147. (not unread) (not subject))
  7148. (gnus-summary-goto-article
  7149. (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
  7150. nil (count-lines (point-min) (point))))
  7151. ;; Go to next/previous group.
  7152. (t
  7153. (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
  7154. (gnus-summary-jump-to-group gnus-newsgroup-name))
  7155. (let ((cmd (if (featurep 'xemacs)
  7156. last-command-char
  7157. last-command-event))
  7158. (point
  7159. (with-current-buffer gnus-group-buffer
  7160. (point)))
  7161. (current-summary (current-buffer))
  7162. (group
  7163. (if (eq gnus-keep-same-level 'best)
  7164. (gnus-summary-best-group gnus-newsgroup-name)
  7165. (gnus-summary-search-group backward gnus-keep-same-level))))
  7166. ;; Select next unread newsgroup automagically.
  7167. (cond
  7168. ((or (not gnus-auto-select-next)
  7169. (not cmd))
  7170. (gnus-message 7 "No more%s articles" (if unread " unread" "")))
  7171. ((or (eq gnus-auto-select-next 'quietly)
  7172. (and (eq gnus-auto-select-next 'slightly-quietly)
  7173. push)
  7174. (and (eq gnus-auto-select-next 'almost-quietly)
  7175. (gnus-summary-last-article-p)))
  7176. ;; Select quietly.
  7177. (if (gnus-ephemeral-group-p gnus-newsgroup-name)
  7178. (gnus-summary-exit)
  7179. (gnus-message 7 "No more%s articles (%s)..."
  7180. (if unread " unread" "")
  7181. (if group (concat "selecting " group)
  7182. "exiting"))
  7183. (gnus-summary-next-group nil group backward)))
  7184. (t
  7185. (when (gnus-key-press-event-p last-input-event)
  7186. ;; Somehow or other, we may now have selected a different
  7187. ;; window. Make point go back to the summary buffer.
  7188. (when (eq current-summary (current-buffer))
  7189. ;; FIXME: This burps when get-buffer-window returns nil.
  7190. (select-window (get-buffer-window current-summary 0)))
  7191. (gnus-summary-walk-group-buffer
  7192. gnus-newsgroup-name cmd unread backward point))))))))
  7193. (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
  7194. (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
  7195. (?\C-p (gnus-group-prev-unread-group 1))))
  7196. (cursor-in-echo-area t)
  7197. keve key group ended prompt)
  7198. (with-current-buffer gnus-group-buffer
  7199. (goto-char start)
  7200. (setq group
  7201. (if (eq gnus-keep-same-level 'best)
  7202. (gnus-summary-best-group gnus-newsgroup-name)
  7203. (gnus-summary-search-group backward gnus-keep-same-level))))
  7204. (while (not ended)
  7205. (setq prompt
  7206. (format
  7207. "No more%s articles%s " (if unread " unread" "")
  7208. (if (and group
  7209. (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
  7210. (format " (Type %s for %s [%s])"
  7211. (single-key-description cmd)
  7212. (gnus-group-decoded-name group)
  7213. (gnus-group-unread group))
  7214. (format " (Type %s to exit %s)"
  7215. (single-key-description cmd)
  7216. (gnus-group-decoded-name gnus-newsgroup-name)))))
  7217. ;; Confirm auto selection.
  7218. (setq key (car (setq keve (gnus-read-event-char prompt)))
  7219. ended t)
  7220. (cond
  7221. ((assq key keystrokes)
  7222. (let ((obuf (current-buffer)))
  7223. (switch-to-buffer gnus-group-buffer)
  7224. (when group
  7225. (gnus-group-jump-to-group group))
  7226. (eval (cadr (assq key keystrokes)))
  7227. (setq group (gnus-group-group-name))
  7228. (switch-to-buffer obuf))
  7229. (setq ended nil))
  7230. ((equal key cmd)
  7231. (if (or (not group)
  7232. (gnus-ephemeral-group-p gnus-newsgroup-name))
  7233. (gnus-summary-exit)
  7234. (gnus-summary-next-group nil group backward)))
  7235. (t
  7236. (push (cdr keve) unread-command-events))))))
  7237. (defun gnus-summary-next-unread-article ()
  7238. "Select unread article after current one."
  7239. (interactive)
  7240. (gnus-summary-next-article
  7241. (or (not (eq gnus-summary-goto-unread 'never))
  7242. (gnus-summary-last-article-p (gnus-summary-article-number)))
  7243. (and gnus-auto-select-same
  7244. (gnus-summary-article-subject))))
  7245. (defun gnus-summary-prev-article (&optional unread subject)
  7246. "Select the article before the current one.
  7247. If UNREAD is non-nil, only unread articles are selected."
  7248. (interactive "P")
  7249. (gnus-summary-next-article unread subject t))
  7250. (defun gnus-summary-prev-unread-article ()
  7251. "Select unread article before current one."
  7252. (interactive)
  7253. (gnus-summary-prev-article
  7254. (or (not (eq gnus-summary-goto-unread 'never))
  7255. (gnus-summary-first-article-p (gnus-summary-article-number)))
  7256. (and gnus-auto-select-same
  7257. (gnus-summary-article-subject))))
  7258. (defun gnus-summary-next-page (&optional lines circular stop)
  7259. "Show next page of the selected article.
  7260. If at the end of the current article, select the next article.
  7261. LINES says how many lines should be scrolled up.
  7262. If CIRCULAR is non-nil, go to the start of the article instead of
  7263. selecting the next article when reaching the end of the current
  7264. article.
  7265. If STOP is non-nil, just stop when reaching the end of the message.
  7266. Also see the variable `gnus-article-skip-boring'."
  7267. (interactive "P")
  7268. (setq gnus-summary-buffer (current-buffer))
  7269. (gnus-set-global-variables)
  7270. (let ((article (gnus-summary-article-number))
  7271. (article-window (get-buffer-window gnus-article-buffer t))
  7272. endp)
  7273. ;; If the buffer is empty, we have no article.
  7274. (unless article
  7275. (error "No article to select"))
  7276. (gnus-configure-windows 'article)
  7277. (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
  7278. (if (and (eq gnus-summary-goto-unread 'never)
  7279. (not (gnus-summary-last-article-p article)))
  7280. (gnus-summary-next-article)
  7281. (gnus-summary-next-unread-article))
  7282. (if (or (null gnus-current-article)
  7283. (null gnus-article-current)
  7284. (/= article (cdr gnus-article-current))
  7285. (not (equal (car gnus-article-current) gnus-newsgroup-name)))
  7286. ;; Selected subject is different from current article's.
  7287. (gnus-summary-display-article article)
  7288. (when article-window
  7289. (gnus-eval-in-buffer-window gnus-article-buffer
  7290. (setq endp (or (gnus-article-next-page lines)
  7291. (gnus-article-only-boring-p))))
  7292. (when endp
  7293. (cond ((or stop gnus-summary-stop-at-end-of-message)
  7294. (gnus-message 3 "End of message"))
  7295. (circular
  7296. (gnus-summary-beginning-of-article))
  7297. (lines
  7298. (gnus-message 3 "End of message"))
  7299. ((null lines)
  7300. (if (and (eq gnus-summary-goto-unread 'never)
  7301. (not (gnus-summary-last-article-p article)))
  7302. (gnus-summary-next-article)
  7303. (gnus-summary-next-unread-article))))))))
  7304. (gnus-summary-recenter)
  7305. (gnus-summary-position-point)))
  7306. (defun gnus-summary-prev-page (&optional lines move)
  7307. "Show previous page of selected article.
  7308. Argument LINES specifies lines to be scrolled down.
  7309. If MOVE, move to the previous unread article if point is at
  7310. the beginning of the buffer."
  7311. (interactive "P")
  7312. (let ((article (gnus-summary-article-number))
  7313. (article-window (get-buffer-window gnus-article-buffer t))
  7314. endp)
  7315. (gnus-configure-windows 'article)
  7316. (if (or (null gnus-current-article)
  7317. (null gnus-article-current)
  7318. (/= article (cdr gnus-article-current))
  7319. (not (equal (car gnus-article-current) gnus-newsgroup-name)))
  7320. ;; Selected subject is different from current article's.
  7321. (gnus-summary-display-article article)
  7322. (gnus-summary-recenter)
  7323. (when article-window
  7324. (gnus-eval-in-buffer-window gnus-article-buffer
  7325. (setq endp (gnus-article-prev-page lines)))
  7326. (when (and move endp)
  7327. (cond (lines
  7328. (gnus-message 3 "Beginning of message"))
  7329. ((null lines)
  7330. (if (and (eq gnus-summary-goto-unread 'never)
  7331. (not (gnus-summary-first-article-p article)))
  7332. (gnus-summary-prev-article)
  7333. (gnus-summary-prev-unread-article))))))))
  7334. (gnus-summary-position-point))
  7335. (defun gnus-summary-prev-page-or-article (&optional lines)
  7336. "Show previous page of selected article.
  7337. Argument LINES specifies lines to be scrolled down.
  7338. If at the beginning of the article, go to the next article."
  7339. (interactive "P")
  7340. (gnus-summary-prev-page lines t))
  7341. (defun gnus-summary-scroll-up (lines)
  7342. "Scroll up (or down) one line current article.
  7343. Argument LINES specifies lines to be scrolled up (or down if negative).
  7344. If no article is selected, then the current article will be selected first."
  7345. (interactive "p")
  7346. (gnus-configure-windows 'article)
  7347. (gnus-summary-show-thread)
  7348. (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
  7349. (gnus-eval-in-buffer-window gnus-article-buffer
  7350. (cond ((> lines 0)
  7351. (when (gnus-article-next-page lines)
  7352. (gnus-message 3 "End of message")))
  7353. ((< lines 0)
  7354. (gnus-article-prev-page (- lines))))))
  7355. (gnus-summary-recenter)
  7356. (gnus-summary-position-point))
  7357. (defun gnus-summary-scroll-down (lines)
  7358. "Scroll down (or up) one line current article.
  7359. Argument LINES specifies lines to be scrolled down (or up if negative).
  7360. If no article is selected, then the current article will be selected first."
  7361. (interactive "p")
  7362. (gnus-summary-scroll-up (- lines)))
  7363. (defun gnus-summary-next-same-subject ()
  7364. "Select next article which has the same subject as current one."
  7365. (interactive)
  7366. (gnus-summary-next-article nil (gnus-summary-article-subject)))
  7367. (defun gnus-summary-prev-same-subject ()
  7368. "Select previous article which has the same subject as current one."
  7369. (interactive)
  7370. (gnus-summary-prev-article nil (gnus-summary-article-subject)))
  7371. (defun gnus-summary-next-unread-same-subject ()
  7372. "Select next unread article which has the same subject as current one."
  7373. (interactive)
  7374. (gnus-summary-next-article t (gnus-summary-article-subject)))
  7375. (defun gnus-summary-prev-unread-same-subject ()
  7376. "Select previous unread article which has the same subject as current one."
  7377. (interactive)
  7378. (gnus-summary-prev-article t (gnus-summary-article-subject)))
  7379. (defun gnus-summary-first-unread-article ()
  7380. "Select the first unread article.
  7381. Return nil if there are no unread articles."
  7382. (interactive)
  7383. (prog1
  7384. (when (gnus-summary-first-subject t)
  7385. (gnus-summary-show-thread)
  7386. (gnus-summary-first-subject t)
  7387. (gnus-summary-display-article (gnus-summary-article-number)))
  7388. (gnus-summary-position-point)))
  7389. (defun gnus-summary-first-unread-subject ()
  7390. "Place the point on the subject line of the first unread article.
  7391. Return nil if there are no unread articles."
  7392. (interactive)
  7393. (prog1
  7394. (when (gnus-summary-first-subject t)
  7395. (gnus-summary-show-thread)
  7396. (gnus-summary-first-subject t))
  7397. (gnus-summary-position-point)))
  7398. (defun gnus-summary-first-unseen-subject ()
  7399. "Place the point on the subject line of the first unseen article.
  7400. Return nil if there are no unseen articles."
  7401. (interactive)
  7402. (prog1
  7403. (when (gnus-summary-first-subject nil nil t)
  7404. (gnus-summary-show-thread)
  7405. (gnus-summary-first-subject nil nil t))
  7406. (gnus-summary-position-point)))
  7407. (defun gnus-summary-first-unseen-or-unread-subject ()
  7408. "Place the point on the subject line of the first unseen and unread article.
  7409. If all article have been seen, on the subject line of the first unread
  7410. article."
  7411. (interactive)
  7412. (prog1
  7413. (unless (when (gnus-summary-first-subject nil nil t)
  7414. (gnus-summary-show-thread)
  7415. (gnus-summary-first-subject nil nil t))
  7416. (when (gnus-summary-first-subject t)
  7417. (gnus-summary-show-thread)
  7418. (gnus-summary-first-subject t)))
  7419. (gnus-summary-position-point)))
  7420. (defun gnus-summary-first-article ()
  7421. "Select the first article.
  7422. Return nil if there are no articles."
  7423. (interactive)
  7424. (prog1
  7425. (when (gnus-summary-first-subject)
  7426. (gnus-summary-show-thread)
  7427. (gnus-summary-first-subject)
  7428. (gnus-summary-display-article (gnus-summary-article-number)))
  7429. (gnus-summary-position-point)))
  7430. (defun gnus-summary-best-unread-article (&optional arg)
  7431. "Select the unread article with the highest score.
  7432. If given a prefix argument, select the next unread article that has a
  7433. score higher than the default score."
  7434. (interactive "P")
  7435. (let ((article (if arg
  7436. (gnus-summary-better-unread-subject)
  7437. (gnus-summary-best-unread-subject))))
  7438. (if article
  7439. (gnus-summary-goto-article article)
  7440. (error "No unread articles"))))
  7441. (defun gnus-summary-best-unread-subject ()
  7442. "Select the unread subject with the highest score."
  7443. (interactive)
  7444. (let ((best -1000000)
  7445. (data gnus-newsgroup-data)
  7446. article score)
  7447. (while data
  7448. (and (gnus-data-unread-p (car data))
  7449. (> (setq score
  7450. (gnus-summary-article-score (gnus-data-number (car data))))
  7451. best)
  7452. (setq best score
  7453. article (gnus-data-number (car data))))
  7454. (setq data (cdr data)))
  7455. (when article
  7456. (gnus-summary-goto-subject article))
  7457. (gnus-summary-position-point)
  7458. article))
  7459. (defun gnus-summary-better-unread-subject ()
  7460. "Select the first unread subject that has a score over the default score."
  7461. (interactive)
  7462. (let ((data gnus-newsgroup-data)
  7463. article score)
  7464. (while (and (setq article (gnus-data-number (car data)))
  7465. (or (gnus-data-read-p (car data))
  7466. (not (> (gnus-summary-article-score article)
  7467. gnus-summary-default-score))))
  7468. (setq data (cdr data)))
  7469. (when article
  7470. (gnus-summary-goto-subject article))
  7471. (gnus-summary-position-point)
  7472. article))
  7473. (defun gnus-summary-last-subject ()
  7474. "Go to the last displayed subject line in the group."
  7475. (let ((article (gnus-data-number (car (gnus-data-list t)))))
  7476. (when article
  7477. (gnus-summary-goto-subject article))))
  7478. (defun gnus-summary-goto-article (article &optional all-headers force)
  7479. "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
  7480. If ALL-HEADERS is non-nil, no header lines are hidden.
  7481. If FORCE, go to the article even if it isn't displayed. If FORCE
  7482. is a number, it is the line the article is to be displayed on."
  7483. (interactive
  7484. (list
  7485. (gnus-completing-read
  7486. "Article number or Message-ID"
  7487. (mapcar 'int-to-string gnus-newsgroup-limit))
  7488. current-prefix-arg
  7489. t))
  7490. (prog1
  7491. (if (and (stringp article)
  7492. (string-match "@\\|%40" article))
  7493. (gnus-summary-refer-article article)
  7494. (when (stringp article)
  7495. (setq article (string-to-number article)))
  7496. (if (gnus-summary-goto-subject article force)
  7497. (gnus-summary-display-article article all-headers)
  7498. (gnus-message 4 "Couldn't go to article %s" article) nil))
  7499. (gnus-summary-position-point)))
  7500. (defun gnus-summary-goto-last-article ()
  7501. "Go to the previously read article."
  7502. (interactive)
  7503. (prog1
  7504. (when gnus-last-article
  7505. (gnus-summary-goto-article gnus-last-article nil t))
  7506. (gnus-summary-position-point)))
  7507. (defun gnus-summary-pop-article (number)
  7508. "Pop one article off the history and go to the previous.
  7509. NUMBER articles will be popped off."
  7510. (interactive "p")
  7511. (let (to)
  7512. (setq gnus-newsgroup-history
  7513. (cdr (setq to (nthcdr number gnus-newsgroup-history))))
  7514. (if to
  7515. (gnus-summary-goto-article (car to) nil t)
  7516. (error "Article history empty")))
  7517. (gnus-summary-position-point))
  7518. ;; Summary commands and functions for limiting the summary buffer.
  7519. (defun gnus-summary-limit-to-articles (n)
  7520. "Limit the summary buffer to the next N articles.
  7521. If not given a prefix, use the process marked articles instead."
  7522. (interactive "P")
  7523. (prog1
  7524. (let ((articles (gnus-summary-work-articles n)))
  7525. (setq gnus-newsgroup-processable nil)
  7526. (gnus-summary-limit articles))
  7527. (gnus-summary-position-point)))
  7528. (defun gnus-summary-pop-limit (&optional total)
  7529. "Restore the previous limit.
  7530. If given a prefix, remove all limits."
  7531. (interactive "P")
  7532. (when total
  7533. (setq gnus-newsgroup-limits
  7534. (list (mapcar (lambda (h) (mail-header-number h))
  7535. gnus-newsgroup-headers))))
  7536. (unless gnus-newsgroup-limits
  7537. (error "No limit to pop"))
  7538. (prog1
  7539. (gnus-summary-limit nil 'pop)
  7540. (gnus-summary-position-point)))
  7541. (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
  7542. "Limit the summary buffer to articles that have subjects that match a regexp.
  7543. If NOT-MATCHING, excluding articles that have subjects that match a regexp."
  7544. (interactive
  7545. (list (read-string (if current-prefix-arg
  7546. "Exclude subject (regexp): "
  7547. "Limit to subject (regexp): "))
  7548. nil current-prefix-arg))
  7549. (unless header
  7550. (setq header "subject"))
  7551. (when (not (equal "" subject))
  7552. (prog1
  7553. (let ((articles (gnus-summary-find-matching
  7554. (or header "subject") subject 'all nil nil
  7555. not-matching)))
  7556. (unless articles
  7557. (error "Found no matches for \"%s\"" subject))
  7558. (gnus-summary-limit articles))
  7559. (gnus-summary-position-point))))
  7560. (defun gnus-summary-limit-to-author (from &optional not-matching)
  7561. "Limit the summary buffer to articles that have authors that match a regexp.
  7562. If NOT-MATCHING, excluding articles that have authors that match a regexp."
  7563. (interactive
  7564. (list (read-string (if current-prefix-arg
  7565. "Exclude author (regexp): "
  7566. "Limit to author (regexp): "))
  7567. current-prefix-arg))
  7568. (gnus-summary-limit-to-subject from "from" not-matching))
  7569. (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
  7570. "Limit the summary buffer to articles with the given RECIPIENT.
  7571. If NOT-MATCHING, exclude RECIPIENT.
  7572. To and Cc headers are checked. You need to include them in
  7573. `nnmail-extra-headers'."
  7574. ;; Unlike `rmail-summary-by-recipients', doesn't include From.
  7575. (interactive
  7576. (list (read-string (format "%s recipient (regexp): "
  7577. (if current-prefix-arg "Exclude" "Limit to")))
  7578. current-prefix-arg))
  7579. (when (not (equal "" recipient))
  7580. (prog1 (let* ((to
  7581. (if (memq 'To nnmail-extra-headers)
  7582. (gnus-summary-find-matching
  7583. (cons 'extra 'To) recipient 'all nil nil
  7584. not-matching)
  7585. (gnus-message
  7586. 1 "`To' isn't present in `nnmail-extra-headers'")
  7587. (sit-for 1)
  7588. nil))
  7589. (cc
  7590. (if (memq 'Cc nnmail-extra-headers)
  7591. (gnus-summary-find-matching
  7592. (cons 'extra 'Cc) recipient 'all nil nil
  7593. not-matching)
  7594. (gnus-message
  7595. 1 "`Cc' isn't present in `nnmail-extra-headers'")
  7596. (sit-for 1)
  7597. nil))
  7598. (articles
  7599. (if not-matching
  7600. ;; We need the numbers that are in both lists:
  7601. (mapcar (lambda (a)
  7602. (and (memq a to) a))
  7603. cc)
  7604. (nconc to cc))))
  7605. (unless articles
  7606. (error "Found no matches for \"%s\"" recipient))
  7607. (gnus-summary-limit articles))
  7608. (gnus-summary-position-point))))
  7609. (defun gnus-summary-limit-to-address (address &optional not-matching)
  7610. "Limit the summary buffer to articles with the given ADDRESS.
  7611. If NOT-MATCHING, exclude ADDRESS.
  7612. To, Cc and From headers are checked. You need to include `To' and `Cc'
  7613. in `nnmail-extra-headers'."
  7614. (interactive
  7615. (list (read-string (format "%s address (regexp): "
  7616. (if current-prefix-arg "Exclude" "Limit to")))
  7617. current-prefix-arg))
  7618. (when (not (equal "" address))
  7619. (prog1 (let* ((to
  7620. (if (memq 'To nnmail-extra-headers)
  7621. (gnus-summary-find-matching
  7622. (cons 'extra 'To) address 'all nil nil
  7623. not-matching)
  7624. (gnus-message
  7625. 1 "`To' isn't present in `nnmail-extra-headers'")
  7626. (sit-for 1)
  7627. t))
  7628. (cc
  7629. (if (memq 'Cc nnmail-extra-headers)
  7630. (gnus-summary-find-matching
  7631. (cons 'extra 'Cc) address 'all nil nil
  7632. not-matching)
  7633. (gnus-message
  7634. 1 "`Cc' isn't present in `nnmail-extra-headers'")
  7635. (sit-for 1)
  7636. t))
  7637. (from
  7638. (gnus-summary-find-matching "from" address
  7639. 'all nil nil not-matching))
  7640. (articles
  7641. (if not-matching
  7642. ;; We need the numbers that are in all lists:
  7643. (if (eq cc t)
  7644. (if (eq to t)
  7645. from
  7646. (mapcar (lambda (a) (car (memq a from))) to))
  7647. (if (eq to t)
  7648. (mapcar (lambda (a) (car (memq a from))) cc)
  7649. (mapcar (lambda (a) (car (memq a from)))
  7650. (mapcar (lambda (a) (car (memq a to)))
  7651. cc))))
  7652. (nconc (if (eq to t) nil to)
  7653. (if (eq cc t) nil cc)
  7654. from))))
  7655. (unless articles
  7656. (error "Found no matches for \"%s\"" address))
  7657. (gnus-summary-limit articles))
  7658. (gnus-summary-position-point))))
  7659. (defun gnus-summary-limit-strange-charsets-predicate (header)
  7660. (when (fboundp 'char-charset)
  7661. (let ((string (concat (mail-header-subject header)
  7662. (mail-header-from header)))
  7663. charset found)
  7664. (dotimes (i (1- (length string)))
  7665. (setq charset (format "%s" (char-charset (aref string (1+ i)))))
  7666. (when (string-match "unicode\\|big\\|japanese" charset)
  7667. (setq found t)))
  7668. found)))
  7669. (defun gnus-summary-limit-to-predicate (predicate)
  7670. "Limit to articles where PREDICATE returns non-nil.
  7671. PREDICATE will be called with the header structures of the
  7672. articles."
  7673. (let ((articles nil)
  7674. (case-fold-search t))
  7675. (dolist (header gnus-newsgroup-headers)
  7676. (when (funcall predicate header)
  7677. (push (mail-header-number header) articles)))
  7678. (gnus-summary-limit (nreverse articles))))
  7679. (defun gnus-summary-limit-to-age (age &optional younger-p)
  7680. "Limit the summary buffer to articles that are older than (or equal) AGE days.
  7681. If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
  7682. articles that are younger than AGE days."
  7683. (interactive
  7684. (let ((younger current-prefix-arg)
  7685. (days-got nil)
  7686. days)
  7687. (while (not days-got)
  7688. (setq days (if younger
  7689. (read-string "Limit to articles younger than (in days, older when negative): ")
  7690. (read-string
  7691. "Limit to articles older than (in days, younger when negative): ")))
  7692. (when (> (length days) 0)
  7693. (setq days (read days)))
  7694. (if (numberp days)
  7695. (progn
  7696. (setq days-got t)
  7697. (when (< days 0)
  7698. (setq younger (not younger))
  7699. (setq days (* days -1))))
  7700. (message "Please enter a number.")
  7701. (sleep-for 1)))
  7702. (list days younger)))
  7703. (prog1
  7704. (let ((data gnus-newsgroup-data)
  7705. (cutoff (days-to-time age))
  7706. articles d date is-younger)
  7707. (while (setq d (pop data))
  7708. (when (and (vectorp (gnus-data-header d))
  7709. (setq date (mail-header-date (gnus-data-header d))))
  7710. (setq is-younger (time-less-p
  7711. (time-since (gnus-date-get-time date))
  7712. cutoff))
  7713. (when (if younger-p
  7714. is-younger
  7715. (not is-younger))
  7716. (push (gnus-data-number d) articles))))
  7717. (gnus-summary-limit (nreverse articles)))
  7718. (gnus-summary-position-point)))
  7719. (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
  7720. "Limit the summary buffer to articles that match an 'extra' header."
  7721. (interactive
  7722. (let ((header
  7723. (intern
  7724. (gnus-completing-read
  7725. (if current-prefix-arg
  7726. "Exclude extra header"
  7727. "Limit extra header")
  7728. (mapcar 'symbol-name gnus-extra-headers)
  7729. t nil nil
  7730. (symbol-name (car gnus-extra-headers))))))
  7731. (list header
  7732. (read-string (format "%s header %s (regexp): "
  7733. (if current-prefix-arg "Exclude" "Limit to")
  7734. header))
  7735. current-prefix-arg)))
  7736. (when (not (equal "" regexp))
  7737. (prog1
  7738. (let ((articles (gnus-summary-find-matching
  7739. (cons 'extra header) regexp 'all nil nil
  7740. not-matching)))
  7741. (unless articles
  7742. (error "Found no matches for \"%s\"" regexp))
  7743. (gnus-summary-limit articles))
  7744. (gnus-summary-position-point))))
  7745. (defun gnus-summary-limit-to-display-predicate ()
  7746. "Limit the summary buffer to the predicated in the `display' group parameter."
  7747. (interactive)
  7748. (unless gnus-newsgroup-display
  7749. (error "There is no `display' group parameter"))
  7750. (let (articles)
  7751. (dolist (gnus-number gnus-newsgroup-articles)
  7752. (when (funcall gnus-newsgroup-display)
  7753. (push gnus-number articles)))
  7754. (gnus-summary-limit articles))
  7755. (gnus-summary-position-point))
  7756. (defun gnus-summary-limit-to-unread (&optional all)
  7757. "Limit the summary buffer to articles that are not marked as read.
  7758. If ALL is non-nil, limit strictly to unread articles."
  7759. (interactive "P")
  7760. (if all
  7761. (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
  7762. (gnus-summary-limit-to-marks
  7763. ;; Concat all the marks that say that an article is read and have
  7764. ;; those removed.
  7765. (list gnus-del-mark gnus-read-mark gnus-ancient-mark
  7766. gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
  7767. gnus-low-score-mark gnus-expirable-mark
  7768. gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
  7769. gnus-duplicate-mark)
  7770. 'reverse)))
  7771. (defun gnus-summary-limit-to-headers (match &optional reverse)
  7772. "Limit the summary buffer to articles that have headers that match MATCH.
  7773. If REVERSE (the prefix), limit to articles that don't match."
  7774. (interactive "sMatch headers (regexp): \nP")
  7775. (gnus-summary-limit-to-bodies match reverse t))
  7776. (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
  7777. "Limit the summary buffer to articles that have bodies that match MATCH.
  7778. If REVERSE (the prefix), limit to articles that don't match."
  7779. (interactive "sMatch body (regexp): \nP")
  7780. (let ((articles nil)
  7781. (gnus-select-article-hook nil) ;Disable hook.
  7782. (gnus-article-prepare-hook nil)
  7783. (gnus-use-article-prefetch nil)
  7784. (gnus-keep-backlog nil)
  7785. (gnus-break-pages nil)
  7786. (gnus-summary-display-arrow nil)
  7787. (gnus-updated-mode-lines nil)
  7788. (gnus-auto-center-summary nil)
  7789. (gnus-display-mime-function nil))
  7790. (dolist (data gnus-newsgroup-data)
  7791. (let (gnus-mark-article-hook)
  7792. (gnus-summary-select-article t t nil (gnus-data-number data)))
  7793. (with-current-buffer gnus-article-buffer
  7794. (article-goto-body)
  7795. (let* ((case-fold-search t)
  7796. (found (if headersp
  7797. (re-search-backward match nil t)
  7798. (re-search-forward match nil t))))
  7799. (when (or (and found
  7800. (not reverse))
  7801. (and (not found)
  7802. reverse))
  7803. (push (gnus-data-number data) articles)))))
  7804. (if (not articles)
  7805. (message "No messages matched")
  7806. (gnus-summary-limit articles)))
  7807. (gnus-summary-position-point))
  7808. (defun gnus-summary-limit-to-singletons (&optional threadsp)
  7809. "Limit the summary buffer to articles that aren't part on any thread.
  7810. If THREADSP (the prefix), limit to articles that are in threads."
  7811. (interactive "P")
  7812. (let ((articles nil)
  7813. thread-articles
  7814. threads)
  7815. (dolist (thread gnus-newsgroup-threads)
  7816. (if (stringp (car thread))
  7817. (dolist (thread (cdr thread))
  7818. (push thread threads))
  7819. (push thread threads)))
  7820. (dolist (thread threads)
  7821. (setq thread-articles (gnus-articles-in-thread thread))
  7822. (when (or (and threadsp
  7823. (> (length thread-articles) 1))
  7824. (and (not threadsp)
  7825. (= (length thread-articles) 1)))
  7826. (setq articles (nconc thread-articles articles))))
  7827. (if (not articles)
  7828. (message "No messages matched")
  7829. (gnus-summary-limit articles))
  7830. (gnus-summary-position-point)))
  7831. (defun gnus-summary-limit-to-replied (&optional unreplied)
  7832. "Limit the summary buffer to replied articles.
  7833. If UNREPLIED (the prefix), limit to unreplied articles."
  7834. (interactive "P")
  7835. (if unreplied
  7836. (gnus-summary-limit
  7837. (gnus-set-difference gnus-newsgroup-articles
  7838. gnus-newsgroup-replied))
  7839. (gnus-summary-limit gnus-newsgroup-replied))
  7840. (gnus-summary-position-point))
  7841. (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
  7842. "Exclude articles that are marked with MARKS (e.g. \"DK\").
  7843. If REVERSE, limit the summary buffer to articles that are marked
  7844. with MARKS. MARKS can either be a string of marks or a list of marks.
  7845. Returns how many articles were removed."
  7846. (interactive "sMarks: ")
  7847. (gnus-summary-limit-to-marks marks t))
  7848. (defun gnus-summary-limit-to-marks (marks &optional reverse)
  7849. "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
  7850. If REVERSE (the prefix), limit the summary buffer to articles that are
  7851. not marked with MARKS. MARKS can either be a string of marks or a
  7852. list of marks.
  7853. Returns how many articles were removed."
  7854. (interactive "sMarks: \nP")
  7855. (prog1
  7856. (let ((data gnus-newsgroup-data)
  7857. (marks (if (listp marks) marks
  7858. (append marks nil))) ; Transform to list.
  7859. articles)
  7860. (while data
  7861. (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
  7862. (memq (gnus-data-mark (car data)) marks))
  7863. (push (gnus-data-number (car data)) articles))
  7864. (setq data (cdr data)))
  7865. (gnus-summary-limit articles))
  7866. (gnus-summary-position-point)))
  7867. (defun gnus-summary-limit-to-score (score)
  7868. "Limit to articles with score at or above SCORE."
  7869. (interactive "NLimit to articles with score of at least: ")
  7870. (let ((data gnus-newsgroup-data)
  7871. articles)
  7872. (while data
  7873. (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
  7874. score)
  7875. (push (gnus-data-number (car data)) articles))
  7876. (setq data (cdr data)))
  7877. (prog1
  7878. (gnus-summary-limit articles)
  7879. (gnus-summary-position-point))))
  7880. (defun gnus-summary-limit-to-unseen ()
  7881. "Limit to unseen articles."
  7882. (interactive)
  7883. (prog1
  7884. (gnus-summary-limit gnus-newsgroup-unseen)
  7885. (gnus-summary-position-point)))
  7886. (defun gnus-summary-limit-include-thread (id)
  7887. "Display all the hidden articles that is in the thread with ID in it.
  7888. When called interactively, ID is the Message-ID of the current
  7889. article."
  7890. (interactive (list (mail-header-id (gnus-summary-article-header))))
  7891. (let ((articles (gnus-articles-in-thread
  7892. (gnus-id-to-thread (gnus-root-id id))))
  7893. ;;we REALLY want the whole thread---this prevents cut-threads
  7894. ;;from removing the thread we want to include.
  7895. (gnus-fetch-old-headers nil)
  7896. (gnus-build-sparse-threads nil))
  7897. (prog1
  7898. (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
  7899. (gnus-summary-limit-include-matching-articles
  7900. "subject"
  7901. (regexp-quote (gnus-simplify-subject-re
  7902. (mail-header-subject (gnus-id-to-header id)))))
  7903. (gnus-summary-position-point))))
  7904. (defun gnus-summary-limit-include-matching-articles (header regexp)
  7905. "Display all the hidden articles that have HEADERs that match REGEXP."
  7906. (interactive (list (read-string "Match on header: ")
  7907. (read-string "Regexp: ")))
  7908. (let ((articles (gnus-find-matching-articles header regexp)))
  7909. (prog1
  7910. (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
  7911. (gnus-summary-position-point))))
  7912. (defun gnus-summary-insert-dormant-articles ()
  7913. "Insert all the dormant articles for this group into the current buffer."
  7914. (interactive)
  7915. (let ((gnus-verbose (max 6 gnus-verbose)))
  7916. (if (not gnus-newsgroup-dormant)
  7917. (gnus-message 3 "No dormant articles for this group")
  7918. (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
  7919. (defun gnus-summary-insert-ticked-articles ()
  7920. "Insert ticked articles for this group into the current buffer."
  7921. (interactive)
  7922. (let ((gnus-verbose (max 6 gnus-verbose)))
  7923. (if (not gnus-newsgroup-marked)
  7924. (gnus-message 3 "No ticked articles for this group")
  7925. (gnus-summary-goto-subjects gnus-newsgroup-marked))))
  7926. (defun gnus-summary-limit-include-dormant ()
  7927. "Display all the hidden articles that are marked as dormant.
  7928. Note that this command only works on a subset of the articles currently
  7929. fetched for this group."
  7930. (interactive)
  7931. (unless gnus-newsgroup-dormant
  7932. (error "There are no dormant articles in this group"))
  7933. (prog1
  7934. (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
  7935. (gnus-summary-position-point)))
  7936. (defun gnus-summary-include-articles (articles)
  7937. "Fetch the headers for ARTICLES and then display the summary lines."
  7938. (let ((gnus-inhibit-demon t)
  7939. (gnus-agent nil)
  7940. (gnus-read-all-available-headers t))
  7941. (setq gnus-newsgroup-headers
  7942. (gnus-merge
  7943. 'list gnus-newsgroup-headers
  7944. (gnus-fetch-headers articles nil t)
  7945. 'gnus-article-sort-by-number))
  7946. (setq gnus-newsgroup-articles
  7947. (gnus-sorted-nunion gnus-newsgroup-articles articles))
  7948. (gnus-summary-limit (append articles gnus-newsgroup-limit))))
  7949. (defun gnus-summary-limit-exclude-dormant ()
  7950. "Hide all dormant articles."
  7951. (interactive)
  7952. (prog1
  7953. (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
  7954. (gnus-summary-position-point)))
  7955. (defun gnus-summary-limit-exclude-childless-dormant ()
  7956. "Hide all dormant articles that have no children."
  7957. (interactive)
  7958. (let ((data (gnus-data-list t))
  7959. articles d children)
  7960. ;; Find all articles that are either not dormant or have
  7961. ;; children.
  7962. (while (setq d (pop data))
  7963. (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
  7964. (and (setq children
  7965. (gnus-article-children (gnus-data-number d)))
  7966. (let (found)
  7967. (while children
  7968. (when (memq (car children) articles)
  7969. (setq children nil
  7970. found t))
  7971. (pop children))
  7972. found)))
  7973. (push (gnus-data-number d) articles)))
  7974. ;; Do the limiting.
  7975. (prog1
  7976. (gnus-summary-limit articles)
  7977. (gnus-summary-position-point))))
  7978. (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
  7979. "Mark all unread excluded articles as read.
  7980. If ALL, mark even excluded ticked and dormants as read."
  7981. (interactive "P")
  7982. (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
  7983. (let ((articles (gnus-sorted-ndifference
  7984. (sort
  7985. (mapcar (lambda (h) (mail-header-number h))
  7986. gnus-newsgroup-headers)
  7987. '<)
  7988. gnus-newsgroup-limit))
  7989. article)
  7990. (setq gnus-newsgroup-unreads
  7991. (gnus-sorted-intersection gnus-newsgroup-unreads
  7992. gnus-newsgroup-limit))
  7993. (if all
  7994. (setq gnus-newsgroup-dormant nil
  7995. gnus-newsgroup-marked nil
  7996. gnus-newsgroup-reads
  7997. (nconc
  7998. (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
  7999. gnus-newsgroup-reads))
  8000. (while (setq article (pop articles))
  8001. (unless (or (memq article gnus-newsgroup-dormant)
  8002. (memq article gnus-newsgroup-marked))
  8003. (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
  8004. (defun gnus-summary-limit (articles &optional pop)
  8005. (if pop
  8006. ;; We pop the previous limit off the stack and use that.
  8007. (setq articles (car gnus-newsgroup-limits)
  8008. gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
  8009. ;; We use the new limit, so we push the old limit on the stack.
  8010. (push gnus-newsgroup-limit gnus-newsgroup-limits))
  8011. ;; Set the limit.
  8012. (setq gnus-newsgroup-limit articles)
  8013. (let ((total (length gnus-newsgroup-data))
  8014. (data (gnus-data-find-list (gnus-summary-article-number)))
  8015. (gnus-summary-mark-below nil) ; Inhibit this.
  8016. found)
  8017. ;; This will do all the work of generating the new summary buffer
  8018. ;; according to the new limit.
  8019. (gnus-summary-prepare)
  8020. ;; Hide any threads, possibly.
  8021. (gnus-summary-maybe-hide-threads)
  8022. ;; Try to return to the article you were at, or one in the
  8023. ;; neighborhood.
  8024. (when data
  8025. ;; We try to find some article after the current one.
  8026. (while data
  8027. (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
  8028. (setq data nil
  8029. found t))
  8030. (setq data (cdr data))))
  8031. (unless found
  8032. ;; If there is no data, that means that we were after the last
  8033. ;; article. The same goes when we can't find any articles
  8034. ;; after the current one.
  8035. (goto-char (point-max))
  8036. (gnus-summary-find-prev))
  8037. (gnus-set-mode-line 'summary)
  8038. ;; We return how many articles were removed from the summary
  8039. ;; buffer as a result of the new limit.
  8040. (- total (length gnus-newsgroup-data))))
  8041. (defsubst gnus-invisible-cut-children (threads)
  8042. (let ((num 0))
  8043. (while threads
  8044. (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
  8045. (incf num))
  8046. (pop threads))
  8047. (< num 2)))
  8048. (defsubst gnus-cut-thread (thread)
  8049. "Go forwards in the thread until we find an article that we want to display."
  8050. (when (or (eq gnus-fetch-old-headers 'some)
  8051. (eq gnus-fetch-old-headers 'invisible)
  8052. (numberp gnus-fetch-old-headers)
  8053. (eq gnus-build-sparse-threads 'some)
  8054. (eq gnus-build-sparse-threads 'more))
  8055. ;; Deal with old-fetched headers and sparse threads.
  8056. (while (and
  8057. thread
  8058. (or
  8059. (gnus-summary-article-sparse-p (mail-header-number (car thread)))
  8060. (gnus-summary-article-ancient-p
  8061. (mail-header-number (car thread))))
  8062. (if (or (<= (length (cdr thread)) 1)
  8063. (eq gnus-fetch-old-headers 'invisible))
  8064. (setq gnus-newsgroup-limit
  8065. (delq (mail-header-number (car thread))
  8066. gnus-newsgroup-limit)
  8067. thread (cadr thread))
  8068. (when (gnus-invisible-cut-children (cdr thread))
  8069. (let ((th (cdr thread)))
  8070. (while th
  8071. (if (memq (mail-header-number (caar th))
  8072. gnus-newsgroup-limit)
  8073. (setq thread (car th)
  8074. th nil)
  8075. (setq th (cdr th))))))))))
  8076. thread)
  8077. (defun gnus-cut-threads (threads)
  8078. "Cut off all uninteresting articles from the beginning of THREADS."
  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. (let ((th threads))
  8085. (while th
  8086. (setcar th (gnus-cut-thread (car th)))
  8087. (setq th (cdr th)))))
  8088. ;; Remove nixed out threads.
  8089. (delq nil threads))
  8090. (defun gnus-summary-initial-limit (&optional show-if-empty)
  8091. "Figure out what the initial limit is supposed to be on group entry.
  8092. This entails weeding out unwanted dormants, low-scored articles,
  8093. fetch-old-headers verbiage, and so on."
  8094. ;; Most groups have nothing to remove.
  8095. (unless (or gnus-inhibit-limiting
  8096. (and (null gnus-newsgroup-dormant)
  8097. (eq gnus-newsgroup-display 'gnus-not-ignore)
  8098. (not (eq gnus-fetch-old-headers 'some))
  8099. (not (numberp gnus-fetch-old-headers))
  8100. (not (eq gnus-fetch-old-headers 'invisible))
  8101. (null gnus-summary-expunge-below)
  8102. (not (eq gnus-build-sparse-threads 'some))
  8103. (not (eq gnus-build-sparse-threads 'more))
  8104. (null gnus-thread-expunge-below)))
  8105. (push gnus-newsgroup-limit gnus-newsgroup-limits)
  8106. (setq gnus-newsgroup-limit nil)
  8107. (mapatoms
  8108. (lambda (node)
  8109. (unless (car (symbol-value node))
  8110. ;; These threads have no parents -- they are roots.
  8111. (let ((nodes (cdr (symbol-value node)))
  8112. thread)
  8113. (while nodes
  8114. (if (and gnus-thread-expunge-below
  8115. (< (gnus-thread-total-score (car nodes))
  8116. gnus-thread-expunge-below))
  8117. (gnus-expunge-thread (pop nodes))
  8118. (setq thread (pop nodes))
  8119. (gnus-summary-limit-children thread))))))
  8120. gnus-newsgroup-dependencies)
  8121. ;; If this limitation resulted in an empty group, we might
  8122. ;; pop the previous limit and use it instead.
  8123. (when (and (not gnus-newsgroup-limit)
  8124. show-if-empty)
  8125. (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
  8126. gnus-newsgroup-limit))
  8127. (defun gnus-summary-limit-children (thread)
  8128. "Return 1 if this subthread is visible and 0 if it is not."
  8129. ;; First we get the number of visible children to this thread. This
  8130. ;; is done by recursing down the thread using this function, so this
  8131. ;; will really go down to a leaf article first, before slowly
  8132. ;; working its way up towards the root.
  8133. (when thread
  8134. (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
  8135. (children
  8136. (if (cdr thread)
  8137. (apply '+ (mapcar 'gnus-summary-limit-children
  8138. (cdr thread)))
  8139. 0))
  8140. (number (mail-header-number (car thread)))
  8141. score)
  8142. (if (and
  8143. (not (memq number gnus-newsgroup-marked))
  8144. (or
  8145. ;; If this article is dormant and has absolutely no visible
  8146. ;; children, then this article isn't visible.
  8147. (and (memq number gnus-newsgroup-dormant)
  8148. (zerop children))
  8149. ;; If this is "fetch-old-headered" and there is no
  8150. ;; visible children, then we don't want this article.
  8151. (and (or (eq gnus-fetch-old-headers 'some)
  8152. (numberp gnus-fetch-old-headers))
  8153. (gnus-summary-article-ancient-p number)
  8154. (zerop children))
  8155. ;; If this is "fetch-old-headered" and `invisible', then
  8156. ;; we don't want this article.
  8157. (and (eq gnus-fetch-old-headers 'invisible)
  8158. (gnus-summary-article-ancient-p number))
  8159. ;; If this is a sparsely inserted article with no children,
  8160. ;; we don't want it.
  8161. (and (eq gnus-build-sparse-threads 'some)
  8162. (gnus-summary-article-sparse-p number)
  8163. (zerop children))
  8164. ;; If we use expunging, and this article is really
  8165. ;; low-scored, then we don't want this article.
  8166. (when (and gnus-summary-expunge-below
  8167. (< (setq score
  8168. (or (cdr (assq number gnus-newsgroup-scored))
  8169. gnus-summary-default-score))
  8170. gnus-summary-expunge-below))
  8171. ;; We increase the expunge-tally here, but that has
  8172. ;; nothing to do with the limits, really.
  8173. (incf gnus-newsgroup-expunged-tally)
  8174. ;; We also mark as read here, if that's wanted.
  8175. (when (and gnus-summary-mark-below
  8176. (< score gnus-summary-mark-below))
  8177. (setq gnus-newsgroup-unreads
  8178. (delq number gnus-newsgroup-unreads))
  8179. (if gnus-newsgroup-auto-expire
  8180. (push number gnus-newsgroup-expirable)
  8181. (push (cons number gnus-low-score-mark)
  8182. gnus-newsgroup-reads)))
  8183. t)
  8184. ;; Do the `display' group parameter.
  8185. (and gnus-newsgroup-display
  8186. (let ((gnus-number number))
  8187. (not (funcall gnus-newsgroup-display))))))
  8188. ;; Nope, invisible article.
  8189. 0
  8190. ;; Ok, this article is to be visible, so we add it to the limit
  8191. ;; and return 1.
  8192. (push number gnus-newsgroup-limit)
  8193. 1))))
  8194. (defun gnus-expunge-thread (thread)
  8195. "Mark all articles in THREAD as read."
  8196. (let* ((number (mail-header-number (car thread))))
  8197. (incf gnus-newsgroup-expunged-tally)
  8198. ;; We also mark as read here, if that's wanted.
  8199. (setq gnus-newsgroup-unreads
  8200. (delq number gnus-newsgroup-unreads))
  8201. (if gnus-newsgroup-auto-expire
  8202. (push number gnus-newsgroup-expirable)
  8203. (push (cons number gnus-low-score-mark)
  8204. gnus-newsgroup-reads)))
  8205. ;; Go recursively through all subthreads.
  8206. (mapcar 'gnus-expunge-thread (cdr thread)))
  8207. ;; Summary article oriented commands
  8208. (defun gnus-summary-refer-parent-article (n)
  8209. "Refer parent article N times.
  8210. If N is negative, go to ancestor -N instead.
  8211. The difference between N and the number of articles fetched is returned."
  8212. (interactive "p")
  8213. (let ((skip 1)
  8214. error header ref)
  8215. (when (not (natnump n))
  8216. (setq skip (abs n)
  8217. n 1))
  8218. (while (and (> n 0)
  8219. (not error))
  8220. (setq header (gnus-summary-article-header))
  8221. (if (and (eq (mail-header-number header)
  8222. (cdr gnus-article-current))
  8223. (equal gnus-newsgroup-name
  8224. (car gnus-article-current)))
  8225. ;; If we try to find the parent of the currently
  8226. ;; displayed article, then we take a look at the actual
  8227. ;; References header, since this is slightly more
  8228. ;; reliable than the References field we got from the
  8229. ;; server.
  8230. (with-current-buffer gnus-original-article-buffer
  8231. (nnheader-narrow-to-headers)
  8232. (unless (setq ref (message-fetch-field "references"))
  8233. (when (setq ref (message-fetch-field "in-reply-to"))
  8234. (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
  8235. (widen))
  8236. (setq ref
  8237. ;; It's not the current article, so we take a bet on
  8238. ;; the value we got from the server.
  8239. (mail-header-references header)))
  8240. (if (and ref
  8241. (not (equal ref "")))
  8242. (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
  8243. (gnus-message 1 "Couldn't find parent"))
  8244. (gnus-message 1 "No references in article %d"
  8245. (gnus-summary-article-number))
  8246. (setq error t))
  8247. (decf n))
  8248. (gnus-summary-position-point)
  8249. n))
  8250. (defun gnus-summary-refer-references ()
  8251. "Fetch all articles mentioned in the References header.
  8252. Return the number of articles fetched."
  8253. (interactive)
  8254. (let ((ref (mail-header-references (gnus-summary-article-header)))
  8255. (current (gnus-summary-article-number))
  8256. (n 0))
  8257. (if (or (not ref)
  8258. (equal ref ""))
  8259. (error "No References in the current article")
  8260. ;; For each Message-ID in the References header...
  8261. (while (string-match "<[^>]*>" ref)
  8262. (incf n)
  8263. ;; ... fetch that article.
  8264. (gnus-summary-refer-article
  8265. (prog1 (match-string 0 ref)
  8266. (setq ref (substring ref (match-end 0))))))
  8267. (gnus-summary-goto-subject current)
  8268. (gnus-summary-position-point)
  8269. n)))
  8270. (defun gnus-delete-duplicate-headers (headers)
  8271. ;; First remove leading duplicates.
  8272. (while (and (> (length headers) 1)
  8273. (= (mail-header-number (car headers))
  8274. (mail-header-number (cadr headers))))
  8275. (pop headers))
  8276. ;; Then the rest.
  8277. (let ((result headers))
  8278. (while (> (length headers) 1)
  8279. (if (= (mail-header-number (car headers))
  8280. (mail-header-number (cadr headers)))
  8281. (setcdr headers (cddr headers))
  8282. (pop headers)))
  8283. result))
  8284. (defun gnus-summary-refer-thread (&optional limit)
  8285. "Fetch all articles in the current thread. For backends that
  8286. know how to search for threads (currently only 'nnimap) a
  8287. non-numeric prefix arg will use nnir to search the entire
  8288. server; without a prefix arg only the current group is
  8289. searched. If the variable `gnus-refer-thread-use-nnir' is
  8290. non-nil the prefix arg has the reverse meaning. If no
  8291. backend-specific 'request-thread function is available fetch
  8292. LIMIT (the numerical prefix) old headers. If LIMIT is
  8293. non-numeric or nil fetch the number specified by the
  8294. `gnus-refer-thread-limit' variable."
  8295. (interactive "P")
  8296. (gnus-warp-to-article)
  8297. (let* ((header (gnus-summary-article-header))
  8298. (id (mail-header-id header))
  8299. (gnus-inhibit-demon t)
  8300. (gnus-summary-ignore-duplicates t)
  8301. (gnus-read-all-available-headers t)
  8302. (gnus-refer-thread-use-nnir
  8303. (if (and (not (null limit)) (listp limit))
  8304. (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
  8305. (new-headers
  8306. (if (gnus-check-backend-function
  8307. 'request-thread gnus-newsgroup-name)
  8308. (gnus-request-thread header gnus-newsgroup-name)
  8309. (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
  8310. gnus-refer-thread-limit))
  8311. (last (if (numberp limit)
  8312. (min (+ (mail-header-number header)
  8313. limit)
  8314. gnus-newsgroup-highest)
  8315. gnus-newsgroup-highest))
  8316. (subject (gnus-simplify-subject
  8317. (mail-header-subject header)))
  8318. (refs (split-string (or (mail-header-references header)
  8319. "")))
  8320. (gnus-parse-headers-hook
  8321. `(lambda () (goto-char (point-min))
  8322. (keep-lines
  8323. (regexp-opt ',(append refs (list id subject)))))))
  8324. (gnus-fetch-headers (list last) (if (numberp limit)
  8325. (* 2 limit) limit) t))))
  8326. article-ids)
  8327. (when (listp new-headers)
  8328. (dolist (header new-headers)
  8329. (push (mail-header-number header) article-ids)
  8330. (when (member (mail-header-number header) gnus-newsgroup-unselected)
  8331. (push (mail-header-number header) gnus-newsgroup-unreads)
  8332. (setq gnus-newsgroup-unselected
  8333. (delete (mail-header-number header)
  8334. gnus-newsgroup-unselected))))
  8335. (setq gnus-newsgroup-headers
  8336. (gnus-delete-duplicate-headers
  8337. (gnus-merge
  8338. 'list gnus-newsgroup-headers new-headers
  8339. 'gnus-article-sort-by-number)))
  8340. (setq gnus-newsgroup-articles
  8341. (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
  8342. (gnus-summary-limit-include-thread id)))
  8343. (gnus-summary-show-thread))
  8344. (defun gnus-summary-refer-article (message-id)
  8345. "Fetch an article specified by MESSAGE-ID."
  8346. (interactive "sMessage-ID: ")
  8347. (gnus-warp-to-article)
  8348. (when (and (stringp message-id)
  8349. (not (zerop (length message-id))))
  8350. (setq message-id (gnus-replace-in-string message-id " " ""))
  8351. ;; Construct the correct Message-ID if necessary.
  8352. ;; Suggested by tale@pawl.rpi.edu.
  8353. (unless (string-match "^<" message-id)
  8354. (setq message-id (concat "<" message-id)))
  8355. (unless (string-match ">$" message-id)
  8356. (setq message-id (concat message-id ">")))
  8357. ;; People often post MIDs from URLs, so unhex it:
  8358. (unless (string-match "@" message-id)
  8359. (setq message-id (gnus-url-unhex-string message-id)))
  8360. (let* ((header (gnus-id-to-header message-id))
  8361. (sparse (and header
  8362. (gnus-summary-article-sparse-p
  8363. (mail-header-number header))
  8364. (memq (mail-header-number header)
  8365. gnus-newsgroup-limit)))
  8366. number)
  8367. (cond
  8368. ;; If the article is present in the buffer we just go to it.
  8369. ((and header
  8370. (or (not (gnus-summary-article-sparse-p
  8371. (mail-header-number header)))
  8372. sparse))
  8373. (prog1
  8374. (gnus-summary-goto-article
  8375. (mail-header-number header) nil t)
  8376. (when sparse
  8377. (gnus-summary-update-article (mail-header-number header)))))
  8378. (t
  8379. ;; We fetch the article.
  8380. (catch 'found
  8381. (dolist (gnus-override-method (gnus-refer-article-methods))
  8382. (when (and (gnus-check-server gnus-override-method)
  8383. ;; Fetch the header,
  8384. (setq number (gnus-summary-insert-subject message-id)))
  8385. ;; and display the article.
  8386. (gnus-summary-select-article nil nil nil number)
  8387. (throw 'found t)))
  8388. (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
  8389. (defun gnus-refer-article-methods ()
  8390. "Return a list of referable methods."
  8391. (cond
  8392. ;; No method, so we default to current and native.
  8393. ((null gnus-refer-article-method)
  8394. (list gnus-current-select-method gnus-select-method))
  8395. ;; Current.
  8396. ((eq 'current gnus-refer-article-method)
  8397. (list gnus-current-select-method))
  8398. ;; List of select methods.
  8399. ((not (and (symbolp (car gnus-refer-article-method))
  8400. (assq (car gnus-refer-article-method) nnoo-definition-alist)))
  8401. (let (out)
  8402. (dolist (method gnus-refer-article-method)
  8403. (push (if (eq 'current method)
  8404. gnus-current-select-method
  8405. (if (eq 'nnir (car method))
  8406. (list
  8407. 'nnir
  8408. (or (cadr method)
  8409. (gnus-method-to-server gnus-current-select-method)))
  8410. method))
  8411. out))
  8412. (nreverse out)))
  8413. ;; One single select method.
  8414. (t
  8415. (list gnus-refer-article-method))))
  8416. (defun gnus-summary-edit-parameters ()
  8417. "Edit the group parameters of the current group."
  8418. (interactive)
  8419. (gnus-group-edit-group gnus-newsgroup-name 'params))
  8420. (defun gnus-summary-customize-parameters ()
  8421. "Customize the group parameters of the current group."
  8422. (interactive)
  8423. (gnus-group-customize gnus-newsgroup-name))
  8424. (defun gnus-summary-enter-digest-group (&optional force)
  8425. "Enter an nndoc group based on the current article.
  8426. If FORCE, force a digest interpretation. If not, try to guess
  8427. what the document format is.
  8428. To control what happens when you exit the group, see the
  8429. `gnus-auto-select-on-ephemeral-exit' variable."
  8430. (interactive "P")
  8431. (let ((conf gnus-current-window-configuration))
  8432. (save-window-excursion
  8433. (save-excursion
  8434. (let (gnus-article-prepare-hook
  8435. gnus-display-mime-function
  8436. gnus-break-pages)
  8437. (gnus-summary-select-article))))
  8438. (setq gnus-current-window-configuration conf)
  8439. (let* ((name (format "%s-%d"
  8440. (gnus-group-prefixed-name
  8441. gnus-newsgroup-name (list 'nndoc ""))
  8442. (with-current-buffer gnus-summary-buffer
  8443. gnus-current-article)))
  8444. (ogroup gnus-newsgroup-name)
  8445. (params (append (gnus-info-params (gnus-get-info ogroup))
  8446. (list (cons 'to-group ogroup))
  8447. (list (cons 'parent-group ogroup))
  8448. (list (cons 'save-article-group ogroup))))
  8449. (case-fold-search t)
  8450. (buf (current-buffer))
  8451. dig to-address)
  8452. (with-current-buffer gnus-original-article-buffer
  8453. ;; Have the digest group inherit the main mail address of
  8454. ;; the parent article.
  8455. (when (setq to-address (or (gnus-fetch-field "reply-to")
  8456. (gnus-fetch-field "from")))
  8457. (setq params
  8458. (append
  8459. (list (cons 'to-address
  8460. (funcall gnus-decode-encoded-address-function
  8461. to-address))))))
  8462. (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
  8463. (insert-buffer-substring gnus-original-article-buffer)
  8464. ;; Remove lines that may lead nndoc to misinterpret the
  8465. ;; document type.
  8466. (narrow-to-region
  8467. (goto-char (point-min))
  8468. (or (search-forward "\n\n" nil t) (point)))
  8469. (goto-char (point-min))
  8470. (delete-matching-lines "^Path:\\|^From ")
  8471. (widen))
  8472. (unwind-protect
  8473. (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
  8474. (gnus-newsgroup-ephemeral-ignored-charsets
  8475. gnus-newsgroup-ignored-charsets))
  8476. (gnus-group-read-ephemeral-group
  8477. name `(nndoc ,name (nndoc-address ,(get-buffer dig))
  8478. (nndoc-article-type
  8479. ,(if force 'mbox 'guess)))
  8480. t nil nil nil
  8481. `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
  8482. "ADAPT")))))
  8483. ;; Make all postings to this group go to the parent group.
  8484. (nconc (gnus-info-params (gnus-get-info name))
  8485. params)
  8486. ;; Couldn't select this doc group.
  8487. (switch-to-buffer buf)
  8488. (gnus-set-global-variables)
  8489. (gnus-configure-windows 'summary)
  8490. (gnus-message 3 "Article couldn't be entered?"))
  8491. (kill-buffer dig)))))
  8492. (defun gnus-summary-read-document (n)
  8493. "Open a new group based on the current article(s).
  8494. This will allow you to read digests and other similar
  8495. documents as newsgroups.
  8496. Obeys the standard process/prefix convention."
  8497. (interactive "P")
  8498. (let* ((ogroup gnus-newsgroup-name)
  8499. (params (append (gnus-info-params (gnus-get-info ogroup))
  8500. (list (cons 'to-group ogroup))))
  8501. group egroup groups vgroup)
  8502. (dolist (article (gnus-summary-work-articles n))
  8503. (setq group (format "%s-%d" gnus-newsgroup-name article))
  8504. (gnus-summary-remove-process-mark article)
  8505. (when (gnus-summary-display-article article)
  8506. (save-excursion ;;What for?
  8507. (with-temp-buffer
  8508. (insert-buffer-substring gnus-original-article-buffer)
  8509. ;; Remove some headers that may lead nndoc to make
  8510. ;; the wrong guess.
  8511. (message-narrow-to-head)
  8512. (goto-char (point-min))
  8513. (delete-matching-lines "^Path:\\|^From ")
  8514. (widen)
  8515. (if (setq egroup
  8516. (gnus-group-read-ephemeral-group
  8517. group `(nndoc ,group (nndoc-address ,(current-buffer))
  8518. (nndoc-article-type guess))
  8519. t nil t))
  8520. (progn
  8521. ;; Make all postings to this group go to the parent group.
  8522. (nconc (gnus-info-params (gnus-get-info egroup))
  8523. params)
  8524. (push egroup groups))
  8525. ;; Couldn't select this doc group.
  8526. (gnus-error 3 "Article couldn't be entered"))))))
  8527. ;; Now we have selected all the documents.
  8528. (cond
  8529. ((not groups)
  8530. (error "None of the articles could be interpreted as documents"))
  8531. ((gnus-group-read-ephemeral-group
  8532. (setq vgroup (format
  8533. "nnvirtual:%s-%s" gnus-newsgroup-name
  8534. (format-time-string "%Y%m%dT%H%M%S" (current-time))))
  8535. `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
  8536. t
  8537. (cons (current-buffer) 'summary)))
  8538. (t
  8539. (error "Couldn't select virtual nndoc group")))))
  8540. (defun gnus-summary-widget-forward (arg)
  8541. "Move point to the next field or button in the article.
  8542. With optional ARG, move across that many fields."
  8543. (interactive "p")
  8544. (gnus-summary-select-article)
  8545. (gnus-configure-windows 'article)
  8546. (select-window (gnus-get-buffer-window gnus-article-buffer))
  8547. (widget-forward arg))
  8548. (defun gnus-summary-isearch-article (&optional regexp-p)
  8549. "Do incremental search forward on the current article.
  8550. If REGEXP-P (the prefix) is non-nil, do regexp isearch."
  8551. (interactive "P")
  8552. (gnus-summary-select-article)
  8553. (gnus-configure-windows 'article)
  8554. (gnus-eval-in-buffer-window gnus-article-buffer
  8555. (save-restriction
  8556. (widen)
  8557. (isearch-forward regexp-p))))
  8558. (defun gnus-summary-repeat-search-article-forward ()
  8559. "Repeat the previous search forwards."
  8560. (interactive)
  8561. (unless gnus-last-search-regexp
  8562. (error "No previous search"))
  8563. (gnus-summary-search-article-forward gnus-last-search-regexp))
  8564. (defun gnus-summary-repeat-search-article-backward ()
  8565. "Repeat the previous search backwards."
  8566. (interactive)
  8567. (unless gnus-last-search-regexp
  8568. (error "No previous search"))
  8569. (gnus-summary-search-article-forward gnus-last-search-regexp t))
  8570. (defun gnus-summary-search-article-forward (regexp &optional backward)
  8571. "Search for an article containing REGEXP forward.
  8572. If BACKWARD, search backward instead."
  8573. (interactive
  8574. (list (read-string
  8575. (format "Search article %s (regexp%s): "
  8576. (if current-prefix-arg "backward" "forward")
  8577. (if gnus-last-search-regexp
  8578. (concat ", default " gnus-last-search-regexp)
  8579. "")))
  8580. current-prefix-arg))
  8581. (if (string-equal regexp "")
  8582. (setq regexp (or gnus-last-search-regexp ""))
  8583. (setq gnus-last-search-regexp regexp)
  8584. (setq gnus-article-before-search gnus-current-article))
  8585. ;; Intentionally set gnus-last-article.
  8586. (setq gnus-last-article gnus-article-before-search)
  8587. (let ((gnus-last-article gnus-last-article))
  8588. (if (gnus-summary-search-article regexp backward)
  8589. (gnus-summary-show-thread)
  8590. (signal 'search-failed (list regexp)))))
  8591. (defun gnus-summary-search-article-backward (regexp)
  8592. "Search for an article containing REGEXP backward."
  8593. (interactive
  8594. (list (read-string
  8595. (format "Search article backward (regexp%s): "
  8596. (if gnus-last-search-regexp
  8597. (concat ", default " gnus-last-search-regexp)
  8598. "")))))
  8599. (gnus-summary-search-article-forward regexp 'backward))
  8600. (defun gnus-summary-search-article (regexp &optional backward)
  8601. "Search for an article containing REGEXP.
  8602. Optional argument BACKWARD means do search for backward.
  8603. `gnus-select-article-hook' is not called during the search."
  8604. ;; We have to require this here to make sure that the following
  8605. ;; dynamic binding isn't shadowed by autoloading.
  8606. (require 'gnus-async)
  8607. (require 'gnus-art)
  8608. (let ((gnus-select-article-hook nil) ;Disable hook.
  8609. (gnus-article-prepare-hook nil)
  8610. (gnus-mark-article-hook nil) ;Inhibit marking as read.
  8611. (gnus-use-article-prefetch nil)
  8612. (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
  8613. (gnus-use-trees nil) ;Inhibit updating tree buffer.
  8614. (gnus-visual nil)
  8615. (gnus-keep-backlog nil)
  8616. (gnus-break-pages nil)
  8617. (gnus-summary-display-arrow nil)
  8618. (gnus-updated-mode-lines nil)
  8619. (gnus-auto-center-summary nil)
  8620. (sum (current-buffer))
  8621. (gnus-display-mime-function nil)
  8622. (found nil)
  8623. point)
  8624. (gnus-save-hidden-threads
  8625. (gnus-summary-select-article)
  8626. (set-buffer gnus-article-buffer)
  8627. (goto-char (window-point (get-buffer-window (current-buffer))))
  8628. (when backward
  8629. (forward-line -1))
  8630. (while (not found)
  8631. (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
  8632. (if (if backward
  8633. (re-search-backward regexp nil t)
  8634. (re-search-forward regexp nil t))
  8635. ;; We found the regexp.
  8636. (progn
  8637. (setq found 'found)
  8638. (beginning-of-line)
  8639. (set-window-start
  8640. (get-buffer-window (current-buffer))
  8641. (point))
  8642. (forward-line 1)
  8643. (set-window-point
  8644. (get-buffer-window (current-buffer))
  8645. (point))
  8646. (set-buffer sum)
  8647. (setq point (point)))
  8648. ;; We didn't find it, so we go to the next article.
  8649. (set-buffer sum)
  8650. (setq found 'not)
  8651. (while (eq found 'not)
  8652. (if (not (if backward (gnus-summary-find-prev)
  8653. (gnus-summary-find-next)))
  8654. ;; No more articles.
  8655. (setq found t)
  8656. ;; Select the next article and adjust point.
  8657. (unless (gnus-summary-article-sparse-p
  8658. (gnus-summary-article-number))
  8659. (setq found nil)
  8660. (gnus-summary-select-article)
  8661. (set-buffer gnus-article-buffer)
  8662. (widen)
  8663. (goto-char (if backward (point-max) (point-min))))))))
  8664. (gnus-message 7 ""))
  8665. ;; Return whether we found the regexp.
  8666. (when (eq found 'found)
  8667. (goto-char point)
  8668. (gnus-summary-show-thread)
  8669. (gnus-summary-goto-subject gnus-current-article)
  8670. (gnus-summary-position-point)
  8671. t)))
  8672. (defun gnus-find-matching-articles (header regexp)
  8673. "Return a list of all articles that match REGEXP on HEADER.
  8674. This search includes all articles in the current group that Gnus has
  8675. fetched headers for, whether they are displayed or not."
  8676. (let ((articles nil)
  8677. ;; Can't eta-reduce because it's a macro.
  8678. (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
  8679. (case-fold-search t))
  8680. (dolist (header gnus-newsgroup-headers)
  8681. (when (string-match regexp (funcall func header))
  8682. (push (mail-header-number header) articles)))
  8683. (nreverse articles)))
  8684. (defun gnus-summary-find-matching (header regexp &optional backward unread
  8685. not-case-fold not-matching)
  8686. "Return a list of all articles that match REGEXP on HEADER.
  8687. The search stars on the current article and goes forwards unless
  8688. BACKWARD is non-nil. If BACKWARD is `all', do all articles.
  8689. If UNREAD is non-nil, only unread articles will
  8690. be taken into consideration. If NOT-CASE-FOLD, case won't be folded
  8691. in the comparisons. If NOT-MATCHING, return a list of all articles that
  8692. not match REGEXP on HEADER."
  8693. (let ((case-fold-search (not not-case-fold))
  8694. articles d func)
  8695. (if (consp header)
  8696. (if (eq (car header) 'extra)
  8697. (setq func
  8698. `(lambda (h)
  8699. (or (cdr (assq ',(cdr header) (mail-header-extra h)))
  8700. "")))
  8701. (error "%s is an invalid header" header))
  8702. (unless (fboundp (intern (concat "mail-header-" header)))
  8703. (error "%s is not a valid header" header))
  8704. (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
  8705. (dolist (d (if (eq backward 'all)
  8706. gnus-newsgroup-data
  8707. (gnus-data-find-list
  8708. (gnus-summary-article-number)
  8709. (gnus-data-list backward))))
  8710. (when (and (or (not unread) ; We want all articles...
  8711. (gnus-data-unread-p d)) ; Or just unreads.
  8712. (vectorp (gnus-data-header d)) ; It's not a pseudo.
  8713. (if not-matching
  8714. (not (string-match
  8715. regexp
  8716. (funcall func (gnus-data-header d))))
  8717. (string-match regexp
  8718. (funcall func (gnus-data-header d)))))
  8719. (push (gnus-data-number d) articles))) ; Success!
  8720. (nreverse articles)))
  8721. (defun gnus-summary-execute-command (header regexp command &optional backward)
  8722. "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
  8723. If HEADER is an empty string (or nil), the match is done on the entire
  8724. article. If BACKWARD (the prefix) is non-nil, search backward instead."
  8725. (interactive
  8726. (list (let ((completion-ignore-case t))
  8727. (gnus-completing-read
  8728. "Header name"
  8729. (mapcar 'symbol-name
  8730. (append
  8731. '(Number Subject From Lines Date
  8732. Message-ID Xref References Body)
  8733. gnus-extra-headers))
  8734. 'require-match))
  8735. (read-string "Regexp: ")
  8736. (read-key-sequence "Command: ")
  8737. current-prefix-arg))
  8738. (when (equal header "Body")
  8739. (setq header ""))
  8740. ;; Hidden thread subtrees must be searched as well.
  8741. (gnus-summary-show-all-threads)
  8742. ;; We don't want to change current point nor window configuration.
  8743. (save-excursion
  8744. (save-window-excursion
  8745. (let (gnus-visual
  8746. gnus-treat-strip-trailing-blank-lines
  8747. gnus-treat-strip-leading-blank-lines
  8748. gnus-treat-strip-multiple-blank-lines
  8749. gnus-treat-hide-boring-headers
  8750. gnus-treat-fold-newsgroups
  8751. gnus-article-prepare-hook)
  8752. (gnus-message 6 "Executing %s..." (key-description command))
  8753. ;; We'd like to execute COMMAND interactively so as to give arguments.
  8754. (gnus-execute header regexp
  8755. `(call-interactively ',(key-binding command))
  8756. backward)
  8757. (gnus-message 6 "Executing %s...done" (key-description command))))))
  8758. (defun gnus-summary-beginning-of-article ()
  8759. "Scroll the article back to the beginning."
  8760. (interactive)
  8761. (gnus-summary-select-article)
  8762. (gnus-configure-windows 'article)
  8763. (gnus-eval-in-buffer-window gnus-article-buffer
  8764. (widen)
  8765. (goto-char (point-min))
  8766. (when gnus-break-pages
  8767. (gnus-narrow-to-page))))
  8768. (defun gnus-summary-end-of-article ()
  8769. "Scroll to the end of the article."
  8770. (interactive)
  8771. (gnus-summary-select-article)
  8772. (gnus-configure-windows 'article)
  8773. (gnus-eval-in-buffer-window gnus-article-buffer
  8774. (widen)
  8775. (goto-char (point-max))
  8776. (recenter -3)
  8777. (when gnus-break-pages
  8778. (gnus-narrow-to-page))))
  8779. (defun gnus-summary-print-truncate-and-quote (string &optional len)
  8780. "Truncate to LEN and quote all \"(\"'s in STRING."
  8781. (gnus-replace-in-string (if (and len (> (length string) len))
  8782. (substring string 0 len)
  8783. string)
  8784. "[()]" "\\\\\\&"))
  8785. (defun gnus-summary-print-article (&optional filename n)
  8786. "Generate and print a PostScript image of the process-marked (mail) articles.
  8787. If used interactively, print the current article if none are
  8788. process-marked. With prefix arg, prompt the user for the name of the
  8789. file to save in.
  8790. When used from Lisp, accept two optional args FILENAME and N. N means
  8791. to print the next N articles. If N is negative, print the N previous
  8792. articles. If N is nil and articles have been marked with the process
  8793. mark, print these instead.
  8794. If the optional first argument FILENAME is nil, send the image to the
  8795. printer. If FILENAME is a string, save the PostScript image in a file with
  8796. that name. If FILENAME is a number, prompt the user for the name of the file
  8797. to save in."
  8798. (interactive (list (ps-print-preprint current-prefix-arg)))
  8799. (dolist (article (gnus-summary-work-articles n))
  8800. (gnus-summary-select-article nil nil 'pseudo article)
  8801. (gnus-eval-in-buffer-window gnus-article-buffer
  8802. (gnus-print-buffer))
  8803. (gnus-summary-remove-process-mark article))
  8804. (ps-despool filename))
  8805. (defun gnus-print-buffer ()
  8806. (let ((ps-left-header
  8807. (list
  8808. (concat "("
  8809. (gnus-summary-print-truncate-and-quote
  8810. (mail-header-subject gnus-current-headers)
  8811. 66) ")")
  8812. (concat "("
  8813. (gnus-summary-print-truncate-and-quote
  8814. (mail-header-from gnus-current-headers)
  8815. 45) ")")))
  8816. (ps-right-header
  8817. (list
  8818. "/pagenumberstring load"
  8819. (concat "("
  8820. (mail-header-date gnus-current-headers) ")"))))
  8821. (gnus-run-hooks 'gnus-ps-print-hook)
  8822. (save-excursion
  8823. (if ps-print-color-p
  8824. (ps-spool-buffer-with-faces)
  8825. (ps-spool-buffer)))))
  8826. (defun gnus-summary-show-complete-article ()
  8827. "Show a complete version of the current article.
  8828. This is only useful if you're looking at a partial version of the
  8829. article currently."
  8830. (interactive)
  8831. (let ((gnus-keep-backlog nil)
  8832. (gnus-use-cache nil)
  8833. (gnus-agent nil)
  8834. (variable (intern
  8835. (format "%s-fetch-partial-articles"
  8836. (car (gnus-find-method-for-group
  8837. gnus-newsgroup-name)))
  8838. obarray))
  8839. old-val)
  8840. (unwind-protect
  8841. (progn
  8842. (setq old-val (symbol-value variable))
  8843. (set variable nil)
  8844. (gnus-flush-original-article-buffer)
  8845. (gnus-summary-show-article))
  8846. (set variable old-val))))
  8847. (defun gnus-summary-show-article (&optional arg)
  8848. "Force redisplaying of the current article.
  8849. If ARG (the prefix) is a number, show the article with the charset
  8850. defined in `gnus-summary-show-article-charset-alist', or the charset
  8851. input.
  8852. If ARG (the prefix) is non-nil and not a number, show the article,
  8853. but without running any of the article treatment functions
  8854. article. Normally, the keystroke is `C-u g'. When using `C-u
  8855. C-u g', show the raw article."
  8856. (interactive "P")
  8857. (cond
  8858. ((numberp arg)
  8859. (gnus-summary-show-article t)
  8860. (let ((gnus-newsgroup-charset
  8861. (or (cdr (assq arg gnus-summary-show-article-charset-alist))
  8862. (mm-read-coding-system
  8863. "View as charset: " ;; actually it is coding system.
  8864. (with-current-buffer gnus-article-buffer
  8865. (mm-detect-coding-region (point) (point-max))))))
  8866. (gnus-newsgroup-ignored-charsets 'gnus-all))
  8867. (gnus-summary-select-article nil 'force)
  8868. (let ((deps gnus-newsgroup-dependencies)
  8869. head header lines)
  8870. (with-current-buffer gnus-original-article-buffer
  8871. (save-restriction
  8872. (message-narrow-to-head)
  8873. (setq head (buffer-string))
  8874. (goto-char (point-min))
  8875. (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
  8876. (goto-char (point-max))
  8877. (widen)
  8878. (setq lines (1- (count-lines (point) (point-max))))))
  8879. (with-temp-buffer
  8880. (insert (format "211 %d Article retrieved.\n"
  8881. (cdr gnus-article-current)))
  8882. (insert head)
  8883. (if lines (insert (format "Lines: %d\n" lines)))
  8884. (insert ".\n")
  8885. (let ((nntp-server-buffer (current-buffer)))
  8886. (setq header (car (gnus-get-newsgroup-headers deps t))))))
  8887. (gnus-data-set-header
  8888. (gnus-data-find (cdr gnus-article-current))
  8889. header)
  8890. (gnus-summary-update-article-line
  8891. (cdr gnus-article-current) header)
  8892. (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
  8893. (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
  8894. ((not arg)
  8895. ;; Select the article the normal way.
  8896. (if (eq mm-text-html-renderer 'shr)
  8897. (progn
  8898. (require 'shr)
  8899. (let ((shr-ignore-cache t))
  8900. (gnus-summary-select-article nil 'force)))
  8901. (gnus-summary-select-article nil 'force)))
  8902. ((equal arg '(16))
  8903. ;; C-u C-u g
  8904. (let ((gnus-inhibit-article-treatments t))
  8905. (gnus-summary-select-article nil 'force)))
  8906. (t
  8907. ;; We have to require this here to make sure that the following
  8908. ;; dynamic binding isn't shadowed by autoloading.
  8909. (require 'gnus-async)
  8910. (require 'gnus-art)
  8911. ;; Bind the article treatment functions to nil.
  8912. (let ((gnus-have-all-headers t)
  8913. gnus-article-prepare-hook
  8914. gnus-article-decode-hook
  8915. gnus-display-mime-function
  8916. gnus-break-pages)
  8917. ;; Destroy any MIME parts.
  8918. (when (gnus-buffer-live-p gnus-article-buffer)
  8919. (with-current-buffer gnus-article-buffer
  8920. (gnus-article-stop-animations)
  8921. (gnus-stop-downloads)
  8922. (mm-destroy-parts gnus-article-mime-handles)
  8923. ;; Set it to nil for safety reason.
  8924. (setq gnus-article-mime-handle-alist nil)
  8925. (setq gnus-article-mime-handles nil)))
  8926. (gnus-summary-select-article nil 'force))))
  8927. (gnus-summary-goto-subject gnus-current-article)
  8928. (gnus-summary-position-point))
  8929. (defun gnus-summary-show-raw-article ()
  8930. "Show the raw article without any article massaging functions being run."
  8931. (interactive)
  8932. (gnus-summary-show-article t))
  8933. (defun gnus-summary-verbose-headers (&optional arg)
  8934. "Toggle permanent full header display.
  8935. If ARG is a positive number, turn header display on.
  8936. If ARG is a negative number, turn header display off."
  8937. (interactive "P")
  8938. (setq gnus-show-all-headers
  8939. (cond ((or (not (numberp arg))
  8940. (zerop arg))
  8941. (not gnus-show-all-headers))
  8942. ((natnump arg)
  8943. t)))
  8944. (gnus-summary-show-article))
  8945. (defun gnus-summary-toggle-header (&optional arg)
  8946. "Show the headers if they are hidden, or hide them if they are shown.
  8947. If ARG is a positive number, show the entire header.
  8948. If ARG is a negative number, hide the unwanted header lines."
  8949. (interactive "P")
  8950. (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
  8951. (get-buffer-window gnus-article-buffer t))))
  8952. (with-current-buffer gnus-article-buffer
  8953. (widen)
  8954. (article-narrow-to-head)
  8955. (let* ((inhibit-read-only t)
  8956. (inhibit-point-motion-hooks t)
  8957. (hidden (if (numberp arg)
  8958. (>= arg 0)
  8959. (or (not (looking-at "[^ \t\n]+:"))
  8960. (gnus-article-hidden-text-p 'headers))))
  8961. s e)
  8962. (delete-region (point-min) (point-max))
  8963. (with-current-buffer gnus-original-article-buffer
  8964. (goto-char (setq s (point-min)))
  8965. (setq e (if (search-forward "\n\n" nil t)
  8966. (1- (point))
  8967. (point-max))))
  8968. (insert-buffer-substring gnus-original-article-buffer s e)
  8969. (run-hooks 'gnus-article-decode-hook)
  8970. (if hidden
  8971. (let ((gnus-treat-hide-headers nil)
  8972. (gnus-treat-hide-boring-headers nil))
  8973. (gnus-delete-wash-type 'headers)
  8974. (gnus-treat-article 'head))
  8975. (gnus-treat-article 'head))
  8976. (widen)
  8977. (if window
  8978. (set-window-start window (goto-char (point-min))))
  8979. (if gnus-break-pages
  8980. (gnus-narrow-to-page)
  8981. (when (gnus-visual-p 'page-marker)
  8982. (let ((inhibit-read-only t))
  8983. (gnus-remove-text-with-property 'gnus-prev)
  8984. (gnus-remove-text-with-property 'gnus-next))))
  8985. (gnus-set-mode-line 'article)))))
  8986. (defun gnus-summary-show-all-headers ()
  8987. "Make all header lines visible."
  8988. (interactive)
  8989. (gnus-summary-toggle-header 1))
  8990. (defun gnus-summary-caesar-message (&optional arg)
  8991. "Caesar rotate the current article by 13.
  8992. With a non-numerical prefix, also rotate headers. A numerical
  8993. prefix specifies how many places to rotate each letter forward."
  8994. (interactive "P")
  8995. (gnus-summary-select-article)
  8996. (let ((mail-header-separator ""))
  8997. (gnus-eval-in-buffer-window gnus-article-buffer
  8998. (save-restriction
  8999. (widen)
  9000. (let ((start (window-start))
  9001. (inhibit-read-only t))
  9002. (if (equal arg '(4))
  9003. (message-caesar-buffer-body nil t)
  9004. (message-caesar-buffer-body arg))
  9005. (set-window-start (get-buffer-window (current-buffer)) start)))))
  9006. ;; Create buttons and stuff...
  9007. (gnus-treat-article nil))
  9008. (declare-function idna-to-unicode "ext:idna" (str))
  9009. (defun gnus-summary-idna-message (&optional arg)
  9010. "Decode IDNA encoded domain names in the current articles.
  9011. IDNA encoded domain names looks like `xn--bar'. If a string
  9012. remain unencoded after running this function, it is likely an
  9013. invalid IDNA string (`xn--bar' is invalid).
  9014. You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
  9015. installed for this command to work."
  9016. (interactive "P")
  9017. (if (not (and (condition-case nil (require 'idna)
  9018. (file-error))
  9019. (mm-coding-system-p 'utf-8)
  9020. (executable-find (symbol-value 'idna-program))))
  9021. (gnus-message
  9022. 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
  9023. (gnus-summary-select-article)
  9024. (let ((mail-header-separator ""))
  9025. (gnus-eval-in-buffer-window gnus-article-buffer
  9026. (save-restriction
  9027. (widen)
  9028. (let ((start (window-start))
  9029. buffer-read-only)
  9030. (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
  9031. (replace-match (idna-to-unicode (match-string 1))))
  9032. (set-window-start (get-buffer-window (current-buffer)) start)))))))
  9033. (defun gnus-summary-morse-message (&optional arg)
  9034. "Morse decode the current article."
  9035. (interactive "P")
  9036. (gnus-summary-select-article)
  9037. (let ((mail-header-separator ""))
  9038. (gnus-eval-in-buffer-window gnus-article-buffer
  9039. (save-excursion
  9040. (save-restriction
  9041. (widen)
  9042. (let ((pos (window-start))
  9043. (inhibit-read-only t))
  9044. (goto-char (point-min))
  9045. (when (message-goto-body)
  9046. (gnus-narrow-to-body))
  9047. (goto-char (point-min))
  9048. (while (search-forward "·" (point-max) t)
  9049. (replace-match "."))
  9050. (unmorse-region (point-min) (point-max))
  9051. (widen)
  9052. (set-window-start (get-buffer-window (current-buffer)) pos)))))))
  9053. (defun gnus-summary-stop-page-breaking ()
  9054. "Stop page breaking in the current article."
  9055. (interactive)
  9056. (gnus-summary-select-article)
  9057. (gnus-eval-in-buffer-window gnus-article-buffer
  9058. (widen)
  9059. (when (gnus-visual-p 'page-marker)
  9060. (let ((inhibit-read-only t))
  9061. (gnus-remove-text-with-property 'gnus-prev)
  9062. (gnus-remove-text-with-property 'gnus-next))
  9063. (setq gnus-page-broken nil))))
  9064. (defun gnus-summary-move-article (&optional n to-newsgroup
  9065. select-method action)
  9066. "Move the current article to a different newsgroup.
  9067. If N is a positive number, move the N next articles.
  9068. If N is a negative number, move the N previous articles.
  9069. If N is nil and any articles have been marked with the process mark,
  9070. move those articles instead.
  9071. If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
  9072. If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
  9073. re-spool using this method.
  9074. When called interactively with TO-NEWSGROUP being nil, the value of
  9075. the variable `gnus-move-split-methods' is used for finding a default
  9076. for the target newsgroup.
  9077. For this function to work, both the current newsgroup and the
  9078. newsgroup that you want to move to have to support the `request-move'
  9079. and `request-accept' functions.
  9080. ACTION can be either `move' (the default), `crosspost' or `copy'."
  9081. (interactive "P")
  9082. (unless action
  9083. (setq action 'move))
  9084. ;; Check whether the source group supports the required functions.
  9085. (cond ((and (eq action 'move)
  9086. (not (gnus-check-backend-function
  9087. 'request-move-article gnus-newsgroup-name)))
  9088. (error "The current group does not support article moving"))
  9089. ((and (eq action 'crosspost)
  9090. (not (gnus-check-backend-function
  9091. 'request-replace-article gnus-newsgroup-name)))
  9092. (error "The current group does not support article editing")))
  9093. (let ((articles (gnus-summary-work-articles n))
  9094. (prefix (if (gnus-check-backend-function
  9095. 'request-move-article gnus-newsgroup-name)
  9096. (funcall gnus-move-group-prefix-function
  9097. gnus-newsgroup-name)
  9098. ""))
  9099. (names '((move "Move" "Moving")
  9100. (copy "Copy" "Copying")
  9101. (crosspost "Crosspost" "Crossposting")))
  9102. (copy-buf (save-excursion
  9103. (nnheader-set-temp-buffer " *copy article*")))
  9104. art-group to-method new-xref article to-groups
  9105. articles-to-update-marks encoded)
  9106. (unless (assq action names)
  9107. (error "Unknown action %s" action))
  9108. ;; Read the newsgroup name.
  9109. (when (and (not to-newsgroup)
  9110. (not select-method))
  9111. (if (and gnus-move-split-methods
  9112. (not
  9113. (and (memq gnus-current-article articles)
  9114. (gnus-buffer-live-p gnus-original-article-buffer))))
  9115. ;; When `gnus-move-split-methods' is non-nil, we have to
  9116. ;; select an article to give `gnus-read-move-group-name' an
  9117. ;; opportunity to suggest an appropriate default. However,
  9118. ;; we needn't render or mark the article.
  9119. (let ((gnus-display-mime-function nil)
  9120. (gnus-article-prepare-hook nil)
  9121. (gnus-mark-article-hook nil))
  9122. (gnus-summary-select-article nil nil nil (car articles))))
  9123. (setq to-newsgroup (gnus-read-move-group-name
  9124. (cadr (assq action names))
  9125. (symbol-value
  9126. (intern (format "gnus-current-%s-group" action)))
  9127. articles prefix)
  9128. encoded to-newsgroup
  9129. to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
  9130. (set (intern (format "gnus-current-%s-group" action))
  9131. (mm-decode-coding-string
  9132. to-newsgroup
  9133. (gnus-group-name-charset to-method to-newsgroup))))
  9134. (unless to-method
  9135. (setq to-method (or select-method
  9136. (gnus-server-to-method
  9137. (gnus-group-method to-newsgroup)))))
  9138. (setq to-newsgroup
  9139. (or encoded
  9140. (and to-newsgroup
  9141. (mm-encode-coding-string
  9142. to-newsgroup
  9143. (gnus-group-name-charset to-method to-newsgroup)))))
  9144. ;; Check the method we are to move this article to...
  9145. (unless (gnus-check-backend-function
  9146. 'request-accept-article (car to-method))
  9147. (error "%s does not support article copying" (car to-method)))
  9148. (unless (gnus-check-server to-method)
  9149. (error "Can't open server %s" (car to-method)))
  9150. (gnus-message 6 "%s to %s: %s..."
  9151. (caddr (assq action names))
  9152. (or (car select-method)
  9153. (gnus-group-decoded-name to-newsgroup))
  9154. articles)
  9155. (while articles
  9156. (setq article (pop articles))
  9157. ;; Set any marks that may have changed in the summary buffer.
  9158. (when gnus-preserve-marks
  9159. (gnus-summary-push-marks-to-backend article))
  9160. (setq
  9161. art-group
  9162. (cond
  9163. ;; Move the article.
  9164. ((eq action 'move)
  9165. ;; Remove this article from future suppression.
  9166. (gnus-dup-unsuppress-article article)
  9167. (let* ((from-method (gnus-find-method-for-group
  9168. gnus-newsgroup-name))
  9169. (to-method (or select-method
  9170. (gnus-find-method-for-group to-newsgroup)))
  9171. (move-is-internal (gnus-server-equal from-method to-method)))
  9172. (gnus-request-move-article
  9173. article ; Article to move
  9174. gnus-newsgroup-name ; From newsgroup
  9175. (nth 1 (gnus-find-method-for-group
  9176. gnus-newsgroup-name)) ; Server
  9177. (list 'gnus-request-accept-article
  9178. to-newsgroup (list 'quote select-method)
  9179. (not articles) t) ; Accept form
  9180. (not articles) ; Only save nov last time
  9181. (and move-is-internal
  9182. to-newsgroup ; Not respooling
  9183. ; Is this move internal?
  9184. (gnus-group-real-name to-newsgroup)))))
  9185. ;; Copy the article.
  9186. ((eq action 'copy)
  9187. (with-current-buffer copy-buf
  9188. (when (gnus-request-article-this-buffer article
  9189. gnus-newsgroup-name)
  9190. (save-restriction
  9191. (nnheader-narrow-to-headers)
  9192. (dolist (hdr gnus-copy-article-ignored-headers)
  9193. (message-remove-header hdr t)))
  9194. (gnus-request-accept-article
  9195. to-newsgroup select-method (not articles) t))))
  9196. ;; Crosspost the article.
  9197. ((eq action 'crosspost)
  9198. (let ((xref (message-tokenize-header
  9199. (mail-header-xref (gnus-summary-article-header
  9200. article))
  9201. " ")))
  9202. (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
  9203. ":" (number-to-string article)))
  9204. (unless xref
  9205. (setq xref (list (system-name))))
  9206. (setq new-xref
  9207. (concat
  9208. (mapconcat 'identity
  9209. (delete "Xref:" (delete new-xref xref))
  9210. " ")
  9211. " " new-xref))
  9212. (with-current-buffer copy-buf
  9213. ;; First put the article in the destination group.
  9214. (gnus-request-article-this-buffer article gnus-newsgroup-name)
  9215. (when (consp (setq art-group
  9216. (gnus-request-accept-article
  9217. to-newsgroup select-method (not articles)
  9218. t)))
  9219. (setq new-xref (concat new-xref " " (car art-group)
  9220. ":"
  9221. (number-to-string (cdr art-group))))
  9222. ;; Now we have the new Xrefs header, so we insert
  9223. ;; it and replace the new article.
  9224. (nnheader-replace-header "Xref" new-xref)
  9225. (gnus-request-replace-article
  9226. (cdr art-group) to-newsgroup (current-buffer) t)
  9227. art-group))))))
  9228. (cond
  9229. ((not art-group)
  9230. (gnus-message 1 "Couldn't %s article %s: %s"
  9231. (cadr (assq action names)) article
  9232. (nnheader-get-report (car to-method))))
  9233. ((eq art-group 'junk)
  9234. (when (eq action 'move)
  9235. (gnus-summary-mark-article article gnus-canceled-mark)
  9236. (gnus-message 4 "Deleted article %s" article)
  9237. ;; run the delete hook
  9238. (run-hook-with-args 'gnus-summary-article-delete-hook
  9239. action
  9240. (gnus-data-header
  9241. (assoc article (gnus-data-list nil)))
  9242. gnus-newsgroup-name nil
  9243. select-method)))
  9244. (t
  9245. (let* ((pto-group (gnus-group-prefixed-name
  9246. (car art-group) to-method))
  9247. (info (gnus-get-info pto-group))
  9248. (to-group (gnus-info-group info))
  9249. to-marks)
  9250. ;; Update the group that has been moved to.
  9251. (when (and info
  9252. (memq action '(move copy)))
  9253. (unless (member to-group to-groups)
  9254. (push to-group to-groups))
  9255. (when (and (not (memq article gnus-newsgroup-unreads))
  9256. (cdr art-group))
  9257. (push 'read to-marks)
  9258. (gnus-info-set-read
  9259. info (gnus-add-to-range (gnus-info-read info)
  9260. (list (cdr art-group)))))
  9261. ;; See whether the article is to be put in the cache.
  9262. (let* ((expirable (gnus-group-auto-expirable-p to-group))
  9263. (marks (if expirable
  9264. gnus-article-mark-lists
  9265. (delete '(expirable . expire)
  9266. (copy-sequence
  9267. gnus-article-mark-lists))))
  9268. (to-article (cdr art-group)))
  9269. ;; Enter the article into the cache in the new group,
  9270. ;; if that is required.
  9271. (when (and to-article
  9272. gnus-use-cache)
  9273. (gnus-cache-possibly-enter-article
  9274. to-group to-article
  9275. (memq article gnus-newsgroup-marked)
  9276. (memq article gnus-newsgroup-dormant)
  9277. (memq article gnus-newsgroup-unreads)))
  9278. (when (and gnus-preserve-marks
  9279. to-article)
  9280. ;; Copy any marks over to the new group.
  9281. (when (and (equal to-group gnus-newsgroup-name)
  9282. (not (memq article gnus-newsgroup-unreads)))
  9283. ;; Mark this article as read in this group.
  9284. (push (cons to-article gnus-read-mark)
  9285. gnus-newsgroup-reads)
  9286. ;; Increase the active status of this group.
  9287. (setcdr (gnus-active to-group) to-article)
  9288. (setcdr gnus-newsgroup-active to-article))
  9289. (while marks
  9290. (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
  9291. (when (memq article (symbol-value
  9292. (intern (format "gnus-newsgroup-%s"
  9293. (caar marks)))))
  9294. (push (cdar marks) to-marks)
  9295. ;; If the other group is the same as this group,
  9296. ;; then we have to add the mark to the list.
  9297. (when (equal to-group gnus-newsgroup-name)
  9298. (set (intern (format "gnus-newsgroup-%s"
  9299. (caar marks)))
  9300. (cons to-article
  9301. (symbol-value
  9302. (intern (format "gnus-newsgroup-%s"
  9303. (caar marks)))))))
  9304. ;; Copy the marks to other group.
  9305. (gnus-add-marked-articles
  9306. to-group (cdar marks) (list to-article) info)))
  9307. (setq marks (cdr marks)))
  9308. (when (and expirable
  9309. gnus-mark-copied-or-moved-articles-as-expirable
  9310. (not (memq 'expire to-marks)))
  9311. ;; Mark this article as expirable.
  9312. (push 'expire to-marks)
  9313. (when (equal to-group gnus-newsgroup-name)
  9314. (push to-article gnus-newsgroup-expirable))
  9315. ;; Copy the expirable mark to other group.
  9316. (gnus-add-marked-articles
  9317. to-group 'expire (list to-article) info))
  9318. (when (and to-marks
  9319. (or gnus-propagate-marks
  9320. (gnus-method-option-p
  9321. (gnus-find-method-for-group to-group)
  9322. 'server-marks)))
  9323. (gnus-request-set-mark
  9324. to-group (list (list (list to-article) 'add to-marks)))))
  9325. (gnus-dribble-enter
  9326. (concat "(gnus-group-set-info '"
  9327. (gnus-prin1-to-string (gnus-get-info to-group))
  9328. ")")
  9329. (concat "^(gnus-group-set-info '(\""
  9330. (regexp-quote to-group) "\""))))
  9331. ;; Update the Xref header in this article to point to
  9332. ;; the new crossposted article we have just created.
  9333. (when (eq action 'crosspost)
  9334. (with-current-buffer copy-buf
  9335. (gnus-request-article-this-buffer article gnus-newsgroup-name)
  9336. (nnheader-replace-header "Xref" new-xref)
  9337. (gnus-request-replace-article
  9338. article gnus-newsgroup-name (current-buffer) t)))
  9339. ;; run the move/copy/crosspost/respool hook
  9340. (run-hook-with-args 'gnus-summary-article-move-hook
  9341. action
  9342. (gnus-data-header
  9343. (assoc article (gnus-data-list nil)))
  9344. gnus-newsgroup-name
  9345. to-newsgroup
  9346. select-method))
  9347. ;;;!!!Why is this necessary?
  9348. (set-buffer gnus-summary-buffer)
  9349. (when (eq action 'move)
  9350. (save-excursion
  9351. (gnus-summary-goto-subject article)
  9352. (gnus-summary-mark-article article gnus-canceled-mark)))))
  9353. (push article articles-to-update-marks))
  9354. (save-excursion
  9355. (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
  9356. ;; Re-activate all groups that have been moved to.
  9357. (with-current-buffer gnus-group-buffer
  9358. (let ((gnus-group-marked to-groups))
  9359. (gnus-group-get-new-news-this-group nil t)))
  9360. (gnus-kill-buffer copy-buf)
  9361. (gnus-summary-position-point)
  9362. (gnus-set-mode-line 'summary)))
  9363. (defun gnus-summary-push-marks-to-backend (article)
  9364. (let ((set nil)
  9365. (marks gnus-article-mark-lists))
  9366. (unless (memq article gnus-newsgroup-unreads)
  9367. (push 'read set))
  9368. (while marks
  9369. (when (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
  9370. (memq article (symbol-value
  9371. (intern (format "gnus-newsgroup-%s"
  9372. (caar marks))))))
  9373. (push (cdar marks) set))
  9374. (pop marks))
  9375. (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)))))
  9376. (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
  9377. "Copy the current article to some other group.
  9378. If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
  9379. When called interactively, if TO-NEWSGROUP is nil, use the value of
  9380. the variable `gnus-move-split-methods' for finding a default target
  9381. newsgroup.
  9382. If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
  9383. re-spool using this method."
  9384. (interactive "P")
  9385. (gnus-summary-move-article n to-newsgroup select-method 'copy))
  9386. (defun gnus-summary-crosspost-article (&optional n)
  9387. "Crosspost the current article to some other group."
  9388. (interactive "P")
  9389. (gnus-summary-move-article n nil nil 'crosspost))
  9390. (defcustom gnus-summary-respool-default-method nil
  9391. "Default method type for respooling an article.
  9392. If nil, use to the current newsgroup method."
  9393. :type 'symbol
  9394. :group 'gnus-summary-mail)
  9395. (defun gnus-summary-respool-article (&optional n method)
  9396. "Respool the current article.
  9397. The article will be squeezed through the mail spooling process again,
  9398. which means that it will be put in some mail newsgroup or other
  9399. depending on `nnmail-split-methods'.
  9400. If N is a positive number, respool the N next articles.
  9401. If N is a negative number, respool the N previous articles.
  9402. If N is nil and any articles have been marked with the process mark,
  9403. respool those articles instead.
  9404. Respooling can be done both from mail groups and \"real\" newsgroups.
  9405. In the former case, the articles in question will be moved from the
  9406. current group into whatever groups they are destined to. In the
  9407. latter case, they will be copied into the relevant groups."
  9408. (interactive
  9409. (list current-prefix-arg
  9410. (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
  9411. (methname
  9412. (symbol-name (or gnus-summary-respool-default-method
  9413. (car (gnus-find-method-for-group
  9414. gnus-newsgroup-name)))))
  9415. (method
  9416. (gnus-completing-read
  9417. "Backend to use when respooling"
  9418. methods t nil 'gnus-mail-method-history methname))
  9419. ms)
  9420. (cond
  9421. ((zerop (length (setq ms (gnus-servers-using-backend
  9422. (intern method)))))
  9423. (list (intern method) ""))
  9424. ((= 1 (length ms))
  9425. (car ms))
  9426. (t
  9427. (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
  9428. (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
  9429. ms-alist))))))))
  9430. (unless method
  9431. (error "No method given for respooling"))
  9432. (if (assoc (symbol-name
  9433. (car (gnus-find-method-for-group gnus-newsgroup-name)))
  9434. (gnus-methods-using 'respool))
  9435. (gnus-summary-move-article n nil method)
  9436. (gnus-summary-copy-article n nil method)))
  9437. (defun gnus-summary-import-article (file &optional edit)
  9438. "Import an arbitrary file into a mail newsgroup."
  9439. (interactive "fImport file: \nP")
  9440. (let ((group gnus-newsgroup-name)
  9441. (now (current-time))
  9442. atts lines group-art)
  9443. (unless (gnus-check-backend-function 'request-accept-article group)
  9444. (error "%s does not support article importing" group))
  9445. (or (file-readable-p file)
  9446. (not (file-regular-p file))
  9447. (error "Can't read %s" file))
  9448. (with-current-buffer (gnus-get-buffer-create " *import file*")
  9449. (erase-buffer)
  9450. (nnheader-insert-file-contents file)
  9451. (goto-char (point-min))
  9452. (if (nnheader-article-p)
  9453. (save-restriction
  9454. (goto-char (point-min))
  9455. (search-forward "\n\n" nil t)
  9456. (narrow-to-region (point-min) (1- (point)))
  9457. (goto-char (point-min))
  9458. (unless (re-search-forward "^date:" nil t)
  9459. (goto-char (point-max))
  9460. (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
  9461. ;; This doesn't look like an article, so we fudge some headers.
  9462. (setq atts (file-attributes file)
  9463. lines (count-lines (point-min) (point-max)))
  9464. (insert "From: " (read-string "From: ") "\n"
  9465. "Subject: " (read-string "Subject: ") "\n"
  9466. "Date: " (message-make-date (nth 5 atts)) "\n"
  9467. "Message-ID: " (message-make-message-id) "\n"
  9468. "Lines: " (int-to-string lines) "\n"
  9469. "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
  9470. (setq group-art (gnus-request-accept-article group nil t))
  9471. (kill-buffer (current-buffer)))
  9472. (setq gnus-newsgroup-active (gnus-activate-group group))
  9473. (forward-line 1)
  9474. (gnus-summary-goto-article (cdr group-art) nil t)
  9475. (when edit
  9476. (gnus-summary-edit-article))))
  9477. (defun gnus-summary-create-article ()
  9478. "Create an article in a mail newsgroup."
  9479. (interactive)
  9480. (let ((group gnus-newsgroup-name)
  9481. (now (current-time))
  9482. group-art)
  9483. (unless (gnus-check-backend-function 'request-accept-article group)
  9484. (error "%s does not support article importing" group))
  9485. (with-current-buffer (gnus-get-buffer-create " *import file*")
  9486. (erase-buffer)
  9487. (goto-char (point-min))
  9488. ;; This doesn't look like an article, so we fudge some headers.
  9489. (insert "From: " (read-string "From: ") "\n"
  9490. "Subject: " (read-string "Subject: ") "\n"
  9491. "Date: " (message-make-date now) "\n"
  9492. "Message-ID: " (message-make-message-id) "\n")
  9493. (setq group-art (gnus-request-accept-article group nil t))
  9494. (kill-buffer (current-buffer)))
  9495. (setq gnus-newsgroup-active (gnus-activate-group group))
  9496. (forward-line 1)
  9497. (gnus-summary-goto-article (cdr group-art) nil t)
  9498. (gnus-summary-edit-article)))
  9499. (defun gnus-summary-article-posted-p ()
  9500. "Say whether the current (mail) article is available from news as well.
  9501. This will be the case if the article has both been mailed and posted."
  9502. (interactive)
  9503. (let ((id (mail-header-references (gnus-summary-article-header)))
  9504. (gnus-override-method (car (gnus-refer-article-methods))))
  9505. (if (gnus-request-head id "")
  9506. (gnus-message 2 "The current message was found on %s"
  9507. gnus-override-method)
  9508. (gnus-message 2 "The current message couldn't be found on %s"
  9509. gnus-override-method)
  9510. nil)))
  9511. (defun gnus-summary-expire-articles (&optional now)
  9512. "Expire all articles that are marked as expirable in the current group."
  9513. (interactive)
  9514. (when (and (not gnus-group-is-exiting-without-update-p)
  9515. (gnus-check-backend-function
  9516. 'request-expire-articles gnus-newsgroup-name))
  9517. ;; This backend supports expiry.
  9518. (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
  9519. (expirable (if total
  9520. (progn
  9521. ;; We need to update the info for
  9522. ;; this group for `gnus-list-of-read-articles'
  9523. ;; to give us the right answer.
  9524. (gnus-run-hooks 'gnus-exit-group-hook)
  9525. (gnus-summary-update-info)
  9526. (gnus-list-of-read-articles gnus-newsgroup-name))
  9527. (setq gnus-newsgroup-expirable
  9528. (sort gnus-newsgroup-expirable '<))))
  9529. (expiry-wait (if now 'immediate
  9530. (gnus-group-find-parameter
  9531. gnus-newsgroup-name 'expiry-wait)))
  9532. (nnmail-expiry-target
  9533. (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
  9534. nnmail-expiry-target))
  9535. es)
  9536. (when expirable
  9537. ;; There are expirable articles in this group, so we run them
  9538. ;; through the expiry process.
  9539. (gnus-message 6 "Expiring articles...")
  9540. (when (gnus-check-group gnus-newsgroup-name)
  9541. ;; The list of articles that weren't expired is returned.
  9542. (save-excursion
  9543. (if expiry-wait
  9544. (let ((nnmail-expiry-wait-function nil)
  9545. (nnmail-expiry-wait expiry-wait))
  9546. (setq es (gnus-request-expire-articles
  9547. expirable gnus-newsgroup-name)))
  9548. (setq es (gnus-request-expire-articles
  9549. expirable gnus-newsgroup-name)))
  9550. (unless total
  9551. (setq gnus-newsgroup-expirable es))
  9552. ;; We go through the old list of expirable, and mark all
  9553. ;; really expired articles as nonexistent.
  9554. (unless (eq es expirable) ;If nothing was expired, we don't mark.
  9555. (let ((gnus-use-cache nil))
  9556. (dolist (article expirable)
  9557. (when (and (not (memq article es))
  9558. (gnus-data-find article))
  9559. (gnus-summary-mark-article article gnus-canceled-mark)
  9560. (run-hook-with-args 'gnus-summary-article-expire-hook
  9561. 'delete
  9562. (gnus-data-header
  9563. (assoc article (gnus-data-list nil)))
  9564. gnus-newsgroup-name
  9565. nil
  9566. nil)))))))
  9567. (gnus-message 6 "Expiring articles...done")))))
  9568. (defun gnus-summary-expire-articles-now ()
  9569. "Expunge all expirable articles in the current group.
  9570. This means that *all* articles that are marked as expirable will be
  9571. deleted forever, right now."
  9572. (interactive)
  9573. (or gnus-expert-user
  9574. (gnus-yes-or-no-p
  9575. "Are you really, really sure you want to delete all expirable messages? ")
  9576. (error "Phew!"))
  9577. (gnus-summary-expire-articles t))
  9578. ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
  9579. (defun gnus-summary-delete-article (&optional n)
  9580. "Delete the N next (mail) articles.
  9581. This command actually deletes articles. This is not a marking
  9582. command. The article will disappear forever from your life, never to
  9583. return.
  9584. If N is negative, delete backwards.
  9585. If N is nil and articles have been marked with the process mark,
  9586. delete these instead.
  9587. If `gnus-novice-user' is non-nil you will be asked for
  9588. confirmation before the articles are deleted."
  9589. (interactive "P")
  9590. (unless (gnus-check-backend-function 'request-expire-articles
  9591. gnus-newsgroup-name)
  9592. (error "The current newsgroup does not support article deletion"))
  9593. (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
  9594. (error "Couldn't open server"))
  9595. ;; Compute the list of articles to delete.
  9596. (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
  9597. (nnmail-expiry-target 'delete)
  9598. not-deleted)
  9599. (if (and gnus-novice-user
  9600. (not (gnus-yes-or-no-p
  9601. (format "Do you really want to delete %s forever? "
  9602. (if (> (length articles) 1)
  9603. (format "these %s articles" (length articles))
  9604. "this article")))))
  9605. ()
  9606. ;; Delete the articles.
  9607. (setq not-deleted (gnus-request-expire-articles
  9608. articles gnus-newsgroup-name 'force))
  9609. (save-excursion
  9610. (while articles
  9611. (gnus-summary-remove-process-mark (car articles))
  9612. ;; The backend might not have been able to delete the article
  9613. ;; after all.
  9614. (unless (memq (car articles) not-deleted)
  9615. (gnus-summary-mark-article (car articles) gnus-canceled-mark)
  9616. (let* ((article (car articles))
  9617. (ghead (gnus-data-header
  9618. (assoc article (gnus-data-list nil)))))
  9619. (run-hook-with-args 'gnus-summary-article-delete-hook
  9620. 'delete ghead gnus-newsgroup-name nil
  9621. nil)))
  9622. (setq articles (cdr articles))))
  9623. (when not-deleted
  9624. (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
  9625. (gnus-summary-position-point)
  9626. (gnus-set-mode-line 'summary)
  9627. not-deleted))
  9628. (defun gnus-summary-edit-article (&optional arg)
  9629. "Edit the current article.
  9630. This will have permanent effect only in mail groups.
  9631. If ARG is nil, edit the decoded articles.
  9632. If ARG is 1, edit the raw articles.
  9633. If ARG is 2, edit the raw articles even in read-only groups.
  9634. If ARG is 3, edit the articles with the current handles.
  9635. Otherwise, allow editing of articles even in read-only
  9636. groups."
  9637. (interactive "P")
  9638. (let (force raw current-handles)
  9639. (cond
  9640. ((null arg))
  9641. ((eq arg 1)
  9642. (setq raw t))
  9643. ((eq arg 2)
  9644. (setq raw t
  9645. force t))
  9646. ((eq arg 3)
  9647. (setq current-handles
  9648. (and (gnus-buffer-live-p gnus-article-buffer)
  9649. (with-current-buffer gnus-article-buffer
  9650. (prog1
  9651. gnus-article-mime-handles
  9652. (setq gnus-article-mime-handles nil))))))
  9653. (t
  9654. (setq force t)))
  9655. (when (and raw (not force)
  9656. (member gnus-newsgroup-name '("nndraft:delayed"
  9657. "nndraft:drafts"
  9658. "nndraft:queue")))
  9659. (error "Can't edit the raw article in group %s"
  9660. gnus-newsgroup-name))
  9661. (with-current-buffer gnus-summary-buffer
  9662. (let ((mail-parse-charset gnus-newsgroup-charset)
  9663. (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
  9664. (gnus-set-global-variables)
  9665. (when (and (not force)
  9666. (gnus-group-read-only-p))
  9667. (error "The current newsgroup does not support article editing"))
  9668. (gnus-summary-show-article t)
  9669. (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
  9670. (with-current-buffer gnus-article-buffer
  9671. (mm-enable-multibyte)))
  9672. (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
  9673. (setq raw t))
  9674. (gnus-article-edit-article
  9675. (if raw 'ignore
  9676. `(lambda ()
  9677. (let ((mbl mml-buffer-list))
  9678. (setq mml-buffer-list nil)
  9679. (let ((rfc2047-quote-decoded-words-containing-tspecials t))
  9680. (mime-to-mml ,'current-handles))
  9681. (let ((mbl1 mml-buffer-list))
  9682. (setq mml-buffer-list mbl)
  9683. (set (make-local-variable 'mml-buffer-list) mbl1))
  9684. (gnus-make-local-hook 'kill-buffer-hook)
  9685. (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
  9686. `(lambda (no-highlight)
  9687. (let ((mail-parse-charset ',gnus-newsgroup-charset)
  9688. (message-options message-options)
  9689. (message-options-set-recipient)
  9690. (mail-parse-ignored-charsets
  9691. ',gnus-newsgroup-ignored-charsets)
  9692. (rfc2047-header-encoding-alist
  9693. ',(let ((charset (gnus-group-name-charset
  9694. (gnus-find-method-for-group
  9695. gnus-newsgroup-name)
  9696. gnus-newsgroup-name)))
  9697. (append (list (cons "Newsgroups" charset)
  9698. (cons "Followup-To" charset)
  9699. (cons "Xref" charset))
  9700. rfc2047-header-encoding-alist))))
  9701. ,(if (not raw) '(progn
  9702. (mml-to-mime)
  9703. (mml-destroy-buffers)
  9704. (remove-hook 'kill-buffer-hook
  9705. 'mml-destroy-buffers t)
  9706. (kill-local-variable 'mml-buffer-list)))
  9707. (gnus-summary-edit-article-done
  9708. ,(or (mail-header-references gnus-current-headers) "")
  9709. ,(gnus-group-read-only-p)
  9710. ,gnus-summary-buffer no-highlight))))))))
  9711. (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
  9712. (defun gnus-summary-edit-article-done (&optional references read-only buffer
  9713. no-highlight)
  9714. "Make edits to the current article permanent."
  9715. (interactive)
  9716. (save-excursion
  9717. ;; The buffer restriction contains the entire article if it exists.
  9718. (when (article-goto-body)
  9719. (let ((lines (count-lines (point) (point-max)))
  9720. (length (- (point-max) (point)))
  9721. (case-fold-search t)
  9722. (body (copy-marker (point))))
  9723. (goto-char (point-min))
  9724. (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
  9725. (delete-region (match-beginning 1) (match-end 1))
  9726. (insert (number-to-string length)))
  9727. (goto-char (point-min))
  9728. (when (re-search-forward
  9729. "^x-content-length:[ \t]\\([0-9]+\\)" body t)
  9730. (delete-region (match-beginning 1) (match-end 1))
  9731. (insert (number-to-string length)))
  9732. (goto-char (point-min))
  9733. (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
  9734. (delete-region (match-beginning 1) (match-end 1))
  9735. (insert (number-to-string lines))))))
  9736. ;; Replace the article.
  9737. (let ((buf (current-buffer))
  9738. (article (cdr gnus-article-current))
  9739. replace-result)
  9740. (with-temp-buffer
  9741. (insert-buffer-substring buf)
  9742. (if (and (not read-only)
  9743. (not (setq replace-result
  9744. (gnus-request-replace-article
  9745. article (car gnus-article-current)
  9746. (current-buffer) t))))
  9747. (error "Couldn't replace article")
  9748. ;; If we got a number back, then that's the new article number
  9749. ;; for this article. Otherwise, the article number didn't change.
  9750. (when (numberp replace-result)
  9751. (with-current-buffer gnus-summary-buffer
  9752. (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
  9753. (gnus-summary-limit gnus-newsgroup-limit)
  9754. (setq article replace-result)
  9755. (gnus-summary-goto-subject article t)))
  9756. ;; Update the summary buffer.
  9757. (if (and references
  9758. (equal (message-tokenize-header references " ")
  9759. (message-tokenize-header
  9760. (or (message-fetch-field "references") "") " ")))
  9761. ;; We only have to update this line.
  9762. (save-excursion
  9763. (save-restriction
  9764. (message-narrow-to-head)
  9765. (let ((head (buffer-substring-no-properties
  9766. (point-min) (point-max)))
  9767. header)
  9768. (with-temp-buffer
  9769. (insert (format "211 %d Article retrieved.\n" article))
  9770. (insert head)
  9771. (insert ".\n")
  9772. (let ((nntp-server-buffer (current-buffer)))
  9773. (setq header (car (gnus-get-newsgroup-headers nil t))))
  9774. (with-current-buffer gnus-summary-buffer
  9775. (gnus-data-set-header (gnus-data-find article) header)
  9776. (gnus-summary-update-article-line article header)
  9777. (if (gnus-summary-goto-subject article nil t)
  9778. (gnus-summary-update-secondary-mark article)))))))
  9779. ;; Update threads.
  9780. (set-buffer (or buffer gnus-summary-buffer))
  9781. (gnus-summary-update-article article)
  9782. (if (gnus-summary-goto-subject article nil t)
  9783. (gnus-summary-update-secondary-mark article)))
  9784. ;; Prettify the article buffer again.
  9785. (unless no-highlight
  9786. (with-current-buffer gnus-article-buffer
  9787. ;;!!! Fix this -- article should be rehighlighted.
  9788. ;;(gnus-run-hooks 'gnus-article-display-hook)
  9789. (set-buffer gnus-original-article-buffer)
  9790. (gnus-request-article
  9791. article (car gnus-article-current) (current-buffer))))
  9792. ;; Prettify the summary buffer line.
  9793. (when (gnus-visual-p 'summary-highlight 'highlight)
  9794. (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
  9795. (defun gnus-summary-edit-wash (key)
  9796. "Perform editing command KEY in the article buffer."
  9797. (interactive
  9798. (list
  9799. (progn
  9800. (message "%s" (concat (this-command-keys) "- "))
  9801. (read-char))))
  9802. (message "")
  9803. (gnus-summary-edit-article)
  9804. (execute-kbd-macro (concat (this-command-keys) key))
  9805. (gnus-article-edit-done))
  9806. ;;; Respooling
  9807. (defun gnus-summary-respool-query (&optional silent trace)
  9808. "Query where the respool algorithm would put this article."
  9809. (interactive)
  9810. (let (gnus-mark-article-hook)
  9811. (gnus-summary-select-article)
  9812. (with-current-buffer gnus-original-article-buffer
  9813. (let ((groups (nnmail-article-group 'identity trace)))
  9814. (unless silent
  9815. (if groups
  9816. (message "This message would go to %s"
  9817. (mapconcat 'car groups ", "))
  9818. (message "This message would go to no groups"))
  9819. groups)))))
  9820. (defun gnus-summary-respool-trace ()
  9821. "Trace where the respool algorithm would put this article.
  9822. Display a buffer showing all fancy splitting patterns which matched."
  9823. (interactive)
  9824. (gnus-summary-respool-query nil t))
  9825. ;; Summary marking commands.
  9826. (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
  9827. "Mark articles which has the same subject as read, and then select the next.
  9828. If UNMARK is positive, remove any kind of mark.
  9829. If UNMARK is negative, tick articles."
  9830. (interactive "P")
  9831. (when unmark
  9832. (setq unmark (prefix-numeric-value unmark)))
  9833. (let ((count
  9834. (gnus-summary-mark-same-subject
  9835. (gnus-summary-article-subject) unmark)))
  9836. ;; Select next unread article. If auto-select-same mode, should
  9837. ;; select the first unread article.
  9838. (gnus-summary-next-article t (and gnus-auto-select-same
  9839. (gnus-summary-article-subject)))
  9840. (gnus-message 7 "%d article%s marked as %s"
  9841. count (if (= count 1) " is" "s are")
  9842. (if unmark "unread" "read"))))
  9843. (defun gnus-summary-kill-same-subject (&optional unmark)
  9844. "Mark articles which has the same subject as read.
  9845. If UNMARK is positive, remove any kind of mark.
  9846. If UNMARK is negative, tick articles."
  9847. (interactive "P")
  9848. (when unmark
  9849. (setq unmark (prefix-numeric-value unmark)))
  9850. (let ((count
  9851. (gnus-summary-mark-same-subject
  9852. (gnus-summary-article-subject) unmark)))
  9853. ;; If marked as read, go to next unread subject.
  9854. (when (null unmark)
  9855. ;; Go to next unread subject.
  9856. (gnus-summary-next-subject 1 t))
  9857. (gnus-message 7 "%d articles are marked as %s"
  9858. count (if unmark "unread" "read"))))
  9859. (defun gnus-summary-mark-same-subject (subject &optional unmark)
  9860. "Mark articles with same SUBJECT as read, and return marked number.
  9861. If optional argument UNMARK is positive, remove any kinds of marks.
  9862. If optional argument UNMARK is negative, mark articles as unread instead."
  9863. (let ((count 1))
  9864. (save-excursion
  9865. (cond
  9866. ((null unmark) ; Mark as read.
  9867. (while (and
  9868. (progn
  9869. (gnus-summary-mark-article-as-read gnus-killed-mark)
  9870. (gnus-summary-show-thread) t)
  9871. (gnus-summary-find-subject subject))
  9872. (setq count (1+ count))))
  9873. ((> unmark 0) ; Tick.
  9874. (while (and
  9875. (progn
  9876. (gnus-summary-mark-article-as-unread gnus-ticked-mark)
  9877. (gnus-summary-show-thread) t)
  9878. (gnus-summary-find-subject subject))
  9879. (setq count (1+ count))))
  9880. (t ; Mark as unread.
  9881. (while (and
  9882. (progn
  9883. (gnus-summary-mark-article-as-unread gnus-unread-mark)
  9884. (gnus-summary-show-thread) t)
  9885. (gnus-summary-find-subject subject))
  9886. (setq count (1+ count)))))
  9887. (gnus-set-mode-line 'summary)
  9888. ;; Return the number of marked articles.
  9889. count)))
  9890. (defun gnus-summary-mark-as-processable (n &optional unmark)
  9891. "Set the process mark on the next N articles.
  9892. If N is negative, mark backward instead. If UNMARK is non-nil, remove
  9893. the process mark instead. The difference between N and the actual
  9894. number of articles marked is returned."
  9895. (interactive "P")
  9896. (if (and (null n) (gnus-region-active-p))
  9897. (gnus-uu-mark-region (region-beginning) (region-end) unmark)
  9898. (setq n (prefix-numeric-value n))
  9899. (let ((backward (< n 0))
  9900. (n (abs n)))
  9901. (while (and
  9902. (> n 0)
  9903. (if unmark
  9904. (gnus-summary-remove-process-mark
  9905. (gnus-summary-article-number))
  9906. (gnus-summary-set-process-mark (gnus-summary-article-number)))
  9907. (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
  9908. (setq n (1- n)))
  9909. (when (/= 0 n)
  9910. (gnus-message 7 "No more articles"))
  9911. (gnus-summary-recenter)
  9912. (gnus-summary-position-point)
  9913. n)))
  9914. (defun gnus-summary-unmark-as-processable (n)
  9915. "Remove the process mark from the next N articles.
  9916. If N is negative, unmark backward instead. The difference between N and
  9917. the actual number of articles unmarked is returned."
  9918. (interactive "P")
  9919. (gnus-summary-mark-as-processable n t))
  9920. (defun gnus-summary-unmark-all-processable ()
  9921. "Remove the process mark from all articles."
  9922. (interactive)
  9923. (save-excursion
  9924. (while gnus-newsgroup-processable
  9925. (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
  9926. (gnus-summary-position-point))
  9927. (defun gnus-summary-add-mark (article type)
  9928. "Mark ARTICLE with a mark of TYPE."
  9929. (let ((vtype (car (assq type gnus-article-mark-lists)))
  9930. var)
  9931. (if (not vtype)
  9932. (error "No such mark type: %s" type)
  9933. (setq var (intern (format "gnus-newsgroup-%s" type)))
  9934. (set var (cons article (symbol-value var)))
  9935. (if (memq type '(processable cached replied forwarded recent saved))
  9936. (gnus-summary-update-secondary-mark article)
  9937. ;;; !!! This is bogus. We should find out what primary
  9938. ;;; !!! mark we want to set.
  9939. (gnus-summary-update-mark gnus-del-mark 'unread)))))
  9940. (defun gnus-summary-mark-as-expirable (n)
  9941. "Mark N articles forward as expirable.
  9942. If N is negative, mark backward instead. The difference between N and
  9943. the actual number of articles marked is returned."
  9944. (interactive "p")
  9945. (gnus-summary-mark-forward n gnus-expirable-mark))
  9946. (defun gnus-summary-mark-as-spam (n)
  9947. "Mark N articles forward as spam.
  9948. If N is negative, mark backward instead. The difference between N and
  9949. the actual number of articles marked is returned."
  9950. (interactive "p")
  9951. (gnus-summary-mark-forward n gnus-spam-mark))
  9952. (defun gnus-summary-mark-article-as-replied (article)
  9953. "Mark ARTICLE as replied to and update the summary line.
  9954. ARTICLE can also be a list of articles."
  9955. (interactive (list (gnus-summary-article-number)))
  9956. (let ((articles (if (listp article) article (list article))))
  9957. (dolist (article articles)
  9958. (unless (numberp article)
  9959. (error "%s is not a number" article))
  9960. (push article gnus-newsgroup-replied)
  9961. (let ((inhibit-read-only t))
  9962. (when (gnus-summary-goto-subject article nil t)
  9963. (gnus-summary-update-secondary-mark article))))))
  9964. (defun gnus-summary-mark-article-as-forwarded (article)
  9965. "Mark ARTICLE as forwarded and update the summary line.
  9966. ARTICLE can also be a list of articles."
  9967. (let ((articles (if (listp article) article (list article))))
  9968. (dolist (article articles)
  9969. (push article gnus-newsgroup-forwarded)
  9970. (let ((inhibit-read-only t))
  9971. (when (gnus-summary-goto-subject article nil t)
  9972. (gnus-summary-update-secondary-mark article))))))
  9973. (defun gnus-summary-set-bookmark (article)
  9974. "Set a bookmark in current article."
  9975. (interactive (list (gnus-summary-article-number)))
  9976. (when (or (not (get-buffer gnus-article-buffer))
  9977. (not gnus-current-article)
  9978. (not gnus-article-current)
  9979. (not (equal gnus-newsgroup-name (car gnus-article-current))))
  9980. (error "No current article selected"))
  9981. ;; Remove old bookmark, if one exists.
  9982. (gnus-alist-pull article gnus-newsgroup-bookmarks)
  9983. ;; Set the new bookmark, which is on the form
  9984. ;; (article-number . line-number-in-body).
  9985. (push
  9986. (cons article
  9987. (with-current-buffer gnus-article-buffer
  9988. (count-lines
  9989. (min (point)
  9990. (save-excursion
  9991. (article-goto-body)
  9992. (point)))
  9993. (point))))
  9994. gnus-newsgroup-bookmarks)
  9995. (gnus-message 6 "A bookmark has been added to the current article."))
  9996. (defun gnus-summary-remove-bookmark (article)
  9997. "Remove the bookmark from the current article."
  9998. (interactive (list (gnus-summary-article-number)))
  9999. ;; Remove old bookmark, if one exists.
  10000. (if (not (assq article gnus-newsgroup-bookmarks))
  10001. (gnus-message 6 "No bookmark in current article.")
  10002. (gnus-alist-pull article gnus-newsgroup-bookmarks)
  10003. (gnus-message 6 "Removed bookmark.")))
  10004. ;; Suggested by Daniel Quinlan <quinlan@best.com>.
  10005. (defun gnus-summary-mark-as-dormant (n)
  10006. "Mark N articles forward as dormant.
  10007. If N is negative, mark backward instead. The difference between N and
  10008. the actual number of articles marked is returned."
  10009. (interactive "p")
  10010. (gnus-summary-mark-forward n gnus-dormant-mark))
  10011. (defun gnus-summary-set-process-mark (article)
  10012. "Set the process mark on ARTICLE and update the summary line."
  10013. (setq gnus-newsgroup-processable
  10014. (cons article
  10015. (delq article gnus-newsgroup-processable)))
  10016. (when (gnus-summary-goto-subject article)
  10017. (gnus-summary-show-thread)
  10018. (gnus-summary-goto-subject article)
  10019. (gnus-summary-update-secondary-mark article)))
  10020. (defun gnus-summary-remove-process-mark (&rest articles)
  10021. "Remove the process mark from ARTICLES and update the summary line."
  10022. (dolist (article articles)
  10023. (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
  10024. (when (gnus-summary-goto-subject article)
  10025. (gnus-summary-show-thread)
  10026. (gnus-summary-goto-subject article)
  10027. (gnus-summary-update-secondary-mark article)))
  10028. t)
  10029. (defun gnus-summary-set-saved-mark (article)
  10030. "Set the process mark on ARTICLE and update the summary line."
  10031. (push article gnus-newsgroup-saved)
  10032. (when (gnus-summary-goto-subject article)
  10033. (gnus-summary-update-secondary-mark article)))
  10034. (defun gnus-summary-mark-forward (n &optional mark no-expire)
  10035. "Mark N articles as read forwards.
  10036. If N is negative, mark backwards instead. Mark with MARK, ?r by default.
  10037. The difference between N and the actual number of articles marked is
  10038. returned.
  10039. If NO-EXPIRE, auto-expiry will be inhibited."
  10040. (interactive "p")
  10041. (gnus-summary-show-thread)
  10042. (let ((backward (< n 0))
  10043. (gnus-summary-goto-unread
  10044. (and gnus-summary-goto-unread
  10045. (not (eq gnus-summary-goto-unread 'never))
  10046. (not (memq mark (list gnus-unread-mark gnus-spam-mark
  10047. gnus-ticked-mark gnus-dormant-mark)))))
  10048. (n (abs n))
  10049. (mark (or mark gnus-del-mark)))
  10050. (while (and (> n 0)
  10051. (gnus-summary-mark-article nil mark no-expire)
  10052. (zerop (gnus-summary-next-subject
  10053. (if backward -1 1)
  10054. (and gnus-summary-goto-unread
  10055. (not (eq gnus-summary-goto-unread 'never)))
  10056. t)))
  10057. (setq n (1- n)))
  10058. (when (/= 0 n)
  10059. (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
  10060. (gnus-summary-recenter)
  10061. (gnus-summary-position-point)
  10062. (gnus-set-mode-line 'summary)
  10063. n))
  10064. (defun gnus-summary-mark-article-as-read (mark)
  10065. "Mark the current article quickly as read with MARK."
  10066. (let ((article (gnus-summary-article-number)))
  10067. (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10068. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
  10069. (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
  10070. (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
  10071. (push (cons article mark) gnus-newsgroup-reads)
  10072. ;; Possibly remove from cache, if that is used.
  10073. (when gnus-use-cache
  10074. (gnus-cache-enter-remove-article article))
  10075. ;; Allow the backend to change the mark.
  10076. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10077. ;; Check for auto-expiry.
  10078. (when (and gnus-newsgroup-auto-expire
  10079. (memq mark gnus-auto-expirable-marks))
  10080. (setq mark gnus-expirable-mark)
  10081. ;; Let the backend know about the mark change.
  10082. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10083. (push article gnus-newsgroup-expirable))
  10084. ;; Set the mark in the buffer.
  10085. (gnus-summary-update-mark mark 'unread)
  10086. t))
  10087. (defun gnus-summary-mark-article-as-unread (mark)
  10088. "Mark the current article quickly as unread with MARK."
  10089. (let* ((article (gnus-summary-article-number))
  10090. (old-mark (gnus-summary-article-mark article)))
  10091. ;; Allow the backend to change the mark.
  10092. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10093. (if (eq mark old-mark)
  10094. t
  10095. (if (<= article 0)
  10096. (progn
  10097. (gnus-error 1 "Can't mark negative article numbers")
  10098. nil)
  10099. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
  10100. (setq gnus-newsgroup-spam-marked
  10101. (delq article gnus-newsgroup-spam-marked))
  10102. (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
  10103. (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
  10104. (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
  10105. (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10106. (cond ((= mark gnus-ticked-mark)
  10107. (setq gnus-newsgroup-marked
  10108. (gnus-add-to-sorted-list gnus-newsgroup-marked
  10109. article)))
  10110. ((= mark gnus-spam-mark)
  10111. (setq gnus-newsgroup-spam-marked
  10112. (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
  10113. article)))
  10114. ((= mark gnus-dormant-mark)
  10115. (setq gnus-newsgroup-dormant
  10116. (gnus-add-to-sorted-list gnus-newsgroup-dormant
  10117. article)))
  10118. (t
  10119. (setq gnus-newsgroup-unreads
  10120. (gnus-add-to-sorted-list gnus-newsgroup-unreads
  10121. article))))
  10122. (gnus-alist-pull article gnus-newsgroup-reads)
  10123. ;; See whether the article is to be put in the cache.
  10124. (and gnus-use-cache
  10125. (vectorp (gnus-summary-article-header article))
  10126. (save-excursion
  10127. (gnus-cache-possibly-enter-article
  10128. gnus-newsgroup-name article
  10129. (= mark gnus-ticked-mark)
  10130. (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
  10131. ;; Fix the mark.
  10132. (gnus-summary-update-mark mark 'unread)
  10133. t))))
  10134. (defun gnus-summary-mark-article (&optional article mark no-expire)
  10135. "Mark ARTICLE with MARK. MARK can be any character.
  10136. Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
  10137. `??' (dormant) and `?E' (expirable).
  10138. If MARK is nil, then the default character `?r' is used.
  10139. If ARTICLE is nil, then the article on the current line will be
  10140. marked.
  10141. If NO-EXPIRE, auto-expiry will be inhibited."
  10142. ;; The mark might be a string.
  10143. (when (stringp mark)
  10144. (setq mark (aref mark 0)))
  10145. ;; If no mark is given, then we check auto-expiring.
  10146. (when (null mark)
  10147. (setq mark gnus-del-mark))
  10148. (when (and (not no-expire)
  10149. gnus-newsgroup-auto-expire
  10150. (memq mark gnus-auto-expirable-marks))
  10151. (setq mark gnus-expirable-mark))
  10152. (let ((article (or article (gnus-summary-article-number)))
  10153. (old-mark (gnus-summary-article-mark article)))
  10154. ;; Allow the backend to change the mark.
  10155. (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
  10156. (if (eq mark old-mark)
  10157. t
  10158. (unless article
  10159. (error "No article on current line"))
  10160. (if (not (if (or (= mark gnus-unread-mark)
  10161. (= mark gnus-ticked-mark)
  10162. (= mark gnus-spam-mark)
  10163. (= mark gnus-dormant-mark))
  10164. (gnus-mark-article-as-unread article mark)
  10165. (gnus-mark-article-as-read article mark)))
  10166. t
  10167. ;; See whether the article is to be put in the cache.
  10168. (and gnus-use-cache
  10169. (not (= mark gnus-canceled-mark))
  10170. (vectorp (gnus-summary-article-header article))
  10171. (save-excursion
  10172. (gnus-cache-possibly-enter-article
  10173. gnus-newsgroup-name article
  10174. (= mark gnus-ticked-mark)
  10175. (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
  10176. (when (gnus-summary-goto-subject article nil t)
  10177. (let ((inhibit-read-only t))
  10178. (gnus-summary-show-thread)
  10179. ;; Fix the mark.
  10180. (gnus-summary-update-mark mark 'unread)
  10181. t))))))
  10182. (defun gnus-summary-update-secondary-mark (article)
  10183. "Update the secondary (read, process, cache) mark."
  10184. (gnus-summary-update-mark
  10185. (cond ((memq article gnus-newsgroup-processable)
  10186. gnus-process-mark)
  10187. ((memq article gnus-newsgroup-cached)
  10188. gnus-cached-mark)
  10189. ((memq article gnus-newsgroup-replied)
  10190. gnus-replied-mark)
  10191. ((memq article gnus-newsgroup-forwarded)
  10192. gnus-forwarded-mark)
  10193. ((memq article gnus-newsgroup-saved)
  10194. gnus-saved-mark)
  10195. ((memq article gnus-newsgroup-unseen)
  10196. gnus-unseen-mark)
  10197. (t gnus-no-mark))
  10198. 'replied)
  10199. (when (gnus-visual-p 'summary-highlight 'highlight)
  10200. (gnus-summary-highlight-line)
  10201. (gnus-run-hooks 'gnus-summary-update-hook))
  10202. t)
  10203. (defun gnus-summary-update-download-mark (article)
  10204. "Update the download mark."
  10205. (gnus-summary-update-mark
  10206. (cond ((memq article gnus-newsgroup-undownloaded)
  10207. gnus-undownloaded-mark)
  10208. (gnus-newsgroup-agentized
  10209. gnus-downloaded-mark)
  10210. (t
  10211. gnus-no-mark))
  10212. 'download)
  10213. (gnus-summary-update-line t)
  10214. t)
  10215. (defun gnus-summary-update-mark (mark type)
  10216. (let ((forward (cdr (assq type gnus-summary-mark-positions)))
  10217. (inhibit-read-only t))
  10218. (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
  10219. (when forward
  10220. (when (looking-at "\r")
  10221. (incf forward))
  10222. (when (<= (+ forward (point)) (point-max))
  10223. ;; Go to the right position on the line.
  10224. (goto-char (+ forward (point)))
  10225. ;; Replace the old mark with the new mark.
  10226. (let ((to-insert
  10227. (mm-subst-char-in-string
  10228. (char-after) mark
  10229. (buffer-substring (point) (1+ (point))))))
  10230. (delete-region (point) (1+ (point)))
  10231. (insert to-insert))
  10232. ;; Optionally update the marks by some user rule.
  10233. (when (eq type 'unread)
  10234. (gnus-data-set-mark
  10235. (gnus-data-find (gnus-summary-article-number)) mark)
  10236. (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
  10237. (defun gnus-mark-article-as-read (article &optional mark)
  10238. "Enter ARTICLE in the pertinent lists and remove it from others."
  10239. ;; Make the article expirable.
  10240. (let ((mark (or mark gnus-del-mark)))
  10241. (setq gnus-newsgroup-expirable
  10242. (if (= mark gnus-expirable-mark)
  10243. (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
  10244. (delq article gnus-newsgroup-expirable)))
  10245. ;; Remove from unread and marked lists.
  10246. (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10247. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
  10248. (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
  10249. (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
  10250. (push (cons article mark) gnus-newsgroup-reads)
  10251. ;; Possibly remove from cache, if that is used.
  10252. (when gnus-use-cache
  10253. (gnus-cache-enter-remove-article article))
  10254. t))
  10255. (defun gnus-mark-article-as-unread (article &optional mark)
  10256. "Enter ARTICLE in the pertinent lists and remove it from others."
  10257. (let ((mark (or mark gnus-ticked-mark)))
  10258. (if (<= article 0)
  10259. (progn
  10260. (gnus-error 1 "Can't mark negative article numbers")
  10261. nil)
  10262. (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
  10263. gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
  10264. gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
  10265. gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
  10266. gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
  10267. ;; Unsuppress duplicates?
  10268. (when gnus-suppress-duplicates
  10269. (gnus-dup-unsuppress-article article))
  10270. (cond ((= mark gnus-ticked-mark)
  10271. (setq gnus-newsgroup-marked
  10272. (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
  10273. ((= mark gnus-spam-mark)
  10274. (setq gnus-newsgroup-spam-marked
  10275. (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
  10276. article)))
  10277. ((= mark gnus-dormant-mark)
  10278. (setq gnus-newsgroup-dormant
  10279. (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
  10280. (t
  10281. (setq gnus-newsgroup-unreads
  10282. (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
  10283. (gnus-alist-pull article gnus-newsgroup-reads)
  10284. t)))
  10285. (defun gnus-summary-tick-article-forward (n)
  10286. "Tick N articles forwards.
  10287. If N is negative, tick backwards instead.
  10288. The difference between N and the number of articles ticked is returned."
  10289. (interactive "p")
  10290. (gnus-summary-mark-forward n gnus-ticked-mark))
  10291. (defun gnus-summary-tick-article-backward (n)
  10292. "Tick N articles backwards.
  10293. The difference between N and the number of articles ticked is returned."
  10294. (interactive "p")
  10295. (gnus-summary-mark-forward (- n) gnus-ticked-mark))
  10296. (defun gnus-summary-tick-article (&optional article clear-mark)
  10297. "Mark current article as unread.
  10298. Optional 1st argument ARTICLE specifies article number to be marked as unread.
  10299. Optional 2nd argument CLEAR-MARK remove any kinds of mark."
  10300. (interactive)
  10301. (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
  10302. gnus-ticked-mark)))
  10303. (defun gnus-summary-mark-as-read-forward (n)
  10304. "Mark N articles as read forwards.
  10305. If N is negative, mark backwards instead.
  10306. The difference between N and the actual number of articles marked is
  10307. returned."
  10308. (interactive "p")
  10309. (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
  10310. (defun gnus-summary-mark-as-read-backward (n)
  10311. "Mark the N articles as read backwards.
  10312. The difference between N and the actual number of articles marked is
  10313. returned."
  10314. (interactive "p")
  10315. (gnus-summary-mark-forward
  10316. (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
  10317. (defun gnus-summary-mark-as-read (&optional article mark)
  10318. "Mark current article as read.
  10319. ARTICLE specifies the article to be marked as read.
  10320. MARK specifies a string to be inserted at the beginning of the line."
  10321. (gnus-summary-mark-article article mark))
  10322. (defun gnus-summary-clear-mark-forward (n)
  10323. "Clear marks from N articles forward.
  10324. If N is negative, clear backward instead.
  10325. The difference between N and the number of marks cleared is returned."
  10326. (interactive "p")
  10327. (gnus-summary-mark-forward n gnus-unread-mark))
  10328. (defun gnus-summary-clear-mark-backward (n)
  10329. "Clear marks from N articles backward.
  10330. The difference between N and the number of marks cleared is returned."
  10331. (interactive "p")
  10332. (gnus-summary-mark-forward (- n) gnus-unread-mark))
  10333. (defun gnus-summary-mark-unread-as-read ()
  10334. "Intended to be used by `gnus-mark-article-hook'."
  10335. (when (memq gnus-current-article gnus-newsgroup-unreads)
  10336. (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
  10337. (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
  10338. "Intended to be used by `gnus-mark-article-hook'."
  10339. (let ((mark (gnus-summary-article-mark)))
  10340. (when (or (gnus-unread-mark-p mark)
  10341. (gnus-read-mark-p mark))
  10342. (gnus-summary-mark-article gnus-current-article
  10343. (or new-mark gnus-read-mark)))))
  10344. (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
  10345. "Intended to be used by `gnus-mark-article-hook'."
  10346. (let ((mark (gnus-summary-article-mark)))
  10347. (when (or (gnus-unread-mark-p mark)
  10348. (gnus-read-mark-p mark))
  10349. (gnus-summary-mark-article (gnus-summary-article-number)
  10350. (or new-mark gnus-read-mark)))))
  10351. (defun gnus-summary-mark-unread-as-ticked ()
  10352. "Intended to be used by `gnus-mark-article-hook'."
  10353. (when (memq gnus-current-article gnus-newsgroup-unreads)
  10354. (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
  10355. (defun gnus-summary-mark-region-as-read (point mark all)
  10356. "Mark all unread articles between point and mark as read.
  10357. If given a prefix, mark all articles between point and mark as read,
  10358. even ticked and dormant ones."
  10359. (interactive "r\nP")
  10360. (save-excursion
  10361. (let (article)
  10362. (goto-char point)
  10363. (beginning-of-line)
  10364. (while (and
  10365. (< (point) mark)
  10366. (progn
  10367. (when (or all
  10368. (memq (setq article (gnus-summary-article-number))
  10369. gnus-newsgroup-unreads))
  10370. (gnus-summary-mark-article article gnus-del-mark))
  10371. t)
  10372. (gnus-summary-find-next))))))
  10373. (defun gnus-summary-mark-below (score mark)
  10374. "Mark articles with score less than SCORE with MARK."
  10375. (interactive "P\ncMark: ")
  10376. (setq score (if score
  10377. (prefix-numeric-value score)
  10378. (or gnus-summary-default-score 0)))
  10379. (with-current-buffer gnus-summary-buffer
  10380. (goto-char (point-min))
  10381. (while
  10382. (progn
  10383. (and (< (gnus-summary-article-score) score)
  10384. (gnus-summary-mark-article nil mark))
  10385. (gnus-summary-find-next)))))
  10386. (defun gnus-summary-kill-below (&optional score)
  10387. "Mark articles with score below SCORE as read."
  10388. (interactive "P")
  10389. (gnus-summary-mark-below score gnus-killed-mark))
  10390. (defun gnus-summary-clear-above (&optional score)
  10391. "Clear all marks from articles with score above SCORE."
  10392. (interactive "P")
  10393. (gnus-summary-mark-above score gnus-unread-mark))
  10394. (defun gnus-summary-tick-above (&optional score)
  10395. "Tick all articles with score above SCORE."
  10396. (interactive "P")
  10397. (gnus-summary-mark-above score gnus-ticked-mark))
  10398. (defun gnus-summary-mark-above (score mark)
  10399. "Mark articles with score over SCORE with MARK."
  10400. (interactive "P\ncMark: ")
  10401. (setq score (if score
  10402. (prefix-numeric-value score)
  10403. (or gnus-summary-default-score 0)))
  10404. (with-current-buffer gnus-summary-buffer
  10405. (goto-char (point-min))
  10406. (while (and (progn
  10407. (when (> (gnus-summary-article-score) score)
  10408. (gnus-summary-mark-article nil mark))
  10409. t)
  10410. (gnus-summary-find-next)))))
  10411. ;; Suggested by Daniel Quinlan <quinlan@best.com>.
  10412. (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
  10413. (defun gnus-summary-limit-include-expunged (&optional no-error)
  10414. "Display all the hidden articles that were expunged for low scores."
  10415. (interactive)
  10416. (let ((inhibit-read-only t))
  10417. (let ((scored gnus-newsgroup-scored)
  10418. headers h)
  10419. (while scored
  10420. (unless (gnus-summary-article-header (caar scored))
  10421. (and (setq h (gnus-number-to-header (caar scored)))
  10422. (< (cdar scored) gnus-summary-expunge-below)
  10423. (push h headers)))
  10424. (setq scored (cdr scored)))
  10425. (if (not headers)
  10426. (when (not no-error)
  10427. (error "No expunged articles hidden"))
  10428. (goto-char (point-min))
  10429. (push gnus-newsgroup-limit gnus-newsgroup-limits)
  10430. (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
  10431. (dolist (x headers)
  10432. (push (mail-header-number x) gnus-newsgroup-limit))
  10433. (gnus-summary-prepare-unthreaded (nreverse headers))
  10434. (goto-char (point-min))
  10435. (gnus-summary-position-point)
  10436. t))))
  10437. (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
  10438. "Mark all unread articles in this newsgroup as read.
  10439. If prefix argument ALL is non-nil, ticked and dormant articles will
  10440. also be marked as read.
  10441. If QUIETLY is non-nil, no questions will be asked.
  10442. If TO-HERE is non-nil, it should be a point in the buffer. All
  10443. articles before (after, if REVERSE is set) this point will be marked
  10444. as read.
  10445. Note that this function will only catch up the unread article
  10446. in the current summary buffer limitation.
  10447. The number of articles marked as read is returned."
  10448. (interactive "P")
  10449. (prog1
  10450. (save-excursion
  10451. (when (or quietly
  10452. (not gnus-interactive-catchup) ;Without confirmation?
  10453. gnus-expert-user
  10454. (gnus-y-or-n-p
  10455. (if all
  10456. "Mark absolutely all articles as read? "
  10457. "Mark all unread articles as read? ")))
  10458. (if (and not-mark
  10459. (not gnus-newsgroup-adaptive)
  10460. (not gnus-newsgroup-auto-expire)
  10461. (not gnus-suppress-duplicates)
  10462. (or (not gnus-use-cache)
  10463. (eq gnus-use-cache 'passive)))
  10464. (progn
  10465. (when all
  10466. (setq gnus-newsgroup-marked nil
  10467. gnus-newsgroup-spam-marked nil
  10468. gnus-newsgroup-dormant nil))
  10469. (setq gnus-newsgroup-unreads
  10470. (gnus-sorted-nunion
  10471. (gnus-sorted-intersection gnus-newsgroup-unreads
  10472. gnus-newsgroup-downloadable)
  10473. (gnus-sorted-difference gnus-newsgroup-unfetched
  10474. gnus-newsgroup-cached))))
  10475. ;; We actually mark all articles as canceled, which we
  10476. ;; have to do when using auto-expiry or adaptive scoring.
  10477. (gnus-summary-show-all-threads)
  10478. (if (and to-here reverse)
  10479. (progn
  10480. (goto-char to-here)
  10481. (gnus-summary-mark-current-read-and-unread-as-read
  10482. gnus-catchup-mark)
  10483. (while (gnus-summary-find-next (not all))
  10484. (gnus-summary-mark-article-as-read gnus-catchup-mark)))
  10485. (when (gnus-summary-first-subject (not all))
  10486. (while (and
  10487. (if to-here (< (point) to-here) t)
  10488. (gnus-summary-mark-article-as-read gnus-catchup-mark)
  10489. (gnus-summary-find-next (not all))))))
  10490. (gnus-set-mode-line 'summary))
  10491. t))
  10492. (gnus-summary-position-point)))
  10493. (defun gnus-summary-catchup-to-here (&optional all)
  10494. "Mark all unticked articles before the current one as read.
  10495. If ALL is non-nil, also mark ticked and dormant articles as read."
  10496. (interactive "P")
  10497. (save-excursion
  10498. (gnus-save-hidden-threads
  10499. (let ((beg (point)))
  10500. ;; We check that there are unread articles.
  10501. (when (or all (gnus-summary-find-prev))
  10502. (gnus-summary-catchup all t beg)))))
  10503. (gnus-summary-position-point))
  10504. (defun gnus-summary-catchup-from-here (&optional all)
  10505. "Mark all unticked articles after (and including) the current one as read.
  10506. If ALL is non-nil, also mark ticked and dormant articles as read."
  10507. (interactive "P")
  10508. (save-excursion
  10509. (gnus-save-hidden-threads
  10510. (let ((beg (point)))
  10511. ;; We check that there are unread articles.
  10512. (when (or all (gnus-summary-find-next))
  10513. (gnus-summary-catchup all t beg nil t)))))
  10514. (gnus-summary-position-point))
  10515. (defun gnus-summary-catchup-all (&optional quietly)
  10516. "Mark all articles in this newsgroup as read.
  10517. This command is dangerous. Normally, you want \\[gnus-summary-catchup]
  10518. instead, which marks only unread articles as read."
  10519. (interactive "P")
  10520. (gnus-summary-catchup t quietly))
  10521. (defun gnus-summary-catchup-and-exit (&optional all quietly)
  10522. "Mark all unread articles in this group as read, then exit.
  10523. If prefix argument ALL is non-nil, all articles are marked as read.
  10524. If QUIETLY is non-nil, no questions will be asked."
  10525. (interactive "P")
  10526. (when (gnus-summary-catchup all quietly nil 'fast)
  10527. ;; Select next newsgroup or exit.
  10528. (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
  10529. (eq gnus-auto-select-next 'quietly))
  10530. (gnus-summary-next-group nil)
  10531. (gnus-summary-exit))))
  10532. (defun gnus-summary-catchup-all-and-exit (&optional quietly)
  10533. "Mark all articles in this newsgroup as read, and then exit.
  10534. This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
  10535. instead, which marks only unread articles as read."
  10536. (interactive "P")
  10537. (gnus-summary-catchup-and-exit t quietly))
  10538. (defun gnus-summary-catchup-and-goto-next-group (&optional all)
  10539. "Mark all articles in this group as read and select the next group.
  10540. If given a prefix, mark all articles, unread as well as ticked, as
  10541. read."
  10542. (interactive "P")
  10543. (save-excursion
  10544. (gnus-summary-catchup all))
  10545. (gnus-summary-next-group))
  10546. (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
  10547. "Mark all articles in this group as read and select the previous group.
  10548. If given a prefix, mark all articles, unread as well as ticked, as
  10549. read."
  10550. (interactive "P")
  10551. (save-excursion
  10552. (gnus-summary-catchup all))
  10553. (gnus-summary-next-group nil nil t))
  10554. ;;;
  10555. ;;; with article
  10556. ;;;
  10557. (defmacro gnus-with-article (article &rest forms)
  10558. "Select ARTICLE and perform FORMS in the original article buffer.
  10559. Then replace the article with the result."
  10560. `(progn
  10561. ;; We don't want the article to be marked as read.
  10562. (let (gnus-mark-article-hook)
  10563. (gnus-summary-select-article t t nil ,article))
  10564. (set-buffer gnus-original-article-buffer)
  10565. ,@forms
  10566. (if (not (gnus-check-backend-function
  10567. 'request-replace-article (car gnus-article-current)))
  10568. (gnus-message 5 "Read-only group; not replacing")
  10569. (unless (gnus-request-replace-article
  10570. ,article (car gnus-article-current)
  10571. (current-buffer) t)
  10572. (error "Couldn't replace article")))
  10573. ;; The cache and backlog have to be flushed somewhat.
  10574. (when gnus-keep-backlog
  10575. (gnus-backlog-remove-article
  10576. (car gnus-article-current) (cdr gnus-article-current)))
  10577. (when gnus-use-cache
  10578. (gnus-cache-update-article
  10579. (car gnus-article-current) (cdr gnus-article-current)))))
  10580. (put 'gnus-with-article 'lisp-indent-function 1)
  10581. (put 'gnus-with-article 'edebug-form-spec '(form body))
  10582. ;; Thread-based commands.
  10583. (defun gnus-summary-articles-in-thread (&optional article)
  10584. "Return a list of all articles in the current thread.
  10585. If ARTICLE is non-nil, return all articles in the thread that starts
  10586. with that article."
  10587. (let* ((article (or article (gnus-summary-article-number)))
  10588. (data (gnus-data-find-list article))
  10589. (top-level (gnus-data-level (car data)))
  10590. (top-subject
  10591. (cond ((null gnus-thread-operation-ignore-subject)
  10592. (gnus-simplify-subject-re
  10593. (mail-header-subject (gnus-data-header (car data)))))
  10594. ((eq gnus-thread-operation-ignore-subject 'fuzzy)
  10595. (gnus-simplify-subject-fuzzy
  10596. (mail-header-subject (gnus-data-header (car data)))))
  10597. (t nil)))
  10598. (end-point (save-excursion
  10599. (goto-char (gnus-data-pos (car data)))
  10600. (if (gnus-summary-go-to-next-thread)
  10601. (point) (point-max))))
  10602. articles)
  10603. (while (and data
  10604. (< (gnus-data-pos (car data)) end-point))
  10605. (when (or (not top-subject)
  10606. (string= top-subject
  10607. (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
  10608. (gnus-simplify-subject-fuzzy
  10609. (mail-header-subject
  10610. (gnus-data-header (car data))))
  10611. (gnus-simplify-subject-re
  10612. (mail-header-subject
  10613. (gnus-data-header (car data)))))))
  10614. (push (gnus-data-number (car data)) articles))
  10615. (unless (and (setq data (cdr data))
  10616. (> (gnus-data-level (car data)) top-level))
  10617. (setq data nil)))
  10618. ;; Return the list of articles.
  10619. (nreverse articles)))
  10620. (defun gnus-summary-rethread-current ()
  10621. "Rethread the thread the current article is part of."
  10622. (interactive)
  10623. (let* ((gnus-show-threads t)
  10624. (article (gnus-summary-article-number))
  10625. (id (mail-header-id (gnus-summary-article-header)))
  10626. (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
  10627. (unless id
  10628. (error "No article on the current line"))
  10629. (gnus-rebuild-thread id)
  10630. (gnus-summary-goto-subject article)))
  10631. (defun gnus-summary-reparent-thread ()
  10632. "Make the current article child of the marked (or previous) article.
  10633. Note that the re-threading will only work if `gnus-thread-ignore-subject'
  10634. is non-nil or the Subject: of both articles are the same."
  10635. (interactive)
  10636. (unless (not (gnus-group-read-only-p))
  10637. (error "The current newsgroup does not support article editing"))
  10638. (unless (<= (length gnus-newsgroup-processable) 1)
  10639. (error "No more than one article may be marked"))
  10640. (let ((child (gnus-summary-article-number))
  10641. ;; First grab the marked article, otherwise one line up.
  10642. (parent (if (not (null gnus-newsgroup-processable))
  10643. (car gnus-newsgroup-processable)
  10644. (save-excursion
  10645. (if (eq (forward-line -1) 0)
  10646. (gnus-summary-article-number)
  10647. (error "Beginning of summary buffer"))))))
  10648. (gnus-summary-reparent-children parent (list child))))
  10649. (defun gnus-summary-reparent-children (parent children)
  10650. "Make PARENT the parent of CHILDREN.
  10651. When called interactively, PARENT is the current article and CHILDREN
  10652. are the process-marked articles."
  10653. (interactive
  10654. (list (gnus-summary-article-number)
  10655. (gnus-summary-work-articles nil)))
  10656. (dolist (child children)
  10657. (save-window-excursion
  10658. (let ((gnus-article-buffer " *reparent*"))
  10659. (unless (not (eq parent child))
  10660. (error "An article may not be self-referential"))
  10661. (let ((message-id (mail-header-id
  10662. (gnus-summary-article-header parent))))
  10663. (unless (and message-id (not (equal message-id "")))
  10664. (error "No message-id in desired parent"))
  10665. (gnus-with-article child
  10666. (save-restriction
  10667. (goto-char (point-min))
  10668. (message-narrow-to-head)
  10669. (if (re-search-forward "^References: " nil t)
  10670. (progn
  10671. (re-search-forward "^[^ \t]" nil t)
  10672. (forward-line -1)
  10673. (end-of-line)
  10674. (insert " " message-id))
  10675. (insert "References: " message-id "\n"))))
  10676. (set-buffer gnus-summary-buffer)
  10677. (gnus-summary-unmark-all-processable)
  10678. (gnus-summary-update-article child)
  10679. (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
  10680. (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
  10681. (gnus-summary-rethread-current)
  10682. (gnus-message 3 "Article %d is now the child of article %d"
  10683. child parent))))))
  10684. (defun gnus-summary-toggle-threads (&optional arg)
  10685. "Toggle showing conversation threads.
  10686. If ARG is positive number, turn showing conversation threads on."
  10687. (interactive "P")
  10688. (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
  10689. (setq gnus-show-threads
  10690. (if (null arg) (not gnus-show-threads)
  10691. (> (prefix-numeric-value arg) 0)))
  10692. (gnus-summary-prepare)
  10693. (gnus-summary-goto-subject current)
  10694. (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
  10695. (gnus-summary-position-point)))
  10696. (eval-and-compile
  10697. (if (fboundp 'remove-overlays)
  10698. (defalias 'gnus-remove-overlays 'remove-overlays)
  10699. (defun gnus-remove-overlays (beg end name val)
  10700. "Clear BEG and END of overlays whose property NAME has value VAL.
  10701. For compatibility with XEmacs."
  10702. (dolist (ov (gnus-overlays-in beg end))
  10703. (when (eq (gnus-overlay-get ov name) val)
  10704. (gnus-delete-overlay ov))))))
  10705. (defun gnus-summary-show-all-threads ()
  10706. "Show all threads."
  10707. (interactive)
  10708. (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
  10709. (gnus-summary-position-point))
  10710. (defsubst gnus-summary--inv (p)
  10711. (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
  10712. (defun gnus-summary-show-thread ()
  10713. "Show thread subtrees.
  10714. Returns nil if no thread was there to be shown."
  10715. (interactive)
  10716. (let* ((orig (point))
  10717. (end (point-at-eol))
  10718. (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
  10719. ;; Leave point at bol
  10720. (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
  10721. (eoi (when end
  10722. (if (fboundp 'next-single-char-property-change)
  10723. ;; Note: XEmacs version of n-s-c-p-c may return nil
  10724. (or (next-single-char-property-change end 'invisible)
  10725. (point-max))
  10726. (while (progn
  10727. (end-of-line 2)
  10728. (and (not (eobp))
  10729. (eq (get-char-property (point) 'invisible)
  10730. 'gnus-sum))))
  10731. (point)))))
  10732. (when eoi
  10733. (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
  10734. (goto-char orig)
  10735. (gnus-summary-position-point)
  10736. eoi)))
  10737. (defun gnus-summary-maybe-hide-threads ()
  10738. "If requested, hide the threads that should be hidden."
  10739. (when (and gnus-show-threads
  10740. gnus-thread-hide-subtree)
  10741. (gnus-summary-hide-all-threads
  10742. (if (or (consp gnus-thread-hide-subtree)
  10743. (functionp gnus-thread-hide-subtree))
  10744. (gnus-make-predicate gnus-thread-hide-subtree)
  10745. nil))))
  10746. ;;; Hiding predicates.
  10747. (defun gnus-article-unread-p (header)
  10748. (memq (mail-header-number header) gnus-newsgroup-unreads))
  10749. (defun gnus-article-unseen-p (header)
  10750. (memq (mail-header-number header) gnus-newsgroup-unseen))
  10751. (defun gnus-map-articles (predicate articles)
  10752. "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
  10753. (apply 'gnus-or (mapcar predicate
  10754. (mapcar (lambda (number)
  10755. (gnus-summary-article-header number))
  10756. articles))))
  10757. (defun gnus-summary-hide-all-threads (&optional predicate)
  10758. "Hide all thread subtrees.
  10759. If PREDICATE is supplied, threads that satisfy this predicate
  10760. will not be hidden."
  10761. (interactive)
  10762. (save-excursion
  10763. (goto-char (point-min))
  10764. (let ((end nil)
  10765. (count 0))
  10766. (while (not end)
  10767. (incf count)
  10768. (when (zerop (mod count 1000))
  10769. (message "Hiding all threads... %d" count))
  10770. (when (or (not predicate)
  10771. (gnus-map-articles
  10772. predicate (gnus-summary-article-children)))
  10773. (gnus-summary-hide-thread))
  10774. (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
  10775. (gnus-summary-position-point))
  10776. (defun gnus-summary-hide-thread ()
  10777. "Hide thread subtrees.
  10778. If PREDICATE is supplied, threads that satisfy this predicate
  10779. will not be hidden.
  10780. Returns nil if no threads were there to be hidden."
  10781. (interactive)
  10782. (let ((start (point))
  10783. (starteol (line-end-position))
  10784. (article (gnus-summary-article-number)))
  10785. (goto-char start)
  10786. ;; Go forward until either the buffer ends or the subthread ends.
  10787. (when (and (not (eobp))
  10788. (or (zerop (gnus-summary-next-thread 1 t))
  10789. (goto-char (point-max))))
  10790. (if (and (> (point) start)
  10791. ;; FIXME: this should actually search for a non-invisible \n.
  10792. (search-backward "\n" start t))
  10793. (progn
  10794. (when (> (point) starteol)
  10795. (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
  10796. (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
  10797. (gnus-overlay-put ol 'invisible 'gnus-sum)
  10798. (gnus-overlay-put ol 'evaporate t)))
  10799. (gnus-summary-goto-subject article)
  10800. (when (> start (point))
  10801. (message "Hiding the thread moved us backwards, aborting!")
  10802. (goto-char (point-max))))
  10803. (goto-char start)
  10804. nil))))
  10805. (defun gnus-summary-go-to-next-thread (&optional previous)
  10806. "Go to the same level (or less) next thread.
  10807. If PREVIOUS is non-nil, go to previous thread instead.
  10808. Return the article number moved to, or nil if moving was impossible."
  10809. (let ((level (gnus-summary-thread-level))
  10810. (way (if previous -1 1))
  10811. (beg (point)))
  10812. (forward-line way)
  10813. (while (and (not (eobp))
  10814. (< level (gnus-summary-thread-level)))
  10815. (forward-line way))
  10816. (if (eobp)
  10817. (progn
  10818. (goto-char beg)
  10819. nil)
  10820. (setq beg (point))
  10821. (prog1
  10822. (gnus-summary-article-number)
  10823. (goto-char beg)))))
  10824. (defun gnus-summary-next-thread (n &optional silent)
  10825. "Go to the same level next N'th thread.
  10826. If N is negative, search backward instead.
  10827. Returns the difference between N and the number of skips actually
  10828. done.
  10829. If SILENT, don't output messages."
  10830. (interactive "p")
  10831. (let ((backward (< n 0))
  10832. (n (abs n)))
  10833. (while (and (> n 0)
  10834. (gnus-summary-go-to-next-thread backward))
  10835. (decf n))
  10836. (unless silent
  10837. (gnus-summary-position-point))
  10838. (when (and (not silent) (/= 0 n))
  10839. (gnus-message 7 "No more threads"))
  10840. n))
  10841. (defun gnus-summary-prev-thread (n)
  10842. "Go to the same level previous N'th thread.
  10843. Returns the difference between N and the number of skips actually
  10844. done."
  10845. (interactive "p")
  10846. (gnus-summary-next-thread (- n)))
  10847. (defun gnus-summary-go-down-thread ()
  10848. "Go down one level in the current thread."
  10849. (let ((children (gnus-summary-article-children)))
  10850. (when children
  10851. (gnus-summary-goto-subject (car children)))))
  10852. (defun gnus-summary-go-up-thread ()
  10853. "Go up one level in the current thread."
  10854. (let ((parent (gnus-summary-article-parent)))
  10855. (when parent
  10856. (gnus-summary-goto-subject parent))))
  10857. (defun gnus-summary-down-thread (n)
  10858. "Go down thread N steps.
  10859. If N is negative, go up instead.
  10860. Returns the difference between N and how many steps down that were
  10861. taken."
  10862. (interactive "p")
  10863. (let ((up (< n 0))
  10864. (n (abs n)))
  10865. (while (and (> n 0)
  10866. (if up (gnus-summary-go-up-thread)
  10867. (gnus-summary-go-down-thread)))
  10868. (setq n (1- n)))
  10869. (gnus-summary-position-point)
  10870. (when (/= 0 n)
  10871. (gnus-message 7 "Can't go further"))
  10872. n))
  10873. (defun gnus-summary-up-thread (n)
  10874. "Go up thread N steps.
  10875. If N is negative, go down instead.
  10876. Returns the difference between N and how many steps down that were
  10877. taken."
  10878. (interactive "p")
  10879. (gnus-summary-down-thread (- n)))
  10880. (defun gnus-summary-top-thread ()
  10881. "Go to the top of the thread."
  10882. (interactive)
  10883. (while (gnus-summary-go-up-thread))
  10884. (gnus-summary-article-number))
  10885. (defun gnus-summary-expire-thread ()
  10886. "Mark articles under current thread as expired."
  10887. (interactive)
  10888. (gnus-summary-kill-thread 0))
  10889. (defun gnus-summary-kill-thread (&optional unmark)
  10890. "Mark articles under current thread as read.
  10891. If the prefix argument is positive, remove any kinds of marks.
  10892. If the prefix argument is zero, mark thread as expired.
  10893. If the prefix argument is negative, tick articles instead."
  10894. (interactive "P")
  10895. (when unmark
  10896. (setq unmark (prefix-numeric-value unmark)))
  10897. (let ((articles (gnus-summary-articles-in-thread))
  10898. (hide (or (null unmark) (= unmark 0))))
  10899. (save-excursion
  10900. ;; Expand the thread.
  10901. (gnus-summary-show-thread)
  10902. ;; Mark all the articles.
  10903. (while articles
  10904. (gnus-summary-goto-subject (car articles))
  10905. (cond ((null unmark)
  10906. (gnus-summary-mark-article-as-read gnus-killed-mark))
  10907. ((> unmark 0)
  10908. (gnus-summary-mark-article-as-unread gnus-unread-mark))
  10909. ((= unmark 0)
  10910. (gnus-summary-mark-article nil gnus-expirable-mark))
  10911. (t
  10912. (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
  10913. (setq articles (cdr articles))))
  10914. ;; Hide killed subtrees when hide is true.
  10915. (and hide
  10916. gnus-thread-hide-killed
  10917. (gnus-summary-hide-thread))
  10918. ;; If hide is t, go to next unread subject.
  10919. (when hide
  10920. ;; Go to next unread subject.
  10921. (gnus-summary-next-subject 1 t)))
  10922. (gnus-set-mode-line 'summary))
  10923. ;; Summary sorting commands
  10924. (defun gnus-summary-sort-by-number (&optional reverse)
  10925. "Sort the summary buffer by article number.
  10926. Argument REVERSE means reverse order."
  10927. (interactive "P")
  10928. (gnus-summary-sort 'number reverse))
  10929. (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
  10930. "Sort the summary buffer by most recent article number.
  10931. Argument REVERSE means reverse order."
  10932. (interactive "P")
  10933. (gnus-summary-sort 'most-recent-number reverse))
  10934. (defun gnus-summary-sort-by-random (&optional reverse)
  10935. "Randomize the order in the summary buffer.
  10936. Argument REVERSE means to randomize in reverse order."
  10937. (interactive "P")
  10938. (gnus-summary-sort 'random reverse))
  10939. (defun gnus-summary-sort-by-author (&optional reverse)
  10940. "Sort the summary buffer by author name alphabetically.
  10941. If `case-fold-search' is non-nil, case of letters is ignored.
  10942. Argument REVERSE means reverse order."
  10943. (interactive "P")
  10944. (gnus-summary-sort 'author reverse))
  10945. (defun gnus-summary-sort-by-recipient (&optional reverse)
  10946. "Sort the summary buffer by recipient name alphabetically.
  10947. If `case-fold-search' is non-nil, case of letters is ignored.
  10948. Argument REVERSE means reverse order."
  10949. (interactive "P")
  10950. (gnus-summary-sort 'recipient reverse))
  10951. (defun gnus-summary-sort-by-subject (&optional reverse)
  10952. "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
  10953. If `case-fold-search' is non-nil, case of letters is ignored.
  10954. Argument REVERSE means reverse order."
  10955. (interactive "P")
  10956. (gnus-summary-sort 'subject reverse))
  10957. (defun gnus-summary-sort-by-date (&optional reverse)
  10958. "Sort the summary buffer by date.
  10959. Argument REVERSE means reverse order."
  10960. (interactive "P")
  10961. (gnus-summary-sort 'date reverse))
  10962. (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
  10963. "Sort the summary buffer by most recent date.
  10964. Argument REVERSE means reverse order."
  10965. (interactive "P")
  10966. (gnus-summary-sort 'most-recent-date reverse))
  10967. (defun gnus-summary-sort-by-score (&optional reverse)
  10968. "Sort the summary buffer by score.
  10969. Argument REVERSE means reverse order."
  10970. (interactive "P")
  10971. (gnus-summary-sort 'score reverse))
  10972. (defun gnus-summary-sort-by-lines (&optional reverse)
  10973. "Sort the summary buffer by the number of lines.
  10974. Argument REVERSE means reverse order."
  10975. (interactive "P")
  10976. (gnus-summary-sort 'lines reverse))
  10977. (defun gnus-summary-sort-by-chars (&optional reverse)
  10978. "Sort the summary buffer by article length.
  10979. Argument REVERSE means reverse order."
  10980. (interactive "P")
  10981. (gnus-summary-sort 'chars reverse))
  10982. (defun gnus-summary-sort-by-original (&optional reverse)
  10983. "Sort the summary buffer using the default sorting method.
  10984. Argument REVERSE means reverse order."
  10985. (interactive "P")
  10986. (let* ((inhibit-read-only t)
  10987. (gnus-summary-prepare-hook nil))
  10988. ;; We do the sorting by regenerating the threads.
  10989. (gnus-summary-prepare)
  10990. ;; Hide subthreads if needed.
  10991. (gnus-summary-maybe-hide-threads)))
  10992. (defun gnus-summary-sort (predicate reverse)
  10993. "Sort summary buffer by PREDICATE. REVERSE means reverse order."
  10994. (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
  10995. (article (intern (format "gnus-article-sort-by-%s" predicate)))
  10996. (gnus-thread-sort-functions
  10997. (if (not reverse)
  10998. thread
  10999. `(lambda (t1 t2)
  11000. (,thread t2 t1))))
  11001. (gnus-sort-gathered-threads-function
  11002. gnus-thread-sort-functions)
  11003. (gnus-article-sort-functions
  11004. (if (not reverse)
  11005. article
  11006. `(lambda (t1 t2)
  11007. (,article t2 t1))))
  11008. (inhibit-read-only t)
  11009. (gnus-summary-prepare-hook nil))
  11010. ;; We do the sorting by regenerating the threads.
  11011. (gnus-summary-prepare)
  11012. ;; Hide subthreads if needed.
  11013. (gnus-summary-maybe-hide-threads)))
  11014. ;; Summary saving commands.
  11015. (defun gnus-summary-save-article (&optional n not-saved)
  11016. "Save the current article using the default saver function.
  11017. If N is a positive number, save the N next articles.
  11018. If N is a negative number, save the N previous articles.
  11019. If N is nil and any articles have been marked with the process mark,
  11020. save those articles instead.
  11021. The variable `gnus-default-article-saver' specifies the saver function.
  11022. If the optional second argument NOT-SAVED is non-nil, articles saved
  11023. will not be marked as saved."
  11024. (interactive "P")
  11025. (require 'gnus-art)
  11026. (let* ((articles (gnus-summary-work-articles n))
  11027. (save-buffer (save-excursion
  11028. (nnheader-set-temp-buffer " *Gnus Save*")))
  11029. (num (length articles))
  11030. ;; Whether to save decoded articles or raw articles.
  11031. (decode (when gnus-article-save-coding-system
  11032. (get gnus-default-article-saver :decode)))
  11033. ;; When saving many articles in a single file, use the other
  11034. ;; function to save articles other than the first one.
  11035. (saver2 (get gnus-default-article-saver :function))
  11036. (gnus-prompt-before-saving (if saver2
  11037. t
  11038. gnus-prompt-before-saving))
  11039. (gnus-default-article-saver gnus-default-article-saver)
  11040. header file)
  11041. (dolist (article articles)
  11042. (setq header (gnus-summary-article-header article))
  11043. (if (not (vectorp header))
  11044. ;; This is a pseudo-article.
  11045. (if (assq 'name header)
  11046. (gnus-copy-file (cdr (assq 'name header)))
  11047. (gnus-message 1 "Article %d is unsavable" article))
  11048. ;; This is a real article.
  11049. (save-window-excursion
  11050. (gnus-summary-select-article decode decode nil article)
  11051. (gnus-summary-goto-subject article))
  11052. (with-current-buffer save-buffer
  11053. (erase-buffer)
  11054. (insert-buffer-substring (if decode
  11055. gnus-article-buffer
  11056. gnus-original-article-buffer)))
  11057. (setq file (gnus-article-save save-buffer file num))
  11058. (gnus-summary-remove-process-mark article)
  11059. (unless not-saved
  11060. (gnus-summary-set-saved-mark article)))
  11061. (when saver2
  11062. (setq gnus-default-article-saver saver2
  11063. saver2 nil)))
  11064. (gnus-kill-buffer save-buffer)
  11065. (gnus-summary-position-point)
  11066. (gnus-set-mode-line 'summary)
  11067. n))
  11068. (defun gnus-summary-pipe-output (&optional n sym)
  11069. "Pipe the current article to a subprocess.
  11070. If N is a positive number, pipe the N next articles.
  11071. If N is a negative number, pipe the N previous articles.
  11072. If N is nil and any articles have been marked with the process mark,
  11073. pipe those articles instead.
  11074. The default command to which articles are piped is specified by the
  11075. variable `gnus-summary-pipe-output-default-command'; if it is nil, you
  11076. will be prompted for the command.
  11077. The properties `:decode' and `:headers' that are put to the function
  11078. symbol `gnus-summary-save-in-pipe' control whether this function
  11079. decodes articles and what headers to keep (see the doc string for the
  11080. `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
  11081. is neither omitted nor the symbol `r', force including all headers
  11082. regardless of the `:headers' property. If it is the symbol `r',
  11083. articles that are not decoded and include all headers will be piped
  11084. no matter what the properties `:decode' and `:headers' are."
  11085. (interactive (gnus-interactive "P\ny"))
  11086. (require 'gnus-art)
  11087. (let* ((articles (gnus-summary-work-articles n))
  11088. (result-buffer "*Shell Command Output*")
  11089. (all-headers (not (memq sym '(nil r))))
  11090. (gnus-save-all-headers (or all-headers gnus-save-all-headers))
  11091. (raw (eq sym 'r))
  11092. (headers (get 'gnus-summary-save-in-pipe :headers))
  11093. command result)
  11094. (unless (numberp (car articles))
  11095. (error "No article to pipe"))
  11096. (setq command (gnus-read-shell-command
  11097. (concat "Shell command on "
  11098. (if (cdr articles)
  11099. (format "these %d articles" (length articles))
  11100. "this article")
  11101. ": ")
  11102. gnus-summary-pipe-output-default-command))
  11103. (when (string-equal command "")
  11104. (error "A command is required"))
  11105. (when all-headers
  11106. (put 'gnus-summary-save-in-pipe :headers nil))
  11107. (unwind-protect
  11108. (while articles
  11109. (gnus-summary-goto-subject (pop articles))
  11110. (save-window-excursion (gnus-summary-save-in-pipe command raw))
  11111. (when (and (get-buffer result-buffer)
  11112. (not (zerop (buffer-size (get-buffer result-buffer)))))
  11113. (setq result (concat result (with-current-buffer result-buffer
  11114. (buffer-string))))))
  11115. (put 'gnus-summary-save-in-pipe :headers headers))
  11116. (unless (zerop (length result))
  11117. (if (with-current-buffer (get-buffer-create result-buffer)
  11118. (erase-buffer)
  11119. (insert result)
  11120. (prog1
  11121. (and (= (count-lines (point-min) (point)) 1)
  11122. (progn
  11123. (end-of-line 0)
  11124. (<= (current-column)
  11125. (window-width (minibuffer-window)))))
  11126. (goto-char (point-min))))
  11127. (message "%s" (substring result 0 -1))
  11128. (message nil)
  11129. (gnus-configure-windows 'pipe)))))
  11130. (defun gnus-summary-save-article-mail (&optional arg)
  11131. "Append the current article to a Unix mail box file.
  11132. If N is a positive number, save the N next articles.
  11133. If N is a negative number, save the N previous articles.
  11134. If N is nil and any articles have been marked with the process mark,
  11135. save those articles instead."
  11136. (interactive "P")
  11137. (require 'gnus-art)
  11138. (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
  11139. (gnus-summary-save-article arg)))
  11140. (defun gnus-summary-save-article-rmail (&optional arg)
  11141. "Append the current article to an rmail file.
  11142. If N is a positive number, save the N next articles.
  11143. If N is a negative number, save the N previous articles.
  11144. If N is nil and any articles have been marked with the process mark,
  11145. save those articles instead."
  11146. (interactive "P")
  11147. (require 'gnus-art)
  11148. (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
  11149. (gnus-summary-save-article arg)))
  11150. (defun gnus-summary-save-article-file (&optional arg)
  11151. "Append the current article to a file.
  11152. If N is a positive number, save the N next articles.
  11153. If N is a negative number, save the N previous articles.
  11154. If N is nil and any articles have been marked with the process mark,
  11155. save those articles instead."
  11156. (interactive "P")
  11157. (require 'gnus-art)
  11158. (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
  11159. (gnus-summary-save-article arg)))
  11160. (defun gnus-summary-write-article-file (&optional arg)
  11161. "Write the current article to a file, deleting the previous file.
  11162. If N is a positive number, save the N next articles.
  11163. If N is a negative number, save the N previous articles.
  11164. If N is nil and any articles have been marked with the process mark,
  11165. save those articles instead."
  11166. (interactive "P")
  11167. (require 'gnus-art)
  11168. (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
  11169. (gnus-summary-save-article arg)))
  11170. (defun gnus-summary-save-article-body-file (&optional arg)
  11171. "Append the current article body to a file.
  11172. If N is a positive number, save the N next articles.
  11173. If N is a negative number, save the N previous articles.
  11174. If N is nil and any articles have been marked with the process mark,
  11175. save those articles instead."
  11176. (interactive "P")
  11177. (require 'gnus-art)
  11178. (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
  11179. (gnus-summary-save-article arg)))
  11180. (defun gnus-summary-write-article-body-file (&optional arg)
  11181. "Write the current article body to a file, deleting the previous file.
  11182. If N is a positive number, save the N next articles.
  11183. If N is a negative number, save the N previous articles.
  11184. If N is nil and any articles have been marked with the process mark,
  11185. save those articles instead."
  11186. (interactive "P")
  11187. (require 'gnus-art)
  11188. (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
  11189. (gnus-summary-save-article arg)))
  11190. (defun gnus-summary-muttprint (&optional arg)
  11191. "Print the current article using Muttprint.
  11192. If N is a positive number, save the N next articles.
  11193. If N is a negative number, save the N previous articles.
  11194. If N is nil and any articles have been marked with the process mark,
  11195. save those articles instead."
  11196. (interactive "P")
  11197. (require 'gnus-art)
  11198. (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
  11199. (gnus-summary-save-article arg t)))
  11200. (defun gnus-summary-pipe-message (program)
  11201. "Pipe the current article through PROGRAM."
  11202. (interactive "sProgram: ")
  11203. (gnus-summary-select-article)
  11204. (let ((mail-header-separator ""))
  11205. (gnus-eval-in-buffer-window gnus-article-buffer
  11206. (save-restriction
  11207. (widen)
  11208. (let ((start (window-start))
  11209. (inhibit-read-only t))
  11210. (message-pipe-buffer-body program)
  11211. (set-window-start (get-buffer-window (current-buffer)) start))))))
  11212. (defun gnus-get-split-value (methods)
  11213. "Return a value based on the split METHODS."
  11214. (let (split-name method result match)
  11215. (when methods
  11216. (with-current-buffer gnus-original-article-buffer
  11217. (save-restriction
  11218. (nnheader-narrow-to-headers)
  11219. (while (and methods (not split-name))
  11220. (goto-char (point-min))
  11221. (setq method (pop methods))
  11222. (setq match (car method))
  11223. (when (cond
  11224. ((stringp match)
  11225. ;; Regular expression.
  11226. (ignore-errors
  11227. (re-search-forward match nil t)))
  11228. ((functionp match)
  11229. ;; Function.
  11230. (save-restriction
  11231. (widen)
  11232. (setq result (funcall match gnus-newsgroup-name))))
  11233. ((consp match)
  11234. ;; Form.
  11235. (save-restriction
  11236. (widen)
  11237. (setq result (eval match)))))
  11238. (setq split-name (cdr method))
  11239. (cond ((stringp result)
  11240. (push (expand-file-name
  11241. result gnus-article-save-directory)
  11242. split-name))
  11243. ((consp result)
  11244. (setq split-name (append result split-name)))))))))
  11245. (nreverse split-name)))
  11246. (defun gnus-valid-move-group-p (group)
  11247. (and (symbolp group)
  11248. (boundp group)
  11249. (symbol-name group)
  11250. (symbol-value group)
  11251. (gnus-get-function (gnus-find-method-for-group
  11252. (symbol-name group)) 'request-accept-article t)))
  11253. (defun gnus-read-move-group-name (prompt default articles prefix)
  11254. "Read a group name."
  11255. (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
  11256. (minibuffer-confirm-incomplete nil) ; XEmacs
  11257. (prom
  11258. (format "%s %s to"
  11259. prompt
  11260. (if (> (length articles) 1)
  11261. (format "these %d articles" (length articles))
  11262. "this article")))
  11263. (to-newsgroup
  11264. (cond
  11265. ((null split-name)
  11266. (gnus-group-completing-read
  11267. prom
  11268. (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
  11269. nil prefix nil default))
  11270. ((= 1 (length split-name))
  11271. (gnus-group-completing-read
  11272. prom
  11273. (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
  11274. nil prefix 'gnus-group-history (car split-name)))
  11275. (t
  11276. (gnus-completing-read
  11277. prom (nreverse split-name) nil nil 'gnus-group-history))))
  11278. (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
  11279. encoded)
  11280. (when to-newsgroup
  11281. (if (or (string= to-newsgroup "")
  11282. (string= to-newsgroup prefix))
  11283. (setq to-newsgroup default))
  11284. (unless to-newsgroup
  11285. (error "No group name entered"))
  11286. (setq encoded (mm-encode-coding-string
  11287. to-newsgroup
  11288. (gnus-group-name-charset to-method to-newsgroup)))
  11289. (or (gnus-active encoded)
  11290. (gnus-activate-group encoded nil nil to-method)
  11291. (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
  11292. to-newsgroup))
  11293. (or (and (gnus-request-create-group encoded to-method)
  11294. (gnus-activate-group encoded nil nil to-method)
  11295. (gnus-subscribe-group encoded))
  11296. (error "Couldn't create group %s" to-newsgroup)))
  11297. (error "No such group: %s" to-newsgroup))
  11298. encoded)))
  11299. (defvar gnus-summary-save-parts-counter)
  11300. (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
  11301. (defun gnus-summary-save-parts (type dir n &optional reverse)
  11302. "Save parts matching TYPE to DIR.
  11303. If REVERSE, save parts that do not match TYPE."
  11304. (interactive
  11305. (list (read-string "Save parts of type: "
  11306. (or (car gnus-summary-save-parts-type-history)
  11307. gnus-summary-save-parts-default-mime)
  11308. 'gnus-summary-save-parts-type-history)
  11309. (setq gnus-summary-save-parts-last-directory
  11310. (read-directory-name "Save to directory: "
  11311. gnus-summary-save-parts-last-directory
  11312. nil t))
  11313. current-prefix-arg))
  11314. (gnus-summary-iterate n
  11315. (let ((gnus-display-mime-function nil)
  11316. gnus-article-prepare-hook
  11317. gnus-article-decode-hook
  11318. gnus-display-mime-function
  11319. gnus-break-pages
  11320. (gnus-inhibit-treatment t))
  11321. (gnus-summary-select-article))
  11322. (with-current-buffer gnus-article-buffer
  11323. (let ((handles (or gnus-article-mime-handles
  11324. (mm-dissect-buffer nil gnus-article-loose-mime)
  11325. (and gnus-article-emulate-mime
  11326. (mm-uu-dissect))))
  11327. (gnus-summary-save-parts-counter 1))
  11328. (when handles
  11329. (gnus-summary-save-parts-1 type dir handles reverse)
  11330. (unless gnus-article-mime-handles ;; Don't destroy this case.
  11331. (mm-destroy-parts handles)))))))
  11332. (defun gnus-summary-save-parts-1 (type dir handle reverse)
  11333. (if (stringp (car handle))
  11334. (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
  11335. (cdr handle))
  11336. (when (if reverse
  11337. (not (string-match type (mm-handle-media-type handle)))
  11338. (string-match type (mm-handle-media-type handle)))
  11339. (let ((file (expand-file-name
  11340. (gnus-map-function
  11341. mm-file-name-rewrite-functions
  11342. (file-name-nondirectory
  11343. (or
  11344. (mm-handle-filename handle)
  11345. (format "%s.%d.%d" gnus-newsgroup-name
  11346. (cdr gnus-article-current)
  11347. gnus-summary-save-parts-counter))))
  11348. dir)))
  11349. (incf gnus-summary-save-parts-counter)
  11350. (unless (file-exists-p file)
  11351. (mm-save-part-to-file handle file))))))
  11352. ;; Summary extract commands
  11353. (defun gnus-summary-insert-pseudos (pslist &optional not-view)
  11354. (let ((inhibit-read-only t)
  11355. (article (gnus-summary-article-number))
  11356. after-article b e)
  11357. (unless (gnus-summary-goto-subject article)
  11358. (error "No such article: %d" article))
  11359. (gnus-summary-position-point)
  11360. ;; If all commands are to be bunched up on one line, we collect
  11361. ;; them here.
  11362. (unless gnus-view-pseudos-separately
  11363. (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
  11364. files action)
  11365. (while ps
  11366. (setq action (cdr (assq 'action (car ps))))
  11367. (setq files (list (cdr (assq 'name (car ps)))))
  11368. (while (and ps (cdr ps)
  11369. (string= (or action "1")
  11370. (or (cdr (assq 'action (cadr ps))) "2")))
  11371. (push (cdr (assq 'name (cadr ps))) files)
  11372. (setcdr ps (cddr ps)))
  11373. (when files
  11374. (when (not (string-match "%s" action))
  11375. (push " " files))
  11376. (push " " files)
  11377. (when (assq 'execute (car ps))
  11378. (setcdr (assq 'execute (car ps))
  11379. (funcall (if (string-match "%s" action)
  11380. 'format 'concat)
  11381. action
  11382. (mapconcat
  11383. (lambda (f)
  11384. (if (equal f " ")
  11385. f
  11386. (shell-quote-argument f)))
  11387. files " ")))))
  11388. (setq ps (cdr ps)))))
  11389. (if (and gnus-view-pseudos (not not-view))
  11390. (while pslist
  11391. (when (assq 'execute (car pslist))
  11392. (gnus-execute-command (cdr (assq 'execute (car pslist)))
  11393. (eq gnus-view-pseudos 'not-confirm)))
  11394. (setq pslist (cdr pslist)))
  11395. (save-excursion
  11396. (while pslist
  11397. (setq after-article (or (cdr (assq 'article (car pslist)))
  11398. (gnus-summary-article-number)))
  11399. (gnus-summary-goto-subject after-article)
  11400. (forward-line 1)
  11401. (setq b (point))
  11402. (insert " " (file-name-nondirectory
  11403. (cdr (assq 'name (car pslist))))
  11404. ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
  11405. (setq e (point))
  11406. (forward-line -1) ; back to `b'
  11407. (gnus-add-text-properties
  11408. b (1- e) (list 'gnus-number gnus-reffed-article-number
  11409. gnus-mouse-face-prop gnus-mouse-face))
  11410. (gnus-data-enter
  11411. after-article gnus-reffed-article-number
  11412. gnus-unread-mark b (car pslist) 0 (- e b))
  11413. (setq gnus-newsgroup-unreads
  11414. (gnus-add-to-sorted-list gnus-newsgroup-unreads
  11415. gnus-reffed-article-number))
  11416. (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
  11417. (setq pslist (cdr pslist)))))))
  11418. (defun gnus-pseudos< (p1 p2)
  11419. (let ((c1 (cdr (assq 'action p1)))
  11420. (c2 (cdr (assq 'action p2))))
  11421. (and c1 c2 (string< c1 c2))))
  11422. (defun gnus-request-pseudo-article (props)
  11423. (cond ((assq 'execute props)
  11424. (gnus-execute-command (cdr (assq 'execute props)))))
  11425. (let ((gnus-current-article (gnus-summary-article-number)))
  11426. (gnus-run-hooks 'gnus-mark-article-hook)))
  11427. (defun gnus-execute-command (command &optional automatic)
  11428. (save-excursion
  11429. (gnus-article-setup-buffer)
  11430. (set-buffer gnus-article-buffer)
  11431. (setq buffer-read-only nil)
  11432. (let ((command (if automatic command
  11433. (read-string "Command: " (cons command 0)))))
  11434. (erase-buffer)
  11435. (insert "$ " command "\n\n")
  11436. (if gnus-view-pseudo-asynchronously
  11437. (start-process "gnus-execute" (current-buffer) shell-file-name
  11438. shell-command-switch command)
  11439. (call-process shell-file-name nil t nil
  11440. shell-command-switch command)))))
  11441. ;; Summary kill commands.
  11442. (defun gnus-summary-edit-global-kill (article)
  11443. "Edit the \"global\" kill file."
  11444. (interactive (list (gnus-summary-article-number)))
  11445. (gnus-group-edit-global-kill article))
  11446. (defun gnus-summary-edit-local-kill ()
  11447. "Edit a local kill file applied to the current newsgroup."
  11448. (interactive)
  11449. (setq gnus-current-headers (gnus-summary-article-header))
  11450. (gnus-group-edit-local-kill
  11451. (gnus-summary-article-number) gnus-newsgroup-name))
  11452. ;;; Header reading.
  11453. (defun gnus-read-header (id &optional header)
  11454. "Read the headers of article ID and enter them into the Gnus system."
  11455. (let ((group gnus-newsgroup-name)
  11456. (gnus-override-method
  11457. (or
  11458. gnus-override-method
  11459. (and (gnus-news-group-p gnus-newsgroup-name)
  11460. (car (gnus-refer-article-methods)))))
  11461. where)
  11462. ;; First we check to see whether the header in question is already
  11463. ;; fetched.
  11464. (if (stringp id)
  11465. ;; This is a Message-ID.
  11466. (setq header (or header (gnus-id-to-header id)))
  11467. ;; This is an article number.
  11468. (setq header (or header (gnus-summary-article-header id))))
  11469. (if (and header
  11470. (not (gnus-summary-article-sparse-p (mail-header-number header))))
  11471. ;; We have found the header.
  11472. header
  11473. ;; We have to really fetch the header to this article.
  11474. (with-current-buffer nntp-server-buffer
  11475. (when (setq where (gnus-request-head id group))
  11476. (nnheader-fold-continuation-lines)
  11477. (goto-char (point-max))
  11478. (insert ".\n")
  11479. (goto-char (point-min))
  11480. (insert "211 ")
  11481. (princ (cond
  11482. ((numberp id) id)
  11483. ((cdr where) (cdr where))
  11484. (header (mail-header-number header))
  11485. (t gnus-reffed-article-number))
  11486. (current-buffer))
  11487. (insert " Article retrieved.\n"))
  11488. (if (or (not where)
  11489. (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
  11490. () ; Malformed head.
  11491. (unless (gnus-summary-article-sparse-p (mail-header-number header))
  11492. (when (and (stringp id)
  11493. (or
  11494. (not (string= (gnus-group-real-name group)
  11495. (car where)))
  11496. (not (gnus-server-equal gnus-override-method
  11497. (gnus-group-method group)))))
  11498. ;; If we fetched by Message-ID and the article came from
  11499. ;; a different group (or server), we fudge some bogus
  11500. ;; article numbers for this article.
  11501. (mail-header-set-number header gnus-reffed-article-number))
  11502. (with-current-buffer gnus-summary-buffer
  11503. (decf gnus-reffed-article-number)
  11504. (gnus-remove-header (mail-header-number header))
  11505. (push header gnus-newsgroup-headers)
  11506. (setq gnus-current-headers header)
  11507. (push (mail-header-number header) gnus-newsgroup-limit)))
  11508. header)))))
  11509. (defun gnus-remove-header (number)
  11510. "Remove header NUMBER from `gnus-newsgroup-headers'."
  11511. (if (and gnus-newsgroup-headers
  11512. (= number (mail-header-number (car gnus-newsgroup-headers))))
  11513. (pop gnus-newsgroup-headers)
  11514. (let ((headers gnus-newsgroup-headers))
  11515. (while (and (cdr headers)
  11516. (not (= number (mail-header-number (cadr headers)))))
  11517. (pop headers))
  11518. (when (cdr headers)
  11519. (setcdr headers (cddr headers))))))
  11520. ;;;
  11521. ;;; summary highlights
  11522. ;;;
  11523. (defun gnus-highlight-selected-summary ()
  11524. "Highlight selected article in summary buffer."
  11525. ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
  11526. (when gnus-summary-selected-face
  11527. (save-excursion
  11528. (let* ((beg (point-at-bol))
  11529. (end (point-at-eol))
  11530. ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
  11531. (from (if (get-text-property beg gnus-mouse-face-prop)
  11532. beg
  11533. (or (next-single-property-change
  11534. beg gnus-mouse-face-prop nil end)
  11535. beg)))
  11536. (to
  11537. (if (= from end)
  11538. (- from 2)
  11539. (or (next-single-property-change
  11540. from gnus-mouse-face-prop nil end)
  11541. end))))
  11542. ;; If no mouse-face prop on line we will have to = from = end,
  11543. ;; so we highlight the entire line instead.
  11544. (when (= (+ to 2) from)
  11545. (setq from beg)
  11546. (setq to end))
  11547. (if gnus-newsgroup-selected-overlay
  11548. ;; Move old overlay.
  11549. (gnus-move-overlay
  11550. gnus-newsgroup-selected-overlay from to (current-buffer))
  11551. ;; Create new overlay.
  11552. (gnus-overlay-put
  11553. (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
  11554. 'face gnus-summary-selected-face))))))
  11555. (defvar gnus-summary-highlight-line-cached nil)
  11556. (defvar gnus-summary-highlight-line-trigger nil)
  11557. (defun gnus-summary-highlight-line-0 ()
  11558. (if (and (eq gnus-summary-highlight-line-trigger
  11559. gnus-summary-highlight)
  11560. gnus-summary-highlight-line-cached)
  11561. gnus-summary-highlight-line-cached
  11562. (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
  11563. gnus-summary-highlight-line-cached
  11564. (let* ((cond (list 'cond))
  11565. (c cond)
  11566. (list gnus-summary-highlight))
  11567. (while list
  11568. (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
  11569. nil))
  11570. (setq c (cdr c)
  11571. list (cdr list)))
  11572. (gnus-byte-compile (list 'lambda nil cond))))))
  11573. (defun gnus-summary-highlight-line ()
  11574. "Highlight current line according to `gnus-summary-highlight'."
  11575. (let* ((beg (point-at-bol))
  11576. (article (or (gnus-summary-article-number) gnus-current-article))
  11577. (score (or (cdr (assq article
  11578. gnus-newsgroup-scored))
  11579. gnus-summary-default-score 0))
  11580. (mark (or (gnus-summary-article-mark) gnus-unread-mark))
  11581. (inhibit-read-only t)
  11582. (default gnus-summary-default-score)
  11583. (default-high gnus-summary-default-high-score)
  11584. (default-low gnus-summary-default-low-score)
  11585. (uncached (and gnus-summary-use-undownloaded-faces
  11586. (memq article gnus-newsgroup-undownloaded)
  11587. (not (memq article gnus-newsgroup-cached)))))
  11588. (let ((face (funcall (gnus-summary-highlight-line-0))))
  11589. (unless (eq face (get-text-property beg 'face))
  11590. (gnus-put-text-property-excluding-characters-with-faces
  11591. beg (point-at-eol) 'face
  11592. (setq face (if (boundp face) (symbol-value face) face)))
  11593. (when gnus-summary-highlight-line-function
  11594. (funcall gnus-summary-highlight-line-function article face))))))
  11595. (defun gnus-update-read-articles (group unread &optional compute)
  11596. "Update the list of read articles in GROUP.
  11597. UNREAD is a sorted list."
  11598. (let ((active (or gnus-newsgroup-active (gnus-active group)))
  11599. (info (gnus-get-info group))
  11600. (prev 1)
  11601. read)
  11602. (if (or (not info) (not active))
  11603. ;; There is no info on this group if it was, in fact,
  11604. ;; killed. Gnus stores no information on killed groups, so
  11605. ;; there's nothing to be done.
  11606. ;; One could store the information somewhere temporarily,
  11607. ;; perhaps... Hmmm...
  11608. ()
  11609. ;; Remove any negative articles numbers.
  11610. (while (and unread (< (car unread) 0))
  11611. (setq unread (cdr unread)))
  11612. ;; Remove any expired article numbers
  11613. (while (and unread (< (car unread) (car active)))
  11614. (setq unread (cdr unread)))
  11615. ;; Compute the ranges of read articles by looking at the list of
  11616. ;; unread articles.
  11617. (while unread
  11618. (when (/= (car unread) prev)
  11619. (push (if (= prev (1- (car unread))) prev
  11620. (cons prev (1- (car unread))))
  11621. read))
  11622. (setq prev (1+ (car unread)))
  11623. (setq unread (cdr unread)))
  11624. (when (<= prev (cdr active))
  11625. (push (cons prev (cdr active)) read))
  11626. (setq read (if (> (length read) 1) (nreverse read) read))
  11627. (if compute
  11628. read
  11629. (save-excursion
  11630. (let (setmarkundo)
  11631. ;; Propagate the read marks to the backend.
  11632. (when (and (or gnus-propagate-marks
  11633. (gnus-method-option-p
  11634. (gnus-find-method-for-group group)
  11635. 'server-marks))
  11636. (gnus-check-backend-function 'request-set-mark group))
  11637. (let ((del (gnus-remove-from-range (gnus-info-read info) read))
  11638. (add (gnus-remove-from-range read (gnus-info-read info))))
  11639. (when (or add del)
  11640. (unless (gnus-check-group group)
  11641. (error "Can't open server for %s" group))
  11642. (gnus-request-set-mark
  11643. group (delq nil (list (if add (list add 'add '(read)))
  11644. (if del (list del 'del '(read))))))
  11645. (setq setmarkundo
  11646. `(gnus-request-set-mark
  11647. ,group
  11648. ',(delq nil (list
  11649. (if del (list del 'add '(read)))
  11650. (if add (list add 'del '(read))))))))))
  11651. (set-buffer gnus-group-buffer)
  11652. (gnus-undo-register
  11653. `(progn
  11654. (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
  11655. (gnus-info-set-read ',info ',(gnus-info-read info))
  11656. (gnus-get-unread-articles-in-group ',info
  11657. (gnus-active ,group))
  11658. (gnus-group-update-group ,group t)
  11659. ,setmarkundo))))
  11660. ;; Enter this list into the group info.
  11661. (gnus-info-set-read info read)
  11662. ;; Set the number of unread articles in gnus-newsrc-hashtb.
  11663. (gnus-get-unread-articles-in-group info (gnus-active group))
  11664. t))))
  11665. (defun gnus-offer-save-summaries ()
  11666. "Offer to save all active summary buffers."
  11667. (let (buffers)
  11668. ;; Go through all buffers and find all summaries.
  11669. (dolist (buffer (buffer-list))
  11670. (when (and (setq buffer (buffer-name buffer))
  11671. (string-match "Summary" buffer)
  11672. (with-current-buffer buffer
  11673. ;; We check that this is, indeed, a summary buffer.
  11674. (and (eq major-mode 'gnus-summary-mode)
  11675. ;; Also make sure this isn't bogus.
  11676. gnus-newsgroup-prepared
  11677. ;; Also make sure that this isn't a
  11678. ;; dead summary buffer.
  11679. (not gnus-dead-summary-mode))))
  11680. (push buffer buffers)))
  11681. ;; Go through all these summary buffers and offer to save them.
  11682. (when buffers
  11683. (save-excursion
  11684. (if (eq gnus-interactive-exit 'quiet)
  11685. (dolist (buffer buffers)
  11686. (switch-to-buffer buffer)
  11687. (gnus-summary-exit))
  11688. (map-y-or-n-p
  11689. "Update summary buffer %s? "
  11690. (lambda (buf)
  11691. (switch-to-buffer buf)
  11692. (gnus-summary-exit))
  11693. buffers))))))
  11694. (defun gnus-summary-setup-default-charset ()
  11695. "Setup newsgroup default charset."
  11696. (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
  11697. (setq gnus-newsgroup-charset nil)
  11698. (let* ((ignored-charsets
  11699. (or gnus-newsgroup-ephemeral-ignored-charsets
  11700. (append
  11701. (and gnus-newsgroup-name
  11702. (gnus-parameter-ignored-charsets gnus-newsgroup-name))
  11703. gnus-newsgroup-ignored-charsets))))
  11704. (setq gnus-newsgroup-charset
  11705. (or gnus-newsgroup-ephemeral-charset
  11706. (and gnus-newsgroup-name
  11707. (gnus-parameter-charset gnus-newsgroup-name))
  11708. gnus-default-charset))
  11709. (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
  11710. ignored-charsets))))
  11711. ;;;
  11712. ;;; Mime Commands
  11713. ;;;
  11714. (defun gnus-summary-display-buttonized (&optional show-all-parts)
  11715. "Display the current article buffer fully MIME-buttonized.
  11716. If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
  11717. treated as multipart/mixed."
  11718. (interactive "P")
  11719. (require 'gnus-art)
  11720. (let ((gnus-unbuttonized-mime-types nil)
  11721. (gnus-mime-display-multipart-as-mixed show-all-parts))
  11722. (gnus-summary-show-article)))
  11723. (defun gnus-summary-repair-multipart (article)
  11724. "Add a Content-Type header to a multipart article without one."
  11725. (interactive (list (gnus-summary-article-number)))
  11726. (gnus-with-article article
  11727. (message-narrow-to-head)
  11728. (message-remove-header "Mime-Version")
  11729. (goto-char (point-max))
  11730. (insert "Mime-Version: 1.0\n")
  11731. (widen)
  11732. (when (search-forward "\n--" nil t)
  11733. (let ((separator (buffer-substring (point) (point-at-eol))))
  11734. (message-narrow-to-head)
  11735. (message-remove-header "Content-Type")
  11736. (goto-char (point-max))
  11737. (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
  11738. separator))
  11739. (widen))))
  11740. (let (gnus-mark-article-hook)
  11741. (gnus-summary-select-article t t nil article)))
  11742. (defun gnus-summary-toggle-display-buttonized ()
  11743. "Toggle the buttonizing of the article buffer."
  11744. (interactive)
  11745. (require 'gnus-art)
  11746. (if (setq gnus-inhibit-mime-unbuttonizing
  11747. (not gnus-inhibit-mime-unbuttonizing))
  11748. (let ((gnus-unbuttonized-mime-types nil))
  11749. (gnus-summary-show-article))
  11750. (gnus-summary-show-article)))
  11751. ;;;
  11752. ;;; Generic summary marking commands
  11753. ;;;
  11754. (defvar gnus-summary-marking-alist
  11755. '((read gnus-del-mark "d")
  11756. (unread gnus-unread-mark "u")
  11757. (ticked gnus-ticked-mark "!")
  11758. (dormant gnus-dormant-mark "?")
  11759. (expirable gnus-expirable-mark "e"))
  11760. "An alist of names/marks/keystrokes.")
  11761. (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
  11762. (defvar gnus-summary-mark-map)
  11763. (defun gnus-summary-make-all-marking-commands ()
  11764. (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
  11765. (dolist (elem gnus-summary-marking-alist)
  11766. (apply 'gnus-summary-make-marking-command elem)))
  11767. (defun gnus-summary-make-marking-command (name mark keystroke)
  11768. (let ((map (make-sparse-keymap)))
  11769. (define-key gnus-summary-generic-mark-map keystroke map)
  11770. (dolist (lway `((next "next" next nil "n")
  11771. (next-unread "next unread" next t "N")
  11772. (prev "previous" prev nil "p")
  11773. (prev-unread "previous unread" prev t "P")
  11774. (nomove "" nil nil ,keystroke)))
  11775. (let ((func (gnus-summary-make-marking-command-1
  11776. mark (car lway) lway name)))
  11777. (setq func (eval func))
  11778. (define-key map (nth 4 lway) func)))))
  11779. (defun gnus-summary-make-marking-command-1 (mark way lway name)
  11780. `(defun ,(intern
  11781. (format "gnus-summary-put-mark-as-%s%s"
  11782. name (if (eq way 'nomove)
  11783. ""
  11784. (concat "-" (symbol-name way)))))
  11785. (n)
  11786. ,(format
  11787. "Mark the current article as %s%s.
  11788. If N, the prefix, then repeat N times.
  11789. If N is negative, move in reverse order.
  11790. The difference between N and the actual number of articles marked is
  11791. returned."
  11792. name (cadr lway))
  11793. (interactive "p")
  11794. (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
  11795. (defun gnus-summary-generic-mark (n mark move unread)
  11796. "Mark N articles with MARK."
  11797. (unless (eq major-mode 'gnus-summary-mode)
  11798. (error "This command can only be used in the summary buffer"))
  11799. (gnus-summary-show-thread)
  11800. (let ((nummove
  11801. (cond
  11802. ((eq move 'next) 1)
  11803. ((eq move 'prev) -1)
  11804. (t 0))))
  11805. (if (zerop nummove)
  11806. (setq n 1)
  11807. (when (< n 0)
  11808. (setq n (abs n)
  11809. nummove (* -1 nummove))))
  11810. (while (and (> n 0)
  11811. (gnus-summary-mark-article nil mark)
  11812. (zerop (gnus-summary-next-subject nummove unread t)))
  11813. (setq n (1- n)))
  11814. (when (/= 0 n)
  11815. (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
  11816. (gnus-summary-recenter)
  11817. (gnus-summary-position-point)
  11818. (gnus-set-mode-line 'summary)
  11819. n))
  11820. (defun gnus-summary-insert-articles (articles)
  11821. (when (setq articles
  11822. (gnus-sorted-difference articles
  11823. (mapcar (lambda (h)
  11824. (mail-header-number h))
  11825. gnus-newsgroup-headers)))
  11826. (setq gnus-newsgroup-headers
  11827. (gnus-merge 'list
  11828. gnus-newsgroup-headers
  11829. (gnus-fetch-headers articles)
  11830. 'gnus-article-sort-by-number))
  11831. (setq gnus-newsgroup-articles
  11832. (gnus-sorted-nunion gnus-newsgroup-articles articles))
  11833. ;; Suppress duplicates?
  11834. (when gnus-suppress-duplicates
  11835. (gnus-dup-suppress-articles))
  11836. (if (and gnus-fetch-old-headers
  11837. (eq gnus-headers-retrieved-by 'nov))
  11838. ;; We might want to build some more threads first.
  11839. (if (eq gnus-fetch-old-headers 'invisible)
  11840. (gnus-build-all-threads)
  11841. (gnus-build-old-threads))
  11842. ;; Mark the inserted articles that are unread as unread.
  11843. (setq gnus-newsgroup-unreads
  11844. (gnus-sorted-nunion
  11845. gnus-newsgroup-unreads
  11846. (gnus-sorted-nintersection
  11847. (gnus-list-of-unread-articles gnus-newsgroup-name)
  11848. articles)))
  11849. ;; Mark the inserted articles as selected so that the information
  11850. ;; of the marks having been changed by a user may be updated when
  11851. ;; exiting this group. See `gnus-summary-update-info'.
  11852. (dolist (art articles)
  11853. (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
  11854. ;; Let the Gnus agent mark articles as read.
  11855. (when gnus-agent
  11856. (gnus-agent-get-undownloaded-list))
  11857. ;; Remove list identifiers from subject
  11858. (gnus-summary-remove-list-identifiers)
  11859. ;; First and last article in this newsgroup.
  11860. (when gnus-newsgroup-headers
  11861. (setq gnus-newsgroup-begin
  11862. (mail-header-number (car gnus-newsgroup-headers))
  11863. gnus-newsgroup-end
  11864. (mail-header-number
  11865. (gnus-last-element gnus-newsgroup-headers))))
  11866. (when gnus-use-scoring
  11867. (gnus-possibly-score-headers))))
  11868. (defun gnus-summary-insert-old-articles (&optional all)
  11869. "Insert all old articles in this group.
  11870. If ALL is non-nil, already read articles become readable.
  11871. If ALL is a number, fetch this number of articles."
  11872. (interactive "P")
  11873. (prog1
  11874. (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
  11875. older len)
  11876. (setq older
  11877. ;; Some nntp servers lie about their active range. When
  11878. ;; this happens, the active range can be in the millions.
  11879. ;; Use a compressed range to avoid creating a huge list.
  11880. (gnus-range-difference (list gnus-newsgroup-active) old))
  11881. (setq len (gnus-range-length older))
  11882. (cond
  11883. ((null older) nil)
  11884. ((numberp all)
  11885. (if (< all len)
  11886. (let ((older-range (nreverse older)))
  11887. (setq older nil)
  11888. (while (> all 0)
  11889. (let* ((r (pop older-range))
  11890. (min (if (numberp r) r (car r)))
  11891. (max (if (numberp r) r (cdr r))))
  11892. (while (and (<= min max)
  11893. (> all 0))
  11894. (push max older)
  11895. (setq all (1- all)
  11896. max (1- max))))))
  11897. (setq older (gnus-uncompress-range older))))
  11898. (all
  11899. (setq older (gnus-uncompress-range older)))
  11900. (t
  11901. (when (and (numberp gnus-large-newsgroup)
  11902. (> len gnus-large-newsgroup))
  11903. (let* ((cursor-in-echo-area nil)
  11904. (initial (gnus-parameter-large-newsgroup-initial
  11905. gnus-newsgroup-name))
  11906. (input
  11907. (read-string
  11908. (format
  11909. "How many articles from %s (%s %d): "
  11910. (gnus-group-decoded-name gnus-newsgroup-name)
  11911. (if initial "max" "default")
  11912. len)
  11913. nil nil
  11914. (and initial
  11915. (number-to-string initial)))))
  11916. (unless (string-match "^[ \t]*$" input)
  11917. (setq all (string-to-number input))
  11918. (if (< all len)
  11919. (let ((older-range (nreverse older)))
  11920. (setq older nil)
  11921. (while (> all 0)
  11922. (let* ((r (pop older-range))
  11923. (min (if (numberp r) r (car r)))
  11924. (max (if (numberp r) r (cdr r))))
  11925. (while (and (<= min max)
  11926. (> all 0))
  11927. (push max older)
  11928. (setq all (1- all)
  11929. max (1- max))))))))))
  11930. (setq older (gnus-uncompress-range older))))
  11931. (if (not older)
  11932. (message "No old news.")
  11933. (gnus-summary-insert-articles older)
  11934. (gnus-summary-limit (gnus-sorted-nunion old older))))
  11935. (gnus-summary-position-point)))
  11936. (defun gnus-summary-insert-new-articles ()
  11937. "Insert all new articles in this group."
  11938. (interactive)
  11939. (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
  11940. (old-high gnus-newsgroup-highest)
  11941. (nnmail-fetched-sources (list t))
  11942. (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
  11943. i new)
  11944. (unless new-active
  11945. (error "Couldn't fetch new data"))
  11946. (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
  11947. (setq i (cdr gnus-newsgroup-active)
  11948. gnus-newsgroup-highest i)
  11949. (while (> i old-high)
  11950. (push i new)
  11951. (decf i))
  11952. (if (not new)
  11953. (message "No gnus is bad news")
  11954. (gnus-summary-insert-articles new)
  11955. (setq gnus-newsgroup-unreads
  11956. (gnus-sorted-nunion gnus-newsgroup-unreads new))
  11957. (gnus-summary-limit (gnus-sorted-nunion old new))))
  11958. (gnus-summary-position-point))
  11959. ;;; Bookmark support for Gnus.
  11960. (declare-function bookmark-make-record-default
  11961. "bookmark" (&optional no-file no-context posn))
  11962. (declare-function bookmark-prop-get "bookmark" (bookmark prop))
  11963. (declare-function bookmark-default-handler "bookmark" (bmk))
  11964. (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
  11965. (defvar bookmark-yank-point)
  11966. (defvar bookmark-current-buffer)
  11967. (defun gnus-summary-bookmark-make-record ()
  11968. "Make a bookmark entry for a Gnus summary buffer."
  11969. (let (pos buf)
  11970. (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
  11971. (save-restriction ; FIXME is it necessary to widen?
  11972. (widen) (setq pos (point))) ; Set position in gnus-article buffer.
  11973. (setq buf "art") ; We are recording bookmark from article buffer.
  11974. (setq bookmark-yank-point (point))
  11975. (setq bookmark-current-buffer (current-buffer))
  11976. (gnus-article-show-summary)) ; Go back in summary buffer.
  11977. ;; We are now recording bookmark from summary buffer.
  11978. (unless buf (setq buf "sum"))
  11979. (let* ((subject (elt (gnus-summary-article-header) 1))
  11980. (grp (car gnus-article-current))
  11981. (art (cdr gnus-article-current))
  11982. (head (gnus-summary-article-header art))
  11983. (id (mail-header-id head)))
  11984. `(,subject
  11985. ,@(condition-case nil
  11986. (bookmark-make-record-default 'no-file 'no-context pos)
  11987. (wrong-number-of-arguments
  11988. (bookmark-make-record-default 'point-only)))
  11989. (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
  11990. (group . ,grp) (article . ,art)
  11991. (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
  11992. ;;;###autoload
  11993. (defun gnus-summary-bookmark-jump (bookmark)
  11994. "Handler function for record returned by `gnus-summary-bookmark-make-record'.
  11995. BOOKMARK is a bookmark name or a bookmark record."
  11996. (let ((group (bookmark-prop-get bookmark 'group))
  11997. (article (bookmark-prop-get bookmark 'article))
  11998. (id (bookmark-prop-get bookmark 'message-id))
  11999. (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
  12000. (gnus-fetch-group group (list article))
  12001. (gnus-summary-insert-cached-articles)
  12002. (gnus-summary-goto-article id nil 'force)
  12003. ;; FIXME we have to wait article buffer is ready (only large buffer)
  12004. ;; Is there a better solution to know that?
  12005. ;; If we don't wait `bookmark-default-handler' will have no chance
  12006. ;; to set position. However there is no error, just wrong pos.
  12007. (sit-for 1)
  12008. (when (string= buf "Gnus-art")
  12009. (other-window 1))
  12010. (bookmark-default-handler
  12011. `(""
  12012. (buffer . ,(current-buffer))
  12013. . ,(bookmark-get-bookmark-record bookmark)))))
  12014. (gnus-summary-make-all-marking-commands)
  12015. (gnus-ems-redefine)
  12016. (provide 'gnus-sum)
  12017. (run-hooks 'gnus-sum-load-hook)
  12018. ;; Local Variables:
  12019. ;; coding: iso-8859-1
  12020. ;; End:
  12021. ;;; gnus-sum.el ends here