0

How do I prevent flycheck from triggering a warning for the following code:

(defun file-path-last-segment ()
  "Get last segment of file path for use in snippets."
  (-> default-directory
      (file-name-directory)
      (directory-file-name)
      (file-name-nondirectory)))

The following warning appears in my flycheck errors:

the function ‘->’ is not known to be defined.
1
  • 1
    Not sure I understand the question. That warning just means that the byte-compiler doesn't know whether -> will be a defined function at the place you invoke it. If you too are unsure then just be sure to load (e.g. require) the library that defines it before you invoke the code that invokes it. (It's just a warning.)
    – Drew
    Commented Jan 28, 2019 at 22:22

1 Answer 1

2

-> is a Lisp macro in `dash.el'.

Macros don't follow the usual rules for function definition which is likely why you're getting this error.

You might be able to do it by explicitly requiring dash in your file, if you haven't already. There's another thread regarding a similar issue around elisp macros that might be relevant Make flycheck's "reference to free variable" work with macros

1
  • 1
    (require 'dash) prevents the warning. Thank you.
    – gburnett
    Commented Jan 28, 2019 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.