Re: Starting new environment in the middle of a line

2022-11-09 Thread Udicoudco
On Wed, Nov 9, 2022 at 7:16 PM Scott Kostyshak 
wrote:

> Sometimes (but not too often), I want to start an environment in the
> middle of a line.
>
> In LaTeX, it seems to work fine, although I don't know if this is
> considered bad practice. But in LyX, we can only start an environment at
> the beginning of a paragraph I believe.
>

To my knowledge lyx starts  a new line with nested environments in the
latex code, but that should not start a new paragraph, unless the latex
environment   is forcing you to start a new paragraph with \par or a
similar command.


> Attached is an example in LyX that uses ERT. I haven't actually
> implemented this environment in LyX yet (I'm still planning to). Sometimes
> I can use the \uncover command, but other times I prefer an environment.
>
> I also attach an example .tex file with an environment that is implemented
> in LyX (block). I attach the example as a .tex file (example-block.tex),
> and the imported .lyx file (example-block-imported.23.lyx). LyX makes a
> paragraph break and then nests the environment. This causes a linebreak
> that I don't want in the corresponding PDF.
>

I think that the differences in the output PDF are coming from using the
block environment with the non ERT version and the uncover environment in
the file with the ERT (note that also the .tex files produces the same pdf
as example-block-imported.23.lyx)

To check my suspicion I've tried to see if using uncover as a style layout
in lyx will cause this problem. To do so I copied the block layout from the
beamer.layout file to the local layout and changed the style name, latex
name and label name to uncover. see the attached file.

Regards,
Udi

> --
> lyx-devel mailing list
> lyx-devel@lists.lyx.org
> http://lists.lyx.org/mailman/listinfo/lyx-devel
>


example-uncoverenv.23.lyx
Description: application/lyx
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Starting new environment in the middle of a line

2022-11-09 Thread Jürgen Spitzmüller
Am Mittwoch, dem 09.11.2022 um 12:16 -0500 schrieb Scott Kostyshak:
> Am I missing a way to accomplish this in LyX without ERT?

InsetFlex.

-- 
Jürgen
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: A fast mostly collision free hash ?

2022-11-09 Thread Pavel Sanda
On Wed, Nov 09, 2022 at 12:29:49PM +0100, Jean-Marc Lasgouttes wrote:
> Le 08/11/2022 ?? 20:44, Pavel Sanda a écrit :
> >I do not follow what's your problem with QHash? Hash tables are designed too 
> >have
> >collisions from time to time.
> 
> My problem here is that I have a cache
>   [string, screen width] -> [points where to break the string]
> 
> In the example file submitted by Scott in #12598, the string is 500kB long,
> and therefore, this will need to be stored in the cache.
> 
> In general, I will need to store in the cache an amount of data ~equal to
> the document size, and I think it is not really necessary.
> 
> This is why I am looking for a fast and almost-collision-free hash to store
> in the key.
> 
> Is it clearer now ?

I think I understand what you need. What I do not understand why you consider
QHash not good enough for your purposes. "Almost collision-free" is another
name to get amortized complexity of O(1) for insertion/lookup and QHash
is supposed to have it, no?

Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Starting new environment in the middle of a line

2022-11-09 Thread Scott Kostyshak
Sometimes (but not too often), I want to start an environment in the middle of 
a line.

In LaTeX, it seems to work fine, although I don't know if this is considered 
bad practice. But in LyX, we can only start an environment at the beginning of 
a paragraph I believe.

Attached is an example in LyX that uses ERT. I haven't actually implemented 
this environment in LyX yet (I'm still planning to). Sometimes I can use the 
\uncover command, but other times I prefer an environment.

I also attach an example .tex file with an environment that is implemented in 
LyX (block). I attach the example as a .tex file (example-block.tex), and the 
imported .lyx file (example-block-imported.23.lyx). LyX makes a paragraph break 
and then nests the environment. This causes a linebreak that I don't want in 
the corresponding PDF.

Am I missing a way to accomplish this in LyX without ERT?

Are there common use cases for wanting to start an environment in the middle of 
a line?

If we did want to allow this operation in LyX, I wonder if we could make a 
"visual-only line-break" that is a no-op LaTeX. i.e., LyX would paint it as a 
line break but would not output a line break to LaTeX. We would have to think 
of a way to show this "just kidding line break" visually. But would there be 
support for this?

Scott


example-uncoverenv.23.lyx
Description: application/lyx
%% LyX 2.4.0dev created this file.  For more info, see https://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{beamer}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\synctex=-1

\makeatletter
%% Textclass specific LaTeX commands.
% this default might be overridden by plain title style
\newcommand\makebeamertitle{\frame{\maketitle}}%
% (ERT) argument for the TOC
\AtBeginDocument{%
  \let\origtableofcontents=\tableofcontents
  \def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
  \def\gobbletableofcontents#1{\origtableofcontents}
}

\makeatother

\usepackage{babel}
\begin{document}
\begin{frame}
\begin{block}<+->{}
This text on one overlay... \begin{block}<+->{}Then,
\[
xyz=3.
\]
This...
\begin{quote}
Someone said a quote...
\end{quote}
And this...

\end{block}
\end{block}
\end{frame}

\end{document}


example-block-imported.23.lyx
Description: application/lyx
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: A fast mostly collision free hash ?

2022-11-09 Thread Jean-Marc Lasgouttes

Le 08/11/2022 à 23:06, Thibaut Cuvelier a écrit :
Probably, the less fancy option is to use std::hash, available since 
C++11. I have no idea about the quality of the produced hashes, and it 
seems it might really depend on the compiler too.


This seems hazardous.

I can totally understand the need for very unique hashes in this case 
(unlike hash tables). If you want something with unicity guarantees, the 
only meaningful choice is cryptographic hashes: other functions do not 
have the right properties (easy to compute, but no real guarantee with 
small hashes). Something like BLAKE2/3 should be good, performance-wise, 
and it's available in Qt since Qt 6 
(https://doc.qt.io/qt-6/qcryptographichash.html#Algorithm-enum 
); 
otherwise, Keccak since 5.9; or SHA-3 before.


Would SHA1 work? I do not care that it has been proven fragile, I do not 
have an opponent here. At least it also exists in Qt5 (along with md4 
and md5, which re not usable if I understand).


Otherwise, you might consider using several hashes (concatenating them): 
I think it should provide enough entropy to have a very low probability 
of collision, but the hash algorithms must be really different for this 
to be worthwhile. (Just starting with std::hash and the string length, 
then see if more is required?)


Yes, but how do I see that more is required ? Because I have a bug 
report that some particular document is not rendered correctly? I'd 
rather avoid that.


JMarc

--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: A fast mostly collision free hash ?

2022-11-09 Thread Jean-Marc Lasgouttes

Le 08/11/2022 à 20:44, Pavel Sanda a écrit :

I do not follow what's your problem with QHash? Hash tables are designed too 
have
collisions from time to time.


My problem here is that I have a cache
  [string, screen width] -> [points where to break the string]

In the example file submitted by Scott in #12598, the string is 500kB 
long, and therefore, this will need to be stored in the cache.


In general, I will need to store in the cache an amount of data ~equal 
to the document size, and I think it is not really necessary.


This is why I am looking for a fast and almost-collision-free hash to 
store in the key.


Is it clearer now ?

JMarc
--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [PATCH] Semantic Linefeeds

2022-11-09 Thread Jean-Marc Lasgouttes

Le 08/11/2022 à 20:46, Pavel Sanda a écrit :

On Sat, Nov 05, 2022 at 12:12:13PM -0400, Scott Kostyshak wrote:

I know this change "shouldn't" matter when it comes to loading/storing of .lyx
file - but given the severe consequences in case we overlooked something
perhaps we should add fileformat increase & empty lyx2lyx conversion routines
in case we need to do some damage control later?


I'm not against a file format change, but I would guess that the code in
Yuriy's patch would be tweaked after committing to master. e.g., a new
punctuation symbol could be added for other languages. Would we change
the file format for each of those, or just for this one time?


I guess just this one. It's just empty handler for case of some emergency...


This looks good to me.

JMarc

--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/2.3.x] Fix configure script with autoconf 2.71

2022-11-09 Thread Jean-Marc Lasgouttes

Le 08/11/2022 à 23:06, Jean-Marc Lasgouttes a écrit :

commit 9fc89762ee731daa36092c598028e0b95afc69f2
Author: Jean-Marc Lasgouttes 
Date:   Fri Jun 24 13:27:55 2022 +0200

 Fix configure script with autoconf 2.71
 
 Not a backport, but related to e4416535.


Pushing this was not intended, but it will be needed eventually, so I 
propose to keep it for now. I'll revert if anything bad crops up.


JMarc


---
  config/lyxinclude.m4 |2 +-
  config/qt4.m4|2 +-
  m4/eilseq.m4 |   20 ++--
  3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index b5d3ab0..d547662 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -49,7 +49,7 @@ AC_MSG_CHECKING([for version suffix])
  dnl We need the literal double quotes in the rpm spec file
  RPM_VERSION_SUFFIX='""'
  AC_ARG_WITH(version-suffix,
-  [AS_HELP_STRING([--with-version-suffix@<:@=STR@:>@],[install lyx files as 
lyxSTR (default STR: -AC_PACKAGE_VERSION)])],
+  [AS_HELP_STRING([--with-version-suffix@<:@=STR@:>@], install lyx files as 
lyxSTR (default STR: -AC_PACKAGE_VERSION))],
[if test "x$withval" = "xyes";
 then
   withval="-"AC_PACKAGE_VERSION
diff --git a/config/qt4.m4 b/config/qt4.m4
index 47a3d16..0d77b8c 100644
--- a/config/qt4.m4
+++ b/config/qt4.m4
@@ -179,7 +179,7 @@ AC_DEFUN([QT_DO_IT_ALL],
CPPFLAGS="$save_CPPFLAGS $QT_CORE_INCLUDES"
AC_CHECK_HEADER(QtGui/qtgui-config.h,
  [lyx_qt5_config=QtGui/qtgui-config.h],
- [lyx_qt5_config=qconfig.h],[-])
+ [lyx_qt5_config=qconfig.h])
AC_MSG_CHECKING([whether Qt uses the X Window system])
if test x$USE_QT5 = xyes ; then
  AC_EGREP_CPP(xcb,
diff --git a/m4/eilseq.m4 b/m4/eilseq.m4
index 792d514..5f86ab3 100644
--- a/m4/eilseq.m4
+++ b/m4/eilseq.m4
@@ -1,6 +1,6 @@
-#serial 1
+#serial 2
  
-AC_PREREQ(2.50)

+AC_PREREQ([2.61])
  
  # The EILSEQ errno value ought to be defined in , according to

  # ISO C 99 and POSIX.  But some systems (like SunOS 4) don't define it,
@@ -16,20 +16,20 @@ AC_DEFUN([AC_EILSEQ],
AC_REQUIRE([AC_PROG_CC])dnl
  
dnl Check for any extra headers that could define EILSEQ.

-  AC_CHECK_HEADERS(wchar.h)
+  AC_CHECK_HEADERS([wchar.h])
  
-  AC_CACHE_CHECK([for EILSEQ], ac_cv_decl_EILSEQ, [

-AC_EGREP_CPP(yes,[
+  AC_CACHE_CHECK([for EILSEQ], [ac_cv_decl_EILSEQ], [
+AC_EGREP_CPP([yes],[
  #include 
  #ifdef EILSEQ
  yes
  #endif
-  ], have_eilseq=1)
+  ], [have_eilseq=1])
  if test -n "$have_eilseq"; then
dnl EILSEQ exists in . Don't need to define EILSEQ ourselves.
ac_cv_decl_EILSEQ=yes
  else
-  AC_EGREP_CPP(yes,[
+  AC_EGREP_CPP([yes],[
  #include 
  #if HAVE_WCHAR_H
  #include 
@@ -37,11 +37,11 @@ yes
  #ifdef EILSEQ
  yes
  #endif
-], have_eilseq=1)
+], [have_eilseq=1])
if test -n "$have_eilseq"; then
  dnl EILSEQ exists in some other system header.
  dnl Define it to the same value.
-_AC_COMPUTE_INT([EILSEQ], ac_cv_decl_EILSEQ, [
+AC_COMPUTE_INT([ac_cv_decl_EILSEQ], [EILSEQ], [
  #include 
  #if HAVE_WCHAR_H
  #include 
@@ -62,6 +62,6 @@ yes
  AC_DEFINE_UNQUOTED([EILSEQ], [$ac_cv_decl_EILSEQ],
 [Define as good substitute value for EILSEQ.])
  EILSEQ="$ac_cv_decl_EILSEQ"
-AC_SUBST(EILSEQ)
+AC_SUBST([EILSEQ])
fi
  ])


--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Warning in master in C++11 mode

2022-11-09 Thread Jean-Marc Lasgouttes

Hi,

I get this warning when compiling in C++11 mode :

../../master/src/insets/InsetIndex.cpp: In member function ‘virtual void 
lyx::InsetIndex::docbook(lyx::XMLStream&, const lyx::OutputParams&) const’:
../../master/src/insets/InsetIndex.cpp:376:6: warning: init-statement in 
selection statements only available with ‘-std=c++17’ or ‘-std=gnu++17’
  376 |  if (const vector potential_terms = 
getSubentriesAsText(runparams); !potential_terms.empty()) {

  |  ^


Thibaut, can I leave that to you ?

JMarc
--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel