-
Notifications
You must be signed in to change notification settings - Fork 409
Enhance fold labels on folded beamer frames #1830
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
Conversation
|
Thanks. Could you provide a couple of complete examples for the various cases? |
|
Sure. Given this code I get this folding: Without the changes the folding is The first example changes, because the regex now allows for The second example changes, because the code now searches and extracts a The third example changes, because commented out |
Thanks for the good examples and before vs after explanations.
It seems possible, but I think this should already suffice for a useful improvement. If you want to look into even more advanced parsing, I'll be glad to consider an updated PR or a future PR for that!
I'm not sure. In a way, I think we should ignore the commented out title. It does not feel light the right way to control the fold text. Do you have a strong opinion about this? |
| if i+1 <= v:foldend && getline(i+1) =~# '^.*\\framesubtitle' | ||
| let framesubtitle = matchstr(getline(i+1), | ||
| \ '^.*\\framesubtitle\(\[.*\]\)\?{\zs.\{-1,}\ze\(}\s*\)\?$') | ||
| return printf('%S: %S', frametitle, framesubtitle) |
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.
I would simplify this to:
let frametitle .= ': ' . matchstr(getline(i+1),
\ '^.*\\framesubtitle\(\[.*\]\)\?{\zs.\{-1,}\ze\(}\s*\)\?$')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.
I tried this and as far as I can tell this adds : 0 to the fold text if no subtitle is available, so the if condition seems necessary. But I could remove the extra variable and return statement, if you prefer.
lervag
left a comment
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.
I've looked through the code, and I think it is decent. I have two comments, and we'll have to decide about the commented out frametitles. I also want to add tests, but I can do that myself. If you want to try, look into test/tests/test-folding for examples of how to do it.
|
|
||
| " If no caption found, check for a caption comment | ||
| return matchstr(a:line,'\\begin\*\?{.*}\s*%\s*\zs.*') | ||
| return matchstr(a:line,'\\begin\*\?{.*}\(\[.*\]\)\?\s*%\s*\zs.*') |
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.
I would change \(\[.*\]\)\? to \(\[[^\]]*\]\)\?.
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.
I can't get it to work with the suggestion. What would be the improvement? I copied the regex for detecting the brackets from the \frametitle regex a few lines above this.
35e438c to
17c25ed
Compare
I removed the code for the commented frame titles. I guess if someone comments the frame title its for a good reason, so we should respect this and not show it on the fold. If the title should be shown it can be added as a comment to the
I added a test, but have some trouble with it. The way it's currently set up the test breaks on recognizing the title comment on line 204. If I switch the order of the two added beamer frames and update the test accordingly (line 204 -> 211, 208 -> 204) the test works. Do you have any idea why? As far as I can tell the order of the frames should not have any effect. When I open the latex file in vim the fold texts are shown as expected either way. |
Great!
Huh, this is very strange. For some reason, the But I'll accept this regardless; let's just swap the tests to make them pass and add a comment (e.g. refer to the issue tread). Nice work, thanks! If you are happy with this, then I can probably merge this in a day or two. |
17c25ed to
b51ea21
Compare
|
The test is updated and I think the PR is ready to be merged. Thank you for the great plugin, it has made my life easier for several years now. I'm glad I could make a small contribution :) |
Merging now.
I'm happy to hear it is useful to you! And thanks for your contribution, it is appreciated! |
Hello,
this PR enhances (IMHO) the labels on folded frames in LaTeX beamer documents.
\begin{frame}line. So far the comments where only found if they were separated from the\begin{frame}only by whitespace. Now optional[...]are allowed, as in\begin{frame}[noframenumbering] % Title page.\frametitle()by looking for\framesubtitle()on the following line and, if both are found, displaying them on the fold asframetitle: framesubtitle.frametitle, so that commented outframetitles are found as well. This originally was a workaround for the first commit, but still could be useful.