Re: [O] mktemp for orgmode

2018-03-17 Thread John Kitchin
Can you do something like:


#+BEGIN_SRC some-lang :results output org drawer :file (make-temp-file
"prefix-")

#+END_SRC


John

---
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


On Sat, Mar 17, 2018 at 9:15 AM, Karl Voit  wrote:

> Hi, I sometimes wonder if there is something like mktemp[1] in
> org-mode as, e.g., a built-in macro.
>
> For example, PlantUML in orgmode[2] requires a file header argument to
> write the image output to: ":file myoutput.svg"
>
> In most cases, I really don't care about the output file and its
> location. I just want to see it in my org-mode buffer and in various
> output formats like PDF or HTML.
>
> When I don't want to trash my org folder, I have to use ":file
> /tmp/tmp.svg". The downside of it is, that this only works for
> non-Windows systems because there is no "/tmp" on Windows.
>
> Therefore, it would be cool to have something like {{{tmpfile}}} that
> I could use in :file {{{tmpfile}}}
>
> However, there is still an issue with this approach: what if I need
> multiple separate {{{tmpfile}}} for, e.g., multiple PlantUML blocks
> that are within the same heading and therefore get exported at once?
>
> And: as a consequence, it would require {{{tmpdir}}} as well.
>
> [1] https://www.gnu.org/software/autogen/mktemp.html
> [2] http://plantuml.com/emacs
>
> --
> get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
>> get Memacs from https://github.com/novoid/Memacs <
> Personal Information Management > http://Karl-Voit.at/tags/pim/
> Emacs-related > http://Karl-Voit.at/tags/emacs/
>
>
>


[O] [RFC] Add new export backend for Jekyll

2018-03-17 Thread Łukasz Stelmach
Jekyll[1] is a static site genrator.  Its most notable deployment are
Github Pages.  It accepts several input formats including HTML, that
is why ox-jekyll is derived from ox-html.  Input files for Jekyll must
be HTML files without any site-specific elements (e.g. menus, headers,
sidebars), because Jekyll will add them.  The HTML code, however, must
be prepended with a piece of YAML code which specifies:

+ page title,
+ page category,
+ layout template to use for the page,
+ publication date.

The main task of ox-jekyll is to read Org '#+KEYWORDS' and output them as
Jekyll's front matter.  At this point also source code blocks are exported
inside special tags instead of html .

[1] http://jekyllrb.com/

Signed-off-by: Łukasz Stelmach 
---

This is kind of work-in-progress version. "Kind of" because it satisfies
my needs and I would like to ask what others think or need.

How to test this module?

Please comment.

 lisp/ox-jekyll.el | 139 ++
 1 file changed, 139 insertions(+)
 create mode 100644 lisp/ox-jekyll.el

diff --git a/lisp/ox-jekyll.el b/lisp/ox-jekyll.el
new file mode 100644
index 0..273792ba9
--- /dev/null
+++ b/lisp/ox-jekyll.el
@@ -0,0 +1,139 @@
+;;; ox-jekyll.el --- Export org files to Jekyll static site generator
+
+;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
+
+;; Author: Łukasz Stelmach 
+;; Keywords: 
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs 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.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see .
+
+;;; Commentary:
+
+;; This library implements a backend to export Org files as HTML
+;; for further processing by Jekyll static site generator.
+;; See Org manual for more information.
+
+;;; Code:
+
+;;; Dependencies
+
+(require 'ox)
+
+;;; Define Back-End
+
+(org-export-define-derived-backend 'jekyll 'html
+  :menu-entry
+  '(?h 1
+   ((?J "As HTML buffer (Jekyll)" org-jekyll-export-as-html)
+(?j "As HTML file (Jekyll)" org-jekyll-export-to-html)))
+
+  :translate-alist
+  '((template . org-jekyll-html-template)
+(src-block . org-jekyll-html-src-block))
+
+  :options-alist
+  '((:jekyll-layout "LAYOUT" nil "post" t)
+(:jekyll-categories "CATEGORIES" nil nil t))
+  ;; TODO: tags, as soon as I learn how they differ from categories
+  ;; https://github.com/jekyll/jekyll/issues/6853
+  )
+
+(defun org-jekyll-export-as-html
+"TODO: Doc"
+  ( async subtreep visible-only body-only ext-plist)
+  (interactive)
+  (org-export-to-buffer 'jekyll "*Org JEKYLL Export*"
+async subtreep visible-only body-only ext-plist (lambda () (html-mode
+
+(defun org-jekyll-export-to-html
+"TODO: Doc"
+  ( async subtreep visible-only body-only ext-plist)
+  (interactive)
+  (let ((file (org-export-output-file-name ".html" subtreep)))
+(org-export-to-file 'beamer file
+  async subtreep visible-only body-only ext-plist)))
+
+(defun org-jekyll-html-src-block (src-block contents info)
+  "Transcode a SRC-BLOCK element from Org to a highlight block for Jekyll.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (message "org-jekyll-html-src-block")
+  (if (org-export-read-attribute :attr_html src-block :textarea)
+  (org-html--textarea-block src-block)
+(let ((lang (org-element-property :language src-block))
+  (caption (org-export-get-caption src-block))
+  (code (org-html-format-code src-block info))
+  (label (let ((lbl (org-element-property :name src-block)))
+   (if (not lbl) ""
+ (format " id=\"%s\""
+ (org-export-solidify-link-text lbl))
+  (if (not lang) (format "\n%s" label code)
+(format
+ "\n%s%s\n"
+ (if (not caption) ""
+   (format "%s"
+   (org-export-data caption info)))
+ (format "\n{%% highlight %s %%}\n%s{%% endhighlight %%}" lang 
code))
+
+(defun org-jekyll-html-template (contents info)
+  "Return complete document for Jekyll, i.e. the HTML contents
+without the  and  tags but prepended with a front
+matter for Jekyll."
+  (let ((title (org-export-data (plist-get info :title) info))
+(date (org-export-data (plist-get info :date) info))
+   (categories (org-export-data  (plist-get info :jekyll-categories) info))
+(now (format-time-string "%FT%T%z" (current-time)))
+   

[O] mktemp for orgmode

2018-03-17 Thread Karl Voit
Hi, I sometimes wonder if there is something like mktemp[1] in
org-mode as, e.g., a built-in macro.

For example, PlantUML in orgmode[2] requires a file header argument to
write the image output to: ":file myoutput.svg"

In most cases, I really don't care about the output file and its
location. I just want to see it in my org-mode buffer and in various
output formats like PDF or HTML.

When I don't want to trash my org folder, I have to use ":file
/tmp/tmp.svg". The downside of it is, that this only works for
non-Windows systems because there is no "/tmp" on Windows.

Therefore, it would be cool to have something like {{{tmpfile}}} that
I could use in :file {{{tmpfile}}}

However, there is still an issue with this approach: what if I need
multiple separate {{{tmpfile}}} for, e.g., multiple PlantUML blocks
that are within the same heading and therefore get exported at once?

And: as a consequence, it would require {{{tmpdir}}} as well.

[1] https://www.gnu.org/software/autogen/mktemp.html
[2] http://plantuml.com/emacs

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
   > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/




Re: [O] Capture template expansion: feature or bug?

2018-03-17 Thread Nicolas Goaziou
Hello,

François Allisson  writes:

> When one uses the following template expansion,
>
>> %^{prop}p   Prompt the user for a value for property ‘prop’.
>
> it supposes one to supply a non-empty string of characters. If one
> simply hits RETURN on a given prompt for property, the capture process
> ends with an
>
>> org-capture: Capture abort: (quit)
>
> message. This means that all prompts for properties are mandatory. It
> this a feature or a bug?

I tried reproducing your issue with the following template:

  ("B" "BUG" entry (file "/tmp/bug-capture.org") "* %?%^{prop}p")

However, I cannot reproduce it.

> Of course, if I ask the question, it is because I clearly see use cases
> for optional properties prompts (which would leave empty the property in
> question): you ask for several information, which you don't always have;
> and you don't want the capture process to quit because of that. But may
> be there is a better way to achieve this?

Another problem is: do you want to skip the property altogether, or set
it to an empty string?

> Org 9.0.10 / Emacs 25.2.1

I suggest to update Org, BTW.

Regards,

-- 
Nicolas Goaziou



Re: [O] [BUG] Convert heading with no content to item fails

2018-03-17 Thread Nicolas Goaziou
Hello,

Adrian Bradd  writes:

> On master (commit: 51b339105), attempting to convert a blank headline to an 
> item with `org-ctrl-c-minus' removes the space after the * and org no longer 
> recognizes it as a heading.
>
> I believe this issue originated in commit 69c5b6c99. Some code was added to 
> strip metadata during the conversion in `org-toggle-item' with 
> `org-heading-delete-metadata'. '(org-set-tags-to nil)' is used to strip tags 
> which in the case of
> the blank heading results in `(delete-region (match-beginning 1) (match-end 
> 1))' being called.
>
> `delete-region' in this case removes the space immediately after the star/s 
> in the blank headline which puts the line in a state that org doesn't 
> consider a headline.
>
> Replacing the removed space following the * or preventing its removal
> would remedy the issue, but I wasn't sure where to implement this.
> Didn't want to make the change in `org-set-tags-to' for fear of
> downstream effects.

Fixed. Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] add :session support for ob-js.el

2018-03-17 Thread Nicolas Goaziou
Hello,

stardiviner  writes:

> updated my code. I followed your suggestions. But modify code one by
> one messed code up. So I merge all related commits into one commit.
> Sorry for this.

Some comments follow.
> +(result (if (not (string= (cdr (assq :session params)) "none"))

You can integrate the test above in the `cond':

(cond
 ((string= "none" (cdr (assq :session params))) nil)
 ((string= "*JS REPL*" session) ...)
 ...)
> +   (sit-for .5) (goto-char (point-max))

(sit-for .5)
(goto-char (point-max))

> +   (mapc (lambda (var)
> + (insert var) (comint-send-input nil t)
> + (org-babel-comint-wait-for-output session)
> + (sit-for .1) (goto-char (point-max))) var-lines)))
>  session))

  (dolist (var ...)
   ...)

Also, what's your status wrt FSF papers? This cannot fit as
a TINYCHANGE.

Regard,

-- 
Nicolas Goaziou



Re: [O] Timestamped items with M-RET

2018-03-17 Thread Marco Wahl
Hi,

Nicolas Goaziou writes:

>> Possibly you also like the feature to create list items including the
>> current time with key M-RET when in such item.  This is for creating
>> lists like the following:
>>
>> - [2018-03-17 Sat 10:19] Write to the list.
>> - [2018-03-17 Sat 10:22] Think about wording.
>
> Is `M-RET C-u C-u C-c !' that long to type? If you use it often enough
> to want to extend `org-insert-item' for it, it should become fairly
> quick.

I guess you are right.

>> This is similar to the functionality already available for timer
>> items.  (info "(org) Timers")
>
> Timers are precise to the second, so speed matters. OTOH, timestamps are
> only precise to the minute.

I like M-RET to be smart about its context.  So it looks to me that we
talk about personal affection here.

The whole thing is just an option for everyone.


Thanks!




Re: [O] Timestamped items with M-RET

2018-03-17 Thread Nicolas Goaziou
Hello,

Marco Wahl  writes:

> Possibly you also like the feature to create list items including the
> current time with key M-RET when in such item.  This is for creating
> lists like the following:
>
> - [2018-03-17 Sat 10:19] Write to the list.
> - [2018-03-17 Sat 10:22] Think about wording.

Is `M-RET C-u C-u C-c !' that long to type? If you use it often enough
to want to extend `org-insert-item' for it, it should become fairly
quick.

> This is similar to the functionality already available for timer
> items.  (info "(org) Timers")

Timers are precise to the second, so speed matters. OTOH, timestamps are
only precise to the minute.

Regards,

-- 
Nicolas Goaziou



[O] Timestamped items with M-RET

2018-03-17 Thread Marco Wahl
Hi!

Possibly you also like the feature to create list items including the
current time with key M-RET when in such item.  This is for creating
lists like the following:

- [2018-03-17 Sat 10:19] Write to the list.
- [2018-03-17 Sat 10:22] Think about wording.

This is similar to the functionality already available for timer
items.  (info "(org) Timers")

Get the functionality by adding the following code to your init file.

#+begin_src emacs-lisp
(defun mw-org-insert-item-with-ina-ts-when-on-such-item ()
  "When on org timestamp item insert org timestamp item with current time.
This holds only for inactive timestamps."
  (when (save-excursion
  (let ((item-pos (org-in-item-p)))
(when item-pos
  (goto-char item-pos)
  (org-list-at-regexp-after-bullet-p org-ts-regexp-inactive
(let ((item-pos (org-in-item-p))
  (pos (point)))
  (assert item-pos)
  (goto-char item-pos)
  (let* ((struct (org-list-struct))
 (prevs (org-list-prevs-alist struct))
 (s (concat (with-temp-buffer
  (org-insert-time-stamp nil t t)
  (buffer-string)) " ")))
(setq struct (org-list-insert-item pos struct prevs nil s))
(org-list-write-struct struct (org-list-parents-alist struct))
(looking-at org-list-full-item-re)
(goto-char (match-end 0))
(end-of-line)))
t))

(add-hook
'org-metareturn-hook 'mw-org-insert-item-with-ina-ts-when-on-such-item)
#+end_src

The snippet can be found also at
https://gist.github.com/marcowahl/8b229ec0979e901d7d90a248c85e3ede .

As always, critique is welcome.


In the hope that this snippet is useful also for someone else,
  Marco





Re: [O] org-return does not work in magit's git-commit-setup-hook

2018-03-17 Thread Nicolas Goaziou
Hello,

kadal  writes:

> I have the line (add-hook 'git-commit-setup-hook 'orgstruct++-mode)
> but (org-return) does not work when edting the commit message.

`orgstruct-mode' does not exist anymore in master branch (i.e., yet to
be released Org 9.2). I suggest to just remove this hook.

Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] org-src-edit support open edit buffer bellow current window

2018-03-17 Thread Nicolas Goaziou
Hello,

stardiviner  writes:

> regenerated patch against HEAD now. Check it out. Thanks for your
> review.

Applied. Thank you.

Regards,

-- 
Nicolas Goaziou