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: Thu, 11 Jun 2015 22:10:53 +0200
User-agent: slrn/pre1.0.0-18 (Linux)

* Barry Fishman <address@hidden> 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




reply via email to

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