diff options
| author | Eric Abrahamsen | 2017-09-29 13:58:04 -0700 |
|---|---|---|
| committer | Eric Abrahamsen | 2017-10-21 19:22:22 -0700 |
| commit | 73dda4e0b45a1f831d5f990fb29e958a76ccc518 (patch) | |
| tree | c72e3ffe7fd751597727059be2c7cfe66f33d846 | |
| parent | 92045f4546b9708dc9f69954799d211c1f56ff1e (diff) | |
| download | emacs-scratch/gnus-docs.tar.gz emacs-scratch/gnus-docs.zip | |
Add more comments and docstrings to Gnus source filesscratch/gnus-docs
| -rw-r--r-- | lisp/gnus/gnus-group.el | 2 | ||||
| -rw-r--r-- | lisp/gnus/gnus-int.el | 26 | ||||
| -rw-r--r-- | lisp/gnus/gnus-start.el | 48 | ||||
| -rw-r--r-- | lisp/gnus/gnus.el | 22 | ||||
| -rw-r--r-- | lisp/gnus/nnheader.el | 18 | ||||
| -rw-r--r-- | lisp/gnus/nnoo.el | 36 |
6 files changed, 138 insertions, 14 deletions
diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el index 985efe6272f..94e32e778b2 100644 --- a/lisp/gnus/gnus-group.el +++ b/lisp/gnus/gnus-group.el | |||
| @@ -2080,7 +2080,7 @@ that group." | |||
| 2080 | no-article nil no-display nil select-articles))) | 2080 | no-article nil no-display nil select-articles))) |
| 2081 | 2081 | ||
| 2082 | (defun gnus-group-select-group (&optional all) | 2082 | (defun gnus-group-select-group (&optional all) |
| 2083 | "Select this newsgroup. | 2083 | "Read news in this newsgroup. |
| 2084 | No article is selected automatically. | 2084 | No article is selected automatically. |
| 2085 | If the group is opened, just switch the summary buffer. | 2085 | If the group is opened, just switch the summary buffer. |
| 2086 | If ALL is non-nil, already read articles become readable. | 2086 | If ALL is non-nil, already read articles become readable. |
diff --git a/lisp/gnus/gnus-int.el b/lisp/gnus/gnus-int.el index 0c7381286cd..4bd66a0cb3a 100644 --- a/lisp/gnus/gnus-int.el +++ b/lisp/gnus/gnus-int.el | |||
| @@ -22,6 +22,25 @@ | |||
| 22 | 22 | ||
| 23 | ;;; Commentary: | 23 | ;;; Commentary: |
| 24 | 24 | ||
| 25 | ;; Together with nnoo.el, this file defines the basic behavior of | ||
| 26 | ;; Gnus' backends. General server functions like `gnus-open-server' | ||
| 27 | ;; and `gnus-request-set-mark' all have a common behavior: | ||
| 28 | |||
| 29 | ;; 1. They accept a server as an argument, or else accept a group as | ||
| 30 | ;; an argument and find the server from the group. | ||
| 31 | |||
| 32 | ;; 2. For functions that aren't mandatory, they see if the server | ||
| 33 | ;; implements the function in question, using | ||
| 34 | ;; `gnus-check-backend-function'. | ||
| 35 | |||
| 36 | ;; 3. They get the server-specific version of the function with | ||
| 37 | ;; `gnus-get-function', and call it with `funcall'. Ie, | ||
| 38 | ;; `gnus-open-server' finds its function with: | ||
| 39 | |||
| 40 | ;; (gnus-get-function server 'open-server) | ||
| 41 | |||
| 42 | ;; and funcalls it. | ||
| 43 | |||
| 25 | ;;; Code: | 44 | ;;; Code: |
| 26 | 45 | ||
| 27 | (eval-when-compile (require 'cl)) | 46 | (eval-when-compile (require 'cl)) |
| @@ -605,7 +624,7 @@ from other groups -- for instance, search results and the like." | |||
| 605 | (gnus-try-warping-via-registry))))) | 624 | (gnus-try-warping-via-registry))))) |
| 606 | 625 | ||
| 607 | (defun gnus-request-head (article group) | 626 | (defun gnus-request-head (article group) |
| 608 | "Request the head of ARTICLE in GROUP." | 627 | "Request the head (ie headers) of ARTICLE in GROUP." |
| 609 | (let* ((gnus-command-method (gnus-find-method-for-group group)) | 628 | (let* ((gnus-command-method (gnus-find-method-for-group group)) |
| 610 | (head (gnus-get-function gnus-command-method 'request-head t)) | 629 | (head (gnus-get-function gnus-command-method 'request-head t)) |
| 611 | res clean-up) | 630 | res clean-up) |
| @@ -845,7 +864,10 @@ If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned." | |||
| 845 | result)) | 864 | result)) |
| 846 | 865 | ||
| 847 | (defun gnus-close-backends () | 866 | (defun gnus-close-backends () |
| 848 | ;; Send a close request to all backends that support such a request. | 867 | "Send a close request to all backends that support closing." |
| 868 | ;; Why would this use `gnus-valid-select-methods', when those aren't | ||
| 869 | ;; actually servers? How is this different from what | ||
| 870 | ;; `gnus-group-suspend' does? | ||
| 849 | (let ((methods gnus-valid-select-methods) | 871 | (let ((methods gnus-valid-select-methods) |
| 850 | (gnus-inhibit-demon t) | 872 | (gnus-inhibit-demon t) |
| 851 | func gnus-command-method) | 873 | func gnus-command-method) |
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el index 3c3c594fe7b..c47e3459b56 100644 --- a/lisp/gnus/gnus-start.el +++ b/lisp/gnus/gnus-start.el | |||
| @@ -22,6 +22,37 @@ | |||
| 22 | 22 | ||
| 23 | ;;; Commentary: | 23 | ;;; Commentary: |
| 24 | 24 | ||
| 25 | ;; This file contains all the code necessary to get Gnus up and | ||
| 26 | ;; running. The main entrypoint is `gnus-1', which clears any | ||
| 27 | ;; existing variables and re-loads from the various init files. The | ||
| 28 | ;; most important steps in `gnus-1' are: | ||
| 29 | |||
| 30 | ;; 1. Read the "gnus.el" init file with `gnus-read-init-file'. | ||
| 31 | ;; 2. Run `gnus-start-news-server' to open the server listed in | ||
| 32 | ;; `gnus-select-method'. | ||
| 33 | ;; 3. Call `gnus-setup-news', which is the heart of startup, see | ||
| 34 | ;; below. | ||
| 35 | ;; 4. Set up the *Group* buffer and mode and list of groups, etc. | ||
| 36 | |||
| 37 | ;; The function `gnus-setup-news' does the next level of work. It | ||
| 38 | ;; does two main things: first it calls `gnus-read-newsrc-file', which | ||
| 39 | ;; reads the ".newsrc.eld" file and sets the variable | ||
| 40 | ;; `gnus-newsrc-alist', holding all known groups and their marks, and | ||
| 41 | ;; eventually calls `gnus-make-hashtable-from-newsrc-alist', which | ||
| 42 | ;; uses `gnus-newsrc-alist' to populate `gnus-newsrc-hashtb'. | ||
| 43 | |||
| 44 | ;; Later, it calls `gnus-get-unread-articles', which is also the | ||
| 45 | ;; function called anytime the user "updates" Gnus with "g" in the | ||
| 46 | ;; Group buffer. `gnus-get-unread-articles' first decides which | ||
| 47 | ;; groups should be updated, then calls | ||
| 48 | ;; `gnus-get-unread-articles-in-group' on each one. This updates the | ||
| 49 | ;; group's active and marks information. | ||
| 50 | |||
| 51 | ;; There are also `gnus-activate-group', which may or may not also | ||
| 52 | ;; request a scan of the group. We're currently investigating what | ||
| 53 | ;; these terms actually mean. | ||
| 54 | |||
| 55 | |||
| 25 | ;;; Code: | 56 | ;;; Code: |
| 26 | 57 | ||
| 27 | (require 'gnus) | 58 | (require 'gnus) |
| @@ -840,7 +871,9 @@ prompt the user for the name of an NNTP server to use." | |||
| 840 | ;;; | 871 | ;;; |
| 841 | 872 | ||
| 842 | (defvar gnus-dribble-ignore nil) | 873 | (defvar gnus-dribble-ignore nil) |
| 843 | (defvar gnus-dribble-eval-file nil) | 874 | (defvar gnus-dribble-eval-file nil |
| 875 | "When non-nil, the dribble file should be read. | ||
| 876 | This flag is set in `gnus-1', and checked by `gnus-setup-news'.") | ||
| 844 | 877 | ||
| 845 | (defun gnus-dribble-file-name () | 878 | (defun gnus-dribble-file-name () |
| 846 | "Return the dribble file for the current .newsrc." | 879 | "Return the dribble file for the current .newsrc." |
| @@ -1463,6 +1496,7 @@ newsgroup." | |||
| 1463 | (when (> (cdr cache-active) (cdr active)) | 1496 | (when (> (cdr cache-active) (cdr active)) |
| 1464 | (setcdr active (cdr cache-active)))))))) | 1497 | (setcdr active (cdr cache-active)))))))) |
| 1465 | 1498 | ||
| 1499 | ;;FIXME: What does "activate" actually MEAN? | ||
| 1466 | (defun gnus-activate-group (group &optional scan dont-check method | 1500 | (defun gnus-activate-group (group &optional scan dont-check method |
| 1467 | dont-sub-check) | 1501 | dont-sub-check) |
| 1468 | "Check whether a group has been activated or not. | 1502 | "Check whether a group has been activated or not. |
| @@ -1614,9 +1648,10 @@ backend check whether the group actually exists." | |||
| 1614 | (setcar (gnus-group-entry (gnus-info-group info)) num)) | 1648 | (setcar (gnus-group-entry (gnus-info-group info)) num)) |
| 1615 | num))) | 1649 | num))) |
| 1616 | 1650 | ||
| 1617 | ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb' | ||
| 1618 | ;; and compute how many unread articles there are in each group. | ||
| 1619 | (defun gnus-get-unread-articles (&optional level dont-connect one-level) | 1651 | (defun gnus-get-unread-articles (&optional level dont-connect one-level) |
| 1652 | "Go though `gnus-newsrc-alist' and compare with | ||
| 1653 | `gnus-active-hashtb' and compute how many unread articles there | ||
| 1654 | are in each group." | ||
| 1620 | (setq gnus-server-method-cache nil) | 1655 | (setq gnus-server-method-cache nil) |
| 1621 | (require 'gnus-agent) | 1656 | (require 'gnus-agent) |
| 1622 | (let* ((newsrc (cdr gnus-newsrc-alist)) | 1657 | (let* ((newsrc (cdr gnus-newsrc-alist)) |
| @@ -1838,9 +1873,12 @@ backend check whether the group actually exists." | |||
| 1838 | (dolist (info infos) | 1873 | (dolist (info infos) |
| 1839 | (gnus-activate-group (gnus-info-group info) nil nil method t)))))) | 1874 | (gnus-activate-group (gnus-info-group info) nil nil method t)))))) |
| 1840 | 1875 | ||
| 1841 | ;; Create a hash table out of the newsrc alist. The `car's of the | ||
| 1842 | ;; alist elements are used as keys. | ||
| 1843 | (defun gnus-make-hashtable-from-newsrc-alist () | 1876 | (defun gnus-make-hashtable-from-newsrc-alist () |
| 1877 | "Create a hash table out of the newsrc alist. | ||
| 1878 | For each element in `gnus-newsrc-alist', representing a group and | ||
| 1879 | its marks, create an equivalent entry in `gnus-newsrc-hashtb'. | ||
| 1880 | If there was already an entry for the group in the hashtable, | ||
| 1881 | preserve the original entry's unread counts." | ||
| 1844 | (let ((alist gnus-newsrc-alist) | 1882 | (let ((alist gnus-newsrc-alist) |
| 1845 | (ohashtb gnus-newsrc-hashtb) | 1883 | (ohashtb gnus-newsrc-hashtb) |
| 1846 | prev info method rest methods) | 1884 | prev info method rest methods) |
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el index 8c0846be9f7..eaaf01b9b26 100644 --- a/lisp/gnus/gnus.el +++ b/lisp/gnus/gnus.el | |||
| @@ -1161,7 +1161,21 @@ REST is a plist of following: | |||
| 1161 | :variable-document The documentation for the variable. | 1161 | :variable-document The documentation for the variable. |
| 1162 | :variable-group The group for customizing the variable. | 1162 | :variable-group The group for customizing the variable. |
| 1163 | :variable-type The type for customizing the variable. | 1163 | :variable-type The type for customizing the variable. |
| 1164 | :variable-default The default value of the variable." | 1164 | :variable-default The default value of the variable. |
| 1165 | |||
| 1166 | This macro can define several things for PARAM: a group | ||
| 1167 | parameter, a function accessor, and a variable. The parameter | ||
| 1168 | has the name PARAM, which is what will be stored in | ||
| 1169 | `gnus-newsrc-alist'. The function accesssor returns the value of | ||
| 1170 | the parameter when called with a group as its only argument. The | ||
| 1171 | variable is by default named `gnus-parameter-PARAM-alist', and | ||
| 1172 | holds a list of '(regexp value) pairs, where the regexp is | ||
| 1173 | matched again group names, and value is the default value for | ||
| 1174 | matched groups. | ||
| 1175 | |||
| 1176 | In other words, PARAM is set for a single group, while | ||
| 1177 | `gnus-parameter-PARAM-alist' works the other way, by providing | ||
| 1178 | default parameter values for whole classes of matching groups." | ||
| 1165 | (let* ((type (plist-get rest :type)) | 1179 | (let* ((type (plist-get rest :type)) |
| 1166 | (parameter-type (plist-get rest :parameter-type)) | 1180 | (parameter-type (plist-get rest :parameter-type)) |
| 1167 | (parameter-document (plist-get rest :parameter-document)) | 1181 | (parameter-document (plist-get rest :parameter-document)) |
| @@ -2689,8 +2703,10 @@ such as a mark that says whether an article is stored in the cache | |||
| 2689 | "Gnus variables saved in the quick startup file.") | 2703 | "Gnus variables saved in the quick startup file.") |
| 2690 | 2704 | ||
| 2691 | (defvar gnus-newsrc-alist nil | 2705 | (defvar gnus-newsrc-alist nil |
| 2692 | "Assoc list of read articles. | 2706 | "Assoc list of groups and their info. |
| 2693 | `gnus-newsrc-hashtb' should be kept so that both hold the same information.") | 2707 | Each element is a list of group name, marks and article numbers, |
| 2708 | and other parameters set by the user. `gnus-newsrc-hashtb' | ||
| 2709 | should be kept so that both hold the same information.") | ||
| 2694 | 2710 | ||
| 2695 | (defvar gnus-registry-alist nil | 2711 | (defvar gnus-registry-alist nil |
| 2696 | "Assoc list of registry data. | 2712 | "Assoc list of registry data. |
diff --git a/lisp/gnus/nnheader.el b/lisp/gnus/nnheader.el index 0ea99d53a4a..036945fed06 100644 --- a/lisp/gnus/nnheader.el +++ b/lisp/gnus/nnheader.el | |||
| @@ -24,6 +24,19 @@ | |||
| 24 | 24 | ||
| 25 | ;;; Commentary: | 25 | ;;; Commentary: |
| 26 | 26 | ||
| 27 | ;; This file implements communication with the (slightly-misnamed) | ||
| 28 | ;; `nntp-server-buffer'. When Gnus sends requests to the backends, | ||
| 29 | ;; they insert their responses into this buffer, and the various | ||
| 30 | ;; `nnheader-*' functions read and parse those responses. The | ||
| 31 | ;; responses might be control strings like "211 OK", and they might be | ||
| 32 | ;; full article headers and bodies. Some backend's server responses | ||
| 33 | ;; are only interpretable by that backend; they still use this buffer | ||
| 34 | ;; to insert server responses, but then read (and remove) those | ||
| 35 | ;; responses themselves. | ||
| 36 | |||
| 37 | ;; Failure to clear this buffer, or to set point correctly, is an easy | ||
| 38 | ;; Gnus bug. | ||
| 39 | |||
| 27 | ;;; Code: | 40 | ;;; Code: |
| 28 | 41 | ||
| 29 | (eval-when-compile (require 'cl)) | 42 | (eval-when-compile (require 'cl)) |
| @@ -564,7 +577,10 @@ the line could be found." | |||
| 564 | 577 | ||
| 565 | ;; Various cruft the backends and Gnus need to communicate. | 578 | ;; Various cruft the backends and Gnus need to communicate. |
| 566 | 579 | ||
| 567 | (defvar nntp-server-buffer nil) | 580 | (defvar nntp-server-buffer nil |
| 581 | "Buffer used for communication with server backends. | ||
| 582 | When Gnus sends a request to the various servers, they insert | ||
| 583 | their responses into this buffer.") | ||
| 568 | (defvar nntp-process-response nil) | 584 | (defvar nntp-process-response nil) |
| 569 | 585 | ||
| 570 | (defvar nnheader-callback-function nil) | 586 | (defvar nnheader-callback-function nil) |
diff --git a/lisp/gnus/nnoo.el b/lisp/gnus/nnoo.el index be38f8d1d75..4f066939d25 100644 --- a/lisp/gnus/nnoo.el +++ b/lisp/gnus/nnoo.el | |||
| @@ -22,13 +22,42 @@ | |||
| 22 | 22 | ||
| 23 | ;;; Commentary: | 23 | ;;; Commentary: |
| 24 | 24 | ||
| 25 | ;; This file defines Gnus' non-object-oriented polymorphism scheme for | ||
| 26 | ;; server backends. It allows the rest of the code to be relatively | ||
| 27 | ;; agnostic about how particular backends (eg IMAP, maildir, nntp, | ||
| 28 | ;; etc) actually work: it simply calls standard functions on them, and | ||
| 29 | ;; retrieves standard variable values from them. | ||
| 30 | |||
| 31 | ;; New backends are created using `nnoo-declare' (functionally | ||
| 32 | ;; equivalent to `defclass'). The macro `defvoo' creates server | ||
| 33 | ;; variables (equivalent to slots in EIEIO). The macro `deffoo' | ||
| 34 | ;; creates server functions (equivalent to generic methods). | ||
| 35 | |||
| 36 | ;; The Gnus manual goes into fair detail about this | ||
| 37 | ;; inheritance/polymorphism system, see (info "(gnus) Writing New Back | ||
| 38 | ;; Ends"). | ||
| 39 | |||
| 40 | ;; Any time the user switches servers, the function | ||
| 41 | ;; `nnoo-change-servers' copies all the relevant server variables into | ||
| 42 | ;; global variables, to make that server the "current server". | ||
| 43 | |||
| 25 | ;;; Code: | 44 | ;;; Code: |
| 26 | 45 | ||
| 27 | (require 'nnheader) | 46 | (require 'nnheader) |
| 28 | (eval-when-compile (require 'cl)) | 47 | (eval-when-compile (require 'cl)) |
| 29 | 48 | ||
| 30 | (defvar nnoo-definition-alist nil) | 49 | (defvar nnoo-definition-alist nil |
| 31 | (defvar nnoo-state-alist nil) | 50 | "A list of all available server backends. |
| 51 | All backends that have been defined with `nnoo-declare' appear | ||
| 52 | here. Each backend appears as a list of four elements: the | ||
| 53 | symbol name of the backend, the parent backends it inherits from, | ||
| 54 | a list of potential server variables, and a list of backend | ||
| 55 | functions it implements.") | ||
| 56 | |||
| 57 | (defvar nnoo-state-alist nil | ||
| 58 | "A list of all the current servers. | ||
| 59 | Includes their server variables and their active groups.") | ||
| 60 | |||
| 32 | (defvar nnoo-parent-backend nil) | 61 | (defvar nnoo-parent-backend nil) |
| 33 | 62 | ||
| 34 | (defmacro defvoo (var init &optional doc &rest map) | 63 | (defmacro defvoo (var init &optional doc &rest map) |
| @@ -57,6 +86,9 @@ | |||
| 57 | (setcar funcs (cons func (car funcs))))) | 86 | (setcar funcs (cons func (car funcs))))) |
| 58 | 87 | ||
| 59 | (defmacro nnoo-declare (backend &rest parents) | 88 | (defmacro nnoo-declare (backend &rest parents) |
| 89 | "Declare BACKEND as a new backend, inheriting from PARENTS. | ||
| 90 | Any functions or variables not implemented by BACKEND may be used | ||
| 91 | from PARENTS instead." | ||
| 60 | `(eval-and-compile | 92 | `(eval-and-compile |
| 61 | (if (assq ',backend nnoo-definition-alist) | 93 | (if (assq ',backend nnoo-definition-alist) |
| 62 | (setcar (cdr (assq ',backend nnoo-definition-alist)) | 94 | (setcar (cdr (assq ',backend nnoo-definition-alist)) |