help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Electric punctuation replacement for editing (correcting grammar)


From: Ludwig, Mark
Subject: Electric punctuation replacement for editing (correcting grammar)
Date: Tue, 13 Dec 2011 19:32:31 +0000

Has anyone else tried to develop a text mode sub-mode with "electric" 
punctuation replacement?  I use this when fixing the grammar in text.  What I 
have handles replacement from either "direction."  For example, consider the 
following sentence (with a comma splice):

    The big horse, tired after running for so long, paused by a creek to take a 
drink, that was where I caught up with him.

By "direction" what I mean is that I might be going through the text one 
sentence at a time (with M-e), and only after skipping a sentence, I might 
notice that I need to back up to fix something.  Then I use M-b to get to the 
front of a word, and type the correction.  To handle that, what I have works 
(in the above example) when point is on the comma (",") after "drink" or the 
space following it, or the "t" starting "that" that follows.  In any of those 
three positions, I can type semi-colon (";") to correct the grammar (for 
example), and the comma (",") gets replaced.  Point is left on the "t" starting 
"that."  If I type period (".") instead of semi-colon, the spacing increases to 
make a proper English sentence end.  (I have to type M-c to change the case of 
"that" in that case.)

Changing the spacing was relatively straight-forward.  More challenging is 
handling parentheses, because my current approach is to use the "sentence" 
infrastructure (e.g., sentence-end) to figure out the spacing.  I don't know 
how to handle situations like:

    I thought so (I was not sure, but suspected.

This should be:

    I thought so (I was not sure), but suspected.

I want to be able to type the closing parenthesis (")") just as I might type 
semi-colon (";") in the above example, and have it correctly place the 
parenthesis before the comma.

It also doesn't handle ending a sentence with "...." properly, because I have 
logic to handle ellipsis ("...") in the middle of a sentence (by normalizing to 
a single space before and after the ellipsis).

I'd appreciate any pointers if anyone else has done anything like this.

Thanks,

Mark




reply via email to

[Prev in Thread] Current Thread [Next in Thread]