gnus-group.el 168 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723
  1. ;;; gnus-group.el --- group 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. (defvar tool-bar-mode)
  24. (require 'gnus)
  25. (require 'gnus-start)
  26. (require 'nnmail)
  27. (require 'gnus-spec)
  28. (require 'gnus-int)
  29. (require 'gnus-range)
  30. (require 'gnus-win)
  31. (require 'gnus-undo)
  32. (require 'gmm-utils)
  33. (require 'time-date)
  34. (require 'gnus-ems)
  35. (eval-when-compile
  36. (require 'mm-url)
  37. (let ((features (cons 'gnus-group features)))
  38. (require 'gnus-sum))
  39. (unless (boundp 'gnus-cache-active-hashtb)
  40. (defvar gnus-cache-active-hashtb nil)))
  41. (autoload 'gnus-agent-total-fetched-for "gnus-agent")
  42. (autoload 'gnus-cache-total-fetched-for "gnus-cache")
  43. (autoload 'gnus-group-make-nnir-group "nnir")
  44. (defcustom gnus-no-groups-message "No Gnus is good news"
  45. "*Message displayed by Gnus when no groups are available."
  46. :group 'gnus-start
  47. :type 'string)
  48. (defcustom gnus-keep-same-level nil
  49. "*Non-nil means that the next newsgroup after the current will be on the same level.
  50. When you type, for instance, `n' after reading the last article in the
  51. current newsgroup, you will go to the next newsgroup. If this variable
  52. is nil, the next newsgroup will be the next from the group
  53. buffer.
  54. If this variable is non-nil, Gnus will either put you in the
  55. next newsgroup with the same level, or, if no such newsgroup is
  56. available, the next newsgroup with the lowest possible level higher
  57. than the current level.
  58. If this variable is `best', Gnus will make the next newsgroup the one
  59. with the best level."
  60. :group 'gnus-group-levels
  61. :type '(choice (const nil)
  62. (const best)
  63. (sexp :tag "other" t)))
  64. (defcustom gnus-group-goto-unread t
  65. "*If non-nil, movement commands will go to the next unread and subscribed group."
  66. :link '(custom-manual "(gnus)Group Maneuvering")
  67. :group 'gnus-group-various
  68. :type 'boolean)
  69. (defcustom gnus-goto-next-group-when-activating t
  70. "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
  71. :link '(custom-manual "(gnus)Scanning New Messages")
  72. :group 'gnus-group-various
  73. :type 'boolean)
  74. (defcustom gnus-permanently-visible-groups nil
  75. "*Regexp to match groups that should always be listed in the group buffer.
  76. This means that they will still be listed even when there are no
  77. unread articles in the groups.
  78. If nil, no groups are permanently visible."
  79. :group 'gnus-group-listing
  80. :type '(choice regexp (const nil)))
  81. (defcustom gnus-safe-html-newsgroups "\\`nnrss[+:]"
  82. "Groups in which links in html articles are considered all safe.
  83. The value may be a regexp matching those groups, a list of group names,
  84. or nil. This overrides `mm-w3m-safe-url-regexp' (which see). This is
  85. effective only when emacs-w3m renders html articles, i.e., in the case
  86. `mm-text-html-renderer' is set to `w3m'."
  87. :version "23.2"
  88. :group 'gnus-group-various
  89. :type '(choice regexp
  90. (repeat :tag "List of group names" (string :tag "Group"))
  91. (const nil)))
  92. (defcustom gnus-list-groups-with-ticked-articles t
  93. "*If non-nil, list groups that have only ticked articles.
  94. If nil, only list groups that have unread articles."
  95. :group 'gnus-group-listing
  96. :type 'boolean)
  97. (defcustom gnus-group-default-list-level gnus-level-subscribed
  98. "Default listing level.
  99. Ignored if `gnus-group-use-permanent-levels' is non-nil."
  100. :group 'gnus-group-listing
  101. :type '(choice (integer :tag "Level")
  102. (function :tag "Function returning level")))
  103. (defcustom gnus-group-list-inactive-groups t
  104. "*If non-nil, inactive groups will be listed."
  105. :group 'gnus-group-listing
  106. :group 'gnus-group-levels
  107. :type 'boolean)
  108. (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
  109. "*Function used for sorting the group buffer.
  110. This function will be called with group info entries as the arguments
  111. for the groups to be sorted. Pre-made functions include
  112. `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
  113. `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
  114. `gnus-group-sort-by-score', `gnus-group-sort-by-method',
  115. `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
  116. This variable can also be a list of sorting functions. In that case,
  117. the most significant sort function should be the last function in the
  118. list."
  119. :group 'gnus-group-listing
  120. :link '(custom-manual "(gnus)Sorting Groups")
  121. :type '(repeat :value-to-internal (lambda (widget value)
  122. (if (listp value) value (list value)))
  123. :match (lambda (widget value)
  124. (or (symbolp value)
  125. (widget-editable-list-match widget value)))
  126. (choice (function-item gnus-group-sort-by-alphabet)
  127. (function-item gnus-group-sort-by-real-name)
  128. (function-item gnus-group-sort-by-unread)
  129. (function-item gnus-group-sort-by-level)
  130. (function-item gnus-group-sort-by-score)
  131. (function-item gnus-group-sort-by-method)
  132. (function-item gnus-group-sort-by-server)
  133. (function-item gnus-group-sort-by-rank)
  134. (function :tag "other" nil))))
  135. (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)\n"
  136. "*Format of group lines.
  137. It works along the same lines as a normal formatting string,
  138. with some simple extensions.
  139. %M Only marked articles (character, \"*\" or \" \")
  140. %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
  141. %L Level of subscribedness (integer)
  142. %N Number of unread articles (integer)
  143. %I Number of dormant articles (integer)
  144. %i Number of ticked and dormant (integer)
  145. %T Number of ticked articles (integer)
  146. %R Number of read articles (integer)
  147. %U Number of unseen articles (integer)
  148. %t Estimated total number of articles (integer)
  149. %y Number of unread, unticked articles (integer)
  150. %G Group name (string)
  151. %g Qualified group name (string)
  152. %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
  153. %C Group comment (string)
  154. %D Group description (string)
  155. %s Select method (string)
  156. %o Moderated group (char, \"m\")
  157. %p Process mark (char)
  158. %B Whether a summary buffer for the group is open (char, \"*\")
  159. %O Moderated group (string, \"(m)\" or \"\")
  160. %P Topic indentation (string)
  161. %m Whether there is new(ish) mail in the group (char, \"%\")
  162. %n Select from where (string)
  163. %z A string that look like `<%s:%n>' if a foreign select method is used
  164. %d The date the group was last entered.
  165. %E Icon as defined by `gnus-group-icon-list'.
  166. %F The disk space used by the articles fetched by both the cache and agent.
  167. %u User defined specifier. The next character in the format string should
  168. be a letter. Gnus will call the function gnus-user-format-function-X,
  169. where X is the letter following %u. The function will be passed a
  170. single dummy parameter as argument. The function should return a
  171. string, which will be inserted into the buffer just like information
  172. from any other group specifier.
  173. Note that this format specification is not always respected. For
  174. reasons of efficiency, when listing killed groups, this specification
  175. is ignored altogether. If the spec is changed considerably, your
  176. output may end up looking strange when listing both alive and killed
  177. groups.
  178. If you use %o or %O, reading the active file will be slower and quite
  179. a bit of extra memory will be used. %D and %F will also worsen
  180. performance. Also note that if you change the format specification to
  181. include any of these specs, you must probably re-start Gnus to see
  182. them go into effect.
  183. General format specifiers can also be used.
  184. See Info node `(gnus)Formatting Variables'."
  185. :link '(custom-manual "(gnus)Formatting Variables")
  186. :group 'gnus-group-visual
  187. :type 'string)
  188. (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
  189. "*The format specification for the group mode line.
  190. It works along the same lines as a normal formatting string,
  191. with some simple extensions:
  192. %S The native news server.
  193. %M The native select method.
  194. %: \":\" if %S isn't \"\"."
  195. :group 'gnus-group-visual
  196. :type 'string)
  197. ;; Extracted from gnus-xmas-redefine in order to preserve user settings
  198. (when (featurep 'xemacs)
  199. (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
  200. (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
  201. (defcustom gnus-group-menu-hook nil
  202. "Hook run after the creation of the group mode menu."
  203. :group 'gnus-group-various
  204. :type 'hook)
  205. (defcustom gnus-group-catchup-group-hook nil
  206. "Hook run when catching up a group from the group buffer."
  207. :group 'gnus-group-various
  208. :link '(custom-manual "(gnus)Group Data")
  209. :type 'hook)
  210. (defcustom gnus-group-update-group-hook nil
  211. "Hook called when updating group lines."
  212. :group 'gnus-group-visual
  213. :type 'hook)
  214. (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
  215. "*A function that is called to generate the group buffer.
  216. The function is called with three arguments: The first is a number;
  217. all group with a level less or equal to that number should be listed,
  218. if the second is non-nil, empty groups should also be displayed. If
  219. the third is non-nil, it is a number. No groups with a level lower
  220. than this number should be displayed.
  221. The only current function implemented is `gnus-group-prepare-flat'."
  222. :group 'gnus-group-listing
  223. :type 'function)
  224. (defcustom gnus-group-prepare-hook nil
  225. "Hook called after the group buffer has been generated.
  226. If you want to modify the group buffer, you can use this hook."
  227. :group 'gnus-group-listing
  228. :type 'hook)
  229. (defcustom gnus-suspend-gnus-hook nil
  230. "Hook called when suspending (not exiting) Gnus."
  231. :group 'gnus-exit
  232. :type 'hook)
  233. (defcustom gnus-exit-gnus-hook nil
  234. "Hook called when exiting Gnus."
  235. :group 'gnus-exit
  236. :type 'hook)
  237. (defcustom gnus-after-exiting-gnus-hook nil
  238. "Hook called after exiting Gnus."
  239. :group 'gnus-exit
  240. :type 'hook)
  241. (defcustom gnus-group-update-hook nil
  242. "Hook called when a group line is changed."
  243. :group 'gnus-group-visual
  244. :version "24.1"
  245. :type 'hook)
  246. (defcustom gnus-useful-groups
  247. '(("(ding) mailing list mirrored at gmane.org"
  248. "gmane.emacs.gnus.general"
  249. (nntp "Gmane"
  250. (nntp-address "news.gmane.org")))
  251. ("Gnus bug archive"
  252. "gnus.gnus-bug"
  253. (nntp "news.gnus.org"
  254. (nntp-address "news.gnus.org")))
  255. ("Local Gnus help group"
  256. "gnus-help"
  257. (nndoc "gnus-help"
  258. (nndoc-article-type mbox)
  259. (eval `(nndoc-address
  260. ,(let ((file (nnheader-find-etc-directory
  261. "gnus-tut.txt" t)))
  262. (unless file
  263. (error "Couldn't find doc group"))
  264. file))))))
  265. "*Alist of useful group-server pairs."
  266. :group 'gnus-group-listing
  267. :type '(repeat (list (string :tag "Description")
  268. (string :tag "Name")
  269. (sexp :tag "Method"))))
  270. (defcustom gnus-group-highlight
  271. '(;; Mail.
  272. ((and mailp (= unread 0) (eq level 1)) .
  273. gnus-group-mail-1-empty)
  274. ((and mailp (eq level 1)) .
  275. gnus-group-mail-1)
  276. ((and mailp (= unread 0) (eq level 2)) .
  277. gnus-group-mail-2-empty)
  278. ((and mailp (eq level 2)) .
  279. gnus-group-mail-2)
  280. ((and mailp (= unread 0) (eq level 3)) .
  281. gnus-group-mail-3-empty)
  282. ((and mailp (eq level 3)) .
  283. gnus-group-mail-3)
  284. ((and mailp (= unread 0)) .
  285. gnus-group-mail-low-empty)
  286. ((and mailp) .
  287. gnus-group-mail-low)
  288. ;; News.
  289. ((and (= unread 0) (eq level 1)) .
  290. gnus-group-news-1-empty)
  291. ((and (eq level 1)) .
  292. gnus-group-news-1)
  293. ((and (= unread 0) (eq level 2)) .
  294. gnus-group-news-2-empty)
  295. ((and (eq level 2)) .
  296. gnus-group-news-2)
  297. ((and (= unread 0) (eq level 3)) .
  298. gnus-group-news-3-empty)
  299. ((and (eq level 3)) .
  300. gnus-group-news-3)
  301. ((and (= unread 0) (eq level 4)) .
  302. gnus-group-news-4-empty)
  303. ((and (eq level 4)) .
  304. gnus-group-news-4)
  305. ((and (= unread 0) (eq level 5)) .
  306. gnus-group-news-5-empty)
  307. ((and (eq level 5)) .
  308. gnus-group-news-5)
  309. ((and (= unread 0) (eq level 6)) .
  310. gnus-group-news-6-empty)
  311. ((and (eq level 6)) .
  312. gnus-group-news-6)
  313. ((and (= unread 0)) .
  314. gnus-group-news-low-empty)
  315. (t .
  316. gnus-group-news-low))
  317. "*Controls the highlighting of group buffer lines.
  318. Below is a list of `Form'/`Face' pairs. When deciding how a
  319. particular group line should be displayed, each form is
  320. evaluated. The content of the face field after the first true form is
  321. used. You can change how those group lines are displayed by
  322. editing the face field.
  323. It is also possible to change and add form fields, but currently that
  324. requires an understanding of Lisp expressions. Hopefully this will
  325. change in a future release. For now, you can use the following
  326. variables in the Lisp expression:
  327. group: The name of the group.
  328. unread: The number of unread articles in the group.
  329. method: The select method used.
  330. mailp: Whether it's a mail group or not.
  331. level: The level of the group.
  332. score: The score of the group.
  333. ticked: The number of ticked articles."
  334. :group 'gnus-group-visual
  335. :type '(repeat (cons (sexp :tag "Form") face)))
  336. (put 'gnus-group-highlight 'risky-local-variable t)
  337. (defcustom gnus-new-mail-mark ?%
  338. "Mark used for groups with new mail."
  339. :group 'gnus-group-visual
  340. :type 'character)
  341. (defgroup gnus-group-icons nil
  342. "Add Icons to your group buffer."
  343. :group 'gnus-group-visual)
  344. (defcustom gnus-group-icon-list
  345. nil
  346. "*Controls the insertion of icons into group buffer lines.
  347. Below is a list of `Form'/`File' pairs. When deciding how a
  348. particular group line should be displayed, each form is evaluated.
  349. The icon from the file field after the first true form is used. You
  350. can change how those group lines are displayed by editing the file
  351. field. The File will either be found in the
  352. `gnus-group-glyph-directory' or by designating absolute name of the
  353. file.
  354. It is also possible to change and add form fields, but currently that
  355. requires an understanding of Lisp expressions. Hopefully this will
  356. change in a future release. For now, you can use the following
  357. variables in the Lisp expression:
  358. group: The name of the group.
  359. unread: The number of unread articles in the group.
  360. method: The select method used.
  361. mailp: Whether it's a mail group or not.
  362. level: The level of the group.
  363. score: The score of the group.
  364. ticked: The number of ticked articles."
  365. :group 'gnus-group-icons
  366. :type '(repeat (cons (sexp :tag "Form") file)))
  367. (put 'gnus-group-icon-list 'risky-local-variable t)
  368. (defcustom gnus-group-name-charset-method-alist nil
  369. "Alist of method and the charset for group names.
  370. For example:
  371. (((nntp \"news.com.cn\") . cn-gb-2312))"
  372. :version "21.1"
  373. :group 'gnus-charset
  374. :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
  375. (defcustom gnus-group-name-charset-group-alist
  376. (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
  377. (mm-coding-system-p 'utf-8))
  378. '((".*" . utf-8))
  379. nil)
  380. "Alist of group regexp and the charset for group names.
  381. For example:
  382. ((\"\\.com\\.cn:\" . cn-gb-2312))"
  383. :group 'gnus-charset
  384. :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
  385. (defcustom gnus-group-jump-to-group-prompt nil
  386. "Default prompt for `gnus-group-jump-to-group'.
  387. If non-nil, the value should be a string or an alist. If it is a string,
  388. e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
  389. nnml:\" in the minibuffer prompt.
  390. If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
  391. \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
  392. used when no prefix argument is given to `gnus-group-jump-to-group'."
  393. :version "22.1"
  394. :group 'gnus-group-various
  395. :type '(choice (string :tag "Prompt string")
  396. (const :tag "Empty" nil)
  397. (repeat (cons (integer :tag "Argument")
  398. (string :tag "Prompt string")))))
  399. (defvar gnus-group-listing-limit 1000
  400. "*A limit of the number of groups when listing.
  401. If the number of groups is larger than the limit, list them in a
  402. simple manner.")
  403. ;;; Internal variables
  404. (defvar gnus-group-is-exiting-p nil)
  405. (defvar gnus-group-is-exiting-without-update-p nil)
  406. (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
  407. "Function for sorting the group buffer.")
  408. (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
  409. "Function for sorting the selected groups in the group buffer.")
  410. (defvar gnus-group-indentation-function nil)
  411. (defvar gnus-goto-missing-group-function nil)
  412. (defvar gnus-group-update-group-function nil)
  413. (defvar gnus-group-goto-next-group-function nil
  414. "Function to override finding the next group after listing groups.")
  415. (defvar gnus-group-edit-buffer nil)
  416. (defvar gnus-group-line-format-alist
  417. `((?M gnus-tmp-marked-mark ?c)
  418. (?S gnus-tmp-subscribed ?c)
  419. (?L gnus-tmp-level ?d)
  420. (?N (cond ((eq number t) "*" )
  421. ((numberp number)
  422. (int-to-string
  423. (+ number
  424. (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
  425. (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
  426. (t number)) ?s)
  427. (?R gnus-tmp-number-of-read ?s)
  428. (?U (if (gnus-active gnus-tmp-group)
  429. (gnus-number-of-unseen-articles-in-group gnus-tmp-group)
  430. "*")
  431. ?s)
  432. (?t gnus-tmp-number-total ?d)
  433. (?y gnus-tmp-number-of-unread ?s)
  434. (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
  435. (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
  436. (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
  437. (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
  438. (?g (if (boundp 'gnus-tmp-decoded-group)
  439. gnus-tmp-decoded-group
  440. gnus-tmp-group)
  441. ?s)
  442. (?G gnus-tmp-qualified-group ?s)
  443. (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
  444. gnus-tmp-decoded-group
  445. gnus-tmp-group))
  446. ?s)
  447. (?C gnus-tmp-comment ?s)
  448. (?D gnus-tmp-newsgroup-description ?s)
  449. (?o gnus-tmp-moderated ?c)
  450. (?O gnus-tmp-moderated-string ?s)
  451. (?p gnus-tmp-process-marked ?c)
  452. (?s gnus-tmp-news-server ?s)
  453. (?n ,(if (featurep 'xemacs)
  454. '(symbol-name gnus-tmp-news-method)
  455. 'gnus-tmp-news-method)
  456. ?s)
  457. (?P gnus-group-indentation ?s)
  458. (?E gnus-tmp-group-icon ?s)
  459. (?B gnus-tmp-summary-live ?c)
  460. (?z gnus-tmp-news-method-string ?s)
  461. (?m (gnus-group-new-mail gnus-tmp-group) ?c)
  462. (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
  463. (?u gnus-tmp-user-defined ?s)
  464. (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
  465. ))
  466. (defvar gnus-group-mode-line-format-alist
  467. `((?S gnus-tmp-news-server ?s)
  468. (?M gnus-tmp-news-method ?s)
  469. (?u gnus-tmp-user-defined ?s)
  470. (?: gnus-tmp-colon ?s)))
  471. (defvar gnus-topic-topology nil
  472. "The complete topic hierarchy.")
  473. (defvar gnus-topic-alist nil
  474. "The complete topic-group alist.")
  475. (defvar gnus-group-marked nil)
  476. (defvar gnus-group-list-mode nil)
  477. (defvar gnus-group-listed-groups nil)
  478. (defvar gnus-group-list-option nil)
  479. ;;;
  480. ;;; Gnus group mode
  481. ;;;
  482. (put 'gnus-group-mode 'mode-class 'special)
  483. (gnus-define-keys gnus-group-mode-map
  484. " " gnus-group-read-group
  485. "=" gnus-group-select-group
  486. "\r" gnus-group-select-group
  487. "\M-\r" gnus-group-quick-select-group
  488. "\M- " gnus-group-visible-select-group
  489. [(meta control return)] gnus-group-select-group-ephemerally
  490. "j" gnus-group-jump-to-group
  491. "n" gnus-group-next-unread-group
  492. "p" gnus-group-prev-unread-group
  493. "\177" gnus-group-prev-unread-group
  494. [delete] gnus-group-prev-unread-group
  495. [backspace] gnus-group-prev-unread-group
  496. "N" gnus-group-next-group
  497. "P" gnus-group-prev-group
  498. "\M-n" gnus-group-next-unread-group-same-level
  499. "\M-p" gnus-group-prev-unread-group-same-level
  500. "," gnus-group-best-unread-group
  501. "." gnus-group-first-unread-group
  502. "u" gnus-group-unsubscribe-current-group
  503. "U" gnus-group-unsubscribe-group
  504. "c" gnus-group-catchup-current
  505. "C" gnus-group-catchup-current-all
  506. "\M-c" gnus-group-clear-data
  507. "l" gnus-group-list-groups
  508. "L" gnus-group-list-all-groups
  509. "m" gnus-group-mail
  510. "i" gnus-group-news
  511. "g" gnus-group-get-new-news
  512. "\M-g" gnus-group-get-new-news-this-group
  513. "R" gnus-group-restart
  514. "r" gnus-group-read-init-file
  515. "B" gnus-group-browse-foreign-server
  516. "b" gnus-group-check-bogus-groups
  517. "F" gnus-group-find-new-groups
  518. "\C-c\C-d" gnus-group-describe-group
  519. "\M-d" gnus-group-describe-all-groups
  520. "\C-c\C-a" gnus-group-apropos
  521. "\C-c\M-\C-a" gnus-group-description-apropos
  522. "a" gnus-group-post-news
  523. "\ek" gnus-group-edit-local-kill
  524. "\eK" gnus-group-edit-global-kill
  525. "\C-k" gnus-group-kill-group
  526. "\C-y" gnus-group-yank-group
  527. "\C-w" gnus-group-kill-region
  528. "\C-x\C-t" gnus-group-transpose-groups
  529. "\C-c\C-l" gnus-group-list-killed
  530. "\C-c\C-x" gnus-group-expire-articles
  531. "\C-c\M-\C-x" gnus-group-expire-all-groups
  532. "V" gnus-version
  533. "s" gnus-group-save-newsrc
  534. "z" gnus-group-suspend
  535. "q" gnus-group-exit
  536. "Q" gnus-group-quit
  537. "?" gnus-group-describe-briefly
  538. "\C-c\C-i" gnus-info-find-node
  539. "\M-e" gnus-group-edit-group-method
  540. "^" gnus-group-enter-server-mode
  541. gnus-mouse-2 gnus-mouse-pick-group
  542. [follow-link] mouse-face
  543. "<" beginning-of-buffer
  544. ">" end-of-buffer
  545. "\C-c\C-b" gnus-bug
  546. "\C-c\C-s" gnus-group-sort-groups
  547. "t" gnus-topic-mode
  548. "\C-c\M-g" gnus-activate-all-groups
  549. "\M-&" gnus-group-universal-argument
  550. "#" gnus-group-mark-group
  551. "\M-#" gnus-group-unmark-group)
  552. (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
  553. "m" gnus-group-mark-group
  554. "u" gnus-group-unmark-group
  555. "w" gnus-group-mark-region
  556. "b" gnus-group-mark-buffer
  557. "r" gnus-group-mark-regexp
  558. "U" gnus-group-unmark-all-groups)
  559. (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
  560. "u" gnus-sieve-update
  561. "g" gnus-sieve-generate)
  562. (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
  563. "d" gnus-group-make-directory-group
  564. "h" gnus-group-make-help-group
  565. "u" gnus-group-make-useful-group
  566. "l" gnus-group-nnimap-edit-acl
  567. "m" gnus-group-make-group
  568. "E" gnus-group-edit-group
  569. "e" gnus-group-edit-group-method
  570. "p" gnus-group-edit-group-parameters
  571. "v" gnus-group-add-to-virtual
  572. "V" gnus-group-make-empty-virtual
  573. "D" gnus-group-enter-directory
  574. "f" gnus-group-make-doc-group
  575. "w" gnus-group-make-web-group
  576. "G" gnus-group-make-nnir-group
  577. "M" gnus-group-read-ephemeral-group
  578. "r" gnus-group-rename-group
  579. "R" gnus-group-make-rss-group
  580. "c" gnus-group-customize
  581. "z" gnus-group-compact-group
  582. "x" gnus-group-expunge-group
  583. "\177" gnus-group-delete-group
  584. [delete] gnus-group-delete-group)
  585. (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
  586. "s" gnus-group-sort-groups
  587. "a" gnus-group-sort-groups-by-alphabet
  588. "u" gnus-group-sort-groups-by-unread
  589. "l" gnus-group-sort-groups-by-level
  590. "v" gnus-group-sort-groups-by-score
  591. "r" gnus-group-sort-groups-by-rank
  592. "m" gnus-group-sort-groups-by-method
  593. "n" gnus-group-sort-groups-by-real-name)
  594. (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
  595. "s" gnus-group-sort-selected-groups
  596. "a" gnus-group-sort-selected-groups-by-alphabet
  597. "u" gnus-group-sort-selected-groups-by-unread
  598. "l" gnus-group-sort-selected-groups-by-level
  599. "v" gnus-group-sort-selected-groups-by-score
  600. "r" gnus-group-sort-selected-groups-by-rank
  601. "m" gnus-group-sort-selected-groups-by-method
  602. "n" gnus-group-sort-selected-groups-by-real-name)
  603. (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
  604. "k" gnus-group-list-killed
  605. "z" gnus-group-list-zombies
  606. "s" gnus-group-list-groups
  607. "u" gnus-group-list-all-groups
  608. "A" gnus-group-list-active
  609. "a" gnus-group-apropos
  610. "d" gnus-group-description-apropos
  611. "m" gnus-group-list-matching
  612. "M" gnus-group-list-all-matching
  613. "l" gnus-group-list-level
  614. "c" gnus-group-list-cached
  615. "?" gnus-group-list-dormant
  616. "!" gnus-group-list-ticked)
  617. (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
  618. "k" gnus-group-list-limit
  619. "z" gnus-group-list-limit
  620. "s" gnus-group-list-limit
  621. "u" gnus-group-list-limit
  622. "A" gnus-group-list-limit
  623. "m" gnus-group-list-limit
  624. "M" gnus-group-list-limit
  625. "l" gnus-group-list-limit
  626. "c" gnus-group-list-limit
  627. "?" gnus-group-list-limit
  628. "!" gnus-group-list-limit)
  629. (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
  630. "k" gnus-group-list-flush
  631. "z" gnus-group-list-flush
  632. "s" gnus-group-list-flush
  633. "u" gnus-group-list-flush
  634. "A" gnus-group-list-flush
  635. "m" gnus-group-list-flush
  636. "M" gnus-group-list-flush
  637. "l" gnus-group-list-flush
  638. "c" gnus-group-list-flush
  639. "?" gnus-group-list-flush
  640. "!" gnus-group-list-flush)
  641. (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
  642. "k" gnus-group-list-plus
  643. "z" gnus-group-list-plus
  644. "s" gnus-group-list-plus
  645. "u" gnus-group-list-plus
  646. "A" gnus-group-list-plus
  647. "m" gnus-group-list-plus
  648. "M" gnus-group-list-plus
  649. "l" gnus-group-list-plus
  650. "c" gnus-group-list-plus
  651. "?" gnus-group-list-plus
  652. "!" gnus-group-list-plus)
  653. (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
  654. "f" gnus-score-flush-cache
  655. "e" gnus-score-edit-all-score)
  656. (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
  657. "d" gnus-group-describe-group
  658. "v" gnus-version)
  659. (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
  660. "l" gnus-group-set-current-level
  661. "t" gnus-group-unsubscribe-current-group
  662. "s" gnus-group-unsubscribe-group
  663. "k" gnus-group-kill-group
  664. "y" gnus-group-yank-group
  665. "w" gnus-group-kill-region
  666. "\C-k" gnus-group-kill-level
  667. "z" gnus-group-kill-all-zombies)
  668. (defun gnus-topic-mode-p ()
  669. "Return non-nil in `gnus-topic-mode'."
  670. (and (boundp 'gnus-topic-mode)
  671. (symbol-value 'gnus-topic-mode)))
  672. (defun gnus-group-make-menu-bar ()
  673. (unless (boundp 'gnus-group-reading-menu)
  674. (easy-menu-define
  675. gnus-group-reading-menu gnus-group-mode-map ""
  676. `("Group"
  677. ["Read" gnus-group-read-group
  678. :included (not (gnus-topic-mode-p))
  679. :active (gnus-group-group-name)]
  680. ["Read " gnus-topic-read-group
  681. :included (gnus-topic-mode-p)]
  682. ["Select" gnus-group-select-group
  683. :included (not (gnus-topic-mode-p))
  684. :active (gnus-group-group-name)]
  685. ["Select " gnus-topic-select-group
  686. :included (gnus-topic-mode-p)]
  687. ["See old articles" (gnus-group-select-group 'all)
  688. :keys "C-u SPC" :active (gnus-group-group-name)]
  689. ["Catch up" gnus-group-catchup-current
  690. :included (not (gnus-topic-mode-p))
  691. :active (gnus-group-group-name)
  692. ,@(if (featurep 'xemacs) nil
  693. '(:help "Mark unread articles in the current group as read"))]
  694. ["Catch up " gnus-topic-catchup-articles
  695. :included (gnus-topic-mode-p)
  696. ,@(if (featurep 'xemacs) nil
  697. '(:help "Mark unread articles in the current group or topic as read"))]
  698. ["Catch up all articles" gnus-group-catchup-current-all
  699. (gnus-group-group-name)]
  700. ["Check for new articles" gnus-group-get-new-news-this-group
  701. :included (not (gnus-topic-mode-p))
  702. :active (gnus-group-group-name)
  703. ,@(if (featurep 'xemacs) nil
  704. '(:help "Check for new messages in current group"))]
  705. ["Check for new articles " gnus-topic-get-new-news-this-topic
  706. :included (gnus-topic-mode-p)
  707. ,@(if (featurep 'xemacs) nil
  708. '(:help "Check for new messages in current group or topic"))]
  709. ["Toggle subscription" gnus-group-unsubscribe-current-group
  710. (gnus-group-group-name)]
  711. ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
  712. ,@(if (featurep 'xemacs) nil
  713. '(:help "Kill (remove) current group"))]
  714. ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
  715. ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
  716. ,@(if (featurep 'xemacs) nil
  717. '(:help "Display description of the current group"))]
  718. ;; Actually one should check, if any of the marked groups gives t for
  719. ;; (gnus-check-backend-function 'request-expire-articles ...)
  720. ["Expire articles" gnus-group-expire-articles
  721. :included (not (gnus-topic-mode-p))
  722. :active (or (and (gnus-group-group-name)
  723. (gnus-check-backend-function
  724. 'request-expire-articles
  725. (gnus-group-group-name))) gnus-group-marked)]
  726. ["Expire articles " gnus-topic-expire-articles
  727. :included (gnus-topic-mode-p)]
  728. ["Set group level..." gnus-group-set-current-level
  729. (gnus-group-group-name)]
  730. ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
  731. ["Customize" gnus-group-customize (gnus-group-group-name)]
  732. ["Compact" gnus-group-compact-group
  733. :active (gnus-group-group-name)]
  734. ("Edit"
  735. ["Parameters" gnus-group-edit-group-parameters
  736. :included (not (gnus-topic-mode-p))
  737. :active (gnus-group-group-name)]
  738. ["Parameters " gnus-topic-edit-parameters
  739. :included (gnus-topic-mode-p)]
  740. ["Select method" gnus-group-edit-group-method
  741. (gnus-group-group-name)]
  742. ["Info" gnus-group-edit-group (gnus-group-group-name)]
  743. ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
  744. ["Global kill file" gnus-group-edit-global-kill t])))
  745. (easy-menu-define
  746. gnus-group-group-menu gnus-group-mode-map ""
  747. '("Groups"
  748. ("Listing"
  749. ["List unread subscribed groups" gnus-group-list-groups t]
  750. ["List (un)subscribed groups" gnus-group-list-all-groups t]
  751. ["List killed groups" gnus-group-list-killed gnus-killed-list]
  752. ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
  753. ["List level..." gnus-group-list-level t]
  754. ["Describe all groups" gnus-group-describe-all-groups t]
  755. ["Group apropos..." gnus-group-apropos t]
  756. ["Group and description apropos..." gnus-group-description-apropos t]
  757. ["List groups matching..." gnus-group-list-matching t]
  758. ["List all groups matching..." gnus-group-list-all-matching t]
  759. ["List active file" gnus-group-list-active t]
  760. ["List groups with cached" gnus-group-list-cached t]
  761. ["List groups with dormant" gnus-group-list-dormant t]
  762. ["List groups with ticked" gnus-group-list-ticked t])
  763. ("Sort"
  764. ["Default sort" gnus-group-sort-groups t]
  765. ["Sort by method" gnus-group-sort-groups-by-method t]
  766. ["Sort by rank" gnus-group-sort-groups-by-rank t]
  767. ["Sort by score" gnus-group-sort-groups-by-score t]
  768. ["Sort by level" gnus-group-sort-groups-by-level t]
  769. ["Sort by unread" gnus-group-sort-groups-by-unread t]
  770. ["Sort by name" gnus-group-sort-groups-by-alphabet t]
  771. ["Sort by real name" gnus-group-sort-groups-by-real-name t])
  772. ("Sort process/prefixed"
  773. ["Default sort" gnus-group-sort-selected-groups
  774. (not (gnus-topic-mode-p))]
  775. ["Sort by method" gnus-group-sort-selected-groups-by-method
  776. (not (gnus-topic-mode-p))]
  777. ["Sort by rank" gnus-group-sort-selected-groups-by-rank
  778. (not (gnus-topic-mode-p))]
  779. ["Sort by score" gnus-group-sort-selected-groups-by-score
  780. (not (gnus-topic-mode-p))]
  781. ["Sort by level" gnus-group-sort-selected-groups-by-level
  782. (not (gnus-topic-mode-p))]
  783. ["Sort by unread" gnus-group-sort-selected-groups-by-unread
  784. (not (gnus-topic-mode-p))]
  785. ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
  786. (not (gnus-topic-mode-p))]
  787. ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
  788. (not (gnus-topic-mode-p))])
  789. ("Mark"
  790. ["Mark group" gnus-group-mark-group
  791. (and (gnus-group-group-name)
  792. (not (memq (gnus-group-group-name) gnus-group-marked)))]
  793. ["Unmark group" gnus-group-unmark-group
  794. (and (gnus-group-group-name)
  795. (memq (gnus-group-group-name) gnus-group-marked))]
  796. ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
  797. ["Mark regexp..." gnus-group-mark-regexp t]
  798. ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
  799. ["Mark buffer" gnus-group-mark-buffer t]
  800. ["Execute command" gnus-group-universal-argument
  801. (or gnus-group-marked (gnus-group-group-name))])
  802. ("Subscribe"
  803. ["Subscribe to a group..." gnus-group-unsubscribe-group t]
  804. ["Kill all newsgroups in region" gnus-group-kill-region
  805. :active (gnus-mark-active-p)]
  806. ["Kill all zombie groups" gnus-group-kill-all-zombies
  807. gnus-zombie-list]
  808. ["Kill all groups on level..." gnus-group-kill-level t])
  809. ("Foreign groups"
  810. ["Make a foreign group..." gnus-group-make-group t]
  811. ["Add a directory group..." gnus-group-make-directory-group t]
  812. ["Add the help group" gnus-group-make-help-group t]
  813. ["Make a doc group..." gnus-group-make-doc-group t]
  814. ["Make a web group..." gnus-group-make-web-group t]
  815. ["Make a search group..." gnus-group-make-nnir-group t]
  816. ["Make a virtual group..." gnus-group-make-empty-virtual t]
  817. ["Add a group to a virtual..." gnus-group-add-to-virtual t]
  818. ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
  819. ["Make an RSS group..." gnus-group-make-rss-group t]
  820. ["Rename group..." gnus-group-rename-group
  821. (gnus-check-backend-function
  822. 'request-rename-group (gnus-group-group-name))]
  823. ["Delete group" gnus-group-delete-group
  824. (gnus-check-backend-function
  825. 'request-delete-group (gnus-group-group-name))])
  826. ("Move"
  827. ["Next" gnus-group-next-group t]
  828. ["Previous" gnus-group-prev-group t]
  829. ["Next unread" gnus-group-next-unread-group t]
  830. ["Previous unread" gnus-group-prev-unread-group t]
  831. ["Next unread same level" gnus-group-next-unread-group-same-level t]
  832. ["Previous unread same level"
  833. gnus-group-prev-unread-group-same-level t]
  834. ["Jump to group..." gnus-group-jump-to-group t]
  835. ["First unread group" gnus-group-first-unread-group t]
  836. ["Best unread group" gnus-group-best-unread-group t])
  837. ("Sieve"
  838. ["Generate" gnus-sieve-generate t]
  839. ["Generate and update" gnus-sieve-update t])
  840. ["Delete bogus groups" gnus-group-check-bogus-groups t]
  841. ["Find new newsgroups" gnus-group-find-new-groups t]
  842. ["Transpose" gnus-group-transpose-groups
  843. (gnus-group-group-name)]
  844. ["Read a directory as a group..." gnus-group-enter-directory t]))
  845. (easy-menu-define
  846. gnus-group-misc-menu gnus-group-mode-map ""
  847. `("Gnus"
  848. ["Send a mail" gnus-group-mail t]
  849. ["Send a message (mail or news)" gnus-group-post-news t]
  850. ["Create a local message" gnus-group-news t]
  851. ["Check for new news" gnus-group-get-new-news
  852. ,@(if (featurep 'xemacs) '(t)
  853. '(:help "Get newly arrived articles"))
  854. ]
  855. ["Send queued messages" gnus-delay-send-queue
  856. ,@(if (featurep 'xemacs) '(t)
  857. '(:help "Send all messages that are scheduled to be sent now"))
  858. ]
  859. ["Activate all groups" gnus-activate-all-groups t]
  860. ["Restart Gnus" gnus-group-restart t]
  861. ["Read init file" gnus-group-read-init-file t]
  862. ["Browse foreign server..." gnus-group-browse-foreign-server t]
  863. ["Enter server buffer" gnus-group-enter-server-mode t]
  864. ["Expire all expirable articles" gnus-group-expire-all-groups t]
  865. ["Gnus version" gnus-version t]
  866. ["Save .newsrc files" gnus-group-save-newsrc t]
  867. ["Suspend Gnus" gnus-group-suspend t]
  868. ["Clear dribble buffer" gnus-group-clear-dribble t]
  869. ["Read manual" gnus-info-find-node t]
  870. ["Flush score cache" gnus-score-flush-cache t]
  871. ["Toggle topics" gnus-topic-mode t]
  872. ["Send a bug report" gnus-bug t]
  873. ["Exit from Gnus" gnus-group-exit
  874. ,@(if (featurep 'xemacs) '(t)
  875. '(:help "Quit reading news"))]
  876. ["Exit without saving" gnus-group-quit t]))
  877. (gnus-run-hooks 'gnus-group-menu-hook)))
  878. (defvar gnus-group-tool-bar-map nil)
  879. (defun gnus-group-tool-bar-update (&optional symbol value)
  880. "Update group buffer toolbar.
  881. Setter function for custom variables."
  882. (when symbol
  883. (set-default symbol value))
  884. ;; (setq-default gnus-group-tool-bar-map nil)
  885. ;; (use-local-map gnus-group-mode-map)
  886. (when (gnus-alive-p)
  887. (with-current-buffer gnus-group-buffer
  888. (gnus-group-make-tool-bar t))))
  889. (defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
  890. 'gnus-group-tool-bar-gnome
  891. 'gnus-group-tool-bar-retro)
  892. "Specifies the Gnus group tool bar.
  893. It can be either a list or a symbol referring to a list. See
  894. `gmm-tool-bar-from-list' for the format of the list. The
  895. default key map is `gnus-group-mode-map'.
  896. Pre-defined symbols include `gnus-group-tool-bar-gnome' and
  897. `gnus-group-tool-bar-retro'."
  898. :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
  899. (const :tag "Retro look" gnus-group-tool-bar-retro)
  900. (repeat :tag "User defined list" gmm-tool-bar-item)
  901. (symbol))
  902. :version "23.1" ;; No Gnus
  903. :initialize 'custom-initialize-default
  904. :set 'gnus-group-tool-bar-update
  905. :group 'gnus-group)
  906. (defcustom gnus-group-tool-bar-gnome
  907. '((gnus-group-post-news "mail/compose")
  908. ;; Some useful agent icons? I don't use the agent so agent users should
  909. ;; suggest useful commands:
  910. (gnus-agent-toggle-plugged "unplugged" t
  911. :help "Gnus is currently unplugged. Click to work online."
  912. :visible (and gnus-agent (not gnus-plugged)))
  913. (gnus-agent-toggle-plugged "plugged" t
  914. :help "Gnus is currently plugged. Click to work offline."
  915. :visible (and gnus-agent gnus-plugged))
  916. ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
  917. ;; should have a better help text.
  918. (gnus-group-send-queue "mail/outbox" t
  919. :visible (and gnus-agent gnus-plugged)
  920. :help "Send articles from the queue group")
  921. (gnus-group-get-new-news "mail/inbox" nil
  922. :visible (or (not gnus-agent)
  923. gnus-plugged))
  924. ;; FIXME: gnus-*-read-group should have a better help text.
  925. (gnus-topic-read-group "open" nil
  926. :visible (and (boundp 'gnus-topic-mode)
  927. gnus-topic-mode))
  928. (gnus-group-read-group "open" nil
  929. :visible (not (and (boundp 'gnus-topic-mode)
  930. gnus-topic-mode)))
  931. ;; (gnus-group-find-new-groups "???" nil)
  932. (gnus-group-save-newsrc "save")
  933. (gnus-group-describe-group "describe")
  934. (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
  935. (gnus-group-prev-unread-group "left-arrow")
  936. (gnus-group-next-unread-group "right-arrow")
  937. (gnus-group-exit "exit")
  938. (gmm-customize-mode "preferences" t :help "Edit mode preferences")
  939. (gnus-info-find-node "help"))
  940. "List of functions for the group tool bar (GNOME style).
  941. See `gmm-tool-bar-from-list' for the format of the list."
  942. :type '(repeat gmm-tool-bar-item)
  943. :version "23.1" ;; No Gnus
  944. :initialize 'custom-initialize-default
  945. :set 'gnus-group-tool-bar-update
  946. :group 'gnus-group)
  947. (defcustom gnus-group-tool-bar-retro
  948. '((gnus-group-get-new-news "gnus/get-news")
  949. (gnus-group-get-new-news-this-group "gnus/gnntg")
  950. (gnus-group-catchup-current "gnus/catchup")
  951. (gnus-group-describe-group "gnus/describe-group")
  952. (gnus-group-subscribe "gnus/subscribe" t
  953. :help "Subscribe to the current group")
  954. (gnus-group-unsubscribe "gnus/unsubscribe" t
  955. :help "Unsubscribe from the current group")
  956. (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
  957. "List of functions for the group tool bar (retro look).
  958. See `gmm-tool-bar-from-list' for the format of the list."
  959. :type '(repeat gmm-tool-bar-item)
  960. :version "23.1" ;; No Gnus
  961. :initialize 'custom-initialize-default
  962. :set 'gnus-group-tool-bar-update
  963. :group 'gnus-group)
  964. (defcustom gnus-group-tool-bar-zap-list t
  965. "List of icon items from the global tool bar.
  966. These items are not displayed in the Gnus group mode tool bar.
  967. See `gmm-tool-bar-from-list' for the format of the list."
  968. :type 'gmm-tool-bar-zap-list
  969. :version "23.1" ;; No Gnus
  970. :initialize 'custom-initialize-default
  971. :set 'gnus-group-tool-bar-update
  972. :group 'gnus-group)
  973. (defvar image-load-path)
  974. (defvar tool-bar-map)
  975. (defun gnus-group-make-tool-bar (&optional force)
  976. "Make a group mode tool bar from `gnus-group-tool-bar'.
  977. When FORCE, rebuild the tool bar."
  978. (when (and (not (featurep 'xemacs))
  979. (boundp 'tool-bar-mode)
  980. tool-bar-mode
  981. (display-graphic-p)
  982. (or (not gnus-group-tool-bar-map) force))
  983. (let* ((load-path
  984. (gmm-image-load-path-for-library "gnus"
  985. "gnus/toggle-subscription.xpm"
  986. nil t))
  987. (image-load-path (cons (car load-path)
  988. (when (boundp 'image-load-path)
  989. image-load-path)))
  990. (map (gmm-tool-bar-from-list gnus-group-tool-bar
  991. gnus-group-tool-bar-zap-list
  992. 'gnus-group-mode-map)))
  993. (if map
  994. (set (make-local-variable 'tool-bar-map) map))))
  995. gnus-group-tool-bar-map)
  996. (defun gnus-group-mode ()
  997. "Major mode for reading news.
  998. All normal editing commands are switched off.
  999. \\<gnus-group-mode-map>
  1000. The group buffer lists (some of) the groups available. For instance,
  1001. `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
  1002. lists all zombie groups.
  1003. Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
  1004. to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
  1005. For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
  1006. The following commands are available:
  1007. \\{gnus-group-mode-map}"
  1008. (interactive)
  1009. (kill-all-local-variables)
  1010. (when (gnus-visual-p 'group-menu 'menu)
  1011. (gnus-group-make-menu-bar)
  1012. (gnus-group-make-tool-bar))
  1013. (gnus-simplify-mode-line)
  1014. (setq major-mode 'gnus-group-mode)
  1015. (setq mode-name "Group")
  1016. (gnus-group-set-mode-line)
  1017. (setq mode-line-process nil)
  1018. (use-local-map gnus-group-mode-map)
  1019. (buffer-disable-undo)
  1020. (setq truncate-lines t)
  1021. (setq buffer-read-only t
  1022. show-trailing-whitespace nil)
  1023. (gnus-set-default-directory)
  1024. (gnus-update-format-specifications nil 'group 'group-mode)
  1025. (gnus-update-group-mark-positions)
  1026. (when gnus-use-undo
  1027. (gnus-undo-mode 1))
  1028. (when gnus-slave
  1029. (gnus-slave-mode))
  1030. (gnus-run-mode-hooks 'gnus-group-mode-hook))
  1031. (defun gnus-update-group-mark-positions ()
  1032. (save-excursion
  1033. (let ((gnus-process-mark ?\200)
  1034. (gnus-group-update-hook nil)
  1035. (gnus-group-marked '("dummy.group"))
  1036. (gnus-active-hashtb (make-vector 10 0))
  1037. (topic ""))
  1038. (gnus-set-active "dummy.group" '(0 . 0))
  1039. (gnus-set-work-buffer)
  1040. (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
  1041. (goto-char (point-min))
  1042. (setq gnus-group-mark-positions
  1043. (list (cons 'process (and (search-forward
  1044. (mm-string-to-multibyte "\200") nil t)
  1045. (- (point) (point-min) 1))))))))
  1046. (defun gnus-mouse-pick-group (e)
  1047. "Enter the group under the mouse pointer."
  1048. (interactive "e")
  1049. (mouse-set-point e)
  1050. (gnus-group-read-group nil))
  1051. (defun gnus-group-default-list-level ()
  1052. "Return the real value for `gnus-group-default-list-level'."
  1053. (if (functionp gnus-group-default-list-level)
  1054. (funcall gnus-group-default-list-level)
  1055. gnus-group-default-list-level))
  1056. ;; Look at LEVEL and find out what the level is really supposed to be.
  1057. ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
  1058. ;; will depend on whether `gnus-group-use-permanent-levels' is used.
  1059. (defun gnus-group-default-level (&optional level number-or-nil)
  1060. (cond
  1061. (gnus-group-use-permanent-levels
  1062. (or (setq gnus-group-use-permanent-levels
  1063. (or level (if (numberp gnus-group-use-permanent-levels)
  1064. gnus-group-use-permanent-levels
  1065. (or (gnus-group-default-list-level)
  1066. gnus-level-subscribed))))
  1067. (gnus-group-default-list-level) gnus-level-subscribed))
  1068. (number-or-nil
  1069. level)
  1070. (t
  1071. (or level (gnus-group-default-list-level) gnus-level-subscribed))))
  1072. (defun gnus-group-setup-buffer ()
  1073. (set-buffer (gnus-get-buffer-create gnus-group-buffer))
  1074. (unless (eq major-mode 'gnus-group-mode)
  1075. (gnus-group-mode)))
  1076. (defun gnus-group-name-charset (method group)
  1077. (unless method
  1078. (setq method (gnus-find-method-for-group group)))
  1079. (when (stringp method)
  1080. (setq method (gnus-server-to-method method)))
  1081. (if (eq (car method) 'nnimap)
  1082. ;; IMAP groups should not be encoded, since they do the encoding
  1083. ;; in utf7 in the protocol.
  1084. 'utf-8
  1085. (let ((item (or (assoc method gnus-group-name-charset-method-alist)
  1086. (and (consp method)
  1087. (assoc (list (car method) (cadr method))
  1088. gnus-group-name-charset-method-alist))))
  1089. (alist gnus-group-name-charset-group-alist)
  1090. result)
  1091. (if item
  1092. (cdr item)
  1093. (while (setq item (pop alist))
  1094. (if (string-match (car item) group)
  1095. (setq alist nil
  1096. result (cdr item))))
  1097. result))))
  1098. (defun gnus-group-name-decode (string charset)
  1099. ;; Fixme: Don't decode in unibyte mode.
  1100. (if (and string charset (featurep 'mule))
  1101. (mm-decode-coding-string string charset)
  1102. string))
  1103. (defun gnus-group-decoded-name (string)
  1104. (let ((charset (gnus-group-name-charset nil string)))
  1105. (gnus-group-name-decode string charset)))
  1106. (defun gnus-group-list-groups (&optional level unread lowest)
  1107. "List newsgroups with level LEVEL or lower that have unread articles.
  1108. Default is all subscribed groups.
  1109. If argument UNREAD is non-nil, groups with no unread articles are also
  1110. listed.
  1111. Also see the `gnus-group-use-permanent-levels' variable."
  1112. (interactive
  1113. (list (if current-prefix-arg
  1114. (prefix-numeric-value current-prefix-arg)
  1115. (or
  1116. (gnus-group-default-level nil t)
  1117. (gnus-group-default-list-level)
  1118. gnus-level-subscribed))))
  1119. (unless level
  1120. (setq level (car gnus-group-list-mode)
  1121. unread (cdr gnus-group-list-mode)))
  1122. (setq level (gnus-group-default-level level))
  1123. (gnus-group-setup-buffer)
  1124. (gnus-update-format-specifications nil 'group 'group-mode)
  1125. (let ((case-fold-search nil)
  1126. (props (text-properties-at (point-at-bol)))
  1127. (empty (= (point-min) (point-max)))
  1128. (group (gnus-group-group-name))
  1129. number)
  1130. (set-buffer gnus-group-buffer)
  1131. (setq number (funcall gnus-group-prepare-function level unread lowest))
  1132. (when (or (and (numberp number)
  1133. (zerop number))
  1134. (zerop (buffer-size)))
  1135. ;; No groups in the buffer.
  1136. (gnus-message 5 "%s" gnus-no-groups-message))
  1137. ;; We have some groups displayed.
  1138. (goto-char (point-max))
  1139. (when (or (not gnus-group-goto-next-group-function)
  1140. (not (funcall gnus-group-goto-next-group-function
  1141. group props)))
  1142. (cond
  1143. (empty
  1144. (goto-char (point-min)))
  1145. ((not group)
  1146. ;; Go to the first group with unread articles.
  1147. (gnus-group-search-forward t))
  1148. (t
  1149. ;; Find the right group to put point on. If the current group
  1150. ;; has disappeared in the new listing, try to find the next
  1151. ;; one. If no next one can be found, just leave point at the
  1152. ;; first newsgroup in the buffer.
  1153. (when (not (gnus-goto-char
  1154. (text-property-any
  1155. (point-min) (point-max)
  1156. 'gnus-group (gnus-intern-safe
  1157. group gnus-active-hashtb))))
  1158. (let ((newsrc (cdddr (gnus-group-entry group))))
  1159. (while (and newsrc
  1160. (not (gnus-goto-char
  1161. (text-property-any
  1162. (point-min) (point-max) 'gnus-group
  1163. (gnus-intern-safe
  1164. (caar newsrc) gnus-active-hashtb)))))
  1165. (setq newsrc (cdr newsrc)))
  1166. (unless newsrc
  1167. (goto-char (point-max))
  1168. (forward-line -1)))))))
  1169. ;; Adjust cursor point.
  1170. (gnus-group-position-point)))
  1171. (defun gnus-group-list-level (level &optional all)
  1172. "List groups on LEVEL.
  1173. If ALL (the prefix), also list groups that have no unread articles."
  1174. (interactive "nList groups on level: \nP")
  1175. (gnus-group-list-groups level all level))
  1176. (defun gnus-group-prepare-logic (group test)
  1177. (or (and gnus-group-listed-groups
  1178. (null gnus-group-list-option)
  1179. (member group gnus-group-listed-groups))
  1180. (cond
  1181. ((null gnus-group-listed-groups) test)
  1182. ((null gnus-group-list-option) test)
  1183. (t (and (member group gnus-group-listed-groups)
  1184. (if (eq gnus-group-list-option 'flush)
  1185. (not test)
  1186. test))))))
  1187. (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
  1188. "List all newsgroups with unread articles of level LEVEL or lower.
  1189. If PREDICATE is a function, list groups that the function returns non-nil;
  1190. if it is t, list groups that have no unread articles.
  1191. If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
  1192. If REGEXP is a function, list dead groups that the function returns non-nil;
  1193. if it is a string, only list groups matching REGEXP."
  1194. (set-buffer gnus-group-buffer)
  1195. (let ((buffer-read-only nil)
  1196. (newsrc (cdr gnus-newsrc-alist))
  1197. (lowest (or lowest 1))
  1198. (not-in-list (and gnus-group-listed-groups
  1199. (copy-sequence gnus-group-listed-groups)))
  1200. info clevel unread group params)
  1201. (erase-buffer)
  1202. (when (or (< lowest gnus-level-zombie)
  1203. gnus-group-listed-groups)
  1204. ;; List living groups.
  1205. (while newsrc
  1206. (setq info (car newsrc)
  1207. group (gnus-info-group info)
  1208. params (gnus-info-params info)
  1209. newsrc (cdr newsrc)
  1210. unread (gnus-group-unread group))
  1211. (when not-in-list
  1212. (setq not-in-list (delete group not-in-list)))
  1213. (when (gnus-group-prepare-logic
  1214. group
  1215. (and (or unread ; This group might be unchecked
  1216. predicate) ; Check if this group should be listed
  1217. (or (not (stringp regexp))
  1218. (string-match regexp group))
  1219. (<= (setq clevel (gnus-info-level info)) level)
  1220. (>= clevel lowest)
  1221. (cond
  1222. ((functionp predicate)
  1223. (funcall predicate info))
  1224. (predicate t) ; We list all groups?
  1225. (t
  1226. (or
  1227. (if (eq unread t) ; Inactive?
  1228. gnus-group-list-inactive-groups
  1229. ; We list inactive
  1230. (and (numberp unread) (> unread 0)))
  1231. ; We list groups with unread articles
  1232. (and gnus-list-groups-with-ticked-articles
  1233. (cdr (assq 'tick (gnus-info-marks info))))
  1234. ; And groups with ticked articles
  1235. ;; Check for permanent visibility.
  1236. (and gnus-permanently-visible-groups
  1237. (string-match gnus-permanently-visible-groups
  1238. group))
  1239. (memq 'visible params)
  1240. (cdr (assq 'visible params)))))))
  1241. (gnus-group-insert-group-line
  1242. group (gnus-info-level info)
  1243. (gnus-info-marks info) unread (gnus-info-method info)))))
  1244. ;; List dead groups.
  1245. (when (or gnus-group-listed-groups
  1246. (and (>= level gnus-level-zombie)
  1247. (<= lowest gnus-level-zombie)))
  1248. (gnus-group-prepare-flat-list-dead
  1249. (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
  1250. gnus-level-zombie ?Z
  1251. regexp))
  1252. (when not-in-list
  1253. (dolist (group gnus-zombie-list)
  1254. (setq not-in-list (delete group not-in-list))))
  1255. (when (or gnus-group-listed-groups
  1256. (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
  1257. (gnus-group-prepare-flat-list-dead
  1258. (gnus-union
  1259. not-in-list
  1260. (setq gnus-killed-list (sort gnus-killed-list 'string<)))
  1261. gnus-level-killed ?K regexp))
  1262. (gnus-group-set-mode-line)
  1263. (setq gnus-group-list-mode (cons level predicate))
  1264. (gnus-run-hooks 'gnus-group-prepare-hook)
  1265. t))
  1266. (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
  1267. ;; List zombies and killed lists somewhat faster, which was
  1268. ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
  1269. ;; this by ignoring the group format specification altogether.
  1270. (let (group)
  1271. (if (> (length groups) gnus-group-listing-limit)
  1272. (while groups
  1273. (setq group (pop groups))
  1274. (when (gnus-group-prepare-logic
  1275. group
  1276. (or (not regexp)
  1277. (and (stringp regexp) (string-match regexp group))
  1278. (and (functionp regexp) (funcall regexp group))))
  1279. (gnus-add-text-properties
  1280. (point) (prog1 (1+ (point))
  1281. (insert " " mark " *: "
  1282. (gnus-group-decoded-name group)
  1283. "\n"))
  1284. (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
  1285. 'gnus-unread t
  1286. 'gnus-level level))))
  1287. (while groups
  1288. (setq group (pop groups))
  1289. (when (gnus-group-prepare-logic
  1290. group
  1291. (or (not regexp)
  1292. (and (stringp regexp) (string-match regexp group))
  1293. (and (functionp regexp) (funcall regexp group))))
  1294. (gnus-group-insert-group-line
  1295. group level nil
  1296. (let ((active (gnus-active group)))
  1297. (if active
  1298. (if (zerop (cdr active))
  1299. 0
  1300. (- (1+ (cdr active)) (car active)))
  1301. nil))
  1302. (gnus-method-simplify (gnus-find-method-for-group group))))))))
  1303. (defun gnus-group-update-group-line ()
  1304. "Update the current line in the group buffer."
  1305. (let* ((buffer-read-only nil)
  1306. (group (gnus-group-group-name))
  1307. (entry (and group (gnus-group-entry group)))
  1308. gnus-group-indentation)
  1309. (when group
  1310. (and entry
  1311. (not (gnus-ephemeral-group-p group))
  1312. (gnus-dribble-enter
  1313. (concat "(gnus-group-set-info '"
  1314. (gnus-prin1-to-string (nth 2 entry))
  1315. ")")
  1316. (concat "^(gnus-group-set-info '(\"" (regexp-quote group) "\"")))
  1317. (setq gnus-group-indentation (gnus-group-group-indentation))
  1318. (gnus-delete-line)
  1319. (gnus-group-insert-group-line-info group)
  1320. (forward-line -1)
  1321. (gnus-group-position-point))))
  1322. (defun gnus-group-insert-group-line-info (group)
  1323. "Insert GROUP on the current line."
  1324. (let ((entry (gnus-group-entry group))
  1325. (gnus-group-indentation (gnus-group-group-indentation))
  1326. active info)
  1327. (if entry
  1328. (progn
  1329. ;; (Un)subscribed group.
  1330. (setq info (nth 2 entry))
  1331. (gnus-group-insert-group-line
  1332. group (gnus-info-level info) (gnus-info-marks info)
  1333. (or (car entry) t) (gnus-info-method info)))
  1334. ;; This group is dead.
  1335. (gnus-group-insert-group-line
  1336. group
  1337. (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
  1338. nil
  1339. (if (setq active (gnus-active group))
  1340. (if (zerop (cdr active))
  1341. 0
  1342. (- (1+ (cdr active)) (car active)))
  1343. nil)
  1344. (gnus-method-simplify (gnus-find-method-for-group group))))))
  1345. (defun gnus-number-of-unseen-articles-in-group (group)
  1346. (let* ((info (nth 2 (gnus-group-entry group)))
  1347. (marked (gnus-info-marks info))
  1348. (seen (cdr (assq 'seen marked)))
  1349. (active (gnus-active group)))
  1350. (if (not active)
  1351. 0
  1352. (length (gnus-uncompress-range
  1353. (gnus-range-difference
  1354. (gnus-range-difference (list active) (gnus-info-read info))
  1355. seen))))))
  1356. ;; Moving through the Group buffer (in topic mode) e.g. with C-n doesn't
  1357. ;; update the state (enabled/disabled) of the icon `gnus-group-describe-group'
  1358. ;; automatically. After `C-l' the state is correct. See the following report
  1359. ;; on emacs-devel
  1360. ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
  1361. ;; From: Reiner Steib
  1362. ;; Subject: tool bar icons not updated according to :active condition
  1363. ;; Newsgroups: gmane.emacs.devel
  1364. ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
  1365. ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
  1366. (defcustom gnus-group-update-tool-bar
  1367. (and (not (featurep 'xemacs))
  1368. (boundp 'tool-bar-mode)
  1369. tool-bar-mode
  1370. ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs might
  1371. ;; be confusing, so maybe we shouldn't call it by default.
  1372. (fboundp 'force-window-update))
  1373. "Force updating the group buffer tool bar."
  1374. :group 'gnus-group
  1375. :version "22.1"
  1376. :initialize 'custom-initialize-default
  1377. :set (lambda (symbol value)
  1378. (set-default symbol value)
  1379. (when (gnus-alive-p)
  1380. (with-current-buffer gnus-group-buffer
  1381. ;; FIXME: Is there a better way to redraw the group buffer?
  1382. (gnus-group-get-new-news 0))))
  1383. :type 'boolean)
  1384. (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
  1385. gnus-tmp-marked number
  1386. gnus-tmp-method)
  1387. "Insert a group line in the group buffer."
  1388. (let* ((gnus-tmp-method
  1389. (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
  1390. (group-name-charset (gnus-group-name-charset gnus-tmp-method
  1391. gnus-tmp-group))
  1392. (gnus-tmp-active (gnus-active gnus-tmp-group))
  1393. (gnus-tmp-number-total
  1394. (if gnus-tmp-active
  1395. (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
  1396. 0))
  1397. (gnus-tmp-number-of-unread
  1398. (if (numberp number) (int-to-string (max 0 number))
  1399. "*"))
  1400. (gnus-tmp-number-of-read
  1401. (if (numberp number)
  1402. (int-to-string (max 0 (- gnus-tmp-number-total number)))
  1403. "*"))
  1404. (gnus-tmp-subscribed
  1405. (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
  1406. ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
  1407. ((= gnus-tmp-level gnus-level-zombie) ?Z)
  1408. (t ?K)))
  1409. (gnus-tmp-qualified-group
  1410. (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
  1411. group-name-charset))
  1412. (gnus-tmp-comment
  1413. (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
  1414. gnus-tmp-group))
  1415. (gnus-tmp-newsgroup-description
  1416. (if gnus-description-hashtb
  1417. (or (gnus-group-name-decode
  1418. (gnus-gethash gnus-tmp-group gnus-description-hashtb)
  1419. group-name-charset) "")
  1420. ""))
  1421. (gnus-tmp-moderated
  1422. (if (and gnus-moderated-hashtb
  1423. (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
  1424. ?m ? ))
  1425. (gnus-tmp-moderated-string
  1426. (if (eq gnus-tmp-moderated ?m) "(m)" ""))
  1427. (gnus-tmp-group-icon (gnus-group-get-icon gnus-tmp-group))
  1428. (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
  1429. (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
  1430. (gnus-tmp-news-method-string
  1431. (if gnus-tmp-method
  1432. (format "(%s:%s)" (car gnus-tmp-method)
  1433. (cadr gnus-tmp-method)) ""))
  1434. (gnus-tmp-marked-mark
  1435. (if (and (numberp number)
  1436. (zerop number)
  1437. (cdr (assq 'tick gnus-tmp-marked)))
  1438. ?* ? ))
  1439. (gnus-tmp-summary-live
  1440. (if (and (not gnus-group-is-exiting-p)
  1441. (gnus-buffer-live-p (gnus-summary-buffer-name
  1442. gnus-tmp-group)))
  1443. ?* ? ))
  1444. (gnus-tmp-process-marked
  1445. (if (member gnus-tmp-group gnus-group-marked)
  1446. gnus-process-mark ? ))
  1447. (buffer-read-only nil)
  1448. beg end
  1449. header gnus-tmp-header) ; passed as parameter to user-funcs.
  1450. (beginning-of-line)
  1451. (setq beg (point))
  1452. (gnus-add-text-properties
  1453. (point)
  1454. (prog1 (1+ (point))
  1455. ;; Insert the text.
  1456. (let ((gnus-tmp-decoded-group (gnus-group-name-decode
  1457. gnus-tmp-group group-name-charset)))
  1458. (eval gnus-group-line-format-spec)))
  1459. `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
  1460. gnus-unread ,(if (numberp number)
  1461. (string-to-number gnus-tmp-number-of-unread)
  1462. t)
  1463. gnus-marked ,gnus-tmp-marked-mark
  1464. gnus-indentation ,gnus-group-indentation
  1465. gnus-level ,gnus-tmp-level))
  1466. (setq end (point))
  1467. (when gnus-group-update-tool-bar
  1468. (gnus-put-text-property beg end 'point-entered
  1469. 'gnus-tool-bar-update)
  1470. (gnus-put-text-property beg end 'point-left
  1471. 'gnus-tool-bar-update))
  1472. (forward-line -1)
  1473. (when (inline (gnus-visual-p 'group-highlight 'highlight))
  1474. (gnus-group-highlight-line gnus-tmp-group beg end))
  1475. (gnus-run-hooks 'gnus-group-update-hook)
  1476. (forward-line)))
  1477. (defun gnus-group-update-eval-form (group list)
  1478. "Eval `car' of each element of LIST, and return the first that return t.
  1479. Some value are bound so the form can use them."
  1480. (when list
  1481. (let* ((entry (gnus-group-entry group))
  1482. (unread (if (numberp (car entry)) (car entry) 0))
  1483. (active (gnus-active group))
  1484. (total (if active (1+ (- (cdr active) (car active))) 0))
  1485. (info (nth 2 entry))
  1486. (method (inline (gnus-server-get-method group (gnus-info-method info))))
  1487. (marked (gnus-info-marks info))
  1488. (mailp (apply 'append
  1489. (mapcar
  1490. (lambda (x)
  1491. (memq x (assoc (symbol-name
  1492. (car (or method gnus-select-method)))
  1493. gnus-valid-select-methods)))
  1494. '(mail post-mail))))
  1495. (level (or (gnus-info-level info) gnus-level-killed))
  1496. (score (or (gnus-info-score info) 0))
  1497. (ticked (gnus-range-length (cdr (assq 'tick marked))))
  1498. (group-age (gnus-group-timestamp-delta group)))
  1499. ;; FIXME: http://thread.gmane.org/gmane.emacs.gnus.general/65451/focus=65465
  1500. ;; ======================================================================
  1501. ;; From: Richard Stallman
  1502. ;; Subject: Re: Rewriting gnus-group-highlight-line (was: [...])
  1503. ;; Cc: ding@gnus.org
  1504. ;; Date: Sat, 27 Oct 2007 19:41:20 -0400
  1505. ;; Message-ID: <E1IlvHM-0006TS-7t@fencepost.gnu.org>
  1506. ;;
  1507. ;; [...]
  1508. ;; The kludge is that the alist elements contain expressions that refer
  1509. ;; to local variables with short names. Perhaps write your own tiny
  1510. ;; evaluator that handles just `and', `or', and numeric comparisons
  1511. ;; and just a few specific variables.
  1512. ;; ======================================================================
  1513. ;;
  1514. ;; Similar for other evaluated variables. Grep for risky-local-variable
  1515. ;; to find them! -- rsteib
  1516. ;;
  1517. ;; Eval the cars of the lists until we find a match.
  1518. (while (and list
  1519. (not (eval (caar list))))
  1520. (setq list (cdr list)))
  1521. list)))
  1522. (defun gnus-group-highlight-line (group beg end)
  1523. "Highlight the current line according to `gnus-group-highlight'.
  1524. GROUP is current group, and the line to highlight starts at BEG
  1525. and ends at END."
  1526. (let ((face (cdar (gnus-group-update-eval-form
  1527. group
  1528. gnus-group-highlight))))
  1529. (unless (eq face (get-text-property beg 'face))
  1530. (let ((inhibit-read-only t))
  1531. (gnus-put-text-property-excluding-characters-with-faces
  1532. beg end 'face
  1533. (if (boundp face) (symbol-value face) face)))
  1534. (gnus-extent-start-open beg))))
  1535. (defun gnus-group-get-icon (group)
  1536. "Return an icon for GROUP according to `gnus-group-icon-list'."
  1537. (if gnus-group-icon-list
  1538. (let ((image-path
  1539. (cdar (gnus-group-update-eval-form group gnus-group-icon-list))))
  1540. (if image-path
  1541. (propertize " "
  1542. 'display
  1543. (append
  1544. (gnus-create-image (expand-file-name image-path))
  1545. '(:ascent center)))
  1546. " "))
  1547. " "))
  1548. (defun gnus-group-refresh-group (group)
  1549. (gnus-activate-group group)
  1550. (gnus-get-unread-articles-in-group (gnus-get-info group)
  1551. (gnus-active group))
  1552. (gnus-group-update-group group))
  1553. (defun gnus-group-update-group (group &optional visible-only
  1554. info-unchanged)
  1555. "Update all lines where GROUP appear.
  1556. If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
  1557. already. If INFO-UNCHANGED is non-nil, dribble buffer is not updated."
  1558. (with-current-buffer gnus-group-buffer
  1559. (save-excursion
  1560. ;; The buffer may be narrowed.
  1561. (save-restriction
  1562. (widen)
  1563. (let ((ident (gnus-intern-safe group gnus-active-hashtb))
  1564. (loc (point-min))
  1565. found buffer-read-only)
  1566. (unless info-unchanged
  1567. ;; Enter the current status into the dribble buffer.
  1568. (let ((entry (gnus-group-entry group)))
  1569. (when (and entry
  1570. (not (gnus-ephemeral-group-p group)))
  1571. (gnus-dribble-enter
  1572. (concat "(gnus-group-set-info '"
  1573. (gnus-prin1-to-string (nth 2 entry))
  1574. ")")
  1575. (concat "^(gnus-group-set-info '(\""
  1576. (regexp-quote group) "\"")))))
  1577. ;; Find all group instances. If topics are in use, each group
  1578. ;; may be listed in more than once.
  1579. (while (setq loc (text-property-any
  1580. loc (point-max) 'gnus-group ident))
  1581. (setq found t)
  1582. (goto-char loc)
  1583. (let ((gnus-group-indentation (gnus-group-group-indentation)))
  1584. (gnus-delete-line)
  1585. (gnus-group-insert-group-line-info group)
  1586. (save-excursion
  1587. (forward-line -1)
  1588. (gnus-run-hooks 'gnus-group-update-group-hook)))
  1589. (setq loc (1+ loc)))
  1590. (unless (or found visible-only)
  1591. ;; No such line in the buffer, find out where it's supposed to
  1592. ;; go, and insert it there (or at the end of the buffer).
  1593. (if gnus-goto-missing-group-function
  1594. (funcall gnus-goto-missing-group-function group)
  1595. (let ((entry (cddr (gnus-group-entry group))))
  1596. (while (and entry (car entry)
  1597. (not
  1598. (gnus-goto-char
  1599. (text-property-any
  1600. (point-min) (point-max)
  1601. 'gnus-group (gnus-intern-safe
  1602. (caar entry)
  1603. gnus-active-hashtb)))))
  1604. (setq entry (cdr entry)))
  1605. (or entry (goto-char (point-max)))))
  1606. ;; Finally insert the line.
  1607. (let ((gnus-group-indentation (gnus-group-group-indentation)))
  1608. (gnus-group-insert-group-line-info group)
  1609. (save-excursion
  1610. (forward-line -1)
  1611. (gnus-run-hooks 'gnus-group-update-group-hook))))
  1612. (when gnus-group-update-group-function
  1613. (funcall gnus-group-update-group-function group))
  1614. (gnus-group-set-mode-line))))))
  1615. (defun gnus-group-set-mode-line ()
  1616. "Update the mode line in the group buffer."
  1617. (when (memq 'group gnus-updated-mode-lines)
  1618. ;; Yes, we want to keep this mode line updated.
  1619. (with-current-buffer gnus-group-buffer
  1620. (let* ((gformat (or gnus-group-mode-line-format-spec
  1621. (gnus-set-format 'group-mode)))
  1622. (gnus-tmp-news-server (cadr gnus-select-method))
  1623. (gnus-tmp-news-method (car gnus-select-method))
  1624. (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
  1625. (max-len 60)
  1626. gnus-tmp-header ;Dummy binding for user-defined formats
  1627. ;; Get the resulting string.
  1628. (modified
  1629. (and gnus-dribble-buffer
  1630. (buffer-name gnus-dribble-buffer)
  1631. (buffer-modified-p gnus-dribble-buffer)
  1632. (with-current-buffer gnus-dribble-buffer
  1633. (not (zerop (buffer-size))))))
  1634. (mode-string (eval gformat)))
  1635. ;; Say whether the dribble buffer has been modified.
  1636. (setq mode-line-modified
  1637. (if modified (car gnus-mode-line-modified)
  1638. (cdr gnus-mode-line-modified)))
  1639. ;; If the line is too long, we chop it off.
  1640. (when (> (length mode-string) max-len)
  1641. (setq mode-string (substring mode-string 0 (- max-len 4))))
  1642. (prog1
  1643. (setq mode-line-buffer-identification
  1644. (gnus-mode-line-buffer-identification
  1645. (list mode-string)))
  1646. (set-buffer-modified-p modified))))))
  1647. (defun gnus-group-group-name ()
  1648. "Get the name of the newsgroup on the current line."
  1649. (let ((group (get-text-property (point-at-bol) 'gnus-group)))
  1650. (when group
  1651. (symbol-name group))))
  1652. (defun gnus-group-group-level ()
  1653. "Get the level of the newsgroup on the current line."
  1654. (get-text-property (point-at-bol) 'gnus-level))
  1655. (defun gnus-group-group-indentation ()
  1656. "Get the indentation of the newsgroup on the current line."
  1657. (or (get-text-property (point-at-bol) 'gnus-indentation)
  1658. (and gnus-group-indentation-function
  1659. (funcall gnus-group-indentation-function))
  1660. ""))
  1661. (defun gnus-group-group-unread ()
  1662. "Get the number of unread articles of the newsgroup on the current line."
  1663. (get-text-property (point-at-bol) 'gnus-unread))
  1664. (defun gnus-group-new-mail (group)
  1665. (if (nnmail-new-mail-p (gnus-group-real-name group))
  1666. gnus-new-mail-mark
  1667. ? ))
  1668. (defun gnus-group-level (group)
  1669. "Return the estimated level of GROUP."
  1670. (or (gnus-info-level (gnus-get-info group))
  1671. (and (member group gnus-zombie-list) gnus-level-zombie)
  1672. gnus-level-killed))
  1673. (defun gnus-group-search-forward (&optional backward all level first-too)
  1674. "Find the next newsgroup with unread articles.
  1675. If BACKWARD is non-nil, find the previous newsgroup instead.
  1676. If ALL is non-nil, just find any newsgroup.
  1677. If LEVEL is non-nil, find group with level LEVEL, or higher if no such
  1678. group exists.
  1679. If FIRST-TOO, the current line is also eligible as a target."
  1680. (let ((way (if backward -1 1))
  1681. (low gnus-level-killed)
  1682. (beg (point))
  1683. pos found lev)
  1684. (if (and backward (progn (beginning-of-line)) (bobp))
  1685. nil
  1686. (unless first-too
  1687. (forward-line way))
  1688. (while (and
  1689. (not (eobp))
  1690. (not (setq
  1691. found
  1692. (and
  1693. (get-text-property (point) 'gnus-group)
  1694. (or all
  1695. (and
  1696. (let ((unread
  1697. (get-text-property (point) 'gnus-unread)))
  1698. (and (numberp unread) (> unread 0)))
  1699. (setq lev (get-text-property (point)
  1700. 'gnus-level))
  1701. (<= lev gnus-level-subscribed)))
  1702. (or (not level)
  1703. (and (setq lev (get-text-property (point)
  1704. 'gnus-level))
  1705. (or (= lev level)
  1706. (and (< lev low)
  1707. (< level lev)
  1708. (progn
  1709. (setq low lev)
  1710. (setq pos (point))
  1711. nil))))))))
  1712. (zerop (forward-line way)))))
  1713. (if found
  1714. (progn (gnus-group-position-point) t)
  1715. (goto-char (or pos beg))
  1716. (and pos t))))
  1717. (defun gnus-total-fetched-for (group)
  1718. (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
  1719. (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
  1720. (size (+ size-in-cache size-in-agent))
  1721. (suffix '("B" "K" "M" "G"))
  1722. (scale 1024.0)
  1723. (cutoff scale))
  1724. (while (> size cutoff)
  1725. (setq size (/ size scale)
  1726. suffix (cdr suffix)))
  1727. (format "%5.1f%s" size (car suffix))))
  1728. ;;; Gnus group mode commands
  1729. ;; Group marking.
  1730. (defun gnus-group-mark-line-p ()
  1731. (save-excursion
  1732. (beginning-of-line)
  1733. (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
  1734. (eq (char-after) gnus-process-mark)))
  1735. (defun gnus-group-mark-group (n &optional unmark no-advance)
  1736. "Mark the current group."
  1737. (interactive "p")
  1738. (let ((buffer-read-only nil)
  1739. group)
  1740. (while (and (> n 0)
  1741. (not (eobp)))
  1742. (when (setq group (gnus-group-group-name))
  1743. ;; Go to the mark position.
  1744. (beginning-of-line)
  1745. (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
  1746. (delete-char 1)
  1747. (if unmark
  1748. (progn
  1749. (setq gnus-group-marked (delete group gnus-group-marked))
  1750. (insert-char ? 1 t))
  1751. (setq gnus-group-marked
  1752. (cons group (delete group gnus-group-marked)))
  1753. (insert-char gnus-process-mark 1 t)))
  1754. (unless no-advance
  1755. (gnus-group-next-group 1))
  1756. (decf n))
  1757. (gnus-group-position-point)
  1758. n))
  1759. (defun gnus-group-unmark-group (n)
  1760. "Remove the mark from the current group."
  1761. (interactive "p")
  1762. (gnus-group-mark-group n 'unmark)
  1763. (gnus-group-position-point))
  1764. (defun gnus-group-unmark-all-groups ()
  1765. "Unmark all groups."
  1766. (interactive)
  1767. (save-excursion
  1768. (mapc 'gnus-group-remove-mark gnus-group-marked))
  1769. (gnus-group-position-point))
  1770. (defun gnus-group-mark-region (unmark beg end)
  1771. "Mark all groups between point and mark.
  1772. If UNMARK, remove the mark instead."
  1773. (interactive "P\nr")
  1774. (let ((num (count-lines beg end)))
  1775. (save-excursion
  1776. (goto-char beg)
  1777. (- num (gnus-group-mark-group num unmark)))))
  1778. (defun gnus-group-mark-buffer (&optional unmark)
  1779. "Mark all groups in the buffer.
  1780. If UNMARK, remove the mark instead."
  1781. (interactive "P")
  1782. (gnus-group-mark-region unmark (point-min) (point-max)))
  1783. (defun gnus-group-mark-regexp (regexp)
  1784. "Mark all groups that match some regexp."
  1785. (interactive "sMark (regexp): ")
  1786. (let ((alist (cdr gnus-newsrc-alist))
  1787. group)
  1788. (save-excursion
  1789. (while alist
  1790. (when (string-match regexp (setq group (gnus-info-group (pop alist))))
  1791. (gnus-group-jump-to-group group)
  1792. (gnus-group-set-mark group)))))
  1793. (gnus-group-position-point))
  1794. (defun gnus-group-remove-mark (group &optional test-marked)
  1795. "Remove the process mark from GROUP and move point there.
  1796. Return nil if the group isn't displayed."
  1797. (if (gnus-group-goto-group group nil test-marked)
  1798. (save-excursion
  1799. (gnus-group-mark-group 1 'unmark t)
  1800. t)
  1801. (setq gnus-group-marked
  1802. (delete group gnus-group-marked))
  1803. nil))
  1804. (defun gnus-group-set-mark (group)
  1805. "Set the process mark on GROUP."
  1806. (if (gnus-group-goto-group group)
  1807. (save-excursion
  1808. (gnus-group-mark-group 1 nil t))
  1809. (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
  1810. (defun gnus-group-universal-argument (arg &optional groups func)
  1811. "Perform any command on all groups according to the process/prefix convention."
  1812. (interactive "P")
  1813. (if (eq (setq func (or func
  1814. (key-binding
  1815. (read-key-sequence
  1816. (substitute-command-keys
  1817. "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
  1818. 'undefined)
  1819. (gnus-error 1 "Undefined key")
  1820. (gnus-group-iterate arg
  1821. (lambda (group)
  1822. (command-execute func))))
  1823. (gnus-group-position-point))
  1824. (defun gnus-group-process-prefix (n)
  1825. "Return a list of groups to work on.
  1826. Take into consideration N (the prefix) and the list of marked groups."
  1827. (cond
  1828. (n
  1829. (setq n (prefix-numeric-value n))
  1830. ;; There is a prefix, so we return a list of the N next
  1831. ;; groups.
  1832. (let ((way (if (< n 0) -1 1))
  1833. (n (abs n))
  1834. group groups)
  1835. (save-excursion
  1836. (while (> n 0)
  1837. (if (setq group (gnus-group-group-name))
  1838. (push group groups))
  1839. (setq n (1- n))
  1840. (gnus-group-next-group way)))
  1841. (nreverse groups)))
  1842. ((and (gnus-region-active-p) (mark))
  1843. ;; Work on the region between point and mark.
  1844. (let ((max (max (point) (mark)))
  1845. groups)
  1846. (save-excursion
  1847. (goto-char (min (point) (mark)))
  1848. (while
  1849. (and
  1850. (push (gnus-group-group-name) groups)
  1851. (zerop (gnus-group-next-group 1))
  1852. (< (point) max)))
  1853. (nreverse groups))))
  1854. (gnus-group-marked
  1855. ;; No prefix, but a list of marked articles.
  1856. (reverse gnus-group-marked))
  1857. (t
  1858. ;; Neither marked articles or a prefix, so we return the
  1859. ;; current group.
  1860. (let ((group (gnus-group-group-name)))
  1861. (and group (list group))))))
  1862. ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
  1863. ;;; imagine why I went through these contortions...
  1864. (eval-and-compile
  1865. (let ((function (make-symbol "gnus-group-iterate-function"))
  1866. (window (make-symbol "gnus-group-iterate-window"))
  1867. (groups (make-symbol "gnus-group-iterate-groups"))
  1868. (group (make-symbol "gnus-group-iterate-group")))
  1869. (eval
  1870. `(defun gnus-group-iterate (arg ,function)
  1871. "Iterate FUNCTION over all process/prefixed groups.
  1872. FUNCTION will be called with the group name as the parameter
  1873. and with point over the group in question."
  1874. (let ((,groups (gnus-group-process-prefix arg))
  1875. (,window (selected-window))
  1876. ,group)
  1877. (while ,groups
  1878. (setq ,group (car ,groups)
  1879. ,groups (cdr ,groups))
  1880. (select-window ,window)
  1881. (gnus-group-remove-mark ,group)
  1882. (save-selected-window
  1883. (save-excursion
  1884. (funcall ,function ,group)))))))))
  1885. (put 'gnus-group-iterate 'lisp-indent-function 1)
  1886. ;; Selecting groups.
  1887. (defun gnus-group-read-group (&optional all no-article group select-articles)
  1888. "Read news in this newsgroup.
  1889. If the prefix argument ALL is non-nil, already read articles become
  1890. readable.
  1891. If ALL is a positive number, fetch this number of the latest
  1892. articles in the group. If ALL is a negative number, fetch this
  1893. number of the earliest articles in the group.
  1894. If the optional argument NO-ARTICLE is non-nil, no article will
  1895. be auto-selected upon group entry. If GROUP is non-nil, fetch
  1896. that group."
  1897. (interactive "P")
  1898. (let ((no-display (eq all 0))
  1899. (group (or group (gnus-group-group-name)))
  1900. number active marked entry)
  1901. (when (eq all 0)
  1902. (setq all nil))
  1903. (unless group
  1904. (error "No group on current line"))
  1905. (setq marked (gnus-info-marks
  1906. (nth 2 (setq entry (gnus-group-entry group)))))
  1907. ;; This group might be a dead group. In that case we have to get
  1908. ;; the number of unread articles from `gnus-active-hashtb'.
  1909. (setq number
  1910. (cond ((numberp all) all)
  1911. (entry (car entry))
  1912. ((setq active (gnus-active group))
  1913. (- (1+ (cdr active)) (car active)))))
  1914. (gnus-summary-read-group
  1915. group (or all (and (numberp number)
  1916. (zerop (+ number (gnus-range-length
  1917. (cdr (assq 'tick marked)))
  1918. (gnus-range-length
  1919. (cdr (assq 'dormant marked)))))))
  1920. no-article nil no-display nil select-articles)))
  1921. (defun gnus-group-select-group (&optional all)
  1922. "Select this newsgroup.
  1923. No article is selected automatically.
  1924. If the group is opened, just switch the summary buffer.
  1925. If ALL is non-nil, already read articles become readable.
  1926. If ALL is a positive number, fetch this number of the latest
  1927. articles in the group.
  1928. If ALL is a negative number, fetch this number of the earliest
  1929. articles in the group."
  1930. (interactive "P")
  1931. (when (and (eobp) (not (gnus-group-group-name)))
  1932. (forward-line -1))
  1933. (gnus-group-read-group all t))
  1934. (defun gnus-group-quick-select-group (&optional all group)
  1935. "Select the GROUP \"quickly\".
  1936. This means that no highlighting or scoring will be performed. If
  1937. ALL (the prefix argument) is 0, don't even generate the summary
  1938. buffer. If GROUP is nil, use current group.
  1939. This might be useful if you want to toggle threading
  1940. before entering the group."
  1941. (interactive "P")
  1942. (require 'gnus-score)
  1943. (let (gnus-visual
  1944. gnus-score-find-score-files-function
  1945. gnus-home-score-file
  1946. gnus-apply-kill-hook
  1947. gnus-summary-expunge-below)
  1948. (gnus-group-read-group all t group)))
  1949. (defun gnus-group-visible-select-group (&optional all)
  1950. "Select the current group without hiding any articles."
  1951. (interactive "P")
  1952. (let ((gnus-inhibit-limiting t))
  1953. (gnus-group-read-group all t)))
  1954. (defun gnus-group-select-group-ephemerally ()
  1955. "Select the current group without doing any processing whatsoever.
  1956. You will actually be entered into a group that's a copy of
  1957. the current group; no changes you make while in this group will
  1958. be permanent."
  1959. (interactive)
  1960. (require 'gnus-score)
  1961. (let* (gnus-visual
  1962. gnus-score-find-score-files-function gnus-apply-kill-hook
  1963. gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
  1964. gnus-summary-mode-hook gnus-select-group-hook
  1965. (group (gnus-group-group-name))
  1966. (method (gnus-find-method-for-group group)))
  1967. (gnus-group-read-ephemeral-group
  1968. (gnus-group-prefixed-name group method) method)))
  1969. (defun gnus-group-name-at-point ()
  1970. "Return a group name from around point if it exists, or nil."
  1971. (if (eq major-mode 'gnus-group-mode)
  1972. (let ((group (gnus-group-group-name)))
  1973. (when group
  1974. (gnus-group-decoded-name group)))
  1975. (let ((regexp "[][\C-@-\t\v-*,/:-@\\^`{-\C-?]*\
  1976. \\(nn[a-z]+\\(?:\\+[^][\C-@-*,/:-@\\^`{-\C-?]+\\)?:\
  1977. \[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)*\
  1978. \\|[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)+\\)")
  1979. (start (point))
  1980. (case-fold-search nil))
  1981. (prog1
  1982. (if (or (and (not (or (eobp)
  1983. (looking-at "[][\C-@-*,/;-@\\^`{-\C-?]")))
  1984. (prog1 t
  1985. (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
  1986. (point-at-bol))))
  1987. (and (looking-at "[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*$")
  1988. (prog1 t
  1989. (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
  1990. (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
  1991. (point-at-bol))))
  1992. (string-match "\\`[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*\\'"
  1993. (buffer-substring (point-at-bol) (point))))
  1994. (when (looking-at regexp)
  1995. (match-string 1))
  1996. (let (group distance)
  1997. (when (looking-at regexp)
  1998. (setq group (match-string 1)
  1999. distance (- (match-beginning 1) (match-beginning 0))))
  2000. (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
  2001. (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
  2002. (point-at-bol))
  2003. (if (looking-at regexp)
  2004. (if (and group (<= distance (- start (match-end 0))))
  2005. group
  2006. (match-string 1))
  2007. group)))
  2008. (goto-char start)))))
  2009. (defun gnus-group-completing-read (&optional prompt collection
  2010. require-match initial-input hist
  2011. def)
  2012. "Read a group name with completion. Non-ASCII group names are allowed.
  2013. The arguments are the same as `completing-read' except that COLLECTION
  2014. and HIST default to `gnus-active-hashtb' and `gnus-group-history'
  2015. respectively if they are omitted. Regards COLLECTION as a hash table
  2016. if it is not a list."
  2017. (or collection (setq collection gnus-active-hashtb))
  2018. (let (choices group)
  2019. (if (listp collection)
  2020. (dolist (symbol collection)
  2021. (setq group (symbol-name symbol))
  2022. (push (if (string-match "[^\000-\177]" group)
  2023. (gnus-group-decoded-name group)
  2024. group)
  2025. choices))
  2026. (mapatoms (lambda (symbol)
  2027. (setq group (symbol-name symbol))
  2028. (push (if (string-match "[^\000-\177]" group)
  2029. (gnus-group-decoded-name group)
  2030. group)
  2031. choices))
  2032. collection))
  2033. (setq group (gnus-completing-read (or prompt "Group") (nreverse choices)
  2034. require-match initial-input
  2035. (or hist 'gnus-group-history)
  2036. def))
  2037. (unless (if (listp collection)
  2038. (member group (mapcar 'symbol-name collection))
  2039. (symbol-value (intern-soft group collection)))
  2040. (setq group
  2041. (mm-encode-coding-string
  2042. group (gnus-group-name-charset nil group))))
  2043. (gnus-replace-in-string group "\n" "")))
  2044. ;;;###autoload
  2045. (defun gnus-fetch-group (group &optional articles)
  2046. "Start Gnus if necessary and enter GROUP.
  2047. If ARTICLES, display those articles.
  2048. Returns whether the fetching was successful or not."
  2049. (interactive (list (gnus-group-completing-read nil
  2050. nil nil
  2051. (gnus-group-name-at-point))))
  2052. (unless (gnus-alive-p)
  2053. (gnus-no-server))
  2054. (gnus-group-read-group (if articles nil t) nil group articles))
  2055. ;;;###autoload
  2056. (defun gnus-fetch-group-other-frame (group)
  2057. "Pop up a frame and enter GROUP."
  2058. (interactive "P")
  2059. (let ((window (get-buffer-window gnus-group-buffer)))
  2060. (cond (window
  2061. (select-frame (window-frame window)))
  2062. ((= (length (frame-list)) 1)
  2063. (select-frame (make-frame)))
  2064. (t
  2065. (other-frame 1))))
  2066. (gnus-fetch-group group))
  2067. (defcustom gnus-large-ephemeral-newsgroup 200
  2068. "The number of articles which indicates a large ephemeral newsgroup.
  2069. Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
  2070. If the number of articles in a newsgroup is greater than this value,
  2071. confirmation is required for selecting the newsgroup. If it is nil, no
  2072. confirmation is required."
  2073. :version "22.1"
  2074. :group 'gnus-group-select
  2075. :type '(choice (const :tag "No limit" nil)
  2076. integer))
  2077. (defcustom gnus-fetch-old-ephemeral-headers nil
  2078. "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
  2079. :version "22.1"
  2080. :group 'gnus-thread
  2081. :type '(choice (const :tag "off" nil)
  2082. (const some)
  2083. number
  2084. (sexp :menu-tag "other" t)))
  2085. ;; Enter a group that is not in the group buffer. Non-nil is returned
  2086. ;; if selection was successful.
  2087. (defun gnus-group-read-ephemeral-group (group method &optional activate
  2088. quit-config request-only
  2089. select-articles
  2090. parameters
  2091. number)
  2092. "Read GROUP from METHOD as an ephemeral group.
  2093. If ACTIVATE, request the group first.
  2094. If QUIT-CONFIG, use that Gnus window configuration name when
  2095. exiting from the ephemeral group.
  2096. If REQUEST-ONLY, don't actually read the group; just request it.
  2097. If SELECT-ARTICLES, only select those articles.
  2098. If PARAMETERS, use those as the group parameters.
  2099. If NUMBER, fetch this number of articles.
  2100. Return the name of the group if selection was successful."
  2101. (interactive
  2102. (list
  2103. ;; (gnus-read-group "Group name: ")
  2104. (gnus-group-completing-read)
  2105. (gnus-read-method "From method")))
  2106. ;; Transform the select method into a unique server.
  2107. (unless (gnus-alive-p)
  2108. (gnus-no-server))
  2109. (when (stringp method)
  2110. (setq method (gnus-server-to-method method)))
  2111. (let ((address-slot
  2112. (intern (format "%s-address" (car method)))))
  2113. (setq method
  2114. (if (assq address-slot (cddr method))
  2115. `(,(car method) ,(concat (cadr method) "-ephemeral")
  2116. ,@(cddr method))
  2117. `(,(car method) ,(concat (cadr method) "-ephemeral")
  2118. (,address-slot ,(cadr method))
  2119. ,@(cddr method)))))
  2120. (let ((group (if (gnus-group-foreign-p group) group
  2121. (gnus-group-prefixed-name (gnus-group-real-name group)
  2122. method))))
  2123. (gnus-sethash
  2124. group
  2125. `(-1 nil (,group
  2126. ,gnus-level-default-subscribed nil nil ,method
  2127. ,(cons
  2128. (cond
  2129. (quit-config
  2130. (cons 'quit-config quit-config))
  2131. ((assq gnus-current-window-configuration
  2132. gnus-buffer-configuration)
  2133. (cons 'quit-config
  2134. (cons gnus-summary-buffer
  2135. gnus-current-window-configuration))))
  2136. parameters)))
  2137. gnus-newsrc-hashtb)
  2138. (push method gnus-ephemeral-servers)
  2139. (set-buffer gnus-group-buffer)
  2140. (unless (gnus-check-server method)
  2141. (error "Unable to contact server: %s" (gnus-status-message method)))
  2142. (when activate
  2143. (gnus-activate-group group 'scan)
  2144. (unless (gnus-request-group group)
  2145. (error "Couldn't request group: %s"
  2146. (nnheader-get-report (car method)))))
  2147. (if request-only
  2148. group
  2149. (condition-case ()
  2150. (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
  2151. (gnus-fetch-old-headers
  2152. gnus-fetch-old-ephemeral-headers))
  2153. (gnus-group-read-group (or number t) t group select-articles))
  2154. group)
  2155. (quit
  2156. (if debug-on-quit
  2157. (debug "Quit")
  2158. (message "Quit reading the ephemeral group"))
  2159. nil)))))
  2160. (defcustom gnus-gmane-group-download-format
  2161. "http://download.gmane.org/%s/%s/%s"
  2162. "URL for downloading mbox files.
  2163. It must contain three \"%s\". They correspond to the group, the
  2164. minimal and maximal article numbers, respectively."
  2165. :group 'gnus-group-foreign
  2166. :version "23.1" ;; No Gnus
  2167. :type 'string)
  2168. (autoload 'url-insert-file-contents "url-handlers")
  2169. ;; FIXME:
  2170. ;; - Add documentation, menu, key bindings, ...
  2171. (defun gnus-read-ephemeral-gmane-group (group start &optional range)
  2172. "Read articles from Gmane group GROUP as an ephemeral group.
  2173. START is the first article. RANGE specifies how many articles
  2174. are fetched. The articles are downloaded via HTTP using the URL
  2175. specified by `gnus-gmane-group-download-format'."
  2176. ;; See <http://gmane.org/export.php> for more information.
  2177. (interactive
  2178. (list
  2179. (gnus-group-completing-read "Gmane group")
  2180. (read-number "Start article number: ")
  2181. (read-number "How many articles: ")))
  2182. (unless range (setq range 500))
  2183. (when (< range 1)
  2184. (error "Invalid range: %s" range))
  2185. (let ((tmpfile (mm-make-temp-file
  2186. (format "%s.start-%s.range-%s." group start range)))
  2187. (gnus-thread-sort-functions '(gnus-thread-sort-by-number)))
  2188. (with-temp-file tmpfile
  2189. (url-insert-file-contents
  2190. (format gnus-gmane-group-download-format
  2191. group start (+ start range)))
  2192. (write-region (point-min) (point-max) tmpfile)
  2193. (gnus-group-read-ephemeral-group
  2194. (format "%s.start-%s.range-%s" group start range)
  2195. `(nndoc ,tmpfile
  2196. (nndoc-article-type mbox))))
  2197. (delete-file tmpfile)))
  2198. (defun gnus-read-ephemeral-gmane-group-url (url)
  2199. "Create an ephemeral Gmane group from URL.
  2200. Valid input formats include:
  2201. \"http://thread.gmane.org/gmane.foo.bar/12300/focus=12399\",
  2202. \"http://thread.gmane.org/gmane.foo.bar/12345/\",
  2203. \"http://article.gmane.org/gmane.foo.bar/12345/\",
  2204. \"http://news.gmane.org/group/gmane.foo.bar/thread=12345\""
  2205. ;; - Feel free to add other useful Gmane URLs here! Maybe the URLs should
  2206. ;; be customizable?
  2207. ;; - The URLs should be added to `gnus-button-alist'. Probably we should
  2208. ;; prompt the user to decide: "View via `browse-url' or in Gnus? "
  2209. ;; (`gnus-read-ephemeral-gmane-group-url')
  2210. (interactive
  2211. (list (gnus-group-completing-read "Gmane URL")))
  2212. (let (group start range)
  2213. (cond
  2214. ;; URLs providing `group', `start' and `range':
  2215. ((string-match
  2216. ;; http://thread.gmane.org/gmane.emacs.devel/86326/focus=86525
  2217. "^http://thread\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)/focus=\\([0-9]+\\)$"
  2218. url)
  2219. (setq group (match-string 1 url)
  2220. start (string-to-number (match-string 2 url))
  2221. ;; Ensure that `range' is large enough to ensure focus article is
  2222. ;; included.
  2223. range (- (string-to-number (match-string 3 url))
  2224. start -1)))
  2225. ;; URLs providing `group' and `start':
  2226. ((or (string-match
  2227. ;; http://article.gmane.org/gmane.comp.gnu.make.bugs/3584
  2228. "^http://\\(?:thread\\|article\\|permalink\\)\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
  2229. url)
  2230. (string-match
  2231. ;; Don't advertise these in the doc string yet:
  2232. "^\\(?:nntp\\|news\\)://news\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
  2233. url)
  2234. (string-match
  2235. ;; http://news.gmane.org/group/gmane.emacs.gnus.general/thread=65099/force_load=t
  2236. "^http://news\.gmane\.org/group/\\([^/]+\\)/thread=\\([0-9]+\\)"
  2237. url))
  2238. (setq group (match-string 1 url)
  2239. start (string-to-number (match-string 2 url))))
  2240. (t
  2241. (error "Can't parse URL %s" url)))
  2242. (gnus-read-ephemeral-gmane-group group start range)))
  2243. (defcustom gnus-bug-group-download-format-alist
  2244. '((emacs . "http://debbugs.gnu.org/%s;mboxmaint=yes;mboxstat=yes")
  2245. (debian
  2246. . "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s&mbox=yes;mboxmaint=yes"))
  2247. "Alist of symbols for bug trackers and the corresponding URL format string.
  2248. The URL format string must contain a single \"%s\", specifying
  2249. the bug number, and browsing the URL must return mbox output."
  2250. :group 'gnus-group-foreign
  2251. ;; Added mboxmaint=yes. This gets the version with the messages as
  2252. ;; they went out, not as they came in.
  2253. ;; Eg bug-gnu-emacs is replaced by ###@debbugs.
  2254. :version "24.1"
  2255. :type '(repeat (cons (symbol) (string :tag "URL format string"))))
  2256. (defun gnus-read-ephemeral-bug-group (ids mbox-url &optional window-conf)
  2257. "Browse bug NUMBER as ephemeral group."
  2258. (interactive (list (read-string "Enter bug number: "
  2259. (thing-at-point 'word) nil)
  2260. ;; FIXME: Add completing-read from
  2261. ;; `gnus-emacs-bug-group-download-format' ...
  2262. (cdr (assoc 'emacs gnus-bug-group-download-format-alist))))
  2263. (when (stringp ids)
  2264. (setq ids (string-to-number ids)))
  2265. (unless (listp ids)
  2266. (setq ids (list ids)))
  2267. (let ((tmpfile (mm-make-temp-file "gnus-temp-group-"))
  2268. (coding-system-for-write 'binary)
  2269. (coding-system-for-read 'binary))
  2270. (with-temp-file tmpfile
  2271. (dolist (id ids)
  2272. (url-insert-file-contents (format mbox-url id)))
  2273. (goto-char (point-min))
  2274. ;; Add the debbugs address so that we can respond to reports easily.
  2275. (while (re-search-forward "^To: " nil t)
  2276. (end-of-line)
  2277. (insert (format ", %s@%s" (car ids)
  2278. (gnus-replace-in-string
  2279. (gnus-replace-in-string mbox-url "^http://" "")
  2280. "/.*$" ""))))
  2281. (write-region (point-min) (point-max) tmpfile)
  2282. (gnus-group-read-ephemeral-group
  2283. "gnus-read-ephemeral-bug"
  2284. `(nndoc ,tmpfile
  2285. (nndoc-article-type mbox))
  2286. nil window-conf))
  2287. (delete-file tmpfile)))
  2288. (defun gnus-read-ephemeral-debian-bug-group (number)
  2289. "Browse Debian bug NUMBER as ephemeral group."
  2290. (interactive (list (read-string "Enter bug number: "
  2291. (thing-at-point 'word) nil)))
  2292. (gnus-read-ephemeral-bug-group
  2293. number
  2294. (cdr (assoc 'debian gnus-bug-group-download-format-alist))))
  2295. (defvar debbugs-gnu-bug-number) ; debbugs-gnu
  2296. (defun gnus-read-ephemeral-emacs-bug-group (ids &optional window-conf)
  2297. "Browse Emacs bugs IDS as an ephemeral group."
  2298. (interactive (list (string-to-number
  2299. (read-string "Enter bug number: "
  2300. (thing-at-point 'word) nil))))
  2301. (unless (listp ids)
  2302. (setq ids (list ids)))
  2303. (gnus-read-ephemeral-bug-group
  2304. ids
  2305. (cdr (assoc 'emacs gnus-bug-group-download-format-alist))
  2306. window-conf)
  2307. (when (fboundp 'debbugs-gnu-summary-mode)
  2308. (with-current-buffer (window-buffer (selected-window))
  2309. (debbugs-gnu-summary-mode 1)
  2310. (set (make-local-variable 'debbugs-gnu-bug-number) (car ids)))))
  2311. (defun gnus-group-jump-to-group (group &optional prompt)
  2312. "Jump to newsgroup GROUP.
  2313. If PROMPT (the prefix) is a number, use the prompt specified in
  2314. `gnus-group-jump-to-group-prompt'."
  2315. (interactive
  2316. (list (gnus-group-completing-read
  2317. nil nil nil
  2318. (if current-prefix-arg
  2319. (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
  2320. (or (and (stringp gnus-group-jump-to-group-prompt)
  2321. gnus-group-jump-to-group-prompt)
  2322. (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
  2323. (and (stringp p) p)))))))
  2324. (when (equal group "")
  2325. (error "Empty group name"))
  2326. (unless (gnus-ephemeral-group-p group)
  2327. ;; Either go to the line in the group buffer...
  2328. (unless (gnus-group-goto-group group)
  2329. ;; ... or insert the line.
  2330. (gnus-group-update-group group)
  2331. (gnus-group-goto-group group)))
  2332. ;; Adjust cursor point.
  2333. (gnus-group-position-point))
  2334. (defun gnus-group-goto-group (group &optional far test-marked)
  2335. "Goto to newsgroup GROUP.
  2336. If FAR, it is likely that the group is not on the current line.
  2337. If TEST-MARKED, the line must be marked."
  2338. (when group
  2339. (beginning-of-line)
  2340. (cond
  2341. ;; It's quite likely that we are on the right line, so
  2342. ;; we check the current line first.
  2343. ((and (not far)
  2344. (eq (get-text-property (point) 'gnus-group)
  2345. (gnus-intern-safe group gnus-active-hashtb))
  2346. (or (not test-marked) (gnus-group-mark-line-p)))
  2347. (point))
  2348. ;; Previous and next line are also likely, so we check them as well.
  2349. ((and (not far)
  2350. (save-excursion
  2351. (forward-line -1)
  2352. (and (eq (get-text-property (point) 'gnus-group)
  2353. (gnus-intern-safe group gnus-active-hashtb))
  2354. (or (not test-marked) (gnus-group-mark-line-p)))))
  2355. (forward-line -1)
  2356. (point))
  2357. ((and (not far)
  2358. (save-excursion
  2359. (forward-line 1)
  2360. (and (eq (get-text-property (point) 'gnus-group)
  2361. (gnus-intern-safe group gnus-active-hashtb))
  2362. (or (not test-marked) (gnus-group-mark-line-p)))))
  2363. (forward-line 1)
  2364. (point))
  2365. (test-marked
  2366. (goto-char (point-min))
  2367. (let (found)
  2368. (while (and (not found)
  2369. (gnus-goto-char
  2370. (text-property-any
  2371. (point) (point-max)
  2372. 'gnus-group
  2373. (gnus-intern-safe group gnus-active-hashtb))))
  2374. (if (gnus-group-mark-line-p)
  2375. (setq found t)
  2376. (forward-line 1)))
  2377. found))
  2378. (t
  2379. ;; Search through the entire buffer.
  2380. (gnus-goto-char
  2381. (text-property-any
  2382. (point-min) (point-max)
  2383. 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
  2384. (defun gnus-group-next-group (n &optional silent)
  2385. "Go to next N'th newsgroup.
  2386. If N is negative, search backward instead.
  2387. Returns the difference between N and the number of skips actually
  2388. done."
  2389. (interactive "p")
  2390. (gnus-group-next-unread-group n t nil silent))
  2391. (defun gnus-group-next-unread-group (n &optional all level silent)
  2392. "Go to next N'th unread newsgroup.
  2393. If N is negative, search backward instead.
  2394. If ALL is non-nil, choose any newsgroup, unread or not.
  2395. If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
  2396. such group can be found, the next group with a level higher than
  2397. LEVEL.
  2398. Returns the difference between N and the number of skips actually
  2399. made."
  2400. (interactive "p")
  2401. (let ((backward (< n 0))
  2402. (n (abs n)))
  2403. (while (and (> n 0)
  2404. (gnus-group-search-forward
  2405. backward (or (not gnus-group-goto-unread) all) level))
  2406. (setq n (1- n)))
  2407. (when (and (/= 0 n)
  2408. (not silent))
  2409. (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
  2410. (if level " on this level or higher" "")))
  2411. n))
  2412. (defun gnus-group-prev-group (n)
  2413. "Go to previous N'th newsgroup.
  2414. Returns the difference between N and the number of skips actually
  2415. done."
  2416. (interactive "p")
  2417. (gnus-group-next-unread-group (- n) t))
  2418. (defun gnus-group-prev-unread-group (n)
  2419. "Go to previous N'th unread newsgroup.
  2420. Returns the difference between N and the number of skips actually
  2421. done."
  2422. (interactive "p")
  2423. (gnus-group-next-unread-group (- n)))
  2424. (defun gnus-group-next-unread-group-same-level (n)
  2425. "Go to next N'th unread newsgroup on the same level.
  2426. If N is negative, search backward instead.
  2427. Returns the difference between N and the number of skips actually
  2428. done."
  2429. (interactive "p")
  2430. (gnus-group-next-unread-group n t (gnus-group-group-level))
  2431. (gnus-group-position-point))
  2432. (defun gnus-group-prev-unread-group-same-level (n)
  2433. "Go to next N'th unread newsgroup on the same level.
  2434. Returns the difference between N and the number of skips actually
  2435. done."
  2436. (interactive "p")
  2437. (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
  2438. (gnus-group-position-point))
  2439. (defun gnus-group-best-unread-group (&optional exclude-group)
  2440. "Go to the group with the highest level.
  2441. If EXCLUDE-GROUP, do not go to that group."
  2442. (interactive)
  2443. (goto-char (point-min))
  2444. (let ((best 100000)
  2445. unread best-point)
  2446. (while (not (eobp))
  2447. (setq unread (get-text-property (point) 'gnus-unread))
  2448. (when (and (numberp unread) (> unread 0))
  2449. (when (and (get-text-property (point) 'gnus-level)
  2450. (< (get-text-property (point) 'gnus-level) best)
  2451. (or (not exclude-group)
  2452. (not (equal exclude-group (gnus-group-group-name)))))
  2453. (setq best (get-text-property (point) 'gnus-level))
  2454. (setq best-point (point))))
  2455. (forward-line 1))
  2456. (when best-point
  2457. (goto-char best-point))
  2458. (gnus-group-position-point)
  2459. (and best-point (gnus-group-group-name))))
  2460. ;; Is there something like an after-point-motion-hook?
  2461. ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
  2462. ;; (defun gnus-group-menu-bar-update ()
  2463. ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
  2464. ;; (current-buffer))))
  2465. ;; (name (buffer-name (car buf))))
  2466. ;; (setcdr buf
  2467. ;; (if (> (length name) 27)
  2468. ;; (concat (substring name 0 12)
  2469. ;; "..."
  2470. ;; (substring name -12))
  2471. ;; name))
  2472. ;; (menu-bar-update-buffers-1 buf)))
  2473. ;; (defun gnus-group-position-point ()
  2474. ;; (gnus-goto-colon)
  2475. ;; (gnus-group-menu-bar-update))
  2476. (defun gnus-group-first-unread-group ()
  2477. "Go to the first group with unread articles."
  2478. (interactive)
  2479. (prog1
  2480. (let ((opoint (point))
  2481. unread)
  2482. (goto-char (point-min))
  2483. (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
  2484. (and (numberp unread) ; Not a topic.
  2485. (not (zerop unread))) ; Has unread articles.
  2486. (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
  2487. (point) ; Success.
  2488. (goto-char opoint)
  2489. nil)) ; Not success.
  2490. (gnus-group-position-point)))
  2491. (defun gnus-group-enter-server-mode ()
  2492. "Jump to the server buffer."
  2493. (interactive)
  2494. (gnus-enter-server-buffer))
  2495. (defun gnus-group-make-group-simple (&optional group)
  2496. "Add a new newsgroup.
  2497. The user will be prompted for GROUP."
  2498. (interactive (list (gnus-group-completing-read)))
  2499. (gnus-group-make-group (gnus-group-real-name group)
  2500. (gnus-group-server group)
  2501. nil nil t))
  2502. (defun gnus-group-make-group (name &optional method address args encoded)
  2503. "Add a new newsgroup.
  2504. The user will be prompted for a NAME, for a select METHOD, and an
  2505. ADDRESS. NAME should be a human-readable string (i.e., not be encoded
  2506. even if it contains non-ASCII characters) unless ENCODED is non-nil.
  2507. If the backend supports it, the group will also be created on the
  2508. server."
  2509. (interactive
  2510. (list
  2511. (gnus-read-group "Group name: ")
  2512. (gnus-read-method "From method")))
  2513. (when (stringp method)
  2514. (setq method (or (gnus-server-to-method method) method)))
  2515. (unless encoded
  2516. (setq name (mm-encode-coding-string
  2517. name
  2518. (gnus-group-name-charset method name))))
  2519. (let* ((meth (gnus-method-simplify
  2520. (when (and method
  2521. (not (gnus-server-equal method gnus-select-method)))
  2522. (if address (list (intern method) address)
  2523. method))))
  2524. (nname (if method (gnus-group-prefixed-name name meth) name))
  2525. backend info)
  2526. (when (gnus-group-entry nname)
  2527. (error "Group %s already exists" (gnus-group-decoded-name nname)))
  2528. ;; Subscribe to the new group.
  2529. (gnus-group-change-level
  2530. (setq info (list t nname gnus-level-default-subscribed nil nil meth))
  2531. gnus-level-default-subscribed gnus-level-killed
  2532. (and (gnus-group-group-name)
  2533. (gnus-group-entry (gnus-group-group-name)))
  2534. t)
  2535. ;; Make it active.
  2536. (gnus-set-active nname (cons 1 0))
  2537. (unless (gnus-ephemeral-group-p name)
  2538. (gnus-dribble-enter
  2539. (concat "(gnus-group-set-info '"
  2540. (gnus-prin1-to-string (cdr info)) ")")
  2541. (concat "^(gnus-group-set-info '(\"" (regexp-quote name) "\"")))
  2542. ;; Insert the line.
  2543. (gnus-group-insert-group-line-info nname)
  2544. (forward-line -1)
  2545. (gnus-group-position-point)
  2546. ;; Load the back end and try to make the back end create
  2547. ;; the group as well.
  2548. (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
  2549. nil meth))))
  2550. gnus-valid-select-methods)
  2551. (require backend))
  2552. (gnus-check-server meth)
  2553. (when (gnus-check-backend-function 'request-create-group nname)
  2554. (unless (gnus-request-create-group nname nil args)
  2555. (error "Could not create group on server: %s"
  2556. (nnheader-get-report backend))))
  2557. t))
  2558. (defun gnus-group-delete-groups (&optional arg)
  2559. "Delete the current group. Only meaningful with editable groups."
  2560. (interactive "P")
  2561. (let ((n (length (gnus-group-process-prefix arg))))
  2562. (when (gnus-yes-or-no-p
  2563. (if (= n 1)
  2564. "Delete this 1 group? "
  2565. (format "Delete these %d groups? " n)))
  2566. (gnus-group-iterate arg
  2567. (lambda (group)
  2568. (gnus-group-delete-group group nil t))))))
  2569. (defun gnus-group-delete-articles (group)
  2570. "Delete all articles in the current group."
  2571. (interactive (list (gnus-group-group-name)))
  2572. (let ((articles (gnus-uncompress-range (gnus-active group))))
  2573. (when (gnus-yes-or-no-p
  2574. (format "Do you really want to delete these %d articles forever? "
  2575. (length articles)))
  2576. (gnus-request-expire-articles articles group 'force))))
  2577. (defun gnus-group-delete-group (group &optional force no-prompt)
  2578. "Delete the current group. Only meaningful with editable groups.
  2579. If FORCE (the prefix) is non-nil, all the articles in the group will
  2580. be deleted. This is \"deleted\" as in \"removed forever from the face
  2581. of the Earth\". There is no undo. The user will be prompted before
  2582. doing the deletion.
  2583. Note that you also have to specify FORCE if you want the group to
  2584. be removed from the server, even when it's empty."
  2585. (interactive
  2586. (list (gnus-group-group-name)
  2587. current-prefix-arg))
  2588. (unless group
  2589. (error "No group to delete"))
  2590. (unless (gnus-check-backend-function 'request-delete-group group)
  2591. (error "This back end does not support group deletion"))
  2592. (prog1
  2593. (let ((group-decoded (gnus-group-decoded-name group)))
  2594. (if (and (not no-prompt)
  2595. (not (gnus-yes-or-no-p
  2596. (format
  2597. "Do you really want to delete %s%s? "
  2598. group-decoded (if force " and all its contents" "")))))
  2599. () ; Whew!
  2600. (gnus-message 6 "Deleting group %s..." group-decoded)
  2601. (if (not (gnus-request-delete-group group force))
  2602. (gnus-error 3 "Couldn't delete group %s" group-decoded)
  2603. (gnus-message 6 "Deleting group %s...done" group-decoded)
  2604. (gnus-group-goto-group group)
  2605. (gnus-group-kill-group 1 t)
  2606. (gnus-set-active group nil)
  2607. t)))
  2608. (gnus-group-position-point)))
  2609. (defun gnus-group-rename-group (group new-name)
  2610. "Rename group from GROUP to NEW-NAME.
  2611. When used interactively, GROUP is the group under point
  2612. and NEW-NAME will be prompted for."
  2613. (interactive
  2614. (let ((group (gnus-group-group-name))
  2615. method new-name)
  2616. (unless (gnus-check-backend-function 'request-rename-group group)
  2617. (error "This back end does not support renaming groups"))
  2618. (setq new-name (gnus-read-group
  2619. "Rename group to: "
  2620. (gnus-group-real-name (gnus-group-decoded-name group)))
  2621. method (gnus-info-method (gnus-get-info group)))
  2622. (list group (mm-encode-coding-string
  2623. new-name
  2624. (gnus-group-name-charset
  2625. method
  2626. (gnus-group-prefixed-name new-name method))))))
  2627. (unless (gnus-check-backend-function 'request-rename-group group)
  2628. (error "This back end does not support renaming groups"))
  2629. (unless group
  2630. (error "No group to rename"))
  2631. (when (equal (gnus-group-real-name group) new-name)
  2632. (error "Can't rename to the same name"))
  2633. ;; We find the proper prefixed name.
  2634. (setq new-name
  2635. (if (gnus-group-native-p group)
  2636. ;; Native group.
  2637. new-name
  2638. ;; Foreign group.
  2639. (gnus-group-prefixed-name
  2640. (gnus-group-real-name new-name)
  2641. (gnus-info-method (gnus-get-info group)))))
  2642. (let ((decoded-group (gnus-group-decoded-name group))
  2643. (decoded-new-name (gnus-group-decoded-name new-name)))
  2644. (when (gnus-active new-name)
  2645. (error "The group %s already exists" decoded-new-name))
  2646. (gnus-message 6 "Renaming group %s to %s..."
  2647. decoded-group decoded-new-name)
  2648. (prog1
  2649. (if (progn
  2650. (gnus-group-goto-group group)
  2651. (not (when (< (gnus-group-group-level) gnus-level-zombie)
  2652. (gnus-request-rename-group group new-name))))
  2653. (gnus-error 3 "Couldn't rename group %s to %s"
  2654. decoded-group decoded-new-name)
  2655. ;; We rename the group internally by killing it...
  2656. (gnus-group-kill-group)
  2657. ;; ... changing its name ...
  2658. (setcar (cdar gnus-list-of-killed-groups) new-name)
  2659. ;; ... and then yanking it. Magic!
  2660. (gnus-group-yank-group)
  2661. (gnus-set-active new-name (gnus-active group))
  2662. (gnus-message 6 "Renaming group %s to %s...done"
  2663. decoded-group decoded-new-name)
  2664. new-name)
  2665. (setq gnus-killed-list (delete group gnus-killed-list))
  2666. (gnus-set-active group nil)
  2667. (gnus-dribble-touch)
  2668. (gnus-group-position-point))))
  2669. (defun gnus-group-edit-group (group &optional part)
  2670. "Edit the group on the current line."
  2671. (interactive (list (gnus-group-group-name)))
  2672. (let ((part (or part 'info))
  2673. info)
  2674. (unless group
  2675. (error "No group on current line"))
  2676. (unless (setq info (gnus-get-info group))
  2677. (error "Killed group; can't be edited"))
  2678. (ignore-errors
  2679. (gnus-close-group group))
  2680. (gnus-edit-form
  2681. ;; Find the proper form to edit.
  2682. (cond ((eq part 'method)
  2683. (or (gnus-info-method info) "native"))
  2684. ((eq part 'params)
  2685. (gnus-info-params info))
  2686. (t info))
  2687. ;; The proper documentation.
  2688. (format
  2689. "Editing the %s for `%s'."
  2690. (cond
  2691. ((eq part 'method) "select method")
  2692. ((eq part 'params) "group parameters")
  2693. (t "group info"))
  2694. (gnus-group-decoded-name group))
  2695. `(lambda (form)
  2696. (gnus-group-edit-group-done ',part ,group form)))
  2697. (local-set-key
  2698. "\C-c\C-i"
  2699. (gnus-create-info-command
  2700. (cond
  2701. ((eq part 'method)
  2702. "(gnus)Select Methods")
  2703. ((eq part 'params)
  2704. "(gnus)Group Parameters")
  2705. (t
  2706. "(gnus)Group Info"))))))
  2707. (defun gnus-group-edit-group-method (group)
  2708. "Edit the select method of GROUP."
  2709. (interactive (list (gnus-group-group-name)))
  2710. (gnus-group-edit-group group 'method))
  2711. (defun gnus-group-edit-group-parameters (group)
  2712. "Edit the group parameters of GROUP."
  2713. (interactive (list (gnus-group-group-name)))
  2714. (gnus-group-edit-group group 'params))
  2715. (defun gnus-group-edit-group-done (part group form)
  2716. "Update variables."
  2717. (let* ((method (cond ((eq part 'info) (nth 4 form))
  2718. ((eq part 'method) form)
  2719. (t nil)))
  2720. (info (cond ((eq part 'info) form)
  2721. ((eq part 'method) (gnus-get-info group))
  2722. (t nil)))
  2723. (new-group (if info
  2724. (if (or (not method)
  2725. (gnus-server-equal
  2726. gnus-select-method method))
  2727. (gnus-group-real-name (car info))
  2728. (gnus-group-prefixed-name
  2729. (gnus-group-real-name (car info)) method))
  2730. nil)))
  2731. (when (and new-group
  2732. (not (equal new-group group)))
  2733. (when (gnus-group-goto-group group)
  2734. (gnus-group-kill-group 1))
  2735. (gnus-activate-group new-group))
  2736. ;; Set the info.
  2737. (if (not (and info new-group))
  2738. (gnus-group-set-info form (or new-group group) part)
  2739. (setq info (gnus-copy-sequence info))
  2740. (setcar info new-group)
  2741. (unless (gnus-server-equal method "native")
  2742. (unless (nthcdr 3 info)
  2743. (nconc info (list nil nil)))
  2744. (unless (nthcdr 4 info)
  2745. (nconc info (list nil)))
  2746. (gnus-info-set-method info method))
  2747. (gnus-group-set-info info))
  2748. (gnus-group-update-group (or new-group group))
  2749. (gnus-group-position-point)))
  2750. (defun gnus-group-make-useful-group (group method)
  2751. "Create one of the groups described in `gnus-useful-groups'."
  2752. (interactive
  2753. (let ((entry (assoc (gnus-completing-read "Create group"
  2754. (mapcar 'car gnus-useful-groups)
  2755. t)
  2756. gnus-useful-groups)))
  2757. (list (cadr entry)
  2758. ;; Don't use `caddr' here since macros within the `interactive'
  2759. ;; form won't be expanded.
  2760. (car (cddr entry)))))
  2761. (setq method (gnus-copy-sequence method))
  2762. (let (entry)
  2763. (while (setq entry (memq (assq 'eval method) method))
  2764. (setcar entry (eval (cadar entry)))))
  2765. (gnus-group-make-group group method))
  2766. (defun gnus-group-make-help-group (&optional noerror)
  2767. "Create the Gnus documentation group.
  2768. Optional argument NOERROR modifies the behavior of this function when the
  2769. group already exists:
  2770. - if not given, and error is signaled,
  2771. - if t, stay silent,
  2772. - if anything else, just print a message."
  2773. (interactive)
  2774. (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
  2775. (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
  2776. (if (gnus-group-entry name)
  2777. (cond ((eq noerror nil)
  2778. (error "Documentation group already exists"))
  2779. ((eq noerror t)
  2780. ;; stay silent
  2781. )
  2782. (t
  2783. (gnus-message 1 "Documentation group already exists")))
  2784. ;; else:
  2785. (if (not file)
  2786. (gnus-message 1 "Couldn't find doc group")
  2787. (gnus-group-make-group
  2788. (gnus-group-real-name name)
  2789. (list 'nndoc "gnus-help"
  2790. (list 'nndoc-address file)
  2791. (list 'nndoc-article-type 'mbox))))
  2792. ))
  2793. (gnus-group-position-point))
  2794. (defun gnus-group-make-doc-group (file type)
  2795. "Create a group that uses a single file as the source.
  2796. If called with a prefix argument, ask for the file type."
  2797. (interactive
  2798. (list (read-file-name "File name: ")
  2799. (and current-prefix-arg 'ask)))
  2800. (when (eq type 'ask)
  2801. (let ((err "")
  2802. char found)
  2803. (while (not found)
  2804. (message
  2805. "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
  2806. err)
  2807. (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
  2808. ((= char ?b) 'babyl)
  2809. ((= char ?d) 'digest)
  2810. ((= char ?f) 'forward)
  2811. ((= char ?a) 'mmfd)
  2812. ((= char ?g) 'guess)
  2813. (t (setq err (format "%c unknown. " char))
  2814. nil))))
  2815. (setq type found)))
  2816. (setq file (expand-file-name file))
  2817. (let* ((name (gnus-generate-new-group-name
  2818. (gnus-group-prefixed-name
  2819. (file-name-nondirectory file) '(nndoc ""))))
  2820. (method (list 'nndoc file
  2821. (list 'nndoc-address file)
  2822. (list 'nndoc-article-type (or type 'guess))))
  2823. (coding (gnus-group-name-charset method name)))
  2824. (setcar (cdr method) (mm-encode-coding-string file coding))
  2825. (gnus-group-make-group
  2826. (mm-encode-coding-string (gnus-group-real-name name) coding)
  2827. method nil nil t)))
  2828. (defvar nnweb-type-definition)
  2829. (defvar gnus-group-web-type-history nil)
  2830. (defvar gnus-group-web-search-history nil)
  2831. (defun gnus-group-make-web-group (&optional solid)
  2832. "Create an ephemeral nnweb group.
  2833. If SOLID (the prefix), create a solid group."
  2834. (interactive "P")
  2835. (require 'nnweb)
  2836. (let* ((group
  2837. (if solid (gnus-read-group "Group name: ")
  2838. (message-unique-id)))
  2839. (default-type (or (car gnus-group-web-type-history)
  2840. (symbol-name (caar nnweb-type-definition))))
  2841. (type
  2842. (gnus-string-or
  2843. (gnus-completing-read
  2844. "Search engine type"
  2845. (mapcar (lambda (elem) (symbol-name (car elem)))
  2846. nnweb-type-definition)
  2847. t nil 'gnus-group-web-type-history)
  2848. default-type))
  2849. (search
  2850. (read-string
  2851. "Search string: "
  2852. (cons (or (car gnus-group-web-search-history) "") 0)
  2853. 'gnus-group-web-search-history))
  2854. (method
  2855. `(nnweb ,group (nnweb-search ,search)
  2856. (nnweb-type ,(intern type))
  2857. (nnweb-ephemeral-p t))))
  2858. (if solid
  2859. (progn
  2860. (gnus-alist-pull 'nnweb-ephemeral-p method)
  2861. (gnus-group-make-group group method))
  2862. (gnus-group-read-ephemeral-group
  2863. group method t
  2864. (cons (current-buffer)
  2865. (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
  2866. (defvar nnrss-group-alist)
  2867. (eval-when-compile
  2868. (defun nnrss-discover-feed (arg))
  2869. (defun nnrss-save-server-data (arg)))
  2870. (defun gnus-group-make-rss-group (&optional url)
  2871. "Given a URL, discover if there is an RSS feed.
  2872. If there is, use Gnus to create an nnrss group"
  2873. (interactive)
  2874. (require 'nnrss)
  2875. (if (not url)
  2876. (setq url (read-from-minibuffer "URL to Search for RSS: ")))
  2877. (let ((feedinfo (nnrss-discover-feed url)))
  2878. (if feedinfo
  2879. (let* ((title (gnus-newsgroup-savable-name
  2880. (read-from-minibuffer "Title: "
  2881. (gnus-newsgroup-savable-name
  2882. (mapconcat
  2883. 'identity
  2884. (split-string
  2885. (or (cdr (assoc 'title
  2886. feedinfo))
  2887. ""))
  2888. " ")))))
  2889. (desc (read-from-minibuffer "Description: "
  2890. (mapconcat
  2891. 'identity
  2892. (split-string
  2893. (or (cdr (assoc 'description
  2894. feedinfo))
  2895. ""))
  2896. " ")))
  2897. (href (cdr (assoc 'href feedinfo)))
  2898. (coding (gnus-group-name-charset '(nnrss "") title)))
  2899. (when coding
  2900. ;; Unify non-ASCII text.
  2901. (setq title (mm-decode-coding-string
  2902. (mm-encode-coding-string title coding)
  2903. coding)))
  2904. (gnus-group-make-group title '(nnrss ""))
  2905. (push (list title href desc) nnrss-group-alist)
  2906. (nnrss-save-server-data nil))
  2907. (error "No feeds found for %s" url))))
  2908. (defun gnus-group-make-directory-group (dir)
  2909. "Create an nndir group.
  2910. The user will be prompted for a directory. The contents of this
  2911. directory will be used as a newsgroup. The directory should contain
  2912. mail messages or news articles in files that have numeric names."
  2913. (interactive
  2914. (list (read-directory-name "Create group from directory: ")))
  2915. (unless (file-exists-p dir)
  2916. (error "No such directory"))
  2917. (unless (file-directory-p dir)
  2918. (error "Not a directory"))
  2919. (let ((ext "")
  2920. (i 0)
  2921. group)
  2922. (while (or (not group) (gnus-group-entry group))
  2923. (setq group
  2924. (gnus-group-prefixed-name
  2925. (expand-file-name ext dir)
  2926. '(nndir "")))
  2927. (setq ext (format "<%d>" (setq i (1+ i)))))
  2928. (gnus-group-make-group
  2929. (gnus-group-real-name group)
  2930. (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
  2931. (defun gnus-group-add-to-virtual (n vgroup)
  2932. "Add the current group to a virtual group."
  2933. (interactive
  2934. (list current-prefix-arg
  2935. (gnus-group-completing-read "Add to virtual group"
  2936. nil t "nnvirtual:")))
  2937. (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
  2938. (error "%s is not an nnvirtual group" vgroup))
  2939. (gnus-close-group vgroup)
  2940. (let* ((groups (gnus-group-process-prefix n))
  2941. (method (gnus-info-method (gnus-get-info vgroup))))
  2942. (setcar (cdr method)
  2943. (concat
  2944. (nth 1 method) "\\|"
  2945. (mapconcat
  2946. (lambda (s)
  2947. (gnus-group-remove-mark s)
  2948. (concat "\\(^" (regexp-quote s) "$\\)"))
  2949. groups "\\|"))))
  2950. (gnus-group-position-point))
  2951. (defun gnus-group-make-empty-virtual (group)
  2952. "Create a new, fresh, empty virtual group."
  2953. (interactive "sCreate new, empty virtual group: ")
  2954. (let* ((method (list 'nnvirtual "^$"))
  2955. (pgroup (gnus-group-prefixed-name group method)))
  2956. ;; Check whether it exists already.
  2957. (when (gnus-group-entry pgroup)
  2958. (error "Group %s already exists" pgroup))
  2959. ;; Subscribe the new group after the group on the current line.
  2960. (gnus-subscribe-group pgroup (gnus-group-group-name) method)
  2961. (gnus-group-update-group pgroup)
  2962. (forward-line -1)
  2963. (gnus-group-position-point)))
  2964. (defun gnus-group-enter-directory (dir)
  2965. "Enter an ephemeral nneething group."
  2966. (interactive "DDirectory to read: ")
  2967. (let* ((method (list 'nneething dir '(nneething-read-only t)))
  2968. (leaf (gnus-group-prefixed-name
  2969. (file-name-nondirectory (directory-file-name dir))
  2970. method))
  2971. (name (gnus-generate-new-group-name leaf)))
  2972. (unless (gnus-group-read-ephemeral-group
  2973. name method t
  2974. (cons (current-buffer)
  2975. (if (eq major-mode 'gnus-summary-mode)
  2976. 'summary 'group)))
  2977. (error "Couldn't enter %s" dir))))
  2978. (defun gnus-group-expunge-group (group)
  2979. "Expunge deleted articles in current nnimap GROUP."
  2980. (interactive (list (gnus-group-group-name)))
  2981. (let ((method (gnus-find-method-for-group group)))
  2982. (if (not (gnus-check-backend-function
  2983. 'request-expunge-group (car method)))
  2984. (error "%s does not support expunging" (car method))
  2985. (gnus-request-expunge-group group method))))
  2986. (autoload 'nnimap-acl-get "nnimap")
  2987. (autoload 'nnimap-acl-edit "nnimap")
  2988. (defun gnus-group-nnimap-edit-acl (group)
  2989. "Edit the Access Control List of current nnimap GROUP."
  2990. (interactive (list (gnus-group-group-name)))
  2991. (let ((mailbox (gnus-group-real-name group)) method acl)
  2992. (unless group
  2993. (error "No group on current line"))
  2994. (unless (gnus-get-info group)
  2995. (error "Killed group; can't be edited"))
  2996. (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
  2997. (error "%s is not an nnimap group" group))
  2998. (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
  2999. (error "Server does not support ACL's"))
  3000. (gnus-edit-form acl (format "Editing the access control list for `%s'.
  3001. An access control list is a list of (identifier . rights) elements.
  3002. The identifier string specifies the corresponding user. The
  3003. identifier \"anyone\" is reserved to refer to the universal identity.
  3004. Rights is a string listing a (possibly empty) set of alphanumeric
  3005. characters, each character listing a set of operations which is being
  3006. controlled. Letters are reserved for ``standard'' rights, listed
  3007. below. Digits are reserved for implementation or site defined rights.
  3008. l - lookup (mailbox is visible to LIST/LSUB commands)
  3009. r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
  3010. SEARCH, COPY from mailbox)
  3011. s - keep seen/unseen information across sessions (STORE \\SEEN flag)
  3012. w - write (STORE flags other than \\SEEN and \\DELETED)
  3013. i - insert (perform APPEND, COPY into mailbox)
  3014. p - post (send mail to submission address for mailbox,
  3015. not enforced by IMAP4 itself)
  3016. c - create and delete mailbox (CREATE new sub-mailboxes in any
  3017. implementation-defined hierarchy, RENAME or DELETE mailbox)
  3018. d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
  3019. a - administer (perform SETACL)" group)
  3020. `(lambda (form)
  3021. (nnimap-acl-edit
  3022. ,mailbox ',method ',acl form)))))
  3023. ;; Group sorting commands
  3024. ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
  3025. (defun gnus-group-sort-groups (func &optional reverse)
  3026. "Sort the group buffer according to FUNC.
  3027. When used interactively, the sorting function used will be
  3028. determined by the `gnus-group-sort-function' variable.
  3029. If REVERSE (the prefix), reverse the sorting order."
  3030. (interactive (list gnus-group-sort-function current-prefix-arg))
  3031. (funcall gnus-group-sort-alist-function
  3032. (gnus-make-sort-function func) reverse)
  3033. (gnus-group-unmark-all-groups)
  3034. (gnus-group-list-groups)
  3035. (gnus-dribble-touch))
  3036. (defun gnus-group-sort-flat (func reverse)
  3037. ;; We peel off the dummy group from the alist.
  3038. (when func
  3039. (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
  3040. (pop gnus-newsrc-alist))
  3041. ;; Do the sorting.
  3042. (setq gnus-newsrc-alist
  3043. (sort gnus-newsrc-alist func))
  3044. (when reverse
  3045. (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
  3046. ;; Regenerate the hash table.
  3047. (gnus-make-hashtable-from-newsrc-alist)))
  3048. (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
  3049. "Sort the group buffer alphabetically by group name.
  3050. If REVERSE, sort in reverse order."
  3051. (interactive "P")
  3052. (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
  3053. (defun gnus-group-sort-groups-by-real-name (&optional reverse)
  3054. "Sort the group buffer alphabetically by real (unprefixed) group name.
  3055. If REVERSE, sort in reverse order."
  3056. (interactive "P")
  3057. (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
  3058. (defun gnus-group-sort-groups-by-unread (&optional reverse)
  3059. "Sort the group buffer by number of unread articles.
  3060. If REVERSE, sort in reverse order."
  3061. (interactive "P")
  3062. (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
  3063. (defun gnus-group-sort-groups-by-level (&optional reverse)
  3064. "Sort the group buffer by group level.
  3065. If REVERSE, sort in reverse order."
  3066. (interactive "P")
  3067. (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
  3068. (defun gnus-group-sort-groups-by-score (&optional reverse)
  3069. "Sort the group buffer by group score.
  3070. If REVERSE, sort in reverse order."
  3071. (interactive "P")
  3072. (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
  3073. (defun gnus-group-sort-groups-by-rank (&optional reverse)
  3074. "Sort the group buffer by group rank.
  3075. If REVERSE, sort in reverse order."
  3076. (interactive "P")
  3077. (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
  3078. (defun gnus-group-sort-groups-by-method (&optional reverse)
  3079. "Sort the group buffer alphabetically by back end name.
  3080. If REVERSE, sort in reverse order."
  3081. (interactive "P")
  3082. (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
  3083. (defun gnus-group-sort-groups-by-server (&optional reverse)
  3084. "Sort the group buffer alphabetically by server name.
  3085. If REVERSE, sort in reverse order."
  3086. (interactive "P")
  3087. (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
  3088. ;;; Selected group sorting.
  3089. (defun gnus-group-sort-selected-groups (n func &optional reverse)
  3090. "Sort the process/prefixed groups."
  3091. (interactive (list current-prefix-arg gnus-group-sort-function))
  3092. (let ((groups (gnus-group-process-prefix n)))
  3093. (funcall gnus-group-sort-selected-function
  3094. groups (gnus-make-sort-function func) reverse)
  3095. (gnus-group-unmark-all-groups)
  3096. (gnus-group-list-groups)
  3097. (gnus-dribble-touch)))
  3098. (defun gnus-group-sort-selected-flat (groups func reverse)
  3099. (let (entries infos)
  3100. ;; First find all the group entries for these groups.
  3101. (while groups
  3102. (push (nthcdr 2 (gnus-group-entry (pop groups)))
  3103. entries))
  3104. ;; Then sort the infos.
  3105. (setq infos
  3106. (sort
  3107. (mapcar
  3108. (lambda (entry) (car entry))
  3109. (setq entries (nreverse entries)))
  3110. func))
  3111. (when reverse
  3112. (setq infos (nreverse infos)))
  3113. ;; Go through all the infos and replace the old entries
  3114. ;; with the new infos.
  3115. (while infos
  3116. (setcar (car entries) (pop infos))
  3117. (pop entries))
  3118. ;; Update the hashtable.
  3119. (gnus-make-hashtable-from-newsrc-alist)))
  3120. (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
  3121. "Sort the group buffer alphabetically by group name.
  3122. Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
  3123. sort in reverse order."
  3124. (interactive (gnus-interactive "P\ny"))
  3125. (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
  3126. (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
  3127. "Sort the group buffer alphabetically by real group name.
  3128. Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
  3129. sort in reverse order."
  3130. (interactive (gnus-interactive "P\ny"))
  3131. (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
  3132. (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
  3133. "Sort the group buffer by number of unread articles.
  3134. Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
  3135. sort in reverse order."
  3136. (interactive (gnus-interactive "P\ny"))
  3137. (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
  3138. (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
  3139. "Sort the group buffer by group level.
  3140. Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
  3141. sort in reverse order."
  3142. (interactive (gnus-interactive "P\ny"))
  3143. (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
  3144. (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
  3145. "Sort the group buffer by group score.
  3146. Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
  3147. sort in reverse order."
  3148. (interactive (gnus-interactive "P\ny"))
  3149. (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
  3150. (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
  3151. "Sort the group buffer by group rank.
  3152. Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
  3153. sort in reverse order."
  3154. (interactive (gnus-interactive "P\ny"))
  3155. (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
  3156. (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
  3157. "Sort the group buffer alphabetically by back end name.
  3158. Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
  3159. sort in reverse order."
  3160. (interactive (gnus-interactive "P\ny"))
  3161. (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
  3162. ;;; Sorting predicates.
  3163. (defun gnus-group-sort-by-alphabet (info1 info2)
  3164. "Sort alphabetically."
  3165. (string< (gnus-info-group info1) (gnus-info-group info2)))
  3166. (defun gnus-group-sort-by-real-name (info1 info2)
  3167. "Sort alphabetically on real (unprefixed) names."
  3168. (string< (gnus-group-real-name (gnus-info-group info1))
  3169. (gnus-group-real-name (gnus-info-group info2))))
  3170. (defun gnus-group-sort-by-unread (info1 info2)
  3171. "Sort by number of unread articles."
  3172. (let ((n1 (gnus-group-unread (gnus-info-group info1)))
  3173. (n2 (gnus-group-unread (gnus-info-group info2))))
  3174. (< (or (and (numberp n1) n1) 0)
  3175. (or (and (numberp n2) n2) 0))))
  3176. (defun gnus-group-sort-by-level (info1 info2)
  3177. "Sort by level."
  3178. (< (gnus-info-level info1) (gnus-info-level info2)))
  3179. (defun gnus-group-sort-by-method (info1 info2)
  3180. "Sort alphabetically by back end name."
  3181. (string< (car (gnus-find-method-for-group
  3182. (gnus-info-group info1) info1))
  3183. (car (gnus-find-method-for-group
  3184. (gnus-info-group info2) info2))))
  3185. (defun gnus-group-sort-by-server (info1 info2)
  3186. "Sort alphabetically by server name."
  3187. (string< (gnus-method-to-full-server-name
  3188. (gnus-find-method-for-group
  3189. (gnus-info-group info1) info1))
  3190. (gnus-method-to-full-server-name
  3191. (gnus-find-method-for-group
  3192. (gnus-info-group info2) info2))))
  3193. (defun gnus-group-sort-by-score (info1 info2)
  3194. "Sort by group score."
  3195. (> (gnus-info-score info1) (gnus-info-score info2)))
  3196. (defun gnus-group-sort-by-rank (info1 info2)
  3197. "Sort by level and score."
  3198. (let ((level1 (gnus-info-level info1))
  3199. (level2 (gnus-info-level info2)))
  3200. (or (< level1 level2)
  3201. (and (= level1 level2)
  3202. (> (gnus-info-score info1) (gnus-info-score info2))))))
  3203. ;;; Clearing data
  3204. (defun gnus-group-clear-data (&optional arg)
  3205. "Clear all marks and read ranges from the current group.
  3206. Obeys the process/prefix convention."
  3207. (interactive "P")
  3208. (when (gnus-y-or-n-p "Really clear data? ")
  3209. (gnus-group-iterate arg
  3210. (lambda (group)
  3211. (let (info)
  3212. (gnus-info-clear-data (setq info (gnus-get-info group)))
  3213. (gnus-get-unread-articles-in-group info (gnus-active group) t)
  3214. (when (gnus-group-goto-group group)
  3215. (gnus-group-update-group-line)))))))
  3216. (defun gnus-group-clear-data-on-native-groups ()
  3217. "Clear all marks and read ranges from all native groups."
  3218. (interactive)
  3219. (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
  3220. (let ((alist (cdr gnus-newsrc-alist))
  3221. info)
  3222. (while (setq info (pop alist))
  3223. (when (gnus-group-native-p (gnus-info-group info))
  3224. (gnus-info-clear-data info)))
  3225. (gnus-get-unread-articles)
  3226. (gnus-dribble-touch)
  3227. (when (gnus-y-or-n-p
  3228. "Move the cache away to avoid problems in the future? ")
  3229. (call-interactively 'gnus-cache-move-cache)))))
  3230. (defun gnus-info-clear-data (info)
  3231. "Clear all marks and read ranges from INFO."
  3232. (let ((group (gnus-info-group info))
  3233. action)
  3234. (dolist (el (gnus-info-marks info))
  3235. (push `(,(cdr el) add (,(car el))) action))
  3236. (push `(,(gnus-info-read info) add (read)) action)
  3237. (gnus-undo-register
  3238. `(progn
  3239. (gnus-request-set-mark ,group ',action)
  3240. (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
  3241. (gnus-info-set-read ',info ',(gnus-info-read info))
  3242. (when (gnus-group-goto-group ,group)
  3243. (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
  3244. (gnus-group-update-group-line))))
  3245. (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
  3246. action))
  3247. (gnus-request-set-mark group action)
  3248. (gnus-info-set-read info nil)
  3249. (when (gnus-info-marks info)
  3250. (gnus-info-set-marks info nil))))
  3251. ;; Group catching up.
  3252. (defun gnus-group-catchup-current (&optional n all)
  3253. "Mark all unread articles in the current newsgroup as read.
  3254. If prefix argument N is numeric, the next N newsgroups will be
  3255. caught up. If ALL is non-nil, marked articles will also be marked as
  3256. read. Cross references (Xref: header) of articles are ignored.
  3257. The number of newsgroups that this function was unable to catch
  3258. up is returned."
  3259. (interactive "P")
  3260. (let ((groups (gnus-group-process-prefix n))
  3261. (ret 0)
  3262. group)
  3263. (unless groups (error "No groups selected"))
  3264. (if (not
  3265. (or (not gnus-interactive-catchup) ;Without confirmation?
  3266. gnus-expert-user
  3267. (gnus-y-or-n-p
  3268. (format
  3269. (if all
  3270. "Do you really want to mark all articles in %s as read? "
  3271. "Mark all unread articles in %s as read? ")
  3272. (if (= (length groups) 1)
  3273. (gnus-group-decoded-name (car groups))
  3274. (format "these %d groups" (length groups)))))))
  3275. n
  3276. (while (setq group (pop groups))
  3277. (gnus-group-remove-mark group)
  3278. ;; Virtual groups have to be given special treatment.
  3279. (let ((method (gnus-find-method-for-group group)))
  3280. (when (eq 'nnvirtual (car method))
  3281. (nnvirtual-catchup-group
  3282. (gnus-group-real-name group) (nth 1 method) all)))
  3283. (cond
  3284. ((>= (gnus-group-level group) gnus-level-zombie)
  3285. (gnus-message 2 "Dead groups can't be caught up"))
  3286. ((prog1
  3287. (gnus-group-goto-group group)
  3288. (gnus-group-catchup group all))
  3289. (gnus-group-update-group-line))
  3290. (t
  3291. (setq ret (1+ ret)))))
  3292. (gnus-group-next-unread-group 1)
  3293. ret)))
  3294. (defun gnus-group-catchup-current-all (&optional n)
  3295. "Mark all articles in current newsgroup as read.
  3296. Cross references (Xref: header) of articles are ignored."
  3297. (interactive "P")
  3298. (gnus-group-catchup-current n 'all))
  3299. (defun gnus-group-catchup (group &optional all)
  3300. "Mark all articles in GROUP as read.
  3301. If ALL is non-nil, all articles are marked as read.
  3302. The return value is the number of articles that were marked as read,
  3303. or nil if no action could be taken."
  3304. (let* ((entry (gnus-group-entry group))
  3305. (num (car entry))
  3306. (marks (gnus-info-marks (nth 2 entry)))
  3307. (unread (gnus-sequence-of-unread-articles group)))
  3308. ;; Remove entries for this group.
  3309. (nnmail-purge-split-history (gnus-group-real-name group))
  3310. ;; Do the updating only if the newsgroup isn't killed.
  3311. (if (not (numberp (car entry)))
  3312. (gnus-message 1 "Can't catch up %s; non-active group" group)
  3313. (gnus-update-read-articles group nil)
  3314. (when all
  3315. ;; Nix out the lists of marks and dormants.
  3316. (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
  3317. 'del '(tick))
  3318. (list (cdr (assq 'dormant marks))
  3319. 'del '(dormant))))
  3320. (setq unread (gnus-range-add (gnus-range-add
  3321. unread (cdr (assq 'dormant marks)))
  3322. (cdr (assq 'tick marks))))
  3323. (gnus-add-marked-articles group 'tick nil nil 'force)
  3324. (gnus-add-marked-articles group 'dormant nil nil 'force))
  3325. ;; Do auto-expirable marks if that's required.
  3326. (when (and (gnus-group-auto-expirable-p group)
  3327. (not (gnus-group-read-only-p group)))
  3328. (gnus-range-map
  3329. (lambda (article)
  3330. (gnus-add-marked-articles group 'expire (list article))
  3331. (gnus-request-set-mark group (list (list (list article)
  3332. 'add '(expire)))))
  3333. unread))
  3334. (let ((gnus-newsgroup-name group))
  3335. (gnus-run-hooks 'gnus-group-catchup-group-hook))
  3336. num)))
  3337. (defun gnus-group-expire-articles (&optional n)
  3338. "Expire all expirable articles in the current newsgroup.
  3339. Uses the process/prefix convention."
  3340. (interactive "P")
  3341. (let ((groups (gnus-group-process-prefix n))
  3342. group)
  3343. (unless groups
  3344. (error "No groups to expire"))
  3345. (while (setq group (pop groups))
  3346. (gnus-group-remove-mark group)
  3347. (gnus-group-expire-articles-1 group)
  3348. (gnus-dribble-touch)
  3349. (gnus-group-position-point))))
  3350. (defun gnus-group-expire-articles-1 (group)
  3351. (when (gnus-check-backend-function 'request-expire-articles group)
  3352. (gnus-message 6 "Expiring articles in %s..."
  3353. (gnus-group-decoded-name group))
  3354. (let* ((info (gnus-get-info group))
  3355. (expirable (if (gnus-group-total-expirable-p group)
  3356. (cons nil (gnus-list-of-read-articles group))
  3357. (assq 'expire (gnus-info-marks info))))
  3358. (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
  3359. (nnmail-expiry-target
  3360. (or (gnus-group-find-parameter group 'expiry-target)
  3361. nnmail-expiry-target)))
  3362. (when expirable
  3363. (gnus-check-group group)
  3364. (setcdr
  3365. expirable
  3366. (gnus-compress-sequence
  3367. (if expiry-wait
  3368. ;; We set the expiry variables to the group
  3369. ;; parameter.
  3370. (let ((nnmail-expiry-wait-function nil)
  3371. (nnmail-expiry-wait expiry-wait))
  3372. (gnus-request-expire-articles
  3373. (gnus-uncompress-sequence (cdr expirable)) group))
  3374. ;; Just expire using the normal expiry values.
  3375. (gnus-request-expire-articles
  3376. (gnus-uncompress-sequence (cdr expirable)) group))))
  3377. (gnus-close-group group))
  3378. (gnus-message 6 "Expiring articles in %s...done"
  3379. (gnus-group-decoded-name group))
  3380. ;; Return the list of un-expired articles.
  3381. (cdr expirable))))
  3382. (defun gnus-group-expire-all-groups ()
  3383. "Expire all expirable articles in all newsgroups."
  3384. (interactive)
  3385. (save-excursion
  3386. (gnus-message 5 "Expiring...")
  3387. (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
  3388. (cdr gnus-newsrc-alist))))
  3389. (gnus-group-expire-articles nil)))
  3390. (gnus-group-position-point)
  3391. (gnus-message 5 "Expiring...done"))
  3392. (defun gnus-group-set-current-level (n level)
  3393. "Set the level of the next N groups to LEVEL."
  3394. (interactive
  3395. (list
  3396. current-prefix-arg
  3397. (progn
  3398. (unless (gnus-group-process-prefix current-prefix-arg)
  3399. (error "No group on the current line"))
  3400. (string-to-number
  3401. (let ((s (read-string
  3402. (format "Level (default %s): "
  3403. (or (gnus-group-group-level)
  3404. gnus-level-default-subscribed)))))
  3405. (if (string-match "^\\s-*$" s)
  3406. (int-to-string (or (gnus-group-group-level)
  3407. gnus-level-default-subscribed))
  3408. s))))))
  3409. (unless (and (>= level 1) (<= level gnus-level-killed))
  3410. (error "Invalid level: %d" level))
  3411. (dolist (group (gnus-group-process-prefix n))
  3412. (gnus-group-remove-mark group)
  3413. (gnus-message 6 "Changed level of %s from %d to %d"
  3414. (gnus-group-decoded-name group)
  3415. (or (gnus-group-group-level) gnus-level-killed)
  3416. level)
  3417. (gnus-group-change-level
  3418. group level (or (gnus-group-group-level) gnus-level-killed))
  3419. (gnus-group-update-group-line))
  3420. (gnus-group-position-point))
  3421. (defun gnus-group-unsubscribe (&optional n)
  3422. "Unsubscribe the current group."
  3423. (interactive "P")
  3424. (gnus-group-unsubscribe-current-group n 'unsubscribe))
  3425. (defun gnus-group-subscribe (&optional n)
  3426. "Subscribe the current group."
  3427. (interactive "P")
  3428. (gnus-group-unsubscribe-current-group n 'subscribe))
  3429. (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
  3430. "Toggle subscription of the current group.
  3431. If given numerical prefix, toggle the N next groups."
  3432. (interactive "P")
  3433. (dolist (group (gnus-group-process-prefix n))
  3434. (gnus-group-remove-mark group)
  3435. (gnus-group-unsubscribe-group
  3436. group
  3437. (cond
  3438. ((eq do-sub 'unsubscribe)
  3439. gnus-level-default-unsubscribed)
  3440. ((eq do-sub 'subscribe)
  3441. gnus-level-default-subscribed)
  3442. ((<= (gnus-group-group-level) gnus-level-subscribed)
  3443. gnus-level-default-unsubscribed)
  3444. (t
  3445. gnus-level-default-subscribed))
  3446. t)
  3447. (gnus-group-update-group-line))
  3448. (gnus-group-next-group 1))
  3449. (defun gnus-group-unsubscribe-group (group &optional level silent)
  3450. "Toggle subscription to GROUP.
  3451. Killed newsgroups are subscribed. If SILENT, don't try to update the
  3452. group line."
  3453. (interactive (list (gnus-group-completing-read
  3454. nil nil (gnus-read-active-file-p))))
  3455. (let ((newsrc (gnus-group-entry group)))
  3456. (cond
  3457. ((string-match "^[ \t]*$" group)
  3458. (error "Empty group name"))
  3459. (newsrc
  3460. ;; Toggle subscription flag.
  3461. (gnus-group-change-level
  3462. newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
  3463. gnus-level-subscribed)
  3464. (1+ gnus-level-subscribed)
  3465. gnus-level-default-subscribed)))
  3466. (unless silent
  3467. (gnus-group-update-group group)))
  3468. ((and (stringp group)
  3469. (or (not (gnus-read-active-file-p))
  3470. (gnus-active group)))
  3471. ;; Add new newsgroup.
  3472. (gnus-group-change-level
  3473. group
  3474. (if level level gnus-level-default-subscribed)
  3475. (or (and (member group gnus-zombie-list)
  3476. gnus-level-zombie)
  3477. gnus-level-killed)
  3478. (when (gnus-group-group-name)
  3479. (gnus-group-entry (gnus-group-group-name))))
  3480. (unless silent
  3481. (gnus-group-update-group group)))
  3482. (t (error "No such newsgroup: %s" group)))
  3483. (gnus-group-position-point)))
  3484. (defun gnus-group-transpose-groups (n)
  3485. "Move the current newsgroup up N places.
  3486. If given a negative prefix, move down instead. The difference between
  3487. N and the number of steps taken is returned."
  3488. (interactive "p")
  3489. (unless (gnus-group-group-name)
  3490. (error "No group on current line"))
  3491. (gnus-group-kill-group 1)
  3492. (prog1
  3493. (forward-line (- n))
  3494. (gnus-group-yank-group)
  3495. (gnus-group-position-point)))
  3496. (defun gnus-group-kill-all-zombies (&optional dummy)
  3497. "Kill all zombie newsgroups.
  3498. The optional DUMMY should always be nil."
  3499. (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
  3500. (unless dummy
  3501. (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
  3502. (setq gnus-zombie-list nil)
  3503. (gnus-dribble-touch)
  3504. (gnus-group-list-groups)))
  3505. (defun gnus-group-kill-region (begin end)
  3506. "Kill newsgroups in current region (excluding current point).
  3507. The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
  3508. (interactive "r")
  3509. (let ((lines
  3510. ;; Count lines.
  3511. (save-excursion
  3512. (count-lines
  3513. (progn
  3514. (goto-char begin)
  3515. (point-at-bol))
  3516. (progn
  3517. (goto-char end)
  3518. (point-at-bol))))))
  3519. (goto-char begin)
  3520. (beginning-of-line) ;Important when LINES < 1
  3521. (gnus-group-kill-group lines)))
  3522. (defun gnus-group-kill-group (&optional n discard)
  3523. "Kill the next N groups.
  3524. The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
  3525. However, only groups that were alive can be yanked; already killed
  3526. groups or zombie groups can't be yanked.
  3527. The return value is the name of the group that was killed, or a list
  3528. of groups killed."
  3529. (interactive "P")
  3530. (let ((buffer-read-only nil)
  3531. (groups (gnus-group-process-prefix n))
  3532. group entry level out)
  3533. (if (< (length groups) 10)
  3534. ;; This is faster when there are few groups.
  3535. (while groups
  3536. (push (setq group (pop groups)) out)
  3537. (gnus-group-remove-mark group)
  3538. (setq level (gnus-group-group-level))
  3539. (gnus-delete-line)
  3540. (when (and (not discard)
  3541. (setq entry (gnus-group-entry group)))
  3542. (gnus-undo-register
  3543. `(progn
  3544. (gnus-group-goto-group ,(gnus-group-group-name))
  3545. (gnus-group-yank-group)))
  3546. (push (cons (car entry) (nth 2 entry))
  3547. gnus-list-of-killed-groups))
  3548. (gnus-group-change-level
  3549. (if entry entry group) gnus-level-killed (if entry nil level))
  3550. (when (numberp (gnus-group-unread group))
  3551. (gnus-request-update-group-status group 'unsubscribe))
  3552. (message "Killed group %s" (gnus-group-decoded-name group)))
  3553. ;; If there are lots and lots of groups to be killed, we use
  3554. ;; this thing instead.
  3555. (dolist (group (nreverse groups))
  3556. (gnus-group-remove-mark group)
  3557. (gnus-delete-line)
  3558. (push group gnus-killed-list)
  3559. (setq gnus-newsrc-alist
  3560. (delq (assoc group gnus-newsrc-alist)
  3561. gnus-newsrc-alist))
  3562. (when gnus-group-change-level-function
  3563. (funcall gnus-group-change-level-function
  3564. group gnus-level-killed 3))
  3565. (cond
  3566. ((setq entry (gnus-group-entry group))
  3567. (push (cons (car entry) (nth 2 entry))
  3568. gnus-list-of-killed-groups)
  3569. (setcdr (cdr entry) (cdddr entry)))
  3570. ((member group gnus-zombie-list)
  3571. (setq gnus-zombie-list (delete group gnus-zombie-list))))
  3572. ;; There may be more than one instance displayed.
  3573. (while (gnus-group-goto-group group)
  3574. (gnus-delete-line))
  3575. (when (numberp (gnus-group-unread group))
  3576. (gnus-request-update-group-status group 'unsubscribe)))
  3577. (gnus-make-hashtable-from-newsrc-alist))
  3578. (gnus-group-position-point)
  3579. (if (< (length out) 2) (car out) (nreverse out))))
  3580. (defun gnus-group-yank-group (&optional arg)
  3581. "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
  3582. The numeric ARG specifies how many newsgroups are to be yanked. The
  3583. name of the newsgroup yanked is returned, or (if several groups are
  3584. yanked) a list of yanked groups is returned."
  3585. (interactive "p")
  3586. (setq arg (or arg 1))
  3587. (let (info group prev out)
  3588. (while (>= (decf arg) 0)
  3589. (when (not (setq info (pop gnus-list-of-killed-groups)))
  3590. (error "No more newsgroups to yank"))
  3591. (push (setq group (nth 1 info)) out)
  3592. ;; Find which newsgroup to insert this one before - search
  3593. ;; backward until something suitable is found. If there are no
  3594. ;; other newsgroups in this buffer, just make this newsgroup the
  3595. ;; first newsgroup.
  3596. (setq prev (gnus-group-group-name))
  3597. (gnus-group-change-level
  3598. info (gnus-info-level (cdr info)) gnus-level-killed
  3599. (and prev (gnus-group-entry prev))
  3600. t)
  3601. (gnus-group-insert-group-line-info group)
  3602. (gnus-request-update-group-status group 'subscribe)
  3603. (gnus-undo-register
  3604. `(when (gnus-group-goto-group ,group)
  3605. (gnus-group-kill-group 1))))
  3606. (forward-line -1)
  3607. (gnus-group-position-point)
  3608. (if (< (length out) 2) (car out) (nreverse out))))
  3609. (defun gnus-group-kill-level (level)
  3610. "Kill all groups that is on a certain LEVEL."
  3611. (interactive "nKill all groups on level: ")
  3612. (cond
  3613. ((= level gnus-level-zombie)
  3614. (setq gnus-killed-list
  3615. (nconc gnus-zombie-list gnus-killed-list))
  3616. (setq gnus-zombie-list nil))
  3617. ((and (< level gnus-level-zombie)
  3618. (> level 0)
  3619. (or gnus-expert-user
  3620. (gnus-yes-or-no-p
  3621. (format
  3622. "Do you really want to kill all groups on level %d? "
  3623. level))))
  3624. (let* ((prev gnus-newsrc-alist)
  3625. (alist (cdr prev)))
  3626. (while alist
  3627. (if (= (gnus-info-level (car alist)) level)
  3628. (progn
  3629. (push (gnus-info-group (car alist)) gnus-killed-list)
  3630. (setcdr prev (cdr alist)))
  3631. (setq prev alist))
  3632. (setq alist (cdr alist)))
  3633. (gnus-make-hashtable-from-newsrc-alist)
  3634. (gnus-group-list-groups)))
  3635. (t
  3636. (error "Can't kill; invalid level: %d" level))))
  3637. (defun gnus-group-list-all-groups (&optional arg)
  3638. "List all newsgroups with level ARG or lower.
  3639. Default is `gnus-level-unsubscribed', which lists all subscribed and most
  3640. unsubscribed groups."
  3641. (interactive "P")
  3642. (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
  3643. ;; Redefine this to list ALL killed groups if prefix arg used.
  3644. ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
  3645. (defun gnus-group-list-killed (&optional arg)
  3646. "List all killed newsgroups in the group buffer.
  3647. If ARG is non-nil, list ALL killed groups known to Gnus. This may
  3648. entail asking the server for the groups."
  3649. (interactive "P")
  3650. ;; Find all possible killed newsgroups if arg.
  3651. (when arg
  3652. (gnus-get-killed-groups))
  3653. (if (not gnus-killed-list)
  3654. (gnus-message 6 "No killed groups")
  3655. (let (gnus-group-list-mode)
  3656. (funcall gnus-group-prepare-function
  3657. gnus-level-killed t gnus-level-killed))
  3658. (goto-char (point-min)))
  3659. (gnus-group-position-point))
  3660. (defun gnus-group-list-zombies ()
  3661. "List all zombie newsgroups in the group buffer."
  3662. (interactive)
  3663. (if (not gnus-zombie-list)
  3664. (gnus-message 6 "No zombie groups")
  3665. (let (gnus-group-list-mode)
  3666. (funcall gnus-group-prepare-function
  3667. gnus-level-zombie t gnus-level-zombie))
  3668. (goto-char (point-min)))
  3669. (gnus-group-position-point))
  3670. (defun gnus-group-list-active ()
  3671. "List all groups that are available from the server(s)."
  3672. (interactive)
  3673. ;; First we make sure that we have really read the active file.
  3674. (unless (gnus-read-active-file-p)
  3675. (let ((gnus-read-active-file t)
  3676. (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
  3677. (gnus-read-active-file)))
  3678. ;; Find all groups and sort them.
  3679. (let ((groups
  3680. (sort
  3681. (let (list)
  3682. (mapatoms
  3683. (lambda (sym)
  3684. (and (boundp sym)
  3685. (symbol-value sym)
  3686. (push (symbol-name sym) list)))
  3687. gnus-active-hashtb)
  3688. list)
  3689. 'string<))
  3690. (buffer-read-only nil)
  3691. group)
  3692. (erase-buffer)
  3693. (while groups
  3694. (setq group (pop groups))
  3695. (gnus-add-text-properties
  3696. (point) (prog1 (1+ (point))
  3697. (insert " *: "
  3698. (gnus-group-decoded-name group)
  3699. "\n"))
  3700. (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
  3701. 'gnus-unread t
  3702. 'gnus-level (inline (gnus-group-level group)))))
  3703. (goto-char (point-min))))
  3704. (defun gnus-activate-all-groups (level)
  3705. "Activate absolutely all groups."
  3706. (interactive (list gnus-level-unsubscribed))
  3707. (let ((gnus-activate-level level)
  3708. (gnus-activate-foreign-newsgroups level))
  3709. (gnus-group-get-new-news)))
  3710. (defun gnus-group-get-new-news (&optional arg)
  3711. "Get newly arrived articles.
  3712. If ARG is a number, it specifies which levels you are interested in
  3713. re-scanning. If ARG is non-nil and not a number, this will force
  3714. \"hard\" re-reading of the active files from all servers."
  3715. (interactive "P")
  3716. (require 'nnmail)
  3717. (let ((gnus-inhibit-demon t)
  3718. ;; Binding this variable will inhibit multiple fetchings
  3719. ;; of the same mail source.
  3720. (nnmail-fetched-sources (list t)))
  3721. (gnus-run-hooks 'gnus-get-top-new-news-hook)
  3722. (gnus-run-hooks 'gnus-get-new-news-hook)
  3723. ;; Read any slave files.
  3724. (unless gnus-slave
  3725. (gnus-master-read-slave-newsrc))
  3726. (gnus-get-unread-articles arg)
  3727. ;; If the user wants it, we scan for new groups.
  3728. (when (eq gnus-check-new-newsgroups 'always)
  3729. (gnus-find-new-newsgroups))
  3730. (gnus-check-reasonable-setup)
  3731. (gnus-run-hooks 'gnus-after-getting-new-news-hook)
  3732. (gnus-group-list-groups (and (numberp arg)
  3733. (max (car gnus-group-list-mode) arg)))))
  3734. (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
  3735. "Check for newly arrived news in the current group (and the N-1 next groups).
  3736. The difference between N and the number of newsgroup checked is returned.
  3737. If N is negative, this group and the N-1 previous groups will be checked.
  3738. If DONT-SCAN is non-nil, scan non-activated groups as well."
  3739. (interactive "P")
  3740. (let* ((groups (gnus-group-process-prefix n))
  3741. (ret (if (numberp n) (- n (length groups)) 0))
  3742. (beg (unless n
  3743. (point-marker)))
  3744. group method
  3745. (gnus-inhibit-demon t)
  3746. ;; Binding this variable will inhibit multiple fetchings
  3747. ;; of the same mail source.
  3748. (nnmail-fetched-sources (list t)))
  3749. (gnus-run-hooks 'gnus-get-new-news-hook)
  3750. (while (setq group (pop groups))
  3751. (gnus-group-remove-mark group)
  3752. ;; Bypass any previous denials from the server.
  3753. (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
  3754. (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
  3755. (let ((info (gnus-get-info group))
  3756. (active (gnus-active group)))
  3757. (when info
  3758. (gnus-request-update-info info method))
  3759. (gnus-get-unread-articles-in-group info active)
  3760. (unless (gnus-virtual-group-p group)
  3761. (gnus-close-group group))
  3762. (when gnus-agent
  3763. (gnus-agent-save-group-info
  3764. method (gnus-group-real-name group) active))
  3765. (gnus-group-update-group group nil t))
  3766. (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
  3767. (when beg
  3768. (goto-char beg))
  3769. (when gnus-goto-next-group-when-activating
  3770. (gnus-group-next-unread-group 1 t))
  3771. (gnus-group-position-point)
  3772. ret))
  3773. (defun gnus-group-describe-group (force &optional group)
  3774. "Display a description of the current newsgroup."
  3775. (interactive (list current-prefix-arg (gnus-group-group-name)))
  3776. (let* ((method (gnus-find-method-for-group group))
  3777. (mname (gnus-group-prefixed-name "" method))
  3778. desc)
  3779. (when (and force
  3780. gnus-description-hashtb)
  3781. (gnus-sethash mname nil gnus-description-hashtb))
  3782. (unless group
  3783. (error "No group name given"))
  3784. (when (or (and gnus-description-hashtb
  3785. ;; We check whether this group's method has been
  3786. ;; queried for a description file.
  3787. (gnus-gethash mname gnus-description-hashtb))
  3788. (setq desc (gnus-group-get-description group))
  3789. (gnus-read-descriptions-file method))
  3790. (gnus-message 1 "%s"
  3791. (or desc (gnus-gethash group gnus-description-hashtb)
  3792. "No description available")))))
  3793. ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
  3794. (defun gnus-group-describe-all-groups (&optional force)
  3795. "Pop up a buffer with descriptions of all newsgroups."
  3796. (interactive "P")
  3797. (when force
  3798. (setq gnus-description-hashtb nil))
  3799. (when (not (or gnus-description-hashtb
  3800. (gnus-read-all-descriptions-files)))
  3801. (error "Couldn't request descriptions file"))
  3802. (let ((buffer-read-only nil)
  3803. b)
  3804. (erase-buffer)
  3805. (mapatoms
  3806. (lambda (group)
  3807. (setq b (point))
  3808. (let ((charset (gnus-group-name-charset nil (symbol-name group))))
  3809. (insert (format " *: %-20s %s\n"
  3810. (gnus-group-name-decode
  3811. (symbol-name group) charset)
  3812. (gnus-group-name-decode
  3813. (symbol-value group) charset))))
  3814. (gnus-add-text-properties
  3815. b (1+ b) (list 'gnus-group group
  3816. 'gnus-unread t 'gnus-marked nil
  3817. 'gnus-level (1+ gnus-level-subscribed))))
  3818. gnus-description-hashtb)
  3819. (goto-char (point-min))
  3820. (gnus-group-position-point)))
  3821. ;; Suggested by Daniel Quinlan <quinlan@best.com>.
  3822. (defun gnus-group-apropos (regexp &optional search-description)
  3823. "List all newsgroups that have names that match a regexp."
  3824. (interactive "sGnus apropos (regexp): ")
  3825. (let ((prev "")
  3826. (obuf (current-buffer))
  3827. groups des)
  3828. ;; Go through all newsgroups that are known to Gnus.
  3829. (mapatoms
  3830. (lambda (group)
  3831. (and (symbol-name group)
  3832. (string-match regexp (symbol-name group))
  3833. (symbol-value group)
  3834. (push (symbol-name group) groups)))
  3835. gnus-active-hashtb)
  3836. ;; Also go through all descriptions that are known to Gnus.
  3837. (when search-description
  3838. (mapatoms
  3839. (lambda (group)
  3840. (and (string-match regexp (symbol-value group))
  3841. (push (symbol-name group) groups)))
  3842. gnus-description-hashtb))
  3843. (if (not groups)
  3844. (gnus-message 3 "No groups matched \"%s\"." regexp)
  3845. ;; Print out all the groups.
  3846. (save-excursion
  3847. (pop-to-buffer "*Gnus Help*")
  3848. (buffer-disable-undo)
  3849. (erase-buffer)
  3850. (setq groups (sort groups 'string<))
  3851. (while groups
  3852. ;; Groups may be entered twice into the list of groups.
  3853. (when (not (string= (car groups) prev))
  3854. (setq prev (car groups))
  3855. (let ((charset (gnus-group-name-charset nil prev)))
  3856. (insert (gnus-group-name-decode prev charset) "\n")
  3857. (when (and gnus-description-hashtb
  3858. (setq des (gnus-gethash (car groups)
  3859. gnus-description-hashtb)))
  3860. (insert " " (gnus-group-name-decode des charset) "\n"))))
  3861. (setq groups (cdr groups)))
  3862. (goto-char (point-min))))
  3863. (pop-to-buffer obuf)))
  3864. (defun gnus-group-description-apropos (regexp)
  3865. "List all newsgroups that have names or descriptions that match REGEXP."
  3866. (interactive "sGnus description apropos (regexp): ")
  3867. (when (not (or gnus-description-hashtb
  3868. (gnus-read-all-descriptions-files)))
  3869. (error "Couldn't request descriptions file"))
  3870. (gnus-group-apropos regexp t))
  3871. ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
  3872. (defun gnus-group-list-matching (level regexp &optional all lowest)
  3873. "List all groups with unread articles that match REGEXP.
  3874. If the prefix LEVEL is non-nil, it should be a number that says which
  3875. level to cut off listing groups.
  3876. If ALL, also list groups with no unread articles.
  3877. If LOWEST, don't list groups with level lower than LOWEST.
  3878. This command may read the active file."
  3879. (interactive "P\nsList newsgroups matching: ")
  3880. ;; First make sure active file has been read.
  3881. (when (and level
  3882. (> (prefix-numeric-value level) gnus-level-killed))
  3883. (gnus-get-killed-groups))
  3884. (funcall gnus-group-prepare-function
  3885. (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
  3886. (goto-char (point-min))
  3887. (gnus-group-position-point))
  3888. (defun gnus-group-list-all-matching (level regexp &optional lowest)
  3889. "List all groups that match REGEXP.
  3890. If the prefix LEVEL is non-nil, it should be a number that says which
  3891. level to cut off listing groups.
  3892. If LOWEST, don't list groups with level lower than LOWEST."
  3893. (interactive "P\nsList newsgroups matching: ")
  3894. (when level
  3895. (setq level (prefix-numeric-value level)))
  3896. (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
  3897. ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
  3898. (defun gnus-group-save-newsrc (&optional force)
  3899. "Save the Gnus startup files.
  3900. If FORCE, force saving whether it is necessary or not."
  3901. (interactive "P")
  3902. (gnus-save-newsrc-file force))
  3903. (defun gnus-group-restart (&optional arg)
  3904. "Force Gnus to read the .newsrc file."
  3905. (interactive "P")
  3906. (when (gnus-yes-or-no-p
  3907. (format "Are you sure you want to restart Gnus? "))
  3908. (gnus-save-newsrc-file)
  3909. (gnus-clear-system)
  3910. (gnus)))
  3911. (defun gnus-group-read-init-file ()
  3912. "Read the Gnus elisp init file."
  3913. (interactive)
  3914. (gnus-read-init-file)
  3915. (gnus-message 5 "Read %s" gnus-init-file))
  3916. (defun gnus-group-check-bogus-groups (&optional silent)
  3917. "Check bogus newsgroups.
  3918. If given a prefix, don't ask for confirmation before removing a bogus
  3919. group."
  3920. (interactive "P")
  3921. (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
  3922. (gnus-group-list-groups))
  3923. (defun gnus-group-find-new-groups (&optional arg)
  3924. "Search for new groups and add them.
  3925. Each new group will be treated with `gnus-subscribe-newsgroup-method'.
  3926. With 1 C-u, use the `ask-server' method to query the server for new
  3927. groups.
  3928. With 2 C-u's, use most complete method possible to query the server
  3929. for new groups, and subscribe the new groups as zombies."
  3930. (interactive "p")
  3931. (let ((new-groups (gnus-find-new-newsgroups (or arg 1)))
  3932. current-group)
  3933. (gnus-group-list-groups)
  3934. (setq current-group (gnus-group-group-name))
  3935. (dolist (group new-groups)
  3936. (gnus-group-jump-to-group group))
  3937. (when current-group
  3938. (gnus-group-jump-to-group current-group))))
  3939. (defun gnus-group-edit-global-kill (&optional article group)
  3940. "Edit the global kill file.
  3941. If GROUP, edit that local kill file instead."
  3942. (interactive "P")
  3943. (setq gnus-current-kill-article article)
  3944. (gnus-kill-file-edit-file group)
  3945. (gnus-message 6 "Editing a %s kill file (Type %s to exit)"
  3946. (if group "local" "global")
  3947. (substitute-command-keys "\\[gnus-kill-file-exit]")))
  3948. (defun gnus-group-edit-local-kill (article group)
  3949. "Edit a local kill file."
  3950. (interactive (list nil (gnus-group-group-name)))
  3951. (gnus-group-edit-global-kill article group))
  3952. (defun gnus-group-force-update ()
  3953. "Update `.newsrc' file."
  3954. (interactive)
  3955. (gnus-save-newsrc-file))
  3956. (defvar gnus-backlog-articles)
  3957. (defun gnus-group-suspend ()
  3958. "Suspend the current Gnus session.
  3959. In fact, cleanup buffers except for group mode buffer.
  3960. The hook `gnus-suspend-gnus-hook' is called before actually suspending."
  3961. (interactive)
  3962. (gnus-run-hooks 'gnus-suspend-gnus-hook)
  3963. (gnus-offer-save-summaries)
  3964. ;; Kill Gnus buffers except for group mode buffer.
  3965. (let ((group-buf (get-buffer gnus-group-buffer)))
  3966. (dolist (buf (gnus-buffers))
  3967. (unless (or (eq buf group-buf)
  3968. (eq buf gnus-dribble-buffer)
  3969. (with-current-buffer buf
  3970. (eq major-mode 'message-mode)))
  3971. (gnus-kill-buffer buf)))
  3972. (setq gnus-backlog-articles nil)
  3973. (gnus-kill-gnus-frames)
  3974. (when group-buf
  3975. (bury-buffer group-buf)
  3976. (delete-windows-on group-buf t))))
  3977. (defun gnus-group-clear-dribble ()
  3978. "Clear all information from the dribble buffer."
  3979. (interactive)
  3980. (gnus-dribble-clear)
  3981. (gnus-message 7 "Cleared dribble buffer"))
  3982. (defun gnus-group-exit ()
  3983. "Quit reading news after updating .newsrc.eld and .newsrc.
  3984. The hook `gnus-exit-gnus-hook' is called before actually exiting."
  3985. (interactive)
  3986. (when
  3987. (or noninteractive ;For gnus-batch-kill
  3988. (not gnus-interactive-exit) ;Without confirmation
  3989. gnus-expert-user
  3990. (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
  3991. (gnus-run-hooks 'gnus-exit-gnus-hook)
  3992. ;; Offer to save data from non-quitted summary buffers.
  3993. (gnus-offer-save-summaries)
  3994. ;; Save the newsrc file(s).
  3995. (gnus-save-newsrc-file)
  3996. ;; Kill-em-all.
  3997. (gnus-close-backends)
  3998. ;; Reset everything.
  3999. (gnus-clear-system)
  4000. ;; Allow the user to do things after cleaning up.
  4001. (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
  4002. (defun gnus-group-quit ()
  4003. "Quit reading news without updating .newsrc.eld or .newsrc.
  4004. The hook `gnus-exit-gnus-hook' is called before actually exiting."
  4005. (interactive)
  4006. (when (or noninteractive ;For gnus-batch-kill
  4007. (zerop (buffer-size))
  4008. (not (gnus-server-opened gnus-select-method))
  4009. gnus-expert-user
  4010. (not gnus-current-startup-file)
  4011. (gnus-yes-or-no-p
  4012. (format "Quit reading news without saving %s? "
  4013. (file-name-nondirectory gnus-current-startup-file))))
  4014. (gnus-run-hooks 'gnus-exit-gnus-hook)
  4015. (gnus-configure-windows 'group t)
  4016. (when (and (gnus-buffer-live-p gnus-dribble-buffer)
  4017. (not (zerop (with-current-buffer gnus-dribble-buffer
  4018. (buffer-size)))))
  4019. (gnus-dribble-enter
  4020. ";;; Gnus was exited on purpose without saving the .newsrc files."))
  4021. (gnus-dribble-save)
  4022. (gnus-close-backends)
  4023. (gnus-clear-system)
  4024. (gnus-kill-buffer gnus-group-buffer)
  4025. ;; Allow the user to do things after cleaning up.
  4026. (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
  4027. (defun gnus-group-describe-briefly ()
  4028. "Give a one line description of the group mode commands."
  4029. (interactive)
  4030. (gnus-message 7 "%s" (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help")))
  4031. (defun gnus-group-browse-foreign-server (method)
  4032. "Browse a foreign news server.
  4033. If called interactively, this function will ask for a select method
  4034. (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
  4035. If not, METHOD should be a list where the first element is the method
  4036. and the second element is the address."
  4037. (interactive
  4038. (list (let ((how (gnus-completing-read
  4039. "Which back end"
  4040. (mapcar 'car (append gnus-valid-select-methods
  4041. gnus-server-alist))
  4042. t (cons "nntp" 0) 'gnus-method-history)))
  4043. ;; We either got a back end name or a virtual server name.
  4044. ;; If the first, we also need an address.
  4045. (if (assoc how gnus-valid-select-methods)
  4046. (list (intern how)
  4047. ;; Suggested by mapjph@bath.ac.uk.
  4048. (gnus-completing-read
  4049. "Address"
  4050. gnus-secondary-servers))
  4051. ;; We got a server name.
  4052. how))))
  4053. (gnus-browse-foreign-server method))
  4054. (defun gnus-group-set-info (info &optional method-only-group part)
  4055. (when (or info part)
  4056. (let* ((entry (gnus-group-entry
  4057. (or method-only-group (gnus-info-group info))))
  4058. (part-info info)
  4059. (info (if method-only-group (nth 2 entry) info))
  4060. method)
  4061. (when method-only-group
  4062. (unless entry
  4063. (error "Trying to change non-existent group %s" method-only-group))
  4064. ;; We have received parts of the actual group info - either the
  4065. ;; select method or the group parameters. We first check
  4066. ;; whether we have to extend the info, and if so, do that.
  4067. (let ((len (length info))
  4068. (total (if (eq part 'method) 5 6)))
  4069. (when (< len total)
  4070. (setcdr (nthcdr (1- len) info)
  4071. (make-list (- total len) nil)))
  4072. ;; Then we enter the new info.
  4073. (setcar (nthcdr (1- total) info) part-info)))
  4074. (unless entry
  4075. ;; This is a new group, so we just create it.
  4076. (with-current-buffer gnus-group-buffer
  4077. (setq method (gnus-info-method info))
  4078. (when (gnus-server-equal method "native")
  4079. (setq method nil))
  4080. (with-current-buffer gnus-group-buffer
  4081. (if method
  4082. ;; It's a foreign group...
  4083. (gnus-group-make-group
  4084. (gnus-group-real-name (gnus-info-group info))
  4085. (if (stringp method) method
  4086. (prin1-to-string (car method)))
  4087. (and (consp method)
  4088. (nth 1 (gnus-info-method info)))
  4089. nil t)
  4090. ;; It's a native group.
  4091. (gnus-group-make-group (gnus-info-group info) nil nil nil t)))
  4092. (gnus-message 6 "Note: New group created")
  4093. (setq entry
  4094. (gnus-group-entry (gnus-group-prefixed-name
  4095. (gnus-group-real-name (gnus-info-group info))
  4096. (or (gnus-info-method info) gnus-select-method))))))
  4097. ;; Whether it was a new group or not, we now have the entry, so we
  4098. ;; can do the update.
  4099. (if entry
  4100. (progn
  4101. (setcar (nthcdr 2 entry) info)
  4102. (when (and (not (eq (car entry) t))
  4103. (gnus-active (gnus-info-group info)))
  4104. (setcar entry (length
  4105. (gnus-list-of-unread-articles (car info))))))
  4106. (error "No such group: %s" (gnus-info-group info))))))
  4107. (defun gnus-group-set-method-info (group select-method)
  4108. (gnus-group-set-info select-method group 'method))
  4109. (defun gnus-group-set-params-info (group params)
  4110. (gnus-group-set-info params group 'params))
  4111. ;; Ad-hoc function for inserting data from a different newsrc.eld
  4112. ;; file. Use with caution, if at all.
  4113. (defun gnus-import-other-newsrc-file (file)
  4114. (with-temp-buffer
  4115. (insert-file-contents file)
  4116. (let (form)
  4117. (while (ignore-errors
  4118. (setq form (read (current-buffer))))
  4119. (when (and (consp form)
  4120. (eq (cadr form) 'gnus-newsrc-alist))
  4121. (let ((infos (cadr (nth 2 form))))
  4122. (dolist (info infos)
  4123. (when (gnus-get-info (car info))
  4124. (gnus-set-info (car info) info)))))))))
  4125. (defun gnus-add-marked-articles (group type articles &optional info force)
  4126. ;; Add ARTICLES of TYPE to the info of GROUP.
  4127. ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
  4128. ;; add, but replace marked articles of TYPE with ARTICLES.
  4129. (let ((info (or info (gnus-get-info group)))
  4130. marked m)
  4131. (or (not info)
  4132. (and (not (setq marked (nthcdr 3 info)))
  4133. (or (null articles)
  4134. (setcdr (nthcdr 2 info)
  4135. (list (list (cons type (gnus-compress-sequence
  4136. articles t)))))))
  4137. (and (not (setq m (assq type (car marked))))
  4138. (or (null articles)
  4139. (setcar marked
  4140. (cons (cons type (gnus-compress-sequence articles t) )
  4141. (car marked)))))
  4142. (if force
  4143. (if (null articles)
  4144. (setcar (nthcdr 3 info)
  4145. (gnus-delete-alist type (car marked)))
  4146. (setcdr m (gnus-compress-sequence articles t)))
  4147. (setcdr m (gnus-compress-sequence
  4148. (sort (nconc (gnus-uncompress-range (cdr m))
  4149. (copy-sequence articles)) '<) t))))))
  4150. (defun gnus-add-mark (group mark article)
  4151. "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
  4152. (let ((buffer (gnus-summary-buffer-name group)))
  4153. (if (gnus-buffer-live-p buffer)
  4154. (with-current-buffer (get-buffer buffer)
  4155. (gnus-summary-add-mark article mark))
  4156. (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
  4157. (list article)))))
  4158. ;;;
  4159. ;;; Group timestamps
  4160. ;;;
  4161. (defun gnus-group-set-timestamp ()
  4162. "Change the timestamp of the current group to the current time.
  4163. This function can be used in hooks like `gnus-select-group-hook'
  4164. or `gnus-group-catchup-group-hook'."
  4165. (when gnus-newsgroup-name
  4166. (let ((time (current-time)))
  4167. (setcdr (cdr time) nil)
  4168. (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
  4169. (defsubst gnus-group-timestamp (group)
  4170. "Return the timestamp for GROUP."
  4171. (gnus-group-get-parameter group 'timestamp t))
  4172. (defun gnus-group-timestamp-delta (group)
  4173. "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
  4174. (let* ((time (or (gnus-group-timestamp group)
  4175. (list 0 0)))
  4176. (delta (subtract-time (current-time) time)))
  4177. (+ (* (nth 0 delta) 65536.0)
  4178. (nth 1 delta))))
  4179. (defun gnus-group-timestamp-string (group)
  4180. "Return a string of the timestamp for GROUP."
  4181. (let ((time (gnus-group-timestamp group)))
  4182. (if (not time)
  4183. ""
  4184. (gnus-time-iso8601 time))))
  4185. (defun gnus-group-list-cached (level &optional lowest)
  4186. "List all groups with cached articles.
  4187. If the prefix LEVEL is non-nil, it should be a number that says which
  4188. level to cut off listing groups.
  4189. If LOWEST, don't list groups with level lower than LOWEST.
  4190. This command may read the active file."
  4191. (interactive "P")
  4192. (when level
  4193. (setq level (prefix-numeric-value level)))
  4194. (when (or (not level) (>= level gnus-level-zombie))
  4195. (gnus-cache-open))
  4196. (funcall gnus-group-prepare-function
  4197. (or level gnus-level-subscribed)
  4198. #'(lambda (info)
  4199. (let ((marks (gnus-info-marks info)))
  4200. (assq 'cache marks)))
  4201. lowest
  4202. #'(lambda (group)
  4203. (or (gnus-gethash group
  4204. gnus-cache-active-hashtb)
  4205. ;; Cache active file might use "."
  4206. ;; instead of ":".
  4207. (gnus-gethash
  4208. (mapconcat 'identity
  4209. (split-string group ":")
  4210. ".")
  4211. gnus-cache-active-hashtb))))
  4212. (goto-char (point-min))
  4213. (gnus-group-position-point))
  4214. (defun gnus-group-list-dormant (level &optional lowest)
  4215. "List all groups with dormant articles.
  4216. If the prefix LEVEL is non-nil, it should be a number that says which
  4217. level to cut off listing groups.
  4218. If LOWEST, don't list groups with level lower than LOWEST.
  4219. This command may read the active file."
  4220. (interactive "P")
  4221. (when level
  4222. (setq level (prefix-numeric-value level)))
  4223. (when (or (not level) (>= level gnus-level-zombie))
  4224. (gnus-cache-open))
  4225. (funcall gnus-group-prepare-function
  4226. (or level gnus-level-subscribed)
  4227. #'(lambda (info)
  4228. (let ((marks (gnus-info-marks info)))
  4229. (assq 'dormant marks)))
  4230. lowest
  4231. 'ignore)
  4232. (goto-char (point-min))
  4233. (gnus-group-position-point))
  4234. (defun gnus-group-list-ticked (level &optional lowest)
  4235. "List all groups with ticked articles.
  4236. If the prefix LEVEL is non-nil, it should be a number that says which
  4237. level to cut off listing groups.
  4238. If LOWEST, don't list groups with level lower than LOWEST.
  4239. This command may read the active file."
  4240. (interactive "P")
  4241. (when level
  4242. (setq level (prefix-numeric-value level)))
  4243. (when (or (not level) (>= level gnus-level-zombie))
  4244. (gnus-cache-open))
  4245. (funcall gnus-group-prepare-function
  4246. (or level gnus-level-subscribed)
  4247. #'(lambda (info)
  4248. (let ((marks (gnus-info-marks info)))
  4249. (assq 'tick marks)))
  4250. lowest
  4251. 'ignore)
  4252. (goto-char (point-min))
  4253. (gnus-group-position-point))
  4254. (defun gnus-group-listed-groups ()
  4255. "Return a list of listed groups."
  4256. (let (point groups)
  4257. (goto-char (point-min))
  4258. (while (setq point (text-property-not-all (point) (point-max)
  4259. 'gnus-group nil))
  4260. (goto-char point)
  4261. (push (symbol-name (get-text-property point 'gnus-group)) groups)
  4262. (forward-char 1))
  4263. groups))
  4264. (defun gnus-group-list-plus (&optional args)
  4265. "List groups plus the current selection."
  4266. (interactive "P")
  4267. (let ((gnus-group-listed-groups (gnus-group-listed-groups))
  4268. (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
  4269. func)
  4270. (push last-command-event unread-command-events)
  4271. (if (featurep 'xemacs)
  4272. (push (make-event 'key-press '(key ?A)) unread-command-events)
  4273. (push ?A unread-command-events))
  4274. (let (gnus-pick-mode keys)
  4275. (setq keys (if (featurep 'xemacs)
  4276. (events-to-keys (read-key-sequence nil))
  4277. (read-key-sequence nil)))
  4278. (setq func (lookup-key (current-local-map) keys)))
  4279. (if (or (not func)
  4280. (numberp func))
  4281. (ding)
  4282. (call-interactively func))))
  4283. (defun gnus-group-list-flush (&optional args)
  4284. "Flush groups from the current selection."
  4285. (interactive "P")
  4286. (let ((gnus-group-list-option 'flush))
  4287. (gnus-group-list-plus args)))
  4288. (defun gnus-group-list-limit (&optional args)
  4289. "List groups limited within the current selection.
  4290. If you've limited the groups, you can further limit the selection
  4291. with this command. If you've first limited to groups with
  4292. dormant articles with `A ?', you can then further limit with
  4293. `A / c', which will then limit to groups with cached articles, giving
  4294. you the groups that have both dormant articles and cached articles."
  4295. (interactive "P")
  4296. (let ((gnus-group-list-option 'limit))
  4297. (gnus-group-list-plus args)))
  4298. (defun gnus-group-mark-article-read (group article)
  4299. "Mark ARTICLE read."
  4300. (let ((buffer (gnus-summary-buffer-name group))
  4301. (mark gnus-read-mark)
  4302. active n)
  4303. (if (get-buffer buffer)
  4304. (with-current-buffer buffer
  4305. (setq active gnus-newsgroup-active)
  4306. (gnus-activate-group group)
  4307. (when gnus-newsgroup-prepared
  4308. (when (and gnus-newsgroup-auto-expire
  4309. (memq mark gnus-auto-expirable-marks))
  4310. (setq mark gnus-expirable-mark))
  4311. (setq mark (gnus-request-update-mark
  4312. group article mark))
  4313. (gnus-mark-article-as-read article mark)
  4314. (setq gnus-newsgroup-active (gnus-active group))
  4315. (when active
  4316. (setq n (1+ (cdr active)))
  4317. (while (<= n (cdr gnus-newsgroup-active))
  4318. (unless (eq n article)
  4319. (push n gnus-newsgroup-unselected))
  4320. (setq n (1+ n)))
  4321. (setq gnus-newsgroup-unselected
  4322. (sort gnus-newsgroup-unselected '<)))))
  4323. (gnus-activate-group group)
  4324. (gnus-group-make-articles-read group (list article))
  4325. (when (and (gnus-group-auto-expirable-p group)
  4326. (not (gnus-group-read-only-p group)))
  4327. (gnus-add-marked-articles
  4328. group 'expire (list article))))))
  4329. ;;;
  4330. ;;; Group compaction. -- dvl
  4331. ;;;
  4332. (defun gnus-group-compact-group (group)
  4333. "Compact the current group.
  4334. Compaction means removing gaps between article numbers. Hence, this
  4335. operation is only meaningful for back ends using one file per article
  4336. \(e.g. nnml).
  4337. Note: currently only implemented in nnml."
  4338. (interactive (list (gnus-group-group-name)))
  4339. (unless group
  4340. (error "No group to compact"))
  4341. (unless (gnus-check-backend-function 'request-compact-group group)
  4342. (error "This back end does not support group compaction"))
  4343. (let ((group-decoded (gnus-group-decoded-name group)))
  4344. (gnus-message 6 "\
  4345. Compacting group %s... (this may take a long time)"
  4346. group-decoded)
  4347. (prog1
  4348. (if (not (gnus-request-compact-group group))
  4349. (gnus-error 3 "Couldn't compact group %s" group-decoded)
  4350. (gnus-message 6 "Compacting group %s...done" group-decoded)
  4351. t)
  4352. ;; Invalidate the "original article" buffer which might be out of date.
  4353. ;; #### NOTE: Yes, this might be a bit rude, but since compaction
  4354. ;; #### will not happen very often, I think this is acceptable.
  4355. (let ((original (get-buffer gnus-original-article-buffer)))
  4356. (and original (gnus-kill-buffer original)))
  4357. ;; Update the group line to reflect new information (art number etc).
  4358. (gnus-group-update-group-line))))
  4359. (provide 'gnus-group)
  4360. ;;; gnus-group.el ends here