aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2015-06-24 09:30:40 -0400
committerStefan Monnier2015-06-24 09:30:40 -0400
commit1b51e23aea976abbbc1f1e9d40b777dfd19925ae (patch)
tree912d05f958539e00042b25f465fa9a00d7f56f7f
parent9b891278cf715cee229a00068fd8d5c29ef9d79d (diff)
downloademacs-1b51e23aea976abbbc1f1e9d40b777dfd19925ae.tar.gz
emacs-1b51e23aea976abbbc1f1e9d40b777dfd19925ae.zip
* lisp/gnus/nnmaildir.el: Silence lexical warnings
* lisp/gnus/nnmaildir.el (nnmaildir--prepare): Use a more functional style. (nnmaildir--update-nov): Remove unused var `numdir'. (nnmaildir-request-type, nnmaildir--scan, nnmaildir-request-newgroups) (nnmaildir-request-group, nnmaildir-request-create-group) (nnmaildir-request-post, nnmaildir-request-move-article) (nnmaildir-request-accept-article, nnmaildir-active-number): Mark unused args. (nnmaildir-get-new-mail, nnmaildir-group-alist) (nnmaildir-active-file): Declare. (nnmaildir-request-scan): Remove unused vars `group' and `grp-dir'. (nnmaildir-request-update-info): Remove unused vars `dotfile', `num', `mark', `end', `new-mark', and `mark-sym'. (nnmaildir-retrieve-headers): Remove unused args `srv-dir', `dir', `nlist2'. (nnmaildir-request-expire-articles): Remove unused vars `article', `stop' and `nlist2'. (nnmaildir-request-set-mark): Remove unused vars `begin', `article' and `end'. Use nnmaildir--article when dyn-binding is needed. Give the value directly in the `let' for `del-mark', `del-action', `add-action', and `set-action'. Don't use `add-to-list' on a local var. (nnmaildir-close-server): Declare those local vars that need to be dyn-bound.
-rw-r--r--lisp/gnus/nnmaildir.el121
1 files changed, 63 insertions, 58 deletions
diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el
index da3d5460c2b..097d4f8b618 100644
--- a/lisp/gnus/nnmaildir.el
+++ b/lisp/gnus/nnmaildir.el
@@ -333,29 +333,24 @@ by nnmaildir-request-article.")
333;; given group, if non-nil, be the current group of the current server. Then 333;; given group, if non-nil, be the current group of the current server. Then
334;; return the group object for the current group. 334;; return the group object for the current group.
335(defun nnmaildir--prepare (server group) 335(defun nnmaildir--prepare (server group)
336 (let (x groups) 336 (catch 'return
337 (catch 'return 337 (if (null server)
338 (if (null server) 338 (unless (setq server nnmaildir--cur-server)
339 (unless (setq server nnmaildir--cur-server)
340 (throw 'return nil))
341 (unless (setq server (intern-soft server nnmaildir--servers))
342 (throw 'return nil)) 339 (throw 'return nil))
343 (setq server (symbol-value server) 340 (unless (setq server (intern-soft server nnmaildir--servers))
344 nnmaildir--cur-server server))
345 (unless (setq groups (nnmaildir--srv-groups server))
346 (throw 'return nil)) 341 (throw 'return nil))
347 (unless (nnmaildir--srv-method server) 342 (setq server (symbol-value server)
348 (setq x (concat "nnmaildir:" (nnmaildir--srv-address server)) 343 nnmaildir--cur-server server))
349 x (gnus-server-to-method x)) 344 (let ((groups (nnmaildir--srv-groups server)))
350 (unless x (throw 'return nil)) 345 (when groups
351 (setf (nnmaildir--srv-method server) x)) 346 (unless (nnmaildir--srv-method server)
352 (if (null group) 347 (setf (nnmaildir--srv-method server)
353 (unless (setq group (nnmaildir--srv-curgrp server)) 348 (or (gnus-server-to-method
354 (throw 'return nil)) 349 (concat "nnmaildir:" (nnmaildir--srv-address server)))
355 (unless (setq group (intern-soft group groups)) 350 (throw 'return nil))))
356 (throw 'return nil)) 351 (if (null group)
357 (setq group (symbol-value group))) 352 (nnmaildir--srv-curgrp server)
358 group))) 353 (symbol-value (intern-soft group groups)))))))
359 354
360(defun nnmaildir--tab-to-space (string) 355(defun nnmaildir--tab-to-space (string)
361 (let ((pos 0)) 356 (let ((pos 0))
@@ -428,7 +423,7 @@ by nnmaildir-request-article.")
428 (srv-dir (nnmaildir--srv-dir server)) 423 (srv-dir (nnmaildir--srv-dir server))
429 (storage-version 1) ;; [version article-number msgid [...nov...]] 424 (storage-version 1) ;; [version article-number msgid [...nov...]]
430 dir gname pgname msgdir prefix suffix file attr mtime novdir novfile 425 dir gname pgname msgdir prefix suffix file attr mtime novdir novfile
431 nov msgid nov-beg nov-mid nov-end field val old-extra num numdir 426 nov msgid nov-beg nov-mid nov-end field val old-extra num
432 deactivate-mark) 427 deactivate-mark)
433 (catch 'return 428 (catch 'return
434 (setq gname (nnmaildir--grp-name group) 429 (setq gname (nnmaildir--grp-name group)
@@ -668,7 +663,7 @@ by nnmaildir-request-article.")
668 "/" "\\057" 'literal) 663 "/" "\\057" 'literal)
669 ":" "\\072" 'literal)) 664 ":" "\\072" 'literal))
670 665
671(defun nnmaildir-request-type (group &optional article) 666(defun nnmaildir-request-type (_group &optional _article)
672 'mail) 667 'mail)
673 668
674(defun nnmaildir-status-message (&optional server) 669(defun nnmaildir-status-message (&optional server)
@@ -768,7 +763,7 @@ by nnmaildir-request-article.")
768 (if (> (aref a 1) (aref b 1)) (throw 'return nil)) 763 (if (> (aref a 1) (aref b 1)) (throw 'return nil))
769 (string-lessp (aref a 2) (aref b 2)))) 764 (string-lessp (aref a 2) (aref b 2))))
770 765
771(defun nnmaildir--scan (gname scan-msgs groups method srv-dir srv-ls) 766(defun nnmaildir--scan (gname scan-msgs groups _method srv-dir srv-ls)
772 (catch 'return 767 (catch 'return
773 (let ((36h-ago (- (car (current-time)) 2)) 768 (let ((36h-ago (- (car (current-time)) 2))
774 absdir nndir tdir ndir cdir nattr cattr isnew pgname read-only ls 769 absdir nndir tdir ndir cdir nattr cattr isnew pgname read-only ls
@@ -883,6 +878,10 @@ by nnmaildir-request-article.")
883 (setf (nnmaildir--grp-cur group) cattr))) 878 (setf (nnmaildir--grp-cur group) cattr)))
884 t)) 879 t))
885 880
881(defvar nnmaildir-get-new-mail)
882(defvar nnmaildir-group-alist)
883(defvar nnmaildir-active-file)
884
886(defun nnmaildir-request-scan (&optional scan-group server) 885(defun nnmaildir-request-scan (&optional scan-group server)
887 (let ((coding-system-for-write nnheader-file-coding-system) 886 (let ((coding-system-for-write nnheader-file-coding-system)
888 (buffer-file-coding-system nil) 887 (buffer-file-coding-system nil)
@@ -890,7 +889,7 @@ by nnmaildir-request-article.")
890 (nnmaildir-get-new-mail t) 889 (nnmaildir-get-new-mail t)
891 (nnmaildir-group-alist nil) 890 (nnmaildir-group-alist nil)
892 (nnmaildir-active-file nil) 891 (nnmaildir-active-file nil)
893 x srv-ls srv-dir method groups target-prefix group dirs grp-dir seen 892 x srv-ls srv-dir method groups target-prefix dirs seen
894 deactivate-mark) 893 deactivate-mark)
895 (nnmaildir--prepare server nil) 894 (nnmaildir--prepare server nil)
896 (setq srv-ls (nnmaildir--srv-ls nnmaildir--cur-server) 895 (setq srv-ls (nnmaildir--srv-ls nnmaildir--cur-server)
@@ -966,7 +965,7 @@ by nnmaildir-request-article.")
966 (nnmaildir--srv-groups nnmaildir--cur-server)))) 965 (nnmaildir--srv-groups nnmaildir--cur-server))))
967 t) 966 t)
968 967
969(defun nnmaildir-request-newgroups (date &optional server) 968(defun nnmaildir-request-newgroups (_date &optional server)
970 (nnmaildir-request-list server)) 969 (nnmaildir-request-list server))
971 970
972(defun nnmaildir-retrieve-groups (groups &optional server) 971(defun nnmaildir-retrieve-groups (groups &optional server)
@@ -995,9 +994,9 @@ by nnmaildir-request-article.")
995 (nnmaildir--srvgrp-dir 994 (nnmaildir--srvgrp-dir
996 (nnmaildir--srv-dir nnmaildir--cur-server) gname))) 995 (nnmaildir--srv-dir nnmaildir--cur-server) gname)))
997 (curdir-mtime (nth 5 (file-attributes curdir))) 996 (curdir-mtime (nth 5 (file-attributes curdir)))
998 pgname flist always-marks never-marks old-marks dotfile num dir 997 pgname flist always-marks never-marks old-marks dir
999 all-marks marks mark ranges markdir read end new-marks ls 998 all-marks marks ranges markdir read ls
1000 old-mmth new-mmth mtime mark-sym existing missing deactivate-mark) 999 old-mmth new-mmth mtime existing missing deactivate-mark)
1001 (catch 'return 1000 (catch 'return
1002 (unless group 1001 (unless group
1003 (setf (nnmaildir--srv-error nnmaildir--cur-server) 1002 (setf (nnmaildir--srv-error nnmaildir--cur-server)
@@ -1096,7 +1095,7 @@ by nnmaildir-request-article.")
1096 (setf (nnmaildir--grp-mmth group) new-mmth) 1095 (setf (nnmaildir--grp-mmth group) new-mmth)
1097 info))) 1096 info)))
1098 1097
1099(defun nnmaildir-request-group (gname &optional server fast info) 1098(defun nnmaildir-request-group (gname &optional server fast _info)
1100 (let ((group (nnmaildir--prepare server gname)) 1099 (let ((group (nnmaildir--prepare server gname))
1101 deactivate-mark) 1100 deactivate-mark)
1102 (catch 'return 1101 (catch 'return
@@ -1119,7 +1118,7 @@ by nnmaildir-request-article.")
1119 (insert " " (gnus-replace-in-string gname " " "\\ " t) "\n") 1118 (insert " " (gnus-replace-in-string gname " " "\\ " t) "\n")
1120 t)))) 1119 t))))
1121 1120
1122(defun nnmaildir-request-create-group (gname &optional server args) 1121(defun nnmaildir-request-create-group (gname &optional server _args)
1123 (nnmaildir--prepare server nil) 1122 (nnmaildir--prepare server nil)
1124 (catch 'return 1123 (catch 'return
1125 (let ((target-prefix (nnmaildir--srv-target-prefix nnmaildir--cur-server)) 1124 (let ((target-prefix (nnmaildir--srv-target-prefix nnmaildir--cur-server))
@@ -1265,7 +1264,7 @@ by nnmaildir-request-article.")
1265 1264
1266(defun nnmaildir-retrieve-headers (articles &optional gname server fetch-old) 1265(defun nnmaildir-retrieve-headers (articles &optional gname server fetch-old)
1267 (let ((group (nnmaildir--prepare server gname)) 1266 (let ((group (nnmaildir--prepare server gname))
1268 srv-dir dir nlist mlist article num start stop nov nlist2 insert-nov 1267 nlist mlist article num start stop nov insert-nov
1269 deactivate-mark) 1268 deactivate-mark)
1270 (setq insert-nov 1269 (setq insert-nov
1271 (lambda (article) 1270 (lambda (article)
@@ -1290,9 +1289,7 @@ by nnmaildir-request-article.")
1290 (erase-buffer) 1289 (erase-buffer)
1291 (setq mlist (nnmaildir--grp-mlist group) 1290 (setq mlist (nnmaildir--grp-mlist group)
1292 nlist (nnmaildir--grp-nlist group) 1291 nlist (nnmaildir--grp-nlist group)
1293 gname (nnmaildir--grp-name group) 1292 gname (nnmaildir--grp-name group))
1294 srv-dir (nnmaildir--srv-dir nnmaildir--cur-server)
1295 dir (nnmaildir--srvgrp-dir srv-dir gname))
1296 (cond 1293 (cond
1297 ((null nlist)) 1294 ((null nlist))
1298 ((and fetch-old (not (numberp fetch-old))) 1295 ((and fetch-old (not (numberp fetch-old)))
@@ -1363,7 +1360,7 @@ by nnmaildir-request-article.")
1363 (nnheader-insert-file-contents nnmaildir-article-file-name)) 1360 (nnheader-insert-file-contents nnmaildir-article-file-name))
1364 (cons gname num-msgid)))) 1361 (cons gname num-msgid))))
1365 1362
1366(defun nnmaildir-request-post (&optional server) 1363(defun nnmaildir-request-post (&optional _server)
1367 (let (message-required-mail-headers) 1364 (let (message-required-mail-headers)
1368 (funcall message-send-mail-function))) 1365 (funcall message-send-mail-function)))
1369 1366
@@ -1405,7 +1402,7 @@ by nnmaildir-request-article.")
1405 t))) 1402 t)))
1406 1403
1407(defun nnmaildir-request-move-article (article gname server accept-form 1404(defun nnmaildir-request-move-article (article gname server accept-form
1408 &optional last move-is-internal) 1405 &optional _last _move-is-internal)
1409 (let ((group (nnmaildir--prepare server gname)) 1406 (let ((group (nnmaildir--prepare server gname))
1410 pgname suffix result nnmaildir--file deactivate-mark) 1407 pgname suffix result nnmaildir--file deactivate-mark)
1411 (catch 'return 1408 (catch 'return
@@ -1442,7 +1439,7 @@ by nnmaildir-request-article.")
1442 (nnmaildir--expired-article group article)) 1439 (nnmaildir--expired-article group article))
1443 result))) 1440 result)))
1444 1441
1445(defun nnmaildir-request-accept-article (gname &optional server last) 1442(defun nnmaildir-request-accept-article (gname &optional server _last)
1446 (let ((group (nnmaildir--prepare server gname)) 1443 (let ((group (nnmaildir--prepare server gname))
1447 (coding-system-for-write nnheader-file-coding-system) 1444 (coding-system-for-write nnheader-file-coding-system)
1448 (buffer-file-coding-system nil) 1445 (buffer-file-coding-system nil)
@@ -1546,7 +1543,7 @@ by nnmaildir-request-article.")
1546 ga)) 1543 ga))
1547 group-art))))) 1544 group-art)))))
1548 1545
1549(defun nnmaildir-active-number (gname) 1546(defun nnmaildir-active-number (_gname)
1550 0) 1547 0)
1551 1548
1552(declare-function gnus-group-mark-article-read "gnus-group" (group article)) 1549(declare-function gnus-group-mark-article-read "gnus-group" (group article))
@@ -1554,8 +1551,8 @@ by nnmaildir-request-article.")
1554(defun nnmaildir-request-expire-articles (ranges &optional gname server force) 1551(defun nnmaildir-request-expire-articles (ranges &optional gname server force)
1555 (let ((no-force (not force)) 1552 (let ((no-force (not force))
1556 (group (nnmaildir--prepare server gname)) 1553 (group (nnmaildir--prepare server gname))
1557 pgname time boundary bound-iter high low target dir nlist nlist2 1554 pgname time boundary bound-iter high low target dir nlist
1558 stop article didnt nnmaildir--file nnmaildir-article-file-name 1555 didnt nnmaildir--file nnmaildir-article-file-name
1559 deactivate-mark) 1556 deactivate-mark)
1560 (catch 'return 1557 (catch 'return
1561 (unless group 1558 (unless group
@@ -1637,6 +1634,8 @@ by nnmaildir-request-article.")
1637 (erase-buffer)) 1634 (erase-buffer))
1638 didnt))) 1635 didnt)))
1639 1636
1637(defvar nnmaildir--article)
1638
1640(defun nnmaildir-request-set-mark (gname actions &optional server) 1639(defun nnmaildir-request-set-mark (gname actions &optional server)
1641 (let* ((group (nnmaildir--prepare server gname)) 1640 (let* ((group (nnmaildir--prepare server gname))
1642 (curdir (nnmaildir--cur 1641 (curdir (nnmaildir--cur
@@ -1646,27 +1645,30 @@ by nnmaildir-request-article.")
1646 (coding-system-for-write nnheader-file-coding-system) 1645 (coding-system-for-write nnheader-file-coding-system)
1647 (buffer-file-coding-system nil) 1646 (buffer-file-coding-system nil)
1648 (file-coding-system-alist nil) 1647 (file-coding-system-alist nil)
1649 del-mark del-action add-action set-action marksdir nlist 1648 marksdir nlist
1650 ranges begin end article all-marks todo-marks mdir mfile 1649 ranges all-marks todo-marks mdir mfile
1651 pgname ls permarkfile deactivate-mark) 1650 pgname ls permarkfile deactivate-mark
1652 (setq del-mark 1651 (del-mark
1653 (lambda (mark) 1652 (lambda (mark)
1654 (let ((prefix (nnmaildir--art-prefix article)) 1653 (let ((prefix (nnmaildir--art-prefix nnmaildir--article))
1655 (suffix (nnmaildir--art-suffix article)) 1654 (suffix (nnmaildir--art-suffix nnmaildir--article))
1656 (flag (nnmaildir--mark-to-flag mark))) 1655 (flag (nnmaildir--mark-to-flag mark)))
1657 (when flag 1656 (when flag
1658 ;; If this mark corresponds to a flag, remove the flag from 1657 ;; If this mark corresponds to a flag, remove the flag from
1659 ;; the file name. 1658 ;; the file name.
1660 (nnmaildir--article-set-flags 1659 (nnmaildir--article-set-flags
1661 article (nnmaildir--remove-flag flag suffix) curdir)) 1660 nnmaildir--article (nnmaildir--remove-flag flag suffix)
1661 curdir))
1662 ;; We still want to delete the hardlink in the marks dir if 1662 ;; We still want to delete the hardlink in the marks dir if
1663 ;; present, regardless of whether this mark has a maildir flag or 1663 ;; present, regardless of whether this mark has a maildir flag or
1664 ;; not, to avoid getting out of sync. 1664 ;; not, to avoid getting out of sync.
1665 (setq mfile (nnmaildir--subdir marksdir (symbol-name mark)) 1665 (setq mfile (nnmaildir--subdir marksdir (symbol-name mark))
1666 mfile (concat mfile prefix)) 1666 mfile (concat mfile prefix))
1667 (nnmaildir--unlink mfile))) 1667 (nnmaildir--unlink mfile))))
1668 del-action (lambda (article) (mapcar del-mark todo-marks)) 1668 (del-action (lambda (article)
1669 add-action 1669 (let ((nnmaildir--article article))
1670 (mapcar del-mark todo-marks))))
1671 (add-action
1670 (lambda (article) 1672 (lambda (article)
1671 (mapcar 1673 (mapcar
1672 (lambda (mark) 1674 (lambda (mark)
@@ -1695,13 +1697,14 @@ by nnmaildir-request-article.")
1695 (rename-file permarkfilenew permarkfile 'replace) 1697 (rename-file permarkfilenew permarkfile 'replace)
1696 (add-name-to-file permarkfile mfile))) 1698 (add-name-to-file permarkfile mfile)))
1697 (t (signal (car err) (cdr err)))))))) 1699 (t (signal (car err) (cdr err))))))))
1698 todo-marks)) 1700 todo-marks)))
1699 set-action (lambda (article) 1701 (set-action (lambda (article)
1700 (funcall add-action article) 1702 (funcall add-action article)
1701 (mapcar (lambda (mark) 1703 (let ((nnmaildir--article article))
1702 (unless (memq mark todo-marks) 1704 (mapcar (lambda (mark)
1703 (funcall del-mark mark))) 1705 (unless (memq mark todo-marks)
1704 all-marks))) 1706 (funcall del-mark mark)))
1707 all-marks)))))
1705 (catch 'return 1708 (catch 'return
1706 (unless group 1709 (unless group
1707 (setf (nnmaildir--srv-error nnmaildir--cur-server) 1710 (setf (nnmaildir--srv-error nnmaildir--cur-server)
@@ -1728,7 +1731,7 @@ by nnmaildir-request-article.")
1728 (setq ranges (car action) 1731 (setq ranges (car action)
1729 todo-marks (caddr action)) 1732 todo-marks (caddr action))
1730 (dolist (mark todo-marks) 1733 (dolist (mark todo-marks)
1731 (add-to-list 'all-marks mark)) 1734 (pushnew mark all-marks :test #'equal))
1732 (if (numberp (cdr ranges)) (setq ranges (list ranges))) 1735 (if (numberp (cdr ranges)) (setq ranges (list ranges)))
1733 (nnmaildir--nlist-iterate nlist ranges 1736 (nnmaildir--nlist-iterate nlist ranges
1734 (cond ((eq 'del (cadr action)) del-action) 1737 (cond ((eq 'del (cadr action)) del-action)
@@ -1775,6 +1778,8 @@ by nnmaildir-request-article.")
1775 t))) 1778 t)))
1776 1779
1777(defun nnmaildir-close-server (&optional server) 1780(defun nnmaildir-close-server (&optional server)
1781 (defvar flist) (defvar ls) (defvar dirs) (defvar dir)
1782 (defvar files) (defvar file) (defvar x)
1778 (let (flist ls dirs dir files file x) 1783 (let (flist ls dirs dir files file x)
1779 (nnmaildir--prepare server nil) 1784 (nnmaildir--prepare server nil)
1780 (when nnmaildir--cur-server 1785 (when nnmaildir--cur-server