Skip to content

Commit bfca76b

Browse files
authored
Merge pull request ethereum#16 from ethereum/fix_flycheck
Fix Using Solc and Flycheck for recent Flycheck Versions
2 parents b8ddfd6 + bab7cd5 commit bfca76b

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

solidity-mode.el

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
;;; solidity-mode.el --- Major mode for ethereum's solidity language
22

3-
;; Copyright (C) 2015 Lefteris Karapetsas
3+
;; Copyright (C) 2015-2018 Lefteris Karapetsas
44

55
;; Author: Lefteris Karapetsas <[email protected]>
66
;; Keywords: languages
7-
;; Version: 0.1.2
7+
;; Version: 0.1.3
88

99
;; This program is free software; you can redistribute it and/or modify
1010
;; it under the terms of the GNU General Public License as published by
@@ -49,12 +49,6 @@
4949
:type 'string
5050
:package-version '(solidity . "0.1.1"))
5151

52-
(defcustom solidity-solc-extra-args ""
53-
"Extra arguments to add to pass to the solidity compiler."
54-
:group 'solidity
55-
:type 'string
56-
:package-version '(solidity . "0.1.2"))
57-
5852
(defvar solidity-mode-map
5953
(let ((map (make-keymap)))
6054
(define-key map "\C-j" 'newline-and-indent)
@@ -63,7 +57,6 @@
6357

6458
(defvar solidity-checker t "The solidity flycheck syntax checker.")
6559
(defvar solidity-mode t "The solidity major mode.")
66-
(defvar flycheck-solidity-executable t "The solc executable used by flycheck.")
6760

6861
;;;###autoload
6962
(add-to-list 'auto-mode-alist '("\\.sol\\'" . solidity-mode))
@@ -451,13 +444,27 @@ Highlight the 1st result."
451444

452445
;;; --- interface with flycheck if existing ---
453446
(when (eval-when-compile (require 'flycheck nil 'noerror))
447+
;; Avoid reference to free variable warnings
448+
(defvar flycheck-solidity-checker-executable)
449+
450+
(flycheck-def-option-var flycheck-solidity-addstd-contracts nil solidity-checker
451+
"Whether to add standard solidity contracts.
452+
453+
When non-nil, enable add also standard solidity contracts via
454+
`--add-std'."
455+
:type 'boolean
456+
:safe #'booleanp
457+
:package-version '(solidity-mode . "0.1.3"))
458+
454459
;; add dummy source-inplace definition to avoid errors
455460
(defvar source-inplace t)
456461
;; add a solidity mode callback to set the executable of solc for flycheck
457462
;; define solidity's flycheck syntax checker
458463
(flycheck-define-checker solidity-checker
459464
"A Solidity syntax checker using the solc compiler"
460-
:command ("/usr/bin/solc" source-inplace)
465+
:command ("solc"
466+
(option-flag "--add-std" flycheck-solidity-addstd-contracts)
467+
source-inplace)
461468
:error-patterns
462469
((error line-start (file-name) ":" line ":" column ":" " Error: " (message))
463470
(error line-start "Error: " (message))
@@ -467,7 +474,7 @@ Highlight the 1st result."
467474
(add-to-list 'flycheck-checkers 'solidity-checker)
468475
(add-hook 'solidity-mode-hook
469476
(lambda ()
470-
(let ((solidity-command (concat solidity-solc-path " " solidity-solc-extra-args)))
477+
(let ((solidity-command (concat solidity-solc-path)))
471478
(setq flycheck-solidity-checker-executable solidity-command)))))
472479

473480
(provide 'solidity-mode)

0 commit comments

Comments
 (0)