* Proper English Title Capitalization
@ 2015-05-24 11:10 Karl Voit
2015-05-24 21:00 ` Emanuel Berg
2015-06-17 13:48 ` Karl Voit
0 siblings, 2 replies; 12+ messages in thread
From: Karl Voit @ 2015-05-24 11:10 UTC (permalink / raw)
To: emacs-devel
Hi!
I was looking for a method to capitalize headings/titles according
to [1]. I found ~s-titleise-s~ which simply capitalizes every word.
However, I was looking for a method which turns stopwords into lower
case and non-stopwords into capitalized words.
Is there something out there?
No, I don't know enough Elisp to code it by myself and I have no
idea if there is a set of English stopwords stored in Emacs.
[1] http://dougscripts.com/itunes/scripts/ss.php?sp=titlecaps
I'm sure there are better resources as well.
[2] https://github.com/magnars/s.el#s-titleize-s
--
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-24 11:10 Proper English Title Capitalization Karl Voit
@ 2015-05-24 21:00 ` Emanuel Berg
2015-05-25 10:13 ` Karl Voit
2015-06-17 13:48 ` Karl Voit
1 sibling, 1 reply; 12+ messages in thread
From: Emanuel Berg @ 2015-05-24 21:00 UTC (permalink / raw)
To: emacs-devel
Karl Voit <devnull@Karl-Voit.at> writes:
> I was looking for a method to capitalize
> headings/titles according to [1]. I found
> ~s-titleise-s~ which simply capitalizes every word.
> However, I was looking for a method which turns
> stopwords into lower case and non-stopwords into
> capitalized words.
>
> Is there something out there?
>
> No, I don't know enough Elisp to code it by myself
> and I have no idea if there is a set of English
> stopwords stored in Emacs.
Good idea, I can never memorize those goofy rules.
It could be a cool thing to have for example
in BibLaTeX.
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) )))
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-24 21:00 ` Emanuel Berg
@ 2015-05-25 10:13 ` Karl Voit
2015-05-25 10:36 ` Rasmus
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Karl Voit @ 2015-05-25 10:13 UTC (permalink / raw)
To: emacs-devel
Hi Emanuel,
* Emanuel Berg <embe8573@student.uu.se> wrote:
> Karl Voit <devnull@Karl-Voit.at> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-25 10:13 ` Karl Voit
@ 2015-05-25 10:36 ` Rasmus
2015-05-25 10:47 ` Karl Voit
2015-05-25 16:59 ` Emanuel Berg
2 siblings, 0 replies; 12+ messages in thread
From: Rasmus @ 2015-05-25 10:36 UTC (permalink / raw)
To: emacs-devel
Karl Voit <devnull@Karl-Voit.at> writes:
> "Those goofy rules" are much more complicated than I thought.
All the more reason to make a `capitalize-word' equivalent for titles!
I'd certainly appreciate it.
Or do as some Speigel journals and adopt "Euro-English" and capitalize in
a sane manner, namely like any other sentences....
—Rasmus
--
. . . The proofs are technical in nature and provides no real understanding
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-25 10:13 ` Karl Voit
2015-05-25 10:36 ` Rasmus
@ 2015-05-25 10:47 ` Karl Voit
2015-05-25 12:22 ` Karl Voit
` (2 more replies)
2015-05-25 16:59 ` Emanuel Berg
2 siblings, 3 replies; 12+ messages in thread
From: Karl Voit @ 2015-05-25 10:47 UTC (permalink / raw)
To: emacs-devel
* Karl Voit <devnull@Karl-Voit.at> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-25 10:47 ` Karl Voit
@ 2015-05-25 12:22 ` Karl Voit
2015-05-25 16:18 ` Rasmus
2015-05-26 15:38 ` Barry Fishman
2015-06-03 15:05 ` Karl Voit
2 siblings, 1 reply; 12+ messages in thread
From: Karl Voit @ 2015-05-25 12:22 UTC (permalink / raw)
To: emacs-devel
I also blogged about this thread and its solution:
http://karl-voit.at/2015/05/25/elisp-title-capitalization/
--
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-25 12:22 ` Karl Voit
@ 2015-05-25 16:18 ` Rasmus
0 siblings, 0 replies; 12+ messages in thread
From: Rasmus @ 2015-05-25 16:18 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 430 bytes --]
Karl Voit <devnull@Karl-Voit.at> writes:
> I also blogged about this thread and its solution:
> http://karl-voit.at/2015/05/25/elisp-title-capitalization/
Ah that's funny. I like M-c though. The attached file does something
similar to your script, but plugs into capitalize-word at supported title
lines (== org and message) if hooked in.
–Rasmus
--
Evidence suggests Snowden used a powerful tool called monospaced fonts
[-- Attachment #2: smartcap.el --]
[-- Type: application/emacs-lisp, Size: 6262 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-25 10:13 ` Karl Voit
2015-05-25 10:36 ` Rasmus
2015-05-25 10:47 ` Karl Voit
@ 2015-05-25 16:59 ` Emanuel Berg
2 siblings, 0 replies; 12+ messages in thread
From: Emanuel Berg @ 2015-05-25 16:59 UTC (permalink / raw)
To: emacs-devel
Karl Voit <devnull@Karl-Voit.at> writes:
>> 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? [...]
The authoritative source is probably a grammar book
from the sturdy and meticulous islanders themselves,
which is Oxford in my experience.
Perhaps it is in this book?
@book{new-oxford-dictionary-for-scientific,
title = {The New Oxford Dictionary for Scientific Writers and Editors},
author = {Elizabeth Martin},
edition = {Second edition},
publisher = {Oxford University Press},
year = 2009,
ISBN-13 = 9780199545155
}
But I don't think those web sources that you mention
are necessarily bad. They should get all or most of it
right. Only when they contradict each other a book has
the advantage to be a permanent source to point to as
the basis of the implementation.
> I was surprised that this quite handy function is
> not part of Emacs yet.
More or less. I think most often, the people who care
don't need it as they know the rules, and the people
who don't care don't look for it.
But I agree it is useful, so when you have perfected
the Elisp, send it to the ELPA or some of the other
repositories. You can then re-use parts of the
homepage text as documentation.
And, I appreciate the compliment [1] tho I suspect you
have already spent much more time on the issue than I.
But I'm glad I could help you get started.
[1] http://karl-voit.at/2015/05/25/elisp-title-capitalization/
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-25 10:47 ` Karl Voit
2015-05-25 12:22 ` Karl Voit
@ 2015-05-26 15:38 ` Barry Fishman
2015-06-11 20:10 ` Karl Voit
2015-06-03 15:05 ` Karl Voit
2 siblings, 1 reply; 12+ messages in thread
From: Barry Fishman @ 2015-05-26 15:38 UTC (permalink / raw)
To: emacs-devel
On 2015-05-25 12:47:51 +0200, Karl Voit wrote:
> * Karl Voit <devnull@Karl-Voit.at> 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)
> | )
> | ))
> `----
If you are looking for more alternative coding:
--8<---------------cut here---------------start------------->8---
;; This is probably subject for debate and tuning.
(defvar own-stop-words '("a" "an" "the" "at" "by" "for" "in"
"of" "on" "to" "up" "and" "as" "but"
"it" "or" "nor" "n" "t" "es" "s")
"Words that are not capitalized in titles.")
(defun own-title-region (beg end)
"Capitalize region as a title,"
(interactive "r")
(save-excursion
(goto-char beg)
(capitalize-word 1)
(while (< (point) end)
(skip-syntax-forward "^w" end)
(let ((word (thing-at-point 'word t)))
(if (stringp word)
(if (member (downcase word) own-stop-words)
(downcase-word 1)
(capitalize-word 1)))))
(backward-word 1)
(if (and (>= (point) beg)
(not (member (or (thing-at-point 'word t) "s")
'("n" "t" "es" "s"))))
(capitalize-word 1))))
--8<---------------cut here---------------end--------------->8---
--
Barry Fishman
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-25 10:47 ` Karl Voit
2015-05-25 12:22 ` Karl Voit
2015-05-26 15:38 ` Barry Fishman
@ 2015-06-03 15:05 ` Karl Voit
2 siblings, 0 replies; 12+ messages in thread
From: Karl Voit @ 2015-06-03 15:05 UTC (permalink / raw)
To: emacs-devel
* Karl Voit <devnull@Karl-Voit.at> wrote:
>
> ,----
>| (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)
>| )
>| ))
> `----
>
With the version above and the version of others as well, I get
errors on my Windows computer running GNU Emacs 24.3.1
(i386-mingw-nt6.1.7601):
| let: Wrong number of arguments: #[(thing) "<some special characters
| which I can't post here since they are obviously binary or
| something>" [thing bounds thing-at-point bounds-of-thing-at-point] 3
| ("c:/Program Files/emacs-24.3/lisp/thingatpt.elc" . 2271)], 2
The weird text does not occur in the region at all.
--
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-26 15:38 ` Barry Fishman
@ 2015-06-11 20:10 ` Karl Voit
0 siblings, 0 replies; 12+ messages in thread
From: Karl Voit @ 2015-06-11 20:10 UTC (permalink / raw)
To: emacs-devel
* Barry Fishman <barry_fishman@acm.org> wrote:
>
>
> If you are looking for more alternative coding:
>
> --8<---------------cut here---------------start------------->8---
> ;; This is probably subject for debate and tuning.
> (defvar own-stop-words '("a" "an" "the" "at" "by" "for" "in"
> "of" "on" "to" "up" "and" "as" "but"
> "it" "or" "nor" "n" "t" "es" "s")
> "Words that are not capitalized in titles.")
>
> (defun own-title-region (beg end)
> "Capitalize region as a title,"
> (interactive "r")
> (save-excursion
> (goto-char beg)
> (capitalize-word 1)
> (while (< (point) end)
> (skip-syntax-forward "^w" end)
> (let ((word (thing-at-point 'word t)))
> (if (stringp word)
> (if (member (downcase word) own-stop-words)
> (downcase-word 1)
> (capitalize-word 1)))))
> (backward-word 1)
> (if (and (>= (point) beg)
> (not (member (or (thing-at-point 'word t) "s")
> '("n" "t" "es" "s"))))
> (capitalize-word 1))))
> --8<---------------cut here---------------end--------------->8---
Thanks for your version. I tested it and it worked great. I added
your input to my solution and to my blog entry.
--
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Proper English Title Capitalization
2015-05-24 11:10 Proper English Title Capitalization Karl Voit
2015-05-24 21:00 ` Emanuel Berg
@ 2015-06-17 13:48 ` Karl Voit
1 sibling, 0 replies; 12+ messages in thread
From: Karl Voit @ 2015-06-17 13:48 UTC (permalink / raw)
To: emacs-devel
* Karl Voit <devnull@Karl-Voit.at> wrote:
>
> I was looking for a method to capitalize headings/titles according
> to [1].
> [1] http://dougscripts.com/itunes/scripts/ss.php?sp=titlecaps
I put my solution on GitHub[2] and updated my blog article [3].
Additionally, I am going to try to publish it as a marmalade
package. My first package ;-)
[2] https://github.com/novoid/title-capitalization.el
[3] http://karl-voit.at/2015/05/25/elisp-title-capitalization/
--
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
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-06-17 13:48 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-24 11:10 Proper English Title Capitalization Karl Voit
2015-05-24 21:00 ` Emanuel Berg
2015-05-25 10:13 ` Karl Voit
2015-05-25 10:36 ` Rasmus
2015-05-25 10:47 ` Karl Voit
2015-05-25 12:22 ` Karl Voit
2015-05-25 16:18 ` Rasmus
2015-05-26 15:38 ` Barry Fishman
2015-06-11 20:10 ` Karl Voit
2015-06-03 15:05 ` Karl Voit
2015-05-25 16:59 ` Emanuel Berg
2015-06-17 13:48 ` Karl Voit
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.