Re: Global find and replace of straight quotes with proper curly quotes?

2012-04-16 Thread Enrico Forestieri
stefano franchi writes:
> 1. I can insert a space back in with  empty ERT+space, but then I have
> my file littered with all these empty ERT boxes. They are ignored in
> the pdf output, as they should, but there are still very annoying. Is
> there any way to get rid of them?

I think you can simply fool LyX and insert a space at the very beginning
even if the stupid thing would not let you do so. You can do this both
in the find and replace area. Simply input any character followed by a
space and what else you need, then delete the first character you inserted.
You now have an initial space in both areas...

-- 
Enrico



Re: Global find and replace of straight quotes with proper curly quotes?

2012-04-16 Thread stefano franchi
On Mon, Apr 16, 2012 at 3:45 PM, Richard Heck  wrote:
> On 04/16/2012 09:22 AM, stefano franchi wrote:
>>
>> On Sun, Apr 15, 2012 at 9:36 PM, Richard Heck  wrote:
>>>
>>> On 04/15/2012 12:13 PM, stefano franchi wrote:

 On Sun, Apr 15, 2012 at 7:46 AM, Richard Heck
  wrote:
>
> On 04/14/2012 07:39 PM, stefano franchi wrote:
>>>
>>> If you do the first thing I suggested, with the pointless regex, will
>>> that
>>> work?
>>>
>> Richard: I guess I'm still not getting your suggestion. Yes, the
>> pointless Regex matches correctly, but I still don't [or "didn't," see
>> below] know how to put the space back in in the replace field
>
> Oh, sorry, I see the problem.
>
>
>> Enrico: Thanks for your suggestion (which I would have never dreamt
>> of). It works, but I have two issues with it:
>>
>> 1. I can insert a space back in with  empty ERT+space, but then I have
>> my file littered with all these empty ERT boxes. They are ignored in
>> the pdf output, as they should, but there are still very annoying. Is
>> there any way to get rid of them?
>>
> Maybe that one could be done with a script. Another option would be to add
> the space back in with something like "X ". Then you can replace that
> with nothing.

Ah right...the old trick. I had forgotten about that (used to do it
all the time on my wife's word files to get rid of double
end-of-paragraphs). Thanks for reminding me.

>
>
>> 2. Every time I try a global find and replace on my file (it's a
>> chapter, about 25K words) with the suggested pattern (i.e: Find field:
>> [REGEX \s"] Replace Field: CTRL-L " ) , Lyx gobbles up all the ram
>> available until it crashes. Is this a general issue with the advanced
>> F&R?
>>
> There have been some reports of this kind of behavior.

Glad to know it is not me...

Stefano



-- 
__
Stefano Franchi
Associate Research Professor
Department of Hispanic Studies            Ph:   +1 (979) 845-2125
Texas A&M University                          Fax:  +1 (979) 845-6421
College Station, Texas, USA

stef...@tamu.edu
http://stefano.cleinias.org


Re: Global find and replace of straight quotes with proper curly quotes?

2012-04-16 Thread Richard Heck

On 04/16/2012 09:22 AM, stefano franchi wrote:

On Sun, Apr 15, 2012 at 9:36 PM, Richard Heck  wrote:

On 04/15/2012 12:13 PM, stefano franchi wrote:

On Sun, Apr 15, 2012 at 7:46 AM, Richard Heckwrote:

On 04/14/2012 07:39 PM, stefano franchi wrote:

If you do the first thing I suggested, with the pointless regex, will that
work?


Richard: I guess I'm still not getting your suggestion. Yes, the
pointless Regex matches correctly, but I still don't [or "didn't," see
below] know how to put the space back in in the replace field

Oh, sorry, I see the problem.


Enrico: Thanks for your suggestion (which I would have never dreamt
of). It works, but I have two issues with it:

1. I can insert a space back in with  empty ERT+space, but then I have
my file littered with all these empty ERT boxes. They are ignored in
the pdf output, as they should, but there are still very annoying. Is
there any way to get rid of them?

Maybe that one could be done with a script. Another option would be to 
add the space back in with something like "X ". Then you can replace 
that with nothing.



