From cd33273db7cd7c8777d4e7236a9310f3f1b8bf99 Mon Sep 17 00:00:00 2001 From: taku0 Date: Sun, 16 May 2021 20:56:33 +0900 Subject: [PATCH 1/2] lispy.el (lispy--read): Support INF and NaN 1.0e+INF and 0.0+NaN are valid float number of Elisp. --- lispy-test.el | 6 +++++- lispy.el | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lispy-test.el b/lispy-test.el index eeabe2de..7542ebea 100644 --- a/lispy-test.el +++ b/lispy-test.el @@ -1914,7 +1914,11 @@ Insert KEY if there's no command." (ly-raw clojure-symbol ":bar") ((ly-raw clojure-symbol ".") % (ly-raw clojure-symbol ".-value")))))) (should (equal (lispy--read ":.name") - '(ly-raw clojure-keyword ":.name")))) + '(ly-raw clojure-keyword ":.name"))) + (should (equal (lispy--read "1.0e+INF") + '(ly-raw float "1.0e+INF"))) + (should (equal (lispy--read "1.0e+NaN") + '(ly-raw float "1.0e+NaN")))) (ert-deftest lispy-tick () (should (string= (lispy-with "|" "'") "'|")) diff --git a/lispy.el b/lispy.el index 70134b7f..3b17379d 100644 --- a/lispy.el +++ b/lispy.el @@ -7422,7 +7422,7 @@ See https://clojure.org/guides/weird_characters#_character_literal.") (lispy--replace-regexp-in-code "\n" " (ly-raw newline)") ;; ——— numbers ———————————————— (goto-char (point-min)) - (while (re-search-forward "\\b[+-]?[0-9]+\\(?:\\.[0-9]+\\)?\\(?:e[+-]?[0-9]*\\)" nil t) + (while (re-search-forward "\\b[+-]?[0-9]+\\(?:\\.[0-9]+\\)?\\(?:e[+-]?\\(?:INF\\|NaN\\|[0-9]+\\)\\)" nil t) (if (setq cbnd (lispy--bounds-string)) (goto-char (cdr cbnd)) (let ((s (match-string-no-properties 0))) From 85dbee5f678a9d65b14aecd0d5fd6c1c10044b78 Mon Sep 17 00:00:00 2001 From: taku0 Date: Sun, 16 May 2021 20:58:16 +0900 Subject: [PATCH 2/2] lispy.el (lispy--read): Support non-decimal numbers - Hex: #xff00 - Binary: #b0101 - Octal: #o777 --- lispy-test.el | 6 ++++++ lispy.el | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lispy-test.el b/lispy-test.el index 7542ebea..217d0c1c 100644 --- a/lispy-test.el +++ b/lispy-test.el @@ -1865,6 +1865,12 @@ Insert KEY if there's no command." (should (equal (lispy--read "#m(foo bar)") '(ly-raw lisp-macro "#m(foo bar)"))) + (should (equal + (lispy--read "#xFF00") + '(ly-raw lisp-macro "#xFF00"))) + (should (equal + (lispy--read "#b0101") + '(ly-raw lisp-macro "#b0101"))) (should (equal (lispy--read ",(or body)") '(ly-raw \, (or body)))) diff --git a/lispy.el b/lispy.el index 3b17379d..7d520185 100644 --- a/lispy.el +++ b/lispy.el @@ -7395,7 +7395,7 @@ See https://clojure.org/guides/weird_characters#_character_literal.") (insert (format "(ly-raw comment %S)" str))) ;; ——— reader macro syntax (LISP) (goto-char (point-min)) - (while (re-search-forward "#[a-z][\"(]" nil t) + (while (re-search-forward "#[a-z]\\(?:[\"(]\\|[0-9a-f]+\\b\\)" nil t) (forward-char -1) (unless (lispy--in-string-or-comment-p) (let ((beg (match-beginning 0))