diff --git a/src/prompt.lisp b/src/prompt.lisp index dd84b4068..dd3feb26b 100644 --- a/src/prompt.lisp +++ b/src/prompt.lisp @@ -19,6 +19,41 @@ history-symbol syntax-table gravity edit-callback special-keymap use-border)) +(flet ((f (c1 c2 step-fn) + (when c1 + (when (and (member c1 '(#\#)) + (or (alphanumericp c2) + (member c2 '(#\+ #\-)))) + (funcall step-fn))))) + + (defun skip-expr-prefix-forward (point) + (f (character-at point 0) + (character-at point 1) + (lambda () + (character-offset point 2)))) + + (defun skip-expr-prefix-backward (point) + (f (character-at point -2) + (character-at point -1) + (lambda () + (character-offset point -2))))) + +(defvar *prompt-syntax-table* + (make-syntax-table + :space-chars '(#\space #\tab #\newline #\page) + :symbol-chars '(#\+ #\- #\< #\> #\/ #\* #\& #\= #\. #\? #\_ #\! #\$ #\% #\: #\@ #\[ #\] + #\^ #\{ #\} #\~ #\# #\|) + :paren-pairs '((#\( . #\)) + (#\[ . #\]) + (#\{ . #\})) + :string-quote-chars '(#\") + :escape-chars '(#\\) + :fence-chars '(#\|) + :expr-prefix-chars '(#\' #\, #\@ #\# #\`) + :expr-prefix-forward-function 'skip-expr-prefix-forward + :expr-prefix-backward-function 'skip-expr-prefix-backward)) + + (defun prompt-for-character (prompt &key (gravity *default-prompt-gravity*)) (%prompt-for-character prompt :gravity gravity)) @@ -139,7 +174,8 @@ prompt :completion-function *prompt-command-completion-function* :test-function 'exist-command-p - :history-symbol 'mh-execute-command)) + :history-symbol 'mh-execute-command + :syntax-table *prompt-syntax-table*)) (defun prompt-for-library (prompt &key history-symbol) (macrolet ((ql-symbol-value (symbol)