Skip to content

Commit

Permalink
Add a function to guess the module name of the current buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdone committed Dec 22, 2013
1 parent c910ed0 commit dc3a02f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions haskell-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,16 @@ given a prefix arg."
(font-lock-fontify-buffer)
(buffer-substring (point-min) (point-max))))

(defun haskell-guess-module-name ()
"Guess the current module name of the buffer."
(interactive)
(let ((components (loop for part
in (reverse (split-string (buffer-file-name) "/"))
while (let ((case-fold-search nil))
(string-match "^[A-Z]+" part))
collect (replace-regexp-in-string "\\.l?hs$" "" part))))
(mapconcat 'identity (reverse components) ".")))


;; Provide ourselves:

Expand Down

0 comments on commit dc3a02f

Please sign in to comment.