From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michal Nazarewicz Newsgroups: gmane.emacs.bugs Subject: bug#16834: 24.3.50; num3-mode detects long hex numbers as decimal Date: Fri, 21 Feb 2014 20:49:26 +0100 Organization: http://mina86.com/ Message-ID: References: <87k3cobdb3.fsf@linaro.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1393012212 24609 80.91.229.3 (21 Feb 2014 19:50:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Feb 2014 19:50:12 +0000 (UTC) Cc: 16834@debbugs.gnu.org To: Stefan Monnier , Alex =?UTF-8?Q?Benn=C3=A9e?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Feb 21 20:50:20 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WGw6x-00045M-G4 for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Feb 2014 20:50:15 +0100 Original-Received: from localhost ([::1]:46645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGw6x-0004sV-5T for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Feb 2014 14:50:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGw6q-0004o6-0T for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2014 14:50:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGw6l-0005DD-Rn for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2014 14:50:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33886) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGw6l-0005CB-OR for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2014 14:50:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WGw6k-0007fj-SQ for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2014 14:50:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michal Nazarewicz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Feb 2014 19:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16834 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16834-submit@debbugs.gnu.org id=B16834.139301218429464 (code B ref 16834); Fri, 21 Feb 2014 19:50:02 +0000 Original-Received: (at 16834) by debbugs.gnu.org; 21 Feb 2014 19:49:44 +0000 Original-Received: from localhost ([127.0.0.1]:35068 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WGw6R-0007f9-HJ for submit@debbugs.gnu.org; Fri, 21 Feb 2014 14:49:44 -0500 Original-Received: from mail-ee0-f51.google.com ([74.125.83.51]:56439) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WGw6O-0007eu-5Y for 16834@debbugs.gnu.org; Fri, 21 Feb 2014 14:49:40 -0500 Original-Received: by mail-ee0-f51.google.com with SMTP id b57so1834996eek.24 for <16834@debbugs.gnu.org>; Fri, 21 Feb 2014 11:49:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:organization:references :user-agent:face:date:message-id:mime-version:content-type; bh=WKmTUp8YJbKjV7ARwiWB9rsg448D5QMv4NYX2eNEZ3M=; b=HntjF1IcfbS8MY6k3QhVZotoQV5xh+qAUCCgRZF/I1JnGAVAYmiQxFqef8mfcskYoz kEckLD4jTAGlH8alU+zpr12t9hoHUvAGm3sJJx1DTJpE3Bo7lMPYVfZEUPoD5k0OApGB OR8iU6lCtlBsiBUNtKmQXA/3wk33pdaz0ZR/M+GXhCyCeoZv9ImxevTupyFCc4vhqaMa mkC43IYcssCphhzp6ku6WHsLmORhNdyGlNlmHWunwxrtIdlEYPpiciZUactEuXHxVzXf st4vKC7Kpb419WZ3yTLTdpeXvzte4Tcit7VO6x1P6/GWhTJGz+Zn3qBH4IHkL2RZIsY5 uN5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to :organization:references:user-agent:face:date:message-id :mime-version:content-type; bh=WKmTUp8YJbKjV7ARwiWB9rsg448D5QMv4NYX2eNEZ3M=; b=ECeIEfPtwbEot8KoTF61JSPQiQ5/ZpBQu+z1PsOVka+T9lmhlia+yyxfgfNWrrSzYW ZgPOJjBwKMoYRGdKh33cydehK7RM9DWUrnQKB4Zm8czHFye86hUKct5XyBmRaJtbFWzu coIgmWw6M2pDZ6WteiK6wtXNAoTc6GUwpR1YhC/CKlV3V/dTNMR5FBRZYElxozb390IW mUN4C/jqcGRH7ZELYNZqvIPsfaJmupCXyaIgbQG4fc8MEXmTVgVI4rab0wyfKmuS81Iz 1y4xY5Si5rHavHiwPkeiaelE7FgSr3U2mwoAK61RCbtNsGjnFLgkESjUWI7F89vnK6bH bdDQ== X-Gm-Message-State: ALoCoQkxvb1/JFyBvH8WYZxXkQ1WaVQPcXtcIW4/2rOsYRr1aNAzo3iz9hcYdMsLY9d7mFVfSYDhos5MU2Xiq9wHEirA9hAgkmYUkxBtlN9SnW2IHHIAetC8Udko2zrAIkxbsL+MN/Gw6na96OKb2wYMGiq19Ec2B3BiDMJnPfOhY55MgBeyta94KBkLfvCZaAj7CDMd71+GjFh9n0/qs+vrvcOPPTHfju6eZB5pLjPCrdYbN5bKFOY= X-Received: by 10.14.110.68 with SMTP id t44mr10468721eeg.74.1393012174088; Fri, 21 Feb 2014 11:49:34 -0800 (PST) Original-Received: from mpn-glaptop.roam.corp.google.com ([2620:0:105f:311:11c7:67ea:c501:4eb0]) by mx.google.com with ESMTPSA id o43sm30057048eef.12.2014.02.21.11.49.31 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 21 Feb 2014 11:49:32 -0800 (PST) In-Reply-To: User-Agent: Notmuch/0.17+15~gb65ca8e (http://notmuchmail.org) Emacs/24.3.50.1 (x86_64-unknown-linux-gnu) X-Face: PbkBB1w#)bOqd`iCe"Ds{e+!C7`pkC9a|f)Qo^BMQvy\q5x3?vDQJeN(DS?|-^$uMti[3D*#^_Ts"pU$jBQLq~Ud6iNwAw_r_o_4]|JO?]}P_}Nc&"p#D(ZgUb4uCNPe7~a[DbPG0T~!&c.y$Ur,=N4RT>]dNpd; KFrfMCylc}gc??'U2j,!8%xdD Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACQElEQVQ4jW3TMWvbQBQHcBk1xE6WyALX1069oZBMlq+ouUwpEQQ6uRjttkWP4CmBgGM0BQLBdPFZYPsyFUo6uEtKDQ7oy/U96XR2Ux8ehH/89Z6enqxBcS7Lg81jmSuujrfCZcLI/TYYvbGj+jbgFpHJ/bqQAUISj8iLyu4LuFHJTosxsucO4jSDNE0Hq3hwK/ceQ5sx97b8LcUDsILfk+ovHkOIsMbBfg43VuQ5Ln9YAGCkUdKJoXR9EclFBhixy3EGVz1K6eEkhxCAkeMMnqoAhAKwhoUJkDrCqvbecaYINlFKSRS1i12VKH1XpUd4qxL876EkMcDvHj3s5RBajHHMlA5iK32e0C7VgG0RlzFPvoYHZLRmAC0BmNcBruhkE0KsMsbEc62ZwUJDxWUdMsMhVqovoT96i/DnX/ASvz/6hbCabELLk/6FF/8PNpPCGqcZTGFcBhhAaZZDbQPaAB3+KrWWy2XgbYDNIinkdWAFcCpraDE/knwe5DBqGmgzESl1p2E4MWAz0VUPgYYzmfWb9yS4vCvgsxJriNTHoIBz5YteBvg+VGISQWUqhMiByPIPpygeDBE6elD973xWwKkEiHZAHKjhuPsFnBuArrzxtakRcISv+XMIPl4aGBUJm8Emk7qBYU8IlgNEIpiJhk/No24jHwkKTFHDWfPniR 4iw5vJaw2nzSjfq2zffcE/GDjRC2dn0J0XwPAbDL84TvaFCJEU4Oml9pRyEUhR3Cl2t01AoEjRbs0sYugp14/4X5n4pU4EHHnMAAAAAElFTkSuQmCC X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 X-Hashcash: 1:20:140221:16834@debbugs.gnu.org::2fAovG17a37SvVN2:00000000000000000000000000000000000000001ONN X-Hashcash: 1:20:140221:kernel-hacker@bennee.com::STrqwwsMQkmHtFwE:00000000000000000000000000000000000002/T+ X-Hashcash: 1:20:140221:monnier@iro.umontreal.ca::obTq+Ru4xE9A3r4x:00000000000000000000000000000000000008Nsf X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:85995 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Feb 21 2014, Stefan Monnier wrote: >> When dealing with large hex numbers the default regex of num3-mode can >> detect them as decimals. For example given: >> V28 : 00000000000000000007fc0000000000 vs 0000000000000000000bfc000000= 000 >> the follow is high-lighted >> V28 : __xxx___xxx___xxx_____x___xxx___ vs _xxx___xxx___xxx_________xxx= ___ >> which is obviously wrong. > > I guess we could use the patch below. Michal, what do you think? Looks good in general, but this leads to some interesting results: =E2=80=9CAaaaaaa=E2=80=9D he screamed as the dentist pulled his teeth out. And if someone sets num3-threshold to 1 and changes num3-face-odd, all the hexadecimal digits will get highlighted in a regular text even when they are inside of a word. I also hope engineers won't get mad when 1000A starts being treated as a hexadecimal number. (They should know to put a non-break space between the number an the unit anyway). Perhaps this would be better: (defconst num3--number-re (concat "[0#][xX]\\([[:xdigit:]]+\\)" ; 1 =3D hexadecimal "\\|\\(?1:\\b\\(?:[0-9]+[a-fA-F]\\|" ; 1 =3D hexadecimal "[a-fA-F]+[0-9]\\)[[:xdigit:]]*\\b\\)"=20=20 "\\|\\([0-9]+\\)" ; 2 =3D decimal "\\|\\.\\([0-9]+\\)")) ; 3 =3D fraction So there would have to be at least one decimal digit and the whole sequence would have to be a complete word (i.e. 1000Ah, which would be a pretty big battery, won't be highlighted as a hexadecimal number). >> It wouldn't hurt to have customisable faces as well as the default can >> look quite harsh depending on the theme. > > Hmmm... they are, AFAICT (faces num3-face-odd and num3-face-even). Yep, I have this in my custom.el: '(num3-face-even ((t (:foreground "#CFF" :underline nil :weight normal)))) I don't particularly like the defaults myself, but that was what Felix used in his original code, so I kept it. > diff --git a/packages/num3-mode/num3-mode.el b/packages/num3-mode/num3-mo= de.el > index b890c89..ae3289a 100644 > --- a/packages/num3-mode/num3-mode.el > +++ b/packages/num3-mode/num3-mode.el > @@ -1,6 +1,6 @@ > ;;; num3-mode.el --- highlight groups of digits in long numbers -*- lex= ical-binding: t -*- >=20=20 > -;; Copyright (C) 2012 Free Software Foundation, Inc. > +;; Copyright (C) 2012, 2014 Free Software Foundation, Inc. >=20=20 > ;; Author: Felix Lee , Michal Nazarewicz > ;; Maintainer: Michal Nazarewicz > @@ -98,7 +98,10 @@ where) decimal point (would be) is." > (define-globalized-minor-mode global-num3-mode num3-mode num3-mode) >=20=20 > (defconst num3--number-re > - (concat "\\(?:0[xX]\\|#\\)\\([0-9a-fA-F]+\\)" ; 1 =3D hexadecimal > + ;; Recognize "0x" and "#x" as prefixes announcing hexadecimal (from C = and > + ;; Elisp, respectively). > + (concat "[0#][xX]\\([[:xdigit:]]+\\)" ; 1 =3D hexadecimal > + "\\|\\(?1:[[:xdigit:]]*[a-fA-F][[:xdigit:]]*\\)" ; 1 =3D hexad= ecimal > "\\|\\([0-9]+\\)" ; 2 =3D decimal > "\\|\\.\\([0-9]+\\)")) ; 3 =3D fraction >=20=20 --=20 Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz = (o o) ooo +------ooO--(_)--Ooo-- --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: text/plain --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJTB63GAAoJECBgQBJQdR/0dEcP/2sCXoRLv/jADqsIQI/CVJcj lc74gdwCNzpN6K+ELH0OFn3UaMrYtrVW6OBuASwrn7uoSsiyrF7NImkj44bDJYGD qxr4PICJjD25nrkEWcWd5TI7q6M3tSEvAMjmVwG3/nIQD/PWWjjRZv8BdDo5cvZV YrjUha7HbvI+Yr/oCUjBSY1/8M8plzk1t3FmLy1wYxb76A9E5IRh3ij6pjw6QgQg duglEEWuZxP/Rx2ygq0KT80VbzDgEtORAoaXGso+l0dGPMACetF7/si8bS2AS/rf 8WML3pSCQMbCcQbKnmvBQk7VcA8RRNyS1jpycPpPW6nkoZqT2AVMUabEdCVyWy70 gwUoMjcLw2qn12+5pVK+SM2t7xybfAOqHwwb+3Nw4f32pNR06I8sKT/ATCmeQAWy rMU86ssY32e2jtU3fSTRyxFTMkEDOKrHczC+Lo3TJ+gwthYD2wRvVqTU4izqBhDX bgfNdYFC9qY+ztY6iWA/PVc85/pQI+pKqKK92n591RLM3oy1L1boHvaOwRUytZqL 3gfOjh+gE1PcmMPaCFjegNl/BCXEGn8mgH9urdnmmbb1jn/bXBjgtMnUrlLBJx7p LWzJdelVbXG/VJD+GwXKQ86ImtDjpGh+yaoYpDXnipoO7rCACUgEZ25GQ5ctz/FJ /uCbYVHDJmLapv/pJyvZ =qB12 -----END PGP SIGNATURE----- --==-=-=-- --=-=-=--