Skip to content

Commit

Permalink
alchemist-complete needs a debug functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
tonini committed Dec 7, 2014
1 parent 99285e5 commit 3b93ff3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v0.10.0-dev (unreleased)

### Enhancements

* [Complete] Add the function `alchemist-complete-debug-mode` for controlling
the display of the error output from completion.

## v0.9.0

### Enhancements
Expand Down
16 changes: 16 additions & 0 deletions alchemist-complete.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
:prefix "alchemist-complete-"
:group 'alchemist)

(defvar alchemist-complete-debug-mode nil)

(defun alchemist-complete-debug-mode ()
"Enables the debug mode for completion if `alchemist-complete-debug-mode'
is `nil', otherwise it disable it."
(interactive)
(setq alchemist-complete-debug-mode (not alchemist-complete-debug-mode))
(let ((state (if alchemist-complete-debug-mode
"ENABLED"
"DISABLED")))
(message "Alchemist complete debug mode is: %s" state)
))

(defun alchemist-complete--clean-functions (candidates)
(mapcar (lambda (c) (replace-regexp-in-string "/[0-9]$" "" c)) candidates))

Expand Down Expand Up @@ -113,6 +126,9 @@ IO.inspect Alchemist.expand('%s')
candidates)))
(funcall callback candidates)))
(t
(when alchemist-complete-debug-mode
(alchemist-utils--warn (format "\n== ALCHEMIST COMPLETION FAILED ==\n== OUTPUT BEGIN:\n%s== OUTPUT END:"
(alchemist-utils--get-buffer-content (process-buffer process)))))
(funcall callback '())))
(alchemist-utils--erase-buffer (process-buffer process)))))

Expand Down
4 changes: 4 additions & 0 deletions alchemist-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ It walks the directory tree until it finds a elixir project root indicator."
(with-current-buffer buffer
(buffer-substring (point-min) (point-max))))

(defun alchemist-utils--warn (message)
(kill-buffer "*Warnings*")
(warn message))

(provide 'alchemist-utils)

;;; alchemist-utils.el ends here
4 changes: 2 additions & 2 deletions alchemist.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
;; Author: Samuel Tonini <tonini.samuel@gmail.com>

;; URL: http://www.github.com/tonini/alchemist.el
;; Version: 0.9.0
;; Version: 0.10.0-cvs
;; Package-Requires: ((emacs "24"))
;; Keywords: languages, mix, elixir, elixirc, hex

Expand Down Expand Up @@ -55,7 +55,7 @@
"Hook which enables `alchemist-mode'"
(alchemist-mode 1))

(defvar alchemist--version "0.9.0")
(defvar alchemist--version "0.10.0-cvs")

;;;###autoload
(defun alchemist-version (&optional show-version)
Expand Down

0 comments on commit 3b93ff3

Please sign in to comment.