[O] Oas: a small addon to Org Mode to automatically close tasks with statistics

2019-08-30 Thread Andrea Giugliano
Hi,

I recently landed on this conversation:
https://lists.gnu.org/archive/html/emacs-orgmode/2010-03/msg00802.html

Since I find myself quite often in a situation like the following:

* TODO abc [3/3]
- [X] a
- [X] b
- [X] c

I decided to dive more into Org's API, and I created this library [0] to
automatically moving that task to DONE. My library checks that when you
are in a situation like:

* TODO abc [1/1]
- [X] a

** TODO b

the parent task does not swap to DONE because there is still a sub-task
to complete.

Tasks that have heading like

* abc [0/1]

or

* TODO abc

do NOT get updated, because I want this to work only for TODO that have
statistics.

How could I propose this as an add-on of Org Mode? Do you think it is
worth the effort?

Any feedback is very welcome to learn more :)

Best,

Andrea

[0] https://github.com/ag91/org-active-statistics



[O] Suggestion for note capture

2019-05-11 Thread Andrea Giugliano
Hi Nathan,

I think I have a starting point for you:

--
(defun ag/org-add-note-to-last-entry ()
  "Add a note to the main agenda file under the latest visited
heading (untested in case the org buffer is not available)"
  (interactive)
  (let ((buffer (car (org-buffer-list 'files 't
(with-current-buffer buffer
  (org-add-note)
  (message "%S" (concat "Adding note in heading: " (fifth 
(org-heading-components)))
---

This function adds a note to the last heading you were editing before
switching file. It is limited to the first file in your
"org-buffer-list" (so does not work if you have multiple org files from
which you generate your agenda).

I imagine you could extend this by choosing the file that has a clock
open (i.e., you need to change the "buffer" binding accordingly), move
to the clocked heading (i.e., add some logic before "org-add-note") and
pointing to the subheading (i.e., again adding some logic before
"org-add-note").

Hope this gives you a lead.

Best,

Andrea


Re: [O] Org mode repeated dates to do spaced learning

2019-01-06 Thread Andrea Giugliano
Hi there,

That was a very helpful suggestion. At the bottom of the mail I attached
my first (working) stab at it.

The idea is to have an headline with the :spaced: tag and another tag
maintaining the number of repetition performed so far. At the beginning
I was thinking to use scheduled times instead of a "counter" tag, but it
was not worth the complexity of the code.

If anybody else finds this feature useful, what would be the best way
to share this?

#+begin_src elisp
(defun my/space-repeat-if-tag-spaced (e)
  "Resets the header on the TODO states and increases the scheduled date
according to a suggested spaced repetition interval."
  (let* ((spaced-rep-map '((0 . "++1d")
  (1 . "++2d")
  (2 . "++10d")
  (3 . "++30d")
  (4 . "++60d")
  (5 . "++4m")))
 (spaced-key "spaced")
 (tags (org-get-tags nil t))
 (spaced-todo-p (member spaced-key tags))
 (repetition-n (first (cdr spaced-todo-p)))
 (n+1 (if repetition-n (+ 1 (string-to-number (substring repetition-n 
(- (length repetition-n) 1) (length repetition-n 0))
 (spaced-repetition-p (alist-get n+1 spaced-rep-map))
 (new-repetition-tag (concat "repetition" (number-to-string n+1)))
 (new-tags (reverse (if repetition-n
(seq-reduce
 (lambda (a x) (if (string-equal x 
repetition-n) (cons new-repetition-tag a) (cons x a)))
 tags
 '())
  (seq-reduce
   (lambda (a x) (if (string-equal x spaced-key) 
(cons new-repetition-tag (cons x a)) (cons x a)))
   tags
   '())
(if (and spaced-todo-p spaced-repetition-p)
  (progn
  ;; avoid infinitive looping
  (remove-hook 'org-trigger-hook 'my/space-repeat-if-tag-spaced)
  ;; reset to previous state
  (org-call-with-arg 'org-todo 'left)
  ;; schedule to next spaced repetition
  (org-schedule nil (alist-get n+1 spaced-rep-map))
  ;; rewrite local tags
  (org-set-tags new-tags)
  (add-hook 'org-trigger-hook 'my/space-repeat-if-tag-spaced))
)))

(add-hook 'org-trigger-hook 'my/space-repeat-if-tag-spaced)
#+end_src


Thanks,

Andrea




On Wed 02 Jan 2019 at 05:59, Marcin Borkowski  wrote:

> On 2019-01-01, at 17:34, Andrea Giugliano  wrote:
>
>> Hi,
>>
>> Thanks for your reply. You are right org-drill does spaced repetition. I
>> just was unclear: I would like to see that in the agenda as a normal
>> item (that gets space-repeated every time I mark it DONE though).
>> I could not get from the docs if org-drill does that.
>
> That is an interesting idea.  I am pretty sure you could make it happen
> with `org-trigger-hook' or `org-after-todo-state-change-hook' (I am not
> entirely sure why both exist, btw).
>
>> Thanks,
>>
>> Andrea
>
> Hth,



Re: [O] Org mode repeated dates to do spaced learning

2019-01-01 Thread Andrea Giugliano
Hi,

Thanks for your reply. You are right org-drill does spaced repetition. I
just was unclear: I would like to see that in the agenda as a normal
item (that gets space-repeated every time I mark it DONE though).
I could not get from the docs if org-drill does that.

Thanks,

Andrea

On Tue 01 Jan 2019 at 16:39, Bingo  wrote:

> Le 1 janvier 2019 18:02:31 GMT+05:30, Andrea Giugliano  a 
> écrit :
>>Happy 2019 everyone!
>>
>>I would like to slightly change my learning method this year. I have
>>heard that spaced learning is much better than bang your head against
>>the same material multiple times in a row.
>>
>>Spaced learning is simply reviewing some interesting topic at given
>>intervals: after 1 day, 1 week, 2 weeks, 1 month, 3 months, etc...
>>
>>It seems to me that org-mode does not support this: how would you make
>>a
>>repetitive task with spaced intervals?
>>
>>I saw org-drill.el, but I do not think it does this.
>>Ideally I could do something like:
>>
>>""
>>* review this interesting thing
>>SCHEDULED: <2019-01-01 Tue>
>>:PROPERTIES:
>>:SPACED:
>>:END:
>>""
>>
>>If this is not an interesting use case for org-mode, what do you think
>>about me trying to extend org-habits.el instead?
>>
>>Best wishes to all the community,
>>
>>Andrea
>
> Hi,
>Why do you think org-drill doesn't do spaced repetition ? I used it for a 
> while in 2017, and it does. I've since moved to Anki on Android phone for the 
> same purpose, because phones are accessible for longer, but was happy with 
> org-drill.


[O] Org mode repeated dates to do spaced learning

2019-01-01 Thread Andrea Giugliano
Happy 2019 everyone!

I would like to slightly change my learning method this year. I have
heard that spaced learning is much better than bang your head against
the same material multiple times in a row.

Spaced learning is simply reviewing some interesting topic at given
intervals: after 1 day, 1 week, 2 weeks, 1 month, 3 months, etc...

It seems to me that org-mode does not support this: how would you make a
repetitive task with spaced intervals?

I saw org-drill.el, but I do not think it does this.
Ideally I could do something like:

""
* review this interesting thing
SCHEDULED: <2019-01-01 Tue>
:PROPERTIES:
:SPACED:
:END:
""

If this is not an interesting use case for org-mode, what do you think
about me trying to extend org-habits.el instead?

Best wishes to all the community,

Andrea



[O] Literate programming: Org mode and Scala

2018-09-09 Thread Andrea Giugliano
Hi everybody,

TL;DR: org mode literate programming does not work easily with the current
scala-mode, there are options to work around this: are the org-mode
maintainers still okay with scala-mode depending on ensime?


Thanks so much for org-mode: the more I use it the more I appreciate the
effort you have put into it!

I am working with Scala and I like to test out things using a literate
programming style. Apparently org-mode decided to offload the scala-mode
to the Ensime maintainers. For this reason there is no straightforward
(at least not to me) support to run code blocks on the fly.

I have opened an issue about this [0], but the Ensime/scala-mode
community does not seem active (at least this pull request did not
receive any comment yet [1]).

For those who are struggling I have created a little of code to make
easy to work with Scala and org-mode [2].

I wonder: is the org-mode community planning to make scala-mode work in
a literate way without workarounds?

Thanks,

Andrea

[0] https://github.com/ensime/emacs-scala-mode/issues/148
[1] https://github.com/ensime/emacs-scala-mode/pull/151
[2] https://github.com/ag91/EasyOrgEnsime



[O] Fwd: Re: Bug: Org-babel-detangle does not work for subtrees [8.3.5 (8.3.5-elpaplus @ /home/andrea/.emacs.d/elpa/org-plus-contrib-20160808/)]

2016-08-31 Thread Andrea Giugliano
I am not sure my previous mail reached everyone interested.
Best,

Andrea

Andrea Giugliano  writes:

> Hello,
>
> I found a solution, or better I have understood how detangling is
> supposed to work after reading ob-tangle.el.
>
> Basically, I found necessary two things to detangle properly (not
> counting the =:comments yes= that is described in the info):
>
> 1) the cursor needs to be _on_ the code body, and *not* on the comments
>generated by org-babel-tangle.
>
> 2) the setting =(setq org-babel-tangle-use-relative-file-links 'nil)= is 
> essential:
>indeed, using relative path makes my org-babel-jump-to-org try to
>find something like home/andrea/home/andrea... that typically does
>not exists.
>
> I am not sure if this is a src bug (in the wrong default of
> =org-babel-tangle-use-relative-file-links=), or a documentation 
> (http://orgmode.org/worg/doc.html) bug.
>
> It would be nice that =org-babel-detangle= and
> =org-babel-tangle-jump-to-org= could support IDs link navigation as well
> sometimes in the future (since it is possible to base links
> definitions on IDs with =(setq org-id-link-to-org-use-id t)=).
> Thanks,
>
> Andrea
>
> P.S: thanks Grant, your answer gave me the right ques to solve my
> problem. (Also, I am not sure I fully understood the capabilities of your
> framework "help" from the repository description, but I liked the
> guidelines for literate programming you gave in one of the readmes.)
>
> Grant Rettke  writes:
>
>> Good evening Andrea,
>>
>> Does it use the contents of the headline instead of the ID?
>>
>> If yes, I know what you mean, but I don't remember why it does that
>> because long ago I changed it so that it uses the NAME of the ID
>> instead. I can tell you how my configuration looks though:
>>
>> All of my Org-Mode LP configuration is in here:
>>
>> https://github.com/grettke/help/blob/master/Org-Mode_Fundamentals.org
>>
>> Here are some values that come to mind though:
>>
>> - Global header-args sets comments to "noweb"
>> - This whole section
>> https://github.com/grettke/help/blob/master/Org-Mode_Fundamentals.org#identity
>> - (require 'org-id)
>> - (setq org-id-link-to-org-use-id 'nil)
>>
>> That makes it so that the comment links to the file, not to the id or
>> custom_id. Yes, I find it confusing and I only figured this out a
>> couple nights ago. However, this makes detangle work.
>>
>> Let me know how it goes and check out my config.
>>
>> Sincerely,
>>
>> Grant Rettke
>>
>>
>> On Tue, Aug 30, 2016 at 5:38 PM, Andrea Giugliano  wrote:
>>> Hello,
>>>
>>> yup, that would be the ideal solution, but at the moment my
>>> org-babel-tangle does not use the ID in the comments! It uses a (not
>>> working) string.
>>> Do you mean that I can force to reference in the comment to be an ID??
>>> Thanks,
>>>
>>> Andrea
>>>
>>> Grant Rettke  writes:
>>>
>>>> On Tue, Aug 30, 2016 at 12:25 PM, Andrea Giugliano  
>>>> wrote:
>>>>> I think that the ideal solution is to allow an user to make
>>>>> org-babel-detangle rely on header IDs, since this not only assures
>>>>> detangle to find the correct header every time, but also push the user
>>>>> to use IDs through org-id (that seems good practice).
>>>>> What do you think?
>>>>
>>>> Yes you should set a ID on every Headline and source-block
>>>> automatically using org-id so that detangling always works.
>>>>
>>>> When you want a custom ID it is easily changed.
>>>




[O] Bug: Org-babel-detangle does not work for subtrees [8.3.5 (8.3.5-elpaplus @ /home/andrea/.emacs.d/elpa/org-plus-contrib-20160808/)]

2016-08-30 Thread Andrea Giugliano

Hello,

I have an org mode file with deep subtrees (i.e., 7 stars nesting
level).
When I try to detangle a src block generated by

"
*** TODO find map
:PROPERTIES:
:ID:   501cfff7-3b24-47cc-9ada-42e6d46abbe9
:END:

#+BEGIN_SRC ocaml :noeval :comments both :mkdirp yes :tangle ~/tmp/findMap.ml
anything here
#+END_SRC
"

and the generated file contains:

(* TODO find map *)
(* :PROPERTIES: *)
(* :ID:   501cfff7-3b24-47cc-9ada-42e6d46abbe9 *)
(* :END: *)


(* [[file:../home/andrea/workspace/agenda/myTasks.org::*find%20map][find\ 
map:1]] *)
anything here
(* find\ map:1 ends here *)

the detangle cannot find the header, and proposes me to create a new one
in the file.
I think that the ideal solution is to allow an user to make
org-babel-detangle rely on header IDs, since this not only assures
detangle to find the correct header every time, but also push the user
to use IDs through org-id (that seems good practice).
What do you think?
Thanks for the fantastic org mode!!

Andrea

Emacs  : GNU Emacs 24.5.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.29)
 of 2016-08-26 on localhost
Package: Org-mode version 8.3.5 (8.3.5-elpaplus @ 
/home/andrea/.emacs.d/elpa/org-plus-contrib-20160808/)

current state:
==
(setq
 org-capture-prepare-finalize-hook '(org-id-get-create)
 org-reveal-mathjax t
 org-pandoc-epub-rights "Copyright 2016 Andrea <>"
 org-tab-first-hook '(org-hide-block-toggle-maybe 
org-babel-hide-result-toggle-maybe
  org-babel-header-arg-expand)
 org-speed-command-hook '(org-speed-command-default-hook 
org-babel-speed-command-hook)
 org-occur-hook '(org-first-headline-recenter)
 org-src-tab-acts-natively t
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-html-format-drawer-function '(lambda (name contents) contents)
 org-src-window-setup 'current-window
 org-latex-format-inlinetask-function 
'org-latex-format-inlinetask-default-function
 org-confirm-shell-link-function 'yes-or-no-p
 org-image-actual-width 550
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-latex-pdf-process '("latexmk -pdf %f")
 org-highlight-latex-and-related '(latex script entities)
 org-latex-format-headline-function 'org-latex-format-headline-default-function
 org-default-notes-file "/home/andrea/workspace/agenda/myTasks.org"
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-format-drawer-function '(lambda (name contents) contents)
 org-from-is-user-regexp "\\"
 org-loop-over-headlines-in-active-region 'start-level
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
 org-src-mode-configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-hook '((lambda nil
  (local-set-key "\357" (quote org-mime-org-buffer-htmlize)))
 org-toggle-blocks turn-on-flyspell
 #[nil "\300\301\302\303\304$\207"
   [org-add-hook change-major-mode-hook org-show-block-all 
append local]
   5]
 #[nil "\300\301\302\303\304$\207"
   [org-add-hook change-major-mode-hook 
org-babel-show-result-all
append local]
   5]
 org-babel-result-hide-spec org-babel-hide-all-hashes 
org-eldoc-load)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-use-speed-commands t
 org-ascii-format-drawer-function '(lambda (name contents width) contents)
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point 
org-babel-execute-safely-maybe)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
  org-cycle-show-empty-lines
  org-optimize-window-after-visibility-change)
 org-babel-tangle-lang-exts '(("haskell" . "hs") ("scala" . "scala") ("ruby" . 
"rb")
  ("python" . "py") ("java" . "java") ("ocaml" . 
"ml")
  ("emacs-lisp" . "el") ("elisp" . "el"))
 org-confirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-html-format-headline-function 'org-html-format-headline-default-function
 org-structure-template-alist '(("n" "#+BEGIN_NOTES\n?\n#+END_NOTES")
("p"
 "#+BEGIN_SRC plantuml :file uml.png 
\n?\n#+END_SRC")
("s" "#+BEGIN_SRC ?\n\n#+END_SRC")
("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE")
("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE")
("v" "#+BEGIN_VERSE\n?\n#+END_VERSE")
("V" "#+BEGIN_VERBATIM\n?\n#+END_VERBATIM")
("c" "#+BEGIN_CENTER\n?\n#+END_CENTER")
("l" "#+BEGIN_LaTeX\n?\n#+END_LaTeX") ("L" 
"#+LaTeX: ")
("h" "#+BEGIN_HTML\n?\n#+END_HTML") ("H" 
"#+HTML: ")

[O] Bug: [Feature request] ob-plantuml fails if there is not jar: can it check for the executable as well? [8.3.5 (8.3.5-elpaplus @ /home/andrea/.emacs.d/elpa/org-plus-contrib-20160808/)]

2016-08-12 Thread Andrea Giugliano

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 http://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org-mode mailing list.


I am using NixOS, and since this operating system does not use /usr/bin
as standard folder for executables, plantuml.jar cannot find the
graphviz dependency. NixOS provides a plantuml package, and so I can
call the plantuml command from commandline. It would be nice if
ob-plantuml tried to use the plantuml executable in the case
a .jar is not provided (instead of just failing).
Thanks for Org mode: it is simply wonderful!

Andrea

P.S:
Sorry if I am using the wrong medium for asking for a feature, but I do
not know where else I should do it.

Emacs  : GNU Emacs 24.5.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.29)
 of 2016-07-26 on localhost
Package: Org-mode version 8.3.5 (8.3.5-elpaplus @ 
/home/andrea/.emacs.d/elpa/org-plus-contrib-20160808/)

current state:
==
(setq
 org-pandoc-epub-rights "Copyright 2016 Andrea <>"
 org-tab-first-hook '(org-hide-block-toggle-maybe 
org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
 org-speed-command-hook '(org-speed-command-default-hook 
org-babel-speed-command-hook)
 org-occur-hook '(org-first-headline-recenter)
 org-src-tab-acts-natively t
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-html-format-drawer-function '(lambda (name contents) contents)
 org-src-window-setup 'current-window
 org-latex-format-inlinetask-function 
'org-latex-format-inlinetask-default-function
 org-confirm-shell-link-function 'yes-or-no-p
 org-image-actual-width 550
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-latex-pdf-process '("latexmk -pdf %f")
 org-highlight-latex-and-related '(latex script entities)
 org-latex-format-headline-function 'org-latex-format-headline-default-function
 org-default-notes-file "/home/andrea/workspace/agenda/myTasks.org"
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-format-drawer-function '(lambda (name contents) contents)
 org-from-is-user-regexp "\\"
 org-loop-over-headlines-in-active-region 'start-level
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-hook '((lambda nil (local-set-key "\357" (quote 
org-mime-org-buffer-htmlize))) turn-on-flyspell
 #[nil "\300\301\302\303\304$\207" [org-add-hook 
change-major-mode-hook org-show-block-all append local] 5]
 #[nil "\300\301\302\303\304$\207" [org-add-hook 
change-major-mode-hook org-babel-show-result-all append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes 
org-eldoc-load)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-use-speed-commands t
 org-ascii-format-drawer-function '(lambda (name contents width) contents)
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point 
org-babel-execute-safely-maybe)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers 
org-cycle-show-empty-lines
  org-optimize-window-after-visibility-change)
 org-plantuml-jar-path 
