Re: Forward/reverse searching problems under Windows (The Sequel)

2011-05-30 Thread Christopher Menzel
On 05/25/2011 4:16 PM, Enrico Forestieri wrote:
> Enrico Forestieri writes:
> 
>> So, can anyone compiling LyX with MSVC perform that check?
> 
> It turned out to be an issue with the MSVC compiler and should be fixed
> in the next release. 

Wow, thanks for all the time and effort you put into this.  I really
appreciate it.

> In the meantime, Windows users needing to perform a dvi forward search
> can workaround it by first generating a pdf and *then* previewing as
> dvi.

Yes, that works.  Thanks very much.

-chris



Re: Forward/reverse searching problems under Windows (The Sequel)

2011-05-25 Thread Enrico Forestieri
Enrico Forestieri writes:

> So, can anyone compiling LyX with MSVC perform that check?

It turned out to be an issue with the MSVC compiler and should be fixed
in the next release. In the meantime, Windows users needing to perform a
dvi forward search can workaround it by first generating a pdf and *then*
previewing as dvi.

-- 
Enrico



Re: Forward/reverse searching problems under Windows (The Sequel)

2011-05-24 Thread Enrico Forestieri
Christopher Menzel writes:
> 
> On May 23, 2011, at 3:33 PM, Enrico Forestieri wrote:
> > Christopher Menzel writes:
> >> 
> >> That is, LyX is calling the appropriate forward search command for a PDF
> >> preview document, not DVI.
> > 
> > LyX performs a forward search for the last generated format, so it means
> > that you generated a pdf after the dvi, even if you quitted the pdf viewer
> > and are now previewing the dvi.
> 
> Sorry, I guess I'm confused about the semantics of "generating a format"
> versus "previewing". What more do I have to do to "generate a format"
> beyond previewing?

If you hit the "update" button, a given format is generated (produced)
in the temp dir, but a previewer is not started.

>  From the documentation it appears that all I should
> have to do is generate a dvi preview:
> 
>Forward search works both with DVI and PDF output. LyX simply
>checks which preview format you have used before (i.e., which
>format is already there in the temporary directory) and chooses
>the appropriate configuration for the respective format.
> 
> I have done that; the only thing in the Temp directory is a DVI file
> for my document. There is no sign of any PDF. 

So, let's see whether we can solve this mystery by looking at the code.
The following is the relevant snippet in src/frontends/qt4/GuiView.cpp:

if (!dviname.exists() && !pdfname.exists()) {
dr.setMessage(_("Please, preview the document first."));
break;
}
string outname = dviname.onlyFileName();
string command = lyxrc.forward_search_dvi;
if (!dviname.exists() ||
pdfname.lastModified() > dviname.lastModified()) {
outname = pdfname.onlyFileName();
command = lyxrc.forward_search_pdf;
}

Firstly, LyX checks whether a dvi or pdf was generated. If not, the message
"Please, preview the document first." is issued.
Then, LyX assumes that you generated a dvi, but if no dvi exists or the
pdf is newer than the dvi, a pdf format is assumed.
Note that if no pdf exists, pdfname.lastModified() returns -1 and the
check pdfname.lastModified() > dviname.lastModified() is never true.
Thus, if no pdf exists a dvi forward search is always attempted.

Anyway, you say that a pdf search is tried, even if no pdf is in sight.
Let's se how that could happen. The lastModified() method returns a time_t
type, which is a signed type on all machines and compilers I have access to.
However, I don't have access to the MSVC compiler, which is the one used
for the Windows version you are using, most probably. I am able to compile
a Windows version with the MinGW compiler, and there it works.

So, the only way that a pdf search could be attempted is if the time_t type
is an unsigned type for the MSVC compiler. Indeed, in that case, the -1
would be interpreted as the greatest possible value and the check
pdfname.lastModified() > dviname.lastModified() would be always true.
I have no way to check that and someone building LyX with MSVC should
perform that test. It would suffice adding the line

   lyxerr << "pdf: " << pdfname.lastModified() << endl;

just before that snippet, trying a forward search with only a dvi generated
and looking at what is printed. If the result is

