From c6da4d259ac7da6ff94652afcb9d31ba023e0a5a Mon Sep 17 00:00:00 2001 From: Marcel van der Boom Date: Fri, 16 May 2014 22:34:37 +0200 Subject: [PATCH] Bring the max. msg size into play and use it. --- twister.el | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/twister.el b/twister.el index 6953fbe..763ffec 100644 --- a/twister.el +++ b/twister.el @@ -67,6 +67,13 @@ twister.conf file" :type 'integer :group 'twister) +(defcustom twister-max-msgsize 140 + "Maximum size of messages to post. Default of the server is 140. +If you want larger messages, you will need to enable automatic splitting +in the twister configuration." + :type 'integer + :group 'twister) + ;; Preliminary convention ;; tw-* methods -> sorta private for now, don't use directly ;; twister-* methods -> public API @@ -110,15 +117,20 @@ while PARAMS contain the rest of the parameters." "Post the current region to twister" (interactive "r") - (twister-post - (buffer-substring-no-properties begin end))) + (let ((selection (buffer-substring-no-properties begin end))) + + (when (or (<= (length selection) twister-max-msgsize) + (y-or-n-p (format (concat "The message is %i characters long. " + "Do you still want to post? ") + (length selection)))) + (message "Posting message...") + (twister-post selection)))) (defun twister-post-buffer() "Post the current buffer to twister" (interactive) - (twister-post-region - (point-min point-max))) + (twister-post-region (point-min) ( point-max))) (provide 'twister)