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:13:23 +0200 Organization: www.karl-voit.at Message-ID: <2015-05-25T12-05-49@devnull.Karl-Voit.at> References: <2015-05-24T13-06-14@devnull.Karl-Voit.at> <87fv6lelmr.fsf@debian.uxu> Reply-To: Karl Voit NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1432549062 18161 80.91.229.3 (25 May 2015 10:17:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 May 2015 10:17:42 +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:17:26 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 1YwpRj-0004LC-Kq for ged-emacs-devel@m.gmane.org; Mon, 25 May 2015 12:17:23 +0200 Original-Received: from localhost ([::1]:42824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YwpRj-0007Xn-1K for ged-emacs-devel@m.gmane.org; Mon, 25 May 2015 06:17:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YwpOy-00045Y-Dm for emacs-devel@gnu.org; Mon, 25 May 2015 06:14:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YwpOu-0005pk-7I for emacs-devel@gnu.org; Mon, 25 May 2015 06:14:32 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:47912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YwpOt-0005pf-Sg for emacs-devel@gnu.org; Mon, 25 May 2015 06:14:28 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YwpOr-000340-Ch for emacs-devel@gnu.org; Mon, 25 May 2015 12:14:25 +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:14:25 +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:14:25 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 165 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:186792 Archived-At: Hi Emanuel, * Emanuel Berg wrote: > Karl Voit writes: > >> I was looking for a method to capitalize >> headings/titles according to [1]. >> [1] http://dougscripts.com/itunes/scripts/ss.php?sp=titlecaps > Good idea, I can never memorize those goofy rules. "Those goofy rules" are much more complicated than I thought. I did some research: What is proper English title capitalization? + http://english.stackexchange.com/questions/14/which-words-in-a-title-should-be-capitalized - http://english.stackexchange.com/a/34 1. Always capitalize the first and the last word. 2. Capitalize all nouns, pronouns, adjectives, verbs, adverbs, and subordinate conjunctions ("as", "because", "although", "if", etc.). 3. Lowercase all articles, coordinate conjunctions ("and", "or", "nor"), and prepositions regardless of length, when they are other than the first or last word. (Note: NIVA prefers to capitalize prepositions of five characters or more ("after", "among", "between").) 4. Lowercase the "to" in an infinitive. + https://en.wikipedia.org/wiki/Capitalization#Titles - summarizes different approaches + https://en.wikipedia.org/wiki/Letter_case#Case_styles - compares different approaches + http://www.grammarbook.com/punctuation/capital.asp - Rule 16a. Composition titles: which words should be capitalized in titles of books, plays, films, songs, poems, essays, chapters, etc.? This is a vexing matter, and policies vary. The usual advice is to capitalize only the "important" words. But this isn't really very helpful. Aren't all words in a title important? - The following rules for capitalizing composition titles are universal. - Capitalize the title's first and last word. - Capitalize verbs, including all forms of the verb to be (is, are, was, etc.). - Capitalize all pronouns, including it, he, who, that, etc. - Capitalize not. - Do not capitalize a, an, or the unless it is first or last in the title. - Do not capitalize the word and, or, or nor unless it is first or last in the title. - Do not capitalize the word to, with or without an infinitive, unless it is first or last in the title. - Otherwise, styles, methods, and opinions vary. Small words such as or, as, if, and but are capped by some, but lowercased by others. - The major bone of contention is prepositions. The Associated Press Stylebook recommends capitalizing all prepositions of more than three letters (e.g., With, About, Across). Others advise lowercase until a preposition reaches five or more letters. Still others say not to capitalize any preposition, even big words like regarding or underneath. - Hyphenated words in a title also present problems. There are no set rules. Some writers, editors, and publishers choose not to capitalize words following hyphens unless they are proper nouns or proper adjectives (Ex-Marine but Ex-husband). Others capitalize any word that would otherwise be capped in titles (Prize-Winning, Up-to-Date). + http://grammar.yourdictionary.com/capitalization/rules-for-capitalization-in-titles.html - As you have probably noticed "short" words, those with less than five letters, are generally lowercase in titles, unless they are the first or last words in a title. - Generally, we do not capitalize: - Articles: a, an, the - Coordinating Conjunctions: and, but, or, for, nor, etc. - Prepositions (fewer than five letters): on, at, to, from, by, etc. - When in doubt and you do not have a reference guide in front of you, here is one general rule to remember recommended by The U.S. Government Printing Office Style Manual: - "Capitalize all words in titles of publications and documents, except a, an, the, at, by, for, in, of, on, to, up, and, as, but, it, or, and nor." + http://www.chompchomp.com/terms/coordinatingconjunction.htm - "And, but, for, nor, or, so, and yet—these are the seven coordinating conjunctions." + https://www.ego4u.com/en/cram-up/grammar/prepositions - on in at since for ago before to past to till until by next beside under below over above across through into towards onto from off "out of" about - less than five letters: - on in at for ago to past to till by next over into onto from off Once again, "it depends" is the correct answer to the title capitalization question as well. > You don't have to know a lot of Elisp to do that. > Here is a start. Only you'll have to insert the > "stopwords" yourself. > > (setq do-not-capitalize '("ah" "oh" "eh")) > > (defun make-a-title (beg end) > (interactive "r") > (save-excursion > (goto-char beg) > (forward-word) > (backward-word) > (while (< (point) end) > (if (member (thing-at-point 'word t) do-not-capitalize) > (forward-word) > (capitalize-word 1) ) > (forward-word) > (backward-word) ))) I was wrong by using the term "stop words". However, I came up with a list of words not to capitalize based on the resources above. What's still missing in your make-a-title: - Always capitalize first word - Always capitalize last word - List of do-not-capitalize words My Elisp knowledge is sufficient to modify your code so that it should get the job done: ,---- | (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) | (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) | ) | )) `---- I was surprised that this quite handy function is not part of Emacs yet. -- 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