Re: [PATCH] Auto feature for minibuffer toolbar

2015-07-01 Thread Jean-Marc Lasgouttes

Le 01/07/2015 12:02, Kornel Benko a écrit :

Looking at the code, the Toolbars part should work. What is the problem?


The problem is, that there is no such extra user ui file.


Just create your test.ui or xxdefaults.ui that contains

===
Format 2

Include default.ui


Toolbars
minibuffer on,bottom
End
===

This should just work, IMO.

JMarc


Re: [PATCH] Auto feature for minibuffer toolbar

2015-07-01 Thread Kornel Benko
Am Mittwoch, 1. Juli 2015 um 10:57:59, schrieb Jean-Marc Lasgouttes 
lasgout...@lyx.org
 Le 30/06/2015 11:32, Kornel Benko a écrit :
  I'll think about it. You can also have a working environment where the
  minibuffer toolbar is not auto but on. This supposedly works.
 
  I could not find a way to do it. Where is the information about the 
  minibuffer toolbar
  stored? I could not find it neither in preferences nor in session file.
 
 The toolbars initial state is defined in lib/ui/default.ui. You could 
 have a testing.ui file that provides the right settings for you.

Thanks, after examining the patch, I already found it. But the lack of a 
preference entry
makes it so un-handy.
We need something which could extend the default.ui.

Say it has the content
...
Toolbars
minibuffer auto,off,bottom
End
Toolbar extra Extra
Item Set language slovak language slovak
End
...

This would overwrite only the minibuffer entry in defaults.ui and add the 
Item to the 'Extra' toolbar from stdtoolbars.inc.

ATM, I had to create own xxdefaults.ui as a replacement of default.ui.
If default.ui or stdtoolbars.inc changes (which sometimes happens), I have to 
adapt the replacement files appropriately.


 How do tests work? Do you have your own userdir with the right 
 configuration files? This is what I would do personally.

Yes, own userdir.

Also the tests (called with 'ctest ...') have their own userdir in 
build-dir/Testing/.lyx, so they don't interfere
with any other lyx installation.

Kornel


signature.asc
Description: This is a digitally signed message part.


Re: [PATCH] Auto feature for minibuffer toolbar

2015-07-01 Thread Jean-Marc Lasgouttes

Le 01/07/2015 11:34, Kornel Benko a écrit :

Thanks, after examining the patch, I already found it. But the lack of a 
preference entry
makes it so un-handy.
We need something which could extend the default.ui.

Say it has the content
...
Toolbars
minibuffer auto,off,bottom
End
Toolbar extra Extra
Item Set language slovak language slovak
End
...

This would overwrite only the minibuffer entry in defaults.ui and add the 
Item to the 'Extra' toolbar from stdtoolbars.inc.


Looking at the code, the Toolbars part should work. What is the problem?

JMarc


Re: false positive in test for unencodable preamble

2015-07-01 Thread Jürgen Spitzmüller
2015-06-29 13:26 GMT+02:00 Guenter Milde mi...@users.sf.net:

 Similarily, all text parts in a comment are uncritical if the file is
 processed by TeX, because comments are not decoded at all.


But LyX cannot convert this to the target encoding and thus fails. Silently
removing the glyphs without giving a warning is no option, IMHO. We cannot
remove data without asking.

See attached file (try to view PDF with LyX 2.1.x).

Jürgen


enc.lyx
Description: application/lyx


Re: [PATCH] Auto feature for minibuffer toolbar

2015-07-01 Thread Kornel Benko
Am Mittwoch, 1. Juli 2015 um 12:31:11, schrieb Jean-Marc Lasgouttes 
lasgout...@lyx.org
 Le 01/07/2015 12:02, Kornel Benko a écrit :
  Looking at the code, the Toolbars part should work. What is the problem?
 
  The problem is, that there is no such extra user ui file.
 
 Just create your test.ui or xxdefaults.ui that contains
 
 ===
 Format 2
 
 Include default.ui
 
 
 Toolbars
   minibuffer on,bottom
 End
 ===
 
 This should just work, IMO.
 

With respect to 'minibuffer' I am with you.

The other probably deserves different subject.

Kornel

signature.asc
Description: This is a digitally signed message part.


Re: [PATCH] Auto feature for minibuffer toolbar

