From: Juri Linkov <juri@linkov.net>
To: Artur Malabarba <bruce.connor.am@gmail.com>
Cc: 22147@debbugs.gnu.org
Subject: bug#22147: Obsolete search-forward-lax-whitespace
Date: Wed, 18 May 2016 22:34:05 +0300 [thread overview]
Message-ID: <87mvnngnyq.fsf@mail.linkov.net> (raw)
In-Reply-To: <CAAdUY-KRCSt1J-U_soOwJ5QZz=VHVWUUVzBAXjbP7mBrVGfU-Q@mail.gmail.com> (Artur Malabarba's message of "Wed, 18 May 2016 03:00:35 +0000")
> I'm of the opinion that we should avoid over thinking this feature for the
> first release. And I'm also of the opinion that complicated custom-vars
> (like alists of alists) are less helpful than simple custom vars. So I'd
> strongly prefer if we don't turn this variable into something more
> complicated.
I agree that we are better off starting with simpler customization,
and then gradually adding more layers later when needed.
I wonder why you removed defvar mappings from your initial patches
with ‘isearch-groups-alist’ and ‘isearch--character-fold-extras’
(a similar variable is also presented in Drew's ‘char-fold-ad-hoc’).
Now I tried to reintroduce these lists with different names:
‘char-fold-include-alist’ with a list to add to default mappings and
‘char-fold-exclude-alist’ with a list to remove from default mappings
taking into account all opinions expressed on emacs-devel for the
default values:
diff --git a/lisp/char-fold.el b/lisp/char-fold.el
index 68bea29..68d1eb0 100644
--- a/lisp/char-fold.el
+++ b/lisp/char-fold.el
@@ -22,10 +22,68 @@
;;; Code:
-(eval-and-compile (put 'char-fold-table 'char-table-extra-slots 1))
+(put 'char-fold-table 'char-table-extra-slots 1)
\f
-(defconst char-fold-table
- (eval-when-compile
+(defcustom char-fold-include-alist
+ (append
+ '((?\" """ "“" "”" "”" "„" "⹂" "〞" "‟" "‟" "❞" "❝" "❠" "“" "„" "〝" "〟" "🙷" "🙶" "🙸" "«" "»")
+ (?' "❟" "❛" "❜" "‘" "’" "‚" "‛" "‚" "" "❮" "❯" "‹" "›")
+ (?` "❛" "‘" "‛" "" "❮" "‹")
+ (?→ "->") (?⇒ "=>")
+ (?1 "⒈") (?2 "⒉") (?3 "⒊") (?4 "⒋") (?5 "⒌") (?6 "⒍") (?7 "⒎") (?8 "⒏") (?9 "⒐") (?0 "🄀")
+ )
+ (unless (string-match-p "^\\(?:da\\|n[obn]\\)" (getenv "LANG"))
+ '((?o "ø")
+ (?O "Ø")))
+ (unless (string-match-p "^pl" (getenv "LANG"))
+ '((?l "ł")
+ (?L "Ł")))
+ (unless (string-match-p "^de" (getenv "LANG"))
+ '((?ß "ss")))
+ )
+ "Ad hoc character foldings.
+Each entry is a list of a character and the strings that fold into it."
+ :set (lambda (symbol value)
+ (custom-set-default symbol value)
+ (with-no-warnings
+ (setq char-fold-table (make-char-fold-table))))
+ :initialize 'custom-initialize-default
+ :type '(repeat (cons
+ (character :tag "Fold to character")
+ (repeat (string :tag "Fold from string"))))
+ :version "25.1"
+ :group 'isearch)
+
+(defcustom char-fold-exclude-alist
+ (append
+ (when (string-match-p "^es" (getenv "LANG"))
+ '((?n "ñ")
+ (?N "Ñ")))
+ (when (string-match-p "^\\(?:sv\\|fi\\|et\\)" (getenv "LANG"))
+ '((?a "ä")
+ (?A "Ä")
+ (?o "ö")
+ (?O "Ö")))
+ (when (string-match-p "^\\(?:sv\\|da\\|n[obn]\\)" (getenv "LANG"))
+ '((?a "å")
+ (?A "Å")))
+ (when (string-match-p "^ru" (getenv "LANG"))
+ '((?и "й")
+ (?И "Й"))))
+ "Character foldings to remove from default mappings.
+Each entry is a list of a character and the strings that unfold from it."
+ :set (lambda (symbol value)
+ (custom-set-default symbol value)
+ (with-no-warnings
+ (setq char-fold-table (make-char-fold-table))))
+ :initialize 'custom-initialize-default
+ :type '(repeat (cons
+ (character :tag "Unfold to character")
+ (repeat (string :tag "Unfold from string"))))
+ :version "25.1"
+ :group 'isearch)
+
+(defun make-char-fold-table ()
(let ((equiv (make-char-table 'char-fold-table))
(equiv-multi (make-char-table 'char-fold-table))
(table (unicode-property-table-internal 'decomposition)))
@@ -58,9 +116,11 @@ char-fold-table
;; If there's no formatting tag, ensure that char matches
;; its decomp exactly. This is because we want 'ä' to
;; match 'ä', but we don't want '¹' to match '1'.
+ (unless (and (assq char char-fold-exclude-alist)
+ (member (apply #'string decomp) (assq char char-fold-exclude-alist)))
(aset equiv char
(cons (apply #'string decomp)
- (aref equiv char))))
+ (aref equiv char)))))
;; Allow the entire decomp to match char. If decomp has
;; multiple characters, this is done by adding an entry
@@ -74,9 +134,11 @@ char-fold-table
(cons (cons (apply #'string (cdr decomp))
(regexp-quote (string char)))
(aref equiv-multi (car decomp))))
+ (unless (and (assq (car decomp) char-fold-exclude-alist)
+ (member (char-to-string char) (assq (car decomp) char-fold-exclude-alist)))
(aset equiv (car decomp)
(cons (char-to-string char)
- (aref equiv (car decomp))))))))
+ (aref equiv (car decomp)))))))))
(funcall make-decomp-match-char decomp char)
;; Do it again, without the non-spacing characters.
;; This allows 'a' to match 'ä'.
@@ -98,9 +160,7 @@ char-fold-table
table)
;; Add some manual entries.
- (dolist (it '((?\" """ "“" "”" "”" "„" "⹂" "〞" "‟" "‟" "❞" "❝" "❠" "“" "„" "〝" "〟" "🙷" "🙶" "🙸" "«" "»")
- (?' "❟" "❛" "❜" "‘" "’" "‚" "‛" "‚" "" "❮" "❯" "‹" "›")
- (?` "❛" "‘" "‛" "" "❮" "‹")))
+ (dolist (it char-fold-include-alist)
(let ((idx (car it))
(chars (cdr it)))
(aset equiv idx (append chars (aref equiv idx)))))
@@ -114,6 +174,9 @@ char-fold-table
(aset equiv char re))))
equiv)
equiv))
+
+(defvar char-fold-table
+ (make-char-fold-table)
"Used for folding characters of the same group during search.
This is a char-table with the `char-fold-table' subtype.
next prev parent reply other threads:[~2016-05-18 19:34 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-11 23:52 bug#22147: Obsolete search-forward-lax-whitespace Juri Linkov
2015-12-12 0:44 ` Artur Malabarba
2015-12-12 23:31 ` Juri Linkov
2015-12-13 0:29 ` Artur Malabarba
2015-12-14 0:23 ` Juri Linkov
2015-12-14 1:11 ` Artur Malabarba
2015-12-14 23:58 ` Juri Linkov
2015-12-15 10:15 ` Artur Malabarba
2015-12-16 0:57 ` Juri Linkov
2015-12-16 1:47 ` Drew Adams
2016-05-14 20:45 ` Juri Linkov
2016-05-14 22:20 ` Artur Malabarba
2016-05-14 22:27 ` Drew Adams
2016-05-15 20:45 ` Juri Linkov
2016-05-14 22:22 ` Drew Adams
2016-05-15 20:56 ` Juri Linkov
2016-05-15 21:51 ` Drew Adams
2016-05-17 20:55 ` Juri Linkov
2016-05-17 21:55 ` Drew Adams
2016-05-18 3:00 ` Artur Malabarba
2016-05-18 19:34 ` Juri Linkov [this message]
2016-05-18 20:40 ` Artur Malabarba
2016-05-30 20:57 ` Juri Linkov
2016-06-01 15:03 ` Artur Malabarba
2020-09-05 14:54 ` Lars Ingebrigtsen
2020-09-07 18:34 ` Juri Linkov
2015-12-16 10:59 ` Artur Malabarba
2015-12-17 0:57 ` Juri Linkov
2015-12-17 16:33 ` Artur Malabarba
2015-12-17 17:21 ` Drew Adams
2015-12-17 18:47 ` Artur Malabarba
2015-12-17 22:16 ` Drew Adams
2015-12-18 0:55 ` Artur Malabarba
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=87mvnngnyq.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=22147@debbugs.gnu.org \
--cc=bruce.connor.am@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).