Re: exporting ics files with broken link

2019-11-03 Thread Thomas Plass
Hello,

Prof. Dr. Johanna May wrote at 23:46 on November 1, 2019:
: Any hints on how to repair that? Any hints in which file
: that strange link may sit?  And: how can I make sure my files stay
: exportable?

I guess an answer to the last question would be to set the variable
`org-export-with-broken-links' to either t (== ignore) or 'mark (==
export a [BROKEN LINK: path]).  Call up the Export section in the Org
Customization to do so.  This sould work in Org 9.

The exported .ics might give hints for answering the first two
questions.

Regards

Thomas



Re: [O] parsing time strings from properties

2019-09-22 Thread Thomas Plass
Hi,

Matt Price wrote at 16:27 on September 21, 2019:
: 
: :DUE_AT: 2019-09-26
: 
: ...
:
: I'm wondering though how hard
: it would be to get the current time zone -- or the time zone that the course 
is taught in -- from
: emacs, and construct the string from that value. 

This'll return the offset suffix (if that's what you want) when
executed in your local time zone (presumably "-04:00"):

(defun Price/local-time-offset-from-iso-date (y-m-d)
  (let* ((ymd (mapcar (lambda (s) (string-to-number s)) (split-string y-m-d 
"-")))
 (offsecs (nth 8
   (decode-time
(apply #'encode-time
   (list 59 59 23 (nth 2 ymd) (nth 1 ymd) (nth 0 
ymd)))
(format "%s%02d:%02d"
(if (> offsecs 0) "+" "-")
(/ offsecs 3600)
(% offsecs 3600

On Unix, this'll always work.  On Windows, it works most of the time,
but may fail in the weeks around switches from and to daylight saving.

Thomas



Re: [O] [week?] (was: insert date-stamp for one month)

2019-08-19 Thread Thomas Plass
Hello,

Uwe Brauer wrote at 16:33 on August 18, 2019:

: The problem seems to be that there is no function
: calendar-last-day-of-week.

Well, there is, it's called `calendar-week-end-day'.

This returns the index into 'calendar-day-name-array.  Note that the
variable 'calendar-week-start-day should be set properly (it defaults
to 0 = $SUNDAY, while I set this to 1, meaning $MONDAY).

This will only get you as far as computing the name of the day.
Computing a date and/or timestamp for an instance of that day name
relative to a date is quite another matter.  The file
calendar/time-date.el might provide useful stuff for doing so.

Thomas



Re: [O] insert date-stamp for one month

2019-08-18 Thread Thomas Plass
Hello,

Uwe Brauer wrote at 09:58 on August 18, 2019:
: I sometimes need to insert a date-stamp which corresponds to one month
: in a year, say march 2019. I usually insert 
: <2019-03-01 Fri>--<2019-03-31 Sun>, but this is cumbersome to do
: manually.

This'll put the computed result on the kill ring.  Beautification and
error checking of input values left as an exercise for the reader.

