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: Switch handling of insert (list) environments over to snippets workflow #1330

Merged

Conversation

frlan
Copy link
Member

@frlan frlan commented Apr 21, 2024

This MR migrates the feature to insert any environment over to Geany's snippets workflow. Hence we don't need to bother about indention, like breaks etc. this much anymore. Also due to the cursor-feature it ensures to position the cursor at the right place , independent from the line break, indention etc.

Due to this rework it makes the code also a little more readable and fixes #1071

@frlan frlan requested a review from eht16 April 21, 2024 13:51
@frlan frlan changed the title LaTeX: Switch handling of insert (list) envioronment over to snippets workflow LaTeX: Switch handling of insert (list) environments over to snippets workflow Apr 21, 2024
@frlan frlan force-pushed the 1071-latex-insert-list-environment-with-wrong-indent branch from 906f9c6 to 0192e1c Compare April 21, 2024 13:51
Copy link
Member

@eht16 eht16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

As you know I'm not LaTeX expert and so I'm wondering if it is on purpose that different environments produce quite different stylings:

\begin{block}{}
_
\end{block}

\begin{itemize}
	\item _ 
\end{itemize}

\begin{table}
 _ 
\end{table}

For "table" and "itemize" there is a trailing space after the cursor marker. Is this intended?

"block" uses no indentation at all, "itemize" uses a tab resp. spaces and "table" uses a single space only.

@@ -103,6 +114,7 @@ glatex_insert_string(const gchar *string, gboolean reset_position)

doc = document_get_current();


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this on purpose?

@frlan frlan force-pushed the 1071-latex-insert-list-environment-with-wrong-indent branch 2 times, most recently from 9313b8e to 6728529 Compare April 21, 2024 15:46
@frlan
Copy link
Member Author

frlan commented Apr 24, 2024

Looks good.

As you know I'm not LaTeX expert and so I'm wondering if it is on purpose that different environments produce quite different stylings:

\begin{block}{}
_
\end{block}

\begin{itemize}
	\item _ 
\end{itemize}

\begin{table}
 _ 
\end{table}

For "table" and "itemize" there is a trailing space after the cursor marker. Is this intended?

"block" uses no indentation at all, "itemize" uses a tab resp. spaces and "table" uses a single space only.

This is fixed. I tried to re-sync the indentions

tmpstring = g_strconcat(
"\\begin{",
environment,
"}\n\t\\item %cursor% \n\\end{",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still a trailing space.

@eht16
Copy link
Member

eht16 commented Apr 26, 2024

For "table" and "itemize" there is a trailing space after the cursor marker. Is this intended?
"block" uses no indentation at all, "itemize" uses a tab resp. spaces and "table" uses a single space only.

This is fixed. I tried to re-sync the indentions

I cannot verify as I do not know what is the purposed variant. To me it looks inconsistent:
Screenshot_2024-04-26_18-38-28

More importantly, the rubbisch after the "block" environment is because g_strconcat() must always be NULL-terminated which it is not in the newly added code.

@frlan frlan force-pushed the 1071-latex-insert-list-environment-with-wrong-indent branch from 5fb3c82 to 4ca8faa Compare April 27, 2024 12:04
@eht16
Copy link
Member

eht16 commented Apr 28, 2024

Looks good now.

As said before, I cannot judge whether the result of the snippets is as desired. To me it feels a little confusing that the element in the "itemize" environment is indented while for the other ones the cursor position is not indented.
Maybe it's ok.

@frlan
Copy link
Member Author

frlan commented Apr 28, 2024

In the end it's a little matter of taste, but compare it to HTML's

<ul>
  <li>...</li>
</ul>

and

<body></body>

@frlan frlan merged commit 03f4dbc into geany:master Apr 28, 2024
2 checks passed
@b4n b4n added this to the 2.1.0 milestone Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LaTeX plugin: Keyboard shurtcuts for itemize and enumerate generate wrong result
3 participants