2015-07-01 Thread Kornel Benko
Am Mittwoch, 1. Juli 2015 um 11:47:33, schrieb Jean-Marc Lasgouttes 
lasgout...@lyx.org
 Le 01/07/2015 11:34, Kornel Benko a écrit :
  Thanks, after examining the patch, I already found it. But the lack of a 
  preference entry
  makes it so un-handy.
  We need something which could extend the default.ui.
 
  Say it has the content
  ...
  Toolbars
  minibuffer auto,off,bottom
  End
  Toolbar extra Extra
  Item Set language slovak language slovak
  End
  ...
 
  This would overwrite only the minibuffer entry in defaults.ui and add the 
  Item to the 'Extra' toolbar from stdtoolbars.inc.
 
 Looking at the code, the Toolbars part should work. What is the problem?

The problem is, that there is no such extra user ui file.

 JMarc

Kornel

signature.asc
Description: This is a digitally signed message part.


Re: [Patch] Two lyxpak bugs

2015-07-01 Thread Guy Rutenberg
Hi Enrico,

Thanks for your feed back.

Sorry, but I cannot reproduce this problem. The file names are already
 utf-8 encoded as they are extracted form the LyX file and the created
 zip file seems to be OK. I attach here an example zip file created with
 lyxpak.py (it is inside a tar archive to avoid problems with mail agents).
 Although when listed the file names in the zip file may appear as mangled,
 they are actually extracted just fine:


I indeed found bugs in the patch I submitted, but for some reason the mail
I sent to the mailing list seems like it wasn't delivered (I hope this one
gets through).

There was a problem in the old patch with handling filesystems where  the
filesystem's encoding is not UTF-8.The problem occurs because in the .lyx
file, the filenames are stored as UTF-8, while the filesystem may use a
different one. For example, Windows uses mbsc. The attached modified
patch addresses these issues. Also by using the arcname argument, the zip
file it produces list the files correctly.

For example, file listing without the patch

Path = בדיקה.zip
Type = zip
Physical Size = 966

   Date  TimeAttr Size   Compressed  Name
--- -  

2015-07-01 21:59:40 . 1634  738  §×.lyx
2015-07-01 21:59:04 .02  ק×××¥.tex
--- -  

  1634  740  2 files, 0 folders

And with the patch

Path = בדיקה.zip
Type = zip
Physical Size = 966

   Date  TimeAttr Size   Compressed  Name
--- -  

2015-07-01 21:59:40 . 1634  738  בדיקה.lyx
2015-07-01 21:59:04 .02  קובץ.tex
--- -  

  1634  740  2 files, 0 folders


The proposed patch should also work with non UTF-8 filesystems (I did
limited testing on a windows 7 machine).

Regarding the first patch.

In your patch you unconditionally strip the last path component, which is
 wrong. Although the case you describe is rare, it may nonetheless happen,
 but the attached 01 patch should suffice. Please, report back whether it
 works for you.


The proposed change still fails when the last prefix bit is a valid
directory.

For example consider the following layout

lyx_file.lyx
lyx_included.tex
lyx_/

Where lyx_file.lyx includes lyx_included.tex. The common prefix will be
lyx_, which is a valid directory, hence the proposed check in your patch
pass, but afterwords, it won't be able to locate the files.

My patch indeed strips the last path component, but I'm pretty sure that
the part that gets removed in never the common parent directory. For
example consider the following cases

some_dir/lyx_file.lyx
some_dir/lyx_included.lyx

The common prefix will be some_dir/lyx_. The lyx_ part will indeed be
removed, and the result will be some_dir/, like it should.

some_dir/lyx_file.lyx
some_dir/tex_file.lyx

The common prefix will be some_dir/ and because the / is part of the
common prefix, some_dir/ will also be the result of the truncation and
the appending of os.path.sep.

Furthermore, consider the following edge case where the common prefix is
/. We have
In [6]: os.path.dirname('/') + os.path.sep
Out[6]: '//'

In [7]: /.rpartition(os.path.sep)[0] + os.path.sep
Out[7]: '/'

This shows that the original lyxpak.py (and I believe your patch as well)
will get topdir to be // instead of /, which means that the string
replacement in

while i  len(incfiles):
incfiles[i] = string.replace(incfiles[i], topdir, '', 1)
i += 1

will fail.

Enrico, did you find a use case where my patch results in the wrong
behaviour? I might be missing some edge-case myself which I be happy to fix.

Thanks a lot for your guidance and remarks.

Regards,

Guy
From 249d30e46b24b92b8e5823e72f8322539620c780 Mon Sep 17 00:00:00 2001
From: Guy Rutenberg guyrutenb...@gmail.com
Date: Fri, 26 Jun 2015 19:54:34 +0300
Subject: [PATCH] lyxpak: Fix filename encoding in zip export.

By default Python's zipfile module stores files in the CP437 encoding.
This can create unreadable filenames on some systems. However, if one
passes `arcname` as a unicode object, a utf-8 representation of the
filename is kept.

Moreover, LyX's internal filename representation is UTF-8, which may
differ from the filesystem's encoding. This may lead to problems
including files which have foreign characters in their names. The patch
fixes this issue.
---
 lib/scripts/lyxpak.py |   17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/scripts/lyxpak.py b/lib/scripts/lyxpak.py
index cc1bdfd..f085b28 100755
--- a/lib/scripts/lyxpak.py
+++ b/lib/scripts/lyxpak.py
@@ -87,6 +87,9 @@ def abspath(name):
 newname = 

Re: #9659: lyx crash when exited from dock

2015-07-01 Thread Stephan Witt
I'd like to change the very old assert in GuiApplication::unregisterView.
It causes a crash on Mac as described below. I don't know if this may happen
on other platforms too. Anyway, does anyone has a better proposal to solve
this problem? A patch is attached.

Stephan

Am 02.07.2015 um 00:28 schrieb LyX Ticket Tracker t...@lyx.org:

 #9659: lyx crash when exited from dock
 -+---
 Reporter:  HongshengHe  |   Owner:  stwitt
 Type:  defect   |  Status:  accepted
 Priority:  high |   Milestone:  2.2.0
 Component:  general  | Version:  2.2.0dev
 Severity:  critical |  Resolution:
 Keywords:  os=macosx,crash  |
 -+---
 
 Comment (by stwitt):
 
 I've read the Qt-code for Mac in QCocoaApplicationDelegate method
 {{{applicationShouldTerminate}}}. It checks in {{{canQuit}}} if the
 application is ready to terminate by sending a close event. If this
 returns true it calls {{{close}}} for the main window. This way the event is
 sent twice and the crash is determined.
 
 -- 
 Ticket URL: http://www.lyx.org/trac/ticket/9659#comment:7
 The LyX Project http://www.lyx.org/
 LyX -- The Document Processor



ticket-9659-b.patch
Description: Binary data


Re: [PATCH] Auto feature for minibuffer toolbar

2015-07-01 Thread Kornel Benko
Am Mittwoch, 1. Juli 2015 um 10:57:59, schrieb Jean-Marc Lasgouttes 

> Le 30/06/2015 11:32, Kornel Benko a écrit :
> >> I'll think about it. You can also have a working environment where the
> >> minibuffer toolbar is not auto but on. This supposedly works.
> >
> > I could not find a way to do it. Where is the information about the 
> > minibuffer toolbar
> > stored? I could not find it neither in preferences nor in session file.
> 
> The toolbars initial state is defined in lib/ui/default.ui. You could 
> have a testing.ui file that provides the right settings for you.

Thanks, after examining the patch, I already found it. But the lack of a 
preference entry
makes it so un-handy.
We need something which could extend the default.ui.

Say it has the content
...
Toolbars
"minibuffer" "auto,off,bottom"
End
Toolbar "extra" "Extra"
Item "Set language slovak" "language slovak"
End
...

This would overwrite only the "minibuffer" entry in defaults.ui and add the 
Item to the 'Extra' toolbar from stdtoolbars.inc.

ATM, I had to create own xxdefaults.ui as a replacement of default.ui.
If default.ui or stdtoolbars.inc changes (which sometimes happens), I have to 
adapt the replacement files appropriately.


> How do tests work? Do you have your own userdir with the right 
> configuration files? This is what I would do personally.

Yes, own userdir.

Also the tests (called with 'ctest ...') have their own userdir in 
/Testing/.lyx, so they don't interfere
with any other lyx installation.

Kornel


signature.asc
Description: This is a digitally signed message part.


Re: false positive in test for unencodable preamble

2015-07-01 Thread Jürgen Spitzmüller
2015-06-29 13:26 GMT+02:00 Guenter Milde :

> Similarily, all text parts in a comment are uncritical if the file is
> processed by TeX, because comments are not decoded at all.
>

But LyX cannot convert this to the target encoding and thus fails. Silently
removing the glyphs without giving a warning is no option, IMHO. We cannot
remove data without asking.

See attached file (try to view PDF with LyX 2.1.x).

Jürgen


enc.lyx
Description: application/lyx


Re: [PATCH] Auto feature for minibuffer toolbar

2015-07-01 Thread Jean-Marc Lasgouttes

Le 01/07/2015 11:34, Kornel Benko a écrit :

Thanks, after examining the patch, I already found it. But the lack of a 
preference entry
makes it so un-handy.
We need something which could extend the default.ui.

Say it has the content
...
Toolbars
"minibuffer" "auto,off,bottom"
End
Toolbar "extra" "Extra"
Item "Set language slovak" "language slovak"
End
...

This would overwrite only the "minibuffer" entry in defaults.ui and add the 
Item to the 'Extra' toolbar from stdtoolbars.inc.


Looking at the code, the Toolbars part should work. What is the problem?

JMarc


Re: [PATCH] Auto feature for minibuffer toolbar

2015-07-01 Thread Kornel Benko
Am Mittwoch, 1. Juli 2015 um 11:47:33, schrieb Jean-Marc Lasgouttes 

> Le 01/07/2015 11:34, Kornel Benko a écrit :
> > Thanks, after examining the patch, I already found it. But the lack of a 
> > preference entry
> > makes it so un-handy.
> > We need something which could extend the default.ui.
> >
> > Say it has the content
> > ...
> > Toolbars
> > "minibuffer" "auto,off,bottom"
> > End
> > Toolbar "extra" "Extra"
> > Item "Set language slovak" "language slovak"
> > End
> > ...
> >
> > This would overwrite only the "minibuffer" entry in defaults.ui and add the 
> > Item to the 'Extra' toolbar from stdtoolbars.inc.
> 
> Looking at the code, the Toolbars part should work. What is the problem?

The problem is, that there is no such extra user ui file.

> JMarc

Kornel

signature.asc
Description: This is a digitally signed message part.


Re: [PATCH] Auto feature for minibuffer toolbar

2015-07-01 Thread Jean-Marc Lasgouttes

Le 01/07/2015 12:02, Kornel Benko a écrit :

Looking at the code, the Toolbars part should work. What is the problem?


The problem is, that there is no such extra user ui file.


Just create your test.ui or xxdefaults.ui that contains

===
Format 2

Include "default.ui"


Toolbars
"minibuffer" "on,bottom"
End
===

This should just work, IMO.

JMarc


Re: [PATCH] Auto feature for minibuffer toolbar

2015-07-01 Thread Kornel Benko
Am Mittwoch, 1. Juli 2015 um 12:31:11, schrieb Jean-Marc Lasgouttes 

> Le 01/07/2015 12:02, Kornel Benko a écrit :
> >> Looking at the code, the Toolbars part should work. What is the problem?
> >
> > The problem is, that there is no such extra user ui file.
> 
> Just create your test.ui or xxdefaults.ui that contains
> 
> ===
> Format 2
> 
> Include "default.ui"
> 
> 
> Toolbars
>   "minibuffer" "on,bottom"
> End
> ===
> 
> This should just work, IMO.
> 

With respect to 'minibuffer' I am with you.

The other probably deserves different subject.

Kornel

signature.asc
Description: This is a digitally signed message part.


Re: [Patch] Two lyxpak bugs

2015-07-01 Thread Guy Rutenberg
Hi Enrico,

Thanks for your feed back.

Sorry, but I cannot reproduce this problem. The file names are already
> utf-8 encoded as they are extracted form the LyX file and the created
> zip file seems to be OK. I attach here an example zip file created with
> lyxpak.py (it is inside a tar archive to avoid problems with mail agents).
> Although when listed the file names in the zip file may appear as mangled,
> they are actually extracted just fine:
>

I indeed found bugs in the patch I submitted, but for some reason the mail
I sent to the mailing list seems like it wasn't delivered (I hope this one
gets through).

There was a problem in the old patch with handling filesystems where  the
filesystem's encoding is not UTF-8.The problem occurs because in the .lyx
file, the filenames are stored as UTF-8, while the filesystem may use a
different one. For example, Windows uses "mbsc". The attached modified
patch addresses these issues. Also by using the "arcname" argument, the zip
file it produces list the files correctly.

For example, file listing without the patch

Path = בדיקה.zip
Type = zip
Physical Size = 966

   Date  TimeAttr Size   Compressed  Name
--- -  

2015-07-01 21:59:40 . 1634  738  §×.lyx
2015-07-01 21:59:04 .02  ק×××¥.tex
--- -  

  1634  740  2 files, 0 folders

And with the patch

