[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add some aliases for re-related functions

From: Richard Stallman
Subject: Re: Add some aliases for re-related functions
Date: Sun, 03 May 2020 23:04:41 -0400

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > replace-regexp-in-string    re-replace-in-string
  > replace-match                       re-replace-match
  > string-match                        re-search-in-string
  > string-match-p                      re-match-in-string-p
  > match-string                        re-matched-string
  > match-string-no-properties  re-matched-string-no-properties
  > match-beginning                     re-match-beginning
  > match-end                   re-match-end

  > looking-at                  re-match-after-point
  > looking-back                        re-match-before-point
  > looking-at-p                        re-match-after-point-p
  > posix-search-forward                re-posix-search-forward
  > posix-search-backward               re-posix-search-backward
  > posix-looking-at            re-posix-looking-at
  > posix-search-in-string              re-posix-search-in-string

Some of these are painfully long.

This sort of systematization is desirable, all else being equal.  But
we have to minimize the costs also, and a longer name is a real cost.

The functions whose names start with 'match-' are not limited to
regexps.  match-beginning and match-end are often used after
search-forward.  For brevity, I think it is better to keep
those names unchanged.

  > replace-match                       match-replace

That puts it into the 'match-' group, where it fits well.
It, like those others, is for operating on a match found by
another function.

  > replace-regexp-in-string            replace-regexp-string

That is parallel to replace-regexp.  If we don't rename
replace-regexp, let's pick a name for this that parallels it.

  > string-match                        re-search-string
  > string-match-p                      re-search-string-p

Since what these do is search, they may as well be called 'search'.
We can reserve 'match' to mean an anchored match.

  > looking-at                          re-match
  > looking-back                        re-match-back
  > looking-at-p                        re-match-p

Those are nice and short.

  > posix-search-forward                re-search-forward-posix
  > posix-search-backward               re-search-backward-posix
  > posix-looking-at                    re-match-posix
  > posix-string-match                  re-search-string-posix

Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)

reply via email to

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