Skip to content

Commit

Permalink
Processes are registered with timeline spec retrieved by them.
Browse files Browse the repository at this point in the history
* twittering-mode.el (twittering-process-info-alist): new variable
for managing active process and timeline spec being retrieved by
the process.
(twittering-register-process): new function for registering a pair
of process and timeline spec.
(twittering-release-process): new function for releasing a process.
(twittering-get-timeline-spec-from-process): new function for
getting timeline spec retrieved by the given process.
(twittering-http-get-default-sentinel): discard statuses if
the retrieved spec differs from the last requested one.
(twittering-get-and-render-timeline): register a pair of the
requested timeline spec and process for retrieving it.
  • Loading branch information
cvmat committed Jan 31, 2010
1 parent 5da1685 commit ed67225
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
13 changes: 13 additions & 0 deletions ChangeLog
Expand Up @@ -8,6 +8,19 @@
(twittering-start-http-non-ssl-session): likewise.
(twittering-get-tweets): likewise.

* twittering-mode.el (twittering-process-info-alist): new variable
for managing active process and timeline spec being retrieved by
the process.
(twittering-register-process): new function for registering a pair
of process and timeline spec.
(twittering-release-process): new function for releasing a process.
(twittering-get-timeline-spec-from-process): new function for
getting timeline spec retrieved by the given process.
(twittering-http-get-default-sentinel): discard statuses if
the retrieved spec differs from the last requested one.
(twittering-get-and-render-timeline): register a pair of the
requested timeline spec and process for retrieving it.

2010-01-30 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el (twittering-fill-string): use `frame-width'
Expand Down
40 changes: 35 additions & 5 deletions twittering-mode.el
Expand Up @@ -146,6 +146,9 @@ then you can use \"$to_me\" as
"The last successfully retrieved timeline spec string.")
(defvar twittering-list-index-retrieved nil)

(defvar twittering-process-info-alist nil
"Alist of active process and timeline spec retrieved by the process.")

(defvar twittering-new-tweets-count 0
"Number of new tweets when `twittering-new-tweets-hook' is run")

Expand Down Expand Up @@ -844,6 +847,25 @@ Return nil if STR is invalid as a timeline spec."
(setq twittering-timeline-history
(cons spec-string twittering-timeline-history)))))))

;;;
;;; Process info
;;;

(defun twittering-register-process (proc spec)
(add-to-list 'twittering-process-info-alist
`(,proc ,spec)))

(defun twittering-release-process (proc)
(let ((spec (twittering-get-timeline-spec-from-process proc)))
(setq twittering-process-info-alist
(delete `(,proc ,spec) twittering-process-info-alist))))

(defun twittering-get-timeline-spec-from-process (proc)
(let ((entry (assoc proc twittering-process-info-alist)))
(if entry
(elt entry 1)
nil)))

;;;
;;; Debug mode
;;;
Expand Down Expand Up @@ -1470,9 +1492,15 @@ Available keywords:
(status-line (and header-is-valid
(match-string-no-properties 1 header)))
(status (and header-is-valid
(match-string-no-properties 2 header))))
(match-string-no-properties 2 header)))
(spec (twittering-get-timeline-spec-from-process proc))
(spec-string (twittering-timeline-spec-to-string spec))
(requested-spec
(twittering-string-to-timeline-spec
twittering-last-requested-timeline-spec-string)))
(twittering-release-process proc)
(cond
((and header-is-valid body)
((and header-is-valid body (equal spec requested-spec))
(case-string
status
(("200")
Expand Down Expand Up @@ -2352,9 +2380,11 @@ variable `twittering-status-format'"
(if (twittering-timeline-spec-primary-p spec)
(let ((pair (twittering-timeline-spec-to-host-method spec)))
(when pair
(let ((host (car pair))
(method (cadr pair)))
(twittering-get-tweets host method noninteractive id))))
(let* ((host (car pair))
(method (cadr pair))
(proc (twittering-get-tweets host method
noninteractive id)))
(twittering-register-process proc spec))))
(let ((type (car spec)))
(error "%s has not been supported yet" type)))))

Expand Down

0 comments on commit ed67225

Please sign in to comment.