diff options
| author | Stefan Monnier | 2019-06-02 19:21:45 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2019-06-02 19:21:45 -0400 |
| commit | e02f751e3fd4cfe8df7e21998477a55eac648575 (patch) | |
| tree | e6bb9c5554cb3142b85c103e462bf16d8a5fc95b | |
| parent | 8047bd08caa11804174535599ee0090c4ead3178 (diff) | |
| download | emacs-e02f751e3fd4cfe8df7e21998477a55eac648575.tar.gz emacs-e02f751e3fd4cfe8df7e21998477a55eac648575.zip | |
* gnus-(sum|async).el: Eliminate assumptions about gnus-data format
* lisp/gnus/gnus-async.el (gnus-async-with-semaphore): Use `declare`.
(gnus-async-prefetch-next): Don't assume gnus-data-number == car.
* lisp/gnus/gnus-sum.el (gnus-data-find-in): New function.
(gnus-data-find, gnus-data-find-list): Use it.
(gnus-summary-article-subject): Make it a function.
(gnus--dummy-data-list): New const.
(gnus-update-summary-mark-positions): Use it.
| -rw-r--r-- | lisp/gnus/gnus-async.el | 10 | ||||
| -rw-r--r-- | lisp/gnus/gnus-sum.el | 34 |
2 files changed, 26 insertions, 18 deletions
diff --git a/lisp/gnus/gnus-async.el b/lisp/gnus/gnus-async.el index b3da3505da8..1ce01856baf 100644 --- a/lisp/gnus/gnus-async.el +++ b/lisp/gnus/gnus-async.el | |||
| @@ -109,15 +109,13 @@ that was fetched." | |||
| 109 | (setcdr (symbol-value semaphore) nil)) | 109 | (setcdr (symbol-value semaphore) nil)) |
| 110 | 110 | ||
| 111 | (defmacro gnus-async-with-semaphore (&rest forms) | 111 | (defmacro gnus-async-with-semaphore (&rest forms) |
| 112 | (declare (indent 0) (debug t)) | ||
| 112 | `(unwind-protect | 113 | `(unwind-protect |
| 113 | (progn | 114 | (progn |
| 114 | (gnus-async-get-semaphore 'gnus-async-article-semaphore) | 115 | (gnus-async-get-semaphore 'gnus-async-article-semaphore) |
| 115 | ,@forms) | 116 | ,@forms) |
| 116 | (gnus-async-release-semaphore 'gnus-async-article-semaphore))) | 117 | (gnus-async-release-semaphore 'gnus-async-article-semaphore))) |
| 117 | 118 | ||
| 118 | (put 'gnus-async-with-semaphore 'lisp-indent-function 0) | ||
| 119 | (put 'gnus-async-with-semaphore 'edebug-form-spec '(body)) | ||
| 120 | |||
| 121 | ;;; | 119 | ;;; |
| 122 | ;;; Article prefetch | 120 | ;;; Article prefetch |
| 123 | ;;; | 121 | ;;; |
| @@ -142,15 +140,15 @@ that was fetched." | |||
| 142 | gnus-asynchronous | 140 | gnus-asynchronous |
| 143 | (gnus-group-asynchronous-p group)) | 141 | (gnus-group-asynchronous-p group)) |
| 144 | (with-current-buffer gnus-summary-buffer | 142 | (with-current-buffer gnus-summary-buffer |
| 145 | (let ((next (caadr (gnus-data-find-list article)))) | 143 | (let ((next (cadr (gnus-data-find-list article)))) |
| 146 | (when next | 144 | (when next |
| 147 | (when gnus-async-timer | 145 | (when gnus-async-timer |
| 148 | (ignore-errors | 146 | (ignore-errors |
| 149 | (cancel-timer 'gnus-async-timer))) | 147 | (cancel-timer 'gnus-async-timer))) |
| 150 | (setq gnus-async-timer | 148 | (setq gnus-async-timer |
| 151 | (run-with-idle-timer | 149 | (run-with-idle-timer |
| 152 | 0.1 nil 'gnus-async-prefetch-article | 150 | 0.1 nil #'gnus-async-prefetch-article |
| 153 | group next summary))))))) | 151 | group (gnus-data-number next) summary))))))) |
| 154 | 152 | ||
| 155 | (defun gnus-async-prefetch-article (group article summary &optional next) | 153 | (defun gnus-async-prefetch-article (group article summary &optional next) |
| 156 | "Possibly prefetch several articles starting with ARTICLE." | 154 | "Possibly prefetch several articles starting with ARTICLE." |
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index a7dd734a342..4c4445275a6 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el | |||
| @@ -3160,6 +3160,8 @@ The following commands are available: | |||
| 3160 | (cl-defstruct (gnus-data | 3160 | (cl-defstruct (gnus-data |
| 3161 | (:constructor nil) | 3161 | (:constructor nil) |
| 3162 | (:constructor gnus-data-make (number mark pos header level)) | 3162 | (:constructor gnus-data-make (number mark pos header level)) |
| 3163 | ;; In gnus-data-find-in, we rely on (car data) returning the | ||
| 3164 | ;; number, because we use `assq' on a list of gnus-data. | ||
| 3163 | (:type list)) | 3165 | (:type list)) |
| 3164 | number mark pos header level) | 3166 | number mark pos header level) |
| 3165 | 3167 | ||
| @@ -3172,12 +3174,14 @@ The following commands are available: | |||
| 3172 | (define-inline gnus-data-pseudo-p (data) | 3174 | (define-inline gnus-data-pseudo-p (data) |
| 3173 | (inline-quote (consp (gnus-data-header ,data)))) | 3175 | (inline-quote (consp (gnus-data-header ,data)))) |
| 3174 | 3176 | ||
| 3177 | (defalias 'gnus-data-find-in #'assq) | ||
| 3178 | |||
| 3175 | (define-inline gnus-data-find (number) | 3179 | (define-inline gnus-data-find (number) |
| 3176 | (inline-quote (assq ,number gnus-newsgroup-data))) | 3180 | (inline-quote (gnus-data-find-in ,number gnus-newsgroup-data))) |
| 3177 | 3181 | ||
| 3178 | (defmacro gnus-data-find-list (number &optional data) | 3182 | (defmacro gnus-data-find-list (number &optional data) |
| 3179 | `(let ((bdata ,(or data 'gnus-newsgroup-data))) | 3183 | `(let ((bdata ,(or data 'gnus-newsgroup-data))) |
| 3180 | (memq (assq ,number bdata) | 3184 | (memq (gnus-data-find-in ,number bdata) |
| 3181 | bdata))) | 3185 | bdata))) |
| 3182 | 3186 | ||
| 3183 | (defun gnus-data-enter (after-article number mark pos header level offset) | 3187 | (defun gnus-data-enter (after-article number mark pos header level offset) |
| @@ -3314,17 +3318,17 @@ article number." | |||
| 3314 | `(gnus-data-pos (gnus-data-find | 3318 | `(gnus-data-pos (gnus-data-find |
| 3315 | ,(or number '(gnus-summary-article-number))))) | 3319 | ,(or number '(gnus-summary-article-number))))) |
| 3316 | 3320 | ||
| 3317 | (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject) | 3321 | (defalias 'gnus-summary-subject-string #'gnus-summary-article-subject) |
| 3318 | (defmacro gnus-summary-article-subject (&optional number) | 3322 | (defsubst gnus-summary-article-subject (&optional number) |
| 3323 | ;; FIXME: Does this really warrant a defsubst? | ||
| 3319 | "Return current subject string or nil if nothing." | 3324 | "Return current subject string or nil if nothing." |
| 3320 | `(let ((headers | 3325 | (let ((headers |
| 3321 | ,(if number | 3326 | (gnus-data-header |
| 3322 | `(gnus-data-header (assq ,number gnus-newsgroup-data)) | 3327 | (gnus-data-find (or number |
| 3323 | '(gnus-data-header (assq (gnus-summary-article-number) | 3328 | (gnus-summary-article-number)))))) |
| 3324 | gnus-newsgroup-data))))) | 3329 | (and headers |
| 3325 | (and headers | 3330 | (mail-header-p headers) |
| 3326 | (mail-header-p headers) | 3331 | (mail-header-subject headers)))) |
| 3327 | (mail-header-subject headers)))) | ||
| 3328 | 3332 | ||
| 3329 | (defmacro gnus-summary-article-score (&optional number) | 3333 | (defmacro gnus-summary-article-score (&optional number) |
| 3330 | "Return current article score." | 3334 | "Return current article score." |
| @@ -3582,6 +3586,9 @@ buffer that was in action when the last article was fetched." | |||
| 3582 | (defconst gnus--dummy-mail-header | 3586 | (defconst gnus--dummy-mail-header |
| 3583 | (make-full-mail-header 0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil)) | 3587 | (make-full-mail-header 0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil)) |
| 3584 | 3588 | ||
| 3589 | (defconst gnus--dummy-data-list | ||
| 3590 | (list (gnus-data-make 0 nil nil gnus--dummy-mail-header nil))) | ||
| 3591 | |||
| 3585 | (defun gnus-make-thread-indent-array (&optional n) | 3592 | (defun gnus-make-thread-indent-array (&optional n) |
| 3586 | (when (or n | 3593 | (when (or n |
| 3587 | (progn (setq n 200) nil) | 3594 | (progn (setq n 200) nil) |
| @@ -3609,6 +3616,9 @@ buffer that was in action when the last article was fetched." | |||
| 3609 | (gnus-score-over-mark ?Z) | 3616 | (gnus-score-over-mark ?Z) |
| 3610 | (gnus-undownloaded-mark ?Z) | 3617 | (gnus-undownloaded-mark ?Z) |
| 3611 | (gnus-summary-line-format-spec spec) | 3618 | (gnus-summary-line-format-spec spec) |
| 3619 | ;; Make sure `gnus-data-find' finds a dummy element | ||
| 3620 | ;; so we don't call gnus-data-<field> accessors on nil. | ||
| 3621 | (gnus-newsgroup-data gnus--dummy-data-list) | ||
| 3612 | (gnus-newsgroup-downloadable '(0)) | 3622 | (gnus-newsgroup-downloadable '(0)) |
| 3613 | case-fold-search ignores) | 3623 | case-fold-search ignores) |
| 3614 | ;; Here, all marks are bound to Z. | 3624 | ;; Here, all marks are bound to Z. |