Changeset 49 for lang/elisp/twittering-mode
- Timestamp:
- 05/11/08 15:44:53 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/elisp/twittering-mode/branches/tsuyoshi/twittering-mode.el
r48 r49 59 59 (defvar twittering-mode-map (make-sparse-keymap)) 60 60 61 (defvar twittering-timer nil "Timer object for timeline refreshing will be stored here. DO NOT SET VALUE MANUALLY.") 61 (defvar twittering-timer nil 62 "Timer object for timeline refreshing will be stored here. DO NOT SET VALUE 63 MANUALLY.") 62 64 63 65 (defvar twittering-idle-time 20) … … 75 77 (make-variable-buffer-local 'twittering-jojo-mode) 76 78 77 (defvar twittering-status-format nil)78 (setq twittering-status-format "%i %s, %@:\n %t // from %f%L") 79 ;;%s - screen_name80 ;;%S - name81 ;;%i - profile_image82 ;;%d - description83 ;;%l - location84 ;; %L - " [location]"85 ;;%u - url86 ;;%j - user.id87 ;;%p - protected?88 ;;%c - created_at (raw UTC string)89 ;;%C{time-format-str} - created_at (formatted with time-format-str)90 ;;%@ - X seconds ago91 ;;%t - text92 ;;%' - truncated93 ;;%f - source94 ;; %# - id 79 (defvar twittering-status-format "%i %s, %@:\n %t // from %f%L" 80 "Formatt Rule: 81 %s - screen_name 82 %S - name 83 %i - profile_image 84 %d - description 85 %l - location 86 %L - \" [location]\" 87 %u - url 88 %j - user.id 89 %p - protected? 90 %c - created_at (raw UTC string) 91 %C{time-format-str} - created_at (formatted with time-format-str) 92 %@ - X seconds ago 93 %t - text 94 %' - truncated 95 %f - source 96 %# - id") 95 97 96 98 (defvar twittering-buffer "*twittering*") … … 253 255 (define-key km "s" 'twittering-scroll-mode) 254 256 (define-key km "t" 'twittering-toggle-proxy) 257 (define-key km "F" 'twittering-status-toggle-favorite) 255 258 (define-key km "\C-c\C-p" 'twittering-toggle-proxy) 256 259 nil)) … … 541 544 (let ((formatted-status (apply 'concat (nreverse result)))) 542 545 (add-text-properties 0 (length formatted-status) 543 `(username ,(attr 'user-screen-name)) 546 `(username ,(attr 'user-screen-name) 547 id ,(attr 'id) 548 favorited ,(attr 'favorited)) 544 549 formatted-status) 545 550 formatted-status) … … 678 683 (let* ((status-data (cddr status)) 679 684 id text source created-at truncated 685 favorited in_reply_to_status_id in_reply_to_user_id 680 686 (user-data (cddr (assq 'user status-data))) 681 687 user-id user-name … … 695 701 (setq created-at (assq-get 'created_at status-data)) 696 702 (setq truncated (assq-get 'truncated status-data)) 703 (setq favorited (assq-get 'favorited status-data)) 704 (setq in_reply_to_user_id (assq-get 'in_reply_to_user_id status-data)) 705 (setq in_reply_to_user_id (assq-get 'in_reply_to_status_id status-data)) 697 706 (setq user-id (string-to-number (assq-get 'id user-data))) 698 707 (setq user-name (twittering-decode-html-entities … … 771 780 `(,sym . ,(symbol-value sym))) 772 781 '(id text source created-at truncated 782 favorited in_reply_to_status_id in_reply_to_user_id 773 783 user-id user-name user-screen-name user-location 774 784 user-description … … 878 888 ("source" . "twmode"))))) 879 889 890 (defun twittering-http-get-fav-sentinel (proc stat &optional suc-msg) 891 (flet ((assq-get (item seq) 892 (car (cddr (assq item seq))))) 893 (let ((header (twittering-get-response-header)) 894 (body (twittering-get-response-body)) 895 (status nil)) 896 (if (string-match "HTTP/1\.[01] \\([a-z0-9 ]+\\)\r?\n" header) 897 (progn 898 (setq status (match-string-no-properties 1 header)) 899 (case-string 900 status 901 (("200 OK") 902 (let ((status-data (assq-get 'status body))) 903 (message "status %s: favorited - %s" 904 (assq-get 'id status-data) 905 (assq-get 'favorited status-data)))) 906 (t (message status)))) 907 (message "Failure: Bad http response."))))) 908 909 (defun twittering-status-set-favorite (id) 910 (with-temp-buffer 911 (twittering-http-get "favourings" (format "create/%d" id) 912 'twittering-http-get-fav-sentinel))) 913 914 (defun twittering-status-destroy-favorite (id) 915 (with-temp-buffer 916 (twittering-http-get "favourings" (format "destroy/%d" id) 917 'twittering-http-get-fav-sentinel))) 918 919 (defun twittering-status-toggle-favorite () 920 (interactive) 921 (let ((id (get-text-property (point) 'id)) 922 (favorite-status 923 (string-equal "true" (get-text-property (point) 'favorited)))) 924 (if favorite-status 925 ;; destroy 926 (progn 927 (twittering-status-destroy-favorite id) 928 (message "Destory favorite : %d" id)) 929 (twittering-status-set-favorite id) 930 (message "Set favorite : %d" id)))) 931 880 932 ;;; 881 933 ;;; Commands