GNU bug report logs - #16834
24.3.50; num3-mode detects long hex numbers as decimal

Previous Next

Package: emacs;

Reported by: Alex Bennée <kernel-hacker <at> bennee.com>

Date: Fri, 21 Feb 2014 17:13:02 UTC

Severity: minor

Found in version 24.3.50

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Alex Bennée <kernel-hacker <at> bennee.com>
Cc: 16834 <at> debbugs.gnu.org, Michal Nazarewicz <mina86 <at> mina86.com>
Subject: bug#16834: 24.3.50; num3-mode detects long hex numbers as decimal
Date: Fri, 21 Feb 2014 13:05:56 -0500
> When dealing with large hex numbers the default regex of num3-mode can
> detect them as decimals.  For example given:
> V28   : 00000000000000000007fc0000000000 vs 0000000000000000000bfc000000000
> 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?

> 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).


        Stefan


diff --git a/packages/num3-mode/num3-mode.el b/packages/num3-mode/num3-mode.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  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2012 Free Software Foundation, Inc.
+;; Copyright (C) 2012, 2014 Free Software Foundation, Inc.
 
 ;; Author: Felix Lee <felix8a <at> gmail.com>, Michal Nazarewicz <mina86 <at> mina86.com>
 ;; Maintainer: Michal Nazarewicz <mina86 <at> mina86.com>
@@ -98,7 +98,10 @@ where) decimal point (would be) is."
 (define-globalized-minor-mode global-num3-mode num3-mode num3-mode)
 
 (defconst num3--number-re
-  (concat    "\\(?:0[xX]\\|#\\)\\([0-9a-fA-F]+\\)"  ; 1 = hexadecimal
+  ;; Recognize "0x" and "#x" as prefixes announcing hexadecimal (from C and
+  ;; Elisp, respectively).
+  (concat    "[0#][xX]\\([[:xdigit:]]+\\)"  ; 1 = hexadecimal
+          "\\|\\(?1:[[:xdigit:]]*[a-fA-F][[:xdigit:]]*\\)" ; 1 = hexadecimal
           "\\|\\([0-9]+\\)"                         ; 2 = decimal
           "\\|\\.\\([0-9]+\\)"))                    ; 3 = fraction
 




This bug report was last modified 11 years and 151 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.