Re: [O] Fontification for the inner bloc of two nested bloc

2017-10-11 Thread Pierre-André Cornillon
Hello,

On Tue, Oct 10, 2017 at 9:16 AM, Nicolas Goaziou <m...@nicolasgoaziou.fr> wrote:
> Hello,
>
> Pierre-André Cornillon <pac.hera...@gmail.com> writes:
>
>> Dear orgmode users/gurus,
>>
>> I have a question about fontification of inner src bloc.
>>
>> I have two nested blocks: one special (outer bloc) and one src (inner
>> bloc) like this
>>
>> #+begin_bloc20171001122500
>> #+begin_src R
>>   blip <- runif(2)
>>   test <- rnorm(2)
>> #+end_src
>>
>> #+end_bloc20171001122500
>>
>> and I want to have the native fontification property for the inner one.
>>
>> I have already (setq org-src-fontify-natively t) in my .emacs and it
>> works like a charm for src blocks alone (not nested) but for nested
>> ones it breaks.
>>
>> Is nested blocks are allowed and if so, is that possible to have that
>> fontification property ?
>
> Nested blocks are allowed, but the fontification system has a few
> shortcomings, including this one. Ultimately, this part of Org needs to
> be rewritten using the parser.
what is "the parser" exactly ?
>
> Anyway The bug probably lies in `org-fontify-meta-lines-and-blocks-1'.
> Do you want to investigate?

I agree that the regular search expression in the
org-fontify-meta-lines-and-blocks-1 seems to match only one level of
src block. I am not an elisp programmer but splitting
the function in two part will allow to make it recursive (and thus to
cope with several level of nested src block) ? Well it's pure
speculation without testing...

>
> Regards,
>
> --
> Nicolas Goaziou

Best regards,
Pierre-Andre



[O] Babel partial support for SAS language

2017-10-11 Thread Pierre-André Cornillon
Dear orgmode users

as the best way to submit a Babel support for a new language is this
mailing list, I submit this partial support for SAS
language (using ESS).

This is partial as only few header arguments are supported
:results output
:output graphics
:session
arguments are supported but one of the most important, :output value, is
not supported (as I am not able to figure out what does it really mean
with SAS).

I am not proud of it but I have added a
:results odsgraphics
for odsgraphics (which are different from sas/graph classical graphics).


If someone is interested in that support, please see the attached file
(as I don't actually know anything about the orgmode mailing list
policy about attached file, I hope it will be still attached...)

Comments and suggestions are welcome.

Best regards
Pierre-Andre
;;; ob-sas.el --- org-babel functions for sas code evaluation

;; Copyright (C) 2017 P.A. Cornillon
;; Author: P.A. Cornillon
;;  G. Jay Kerns
;;  Eric Schulte
;;  Dan Davison


;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; The file provides Org-Babel support for evaluating sas code.  It is
;; basically result of find-and-replace "sas" for "julia" in
;; ob-julia.el by G. Jay Kerns.
;; 1) Parameter ":results output" needs a
;; to give the right filename for SAS in the  Parameter ":results value"
;; does not work (I'm not sure it makes sense or is useful).  Parameter
;; ":session" works with default value using ESS
;; 

;;; Requirements:
;; Sas: http://sas.com
;; ESS: http://ess.r-project.org

;;; Code:
(require 'ob)
(require 'cl-lib)

(declare-function orgtbl-to-csv "org-table" (table params))
(declare-function sas "ext:ess-sas" ( start-args))
(declare-function inferior-ess-send-string "ext:ess-inf" ())
(declare-function ess-make-buffer-current "ext:ess-inf" ())
(declare-function ess-eval-buffer "ext:ess-inf" (vis))
(declare-function org-number-sequence "org-compat" (from  to inc))
 could be useful to increase or decrease timeout 
(defcustom org-babel-sas-timeout 1000
  "Timeout (in sec) used when waiting output from a submitted src block (to sas) with argument :session."
  :group 'org-babel
  :type 'integer)
 could be useful to tweak printing page size
(defcustom org-babel-sas-print-options "options formdlim='' pagesize=max;\n"
  "general options used to have the maximum page size"
  :group 'org-babel
  :type 'string)

 where is SAS
(defcustom org-babel-sas-command "/usr/local/bin/sas_u8"
;  inferior-SAS-program-name
  "Name of command to use for executing sas code."
  :group 'org-babel
  :type 'string)

;;;
(defvar org-babel-sas-lepoint 1)
(defvar org-babel-sas-logfile-name "log_sas.log")
(defvar org-babel-sas-eoe-indicator "data eoe_org_data;\n nbabelvareoe=1;\nrun;\nOPTIONS NODATE NONUMBER;\nTITLE1;\nTITLE2;\nproc print data=eoe_org_data;\nrun;")
(defvar org-babel-sas-eoe-output "Obs.nbabelvareoe\n\n1   1")
(defvar org-babel-sas-boe-output "$ tty\n/dev/pts/[0-9]+\n\\$")
(defconst org-babel-header-args:sas
  '((hsize		 . :any)
(vsize		 . :any)
(xpixels		 . :any)
(ypixels		 . :any)
(border		 . :any)
(width		 . :any)
(height		 . :any)
(results . ((file list vector table scalar verbatim)
			(raw org html latex code pp wrap)
			(replace silent append prepend)
;; NOTE: not sure 'value' makes sense in sas
;; we may want to remove it from the list
			(output graphics
  "sas-specific header arguments.")

(add-to-list 'org-babel-tangle-lang-exts '("sas" . "sas"))

;; session using ESS is the way to go, so make that the default
(defvar org-babel-default-header-args:sas '((:results . "output") (:session . nil)))

;; trim white space and garbage
(defun org-babel-sas-trim-white (s)
  "replace S by empty string if S is whitespace only"
  (if (string-match "\\`[ \t\n\r]+\\'" s)
  (replace-match "" t t s)
