I thank you both, Tim and Ben, for your help. Let me explain the situation more fully. I'm testing the feasibility of semi-automated repair of texts that have been ocr-ed from less than ideal sources, most notably from books.google.com. To that end I've written two scripts; the first in sed to detect and impose formatting structure on the text from cues within the text itself; the second in awk to refer every word in the text to a word-list, and to prepend every word not in the list with @@.
At this point the text must be inspected visually to decide if each @@word is an error or not. If not, the @@ is removed and the actual word is saved to be added to the awk script's word list. If an error, the @@ is changed to qq (for later manual correction), so that errors that have already been processed will not be reprocessed by this vim script.On Mon, Nov 17, 2014 at 9:01 AM, Ben Fritz <fritzophrenic@gmail.com> wrote:
On Monday, November 17, 2014 5:27:47 AM UTC-6, Tim Chase wrote:
> On 2014-11-15 13:59, porphyry5 wrote:
> > On Friday, November 14, 2014 4:02:55 PM UTC-8, porphyry5 wrote:
> > > In a key mapping I use the command ':%s//\=@o/gce'.
> > >
> > > The command executes as expected except that it behaves as if the
> > > c flag were not set. Is this flag unavailable in a key mapping,
> > > or is there some other option that needs to be set for it to
> > > work. It works as expected at the command line.
> >
> > This is the mapping concerned:
> > "map ,, /@@<CR>"myWcwqq<Esc>h"oywxx"nywma:let
> > @/=@m<CR>:%s//\=@n/ge<CR>:let @/=@n<CR>:%s//\=@o/gce<CR>`ay2h`a:if
> > @" != 'qq'<CR>:norm "Zyw<CR>:en<CR><CR>
>
> Ah, I believe the problem is triggered because the atoms after the
> ":%s//\=@o/gce<CR>" are interpreted as answers to the y/n/a/q/l/^E/^Y
> prompt. The back-tick is ignored and the "a" (the subsequent atom)
> is interpreted as "a"ll the remaining matches.
>
> For this to work (actually prompting the user), the
> ":%s//\=@o/gce<cr>" has to be the last item in your mapping, leaving
> the :s command in the user-prompting state.
>
If this is the cause, it's probably cleaner to wrap everything in a function with one command per line, and call the function from the mapping. Then there are fewer ways for it to go awry.
--
Graham Lawrence
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment