annotate lisp/org/ob-scheme.el @ 111539:ad93f2dd2d38

Add const to array elements. * keyboard.c (modify_event_symbol) : Add const to array elements of arg NAME_TABLE. (lispy_accent_keys, lispy_function_keys, lispy_multimedia_keys) (lispy_kana_keys, iso_lispy_function_keys, lispy_wheel_names) (lispy_wheel_names, lispy_drag_n_drop_names, modifier_names): Add const to array elements. (scroll_bar_parts): Make static. Fix position of const. * w32fns.c (lispy_function_keys): Add const to extern. * w32inevt.c (lispy_function_keys): Likewise.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Sun, 14 Nov 2010 15:55:27 +0900
parents 76c2ff4450eb
children a7740098b594
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
1 ;;; ob-scheme.el --- org-babel functions for Scheme
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
2
111521
76c2ff4450eb Standardize some file headers.
Glenn Morris <rgm@gnu.org>
parents: 111506
diff changeset
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
4
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
5 ;; Author: Eric Schulte
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
6 ;; Keywords: literate programming, reproducible research, scheme
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
7 ;; Homepage: http://orgmode.org
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
8 ;; Version: 7.3
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
9
111521
76c2ff4450eb Standardize some file headers.
Glenn Morris <rgm@gnu.org>
parents: 111506
diff changeset
10 ;; This file is part of GNU Emacs.
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
11
111521
76c2ff4450eb Standardize some file headers.
Glenn Morris <rgm@gnu.org>
parents: 111506
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
111521
76c2ff4450eb Standardize some file headers.
Glenn Morris <rgm@gnu.org>
parents: 111506
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
76c2ff4450eb Standardize some file headers.
Glenn Morris <rgm@gnu.org>
parents: 111506
diff changeset
15 ;; (at your option) any later version.
76c2ff4450eb Standardize some file headers.
Glenn Morris <rgm@gnu.org>
parents: 111506
diff changeset
16
76c2ff4450eb Standardize some file headers.
Glenn Morris <rgm@gnu.org>
parents: 111506
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
111521
76c2ff4450eb Standardize some file headers.
Glenn Morris <rgm@gnu.org>
parents: 111506
diff changeset
21
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
111521
76c2ff4450eb Standardize some file headers.
Glenn Morris <rgm@gnu.org>
parents: 111506
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
24
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
25 ;;; Commentary:
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
26
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
27 ;; Now working with SBCL for both session and external evaluation.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
28 ;;
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
29 ;; This certainly isn't optimally robust, but it seems to be working
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
30 ;; for the basic use cases.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
31
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
32 ;;; Requirements:
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
33
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
34 ;; - a working scheme implementation
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
35 ;; (e.g. guile http://www.gnu.org/software/guile/guile.html)
111521
76c2ff4450eb Standardize some file headers.
Glenn Morris <rgm@gnu.org>
parents: 111506
diff changeset
36 ;;
111506
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
37 ;; - for session based evaluation cmuscheme.el is required which is
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
38 ;; included in Emacs
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
39
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
40 ;;; Code:
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
41 (require 'ob)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
42 (require 'ob-ref)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
43 (require 'ob-comint)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
44 (require 'ob-eval)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
45 (eval-when-compile (require 'cl))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
46
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
47 (declare-function run-scheme "ext:cmuscheme" (cmd))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
48
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
49 (defvar org-babel-default-header-args:scheme '()
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
50 "Default header arguments for scheme code blocks.")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
51
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
52 (defvar org-babel-scheme-eoe "org-babel-scheme-eoe"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
53 "String to indicate that evaluation has completed.")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
54
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
55 (defcustom org-babel-scheme-cmd "guile"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
56 "Name of command used to evaluate scheme blocks."
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
57 :group 'org-babel
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
58 :type 'string)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
59
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
60 (defun org-babel-expand-body:scheme (body params)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
61 "Expand BODY according to PARAMS, return the expanded body."
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
62 (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
63 (if (> (length vars) 0)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
64 (concat "(let ("
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
65 (mapconcat
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
66 (lambda (var) (format "%S" (print `(,(car var) ',(cdr var)))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
67 vars "\n ")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
68 ")\n" body ")")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
69 body)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
70
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
71 (defvar scheme-program-name)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
72 (defun org-babel-execute:scheme (body params)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
73 "Execute a block of Scheme code with org-babel.
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
74 This function is called by `org-babel-execute-src-block'"
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
75 (let* ((result-type (cdr (assoc :result-type params)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
76 (org-babel-scheme-cmd (or (cdr (assoc :scheme params))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
77 org-babel-scheme-cmd))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
78 (full-body (org-babel-expand-body:scheme body params)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
79 (read
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
80 (if (not (string= (cdr (assoc :session params)) "none"))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
81 ;; session evaluation
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
82 (let ((session (org-babel-prep-session:scheme
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
83 (cdr (assoc :session params)) params)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
84 (org-babel-comint-with-output
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
85 (session (format "%S" org-babel-scheme-eoe) t body)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
86 (mapc
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
87 (lambda (line)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
88 (insert (org-babel-chomp line)) (comint-send-input nil t))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
89 (list body (format "%S" org-babel-scheme-eoe)))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
90 ;; external evaluation
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
91 (let ((script-file (org-babel-temp-file "scheme-script-")))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
92 (with-temp-file script-file
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
93 (insert
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
94 ;; return the value or the output
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
95 (if (string= result-type "value")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
96 (format "(display %s)" full-body)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
97 full-body)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
98 (org-babel-eval
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
99 (format "%s %s" org-babel-scheme-cmd
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
100 (org-babel-process-file-name script-file)) ""))))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
101
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
102 (defun org-babel-prep-session:scheme (session params)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
103 "Prepare SESSION according to the header arguments specified in PARAMS."
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
104 (let* ((session (org-babel-scheme-initiate-session session))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
105 (vars (mapcar #'cdr (org-babel-get-header params :var)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
106 (var-lines
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
107 (mapcar
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
108 (lambda (var) (format "%S" (print `(define ,(car var) ',(cdr var)))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
109 vars)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
110 (when session
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
111 (org-babel-comint-in-buffer session
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
112 (sit-for .5) (goto-char (point-max))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
113 (mapc (lambda (var)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
114 (insert var) (comint-send-input nil t)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
115 (org-babel-comint-wait-for-output session)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
116 (sit-for .1) (goto-char (point-max))) var-lines)))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
117 session))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
118
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
119 (defun org-babel-scheme-initiate-session (&optional session)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
120 "If there is not a current inferior-process-buffer in SESSION
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
121 then create. Return the initialized session."
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
122 (require 'cmuscheme)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
123 (unless (string= session "none")
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
124 (let ((session-buffer (save-window-excursion
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
125 (run-scheme org-babel-scheme-cmd)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
126 (rename-buffer session)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
127 (current-buffer))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
128 (if (org-babel-comint-buffer-livep session-buffer)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
129 (progn (sit-for .25) session-buffer)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
130 (sit-for .5)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
131 (org-babel-scheme-initiate-session session)))))
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
132
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
133 (provide 'ob-scheme)
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
134
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
135 ;; arch-tag: 6b2fe76f-4b25-4e87-ad1c-225b2f282a71
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
136
5cb272c831e8 Install org-mode version 7.3
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
137 ;;; ob-scheme.el ends here