diff options
| author | Stefan Monnier | 2019-12-22 16:09:31 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2019-12-22 16:09:31 -0500 |
| commit | 7b3b27eef1325b41187f2e9cc898644d5eae9ff3 (patch) | |
| tree | ebe4c4cd0dd8c58768844d4f63abd267e6132327 | |
| parent | d7ab4edd93d44b33df72a4697b4628ee1133ca41 (diff) | |
| download | emacs-7b3b27eef1325b41187f2e9cc898644d5eae9ff3.tar.gz emacs-7b3b27eef1325b41187f2e9cc898644d5eae9ff3.zip | |
* lisp/gnus/gnus-start.el: Use lexical-binding
(gnus-group-change-level, gnus-make-hashtable-from-newsrc-alist):
Use gnus-info-make.
(gnus-make-hashtable-from-newsrc-alist): Prefer `gnus-info-group`
to `car` when applied to a `gnus-info` object.
(gnus-make-hashtable-from-killed): Remove unused vars `lists` and `list`.
(gnus-gnus-to-quick-newsrc-format): Extract common code from if branches.
* lisp/gnus/gnus.el (gnus-info-make): New constructor.
| -rw-r--r-- | lisp/gnus/gnus-start.el | 59 | ||||
| -rw-r--r-- | lisp/gnus/gnus.el | 4 |
2 files changed, 31 insertions, 32 deletions
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el index b90229e6f57..409fd442dd1 100644 --- a/lisp/gnus/gnus-start.el +++ b/lisp/gnus/gnus-start.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; gnus-start.el --- startup functions for Gnus | 1 | ;;; gnus-start.el --- startup functions for Gnus -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1996-2019 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1996-2019 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -518,7 +518,7 @@ Can be used to turn version control on or off." | |||
| 518 | 518 | ||
| 519 | (defun gnus-subscribe-hierarchical-interactive (groups) | 519 | (defun gnus-subscribe-hierarchical-interactive (groups) |
| 520 | (let ((groups (sort groups 'string<)) | 520 | (let ((groups (sort groups 'string<)) |
| 521 | prefixes prefix start ans group starts real-group) | 521 | prefixes prefix start ans group starts) |
| 522 | (while groups | 522 | (while groups |
| 523 | (setq prefixes (list "^")) | 523 | (setq prefixes (list "^")) |
| 524 | (while (and groups prefixes) | 524 | (while (and groups prefixes) |
| @@ -1101,7 +1101,7 @@ for new groups, and subscribe the new groups as zombies." | |||
| 1101 | ;; Go though every newsgroup in `gnus-active-hashtb' and compare | 1101 | ;; Go though every newsgroup in `gnus-active-hashtb' and compare |
| 1102 | ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'. | 1102 | ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'. |
| 1103 | (maphash | 1103 | (maphash |
| 1104 | (lambda (g-name active) | 1104 | (lambda (g-name _active) |
| 1105 | (unless (or (gethash g-name gnus-killed-hashtb) | 1105 | (unless (or (gethash g-name gnus-killed-hashtb) |
| 1106 | (gethash g-name gnus-newsrc-hashtb)) | 1106 | (gethash g-name gnus-newsrc-hashtb)) |
| 1107 | (let ((do-sub (gnus-matches-options-n g-name))) | 1107 | (let ((do-sub (gnus-matches-options-n g-name))) |
| @@ -1330,14 +1330,10 @@ string name) to insert this group before." | |||
| 1330 | (setq active (gnus-active group)) | 1330 | (setq active (gnus-active group)) |
| 1331 | (setq num | 1331 | (setq num |
| 1332 | (if active (- (1+ (cdr active)) (car active)) t)) | 1332 | (if active (- (1+ (cdr active)) (car active)) t)) |
| 1333 | ;; Shorten the select method if possible, if we need to | ||
| 1334 | ;; store it at all (native groups). | ||
| 1335 | (let ((method (gnus-method-simplify | 1333 | (let ((method (gnus-method-simplify |
| 1336 | (or gnus-override-subscribe-method | 1334 | (or gnus-override-subscribe-method |
| 1337 | (gnus-group-method group))))) | 1335 | (gnus-group-method group))))) |
| 1338 | (if method | 1336 | (gnus-info-make group level nil nil method))) |
| 1339 | (setq info (list group level nil nil method)) | ||
| 1340 | (setq info (list group level nil))))) | ||
| 1341 | ;; Add group. The exact ordering only matters for | 1337 | ;; Add group. The exact ordering only matters for |
| 1342 | ;; `gnus-group-list', though we need to keep the dummy group | 1338 | ;; `gnus-group-list', though we need to keep the dummy group |
| 1343 | ;; at the head of `gnus-newsrc-alist'. | 1339 | ;; at the head of `gnus-newsrc-alist'. |
| @@ -1585,6 +1581,7 @@ backend check whether the group actually exists." | |||
| 1585 | (defun gnus-get-unread-articles (&optional level dont-connect one-level) | 1581 | (defun gnus-get-unread-articles (&optional level dont-connect one-level) |
| 1586 | (setq gnus-server-method-cache nil) | 1582 | (setq gnus-server-method-cache nil) |
| 1587 | (require 'gnus-agent) | 1583 | (require 'gnus-agent) |
| 1584 | (defvar gnus-agent-article-local-times) | ||
| 1588 | (let* ((newsrc (cdr gnus-newsrc-alist)) | 1585 | (let* ((newsrc (cdr gnus-newsrc-alist)) |
| 1589 | (alevel (or level gnus-activate-level (1+ gnus-level-subscribed))) | 1586 | (alevel (or level gnus-activate-level (1+ gnus-level-subscribed))) |
| 1590 | (foreign-level | 1587 | (foreign-level |
| @@ -1602,7 +1599,7 @@ backend check whether the group actually exists." | |||
| 1602 | (type-cache nil) | 1599 | (type-cache nil) |
| 1603 | (gnus-agent-article-local-times 0) | 1600 | (gnus-agent-article-local-times 0) |
| 1604 | (archive-method (gnus-server-to-method "archive")) | 1601 | (archive-method (gnus-server-to-method "archive")) |
| 1605 | infos info group active method cmethod | 1602 | info group active method cmethod |
| 1606 | method-type method-group-list entry) | 1603 | method-type method-group-list entry) |
| 1607 | (gnus-message 6 "Checking new news...") | 1604 | (gnus-message 6 "Checking new news...") |
| 1608 | 1605 | ||
| @@ -1666,7 +1663,7 @@ backend check whether the group actually exists." | |||
| 1666 | ;; aren't equal (and that need extension; i.e., they are async). | 1663 | ;; aren't equal (and that need extension; i.e., they are async). |
| 1667 | (let ((methods nil)) | 1664 | (let ((methods nil)) |
| 1668 | (dolist (elem type-cache) | 1665 | (dolist (elem type-cache) |
| 1669 | (cl-destructuring-bind (method method-type infos dummy) elem | 1666 | (cl-destructuring-bind (method _method-type infos _dummy) elem |
| 1670 | (let ((gnus-opened-servers methods)) | 1667 | (let ((gnus-opened-servers methods)) |
| 1671 | (when (and (gnus-similar-server-opened method) | 1668 | (when (and (gnus-similar-server-opened method) |
| 1672 | (gnus-check-backend-function | 1669 | (gnus-check-backend-function |
| @@ -1689,7 +1686,7 @@ backend check whether the group actually exists." | |||
| 1689 | 1686 | ||
| 1690 | ;; Clear out all the early methods. | 1687 | ;; Clear out all the early methods. |
| 1691 | (dolist (elem type-cache) | 1688 | (dolist (elem type-cache) |
| 1692 | (cl-destructuring-bind (method method-type infos dummy) elem | 1689 | (cl-destructuring-bind (method _method-type infos _dummy) elem |
| 1693 | (when (and method | 1690 | (when (and method |
| 1694 | infos | 1691 | infos |
| 1695 | (gnus-check-backend-function | 1692 | (gnus-check-backend-function |
| @@ -1706,7 +1703,7 @@ backend check whether the group actually exists." | |||
| 1706 | (let ((done-methods nil) | 1703 | (let ((done-methods nil) |
| 1707 | sanity-spec) | 1704 | sanity-spec) |
| 1708 | (dolist (elem type-cache) | 1705 | (dolist (elem type-cache) |
| 1709 | (cl-destructuring-bind (method method-type infos dummy) elem | 1706 | (cl-destructuring-bind (method _method-type infos _dummy) elem |
| 1710 | (setq sanity-spec (list (car method) (cadr method))) | 1707 | (setq sanity-spec (list (car method) (cadr method))) |
| 1711 | (when (and method infos | 1708 | (when (and method infos |
| 1712 | (not (gnus-method-denied-p method))) | 1709 | (not (gnus-method-denied-p method))) |
| @@ -1737,7 +1734,7 @@ backend check whether the group actually exists." | |||
| 1737 | 1734 | ||
| 1738 | ;; Do the rest of the retrieval. | 1735 | ;; Do the rest of the retrieval. |
| 1739 | (dolist (elem type-cache) | 1736 | (dolist (elem type-cache) |
| 1740 | (cl-destructuring-bind (method method-type infos early-data) elem | 1737 | (cl-destructuring-bind (method _method-type infos early-data) elem |
| 1741 | (when (and method infos | 1738 | (when (and method infos |
| 1742 | (not (gnus-method-denied-p method))) | 1739 | (not (gnus-method-denied-p method))) |
| 1743 | (let ((updatep (gnus-check-backend-function | 1740 | (let ((updatep (gnus-check-backend-function |
| @@ -1822,7 +1819,7 @@ The info element is shared with the same element of | |||
| 1822 | (if (equal (caar gnus-newsrc-alist) | 1819 | (if (equal (caar gnus-newsrc-alist) |
| 1823 | "dummy.group") | 1820 | "dummy.group") |
| 1824 | gnus-newsrc-alist | 1821 | gnus-newsrc-alist |
| 1825 | (cons (list "dummy.group" 0 nil) alist)))) | 1822 | (cons (gnus-info-make "dummy.group" 0 nil) alist)))) |
| 1826 | (while alist | 1823 | (while alist |
| 1827 | (setq info (car alist)) | 1824 | (setq info (car alist)) |
| 1828 | ;; Make the same select-methods identical Lisp objects. | 1825 | ;; Make the same select-methods identical Lisp objects. |
| @@ -1831,10 +1828,10 @@ The info element is shared with the same element of | |||
| 1831 | (setf (gnus-info-method info) (car rest)) | 1828 | (setf (gnus-info-method info) (car rest)) |
| 1832 | (push method methods))) | 1829 | (push method methods))) |
| 1833 | ;; Check for encoded group names and decode them. | 1830 | ;; Check for encoded group names and decode them. |
| 1834 | (when (string-match-p "[^[:ascii:]]" (setq gname (car info))) | 1831 | (when (string-match-p "[^[:ascii:]]" (setq gname (gnus-info-group info))) |
| 1835 | (let ((decoded (gnus-group-decoded-name gname))) | 1832 | (let ((decoded (gnus-group-decoded-name gname))) |
| 1836 | (setf gname decoded | 1833 | (setf gname decoded |
| 1837 | (car info) decoded))) | 1834 | (gnus-info-group info) decoded))) |
| 1838 | ;; Check for duplicates. | 1835 | ;; Check for duplicates. |
| 1839 | (if (gethash gname gnus-newsrc-hashtb) | 1836 | (if (gethash gname gnus-newsrc-hashtb) |
| 1840 | ;; Remove this entry from the alist. | 1837 | ;; Remove this entry from the alist. |
| @@ -1857,15 +1854,13 @@ The info element is shared with the same element of | |||
| 1857 | 1854 | ||
| 1858 | (defun gnus-make-hashtable-from-killed () | 1855 | (defun gnus-make-hashtable-from-killed () |
| 1859 | "Create a hash table from the killed and zombie lists." | 1856 | "Create a hash table from the killed and zombie lists." |
| 1860 | (let ((lists '(gnus-killed-list gnus-zombie-list)) | 1857 | (setq gnus-killed-hashtb |
| 1861 | list) | 1858 | (gnus-make-hashtable |
| 1862 | (setq gnus-killed-hashtb | 1859 | (+ (length gnus-killed-list) (length gnus-zombie-list)))) |
| 1863 | (gnus-make-hashtable | 1860 | (dolist (g (append gnus-killed-list gnus-zombie-list)) |
| 1864 | (+ (length gnus-killed-list) (length gnus-zombie-list)))) | 1861 | ;; NOTE: We have lost the ordering that used to be kept in this |
| 1865 | (dolist (g (append gnus-killed-list gnus-zombie-list)) | 1862 | ;; variable. |
| 1866 | ;; NOTE: We have lost the ordering that used to be kept in this | 1863 | (puthash g t gnus-killed-hashtb))) |
| 1867 | ;; variable. | ||
| 1868 | (puthash g t gnus-killed-hashtb)))) | ||
| 1869 | 1864 | ||
| 1870 | (defun gnus-parse-active () | 1865 | (defun gnus-parse-active () |
| 1871 | "Parse active info in the nntp server buffer." | 1866 | "Parse active info in the nntp server buffer." |
| @@ -1982,7 +1977,7 @@ The info element is shared with the same element of | |||
| 1982 | (gnus-make-hashtable-from-killed)) | 1977 | (gnus-make-hashtable-from-killed)) |
| 1983 | ;; Go through all newsgroups that are known to Gnus - enlarge kill list. | 1978 | ;; Go through all newsgroups that are known to Gnus - enlarge kill list. |
| 1984 | (maphash | 1979 | (maphash |
| 1985 | (lambda (g-name active) | 1980 | (lambda (g-name _active) |
| 1986 | (let ((groups 0)) | 1981 | (let ((groups 0)) |
| 1987 | (unless (or (gethash g-name gnus-killed-hashtb) | 1982 | (unless (or (gethash g-name gnus-killed-hashtb) |
| 1988 | (gethash g-name gnus-newsrc-hashtb)) | 1983 | (gethash g-name gnus-newsrc-hashtb)) |
| @@ -2262,7 +2257,7 @@ If FORCE is non-nil, the .newsrc file is read." | |||
| 2262 | (gnus-convert-old-newsrc) | 2257 | (gnus-convert-old-newsrc) |
| 2263 | (gnus-clean-old-newsrc)))) | 2258 | (gnus-clean-old-newsrc)))) |
| 2264 | 2259 | ||
| 2265 | (defun gnus-clean-old-newsrc (&optional force) | 2260 | (defun gnus-clean-old-newsrc (&optional _force) |
| 2266 | ;; Currently no cleanups. | 2261 | ;; Currently no cleanups. |
| 2267 | ) | 2262 | ) |
| 2268 | 2263 | ||
| @@ -2354,7 +2349,7 @@ If FORCE is non-nil, the .newsrc file is read." | |||
| 2354 | no-prompt | 2349 | no-prompt |
| 2355 | (funcall no-prompt))))) | 2350 | (funcall no-prompt))))) |
| 2356 | 2351 | ||
| 2357 | (defun gnus-convert-old-ticks (converting-to) | 2352 | (defun gnus-convert-old-ticks (_converting-to) |
| 2358 | (let ((newsrc (cdr gnus-newsrc-alist)) | 2353 | (let ((newsrc (cdr gnus-newsrc-alist)) |
| 2359 | marks info dormant ticked) | 2354 | marks info dormant ticked) |
| 2360 | (while (setq info (pop newsrc)) | 2355 | (while (setq info (pop newsrc)) |
| @@ -2375,7 +2370,7 @@ If FORCE is non-nil, the .newsrc file is read." | |||
| 2375 | (while (not (eobp)) | 2370 | (while (not (eobp)) |
| 2376 | (condition-case type | 2371 | (condition-case type |
| 2377 | (let ((form (read (current-buffer)))) | 2372 | (let ((form (read (current-buffer)))) |
| 2378 | (eval form)) | 2373 | (eval form t)) |
| 2379 | (error | 2374 | (error |
| 2380 | (unless (eq (car type) 'end-of-file) | 2375 | (unless (eq (car type) 'end-of-file) |
| 2381 | (let ((errmsg (format "Error in %s line %d" file | 2376 | (let ((errmsg (format "Error in %s line %d" file |
| @@ -2858,9 +2853,9 @@ Variables printed are either the variables specified in | |||
| 2858 | SPECIFIC-VARIABLES, or those in `gnus-variable-list'." | 2853 | SPECIFIC-VARIABLES, or those in `gnus-variable-list'." |
| 2859 | (princ (format ";; -*- mode:emacs-lisp; coding: %s; -*-\n" | 2854 | (princ (format ";; -*- mode:emacs-lisp; coding: %s; -*-\n" |
| 2860 | gnus-ding-file-coding-system)) | 2855 | gnus-ding-file-coding-system)) |
| 2861 | (if name | 2856 | (princ (if name |
| 2862 | (princ (format ";; %s\n" name)) | 2857 | (format ";; %s\n" name) |
| 2863 | (princ ";; Gnus startup file.\n")) | 2858 | ";; Gnus startup file.\n")) |
| 2864 | 2859 | ||
| 2865 | (unless minimal | 2860 | (unless minimal |
| 2866 | (princ "\ | 2861 | (princ "\ |
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el index 23643cc6c79..7aec4d6216a 100644 --- a/lisp/gnus/gnus.el +++ b/lisp/gnus/gnus.el | |||
| @@ -2818,7 +2818,11 @@ See Info node `(gnus)Formatting Variables'." | |||
| 2818 | ;; Info access macros. | 2818 | ;; Info access macros. |
| 2819 | 2819 | ||
| 2820 | (cl-defstruct (gnus-info | 2820 | (cl-defstruct (gnus-info |
| 2821 | (:constructor gnus-info-make | ||
| 2822 | (group rank read &optional marks method params)) | ||
| 2821 | (:constructor nil) | 2823 | (:constructor nil) |
| 2824 | ;; FIMXE: gnus-newsrc-alist contains a list of those, | ||
| 2825 | ;; so changing them to a real struct will take more work! | ||
| 2822 | (:type list)) | 2826 | (:type list)) |
| 2823 | group rank read marks method params) | 2827 | group rank read marks method params) |
| 2824 | 2828 | ||