Skip to content

Commit

Permalink
Inactive processes are automatically removed from the alist.
Browse files Browse the repository at this point in the history
* twittering-mode.el
(twittering-find-processes-for-timeline-spec): new function for
finding processes retrieving a specific timeline spec.
(twittering-remove-inactive-processes): new function for removing
inactive processes from `twittering-process-info-alist'.
(twittering-process-active-p): new function for checking whether
the processes for a specific timeline spec are active or not.
(twittering-get-and-render-timeline): use
`twittering-process-active-p' instead of referring
`twittering-process-info-alist' directly.
  • Loading branch information
cvmat committed Feb 11, 2010
1 parent a304114 commit 16ff47d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
13 changes: 13 additions & 0 deletions ChangeLog
@@ -1,3 +1,16 @@
2010-02-12 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el
(twittering-find-processes-for-timeline-spec): new function for
finding processes retrieving a specific timeline spec.
(twittering-remove-inactive-processes): new function for removing
inactive processes from `twittering-process-info-alist'.
(twittering-process-active-p): new function for checking whether
the processes for a specific timeline spec are active or not.
(twittering-get-and-render-timeline): use
`twittering-process-active-p' instead of referring
`twittering-process-info-alist' directly.

2010-02-11 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el (twittering-fill-string): load "kinsoku.el"
Expand Down
33 changes: 32 additions & 1 deletion twittering-mode.el
Expand Up @@ -890,6 +890,37 @@ Return nil if SPEC-STR is invalid as a timeline spec."
(elt entry 1)
nil)))

(defun twittering-find-processes-for-timeline-spec (spec)
(apply 'append
(mapcar
(lambda (pair)
(let* ((proc (car pair))
(spec-info (cadr pair)))
(if (equal spec-info spec)
`(,proc)
nil)))
twittering-process-info-alist)))

(defun twittering-remove-inactive-processes ()
(let ((inactive-statuses '(nil closed failed)))
(setq twittering-process-info-alist
(apply 'append
(mapcar
(lambda (pair)
(let* ((proc (car pair))
(info (cdr pair))
(status (process-status proc)))
(if (memq status inactive-statuses)
nil
`((,proc ,@info)))))
twittering-process-info-alist)))))

(defun twittering-process-active-p (&optional spec)
(twittering-remove-inactive-processes)
(if spec
(twittering-find-processes-for-timeline-spec spec)
twittering-process-info-alist))

;;;
;;; Debug mode
;;;
Expand Down Expand Up @@ -2435,7 +2466,7 @@ variable `twittering-status-format'."
(error "\"%s\" is invalid as a timeline spec"
(or spec-string original-spec)))
(cond
((and noninteractive twittering-process-info-alist)
((and noninteractive (twittering-process-active-p))
;; ignore non-interactive request if a process is waiting for responses.
t)
((twittering-timeline-spec-primary-p spec)
Expand Down

0 comments on commit 16ff47d

Please sign in to comment.