s))
;; let's go: main function
(defun org-babel-execute:sas (body params)
  "Execute a block of sas code.
This function is called by `org-babel-execute-src-block'."
  (save-excursion
(let* ((result-params (cdr (assq :result-params 

[O] Fontification for the inner bloc of two nested bloc

2017-10-07 Thread Pierre-André Cornillon
Dear orgmode users/gurus,

I have a question about fontification of inner src bloc.

I have two nested blocks: one special (outer bloc) and one src (inner
bloc) like this

#+begin_bloc20171001122500
#+begin_src R
  blip <- runif(2)
  test <- rnorm(2)
#+end_src
#+end_bloc20171001122500

and I want to have the native fontification property for the inner one.

I have already (setq org-src-fontify-natively t) in my .emacs and it
works like a charm for src blocks alone (not nested) but for nested
ones it breaks.

Is nested blocks are allowed and if so, is that possible to have that
fontification property ?

Best regards,
Pierre-Andre



[O] Fontification for the inner bloc of two nested bloc

2017-10-05 Thread Pierre-André Cornillon
Dear org-mode users/gurus


I have a question about fontification of inner src bloc. I have already
submitted this question to the list a few days ago but it did not appear
(and I suspect my mail account to be blacklisted) So I apologize first if
this question is submitted another time to the list...

I have two nested blocks: one special (outer bloc) and one src (inner
bloc) like this
#+begin_bloc20171001122500
#+begin_src R :results value :session :exports both
  blip <- runif(2)
  test <- rnorm(2)
#+end_src
#+end_bloc20171001122500
and I want to have the native fontification property for the inner one.

I have already (setq org-src-fontify-natively t) in my .emacs and it
works like a charm for src blocks alone (not nested) but for nested
ones it breaks.

Is nested blocks are allowed and if so, is that possible to have that
fontification property ?

Thanks,
Pierre-Andre