Skip to content
Browse files

Provide customization to append chat messages at top or bottom

* rudel-chat.el (header): updated copyright
  (rudel-chat-handler-function): split "log into buffer" behavior into
  "append at bottom" and "appending at top"
  (rudel-chat-handle-buffer-top): renamed `rudel-chat-handle-buffer ->
  `rudel-chat-handle-buffer-top
  (rudel-chat-handle-buffer-bottom): new function; append chat
  messages at bottom of target buffer
  • Loading branch information...
1 parent 498eb0d commit 0f69e06d618e57b80933cd0b5033602a2719fc66 @scymtym committed Mar 1, 2010
Showing with 21 additions and 6 deletions.
  1. +21 −6 rudel-chat.el
View
27 rudel-chat.el
@@ -1,6 +1,6 @@
;;; rudel-chat.el --- Handling of chat messages
;;
-;; Copyright (C) 2008, 2009 Jan Moringen
+;; Copyright (C) 2008, 2009, 2010 Jan Moringen
;;
;; Author: Jan Moringen <scymtym@users.sourceforge.net>
;; Keywords: Rudel, chat, message
@@ -42,13 +42,17 @@
;;; Customization
;;
-(defcustom rudel-chat-handler-function #'rudel-chat-handle-buffer
+(defcustom rudel-chat-handler-function #'rudel-chat-handle-buffer-top
"A function that is called when chat messages arrive."
:group 'rudel
:type '(choice (const :tag "Display messages in the echo area"
rudel-chat-handle-message)
- (const :tag "Log messages into a buffer"
- rudel-chat-handle-buffer)
+ (const :tag "Log messages into a buffer, \
+inserting at the top"
+ rudel-chat-handle-buffer-top)
+ (const :tag "Log messages into a buffer, \
+inserting at the bottom"
+ rudel-chat-handle-buffer-bottom)
(function :tag "Other function"))
)
@@ -78,8 +82,8 @@ inserted.")
(rudel-chat-format-sender sender)
text))
-(defun rudel-chat-handle-buffer (sender text)
- "Insert SENDER and MESSAGE in a buffer."
+(defun rudel-chat-handle-buffer-top (sender text)
+ "Insert SENDER and MESSAGE at the beginning a buffer."
(let ((buffer (or (get-buffer rudel-chat-buffer-name)
(pop-to-buffer rudel-chat-buffer-name))))
(with-current-buffer buffer
@@ -89,6 +93,17 @@ inserted.")
text))))
)
+(defun rudel-chat-handle-buffer-bottom (sender text)
+ "Insert SENDER and MESSAGE at the end of a buffer."
+ (let ((buffer (or (get-buffer rudel-chat-buffer-name)
+ (pop-to-buffer rudel-chat-buffer-name))))
+ (with-current-buffer buffer
+ (goto-char (point-max))
+ (insert (format "\n%s: %s"
+ (rudel-chat-format-sender sender)
+ text))))
+ )
+
;;; Miscellaneous functions
;;

0 comments on commit 0f69e06

Please sign in to comment.
Something went wrong with that request. Please try again.