all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Electric punctuation replacement for editing (correcting grammar)
@ 2011-12-13 19:32 Ludwig, Mark
  2011-12-13 21:30 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Ludwig, Mark @ 2011-12-13 19:32 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-13 21:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-13 19:32 Electric punctuation replacement for editing (correcting grammar) Ludwig, Mark
2011-12-13 21:30 ` Thien-Thi Nguyen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.