Skip to content

Commit 83a6826

Browse files
committed
Fix for function detection. Use 'symbol
1 parent a2f722c commit 83a6826

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

solidity-mode.el

+12-9
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ If your provide 0 for COUNT then the entire regex match is returned."
473473
(let ((pos 0)
474474
matches)
475475
(while (string-match regexp string pos)
476-
(push (match-string count string) matches)
476+
(push (match-string-no-properties count string) matches)
477477
(setq pos (match-end 0)))
478478
matches)))
479479

@@ -488,13 +488,16 @@ EVENT is isgnored."
488488
(matches (solidity--re-matches (format "%s(.*?):.*?\\([0-9]+\\|infinite\\)" funcname) output 1))
489489
(result (car matches)))
490490
(kill-buffer buffer)
491-
(if result
491+
(if (not result)
492492
(let* ((clearfilename (file-name-nondirectory filename))
493493
(ctor-matches (solidity--re-matches (format "=.*?%s:%s.*?=" clearfilename funcname) output 0)))
494494
(if ctor-matches
495-
(message "Gas for '%s' constructor is %s" funcname (car (solidity--re-matches "construction:
495+
(message "Gas estimate for '%s' constructor is %s" funcname (car (solidity--re-matches "construction:
496496
.*?=.*?\\([0-9]+\\|infinite\\)" output 1)))
497-
(message "No gas estimate found for '%s'" funcname)))))))
497+
;;innermost else
498+
(message "No gas estimate found for '%s'" funcname)))
499+
;; outermost else
500+
(message "Gas estimate for '%s' is %s" funcname result)))))
498501

499502

500503
(defun solidity--start-gasestimate (func)
@@ -508,17 +511,17 @@ Does not currently work for constructors."
508511
process-name
509512
(format "*%s*" process-name)
510513
command)))
511-
(set-process-query-on-exit-flag process nil)
512-
(set-process-sentinel process 'solidity--handle-gasestimate-finish)
513-
(process-put process 'solidity-gasestimate-for-function func)
514-
(process-put process 'solidity-gasestimate-for-filename filename)))
514+
(set-process-query-on-exit-flag process nil)
515+
(set-process-sentinel process 'solidity--handle-gasestimate-finish)
516+
(process-put process 'solidity-gasestimate-for-function func)
517+
(process-put process 'solidity-gasestimate-for-filename filename)))
515518

516519
(defun solidity-estimate-gas-at-point ()
517520
"Estimate gas of the function at point.
518521
519522
Cursor must be at the function's name. Does not currently work for constructors."
520523
(interactive)
521-
(solidity--start-gasestimate (thing-at-point 'word 'no-properties)))
524+
(solidity--start-gasestimate (thing-at-point 'symbol 'no-properties)))
522525

523526
;;;###autoload
524527
(define-derived-mode solidity-mode c-mode "solidity"

0 commit comments

Comments
 (0)