forked from redguardtoo/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-elisp.el
75 lines (65 loc) · 2.59 KB
/
init-elisp.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
(require 'flymake)
(defun elisp-mode-hooks ()
"lisp-mode-hooks"
(when (require 'eldoc nil t)
(setq eldoc-idle-delay 0.2)
(setq eldoc-echo-area-use-multiline-p t)
(turn-on-eldoc-mode)))
(add-hook 'emacs-lisp-mode-hook 'elisp-mode-hooks)
;; @see http://blog.urth.org/2011/06/02/flymake-versus-the-catalyst-restarter/
(defun flymake-create-temp-intemp (file-name prefix)
"Return file name in temporary directory for checking
FILE-NAME. This is a replacement for
`flymake-create-temp-inplace'. The difference is that it gives
a file name in `temporary-file-directory' instead of the same
directory as FILE-NAME.
For the use of PREFIX see that function.
Note that not making the temporary file in another directory
\(like here) will not if the file you are checking depends on
relative paths to other files \(for the type of checks flymake
makes)."
(unless (stringp file-name)
(error "Invalid file-name"))
(or prefix
(setq prefix "flymake"))
(let* ((name (concat
(file-name-nondirectory
(file-name-sans-extension file-name))
"_" prefix))
(ext (concat "." (file-name-extension file-name)))
(temp-name (make-temp-file name nil ext))
)
(flymake-log 3 "create-temp-intemp: file=%s temp=%s" file-name temp-name)
temp-name))
;; do not use elisplint
(defun flymake-elisp-init ()
(unless (string-match "^ " (buffer-name))
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-intemp))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list
(expand-file-name invocation-name invocation-directory)
(list
"-Q" "--batch" "--eval"
(prin1-to-string
(quote
(dolist (file command-line-args-left)
(with-temp-buffer
(insert-file-contents file)
(condition-case data
(scan-sexps (point-min) (point-max))
(scan-error
(goto-char(nth 2 data))
(princ (format "%s:%s: error: Unmatched bracket or quote\n"
file (line-number-at-pos)))))))
)
)
local-file)))))
(push '("\\.el$" flymake-elisp-init) flymake-allowed-file-name-masks)
;; ;; workaround for (eq buffer-file-name nil)
(defun emacs-lisp-mode-hook-flymake-elisp ()
(if buffer-file-name (flymake-mode)))
(add-hook 'emacs-lisp-mode-hook 'emacs-lisp-mode-hook-flymake-elisp)
(provide 'init-elisp)