pdf: -1

the mystery remains unsolved (I always get that), but if it prints something
like

pdf: 2147483647

we found the bug.

So, can anyone compiling LyX with MSVC perform that check?

-- 
Enrico



Re: Forward/reverse searching problems under Windows (The Sequel)

2011-05-24 Thread Christopher Menzel
On May 23, 2011, at 3:33 PM, Enrico Forestieri wrote:
> Christopher Menzel writes:
>> 
>> That is, LyX is calling the appropriate forward search command for a PDF
>> preview document, not DVI.
> 
> LyX performs a forward search for the last generated format, so it means
> that you generated a pdf after the dvi, even if you quitted the pdf viewer
> and are now previewing the dvi.

Sorry, I guess I'm confused about the semantics of "generating a format" versus 
"previewing". What more do I have to do to "generate a format" beyond 
previewing?  From the documentation it appears that all I should have to do is 
generate a dvi preview:

   Forward search works both with DVI and PDF output. LyX simply
   checks which preview format you have used before (i.e., which
   format is already there in the temporary directory) and chooses
   the appropriate configuration for the respective format.

I have done that; the only thing in the Temp directory is a DVI file for my 
document. There is no sign of any PDF.  How do I "generate a formate" to tell 
LyX I'm using DVI now?

Thanks for your patience.

Chris Menzel



Re: Forward/reverse searching problems under Windows (The Sequel)

2011-05-23 Thread Enrico Forestieri
Christopher Menzel writes:
> 
> That is, LyX is calling the appropriate forward search command for a PDF
> preview document, not DVI.

LyX performs a forward search for the last generated format, so it means
that you generated a pdf after the dvi, even if you quitted the pdf viewer
and are now previewing the dvi.

-- 
Enrico



Re: Forward/reverse searching problems under Windows (The Sequel)

2011-05-23 Thread Christopher Menzel
On 05/22/2011 8:59 PM, Christopher Menzel wrote:
> On 22/05/2011 7:07 PM, Christopher Menzel wrote:
>> ...Yes, yes, that is exactly what I was looking for.  The relevant
>> debugging output appears to be this:
>>
>> ...
>> The row information is indeed there.  I do not know enough about LyX's
>> internals to figure out from the rest of it why the forward search is
>> still failing.
> 
> Whoops, hang on, I had been doing a bit of experimenting with PDF output
> and had deleted entry for a DVI viewer in Preferences -> Output ->
> General.  I've put the command for Yap back in and now, well, forward
> search is now working.  I am certain I had selected the built-in Yap
> command when it was first failing, as I checked and double-checked
> against the instructions, but perhaps I just had some sort of blind spot
> (or, as I shall choose to believe, I inadvertently fixed something :-) .

OK, things still aren't quite right but I think I've uncovered what
might be the problem.  As I note above, when I first set things up, I
was certain I had selected the supplied Yap command for Preferences ->
Output -> General.  However, since I was only using Yap, I left the
field for the PDF viewer blank.  This led to the "Couldn't proceed"
message when I invoked Forward Search.  I have since added the supplied
viewer command for SumatraPDF, even though I am only previewing with
DVI, and now when I invoke Forward Search, I see the following error
message:

13:00:31.093: The process failed to start. Either the invoked program is
missing, or you may have insufficient permissions to invoke the
program...\..\..\lyx-2.0.0\src\support\Systemcall.cpp(217): Systemcall:
'CMCDDE SUMATRA control
[ForwardSearch("""Recombination.pdf""","""Recombination.tex""",84,0,0,1)]'
did not start!
..\..\..\lyx-2.0.0\src\support\Systemcall.cpp(218): error The process
failed to start. Either the invoked program is missing, or you may have
insufficient permissions

That is, LyX is calling the appropriate forward search command for a PDF
preview document, not DVI.  According to the documentation, this should
not be happening:

  Forward search works both with DVI and PDF output. LyX simply
  checks which preview format you have used before (i.e., which
  format is already there in the temporary directory) and chooses
  the appropriate configuration for the respective format.

