Re: [O] Bug: finding close tasks has infinite loop [9.0.5 (release_9.0.5-433-ge65be5 @ /home/hs/.emacs.d/git/org-mode/lisp/)]

2017-04-25 Thread Nicolas Goaziou
Hello,

"Stefan-W. Hahn"  writes:

> Mail von Stefan-W. Hahn, Fri, 07 Apr 2017 at 09:39:30 +0200:
>
> Hello,
>
> I tried an instrumented version with code below and got an hint where the
> time get consumed.
>
>> #+BEGIN_QUOTE
>> ** DONE Task 
>> :@status:
>> CLOSED: [2017-02-17 Fr 14:08]
>>:CLOCK:
>>CLOCK: [2016-03-07 Mo 12:58]--[2016-03-07 Mo 14:09] =>  1:11
>
> 979 CLOCK lines, gives 1958 org-time entries.
>
>>CLOCK: [2011-09-26 Mo 13:02]--[2011-09-26 Mo 13:48] =>  0:46
>>:END:
>>Added: [2011-09-26 Mo]
>> 
>> #+END_QUOTE
>> 
>
> With following code I let it run. It came to an end after 119 seconds:
>
> #+BEGIN_SRC emacs-lisp
>
> (defmacro profile-org (times  body)
> `(let (output)
>(dolist (p '("org-"))  ; symbol prefixes to instrument
>  (elp-instrument-package p))
>(dotimes (x ,times)
>  ,@body)
>(elp-results)
>(elp-restore-all)
>(point-min)
>(forward-line 20)
>(delete-region (point) (point-max))
>(setq output (buffer-substring-no-properties (point-min) (point-max)))
>(kill-buffer)
>(delete-window)
>output))
>
> (let ((org-agenda-files
>'("~/notes/bug/test.org")))
>   (profile-org 1
>(org-tags-view nil "+CLOSED<=\"<-1m>\"")))
> #+END_SRC
>
>
> This is the elp-result:
>
> #+BEGIN_QUOTE
>
> Back to top level
> org-tags-view 1   
> 119.90470040  119.90470040
> org-scan-tags 1   
> 119.89504432  119.89504432
> org-entry-properties  2   
> 119.89459378  59.947296892
> org-cached-entry-get  1   
> 119.89455419  119.89455419
> org-element-context   1959
> 119.88264565  0.0611958374
> org-element-at-point  1959
> 119.87516006  0.0611920163
> org-element--parse-to 1959
> 119.61624070  0.0610598472
> org-element--current-element  963339  
> 106.53174518  0.0001105859
> org-element-clock-parser  959420  
> 77.279206300  8.054...e-05
> org-element-timestamp-parser  961380  
> 60.700601205  6.313...e-05
> org-parse-time-string 1920801 
> 32.491741821  1.691...e-05
> org-get-limited-outline-regexp969216  
> 10.924480618  1.127...e-05
> org-at-heading-p  967259  
> 4.0055616979  4.141...e-06
> org-element--cache-put963339  
> 2.1260797540  2.206...e-06
> org-element-drawer-parser 1959
> 0.5903366010  0.0003013458
> org-element-planning-parser   1959
> 0.0443325489  2.263...e-05
> org-element--collect-affiliated-keywords  1960
> 0.0102636800  5.236...e-06
> org-agenda-prepare1   
> 0.008041049   0.008041049
> org-agenda-mode   1   
> 0.002911944   0.002911944
> org-agenda-prepare-buffers1   
> 0.002577423   0.002577423
>
> #+END_QUOTE
>
> It gives an amazing number of calles to org-parse-time-string, around 981
> calls or each org-timestamp.

This is not that amazing. Each `org-element-clock-parser' calls
`org-parse-time-string' twice.

Anyway, this probably happens because parsing an element starts from the
headline, so parsing multiple elements has a quadratic behaviour.

You may want to try to activate the cache. See `org-element-use-cache'
docstring, though.

Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] org-agenda: Store stuck project redo command

2017-04-25 Thread Nicolas Goaziou
Hello,

Allen Li  writes:

