r4819: Auto commit for Debian build
[cl-readline.git] / readline.lisp
index 2685c4b374367145cb37c3ad5b923446d84e6604..4e8af262c09fe969a4d58d71974a6809c3b6ae1f 100644 (file)
     (setq cl-complete nil)
     (libreadline::clear-completions))
   
-  (defun use-custom-complete ()
-    "Use custom-competions."
-    (libreadline::use-custom-complete)
-    nil)
-  
-  (defun use-filename-complete ()
-    "Use default completion system. (filename)"
-    (libreadline::use-filename-complete)
-    nil)
-
   (defun use-cl-complete ()
     "Load symbols in package CL-USER as custom-completions."
     (unless cl-complete
       (do-symbols (sym (find-package :cl-user))
        (add-completion (string-downcase (string sym)))))
     (use-custom-complete)
-    nil)
+    nil))
+
+;;; Everything that affects the custom-completion collection goes
+;;; above.
+
+(defun use-custom-complete ()
+  "Use custom-competions."
+  (libreadline::use-custom-complete)
+  nil)
+  
+(defun use-filename-complete ()
+  "Use default completion system. (filename)"
+  (libreadline::use-filename-complete)
+  nil)
 
-  (defun add-history (string)
-    "Add STRING to history."
-    (with-cstring (c-string string)
-      (libreadline::add-history c-string))
-    string)
+(defun add-history (string)
+  "Add STRING to history."
+  (with-cstring (c-string string)
+    (libreadline::add-history c-string))
+  string)
   
-  (defun readline (&key (prompt "") (history t))
-    "Read a line from current TTY with line-editing."
-    (with-cstring (c-prompt prompt)
-      (let ((str (string-trim
-                 *whitespace*
-                 (convert-from-cstring (libreadline::readline c-prompt)))))
-       (when (and history (not (string= "" str)))
-         (add-history str))))))
+(defun readline (&key (prompt "") (history t))
+  "Read a line from current TTY with line-editing."
+  (with-cstring (c-prompt prompt)
+    (let* ((char* (libreadline::readline c-prompt))
+          (str (string-trim *whitespace*
+                            (convert-from-foreign-string char*))))
+      (free-foreign-object char*)
+      (when (and history (not (string= "" str)))
+       (add-history str))
+      str)))