I'm trying to "override" a function

(defun org-babel-ruby-evaluate (buffer body &optional result-type)   

I think it came with org mode, which came with prelude.

As a first step, I paste this unmodified version (found via google) in to Scratch and eval-buffer

(defun org-babel-ruby-evaluate (buffer body &optional result-type)
  "Pass BODY to the Ruby process in BUFFER.  If RESULT-TYPE equals
'output then return a list of the outputs of the statements in
BODY, if RESULT-TYPE equals 'value then return the value of the
last statement in BODY."
  (if (not session)
      ;; external process evaluation
      (save-window-excursion
        (case result-type
          (output
           (with-temp-buffer
             (insert body)
             ;; (message "buffer=%s" (buffer-string)) ;; debugging
             (shell-command-on-region (point-min) (point-max) "ruby" 'replace)
             (buffer-string)))
          (value
           (let ((tmp-file (make-temp-file "ruby-functional-results")))
             (with-temp-buffer
               (insert (format org-babel-ruby-wrapper-method body tmp-file))
               ;; (message "buffer=%s" (buffer-string)) ;; debugging
               (shell-command-on-region (point-min) (point-max) "ruby"))
             (with-temp-buffer (insert-file-contents tmp-file) (buffer-string))))))
    ;; comint session evaluation
    (message "session evaluation")
    (let* ((full-body (mapconcat #'org-babel-chomp
                                 (list body org-babel-ruby-last-value-eval org-babel-ruby-eoe-indicator) "\n"))
           (raw (org-babel-comint-with-output buffer org-babel-ruby-eoe-indicator t
                  (insert full-body) (comint-send-input nil t)))
           (results (cdr (member org-babel-ruby-eoe-indicator
                                 (reverse (mapcar #'org-babel-ruby-read-string
                                                  (mapcar #'org-babel-trim raw)))))))
      (case result-type
        (output (mapconcat #'identity (reverse (cdr results)) "\n"))
        (value (car results))))))

But I don't think it worked for me, I got

Eager macro-expansion failure: (wrong-type-argument listp buffer)

in minibufffer.

I used a emacs feature called M-x find-function which gave me the correct prototype of the function.

That worked. MY guess is that the function I found on the web was outdated, so it didn't fit in well with the rest of the system.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.