(kbd-map
(:mode in-math?)
("1 /" (begin
(math-insert '(frac "1" "")))
(kbd-left)))
the (kbd-left)
does not work. It has no effect of moving the cursor.
Why is this? What is the alternative way?
(kbd-map
(:mode in-math?)
("1 /" (begin
(math-insert '(frac "1" "")))
(kbd-left)))
the (kbd-left)
does not work. It has no effect of moving the cursor.
Why is this? What is the alternative way?
Firstly, I find that if I use Debug -> Execute -> Evaluate Scheme Expression...
, the single (kbd-left)
works as expected.
Secondly, I will look into how (kbd-left)
is implemented. Using Help->Search->Source Code...
to search (kbd-left)
, I found:
(tm-define (kbd-left)
(kbd-horizontal (focus-tree) #f))
(tm-define (kbd-horizontal t forwards?)
(:require (tree-is-buffer? t))
(with move (lambda () (if forwards? (go-right) (go-left)))
(go-to-next-such-that move generic-context?)))
(tm-define (traverse-horizontal t forwards?)
(if forwards? (go-to-next-word) (go-to-previous-word)))
I do know why kbd-left
and go-left
does not work as expected. but go-to-previous-word
works fine.
Finally, the you may use the following code snippet:
(kbd-map (:mode in-math?)
("1 /" (begin (math-insert `(frac "1" ""))
(go-to-previous-word)))))
As a matter of fact, I have found traverse-previous
. It does not work somehow. I forgot to try others in the family. I turns out that traverse-left
works.
however,
(kbd-map (:mode in-math?)
("p / p" (begin (math-insert '(frac "<partial>" "<partial>")))
(go-to-previous-word)))
will move the cursor to the beginning of denominator. I tried traverse-right
and traverse-next
after (go-to-previous-word)
to put the cursor at the end of the denominator. It does not work. Somehow, (go-to-next-word)
works.
I have achiedved what I want. It is put in the code
("p / p" (begin (math-insert '(frac "<partial>" "<partial>"))
(go-to-previous-word)
(go-to-next-word)))
But it seems still strange that (go-to-next-word)
and (go-to-previous-word)
are not inverse to each other in this instance.
Thank you.