* riece-commands.el (riece-command-enter-message): Fix behavior at last line of buffer.
[riece] / lisp / riece-commands.el
index 8efa507..1f47339 100644 (file)
@@ -34,8 +34,6 @@
 (require 'riece-message)
 (require 'riece-mcat)
 
-(autoload 'derived-mode-class "derived")
-
 ;;; Channel movement:
 (defun riece-command-switch-to-channel (channel)
   (interactive (list (riece-completing-read-identity
@@ -234,6 +232,37 @@ the layout to the selected layout-name."
             user))
    riece-current-channel))
 
+(defun riece-command-kick-with-ban (user pattern &optional message)
+  (interactive
+   (let ((completion-ignore-case t)
+        user)
+     (riece-check-channel-commands-are-usable t)
+     (riece-with-server-buffer (riece-identity-server riece-current-channel)
+       (setq user (completing-read
+                  (riece-mcat "Kick user: ")
+                  (riece-channel-get-users (riece-identity-prefix
+                                            riece-current-channel))))
+       (list
+       user
+       (read-from-minibuffer
+        (riece-mcat "Ban pattern: ")
+        (concat user "!" (riece-user-get-user-at-host user)))
+       (if current-prefix-arg
+           (read-string "Message: "))))))
+  (riece-send-string (format "MODE %s :+b %s\r\n"
+                            (riece-identity-prefix riece-current-channel)
+                            pattern)
+                    riece-current-channel)
+  (riece-send-string
+   (if message
+       (format "KICK %s %s :%s\r\n"
+              (riece-identity-prefix riece-current-channel)
+              user message)
+     (format "KICK %s %s\r\n"
+            (riece-identity-prefix riece-current-channel)
+            user))
+   riece-current-channel))
+
 (defun riece-command-names (pattern)
   (interactive
    (let ((completion-ignore-case t))
@@ -414,8 +443,10 @@ the layout to the selected layout-name."
                               (riece-line-beginning-position)
                               (riece-line-end-position))
                              nil)
-  (let ((next-line-add-newlines t))
-    (next-line 1)))
+  (forward-line 1)
+  (when (eobp)
+    (insert "\n")))
+
 
 (defun riece-command-enter-message-as-notice ()
   "Send the current line to the current channel as NOTICE."
@@ -424,8 +455,9 @@ the layout to the selected layout-name."
                               (riece-line-beginning-position)
                               (riece-line-end-position))
                              t)
-  (let ((next-line-add-newlines t))
-    (next-line 1)))
+  (forward-line 1)
+  (when (eobp)
+    (insert "\n")))
 
 (defun riece-command-enter-message-to-user (user)
   "Send the current line to USER."
@@ -445,8 +477,9 @@ the layout to the selected layout-name."
      user)
     (riece-display-message
      (riece-make-message (riece-current-nickname) user text nil t)))
-  (let ((next-line-add-newlines t))
-    (next-line 1)))
+  (forward-line 1)
+  (when (eobp)
+    (insert "\n")))
 
 (defun riece-command-join-channel (target key)
   (unless (riece-server-opened (riece-identity-server target))
@@ -598,8 +631,7 @@ the layout to the selected layout-name."
   "Prevent automatic scrolling of the dialogue window.
 If prefix argument ARG is non-nil, toggle frozen status."
   (interactive "P")
-  (with-current-buffer (if (eq (derived-mode-class major-mode)
-                              'riece-dialogue-mode)
+  (with-current-buffer (if (riece-derived-mode-p 'riece-dialogue-mode)
                           (current-buffer)
                         (if (and riece-channel-buffer-mode
                                  riece-channel-buffer)
@@ -616,8 +648,7 @@ If prefix argument ARG is non-nil, toggle frozen status."
 The difference from `riece-command-freeze' is that your messages are hidden.
 If prefix argument ARG is non-nil, toggle frozen status."
   (interactive "P")
-  (with-current-buffer (if (eq (derived-mode-class major-mode)
-                              'riece-dialogue-mode)
+  (with-current-buffer (if (riece-derived-mode-p 'riece-dialogue-mode)
                           (current-buffer)
                         (if (and riece-channel-buffer-mode
                                  riece-channel-buffer)