New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YASnippet select more than field in latex mode #579
Comments
Doesn't happen here. Which Emacs and Yasnippet versions are you using? Also, is this the builtin |
I am using AUCTeX, package-activated-list equals (auctex auto-complete-auctex auto-complete popup yasnippet hideshow-org popup yasnippet). Version is 20150415.244 from elpa. |
Emacs version? Can you check if it happens with just builtin |
Emacs is version 24.5.1. The problem disappears if I uninstall auctex. |
Confirmed. The markers for the field go wrong during indentation, I can't tell why. Minimal reproduction recipe:
|
Indentation happens after snippet field insertion (it may depend on field contents, for instance). The problem is that some indentation techniques destroy the whole whitespace in front of the line (or maybe the whole line, who knows?) and restore an indented version. Obviously, yasnippet's markers aren't restored by those strategies, so there is I don't have time to fix this right now, but if you can think of some better approach, I would very much like to hear it, as this problem is central in the yasnippet engine, which is being exported to the From your exchange, though, I still haven't understood if this happens with vanilla Emacs' |
In |
It doesn't. Probably related to what AUCTeX calls "inner indentation":
|
I think it might be enough to It works for this case at least, need to test more to see if it works elsewhere. I used this code to play with marker types: (switch-to-buffer (get-buffer-create "mtest.latex"))
(erase-buffer)
(latex-mode)
(defvar m-beg (make-marker))
(defvar mt-beg (make-marker))
(defvar m-end (make-marker))
(insert "%\n% ")
(set-marker m-beg (point))
(set-marker mt-beg (point))
(insert "field")
(set-marker m-end (point))
(set-marker-insertion-type mt-beg t)
(defun show-markers ()
(interactive)
(message "(%d, %d): %s; (%dt, %d): %s"
(marker-position m-beg) (marker-position m-end) (buffer-substring m-beg m-end)
(marker-position mt-beg) (marker-position m-end) (buffer-substring mt-beg m-end)))
(define-key global-map [f12] 'show-markers) Hit f12 to see where the markers are currently, then change the buffer text and hit f12 again to see how the markers were affected. |
Most definitely, yes.
Not enough. Suppose you have "whitespace -> null field -> whitespace", for example. You are also assuming that the major-mode adds whitespace using |
Ah, I didn't consider null fields indeed. |
In a LaTeX snippet, when the snippet is inserted, not just "field" is selected for entering but the entire line including the leading %% (see below). For the 2nd field, this then works correctly. Looks like it is related to the '%', because adding another character after the two (or three) % fixed this behaviour.
The text was updated successfully, but these errors were encountered: