[O] Request for worg page -- escaping questions

2014-04-01 Thread Rustom Mody
Over time in using org Ive come up with some issues.
Some have been solved. Some I was shown workarounds.
Some remain unsolved.

Many of these issues can be clubbed together under what computer folk call
'escaping'.

Can we have a worg page for such as the following?

   1. How to put a '=' into code
   2. How to start a line with a '*' -- (a) for headers (b) for ordinary
   lines?
   3. How to enter a '|' into tables
   4. Newlines -- \\ behaves inconsistently in latex and html [Same  as
   above because its about escaping newlines]
   5. How to make normal (ie not radio) text like this <>
   6. How to make normal text that looks like  [fn::somestuff]

Note all these may not have solutions, eg a C programmer cannot get a '*/'
into a comment however he may try.  However he can get a '\' into a string
or a quote mark itself with '\\' and '\"'.  For getting a '%' into a printf
format however, '\%' is not the way but '%%' Such things are documented
(and taught to) C programmers.

Just expressing a similar need of org-moders!

Regards,

Rusi


[O] [PATCH] ob-scheme.el: Fix scheme code blocks execution error in batch mode

2014-04-01 Thread KDr2
The bug:
write file ~/scheme-test.org with the content below:
---8<--
#+BEGIN_SRC scheme :exports results :results output raw
  (display "Hello Scheme in OrgMode")
#+END_SRC
---8<--

and run:

emacs --batch --eval='(load "~/.emacs.d/init.el")' ~/scheme-test.org -f
org-html-export-to-html

you will find the bug:

`org-babel-scheme-execute-with-geiser' uses `current-message' to get the
results of scheme code blocks, but `current-message' always returns nil in
batch mode, and this patch fixes this.

-- 
-- 

KDr2, http://kdr2.com
From cebf9fc4fe09ab22fd31ff8e5606d0f680c121e9 Mon Sep 17 00:00:00 2001
From: KDr2 
Date: Wed, 2 Apr 2014 10:30:38 +0800
Subject: [PATCH] ob-scheme.el: Fix scheme code blocks execution error in batch
 mode

* lisp/ob-scheme.el (org-babel-scheme-capture-current-message, org-babel-scheme-execute-with-geiser): Capture scheme code results via current-message both in interactive mode and noninteractive mode.

`org-babel-scheme-execute-with-geiser' uses `current-message' to get the results of scheme code blocks, but `current-message' always returns nil in batch mode, and this patch fixes this.

Modified from a patch proposal by KDr2
---
 lisp/ob-scheme.el | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el
index b7117e9..3b7ceb2 100644
--- a/lisp/ob-scheme.el
+++ b/lisp/ob-scheme.el
@@ -118,6 +118,17 @@ org-babel-scheme-execute-with-geiser will use a temporary session."
 	   (name
 result))
 
+(defmacro org-babel-scheme-capture-current-message (&rest body)
+  "Capture current message in both interactive and noninteractive mode"
+  `(if noninteractive
+   (let ((current-message nil))
+ (flet ((message (fmt &rest args) (setq current-message (apply #'format fmt args
+   ,@body
+   current-message))
+ (progn
+   ,@body
+   (current-message
+
 (defun org-babel-scheme-execute-with-geiser (code output impl repl)
   "Execute code in specified REPL. If the REPL doesn't exist, create it
 using the given scheme implementation.
@@ -142,10 +153,11 @@ is true; otherwise returns the last value."
 			 (current-buffer)
 	(setq geiser-repl--repl repl-buffer)
 	(setq geiser-impl--implementation nil)
-	(geiser-eval-region (point-min) (point-max))
+	(setq result (org-babel-scheme-capture-current-message
+		  (geiser-eval-region (point-min) (point-max
 	(setq result
-	  (if (equal (substring (current-message) 0 3) "=> ")
-		  (replace-regexp-in-string "^=> " "" (current-message))
+	  (if (and (stringp result) (equal (substring result 0 3) "=> "))
+		  (replace-regexp-in-string "^=> " "" result)
 		"\"An error occurred.\""))
 	(when (not repl)
 	  (save-current-buffer (set-buffer repl-buffer)
-- 
1.9.1



[O] Org-set-repeat

2014-04-01 Thread R. Michael Weylandt
I see that Org provides a `org-cancel-repeater` and `org-get-repeat`
but I don't see a `org-set-repeat` (or function which can be made to
do so). Is there something like that that I've missed or should I
write a wrapper around `org-deadline`?

Michael



Re: [O] Incremental search only within visble text

2014-04-01 Thread Ali Tofigh
Thanks! This is exactly what I was looking for.

/ali

On Tue, Apr 1, 2014 at 5:47 PM, Samuel Wales  wrote:
> (define-key global-map "\C-\M-r" 'alpha-isearch-backward-visible)
> ;; also for dired filename search
> (define-key global-map "\C-\M-s" 'alpha-isearch-visible)
> (defun alpha-isearch-backward-visible ()
>   (interactive)
>   (let ((search-invisible))
> (isearch-backward-regexp)))
> (defun alpha-isearch-visible ()
>   (interactive)
>   (let ((search-invisible))
> ;; notwork
> ;; (call-interactively #'query-replace-regexp)
> (isearch-forward-regexp)))
>
>
> On 4/1/14, Ali Tofigh  wrote:
>> Sometimes I just want to do an incremental search in the visible text
>> of a partially folded org file. In other words, I want the search to
>> ignore text that is invisible due to folding. I know that there is an
>> org-copy-visible command. Is there an equivalent command for
>> searching?
>>
>> /ali
>>
>>
>
>
> --
> The Kafka Pandemic: http://thekafkapandemic.blogspot.com
>
> The disease DOES progress.  MANY people have died from it.  And
> ANYBODY can get it.
>
> Denmark: free Karina Hansen NOW.



Re: [O] Generate a table of contents without exporting

2014-04-01 Thread Nick Dokos
Charles Berry  writes:

> RG Williams  gmail.com> writes:
>
>> 
>> Hi,
>> I know you can generate a table of contents when exporting, but can you do
>> it just within org? For context, I'm uploading an .org file to github and I
>> don't need to export it to another format because github recognizes and
>> displays it just fine. It's long so a ToC would be nice. Do I just have to
>> write it myself?
>> 
>> 
>
> AFAIK, you do have to write it yourself, but org-mode provides decent tools
> for doing it. Here is an example. Run the src-block and a table of contents
> will appear near the top. Change the content and rerun the src-block and
> the t-o-c will change accordingly.
>
> It doesn't deal with rules for omitting headlines like
> COMMENT, :noexport:, etc, but if you are simply copying the .org file,
> maybe it is good enough.
>
>
> #+RESULTS: Table_of_Contents
>
> * h
> lower H
> * i
> lower I
> * j
> lower J
> ** 1
> one
> ** 2
> two
>
> #+NAME: Table_of_Contents
> #+BEGIN_SRC emacs-lisp :wrap example
>   (mapconcat 'identity
>(org-element-map 
>(org-element-parse-buffer 'headline) 'headline 
>  (lambda (hl) (let
>   ((lev
> (org-element-property :level hl)) 
>(htitle (org-element-property :title hl)))
> (concat (make-string  lev ? ) "- " htitle  "\n")
> #+END_SRC
>
>

Another more manual way: export to text and cut-and-paste the TOC into
a noexport top-level section.

Nick




Re: [O] Incremental search only within visble text

2014-04-01 Thread Samuel Wales
(define-key global-map "\C-\M-r" 'alpha-isearch-backward-visible)
;; also for dired filename search
(define-key global-map "\C-\M-s" 'alpha-isearch-visible)
(defun alpha-isearch-backward-visible ()
  (interactive)
  (let ((search-invisible))
(isearch-backward-regexp)))
(defun alpha-isearch-visible ()
  (interactive)
  (let ((search-invisible))
;; notwork
;; (call-interactively #'query-replace-regexp)
(isearch-forward-regexp)))


On 4/1/14, Ali Tofigh  wrote:
> Sometimes I just want to do an incremental search in the visible text
> of a partially folded org file. In other words, I want the search to
> ignore text that is invisible due to folding. I know that there is an
> org-copy-visible command. Is there an equivalent command for
> searching?
>
> /ali
>
>


-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  And
ANYBODY can get it.

Denmark: free Karina Hansen NOW.



[O] Creating changelog with magit

2014-04-01 Thread Thorsten Jolitz

Hi List, 

reading this

,
| http://orgmode.org/worg/org-contribute.html
`

I find:

,---
| If you are using magit.el in Emacs, the ChangeLog for such entries
| are easily produced by pressing C in the diff listing.
`---

but when doing so with point on a staged changed in the magit-status
buffer, I get a meager

,---
| 
| * org.el: 
| 
| # <>
| 
`---

instead of something more useful like this:

,---
| org.el: 
|
| * org.el(foo):
|   (bar):
| * ox.el(doo):
|   (daa):
|   (dee):
| 
| # <>
| 
`---

i.e. magit does not detect which files/definitions have changed and already
offers the template for all changes of the current diff to HEAD.

Am I doing something wrong or is this all there is?

-- 
cheers,
Thorsten





Re: [O] Incremental search only within visble text

2014-04-01 Thread Anthony Lander
Hi Ali,

If you install isearch+ (in elpa) you can toggle invisible text searching
with C-+.

Hope this helps,

 -Anthony


On Tue, Apr 1, 2014 at 3:43 PM, Ali Tofigh  wrote:

> Sometimes I just want to do an incremental search in the visible text
> of a partially folded org file. In other words, I want the search to
> ignore text that is invisible due to folding. I know that there is an
> org-copy-visible command. Is there an equivalent command for
> searching?
>
> /ali
>
>


Re: [O] Generate a table of contents without exporting

2014-04-01 Thread Charles Berry
RG Williams  gmail.com> writes:

> 
> Hi,
> I know you can generate a table of contents when exporting, but can you do
> it just within org? For context, I'm uploading an .org file to github and I
> don't need to export it to another format because github recognizes and
> displays it just fine. It's long so a ToC would be nice. Do I just have to
> write it myself?
> 
> 

AFAIK, you do have to write it yourself, but org-mode provides decent tools
for doing it. Here is an example. Run the src-block and a table of contents
will appear near the top. Change the content and rerun the src-block and
the t-o-c will change accordingly.

It doesn't deal with rules for omitting headlines like
COMMENT, :noexport:, etc, but if you are simply copying the .org file,
maybe it is good enough.


--8<---cut here---start->8---
#+RESULTS: Table_of_Contents

* h
lower H
* i
lower I
* j
lower J
** 1
one
** 2
two

#+NAME: Table_of_Contents
#+BEGIN_SRC emacs-lisp :wrap example
  (mapconcat 'identity
   (org-element-map 
   (org-element-parse-buffer 'headline) 'headline 
 (lambda (hl) (let
  ((lev
(org-element-property :level hl)) 
   (htitle (org-element-property :title hl)))
(concat (make-string  lev ? ) "- " htitle  "\n")
#+END_SRC
--8<---cut here---end--->8---


HTH,

Chuck




Re: [O] `org-attach-file-list' doesn't allow dotfiles

2014-04-01 Thread John Wiegley
No reason I can think of.

John

On Mar 12, 2014, at 1:39 PM, Bastien  wrote:

> Hi Oleh,
> 
> Oleh  writes:
> 
>> I wanted to store this file as an attachment in an org document, so I
>> don't forget about it, but this attachment can't be opened due
>> to `org-attach-file-list` ignoring all files that start with a dot.
> 
> I'm copying John to this email, to see if there is any reason why
> files starting with a dot cannot be attached.
> 
> Otherwise the change looks okay to me.
> 
> Thanks,
> 
> -- 
> Bastien




[O] Is the worg/code/org-info-js page broken?

2014-04-01 Thread Bill Ashmanskas
It seems that the page

http://orgmode.org/worg/code/org-info-js/

doesn't display anything sensible.  There's just a heading and a
non-functioning "Show Org Source" button.  But using links found in other
places, it seems possible to read directly some of the contents:

http://orgmode.org/worg/code/org-info-js/index.org.html

Is org-info.js still supported?  It sounds quite handy.  Is there an online
example somewhere of a page that supports the javascript-based
folding/unfolding of the outline, and various keyboard navigation?

Thanks,
Bill


Re: [O] Is it possible to add a class to a paragraph in HTML export?

2014-04-01 Thread Marcin Borkowski
Dnia 2014-04-01, o godz. 21:37:06
Bastien  napisał(a):

> Hi Marcin,
> 
> Marcin Borkowski  writes:
> 
> > I'd like to have a  in export.  I tried
> > #+ATTR_HTML :class myfunnyclass
> > but it didn't work.
> 
> You can't for now but this patch will make it work.
> 

Wow, thanks a lot?  Any chance this will land in the "official"
Org-mode repo soon?

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



[O] Incremental search only within visble text

2014-04-01 Thread Ali Tofigh
Sometimes I just want to do an incremental search in the visible text
of a partially folded org file. In other words, I want the search to
ignore text that is invisible due to folding. I know that there is an
org-copy-visible command. Is there an equivalent command for
searching?

/ali



Re: [O] Is it possible to add a class to a paragraph in HTML export?

2014-04-01 Thread Bastien
Hi Marcin,

Marcin Borkowski  writes:

> I'd like to have a  in export.  I tried
> #+ATTR_HTML :class myfunnyclass
> but it didn't work.

You can't for now but this patch will make it work.

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index a843441..76472c7 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2899,6 +2899,8 @@ the plist used as a communication channel."
   (let* ((parent (org-export-get-parent paragraph))
 	 (parent-type (org-element-type parent))
 	 (style '((footnote-definition " class=\"footpara\"")))
+	 (class0 (org-export-read-attribute :attr_html paragraph :class))
+	 (class (if class0 (format " class=\"%s\"" class0)))
 	 (extra (or (cadr (assoc parent-type style)) "")))
 (cond
  ((and (eq (org-element-type parent) 'item)
@@ -2925,7 +2927,7 @@ the plist used as a communication channel."
 	(label (org-element-property :name paragraph)))
 	(org-html--wrap-image contents info caption label)))
  ;; Regular paragraph.
- (t (format "\n%s" extra contents)
+ (t (format "\n%s" class extra contents)
 
  Plain List
 

-- 
 Bastien


[O] Is it possible to add a class to a paragraph in HTML export?

2014-04-01 Thread Marcin Borkowski
Hi,

I'd like to have a  in export.  I tried
#+ATTR_HTML :class myfunnyclass
but it didn't work.

Is there any way to do it?

TIA,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



Re: [O] Add TODO from external app?

2014-04-01 Thread Anthony Lander
Hi Lawrence,

Here is a Python script I use to scrape TODOs from emails. I haven't
polished it up and put it on github yet, but you are welcome to give it a
whirl (anyone else is too, obviously). You need python 2.5 or greater to
run this. Configure by modifying the variables at the top of the file.

Carsten: If you think this is a worthwhile addition to contrib,  I am happy
to clean it up, and write a bit of documentation for inclusion with org
mode.

Hope this helps,

  -Anthony



On Tue, Apr 1, 2014 at 11:41 AM, Lawrence Bottorff wrote:

> I've seen various things for interacting with org mode from external apps.
> I found org-protocol, as well as a Mutt-to-org mode article. Per the
> tittle, I want to be able to add new TODO items from, say, an email or a
> PHP-based web page form. Is this just brute force external file
> manipulation, i.e., e.g., my PHP code would simply open a .org file and
> concatenate a properly formatted TODO line . . . or are there more
> sophisticated ways of talking to emacs/org-mode from without?
>
> LB
>
#!/usr/bin/env python

#  todo-email-scraper.py - Watch an email address for TODOs and add them to an org file
#
# Copyright (c) 2014 Free Software Foundation, Inc.
#
# Authors:
#  Anthony Lander 
#
# Version: 1.0
# Keywords: org, todo, email
#
# This file is not part of GNU Emacs.
#
# This program is free software# you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation# either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY# without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Emacs.  If not, see .
#
# Commentary:
#
# - Email subject is the TODO line, and body is the TODO body.
# - Add a property line :TODO-TARGET: true to the parent heading where TODOs should be dropped
# - Configure email address, diary file, password below.
# - You can schedule this to run every 30 minutes in a cron job.

# - The scraper scrapes all emails from a designated address (so only you can
# - send yourself todos). as such, it is best to set up a todo email address to
# - receive only todo emails.


import sys
from os import rename
from datetime import datetime
from string import replace
import imaplib
import StringIO
from email.parser import Parser

# ### Configuration
diary_file = "/path/to/org_file.org"  # Replace with your org file
server = 'imap.gmail.com' # Replace with your imap mail server
username = 'taskl...@gmail.com'   # Replace with the email address that receives todos
password = 'passowrd' # Replace with the password for the above email address
authorized_sender = 'y...@gmail.com'   # Replace with the email address from which you send todos


def is_diary_file_available():
try:
file = open(diary_file, "r")
except IOError:
return False
file.close()
return True


def get_todos():

imap = imaplib.IMAP4_SSL(server)
imap.login(username, password)
imap.select()

search_criteria = '(UNSEEN FROM "' + authorized_sender + '")'
typ, data = imap.search(None, search_criteria)

todos = []
for num in data[0].split():
todo_subject = ""
todo_body = []
typ, data = imap.fetch(num, '(RFC822)')

file = StringIO.StringIO(data[0][1])
message = Parser().parse(file)
todo_subject = message['subject']
#print message['Subject'] + "\n"

body = ""
for part in message.walk():
t = part.get_content_type()
if t and t.lower() == "text/plain":
# Found the first text/plain part 
body = part.get_payload(decode=True)
break

 #   print ">", body, "<"
long_line = ""
for line in [line.strip() for line in body.splitlines() if len(line) > 0]:
if line[-1:] == "=":
long_line += line[:-1]
else:
if len(long_line) > 0:  # There is a long line waiting to be written
#print "long line: ", long_line
todo_body.append(long_line)
long_line = ""
else:
#print "line: ", line
todo_body.append(line)
long_line = ""

if len(long_line) > 0:
#print "long line (final): ", long_line
todo_body.append(long_line)
todos.append({'subject' : todo_subject, 'body' : todo_body})

imap.close()
imap.logout()
return todos


def new_diary_lines_with_todos(todos):
try:
file = open(diary_file, "rt+")
fo

Re: [O] Controlling example block export?

2014-04-01 Thread Charles Berry
Heikki Lehvaslaiho  gmail.com> writes:

> 
> 
> 
> I am using example blocks as inline notes where I paste snippets of 
> (pre-formatted) text. I'd like to  be able to control the exporting of 
> those block individually (per document would also be useful). I do not 
> seem to be able to find documentation about anything along those lines. 
> 
> 
> Here is a mock-up:
> 
> 
> #+BEGIN_EXAMPLE :exports none
> private notes...
> #+END_EXAMPLE
> 
> 

Advise or redefine the org--example-block function to use
:switches to decide whether to skip an example block.

Something like this:

#+BEGIN_SRC emacs-lisp

  (defvar org-example-block-skip ":skip"
"example block :switch to skip.")

  (defun org-latex-example-block (example-block contents info)
  "Transcode an EXAMPLE-BLOCK element from Org to LaTeX.
CONTENTS is nil.  INFO is a plist holding contextual
information."
  (when (and (org-string-nw-p 
  (org-element-property :value example-block))
 (not (string= 
   org-example-block-skip 
   (org-element-property :switches example-block
(org-latex--wrap-label
 example-block
 (format "\\begin{verbatim}\n%s\\end{verbatim}"
 (org-export-format-code-default 
  example-block info)

#+END_SRC

> A bigger question is that while code blocks are well defined and well 
> documented, all other blocks are not. Is there somewhere a design 
> document the would give a logic of having different blocks and how they 
> are controlled? Maybe there is an other type of a block that does what I 
> want?
> 
> 
> The inline documentation in ox*.el files is too low level to be helpful.
> 

See also org-element.el and 
http://orgmode.org/worg/dev/org-export-reference.html

Looking at what (org-element-at-point) returns often helps.

Special blocks are another possibility, but will require some customization.

HTH,

Chuck





[O] Add TODO from external app?

2014-04-01 Thread Lawrence Bottorff
I've seen various things for interacting with org mode from external apps.
I found org-protocol, as well as a Mutt-to-org mode article. Per the
tittle, I want to be able to add new TODO items from, say, an email or a
PHP-based web page form. Is this just brute force external file
manipulation, i.e., e.g., my PHP code would simply open a .org file and
concatenate a properly formatted TODO line . . . or are there more
sophisticated ways of talking to emacs/org-mode from without?

LB


Re: [O] Controlling example block export?

2014-04-01 Thread Nicolas Goaziou
Hello,

Heikki Lehvaslaiho  writes:

> The org-syntax.html says of blocks:
>
> #+BEGIN_NAME PARAMETERS
> CONTENTS
> #+END_NAME
>
> NAME can contain any non-whitespace character.
> PARAMETERS can contain any character other than new line, and can be
> omitted.
> If NAME is "CENTER", it will be a "center block". If it is "QUOTE", it will
> be a "quote block".
> If the block is neither a center block, a quote block or a block
> element,
> it will be a "special block".
>
> That does not seem to be quite true as lisp/org-element.el recognises the
> following blocks (perlregexp: /begin_(\w+)/i):

Have you looked at:

  http://orgmode.org/worg/dev/org-syntax.html#Blocks

> Note: org-syntax.html  needs updating.

Possibly. Where?

> So, to implement parameters for the EXAMPLE block, relevant code has to be
> added to the exporter. That's a nontrivial task to do consistently.

For now, there is no need for that.

> Incidentally, the solution to my immediate problem is the COMMENT block.
> Its contents are completely ignored and not passed to exporters.

This is the purpose of comments.


Regards,

-- 
Nicolas Goaziou



Re: [O] Controlling example block export?

2014-04-01 Thread Nicolas Goaziou
Hello,

Heikki Lehvaslaiho  writes:

> I am using example blocks as inline notes where I paste snippets of
> (pre-formatted) text. I'd like to  be able to control the exporting of
> those block individually (per document would also be useful). I do not seem
> to be able to find documentation about anything along those lines.
>
> Here is a mock-up:
>
> #+BEGIN_EXAMPLE :exports none
> private notes...
> #+END_EXAMPLE

You should use drawers for that. See also `org-export-with-drawers'.


Regards,

-- 
Nicolas Goaziou



Re: [O] Controlling example block export?

2014-04-01 Thread Thorsten Jolitz
Thorsten Jolitz  writes:

> Heikki Lehvaslaiho  writes:
>
>> Unless someone beats me to it, I'll write it one day. :)
>
> What about:
>
> #+begin_src emacs-lisp
>   (defun tj/toggle-example-and-comment-blocks ()
> "Toggle example and comment blocks in current buffer."
> (interactive)
> (org-block-map
>  (lambda ()
>(org-mark-element)
>(when (use-region-p)
>  (let ((beg (region-beginning))
>(end (region-end)))
>(cond
> ((save-excursion
>(re-search-forward "#\\+begin_comment"
>   (line-end-position) 'NOERROR))
>  (replace-string "#+begin_comment" "#+begin_example"
>  nil beg end)
>  (replace-string "#+end_comment" "#+end_example"
>  nil beg end))
> ((save-excursion
>(re-search-forward "#\\+begin_example"
>   (line-end-position) 'NOERROR))
>  (replace-string "#+begin_example" "#+begin_comment"
>  nil beg end)
>  (replace-string "#+end_example" "#+end_comment"
>  nil beg end))
> (t nil))
>(deactivate-mark))
> #+end_src

I should have read the help string of `replace-string' till the end,
because

,---
| This function is usually the wrong thing to use in a Lisp program.
| What you probably want is a loop like this:
|   (while (search-forward FROM-STRING nil t)
| (replace-match TO-STRING nil t))
| which will run faster and will not set the mark or print anything.
`---

Here is the corrected version:

#+begin_src emacs-lisp
  (defun tj/toggle-example-and-comment-blocks ()
"Toggle example and comment blocks in current buffer."
(interactive)
(org-block-map
 (lambda ()
   (org-mark-element)
   (when (use-region-p)
 (let ((end (region-end)))
   (cond
((save-excursion
   (re-search-forward "#\\+begin_comment"
  (line-end-position) 'NOERROR))
 (while (search-forward "#+begin_comment"
(line-end-position) t)
   (replace-match "#+begin_example" nil t))
 (while (search-forward "#+end_comment" end t)
   (replace-match "#+end_example" nil t)))
((save-excursion
   (re-search-forward "#\\+begin_example"
  (line-end-position) 'NOERROR))
 (while (search-forward "#+begin_example"
(line-end-position) t)
   (replace-match "#+begin_comment" nil t))
 (while (search-forward "#+end_example" end t)
   (replace-match "#+end_comment" nil t)))
(t nil))
   (deactivate-mark))
#+end_src


-- 
cheers,
Thorsten




Re: [O] Controlling example block export?

2014-04-01 Thread Thorsten Jolitz
Heikki Lehvaslaiho  writes:

> Unless someone beats me to it, I'll write it one day. :)

What about:

#+begin_src emacs-lisp
  (defun tj/toggle-example-and-comment-blocks ()
"Toggle example and comment blocks in current buffer."
(interactive)
(org-block-map
 (lambda ()
   (org-mark-element)
   (when (use-region-p)
 (let ((beg (region-beginning))
   (end (region-end)))
   (cond
((save-excursion
   (re-search-forward "#\\+begin_comment"
  (line-end-position) 'NOERROR))
 (replace-string "#+begin_comment" "#+begin_example"
 nil beg end)
 (replace-string "#+end_comment" "#+end_example"
 nil beg end))
((save-excursion
   (re-search-forward "#\\+begin_example"
  (line-end-position) 'NOERROR))
 (replace-string "#+begin_example" "#+begin_comment"
 nil beg end)
 (replace-string "#+end_example" "#+end_comment"
 nil beg end))
(t nil))
   (deactivate-mark))
#+end_src


-- 
cheers,
Thorsten




[O] org-dblock-write:myownfunc does not split my window?

2014-04-01 Thread Martin

Hi there:

Using a minimal example:
Creating an org file with somewhere:


#+BEGIN: myownfunc
#+END

And using scratch (or this email) with

(defun org-dblock-write:myownfunc (params)
  (interactive)
  (split-window nil -15)
  (insert "window should be splitted"))

This just inserts the text "window should be splitted" but does not
acutall split my window.

What am I doing wrong?  And how can I make it right?

Thanks,
Martin



[O] problem with call lines with post block that are not exported (elpa org)

2014-04-01 Thread Alan Schmitt
Hello,

I'm writing a paper with some colleagues for a conference, and we've
just stumbled on a strange bug. My colleague is using org from elpa, and
is having the problem, whereas I'm compiling using a very current org
version and everything works for me.

The problem is as follows.

Given this org file (exp.org):

--8<---cut here---start->8---
#+options: toc:nil
#+property: results drawer

#+name: fetch
#+BEGIN_SRC emacs-lisp :results raw :var f="foo" :exports none
f
#+END_SRC

#+name: wrap
#+BEGIN_SRC emacs-lisp :var text="" :results raw :exports none
(concat "#+BEGIN_EXAMPLE\n" text "\n#+END_EXAMPLE")
#+END_SRC

* Test
  :PROPERTIES:
  :post: wrap(text=*this*)
  :END:

Hello world

#+call: fetch("testing")
--8<---cut here---end--->8---

and this initialization file (exp_init.el):

--8<---cut here---start->8---
(setq emacsd-dir "~/.emacs.d/")

(package-initialize)
(require 'org-loaddefs)

(require 'ox-html)

(setq org-confirm-babel-evaluate nil)
--8<---cut here---end--->8---

running this command

emacs --batch -Q -l exp_init.el exp.org -f org-html-export-to-html

yields in my colleague's case the following:

> Loading vc-git...
> executing Emacs-Lisp code block (fetch)...
>
> (f (quote "testing"))
>
> "testing"
> executing Emacs-Lisp code block...
>
> (results (quote "testing"))
> Reference 'wrap' not found in this buffer

The same command works for me (for completeness's sake, here is my
configuration file):

--8<---cut here---start->8---
(setq emacsd-dir "~/.emacs.d/")

(add-to-list 'load-path (concat emacsd-dir "org/emacs/site-lisp/org"))

(require 'ox-html)

(setq org-confirm-babel-evaluate nil)
--8<---cut here---end--->8---

He's using this org version:
Org-mode version 8.2.5h (8.2.5h-94-g91175a-elpa @ 
/Users/pmaksimo/.emacs.d/elpa/org-20140331/)
updated yesterday.

My questions are:
- is there a bug in the ELPA version of org mode?
- is there a workaround? We tried ":exports results" instead of
":exports none" but the blocks are not exported in that case.

Thanks,

Alan



Re: [O] Controlling example block export?

2014-04-01 Thread Heikki Lehvaslaiho
Thanks, Torsten. Very illuminating.


The org-syntax.html says of blocks:


#+BEGIN_NAME PARAMETERS
CONTENTS
#+END_NAME

NAME can contain any non-whitespace character.
PARAMETERS can contain any character other than new line, and can be
omitted.
If NAME is "CENTER", it will be a "center block". If it is "QUOTE", it will
be a "quote block".
If the block is neither a center block, a quote block or a block
element,
it will be a "special block".

That does not seem to be quite true as lisp/org-element.el recognises the
following blocks (perlregexp: /begin_(\w+)/i):

- CENTER
- COMMENT
- EXAMPLE
- QUOTE
- SRC
- VERSE

... in addition to any other valid block names. For these, the content is
displayed as plain text after striping the BEGIN/END lines unless the
exporter used has code for handling it differently.

Note: org-syntax.html  needs updating.

So, to implement parameters for the EXAMPLE block, relevant code has to be
added to the exporter. That's a nontrivial task to do consistently.

Incidentally, the solution to my immediate problem is the COMMENT block.
Its contents are completely ignored and not passed to exporters. If I find
myself using that a lot, a macro or a a function to toggle between these
two might come handy:


#+BEGIN_COMMENT :type EXAMPLE
 text in a  block
#+END_COMMENT

<>

#+BEGIN_ EXAMPLE
 text in a  block
#+END_EXAMPLE

Unless someone beats me to it, I'll write it one day. :)



 -Heikki

Heikki Lehvaslaiho - skype:heikki_lehvaslaiho http://about.me/heikki
cell: +966 545 595 849  office: +966 12 808 2429

Saudi Arabian weekend is now Friday and Saturday.

KAUST Supercomputing Center, Building #1, Level 0, 0203-WS23
4700 King Abdullah University of Science and Technology (KAUST)
Thuwal 23955-6900, Kingdom of Saudi Arabia


On 1 April 2014 13:10, Thorsten Jolitz  wrote:

> Heikki Lehvaslaiho  writes:
>
> > I am using example blocks as inline notes where I paste snippets of
> > (pre-formatted) text. I'd like to be able to control the exporting of
> > those block individually (per document would also be useful). I do not
> > seem to be able to find documentation about anything along those
> > lines.
> >
> > Here is a mock-up:
> >
> > #+BEGIN_EXAMPLE :exports none
> > private notes...
> > #+END_EXAMPLE
>
> I don't think example blocks take arguments. You might try
>
> #+BEGIN_SRC org :exports none
>  private notes...
> #+END_SRC
>
> or collect these example blocks in subtrees with export tags/properties.
>
> > A bigger question is that while code blocks are well defined and well
> > documented, all other blocks are not. Is there somewhere a design
> > document the would give a logic of having different blocks and how
> > they are controlled? Maybe there is an other type of a block that does
> > what I want?
> > The inline documentation in ox*.el files is too low level to be
> > helpful.
>
> AFAIK export of these block types is backend specific, e.g. ox-ascii.el
> might treat example block different than ox-html.el, so thats where to
> look.
>
> ,---
> | C-h v org-export-with- TAB
> `---
>
> gives some hints too. Using drawers instead of example blocks would
> enable you to toggle export documentwise.
>
> I asked a similar 'bigger' question before, and remember that the answer
> was more or less 'the block name says it all'.
>
> However, here is a (dense) description of the org syntax:
>
> ,
> | http://orgmode.org/worg/dev/org-syntax.html
> `
>
> --
> cheers,
> Thorsten
>
>
>


Re: [O] Possible regexp bug in org.el

2014-04-01 Thread Nicolas Richard
Thorsten Jolitz  writes:
> here is a possible regexp bug in org.el I discovered by accident:
>
> ,-
> | 7734:   (and (not (looking-back "^\*+"))
> `-

It's almost certainly a typo, but it introduces no bug because '*' can't
bear its special meaning after '^', so the regexp engine will make it
match exactly the '*' character. But it'd be better written as "^*+"
(but this is not recommended) or, preferably, "^\\*+" indeed.

Here's the relevant manual excerpt from (info "(elisp) Regexp Special") :

>*Please note:* For historical compatibility, special characters are
> treated as ordinary ones if they are in contexts where their special
> meanings make no sense.  For example, `*foo' treats `*' as ordinary
> since there is no preceding expression on which the `*' can act.  It is
> poor practice to depend on this behavior; quote the special character
> anyway, regardless of where it appears.

-- 
Nico.



Re: [O] Controlling example block export?

2014-04-01 Thread Thorsten Jolitz
Heikki Lehvaslaiho  writes:

> I am using example blocks as inline notes where I paste snippets of
> (pre-formatted) text. I'd like to be able to control the exporting of
> those block individually (per document would also be useful). I do not
> seem to be able to find documentation about anything along those
> lines. 
>
> Here is a mock-up:
>
> #+BEGIN_EXAMPLE :exports none
> private notes...
> #+END_EXAMPLE

I don't think example blocks take arguments. You might try 

#+BEGIN_SRC org :exports none
 private notes...
#+END_SRC

or collect these example blocks in subtrees with export tags/properties.

> A bigger question is that while code blocks are well defined and well
> documented, all other blocks are not. Is there somewhere a design
> document the would give a logic of having different blocks and how
> they are controlled? Maybe there is an other type of a block that does
> what I want?
> The inline documentation in ox*.el files is too low level to be
> helpful.

AFAIK export of these block types is backend specific, e.g. ox-ascii.el
might treat example block different than ox-html.el, so thats where to
look. 

,---
| C-h v org-export-with- TAB
`---

gives some hints too. Using drawers instead of example blocks would
enable you to toggle export documentwise.

I asked a similar 'bigger' question before, and remember that the answer
was more or less 'the block name says it all'.

However, here is a (dense) description of the org syntax:

,
| http://orgmode.org/worg/dev/org-syntax.html
`

-- 
cheers,
Thorsten




[O] Possible regexp bug in org.el

2014-04-01 Thread Thorsten Jolitz

Hi List, 

here is a possible regexp bug in org.el I discovered by accident:

,-
| 7734:   (and (not (looking-back "^\*+"))
`-

#+begin_src emacs-lisp
(and (not (looking-back "^\*+")) ; missing backslash?
 (looking-at "[ \t]+") (replace-match ""))
(unless (eobp) (forward-char 1))
(when (looking-at "^\\*")
#+end_src

-- 
cheers,
Thorsten




[O] Controlling example block export?

2014-04-01 Thread Heikki Lehvaslaiho
I am using example blocks as inline notes where I paste snippets of
(pre-formatted) text. I'd like to  be able to control the exporting of
those block individually (per document would also be useful). I do not seem
to be able to find documentation about anything along those lines.

Here is a mock-up:

#+BEGIN_EXAMPLE :exports none
private notes...
#+END_EXAMPLE

A bigger question is that while code blocks are well defined and well
documented, all other blocks are not. Is there somewhere a design document
the would give a logic of having different blocks and how they are
controlled? Maybe there is an other type of a block that does what I want?

The inline documentation in ox*.el files is too low level to be helpful.


 -Heikki

Heikki Lehvaslaiho - skype:heikki_lehvaslaiho http://about.me/heikki
cell: +966 545 595 849  office: +966 12 808 2429

Saudi Arabian weekend is now Friday and Saturday.

KAUST Supercomputing Center, Building #1, Level 0, 0203-WS23
4700 King Abdullah University of Science and Technology (KAUST)
Thuwal 23955-6900, Kingdom of Saudi Arabia


Re: [O] New headline after no content (empty headline)

2014-04-01 Thread Brady Trainor


On 3/30/2014 10:55 PM, Bastien wrote:

Hi Brady,

Brady Trainor  writes:


For `org-insert-heading' (M-RET), I wanted the following action on empty
headlines:

"* " |--> "* \n* ", rather than "*\n* ".


I'm not sure I understand this, can you make it more explicit?

Thanks!



I mean that if I use org-insert heading on an empty headline, it removes 
the space after asterisk(s). This then means that what was previously an 
empty heading (with a space), becomes just asterisk(s) no longer 
interpreted by org-mode as a heading.


I concluded that the space was removed by 
org-N-empty-lines-before-current function, where `(unless (looking-back 
"\* \n")...` prevents `org-N-...` from removing that space.


Thank you,

Brady



Re: [O] Get counting of items

2014-04-01 Thread Thorsten Jolitz
Martin Gross  writes:

> Dear helpers,
>
> I would like to get a counting of the first level items in a buffer
> (or even better in a region).  Since I‘m not a programmer I tried
> this, which doesn‘t work:
>
> (defun org-items-counting ()
>   "Print a message with the counting of the first level outline items
> in the current buffer"
>   (interactive)
>   (save-excursion
>  (goto-char (point-min))
>  (message "Counting of first level outline items: %d"
> (count-matches "\n* "
>
> Probably there is a very much better approaching to this problem.
> Could please somebody help me?

This should work, although its a bit funny (you can wrap it in an
interactive command like above):

#+begin_src emacs-lisp
  (with-current-buffer "my.org"
(eval (append (list '+)
  (org-map-entries
   (lambda () (if (eq (org-outline-level) 1) 1 0))
#+end_src

or rather something like this:

#+begin_src emacs-lisp
  (with-current-buffer "my.org"
(let ((count 0))
  (goto-char (point-min))
  (while (re-search-forward "^\\* " nil 'noerror)
(setq count (1+ count)))
  count))
#+end_src

-- 
cheers,
Thorsten




[O] Get counting of items

2014-04-01 Thread Martin Gross
Dear helpers,

I would like to get a counting of the first level items in a buffer
(or even better in a region).  Since I‘m not a programmer I tried
this, which doesn‘t work:

(defun org-items-counting ()
  "Print a message with the counting of the first level outline items
in the current buffer"
  (interactive)
  (save-excursion
 (goto-char (point-min))
 (message "Counting of first level outline items: %d"
(count-matches "\n* "

Probably there is a very much better approaching to this problem.
Could please somebody help me?

Thanks in advance,

Martin



[O] Can ELPA package split contrib part?

2014-04-01 Thread Satoru KURASHIKI
hi,

While I use "org-plus-contrib" package from orgmode ELPA,
With other package which requires (updated) "org", it isn't
recognized as I expect.

So, I'm glad if orgmode ELPA provides:
- org
- org-contrib (requires "org")

regards,
-- 
KURASHIKI Satoru