[O] [FEATURE] Make header argument :mkdirp yes work for other header arguments not just :tangle

2019-03-02 Thread stardiviner

I hope ~:mkdirp~ header argument can also work for other related header 
arguments
like ~:dir~, ~:file~ etc not just ~:tangle~. Like following example.

#+begin_src sh :mkdirp yes :dir "data/code/mkdirp/dir" :file "test" :results 
file link
echo "hello"
#+end_src

So I added a simple patch to make it work.

(I posted message before, but I forgot to update the subject which might be
ignored, so I post a new one again.)
  
>From 53103450181c86c5b5fe07e7d4222618f9d1d8f8 Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Sat, 2 Mar 2019 12:11:47 +0800
Subject: [PATCH] ob-core.el: Make :mkdirp work for :dir too

* lisp/ob-core.el (org-babel-execute-src-block): make directory if :dir
  path does not exist when :mkdirp yes exist.

* doc/org-manualo.rg (mkdirp): declare new change in manual.

* etc/ORG-NEWS: declare changes in ORG-NEWS.

* testing/lisp/test-ob-core.el: Add a specific testing file for
  ob-core.el, and add a testing for :mkdir yes work with :dir header
  argument usage.
---
 doc/org-manual.org   |  7 ---
 etc/ORG-NEWS |  6 ++
 lisp/ob-core.el  |  7 ++-
 testing/lisp/test-ob-core.el | 30 ++
 4 files changed, 46 insertions(+), 4 deletions(-)
 create mode 100644 testing/lisp/test-ob-core.el

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 00e5e1072..30c797ad7 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -17476,9 +17476,10 @@ to source file(s).
   location.  Example: =:tangle FILENAME=.
 
 #+cindex: @samp{mkdirp}, header argument
-The =mkdirp= header argument creates parent directories for tangled
-files if the directory does not exist.  =yes= enables directory
-creation and =no= inhibits directory creation.
+The =mkdirp= header argument creates parent directories for =dir=
+header argument specified path and tangled files if the directory does
+not exist.  =yes= enables directory creation and =no= inhibits
+directory creation.
 
 #+cindex: @samp{comments}, header argument
 The =comments= header argument controls inserting comments into
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 057440a71..cd5e4d900 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -157,6 +157,12 @@ A call of ~org-set-tags-command~ with prefix argument C-u C-u avoids
 the fast tag selection interface and instead offers the plain
 interface.
 
