-
Notifications
You must be signed in to change notification settings - Fork 8
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
Allow users to specify additional sentence terminators #17
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to contribute. Can you please add a commit to this PR that documents this feature in the README so that it is discoverable?
Okay, I will do that. I am also thinking about the interface and might try to make it more flexible. Will probably update the pull request on the weekend. Thanks for considering to merge it! |
I have been working on it and noticed a problem: there is interference with the I noticed that problem is gone when I remove Any suggestions how this can be fixed properly, i.e., by adjusting |
I've been trying but can't quite get it to work due to lack of experience with lookahead and lookbehind regexp tricks. What I want to do is modify |
\ '([!?]' . | ||
\ g:re_extra_sentence_term . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A cursory look at your question ... wouldn't the extra expressions you are trying to inject need to go inside the character class expression rather than after it? Something like:
\ '([!?]' . | |
\ g:re_extra_sentence_term . | |
\ '([!?'. g:re_extra_sentence_term .']' . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hmm you aren't adding characters you're adding whole expressions. We probably need to setup all our matches as an array of expressions and join them at the last minute using (one|two|three)
option grouping instead of a character class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hmm you aren't adding characters you're adding whole expressions. We probably need to setup all our matches as an array of expressions and join them at the last minute using
(one|two|three)
option grouping instead of a character class.
Yes, I want to allow whole expressions. Let me give an example and demonstrate the problem:
\documentclass{minimal}
\begin{document}
\newcommand{\beq}{\begin{equation}}
\newcommand{\eeq}{\end{equation}}
This is a long sentence, exceeding eighty characters and containing an equation environment below, starting here:
\beq
x = 1 \,,
\eeq
and it is followed by another long sentence that exceeds eighty characters and should be wrapped by \texttt{gqis}.
\end{document}
Consider this with
let g:re_extra_sentence_term =
\ '|\\beq' .
\ '|\\eeq'
call textobj#sentence#init()
With my proposed implementation, when I place the cursor on the line before the equation and hit gqis
, it does (almost) the right thing:
This is a long sentence, exceeding eighty characters and containing an equation
environment below, starting here: \beq
...
(I noticed only now it's not perfect, the \beq
should actually stay on its own line ideally, but that may be a paragraph issue rather than a sentence issue).
Setting that aside, the main trouble is that hitting gqis
when the cursor is in the line after the \eeq
, it does not rewrap that but rather the cursor jumps to above the equation and gives again
This is a long sentence, exceeding eighty characters and containing an equation
environment below, starting here: \beq
...
As far as I can tell, the reason is that the negative lookback jumps over the \eeq
and \beq
somehow.
Has there been any new progress on this PR (Pull Request)? |
I use this to prevent LeTeX environments from interfering with sentence rewrapping (
gqis
). In my after/ftplugin/tex.vim: