Show
Ignore:
Timestamp:
05/02/08 13:08:26 (16 years ago)
Author:
tsuyoshi
Message:

Fix id/user-id formatting problem. append created-time clicable url(status).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/elisp/twittering-mode/branches/tsuyoshi/twittering-mode.el

    r39 r40  
    480480           (list-push (attr 'user-url) result)) 
    481481          ((?j)                         ; %j - user.id 
    482            (list-push (attr 'user-id) result)) 
     482           (list-push (format "%d" (attr 'user-id)) result)) 
    483483          ((?p)                         ; %p - protected? 
    484484           (let ((protected (attr 'user-protected))) 
     
    499499                 (now (current-time))) 
    500500             (let ((secs (+ (* (- (car now) (car created-at)) 65536) 
    501                             (- (cadr now) (cadr created-at))))) 
    502                (list-push (cond ((< secs 5) "less than 5 seconds ago") 
    503                                 ((< secs 10) "less than 10 seconds ago") 
    504                                 ((< secs 20) "less than 20 seconds ago") 
    505                                 ((< secs 30) "half a minute ago") 
    506                                 ((< secs 60) "less than a minute ago") 
    507                                 ((< secs 150) "1 minute ago") 
    508                                 ((< secs 2400) (format "%d minutes ago" 
    509                                                        (/ (+ secs 30) 60))) 
    510                                 ((< secs 5400) "about 1 hour ago") 
    511                                 ((< secs 84600) (format "about %d hours ago" 
    512                                                         (/ (+ secs 1800) 3600))) 
    513                                 (t (format-time-string "%I:%M %p %B %d, %Y" created-at))) 
    514                           result)))) 
     501                            (- (cadr now) (cadr created-at)))) 
     502                   time-string url) 
     503               (setq time-string 
     504                (cond ((< secs 5) "less than 5 seconds ago") 
     505                      ((< secs 10) "less than 10 seconds ago") 
     506                      ((< secs 20) "less than 20 seconds ago") 
     507                      ((< secs 30) "half a minute ago") 
     508                      ((< secs 60) "less than a minute ago") 
     509                      ((< secs 150) "1 minute ago") 
     510                      ((< secs 2400) (format "%d minutes ago" 
     511                                             (/ (+ secs 30) 60))) 
     512                      ((< secs 5400) "about 1 hour ago") 
     513                      ((< secs 84600) (format "about %d hours ago" 
     514                                              (/ (+ secs 1800) 3600))) 
     515                      (t (format-time-string "%I:%M %p %B %d, %Y" created-at)))) 
     516               (setq url (twittering-get-status-url (attr 'user-screen-name) (attr 'id))) 
     517               ;; make status url clickable 
     518               (add-text-properties 
     519                0 (length time-string) 
     520                `(mouse-face highlight 
     521                             face twittering-uri-face 
     522                             uri ,url) 
     523                time-string) 
     524               (list-push time-string result)))) 
    515525          ((?t)                         ; %t - text 
    516526           (list-push                   ;(clickable-text) 
     
    524534           (list-push (attr 'source) result)) 
    525535          ((?#)                         ; %# - id 
    526            (list-push (attr 'id) result)) 
     536           (list-push (format "%d" (attr 'id)) result)) 
    527537          (t 
    528538           (list-push (char-to-string c) result))) 
     
    10291039      (buffer-substring start-pos end-pos)))) 
    10301040 
     1041(defun twittering-get-status-url (username id) 
     1042  "Generate status URL." 
     1043  (format "http://twitter.com/%s/statuses/%d" username id)) 
     1044 
    10311045;;;###autoload 
    10321046(defun twit ()