+*** ~:mkdirp~ now supports create directory for ~:dir~ path
+
+The ~:mkdirp~ header argument used to only work for ~:tangle~ tangle
+files. Now ~:mkdirp~ works for ~:dir~ too. This is more convenient for
+specify default directory and with ~:file~ header argument.
+
 * Version 9.2
 ** Incompatible changes
 *** Removal of OrgStruct mode mode and radio lists
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index e6f0edba5..b2a5ee5cb 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -677,8 +677,13 @@ block."
 		  (replace-regexp-in-string
 		   (org-src-coderef-regexp coderef) "" expand nil nil 1
 		 (dir (cdr (assq :dir params)))
+		 (mkdirp (cdr (assq :mkdirp params)))
 		 (default-directory
-		   (or (and dir (file-name-as-directory (expand-file-name dir)))
+		   (or (and dir
+			;; Possibly create the parent directories for file.
+			(let (fnd (file-name-as-directory (expand-file-name dir)))
+			  (if (and (string= mkdirp "yes") fnd)
+  (make-directory fnd 'parents
 		   default-directory))
 		 (cmd (intern (concat "org-babel-execute:" lang)))
 		 result)
diff --git a/testing/lisp/test-ob-core.el b/testing/lisp/test-ob-core.el
new file mode 100644
index 0..c601e44eb
--- /dev/null
+++ b/testing/lisp/test-ob-core.el
@@ -0,0 +1,30 @@
+;;; test-ob-core.el --- tests for ob-core.el
+
+;; Copyright (c) 2018-2022 Free Software Foundation, Inc.
+;; Authors: stardiviner
+
+;; 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 of the License, 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 this program.  If not, see .
+
+;;; Code:
+(ert-deftest test-ob-core/dir-mkdirp ()
+  (org-test-with-temp-text
+   "#+begin_src sh :mkdirp yes :dir \"data/code\"
+pwd
+#+end_src"
+   (org-babel-execute-src-block)
+   (should (file-directory-p "data/code"
+
+(provide 'test-ob-core)
+
+;;; test-ob-core.el ends here
-- 
2.21.0


-- 
[ stardiviner ]
   I try to make every word tell the meaning what I want to express.

   Blog: https://stardiviner.github.io/
   IRC(freenode): stardiviner, Matrix: stardiviner
   GPG: F09F650D7D674819892591401B5DF1C95AE89AC3


Re: [O] [RFC] Fixing link encoding once and for all

2019-03-02 Thread stardiviner


Nicolas Goaziou  writes:

> Hello,
>
> Neil Jerram  writes:
>
>> Do you mean Windows file names in existing Org files?  I.e. the
>> back-compatibility concern?
>>
>> If so, yes, I confess I didn't think at all about back-compatibility,
>> with my suggestion above.  So perhaps that rules my idea out.
>>
>> If we were starting from scratch, however,
>> - I believe it would technically be fine; i.e. it's a complete and
>> unambiguous encoding
>> - it might be considered awkward for Windows users to have to write
>> c:\\system32\\mydoc.txt instead of c:\system32\mydoc.txt, but I don't
>> know how big a concern that would be.
>
> Thinking a bit more about it, we don't need to escape /all/ square
> brackets, only "]]" and "][" constructs. Therefore, we don't need to
> escape every backslash either.
>
> The regexp for bracket links could be, in its simple (!) form:
>
>   \[\[\(.*?[^\\]\(?:\\\)*\)\]\(?:\[\([^\000]+?\)\]\)?\]
>
> Most links would need no change.  I see one notable exception:
> directories in Windows:
>
>   [[c:\system32\\]] for "c:\system32\"
>
> Some further notes:
>
> 1. Macros already use backslashes to escape commas in arguments, so it
>is at least consistent with this part of Org.
>
> 2. The description part of the link, like most parts of Org, does not
>use backslash escaping. If needed, we can implement an entity for
>a square bracket.
>
> 3. There will be some backward compatibility issues. We can add
>a checker in Org Lint to catch most of those. For example, we could
>look at URI where every percent is followed only by 25, 5B, and 5D.
>

About this, I'm curious, is it possible let this checker search and interactive
query replace with running recursively in a directory for all Org files. If Org
updated, I hope my Org documents are update too.

> WDYT?
>
> Regards,


-- 
[ stardiviner ]
   I try to make every word tell the meaning what I want to express.

   Blog: https://stardiviner.github.io/
   IRC(freenode): stardiviner, Matrix: stardiviner
   GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
  



Re: [O] Set checkbox to intermediate in code

2019-03-02 Thread Ken Mankoff


On 2019-02-28 at 08:51 +0100, Cecil Westerhof  wrote...
> I can set a checkbox to intermediate with:
> C-u C-u C-c C-x C-b

FYI, C-c C-c toggles boxes too. Shorter than C-c C-x C-b.

  -k.




Re: [O] [Proposal] Make header argument :mkdirp yes work for other header arguments not just :tangle

2019-03-02 Thread stardiviner

Christopher M. Miles  writes:

> I hope `:mkdirp` header argument can also work for other related header
> arguments like `:dir`, `:file` etc not just `:tangle`. Like following
> example.
>
> #+begin_src sh :mkdirp yes :dir "data/code/mkdirp/dir" :file "test" :results 
> file link
> echo "hello"
> #+end_src
>
> Do you have any idea about this?

I figured out previous question now, it's because ~expand-file-name~ on ~nil~.

#+begin_example
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  expand-file-name(nil)
  (file-name-as-directory (expand-file-name dir))
  (let ((mkdirp (cdr (assq :mkdirp params))) (fnd (file-name-as-directory 
(expand-file-name dir (if (and (string= mkdirp "yes") fnd) (make-directory 
fnd 'parents)) (or (and dir (file-name-as-directory (expand-file-name dir))) 
default-directory))'
#+end_example

After fix, the patch works fine and passed all tests include my write 
corresponding test.
  
>From 53103450181c86c5b5fe07e7d4222618f9d1d8f8 Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Sat, 2 Mar 2019 12:11:47 +0800
Subject: [PATCH] ob-core.el: Make :mkdirp work for :dir too

* lisp/ob-core.el (org-babel-execute-src-block): make directory if :dir
  path does not exist when :mkdirp yes exist.

* doc/org-manualo.rg (mkdirp): declare new change in manual.

* etc/ORG-NEWS: declare changes in ORG-NEWS.

* testing/lisp/test-ob-core.el: Add a specific testing file for
  ob-core.el, and add a testing for :mkdir yes work with :dir header
  argument usage.
---
 doc/org-manual.org   |  7 ---
 etc/ORG-NEWS |  6 ++
 lisp/ob-core.el  |  7 ++-
 testing/lisp/test-ob-core.el | 30 ++
 4 files changed, 46 insertions(+), 4 deletions(-)
 create mode 100644 testing/lisp/test-ob-core.el

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 00e5e1072..30c797ad7 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -17476,9 +17476,10 @@ to source file(s).
   location.  Example: =:tangle FILENAME=.
 
 #+cindex: @samp{mkdirp}, header argument
-The =mkdirp= header argument creates parent directories for tangled
-files if the directory does not exist.  =yes= enables directory
-creation and =no= inhibits directory creation.
+The =mkdirp= header argument creates parent directories for =dir=
+header argument specified path and tangled files if the directory does
+not exist.  =yes= enables directory creation and =no= inhibits
+directory creation.
 
 #+cindex: @samp{comments}, header argument
 The =comments= header argument controls inserting comments into
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 057440a71..cd5e4d900 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -157,6 +157,12 @@ A call of ~org-set-tags-command~ with prefix argument C-u C-u avoids
 the fast tag selection interface and instead offers the plain
 interface.
 
+*** ~:mkdirp~ now supports create directory for ~:dir~ path
+
+The ~:mkdirp~ header argument used to only work for ~:tangle~ tangle
+files. Now ~:mkdirp~ works for ~:dir~ too. This is more convenient for
+specify default directory and with ~:file~ header argument.
+
 * Version 9.2
 ** Incompatible changes
 *** Removal of OrgStruct mode mode and radio lists
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index e6f0edba5..b2a5ee5cb 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -677,8 +677,13 @@ block."
 		  (replace-regexp-in-string
 		   (org-src-coderef-regexp coderef) "" expand nil nil 1
 		 (dir (cdr (assq :dir params)))
+		 (mkdirp (cdr (assq :mkdirp params)))
 		 (default-directory
-		   (or (and dir (file-name-as-directory (expand-file-name dir)))
+		   (or (and dir
+			;; Possibly create the parent directories for file.
+			(let (fnd (file-name-as-directory (expand-file-name dir)))
+			  (if (and (string= mkdirp "yes") fnd)
+  (make-directory fnd 'parents
 		   default-directory))
 		 (cmd (intern (concat "org-babel-execute:" lang)))
 		 result)
diff --git a/testing/lisp/test-ob-core.el b/testing/lisp/test-ob-core.el
new file mode 100644
index 0..c601e44eb
--- /dev/null
+++ b/testing/lisp/test-ob-core.el
@@ -0,0 +1,30 @@
+;;; test-ob-core.el --- tests for ob-core.el
+
+;; Copyright (c) 2018-2022 Free Software Foundation, Inc.
+;; Authors: stardiviner
+
+;; 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 of the License, 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 this program.  If not, see .
+
+;;; 

[O] Latex formatting for an extracted table

2019-03-02 Thread Brett Presnell


I've taken to typing scores and brief comments into an org table when
grading my students papers.  In order to extract the scores and comments
for each individual student, I use orgtbl-aggregate as follows (the
student's nickname in this case is assumed to be "tophat", and the table
containing all the scores and comments is names "everyone"):

#+BEGIN: aggregate :table "everyone" :cols "Last First Exercise Pts Comments" 
:cond (equal Nickname "tophat")
#+END

This creates a new table by extracting the Last, First, Exercise, Pts,
and Comments columns (with headers) and only the rows with "tophat" in
the Nickname column.

My problem is that I need to have the following header on each of the
individual tables in order for them to print out properly:

#+ATTR_LATEX: :environment tabularx :width \textwidth :align lllrX

If I start with

#+BEGIN: aggregate :table "everyone" :cols "Last First Exercise Pts Comments" 
:cond (equal Nickname "tophat")
#+ATTR_LATEX: :environment tabularx :width \textwidth :align lllrX
#+END

then C-c C-c causes the table to appear but the ATTR_LATEX line is wiped
out.  If instead I start with

#+ATTR_LATEX: :environment tabularx :width \textwidth :align lllrX
#+BEGIN: aggregate :table "everyone" :cols "Last First Exercise Pts Comments" 
:cond (equal Nickname "tophat")
#+END

then the #+ATTR_LATEX: line is ignored in exporting.

I've been manually pasting the #+ATTR_LATEX: in after extracting the
tables, but there must be a better way to do this.  Any advice will be
appreciated.

FWIW, I realize that I probably don't need orgtbl-aggregate for
this. Also, my ideal solution would be to auto-generate the sub-tables
by looping over the nicknames, simultaneously inserting a section header
with the student's name before each sub-table and a "#+LATEX: \newpage"
line after.  Hints along these lines would be welcome.



Re: [O] Multiple Indices

2019-03-02 Thread Gregor Zattler
Hi Robert,
* Robert Love  [2019-03-02; 16:29]:
> I don’t understand this advice.   I went looking for the source
> for the Org manual and found it IS written in Texinfo. This
> is version 8.2.10.   Is there a native Org mode manual written
> in Org?

Yes since version 9 I think.  It will be part of emacs when a
newer version is bundled with a released version of emacs. 

> If so, please provide the source location.

In the mean time:
https://code.orgmode.org/bzg/org-mode/raw/master/doc/org-manual.org

Ciao; Gregor 




Re: [O] Multiple Indices

2019-03-02 Thread Robert Love
I don’t understand this advice.   I went looking for the source for the Org 
manual and found it IS written in Texinfo. This is version 8.2.10.   Is 
there a native Org mode manual written in Org?  If so, please provide the 
source location.



> On Mar 1, 2019, at 2:15 AM, Gregor Zattler  wrote:
> 
> Hi Robert,
> * Robert Love  [2019-02-28; 23:52]:
>> I’m using Org mode to document some software.  When I see
>> Texinfo used for this, I see that you can have a subject index
>> and a variable index.  How do I achieve the same thing in Org
>> mode?  Can someone point to examples of this?
> 
> I don't know anything about texinfo, but the Org-mode manual has
> three indices.  You may have a look at doc/org-manual.org.
> 
> Ciao; Gregor
> -- 
> -... --- .-. . -.. ..--.. ...-.-
> 
> 


— 
Bob Love
"Save the books...BURN the censors!"  







[O] Babel: how to get rid of the quotes wraping the result of a Sagemath code block ?

2019-03-02 Thread Emmanuel Charpentier
Dear list,

I would like to use Sage to build the text of a Graphviz program to
display some graph, then pass this program body to a dot code block.

The first step is easy. But I'm unable to accomplish the second one
becausethe program text (which is correct !) is wrapped in a pair of
quotes, on which Graphviz (dot) chokes. I-ve tried
  * passing it as an argument (:var=myblock())
  * calling the Sage code block in a noweb call (<>)
to no avail.

I've tried the "verbatim" and "raw" options to :results of my Sage
block. Again without success.

It [[
https://emacs.stackexchange.com/questions/20652/org-babels-call-functionality-wraps-all-results-in-quotes
][seems]]
 that a similar problem exists for Python code...

Any suggestions ?

--
Emmanuel Charpentier




[O] Bug: link to gnuplot [9.1.14 (9.1.14-1-g4931fc-elpa @ /home/kiwibird/.emacs.d/elpa/org-9.1.14/)]

2019-03-02 Thread Kevin Brubeck Unhammer
When I do

C-c " g 

or

M-x org-plot/gnuplot

I get

org-plot/gnuplot: Cannot open load file: No such file or directory, gnuplot

It'd be nice if org-plot/gnuplot could instead `message' me a link to
the package that needs installing (or at least if the docstring for that
function could mention it).

Also, the link from Worg is wrong,
https://orgmode.org/worg/org-tutorials/org-plot.html points to
http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html instead of
http://xafs.org/BruceRavel/GnuplotMode or
https://github.com/bruceravel/gnuplot-mode/

(This is especially annoying since Bruce Ravel's gnuplot isn't in GNU
ELPA, while Melpa confusingly has both gnuplot and gnuplot-mode.)

Emacs  : GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2018-05-29
Package: Org mode version 9.1.14 (9.1.14-1-g4931fc-elpa @ 
/home/kiwibird/.emacs.d/elpa/org-9.1.14/)