[O] FYI: with-org-today-date macro, helps with testing

2017-07-28 Thread Adam Porter
Hi friends,

Just wanted to drop this here.  I was testing some agenda-related code,
and got tired of having to keep moving the dates forward on my test data
as days passed in real life, so after digging into the agenda code, I
came up with this macro that makes testing much easier:

#+BEGIN_SRC elisp
  (defmacro with-org-today-date (date &rest body)
"Run BODY with the `org-today' function set to return simply DATE.
  DATE should be a date-time string (both date and time must be included)."
(declare (indent defun))
`(let ((day (date-to-day ,date))
   (orig (symbol-function 'org-today)))
   (unwind-protect
   (progn
 (fset 'org-today (lambda () day))
 ,@body)
 (fset 'org-today orig
#+END_SRC

You can use it like this:

#+BEGIN_SRC elisp
  (with-org-today-date "2017-07-05 00:00"
(let ((org-agenda-files (list "~/test.org"))
  (org-agenda-span 'day))
  (org-agenda-list nil)))
#+END_SRC

Hope someone finds this useful.




Re: [O] ANN: org-super-agenda

2017-07-28 Thread Adam Porter
Adam Porter  writes:

> After thinking about this some more, I have an idea: if I go ahead and
> import the agenda-building functions into my package and modify them, I
> can use a minor mode to override the standard functions with advice.
> That way users would only have to define the groups variable, and all
> the agenda commands would pick it up automatically, from the user's
> perspective.  That would prevent users from having to define new agenda
> commands that call special functions; they could just use their existing
> custom agenda commands.

FYI, this idea worked out well.  In fact, I only have to override one
function, org-agenda-finalize-entries.  I haven't fully tested all the
different agenda commands yet, but it's working well so far.  I'd
appreciate help testing further.  :)




Re: [O] Adding single cell movement to org-table

2017-07-28 Thread Chris Kauffman
Apologies for the earlier diff-blast: I did not see the advice on the
org-mode contributions page that patches generated via
  git format-patch master
are preferred.  Please find four patches attached which now include
modifications to ORG-NEWS, org.texi, orgguid.texi, and keybindings
suggested by Carsten: S-up, S-down, S-left, S-right in org.el (via
org-shiftup etc.).

Cheers,
Chris


On Fri, Jul 28, 2017 at 4:19 AM, Nicolas Goaziou 
wrote:

> Hello,
>
> Chris Kauffman  writes:
>
> > Greetings from a first-time contributor. Another patch contributor, Uwe
> > Brauer, recruited me after finding some code I had written to move single
> > org-table cells up/down/left/right.  I found this feature to be useful in
> > certain kinds of tables so wrote the functions for myself but am told
> that
> > others might benefit from it.
> >
> > I have formalized that code into a git repo with a feature branch on it
> > which may be found here:
> >   https://github.com/kauffman77/org-mode/tree/single-cell-table-move
> >
> > I have included documentation in org-table.el for the new functions and
> > tests for them.  If further work or documentation needs to be done,
> please
> > let me know. I am also not sure if I got the commit messages formatted to
> > the specification mentioned on the contributing page.  I am happy to
> > explain more if needed.
>
> Thank you.
>
> Could you send the patch here? It will ease reviewing it.
>
> It will also require an entry in ORG-NEWS and some documentation in
> org.texi.
>
> > I just mailed ass...@gnu.org to get the copyright for the code resolved
> but
> > thought I would put up this branch now so others can have a look.
>
> Great!
>
> Regards,
>
> --
> Nicolas Goaziou
>
From b43054c9892f7e08fa958bcb5d8df978e6392d57 Mon Sep 17 00:00:00 2001
From: Chris Kauffman 
Date: Fri, 28 Jul 2017 22:46:12 -0400
Subject: [PATCH 5/5] Modified orgguide.texi to include documentation of single
 cell movement functions.

---
 doc/orgguide.texi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/doc/orgguide.texi b/doc/orgguide.texi
index 8c91aae3a..fc5c0c22c 100644
--- a/doc/orgguide.texi
+++ b/doc/orgguide.texi
@@ -647,6 +647,12 @@ Re-align, move to previous field.
 @item @key{RET}
 Re-align the table and move down to next row.  Creates a new row if
 necessary.
+@c
+@item S-@key{up}
+@itemx S-@key{down}
+@itemx S-@key{left}
+@itemx S-@key{right}
+Move single cells up, down, left, and right by swapping with adjacent cells.
 
 @tsubheading{Column and row editing}
 @item M-@key{left}
-- 
2.12.2

From 6682b22642c34f61feee27cd44a503dd4c21e9cb Mon Sep 17 00:00:00 2001
From: Chris Kauffman 
Date: Fri, 28 Jul 2017 22:37:31 -0400
Subject: [PATCH 4/5] Modified org.texi to include documentation of single cell
 movement functions.

---
 doc/org.texi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/doc/org.texi b/doc/org.texi
index 101d532e3..55c8ebd27 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -2156,6 +2156,12 @@ NEWLINE, so it can be used to split a table.
 Move to beginning of the current table field, or on to the previous field.
 @orgcmd{M-e,org-table-end-of-field}
 Move to end of the current table field, or on to the next field.
+@c
+@orgcmd{S-@key{up},org-table-move-single-cell-up}
+@orgcmd{S-@key{down},org-table-move-single-cell-down}
+@orgcmd{S-@key{left},org-table-move-single-cell-left}
+@orgcmd{S-@key{right},org-table-move-single-cell-right}
+Move single cells up, down, left, and right by swapping with adjacent cells.
 
 @tsubheading{Column and row editing}
 @orgcmdkkcc{M-@key{left},M-@key{right},org-table-move-column-left,org-table-move-column-right}
-- 
2.12.2

From 6be32b39c590d003be75a33033bb3301a11db483 Mon Sep 17 00:00:00 2001
From: Chris Kauffman 
Date: Fri, 28 Jul 2017 22:18:28 -0400
Subject: [PATCH 3/5] Updates to ORG-NEWS describing single-cell movement
 functions.

---
 etc/ORG-NEWS | 20 
 1 file changed, 20 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index d7bd3e2ce..05efce4f4 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -291,6 +291,11 @@ This variable allow computed durations in tables to be zero-padded.
 *** New mode switch for table formulas : =U=
 This mode omits seconds in durations.
 
+*** New single table cell movement options : ~org-table-move-single-cell-up~
+Shift-Up, Shift-Down, Shift-Right, and Shift-Left now move single
+table cells in the corresponding directions by swapping with the
+adjacent cell.
+
 ** Removed functions
 
 *** Org Timeline
@@ -368,6 +373,21 @@ It is the reciprocal of ~org-list-to-lisp~, which see.
 
 Call ~org-agenda-set-restriction-lock~ from the agenda.
 
+*** ~org-table-move-single-cell~ and related
+
+Four new user functions to move single table cells in cardinal
+directions.
+
+- ~org-table-move-single-cell-up~
+- ~org-table-move-single-cell-down~
+- ~org-table-move-single-cell-left~
+- ~org-table-move-single-cell-right~
+
+Support functions which are used to facilitate single cell movement.
+- ~org-t

Re: [O] Update to org-protocol-capture-html

2017-07-28 Thread Adam Porter
Nikolay Kudryavtsev  writes:

> My testing had shown that if in
> org-protocol-check-filename-for-protocol we have (server-delete-client
> _client) instead of (server-edit), the client process gets closed
> fine. May I propose such a change?

Hi Nikolay,

I'm not sure if you're asking me or Nicolas.  But since we have observed
differences between platforms, I guess your proposal should be tested on
Linux, Mac OS, etc. to make sure it doesn't break anything on them.




Re: [O] agenda configurable entry-text-mode

2017-07-28 Thread Adam Porter
Alexander Baier  writes:

> Hi Adam,
>
> I hadn't heard of org-quick-peek.  I found
> https://github.com/alphapapa/org-quick-peek but could not find the
> package on MELPA, do you know why this is the case?

Hi Alexander,

Actually I haven't submitted it to MELPA yet.  I've been hoping to get
some more feedback and testing before doing that.  I guess I should have
adjusted the readme accordingly.  I would appreciate if you could give
it a quick test and let me know any feedback you may have.  :)

> Also the screenshot in the README is not present (any more), thus I am
> currently having a hard time imagining what this package does / how it
> looks.

Alas, I neglected to upload a screenshot yet, either.  Basically, it
does what the agenda's "entry text mode" does, but it uses overlays from
the quick-peek package, and they look a bit nicer.

Thanks,
Adam




Re: [O] ANN: org-super-agenda

2017-07-28 Thread Adam Porter
Eric S Fraga  writes:

> Hi Adam,
>
> have now given this a try.  Looks really nice.  Some questions, if I
> may.  I would like to have the following sections:

Hi Eric,

Thanks, I appreciate your feedback.

> 1. items that have deadlines, any deadline for now and in the future,
>whether scheduled or not.
> 2. items that have a specific TODO type whether scheduled or not.

Well, as it stands, this package is mainly a way to group together items
that the standard agenda view (i.e. the org-agenda-list function) has
gathered.  The standard agenda view uses org-agenda-get-day-entries for
that.  What I think you're wanting is already provided by, e.g. the
org-todo-list function.  So you could add that as a separate section in
a custom agenda series command.

Now if you're wanting to use the grouping ability on the global TODO
list provided by org-todo-list, that is a possibility, but it would
require my essentially copying the org-todo-list function and making it
available under a new name that does the grouping.  This is what I did
with the org-agenda-list function: I just copied it and made one change
that calls my grouping/inserting functions instead of inserting results
directly.

The problem with this approach in general is that I end up copying large
Org agenda functions (and they are large) and making minor changes to
them, and then they will get out of sync when those functions change in
Org.

So the question becomes, how many Org agenda functions do I want to copy
into my package and be responsible for fixing?

I considered an alternative approach of post-processing agenda buffers,
instead of doing the filtering and inserting myself, but considering all
the special blocks that agenda buffers can have (e.g. clockreports,
timelines, etc), I decided that down that path lies madness.  ;)

So I'm not sure how far I should go with adding these other agenda types
to this package.  It would be nice if the agenda functions in Org itself
could be modified to accept grouping functions like this (it's a minor
change, really, to call a function to do insertion instead of doing it
directly), and that's something that I'd eventually like to propose to
the maintainers.

> 3. a clock summary (equivalent to what one gets with "v c" in standard
>view)

I confess that I have never used this feature before you mentioned it.
:)  I tried to investigate this, but I've hit somewhat of a dead end:
the org-agenda-show-log-scoped variable, which is bound by
org-agenda-list, for some reason becomes unbound in org-super-agenda,
which doesn't seem to make sense, since it is just a copy of
org-agenda-list.  And even using edebug and stepping through everything
I can find, I can't figure out why it becomes unbound.

...And, having written that, it suddenly occurred to me: I wonder if
org-agenda-show-log-scoped is defined with defvar...and I see that it is
not...and so I tried doing it...and it seems to have fixed that
problem.  I guess I don't realy know anything until I explain it to
someone else.  :)

Now I can go ahead and add that defvar to my package for now, but it
should probably be added to Org itself.  It might be considered a bug
fix, but on the other hand, if it only happens with my non-standard
package...

Anyway, I will add this to my package and upload it shortly.  Please let
me know if it fixes the clockcheck command for you.

> 4. a clock report at the end (and really the end, after all other
> items)

As far as I know, this already works.  Just press "R" in the agenda
buffer.  Please let me know if it doesn't work for you.

After thinking about this some more, I have an idea: if I go ahead and
import the agenda-building functions into my package and modify them, I
can use a minor mode to override the standard functions with advice.
That way users would only have to define the groups variable, and all
the agenda commands would pick it up automatically, from the user's
perspective.  That would prevent users from having to define new agenda
commands that call special functions; they could just use their existing
custom agenda commands.

I will look into this and push it to the repo if it works.  Please let
me know if you have any other ideas or suggestions.

Thanks,
Adam




Re: [O] Help resolving CUSTOM_ID based links that point to outside current subtree scope

2017-07-28 Thread Kaushal Modi
Ah! I made a typo in the example above; here's the corrected one:

* Link source
:PROPERTIES:
:EXPORT_FILE_NAME: link-source
:END:
- Link to [[#link-dest][Link dest]]
* Link dest
:PROPERTIES:
:EXPORT_FILE_NAME: link-dest
:CUSTOM_ID: link-dest
:END:

("Link source" and "Link dest" subtrees are at the same level. So exporting
just "Link source" subtree does not 'see' the "Link dest" subtree.)

On Fri, Jul 28, 2017 at 3:17 PM Kaushal Modi  wrote:

> Hello,
>
> Is there a way to make org-export-resolve-id-link look for link resolution
> outside the current scope?
>
> I just threw in a (save-restriction (widen) ..) inside
> org-export-resolve-id-link, and that of course did not work (and thus this
> email).
>
> Below is a little example:
>
> * Link source
> :PROPERTIES:
> :EXPORT_FILE_NAME: link-source
> :END:
> - Link to [[#link-dest][Link dest]]
> ** Link dest
> :PROPERTIES:
> :EXPORT_FILE_NAME: link-dest
> :CUSTOM_ID: link-dest
> :END:
>
> - I would like to export just the "Link source" subtree (let's say C-c C-e
> C-s t A), and have the link resolve to the "link-dest" CUSTOM_ID.
> - To put this the other way, I want to export just the subtree, but look
> at the whole buffer for link resolution.
>
> I know that does not make sense, but I need that for the Hugo exporter
> backend.
>
> Application: I have one subtree (Hugo post) containing a CUSTOM_ID based
> internal link to some other subtree (Hugo post), and I want to retain the
> link reference. Hugo would then figure out the rest.
>
> What function could I advice and with what to make this happen?
>
> Thanks.
> --
>
> Kaushal Modi
>
-- 

Kaushal Modi


[O] Help resolving CUSTOM_ID based links that point to outside current subtree scope

2017-07-28 Thread Kaushal Modi
Hello,

Is there a way to make org-export-resolve-id-link look for link resolution
outside the current scope?

I just threw in a (save-restriction (widen) ..) inside
org-export-resolve-id-link, and that of course did not work (and thus this
email).

Below is a little example:

* Link source
:PROPERTIES:
:EXPORT_FILE_NAME: link-source
:END:
- Link to [[#link-dest][Link dest]]
** Link dest
:PROPERTIES:
:EXPORT_FILE_NAME: link-dest
:CUSTOM_ID: link-dest
:END:

- I would like to export just the "Link source" subtree (let's say C-c C-e
C-s t A), and have the link resolve to the "link-dest" CUSTOM_ID.
- To put this the other way, I want to export just the subtree, but look at
the whole buffer for link resolution.

I know that does not make sense, but I need that for the Hugo exporter
backend.

Application: I have one subtree (Hugo post) containing a CUSTOM_ID based
internal link to some other subtree (Hugo post), and I want to retain the
link reference. Hugo would then figure out the rest.

What function could I advice and with what to make this happen?

Thanks.
-- 

Kaushal Modi


Re: [O] [PATCH] org-depend: multi-file TRIGGER and BLOCKER tasks

2017-07-28 Thread Nicolas Goaziou
Hello,

Adrian Bradd  writes:

> Adds multi-file TRIGGER and BLOCKER tasks to org-depend by first searching
> the current file `org-find-entry-with-id` and then all files visisble
> through `org-find-id`.
> From d4095a57f1c9c42426d8c0d51ca7f4640f036a3a Mon Sep 17 00:00:00 2001
> From: Adrian Bradd 
> Date: Thu, 13 Jul 2017 22:49:26 -0400
> Subject: [PATCH] org-depend: multi-file TRIGGER and BLOCKER tasks

Thank you.

You need to list the functions modified in the commit message:

lisp/contrib/org-depend.el (...function...): 

>  (catch 'return
>(unless (eq type 'todo-state-change)
>   ;; We are only handling todo-state-change
> @@ -336,11 +336,18 @@ This does two different kinds of triggers:
> (setq id (match-string 1 tr)
>   kwd (match-string 2 tr)
>   p1 (org-find-entry-with-id id))
> -   (when p1
> +   ;; first check current buffer, then all files
> +   (if p1
>   ;; there is an entry with this ID, mark it TODO
>   (save-excursion
> (goto-char p1)
> -   (org-todo kwd
> +   (org-todo kwd))
> + (when (setq p2 (org-id-find id))
> +   (save-excursion
> + (save-window-excursion
> +   (find-file (car p2))

I suggest to use 

  (with-current-buffer (find-file-noselect (car p2))
   ...)

Then, `save-window-excursion' is not necessary.

> +((setq p2 (org-id-find bl))
> + (save-excursion
> +   (save-window-excursion
> + (find-file (car p2))

Ditto.

Regards,

-- 
Nicolas Goaziou



Re: [O] Log change TODO state after clock-out

2017-07-28 Thread Nicolas Goaziou
Hello,

Рома Рудаков  writes:

> Expected result:
>
> * DONE task 1
>   CLOSED: [2017-07-26 Wed 15:39]
>   :LOGBOOK:
>   - State "DONE"   from "PROGRESS"   [2017-07-26 Wed 15:39]
>   - State "PROGRESS"   from "TODO"   [2017-07-26 Wed 15:37]
>   CLOCK: [2017-07-26 Wed 15:37]--[2017-07-26 Wed 15:38] =>  0:01
>   :END:
> * TODO task 2
> * TODO task 3
> * TODO task 4
>
>
> Actual result:
>
> * DONE task 1
>   :LOGBOOK:
>   - State "PROGRESS"   from "TODO"   [2017-07-26 Wed 15:37]
>   CLOCK: [2017-07-26 Wed 15:37]--[2017-07-26 Wed 15:38] =>  0:01
>   :END:
> * TODO task 2
> * TODO task 3
> * TODO task 4
>
> There is no CLOSED log entry and change state from PROGRESS to DONE
> entry.

Logging was inhibited when using `org-clock-out-switch-to-state', but
not when using `org-clock-in-switch-to-state'. I assume this is a bug,
so I removed it.

I may be wrong though, so this change is in master only.

Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] org-time-stamp in latex buffer

2017-07-28 Thread Nicolas Goaziou
Hello,

Uwe Brauer  writes:

> org-time-stamp-custom-formats is a variable defined in ‘org.el’.
> Its value is ("«%d-%m-%Y %a»" . "«%d-%m-%Y %a %H:%M»")
> Original value was 
> ("<%m/%d/%y %a>" . "<%m/%d/%y %a %H:%M>")
>
>
> And indeed in an org buffer this format is used. However when I try to
> use org-time-stamp in a latex buffer the string
> <2017-07-28 Fr>
> is inserted which does not respect my new setting.
>
> What is wrong?

Custom format time are applied during fontification time. The major mode
you're using in your LaTeX document doesn't know about Org fontification
rules.

You may want to add some rules to font lock there.

Regards,

-- 
Nicolas Goaziou



[O] org-time-stamp in latex buffer

2017-07-28 Thread Uwe Brauer


Hi

I changed by org-time-stamp-custom-formats
to 



org-time-stamp-custom-formats is a variable defined in ‘org.el’.
Its value is ("«%d-%m-%Y %a»" . "«%d-%m-%Y %a %H:%M»")
Original value was 
("<%m/%d/%y %a>" . "<%m/%d/%y %a %H:%M>")


And indeed in an org buffer this format is used. However when I try to
use org-time-stamp in a latex buffer the string
<2017-07-28 Fr>
is inserted which does not respect my new setting.

What is wrong?

Thanks

Uwe Brauer 




Re: [O] agenda configurable entry-text-mode

2017-07-28 Thread Alexander Baier

Hi Adam,

I hadn't heard of org-quick-peek.  I found 
https://github.com/alphapapa/org-quick-peek but could not find the 
package on MELPA, do you know why this is the case?


Also the screenshot in the README is not present (any more), thus I am 
currently having a hard time imagining what this package does / how it 
looks.


On 25.07.2017 20:08, Adam Porter wrote:

I think it wouldn't be too hard to implement
something like that using org-quick-peek.  Let me know what you think.
I might give it a try myself.







Re: [O] Adding single cell movement to org-table

2017-07-28 Thread Carsten Dominik
Hi Chris,

I really like this functionality, thank you!

Has there been a discussion about a possible key binding for this feature?

Carsten

On Thu, Jul 27, 2017 at 10:20 PM, Chris Kauffman 
wrote:

> Greetings from a first-time contributor. Another patch contributor, Uwe
> Brauer, recruited me after finding some code I had written to move single
> org-table cells up/down/left/right.  I found this feature to be useful in
> certain kinds of tables so wrote the functions for myself but am told that
> others might benefit from it.
>
> I have formalized that code into a git repo with a feature branch on it
> which may be found here:
>   https://github.com/kauffman77/org-mode/tree/single-cell-table-move
>
> I have included documentation in org-table.el for the new functions and
> tests for them.  If further work or documentation needs to be done, please
> let me know. I am also not sure if I got the commit messages formatted to
> the specification mentioned on the contributing page.  I am happy to
> explain more if needed.
>
> I just mailed ass...@gnu.org to get the copyright for the code resolved
> but thought I would put up this branch now so others can have a look.
>
> Cheers,
> Chris
>


Re: [O] Adding single cell movement to org-table

2017-07-28 Thread Nicolas Goaziou
Hello,

Chris Kauffman  writes:

> Greetings from a first-time contributor. Another patch contributor, Uwe
> Brauer, recruited me after finding some code I had written to move single
> org-table cells up/down/left/right.  I found this feature to be useful in
> certain kinds of tables so wrote the functions for myself but am told that
> others might benefit from it.
>
> I have formalized that code into a git repo with a feature branch on it
> which may be found here:
>   https://github.com/kauffman77/org-mode/tree/single-cell-table-move
>
> I have included documentation in org-table.el for the new functions and
> tests for them.  If further work or documentation needs to be done, please
> let me know. I am also not sure if I got the commit messages formatted to
> the specification mentioned on the contributing page.  I am happy to
> explain more if needed.

Thank you. 

Could you send the patch here? It will ease reviewing it.

It will also require an entry in ORG-NEWS and some documentation in
org.texi.

> I just mailed ass...@gnu.org to get the copyright for the code resolved but
> thought I would put up this branch now so others can have a look.

Great!

Regards,

-- 
Nicolas Goaziou



Re: [O] org-backward-paragraph probably should *not* signal user-error at start of buffer

2017-07-28 Thread Nicolas Goaziou
Hello,

Omar Antolín Camarena  writes:

> I just noticed that org-backward-paragraph raises a user error if you call
> it at the beginning of the buffer. This is not what the general
> backward-paragraph command does, nor is it what I remember other Emacs
> movement commands doing when the move can't actually be done.

Fixed. Thank you.

Regards,

-- 
Nicolas Goaziou