emacs-devel
[Top][All Lists]
Advanced

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

Re: Proper English Title Capitalization


From: Karl Voit
Subject: Re: Proper English Title Capitalization
Date: Mon, 25 May 2015 12:13:23 +0200
User-agent: slrn/pre1.0.0-18 (Linux)

Hi Emanuel,

* Emanuel Berg <address@hidden> wrote:
> Karl Voit <address@hidden> 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




reply via email to

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