> * lisp/org-agenda.el (org-agenda-list-stuck-projects): Store the redo
> command in a text property so it is found correctly.
>
> `org-agenda-redo' checks the `org-redo-cmd' text property, not
> `org-agenda-redo-command'.
>
> TINYCHANGE

Applied. Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] org refile completion for won't use ido

2017-04-25 Thread Joel Walker
Sorry for the noise, but I missed the note in the release about
org-completion-use-id. Ignore - I'll look into adjusting my init for the
the change.

On Tue, Apr 25, 2017 at 12:17 PM Joel Walker  wrote:

> When using org-refile, I'm accustom to getting ido completion when
> selecting a target due to the customizations in my init below. In org-mode
> release 9.0.5, the minibuffer won't ido for an org-refile. Ido works
> otherwise. There isn't an error, and refiling still works; ido completion
> is just missing. I changed to org-mode release 8.3.6, things work as
> expected.
>
>
> ; Use full outline paths for refile targets - we file directly with IDO
> (setq org-refile-use-outline-path t)
>
> ; Targets complete directly with IDO
> (setq org-outline-path-complete-in-steps nil)
>
> ; Allow refile to create parent tasks with confirmation
> (setq org-refile-allow-creating-parent-nodes (quote confirm))
>
> ; Use IDO for both buffer and file completion and ido-everywhere to t
> (setq org-completion-use-ido t)
> (setq ido-everywhere t)
> (setq ido-max-directory-size 10)
> (ido-mode (quote both))
> ; Use the current window when visiting files and buffers with ido
> (setq ido-default-file-method 'selected-window)
> (setq ido-default-buffer-method 'selected-window)
> ; Use the current window for indirect buffer display
> (setq org-indirect-buffer-display 'current-window)
>
>  Refile settings
> ; Exclude DONE state tasks from refile targets
> (defun bh/verify-refile-target ()
>   "Exclude todo keywords with a done state from refile targets"
>   (not (member (nth 2 (org-heading-components)) org-done-keywords)))
>
> (setq org-refile-target-verify-function 'bh/verify-refile-target)
>


[O] org refile completion for won't use ido

2017-04-25 Thread Joel Walker
When using org-refile, I'm accustom to getting ido completion when
selecting a target due to the customizations in my init below. In org-mode
release 9.0.5, the minibuffer won't ido for an org-refile. Ido works
otherwise. There isn't an error, and refiling still works; ido completion
is just missing. I changed to org-mode release 8.3.6, things work as
expected.


; Use full outline paths for refile targets - we file directly with IDO
(setq org-refile-use-outline-path t)

; Targets complete directly with IDO
(setq org-outline-path-complete-in-steps nil)

; Allow refile to create parent tasks with confirmation
(setq org-refile-allow-creating-parent-nodes (quote confirm))

; Use IDO for both buffer and file completion and ido-everywhere to t
(setq org-completion-use-ido t)
(setq ido-everywhere t)
(setq ido-max-directory-size 10)
(ido-mode (quote both))
; Use the current window when visiting files and buffers with ido
(setq ido-default-file-method 'selected-window)
(setq ido-default-buffer-method 'selected-window)
; Use the current window for indirect buffer display
(setq org-indirect-buffer-display 'current-window)

 Refile settings
; Exclude DONE state tasks from refile targets
(defun bh/verify-refile-target ()
  "Exclude todo keywords with a done state from refile targets"
  (not (member (nth 2 (org-heading-components)) org-done-keywords)))

(setq org-refile-target-verify-function 'bh/verify-refile-target)


Re: [O] org capture properties from a list of strings?

2017-04-25 Thread Nicolas Goaziou
Hello,

Xebar Saram  writes:

> thx Nicolas
>
> really appreciate your answer! though im very week in coding so im
> struggling to understand. but perhaps an example will help. the following
> is a part of my capture:
>
> (add-to-list 'org-capture-templates
> '("ff" "Food"
> entry
> (file+headline (concat pmm "/org/files/agenda/food.org") "Inbox")
> "* COOK %^{Recipe Name}
> :PROPERTIES:
> :ID: %(org-id-uuid)
> :Time: %^{minutes|-|10|15|30|60}
> :Rating: %^{rating?|-|1|2|3|4|5}
> :Source:  %x
> :Cuisine:
> %^{Cuisine?|-|Indian|Thai|Vietnamese|Asian|Chinese|Israeli|Italian|American|EastEuro|Mexican|French|Persian|Austrian}
> :Type: %^{Type?|-|main|side|starter|sweets|drinks|sauce|breakfast}
> :Main.ing:
>  %^{main.ing?|-|chicken|beef|potatos|fish|seafood|shrimp|rice|pasta|fruit}
> :Serves: %^{Serves?|-|1|2|4|6|8}
> :END:
>
> %^{prompt|*** Ingredients}
> %?
> %^{prompt|*** Preparation}
>
> "
> "Capture Template for food recipe"
> ))
>
>
> so do i need a separate  mapconcat #'number-to-string for each property
> value (time,type etc?)

Yes, you do. However, #'number-to-string is only useful if you're
inserting numbers. I think you can use the more general
#'prin1-to-string everywhere instead, e.g.,

  (mapconcat #'prin1-to-string '(Indian Thai Vietnamese Asian Chinese) "|")

or even, using strings

  (mapconcat #'identity '("Indian" "Thai" "Vietnamese" "Asian" "Chinese") "|")

> and how dows the %s know which mapconcat command to refer to?

The are processed by order. The first "%s" refers to the first
mapconcat, the second "%s" to the second mapconcat, and so on...

Regards,

-- 
Nicolas Goaziou0x80A93738



Re: [O] org capture properties from a list of strings?

2017-04-25 Thread Xebar Saram
thx Nicolas

really appreciate your answer! though im very week in coding so im
struggling to understand. but perhaps an example will help. the following
is a part of my capture:

(add-to-list 'org-capture-templates
'("ff" "Food"
entry
(file+headline (concat pmm "/org/files/agenda/food.org") "Inbox")
"* COOK %^{Recipe Name}
:PROPERTIES:
:ID: %(org-id-uuid)
:Time: %^{minutes|-|10|15|30|60}
:Rating: %^{rating?|-|1|2|3|4|5}
:Source:  %x
:Cuisine:
%^{Cuisine?|-|Indian|Thai|Vietnamese|Asian|Chinese|Israeli|Italian|American|EastEuro|Mexican|French|Persian|Austrian}
:Type: %^{Type?|-|main|side|starter|sweets|drinks|sauce|breakfast}
:Main.ing:
 %^{main.ing?|-|chicken|beef|potatos|fish|seafood|shrimp|rice|pasta|fruit}
:Serves: %^{Serves?|-|1|2|4|6|8}
:END:

%^{prompt|*** Ingredients}
%?
%^{prompt|*** Preparation}

"
"Capture Template for food recipe"
))


so do i need a separate  mapconcat #'number-to-string for each property
value (time,type etc?)

and how dows the %s know which mapconcat command to refer to?

thx alot again

Z


On Tue, Apr 25, 2017 at 11:00 AM, Nicolas Goaziou 
wrote:

> Hello,
>
> Xebar Saram  writes:
>
> > kinda stuck with this and cant find any documentation. would also be glad
> > to know its not possible so i can perhaps explore another method :)
> >
> > im basically wondering if instead of manually imputing string separated
> > with | in the  : %^{} capture template i can provide a lisp way to send a
> > pre defined list of strings ("a" "b" "c") etc.. anyone has any clue?
>
> Since it is pre-defined, you can do the following during capture
> definition
>
>   (format "* Headline
>   :PROPERTIES:
>   :Time: %%^{minutes|-|%s}
>   :Rating: %%^{rating?|-|%s}
>   :END:"
>   (mapconcat #'number-to-string '(10 15 30 60) "|")
>   (mapconcat #'number-to-string '(1 2 3 4 5) "|"))
>
> Can't you?
>
> Regards,
>
> --
> Nicolas Goaziou
>


[O] displaying thumbnails in heading or subheadings

2017-04-25 Thread cédric ody
Hi everyone,

I'd like to be able to display thumbnails of images in headlines.

Assume I define a ICON property with the path to a thumbnail. For instance

* Emacs heading
  :PROPERTIES:
  :ICON:  /tmp/emacs.png
  :END:

I have been able to get some results with the following code

#+BEGIN_SRC elisp
(defun my-function ()
  "comment"
  (interactive)
  (save-excursion
(org-with-limited-levels (org-map-tree 'my_subfunction)))
  (org-fix-position-after-promote))
(defun my_subfunction ()
"comment"
  (org-with-wide-buffer
   (org-back-to-heading t)
   (let ((e (org-element-at-point)))
   (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))
(insert-image (create-image (org-element-property :ICON e))
#+END_SRC

There are two issues I'd like to solve:

- when the document is saved and re-opened, a blank space has
substituted the thumbnail.
- is it possible to control the appearance or not of thel thumbnails
of all headlinesin one command?

Thanks,

cedric



Re: [O] org-clock-report/org-create-dblock breaks drawers with point on headine?

2017-04-25 Thread Nicolas Goaziou
Hello,

Adam Porter  writes:

> I feel like I must be missing something obvious, but doesn't
> org-clock-report, which calls org-create-dblock, break drawers and
> planning lines when it's called with point on a heading?  It inserts the
> clocktable above the existing drawers and planning line, making them
> invalid.

That's true, but so does `org-insert-drawer', for example. 

