Emacs Lisp: Capitalize English Line by Chicago Manual of Style (CMOS)
While Emacs Lips keyboard binding M-c capitalizes each next word on the line, it is not sufficient to capitalize the English title. There are different capitalization styles in English such as Chicago Manual of Style, Associated Press Style, Modern Language Association, so here we are using Chigago Manual of Style for capitalization.
Emacs Lisp: Capitalize English Line by Chicago Manual of Style (CMOS)
defvar rcd-do-not-capitalize
("a" "an" "and" "as" "at" "but" "by" "for" "he" "if" "in" "it" "nor" "of" "on" "or" "she" "so" "the" "they" "to" "up" "via" "we" "with" "yet")
'("Words which should not be capitalized by Chicago Manual of Style (CMOS).")
defun rcd-capitalize-english (string)
("Capitalize correctly the English string."
let* ((string (replace-regexp-in-string "[[:blank:]]+" " " string))
(string " "))
(words (split-string nil))
(capitalized setq capitalized (append (list (capitalize (downcase (pop words)))) capitalized))
(
(while wordslet* ((word (pop words))
(cond ((member word rcd-do-not-capitalize)
(word (
(downcase word))t (capitalize (downcase word))))))
(setq capitalized (append (list word) capitalized))))
(reverse capitalized) " ")))
(mapconcat 'identity (
defun rcd-capitalize-english-line ()
("Capitalize current line by Chicago Manual of Style (CMOS)."
(interactive)
(beginning-of-line)let ((line (thing-at-point 'line)))
(when (stringp line)
(
(kill-whole-line)
(beginning-of-line) (insert (rcd-capitalize-english line)))))
How to use
the function rcd-capitalize-english-line
?
Position cursor at the title you wish to capitalize by using Chicago
Manual of Style (CMOS) and run
M-x rcd-capitalize-english-line
.
Of course you could bind the function to a key as well.
Leave Your Comment or Contact GNU.Support
Contact GNU.Support now. There is a simple rule at GNU.Support: if we can help you, we do, whenever and wherever necessary, and it's the way we've been doing business since 2002, and the only way we know