Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-14 Thread Vladimir Lomov
Hello,
** Nicolas Goaziou [2016-05-13 14:12:20 +0200]:

> Hello,
> 
> Aaron Ecay  writes:
> 
>> Is this a correct change?  Previously, C-x C-s in the org-src buffer
>> would save the underlying .org file, which was useful.  AFAICS this now
>> would not work.
> 
> Why do you think so ? C-x C-s is still bound to `org-edit-src-save'. Do
> you have an ECM demonstrating the issue?

I have small example that worked before the commit, please see attached
Org document.

>> I also wonder whether autosave will work correctly from
>> the org-src buffer.
> 
> Again, why wouldn't it work? It calls `org-edit-src-save'.
> 
>> I think the other suggestion in this thread (to use write-region) is
>> a better solution.
> 
> The problem is about `write-file' (C-x C-w). If this function is not
> behaving as expected, it should be fixed, if possible.
> 
> In any case, I think the lines of code I removed were useless anyway. Do
> you have any use case in mind for them?
> 
> 
> Regards,
> 
> -- 
> Nicolas Goaziou
> 

---
WBR, Vladimir Lomov

-- 
Economists are still trying to figure out why the girls with the least
principle draw the most interest.


ex.org
Description: Lotus Organizer
(global-set-key [f2] 'save-buffer)
(add-to-list 'load-path "/usr/share/emacs/site-lisp/org")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/org_contrib")


[O] ATTR_LATEX :options ignored for source code

2016-05-14 Thread Jeff Trull
According to the manual users can supply #+ATTR_LATEX: :options ... prior
to a source section and the options present will be supplied to the
environment (lstlistings in my case).  I find that this does not work -
regardless of settings, no options are supplied to the lstlistings
environment.  Attached is a test case that demonstrates the problem.  It is
taken from the manual.

Thanks,
Jeff


testcase.org
Description: Binary data


Re: [O] [PATCH] New feature: Use dvisvgm to preview latex formular

2016-05-14 Thread Feng Shu
"Feng Shu"  writes:

This is version 2, make diff more easy read.

>From 66804cf5642256a38beb0b84ad8194562f34bfce Mon Sep 17 00:00:00 2001
From: Feng Shu 
Date: Sat, 14 May 2016 22:42:53 +0800
Subject: [PATCH] New feature: Use dvisvgm to preview latex formular

Tester should set like below:

(setq org-latex-create-formula-image-program 'dvisvgm)
(setq org-latex-pdf-process
  '(:fetcher my-org-latex-pdf-process-format))
(defun my-org-latex-pdf-process-format ( texfile snippet caller-info)
  (cond
   (snippet '("latex -interaction nonstopmode -output-directory %o %f"))
   (t '("%latex -interaction nonstopmode -output-directory %o %f"
"%latex -interaction nonstopmode -output-directory %o %f"
"%latex -interaction nonstopmode -output-directory %o %f"

* ox-latex.el (org-latex-pdf-process): Add a new config method, :fetcher.
(org-latex-compile): Add a new optional argument: caller-info,
 which used to record the caller's info

* ox-html.el (org-html-with-latex): Add dvisvgm support.
(org-html-with-latex): Add dvisvgm support.
(org-html-format-latex): "ltxpng" -> "ltximg".
(org-html-latex-environment): Add dvisvgm support.
(org-html-latex-fragment): Add dvisvgm support.

* org.el (org-latex-create-formula-image-program): Add dvisvgm.
(org-latex-preview-ltximg-directory): Rename from `org-latex-preview-ltximg-directory'.
(org--format-latex-make-overlay): Add optional image-type, which used to deal with svg.
(org-toggle-latex-fragment): "org-ltxpng" -> "org-ltximg".
(org-format-latex): Add dvisvgm support.
(org-create-formula-image): Add dvisvgm case.
(org-create-formula-image-with-dvisvgm): New function, deal with latex formula with dvisvgm command.

* org.texi (@LaTeX{} fragments): Add dvisvgm information.
(Previewing @LaTeX{} fragments): Add dvisvgm information.
(Math formatting in HTML export): Add dvisvgm information.
(Working with @LaTeX{} math snippets): Add dvisvgm information.
---
 doc/org.texi |  39 +-
 lisp/org.el  | 101 --
 lisp/ox-html.el  |  19 ---
 lisp/ox-latex.el | 161 +++
 4 files changed, 225 insertions(+), 95 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 17b01c2..286fabb 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10393,10 +10393,10 @@ snippets will be identified as @LaTeX{} source code:
 @item
 Environments of any kind@footnote{When MathJax is used, only the
 environments recognized by MathJax will be processed.  When
-@file{dvipng} program or @file{imagemagick} suite is used to create images,
-any @LaTeX{} environment will be handled.}.  The only requirement is that the
-@code{\begin} statement appears on a new line, at the beginning of the line
-or after whitespaces only.
+@file{dvipng} program, @file{dvisvgm} program or @file{imagemagick} suite is
+used to create images, any @LaTeX{} environment will be handled.}.  The only
+requirement is that the @code{\begin} statement appears on a new line, at the
+beginning of the line or after whitespaces only.
 @item
 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
 currency specifications, single @samp{$} characters are only recognized as
@@ -10444,10 +10444,10 @@ lines:
 @cindex @LaTeX{} fragments, preview
 
 @vindex org-latex-create-formula-image-program
