From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#26666: 26.0.50; Unused faces drop from hi-lock--unused-faces Date: Wed, 26 Apr 2017 19:13:37 +0900 Message-ID: <87inlr5ve6.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1493201661 21015 195.159.176.226 (26 Apr 2017 10:14:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 26 Apr 2017 10:14:21 +0000 (UTC) To: 26666@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 26 12:14:17 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3Jxg-0005KS-5u for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Apr 2017 12:14:16 +0200 Original-Received: from localhost ([::1]:54011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3Jxl-0007um-Qa for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Apr 2017 06:14:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3JxV-0007nS-SD for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2017 06:14:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3JxS-0005XD-Mx for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2017 06:14:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d3JxS-0005X1-J3 for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2017 06:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d3JxS-0005aQ-BW for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2017 06:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Apr 2017 10:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 26666 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.149320163721451 (code B ref -1); Wed, 26 Apr 2017 10:14:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Apr 2017 10:13:57 +0000 Original-Received: from localhost ([127.0.0.1]:40590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3JxN-0005Zu-DK for submit@debbugs.gnu.org; Wed, 26 Apr 2017 06:13:57 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57170) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3JxL-0005Ze-J5 for submit@debbugs.gnu.org; Wed, 26 Apr 2017 06:13:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3JxF-0005Sq-7l for submit@debbugs.gnu.org; Wed, 26 Apr 2017 06:13:50 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:43110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3JxF-0005Sm-3w for submit@debbugs.gnu.org; Wed, 26 Apr 2017 06:13:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3JxD-0007aH-Jo for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2017 06:13:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3JxA-0005Qu-DZ for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2017 06:13:47 -0400 Original-Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:36378) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d3JxA-0005QI-5e for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2017 06:13:44 -0400 Original-Received: by mail-pg0-x22a.google.com with SMTP id t7so3108677pgt.3 for ; Wed, 26 Apr 2017 03:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=2YmFtUjRkr1W4OodD7VY1tTDrUT0B3Bl1FHv+Tp7C2k=; b=ZFDQR/btgkPKeywXWS5XE7LgFA3I7pJvL7O60Z7QiVg1acWKwwHS6Ti33j0RP9IJFT GX1lRWFJBm7hE9vdTwP/Kr0vBNX89JoPMoOJT26HS+8NME96zbLedmj4k1fzqSUlXMW7 HLlOqE+VbNDgKh2d0/7wwQMN8SrwcUPQwQscROYOOp2o0islZLQZbpUC6WeH8CNF95KV 9+4dtSn1WXUBel+oJCzAoN909cGtLJUT1xomi48NxpfBjw7XPxpZ3saHAyl+lygb7Tqq d7Or9aYh2zJ69ttVNDVRcbr/epvdyzNtvoufodR1T5isS5RsZSAtzogaYkMx5vYQO7DY Lf7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=2YmFtUjRkr1W4OodD7VY1tTDrUT0B3Bl1FHv+Tp7C2k=; b=gtuELL/5Vr/4YP7mJlIkEbQl8z8hgo58e9kE81f9Ja4lW+dR7pqNZbb53D4O9NklTf wdypePZMuoH9FodfsV8qtBbS6BdfgFYzTVD8ADgRoYfC/EsDMZJYJOk0EZBT+SQsjTLT 3nsy6gNl5/uYQhP2dcH7A4lPLeUSHS1HL7d/X5+8uiZcS8i20NC/eZoEl+Mncfd07+FM paGNSjhmznhSkmWxQfhFIwf+4hvsb8ApMiEfgNqNJ56Siu9/1Twx3nPFUTwXJkX0aPhT HogcSqXgHB6lcf1x3lxv/+JBIJj6KNGtBEnDG1eIRoJ3JLIQN11rCvGVfhYRFLv0gW+r lbUQ== X-Gm-Message-State: AN3rC/5q18uYfr6qF7xHsuW0XFfw7eWac/u5nkxLeyRGt2ZYm1cPdQmL DjwpOpkWhN8DwS6J X-Received: by 10.84.230.229 with SMTP id e92mr42143107plk.2.1493201622803; Wed, 26 Apr 2017 03:13:42 -0700 (PDT) Original-Received: from calancha-pc (222.139.137.133.dy.bbexcite.jp. [133.137.139.222]) by smtp.gmail.com with ESMTPSA id r90sm41445705pfl.120.2017.04.26.03.13.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Apr 2017 03:13:42 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:132002 Archived-At: emacs -Q M-s hr t RET RET M-s hr t RET RET ; Already highlighted M-s hr f RET RET ; Should offer hi-pink face, but it offers hi-green. --8<-----------------------------cut here---------------start------------->8--- >From 287bff616ef715c54628fba5c6db95b878f1519f Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Wed, 26 Apr 2017 19:06:47 +0900 Subject: [PATCH] Drop face from hi-lock--unused-faces only when used * lisp/hi-lock.el (hi-lock-set-pattern): If REGEXP is already highlighted, then push FACE into hi-lock--unused-faces. * test/lisp/hi-lock-tests.el (hi-lock-bug26666): Add test. --- lisp/hi-lock.el | 3 ++- test/lisp/hi-lock-tests.el | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/lisp/hi-lock-tests.el diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index ebd18621ef..5139e01fa8 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -695,7 +695,8 @@ hi-lock-set-pattern (setq regexp (hi-lock--hashcons regexp)) (let ((pattern (list regexp (list 0 (list 'quote face) 'prepend)))) ;; Refuse to highlight a text that is already highlighted. - (unless (assoc regexp hi-lock-interactive-patterns) + (if (assoc regexp hi-lock-interactive-patterns) + (add-to-list 'hi-lock--unused-faces (face-name face)) (push pattern hi-lock-interactive-patterns) (if (and font-lock-mode (font-lock-specified-p major-mode)) (progn diff --git a/test/lisp/hi-lock-tests.el b/test/lisp/hi-lock-tests.el new file mode 100644 index 0000000000..2cb662cfac --- /dev/null +++ b/test/lisp/hi-lock-tests.el @@ -0,0 +1,40 @@ +;;; hi-lock-tests.el --- Tests for hi-lock.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; Author: Tino Calancha +;; Keywords: + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Code: + +(require 'ert) +(require 'hi-lock) + +(ert-deftest hi-lock-bug26666 () + "Test for http://debbugs.gnu.org/26666 ." + (let ((faces hi-lock-face-defaults)) + (with-temp-buffer + (insert "a A b B\n") + (cl-letf (((symbol-function 'completing-read) + (lambda (prompt coll x y z hist defaults) + (car defaults)))) + (dotimes (_ 2) + (let ((face (hi-lock-read-face-name))) + (hi-lock-set-pattern "a" face)))) + (should (equal hi-lock--unused-faces (cdr faces)))))) + +(provide 'hi-lock-tests) +;;; hi-lock-tests.el ends here -- 2.11.0 --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-04-26 Repository revision: 513d000c75b582edf9acef1c6df00ee2c382dcb9