[ESS] ess-tracebug under org-mode / babel

Andreas Leha andreas.leha at med.uni-goettingen.de
Thu Jan 26 09:56:45 CET 2012


Vitalie Spinu <spinuvit at gmail.com> writes:

> On 11 January 2012 14:05, Rainer M Krug <r.m.krug at gmail.com> wrote:

[...]

>>
>> As I did not manage to get the backward org-babel-detangle) to work, I
>> am wondering: is there a way of running the debug with the source
>> buffer from org-mode (C-' from the source block) instead of the R file?
>>
>> I guess it is tricky?
>>
>

[...]

>
> By default ess-tracebug automatically injects the source only for
> ess-eval-function. The behavior is governed by
> ess-tracebug-inject-source-p, which  is nil. If you set it to 't' all
> the code evaluated *invisibly* will be associated with the source
> buffer (be it R, Rnw, or org).
>
> The above works in Rnw files because ess-mode is active in R chunks.
> Org-mode has a different approach for managing code  and some
> elaboration is required. I've just implemented the basic
> org-mode/babel integration and it works like a charm.
>
> You don't have to do anything special. Start editing source chunk with
> [C-c '], edit the stuff, insert the breakpoint in a function [M-c b]
> and eval function as usual ([C-c C-c] or [C-c C-f]). Next time your
> func is called, visual debugger will start jumping in the *org src*
> buffer. If that buffer has been already closed, the debugger uses the
> original .org file to jump through the code in org chunk. Please try.
>

[...]


Hi Vitalie,

this sounds great, but I can not get this to work.  Instead I am seeing
(wrong-type-argument stringp nil)

I am on emacs 24.0.92 and fresh svn up of ess.

Best,
Andreas

PS:  Here is a backtrace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-name-nondirectory(nil)
  (let ((filename (file-name-nondirectory (buffer-file-name)))) (goto-char beg) (when (looking-at "\\s +") (re-search-forward "[^ 	\n]" nil t) (setq beg (point-at-bol))) (goto-char end) (when (looking-back "\\s +") (re-search-backward "[^ 	\n]" nil t) (setq end (point-at-eol))) (setq ess--tracebug-eval-index (1+ ess--tracebug-eval-index)) (put-text-property beg end (quote tb-index) ess--tracebug-eval-index) (format "eval(parse(text=\"%s\",srcfile=srcfile(\"%s@%d\")))\n" (replace-regexp-in-string "\"" "\\\\\\&" (replace-regexp-in-string "\\\\\"" "\\\\\\&" (buffer-substring-no-properties beg end))) filename ess--tracebug-eval-index))
  ess--tb-get-source-refd-string(81 178)
  (let ((ess-eval-visibly-p nil) (comm (ess--tb-get-source-refd-string beg end)) assigned-p) (ess-tb-set-last-input) (when dev-p (setq assigned-p (ess-developer-assign-function name comm))) (unless assigned-p (ess-process-send-string (get-process ess-local-process-name) comm) (message "Sourced function %s " (or name "???"))))
  (save-excursion (let ((ess-eval-visibly-p nil) (comm (ess--tb-get-source-refd-string beg end)) assigned-p) (ess-tb-set-last-input) (when dev-p (setq assigned-p (ess-developer-assign-function name comm))) (unless assigned-p (ess-process-send-string (get-process ess-local-process-name) comm) (message "Sourced function %s " (or name "???")))) t)
  ess--tb-assign-function(#("buildTableName.sampleIndex" 0 26 (fontified t face font-lock-function-name-face)) 81 178 nil)
  (setq assigned-p (ess--tb-assign-function name beg end dev-p))
  (if tb-p (setq assigned-p (ess--tb-assign-function name beg end dev-p)) (if dev-p (setq assigned-p (ess-developer-assign-function name (buffer-substring-no-properties beg end)))))
  (let ((tb-p (and (boundp (quote ess--tracebug-p)) (ess-get-process-variable ess-local-process-name (quote ess--tracebug-p)))) (dev-p (ess-get-process-variable ess-local-process-name (quote ess--developer-p)))) (if tb-p (setq assigned-p (ess--tb-assign-function name beg end dev-p)) (if dev-p (setq assigned-p (ess-developer-assign-function name (buffer-substring-no-properties beg end))))))
  (progn (let ((tb-p (and (boundp (quote ess--tracebug-p)) (ess-get-process-variable ess-local-process-name (quote ess--tracebug-p)))) (dev-p (ess-get-process-variable ess-local-process-name (quote ess--developer-p)))) (if tb-p (setq assigned-p (ess--tb-assign-function name beg end dev-p)) (if dev-p (setq assigned-p (ess-developer-assign-function name (buffer-substring-no-properties beg end)))))))
  (if (string-match "^R" ess-dialect) (progn (let ((tb-p (and (boundp (quote ess--tracebug-p)) (ess-get-process-variable ess-local-process-name (quote ess--tracebug-p)))) (dev-p (ess-get-process-variable ess-local-process-name (quote ess--developer-p)))) (if tb-p (setq assigned-p (ess--tb-assign-function name beg end dev-p)) (if dev-p (setq assigned-p (ess-developer-assign-function name (buffer-substring-no-properties beg end))))))))
  (when (string-match "^R" ess-dialect) (let ((tb-p (and (boundp (quote ess--tracebug-p)) (ess-get-process-variable ess-local-process-name (quote ess--tracebug-p)))) (dev-p (ess-get-process-variable ess-local-process-name (quote ess--developer-p)))) (if tb-p (setq assigned-p (ess--tb-assign-function name beg end dev-p)) (if dev-p (setq assigned-p (ess-developer-assign-function name (buffer-substring-no-properties beg end)))))))
  (let ((beg (nth 0 beg-end)) (end (nth 1 beg-end)) name assigned-p) (goto-char beg) (setq name (ess-read-object-name-default)) (when (string-match "^R" ess-dialect) (let ((tb-p (and (boundp (quote ess--tracebug-p)) (ess-get-process-variable ess-local-process-name (quote ess--tracebug-p)))) (dev-p (ess-get-process-variable ess-local-process-name (quote ess--developer-p)))) (if tb-p (setq assigned-p (ess--tb-assign-function name beg end dev-p)) (if dev-p (setq assigned-p (ess-developer-assign-function name (buffer-substring-no-properties beg end))))))) (unless assigned-p (princ (concat "Loading: " name) t) (ess-eval-region beg end vis (concat "Sourced function " (or name "???")))) beg-end)
  (if beg-end (let ((beg (nth 0 beg-end)) (end (nth 1 beg-end)) name assigned-p) (goto-char beg) (setq name (ess-read-object-name-default)) (when (string-match "^R" ess-dialect) (let ((tb-p (and (boundp ...) (ess-get-process-variable ess-local-process-name ...))) (dev-p (ess-get-process-variable ess-local-process-name (quote ess--developer-p)))) (if tb-p (setq assigned-p (ess--tb-assign-function name beg end dev-p)) (if dev-p (setq assigned-p (ess-developer-assign-function name ...)))))) (unless assigned-p (princ (concat "Loading: " name) t) (ess-eval-region beg end vis (concat "Sourced function " (or name "???")))) beg-end) nil)
  (let ((beg-end (ess-end-of-function nil no-error))) (if beg-end (let ((beg (nth 0 beg-end)) (end (nth 1 beg-end)) name assigned-p) (goto-char beg) (setq name (ess-read-object-name-default)) (when (string-match "^R" ess-dialect) (let ((tb-p (and ... ...)) (dev-p (ess-get-process-variable ess-local-process-name ...))) (if tb-p (setq assigned-p (ess--tb-assign-function name beg end dev-p)) (if dev-p (setq assigned-p ...))))) (unless assigned-p (princ (concat "Loading: " name) t) (ess-eval-region beg end vis (concat "Sourced function " (or name "???")))) beg-end) nil))
  (save-excursion (let ((beg-end (ess-end-of-function nil no-error))) (if beg-end (let ((beg (nth 0 beg-end)) (end (nth 1 beg-end)) name assigned-p) (goto-char beg) (setq name (ess-read-object-name-default)) (when (string-match "^R" ess-dialect) (let ((tb-p ...) (dev-p ...)) (if tb-p (setq assigned-p ...) (if dev-p ...)))) (unless assigned-p (princ (concat "Loading: " name) t) (ess-eval-region beg end vis (concat "Sourced function " (or name "???")))) beg-end) nil)))
  ess-eval-function(nil)
  call-interactively(ess-eval-function nil nil)



More information about the ESS-help mailing list