From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#44236: [PATCH] xdisp: Apply nobreak-char-display also to NARROW NO-BREAK SPACE U+202F Date: Tue, 03 Nov 2020 20:44:18 +0200 Organization: LINKOV.NET Message-ID: <87y2ji2yd1.fsf@mail.linkov.net> References: <20201026111348.773761-1-bpeeluk.ref@yahoo.co.uk> <20201026111348.773761-1-bpeeluk@yahoo.co.uk> <837drdeyss.fsf@gnu.org> <87h7q98p4q.fsf@mail.linkov.net> <87imapcjam.fsf@gnus.org> <83v9epf6q6.fsf@gnu.org> <87d00w29my.fsf@mail.linkov.net> <83y2jkeuz6.fsf@gnu.org> <87wnz4yifo.fsf@mail.linkov.net> <83mu00etww.fsf@gnu.org> <87h7q8x2em.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33611"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: bpeeluk@yahoo.co.uk, larsi@gnus.org, 44236@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 03 20:11:24 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ka1iF-0008ek-To for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Nov 2020 20:11:24 +0100 Original-Received: from localhost ([::1]:45662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka1iD-0006jp-Dj for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Nov 2020 14:11:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka1hv-0006hU-Jn for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 14:11:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34894) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ka1hu-0004GL-OY for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 14:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ka1hu-0000sf-Jj for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 14:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Nov 2020 19:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44236 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch fixed Original-Received: via spool by 44236-submit@debbugs.gnu.org id=B44236.16044306033259 (code B ref 44236); Tue, 03 Nov 2020 19:11:02 +0000 Original-Received: (at 44236) by debbugs.gnu.org; 3 Nov 2020 19:10:03 +0000 Original-Received: from localhost ([127.0.0.1]:46432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ka1gw-0000qK-NS for submit@debbugs.gnu.org; Tue, 03 Nov 2020 14:10:03 -0500 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:45593) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ka1gv-0000pc-1g for 44236@debbugs.gnu.org; Tue, 03 Nov 2020 14:10:01 -0500 Original-Received: from mail.gandi.net (m91-129-102-160.cust.tele2.ee [91.129.102.160]) (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id CA04E24000B; Tue, 3 Nov 2020 19:09:53 +0000 (UTC) In-Reply-To: <87h7q8x2em.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 01 Nov 2020 22:12:01 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:192640 Archived-At: --=-=-= Content-Type: text/plain >> But that's not what I meant. I meant that if we want to base this on >> text properties, we should do this via hi-lock or similar, not in the >> display engine which treats all characters the same. > > Or markchars.el, or uni-confusables.el. Like these packages maybe better > to create another package e.g. nobreak.el, based on font-lock-mode? Now I extended markchars.el to highlight exactly the same characters as highlighted by nobreak-char-display, and additionally highlight them only in files names in Dired. This is configurable with such hook: (add-hook 'dired-mode-hook (lambda () (setq-local nobreak-char-display nil) (setq-local markchars-what '(markchars-nobreak-space markchars-nobreak-hyphen)) (markchars-mode 1))) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=markchars-nobreak.patch diff --git a/packages/markchars/markchars.el b/packages/markchars/markchars.el index 7d7fe2982..bd902f7c7 100644 --- a/packages/markchars/markchars.el +++ b/packages/markchars/markchars.el @@ -31,6 +31,12 @@ ;; `markchars-face-confusable' or `markchars-face-pattern' ;; respectively. ;; +;; You can set `nobreak-char-display' to nil, and use +;; `markchars-nobreak-space' and `markchars-nobreak-hyphen' +;; in Dired buffers to highlight `nobreak-space' and `nobreak-hyphen' +;; only in file names, not `nobreak-space' used by thousands separators +;; in file sizes (bug#44236). +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;; Change log: @@ -79,6 +85,16 @@ markchars-white "White face for `markchars-mode' char marking." :group 'markchars) +(defface markchars-nobreak-space + '((t (:inherit nobreak-space))) + "Face for displaying nobreak space." + :group 'markchars) + +(defface markchars-nobreak-hyphen + '((t (:inherit nobreak-hyphen))) + "Face for displaying nobreak hyphens." + :group 'markchars) + (defcustom markchars-face-pattern 'markchars-heavy "Pointer to face used for marking matched patterns." :type 'face @@ -101,12 +117,40 @@ markchars-simple-pattern :type 'regexp :group 'markchars) +(defvar markchars-nobreak-space-pattern + (rx (any ;; ?\N{SPACE} + ?\N{NO-BREAK SPACE} + ?\N{OGHAM SPACE MARK} + ?\N{EN QUAD} + ?\N{EM QUAD} + ?\N{EN SPACE} + ?\N{EM SPACE} + ?\N{THREE-PER-EM SPACE} + ?\N{FOUR-PER-EM SPACE} + ?\N{SIX-PER-EM SPACE} + ?\N{FIGURE SPACE} + ?\N{PUNCTUATION SPACE} + ?\N{THIN SPACE} + ?\N{HAIR SPACE} + ?\N{NARROW NO-BREAK SPACE} + ?\N{MEDIUM MATHEMATICAL SPACE} + ?\N{IDEOGRAPHIC SPACE})) + "A list of characters with general-category `Zs' (Separator, Space).") + +(defvar markchars-nobreak-hyphen-pattern + (rx (any ?\N{SOFT HYPHEN} ?\N{HYPHEN} ?\N{NON-BREAKING HYPHEN})) + "A list of hyphen characters.") + (defcustom markchars-what `(markchars-simple-pattern markchars-confusables ,@(when (fboundp 'idn-is-recommended) '(markchars-nonidn-fun))) "Things to mark, a list of regular expressions or symbols." :type `(repeat (choice :tag "Marking choices" + (const :tag "Non-ASCII space chars" + markchars-nobreak-space) + (const :tag "Non-ASCII hyphen chars" + markchars-nobreak-hyphen) (const :tag "Non IDN chars (Unicode.org tr39 suggestions)" markchars-nonidn-fun) @@ -129,6 +173,18 @@ markchars-set-keywords (when (eq what 'markchars-simple-pattern) (setq what markchars-simple-pattern)) (cond + ((eq what 'markchars-nobreak-space) + (list + markchars-nobreak-space-pattern + (list 0 '(markchars--render-nobreak-space + (match-beginning 0) + (match-end 0))))) + ((eq what 'markchars-nobreak-hyphen) + (list + markchars-nobreak-hyphen-pattern + (list 0 '(markchars--render-nobreak-hyphen + (match-beginning 0) + (match-end 0))))) ((eq what 'markchars-nonidn-fun) (list "\\<\\w+\\>" @@ -184,6 +240,22 @@ markchars--render-nonidn (put-text-property (point) (1+ (point)) 'face markchars-face-nonidn))) (forward-char)))) +(defun markchars--render-nobreak-space (beg end) + "Assign markchars pattern properties between BEG and END. +In Dired/WDired buffers, highlight nobreak-space characters +only in file names, not anywhere else, so it doesn't highlight +nobreak-space characters used by thousands separators in file sizes." + (when (or (not (derived-mode-p 'dired-mode 'wdired-mode)) + (or (get-text-property beg 'dired-filename) + (get-text-property end 'dired-filename))) + (put-text-property beg end 'face 'markchars-nobreak-space) + (put-text-property beg end 'markchars 'nobreak-space))) + +(defun markchars--render-nobreak-hyphen (beg end) + "Assign markchars pattern properties between BEG and END." + (put-text-property beg end 'face 'markchars-nobreak-hyphen) + (put-text-property beg end 'markchars 'nobreak-hyphen)) + ;;;###autoload (define-minor-mode markchars-mode "Mark special characters. --=-=-=--