2. Every time I try a global find and replace on my file (it's a
chapter, about 25K words) with the suggested pattern (i.e: Find field:
[REGEX \s"] Replace Field: CTRL-L " ) , Lyx gobbles up all the ram
available until it crashes. Is this a general issue with the advanced
F&R?


There have been some reports of this kind of behavior.

Richard



Re: Global find and replace of straight quotes with proper curly quotes?

2012-04-16 Thread stefano franchi
On Sun, Apr 15, 2012 at 9:36 PM, Richard Heck  wrote:
> On 04/15/2012 12:13 PM, stefano franchi wrote:
>>
>> On Sun, Apr 15, 2012 at 7:46 AM, Richard Heck  wrote:
>>>
>>> On 04/14/2012 07:39 PM, stefano franchi wrote:

> If you do the first thing I suggested, with the pointless regex, will that
> work?
>
Richard: I guess I'm still not getting your suggestion. Yes, the
pointless Regex matches correctly, but I still don't [or "didn't," see
below] know how to put the space back in in the replace field


Enrico: Thanks for your suggestion (which I would have never dreamt
of). It works, but I have two issues with it:

1. I can insert a space back in with  empty ERT+space, but then I have
my file littered with all these empty ERT boxes. They are ignored in
the pdf output, as they should, but there are still very annoying. Is
there any way to get rid of them?

