diff options
| author | Glenn Morris | 2008-02-27 09:11:02 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-02-27 09:11:02 +0000 |
| commit | e80c716461624ed8e22b8254fa0f16a19a3ae49e (patch) | |
| tree | 7111907e7836259c2d7567e546c6a2ce208d84d9 | |
| parent | da13b6ccb19012036d27b4b4a26f1fcf320e81ff (diff) | |
| download | emacs-e80c716461624ed8e22b8254fa0f16a19a3ae49e.tar.gz emacs-e80c716461624ed8e22b8254fa0f16a19a3ae49e.zip | |
(nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
variables to defconsts. Convert comments to doc-strings.
(nnmairix-last-server, nnmairix-current-server): Convert from free
variables to defvars. Convert comments to doc-strings.
(gnus-registry-fetch-group): Autoload.
(nnmairix-replace-group-and-numbers): Use mapc rather than mapcar.
(nnmairix-widget-get-values, nnmairix-widget-make-query-from-widgets)
(nnmairix-widget-build-editable-fields): Use car cddr rather than caddr.
| -rw-r--r-- | lisp/gnus/nnmairix.el | 112 |
1 files changed, 57 insertions, 55 deletions
diff --git a/lisp/gnus/nnmairix.el b/lisp/gnus/nnmairix.el index 4719d8c6d14..aa635b2d99c 100644 --- a/lisp/gnus/nnmairix.el +++ b/lisp/gnus/nnmairix.el | |||
| @@ -338,21 +338,22 @@ temporary searches, e.g. nnmairix-search.") | |||
| 338 | 338 | ||
| 339 | ;;; === Internal variables | 339 | ;;; === Internal variables |
| 340 | 340 | ||
| 341 | ;; Regexp for mairix groups on back end | 341 | (defconst nnmairix-group-regexp |
| 342 | (setq nnmairix-group-regexp (format "%s-\\(.*\\)-[0-9]+" nnmairix-group-prefix)) | 342 | (format "%s-\\(.*\\)-[0-9]+" nnmairix-group-prefix) |
| 343 | "Regexp for mairix groups on back end.") | ||
| 343 | 344 | ||
| 344 | ;; Back ends (hopefully...) supported by nnmairix. | 345 | (defconst nnmairix-valid-backends '(nnimap nnml nnmaildir) |
| 345 | ;; Other backends might or might not work. | 346 | "Backends supported by nnmairix. |
| 346 | (setq nnmairix-valid-backends '(nnimap nnml nnmaildir)) | 347 | Other backends might or might not work.") |
| 347 | 348 | ||
| 348 | ;; Last chosen server | 349 | (defvar nnmairix-last-server nil |
| 349 | (setq nnmairix-last-server nil) | 350 | "Last chosen server.") |
| 350 | 351 | ||
| 351 | ;; Current server | 352 | (defvar nnmairix-current-server nil |
| 352 | (setq nnmairix-current-server nil) | 353 | "Current server.") |
| 353 | 354 | ||
| 354 | ;;; === Gnus backend functions | 355 | ;;; === Gnus backend functions |
| 355 | 356 | ||
| 356 | (nnoo-define-basics nnmairix) | 357 | (nnoo-define-basics nnmairix) |
| 357 | 358 | ||
| 358 | (gnus-declare-backend "nnmairix" 'mail 'address) | 359 | (gnus-declare-backend "nnmairix" 'mail 'address) |
| @@ -537,7 +538,7 @@ temporary searches, e.g. nnmairix-search.") | |||
| 537 | t) | 538 | t) |
| 538 | nil)) | 539 | nil)) |
| 539 | 540 | ||
| 540 | 541 | ||
| 541 | (nnoo-define-skeleton nnmairix) | 542 | (nnoo-define-skeleton nnmairix) |
| 542 | 543 | ||
| 543 | 544 | ||
| @@ -678,7 +679,7 @@ All necessary information will be queried from the user." | |||
| 678 | (gnus-group-set-parameter group 'query query) | 679 | (gnus-group-set-parameter group 'query query) |
| 679 | (nnmairix-update-and-clear-marks group))) | 680 | (nnmairix-update-and-clear-marks group))) |
| 680 | (error "This is no nnmairix group")))) | 681 | (error "This is no nnmairix group")))) |
| 681 | 682 | ||
| 682 | 683 | ||
| 683 | (defun nnmairix-group-toggle-threads-this-group (&optional threads) | 684 | (defun nnmairix-group-toggle-threads-this-group (&optional threads) |
| 684 | "Toggle threads parameter for this group. | 685 | "Toggle threads parameter for this group. |
| @@ -699,7 +700,7 @@ If THREADS is a negative number, set it to nil." | |||
| 699 | (message "Threads deacitavted for group %s" group)) | 700 | (message "Threads deacitavted for group %s" group)) |
| 700 | (nnmairix-update-and-clear-marks group)) | 701 | (nnmairix-update-and-clear-marks group)) |
| 701 | (error "This is no nnmairix group")))) | 702 | (error "This is no nnmairix group")))) |
| 702 | 703 | ||
| 703 | 704 | ||
| 704 | (defun nnmairix-search (query &optional server threads) | 705 | (defun nnmairix-search (query &optional server threads) |
| 705 | "Sends QUERY to nnmairix backend SERVER, using default its search group. | 706 | "Sends QUERY to nnmairix backend SERVER, using default its search group. |
| @@ -845,6 +846,8 @@ with `nnmairix-mairix-update-options'." | |||
| 845 | (set-process-sentinel (apply 'start-process args) | 846 | (set-process-sentinel (apply 'start-process args) |
| 846 | 'nnmairix-sentinel-mairix-update-finished)))))) | 847 | 'nnmairix-sentinel-mairix-update-finished)))))) |
| 847 | 848 | ||
| 849 | (autoload 'gnus-registry-fetch-group "gnus-registry") | ||
| 850 | |||
| 848 | (defun nnmairix-goto-original-article (&optional no-registry) | 851 | (defun nnmairix-goto-original-article (&optional no-registry) |
| 849 | "Jump to the original group and display article. | 852 | "Jump to the original group and display article. |
| 850 | The original group of the article is first determined with the | 853 | The original group of the article is first determined with the |
| @@ -879,9 +882,9 @@ search in raw mode." | |||
| 879 | ;; registry was not available or did not find article | 882 | ;; registry was not available or did not find article |
| 880 | ;; so we search again with mairix in raw mode to get filename | 883 | ;; so we search again with mairix in raw mode to get filename |
| 881 | (nnmairix-open-server server) | 884 | (nnmairix-open-server server) |
| 882 | (setq rval | 885 | (setq rval |
| 883 | (nnmairix-call-mairix-binary-raw | 886 | (nnmairix-call-mairix-binary-raw |
| 884 | (split-string nnmairix-mairix-command) | 887 | (split-string nnmairix-mairix-command) |
| 885 | (list (concat "m:" mid)))) | 888 | (list (concat "m:" mid)))) |
| 886 | (if (zerop rval) | 889 | (if (zerop rval) |
| 887 | ;; determine original group(s) from filename | 890 | ;; determine original group(s) from filename |
| @@ -893,12 +896,12 @@ search in raw mode." | |||
| 893 | allgroups) | 896 | allgroups) |
| 894 | (forward-line 1)) | 897 | (forward-line 1)) |
| 895 | (if (> (length allgroups) 1) | 898 | (if (> (length allgroups) 1) |
| 896 | (setq group | 899 | (setq group |
| 897 | (completing-read | 900 | (completing-read |
| 898 | "Message exists in more than one group. Choose: " | 901 | "Message exists in more than one group. Choose: " |
| 899 | allgroups nil t)) | 902 | allgroups nil t)) |
| 900 | (setq group (car allgroups)))) | 903 | (setq group (car allgroups)))) |
| 901 | (error "Mairix could not find original article. See buffer %s for details" | 904 | (error "Mairix could not find original article. See buffer %s for details" |
| 902 | nnmairix-mairix-output-buffer)))) | 905 | nnmairix-mairix-output-buffer)))) |
| 903 | (if group | 906 | (if group |
| 904 | ;; show article in summary buffer | 907 | ;; show article in summary buffer |
| @@ -915,10 +918,10 @@ search in raw mode." | |||
| 915 | (setq maildirflag (string-match ".+\\..+\\..+" filename)) | 918 | (setq maildirflag (string-match ".+\\..+\\..+" filename)) |
| 916 | (when maildirflag | 919 | (when maildirflag |
| 917 | (setq path | 920 | (setq path |
| 918 | (replace-regexp-in-string | 921 | (replace-regexp-in-string |
| 919 | ".*\\(/cur\\|/new\\|/tmp\\)$" "" path t t 1))) | 922 | ".*\\(/cur\\|/new\\|/tmp\\)$" "" path t t 1))) |
| 920 | ;; we first check nnml and nnmaildir servers | 923 | ;; we first check nnml and nnmaildir servers |
| 921 | (setq | 924 | (setq |
| 922 | group | 925 | group |
| 923 | (catch 'found | 926 | (catch 'found |
| 924 | (dolist (cur gnus-opened-servers) | 927 | (dolist (cur gnus-opened-servers) |
| @@ -927,12 +930,12 @@ search in raw mode." | |||
| 927 | (and maildirflag | 930 | (and maildirflag |
| 928 | (eq (caar cur) 'nnmaildir))) | 931 | (eq (caar cur) 'nnmaildir))) |
| 929 | ;; get base path from server | 932 | ;; get base path from server |
| 930 | (if maildirflag | 933 | (if maildirflag |
| 931 | (setq serverbase (cadr (assoc 'directory (car cur)))) | 934 | (setq serverbase (cadr (assoc 'directory (car cur)))) |
| 932 | (setq serverbase (cadr (assoc 'nnml-directory (car cur)))) | 935 | (setq serverbase (cadr (assoc 'nnml-directory (car cur)))) |
| 933 | (when (not serverbase) | 936 | (when (not serverbase) |
| 934 | (setq serverbase nnml-directory))) | 937 | (setq serverbase nnml-directory))) |
| 935 | (setq serverbase (file-name-as-directory | 938 | (setq serverbase (file-name-as-directory |
| 936 | (expand-file-name serverbase))) | 939 | (expand-file-name serverbase))) |
| 937 | (when (string-match (concat serverbase "\\(.*\\)") path) | 940 | (when (string-match (concat serverbase "\\(.*\\)") path) |
| 938 | ;; looks good - rest of the path should be the group | 941 | ;; looks good - rest of the path should be the group |
| @@ -957,14 +960,14 @@ search in raw mode." | |||
| 957 | (setq group (replace-match "/" t t group))) | 960 | (setq group (replace-match "/" t t group))) |
| 958 | (dolist (cur gnus-opened-servers) | 961 | (dolist (cur gnus-opened-servers) |
| 959 | (when (eq (caar cur) 'nnimap) | 962 | (when (eq (caar cur) 'nnimap) |
| 960 | (when (gnus-group-entry | 963 | (when (gnus-group-entry |
| 961 | (gnus-group-prefixed-name group (car cur))) | 964 | (gnus-group-prefixed-name group (car cur))) |
| 962 | (push | 965 | (push |
| 963 | (gnus-group-prefixed-name group (car cur)) | 966 | (gnus-group-prefixed-name group (car cur)) |
| 964 | allgroups)))) | 967 | allgroups)))) |
| 965 | (if (> (length allgroups) 1) | 968 | (if (> (length allgroups) 1) |
| 966 | (setq group (completing-read | 969 | (setq group (completing-read |
| 967 | "Group %s exists on more than one IMAP server. Choose: " | 970 | "Group %s exists on more than one IMAP server. Choose: " |
| 968 | allgroups nil t)) | 971 | allgroups nil t)) |
| 969 | (setq group (car allgroups)))) | 972 | (setq group (car allgroups)))) |
| 970 | group)) | 973 | group)) |
| @@ -1169,25 +1172,24 @@ MAIRIXGROUP. NUMC contains values for article number correction." | |||
| 1169 | (set-buffer nntp-server-buffer) | 1172 | (set-buffer nntp-server-buffer) |
| 1170 | (goto-char (point-min)) | 1173 | (goto-char (point-min)) |
| 1171 | (nnheader-message 7 "nnmairix: Rewriting headers...") | 1174 | (nnheader-message 7 "nnmairix: Rewriting headers...") |
| 1172 | (mapcar | 1175 | (mapc |
| 1173 | (function | 1176 | (lambda (article) |
| 1174 | (lambda (article) | 1177 | (when (or (looking-at (number-to-string article)) |
| 1175 | (when (or (looking-at (number-to-string article)) | 1178 | (nnheader-find-nov-line article)) |
| 1176 | (nnheader-find-nov-line article)) | 1179 | (setq cur (nnheader-parse-nov)) |
| 1177 | (setq cur (nnheader-parse-nov)) | 1180 | (when corr |
| 1178 | (when corr | 1181 | (setq article (+ (mail-header-number cur) numc)) |
| 1179 | (setq article (+ (mail-header-number cur) numc)) | 1182 | (mail-header-set-number cur article)) |
| 1180 | (mail-header-set-number cur article)) | 1183 | (setq xref (mail-header-xref cur)) |
| 1181 | (setq xref (mail-header-xref cur)) | 1184 | (when (and (stringp xref) |
| 1182 | (when (and (stringp xref) | 1185 | (string-match (format "[ \t]%s:[0-9]+" backendgroup) xref)) |
| 1183 | (string-match (format "[ \t]%s:[0-9]+" backendgroup) xref)) | 1186 | (setq xref (replace-match (format " %s:%d" mairixgroup article) t nil xref)) |
| 1184 | (setq xref (replace-match (format " %s:%d" mairixgroup article) t nil xref)) | 1187 | (mail-header-set-xref cur xref)) |
| 1185 | (mail-header-set-xref cur xref)) | 1188 | (set-buffer buf) |
| 1186 | (set-buffer buf) | 1189 | (nnheader-insert-nov cur) |
| 1187 | (nnheader-insert-nov cur) | 1190 | (set-buffer nntp-server-buffer) |
| 1188 | (set-buffer nntp-server-buffer) | 1191 | (when (not (eobp)) |
| 1189 | (when (not (eobp)) | 1192 | (forward-line 1)))) |
| 1190 | (forward-line 1))))) | ||
| 1191 | articles) | 1193 | articles) |
| 1192 | (nnheader-message 7 "nnmairix: Rewriting headers... done") | 1194 | (nnheader-message 7 "nnmairix: Rewriting headers... done") |
| 1193 | (kill-buffer nntp-server-buffer) | 1195 | (kill-buffer nntp-server-buffer) |
| @@ -1278,7 +1280,7 @@ group." | |||
| 1278 | (when (gnus-group-jump-to-group group) | 1280 | (when (gnus-group-jump-to-group group) |
| 1279 | (gnus-group-get-new-news-this-group))) | 1281 | (gnus-group-get-new-news-this-group))) |
| 1280 | (error "Nnmairix-update-and-clear-marks - Called with non-nnmairix group")))) | 1282 | (error "Nnmairix-update-and-clear-marks - Called with non-nnmairix group")))) |
| 1281 | 1283 | ||
| 1282 | 1284 | ||
| 1283 | (defun nnmairix-sentinel-mairix-update-finished (proc status) | 1285 | (defun nnmairix-sentinel-mairix-update-finished (proc status) |
| 1284 | "Sentinel for mairix update process PROC with STATUS." | 1286 | "Sentinel for mairix update process PROC with STATUS." |
| @@ -1313,7 +1315,7 @@ See %s for details" proc nnmairix-mairix-output-buffer))) | |||
| 1313 | (gnus-summary-exit)) | 1315 | (gnus-summary-exit)) |
| 1314 | (pop-to-buffer gnus-group-buffer) | 1316 | (pop-to-buffer gnus-group-buffer) |
| 1315 | (gnus-group-jump-to-group group) | 1317 | (gnus-group-jump-to-group group) |
| 1316 | (gnus-summary-read-group group 1 t) | 1318 | (gnus-summary-read-group group 1 t) |
| 1317 | (gnus-summary-refer-article mid) | 1319 | (gnus-summary-refer-article mid) |
| 1318 | (gnus-summary-limit-to-headers (format "message-id: <%s>" mid)) | 1320 | (gnus-summary-limit-to-headers (format "message-id: <%s>" mid)) |
| 1319 | (gnus-summary-select-article) | 1321 | (gnus-summary-select-article) |
| @@ -1344,13 +1346,13 @@ See %s for details" proc nnmairix-mairix-output-buffer))) | |||
| 1344 | (mapcar | 1346 | (mapcar |
| 1345 | (function | 1347 | (function |
| 1346 | (lambda (field) | 1348 | (lambda (field) |
| 1347 | (list (caddr field) | 1349 | (list (car (cddr field)) |
| 1348 | (if (car field) | 1350 | (if (car field) |
| 1349 | (nnmairix-replace-illegal-chars | 1351 | (nnmairix-replace-illegal-chars |
| 1350 | (gnus-fetch-field (car field))) | 1352 | (gnus-fetch-field (car field))) |
| 1351 | nil)))) | 1353 | nil)))) |
| 1352 | nnmairix-widget-fields-list)))) | 1354 | nnmairix-widget-fields-list)))) |
| 1353 | 1355 | ||
| 1354 | 1356 | ||
| 1355 | (defun nnmairix-widget-search (&optional mvalues) | 1357 | (defun nnmairix-widget-search (&optional mvalues) |
| 1356 | "Create mairix query interactively using graphical widgets. | 1358 | "Create mairix query interactively using graphical widgets. |
| @@ -1428,7 +1430,7 @@ If WITHVALUES is t, query is based on current article." | |||
| 1428 | (dolist (cur nnmairix-widget-fields-list) | 1430 | (dolist (cur nnmairix-widget-fields-list) |
| 1429 | ;; See if checkbox is checked | 1431 | ;; See if checkbox is checked |
| 1430 | (when (widget-value | 1432 | (when (widget-value |
| 1431 | (cadr (assoc (concat "c" (caddr cur)) widgets))) | 1433 | (cadr (assoc (concat "c" (car (cddr cur))) widgets))) |
| 1432 | ;; create query for the field | 1434 | ;; create query for the field |
| 1433 | (push | 1435 | (push |
| 1434 | (concat | 1436 | (concat |
| @@ -1436,7 +1438,7 @@ If WITHVALUES is t, query is based on current article." | |||
| 1436 | ":" | 1438 | ":" |
| 1437 | (nnmairix-replace-illegal-chars | 1439 | (nnmairix-replace-illegal-chars |
| 1438 | (widget-value | 1440 | (widget-value |
| 1439 | (cadr (assoc (concat "e" (caddr cur)) widgets))))) | 1441 | (cadr (assoc (concat "e" (car (cddr cur))) widgets))))) |
| 1440 | query))) | 1442 | query))) |
| 1441 | ;; Flags | 1443 | ;; Flags |
| 1442 | (when (member 'flags nnmairix-widget-other) | 1444 | (when (member 'flags nnmairix-widget-other) |
| @@ -1500,7 +1502,7 @@ VALUES may contain values for editable fields from current article." | |||
| 1500 | (mapc | 1502 | (mapc |
| 1501 | (function | 1503 | (function |
| 1502 | (lambda (field) | 1504 | (lambda (field) |
| 1503 | (setq field (caddr field)) | 1505 | (setq field (car (cddr field))) |
| 1504 | (setq ret | 1506 | (setq ret |
| 1505 | (nconc | 1507 | (nconc |
| 1506 | (list | 1508 | (list |