Skip to content

Instantly share code, notes, and snippets.

@gmfawcett
Last active January 4, 2016 17:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmfawcett/8656475 to your computer and use it in GitHub Desktop.
Save gmfawcett/8656475 to your computer and use it in GitHub Desktop.
(require 'flymake)
(require 'd-mode)
(defun flymake-D-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name)))
(opts_ (concat (file-name-directory buffer-file-name)
"d.flymake.opts"))
(opts (concat "@" opts_)))
(if (not (file-exists-p opts_))
(write-region "" nil opts_))
(list "/opt/dmd/bin/dmd" (list opts "-c" local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'(".+\\.d$" flymake-D-init
flymake-simple-cleanup flymake-get-real-file-name))
(add-to-list 'flymake-err-line-patterns
'("^\\([^ :]+\\)(\\([0-9]+\\)): \\(.*\\)$" 1 2 nil 3))
;;(setq flymake-log-level 3)
(defun flymake-d-load ()
(flymake-mode t)
(local-set-key (kbd "C-c C-d") 'flymake-display-err-menu-for-current-line)
(local-set-key (kbd "C-c C-n") 'flymake-goto-next-error)
(local-set-key (kbd "C-c C-p") 'flymake-goto-prev-error))
(add-hook 'd-mode-hook 'flymake-d-load)
(provide 'flymake-d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment