nendo 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,84 @@
1
+ ;;
2
+ ;; Nendo-mode for Emacs
3
+ ;;
4
+ ;; Copyright (c) 2010 Kiyoka Nishiyama
5
+ ;;
6
+ ;;
7
+
8
+ (require 'comint)
9
+ (require 'cmuscheme)
10
+
11
+ ;; Custom Variables:
12
+ (defgroup nendo nil
13
+ "*Support for editing and evaluation nendo s-exparession."
14
+ :group 'scheme
15
+ :prefix "nendo-"
16
+ :link '(url-link "http://oldtype.sumibi.org/show-page/Nendo"))
17
+
18
+
19
+ (defvar nendo-result-buffer '())
20
+
21
+ (defun nendo-watch-for-eval-result (string)
22
+ (let ((lines
23
+ (split-string string "[\r\n]")))
24
+ (mapcar
25
+ (lambda (x)
26
+ (cond
27
+ ((string= "nendo> " x)
28
+ (when (not (get-buffer-window-list "*scheme*" t t))
29
+ (message "%s" (mapconcat
30
+ (lambda (e) e)
31
+ (reverse nendo-result-buffer)
32
+ "\n"))
33
+ (setq nendo-result-buffer '())))
34
+ ((< 0 (length x))
35
+ (push x nendo-result-buffer))
36
+ (t
37
+ nil)))
38
+ lines)))
39
+
40
+
41
+ (define-derived-mode nendo-mode scheme-mode "Nendo mode"
42
+ "Major mode for editing nendo code.
43
+ Editing commands are similar to those of 'scheme-mode'."
44
+ (make-local-variable 'scheme-buffer)
45
+ (local-set-key "\C-c\C-e" 'nendo-send-definition)
46
+ (local-set-key "\C-x\C-e" 'nendo-send-last-sexp))
47
+
48
+ (defun nendo-add-hooks ()
49
+ (when (get-buffer "*scheme*")
50
+ (with-current-buffer (get-buffer "*scheme*")
51
+ (add-hook 'comint-output-filter-functions 'nendo-watch-for-eval-result t t))))
52
+
53
+ (defun nendo-send-definition ()
54
+ "Send the current definition to the inferior Scheme process."
55
+ (interactive)
56
+ (nendo-add-hooks)
57
+ (scheme-send-definition))
58
+
59
+ (defun nendo-send-last-sexp ()
60
+ "Send the previous sexp to the inferior Scheme process."
61
+ (interactive)
62
+ (nendo-add-hooks)
63
+ (scheme-send-last-sexp))
64
+
65
+ ;; for compatibility with Emacs 21
66
+ (unless (functionp 'read-directory-name)
67
+ (defun read-directory-name (prompt &optional dir default match init)
68
+ (let ((dir (cond (dir dir)
69
+ ((not init) "")
70
+ (t default-directory))))
71
+ (read-file-name prompt dir
72
+ (or default (if (and init (not (string= init "")))
73
+ (expand-file-name init dir)
74
+ ""))
75
+ match init))))
76
+
77
+
78
+
79
+ (provide 'nendo-mode)
80
+
81
+ ;; Local variables:
82
+ ;; mode: emacs-lisp
83
+ ;; end:
84
+