Skip to content

Commit

Permalink
Consider - as operator in idris-thing-at-point
Browse files Browse the repository at this point in the history
Why:
The `-` char is defined in idris-syntax-table as being
beginning of comment and causing condition:
`(equal (syntax-after (point)) (string-to-syntax ".")`
in `idris-thing-at-point` be evaluated to nil (false)
and throw error.

Fixes:
idris-community/idris2-mode#16
  • Loading branch information
keram committed Nov 29, 2022
1 parent fdbd019 commit 1382948
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions idris-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,17 @@ Idris process. This sets the load position to point, if there is one."
(error "Cannot find file for current buffer")))


(defun idris-operator-at-position-p (pos)
"Return t if syntax lookup is `.' or char after POS is `-'."
(or (equal (syntax-after pos) (string-to-syntax "."))
(eq (char-after pos) ?-)))

(defun idris-thing-at-point ()
"Return the line number and name at point as a cons.
Use this in Idris source buffers."
(let ((line (idris-get-line-num (point))))
(cons
(if (equal (syntax-after (point))
(string-to-syntax "."))
;; We're on an operator.
(if (idris-operator-at-position-p (point))
(save-excursion
(skip-syntax-backward ".")
(let ((beg (point)))
Expand Down

0 comments on commit 1382948

Please sign in to comment.