-If you have a working @LaTeX{} installation and either @file{dvipng} or
-@file{convert} installed@footnote{These are respectively available at
-@url{http://sourceforge.net/projects/dvipng/} and from the @file{imagemagick}
-suite. Choose the converter by setting the variable
+If you have a working @LaTeX{} installation and @file{dvipng}, @file{dvisvgm}
+or @file{convert} installed@footnote{These are respectively available at
+@url{http://sourceforge.net/projects/dvipng/}, @url{http://dvisvgm.bplaced.net/}
+and from the @file{imagemagick} suite. Choose the converter by setting the variable
 @code{org-latex-create-formula-image-program} accordingly.}, @LaTeX{}
 fragments can be processed to produce images of the typeset expressions to be
 used for inclusion while exporting to HTML (see @pxref{@LaTeX{} fragments}),
@@ -11713,6 +11713,7 @@ You could use @code{http} addresses just as well.
 @subsection Math formatting in HTML export
 @cindex MathJax
 @cindex dvipng
+@cindex dvisvgm
 @cindex imagemagick
 
 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
@@ -11737,13 +11738,18 @@ template can be configure via @code{org-html-mathjax-template}.
 If you prefer, you can also request that @LaTeX{} fragments are processed
 into small images that will be inserted into the browser page.  Before the
 availability of MathJax, this was the default method for Org files.  This
-method requires that the @file{dvipng} program or @file{imagemagick} suite is
-available on your system.  You can still get this processing with
+method 

Re: [O] latex fragment png's size too small

2016-05-14 Thread Feng Shu
"Feng Shu"  writes:

> Nicolas Goaziou  writes:
>
>> tumashu  writes:
>>
>>> The problem is that the pic is too small and nearly can not see the
>>> words in the picture, it will force user config it, if we use a larger
>>> pic, it can work although it is ugly
>>
>> Then is :scale 1.2 enough?
>
> I tested in bare emacs, 1.2 seem ok. 

I have found the other problem, the below two version of
org-create-formula-image-with-dvipng generate different size png,
for they use different dpi.

I think, we should hold :scale to 1.0 and fix size problem in function
`org-create-formula-image-with-dvipng'.

#+BEGIN_SRC emacs-lisp
;; Old version
(defun org-create-formula-image-with-dvipng (string tofile options buffer)
  "This calls dvipng."
  (require 'ox-latex)
  (let* ((tmpdir (if (featurep 'xemacs)
 (temp-directory)
   temporary-file-directory))
 (texfilebase (make-temp-name
   (expand-file-name "orgtex" tmpdir)))
 (texfile (concat texfilebase ".tex"))
 (dvifile (concat texfilebase ".dvi"))
 (pngfile (concat texfilebase ".png"))
 (fnh (if (featurep 'xemacs)
  (font-height (face-font 'default))
(face-attribute 'default :height nil)))
 (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0))
 (dpi (number-to-string (* scale (floor (* 0.9 (if buffer fnh 140.))
 (fg (or (plist-get options (if buffer :foreground :html-foreground))
 "Black"))
 (bg (or (plist-get options (if buffer :background :html-background))
 "Transparent")))
(princ (format "dpi:%s" dpi))
(if (eq fg 'default) (setq fg (org-dvipng-color :foreground))
  (unless (string= fg "Transparent") (setq fg (org-dvipng-color-format 
fg
(if (eq bg 'default) (setq bg (org-dvipng-color :background))
  (unless (string= bg "Transparent") (setq bg (org-dvipng-color-format 
bg
(let ((latex-header (org-create-formula--latex-header)))
  (with-temp-file texfile
(insert latex-header)
(insert "\n\\begin{document}\n" string "\n\\end{document}\n")))
(let ((dir default-directory))
  (condition-case nil
  (progn
(cd tmpdir)
(call-process "latex" nil nil nil texfile))
(error nil))
  (cd dir))
(if (not (file-exists-p dvifile))
(progn (message "Failed to create dvi file from %s" texfile) nil)
  (condition-case nil
  (if (featurep 'xemacs)
  (call-process "dvipng" nil nil nil
"-fg" fg "-bg" bg
"-T" "tight"
"-o" pngfile
dvifile)
(call-process "dvipng" nil nil nil
  "-fg" fg "-bg" bg
  "-D" dpi
  ;;"-x" scale "-y" scale
  "-T" "tight"
  "-o" pngfile
  dvifile))
(error nil))
  (if (not (file-exists-p pngfile))
  (if org-format-latex-signal-error
  (error "Failed to create png file from %s" texfile)
(message "Failed to create png file from %s" texfile)
nil)
;; Use the requested file name and clean up
(copy-file pngfile tofile 'replace)
(loop for e in '(".dvi" ".tex" ".aux" ".log" ".png" ".out") do
  (if (file-exists-p (concat texfilebase e))
  (delete-file (concat texfilebase e
pngfile

;; New version
(defun org-create-formula-image-with-dvipng (string tofile options buffer)
  "This calls dvipng."
  (require 'ox-latex)
  (let* ((tmpdir (if (featurep 'xemacs)
 (temp-directory)
   temporary-file-directory))
 (texfilebase (make-temp-name
   (expand-file-name "orgtex" tmpdir)))
 (texfile (concat texfilebase ".tex"))
 (dvifile (concat texfilebase ".dvi"))
 (pngfile (concat texfilebase ".png"))
 (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0))
 ;; This assumes that the display has the same pixel width in
 ;; the horizontal and vertical directions
 (dpi (number-to-string (* scale (if buffer (org--get-display-dpi) 120
 (fg (or (plist-get options (if buffer :foreground :html-foreground))
 "Black"))
 (bg (or (plist-get options (if buffer :background :html-background))
 "Transparent")))
(princ (format "dpi: %s" dpi))
(if (eq fg 'default) (setq fg (org-dvipng-color :foreground))
  (unless (string= fg "Transparent") (setq fg (org-dvipng-color-format 
fg
(if (eq bg 'default) (setq bg (org-dvipng-color :background))
  (unless (string= bg "Transparent") (setq bg (org-dvipng-color-format 
bg
(let ((latex-header (org-create-formula--latex-header)))
  (with-temp-file texfile
(insert latex-header)
(insert "\n\\begin{document}\n" string "\n\\end{document}\n")))
(let ((dir default-directory))
  (ignore-errors
(cd tmpdir)
(call-process "latex" nil nil nil texfile))
  (cd dir))
(if (not (file-exists-p dvifile))
(progn 

Re: [O] latex fragment png's size too small

2016-05-14 Thread Feng Shu
Nicolas Goaziou  writes:

> tumashu  writes:
>
>> The problem is that the pic is too small and nearly can not see the
>> words in the picture, it will force user config it, if we use a larger
>> pic, it can work although it is ugly
>
> Then is :scale 1.2 enough?

I tested in bare emacs, 1.2 seem ok.

> If it is too ugly, it will also force users configuring it anyway.
>
> Regards,

-- 




Re: [O] latex fragment png's size too small

2016-05-14 Thread Nicolas Goaziou
tumashu  writes:

> The problem is that the pic is too small and nearly can not see the
> words in the picture, it will force user config it, if we use a larger
> pic, it can work although it is ugly

Then is :scale 1.2 enough?

If it is too ugly, it will also force users configuring it anyway.

Regards,



Re: [O] latex fragment png's size too small

2016-05-14 Thread tumashu
The problem is that the pic is too small and nearly can not see the words in 
the picture, it will force user config it, if we use a larger pic, it can work 
although it is ugly
在 2016-05-14 16:56:15,"Nicolas Goaziou"  写道:
Hello,

tumashu  writes:

> The preview png of latex fragment seem to small, what about change
> default `org-format-latex-options'  :scale from 1.0 to 2.0?

As a data point, I use :scale 1.2. A factor of 2 may be too large for
some users.

In any case, the manual already highlights it:

 You can customize the variable ‘org-format-latex-options’ to
  influence some aspects of the preview.  In particular, the ‘:scale’ (and
  for HTML export, ‘:html-scale’) property can be used to adjust the size
  of the preview images.

Since there may not be a more reasonable default value, the best thing
to do could be to leave it up to the user to set his own factor.

WDYT?


Regards,

-- 
Nicolas Goaziou


Re: [O] latex fragment png's size too small

2016-05-14 Thread Nicolas Goaziou
Hello,

tumashu  writes:

> The preview png of latex fragment seem to small, what about change
> default `org-format-latex-options'  :scale from 1.0 to 2.0?

As a data point, I use :scale 1.2. A factor of 2 may be too large for
some users.

In any case, the manual already highlights it:

 You can customize the variable ‘org-format-latex-options’ to
  influence some aspects of the preview.  In particular, the ‘:scale’ (and
  for HTML export, ‘:html-scale’) property can be used to adjust the size
  of the preview images.

Since there may not be a more reasonable default value, the best thing
to do could be to leave it up to the user to set his own factor.

WDYT?


Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] New feature: Use dvisvgm to preview latex formular

2016-05-14 Thread numbch...@gmail.com
This is great!

[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/

2016-05-14 14:30 GMT+08:00 Feng Shu :

>
> --
>


Re: [O] [SPAM] Re: Disabling completion during capture

2016-05-14 Thread Nicolas Goaziou
Hello,

swfl...@flintfam.org (Samuel W. Flint) writes:

> now on Org-mode version 8.3.4 (release_8.3.4-790-g1fd6f2 @
> /home/swflint/.emacs.d/org-mode/lisp/), but I still have the same
> problem.  Any suggestions?

As Eric said, this bug was fixed a while ago. Basically, the solution
was to replace `completing-read' with `org-completing-read'. At the
moment, "org-capture.el" calls the latter (see line 1765 from master
branch).

You may want to check why `completing-read' is called instead in your
configuration.


Regards,

-- 
Nicolas Goaziou



Re: [O] Problem with Including subsection by CUSTOM_ID

2016-05-14 Thread Nicolas Goaziou
Hello,

Ilya Filippov  writes:

> I try to include subsection from one org-file to another 
> (http://orgmode.org/manual/Include-files.html) with using CUSTOM_ID.
>
> In first-file.org:
>
> ** Subsection name
> :PROPERTIES:
> :CUSTOM_ID: subsec_to_include
> :END:
>
> bla-bla
>
>
> In second-file.org I use construction:
>
> * I want include here
> #+INCLUDE: "./first-file.org::#funcNT10"
>
>
> And when I export second file to PDF, org-mode gives an error message: 
> "Cannot include file /org/first-file.org::#funcNT10"

FWIW, I cannot reproduce the problem. You may want to edebug
`org-link-search' and see why it cannot find #funcNT10.


Regards,

-- 
Nicolas Goaziou



Re: [O] Buffer local value lost when exporting? (was Evaluate all org tables in file before exporting)

2016-05-14 Thread Nicolas Goaziou
Hello,

Kaushal Modi  writes:

> It got it working after setting org-export-allow-bind-keywords to t BUT now
> I need to set the buffer local value twice: (1) Using the Local Variables
> footer style so that that local value is effective when before-save-hook is
> run (2) Using #+BIND so that that value is effective when
>  org-export-before-processing-hook is run.
>
> Below is the MWE now:
>
> =
> | N |
> |---|
> |   |
> |   |
> |   |
> |   |
> #+TBLFM: $1=@#-1
>
> #+BIND: modi/org-table-enable-buffer-wide-recalculation nil
> # Local Variables:
> # modi/org-table-enable-buffer-wide-recalculation: nil
> # End:
> =

You could cheat and prefix your variable with "org-", e.g.,
"org-modi/...".

You could also try removing the limitation in the code I quoted earlier
so that it really copies all local variables before the export process,
and test if there are some drawbacks to it.

Regards,

-- 
Nicolas Goaziou



[O] [PATCH] New feature: Use dvisvgm to preview latex formular

2016-05-14 Thread Feng Shu
>From 4e40deddfb342135b78df83fc5a05ddbce965300 Mon Sep 17 00:00:00 2001
From: Feng Shu 
Date: Fri, 13 May 2016 20:12:22 +0800
Subject: [PATCH] New feature: Use dvisvgm to preview latex formular

Tester should set like below:

(setq org-latex-create-formula-image-program 'dvisvgm)
(setq org-latex-pdf-process
  '(:fetcher my-org-latex-pdf-process-format))
(defun my-org-latex-pdf-process-format ( texfile snippet caller-info)
  (cond
   (snippet '("latex -interaction nonstopmode -output-directory %o %f"))
   (t '("%latex -interaction nonstopmode -output-directory %o %f"
"%latex -interaction nonstopmode -output-directory %o %f"
"%latex -interaction nonstopmode -output-directory %o %f"

* ox-latex.el (org-latex-pdf-process): Add a new config method, :fetcher.
(org-latex-compile): Add a new optional argument: caller-info,
 which used to record the caller's info

* ox-html.el (org-html-with-latex): Add dvisvgm support.
(org-html-with-latex): Add dvisvgm support.
(org-html-format-latex): "ltxpng" -> "ltximg".
(org-html-latex-environment): Add dvisvgm support.
(org-html-latex-fragment): Add dvisvgm support.

* org.el (org-latex-create-formula-image-program): Add dvisvgm.
(org-latex-preview-ltximg-directory): Rename from `org-latex-preview-ltximg-directory'.
(org--format-latex-make-overlay): Add optional image-type, which used to deal with svg.
(org-toggle-latex-fragment): "org-ltxpng" -> "org-ltximg".
(org-format-latex): Add dvisvgm support.
(org-create-formula-image): Add dvisvgm case.
(org-create-formula-image-with-dvisvgm): New function, deal with latex formula with dvisvgm command.

* org.texi (@LaTeX{} fragments): Add dvisvgm information.
(Previewing @LaTeX{} fragments): Add dvisvgm information.
(Math formatting in HTML export): Add dvisvgm information.
(Working with @LaTeX{} math snippets): Add dvisvgm information.
---
 doc/org.texi |  39 -
 lisp/org.el  | 110 ---
 lisp/ox-html.el  |  23 
 lisp/ox-latex.el | 171 +++
 4 files changed, 237 insertions(+), 106 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 17b01c2..286fabb 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10393,10 +10393,10 @@ snippets will be identified as @LaTeX{} source code:
 @item
 Environments of any kind@footnote{When MathJax is used, only the
 environments recognized by MathJax will be processed.  When
-@file{dvipng} program or @file{imagemagick} suite is used to create images,
-any @LaTeX{} environment will be handled.}.  The only requirement is that the
-@code{\begin} statement appears on a new line, at the beginning of the line
-or after whitespaces only.
+@file{dvipng} program, @file{dvisvgm} program or @file{imagemagick} suite is
+used to create images, any @LaTeX{} environment will be handled.}.  The only
+requirement is that the @code{\begin} statement appears on a new line, at the
+beginning of the line or after whitespaces only.
 @item
 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
 currency specifications, single @samp{$} characters are only recognized as
@@ -10444,10 +10444,10 @@ lines:
 @cindex @LaTeX{} fragments, preview
 
 @vindex org-latex-create-formula-image-program
-If you have a working @LaTeX{} installation and either @file{dvipng} or
-@file{convert} installed@footnote{These are respectively available at
-@url{http://sourceforge.net/projects/dvipng/} and from the @file{imagemagick}
-suite. Choose the converter by setting the variable
+If you have a working @LaTeX{} installation and @file{dvipng}, @file{dvisvgm}
+or @file{convert} installed@footnote{These are respectively available at
+@url{http://sourceforge.net/projects/dvipng/}, @url{http://dvisvgm.bplaced.net/}
+and from the @file{imagemagick} suite. Choose the converter by setting the variable
 @code{org-latex-create-formula-image-program} accordingly.}, @LaTeX{}
 fragments can be processed to produce images of the typeset expressions to be
 used for inclusion while exporting to HTML (see @pxref{@LaTeX{} fragments}),
@@ -11713,6 +11713,7 @@ You could use @code{http} addresses just as well.
 @subsection Math formatting in HTML export
 @cindex MathJax
 @cindex dvipng
+@cindex dvisvgm
 @cindex imagemagick
 
 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
@@ -11737,13 +11738,18 @@ template can be configure via @code{org-html-mathjax-template}.
 If you prefer, you can also request that @LaTeX{} fragments are processed
 into small images that will be inserted into the browser page.  Before the
 availability of MathJax, this was the default method for Org files.  This
-method requires that the @file{dvipng} program or @file{imagemagick} suite is
-available on your system.  You can still get this processing with
+method requires that the @file{dvipng} program, @file{dvisvgm} or
+@file{imagemagick} 

Re: [O] org-table-mark-field

2016-05-14 Thread Kaushal Modi
The solution was unnecessarily over-complicated.

Below one seems simpler and more intuitive. It requires the hydra package.

(defun org-table-mark-field ()
  "Mark the current table field."
  (interactive)
  ;; Do not try to jump to the beginning of field if the point is already
there
  (when (not (looking-back "|\\s-?"))
(org-table-beginning-of-field 1))
  (set-mark-command nil)
  (org-table-end-of-field 1))

(defhydra hydra-org-table-mark-field
  (:body-pre (org-table-mark-field)
   :color pink
   :hint nil)
  "
   ^^  _p_ ^^
 _b_  selection  _f_   | org table mark ▯field▮ |
   ^^  _n_ ^^
"
  ("x" exchange-point-and-mark "exchange point/mark")
  ("f" (lambda (arg)
 (interactive "p")
 (when (eq 1 arg)
   (setq arg 2))
 (org-table-end-of-field arg)))
  ("b" (lambda (arg)
 (interactive "p")
 (when (eq 1 arg)
   (setq arg 2))
 (org-table-beginning-of-field arg)))
  ("n" next-line)
  ("p" previous-line)
  ("q" nil "cancel" :color blue))

(bind-keys
 :map org-mode-map
 :filter (org-at-table-p)
  ("S-SPC" . hydra-org-table-mark-field/body))

-- 

-- 
Kaushal Modi