2005-08-12 Daiki Ueno <ueno@unixuser.org>
+ * riece-ruby.el (riece-ruby-out-file): New user option.
+ (riece-ruby-err-file): New user option.
+ (riece-ruby-log-file): New user option..
+ (riece-ruby-server-program-arguments): New variable.
+ (riece-ruby-filter): Call output-handler within
+ riece-debug-with-backtrace; erase process output.
+ (riece-ruby-run-exit-handler): Call exit-handler within
+ riece-debug-with-backtrace.
+
* server.rb: Don't bind @err in execution environment;
added logging feature.
;;; Code:
+(require 'riece-debug)
+
(defgroup riece-ruby nil
"Interact with Ruby interpreter."
:group 'riece)
:type 'string
:group 'riece-ruby)
+(defcustom riece-ruby-out-file (expand-file-name "riece-ruby.out"
+ riece-directory)
+ "A file which records stdout of Ruby programs."
+ :type 'string
+ :group 'riece-ruby)
+
+(defcustom riece-ruby-err-file (expand-file-name "riece-ruby.err"
+ riece-directory)
+ "A file which records stderr of Ruby programs."
+ :type 'string
+ :group 'riece-ruby)
+
+(defcustom riece-ruby-log-file (expand-file-name "riece-ruby.log"
+ riece-directory)
+ "A file used to logging."
+ :type 'string
+ :group 'riece-ruby)
+
(defvar riece-ruby-server-program "server.rb"
"The server program file. If the filename is not absolute, it is
assumed that the file is in the same directory of this file.")
+(defvar riece-ruby-server-program-arguments (list "-o" riece-ruby-out-file
+ "-e" riece-ruby-err-file
+ "-l" riece-ruby-log-file)
+ "Command line arguments passed to `riece-ruby-server-program'.")
+
(defvar riece-ruby-process nil
"Process object of Ruby interpreter.")
(set-buffer (process-buffer process))
(goto-char (point-max))
(insert input)
- (goto-char (process-mark process))
+ (goto-char (point-min))
(beginning-of-line)
(while (looking-at ".*\r\n")
(if (looking-at "OK\\( \\(.*\\)\\)?\r")
(let ((entry (assoc (match-string 1)
riece-ruby-output-handler-alist)))
(if entry
- (funcall (cdr entry) (car entry) (match-string 2))))
+ (riece-debug-with-backtrace
+ (funcall (cdr entry) (car entry) (match-string 2)))))
(if (looking-at "# exit \\(.*\\)\r")
(riece-ruby-run-exit-handler (match-string 1))))))))
(forward-line))
- (set-marker (process-mark process) (point-marker))))
+ (delete-region (point-min) (point))))
(defun riece-ruby-run-exit-handler (name)
(let ((entry (assoc name riece-ruby-exit-handler-alist)))
(progn
(setq riece-ruby-exit-handler-alist
(delq entry riece-ruby-exit-handler-alist))
- (funcall (cdr entry) (car entry))
+ (riece-debug-with-backtrace
+ (funcall (cdr entry) (car entry)))
(riece-ruby-clear name)))))
(defun riece-ruby-sentinel (process status)
(coding-system-for-write 'binary)
(coding-system-for-read 'binary))
(setq riece-ruby-process
- (start-process "riece-ruby" (generate-new-buffer " *Ruby*")
+ (apply #'start-process "riece-ruby" (generate-new-buffer " *Ruby*")
riece-ruby-command
(if (file-name-absolute-p riece-ruby-server-program)
riece-ruby-server-program
riece-ruby-server-program
(file-name-directory
(locate-library
- (symbol-file 'riece-ruby-execute)))))))
+ (symbol-file 'riece-ruby-execute)))))
+ riece-ruby-server-program-arguments))
(process-kill-without-query riece-ruby-process)
(set-process-filter riece-ruby-process #'riece-ruby-filter)
(set-process-sentinel riece-ruby-process #'riece-ruby-sentinel)))