I'm not a big fan of preventing users from shooting them on the foot.
Nevertheless, there are three possibilities to consider:

1. insert the dynamic block (or the drawer) at point, or below if it
   would break planning line or property drawer;

2. raise an error when we try to insert it where it would break planning
   line or property drawer;

3. insert it at point. Let the user sort it out as they know better than
   us what they want.

Option 3 is already implemented (or is it a non-implementation?).

Regards,

-- 
Nicolas Goaziou



Re: [O] How to use :prologue with latex

2017-04-25 Thread Jérémie Juste
Hello,

Many thanks to you,

Best wishes,
Jeremie



On Mon, Apr 24, 2017 at 6:43 PM, Charles C. Berry  wrote:

> On Mon, 24 Apr 2017, Jeremie Juste wrote:
>
>
>>
>> Hello,
>>
>> I would like to use :prologue  and epilogue with latex output when using
>> R. Would it be possible to do something like the following?
>>
>>
> [...]
>
>> #+BEGIN_SRC R :results output latex :prologue \\begin{table} :epilogue
>> \\end{table} [...]
>>
>
> [...]
>
>
> Sure. But you do not need to; see my comment at bottom.  Try this:
>
> #+NAME: test1123
> #+HEADER: :prologue cat("\\begin{table}\n")
> #+HEADER: :epilogue cat("\\end{table}\n")
> #+BEGIN_SRC R :results output latex  :session *R* :dir tmp :cache no
> require(xtable)
> print(xtable(data.frame(a=rnorm(10),b=letters[1:10])),floati
> ng.environment=FALSE)
> #+END_SRC
>
> You might be better off using the :post header arg.
>
> Define a src block like this:
>
> #+name: add-table-env
> #+BEGIN_SRC emacs-lisp
> (format "\\begin{table}\n%s\n\\end{table}\n" *this*)
> #+END_SRC
>
> Then use
>
> #+HEADER: :post add-table-env()
>
> in place of the two header lines above.  The advantage is that you can if
> you want do more complicated moidification of the result.
>
> 
>
> AFAIK, LaTeX has no FALSE environment.
>
> I think what you actually wanted was *not* :prologue and :epilogue but
> this R code:
>
> #+begin_src R
> print(xtable(data.frame(a=rnorm(10),b=letters[1:10])),floati
> ng.environment="table")
> #+end_src
>
>
> HTH,
>
> Chuck
>
>
>
>


