From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Karl Voit Newsgroups: gmane.emacs.devel Subject: Re: Proper English Title Capitalization Date: Mon, 25 May 2015 12:47:51 +0200 Organization: www.karl-voit.at Message-ID: <2015-05-25T12-45-36@devnull.Karl-Voit.at> References: <2015-05-24T13-06-14@devnull.Karl-Voit.at> <87fv6lelmr.fsf@debian.uxu> <2015-05-25T12-05-49@devnull.Karl-Voit.at> Reply-To: Karl Voit NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1432550932 14788 80.91.229.3 (25 May 2015 10:48:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 May 2015 10:48:52 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 25 12:48:44 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ywpw1-0000ne-3w for ged-emacs-devel@m.gmane.org; Mon, 25 May 2015 12:48:41 +0200 Original-Received: from localhost ([::1]:42912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ywpw0-0006gM-5e for ged-emacs-devel@m.gmane.org; Mon, 25 May 2015 06:48:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ywpvt-0006g1-0P for emacs-devel@gnu.org; Mon, 25 May 2015 06:48:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ywpvp-00082m-4d for emacs-devel@gnu.org; Mon, 25 May 2015 06:48:32 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:49650) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ywpvo-00082e-Tr for emacs-devel@gnu.org; Mon, 25 May 2015 06:48:29 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ywpvm-0000iH-TS for emacs-devel@gnu.org; Mon, 25 May 2015 12:48:27 +0200 Original-Received: from friends.grml.info ([136.243.234.19]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 25 May 2015 12:48:26 +0200 Original-Received: from news1142 by friends.grml.info with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 25 May 2015 12:48:26 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 46 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: friends.grml.info X-GPG-Key: http://www.Karl-Voit.at/Karl_Voit_GnuPG_public_key.gpg X-Registered-Linux-User: 224337 X-Confession: Pastafarian http://www.venganza.org/ User-Agent: slrn/pre1.0.0-18 (Linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:186798 Archived-At: * Karl Voit wrote: > > My Elisp knowledge is sufficient to modify your code so that it > should get the job done: I have to post a corrected version of the code which also handles the edge case "a a a a a" (a do-not-capitalize word as second word) properly: ,---- | (defun my-title-capitalization (beg end) | (interactive "r") | (save-excursion | (let ( | (do-not-capitalize '("a" "ago" "an" "and" "as" "at" "but" "by" "for" | "from" "in" "into" "it" "next" "nor" "of" "off" | "on" "onto" "or" "over" "past" "so" "the" "till" | "to" "up" "yet" )) | ) | ;; go to begin of first word: | (goto-char beg) | (forward-word) | (backward-word) | ;; capitalize first word in any case: | (capitalize-word 1) | (forward-word) | (backward-word) | (while (< (point) end) | ;; capitalize each word in between except it is list member: | (if (member (thing-at-point 'word t) do-not-capitalize) | (forward-word) | (capitalize-word 1) ) | (forward-word) | (backward-word) ) | ;; capitalize last word in any case: | (backward-word) | (capitalize-word 1) | ) | )) `---- -- All in all, one of the most disturbing things today is the definitive fact that the NSA, GCHQ, and many more government organizations are massively terrorizing the freedom of us and the next generations. http://Karl-Voit.at