I have checked the Temp directory LyX is using for my current document
and there are no signs that I am using PDF there; there are only the
output files you expect from using the latex command to generate a DVI
file. I'm not sure why forward search started working properly for me
last night -- something happened to enable LyX correctly to realize that
I was doing a DVI preview -- but pretty clearly its invoking the forward
search command appropriate for PDF instead of DVI is the reason why it
wasn't working for me before and is not working again now. (The problem
arises whether or not I use the synctex option.)

Suggestions, as always, much appreciated.

Chris Menzel


Re: Forward/reverse searching problems under Windows

2011-05-22 Thread Christopher Menzel
On 22/05/2011 7:07 PM, Christopher Menzel wrote:
> ...Yes, yes, that is exactly what I was looking for.  The relevant
> debugging output appears to be this:
> 
> ...
> The row information is indeed there.  I do not know enough about LyX's
> internals to figure out from the rest of it why the forward search is
> still failing.

Whoops, hang on, I had been doing a bit of experimenting with PDF output
and had deleted entry for a DVI viewer in Preferences -> Output ->
General.  I've put the command for Yap back in and now, well, forward
search is now working.  I am certain I had selected the built-in Yap
command when it was first failing, as I checked and double-checked
against the instructions, but perhaps I just had some sort of blind spot
(or, as I shall choose to believe, I inadvertently fixed something :-) .

Thanks for your time.

-chris


Re: Forward/reverse searching problems under Windows

2011-05-22 Thread Christopher Menzel
On 22/05/2011 6:07 PM, Enrico Forestieri wrote:
> Christopher Menzel writes:
>> 
>> Well, as I noted, I followed the instructions in the Additional
>> Features document assiduously, so one of the first things I did
>> was to choose the default command for the Yap previewer under
>> Preferences->Output->General.  The default setting -- yap -1
>> -s "$$n $$t" $$o -- leads to the "Couldn't proceed" message. And,
>> although the MiKTeX bin directory is in my PATH, I have also tried
>> using a fully qualified path to yap.exe and I still get the
>> message in question. Any other possibilities you can think of?
> 
> That message is only printed either if the forward search command is
> not defined or LyX is not able to map the cursor position to a row in
> the LaTeX file. The relevant code is the following:
> 
> int row = doc_buffer->texrow().getRowFromIdPos(
>bv->cursor().paragraph().id(), bv->cursor().pos());
> LYXERR(Debug::ACTION, "Forward search: row:" << row
> << " id:" << bv->cursor().paragraph().id());
> if (!row || command.empty()) {
>   dr.setMessage(_("Couldn't proceed."));
> break;
> }
> 
> So, if your command is not empty, we are left with the second option.
> As you can see, using "-dbg action", one is also informed about what
> row in the LaTeX file is mapped to the paragraph where the cursor in
> LyX currently is. Thus, the next thing to try is using -dbg action
> and look in the output for the "Forward search: row: ... id: ..."
> message. If row turns out to be zero, then that's the reason for the
> failure.
> 
>> And, again, is there anything analogous to the Unix /var/log
>> directory under Windows where I might be able to examine a log
>> file for clues?
> 
> I don't think something similar exists in Windows.
> 
>>  Oh, also, can you (or anyone) tell me how to run
>> LyX under Windows from the command line with debugging on?  I
>> figure that might yield a clue or two as well but I haven't been
>> able to figure out how to do that; it doesn't seem to be a simple
>> matter of calling the .exe file with the -dbg option.
> 
> If you are using one of the installers and not compiling LyX by yourself,
> that is not going to work because I think that they compile LyX as a GUI
> application, such that there's no standard input and output.
> However, you can use the messages window (View->View messages) and set
> there the wanted debug level (I think that "-dbg action" corresponds to
> the "User commands" debug level).

Yes, yes, that is exactly what I was looking for.  The relevant
debugging output appears to be this:

19:01:53.867: Couldn't proceed.
(forward-search)..\..\..\..\lyx-2.0.0\src\frontends\qt4\GuiWorkArea.cpp(747):
GuiWorkArea::focusInEvent(): 0A75D610

