Skip to content

Commit

Permalink
initial implementaion of pop-up buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
hayamiz committed Jan 15, 2010
1 parent 05a5b84 commit dd424de
Showing 1 changed file with 54 additions and 16 deletions.
70 changes: 54 additions & 16 deletions twittering-mode.el
Expand Up @@ -889,6 +889,60 @@ Return nil if STR is invalid as a timeline spec."
(defvar twittering-mode-hook nil
"Twittering-mode hook.")

(defun twittering-mode ()
"Major mode for Twitter
\\{twittering-mode-map}"
(interactive)
(switch-to-buffer (twittering-buffer))
(kill-all-local-variables)
(twittering-mode-init-variables)
(use-local-map twittering-mode-map)
(setq major-mode 'twittering-mode)
(twittering-update-mode-line)
(set-syntax-table twittering-mode-syntax-table)
(run-hooks 'twittering-mode-hook)
(font-lock-mode -1)
(twittering-stop)
(twittering-start))

(define-derived-mode twittering-edit-mode text-mode "Twittering Status Edit"
(use-local-map twittering-edit-mode-map))

(defvar twittering-pre-edit-window-configuration nil)

(when twittering-edit-mode-map
(let ((km twittering-edit-mode-map))
(define-key km (kbd "C-c C-c") 'twittering-edit-post-status)
(define-key km (kbd "C-c C-k") 'twittering-edit-cancel-status)))

(defun twittering-edit-close ()
(kill-buffer (current-buffer))
(when twittering-pre-edit-window-configuration
(set-window-configuration twittering-pre-edit-window-configuration)
(setq twittering-pre-edit-window-configuration nil)))

(defun twittering-edit-status ()
(interactive)
(let ((buf (generate-new-buffer "*twittering-edit*")))
(setq twittering-pre-edit-window-configuration
(current-window-configuration))
(pop-to-buffer buf)
(twittering-edit-mode)
(message "C-c C-c to post, C-c C-k to cancel")))

(defun twittering-edit-post-status ()
(interactive)
(let ((status (buffer-string)))
(when (twittering-status-not-blank-p status)
(let ((parameters `(("status" . ,status)
("source" . "twmode"))))
(twittering-http-post "twitter.com" "statuses/update" parameters))))
(twittering-edit-close))

(defun twittering-edit-cancel-status ()
(interactive)
(twittering-edit-close))

(defun twittering-update-mode-line ()
"Update mode line"
(let ((enabled-options nil)
Expand Down Expand Up @@ -2615,22 +2669,6 @@ variable `twittering-status-format'"
(pos (max (point-min) (1- border))))
(get-text-property pos 'username))))

(defun twittering-mode ()
"Major mode for Twitter
\\{twittering-mode-map}"
(interactive)
(switch-to-buffer (twittering-buffer))
(kill-all-local-variables)
(twittering-mode-init-variables)
(use-local-map twittering-mode-map)
(setq major-mode 'twittering-mode)
(twittering-update-mode-line)
(set-syntax-table twittering-mode-syntax-table)
(run-hooks 'twittering-mode-hook)
(font-lock-mode -1)
(twittering-stop)
(twittering-start))

(defun twittering-suspend ()
"Suspend twittering-mode then switch to another buffer."
(interactive)
Expand Down

0 comments on commit dd424de

Please sign in to comment.