"/nix/store/2s91vgzv8ckhwq1hhxrf666q99z0pnhi-plantuml-8012/lib/plantuml.jar"
 org-babel-tangle-lang-exts '(("haskell" . "hs") ("ruby" . "rb") ("python" . 
"py") ("java" . "java") ("ocaml" . "ml")
  ("emacs-lisp" . "el") ("elisp" . "el"))
 org-confirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-html-format-headline-function 'org-html-format-headline-default-function
 org-structure-template-alist '(("p" "#+BEGIN_SRC plantuml :file uml.png 
\n?\n#+END_SRC") ("s" "#+BEGIN_SRC ?\n\n#+END_SRC")
("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE") ("q" 
"#+BEGIN_QUOTE\n?\n#+END_QUOTE")
("v" "#+BEGIN_VERSE\n?\n#+END_VERSE") ("V" 
"#+BEGIN_VERBATIM\n?\n#+END_VERBATIM")
("c" "#+BEGIN_CENTER\n?\n#+END_CENTER") ("l" 
"#+BEGIN_LaTeX\n?\n#+END_LaTeX") ("L" "#+LaTeX: ")
("h" "#+BEGIN_HTML\n?\n#+END_HTML") ("H" 
"#+HTML: ") ("a" "#+BEGIN_ASCII\n?\n#+END_ASCII")
("A" "#+ASCII: ") ("i" "#+INDEX: ?") ("I" 
"#+INCLUDE: %file ?"))
 org-babel-load-languages '((ocaml . t) (java . t) (sh . t) (python . t) (ruby 
. t) (haskell . t) (plantuml . t) (dot . t))
 org-src-preserve-indentation t
 org-html-format-inlinetask-function 
'org-html-format-inlinetask-default-function
 org-agenda-files '("/home/andrea/workspace/agenda/myTasks.org")
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-confirm-babel-evaluate nil
 )