Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Render statuses in order of field property instead of id property.

* twittering-mode.el: Render statuses in order of field property
instead of id property.
(twittering-make-common-properties): add field property.
(twittering-get-common-properties): likewise.
(twittering-field-id<): new function.
(twittering-field-id=): new function.
(twittering-make-field-id): new function.
(twittering-make-field-properties): new function.
(twittering-render-timeline): render statuses in order of their
field properties.
(twittering-show-replied-statuses): add special field property to
replied statuses.
  • Loading branch information...
commit 5284454a36d7c91d8fdb1dae9f89471c295fe035 1 parent ebff110
@cvmat cvmat authored
Showing with 58 additions and 9 deletions.
  1. +14 −0 ChangeLog
  2. +44 −9 twittering-mode.el
View
14 ChangeLog
@@ -12,6 +12,20 @@
statuses.
(twittering-status-to-status-datum): likewise.
+ * twittering-mode.el: Render statuses in order of field property
+ instead of id property.
+ (twittering-make-common-properties): add field property as a
+ common property.
+ (twittering-get-common-properties): likewise.
+ (twittering-field-id<): new function.
+ (twittering-field-id=): new function.
+ (twittering-make-field-id): new function.
+ (twittering-make-field-properties): new function.
+ (twittering-render-timeline): render statuses in order of their
+ field properties.
+ (twittering-show-replied-statuses): add special field property to
+ replied statuses.
+
2011-01-09 Tadashi MATSUO <tad@mymail.twin.jp>
* twittering-mode.el: Ensure that encrypted strings are written
View
53 twittering-mode.el
@@ -5042,6 +5042,7 @@ static char * unplugged_xpm[] = {
(defun twittering-make-common-properties (status)
"Generate a property list that tweets should have irrespective of format."
(apply 'append
+ `(field ,(twittering-make-field-id status))
(mapcar (lambda (entry)
(let ((prop-sym (if (consp entry) (car entry) entry))
(status-sym (if (consp entry) (cdr entry) entry)))
@@ -5054,13 +5055,15 @@ static char * unplugged_xpm[] = {
The common property list is added to each rendered tweet irrespective
of format. The common properties follows:
properites generated by `twittering-make-common-properties',
+ `field' added by `twittering-make-common-properties' or
+ `twittering-show-replied-statuses',
`original-id' added by `twittering-show-replied-statuses'."
(apply 'append
(mapcar (lambda (prop)
(let ((value (get-text-property pos prop)))
(when value
`(,prop ,value))))
- '(id original-id source-id source-spec text username))))
+ '(field id original-id source-id source-spec text username))))
(defun twittering-format-string (string prefix replacement-table)
"Format STRING according to PREFIX and REPLACEMENT-TABLE.
@@ -5355,6 +5358,33 @@ variable `twittering-status-format'."
;;;; Rendering
;;;;
+(defun twittering-field-id< (field1 field2)
+ (string< field1 field2))
+
+(defun twittering-field-id= (field1 field2)
+ (string= field1 field2))
+
+(defun twittering-make-field-id (status &optional base-id)
+ "Generate a field property for STATUS.
+Tweets are rendered in order of the field.
+
+If BASE-ID is non-nil, generate a field id for a tweet rendered
+as a popped ancestor tweet by `twittering-show-replied-statuses'.
+In the case, BASE-ID means the ID of the descendant."
+ (let ((id (cdr (assq 'id status)))
+ (format-func (lambda (id) (format "%02d-%s" (length id) id))))
+ (cond
+ (base-id
+ (format "O:%s:5:ancestor:%s"
+ (funcall format-func base-id)
+ (funcall format-func id)))
+ (t
+ (format "O:%s" (funcall format-func id))))))
+
+(defun twittering-make-field-properties (status &optional replied-by)
+ (let ((field-id (twittering-make-field-id status replied-by)))
+ `(field ,field-id)))
+
(defun twittering-fill-string (str &optional adjustment prefix keep-newline)
(when (and (not (boundp 'kinsoku-limit))
enable-kinsoku)
@@ -5498,20 +5528,21 @@ variable `twittering-status-format'."
(twittering-get-first-status-head))))
(mapc
(lambda (status)
- (let ((id (cdr (assq 'id status))))
+ (let ((field-id (twittering-make-field-id status)))
;; Find where the status should be inserted.
(while
- (let ((buf-id (get-text-property pos 'id)))
- (if (and buf-id
+ (let ((buf-field-id (get-text-property pos 'field)))
+ (if (and buf-field-id
(if twittering-reverse-mode
- (twittering-status-id< buf-id id)
- (twittering-status-id< id buf-id)))
+ (twittering-field-id< buf-field-id field-id)
+ (twittering-field-id< field-id buf-field-id)))
(let ((next-pos
(twittering-get-next-status-head pos)))
(setq pos (or next-pos (point-max)))
next-pos)
nil)))
- (unless (twittering-status-id= id (get-text-property pos 'id))
+ (unless (twittering-field-id= field-id
+ (get-text-property pos 'field))
(let ((formatted-status (twittering-format-status status))
(separator "\n"))
(goto-char pos)
@@ -5747,9 +5778,13 @@ If INTERRUPT is non-nil, the iteration is stopped if FUNC returns nil."
(lambda (status)
(let ((id (cdr (assq 'id status)))
(formatted-status (twittering-format-status status
- prefix)))
+ prefix))
+ ;; Overwrite field property.
+ (field-properties
+ (twittering-make-field-properties status base-id)))
(add-text-properties 0 (length formatted-status)
- `(id ,base-id original-id ,id)
+ `(id ,base-id original-id ,id
+ ,@field-properties)
formatted-status)
(if twittering-reverse-mode
(insert-before-markers formatted-status separator)
Please sign in to comment.
Something went wrong with that request. Please try again.