-- 
Jérémie Juste


[O] org-clock-report/org-create-dblock breaks drawers with point on headine?

2017-04-25 Thread Adam Porter
I feel like I must be missing something obvious, but doesn't
org-clock-report, which calls org-create-dblock, break drawers and
planning lines when it's called with point on a heading?  It inserts the
clocktable above the existing drawers and planning line, making them
invalid.

Using Emacs 25.1 with Org 9.0.5.  Thanks.




Re: [O] [PATCH] ob-C.el: Fix command to perform on remote host

2017-04-25 Thread Nicolas Goaziou
Hello,

Иван Трусков  writes:

> * lisp/ob-C.el (org-babel-C-execute): Made sure name of compiled
> program is converted to local representation before sending it to the
> shell on remote host.
>
> The problem was when one would try to evaluate C source code block in
> the file on remote host. Compilation would go normally, then
> evaluation will fail with error like "/bin/sh: unable to find file
> prevents that.
>
> TINYCHANGE

Applied. Thank you.

> +  (concat (org-babel-process-file-name tmp-bin-file) cmdline))

I made that change at `tmp-bin-file' binding instead.

Regards,

-- 
Nicolas Goaziou



Re: [O] org capture properties from a list of strings?

2017-04-25 Thread Nicolas Goaziou
Hello,

Xebar Saram  writes:

> kinda stuck with this and cant find any documentation. would also be glad
> to know its not possible so i can perhaps explore another method :)
>
> im basically wondering if instead of manually imputing string separated
> with | in the  : %^{} capture template i can provide a lisp way to send a
> pre defined list of strings ("a" "b" "c") etc.. anyone has any clue?

Since it is pre-defined, you can do the following during capture
definition

  (format "* Headline
  :PROPERTIES:
  :Time: %%^{minutes|-|%s}
  :Rating: %%^{rating?|-|%s}
  :END:"
  (mapconcat #'number-to-string '(10 15 30 60) "|")
  (mapconcat #'number-to-string '(1 2 3 4 5) "|"))

Can't you?

Regards,

-- 
Nicolas Goaziou



Re: [O] org capture properties from a list of strings?

2017-04-25 Thread Xebar Saram
Hi again all

kinda stuck with this and cant find any documentation. would also be glad
to know its not possible so i can perhaps explore another method :)

im basically wondering if instead of manually imputing string separated
with | in the  : %^{} capture template i can provide a lisp way to send a
pre defined list of strings ("a" "b" "c") etc.. anyone has any clue?

best

Z

On Sun, Apr 23, 2017 at 5:41 PM, Xebar Saram  wrote:

> Hi all
>
> so i currently have this in my capture templates
>
>
> :PROPERTIES:
> :Time: %^{minutes|-|10|15|30|60}
> :Rating: %^{rating?|-|1|2|3|4|5}
> :END:
>
> i was wondering if instead of manually putting the values in each line i
> can perhaps supply a list like this
>
>
> (defun returns-a-list-of-strings2
> ()
> (list  "1" "2" "3" "4" "5" ))
>
> is that somehow possible where i could have something like this
>
>
> :Rating: %^{rating?|(returns-a-list-of-strings2)}
>
> is that possible at all?
>
> best
>
> Z
>