Re: [O] Some thought about `org-latex-pdf-process-alist', was Re: (V9) [PATCH] New feature: Use dvisvgm to preview latex formular

2016-05-22 Thread Feng Shu


> This is mixing together org-latex-packages-alist, org-latex-pdf-process
> and org-latex-document-class, org-latex-default-class,
> org-koma-letter-default-class etc, and latexmk/carara into one (modulus
> typos).  IMO, it introduces too much dependency and convolution.  Take
> :valid-class; When I add a new class CLASS, I need to add it to the
> correct entries in org-latex-pdf-process-alist.  You ask me to form a
> joint opinion about too many things at once.

Yes, I think: compile + class + packages = process, if I don't joint
them to a profile setting, it is impossible to swith process easily.


If you know the default class and packages setting is suitable for your
process, just ignore :default-class :valid-classes :packages-alist
:default-packages-alist and :packages-override, the four options are
used by user special processes.


> equivalent should be used.  I don’t care about the process.  I care about
> the final document and its correctness.

because latex system can deal with English very well by default, so you
can "don't care about the process", if I don't care about the process,
"the final document and its correctness" is just a dream. :-)


> This is the nature of LaTeX.  The packages that Org selects by default do
> not conflict with each other.

packages selected by org may conflict with user's latex package, so user
should edit `org-latex-default-packages-alist' by hand.

>
>> 2. I don't want every users have to write latex-header in every org-file
>> and I like: install ox-latex-chinese and
>>
>>(setq org-latex-default-pdf-process "cn/xelatex-xelatex-xelatex")
>>
>> every org-file can export to pdf.
>
> I strongly disagree with this vision.
>
> This should be possible with org-latex-classes without limiting the
> flexibility of ox-latex.  Also, we already have a way of solving this
> use-case, namely org-export-define-derived-backend`.

`org-export-define-derived-backend' seem to be overkill for this situation.

> LaTeX success rests in its flexibility, so this critique is misfounded
> IMO.  The success of ox-latex is that it’s flexible enough to satisfy even
> power users’ use-cases, making it an uncompromizing alternative to plain
> LaTeX.

power users can do "anything" in org-mode, even rewrite ox-latex, my
question is that: is it flexible enough to let some power users to well
maintain some predefined configures which can make many beginning user's
install and config easily?

-- 




[O] PATCH: ox: Starting source code export at non-zero (-n value)

2016-05-22 Thread Brian Carlson



On 2016-05-20 16:48, Nicolas Goaziou wrote:

The code is written with the following design:

-n   is the same as -n 1 : The functionality is unchanged
+n   is the same as +n 1 :  The functionality is unchanged

-n X   will "reset" and start new code block starting at line X
+n X   will "add" X to the last line of the block before.


Thank you for the patch. It looks like an useful addition to Org. Some
comments follow.


I believe that I addressed all your review comments/recommendations. I 
am submitting the latest patch. This patch also include some additions 
to /testing/lisp/test-ox.el to test the feature. All of the existing 
tests pass (without modification).



In general the main change was to (org-export-get-loc) which returns
the number of lines "before" the first line of a block (as it always 
has) regardless of the type (new/continued) (or nil if the block does 
not provide +/-n option (as it always has).



Thanks,
;-b



>From dd01dada2c3c0ee0d8cc28184026720f8602680b Mon Sep 17 00:00:00 2001
From: Brian Carlson 
Date: Mon, 16 May 2016 10:58:01 -0400
Subject: [PATCH] ox: Provide offset to [+-]n in SRC/EXAMPLE export

* lisp/org-element.el (org-element-example-block-parser): Use cons cell
  for :number-lines specifying offset in addition to type (new/continue).
  ('continue . offset) for :number-lines will add this offset count to
  the last line number. ('new . offset) for :number-lines will reset the
  line number counting starting at offset
(org-element-src-block-parser): same for SRC block as EXAMPLE block

* lisp/ox-html.el (org-html-format-code): Use cons cell :number-lines

* lisp/ox-latex.el (org-latex-src-block): Use cons cell :number-lines

* lisp/ox-odt.el (org-odt-format-code): Use cons cell for :number-lines

* lisp/ox.el (org-export-resolve-coderef): Use cons cell for :number-lines
(org-export-get-loc): Use new cons cell for :number-lines
(org-export-format-code-default): Use new cons cell for :number-lines

* testing/lisp/test-ox.el  (ert-deftest test-org-export/get-loc): Tests for
changes
(test-org-gen-loc-list): helper function for test-org-export/get-loc

* contrib/lisp/ox-groff.el (org-groff-src-block): Use new cons cell for
  :number-lines
---
 contrib/lisp/ox-groff.el |   4 +-
 lisp/org-element.el  |  26 ---
 lisp/ox-html.el  |   4 +-
 lisp/ox-latex.el |   4 +-
 lisp/ox-odt.el   |   4 +-
 lisp/ox.el   |  20 +
 testing/lisp/test-ox.el  | 109 +++
 7 files changed, 146 insertions(+), 25 deletions(-)

diff --git a/contrib/lisp/ox-groff.el b/contrib/lisp/ox-groff.el
index b49edce..25ed8b0 100644
--- a/contrib/lisp/ox-groff.el
+++ b/contrib/lisp/ox-groff.el
@@ -1488,9 +1488,7 @@ contextual information."
  (custom-env (and lang
   (cadr (assq (intern lang)
   org-groff-custom-lang-environments
- (num-start (case (org-element-property :number-lines src-block)
-  (continued (org-export-get-loc src-block info))
-  (new 0)))
+ (num-start (org-export-get-loc src-block info))
  (retain-labels (org-element-property :retain-labels src-block))
  (caption (and (not (org-export-read-attribute
 			 :attr_groff src-block :disable-caption))
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 368da60..5f62a7e 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -1896,8 +1896,16 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent',
 		 ;; Switches analysis
 		 (number-lines
 		  (cond ((not switches) nil)
-			((string-match "-n\\>" switches) 'new)
-			((string-match "+n\\>" switches) 'continued)))
+			((string-match "-n *\\([0-9]+\\)\\>" switches)
+			 ;; subtract 1 to give number of lines before first line
+			 (cons 'new (- (string-to-number (match-string 1 switches)) 1)))
+			((string-match "-n\\>" switches)
+			 (cons 'new 0))
+			((string-match "+n *\\([0-9]+\\)\\>" switches)
+			 ;; subtract 1 to give number of lines between last number and first line
+			 (cons 'continued (- (string-to-number (match-string 1 switches)) 1)))
+			((string-match "+n\\>" switches)
+			 (cons 'continued 0
 		 (preserve-indent
 		  (and switches (string-match "-i\\>" switches)))
 		 ;; Should labels be retained in (or stripped from) example
@@ -2393,7 +2401,7 @@ Assume point is at the beginning of the block."
 		(looking-at
 		 (concat "^[ \t]*#\\+BEGIN_SRC"
 			 "\\(?: +\\(\\S-+\\)\\)?"
-			 "\\(\\(?: +\\(?:-l \".*?\"\\|[-+][A-Za-z]\\)\\)+\\)?"
+			 "\\(\\(?: +\\(?:-l \".+\"\\|[+-]n *[0-9]+\\|-[iIkKrRnN]\\|+[nN]\\)\\)+\\)?"
 			 "\\(.*\\)[ \t]*$"))
 		(org-match-string-no-properties 1)))
 		 ;; Get switches.
@@ -2403,8 +2411,16 @@ Assume point is at the beginning of the block."
 		 ;; Switches analysis
 		 (number-lines
 		  (cond ((not switches) nil)
-			((string-match "-n\\>" switches) 'new)
-			((s

Re: [O] add some babel supports (PHP, Lua, Redis)

2016-05-22 Thread numbch...@gmail.com
I modified most part of my files.

- There are some places I can't improve because I'm not good at elisp.
(maybe other  people can improve it later) Like ob-redis.el implement
ob-sql style configuration. and ob-lua.el make use of lua-mode's running
process.

- I guess ob-php.el is the only one branch can be merged.
- Anyway, check out my updates, if no one can be merged, I will still keep
my github repositories.

Thanks for your detail reviews.


[stardiviner] GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/

On Mon, May 23, 2016 at 1:20 AM, Rasmus  wrote:

> Hi,
>
> Thanks for your patches.  Sorry about the delay.  I was hoping that
> someone with more ob knowledge would step in.
>
> Please find some comments below.  I think some more work is needed before
> your libraries are
>
> "numbch...@gmail.com"  writes:
>
> > From 2589d4e7d28016fb515d2131cbd9ff52797e50eb Mon Sep 17 00:00:00 2001
> > From: stardiviner 
> > Date: Tue, 10 May 2016 16:03:32 +0800
> > Subject: [PATCH] ob-lua.el: add Lua src block executing support
> >
> > * contrib/lisp/ob-lua.el (org-babel-execute:lua): support executing Lua
> > src block.
>
> Please capitalize after the colon.
>
> > ---
> > +;;; ob-lua.el --- Execute Lua code within org-mode blocks.
> > +;; Copyright 2016 stardiviner
>
> > +;; Author: stardiviner 
> > +;; Maintainer: stardiviner 
>
>
>
> > +;; Keywords: org babel lua
>
> For whatever reason this seems to be
>
> ;; Keywords: literate programming, reproducible research
>
> In most ob files.
>
> > +;; URL: https://github.com/stardiviner/ob-lua
>
>
> > +;; Created: 12th April 2016
>
> This header is unnecessary, but if you like it, it’s fine.
>
> > +;; Version: 0.0.1
> > +;; Package-Requires: ((org "8"))
>
> > +;;; Commentary:
> > +;;
> > +;; Execute Lua code within org-mode blocks.
>
>
> Maybe,
>
> The file provides Org-Babel support for evaluating Lua code.
>
>
>
> > +;;; Code:
> > +(require 'org)
>
> This is unnecessary.  Ob implies Org.
>
> > +(require 'ob)
> > +
> > +(defgroup ob-lua nil
> > +  "org-mode blocks for Lua."
> > +  :group 'org)
>
> It seems that ob languages do not typically define new groups.
>
> Also, ob is the filename.  Variables are org-babel.
>
> > +(defcustom ob-lua:default-session "*lua*"
> > +  "Default Lua session.
> > +
> > +It is lua inferior process from `run-lua'."
> > +  :group 'ob-lua
> > +  :type 'string)
>
> I don’t think this is necessary to have as a defcustom.  There’s already
> :session.  Also, you are missing :type.  Per above, group is org-babel.
>
> > +;;;###autoload
> This is normally not autoloaded.  Babel languages are loaded via
> org-babel-do-load-languages.
>
> > +(defun org-babel-execute:lua (body params)
> > +  "org-babel lua hook."
>
> Please capitalize sentences.
>
> > +  (let* ((session (or (cdr (assoc :session params))
> > +  ob-lua:default-session))
> > + (cmd (mapconcat 'identity (list "lua -") " ")))
>
> Is something missing here?  AFAIK cmd → "lua -" always.
>
> Also, what if my lua is not in my PATH?  I got a felling that you might
> make a more robust mode by hooking into lua-mode
>
>  https://immerrr.github.io/lua-mode/
>
> > +(org-babel-eval cmd body)))
>
> How are various return values handled?  E.g. will a table be correctly
> interpreted as such?  (It’s a while since I coded in lua).
>
> > +;;;###Autoload
> > +(eval-after-load "org"
> > +  '(add-to-list 'org-src-lang-modes '("lua" . lua)))
>
>
> This should be unnecessary as the lua-mode is presumably lua-mode.  Also,
> I think your code depends on lua-mode in order to be able to edit it.  You
> need to declare that as a dependency.
>
> > +(provide 'ob-lua)
> > +
> > +;;; ob-lua.el ends here
> > --
> > 2.8.2
> >
> >
> > From d2e7202930fcf24e7c90826e69bb768094463a0c Mon Sep 17 00:00:00 2001
> > From: stardiviner 
> > Date: Tue, 10 May 2016 16:05:38 +0800
> > Subject: [PATCH] ob-php.el: Add PHP src block executing support
> >
> > * contrib/lisp/ob-php.el (org-babel-execute:php): support executing PHP
> >   src block.
>
> Capitalize.
>
> > ---
> >  contrib/lisp/ob-php.el | 44 
> >  1 file changed, 44 insertions(+)
> >  create mode 100644 contrib/lisp/ob-php.el
> >
> > diff --git a/contrib/lisp/ob-php.el b/contrib/lisp/ob-php.el
> > new file mode 100644
> > index 000..31960a5
> > --- /dev/null
> > +++ b/contrib/lisp/ob-php.el
> > @@ -0,0 +1,44 @@
> > +;;; ob-php.el --- Execute PHP within org-mode blocks.
> > +;; Copyright 2016 stardiviner
> > +
> > +;; Author: stardiviner 
> > +;; Maintainer: stardiviner 
> > +;; Keywords: org babel php
> > +;; URL: https://github.com/stardiviner/ob-php
> > +;; Created: 04th May 2016
> > +;; Version: 0.0.1
> > +;; Package-Requires: ((org "8"))
> > +
> > +;;; Commentary:
> > +;;
> > +;; Execute PHP within org-mode blocks

Re: [O] bug org-list-send-list

2016-05-22 Thread Charles Millar

Hi Nick,

On 05/22/2016 07:17 PM, Nicolas Goaziou wrote:

Hello,

Charles Millar  writes:


The following radio table is in LaTeX major mode and orgstruct minotr
mode per the manual.

% BEGIN RECEIVE ORGLST radioTableTest
% END RECEIVE ORGLST radioTableTest
\begin{comment}
#+ORGLST: SEND radioTableTest org-list-to-latex
- Something to send
\end{comment}

With cursor on the "S" in Something calling (or "-")

M-x org-list-send-list

does not convert LATEX list between the two marker lines. Instead the
following message is in the mini-buffer

No such transformation function org-list-to-latex and the
degug-on-entry is

Fixed. Thank you.

The org-list-send-list works fine, however C-c C-c on the first item is 
still a problem just as reported earlier.


GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5) of 
2015-03-07 on trouble, modified by Debian
Org-mode version 8.3.4 (release_8.3.4-839-g3c729c @ 
/usr/local/share/emacs/site-lisp/org-mode/lisp/)


regards,

Charlie Millar

Regards,






Re: [O] Bug: orgtbl-self-insert-command does not overwrite whitespace [8.3.4 (8.3.4-50-g83e373-elpa @ /home/alex/.emacs.d/elpa/org-20160509/)]

2016-05-22 Thread Nicolas Goaziou
Hello,

Alex  writes:

> Thank you for the fixes. However, the fix in 4914f89 does not work for
> me. When I run it (type backspace) in a graphical Emacs I get:
>
> user-error: This key has no function outside tables
>
> When I run it in a terminal Emacs the command is not rebound at all.
>
> Replacing [(del)] with (kbd "DEL") fixed the issue for me.

Done. Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] bug org-list-send-list

2016-05-22 Thread Nicolas Goaziou
Hello,

Charles Millar  writes:

> The following radio table is in LaTeX major mode and orgstruct minotr 
> mode per the manual.
>
> % BEGIN RECEIVE ORGLST radioTableTest
> % END RECEIVE ORGLST radioTableTest
> \begin{comment}
> #+ORGLST: SEND radioTableTest org-list-to-latex
> - Something to send
> \end{comment}
>
> With cursor on the "S" in Something calling (or "-")
>
> M-x org-list-send-list
>
> does not convert LATEX list between the two marker lines. Instead the 
> following message is in the mini-buffer
>
> No such transformation function org-list-to-latex and the
> degug-on-entry is

Fixed. Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] [ox-publish, patch] More flexible sitemaps

2016-05-22 Thread Nicolas Goaziou
Hello,

Rasmus  writes:

> I've long wanted to use ox to auto-generate something that looks like a
> blog index.
>
> This patch makes ox sitemaps a bit more flexible.  For instance, it would
> allow me to use something like this for ‘:sitemap-file-entry-format’,
>
> :sitemap-file-entry-format "* [[file:%l][%t]]
> #+include: \"%f::lead\"
>
> [[file:%l][Read more]]"
>
> Which would come out as;
>
> * [[file:link][Title]]
> #+Include: "file.org::lead"
>
> [[File:link][Read more]]
>
> For the tests I did, it matches the "old" sitemap for list and tree.
>
> WDYT?

It sounds interesting. Usual nitpicking follows.

> * lisp/ox-publish.el (org-publish-sitemap-file-entry-format): Support
>   more formatters.
> (org-publish-sitemap-dir-entry-format): New defcustom.
> (org-publish-org-sitemap): Use new variables and functions.
> (org-publish-org-sitemap-as-list): New function.
> (org-publish--tree-assoc): New function.
> (org-pubish--order-files-by-dir-tree): New function.
> (org-publish-find-title): New function.

This is not a new function.

> (org-publish-find-subtitle): New function.
> (org-publish-org-sitemap-as-tree): New function.
> (org-publish--find-property): Find arbirary property.
> (org-publish-project-alist): Document changes.
> * doc/org.texi (Sitemap): Update documentation.

All in all, I think this deserves to be split into 3 patches: one for
the preamble-postamble feature, another one for implementing
`org-publish--find-property' and associated refactoring, and the latter
for the sitemap itself.

> +(autoload 'message-flatten-list "message")
> +(autoload 'dired-tree-lessp "dired-aux")

I hope we can avoid these. In particular, why are you using
`dired-tree-lessp' instead of `org-publish-compare-directory-files'?

> @@ -399,6 +469,7 @@ This splices all the components into the list."
>  (defvar org-publish-sitemap-requested)
>  (defvar org-publish-sitemap-date-format)
>  (defvar org-publish-sitemap-file-entry-format)
> +(defvar org-publish-sitemap-dir-entry-format)

The above is not necessary.

> +  (files (nreverse
> +  ;; Sitemap shouldn't list itself.
> +  (cl-delete-if (lambda (f)
> +  (equal (file-truename f)
> + (file-truename sitemap-filename)))

See `file-equal-p'.

> +(org-publish-get-base-files
> + project
> + (plist-get project-plist :exclude)
>(sitemap-title (or (plist-get project-plist :sitemap-title)
> -   (concat "Sitemap for project " (car project
> -  (sitemap-style (or (plist-get project-plist :sitemap-style)
> - 'tree))
> -  (sitemap-sans-extension
> -   (plist-get project-plist :sitemap-sans-extension))
> + (concat "Sitemap for project " (car project
>(visiting (find-buffer-visiting sitemap-filename))
> -  file sitemap-buffer)
> -(with-current-buffer
> - (let ((org-inhibit-startup t))
> -   (setq sitemap-buffer
> - (or visiting (find-file sitemap-filename
> +  (sitemap-buffer (or visiting (find-file sitemap-filename)))
> +  (insert-pre-or-postamble (function (lambda (pre-or-postamble)

No need to wrap `function' around `lambda'.  Also, it doesn't "insert"
anything, does it? IOW, isn't the name a bit confusing ?

> +   (when pre-or-postamble

You can include the `when' in the cond:

  (cond ((not pre-or-postamble) nil)
((stringp pre-or-postamble) ...)
...)
> + (cond ((stringp 
> pre-or-postamble) pre-or-postamble)
> +   ((listp pre-or-postamble)
> +(mapconcat 'identity 
> preamble "\n"))
> +   ((functionp 
> pre-or-postamble)
> +(funcall 
> pre-or-postamble project-plist))
> +   (t (error (concat 
> "unknown `:sitemap-preamble' or "
> + 
> "`:sitemap-postamble' format")
> +(with-current-buffer (let ((org-inhibit-startup t)) sitemap-buffer)

You can drop the `let' part, which is a no-op here.

> +  ;; Insert sitemap-preamble.
> +  (funcall insert-pre-or-postamble
> +(plist-get project-plist :sitemap-preamble))
> +  ;; Call function to build sitemap based on files and the project-plist.
> +  (insert (funcall (intern
> + (concat "org-publish-org-sitemap-as-"
> + (symbol-name (or (plist-get project-plist 
> :sitemap-style) 'tree
> +files project-plist))

(intern (format "org-publish-org-sitemap-as-%s" (or (plist-get ...) 'tree)

Re: [O] exporting documents w/ babel results w/o evaluating babel blocks

2016-05-22 Thread Charles C. Berry


John and Nick,

Comments in line below.

TL;DR: Org babel headers give excellent control over what gets run,
when it gets run, and how. Users should use them. Don't reset
`org-export-babel-evaluate'.

Chuck

On Sun, 22 May 2016, John Hendy wrote:


On Fri, May 20, 2016 at 4:20 PM, Charles C. Berry  wrote:

On Fri, 20 May 2016, Nick Dokos wrote:


Ken Mankoff  writes:


[deleted discussion of  `org-export-babel-evaluate' settings]



With ":exports results" and o-e-b-e set to nil, I get no evaluation on
export, but I get both code and results in the output.


There may have been a misunderstanding, but when I mentioned this in
the bug report, I was told this is a "feature".

http://thread.gmane.org/gmane.emacs.orgmode/107230/focus=107231



Not sure what exactly Chuck meant is a feature, but IIUC, the fact
that I get both code and results even if I specify ":exports results"
looks like a bug to me.



I meant this, as of commit ec615b1..., `org-export-babel-evaluate' set to
`nil' keeps the exporter from running this line

  (org-export-execute-babel-code)

during exports. So, 'no Babel code is run' in the sense that the above
line does not execute.

src-blocks and inline-src-blocks are neither run nor removed, and no
#+results: or {{{results()}}} are added, removed, or
modified. Babel handles all that. The exporter merely formats those
things once Babel is done.

So the bug, if any, is in the docstring in failing to mention that
everything that babel does is switched off.


I don't entirely follow. Is there an intermediate step between a .org
src block, babel, and the exporter? If so, the behavior I see could
make sense. If not, then it doesn't.

As in, why is babel "execution" (as in o-e-b-e to non-nil) required to
*not* export this code into the resultant pdf?

#+begin_src R :exports results :results output
 dat <- 1:10
 print(dat)
#+end_src

With o-e-b-e set to nil, I get the code in the exported document,
hence my asking. If I turn o-e-b-e on, I don't (but get the results).
So perhaps the real missing bit from the documentation is something
like "all babel functionality is turned off, and babel is responsible
for executing code and generating/updating any results, as well as
controlling src block export controls (results vs. code vs. both). In
other words, without babel, src blocks in .org files are treated like
example blocks during export."

Is that accurate?



Yes. That is the point. Babel does it all.

(Caveat: 'like example blocks' is not precisely true, since the
exporter calls a src-block transcoder for the formatting.)


I think one of the main points of confusion in this thread still has
to do with why o-e-b-e switches what gets exported. If no code/results
are run/added/removed/modified as you mention, it doesn't speak to why
code export is always done for o-e-b-e = nil, but not otherwise. This
suggests babel is doing more than "executing code;" it's somehow
influencing what makes it into the export document. At least for me,
that was an unexpected interpretation of "everything babel does is
switched off."


Babel is a fairly complicated beast.

If you want to grok what it is doing during export, you could instrument 
`org-export-as' (do `(info "(elisp) Edebug")' if you need to know about 
this), export something with babel code in it, and step thru to just 
before the line `(org-export-execute-babel-code)'. At that point have a 
look at the temp buffer the exporter is working in. (IIRC, it will have 
<2> suffixed to the name of the buffer from which you started the export.) 
Then do one more step to run the babel code and look again - be sure it is 
*still* the buffer named with the *<2> format that you are inspecting now. 
You will see what it is that Babel has done.


In particular, a src block with no results initially, but with
`:exports results' as a header will be gone, but results will now be
seen.

A src block that is has `#+begin-src emacs-lisp :exports code' will
survive, but the header arg will be gone. So, transcoders in the
exporter will not see the header arg.



In fact, I just had an idea... I have o-e-b-e set to always, but just
turned org-confirm-babel-evaluate to on (I typically have it off). If
export the above and type "no" to make sure the code block is not
executed I do *not* get the code in the document. I think this
confirms that babel's responsibilities include *what* plain text in
.org the exporter formats into the output format.

My suggestion would be to create a different variable to handle
formatting vs. execution unless things were designed this way? It
seems from all the comments that the majority of users expect the
time-heavy *code* not to be run at each export but still prefer the
blocks to behave as they intended.


This is what `:eval never-export' was created for.


Theoretically, with all of my
results generated (e.g. into .pdf, .png, etc. plots; ascii tables,
whatever) shouldn't I be able to have o-e-b-e set to whatever and get
the same document

Re: [O] [PATCH] add port switch for postgresql support in ob-sql.el

2016-05-22 Thread Nicolas Goaziou
Hello,

Justin Kirby  writes:

> I added a port switch for postgresql in ob-sql.el

Thank you for the patch. Some comments follow.

> I have attached a simple patch to fix this and have verified it works
> for me. I would have loved to add some tests, but I ran into some
> problems:
>
> 1) I could not figure out how to get just one test file to run
> 2) I was not able get make test to load the sql language in babel
>
>
> Is there a recommended/standard way to resolve these problems with
> tests?

See , in particular
BTEST_RE and BTEST_OB_LANGUAGES environment variables.

> From 4ca513afe3725fbfbefd7ad9bf54637adfd56ea2 Mon Sep 17 00:00:00 2001
> From: Justin Kirby 
> Date: Wed, 18 May 2016 23:14:48 -0400
> Subject: [PATCH] add dbport parameter to postgresql dbstring

First letter should be upper case.

You also need to provide the name of the function being modified in the
commit message, e.g.

  lisp/ob-sql.el (org-babel-sql-dbstring-postgresql): Add PORT argument.
  (org-babel-execute:sql): Apply previous change.

I you haven't signed FSF papers, you also need to add TINYCHANGE at the
end of the commit message.

Could you send an updated patch ? Also, could you provide a short notice
in ORG-NEWS (located in doc/)?

Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: When exporting to PDF an Org file where multiple footnotes share the same definition, only the first footnote is clickable [8.3.4 (8.3.4-39-ge0acd8-elpaplus @ /home/jorge/.emacs.d/elpa/or

2016-05-22 Thread Rasmus
Nicolas Goaziou  writes:

> Rasmus  writes:
>
>> Could we inject labels in all footnotes?  If so we could simply use
>>
>>\textsuperscript{\ref{FN-LABEL}}
>>
>> In place of
>>
>>\footnotemark[FN-GUESS]{}
>>
>> It seems \footref of scrextend.sty has some extra robustness built into it
>> but until someone complains I think the \textsuperscript hack should be
>> enough and better then what we’ve got.
>
> That's a bit hackish, but definitely possible. Do yo want to provide
> a patch?

With the attached patch ox-latex seems to behave in this way.  Though
perhaps there’s a more efficient way to get the first footnote-reference
to a given definition than trawling through with
org-export--footnote-reference-map.

Nicolas, where is the info plist documented or defined/populated?

Rasmus

-- 
Together we will make the possible totay impossible!
>From 07f15d538aa02d5b45fa545395442f5663260430 Mon Sep 17 00:00:00 2001
From: Rasmus 
Date: Sun, 22 May 2016 20:33:06 +0200
Subject: [PATCH] ox-latex: More robust footnote referencing

* lisp/ox-latex.el (org-latex--label): Prefix footnote with "fn".
(org-latex--delayed-footnotes-definitions): Fix typo in docstring.
(org-latex-footnote-reference): Use \ref{.} and \label{.} for repeated
references.
---
 lisp/ox-latex.el | 72 
 1 file changed, 47 insertions(+), 25 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 9c31645..3c66a32 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1246,6 +1246,8 @@ Eventually, if FULL is non-nil, wrap label within \"\\label{}\"."
   org-latex-math-environments-re
   (org-element-property :value datum))
  "eq:"))
+			   (footnote-reference "fn:")
+			   (footnote-definition "fn:")
 			   (paragraph
 			(and (org-element-property :caption datum)
  "fig:")))
@@ -1498,7 +1500,7 @@ INFO is a plist used as a communication channel.  See
 
 INFO is a plist used as a communication channel.
 
-Footnotes definitions are returned within \"\\footnotetxt{}\"
+Footnotes definitions are returned within \"\\footnotetext{}\"
 commands.
 
 This function is used within constructs that don't support
@@ -1803,30 +1805,50 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 (defun org-latex-footnote-reference (footnote-reference _contents info)
   "Transcode a FOOTNOTE-REFERENCE element from Org to LaTeX.
 CONTENTS is nil.  INFO is a plist holding contextual information."
-  (concat
-   ;; Insert separator between two footnotes in a row.
-   (let ((prev (org-export-get-previous-element footnote-reference info)))
- (when (eq (org-element-type prev) 'footnote-reference)
-   (plist-get info :latex-footnote-separator)))
-   (cond
-;; Use \footnotemark if the footnote has already been defined.
-((not (org-export-footnote-first-reference-p footnote-reference info))
- (format "\\footnotemark[%s]{}"
-	 (org-export-get-footnote-number footnote-reference info)))
-;; Use \footnotemark if reference is within another footnote
-;; reference, footnote definition or table cell.
-((org-element-lineage footnote-reference
-			  '(footnote-reference footnote-definition table-cell))
- "\\footnotemark")
-;; Otherwise, define it with \footnote command.
-(t
- (let ((def (org-export-get-footnote-definition footnote-reference info)))
-   (concat
-	(format "\\footnote{%s}" (org-trim (org-export-data def info)))
-	;; Retrieve all footnote references within the footnote and
-	;; add their definition after it, since LaTeX doesn't support
-	;; them inside.
-	(org-latex--delayed-footnotes-definitions def info)))
+  (let ((label (org-element-property :label footnote-reference)))
+(concat
+ ;; Insert separator between two footnotes in a row.
+ (let ((prev (org-export-get-previous-element footnote-reference info)))
+   (when (eq (org-element-type prev) 'footnote-reference)
+	 (plist-get info :latex-footnote-separator)))
+ (cond
+  ;; Use \footnotemark if the footnote has already been defined.
+  ((not (org-export-footnote-first-reference-p footnote-reference info))
+   (format "\\textsuperscript{\\ref{%s}}"
+	   (org-latex--label
+		(catch 'exit
+		  (org-export--footnote-reference-map
+		   (lambda (f)
+		 (let ((l (org-element-property :label f)))
+		   (when (and l label (string= label l))
+			 (throw 'exit f
+		   (plist-get info :parse-tree) info))
+		info t)))
+  ;; Use \footnotemark if reference is within another footnote
+  ;; reference, footnote definition or table cell.
+  ((org-element-lineage footnote-reference
+			'(footnote-reference footnote-definition table-cell))
+   "\\footnotemark")
+  ;; Otherwise, define it with \footnote command.
+  (t
+   (let ((def (org-export-get-footnote-definition footnote-reference info)))
+	 (concat
+	  (format "\\footnote{%s%s}" (org-trim (org-export-data def info))
+		  (if (catch 'exit
+

Re: [O] #+language and case

2016-05-22 Thread Rasmus
Nicolas Goaziou  writes:

> Hello,
>
> Rasmus  writes:
>
>> I just pushed a patch (d07fafed4af9d22044870ae909f0bb82b1412eb6) that
>> makes the ox-html insensitive to the usage of case of the #+language
>> keyword value.
>>
>> I realize this might be design, as ox-latex is done in the same way.  But
>> I don’t see any reason for Org to have an opinion on the case of language,
>> especially since e.g. blocks are not case-sensitive.  Should I also make
>> ox-latex and other backends insensitive to case or maybe just remove the
>> aforementioned commit?
>
> Indeed. Value is case insensitive. The change can be propagated to other
> back-ends. Thank you for catching it.

OK, I will be going over this and push changes to maint.

-- 
To err is human. To screw up 10⁶ times per second, you need a computer




Re: [O] exporting documents w/ babel results w/o evaluating babel blocks

2016-05-22 Thread John Hendy
On Fri, May 20, 2016 at 4:20 PM, Charles C. Berry  wrote:
> On Fri, 20 May 2016, Nick Dokos wrote:
>
>> Ken Mankoff  writes:
>>
> [deleted discussion of  `org-export-babel-evaluate' settings]
>
>>
>> With ":exports results" and o-e-b-e set to nil, I get no evaluation on
>> export, but I get both code and results in the output.
>>
>>> There may have been a misunderstanding, but when I mentioned this in
>>> the bug report, I was told this is a "feature".
>>>
>>> http://thread.gmane.org/gmane.emacs.orgmode/107230/focus=107231
>>>
>>
>> Not sure what exactly Chuck meant is a feature, but IIUC, the fact
>> that I get both code and results even if I specify ":exports results"
>> looks like a bug to me.
>>
>
> I meant this, as of commit ec615b1..., `org-export-babel-evaluate' set to
> `nil' keeps the exporter from running this line
>
>   (org-export-execute-babel-code)
>
> during exports. So, 'no Babel code is run' in the sense that the above
> line does not execute.
>
> src-blocks and inline-src-blocks are neither run nor removed, and no
> #+results: or {{{results()}}} are added, removed, or
> modified. Babel handles all that. The exporter merely formats those
> things once Babel is done.
>
> So the bug, if any, is in the docstring in failing to mention that
> everything that babel does is switched off.

I don't entirely follow. Is there an intermediate step between a .org
src block, babel, and the exporter? If so, the behavior I see could
make sense. If not, then it doesn't.

As in, why is babel "execution" (as in o-e-b-e to non-nil) required to
*not* export this code into the resultant pdf?

#+begin_src R :exports results :results output
  dat <- 1:10
  print(dat)
#+end_src

With o-e-b-e set to nil, I get the code in the exported document,
hence my asking. If I turn o-e-b-e on, I don't (but get the results).
So perhaps the real missing bit from the documentation is something
like "all babel functionality is turned off, and babel is responsible
for executing code and generating/updating any results, as well as
controlling src block export controls (results vs. code vs. both). In
other words, without babel, src blocks in .org files are treated like
example blocks during export."

Is that accurate?

I think one of the main points of confusion in this thread still has
to do with why o-e-b-e switches what gets exported. If no code/results
are run/added/removed/modified as you mention, it doesn't speak to why
code export is always done for o-e-b-e = nil, but not otherwise. This
suggests babel is doing more than "executing code;" it's somehow
influencing what makes it into the export document. At least for me,
that was an unexpected interpretation of "everything babel does is
switched off."

In fact, I just had an idea... I have o-e-b-e set to always, but just
turned org-confirm-babel-evaluate to on (I typically have it off). If
export the above and type "no" to make sure the code block is not
executed I do *not* get the code in the document. I think this
confirms that babel's responsibilities include *what* plain text in
.org the exporter formats into the output format.

My suggestion would be to create a different variable to handle
formatting vs. execution unless things were designed this way? It
seems from all the comments that the majority of users expect the
time-heavy *code* not to be run at each export but still prefer the
blocks to behave as they intended. Theoretically, with all of my
results generated (e.g. into .pdf, .png, etc. plots; ascii tables,
whatever) shouldn't I be able to have o-e-b-e set to whatever and get
the same document? My document no longer depends on any of the code...
so I don't need it run, but the exported document will behave like
:exports both instead of :exports results just from turning babel off.


John

>
> Since the behavior that the OP wanted can be had by setting babel
> header args, I don't see this as a bug even though the behavior
> changed in a way that surprised him.
>
> Chuck
>



[O] Why does the clocking format in the mode line string look like this?

2016-05-22 Thread Trevor Murphy
Hey, list!

When I clock into a task, I get a nice notification in my mode line.
Except there's always been this one thing that confuses me.

With an effort property on the task, the mode line looks like this:

[0:00/0:30] (the task headline)

But with no effort property set, the mode line looks like this:

[0:00 (the task headline)]

Note that the headline is outside the square brackets in the first
case, and inside in the second case.

Does that look inconsistent to anybody else?  I would have expected
the no-effort-property case to look like this:

[0:00] (the task headline)

The next email contains a patch I've been using to make the two
consistent, in case this makes sense to you all.  FYI, I signed the
FSF copyright paperwork a long time ago.

Cheers!

Trevor




[O] [PATCH] Place `org-clock-heading' outside clock time.

2016-05-22 Thread Trevor Murphy
* org-clock.el (org-clock-get-clock-string): When `org-clock-effort'
  is nil, arrange the format string components separately, similar to
  how they are arranged when o-c-e is not-nil.
---
 lisp/org-clock.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index c72bed4..a7c2a0a 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -682,7 +682,7 @@ If not, show simply the clocked time like 01:50."
  'face 'org-mode-line-clock)))
  (format clockstr work-done-str))
   (org-propertize (concat "[" (org-minutes-to-clocksum-string clocked-time)
- (format " (%s)" org-clock-heading) "]")
+ "]" (format " (%s)" org-clock-heading))
  'face 'org-mode-line-clock
 
 (defun org-clock-get-last-clock-out-time ()
-- 
2.8.2




Re: [O] Bug: org links do not work in some latex files [8.3.4 (8.3.4-34-gacfd41-elpaplus @ /home/oub/.emacs.d/elpa/org-plus-contrib-20160411/)]

2016-05-22 Thread Nicolas Goaziou
Hello,

Uwe Brauer  writes:

> Ok, I could clone the git rep of org and then try to merge your
> modification into ELPA, it is just that function you changed?

That one and `org-open-at-point'.

> BTW I see that org is also in the trunk of Emacs master (25.1.5) which I
> use, is org master the same as that version? I would then need to re
> compile emacs...

Org in Emacs trunk is an outdated version no longer supported.

Regards,

-- 
Nicolas Goaziou



Re: [O] #+language and case

2016-05-22 Thread Nicolas Goaziou
Hello,

Rasmus  writes:

> I just pushed a patch (d07fafed4af9d22044870ae909f0bb82b1412eb6) that
> makes the ox-html insensitive to the usage of case of the #+language
> keyword value.
>
> I realize this might be design, as ox-latex is done in the same way.  But
> I don’t see any reason for Org to have an opinion on the case of language,
> especially since e.g. blocks are not case-sensitive.  Should I also make
> ox-latex and other backends insensitive to case or maybe just remove the
> aforementioned commit?

Indeed. Value is case insensitive. The change can be propagated to other
back-ends. Thank you for catching it.


Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: check that org-element--cache-sync-keys is non-nil before clrhash [8.3.4 (8.3.4-42-gae73c7-elpa @ /home/mah/.emacs.d/elpa/org-20160425/)]

2016-05-22 Thread Mark A . Hershberger
> Could you investigate about how this happens in your case?

I removed [gnus-alias-use-identity](https://www.emacswiki.org/emacs/GnusAlias) 
and the problem went away.  I'm guessing it is because some sort of race 
condition when I reply to a message.  I would gues that org-mode is invoked 
when the signature files are inserted into the message.



[O] error: org-meta-return release_8.3.4.zip

2016-05-22 Thread Mambo Levis
Hi,
1.) By testing org-mode release_8.3.4.zip from ( 
http://orgmode.org/cgit.cgi/org-mode.git/) without compile it in emacs 
25.1.50.1 an error is shown
when typing M-RET to add a new heading/item (see attached backtrace).
I am using the minimal configuration suggested in the manual.
-;;
 
init.el--(use-package
 org-mode  :load-path "~/.emacs.d/user/site-lisp/org-mode"  :init  (load-file 
"~/.emacs.d/user/lisp/init-org-minimal.el")  
)--;;;
 init-org-minimal.el --- org-mode minimal configuration 
;;;
 Minimal setup to load latest 'org-mode';; activate debugging(setq 
debug-on-error t      debug-on-signal nil      debug-on-quit nil);; add latest 
org-mode to load path(add-to-list 'load-path 
"~/.emacs.d/user/site-lisp/org-mode/lisp")(add-to-list 'load-path 
"~/.emacs.d/user/site-lisp/org-mode/contrib/lisp" t);;(org-capture)
(provide 'init-org-minimal);;; init-org-minimal.el ends 
here---
2) If I use the option reload Org uncompiled there is no problem when using 
M-RET but the following message appears:Successfully reloaded OrgOrg-mode 
version 8.2.10 (release_8.2.10 @ mixed installation! 
c:/emacs/emacs-25.1.50/share/emacs/25.1.50/lisp/org/ and 
c:/home/.emacs.d/user/site-lisp/org-mode/lisp/)
3) Now I force emacs to search the new org-mode version by adding a org__ to 
the original installation. The following message appears:File error: Cannot 
open load file, No such file or directory, org-table


Questions: - How can isolate the new org version from the default installed?- 
How can I solve this issue? 

I appreciate your help,regards,
Levis


backtrace.el
Description: Binary data


[O] org agenda persistent mark

2016-05-22 Thread Jesse Johnson
Hello!

When I enable persistent marks while performing bulk actions in
org-agenda, the marks are always lost after the bulk action. Any idea
why? I am using org (elpa version 20160516) in upstream emacs (compiled
2015-12-22).

Thanks.

Jesse



Re: [O] add some babel supports (PHP, Lua, Redis)

2016-05-22 Thread Rasmus
Hi,

Thanks for your patches.  Sorry about the delay.  I was hoping that
someone with more ob knowledge would step in.

Please find some comments below.  I think some more work is needed before
your libraries are 

"numbch...@gmail.com"  writes:

> From 2589d4e7d28016fb515d2131cbd9ff52797e50eb Mon Sep 17 00:00:00 2001
> From: stardiviner 
> Date: Tue, 10 May 2016 16:03:32 +0800
> Subject: [PATCH] ob-lua.el: add Lua src block executing support
>
> * contrib/lisp/ob-lua.el (org-babel-execute:lua): support executing Lua
> src block.

Please capitalize after the colon.

> ---
> +;;; ob-lua.el --- Execute Lua code within org-mode blocks.
> +;; Copyright 2016 stardiviner

> +;; Author: stardiviner 
> +;; Maintainer: stardiviner 



> +;; Keywords: org babel lua

For whatever reason this seems to be

;; Keywords: literate programming, reproducible research

In most ob files.

> +;; URL: https://github.com/stardiviner/ob-lua


> +;; Created: 12th April 2016

This header is unnecessary, but if you like it, it’s fine.

> +;; Version: 0.0.1
> +;; Package-Requires: ((org "8"))

> +;;; Commentary:
> +;;
> +;; Execute Lua code within org-mode blocks.


Maybe,

The file provides Org-Babel support for evaluating Lua code.



> +;;; Code:
> +(require 'org)

This is unnecessary.  Ob implies Org.

> +(require 'ob)
> +
> +(defgroup ob-lua nil
> +  "org-mode blocks for Lua."
> +  :group 'org)

It seems that ob languages do not typically define new groups.  

Also, ob is the filename.  Variables are org-babel.

> +(defcustom ob-lua:default-session "*lua*"
> +  "Default Lua session.
> +
> +It is lua inferior process from `run-lua'."
> +  :group 'ob-lua
> +  :type 'string)

I don’t think this is necessary to have as a defcustom.  There’s already
:session.  Also, you are missing :type.  Per above, group is org-babel.

> +;;;###autoload
This is normally not autoloaded.  Babel languages are loaded via
org-babel-do-load-languages.

> +(defun org-babel-execute:lua (body params)
> +  "org-babel lua hook."

Please capitalize sentences.

> +  (let* ((session (or (cdr (assoc :session params))
> +  ob-lua:default-session))
> + (cmd (mapconcat 'identity (list "lua -") " ")))

Is something missing here?  AFAIK cmd → "lua -" always.

Also, what if my lua is not in my PATH?  I got a felling that you might
make a more robust mode by hooking into lua-mode

 https://immerrr.github.io/lua-mode/

> +(org-babel-eval cmd body)))

How are various return values handled?  E.g. will a table be correctly
interpreted as such?  (It’s a while since I coded in lua).

> +;;;###Autoload
> +(eval-after-load "org"
> +  '(add-to-list 'org-src-lang-modes '("lua" . lua)))


This should be unnecessary as the lua-mode is presumably lua-mode.  Also,
I think your code depends on lua-mode in order to be able to edit it.  You
need to declare that as a dependency.

> +(provide 'ob-lua)
> +
> +;;; ob-lua.el ends here
> -- 
> 2.8.2
>
>
> From d2e7202930fcf24e7c90826e69bb768094463a0c Mon Sep 17 00:00:00 2001
> From: stardiviner 
> Date: Tue, 10 May 2016 16:05:38 +0800
> Subject: [PATCH] ob-php.el: Add PHP src block executing support
>
> * contrib/lisp/ob-php.el (org-babel-execute:php): support executing PHP
>   src block.

Capitalize.

> ---
>  contrib/lisp/ob-php.el | 44 
>  1 file changed, 44 insertions(+)
>  create mode 100644 contrib/lisp/ob-php.el
>
> diff --git a/contrib/lisp/ob-php.el b/contrib/lisp/ob-php.el
> new file mode 100644
> index 000..31960a5
> --- /dev/null
> +++ b/contrib/lisp/ob-php.el
> @@ -0,0 +1,44 @@
> +;;; ob-php.el --- Execute PHP within org-mode blocks.
> +;; Copyright 2016 stardiviner
> +
> +;; Author: stardiviner 
> +;; Maintainer: stardiviner 
> +;; Keywords: org babel php
> +;; URL: https://github.com/stardiviner/ob-php
> +;; Created: 04th May 2016
> +;; Version: 0.0.1
> +;; Package-Requires: ((org "8"))
> +
> +;;; Commentary:
> +;;
> +;; Execute PHP within org-mode blocks.
> +
> +;;; Code:
> +(require 'org)
> +(require 'ob)
> +
> +(defgroup ob-php nil
> +  "org-mode blocks for PHP."
> +  :group 'org)


See comments above.

> +;; Todo

Remove.

> +(defcustom ob-php:inf-php-buffer "*php*"
> +  "Default PHP inferior buffer."
> +  :group 'ob-php
> +  :type 'string)

:Type is missing and this buffer should not be a defcustom.

> +;;;###Autoload

Remove.

> +(defun org-babel-execute:php (body params)
> +  "org-babel PHP hook."
> +  ;; Todo

Remove.

> +  (let* ((cmd (mapconcat 'identity (list "php") " -r ")))
> +(org-babel-eval cmd body)
> +))

See comments above re docstring, and robustness.

What sort of return values can I expect from this?  I don’t know php, but
I assume it’s mainly "log messages".

> +;;;###autoload
> +(eval-after-load "org"
> +  '(add-to-list 'org-src-lang-modes '("php" . php)))

Unnecessary.  Also, it seems there’s an undeclared decency on some sort of
php mode.

> +
> +(provide 'ob-php)

> From eb3c0cb1467416d141a63

Re: [O] Org insert different hour than current time

2016-05-22 Thread Mambo Levis
> Hi,
>
> 1. When I insert date and time format (C-u C-c .) the hour display in emacs 
> calendar is the same as my
> system hour. Nonetheless,
> org-mode insert a different hour (it adds automatically 3 hours)
>

FWIW, everything is working fine here.

But I don't understand what "the hour display in emacs calendar" means,
or what your "system hour" is. Can you specify *exactly* what you do?

> 2. I make tests with different time zones and the same problem appeared.
>
> 3. When the time zone is UTC, there is no problem because org insert the 
> system hour.
>

How do you set the timezone?

--
Nick
--Thank you for your answer.See the 
following test:1) When I C-u C-c . to insert Date and Time format, the 
following option is shown:

I press RET and the following Date+time is inserted:<2016-05-22 So 20:50>As you 
see, the inserted time is different.But if I call the agenda the current time 
is shown properly:


2) When I change the timezone to UTC in my computer (not in emacs) there is no 
problem to inserta Date+time. However, it is not a solution because it changes 
emacs clock, agenda, ... etc. I made that change justfor testing purposes.
Regards,Levis
 


Re: [O] Starting source code export at non-zero (-n value)

2016-05-22 Thread Brian Carlson



On 2016-05-20 16:48, Nicolas Goaziou wrote:

Hello,

Brian Carlson  writes:


Hello other org mode aficionados! (I apologize for the errant email I
send a minute ago. )





 From 6b4db0a978cc3492f0d0ac7e29008de6846fbe4a Mon Sep 17 00:00:00 2001
From: Brian Carlson 
Date: Mon, 16 May 2016 10:58:01 -0400
Subject: [PATCH] ox: provide [+-]n  functionality


Here you need to specify all the functions being modified. You may want
to look at other commit messages in the repository.


I'll make the appropriate commentary in my commit message in my branch.




@@ -1488,9 +1488,9 @@ contextual information."
   (custom-env (and lang
(cadr (assq (intern lang)
org-groff-custom-lang-environments
- (num-start (case (org-element-property :number-lines src-block)
+ (num-start (case (car (org-element-property :number-lines src-block))
(continued (org-export-get-loc src-block info))
-  (new 0)))
+  (new (or (cdr (org-element-property :number-lines 
src-block)) 0


This pattern appears often in your patch, and, of course in the code
base. I suggest to factorize it out.  Indeed, we could take advantage of
the new behaviour of `org-export-get-loc' that your patch introduces.


I started doing that, and with your recommendation. I'll do just that.



IIUC, the new `org-export-get-loc' returns the number for the first line
of the current block, not the number of the last line in the previous
block, like it used to do. It can then includes the construct above:

   (pcase (org-element-property :number-lines src-block)
 ;; No need to compute line numbers before this one.
 (`(new . ,n) (or n 2))
 (`(continued . ,_)
  ;; Count all lines above, up to the first block that has "new" line
  ;; numbering.
  (let ((loc 0))
(org-element-map (plist-get info :parse-tree)
...

Of course, tests would have to be changed or updated accordingly.


A very nice recommendation. I'll look into this.




-   ((string-match "-n\\>" switches) 'new)
-   ((string-match "+n\\>" switches) 'continued)))
+   ((string-match "-n *\\([0-9]+\\)" switches) (cons 'new 
(- (string-to-number (match-string 1 switches)) 1 )))


There is a spurious white space after the last 1.

+   ((string-match "+n *\\([0-9]+\\)" switches) (cons 
'continued (- (string-to-number (match-string 1 switches)) 1 )))


Ditto.

+   ((string-match "+n" switches) (cons 'continued 0))
+   ))


These parens should be moved at the end of the previous line.
Nice catch. Before I resubmit the patch. I'll clean up this and the 
other non-standard coding conventions. I haven't submitted patches to 
emacs code before, so I really do appreciate bringing my attention to 
areas where I fail to follow the coding conventions.






 (preserve-indent
  (and switches (string-match "-i\\>" switches)))
 ;; Should labels be retained in (or stripped from) example
@@ -2393,7 +2396,7 @@ Assume point is at the beginning of the block."
(looking-at
 (concat "^[ \t]*#\\+BEGIN_SRC"
 "\\(?: +\\(\\S-+\\)\\)?"
-"\\(\\(?: +\\(?:-l 
\".*?\"\\|[-+][A-Za-z]\\)\\)+\\)?"
+"\\(\\(?: +\\(?:-l \".+\"\\|[+-]n 
*[[:digit:]]+\\|[+-][[:alpha:]]\\)\\)+\\)?"


I don't think "[-+][[:alpha:]]" is correct here and neither was [-+][A-Za-z].  
We
only want to match valid switches: k, r and i. Besides, there is no +k,
+r or +i. Thus, it should be "-[iIkKrR]".


I agree with this. I'll fix this, as well. I think we actually need 
-[iIkKrRnN]|+[nN]
The first part of the regular expression catches [-+][Nn] *[0-9]+ but 
not [-+][Nn] in isolation (which obviously we still need).



 "\\(.*\\)[ \t]*$"))
(org-match-string-no-properties 1)))
 ;; Get switches.
@@ -2403,8 +2406,11 @@ Assume point is at the beginning of the block."
 ;; Switches analysis
 (number-lines
  (cond ((not switches) nil)
-   ((string-match "-n\\>" switches) 'new)
-   ((string-match "+n\\>" switches) 'continued)))
+   ((string-match "-n *\\([0-9]+\\)" switches) (cons 'new 
(- (string-to-number (match-string 1 switches)) 1 )))
+   ((string-match "+n *\\([0-9]+\\)" switches) (cons 
'continued (- (string-to-number (match-string 1 switches)) 1 )))
+   ((string-match "-n" switches) (cons 'new 0))
+   ((string-match "+n" switches) (cons 'continued 0))
+   ))


See above.
I'll do some testing and tinkering. The "problem" is that -n  is equal 

Re: [O] #+language and case

2016-05-22 Thread Eric S Fraga
On Sunday, 22 May 2016 at 13:44, Rasmus wrote:
> Hi,
>
> I just pushed a patch (d07fafed4af9d22044870ae909f0bb82b1412eb6) that
> makes the ox-html insensitive to the usage of case of the #+language
> keyword value.
>
> I realize this might be design, as ox-latex is done in the same way.  But
> I don’t see any reason for Org to have an opinion on the case of language,
> especially since e.g. blocks are not case-sensitive.  Should I also make
> ox-latex and other backends insensitive to case or maybe just remove the
> aforementioned commit?

Strangely and/or luckily, I had assumed that all parsing of keywords was
done in a case insensitive manner and I've never had a problem.  If this
is actually not the case, I would strongly support making the changes
you propose.  Unless I misunderstood, of course!

thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.93.1, Org release_8.3.4-775-g3308a5



[O] #+language and case

2016-05-22 Thread Rasmus
Hi,

I just pushed a patch (d07fafed4af9d22044870ae909f0bb82b1412eb6) that
makes the ox-html insensitive to the usage of case of the #+language
keyword value.

I realize this might be design, as ox-latex is done in the same way.  But
I don’t see any reason for Org to have an opinion on the case of language,
especially since e.g. blocks are not case-sensitive.  Should I also make
ox-latex and other backends insensitive to case or maybe just remove the
aforementioned commit?

Rasmus

-- 
If you can mix business and politics wonderful things can happen!




Re: [O] Some thought about `org-latex-pdf-process-alist', was Re: (V9) [PATCH] New feature: Use dvisvgm to preview latex formular

2016-05-22 Thread Rasmus
Hi Feng,

Thanks for the detailed explanation.

"Feng Shu"  writes:

> #+BEGIN_SRC emacs-lisp
> (setq org-latex-pdf-process-alist
>   '(("pdflatex-pdflatex-pdflatex"
>  :commands ("pdflatex -interaction nonstopmode -output-directory %o 
> %f"
> "pdflatex -interaction nonstopmode -output-directory %o 
> %f"
> "pdflatex -interaction nonstopmode -output-directory %o 
> %f")
>
>  ;; A string in `:valid-classes',
>  ;; when nil, fallback to `org-latex-default-class'
>  :default-class "article"



>  ;; class-settings which works well with the process,
>  ;; they must be defined `org-latex-classes'.
>  ;; when nil, all class-settings defined `org-latex-classes'
>  ;; are valid.
>  :valid-classes ("article" "beamer" "report" "book")
>
>  ;; the process's default packages, when nil
>  ;; fallback to `org-latex-default-packages-alist'
>  :default-packages-alist nil
>
>  ;; the process's packages, when nil
>  ;; fallback to `org-latex-packages-alist'
>  :packages-alist nil
>  :packages-override nil)))
> #+END_SRC


This is mixing together org-latex-packages-alist, org-latex-pdf-process
and org-latex-document-class, org-latex-default-class,
org-koma-letter-default-class etc, and latexmk/carara into one (modulus
typos).  IMO, it introduces too much dependency and convolution.  Take
:valid-class; When I add a new class CLASS, I need to add it to the
correct entries in org-latex-pdf-process-alist.  You ask me to form a
joint opinion about too many things at once.

LaTeX is very modular and straight forward.  Little "bottles" curated
towards specific use-cases is rather the business of LyX (which is a great
program).

>>> 3. Add #+LATEX_PDF_PROCESS setting
>>
>> Is this the same as #+latex_compiler, which is used for setting the
>> process to pdflatex, xelatex or lualatex?
>
> It is different, 3 runs of latex as example:
>
> if we don't deal with %latex place-hold in process commands,
> #+latex_compiler is useless, we need to define pdf process
> in org-latex-pdf-process-alist, 

But we do define %latex everywhere,

http://orgmode.org/cgit.cgi/org-mode.git/tree/lisp/ox-latex.el#n1149
  
> otherwise, we can use #+latex_compile and define pdf process
>
>"latex-latex-latex"

%latex × 3 is a subpar solution.  Programs like latexmk or something
equivalent should be used.  I don’t care about the process.  I care about
the final document and its correctness.

> Reason:
> 1. Not so simple, we often need to edit `org-latex-classes'
>`org-latex-default-packages-alist' and `org-latex-package-alist'
>for many reason, for example: macro conflict

This is the nature of LaTeX.  The packages that Org selects by default do
not conflict with each other.

> 2. I don't want every users have to write latex-header in every org-file
> and I like: install ox-latex-chinese and
>
>(setq org-latex-default-pdf-process "cn/xelatex-xelatex-xelatex")
>
> every org-file can export to pdf.

I strongly disagree with this vision.

This should be possible with org-latex-classes without limiting the
flexibility of ox-latex.  Also, we already have a way of solving this
use-case, namely org-export-define-derived-backend.

> By the way, I don't like the #+latex_compile approach, In my opinion, it seem 
> to be a
> hack. For user, ox-latex provide too much configure options.

LaTeX success rests in its flexibility, so this critique is misfounded
IMO.  The success of ox-latex is that it’s flexible enough to satisfy even
power users’ use-cases, making it an uncompromizing alternative to plain
LaTeX.

Take the example of "𝟙" (U+1D7D9).  This is only supported with
"unicode-math" which in turn requires xelatex/lualatex.  OTOH, microtype
supports pdflatex better.  As such, the "optimal" compiler depends on the
content.

> Maybe someone says, it is stupid duplicate code:
>
> #+BEGIN_COMMENT
> pdflatex-pdflatex-pdflatex
> pdflatex-pdflatex-pdflatex
> pdflatex-bibtex-pdflatex-pdflatex
> xelatex-xelatex-pdflatex
> xelatex-xelatex-pdflatex
> xelatex-bibtex-xelatex-xelatex
> luatex-luatex-lualatex
> luatex-luatex-lualatex
> luatex-bibtex-luatex-lualatex
> #+END_COMMENT
>
> but I think, it is a right approach, we must know, we have org contrib
> package, and we have other personnel org extension package, we don't
> need put all the process setting to ox-latex.el, we just add the
> following three as defaults and examples.
>
> #+BEGIN_COMMENT
> pdflatex-pdflatex-pdflatex
> pdflatex-pdflatex-pdflatex
> pdflatex-bibtex-pdflatex-pdflatex
> #+END_SRC
>
> ox-latex-process:xelatex package can be provided in elpa or melpa,
> if some need xelatex process setting, just install it.
>
> Users can develop and share their own special processes with the
> help of emacs package.

This sounds like a step back.

Rasmus

-- 
Got mashed potatoes. Ain't got no T-Bone. No T-Bone