From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Paul W. Rankin" Newsgroups: gmane.emacs.help Subject: Re: title-case function Date: Sun, 21 Apr 2019 16:40:55 +1000 Message-ID: References: <868sw4lye1.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; format=flowed Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="92013"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.0; emacs 26.2 Cc: help-gnu-emacs@gnu.org To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Apr 21 08:41:18 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hI6A9-000Npr-Fq for geh-help-gnu-emacs@m.gmane.org; Sun, 21 Apr 2019 08:41:18 +0200 Original-Received: from localhost ([127.0.0.1]:49643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hI6A8-00080c-Dh for geh-help-gnu-emacs@m.gmane.org; Sun, 21 Apr 2019 02:41:16 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:56502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hI69w-00080D-Nq for help-gnu-emacs@gnu.org; Sun, 21 Apr 2019 02:41:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hI69v-0006WR-IQ for help-gnu-emacs@gnu.org; Sun, 21 Apr 2019 02:41:04 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:50063) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hI69v-0006VO-4m for help-gnu-emacs@gnu.org; Sun, 21 Apr 2019 02:41:03 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 7DF3920963; Sun, 21 Apr 2019 02:41:02 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sun, 21 Apr 2019 02:41:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paulwrankin.com; h=references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; s=fm3; bh=6w3dkdMHw1uYb5QnS+jghI5kBK gs0+CgjePBzBAgSU0=; b=mFepat5SnWfzXL2dqUHm8CqDVsqlk0KzHY8/0RvjOy CltH+BimKNijrdcV2pckf2U6O8afD0ykyQwN04CbB7BzNfCftP0qRR/ORbvQ6Na/ gIEtCZDj+7PnJ1LFj1lx5gGW1mQf6K+eI8pRLb1a+RfII170eKNzWrUMpVcy3JWN SOs5rGdFI3DXNY4z0mToEVedskgKFcMpXE4Jb4nSwduBLBXY9OPhGuDRpNu+A5oO vxQp3anhTd1eDRno5UKXD0EskSEwJwdaaFDhHvUtT4BejdxehKseMnY3QvjXDc3p 2hvtymNmIy+K+BuuZfVhY8toAPQOmlBgxjq4hPmzZHPA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=6w3dkd MHw1uYb5QnS+jghI5kBKgs0+CgjePBzBAgSU0=; b=Ud/TSKSez1mEhwPxnBithH MxqWxGvslptEyw7O/Qwh9PtFkXBET+KtLPQtB4har015JAemw3NGWMCRb6tjMYej 8NH5JRq2T1G3VttCbwovld2hTWgtSZoOrt1ATPQWb+Vx0GO0wWbcxr0FlMvrMN8A NgnL5ulF4Cof83vKW1IROxaup8SfnnXfK6J6OD/IZ24RKKgDBQDFC9h3iJemb574 H7gyUu5U5RvXwGGRavDbiFU6/Do7cZEXWoq6cZorHYndT25BCVVu4IbtlvUnJdfe zoZ/V8v5hhHs56cnBOe7ZWbumfh0HQDCwMwe0hgaN7Nf/vUb8Ou46n/cTGsOQ9Lg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrgeefgddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfhgfhffvufgjfffkgggtsehttdertd dtredtnecuhfhrohhmpedfrfgruhhlucghrdcutfgrnhhkihhnfdcuoehhvghllhhosehp rghulhifrhgrnhhkihhnrdgtohhmqeenucffohhmrghinhepphgruhhlfihrrghnkhhinh drtghomhdpughishgtohhgshdrtghomhenucfkphepuddvtddrvddvrddutdekrddufeel necurfgrrhgrmhepmhgrihhlfhhrohhmpehhvghllhhosehprghulhifrhgrnhhkihhnrd gtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Original-Received: from localhost (unknown [120.22.108.139]) by mail.messagingengine.com (Postfix) with ESMTPA id 34F4510316; Sun, 21 Apr 2019 02:41:00 -0400 (EDT) In-reply-to: <868sw4lye1.fsf@zoho.eu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:120005 Archived-At: 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