Skip to content

Instantly share code, notes, and snippets.

@milkypostman
Created August 16, 2011 02:28
Show Gist options
  • Save milkypostman/1148324 to your computer and use it in GitHub Desktop.
Save milkypostman/1148324 to your computer and use it in GitHub Desktop.
(make-face 'font-lock-number-face)
(set-face-attribute 'font-lock-number-face nil :inherit font-lock-constant-face)
(setq font-lock-number-face 'font-lock-number-face)
(defvar font-lock-number "[0-9-.]+\\([eE][+-]?[0-9]*\\)?")
(defvar font-lock-hexnumber "0[xX][0-9a-fA-F]+")
(defun add-font-lock-numbers (mode)
(font-lock-add-keywords mode `(
(,(concat "\\<\\(" font-lock-number "\\)\\>" ) 0 font-lock-number-face)
(,(concat "\\<\\(" font-lock-hexnumber "\\)\\>" ) 0 font-lock-number-face)
)))
@milkypostman
Copy link
Author

usage:

(add-font-lock-numbers `python-mode)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment