Changeset 80 for lang/elisp/twittering-mode
- Timestamp:
- 03/12/09 13:07:44 (16 years ago)
- Location:
- lang/elisp/twittering-mode/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/elisp/twittering-mode/trunk/ChangeLog
r78 r80 1 2009-03-12 Tsuyoshi CHO <Tsuyoshi.CHO+develop@Gmail.com> 2 3 * twittering-mode.el: Append new methods by Alberto Garcia 4 <agarcia@igalia.com>'s patch. 5 (twittering-get-timeline): Add new general method. Old name is 6 `twittering-friends-timeline'. 7 (twittering-friends-timeline): Renew use general method. 8 (twittering-replies-timeline): Add new. 9 (twittering-public-timeline): Ditto. 10 (twittering-user-timeline): Ditto. 11 (twittering-current-timeline): Ditto. 12 (twittering-last-timeline-retrieved): Add new variable. 13 (twittering-mode-map): Add new key binding. 14 (twittering-erase-old-statuses): Support multi method. 15 16 (twittering-timer): Comment update. 17 (twittering-icon-mode): Ditto. 18 (twittering-http-post): Ditto. 19 (twittering-get-response-body): Ditto. 20 (twittering-cache-status-datum): Ditto and Fix renaming. 21 (twittering-timeline-data, twittering-timeline-last-update): Rename. 22 (twittering-render-timeline): Ditto. 23 (twittering-icon-mode): Fix renaming. 24 (twittering-http-get-default-sentinel): Ditto. 25 (twittering-format-status): Fix indentation. 26 1 27 2009-03-09 Tsuyoshi CHO <Tsuyoshi.CHO+develop@Gmail.com> 2 28 3 29 * twittering-mode.el (twittering-mode): Add keybind in Major mode 4 docstirng 30 docstirng by Alex Schröder <kensanata@gmail.com> 5 31 6 32 2008-08-03 Tsuyoshi CHO <Tsuyoshi.CHO+develop@Gmail.com> -
lang/elisp/twittering-mode/trunk/twittering-mode.el
r77 r80 11 11 ;; URL: http://lambdarepos.svnrepository.com/share/trac.cgi/browser/lang/elisp/twittering-mode 12 12 13 ;; Modified by Alberto Garcia <agarcia@igalia.com> to add the following methods: 14 ;; twittering-replies-timeline 15 ;; twittering-public-timeline 16 ;; twittering-user-timeline 17 ;; twittering-current-timeline 18 13 19 ;; This file is free software; you can redistribute it and/or modify 14 20 ;; it under the terms of the GNU General Public License as published by … … 59 65 (defvar twittering-mode-map (make-sparse-keymap)) 60 66 61 (defvar twittering-timer nil "Timer object for timeline refreshing will be stored here. DO NOT SET VALUE MANUALLY.") 67 (defvar twittering-timer nil "Timer object for timeline refreshing will be 68 stored here. DO NOT SET VALUE MANUALLY.") 62 69 63 70 (defvar twittering-idle-time 20) … … 68 75 69 76 (defvar twittering-password nil) 77 78 (defvar twittering-last-timeline-retrieved nil) 70 79 71 80 (defvar twittering-scroll-mode nil) … … 102 111 (twittering-get-or-generate-buffer twittering-http-buffer)) 103 112 104 (defvar twittering- friends-timeline-data nil)105 (defvar twittering- friends-timeline-last-update nil)113 (defvar twittering-timeline-data nil) 114 (defvar twittering-timeline-last-update nil) 106 115 107 116 (defvar twittering-username-face 'twittering-username-face) … … 163 172 temporary-file-directory)) 164 173 165 (defvar twittering-icon-mode nil "You MUST NOT CHANGE this variable directory. You should change through function'twittering-icon-mode'") 174 (defvar twittering-icon-mode nil "You MUST NOT CHANGE this variable 175 directory. You should change through function'twittering-icon-mode'") 176 166 177 (make-variable-buffer-local 'twittering-icon-mode) 167 178 (defun twittering-icon-mode (&optional arg) … … 179 190 (make-directory twittering-tmp-dir)) 180 191 t))))) 181 (twittering-render- friends-timeline))192 (twittering-render-timeline)) 182 193 183 194 (defun twittering-scroll-mode (&optional arg) … … 237 248 (let ((km twittering-mode-map)) 238 249 (define-key km "\C-c\C-f" 'twittering-friends-timeline) 250 (define-key km "\C-c\C-r" 'twittering-replies-timeline) 251 (define-key km "\C-c\C-g" 'twittering-public-timeline) 252 (define-key km "\C-c\C-u" 'twittering-user-timeline) 239 253 (define-key km "\C-c\C-s" 'twittering-update-status-interactive) 240 254 (define-key km "\C-c\C-e" 'twittering-erase-old-statuses) … … 243 257 (define-key km [mouse-1] 'twittering-click) 244 258 (define-key km "\C-c\C-v" 'twittering-view-user-page) 259 (define-key km "g" 'twittering-current-timeline) 245 260 ;; (define-key km "j" 'next-line) 246 261 ;; (define-key km "k" 'previous-line) … … 295 310 (body (cdr clause))) 296 311 `(,(if (listp keylist) 297 `(or ,@(mapcar (lambda (key) `(string-equal ,str ,key)) keylist)) 312 `(or ,@(mapcar (lambda (key) `(string-equal ,str ,key)) 313 keylist)) 298 314 't) 299 315 ,@body))) … … 325 341 (run-hooks 'twittering-mode-hook) 326 342 (font-lock-mode -1) 327 (twittering-start) 328 ) 343 (twittering-start)) 329 344 330 345 ;;; … … 369 384 (lambda (param-pair) 370 385 (format "%s=%s" 371 (twittering-percent-encode (car param-pair)) 372 (twittering-percent-encode (cdr param-pair)))) 386 (twittering-percent-encode (car 387 param-pair)) 388 (twittering-percent-encode (cdr 389 param-pair)))) 373 390 parameters 374 391 "&"))) … … 378 395 "Authorization: Basic " 379 396 (base64-encode-string 380 (concat twittering-username ":" (twittering-get-password))) 397 (concat twittering-username ":" 398 (twittering-get-password))) 381 399 nl 382 400 "Accept: text/xml" … … 417 435 (reverse (twittering-xmltree-to-status 418 436 body))) 419 (twittering-render- friends-timeline)437 (twittering-render-timeline) 420 438 (message (if suc-msg suc-msg "Success: Get."))) 421 439 (t (message status)))) … … 423 441 ) 424 442 425 (defun twittering-render- friends-timeline ()443 (defun twittering-render-timeline () 426 444 (with-current-buffer (twittering-buffer) 427 445 (let ((point (point)) … … 435 453 (save-excursion (beginning-of-line) (point)) (point)) 436 454 (insert "\n")) 437 twittering- friends-timeline-data)455 twittering-timeline-data) 438 456 (if twittering-image-stack 439 457 (clear-image-cache)) … … 451 469 (icon-string "\n ")) 452 470 (if (string-match "/\\([^/?]+\\)\\(?:\\?\\|$\\)" profile-image-url) 453 (let ((filename (match-string-no-properties 1 profile-image-url))) 471 (let ((filename (match-string-no-properties 1 472 profile-image-url))) 454 473 ;; download icons if does not exist 455 474 (if (file-exists-p (concat twittering-tmp-dir … … 474 493 (setq cursor 0) 475 494 (setq result '()) 476 (while (setq found-at (string-match "%\\(C{\\([^}]+\\)}\\|[A-Za-z#@']\\)" format-str cursor)) 495 (while (setq found-at (string-match "%\\(C{\\([^}]+\\)}\\|[A-Za-z#@']\\)" 496 format-str cursor)) 477 497 (setq c (string-to-char (match-string-no-properties 1 format-str))) 478 498 (if (> found-at cursor) … … 506 526 ((?c) ; %c - created_at (raw UTC string) 507 527 (list-push (attr 'created-at) result)) 508 ((?C) ; %C{time-format-str} - created_at (formatted with time-format-str) 528 ((?C) ; %C{time-format-str} - created_at (formatted with 529 ; time-format-str) 509 530 (list-push (twittering-local-strftime 510 531 (or (match-string-no-properties 2 format-str) "%H:%M:%S") … … 532 553 ((< secs 84600) (format "about %d hours ago" 533 554 (/ (+ secs 1800) 3600))) 534 (t (format-time-string "%I:%M %p %B %d, %Y" created-at)))) 535 (setq url (twittering-get-status-url (attr 'user-screen-name) (attr 'id))) 555 (t (format-time-string "%I:%M %p %B %d, %Y" 556 created-at)))) 557 (setq url (twittering-get-status-url (attr 'user-screen-name) 558 (attr 'id))) 536 559 ;; make status url clickable 537 560 (add-text-properties … … 569 592 "Send HTTP POST request to twitter.com 570 593 571 METHOD-CLASS must be one of Twitter API method classes(statuses, users or direct_messages). 594 METHOD-CLASS must be one of Twitter API method classes 595 (statuses, users or direct_messages). 572 596 METHOD must be one of Twitter API method which belongs to METHOD-CLASS. 573 PARAMETERS is alist of URI parameters. ex) ((\"mode\" . \"view\") (\"page\" . \"6\")) => <URI>?mode=view&page=6" 597 PARAMETERS is alist of URI parameters. 598 ex) ((\"mode\" . \"view\") (\"page\" . \"6\")) => <URI>?mode=view&page=6" 574 599 (if (null sentinel) (setq sentinel 'twittering-http-post-default-sentinel)) 575 600 … … 660 685 661 686 (defun twittering-get-response-body (&optional buffer) 662 "Exract HTTP response body from HTTP response, parse it as XML, and return a XML tree as list.663 `buffer' may be a buffer or the name of an existing buffer. 664 If`buffer' is omitted, the value of `twittering-http-buffer' is used as `buffer'."687 "Exract HTTP response body from HTTP response, parse it as XML, and return a 688 XML tree as list. `buffer' may be a buffer or the name of an existing buffer. If 689 `buffer' is omitted, the value of `twittering-http-buffer' is used as `buffer'." 665 690 (if (stringp buffer) (setq buffer (get-buffer buffer))) 666 691 (if (null buffer) (setq buffer (twittering-http-buffer))) … … 675 700 676 701 (defun twittering-cache-status-datum (status-datum &optional data-var) 677 "Cache status datum into data-var(default twittering- friends-timeline-data)702 "Cache status datum into data-var(default twittering-timeline-data) 678 703 If STATUS-DATUM is already in DATA-VAR, return nil. If not, return t." 679 704 (if (null data-var) 680 (setf data-var 'twittering- friends-timeline-data))705 (setf data-var 'twittering-timeline-data)) 681 706 (let ((id (cdr (assq 'id status-datum)))) 682 707 (if (or (null (symbol-value data-var)) … … 687 712 (progn 688 713 (if twittering-jojo-mode 689 (twittering-update-jojo (cdr (assq 'user-screen-name status-datum)) 714 (twittering-update-jojo (cdr (assq 'user-screen-name 715 status-datum)) 690 716 (cdr (assq 'text status-datum)))) 691 717 (set data-var (cons status-datum (symbol-value data-var))) … … 788 814 789 815 ;; save last update time 790 (setq twittering- friends-timeline-last-update created-at)816 (setq twittering-timeline-last-update created-at) 791 817 792 818 (mapcar … … 921 947 (setq twittering-timer nil)) 922 948 923 (defun twittering-friends-timeline () 924 (interactive) 949 (defun twittering-get-timeline (method) 950 (if (not (eq twittering-last-timeline-retrieved method)) 951 (setq twittering-timeline-last-update nil 952 twittering-timeline-data nil)) 953 (setq twittering-last-timeline-retrieved method) 925 954 (let ((buf (get-buffer twittering-buffer))) 926 955 (if (not buf) 927 956 (twittering-stop) 928 (if (not twittering-friends-timeline-last-update)929 (twittering-http-get "statuses" "friends_timeline")930 931 932 933 934 twittering-friends-timeline-last-update)))935 (twittering-http-get "statuses" "friends_timeline"936 957 (if (not twittering-timeline-last-update) 958 (twittering-http-get "statuses" method) 959 (let* ((system-time-locale "C") 960 (since 961 (twittering-global-strftime 962 "%a, %d %b %Y %H:%M:%S GMT" 963 twittering-timeline-last-update))) 964 (twittering-http-get "statuses" method 965 `(("since" . ,since))))))) 937 966 938 967 (if twittering-icon-mode … … 956 985 ))))))) 957 986 987 (defun twittering-friends-timeline () 988 (interactive) 989 (twittering-get-timeline "friends_timeline")) 990 991 (defun twittering-replies-timeline () 992 (interactive) 993 (twittering-get-timeline "replies")) 994 995 (defun twittering-public-timeline () 996 (interactive) 997 (twittering-get-timeline "public_timeline")) 998 999 (defun twittering-user-timeline () 1000 (interactive) 1001 (twittering-get-timeline "user_timeline")) 1002 1003 (defun twittering-current-timeline () 1004 (interactive) 1005 (if (not twittering-last-timeline-retrieved) 1006 (setq twittering-last-timeline-retrieved "friends_timeline")) 1007 (twittering-get-timeline twittering-last-timeline-retrieved)) 1008 958 1009 (defun twittering-update-status-interactive () 959 1010 (interactive) … … 962 1013 (defun twittering-erase-old-statuses () 963 1014 (interactive) 964 (setq twittering-friends-timeline-data nil) 965 (if (not twittering-friends-timeline-last-update) 966 (twittering-http-get "statuses" "friends_timeline") 1015 (setq twittering-timeline-data nil) 1016 (if (not twittering-last-timeline-retrieved) 1017 (setq twittering-last-timeline-retrieved "friends_timeline")) 1018 (if (not twittering-timeline-last-update) 1019 (twittering-http-get "statuses" twittering-last-timeline-retrieved) 967 1020 (let* ((system-time-locale "C") 968 1021 (since 969 970 971 twittering-friends-timeline-last-update)))972 (twittering-http-get "statuses" "friends_timeline"1022 (twittering-global-strftime 1023 "%a, %d %b %Y %H:%M:%S GMT" 1024 twittering-timeline-last-update))) 1025 (twittering-http-get "statuses" twittering-last-timeline-retrieved 973 1026 `(("since" . ,since)))))) 974 1027