Skip to content
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

LaTeX-insert-item problem with end of line in evil mode #5241

Closed
brabalan opened this issue Feb 25, 2016 · 17 comments
Closed

LaTeX-insert-item problem with end of line in evil mode #5241

brabalan opened this issue Feb 25, 2016 · 17 comments
Labels
- Bug tracker - LaTeX stale marked as a stale issue/pr (usually by a bot)

Comments

@brabalan
Copy link
Contributor

Description

When using LaTeX-insert-item (,i in latex,

"i" 'LaTeX-insert-item ;; C-c C-j
), the character under the cursor is put in the following item. As it's not possible to go right of this character, on has to make sure there is a space at the end of the line before using ,i

Reproduction guide

  • Start Emacs
  • open a latex file
  • insert an itemize environment ,e<RET>
  • type afoo, then hit escape
  • type ,i

Observed behaviour:
This is what we get:

\begin{itemize}
\item fo
\item o
\end{itemize}

Expected behaviour:
This is what we should get

\begin{itemize}
\item foo
\item 
\end{itemize}

System Info

  • OS: darwin
  • Emacs: 24.5.1
  • Spacemacs: 0.105.11
  • Spacemacs branch: master (rev. 93e55bb)
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(auto-completion elfeed emacs-lisp finance git gnus latex ocaml org
                 (spell-checking :variables spell-checking-enable-auto-dictionary t))

Backtrace

not relevant

@justbur
Copy link
Contributor

justbur commented Feb 25, 2016

I agree. I'll take this one.

@justbur
Copy link
Contributor

justbur commented Feb 25, 2016

try this

      (defun spacemacs/latex-insert-item ()
        (interactive "*")
        (if (evil-normal-state-p)
            (progn (evil-open-below 1)
                   (beginning-of-line)
                   (call-interactively 'LaTeX-insert-item))
          (call-interactively 'LaTeX-insert-item)))
      (spacemacs/set-leader-keys-for-major-mode 'latex-mode
        "i" 'spacemacs/latex-insert-item)

@brabalan
Copy link
Contributor Author

It works great, thanks.

@dl3br
Copy link

dl3br commented Feb 25, 2016

if you use autocompletion layer there's a snippet bound on "-" (hyphen) for that.
Thus:
"- M-/" or "- TAB" or "- RET" depending on your config

@brabalan
Copy link
Contributor Author

@dlebrecht thank you for the suggestion. It works with M-/ here, which is not very convenient.

@dl3br
Copy link

dl3br commented Feb 25, 2016

if that interests you, adding this to ur .spacemacs layer configuration, it
should work using tab key:
instead of simply auto-completion, you set variables

 (auto-completion :variables
                  auto-completion-enable-snippets-in-popup t
                  auto-completion-tab-key-behavior 'complete
                  )

On Thu, Feb 25, 2016 at 4:21 PM, Alan Schmitt notifications@github.com
wrote:

@dlebrecht https://github.com/dlebrecht thank you for the suggestion.
It works with M-/ here, which is not very convenient.


Reply to this email directly or view it on GitHub
#5241 (comment)
.

@brabalan
Copy link
Contributor Author

@dlebrecht Thanks for the hint, but I think I found another bug, which I'll report separately (done as #5259): one-letter snippets do not work, as for some reason the completion mechanism is not triggered for them. As soon as I enter two letters, I see both completions from company (usual words), and snippets.

@ghost
Copy link

ghost commented Feb 28, 2016

This is actually not LaTeX specific. This is rather a more general bug and issue with emacs in general. Since emacs is built around the idea of non-modal editing, it has no concept of modal editing. Thus, any command that acts to modify the state of the environment will do so with a "one character off" error. Making a new bullet point in org mode breaks the same way as inserting a new item does in LaTeX, for example. Anything sensitive to the position of the cursor will break this way.

The easiest fix that I can think of is to have commands like $ go one character past the end of a line so that all of those things work as expected. Otherwise trying to fix each individual thing will be nearly impossible if you want them to implicitly cut the remainder of the line down to the next line.

@TheBB
Copy link
Collaborator

TheBB commented Feb 28, 2016

You can set evil-move-beyond-eol to t in your config if you want to be able to move past the end of the line.

@brabalan
Copy link
Contributor Author

@TheBB I used so have that setting before switching to spacemacs. It may be nice to put it by default.

@TheBB
Copy link
Collaborator

TheBB commented Feb 28, 2016

We did have it as default for a while and it was quite contentious.

@brabalan
Copy link
Contributor Author

Why? If there is a link to a discussion, I would really like to know what the problems could be with that setting.

@TheBB
Copy link
Collaborator

TheBB commented Feb 28, 2016

#2525

@brabalan
Copy link
Contributor Author

Very interesting read, thanks. So my understanding of the conclusion there is that we need to fix every function that relies on the character being after another character, and the fix by @justbur is the way to go.

@justbur
Copy link
Contributor

justbur commented Feb 29, 2016

My interpretation of this bug report was that you were expecting this function to open up a new line below the current one, when what it actually does is insert a new line into the current line, splitting the line if the point is not at the end of of the line.

My "fix" is not trying to reposition the point. It was actually rewriting the function to do something different in normal mode (open a new line below).

I think it would be awful to try and manually "fix" functions by repositioning the point depending on context.

@dschrempf
Copy link
Contributor

Hi,
I cannot see why this has been closed, I repeatedly run into this problem that functions which assume to be at the eol do not work as expected.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Bug tracker - LaTeX stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests

6 participants