From 3f8f409518e9322db47b84fb3b4d101eed0bff37 Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Wed, 22 Jul 2020 10:49:37 -0600 Subject: [PATCH 1/8] Allow highlighting for numbers --- elixir-mode.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/elixir-mode.el b/elixir-mode.el index 48e6f24b..e1fbd156 100644 --- a/elixir-mode.el +++ b/elixir-mode.el @@ -88,6 +88,13 @@ "For use with atoms & map keys." :group 'font-lock-faces) +(defvar elixir-number-face 'elixir-number-face) +(defface elixir-number-face + '((t (:inherit font-lock-builtin-face))) + "For use with numbers." + :group 'font-lock-faces) + + (eval-when-compile (defconst elixir-rx-constituents `( @@ -107,6 +114,11 @@ (zero-or-more (any "a-z" "A-Z" "0-9" "_" "\"" "'" "!" "@" "?"))) (and "\"" (one-or-more (not (any "\""))) "\"") (and "'" (one-or-more (not (any "'"))) "'")))) + (numbers . ,(rx (and symbol-start + (? "-") + (+ digit) + (0+ (and "_" (= 3 digit))) + symbol-end))) (builtin . ,(rx symbol-start (or "case" "cond" "for" "if" "quote" "raise" "receive" "send" "super" "throw" "try" "unless" "unquote" "unquote_splicing" @@ -382,6 +394,10 @@ is used to limit the scan." (optional "=")) 1 elixir-atom-face) + ;; Numbers + (,(elixir-rx (group numbers)) + 1 elixir-number-face) + ;; Gray out variables starting with "_" (,(elixir-rx symbol-start (group (and "_" From 1d94b525ddcc995b5a979de7b050c2309648ca6f Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Wed, 22 Jul 2020 11:38:25 -0600 Subject: [PATCH 2/8] Expose attributes as customizable where appropriate --- elixir-format.el | 2 ++ elixir-mode.el | 46 +++++++++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/elixir-format.el b/elixir-format.el index 3d96924b..6c2ab224 100644 --- a/elixir-format.el +++ b/elixir-format.el @@ -28,11 +28,13 @@ (defcustom elixir-format-arguments nil "Additional arguments to 'mix format'" :type '(repeat string) + :group 'elixir :group 'elixir-format) (defcustom elixir-format-hook nil "Hook called by `elixir-format'." :type 'hook + :group 'elixir :group 'elixir-format) diff --git a/elixir-mode.el b/elixir-mode.el index e1fbd156..10d755b6 100644 --- a/elixir-mode.el +++ b/elixir-mode.el @@ -1,4 +1,4 @@ -;;; elixir-mode.el --- Major mode for editing Elixir files +;;; elixir-mode.el --- Major mode for editing Elixir files -*- lexical-binding: t -*- ;; Copyright 2011-2015 secondplanet ;; 2013-2015 Samuel Tonini, Matt DeBoard, Andreas Fuchs @@ -10,7 +10,7 @@ ;; URL: https://github.com/elixir-editors/emacs-elixir ;; Created: Mon Nov 7 2011 ;; Keywords: languages elixir -;; Version: 2.3.1 +;; Version: 2.4.0 ;; Package-Requires: ((emacs "24") (pkg-info "0.4")) ;; This file is not a part of GNU Emacs. @@ -48,13 +48,17 @@ :link '(url-link :tag "Github" "https://github.com/elixir-editors/emacs-elixir") :link '(emacs-commentary-link :tag "Commentary" "elixir-mode")) -(defvar elixir-mode-website-url "http://elixir-lang.org" - "Official url of Elixir programming website.") +(defcustom elixir-mode-website-url "http://elixir-lang.org" + "Official url of Elixir programming website." + :type 'string) -(defvar elixir-mode-doc-url "https://hexdocs.pm/elixir" - "Official documentation for the Elixir programming language.") +(defcustom elixir-mode-doc-url "https://hexdocs.pm/elixir" + "Official documentation for the Elixir programming language." + :type 'string) -(defvar elixir-mode-hook nil) +(defcustom elixir-mode-hook nil + "Hook that runs when switching to major mode" + :type 'hook) (defvar elixir-mode-map (let ((map (make-sparse-keymap))) @@ -72,27 +76,35 @@ ("Tests" "^\\s-*test[ \t\n]+\"?\\(:?[a-z0-9_@+() \t-]+\\)\"?[ \t\n]+.*" 1)) "Imenu pattern for `elixir-mode'.") -(defvar elixir-basic-offset 2) -(defvar elixir-key-label-offset 0) -(defvar elixir-match-label-offset 2) +(defcustom elixir-basic-offset 2 + "Basic offset." + :type 'integer) +(defcustom elixir-key-label-offset 0 + "Offset used for key label." + :type 'integer) +(defcustom elixir-match-label-offset 2 + "Offset for a match label." + :type 'integer) + +(defgroup elixir-faces nil + "Font-lock faces for `elixir'." + :group 'elixir + :group 'faces) (defvar elixir-attribute-face 'elixir-attribute-face) (defface elixir-attribute-face '((t (:inherit font-lock-preprocessor-face))) - "For use with module attribute tokens." - :group 'font-lock-faces) + "For use with module attribute tokens.") (defvar elixir-atom-face 'elixir-atom-face) (defface elixir-atom-face '((t (:inherit font-lock-builtin-face))) - "For use with atoms & map keys." - :group 'font-lock-faces) + "For use with atoms & map keys.") (defvar elixir-number-face 'elixir-number-face) (defface elixir-number-face - '((t (:inherit font-lock-builtin-face))) - "For use with numbers." - :group 'font-lock-faces) + '((t (:inherit default))) + "For use with numbers.") (eval-when-compile From 9578c0fbb7cca3ac04f8f1584f26effeffc3eb49 Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Wed, 22 Jul 2020 11:55:02 -0600 Subject: [PATCH 3/8] Try reverting change to elixir-format.el to see if tests pass --- elixir-format.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/elixir-format.el b/elixir-format.el index 6c2ab224..3d96924b 100644 --- a/elixir-format.el +++ b/elixir-format.el @@ -28,13 +28,11 @@ (defcustom elixir-format-arguments nil "Additional arguments to 'mix format'" :type '(repeat string) - :group 'elixir :group 'elixir-format) (defcustom elixir-format-hook nil "Hook called by `elixir-format'." :type 'hook - :group 'elixir :group 'elixir-format) From f4e1dc6b7da78f37c5533c6a00af48d3177ef9d7 Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Wed, 22 Jul 2020 11:59:27 -0600 Subject: [PATCH 4/8] Change test matrix to match ElixirLS and recent Emacs versions --- .travis.yml | 25 +++++++++++-------------- CHANGELOG.md | 3 +++ Cask | 1 + elixir-format.el | 2 ++ elixir-mode.el | 2 +- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 43777fc5..ffaf2e86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,19 @@ +dist: xenial language: elixir cache: apt env: - - EVM_EMACS=24.3 - - EVM_EMACS=24.4 - - EVM_EMACS=24.5 - - EVM_EMACS=25.1 - - EVM_EMACS=25.2 -matrix: - include: - - elixir: 1.0.5 - otp_release: 17.4 - - elixir: 1.4.3 - otp_release: 19.0 - - elixir: 1.6.0 - otp_release: 20.1 + - EVM_EMACS=git-snapshot + - EVM_EMACS=26.3 +elixir: + - 1.7.4 + - 1.9.4 + - 1.10.4 +otp_release: + - 20.3 + - 22.3 before_install: - curl -fsSkL https://gist.githubusercontent.com/Trevoke/90409590f43abfd0d7fe3b02b5249849/raw > travis.sh && source ./travis.sh - - evm install emacs-$EVM_EMACS-travis --use --skip + - evm install emacs-$EVM_EMACS-travis-linux-xenial --use --skip - cask install: - cask install diff --git a/CHANGELOG.md b/CHANGELOG.md index 5409a298..3c5166ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v2.4.0 - Unreleased +* [#459](https://github.com/elixir-editors/emacs-elixir/pull/459) - Customizable font-face for numbers + ## v2.3.1 - 2016/04/19 * [#337](https://github.com/elixir-editors/emacs-elixir/pull/337) - Fix indentation issue after COMMA token * [#333](https://github.com/elixir-editors/emacs-elixir/pull/333) - Fix indentation of second element inside list of tuples diff --git a/Cask b/Cask index 0015757c..0d8fd5c9 100644 --- a/Cask +++ b/Cask @@ -6,4 +6,5 @@ (files "*.el") (development + (depends-on "pkg-info") (depends-on "ert-runner")) diff --git a/elixir-format.el b/elixir-format.el index 3d96924b..6c2ab224 100644 --- a/elixir-format.el +++ b/elixir-format.el @@ -28,11 +28,13 @@ (defcustom elixir-format-arguments nil "Additional arguments to 'mix format'" :type '(repeat string) + :group 'elixir :group 'elixir-format) (defcustom elixir-format-hook nil "Hook called by `elixir-format'." :type 'hook + :group 'elixir :group 'elixir-format) diff --git a/elixir-mode.el b/elixir-mode.el index 10d755b6..7e95f32a 100644 --- a/elixir-mode.el +++ b/elixir-mode.el @@ -11,7 +11,7 @@ ;; Created: Mon Nov 7 2011 ;; Keywords: languages elixir ;; Version: 2.4.0 -;; Package-Requires: ((emacs "24") (pkg-info "0.4")) +;; Package-Requires: ((emacs "26.3")) ;; This file is not a part of GNU Emacs. From ce66d672757a8f7b5144f09c5d295736ce3b1f2e Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Wed, 22 Jul 2020 12:36:54 -0600 Subject: [PATCH 5/8] Remove OTP 20 as there is no elixir version built against it for 1.10.4 --- .gitignore | 1 + .travis.yml | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8b647d60..bbce8da7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /.cask/ /dist/ *-emacs-elixir-format.ex +ert-profile diff --git a/.travis.yml b/.travis.yml index ffaf2e86..381323e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,13 @@ dist: xenial language: elixir cache: apt env: - - EVM_EMACS=git-snapshot - EVM_EMACS=26.3 elixir: - 1.7.4 - 1.9.4 - 1.10.4 otp_release: - - 20.3 + - 21.3 - 22.3 before_install: - curl -fsSkL https://gist.githubusercontent.com/Trevoke/90409590f43abfd0d7fe3b02b5249849/raw > travis.sh && source ./travis.sh From 3f89e844eacca4da446bb7b8cbd1c7e5939ecd91 Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Sun, 18 Oct 2020 13:58:22 -0600 Subject: [PATCH 6/8] Revert "Remove OTP 20 as there is no elixir version built against it for 1.10.4" This reverts commit ce66d672757a8f7b5144f09c5d295736ce3b1f2e. --- .gitignore | 1 - .travis.yml | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index bbce8da7..8b647d60 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ /.cask/ /dist/ *-emacs-elixir-format.ex -ert-profile diff --git a/.travis.yml b/.travis.yml index 381323e7..ffaf2e86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,14 @@ dist: xenial language: elixir cache: apt env: + - EVM_EMACS=git-snapshot - EVM_EMACS=26.3 elixir: - 1.7.4 - 1.9.4 - 1.10.4 otp_release: - - 21.3 + - 20.3 - 22.3 before_install: - curl -fsSkL https://gist.githubusercontent.com/Trevoke/90409590f43abfd0d7fe3b02b5249849/raw > travis.sh && source ./travis.sh From 2d3dd8ea454efce95b15074da2965ac535f62bde Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Sun, 18 Oct 2020 13:58:31 -0600 Subject: [PATCH 7/8] Revert "Change test matrix to match ElixirLS and recent Emacs versions" This reverts commit f4e1dc6b7da78f37c5533c6a00af48d3177ef9d7. --- .travis.yml | 25 ++++++++++++++----------- CHANGELOG.md | 3 --- Cask | 1 - elixir-format.el | 2 -- elixir-mode.el | 2 +- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index ffaf2e86..43777fc5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,22 @@ -dist: xenial language: elixir cache: apt env: - - EVM_EMACS=git-snapshot - - EVM_EMACS=26.3 -elixir: - - 1.7.4 - - 1.9.4 - - 1.10.4 -otp_release: - - 20.3 - - 22.3 + - EVM_EMACS=24.3 + - EVM_EMACS=24.4 + - EVM_EMACS=24.5 + - EVM_EMACS=25.1 + - EVM_EMACS=25.2 +matrix: + include: + - elixir: 1.0.5 + otp_release: 17.4 + - elixir: 1.4.3 + otp_release: 19.0 + - elixir: 1.6.0 + otp_release: 20.1 before_install: - curl -fsSkL https://gist.githubusercontent.com/Trevoke/90409590f43abfd0d7fe3b02b5249849/raw > travis.sh && source ./travis.sh - - evm install emacs-$EVM_EMACS-travis-linux-xenial --use --skip + - evm install emacs-$EVM_EMACS-travis --use --skip - cask install: - cask install diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c5166ea..5409a298 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,3 @@ -## v2.4.0 - Unreleased -* [#459](https://github.com/elixir-editors/emacs-elixir/pull/459) - Customizable font-face for numbers - ## v2.3.1 - 2016/04/19 * [#337](https://github.com/elixir-editors/emacs-elixir/pull/337) - Fix indentation issue after COMMA token * [#333](https://github.com/elixir-editors/emacs-elixir/pull/333) - Fix indentation of second element inside list of tuples diff --git a/Cask b/Cask index 0d8fd5c9..0015757c 100644 --- a/Cask +++ b/Cask @@ -6,5 +6,4 @@ (files "*.el") (development - (depends-on "pkg-info") (depends-on "ert-runner")) diff --git a/elixir-format.el b/elixir-format.el index 6c2ab224..3d96924b 100644 --- a/elixir-format.el +++ b/elixir-format.el @@ -28,13 +28,11 @@ (defcustom elixir-format-arguments nil "Additional arguments to 'mix format'" :type '(repeat string) - :group 'elixir :group 'elixir-format) (defcustom elixir-format-hook nil "Hook called by `elixir-format'." :type 'hook - :group 'elixir :group 'elixir-format) diff --git a/elixir-mode.el b/elixir-mode.el index 7e95f32a..10d755b6 100644 --- a/elixir-mode.el +++ b/elixir-mode.el @@ -11,7 +11,7 @@ ;; Created: Mon Nov 7 2011 ;; Keywords: languages elixir ;; Version: 2.4.0 -;; Package-Requires: ((emacs "26.3")) +;; Package-Requires: ((emacs "24") (pkg-info "0.4")) ;; This file is not a part of GNU Emacs. From 80562fa5d85eb001fb8f442e04b20fbe9f08d817 Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Sun, 18 Oct 2020 13:59:20 -0600 Subject: [PATCH 8/8] Add elixir format variables to elixir group as well --- elixir-format.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/elixir-format.el b/elixir-format.el index 3d96924b..6c2ab224 100644 --- a/elixir-format.el +++ b/elixir-format.el @@ -28,11 +28,13 @@ (defcustom elixir-format-arguments nil "Additional arguments to 'mix format'" :type '(repeat string) + :group 'elixir :group 'elixir-format) (defcustom elixir-format-hook nil "Hook called by `elixir-format'." :type 'hook + :group 'elixir :group 'elixir-format)