Skip to content

Commit 145ebb7

Browse files
committed
Guess a project's setting from it's .cabal file
A generalised version of what I proposed in haskell#464.
1 parent db967b9 commit 145ebb7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

haskell-cabal.el

+14
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,20 @@
179179
(setq val (replace-match "" t t val))))
180180
val)))))
181181

182+
;;;###autoload
183+
(defun haskell-guess-setting (name)
184+
"Guess the specified setting of this project.
185+
If there is no valid .cabal file to get the setting from (or
186+
there is no corresponding setting with that name in the .cabal
187+
file), then this function returns nil."
188+
(interactive)
189+
(when (and name buffer-file-name)
190+
(let ((cabal-file (haskell-cabal-find-file (file-name-directory buffer-file-name))))
191+
(when (and cabal-file (file-readable-p cabal-file))
192+
(with-temp-buffer
193+
(insert-file-contents cabal-file)
194+
(haskell-cabal-get-setting name))))))
195+
182196
;;;###autoload
183197
(defun haskell-cabal-get-dir ()
184198
"Get the Cabal dir for a new project. Various ways of figuring this out,

0 commit comments

Comments
 (0)