(defun Brauer/make-month-timerange (year month)
  (interactive
   (list (string-to-int (read-string "Year: " (int-to-string (nth 5 
(decode-time)
 (string-to-int (read-string "Month: " (int-to-string (nth 4 
(decode-time)))
  (let* ((last-day (calendar-last-day-of-month month year))
 (start (list 0 0 0 1 month year))
 (end (list 0 0 0 last-day month year))
 (ts (format "<%d-%02d-%02d %s>--<%d-%02d-%02d %s>"
 year month 1 (format-time-string "%a" (apply #'encode-time 
start))
 year month last-day (format-time-string "%a" (apply 
#'encode-time end)
(message (substitute-command-keys (concat "Use \\[yank] to yank " ts)))
(kill-new ts)))


Regards

Thomas





Re: [O] org-agenda list on other language than english

2019-08-11 Thread Thomas Plass
Hello,

Andrés Ramírez wrote at 14:30 on August 10, 2019:
: 
: Would it be possibe to render agenda in other language than English.

Mostly.

Localised day and month names are taken from your (apparently missing)
calendar setup.  Make sure that your startup file setq's at least
these two variables:

- calendar-month-name-array
- calendar-day-name-array (starts with $SUNDAY)

Also, it might be advisable to set calendar-date-style (to 'european
in my case).

My setup for German is this, modify for Spanish as appropriate:

(setq calendar-date-style 'european
  calendar-month-name-array ["Januar" "Februar" "März" "April" "Mai" "Juni"
 "Juli" "August" "September" "Oktober" 
"November" "Dezember"]
  calendar-day-name-array ["Sonntag" "Montag" "Dienstag" "Mittwoch"
   "Donnerstag" "Freitag" "Samstag"]
   )

The "days" in "10 days-agenda", however, is hard-wired.

: Convert from this:
: --8<---cut here---start->8---
: 10 days-agenda (W32-W33):
: Wednesday   7 August 2019
: 
: To this (Spanish):
: --8<---cut here---start->8---
: 10 dias-agenda (W32-W33):
: Miercoles   7 Agosto 2019

Regards

Thomas



Re: [O] converting many ics files to a single org file

2019-06-10 Thread Thomas Plass
Hello,

Alan Schmitt wrote at 16:32 on June 10, 2019:
: I've found this tool
: https://github.com/asoroa/ical2org.py but it's not clear if it can
: handle many files.

As per its docstring it's one file per invocation.  But the docstring
also lists:

$ cat in.ical | ical2orgpy - - > out.org

I haven't tried, but something like this might work (on Unixoids):

$ echo -n > out.org
$ for i in *.ical; do cat $i | ical2orgpy - - >> out.org; echo >> out.org; done

Regards

Thomas



Re: [O] Vertical bars in org file break export to ics

2019-05-30 Thread Thomas Plass
Hello michael,

michael wrote at 08:57 on May 30, 2019:
: for the following *.org file running org-icalendar-export-to-ics will fail
: with "Args out of range: [nil nil], 2".
: 
: * This is a test
:   <2020-01-01 Mi>
: 
: | | |
: | | | | |

Org recognizes the last two lines as a genuine Org table (with two
rows), not as a collection of vertical bars having a completely
different meaning.

Making the export more robust by gracefully handling unequal
numbers of columns won't help you as I guess you wish to have the
vertical bars exported verbatim (which Org won't do).

Your best bet is probably to choose an unreserved character for use in
the graphics, possibly just before exporting.  Unicode code point
0xFFE4 FULLWIDTH BROKEN BAR looks similar.

Regards

Thomas



Re: [O] Temporarily setting agenda files list, cleaning up

2019-05-27 Thread Thomas Plass


Christoph Groth wrote at 14:04 on May 27, 2019:

: Instead, I imagine a custom Emacs command to launch an agenda with
: org-agenda-files that is temporarily set to a list of files that depends
: on the current context.  For starters, this list could contain all the
: org files under the current directory:

This will use a private set of 'org-agenda-files and kill their
buffers after executing `org-agenda-list':

(defun Groth/agenda-list ( dir)
  (interactive)
  (let* ((project-dir (or dir default-directory))
 (org-agenda-files (directory-files-recursively project-dir "\\.org$"))
 tmp-agenda-buffer)
(unwind-protect
;; FIXME: set org-agenda-list args as necessary:  ARG 
START-DAY SPAN WITH-HOUR) 
(org-agenda-list)
  (mapc
   (lambda (f)
 (and (setq tmp-agenda-buffer (find-buffer-visiting f))
  (kill-buffer tmp-agenda-buffer)))
   org-agenda-files

Call it like this:

  M-x Groth/agenda-list

or eval 

  (Groth/agenda-list "/path/to/dir")

I just whipped this up and it might need improvements such as optional
prompting for a search directory and a set of arguments to
`org-agenda-list' that fit your needs (refer to its docstring).  Note
that buffers for files on the old value of 'org-agenda-files that are
already open will be killed, too.

Regards

Thomas




Re: [O] Incorrect clock duration calculation

2019-05-07 Thread Thomas Plass
Note that the day starts at 00:00 and ends at 24:00.  So:

Martin Schroeder wrote at 11:07 on May 7, 2019:
: For example, this should produce 2:00 duration:
: CLOCK: [2019-04-19 Fri 22:00]--[2019-04-19 Fri 00:00] => -22:00

It will if you change [2019-04-19 Fri 00:00] to [2019-04-19 Fri 24:00].

: I tried this, but id did not work either:
: CLOCK: [2019-04-19 Fri 22:00]--[2019-04-19 Sat 00:00] => -22:00

Day name abbreviations ("Fri", "Sat") in timestamps are really for
human consumption.  Org doesn't attach a lot of meaning to them.
Hell, since they use a setting from `calendar', they are subject to
localisation.  Note that

[2019-04-19 00:00]
[2019-04-19 Sa 00:00]
[2019-04-19 Sat 00:00]
[2019-04-19 fooble 00:00]

work the same as Org is agnostic about the non-whitespace string
between the date and the time (as long as it doesn't contain
whitespace itself).

: This should produce 3:00 but it gives -21 even though the end time is
: later than start time:
: CLOCK: [2019-04-19 Fri 22:00]--[2019-04-19 Sat 01:00] => -21:00

No, the end time preceeds the start time.  The encoded duration starts
at 1am and ends at 10pm on the same day.  If you want to cross day
boundaries then the dates must be different in the timestamps.
"2019-04-20" is what you want in the second one:

CLOCK: [2019-04-19 Fri 22:00]--[2019-04-20 Sat 01:00] =>  3:00

Regards,

Thomas





Re: [O] How remove time from date-time stamp

2019-04-08 Thread Thomas Plass
Detlef,

Detlef Steuer wrote at 14:36 on April 8, 2019:
: When in agenda view I can use C-k to kill an entry
: or S-right to promote to next day etc.
: 
: What I need really often in my workflow is the
: promotion to another day, but without the time part of the time stamp

This type of remote edit won't be possible without rewriting Org code.

However, if you want to directly change timestamps in the buffer they
live (not: an agenda view), then S-right/left/up/down can call a hook
function that does what you're trying to achieve.

Thomas




Re: [O] property matching in org-agenda-custom-commands

2019-04-06 Thread Thomas Plass
Matt,

Matt Price wrote at 21:26 on April 5, 2019:
: Is it possible to specify "current buffer only" in the definition of a 
shortcut, but still
: produce an agenda, rather than a sparse tree? 

Agenda matching will always use 'org-agend-files, sparse tree matching
doesn't.  So, you'd need to force "current buffer" (really: current
file) by fiddling und unfiddling 'org-agend-files.  Kludgy.

: +GRADE={"0"|"Fail"}

The thing is that the tags matcher, used here to match PROPERTYs,
translates the "=" in the string above to Lisp `string='.  You're on
the right track to use "{|}" but then it the contents of the {}
has to be a properly escaped regexp.

This works for me:

("F" "Failing Students in Current Buffer Only" tags "+GRADE={0\\|Fail}")

Overkill:

("F" "Failing Students in Current Buffer Only" tags "+GRADE={^\\(0\\|Fail\\)$}")

Thomas



Re: [O] property matching in org-agenda-custom-commands

2019-04-05 Thread Thomas Plass
Matt,

Matt Price wrote at 13:31 on April 5, 2019:
: 
: ("F" "Failing Students in Current Buffer Only" tags-tree "+GRADE=\"0\"")
: 
: However, this seems to choke, and the agenda is not generated.

Works as advertised (docstring'ed?), I think.  The 'tags-tree creates
a sparse tree, not an agenda.  Plain 'tags does.  If that's what
you're after.

("F" "Failing Students in Current Buffer Only" tags "+GRADE=\"0\"")

Thomas



[O] [ANN] org-conflict add-on: timing conflicts detector and resolver for Org agenda

2019-04-04 Thread Thomas Plass
With this post, I'd like to submit org-conflict, a new Org add-on, to
the community for enjoyment, scrutiny and feedback.

Org-conflict aims to help Org agenda users prevent creating scheduling
conflicts.  If you use the agenda for calendar purposes, you might
benefit from validating timestamps before you commit them.

My own demand for conflict-free timestamps arose from using Org as the
back end of an iCalendar client I created for VM which exports Org
entries.  Most people who send me meeting requests use MS Outlook and
I got envious when I saw that Outlook informs them immediately of any
scheduling conflict when it processes incoming iCalendar data.
Initially, org-conflict was intended just as a Lisp predicate called
from the VM presentation buffer.  Adding an interactive mode, so that
it could be used on regular Org timestamps, was fairly easy.  Having
then added conflict resolution, I thought this might have enough
functionality to count as an Org add-on.

So here it is as the attached org-conflict.el, tested with Org 9.0 and
9.2.  Its implementation is "pure Org" and relies only on code that is
loaded anyway when Org is running.

Instead of posting a longish message to this list, I opted to explain
org-conflict in the attached FAQ document, of course a .org file.  The
added benefit being that the document is a self-contained demo.
Following the guided tour, you know after a couple of minutes
interaction if this package is for you.

If this is all tl;dr, here's org-conflict in brief:

 - compares a test time/timestamp/-range against 'org-agenda-files.
   Eligible timestamps in there are event-type, ie. contain a
   time-of-day and encode a duration

 - detects overlaps ("conflicts"), computes a resolution

 - supports intervals between events ("coffee breaks")

 - supports virtual ranges (end time is before start time)
   
 - customizable levels of automation

 - designed to be put on the C-c C-c hook, makes timestamps magic
 
 - dedicated interactive and non-interactive modes

Please let me know if this package is remotely useful, completely
misses the point or has crippling bugs and oversights.

Regards,

Thomas



org-conflict.el
Description: Binary data


org-conflict-faq.org
Description: Binary data


Re: [O] Bug: Entries with diary-sexps in "scheduled" not exported properly to calendar file (.ics file)

2019-03-26 Thread Thomas Plass


Wanrong Lin wrote at 15:20 on March 26, 2019:
: 
: As a work around, do you know if there is a way 
: to generate a series of dates / org entries from a diary-sexps? Thanks.

Evaluating those sexp is done in diary-lib.  But it's no use simply
supplying arguments to functions there as they require external setup,
in particular variables such the current DATE (mon day year), itself
coming from calendar.el.  However, it's exactly such dates that you
are looking for in the first place.  I guess, in your example
(diary-float t 1 2) you might have to loop through all the days of all
months (calendar knows about those) to see whether your sexp evaluates
to something useful.  But I haven't looked at that in detail.

Thomas



Re: [O] Bug: Entries with diary-sexps in "scheduled" not exported properly to calendar file (.ics file)

2019-03-26 Thread Thomas Plass
Hi,

Wanrong Lin wrote at 10:23 on March 26, 2019:
: 
: * TODO Do this on the second Monday every month
:   SCHEDULED: <%%(diary-float t 1 2) 19:00-20:30>
: 
: M-x org-icalendar-export-to-ics

Org agenda has its own processing of sexps, so its views are correct.
The exporter, however, uses icalendar.el for creating the iCal data.
Date processing there in `icalendar--convert-float-to-ical' is
somewhat arbitrary as per the docstring:

  "Convert float diary entry to iCalendar format -- partially unsupported!

  FIXME! DAY from diary-float yet unimplemented.

As far as the exported date is concerned, it'll always be today's
date as per this comment further down:

  ;;Start today (yes this is an arbitrary choice):

So, bug-gnu-emacs would be the list to post this issue to.

Regards

Thomas






Re: [O] [PATCH] make 'org-at-date-range-p work like org-at-timestamp-p

2019-03-19 Thread Thomas Plass
Nicolas,

thanks for taking care.  But there's another thing.

I don't know what I've done to my Org buffer, but what look like
timestamps are a mixture of element types 'timestamp and 'planning.

Anyway, 'org-at-timestamp-p returns nil for the 'planning timestamps.
Which causes breakage.

Please take a look at the patch.  It could be that 'org-check-*-date
functions might also be affected by the same problem, I haven't
tested.

Regards

Thomas

>From dda6f686e40663b1da3151686145cd125d1f88d1 Mon Sep 17 00:00:00 2001
From: Thomas Plass 
Date: Tue, 19 Mar 2019 21:24:19 +0200
Subject: [PATCH] Check timestamp contexts for both element types
 'timestamp and 'planning.

---
 lisp/org.el | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ee1082376..3f2e429dd 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15178,10 +15178,10 @@ When matching, the match groups are the following:
  (and (bound-and-true-p
org-agenda-include-inactive-timestamps)
   (org-at-clock-log-p
-(eq 'timestamp
-(save-excursion
-  (when (= pos (cdr boundaries)) (forward-char -1))
-  (org-element-type (org-element-context)))
+(memq (save-excursion
+(when (= pos (cdr boundaries)) (forward-char 
-1))
+(org-element-type (org-element-context)))
+   '(timestamp planning)
 (cond
  ((not match?)nil)
  ((= pos (match-beginning 0)) 'bracket)
-- 
2.13.1.windows.2






Re: [O] [PATCH] make 'org-at-date-range-p work like org-at-timestamp-p

2019-03-19 Thread Thomas Plass
Nicolas,

thanks for taking care.  But there's another thing.

I don't know what I've done to my Org buffer, but what look like
timestamps are a mixture of element types 'timestamp and 'planning.

Anyway, 'org-at-timestamp-p returns nil for the 'planning timestamps.
Which causes breakage.

Please take a look at the patch.  It could be that 'org-check-*-date
functions might also be affected by the same problem, I haven't
tested.

Regards

Thomas

>From dda6f686e40663b1da3151686145cd125d1f88d1 Mon Sep 17 00:00:00 2001
From: Thomas Plass 
Date: Tue, 19 Mar 2019 21:24:19 +0200
Subject: [PATCH] Check timestamp contexts for both element types
 'timestamp and 'planning.

---
 lisp/org.el | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ee1082376..3f2e429dd 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15178,10 +15178,10 @@ When matching, the match groups are the following:
  (and (bound-and-true-p
org-agenda-include-inactive-timestamps)
   (org-at-clock-log-p
-(eq 'timestamp
-(save-excursion
-  (when (= pos (cdr boundaries)) (forward-char -1))
-  (org-element-type (org-element-context)))
+(memq (save-excursion
+(when (= pos (cdr boundaries)) (forward-char 
-1))
+(org-element-type (org-element-context)))
+   '(timestamp planning)
 (cond
  ((not match?)nil)
  ((= pos (match-beginning 0)) 'bracket)
-- 
2.13.1.windows.2






Re: [O] bug? 'org-ctrl-c-ctrl-c-final-hook not run

2019-03-17 Thread Thomas Plass
Marco,

thanks for clearing this up.

Marco Wahl wrote at 20:42 on March 17, 2019:
: 
: Possibly it's a good idea to realize the implementation of your idea
: independent of C-c C-c.  And postpone the binding with C-c C-c.

I've developed something that initially started off as a predicate to
be called and used by Lisp, but adding an interactive mode was easy
and turns the whole thing into an Org add-on.

There are no inherent dependencies.  Binding with C-c C-c would just
be a recommendation to users as a convenient and natural way to access
the functionality.

On this note: is this list the proper channel to publish initial
versions of add-ons and solicit feedback?

Regards

Thoams



[O] bug? 'org-ctrl-c-ctrl-c-final-hook not run

2019-03-17 Thread Thomas Plass
This is a question for Org API users regarding
'org-ctrl-c-ctrl-c-final-hook and how it is to be understood.

As per the docstring

   This can be used to add additional functionality to the C-c C-c key
   which executes context-dependent commands.  This hook is run after
   any other test, ...

should the 'message in the hook function below be executed?

(add-hook 'org-ctrl-c-ctrl-c-final-hook
  (function (lambda ()
  (message "org-ctrl-c-ctrl-c-final-hook called from %s"
   (org-element-type (org-element-context)))
  t)))

In fact, the hook isn't run at all, although it makes no assumptions
whatsoever about its context.  

Is this the way things are intended or is this behaviour a bug?

What I'm trying to achieve is to post-process a standard Org element.
However, my target element is already taken care of by one of the
patterns in 'ctrl-c-ctrl-c, so the hook-caller is never reached.

As a workaround, I take advantage of the rest of the above docstring

   ... while ‘org-ctrl-c-ctrl-c-hook’ is run before the first test.

and add to this hook a function that recursively calls
'org-ctrl-c-ctrl-c before it does its own work - which seems
incredibly kludgy.

Thanks for any feedback.

Regards

Thomas






[O] [PATCH] make 'org-at-date-range-p work like org-at-timestamp-p

2019-03-15 Thread Thomas Plass
Hello maintainers,

it's counter-intuitive that 'org-at-date-range-p doesn't work like
'org-at-timestamp-p when point is on the leading bracket of a range.
Witness (^ = point)

<2019-12-30 Mo 12:00>
^ (org-at-timestamp-p)=> t

<2019-12-30 Mo 12:00>--<2019-12-31 Di 09:00>
^ (org-at-timestamp-p)=> t
 ^ (org-at-date-range-p)  => t
^ (org-at-date-range-p)   => nil

Is the attached patch OK?

Regards,

Thomas


>From 11424a8a8f975148a6914ba324b7e34218fed30d Mon Sep 17 00:00:00 2001
From: Thomas Plass 
Date: Fri, 15 Mar 2019 22:56:01 +0200
Subject: [PATCH] * make 'org-at-date-range-p work like org-at-timestamp-p  
 when point is on starting bracket

---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 24e1549a2..2053ae6b7 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10651,7 +10651,7 @@ on INACTIVE-OK."
   (save-excursion
 (catch 'exit
   (let ((pos (point)))
-   (skip-chars-backward "^[<\r\n")
+   (or (looking-at-p "[<[]") (skip-chars-backward "^[<\r\n"))
(skip-chars-backward "<[")
(and (looking-at (if inactive-ok org-tr-regexp-both org-tr-regexp))
 (>= (match-end 0) pos)
-- 
2.13.1.windows.2




[O] Timestamps: overnight repeater possible?

2019-03-14 Thread Thomas Plass
Hi subscribers,

can multiday timestamp ranges be made repeatable?  Case in point: I'd
like to create the timestamp(s) for an "after-hour" time span ranging
from 18:00 in the evening til the following morning 10:00, repeated
every day.

I tried these:

* Overnighter (listed for 2000-01-03 and -04 only)
  <2000-01-03 Mo 18:00>--<2000-01-04 Di 10:00>

* Overnighter (has cookie, but doesn't repeat beyond -04)
  <2000-01-03 Mo 18:00 +1d>--<2000-01-04 Di 10:00 +1d>

* 6 o'clock Repeater (repeats, but is overnight only notionally)
  <2000-01-03 Mo 18:00-10:00 +1d>

Agenda week view looks like this (when opening the last timestamp):

Week-agenda (W01):
Montag  3 Januar 2000 W01
  manual: 18:00.. (1/2):  Overnighter (listed for 2000-01-03 and -04 
only)
  manual: 18:00.. (1/2):  Overnighter (has cookie, but doesn't repeat 
beyond -04)
  manual: 18:00-10:00 6 o'clock Repeater (repeats, but is overnight only 
notionally)
Dienstag4 Januar 2000
  manual: 10:00.. (2/2):  Overnighter (listed for 2000-01-03 and -04 
only)
  manual: 10:00.. (2/2):  Overnighter (has cookie, but doesn't repeat 
beyond -04)
  manual: 18:00-10:00 6 o'clock Repeater (repeats, but is overnight only 
notionally)
Mittwoch5 Januar 2000
  manual: 18:00-10:00 6 o'clock Repeater (repeats, but is overnight only 
notionally)
Donnerstag  6 Januar 2000
  manual: 18:00-10:00 6 o'clock Repeater (repeats, but is overnight only 
notionally)
Freitag 7 Januar 2000
  manual: 18:00-10:00 6 o'clock Repeater (repeats, but is overnight only 
notionally)
Samstag 8 Januar 2000
  manual: 18:00-10:00 6 o'clock Repeater (repeats, but is overnight only 
notionally)
Sonntag 9 Januar 2000
  manual: 18:00-10:00 6 o'clock Repeater (repeats, but is overnight only 
notionally)

I'd like the "Overnighter" to be listed for every day.

Thanks for any suggestions!

Thomas