Skip to content

Commit

Permalink
make flymake use $HOME/.erlang-flymake as temp dir. Ought to work on …
Browse files Browse the repository at this point in the history
…windows, and (more importantly) if the erl file is write protected.

smarter(?) include path guessing.

spawn_monitor highlighted as a bif.
  • Loading branch information
massemanet committed Jun 15, 2009
1 parent 5c6ebcd commit 6984b6e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 22 deletions.
22 changes: 13 additions & 9 deletions erlang-flymake.el
Expand Up @@ -17,21 +17,25 @@
(if (locate-library "flymake")
(progn
(require 'flymake)
(defun flymake-tmp-filename(filename prefix)
(let*
((tmp-dir (concat (getenv "HOME") "/.erlang-flymake"))
(tmp-name (file-name-nondirectory filename))
(tmp-file (concat tmp-dir "/" tmp-name)))
(flymake-log 3 "made temp-file: %s" tmp-file)
tmp-file))
(defun erlang-flymake-init ()
"Set up the command used to parse our buffer"
(let* ((erlang-dir (file-name-directory (locate-library "erlang")))
(temp-file (flymake-init-create-temp-buffer-copy
'flymake-tmp-filename)))
(list (concat erlang-dir "flymaker.sh") (list temp-file))))
(defun flymake-siblicide()
"Kill all next-error capable buffers."
(condition-case nil
(progn (kill-buffer (next-error-find-buffer))
(flymake-siblicide))
(error nil)))
(defun erlang-flymake-init ()
"Set up the command used to parse our buffer"
(let* ((erlang-dir (file-name-directory (locate-library "erlang")))
(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))))
(list (concat erlang-dir "flymaker.sh") (list local-file))))
(defun erlang-flymake-next-error ()
"Goto next error, if any. Display error in mini-buffer."
(interactive)
Expand Down
2 changes: 1 addition & 1 deletion erlang.el
Expand Up @@ -551,7 +551,7 @@ This is used to determine matches in complex regexps which contains
"p\\(id_to_list\\|rocess\\(_\\(flag\\|info\\)\\|es\\)\\|ut\\)\\|"
"r\\(egister\\(\\|ed\\)\\|ound\\)\\|"
"s\\(e\\(lf\\|telement\\)\\|ize"
"\\|p\\(awn\\(\\|_link\\)\\|lit_binary\\)\\|tatistics\\)\\|"
"\\|p\\(awn\\(\\|_link\\|_monitor\\)\\|lit_binary\\)\\|tatistics\\)\\|"
"t\\(erm_to_binary\\|hrow\\|ime\\|l\\|r\\(ace\\|unc\\)\\|uple_to_list\\)\\|"
"un\\(link\\|"
"register\\)\\|"
Expand Down
38 changes: 29 additions & 9 deletions flymaker.sh
@@ -1,15 +1,35 @@
#!/bin/bash

echo $1

dname (){ (cd $1 ; pwd); }
bdname(){ basename `dname $1`; }

# if our module lives in a src dir, we attempt to handle the cases
# .../lib/<app>/src/<our module>
# and
# .../<app>/src/<our module>
# assuming that include and ebin are parallel to src
Is=""
PAs=""
for i in `dirname $1`/../../*/include; do
Is="-I$i $Is"
done
for e in `dirname $1`/../../*/ebin; do
PAs="-pa$e $PAs"
done

erlc -o/tmp $Is $PAs -Wall -P $1 | grep -v "list comprehension has no gene"
if [ `bdname $2` == "src" ]; then
if [ `bdname $2/../..` == "lib" ]; then
top=`dname $2/../..`
else
top=`dname $2/..`
fi
for i in $top/*/include; do
Is="-I$i $Is"
done
for e in $top/*/ebin; do
PAs="-pa$e $PAs"
done
else
top=`dname $2`
PAs="-pa $top"
Is="-I $top"
fi

OUT=`dirname $1`

erlc -o$OUT $Is $PAs -Wall -P $1 | grep -v "list comprehension has no gene"
exit 0
8 changes: 5 additions & 3 deletions test.erl
Expand Up @@ -42,8 +42,8 @@ func4() ->
error
end.

func5(X)
when is_atom(X) ->
func5(Xyz)
when is_atom(Xyz) ->
% `is_atom' should be highlighted as a guard above

% All functions below should be highlighted as functions, not
Expand All @@ -55,8 +55,10 @@ func5(X)
func6(),
deregistered(),

% Xyz should be highlighted as a variabla
AppSpec = Xyz/2,
% atom_to_list and element should be highlighted as bifs
AppName = atom_to_list(element(1, AppSpec)),
atom_to_list(element(1, AppSpec)),

% These should be highlighted as bifs.
erlang:registered(),
Expand Down

0 comments on commit 6984b6e

Please sign in to comment.