..\..\..\..\lyx-2.0.0\src\frontends\qt4\GuiApplication.cpp(1269): cmd:
..\..\..\..\lyx-2.0.0\src\frontends\qt4\GuiView.cpp(3539): Forward
search: row:106 id:93
..\..\lyx-2.0.0\src\BufferView.cpp(422):
BufferView::processUpdateFlags()[fitcursor = 0, forceupdate = 0,
singlepar = 0]  buffer: 034CA8A8
..\..\lyx-2.0.0\src\Buffer.cpp(2876): updateMacro of Recombination.lyx
..\..\..\..\lyx-2.0.0\src\frontends\qt4\LayoutBox.cpp(545): Already had
Standard selected.
..\..\..\..\lyx-2.0.0\src\frontends\qt4\GuiApplication.cpp(1085):
verbose dispatch msg Couldn't proceed. (forward-search)

The row information is indeed there.  I do not know enough about LyX's
internals to figure out from the rest of it why the forward search is
still failing.

-chris



Re: Forward/reverse searching problems under Windows

2011-05-22 Thread Enrico Forestieri
Christopher Menzel writes:
> 
> Well, as I noted, I followed the instructions in the Additional
> Features document assiduously, so one of the first things I did
> was to choose the default command for the Yap previewer under
> Preferences->Output->General.  The default setting -- yap -1
> -s "$$n $$t" $$o -- leads to the "Couldn't proceed" message. And,
> although the MiKTeX bin directory is in my PATH, I have also tried
> using a fully qualified path to yap.exe and I still get the
> message in question. Any other possibilities you can think of?

That message is only printed either if the forward search command is
not defined or LyX is not able to map the cursor position to a row in
the LaTeX file. The relevant code is the following:

int row = doc_buffer->texrow().getRowFromIdPos(
   bv->cursor().paragraph().id(), bv->cursor().pos());
LYXERR(Debug::ACTION, "Forward search: row:" << row
<< " id:" << bv->cursor().paragraph().id());
if (!row || command.empty()) {
dr.setMessage(_("Couldn't proceed."));
break;
}

So, if your command is not empty, we are left with the second option.
As you can see, using "-dbg action", one is also informed about what
row in the LaTeX file is mapped to the paragraph where the cursor in
LyX currently is. Thus, the next thing to try is using -dbg action
and look in the output for the "Forward search: row: ... id: ..."
message. If row turns out to be zero, then that's the reason for the
failure.

> And, again, is there anything analogous to the Unix /var/log
> directory under Windows where I might be able to examine a log
> file for clues?

I don't think something similar exists in Windows.

> Oh, also, can you (or anyone) tell me how to run
> LyX under Windows from the command line with debugging on?  I
> figure that might yield a clue or two as well but I haven't been
> able to figure out how to do that; it doesn't seem to be a simple
> matter of calling the .exe file with the -dbg option.

If you are using one of the installers and not compiling LyX by yourself,
that is not going to work because I think that they compile LyX as a GUI
application, such that there's no standard input and output.
However, you can use the messages window (View->View messages) and set
there the wanted debug level (I think that "-dbg action" corresponds to
the "User commands" debug level).
If you are familiar with the Unix world, maybe you could try the Cygwin
version, which behaves as one expects when using the command line.




Re: Forward/reverse searching problems under Windows

2011-05-22 Thread Christopher Menzel
On May 22, 2011, at 12:15 AM, Enrico Forestieri wrote:
> Christopher Menzel writes:
>
>> Unfortunately, forward search is still not functioning, although I
>> do see a small message at the bottom of the screen that reports
>> "Couldn't proceed" when I invoke the Forward Search command, in case
>> that's a clue;
>
> Yes, it is. Most probably, you don't defined a command for performing the
> forward search. This depends on the viewer you use and you can find a
> predefined list for some most used viewers in
> Preferences->Output->General.
> Pick the one for your viewer and you should be fine. If your viewer is
> not listed, you will have to discover whether it supports forward search
> and what command should be used.

Well, as I noted, I followed the instructions in the Additional Features
document assiduously, so one of the first things I did was to choose the
default command for the Yap previewer under
Preferences->Output->General.  The default setting -- yap -1 -s "$$n
$$t" $$o -- leads to the "Couldn't proceed" message. And, although the
MiKTeX bin directory is in my PATH, I have also tried using a fully
qualified path to yap.exe and I still get the message in question. Any
other possibilities you can think of? And, again, is there anything
analogous to the Unix /var/log directory under Windows where I might be
able to examine a log file for clues?  Oh, also, can you (or anyone)
tell me how to run LyX under Windows from the command line with
debugging on?  I figure that might yield a clue or two as well but I
haven't been able to figure out how to do that; it doesn't seem to be a
simple matter of calling the .exe file with the -dbg option.

Chris Menzel



Re: Forward/reverse searching problems under Windows

2011-05-21 Thread Enrico Forestieri
Christopher Menzel writes:
> 
> Unfortunately, forward search is still not functioning, although I
> do see a small message at the bottom of the screen that reports
> "Couldn't proceed" when I invoke the Forward Search command, in case
> that's a clue;

Yes, it is. Most probably, you don't defined a command for performing the
forward search. This depends on the viewer you use and you can find a
predefined list for some most used viewers in Preferences->Output->General.
Pick the one for your viewer and you should be fine. If your viewer is
not listed, you will have to discover whether it supports forward search
and what command should be used.

-- 
Enrico






Re: Forward/reverse searching problems under Windows

2011-05-21 Thread Christopher Menzel
On 20/05/2011 2:43 PM, Enrico Forestieri wrote:
> Christopher Menzel writes:
>>
>> I have followed all the instructions assiduously in the Additional
>> Features document -- path to LyXserver pipe is set to
>> \\.\pipe\lyxpipe, I've created the batch file lyxeditor.bat, have
>> configured Yap properly, etc.  But when I double-click in my DVI
>> preview document, a command window pops up quickly with the message
>> "The system cannot find the file specified".
>
> Make sure you use the full path to lyxeditor.bat in yap.

A reasonable suggestion, but I'm of course using the full path.
Actually, I'm happy to report that inverse searching has begun to work,
without my having made any changes to my LyX config.  I have no idea
why.  Unfortunately, forward search is still not functioning, although I
do see a small message at the bottom of the screen that reports
"Couldn't proceed" when I invoke the Forward Search command, in case
that's a clue; I can't find anything on the Web or the LyX wiki. And I
can't find any LyX error logs to look through.  (Where do programs
typically keep those under Windows?  Is there anything analagous to the
unix /var/log dir?

Chris Menzel


Re: Forward/reverse searching problems under Windows

2011-05-20 Thread Enrico Forestieri
Christopher Menzel writes:
> 
> I have followed all the
> instructions assiduously in the Additional Features document -- path to
> LyXserver pipe is set to \\.\pipe\lyxpipe, I've created the batch file
> lyxeditor.bat, have configured Yap properly, etc.  But when I
> double-click in my DVI preview document, a command window pops up
> quickly with the message "The system cannot find the file specified".

Make sure you use the full path to lyxeditor.bat in yap.

> I've seen a couple of reports of problems with inverse search and MikTeX
> 2.9 but no solutions.

Uh? It works just fine for me.

-- 
Enrico



Forward/reverse searching problems under Windows

2011-05-20 Thread Christopher Menzel
LyX folk:

I usually work in OS X or Linux but on occasion work in Windows 7.  No
problems at all with LyX under the former two but both forward and
inverse searching are failing under Windows.  I have followed all the
instructions assiduously in the Additional Features document -- path to
LyXserver pipe is set to \\.\pipe\lyxpipe, I've created the batch file
lyxeditor.bat, have configured Yap properly, etc.  But when I
double-click in my DVI preview document, a command window pops up
quickly with the message "The system cannot find the file specified". 
I've seen a couple of reports of problems with inverse search and MikTeX
2.9 but no solutions.  Any help or relevant information appreciated. 
I'm using LyX 2.0, of course.

Chris Menzel