diff options
| -rw-r--r-- | lisp/gnus.el | 97 |
1 files changed, 90 insertions, 7 deletions
diff --git a/lisp/gnus.el b/lisp/gnus.el index de94ffe9646..5490d696510 100644 --- a/lisp/gnus.el +++ b/lisp/gnus.el | |||
| @@ -594,6 +594,25 @@ field; if a string, use this; if non-nil, strip of the local host name.") | |||
| 594 | (defvar gnus-use-generic-path nil | 594 | (defvar gnus-use-generic-path nil |
| 595 | "*If nil, use the NNTP server name in the Path: field; if stringp, | 595 | "*If nil, use the NNTP server name in the Path: field; if stringp, |
| 596 | use this; if non-nil, use no host name (user name only)") | 596 | use this; if non-nil, use no host name (user name only)") |
| 597 | |||
| 598 | (defvar gnus-newsgroups-regex "^\\([^ \t\n]+\\)[ \t]+\\(.*\\)$" | ||
| 599 | "Regex to retrieve the group name and the group description from | ||
| 600 | the output of the newsgroups listing. | ||
| 601 | |||
| 602 | If you have ^M at the end of lines try \"^\\([^ \t\n]+\\)[ \t]+\\([^\r]+\\)[\r]*$\"") | ||
| 603 | |||
| 604 | (defvar gnus-newsgroups-display t | ||
| 605 | "*display the newsgroup description in *Newsgroup* buffer if not nil") | ||
| 606 | |||
| 607 | (defvar gnus-newsgroups-alist nil | ||
| 608 | "alist (groupname . description)") | ||
| 609 | |||
| 610 | (defvar gnus-newsgroups-hashtb nil | ||
| 611 | "hashtable of gnus-newsgroups-alist") | ||
| 612 | |||
| 613 | (defvar gnus-newsgroups-showall nil | ||
| 614 | "non nil if we display all the groups") | ||
| 615 | |||
| 597 | 616 | ||
| 598 | ;; Internal variables. | 617 | ;; Internal variables. |
| 599 | 618 | ||
| @@ -969,6 +988,7 @@ Optional argument HASHSIZE specifies the table size." | |||
| 969 | (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly) | 988 | (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly) |
| 970 | (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node) | 989 | (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node) |
| 971 | (define-key gnus-group-mode-map [mouse-2] 'gnus-mouse-pick-group) | 990 | (define-key gnus-group-mode-map [mouse-2] 'gnus-mouse-pick-group) |
| 991 | (define-key gnus-group-mode-map "t" 'gnus-newsgroups-display-toggle) | ||
| 972 | 992 | ||
| 973 | ;; Make a menu bar item. | 993 | ;; Make a menu bar item. |
| 974 | (define-key gnus-group-mode-map [menu-bar GNUS] | 994 | (define-key gnus-group-mode-map [menu-bar GNUS] |
| @@ -1007,6 +1027,10 @@ Optional argument HASHSIZE specifies the table size." | |||
| 1007 | (define-key gnus-group-mode-map [menu-bar groups separator-1] | 1027 | (define-key gnus-group-mode-map [menu-bar groups separator-1] |
| 1008 | '("--")) | 1028 | '("--")) |
| 1009 | 1029 | ||
| 1030 | (define-key gnus-group-mode-map [menu-bar groups newsgroups-update-description] | ||
| 1031 | '("Update descriptions" . gnus-newsgroups-update-description)) | ||
| 1032 | (define-key gnus-group-mode-map [menu-bar groups newsgroups-display-toggle] | ||
| 1033 | '("Toggle descriptions" . gnus-newsgroups-display-toggle)) | ||
| 1010 | (define-key gnus-group-mode-map [menu-bar groups jump-to-group] | 1034 | (define-key gnus-group-mode-map [menu-bar groups jump-to-group] |
| 1011 | '("Jump to Group..." . gnus-group-jump-to-group)) | 1035 | '("Jump to Group..." . gnus-group-jump-to-group)) |
| 1012 | (define-key gnus-group-mode-map [menu-bar groups list-all-groups] | 1036 | (define-key gnus-group-mode-map [menu-bar groups list-all-groups] |
| @@ -1057,6 +1081,7 @@ V Show the version number of this GNUS. | |||
| 1057 | ? Describe Group Mode commands briefly. | 1081 | ? Describe Group Mode commands briefly. |
| 1058 | C-h m Describe Group Mode. | 1082 | C-h m Describe Group Mode. |
| 1059 | C-c C-i Read Info about Group Mode. | 1083 | C-c C-i Read Info about Group Mode. |
| 1084 | t Toggle displaying newsgroup descriptions. | ||
| 1060 | 1085 | ||
| 1061 | The name of the host running NNTP server is asked for if no default | 1086 | The name of the host running NNTP server is asked for if no default |
| 1062 | host is specified. It is also possible to choose another NNTP server | 1087 | host is specified. It is also possible to choose another NNTP server |
| @@ -1288,6 +1313,7 @@ umerin@mse.kyutech.ac.jp" gnus-version)) | |||
| 1288 | "List newsgroups in the Newsgroup buffer. | 1313 | "List newsgroups in the Newsgroup buffer. |
| 1289 | If argument SHOW-ALL is non-nil, unsubscribed groups are also listed." | 1314 | If argument SHOW-ALL is non-nil, unsubscribed groups are also listed." |
| 1290 | (interactive "P") | 1315 | (interactive "P") |
| 1316 | (setq gnus-newsgroups-showall show-all) | ||
| 1291 | (let ((case-fold-search nil) | 1317 | (let ((case-fold-search nil) |
| 1292 | (last-group ;Current newsgroup. | 1318 | (last-group ;Current newsgroup. |
| 1293 | (gnus-group-group-name)) | 1319 | (gnus-group-group-name)) |
| @@ -1325,21 +1351,27 @@ If optional argument ALL is non-nil, unsubscribed groups are also listed." | |||
| 1325 | (newsrc gnus-newsrc-assoc) | 1351 | (newsrc gnus-newsrc-assoc) |
| 1326 | (group-info nil) | 1352 | (group-info nil) |
| 1327 | (group-name nil) | 1353 | (group-name nil) |
| 1354 | (group-description nil) | ||
| 1328 | (unread-count 0) | 1355 | (unread-count 0) |
| 1356 | (nb-tab 0) | ||
| 1329 | ;; This specifies the format of Group buffer. | 1357 | ;; This specifies the format of Group buffer. |
| 1330 | (cntl "%s%s%5d: %s\n")) | 1358 | (cntl "%s%s%5d: %s")) |
| 1331 | (erase-buffer) | 1359 | (erase-buffer) |
| 1332 | ;; List newsgroups. | 1360 | ;; List newsgroups. |
| 1333 | (while newsrc | 1361 | (while newsrc |
| 1334 | (setq group-info (car newsrc)) | 1362 | (setq group-info (car newsrc)) |
| 1335 | (setq group-name (car group-info)) | 1363 | (setq group-name (car group-info)) |
| 1364 | (if gnus-newsgroups-display | ||
| 1365 | (progn (setq group-description (gnus-gethash group-name gnus-newsgroups-hashtb)) | ||
| 1366 | (setq nb-tab (/ (- 38 (length group-name)) tab-width)))) | ||
| 1336 | (setq unread-count (nth 1 (gnus-gethash group-name gnus-unread-hashtb))) | 1367 | (setq unread-count (nth 1 (gnus-gethash group-name gnus-unread-hashtb))) |
| 1337 | (if (or all | 1368 | (if (or all |
| 1338 | (and (nth 1 group-info) ;Subscribed. | 1369 | (and (nth 1 group-info) ;Subscribed. |
| 1339 | (> unread-count 0))) ;There are unread articles. | 1370 | (> unread-count 0))) ;There are unread articles. |
| 1340 | ;; Yes, I can use gnus-group-prepare-line, but this is faster. | 1371 | ;; Yes, I can use gnus-group-prepare-line, but this is faster. |
| 1341 | (insert | 1372 | (insert |
| 1342 | (format cntl | 1373 | (format (concat cntl (make-string (if (> nb-tab 0) nb-tab 1) ?\t) |
| 1374 | "%s\n") | ||
| 1343 | ;; Subscribed or not. | 1375 | ;; Subscribed or not. |
| 1344 | (if (nth 1 group-info) " " "U") | 1376 | (if (nth 1 group-info) " " "U") |
| 1345 | ;; Has new news? | 1377 | ;; Has new news? |
| @@ -1353,7 +1385,10 @@ If optional argument ALL is non-nil, unsubscribed groups are also listed." | |||
| 1353 | ;; Number of unread articles. | 1385 | ;; Number of unread articles. |
| 1354 | unread-count | 1386 | unread-count |
| 1355 | ;; Newsgroup name. | 1387 | ;; Newsgroup name. |
| 1356 | group-name)) | 1388 | group-name |
| 1389 | ;; Newsgroup description | ||
| 1390 | (if group-description (cdr group-description) "") | ||
| 1391 | )) | ||
| 1357 | ) | 1392 | ) |
| 1358 | (setq newsrc (cdr newsrc)) | 1393 | (setq newsrc (cdr newsrc)) |
| 1359 | ) | 1394 | ) |
| @@ -1366,6 +1401,8 @@ If optional argument ALL is non-nil, unsubscribed groups are also listed." | |||
| 1366 | "Return a string for the Newsgroup buffer from INFO. | 1401 | "Return a string for the Newsgroup buffer from INFO. |
| 1367 | INFO is an element of `gnus-newsrc-assoc' or `gnus-killed-assoc'." | 1402 | INFO is an element of `gnus-newsrc-assoc' or `gnus-killed-assoc'." |
| 1368 | (let* ((group-name (car info)) | 1403 | (let* ((group-name (car info)) |
| 1404 | (group-description nil) | ||
| 1405 | (nb-tab 0) | ||
| 1369 | (unread-count | 1406 | (unread-count |
| 1370 | (or (nth 1 (gnus-gethash group-name gnus-unread-hashtb)) | 1407 | (or (nth 1 (gnus-gethash group-name gnus-unread-hashtb)) |
| 1371 | ;; Not in hash table, so compute it now. | 1408 | ;; Not in hash table, so compute it now. |
| @@ -1374,8 +1411,13 @@ INFO is an element of `gnus-newsrc-assoc' or `gnus-killed-assoc'." | |||
| 1374 | (nth 2 (gnus-gethash group-name gnus-active-hashtb)) | 1411 | (nth 2 (gnus-gethash group-name gnus-active-hashtb)) |
| 1375 | (nthcdr 2 info))))) | 1412 | (nthcdr 2 info))))) |
| 1376 | ;; This specifies the format of Group buffer. | 1413 | ;; This specifies the format of Group buffer. |
| 1377 | (cntl "%s%s%5d: %s\n")) | 1414 | (cntl "%s%s%5d: %s")) |
| 1378 | (format cntl | 1415 | (if gnus-newsgroups-display |
| 1416 | (progn | ||
| 1417 | (setq group-description (gnus-gethash group-name gnus-newsgroups-hashtb)) | ||
| 1418 | (setq nb-tab (/ (- 38 (length group-name)) tab-width)))) | ||
| 1419 | (format (concat cntl (make-string (if (> nb-tab 0) nb-tab 1) ?\t) | ||
| 1420 | "%s\n") | ||
| 1379 | ;; Subscribed or not. | 1421 | ;; Subscribed or not. |
| 1380 | (if (nth 1 info) " " "U") | 1422 | (if (nth 1 info) " " "U") |
| 1381 | ;; Has new news? | 1423 | ;; Has new news? |
| @@ -1390,6 +1432,8 @@ INFO is an element of `gnus-newsrc-assoc' or `gnus-killed-assoc'." | |||
| 1390 | unread-count | 1432 | unread-count |
| 1391 | ;; Newsgroup name. | 1433 | ;; Newsgroup name. |
| 1392 | group-name | 1434 | group-name |
| 1435 | ;; Newsgroup description | ||
| 1436 | (if group-description (cdr group-description) "") | ||
| 1393 | ))) | 1437 | ))) |
| 1394 | 1438 | ||
| 1395 | (defun gnus-group-update-group (group &optional visible-only) | 1439 | (defun gnus-group-update-group (group &optional visible-only) |
| @@ -1437,7 +1481,7 @@ If optional argument VISIBLE-ONLY is non-nil, non displayed group is ignored." | |||
| 1437 | "Get newsgroup name around point." | 1481 | "Get newsgroup name around point." |
| 1438 | (save-excursion | 1482 | (save-excursion |
| 1439 | (beginning-of-line) | 1483 | (beginning-of-line) |
| 1440 | (if (looking-at "^.+:[ \t]+\\([^ \t\n]+\\)\\([ \t].*\\|$\\)") | 1484 | (if (looking-at "^..[0-9 \t]+:[ \t]+\\([^ \t\n]+\\)\\([ \t].*\\|$\\)") |
| 1441 | (let ((group-name (buffer-substring (match-beginning 1) (match-end 1)))) | 1485 | (let ((group-name (buffer-substring (match-beginning 1) (match-end 1)))) |
| 1442 | (set-text-properties 0 (length group-name) nil group-name) | 1486 | (set-text-properties 0 (length group-name) nil group-name) |
| 1443 | group-name)))) | 1487 | group-name)))) |
| @@ -6260,6 +6304,15 @@ If optional argument RAWFILE is non-nil, force to read raw startup file." | |||
| 6260 | )) | 6304 | )) |
| 6261 | (gnus-expire-marked-articles) | 6305 | (gnus-expire-marked-articles) |
| 6262 | (gnus-get-unread-articles) | 6306 | (gnus-get-unread-articles) |
| 6307 | |||
| 6308 | ;; newsgroups description | ||
| 6309 | (if gnus-newsgroups-display | ||
| 6310 | (if (not gnus-newsgroups-alist) | ||
| 6311 | ;; Get newsgroups file only once. | ||
| 6312 | (gnus-newsgroups-retrieve-description))) | ||
| 6313 | |||
| 6314 | (setq gnus-newsgroups-hashtb (gnus-make-hashtable-from-alist gnus-newsgroups-alist)) | ||
| 6315 | |||
| 6263 | ;; Check new newsgroups and subscribe them. | 6316 | ;; Check new newsgroups and subscribe them. |
| 6264 | (if init | 6317 | (if init |
| 6265 | (let ((new-newsgroups (gnus-find-new-newsgroups))) | 6318 | (let ((new-newsgroups (gnus-find-new-newsgroups))) |
| @@ -6993,7 +7046,7 @@ If optional 2nd argument NEXT is non-nil, inserted before it." | |||
| 6993 | (insert ";; GNUS internal format of .newsrc.\n") | 7046 | (insert ";; GNUS internal format of .newsrc.\n") |
| 6994 | (insert ";; Touch .newsrc instead if you think to remove this file.\n") | 7047 | (insert ";; Touch .newsrc instead if you think to remove this file.\n") |
| 6995 | (let ((variable nil) | 7048 | (let ((variable nil) |
| 6996 | (variables gnus-variable-list) | 7049 | (variables (cons 'gnus-newsgroups-alist gnus-variable-list)) |
| 6997 | ;; Temporary rebind to make changes | 7050 | ;; Temporary rebind to make changes |
| 6998 | ;; gnus-check-killed-newsgroups in invisible. | 7051 | ;; gnus-check-killed-newsgroups in invisible. |
| 6999 | (gnus-killed-assoc gnus-killed-assoc) | 7052 | (gnus-killed-assoc gnus-killed-assoc) |
| @@ -7150,6 +7203,36 @@ Range of OBJ is expressed as `((beg1 . end1) (beg2 . end2) ...)." | |||
| 7150 | (setq gnus-distribution-list | 7203 | (setq gnus-distribution-list |
| 7151 | (nreverse gnus-distribution-list))) | 7204 | (nreverse gnus-distribution-list))) |
| 7152 | 7205 | ||
| 7206 | (defun gnus-newsgroups-retrieve-description () | ||
| 7207 | "Retrieve newsgroups description and build gnus-newsgroups-alist" | ||
| 7208 | (message "Reading newsgroups file...") | ||
| 7209 | (if (gnus-request-list-newsgroups) | ||
| 7210 | (save-excursion | ||
| 7211 | (setq gnus-newsgroups-alist nil) | ||
| 7212 | (set-buffer nntp-server-buffer) | ||
| 7213 | (goto-char (point-min)) | ||
| 7214 | (while (re-search-forward gnus-newsgroups-regex nil t) | ||
| 7215 | (setq gnus-newsgroups-alist | ||
| 7216 | (cons (cons (buffer-substring (match-beginning 1) (match-end 1)) | ||
| 7217 | (buffer-substring (match-beginning 2) (match-end 2))) | ||
| 7218 | gnus-newsgroups-alist))) | ||
| 7219 | (message "Reading newsgroups file...done")) | ||
| 7220 | (message "Cannot read newsgroups file"))) | ||
| 7221 | |||
| 7222 | (defun gnus-newsgroups-update-description () | ||
| 7223 | "Update the newsgroups description" | ||
| 7224 | (interactive) | ||
| 7225 | (gnus-newsgroups-retrieve-description) | ||
| 7226 | (setq gnus-newsgroups-hashtb (gnus-make-hashtable-from-alist gnus-newsgroups-alist))) | ||
| 7227 | |||
| 7228 | (defun gnus-newsgroups-display-toggle () | ||
| 7229 | "Toggle displaying newsgroup descriptions in *Newsgroup* buffer." | ||
| 7230 | (interactive) | ||
| 7231 | (setq gnus-newsgroups-display (not gnus-newsgroups-display)) | ||
| 7232 | (if gnus-newsgroups-showall | ||
| 7233 | (gnus-group-list-groups t) | ||
| 7234 | (gnus-group-list-groups nil))) | ||
| 7235 | |||
| 7153 | (provide 'gnus) | 7236 | (provide 'gnus) |
| 7154 | 7237 | ||
| 7155 | ;;Local variables: | 7238 | ;;Local variables: |