A macro problem

I start to play with macros in texmacs. I encounter a problem:

I have this macro defined

  <assign|demo|<macro|w|x|y|z|R<rsub|<arg|w> <arg|x> <arg|y> <arg|z>>>>

which basically assign \demo to the math R_{i j k l} with i,j,k and l being inserted by me when macro expands.

I want to have a shortcut to move from one parameter to the next parameter, so I defined the following:

(kbd-map
  (:mode in-math?)
  ("C-h" 
   (let ((t (focus-tree)))
     (if
      (and (tree-in? t '(demo))
           (not (tree-at-end? t)))
      (traverse-next)
      (set-message "Tree is end" "Tree is end")))))

I noticed that when I moved to the second argument using C-h key, it already displays an “Tree is end” message.

This may be a bug!

Any progress on this?

This is because of line 3 in the definition of tree-at-end?:

(tm-define (tree-at-end? t)
  (with p (cursor-path)
    (or (== p (tree->path t 1 :end))
        (== p (tree->path t :end)))))

The second argument to the macro in this case is at (t 1), so if the cursor is at the end of that element you are at (t 1 :end) and tree-at-end? returns true.

1 Like