From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gabriel Newsgroups: gmane.emacs.bugs Subject: bug#47083: 28.0.50; [PATCH] Use color.el on pulse.el Date: Thu, 11 Mar 2021 22:43:52 -0300 Message-ID: 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="35021"; mail-complaints-to="usenet@ciao.gmane.io" To: 47083@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 12 02:45:46 2021 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 1lKWs6-0008zA-7E for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Mar 2021 02:45:46 +0100 Original-Received: from localhost ([::1]:54664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKWs5-00018P-AO for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Mar 2021 20:45:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKWrO-000156-DO for bug-gnu-emacs@gnu.org; Thu, 11 Mar 2021 20:45:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lKWrO-0002C1-5Q for bug-gnu-emacs@gnu.org; Thu, 11 Mar 2021 20:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lKWrO-0002bc-2y for bug-gnu-emacs@gnu.org; Thu, 11 Mar 2021 20:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gabriel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Mar 2021 01:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47083 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16155134659950 (code B ref -1); Fri, 12 Mar 2021 01:45:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Mar 2021 01:44:25 +0000 Original-Received: from localhost ([127.0.0.1]:55564 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKWqm-0002aP-GC for submit@debbugs.gnu.org; Thu, 11 Mar 2021 20:44:25 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:55780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKWqY-0002a5-D0 for submit@debbugs.gnu.org; Thu, 11 Mar 2021 20:44:22 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKWqY-0000Py-5i for bug-gnu-emacs@gnu.org; Thu, 11 Mar 2021 20:44:10 -0500 Original-Received: from mail-dm6nam11olkn2022.outbound.protection.outlook.com ([40.92.19.22]:52960 helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKWqS-0001gs-BF for bug-gnu-emacs@gnu.org; Thu, 11 Mar 2021 20:44:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dVDpVBBFzRivB33EB2gfvqUXkktKTJHNzWM+vtqU8BXbPMyyjOX2j6gzZojK2rYb9GO5aNQZsSSym6WkvZnxH9yjpo/7yMXtJlGpGJN4VZAtEYpE4s/9rUn4dameDiskZ9StL/Xk/rAD94yxw+QhJ2RAN3jqf8DnfkIEtN6F00XsxFx7lbGL9xobNBTTa/WRtqpJlEyTemTVBIBbkr4E/ownprPn71RVZX1xr3s5OMPuvf+sDosr/w6je4vYAUrgCRw5MvSqRMpoxgfXSs5UQPHfxepksHWLq6Nj+3y2wNB7pVg/qfs1XISloJSEi4WjiCJ0jGu6r1mZs+vwqu6pQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fuPuUz5X5Xk8G8afyKLRZaB0kIjXW9XmGci/7ClBsiM=; b=jcanesPWmbv1DN3b1+TxCrsIZKILy/WK7uO+tCCGlZsFLSAYK8YB3/9DCTs1yt36x7+2jmBhDFffpbxoU2rcSGG3trouBKCivNITrDPCPdpNuHMxUAM9tpqpH0gKtaft3MYQW++PEjX8e3FSREaaJcCLdROjvZFAFS1I971b4uH4SI7huZsymwssQrj8gYbJnc1OxD0sUN75Iv5MhArsT0Cri3Aq+o36Q5KD15Q7DOivc5RgG/yxp7jAFif+ws2R5QvqH0DQM6M/k67FCGpF8LFpwBwMXOUjVio6e0Fv9b7Eu8PmtTwFosizVNZwt76mRWnC7DgGtotGFu+dFSPyRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fuPuUz5X5Xk8G8afyKLRZaB0kIjXW9XmGci/7ClBsiM=; b=W7c+C5QdZ0uPYi5uetXeTFF7see1bnJKk2dNFylrK1djozcJcenOTZ9AZz7fuTMZxJmYpJKgS3TEpkdwCMybJ5s5z6QQdBlIilHDjB+5lEMW5AEL/laa8i/gNgWyxjoznjQe6R4ixtxe9gocmGYj7IdDL1ZQ4cNIBKvI0P7wlQkvOKlFMvIHb3s1IlD8sS6vAmWBRM8atPvJBRssoUY6BmXuZrYLLAgzGxwxbgGZYl2lpQIVI0fwl9JlZyHgkMocaOOh8TZgmNJ5vm+qhp5N5b/PqsEsNqtkLKb6oyi/8jYdcvxhXcLwhjrMmCffVODuOkwjGubtvTOgqRwjwm0L6Q== Original-Received: from DM6NAM11FT008.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::41) by DM6NAM11HT134.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::281) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Fri, 12 Mar 2021 01:43:59 +0000 Original-Received: from CH2PR01MB5879.prod.exchangelabs.com (2a01:111:e400:fc4d::42) by DM6NAM11FT008.mail.protection.outlook.com (2a01:111:e400:fc4d::85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31 via Frontend Transport; Fri, 12 Mar 2021 01:43:59 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:0AD3CDC0EAB0D60260F8C85FA4B92C778D17EA335E33D217DE75D26CFB7F7392; UpperCasedChecksum:F1F72E1460E3EB6C790147606AB31B2058E489CECA2467193FF09D8C27453F3D; SizeAsReceived:7232; Count:42 Original-Received: from CH2PR01MB5879.prod.exchangelabs.com ([fe80::592f:9a58:d8cd:d9c9]) by CH2PR01MB5879.prod.exchangelabs.com ([fe80::592f:9a58:d8cd:d9c9%7]) with mapi id 15.20.3912.028; Fri, 12 Mar 2021 01:43:59 +0000 X-TMN: [FeHVNG4Ijd0cYNGC4/VPcaI9dv6eEDLEjVLx6IYkmGc81RpZAfK+g7GSRv6GA4J1] X-ClientProxiedBy: CP3P284CA0146.BRAP284.PROD.OUTLOOK.COM (2603:10d6:103:6a::31) To CH2PR01MB5879.prod.exchangelabs.com (2603:10b6:610:3c::12) X-Microsoft-Original-Message-ID: <87k0qdcfjb.fsf@hotmail.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from precision5540 (2804:431:c7f2:d29a:abdc:28c1:c75d:6170) by CP3P284CA0146.BRAP284.PROD.OUTLOOK.COM (2603:10d6:103:6a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 01:43:57 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 42 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 2508dd24-5b5d-445b-ad9c-08d8e4f84dee X-MS-TrafficTypeDiagnostic: DM6NAM11HT134: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WnJ8UGyLg08GDics5ahzcAyN7W4dfoSvN+AEQvrjNeaQF+CTobc+93I8lU7AmYZ+LvlasQexMvkO5huUchYfPq89gXEbs89jb9LF19wqIXGP2KMq3CKVde/iONcDHjz0eA3nnBR9t53BVolFK4hsRqNQWY97u7pcZKJocnMjFgoN62coyqyVqU5Ii2nQPrfTkUm9QgJPtCbxO+VNNlOEFnxGo+lg2LLb/lO2fZvKTdflPCof/ADj7z1pTXriadm3Y2MYTTHbYTGSz9exSuE/kw+WyO/JeT+1Nl3YAoxFoxqrtzJby65odbxbGTHE7uY0tjfTsPMdn8IDtbjvNLynVXFdMWBk0UhCe7LGFl4vN2/uGIax8wehE10dgxZPhv3m X-MS-Exchange-AntiSpam-MessageData: CcNHRs8vvAKfMUHQAtlSprJY3ykoZixGXNWMw5R8OkDdtDQ1lJ+2+6NpyEc7+iVxRAm4aHWn3DYuuKYYSkIGdxMRR9Yk5qWxx3nIE+ptXRCiWHbcBBWqhlkT8PaJX4rFVO1kYp+g3+jPKotzWCvnXgTdTR7BJbvVMu7+fiOqffrA9+upusBBvoJPjIX7PFZPwqn0V+f82BgPF8PGdZmJpw== X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2508dd24-5b5d-445b-ad9c-08d8e4f84dee X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 01:43:59.3109 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM11HT134 Received-SPF: pass client-ip=40.92.19.22; envelope-from=gabriel376@hotmail.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:202121 Archived-At: --=-=-= Content-Type: text/plain Replace custom color calculation in pulse.el with color-gradient from color.el and some other minor changes. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-lisp-cedet-pulse.el-Use-color.el.patch >From c9e6614c01941243752e590e486788d029ecd3e8 Mon Sep 17 00:00:00 2001 From: Gabriel do Nascimento Ribeiro Date: Thu, 11 Mar 2021 22:37:12 -0300 Subject: [PATCH] lisp/cedet/pulse.el: Use color.el (pulse-int-to-hex): remove function (pulse-color-values-to-hex): remove function (pulse-lighten-highlight): remove function (pulse-momentary-iteration): add variable (pulse-momentary-highlight-overlay): use color-gradient from color.el (pulse-tick): receive colors and update overlay background based on iteration --- lisp/cedet/pulse.el | 102 +++++++++++++------------------------------- 1 file changed, 30 insertions(+), 72 deletions(-) diff --git a/lisp/cedet/pulse.el b/lisp/cedet/pulse.el index 3257feb1fe..ca4f7f48c2 100644 --- a/lisp/cedet/pulse.el +++ b/lisp/cedet/pulse.el @@ -30,10 +30,9 @@ ;; ;; The following are useful entry points: ;; -;; `pulse' - Cause `pulse-highlight-face' to shift toward background color. +;; `pulse-tick' - Cause `pulse-highlight-face' to shift toward background color. ;; Assumes you are using a version of Emacs that supports pulsing. ;; -;; ;; `pulse-momentary-highlight-one-line' - Pulse a single line at POINT. ;; `pulse-momentary-highlight-region' - Pulse a region. ;; `pulse-momentary-highlight-overlay' - Pulse an overlay. @@ -50,7 +49,9 @@ ;; ;; Pulse is a part of CEDET. http://cedet.sf.net -(defun pulse-available-p () +(require 'color) + +(defun pulse-available-p () "Return non-nil if pulsing is available on the current frame." (condition-case nil (let ((v (color-values (face-background 'default)))) @@ -90,69 +91,27 @@ pulse-highlight-face :group 'pulse) ;;; Code: -;; -(defun pulse-int-to-hex (int &optional nb-digits) - "Convert integer argument INT to a #XXXXXXXXXXXX format hex string. -Each X in the output string is a hexadecimal digit. -NB-DIGITS is the number of hex digits. If INT is too large to be -represented with NB-DIGITS, then the result is truncated from the -left. So, for example, INT=256 and NB-DIGITS=2 returns \"00\", since -the hex equivalent of 256 decimal is 100, which is more than 2 digits. - -This function was blindly copied from hexrgb.el by Drew Adams. -https://www.emacswiki.org/emacs/hexrgb.el" - (setq nb-digits (or nb-digits 4)) - (substring (format (concat "%0" (int-to-string nb-digits) "X") int) (- nb-digits))) - -(defun pulse-color-values-to-hex (values) - "Convert list of rgb color VALUES to a hex string, #XXXXXXXXXXXX. -Each X in the string is a hexadecimal digit. -Input VALUES is as for the output of `x-color-values'. - -This function was blindly copied from hexrgb.el by Drew Adams. -https://www.emacswiki.org/emacs/hexrgb.el" - (concat "#" - (pulse-int-to-hex (nth 0 values) 4) ; red - (pulse-int-to-hex (nth 1 values) 4) ; green - (pulse-int-to-hex (nth 2 values) 4))) ; blue (defcustom pulse-iterations 10 "Number of iterations in a pulse operation." :group 'pulse :type 'number) + (defcustom pulse-delay .03 "Delay between face lightening iterations." :group 'pulse :type 'number) -(defun pulse-lighten-highlight () - "Lighten the face by 1/`pulse-iterations' toward the background color. -Return t if there is more drift to do, nil if completed." - (if (>= (get 'pulse-highlight-face :iteration) pulse-iterations) - nil - (let* ((frame (color-values (face-background 'default))) - (pulse-background (face-background - (get 'pulse-highlight-face - :startface) - nil t)));; can be nil - (when pulse-background - (let* ((start (color-values pulse-background)) - (frac (list (/ (- (nth 0 frame) (nth 0 start)) pulse-iterations) - (/ (- (nth 1 frame) (nth 1 start)) pulse-iterations) - (/ (- (nth 2 frame) (nth 2 start)) pulse-iterations))) - (it (get 'pulse-highlight-face :iteration)) - ) - (set-face-background 'pulse-highlight-face - (pulse-color-values-to-hex - (list - (+ (nth 0 start) (* (nth 0 frac) it)) - (+ (nth 1 start) (* (nth 1 frac) it)) - (+ (nth 2 start) (* (nth 2 frac) it))))) - (put 'pulse-highlight-face :iteration (1+ it)) - (if (>= (1+ it) pulse-iterations) - nil - t))) - ))) +;;; Convenience Functions +;; +(defvar pulse-momentary-overlay nil + "The current pulsing overlay.") + +(defvar pulse-momentary-timer nil + "The current pulsing timer.") + +(defvar pulse-momentary-iteration 0 + "The current pulsing iteration.") (defun pulse-reset-face (&optional face) "Reset the pulse highlighting FACE." @@ -166,15 +125,7 @@ pulse-reset-face (face-extend-p face nil t))) (put 'pulse-highlight-face :startface (or face 'pulse-highlight-start-face)) - (put 'pulse-highlight-face :iteration 0)) - -;;; Convenience Functions -;; -(defvar pulse-momentary-overlay nil - "The current pulsing overlay.") - -(defvar pulse-momentary-timer nil - "The current pulsing timer.") + (setq pulse-momentary-iteration 0)) (defun pulse-momentary-highlight-overlay (o &optional face) "Pulse the overlay O, unhighlighting before next command. @@ -201,14 +152,21 @@ pulse-momentary-highlight-overlay ;; Thus above we put our face on the overlay, but pulse ;; with a reference face needed for the color. (pulse-reset-face face) - (setq pulse-momentary-timer - (run-with-timer 0 pulse-delay #'pulse-tick - (time-add nil - (* pulse-delay pulse-iterations))))))) - -(defun pulse-tick (stop-time) + (let* ((start (color-name-to-rgb (face-background 'pulse-highlight-start-face))) + (stop (color-name-to-rgb (face-background 'default))) + (colors (mapcar (apply-partially 'apply 'color-rgb-to-hex) + (color-gradient start stop pulse-iterations)))) + (setq pulse-momentary-timer + (run-with-timer 0 pulse-delay #'pulse-tick + colors + (time-add nil + (* pulse-delay pulse-iterations)))))))) + +(defun pulse-tick (colors stop-time) (if (time-less-p nil stop-time) - (pulse-lighten-highlight) + (when-let (color (elt colors pulse-momentary-iteration)) + (set-face-background 'pulse-highlight-face color) + (setq pulse-momentary-iteration (1+ pulse-momentary-iteration))) (pulse-momentary-unhighlight))) (defun pulse-momentary-unhighlight () -- 2.27.0 --=-=-=--