Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix a bug that some text properties may be lost by redisplaying.

* twittering-mode.el: Fix a bug that some text properties of a
tweet rendered on a buffer may be lost by redisplaying it.
(twittering-make-common-properties): new function.
(twittering-get-common-properties): new function.
(twittering-generate-format-status-function): use
`twittering-make-common-properties'.
(twittering-format-status-for-redisplay): use
`twittering-get-common-properties'.
(twittering-update-filled-string): likewise.
  • Loading branch information...
commit 93d7f42779ce73598297f9c5364bcd864f93dba2 1 parent 9f98715
@cvmat cvmat authored
Showing with 36 additions and 23 deletions.
  1. +10 −0 ChangeLog
  2. +26 −23 twittering-mode.el
View
10 ChangeLog
@@ -47,6 +47,16 @@
`belongs-to'.
(twittering-enter): likewise.
+ * twittering-mode.el: Fix a bug that some text properties of a
+ tweet rendered on a buffer may be lost by redisplaying it.
+ (twittering-make-common-properties): new function.
+ (twittering-get-common-properties): new function.
+ (twittering-generate-format-status-function): use
+ `twittering-make-common-properties'.
+ (twittering-format-status-for-redisplay): use
+ `twittering-get-common-properties'.
+ (twittering-update-filled-string): likewise.
+
2010-11-14 Tadashi MATSUO <tad@mymail.twin.jp>
* twittering-mode.el: Fix a bug in registration of a sentinel for
View
49 twittering-mode.el
@@ -5020,6 +5020,29 @@ static char * unplugged_xpm[] = {
(+ (* (car encoded-time) 65536)
(cadr encoded-time))))
+(defun twittering-make-common-properties (status)
+ "Generate a property list that tweets should have irrespective of format."
+ (apply 'append
+ (mapcar (lambda (entry)
+ (let ((prop-sym (if (consp entry) (car entry) entry))
+ (status-sym (if (consp entry) (cdr entry) entry)))
+ (list prop-sym (cdr (assq status-sym status)))))
+ '(id source-id (username . user-screen-name) text))))
+
+(defun twittering-get-common-properties (pos)
+ "Get a common property list of the tweet rendered at POS.
+The common property list is added to each rendered tweet irrespective
+of format. The common properties follows:
+ properites generated by `twittering-make-common-properties',
+ `original-id' added by `twittering-show-replied-statuses',
+ `source-spec' added by `twittering-render-timeline'."
+ (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))))
+
(defun twittering-format-string (string prefix replacement-table)
"Format STRING according to PREFIX and REPLACEMENT-TABLE.
PREFIX is a regexp. REPLACEMENT-TABLE is a list of (FROM . TO) pairs,
@@ -5263,13 +5286,7 @@ following symbols;
(cond
((null rest)
`(lambda (status prefix)
- (let* ((username (cdr (assq 'user-screen-name status)))
- (id (cdr (assq 'id status)))
- (source-id (cdr (assq 'source-id status)))
- (text (cdr (assq 'text status)))
- (common-properties
- (list 'username username 'id id 'source-id source-id
- 'text text))
+ (let* ((common-properties (twittering-make-common-properties status))
(str (concat ,@body))
(str (if prefix
(replace-regexp-in-string "^" prefix str)
@@ -5313,14 +5330,7 @@ variable `twittering-status-format'."
(funcall twittering-format-status-function status prefix))
(defun twittering-format-status-for-redisplay (beg end status &optional prefix)
- (let* ((properties
- (and beg
- (apply 'append
- (mapcar (lambda (prop)
- (let ((value (get-text-property beg prop)))
- (when value
- `(,prop ,value))))
- '(id original-id)))))
+ (let* ((properties (and beg (twittering-get-common-properties beg)))
(str (twittering-format-status status prefix)))
;; Restore properties.
(when properties
@@ -5379,14 +5389,7 @@ variable `twittering-status-format'."
(length prefix) local-prefix
keep-newline))
(next (next-single-property-change 0 'need-to-be-updated str))
- (properties
- (and beg
- (apply 'append
- (mapcar (lambda (prop)
- (let ((value (get-text-property beg prop)))
- (when value
- `(,prop ,value))))
- '(id text username))))))
+ (properties (and beg (twittering-get-common-properties beg))))
;; Restore properties.
(when properties
(add-text-properties 0 (length str) properties str))
Please sign in to comment.
Something went wrong with that request. Please try again.