X.U.Run: Use isPrefixOf in withEmacsLibs

The `lisp` and `elpa` lists will simply be the (unqualified) file names.
Thus, if we use isInfixOf and try to require a library with a very short
name (like s.el), other things may be chosen over it.  isPrefixOf,
together with the additional `-`, prevents this from happening.
This commit is contained in:
Tony Zorman
2022-08-16 07:35:45 +02:00
parent ee97eec17d
commit df3d0aa057

View File

@@ -478,8 +478,8 @@ withEmacsLibs libs = XC.withDef $ \ProcessConfig{emacsLispDir, emacsElpaDir} ->
elpa <- liftIO $ getDirectoryContents elpaDir
let getLib :: EmacsLib -> Maybe String = \case
OwnFile f -> (("-l " <> lispDir) <>) <$> find (f `isInfixOf`) lisp
ElpaLib d -> (("-L " <> elpaDir) <>) <$> find ((d <> "-") `isInfixOf`) elpa
OwnFile f -> (("-l " <> lispDir) <>) <$> find (f `isPrefixOf`) lisp
ElpaLib d -> (("-L " <> elpaDir) <>) <$> find ((d <> "-") `isPrefixOf`) elpa
Special f -> Just $ " -l " <> f
pure . mkDList . unwords . mapMaybe getLib $ libs