dandavison / xenops

An editing environment for LaTeX mathematical documents
MIT License
228 stars 14 forks source link

xenops-reveal-on-entry messes with cursor position #59

Closed quarkQuark closed 1 year ago

quarkQuark commented 2 years ago

When xenops-reveal-on-entry is enabled and a previously completed fragment (say, \(x\)) is edited, typing an underscore immediately moves the cursor to the beginning of the fragment, leading to input such as \(1x_{}\) instead of \(x_{1}\). I have checked that this does not happen when xenops-reveal-on-entry is set to nil.

fanzhuyifan commented 1 year ago

Hi, I am using cdlatex and also experiencing this issue. I found a work-around by redefining xenops-math-reveal and removing the goto-char:

(defun xenops-math-reveal (element)
  "Remove image overlay for ELEMENT.
If a prefix argument is in effect, also delete its cache file."
  (xenops-element-overlays-delete element)
  (if current-prefix-arg
      (delete-file (xenops-math-get-cache-file element)))
  ;; TODO: is :begin-content for block math off by one?
  (let ((element-type (plist-get element :type))
        (begin-content (plist-get element :begin-content)))
    )
  (xenops-math-render-below-maybe element))

Just place this in your emacs init file after loading xenops

quarkQuark commented 1 year ago

Thanks! That seems to work well. I would be curious to know what the intended purpose is for goto-char in that function. Might be worth you submitting your work-around as a pull request.