From: "Ludwig, Mark" <ludwig.mark@siemens.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Electric punctuation replacement for editing (correcting grammar)
Date: Tue, 13 Dec 2011 19:32:31 +0000 [thread overview]
Message-ID: <BC5672F8AD4C054BAF167C9801500D1A6FBEA371@USSLMMBX003.net.plm.eds.com> (raw)
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
next reply other threads:[~2011-12-13 19:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-13 19:32 Ludwig, Mark [this message]
2011-12-13 21:30 ` Electric punctuation replacement for editing (correcting grammar) Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BC5672F8AD4C054BAF167C9801500D1A6FBEA371@USSLMMBX003.net.plm.eds.com \
--to=ludwig.mark@siemens.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).