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.
Drew
  • 75,699
  • 9
  • 109
  • 225
gburnett
  • 165
  • 7
  • 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 Jan 28 '19 at 22:22

1 Answers1

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

shoshin
  • 904
  • 4
  • 9