unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Paul W. Rankin" <hello@paulwrankin.com>
To: Emanuel Berg <moasenwood@zoho.eu>
Cc: help-gnu-emacs@gnu.org
Subject: Re: title-case function
Date: Sun, 21 Apr 2019 16:40:55 +1000	[thread overview]
Message-ID: <m2wojn5094.fsf@paulwrankin.com> (raw)
In-Reply-To: <868sw4lye1.fsf@zoho.eu>


On Sun, Apr 21 2019, Emanuel Berg wrote:
> Did you look into this [2] ?
>     
> BTW make a search for "Emanuel Berg" :)

Ah right, no I didn't find that one. Nice.

Given that there are no definitive rules regarding title case minor 
words, I think I prefer using a defcustom for these (i.e. I wouldn't 
consider "over" or "past" as a minor words because they're four 
letters).

I've found thing-at-point to be quite resource hungry so I try to avoid 
using it unless absolutely necessary.

I am curious about the comparative performance of using (member WORDS) 
vs (looking-at (regexp-opt WORDS)).

>        (if (looking-at "[:\x2013\x2014]")
>            (capitalize-word 1)
>          (skip-syntax-forward "-." last-word)
>          (if (looking-at (concat "\\b" (regexp-opt 
>          title-case-minor-words)
>                                  "\\b") )
>              (downcase-word 1)
>            (capitalize-word 1)))
>
> It seems to work alright, but I don't
> understand it? You don't need `progn' anymore?

The regexp "[:\x2013\x2014]" just looks for a colon, an en dash or an em 
dash and makes sure to capitalize a word following one of those. I used 
the character codes for the dashes because otherwise they're difficult 
to discern from hyphens in monospace.

Do you mean using progn for the ELSE in the if expression? From the 
documentation on `if':

> (if COND THEN ELSE...)
>
> THEN must be one expression, but ELSE... can be zero or more 
> expressions.

So yeah, progn is unnecessary.

Thanks for the trance, but I'm already spending my rainy Easter day 
listening to this: 
https://www.discogs.com/Various-Dark-Was-The-Night/release/1655481

-- 
https://www.paulwrankin.com



  reply	other threads:[~2019-04-21  6:40 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-21  3:56 title-case function Paul W. Rankin
2019-04-21  5:29 ` Emanuel Berg
2019-04-21  6:40   ` Paul W. Rankin [this message]
2019-04-21 10:31     ` `if' in Elisp (was: Re: title-case function) Emanuel Berg
2019-04-21 12:34       ` Drew Adams
2019-04-21 14:02         ` Emanuel Berg
2019-04-21  5:57 ` title-case function Eli Zaretskii
2019-04-21  6:10   ` Emanuel Berg
2019-04-21  6:45   ` Paul W. Rankin
2019-04-21  7:20     ` Eli Zaretskii
2019-04-21  5:57 ` Jean-Christophe Helary
2019-04-21 12:45   ` Paul W. Rankin
2019-04-21 12:59     ` Jean-Christophe Helary
2019-04-21 13:25       ` Paul W. Rankin
2019-04-21 13:58       ` the English language part 2 (was: Re: title-case function) Emanuel Berg
2019-04-21 14:23         ` the English language part 2 Ralph Seichter
2019-04-21 14:32           ` Emanuel Berg
2019-04-21 14:42             ` Ralph Seichter
2019-04-21 15:08               ` Emanuel Berg
2019-04-21 15:21                 ` Ralph Seichter
2019-04-22  4:13                 ` Marcin Borkowski
2019-04-22  7:55                   ` Paul W. Rankin
2019-04-22 21:21                     ` Emanuel Berg
2019-04-22 21:31                   ` Emanuel Berg
2019-04-25 22:58                   ` Europe in 1648 (was: Re: the English language part 2) Emanuel Berg
2019-04-26 13:40                     ` Ralph Seichter
2019-04-27 21:16                       ` Emanuel Berg
2019-04-29  3:26                         ` Europe in 1648 Van L
2019-04-21 15:22             ` the English language part 2 Drew Adams
2019-04-21 15:38               ` Jean-Christophe Helary
2019-04-21 16:16               ` Emanuel Berg
2019-04-21 13:45     ` title-case function Emanuel Berg
2019-04-21 13:37   ` the English language, again (was: Re: title-case function) Emanuel Berg
2019-04-21 13:38   ` Emanuel Berg
2019-04-22 16:41     ` Robert Thorpe
2019-04-22 21:44       ` Emanuel Berg
2019-04-23  2:35         ` Emanuel Berg
2019-04-24 11:56           ` the English language, again Van L

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2wojn5094.fsf@paulwrankin.com \
    --to=hello@paulwrankin.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=moasenwood@zoho.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).