From 145ebb7b28f95355ca8cb9e75aeffbf828e6f99e Mon Sep 17 00:00:00 2001 From: Ivan Lazar Miljenovic Date: Sat, 14 Feb 2015 22:57:40 +1100 Subject: [PATCH] Guess a project's setting from it's .cabal file A generalised version of what I proposed in #464. --- haskell-cabal.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/haskell-cabal.el b/haskell-cabal.el index 91c75051a..49e3fae99 100644 --- a/haskell-cabal.el +++ b/haskell-cabal.el @@ -179,6 +179,20 @@ (setq val (replace-match "" t t val)))) val))))) +;;;###autoload +(defun haskell-guess-setting (name) + "Guess the specified setting of this project. +If there is no valid .cabal file to get the setting from (or +there is no corresponding setting with that name in the .cabal +file), then this function returns nil." + (interactive) + (when (and name buffer-file-name) + (let ((cabal-file (haskell-cabal-find-file (file-name-directory buffer-file-name)))) + (when (and cabal-file (file-readable-p cabal-file)) + (with-temp-buffer + (insert-file-contents cabal-file) + (haskell-cabal-get-setting name)))))) + ;;;###autoload (defun haskell-cabal-get-dir () "Get the Cabal dir for a new project. Various ways of figuring this out,