unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Sam Steingold <sds@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: idiomatic case-insensitive string comparison?
Date: Mon, 18 Jul 2022 15:41:28 -0400	[thread overview]
Message-ID: <lza696us2f.fsf@3c22fb11fdab.ant.amazon.com> (raw)
In-Reply-To: <lzedyiuxcc.fsf@3c22fb11fdab.ant.amazon.com> (Sam Steingold's message of "Mon, 18 Jul 2022 13:47:31 -0400")

Apparently, I need to do

--8<---------------cut here---------------start------------->8---
(defun string=-ic (a b)
  "case-insensitive string equality test"
  (eq t (compare-strings a nil nil b nil nil t)))
--8<---------------cut here---------------end--------------->8---

I discovered `compare-strings' by noticing that `string-prefix-p'
accepts an IGNORE-CASE argument and looking at its source code.

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
https://www.peaceandtolerance.org/ https://camera.org https://ffii.org
Between grand theft and a legal fee, there only stands a law degree.



      reply	other threads:[~2022-07-18 19:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 17:47 idiomatic case-insensitive string comparison? Sam Steingold
2022-07-18 19:41 ` Sam Steingold [this message]

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=lza696us2f.fsf@3c22fb11fdab.ant.amazon.com \
    --to=sds@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /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).