Show
Ignore:
Timestamp:
05/11/08 12:53:10 (16 years ago)
Author:
tsuyoshi
Message:

update 0.5 : twittering-mode

Location:
lang/elisp/twittering-mode/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/elisp/twittering-mode/trunk/ChangeLog

    r38 r47  
     12008-05-11  Tsuyoshi CHO  <Tsuyoshi.CHO+develop@Gmail.com> 
     2 
     3        * twittering-mode.el (twittering-format-status): id/user-idのフォー 
     4        マット整形。時間情報にuriを付与。Nicholasのパッチにより全体に 
     5        username情報を付与 
     6        (twittering-status-to-status-datum): username/user-screen-nameにつ 
     7        いて整理 
     8        (twittering-get-status-url): 新規関数(マクロでもいいんだけど...) 
     9 
    1102008-05-01  Tsuyoshi CHO  <Tsuyoshi.CHO+develop@Gmail.com> 
    211 
  • lang/elisp/twittering-mode/trunk/twittering-mode.el

    r38 r47  
    4646(require 'parse-time) 
    4747 
    48 (defconst twittering-mode-version "0.4") 
     48(defconst twittering-mode-version "0.5") 
    4949 
    5050(defun twittering-mode-version () 
     
    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))) 
    529539        ) 
    530540      (list-push (substring format-str cursor) result) 
    531       (apply 'concat (nreverse result)) 
     541      (let ((formatted-status (apply 'concat (nreverse result)))) 
     542        (add-text-properties 0 (length formatted-status) 
     543                             `(username ,(attr 'user-screen-name)) 
     544                             formatted-status) 
     545        formatted-status) 
    532546      ))) 
    533547 
     
    695709 
    696710      ;; make username clickable 
    697       (add-text-properties 0 (length user-screen-name) 
    698                            `(mouse-face highlight 
    699                                         uri ,(concat "http://twitter.com/" user-screen-name) 
    700                                         username ,user-screen-name 
    701                                         face twittering-username-face) 
    702                            user-screen-name) 
     711      (add-text-properties 
     712       0 (length user-name) 
     713       `(mouse-face highlight 
     714                    uri ,(concat "http://twitter.com/" user-screen-name) 
     715                    face twittering-username-face) 
     716       user-name) 
     717 
     718      ;; make screen-name clickable 
     719      (add-text-properties 
     720       0 (length user-screen-name) 
     721       `(mouse-face highlight 
     722                    face twittering-username-face 
     723                    uri ,(concat "http://twitter.com/" user-screen-name) 
     724                    face twittering-username-face) 
     725       user-screen-name) 
    703726 
    704727      ;; make URI clickable 
     
    722745                   highlight 
    723746                   face twittering-uri-face 
    724                    username ,screen-name 
    725747                   uri ,(concat "http://twitter.com/" screen-name)) 
    726748               `(mouse-face highlight 
     
    730752          (setq regex-index (match-end 0)) )) 
    731753 
    732       ;; make screen-name clickable 
    733       (add-text-properties 
    734        0 (length user-screen-name) 
    735        `(mouse-face highlight 
    736                     face twittering-username-face 
    737                     uri ,(concat "http://twitter.com/" user-screen-name) 
    738                     username ,user-screen-name) 
    739        user-screen-name) 
    740754 
    741755      ;; make source pretty and clickable 
     
    10291043      (buffer-substring start-pos end-pos)))) 
    10301044 
     1045(defun twittering-get-status-url (username id) 
     1046  "Generate status URL." 
     1047  (format "http://twitter.com/%s/statuses/%d" username id)) 
     1048 
    10311049;;;###autoload 
    10321050(defun twit ()