Path = בדיקה.zip
Type = zip
Physical Size = 966

   Date  TimeAttr Size   Compressed  Name
--- -  

2015-07-01 21:59:40 . 1634  738  בדיקה.lyx
2015-07-01 21:59:04 .02  קובץ.tex
--- -  

  1634  740  2 files, 0 folders


The proposed patch should also work with non UTF-8 filesystems (I did
limited testing on a windows 7 machine).

Regarding the first patch.

In your patch you unconditionally strip the last path component, which is
> wrong. Although the case you describe is rare, it may nonetheless happen,
> but the attached 01 patch should suffice. Please, report back whether it
> works for you.
>

The proposed change still fails when the last prefix bit is a valid
directory.

For example consider the following layout

lyx_file.lyx
lyx_included.tex
lyx_/

Where lyx_file.lyx includes lyx_included.tex. The common prefix will be
"lyx_", which is a valid directory, hence the proposed check in your patch
pass, but afterwords, it won't be able to locate the files.

My patch indeed strips the last path component, but I'm pretty sure that
the part that gets removed in never the common parent directory. For
example consider the following cases

some_dir/lyx_file.lyx
some_dir/lyx_included.lyx

The common prefix will be "some_dir/lyx_". The "lyx_" part will indeed be
removed, and the result will be "some_dir/", like it should.

some_dir/lyx_file.lyx
some_dir/tex_file.lyx

The common prefix will be "some_dir/" and because the "/" is part of the
common prefix, "some_dir/" will also be the result of the truncation and
the appending of os.path.sep.

Furthermore, consider the following edge case where the common prefix is
"/". We have
In [6]: os.path.dirname('/') + os.path.sep
Out[6]: '//'

In [7]: "/".rpartition(os.path.sep)[0] + os.path.sep
Out[7]: '/'

This shows that the original lyxpak.py (and I believe your patch as well)
will get topdir to be "//" instead of "/", which means that the string
replacement in

while i < len(incfiles):
incfiles[i] = string.replace(incfiles[i], topdir, '', 1)
i += 1

will fail.

Enrico, did you find a use case where my patch results in the wrong
behaviour? I might be missing some edge-case myself which I be happy to fix.

Thanks a lot for your guidance and remarks.

Regards,

Guy
From 249d30e46b24b92b8e5823e72f8322539620c780 Mon Sep 17 00:00:00 2001
From: Guy Rutenberg 
Date: Fri, 26 Jun 2015 19:54:34 +0300
Subject: [PATCH] lyxpak: Fix filename encoding in zip export.

By default Python's zipfile module stores files in the CP437 encoding.
This can create unreadable filenames on some systems. However, if one
passes `arcname` as a unicode object, a utf-8 representation of the
filename is kept.

Moreover, LyX's internal filename representation is UTF-8, which may
differ from the filesystem's encoding. This may lead to problems
including files which have foreign characters in their names. The patch
fixes this issue.
---
 lib/scripts/lyxpak.py |   17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/scripts/lyxpak.py b/lib/scripts/lyxpak.py
index cc1bdfd..f085b28 100755
--- a/lib/scripts/lyxpak.py
+++ b/lib/scripts/lyxpak.py
@@ -87,6 +87,9 @@ def 

Re: #9659: lyx crash when exited from dock

2015-07-01 Thread Stephan Witt
I'd like to change the very old assert in GuiApplication::unregisterView.
It causes a crash on Mac as described below. I don't know if this may happen
on other platforms too. Anyway, does anyone has a better proposal to solve
this problem? A patch is attached.

Stephan

Am 02.07.2015 um 00:28 schrieb LyX Ticket Tracker :

> #9659: lyx crash when exited from dock
> -+---
> Reporter:  HongshengHe  |   Owner:  stwitt
> Type:  defect   |  Status:  accepted
> Priority:  high |   Milestone:  2.2.0
> Component:  general  | Version:  2.2.0dev
> Severity:  critical |  Resolution:
> Keywords:  os=macosx,crash  |
> -+---
> 
> Comment (by stwitt):
> 
> I've read the Qt-code for Mac in QCocoaApplicationDelegate method
> {{{applicationShouldTerminate}}}. It checks in {{{canQuit}}} if the
> application is ready to terminate by sending a close event. If this
> returns true it calls {{{close}}} for the main window. This way the event is
> sent twice and the crash is determined.
> 
> -- 
> Ticket URL: 
> The LyX Project 
> LyX -- The Document Processor



ticket-9659-b.patch
Description: Binary data