emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Error when =(stata . t)= added to =org-babel-do-load-languages= in an attempt to evaluate Stata code in org-mode
@ 2017-01-08 17:00 Daniel Guinea
  2017-01-15  8:41 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Guinea @ 2017-01-08 17:00 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 9567 bytes --]

Hello,

I have built the latest Emacs 26.0.50.1 on a Debian OS 8 (Jessie) that
uses Linux version 3.14.5. Then I installed org-mode version 9.0.3. I
want to use the proprietary data analysis and statistical software
Stata version 14. I have checked that it runs alright within Emacs
thanks to ESS by typing  =M-x stata=.

However, I also want to evaluate Stata code in org-mode documents. For that
I have
downloaded the script =ob-stata.el= by Ista Zahn and I have saved it
together with the other =ob-sth.el= files in
=~/.emacs.d/elpa/org-20161224=. Moreover, I have edited the entry:

(defcustom org-babel-stata-command inferior-STA-program-name
  "Name of command to use for executing stata code."
  :group 'org-babel
  :version "24.1"
  :package-version '(Org . "8.3")
  :type 'string)

to reflect my current version of Org, so this piece of code currently
stands as follows in my version of  =ob-stata.el=:

(defcustom org-babel-stata-command inferior-STA-program-name
  "Name of command to use for executing stata code."
  :group 'org-babel
  :version "24.1"
  :package-version '(Org . "9.0.3")
  :type 'string)


However, if I add =(stata . t)= to =org-babel-do-load-languages= as follows:

(org-babel-do-load-languages
   'org-babel-load-languages
  '((emacs-lisp . t)
    (sh . t)
    (R . t)
    (perl . t)
    (ruby . t)
    (python . t)
    (js . t)
    (haskell . t)
    (stata . t)
    (shell . t)))

I get the following message when I restart emacs:

#################  Beginning of debugger message ###################

Debugger entered--Lisp error: (void-variable inferior-STA-program-name)
  eval(inferior-STA-program-name)
  custom-initialize-reset(org-babel-stata-command inferior-STA-program-name)
  custom-declare-variable(org-babel-stata-command inferior-STA-program-name
"Name of command to use for executing stata code." :group org-babel
:version "24.1" :package-version (Org . "9.0.3") :type string)
  eval-buffer(#<buffer  *load*-437726> nil
"/home/dgm/.emacs.d/elpa/org-20161224/ob-stata.el" nil t)  ; Reading at
buffer position 2975

load-with-code-conversion("/home/dgm/.emacs.d/elpa/org-20161224/ob-stata.el"
"/home/dgm/.emacs.d/elpa/org-20161224/ob-stata.el" nil t)
  require(ob-stata)
  (if active (require (intern (concat "ob-" lang))) (funcall (quote
fmakunbound) (intern (concat "org-babel-execute:" lang))) (funcall (quote
fmakunbound) (intern (concat "org-babel-expand-body:" lang))))
  (let ((active (cdr pair)) (lang (symbol-name (car pair)))) (if active
(require (intern (concat "ob-" lang))) (funcall (quote fmakunbound) (intern
(concat "org-babel-execute:" lang))) (funcall (quote fmakunbound) (intern
(concat "org-babel-expand-body:" lang)))))
  (let ((pair (car --dolist-tail--))) (let ((active (cdr pair)) (lang
(symbol-name (car pair)))) (if active (require (intern (concat "ob-"
lang))) (funcall (quote fmakunbound) (intern (concat "org-babel-execute:"
lang))) (funcall (quote fmakunbound) (intern (concat
"org-babel-expand-body:" lang))))) (setq --dolist-tail-- (cdr
--dolist-tail--)))
  (while --dolist-tail-- (let ((pair (car --dolist-tail--))) (let ((active
(cdr pair)) (lang (symbol-name (car pair)))) (if active (require (intern
(concat "ob-" lang))) (funcall (quote fmakunbound) (intern (concat
"org-babel-execute:" lang))) (funcall (quote fmakunbound) (intern (concat
"org-babel-expand-body:" lang))))) (setq --dolist-tail-- (cdr
--dolist-tail--))))
  (let ((--dolist-tail-- org-babel-load-languages)) (while --dolist-tail--
(let ((pair (car --dolist-tail--))) (let ((active (cdr pair)) (lang
(symbol-name (car pair)))) (if active (require (intern (concat "ob-"
lang))) (funcall (quote fmakunbound) (intern (concat "org-babel-execute:"
lang))) (funcall (quote fmakunbound) (intern (concat
"org-babel-expand-body:" lang))))) (setq --dolist-tail-- (cdr
--dolist-tail--)))))
  org-babel-do-load-languages(org-babel-load-languages ((emacs-lisp . t)
(sh . t) (R . t) (perl . t) (ruby . t) (python . t) (js . t) (haskell . t)
(stata . t) (shell . t)))
  eval-buffer(#<buffer  *load*-405315> nil
"/home/dgm/.emacs.d/starter-kit-org.el" nil t)  ; Reading at buffer
position 2047
  load-with-code-conversion("/home/dgm/.emacs.d/starter-kit-org.el"
"/home/dgm/.emacs.d/starter-kit-org.el" nil nil)
  load("/home/dgm/.emacs.d/starter-kit-org.el" nil nil t)
  load-file("/home/dgm/.emacs.d/starter-kit-org.el")
  (progn (load-file exported-file) "Loaded")
  (if compile (progn (byte-compile-file exported-file (quote load))
"Compiled and loaded") (progn (load-file exported-file) "Loaded"))
  (message "%s %s" (if compile (progn (byte-compile-file exported-file
(quote load)) "Compiled and loaded") (progn (load-file exported-file)
"Loaded")) exported-file)
  (let* ((age (function (lambda (file) (float-time (time-subtract
(current-time) (nth 5 ...)))))) (base-name (file-name-sans-extension file))
(exported-file (concat base-name ".el"))) (if (and (file-exists-p
exported-file) (> (funcall age file) (funcall age exported-file))) nil
(setq exported-file (car (last (org-babel-tangle-file file exported-file
"emacs-lisp"))))) (message "%s %s" (if compile (progn (byte-compile-file
exported-file (quote load)) "Compiled and loaded") (progn (load-file
exported-file) "Loaded")) exported-file))
  org-babel-load-file("/home/dgm/.emacs.d/starter-kit-org.org")
  starter-kit-load("starter-kit-org.org")
  eval-buffer(#<buffer  *load*-847456> nil
"/home/dgm/.emacs.d/starter-kit.el" nil t)  ; Reading at buffer position
3784
  load-with-code-conversion("/home/dgm/.emacs.d/starter-kit.el"
"/home/dgm/.emacs.d/starter-kit.el" nil nil)
  load("/home/dgm/.emacs.d/starter-kit.el" nil nil t)
  load-file("/home/dgm/.emacs.d/starter-kit.el")
  (progn (load-file exported-file) "Loaded")
  (if compile (progn (byte-compile-file exported-file (quote load))
"Compiled and loaded") (progn (load-file exported-file) "Loaded"))
  (message "%s %s" (if compile (progn (byte-compile-file exported-file
(quote load)) "Compiled and loaded") (progn (load-file exported-file)
"Loaded")) exported-file)
  (let* ((age (function (lambda (file) (float-time (time-subtract
(current-time) (nth 5 ...)))))) (base-name (file-name-sans-extension file))
(exported-file (concat base-name ".el"))) (if (and (file-exists-p
exported-file) (> (funcall age file) (funcall age exported-file))) nil
(setq exported-file (car (last (org-babel-tangle-file file exported-file
"emacs-lisp"))))) (message "%s %s" (if compile (progn (byte-compile-file
exported-file (quote load)) "Compiled and loaded") (progn (load-file
exported-file) "Loaded")) exported-file))
  org-babel-load-file("/home/dgm/.emacs.d/starter-kit.org")
  eval-buffer(#<buffer  *load*> nil "/home/dgm/.emacs.d/init.el" nil t)  ;
Reading at buffer position 4099
  load-with-code-conversion("/home/dgm/.emacs.d/init.el"
"/home/dgm/.emacs.d/init.el" t t)
  load("/home/dgm/.emacs.d/init" t t)
#################  End of debugger message ###################

I have checked that the file =ess-sta-d.el= located in
=/.emacs.d/elpa/ess-20161101.215/lisp= has the line
=(inferior-ess-program  . inferior-STA-program-name)= included in the
definition of the variable =STA-customize-alist= as follows:

(defvar STA-customize-alist
  '((ess-local-customize-alist     . 'STA-customize-alist)
    (ess-language                  . "STA")
    (ess-dialect                   . STA-dialect-name)
    (ess-suffix                    . "ado")
    (ess-mode-editing-alist        . STA-editing-alist)
    (ess-mode-syntax-table         . STA-syntax-table)
    (ess-mode-edit                 . 'STA-mode)
    (ess-help-sec-regex            . ess-help-STA-sec-regex)
    (ess-help-sec-keys-alist       . ess-help-STA-sec-keys-alist)
    (ess-loop-timeout              . 500000 )
    (ess-object-name-db-file       . "ess-sta-namedb.el" )
    (ess-help-web-search-command   . "
http://www.stata.com/search/?q=%s&restrict=&btnG=Search&client=stata&num=&output=xml_no_dtd&site=stata&ie=&oe=UTF-8&sort=&proxystylesheet=stata
")
    (ess-eval-linewise-function    . #'stata-eval-linewise)
    (inferior-ess-font-lock-defaults . ess-STA-mode-font-lock-defaults)
    (inferior-ess-program          . inferior-STA-program-name)
    (inferior-ess-objects-command  . "describe\n")
    (inferior-ess-help-command     . "help %s\n") ;; assumes set more off
    (inferior-ess-exit-command     . "exit\n")
    ;; --more-- is necessary here (hangs otherwise if startup stata.msg is
big)
    (inferior-ess-primary-prompt   . "[.:] \\|--more--")
    (inferior-ess-secondary-prompt . "--more--")
    (comint-use-prompt-regexp      . t)
    (inferior-ess-start-file       . inferior-STA-start-file)
;"~/.ess-stata")
    (inferior-ess-start-args       . inferior-STA-start-args)
    (ess-get-help-topics-function  . 'ess-get-STA-help-topics)
    (inferior-ess-search-list-command   . "set more off\n search()\n")
    (comment-start                . "/\* ")
    (comment-end                  . " \*/")
    (comment-start-skip           . "/\\*+ *")
    (comment-use-syntax           . t) ;; needed for multiline
    (ess-execute-screen-options-command . "set linesize %s\n")
    )
  "Variables to customize for Stata.")

From here on I am lost. I have checked the corresponding scripts for
other languages and in them =inferior-ess-program= is also and correctly
assigned to their inferior program name. I don't understand why this
does not happen with Stata.

Any help is greatly appreciated! I normally use R but Stata is
the industry standard in econometrics and I am bound to use it when
working with colleagues.

Thank you very much,
Daniel

[-- Attachment #2: Type: text/html, Size: 11679 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Error when =(stata . t)= added to =org-babel-do-load-languages= in an attempt to evaluate Stata code in org-mode
  2017-01-08 17:00 Error when =(stata . t)= added to =org-babel-do-load-languages= in an attempt to evaluate Stata code in org-mode Daniel Guinea
@ 2017-01-15  8:41 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2017-01-15  8:41 UTC (permalink / raw)
  To: Daniel Guinea; +Cc: emacs-orgmode

Hello,

Daniel Guinea <daniel.guinea@poli.uned.es> writes:

> However, I also want to evaluate Stata code in org-mode documents. For that
> I have
> downloaded the script =ob-stata.el= by Ista Zahn and I have saved it
> together with the other =ob-sth.el= files in
> =~/.emacs.d/elpa/org-20161224=. Moreover, I have edited the entry:
>
> (defcustom org-babel-stata-command inferior-STA-program-name
>   "Name of command to use for executing stata code."
>   :group 'org-babel
>   :version "24.1"
>   :package-version '(Org . "8.3")
>   :type 'string)
>
> to reflect my current version of Org, so this piece of code currently
> stands as follows in my version of  =ob-stata.el=:
>
> (defcustom org-babel-stata-command inferior-STA-program-name
>   "Name of command to use for executing stata code."
>   :group 'org-babel
>   :version "24.1"
>   :package-version '(Org . "9.0.3")
>   :type 'string)

This part is not needed. :package-version is used to specify when
a defcustom was introduced or when its default value last changed.

> However, if I add =(stata . t)= to =org-babel-do-load-languages= as follows:
>
> (org-babel-do-load-languages
>    'org-babel-load-languages
>   '((emacs-lisp . t)
>     (sh . t)
>     (R . t)
>     (perl . t)
>     (ruby . t)
>     (python . t)
>     (js . t)
>     (haskell . t)
>     (stata . t)
>     (shell . t)))
>
> I get the following message when I restart emacs:
>
> #################  Beginning of debugger message ###################
>
> Debugger entered--Lisp error: (void-variable inferior-STA-program-name)

inferior-STAT-program-name is a variable defined in "ess-custom.el".
The error probably comes from the fact "ob-stata.el" is loaded before
"ess-custom.el" is.

You may want to tell the author of "ob-stata.el" about it. It is missing
a (require 'ess) somewhere in the library.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-15  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-08 17:00 Error when =(stata . t)= added to =org-babel-do-load-languages= in an attempt to evaluate Stata code in org-mode Daniel Guinea
2017-01-15  8:41 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).