2. Every time I try a global find and replace on my file (it's a
chapter, about 25K words) with the suggested pattern (i.e: Find field:
[REGEX \s"] Replace Field: CTRL-L " ) , Lyx gobbles up all the ram
available until it crashes. Is this a general issue with the advanced
F&R?

Cheers,

Stefano



-- 
__
Stefano Franchi
Associate Research Professor
Department of Hispanic Studies            Ph:   +1 (979) 845-2125
Texas A&M University                          Fax:  +1 (979) 845-6421
College Station, Texas, USA

stef...@tamu.edu
http://stefano.cleinias.org


Re: Global find and replace of straight quotes with proper curly quotes?

2012-04-15 Thread Richard Heck

On 04/15/2012 12:13 PM, stefano franchi wrote:

On Sun, Apr 15, 2012 at 7:46 AM, Richard Heck  wrote:

On 04/14/2012 07:39 PM, stefano franchi wrote:

I have a (long) manuscript imported from Framemaker via Latex where
all the quotation marks (both single and double) appear in Lyx as
straight quotes instead of the properly curly ones. The source view,
in fact, shows me countless \texquotedbl commands instead of regular
quotes.

Is there any way to do a global find and replace that would properly
substitute opening straight quotes with open single|double quotes and
viceversa for closing quotes? I could search and replace for
space+quote(s) and, respectively for quote+space. That would work in
most cases and I could fix the remaining issues by hand. I thought the
new find and replace could manage, but:

1. I cannot do a simple find and replace for [space][quote] because I
am not allowed to enter a space in the find area
2. I can search for reg expression \s" thereby finding most of the
instances I'm looking for.  But I cannot enter a space in the replace
area, nor can I enter a regular expression in it (as the manual
explains, reg expressions are not allowed in the replace area yet).
3. Using regular expressions as sketched above in an external editor
breaks the lyx file, because straight quotes are needed for citation
commands (and probably in other places as well.

Any idea?


Try inserting into the Advanced Find field: [REGEX .*] ", or something like
that. The regex matches anything, or nothing, so is pointless, but it allows
you to enter the space. You could presumably also enter a user-defined regex
for a space: \s.

Hi Richard,

sorry for not being clear. I can match a space with a regex in the
find field (I did it with /s), but how do I put the space back in? The
replace field does not allow regexes nor spaces.
If you do the first thing I suggested, with the pointless regex, will 
that work?


Richard



Re: Global find and replace of straight quotes with proper curly quotes?

2012-04-15 Thread Enrico Forestieri
stefano franchi writes:
> sorry for not being clear. I can match a space with a regex in the
> find field (I did it with /s), but how do I put the space back in? The
> replace field does not allow regexes nor spaces.

Try inserting an empty ERT (Ctrl+L) and then a space.

-- 
Enrico





Re: Global find and replace of straight quotes with proper curly quotes?

2012-04-15 Thread stefano franchi
HI Steve,

On Sun, Apr 15, 2012 at 4:50 PM, Steve Litt  wrote:
> On Sat, 14 Apr 2012 18:39:15 -0500
> stefano franchi  wrote:
>
>> I have a (long) manuscript imported from Framemaker via Latex where
>> all the quotation marks (both single and double) appear in Lyx as
>> straight quotes instead of the properly curly ones. The source view,
>> in fact, shows me countless \texquotedbl commands instead of regular
>> quotes.
>
> When you say "source view", do you mean viewed in a text editor?

No, I meant the LateX code you get to see with Lyx's own "View Source" command.
In Lyx (not Latex) source code, they are just straight ascii double quotes

>
> My LyX 2.0.0 April 29, 2011 on Ubuntu 11.04 errored out when I put an
> ERT symbol of \texquotedbl into a document. In my LyX, when I put in a
> straight quote (Ctrl+Shift+"), in Vim it's just an ascii doublequote.
> In my LyX, viewed in Vim, my curly quotes look like this:
>
> \begin_inset Quotes eld
> \end_inset
>
> phrase to be quoted
> \begin_inset Quotes erd
> \end_inset

Same here

>
>
>>
>> Is there any way to do a global find and replace that would properly
>> substitute opening straight quotes with open single|double quotes and
>> viceversa for closing quotes?
>
> Personally, I think this is a job for Vim. Or maybe a short program in
> awk, Perl, Python, Ruby or Lua.
>
> I just experimented with it, and assuming you can get your LyX to treat
> a straight quote as the ascii character (maybe by changing your
> fontenc), then I think the following two commands, within Vim, should
> do what you want:
>
> :%s/\(\s\)"\(\S\)/\1\r\\begin_inset Quotes eld\r\\end_inset\r\r\2/gc
>
> :%s/\(\S\)"\(\s\)/\1\r\\begin_inset Quotes erd\r\\end_inset\r\r\2/gc
>


That's pretty much what I was trying to do in Kile (even though my
RegEx was way simpler than yours...)
Unfortunately I cannot find a way to do it automatically, because
there are instances where the straight double quotes are actually used
by Lyx. So I guess I'll have to confirm every single one. Long night
ahead (book is close to 300K words...)

Thanks for confirming my hunch and providing the regex.


Cheers,

Stefano
-- 
__
Stefano Franchi
Associate Research Professor
Department of Hispanic Studies            Ph:   +1 (979) 845-2125
Texas A&M University                          Fax:  +1 (979) 845-6421
College Station, Texas, USA

stef...@tamu.edu
http://stefano.cleinias.org


Re: Global find and replace of straight quotes with proper curly quotes?

2012-04-15 Thread Steve Litt
On Sat, 14 Apr 2012 18:39:15 -0500
stefano franchi  wrote:

> I have a (long) manuscript imported from Framemaker via Latex where
> all the quotation marks (both single and double) appear in Lyx as
> straight quotes instead of the properly curly ones. The source view,
> in fact, shows me countless \texquotedbl commands instead of regular
> quotes.

When you say "source view", do you mean viewed in a text editor?

My LyX 2.0.0 April 29, 2011 on Ubuntu 11.04 errored out when I put an
ERT symbol of \texquotedbl into a document. In my LyX, when I put in a
straight quote (Ctrl+Shift+"), in Vim it's just an ascii doublequote.
In my LyX, viewed in Vim, my curly quotes look like this:

\begin_inset Quotes eld
\end_inset

phrase to be quoted
\begin_inset Quotes erd
\end_inset


> 
> Is there any way to do a global find and replace that would properly
> substitute opening straight quotes with open single|double quotes and
> viceversa for closing quotes?

Personally, I think this is a job for Vim. Or maybe a short program in
awk, Perl, Python, Ruby or Lua.

I just experimented with it, and assuming you can get your LyX to treat
a straight quote as the ascii character (maybe by changing your
fontenc), then I think the following two commands, within Vim, should
do what you want:


:%s/\(\s\)"\(\S\)/\1\r\\begin_inset Quotes eld\r\\end_inset\r\r\2/gc

:%s/\(\S\)"\(\s\)/\1\r\\begin_inset Quotes erd\r\\end_inset\r\r\2/gc

Note that the c on the end of each of those commands causes it to ask,
on each one, whether it's OK to make the change. If you don't want to
be asked, eliminate the trailing c on each command and they'll do the
job in a matter of seconds for a 100K word book.

Obviously, you'll need to back up the original in case my commands do
more harm than good.

Anyway, if you can get your LyX to treat straightdoublequotes like
ascii characters, I'd anticipate this solution will take you a few
minutes.

As far as single quotes, I'd do those manually. If your writing is
anything like mine, the VAST majority of single quotes are apostrophes,
and as far as I know those SHOULD be straightquotes. From what I
understand, you use straight double quotes only in a quotation within a
quotation, which are rare. I'd seek out such instances, delete the
straight single quote, and type in Ctrl+' to insert the proper curly
quote. LyX knows by context whether to make it a beginning or ending
singlequote.

HTH

SteveT


Re: Global find and replace of straight quotes with proper curly quotes?

2012-04-15 Thread stefano franchi
On Sun, Apr 15, 2012 at 7:46 AM, Richard Heck  wrote:
> On 04/14/2012 07:39 PM, stefano franchi wrote:
>>
>> I have a (long) manuscript imported from Framemaker via Latex where
>> all the quotation marks (both single and double) appear in Lyx as
>> straight quotes instead of the properly curly ones. The source view,
>> in fact, shows me countless \texquotedbl commands instead of regular
>> quotes.
>>
>> Is there any way to do a global find and replace that would properly
>> substitute opening straight quotes with open single|double quotes and
>> viceversa for closing quotes? I could search and replace for
>> space+quote(s) and, respectively for quote+space. That would work in
>> most cases and I could fix the remaining issues by hand. I thought the
>> new find and replace could manage, but:
>>
>> 1. I cannot do a simple find and replace for [space][quote] because I
>> am not allowed to enter a space in the find area
>> 2. I can search for reg expression \s" thereby finding most of the
>> instances I'm looking for.  But I cannot enter a space in the replace
>> area, nor can I enter a regular expression in it (as the manual
>> explains, reg expressions are not allowed in the replace area yet).
>> 3. Using regular expressions as sketched above in an external editor
>> breaks the lyx file, because straight quotes are needed for citation
>> commands (and probably in other places as well.
>>
>> Any idea?
>>
> Try inserting into the Advanced Find field: [REGEX .*] ", or something like
> that. The regex matches anything, or nothing, so is pointless, but it allows
> you to enter the space. You could presumably also enter a user-defined regex
> for a space: \s.

Hi Richard,

sorry for not being clear. I can match a space with a regex in the
find field (I did it with /s), but how do I put the space back in? The
replace field does not allow regexes nor spaces.

Cheers,

Stefano

-- 
__
Stefano Franchi
Associate Research Professor
Department of Hispanic Studies            Ph:   +1 (979) 845-2125
Texas A&M University                          Fax:  +1 (979) 845-6421
College Station, Texas, USA

stef...@tamu.edu
http://stefano.cleinias.org


Re: Global find and replace of straight quotes with proper curly quotes?

2012-04-15 Thread Richard Heck

On 04/14/2012 07:39 PM, stefano franchi wrote:

I have a (long) manuscript imported from Framemaker via Latex where
all the quotation marks (both single and double) appear in Lyx as
straight quotes instead of the properly curly ones. The source view,
in fact, shows me countless \texquotedbl commands instead of regular
quotes.

Is there any way to do a global find and replace that would properly
substitute opening straight quotes with open single|double quotes and
viceversa for closing quotes? I could search and replace for
space+quote(s) and, respectively for quote+space. That would work in
most cases and I could fix the remaining issues by hand. I thought the
new find and replace could manage, but:

1. I cannot do a simple find and replace for [space][quote] because I
am not allowed to enter a space in the find area
2. I can search for reg expression \s" thereby finding most of the
instances I'm looking for.  But I cannot enter a space in the replace
area, nor can I enter a regular expression in it (as the manual
explains, reg expressions are not allowed in the replace area yet).
3. Using regular expressions as sketched above in an external editor
breaks the lyx file, because straight quotes are needed for citation
commands (and probably in other places as well.

Any idea?

Try inserting into the Advanced Find field: [REGEX .*] ", or something 
like that. The regex matches anything, or nothing, so is pointless, but 
it allows you to enter the space. You could presumably also enter a 
user-defined regex for a space: \s.


Richard



Global find and replace of straight quotes with proper curly quotes?

2012-04-14 Thread stefano franchi
I have a (long) manuscript imported from Framemaker via Latex where
all the quotation marks (both single and double) appear in Lyx as
straight quotes instead of the properly curly ones. The source view,
in fact, shows me countless \texquotedbl commands instead of regular
quotes.

Is there any way to do a global find and replace that would properly
substitute opening straight quotes with open single|double quotes and
viceversa for closing quotes? I could search and replace for
space+quote(s) and, respectively for quote+space. That would work in
most cases and I could fix the remaining issues by hand. I thought the
new find and replace could manage, but:

1. I cannot do a simple find and replace for [space][quote] because I
am not allowed to enter a space in the find area
2. I can search for reg expression \s" thereby finding most of the
instances I'm looking for.  But I cannot enter a space in the replace
area, nor can I enter a regular expression in it (as the manual
explains, reg expressions are not allowed in the replace area yet).
3. Using regular expressions as sketched above in an external editor
breaks the lyx file, because straight quotes are needed for citation
commands (and probably in other places as well.

Any idea?

Cheers,

Stefano




-- 
__
Stefano Franchi
Associate Research Professor
Department of Hispanic Studies            Ph:   +1 (979) 845-2125
Texas A&M University                          Fax:  +1 (979) 845-6421
College Station, Texas, USA

stef...@tamu.edu
http://stefano.cleinias.org