diff -Ndrup linedit_0.15.12/command-functions.lisp linedit_0.15.12.2/command-functions.lisp --- linedit_0.15.12/command-functions.lisp 2004-04-25 17:08:43.000000000 +0200 +++ linedit_0.15.12.2/command-functions.lisp 2007-04-19 11:10:16.000000000 +0200 @@ -216,6 +216,7 @@ (defun kill-sexp (chord editor) (declare (ignore chord)) (with-editor-point-and-string ((point string) editor) + (declare (ignore point)) (let ((start (editor-sexp-start editor)) (end (min (1+ (editor-sexp-end editor)) (length string)))) (buffer-push (subseq string start end) (editor-killring editor)) diff -Ndrup linedit_0.15.12/complete.lisp linedit_0.15.12.2/complete.lisp --- linedit_0.15.12/complete.lisp 2004-04-25 17:08:43.000000000 +0200 +++ linedit_0.15.12.2/complete.lisp 2007-04-20 08:50:49.000000000 +0200 @@ -166,9 +166,10 @@ to the appropriate home directory." (select-symbol (symbol match) (let ((name (stringify symbol)) (end (length match))) - (when (and (> (length name) end) ; Skip indetical + (when (and (> (length name) end) ; Skip identical (equal match (subseq name 0 end))) (push-name (concat string (subseq name end))))))) + ;; Skip empty strings (when (plusp length) (if package @@ -199,4 +200,4 @@ to the appropriate home directory." (declare (ignore val)) (push key list)) hash) - (values list max-len)))))))) + (values list max-len t)))))))) diff -Ndrup linedit_0.15.12/editor.lisp linedit_0.15.12.2/editor.lisp --- linedit_0.15.12/editor.lisp 2004-04-25 17:08:43.000000000 +0200 +++ linedit_0.15.12.2/editor.lisp 2007-04-20 09:23:05.000000000 +0200 @@ -35,7 +35,7 @@ :initform *commands* :initarg :commands) (completer :reader editor-completer - :initform 'lisp-complete + :initform nil :initarg :complete) (history :reader editor-history :initform (ensure *history* (make-instance 'buffer)) @@ -54,7 +54,13 @@ :initform nil) (prompt :reader editor-prompt :initform "" - :initarg :prompt))) + :initarg :prompt) + (reader-hook :reader reader-hook ; not used but needed + :initform nil ; when we pass all key args + :initarg :reader-hook) ; as is to make-instance + (symbol-hook :reader symbol-hook ; not used but + :initform nil ; same as reader-hook but data + :initarg :symbol-hook))) ; has passed lisp-reader (defmethod initialize-instance :after ((editor editor) &rest initargs) (save-state editor)) @@ -220,8 +226,20 @@ empty string." (min (1+ point) (length string)))) (t (editor-next-word-end editor))))) +; Call each complete function and summarize a list of +; possible words for completion. Each completion function +; can terminate the walk. Therefor a user should put the +; most specific complete-functions first in the list (defun editor-complete (editor) - (funcall (editor-completer editor) (editor-word editor) editor)) + (let (final (max 0)) + (loop for fun in (editor-completer editor) do + (multiple-value-bind (list max-len continue) + (funcall fun (editor-word editor) editor) + (if (not max-len) (setf max-len 0)) + (setf final (nconc final list)) + (if (> max-len max) (setf max max-len)) + (if (not continue) (return)))) + (values final max))) (defun remember-yank (editor) (setf (editor-yank editor) (get-point editor))) diff -Ndrup linedit_0.15.12/main.lisp linedit_0.15.12.2/main.lisp --- linedit_0.15.12/main.lisp 2004-04-25 17:08:43.000000000 +0200 +++ linedit_0.15.12.2/main.lisp 2007-04-19 10:43:07.000000000 +0200 @@ -32,7 +32,7 @@ (redraw-line editor) (get-finished-string editor)))) -(defun formedit (&rest args &key (prompt1 "") (prompt2 "") +(defun formedit (&rest args &key (prompt1 "") (prompt2 "") reader-hook &allow-other-keys) "Reads a single form of input with line-editing. Returns the form as a string. Assumes standard readtable." @@ -65,7 +65,10 @@ a string. Assumes standard readtable." (end-of-file () eof-marker)))) (unless (eq eof-marker form) - (throw 'form-done str))))))))) + (throw 'form-done + (if reader-hook + (funcall reader-hook str) + str)))))))))) (defun semicolon-reader (stream char) (declare (ignore char)) diff -Ndrup linedit_0.15.12/sbcl-repl.lisp linedit_0.15.12.2/sbcl-repl.lisp --- linedit_0.15.12/sbcl-repl.lisp 2004-04-25 17:08:43.000000000 +0200 +++ linedit_0.15.12.2/sbcl-repl.lisp 2007-04-20 08:45:48.000000000 +0200 @@ -24,7 +24,7 @@ #-sbcl (error "Attempt to load an SBCL specific file in anothr implementation.") -(let (prompt-fun read-form-fun) +(let (prompt-fun read-form-fun user-symbol-hook) (declare (type (or null function) prompt-fun read-form-fun)) (macrolet ((enforce-consistent-state () @@ -42,13 +42,15 @@ (warn "UNINSTALL-REPL failed: No Linedit REPL present.")) nil) - (defun install-repl (&key wrap-current eof-quits) + (defun install-repl (&key wrap-current eof-quits reader-hook symbol-hook + completer) "Installs the Linedit at REPL. Original input handlers can be preserved with the :WRAP-CURRENT T." (enforce-consistent-state) (when prompt-fun (warn "INSTALL-REPL failed: Linedit REPL already installed.") (return-from install-repl nil)) + (setf user-symbol-hook symbol-hook) (setf prompt-fun sb-int:*repl-prompt-fun* read-form-fun sb-int:*repl-read-form-fun*) (flet ((repl-reader (in out) @@ -61,8 +63,11 @@ preserved with the :WRAP-CURRENT T." (linedit:formedit :prompt1 prompt :prompt2 (make-string (length prompt) - :initial-element #\Space)) + :initial-element #\Space) + :reader-hook reader-hook + :complete (nconc completer (list #'lisp-complete))) (end-of-file (e) + (declare (ignore e)) (if eof-quits (and (fresh-line) (eof-handler)) ;; Hackins, I know. @@ -75,7 +80,9 @@ preserved with the :WRAP-CURRENT T." ;; FIXME: Yich. (terpri) (with-input-from-string (in (meta-escape (repl-reader in out))) - (funcall read-form-fun in out))) + (if user-symbol-hook + (funcall user-symbol-hook (funcall read-form-fun in out)) + (funcall read-form-fun in out)))) (lambda (in out) (declare (type stream out in)) (handler-case (read-from-string (repl-reader in out))