Subject: RE: bug#22147: Obsolete search-forward-lax-whitespace

From: Drew Adams <[email-masked]>
Date: Thu, 17 Dec 2015 09:21:05 -0800 (PST)

>> char-fold-symmetric could wait for later, but we definitely need
>> char-fold-ad-hoc now before the release because the users should be
>> able to customize the default rules.
>
> Indeed.  Once we do that, we also need a variable to determine
> whether we should derive the default table from the unicode
> standard (like we currently do) or just use an empty default with
> the ad-hoc rules slapped on top. 

Users should be able to define their own equivalence classes (groups),
not just one class.  Each class should be the value of a user option.

Here is one simple and flexible way to do this:

1. Define a user option, `char-folding-classes', which is a list of
   any number of (OPTION-NAME DOC-STRING) pairs, where OPTION-NAME
   is a symbol that will name a user option and DOC-STRING is its doc
   string.

   Each symbol would automatically be used to define an option (a
   defcustom) that the user can then use to define a given equivalence
   class.

2. The generated defcustom for each user option specified in option
   `char-folding-classes' would allow for any number of entries, each
   of which could be a `choice' of either of these defcustom types:

   a. An alist, such as used currently in my `char-fold-ad-hoc' option:
      Each entry is a list of a char and the strings that fold into it.

   b. A function that populates such an alist.

The default value of `char-folding-classes' would be something like
this:

((char-fold-diacriticals
  "Classes of chars equivalent because they have the same base char.")
 (char-fold-quotations
  "Classes of equivalent quotation-mark characters."))

Option `char-fold-diacriticals' would have as its default value a
function that returns the alist of diacritical-equivalent classes
that we provide today.  Its code would be derived from what we use
today.

(If needed, a user can replace the function with another that
defines some of the classes differently or that provides only a
subset of the classes we provide today.  But most users would
probably not customize this option.)

Option `char-fold-quotations' would have as its default value what I
use as the default value of my `char-fold-ad-hoc', which is an alist
of the quotation-mark equivalences provided today by character-fold.el:

((?\" "＂" "“" "”" "”" "„" "⹂" "〞" "‟" "‟" "❞" "❝"
      "❠" "“" "„" "〝" "〟" "🙷" "🙶" "🙸" "«" "»")
 (?' "❟" "❛" "❜" "‘" "’" "‚" "‛" "‚" "󠀢" "❮" "❯" "‹" "›")
 (?` "❛" "‘" "‛" "󠀢" "❮" "‹"))

Having an option that lets users define any number of classes, and
having each class be defined by a user option, is flexible.

Having multiple classes, each associated with a variable (option),
lets users and libraries easily enable/disable different equivalence
classes in different contexts.