erbot-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Erbot-cvs] erbot erbtranslate.el ChangeLog


From: Vivek Dasmohapatra
Subject: [Erbot-cvs] erbot erbtranslate.el ChangeLog
Date: Thu, 18 May 2006 14:59:07 +0000

CVSROOT:        /sources/erbot
Module name:    erbot
Branch:         
Changes by:     Vivek Dasmohapatra <address@hidden>     06/05/18 14:59:07

Modified files:
        .              : erbtranslate.el ChangeLog 

Log message:
        Make fsi-translate emit a usage message if called incorrectly.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/erbot/erbot/erbtranslate.el.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/erbot/erbot/ChangeLog.diff?tr1=1.59&tr2=1.60&r1=text&r2=text

Patches:
Index: erbot/ChangeLog
diff -u erbot/ChangeLog:1.59 erbot/ChangeLog:1.60
--- erbot/ChangeLog:1.59        Wed May 17 06:23:05 2006
+++ erbot/ChangeLog     Thu May 18 14:59:06 2006
@@ -1,3 +1,8 @@
+2006-05-18  Vivek Dasmohapatra  <address@hidden>
+
+       * erbtranslate.el (fsi-translate): If we can't make sense 
+       of the call (not enough arguments) emit a usage message.
+
 2006-05-17  Michael Olson  <address@hidden>
 
        * contrib/translate.el (translate-load-pairs): Docfix.
Index: erbot/erbtranslate.el
diff -u erbot/erbtranslate.el:1.21 erbot/erbtranslate.el:1.22
--- erbot/erbtranslate.el:1.21  Wed May 17 06:23:05 2006
+++ erbot/erbtranslate.el       Thu May 18 14:59:06 2006
@@ -46,15 +46,20 @@
  "Enabling this should be completely safe.  We do use call-process
 here whenever passing any arguments to external commands.")
 
-(defun fsi-translate (from to &rest text)
+(defun fsi-translate (&optional from to &rest text)
   (erbtranslate-enabled-check)
-  (setq text (mapconcat #'(lambda (arg) (format "%s" arg)) text " ")
-        from (format "%s" from)
-        to   (format "%s" to  ))
-  (condition-case caught
-      (translate from to text)
-    (error (concat "libtranslate error:" (cdr caught) )) ))
-
+  (if (not (and from to text))
+      (let ((frame (backtrace-frame 3)) (caller nil))
+        (setq caller (symbol-name (cadr frame))
+              caller (replace-regexp-in-string "^\\w+-" "" caller))
+        (format "Usage: ,%s FROM TO TEXT" caller))
+    (setq text (mapconcat #'(lambda (arg) (format "%s" arg)) text " ")
+          from (format "%s" from)
+          to   (format "%s" to  ))
+    (condition-case caught
+        (translate from to text)
+      (error (concat "libtranslate error:" (cdr caught)) )) ))
+  
 (defalias 'fsi-t8-l 'fsi-translate-list-pairs)
 
 (defun fsi-translate-list-pairs (&optional from to &rest args)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]