Skip to content

Commit

Permalink
fix execute-command behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Jan 21, 2025
1 parent 8a5148b commit 4a8d970
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/prompt.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4a8d970

Please sign in to comment.