Skip to content

Commit

Permalink
use 0-witdh overlay to display help in pop-up buffer
Browse files Browse the repository at this point in the history
* twittering-mode.el (twittering-edit-setup-help): use 0-witdh
overlay to display help.
(twittering-edit-mode, twittering-edit-post-status): do not use
newline chars for help-overlay anymore.
  • Loading branch information
hayamiz committed Jan 15, 2010
1 parent 4eea5d9 commit 821737c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
2010-01-16 Yuto Hayamizu <y.hayamizu@gmail.com>

* twittering-mode.el (twittering-edit-setup-help): use 0-witdh
overlay to display help.
(twittering-edit-mode, twittering-edit-post-status): do not use
newline chars for help-overlay anymore.

2010-01-15 Yuto Hayamizu <y.hayamizu@gmail.com>

* twittering-mode.el: changed URL
Expand Down
32 changes: 14 additions & 18 deletions twittering-mode.el
Expand Up @@ -956,9 +956,6 @@ Return nil if STR is invalid as a timeline spec."
(define-derived-mode twittering-edit-mode text-mode "twmode-status-edit"
(use-local-map twittering-edit-mode-map)

(insert "\n\n\n")
(goto-char (point-min))
(setq buffer-undo-list nil)
(make-local-variable 'twittering-help-overlay)
(setq twittering-help-overlay nil)
(twittering-edit-setup-help)
Expand Down Expand Up @@ -1005,25 +1002,24 @@ Return nil if STR is invalid as a timeline spec."
(defun twittering-edit-extract-status ()
(if (not (eq major-mode 'twittering-edit-mode))
""
(save-excursion
(goto-char (point-max))
(if (re-search-backward "[^\r\n\t ]" nil t)
(buffer-substring (point-min) (+ 1 (point)))
""))))
(buffer-string)))

(defun twittering-edit-setup-help ()
(let ((help-overlay
(or twittering-help-overlay
(make-overlay (- (point-max) 1) (point-max) nil t t))))
(move-overlay help-overlay (- (point-max) 1) (point-max))
(overlay-put help-overlay 'face 'font-lock-comment-face)
(overlay-put help-overlay 'display
"---- text under this line is ignored ----
Keymap:
(let ((help-str "Keymap:
C-c C-c: post a tweet
C-c C-k: cancel a tweet
M-n : next history element
M-p : previous history element")
M-p : previous history element
---- text above this line is ignored ----
")
(help-overlay
(or twittering-help-overlay
(make-overlay 1 1 nil nil nil))))

(add-text-properties 0 (length help-str) '(face font-lock-comment-face)
help-str)
(overlay-put help-overlay 'before-string help-str)
(setq twittering-help-overlay help-overlay)))

(defun twittering-edit-close ()
Expand All @@ -1049,7 +1045,7 @@ Keymap:
(interactive)
(let ((status (twittering-edit-extract-status)))
(setq twittering-edit-history
(cons (concat status "\n\n\n") twittering-edit-history))
(cons status twittering-edit-history))
(if (twittering-status-not-blank-p status)
(let ((parameters `(("status" . ,status)
("source" . "twmode")
Expand Down

0 comments on commit 821737c

Please sign in to comment.