Re: Proposal: do not align tags in Agenda

2020-10-04 Thread Michaël Cadilhac
Hello Kyle,

Thanks very much for your feedback.  As these are changes I made
months ago, I forgot the … finer details—I basically got my narrative
completely wrong, my apologies.

My problem wasn't at all, as you point out, that the tag would erase the entry.

It has to do with habits: The habit graph overwrites anything else.  I
like having org-agenda-tags-column to a low value (wide screen), but
tags are crucial to my workflow, so them being overwritten is
problematic.

My previous patch is completely overkill for that purpose (it's even
misguided since it does stem from a misunderstanding of tags
alignment).  Here's a simpler patch.  It may be a matter of taste,
though.

Cheers,
M.


On Tue, Sep 29, 2020 at 10:36 PM Kyle Meyer  wrote:
>
> Michaël Cadilhac writes:
>
> > Hello all,
> >
> > I have a wide screen, which makes right edge alignment of tags in the
> > agenda inconvenient (they're hard to match with the main entry).
> > Setting org-agenda-tags-column to a specific column overwrites part of
> > the entry, which is not optimal.  I'd simply want the tag to be put
> > _after_ the entry.
>
> Hmm, I don't think it's supposed to overwrite part of the entry.  I
> haven't been able to trigger that on my end.  Here's the setup I tried
> with an otherwise vanilla configuration:
>
> (setq org-agenda-files (list "/tmp/scratch.org"))
> (setq org-agenda-tags-column 25)
>
> where /tmp/scratch.org looks like this
>
> * TODO foo bar baz  
> :one:
> * TODO b
> :two:
>
> When I run org-todo-list, the longer top entry isn't overwritten:
>
> Global list of TODO items of type: ALL
> Press ‘N r’ (e.g. ‘0 r’) to search again: (0)[ALL] (1)TODO (2)DONE
>   scratch:TODO foo bar baz :one:
>   scratch:TODO b :two:
>
> What am I missing?
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index e4a334dbd..a80123853 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -9080,6 +9080,10 @@ current line."
 	(goto-char (match-beginning 1))
 	(delete-region (save-excursion (skip-chars-backward " \t") (point))
 		   (point))
+	(when (get-text-property (point) 'org-habit-p)
+	  (setq c (max c (+ 1 org-habit-graph-column
+			org-habit-preceding-days
+			org-habit-following-days
 	(insert (org-add-props
 		(make-string (max 1 (- c (current-column))) ?\s)
 		(plist-put (copy-sequence (text-properties-at (point)))


Proposal: do not align tags in Agenda

2020-09-24 Thread Michaël Cadilhac
Hello all,

I have a wide screen, which makes right edge alignment of tags in the
agenda inconvenient (they're hard to match with the main entry).
Setting org-agenda-tags-column to a specific column overwrites part of
the entry, which is not optimal.  I'd simply want the tag to be put
_after_ the entry.  The attached patch is what I've been using for the
past month, and it seems to work alright.

Thoughts for/against?

Stay safe,
M.
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index e4a334dbd..792348e4c 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1912,6 +1912,7 @@ character screen."
   :group 'org-agenda-line-format
   :type '(choice
 	  (const :tag "Automatically align to right edge of window" auto)
+	  (const :tag "Do not align" nil)
 	  (integer :tag "Specific column" -80))
   :package-version '(Org . "9.1")
   :version "26.1")
@@ -9073,13 +9074,20 @@ current line."
  (if (memq 'org-tag prop)
  prop
    (cons 'org-tag prop))
-	(setq l (string-width (match-string 1))
-	  c (if (< org-agenda-tags-column 0)
-		(- (abs org-agenda-tags-column) l)
-		  org-agenda-tags-column))
+	(when org-agenda-tags-column
+	(setq l (string-width (match-string 1))
+		  c (if (< org-agenda-tags-column 0)
+			(- (abs org-agenda-tags-column) l)
+		  org-agenda-tags-column)))
 	(goto-char (match-beginning 1))
 	(delete-region (save-excursion (skip-chars-backward " \t") (point))
 		   (point))
+	(unless org-agenda-tags-column
+	  (setq c (if (get-text-property (point) 'org-habit-p)
+		  (+ 1 org-habit-graph-column
+			 org-habit-preceding-days
+			 org-habit-following-days)
+		(current-column
 	(insert (org-add-props
 		(make-string (max 1 (- c (current-column))) ?\s)
 		(plist-put (copy-sequence (text-properties-at (point)))


Re: Why is Babel-C trimming its output?

2020-07-17 Thread Michaël Cadilhac
Thanks for the investigation Ian.  So, since the tests run just fine
without it, and it offers an inconsistent and at times detrimental
feature, can we consider removing it, and/or adding some options for
that?

I'd be fine having to flag my src-block with a ":verbatim t" option to
make sure that the output is not mangled.

Thoughts?

On Fri, Jul 17, 2020 at 7:30 AM ian martins  wrote:
>
> Fortunately the author wrote tests, so we can tie the behavior of the code to 
> use cases. Unfortunately all the tests pass with the call to org-trim 
> removed. Also the call is there from the first commit of the file in git, so 
> there's no commit message to explain.
>
> My guess is that it was added to clean up cases that resulted in extra 
> trailing whitespace, but I dunno.
>
>
> On Wed, Jul 15, 2020 at 7:12 PM Michaël Cadilhac  
> wrote:
>>
>> Hello,
>>
>> Quick question here: in ob-C.el, before returning the output of a C
>> file, there's this line:
>>
>> (setq results (org-trim (org-remove-indentation results)))
>>
>> That seems quite arbitrary; is it on purpose?  I have a C file that
>> outputs some sort of list of formatted numbers, e.g.:
>>
>>   0  -17.8
>>  404.4
>>  80   26.7
>> 120   48.9
>>
>> and only the first line gets trimmed, leading to a faulty output.
>>
>> This does not seem to be a universal thing in Babel; for instance:
>>
>> #+begin_src emacs-lisp :exports both :results value raw
>>   " 0\n 1\n2\n"
>> #+end_src
>>
>> …results in:
>>
>> #+RESULTS:
>>  0
>>  1
>> 2
>>
>> But the same thing in C:
>>
>> #+begin_src C :exports both :results output raw
>>   printf (" 0\n 1\n2\n");
>> #+end_src
>>
>> …results in:
>> #+RESULTS:
>> 0
>>  1
>> 2
>>
>> Cheers,
>> M.
>>



Why is Babel-C trimming its output?

2020-07-15 Thread Michaël Cadilhac
Hello,

Quick question here: in ob-C.el, before returning the output of a C
file, there's this line:

(setq results (org-trim (org-remove-indentation results)))

That seems quite arbitrary; is it on purpose?  I have a C file that
outputs some sort of list of formatted numbers, e.g.:

  0  -17.8
 404.4
 80   26.7
120   48.9

and only the first line gets trimmed, leading to a faulty output.

This does not seem to be a universal thing in Babel; for instance:

#+begin_src emacs-lisp :exports both :results value raw
  " 0\n 1\n2\n"
#+end_src

…results in:

#+RESULTS:
 0
 1
2

But the same thing in C:

#+begin_src C :exports both :results output raw
  printf (" 0\n 1\n2\n");
#+end_src

…results in:
#+RESULTS:
0
 1
2

Cheers,
M.



Re: [O] org-icalendar: Change dates to today in VEVENT export

2019-09-15 Thread Michaël Cadilhac
Hi there,

On Thu, 5 Sep 2019 at 11:53, Nicolas Goaziou  wrote:

> Michaël Cadilhac  writes:

> > +(defun org-icalendar-today-timestamp ()
> > +  "Return a TIMESTAMP object for today, at 00:00."
> > +  (let ((dt (decode-time)))
> > +(list 'timestamp
> > +   (nconc (list :year-start (nth 5 dt)
> > +:year-end (nth 5 dt)
> > +:month-start (nth 4 dt)
> > +:month-end (nth 4 dt)
> > +:day-start (nth 3 dt)
> > +:day-end (nth 3 dt))
>
> This function already exists: `org-timestamp-from-time'. Could you use
> that instead?

Right, you pointed this out the first time, and I forgot to address
this: How would you build such a timestamp *with the -end bits* using
org-timestamp-from-time?  It seems that
org-icalendar-convert-timestamp expects that these be filled.

Thanks,
M.



[O] Scheduling in a narrowed subtree: Bug?

2019-09-09 Thread Michaël Cadilhac
Is this the expected behavior?

1. Create an empty org file
2. Insert
* Test
* Test 2
3. With the cursor at Test, hit C-x n s to narrow the view to the Test
subtree
4. Hit C-c C-s to schedule the line at any date.

As a result, the SCHEDULED keyword is _not_ included in the narrow view,
and inserting things after the Test heading moves the SCHEDULED keyword
away from its second-line position.

Cheers,
Michaël


Re: [O] org-clock: Custom shortcuts for C-u C-c C-x C-i

2019-08-30 Thread Michaël Cadilhac
By the way, I've been using this for quite some time, and I find it quite
useful.  It may be worth considering it for inclusion—see attached patch.
Opinions?



On Thu, 14 Feb 2019 at 06:32, Michaël Cadilhac 
wrote:

> Hi Leo;
>
> On Wed, 13 Feb 2019 at 17:46, Leo Gaspard  wrote:
> > Michaël Cadilhac  writes:
> > > This is not possible out of the box; can you say a bit more about how
> > > you expect to indicate which tasks are to be always present?
> >
> > I would be thinking of something like defining a list of key -> link to
> > a task (that may be generated with org-id's task ID, [[*foobar]] links
> > or whatever) in my `init.el`.
>
> Alright, can you give this patch a spin and see if that's what you want?
>
> Cheers;
> M.
>
From aef6f6d3ab553ff83f5cc9b7c0ad26c5cd2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Fri, 30 Aug 2019 12:28:58 -0500
Subject: [PATCH] org-clock: let user provide a list of default clock-in tasks.

* lisp/org-clock.el (org-clock-default-tasks): New variable.
(org-clock-select-task): Implement it.
---
 lisp/org-clock.el | 21 +
 1 file changed, 21 insertions(+)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 9e64645cb..b8523e3e1 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -168,6 +168,18 @@ which case all digits and capital letters are used up by the
   :group 'org-clock
   :type 'integer)
 
+(defcustom org-clock-default-tasks nil
+  "Default tasks that always appear in the clock-in dialog.
+This should be a list of pairs (KEY . ID), where KEY is the key
+used to select the task, and ID is the unique identifier of the
+task."
+  :group 'org-clock
+  :version "26.2"
+  :package-version '(Org . "9.3")
+  :type '(repeat (cons :tag "Key and ID"
+		   (character :tag "Access key")
+		   (string:tag "Task ID"
+
 (defcustom org-clock-goto-may-find-recent-task t
   "Non-nil means `org-clock-goto' can go to recent task if no active clock."
   :group 'org-clock
@@ -626,6 +638,15 @@ there is no recent clock to choose from."
 		   (+ i (- ?A 10))) m))
 	(if (fboundp 'int-to-char) (setf (car s) (int-to-char (car s
 	(push s sel-list)))
+	(let (has-elt m)
+	  (dolist (charid org-clock-default-tasks)
+	;; Only add tasks that actually exist
+	(when (setq m (org-id-find (cdr charid) 'marker))
+	  (unless has-elt
+		(setq has-elt t)
+		(insert (org-add-props "Default Tasks\n" nil 'face 'bold)))
+	  (setq s (org-clock-insert-selection-line (car charid) m))
+	  (push s sel-list
 	(run-hooks 'org-clock-before-select-task-hook)
 	(goto-char (point-min))
 	;; Set min-height relatively to circumvent a possible but in
-- 
2.23.0



Re: [O] Can I get the results of shell code block when exit code is non-zero?

2019-08-29 Thread Michaël Cadilhac
Hi there,

This is the expected behavior, implemented in `org-babel-eval`. (By the
way, the docline of `org-babel-sh-evaluate` seems to talk about a different
function.)

As a workaround, you could define a new shell that always returns 0:

(push "0bash" org-babel-shell-names)
(org-babel-shell-initialize)
(defun org-babel-execute:0bash (body params)
  "Execute a block of bash commands with Babel, returning 0."
  (let ((shell-file-name "bash"))
(org-babel-execute:shell (concat "trap 'exit 0' EXIT\n" body) params)))

—This is called 0bash because there are special treatments if the shell
name ends with "bash", see `org-babel--variable-assignments:bash`.

Cheers,
M.

On Thu, 29 Aug 2019 at 02:10, Marcin Borkowski  wrote:

> Hi all,
>
> apparently when the exit code of the last command in a shell code block
> is not zero, I do not get the results.  This doesn't seem to be
> documented in the manual (though I might be missing something).  Check
> this:
>
> #+begin_src bash :results verbatim
>   echo hello world
>   exit 0
> #+end_src
>
> and this:
>
> #+begin_src bash :results verbatim
>   echo hello world
>   exit 1
> #+end_src
>
> How can I tell Org to put the results in the file anyway?  My use case
> is =diff=, which exists with status 1 if differences are found, and this
> is a blog post, so I do not want to pollute the post with an =exit 0= at
> the end of the code snippet.
>
> TIA,
>
> --
> Marcin Borkowski
> http://mbork.pl
>
>


[O] HTML export with LaTeX babel blocks

2019-08-28 Thread Michaël Cadilhac
My goal is to export SVG files of TikZ drawings in HTML.  Now, what follows
is a bit of a rant on `org-babel-execute:latex`; let's go through the
options:

- You're exporting to PNG without imagemagick:
This uses `org-create-formula-image` which works really well, but it
discards the options of the LaTeX block (fit, width, height, ...),
including headers.  It also fails to *force* using 'dvipng as processing
type, so if `org-preview-latex-default-process` has been changed, it may be
confusing.  Finally, it uses `in-buffer` to render LaTeX as if it were in
the buffer, which is not what the user would want since they are exporting
to html (as a result, I get a black background on my pictures, since my
buffer background is black).

- You're exporting to PNG with imagemagick or to PDF:
This may work.  Sadly, "#+LATEX_HEADER:" is ignored, though it is in the
previous case.

- You're exporting to HTML.  This uses htlatex—it's very rarely functional,
but eh, you asked for TeX to HTML, and pdf2htmlEX seems unmaintained, so
expect chaos.

- You're exporting to SVG.
This… uses htlatex?  Why in paradise?  org-create-formula-image would do
that *brilliantly.  *In any case, I can't seem to make it work: my fonts
are always disappearing.

So what do I do?  I use the attached patch, that bypasses `htlatex` and
uses the oh-so-working `org-create-formula-image`.  This, of course, is not
a complete solution—this whole function is messy at best, buggy at
worst—but in the meantime, I can finally export my pictures to SVG (end
result: https://autoboz.org/open-problems/19.1-ccra/).

If anyone has an opinion on what to do with this situation, I'd be happy to
help.

Cheers,
M.
From 7f2cbee0e45ba6a57c913ed49690262401e67f39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Thu, 15 Aug 2019 10:28:27 -0400
Subject: [PATCH] ob-latex: Use org-create-formula-image when generating SVG

* lisp/ob-latex.el (org-babel-execute:latex): Remove convoluted and
buggy htlatex based SVG generation, and use `org-create-formula-image`
---
 lisp/ob-latex.el | 37 ++---
 1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el
index adf83d460..02ddfa2a8 100644
--- a/lisp/ob-latex.el
+++ b/lisp/ob-latex.el
@@ -114,14 +114,13 @@ This function is called by `org-babel-execute-src-block'."
 	  (when (file-exists-p out-file) (delete-file out-file))
 	  (with-temp-file out-file
 	(insert body)))
-	 ((and (or (string= "svg" extension)
-		   (string= "html" extension))
+	 ;; TODO: this is a very different way of generating the
+	 ;; frame latex document than in the pdf case.  Ideally, both
+	 ;; would be unified.  This would prevent bugs creeping in
+	 ;; such as the one fixed on Aug 16 2014 whereby :headers was
+	 ;; not included in the SVG/HTML case.
+	 ((and (string= "html" extension)
 	   (executable-find org-babel-latex-htlatex))
-	  ;; TODO: this is a very different way of generating the
-	  ;; frame latex document than in the pdf case.  Ideally, both
-	  ;; would be unified.  This would prevent bugs creeping in
-	  ;; such as the one fixed on Aug 16 2014 whereby :headers was
-	  ;; not included in the SVG/HTML case.
 	  (with-temp-file tex-file
 	(insert (concat
 		 "\\documentclass[preview]{standalone}
@@ -143,23 +142,14 @@ This function is called by `org-babel-execute-src-block'."
 	  (when (file-exists-p out-file) (delete-file out-file))
 	  (let ((default-directory (file-name-directory tex-file)))
 	(shell-command (format "%s %s" org-babel-latex-htlatex tex-file)))
-	  (cond
-	   ((file-exists-p (concat (file-name-sans-extension tex-file) "-1.svg"))
-	(if (string-suffix-p ".svg" out-file)
-		(progn
-		  (shell-command "pwd")
-		  (shell-command (format "mv %s %s"
-	 (concat (file-name-sans-extension tex-file) "-1.svg")
-	 out-file)))
-	  (error "SVG file produced but HTML file requested")))
-	   ((file-exists-p (concat (file-name-sans-extension tex-file) ".html"))
-	(if (string-suffix-p ".html" out-file)
-		(shell-command "mv %s %s"
-			   (concat (file-name-sans-extension tex-file)
-   ".html")
-			   out-file)
-	  (error "HTML file produced but SVG file requested")
+	  (when (file-exists-p (concat (file-name-sans-extension tex-file) ".html"))
+	(shell-command "mv %s %s"
+			   (concat (file-name-sans-extension tex-file)
+   ".html")
+			   out-file)))
+	 ((string= "svg" extension)
+	  (org-create-formula-image
+   body out-file org-format-latex-options nil 'dvisvgm))
 	 ((or (string= "pdf" extension) imagemagick)
 	  (with-temp-file tex-file
 	(require 'ox-latex)
-- 
2.22.0



Re: [O] [Patch] Hide the file column in a clock report.

2019-08-28 Thread Michaël Cadilhac
Here attached.  Let me know if that's all good!

Cheers,
M.

On Sun, 3 Sep 2017 at 03:15, Nicolas Goaziou  wrote:

> Hello,
>
> Michaël Cadilhac  writes:
>
> > From f251bf0fa764e245eabe88e3959e801af5c8fd37 Mon Sep 17 00:00:00 2001
> > From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
> > Date: Thu, 31 Aug 2017 19:37:55 +0100
> > Subject: [PATCH] Add the option of hiding the file column in a clock
> > report
>
> Thank you.
>
> We are in feature-freeze phase, but it can go in master once Org 9.1 is
> released.
>
> Could you provide tests in "test-org-clock.el"? This can be named
> "test-org-clock/clocktable/hidefiles". There are examples in the file.
>
> Regards,
>
> --
> Nicolas Goaziou
>
From 77006082d020f26147e9412e10d07a9a2ac50cb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Sun, 10 Mar 2019 19:05:10 +
Subject: [PATCH 1/3] org-clock.el: Add an option to not show the file column
 in clock report

* lisp/org-clock.el (org-clocktable-defaults): Add `hidefiles'.
(org-dblock-write:clocktable): Implement not showing files when
`hidefiles' is true.
* lisp/org-pcomplete.el: Add `hidefiles'.
---
 lisp/org-clock.el | 5 -
 lisp/org-pcomplete.el | 5 +++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index bf9053ec2..8af59e705 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -304,6 +304,7 @@ string as argument."
:link nil
:narrow '40!
:indent t
+   :hidefiles nil
:formula nil
:timestamp nil
:level nil
@@ -2391,6 +2392,7 @@ the currently selected interval size."
 	   (ws (plist-get params :wstart))
 	   (ms (plist-get params :mstart))
 	   (step (plist-get params :step))
+	   (hide-files (plist-get params :hidefiles))
 	   (formatter (or (plist-get params :formatter)
 			  org-clock-clocktable-formatter
 			  'org-clocktable-write-default))
@@ -2445,7 +2447,8 @@ the currently selected interval size."
 	 ;; Even though `file-with-archives' can consist of
 	 ;; multiple files, we consider this is one extended file
 	 ;; instead.
-	 (and (consp files) (not (eq scope 'file-with-archives)
+	 (and (not hide-files)
+		  (consp files) (not (eq scope 'file-with-archives)
 
 	(funcall formatter
 		 origin
diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index 70a8173d8..9e68c7dc1 100644
--- a/lisp/org-pcomplete.el
+++ b/lisp/org-pcomplete.el
@@ -430,8 +430,9 @@ switches."
 			   ":tstart" ":tend" ":block" ":step"
 			   ":stepskip0" ":fileskip0"
 			   ":emphasize" ":link" ":narrow" ":indent"
-			   ":tcolumns" ":level" ":compact" ":timestamp"
-			   ":formula" ":formatter" ":wstart" ":mstart"
+			   ":hidefiles" ":tcolumns" ":level" ":compact"
+			   ":timestamp" ":formula" ":formatter"
+			   ":wstart" ":mstart"
 
 
 ;;; Finish up
-- 
2.22.0

From a8e4d713e7c9d6a3ad0b5d0e3244c685bbef2163 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Wed, 28 Aug 2019 18:15:40 -0500
Subject: [PATCH 2/3] Add test for the hidefiles parameter in clocktables.

* testing/lisp/test-org-clock.el (test-org-clock/clocktable/hidefiles):
Add test.
---
 testing/lisp/test-org-clock.el | 17 +
 1 file changed, 17 insertions(+)

diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index fa336f680..ad75a2ba5 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -1175,6 +1175,23 @@ CLOCK: [2017-10-02 Mon 11:00]--[2017-10-02 Mon 13:00] =>  2:00"
   (test-org-clock-clocktable-contents
":step week :block 2017-10 :stepskip0 t"))
 
+(ert-deftest test-org-clock/clocktable/hidefiles ()
+  "Test \":hidefiles\" parameter in Clock table."
+  ;; Test that hidefiles removes the file column.
+  (should
+   (equal
+"| Headline | Time   |
+|--+|
+| *Total time* | *1:00* |
+|--+|
+| Test | 1:00   |"
+(org-test-with-temp-text-in-file
+"* Test
+CLOCK: [2012-03-29 Thu 16:00]--[2012-03-29 Thu 17:00] =>  1:00"
+  (let ((the-file (buffer-file-name)))
+(org-test-with-temp-text-in-file ""
+  (test-org-clock-clocktable-contents
+   (format ":hidefiles t :scope (lambda () (list %S))" the-file
 
 (provide 'test-org-clock)
 ;;; test-org-clock.el end here
-- 
2.22.0

From cc6744a089199a913cd602539990097c5fe691e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Wed, 28 Aug 2019 18:22:46 -0500
Subjec

Re: [O] org-icalendar: Change dates to today in VEVENT export

2019-08-28 Thread Michaël Cadilhac
Hopefully I didn't miss anything—I've been running the patched version for
weeks now, so it should be stable in any case.  Patch 0003 above should
still be OK.

Cheers,
M.


On Tue, 12 Feb 2019 at 02:34, Nicolas Goaziou 
wrote:

> Hello,
>
> Michaël Cadilhac  writes:
>
> > Well, certainly.  I may not have had the best discipline in writing
> > these, so turning them into patches is a bit painful.  Let me know if
> > I can make things better.  (I believe my FSF paperwork is still
> > alright, if need be.)
>
> Thank you! Comments follow.
>
> > +(defcustom org-icalendar-bump-todos nil
> > +  "Non-nil means that pending TODO VEVENTs are bumped to today.
> > +In addition, if non-nil, the number of late days is indicated in the
> summary."
> > +  :group 'org-export-icalendar
> > +  :type 'boolean)
>
> This variable is missing :package-version '(Org . "9.3") and :safe
> keywords.  This is also true for other defcustom introduced throughout
> your patches.
>
> > +(defun org-icalendar-today-timestamp ()
> > +  "Return a TIMESTAMP object for today, at 00:00."
> > +  (let ((dt (decode-time)))
> > +(list 'timestamp
> > +   (nconc (list :year-start (nth 5 dt)
> > +:year-end (nth 5 dt)
> > +:month-start (nth 4 dt)
> > +:month-end (nth 4 dt)
> > +:day-start (nth 3 dt)
> > +:day-end (nth 3 dt))
>
> This function already exists: `org-timestamp-from-time'.
>
> > +(defun org-icalendar-days-until-timestamp (timestamp)
> > +  "Return the number of days until TIMESTAMP.
> > +
> > +If TIMESTAMP occurs today, return 0.
> > +If TIMESTAMP occurs yesterday, return -1."
> > +  (floor
> > +   (/ (float-time
> > +   (time-subtract (org-timestamp--to-internal-time timestamp)
> > +   (apply 'encode-time
> > +  (append '(0 0 0) (nthcdr 3 (decode-time))
>
> (time-substract (org-timestamp-to-time timestamp)
> (current-time))
>
> > +  (* 60 60 24
> >
> > -   (concat "DL: " summary) loc desc cat tz class)))
> > +(concat "DL: " summary) loc desc cat tz class))
> > +
>
> Spurious blank line.
>
> > +  ;; Case 2: pending TODO overdue and should bump.
> > +  ((and org-icalendar-bump-todos
> > +(< days-until-deadline 0))
> > +   (org-icalendar--vevent
> > +entry (org-icalendar-today-timestamp) (concat "DL-" uid)
> > +(concat "DL (" (number-to-string (-
> days-until-deadline))
> > +"x): " summary)
>
> Nitpick:
>
>   (format "DL (%d)x): %s" (- days-until-deadline) summary
>
> is more readable.
>
> > +loc desc cat tz class))
> > +  ;; Case 3: in the future and should warn.
> > +  (t
> > +   (concat
> > +;; If in the warning zone.
> > +(when (<= days-until-deadline org-deadline-warning-days)
> > +  (org-icalendar--vevent
> > +   entry (org-icalendar-today-timestamp) (concat "DL-"
> uid)
> > +   (concat "DL (in " (number-to-string
> days-until-deadline)
> > +   "d.): " summary)
>
> See above.
>
> > +  ;; Overdue and should bump.
> > +  (t
> > +   (org-icalendar--vevent
> > +entry (org-icalendar-today-timestamp) (concat "SC-" uid)
> > +(concat "S (" (number-to-string (-
> days-until-scheduled)) "x): "
> > +summary)
>
> Ditto.
>
> > Subject: [PATCH 2/6] Include tags in SUMMARY if so desired.
>
> I'm ignoring this patch since it is superseded by the fifth.  Could you
> merge them?
>
> >  #+vindex: org-icalendar-categories
> >  #+vindex: org-icalendar-alarm-time
> > +#+vindex: org-icalendar-summary-uses-tags
> >  For tags on the headline, the iCalendar export back-end makes them
> >  into iCalendar categories.  To tweak the inheritance of tags and TODO
> >  states, configure the variable ~org-icalendar-categories~.  To assign
> >  clock alarms based on time, configure the ~org-icalendar-alarm-time~
> > -variable.
> > +variable.  Additionally, the variable
> > +~org-icalendar-summary-uses

Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-08-28 Thread Michaël Cadilhac
Apologies for the delay.

Is that alright?

On Thu, 14 Feb 2019 at 17:15, Nicolas Goaziou 
wrote:

> Michaël Cadilhac  writes:
>
> > Will do.  This in particular requires to swap fontifying the drawers
> > and the keywords (since :END: and :PROPERTIES: are keywords):
>
> [...]
>
> > Agreed?
>
> Sure. Please do what is necessary ;)
>
From aebea2663b929f0dbf8e1408c9ddb85f210e2c0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Wed, 28 Aug 2019 16:26:06 -0500
Subject: [PATCH] Fontify drawers correctly.

* lisp/org.el (org-fontify-drawers): Fix face used, fix range of text
properties.
(org-set-font-lock-defaults): Fontify drawers after keywords.
---
 lisp/org.el | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ea2c75130..31faac516 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5356,9 +5356,10 @@ by a #."
   "Fontify drawers."
   (when (re-search-forward org-drawer-regexp limit t)
 (add-text-properties
- (match-beginning 0) (match-end 0)
- '(font-lock-fontified t face org-special-keyword))
-(org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
+ (line-beginning-position) (line-beginning-position 2)
+ '(font-lock-fontified t face org-drawer))
+(org-remove-flyspell-overlays-in
+ (line-beginning-position) (line-beginning-position 2))
 t))
 
 (defun org-fontify-macros (limit)
@@ -5612,12 +5613,12 @@ needs to be inserted at a specific position in the font-lock sequence.")
 	   '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
 	   '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
 	   '("| *\\(<[lrc]?[0-9]*>\\)" (1 'org-formula t))
-	   ;; Drawers
-	   '(org-fontify-drawers)
 	   ;; Properties
 	   (list org-property-re
 		 '(1 'org-special-keyword t)
 		 '(3 'org-property-value t))
+	   ;; Drawers
+	   '(org-fontify-drawers)
 	   ;; Link related fontification.
 	   '(org-activate-links)
 	   (when (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend)))
-- 
2.22.0



[O] [PATCH] Export with verbatim LaTeX removes spaces

2019-07-08 Thread Michaël Cadilhac
Hi,

When LaTeX is exported verbatim, some spaces are lost.  Try for instance:
  M-: (let ((org-html-with-latex 'verbatim)) (org-html-export-as-html)) RET
on a buffer containing "$a$ $b$".  Post-blanks were simply not added
back, see below.

Thanks!

Cheers,
Michaël

ox.el: Add post-blanks when latex is verbatim

* lisp/ox.el (org-export--remove-uninterpreted-data): Add post-blanks
  when latex is verbatim.

TINYCHANGE
---
 lisp/ox.el | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 078efaffc..395ce7feb 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -2950,7 +2950,12 @@ returned by the function."
   ;; ... LaTeX environments and fragments...
   ((latex-environment latex-fragment)
(and (eq (plist-get info :with-latex) 'verbatim)
-(list (org-export-expand datum nil
+(list (concat
+(org-export-expand datum nil)
+(make-string
+   (or (org-element-property :post-blank datum)
+   0)
+   ?\s)
   ;; ... sub/superscripts...
   ((subscript superscript)
(let ((sub/super-p (plist-get info :with-sub-superscript))



[O] org-clock-resolving-clocks & idle

2019-02-25 Thread Michaël Cadilhac
Hi there;

CONTEXT:  When I'm idling with the clock running, Org asks if I want
to resolve the clock when I come back (this is by setting
org-clock-idle-time).

PROBLEM: I'm not sure how recent the change was, but Org started
asking me _multiple times_ what I want to do when back.

CAUSE: It seems that the mechanism that prevents multiple such
questions is broken.  It boils down to checking whether
org-clock-resolving-clocks is non-nil in org-resolve-clocks-if-idle.
The problem is that org-resolve-clocks-if-idle then calls
org-clock-resolve, which does *not* change org-clock-resolving-clocks
(that's the job of org-resolve-clocks, it seems).

POSSIBLE SOLUTION: (if we agree there is a problem) Check for
org-clock-resolving-clocks-due-to-idleness rather than
org-clock-resolving-clocks in org-resolve-clocks-if-idle.  How does
that sound?  Maybe org-clock-resolve should also set
org-clock-resolving-clocks; is there a use case where
org-clock-resolve may be called multiple times (with timers probably)
with different clocks, and we'd want all of them to prompt the user?

Cheers;
M.



[O] org-log-post-message: is it properly reset?

2019-02-22 Thread Michaël Cadilhac
Hi there;

>From time to time, I have some spurious "Entry repeats" messages when
editing tasks that have no repetition.  I've tracked that down to
org-log-post-message being message'd in org-store-log-note, and I
can't really see anywhere where the variable is reset.  Should it be
reset after it's used in org-store-log-note?

Additionally, why is it defvar'd twice?

Cheers;
M.



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-14 Thread Michaël Cadilhac
On Thu, 14 Feb 2019 at 16:11, Nicolas Goaziou  wrote:

> Would you want to provide a patch including the replacement of
> `org-special-keyword' with `org-drawer'?

Will do.  This in particular requires to swap fontifying the drawers
and the keywords (since :END: and :PROPERTIES: are keywords):

--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6255,12 +6255,12 @@ needs to be inserted at a specific position in
the font-lock sequence.")
 '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
 '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
 '("| *\\(<[lrc]?[0-9]*>\\)" (1 'org-formula t))
-;; Drawers
-'(org-fontify-drawers)
 ;; Properties
 (list org-property-re
  '(1 'org-special-keyword t)
  '(3 'org-property-value t))
+;; Drawers
+'(org-fontify-drawers)
 ;; Link related fontification.
 '(org-activate-links)
 (when (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend)))

Agreed?

Cheers;
M.



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-14 Thread Michaël Cadilhac
Hi there;

Again, thanks for your help Nicolas—that's much appreciated.

On Wed, 13 Feb 2019 at 15:55, Nicolas Goaziou  wrote:
> The face you use for drawers is, well obnoxious, to say the least. No
> wonder you find them cluttering your display.

I agree; following your advice, I took the simpler path of customizing
org-special-keyword.  By changing its height, I got a small glitch;
consider:
  https://michael.cadilhac.name/public/org-props-small-1.png
The lines with ":PROPERTIES:" did not change height; this is simply
due to the line-feed having the default face.  With:

--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5934,7 +5934,7 @@ by a #."
   "Fontify drawers."
   (when (re-search-forward org-drawer-regexp limit t)
 (add-text-properties
- (match-beginning 0) (match-end 0)
+ (match-beginning 0) (+ 1 (match-end 0))
  '(font-lock-fontified t face org-special-keyword))
 (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
 t))

I get the desired outcome:
  https://michael.cadilhac.name/public/org-props-small-2.png

(this is also where org-special-keyword should be replaced with org-drawer.)

Any thoughts?

Thanks!

Michaël



Re: [O] org-clock: Custom shortcuts for C-u C-c C-x C-i

2019-02-14 Thread Michaël Cadilhac
Hi Leo;

On Wed, 13 Feb 2019 at 17:46, Leo Gaspard  wrote:
> Michaël Cadilhac  writes:
> > This is not possible out of the box; can you say a bit more about how
> > you expect to indicate which tasks are to be always present?
>
> I would be thinking of something like defining a list of key -> link to
> a task (that may be generated with org-id's task ID, [[*foobar]] links
> or whatever) in my `init.el`.

Alright, can you give this patch a spin and see if that's what you want?

Cheers;
M.
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 343264f7e..1f0870e62 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -164,6 +164,13 @@ which case all digits and capital letters are used up by the
   :group 'org-clock
   :type 'integer)
 
+(defcustom org-clock-default-tasks nil
+  "List of pairs (KEY . ID) ..."
+  :group 'org-clock
+  :type '(repeat (cons :tag "Key and ID"
+		   (character :tag "Access char")
+		   (string:tag "Task ID"
+
 (defcustom org-clock-goto-may-find-recent-task t
   "Non-nil means `org-clock-goto' can go to recent task if no active clock."
   :group 'org-clock
@@ -622,6 +629,15 @@ there is no recent clock to choose from."
 		   (+ i (- ?A 10))) m))
 	(if (fboundp 'int-to-char) (setf (car s) (int-to-char (car s
 	(push s sel-list)))
+	(let (has-elt m)
+	  (dolist (charid org-clock-default-tasks)
+	(setq m (org-id-find (cdr charid) 'marker))
+	(when m
+	  (unless has-elt
+		(setq has-elt t)
+		(insert (org-add-props "Default Tasks\n" nil 'face 'bold)))
+	  (setq s (org-clock-insert-selection-line (car charid) m))
+	  (push s sel-list
 	(run-hooks 'org-clock-before-select-task-hook)
 	(goto-char (point-min))
 	;; Set min-height relatively to circumvent a possible but in


Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-13 Thread Michaël Cadilhac
On Wed, 13 Feb 2019 at 14:32, Nicolas Goaziou  wrote:

> Since properties drawers are almost exclusively folded, I don't think
> incriminated properties clutter display. Besides, I don't think any
> property is irrelevant to every user. How would we know?

I'd have a customizable list of unimportant/internal properties, and
if a property drawer only contains these properties, it is hidden.

You mention that these drawers don't clutter display, so as an
example, consider the following screenshot:
  https://michael.cadilhac.name/public/org-props.png
All the property drawers in that screenshot consist of "ID" elements
added by ox-icalendar.  Arguably, these properties are internal values
and their storage shouldn't interfere with the user's experience.

But I do understand being uneasy about hiding stuff.   Another
solution that would work for me would be to change the font size and
color a folded :PROPERTIES: drawer, and have a normal font when I open
the drawer.  Is there a way to do that?
I thought I could start playing with the face "org-drawer" but it
looks unused.  Any help?

Thanks!

Cheers;
M.



Re: [O] org-clock: Custom shortcuts for C-u C-c C-x C-i

2019-02-13 Thread Michaël Cadilhac
Hi there Leo;

This is not possible out of the box; can you say a bit more about how
you expect to indicate which tasks are to be always present?

A quick-and-dirty way to implement something along these lines is to
modify org-clock-history-push to always keep a selected set of markers
in org-clock-history.

Cheers;
M.

On Mon, 11 Feb 2019 at 16:32, Leo Gaspard  wrote:
>
> Hello,
>
> When I run C-u C-c C-x C-i I get a choice between the interrupted task,
> the current task, the default task and recent tasks.
>
> I however wonder whether it's possible to add in custom shortcuts to
> fixed tasks? This would help me easily clock into my “IRC”, “Mails”
> etc. tasks, to and from which I frequently switch.
>
> Do you have any idea how to accomplish that? I haven't been able to find
> anything in the manual [1].
>
> [1] https://orgmode.org/org.html#Clocking-commands
>
> Cheers, and thank you once again for this great piece of software!
>   Leo
>



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-12 Thread Michaël Cadilhac
Hi there;

Agreed, hiding properties entirely seems overkill and quite limited in
use cases.  However, I think this stems from a more general need to
hide properties that are irrelevant to the user—for instance, UIDs
created by ox-icalendar, or other internal properties.  As a user, I
see no need whatsoever to see—let alone edit—such a property, and feel
that it clutters the display.  Assuming that properties are edited
using the suitable commands, no clash would be created by having a set
P of properties such that drawers with only P-properties would be
hidden.  What do you think?

Cheers;
M.

On Tue, 12 Feb 2019 at 08:38, Nicolas Goaziou  wrote:
>
> Hello,
>
> Keith David Bershatsky  writes:
>
> > A few years ago, I wrote up an answer to my own question on
> > Stackoverflow to completely hide the :PROPERTIES: drawer, including
> > the line that says :PROPERTIES:. Since then, it has received nearly
> > 5,000 views, 11 stars, 17 upvotes on the initial question, and 15
> > upvotes on the answer.
> >
> > Today, a forum participant posted a comment underneath my answer asking why 
> > not send this upstream.  So, here is the link to the answer:
> >
> > https://stackoverflow.com/a/17492723/2112489
>
> Thank you for the suggestion.
>
> However, I think hiding completely stuff from the user is not great. How
> would you edit it, or even know there are properties there?
>
> You can write ":properties:" instead of ":PROPERTIES:", dim them with an
> appropriate face…
>
> Regards,
>
> --
> Nicolas Goaziou
>



Re: [O] org-icalendar: Change dates to today in VEVENT export

2019-02-07 Thread Michaël Cadilhac
On Thu, 7 Feb 2019 at 13:30, Nicolas Goaziou  wrote:

> If you think that's a feature Org ought to provide, please consider
> sending a patch about it.

Well, certainly.  I may not have had the best discipline in writing
these, so turning them into patches is a bit painful.  Let me know if
I can make things better.  (I believe my FSF paperwork is still
alright, if need be.)

PATCHES 0001 & 0006

ox-icalendar.el: Enable bumping overdue TODOs and deadline warnings.

* lisp/ox-icalendar.el (org-icalendar-bump-todos, org-icalendar-warn-deadlines):
New customizable variables.
(org-icalendar-today-timestamp, org-icalendar-days-until-timestamp): New
internal functions.
(org-icalendar-entry): Implement behavior.

* doc/org-manual.org (iCalendar Export): Document.


PATCHES 0002 & 0005

ox-icalendar.el: Use tags in summary, if so desired.

* lisp/ox-icalendar.el (org-icalendar-summary-uses-tags): New customizable
variable.
(org-icalendar-entry): Implement behavior.

* doc/org-manual.org (iCalendar Export): Document.


PATCH 0003

ox-icalendar.el: Add a VTIMEZONE block.

* lisp/ox-icalendar.el (org-icalendar--vcalendar): Add a VTIMEZONE block.
From c7c0f17d0902d3d89503d1dc24f248ee9bdfab1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Thu, 7 Feb 2019 12:20:51 +
Subject: [PATCH 3/6] Be a bit more compliant with iCalendar standard by having
 a VTIMEZONE block.

---
 lisp/ox-icalendar.el | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index 5e7f2804a..a5b586434 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -897,11 +897,15 @@ X-WR-CALNAME:%s
 PRODID:-//%s//Emacs with Org mode//EN
 X-WR-TIMEZONE:%s
 X-WR-CALDESC:%s
-CALSCALE:GREGORIAN\n"
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:%s
+END:VTIMEZONE\n"
 		  (org-icalendar-cleanup-string name)
 		  (org-icalendar-cleanup-string owner)
 		  (org-icalendar-cleanup-string tz)
-		  (org-icalendar-cleanup-string description))
+		  (org-icalendar-cleanup-string description)
+		  (org-icalendar-cleanup-string tz))
 	  contents
 	  "END:VCALENDAR\n"))
 
-- 
2.19.2

From 80f013e60b6a0330c5f13402ef46b1b4a68ce6aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Thu, 7 Feb 2019 12:19:28 +
Subject: [PATCH 1/6] Introduce ways to bump overdue TODOs today, and warn of
 forthcoming deadlines.

---
 lisp/ox-icalendar.el | 99 +---
 1 file changed, 93 insertions(+), 6 deletions(-)

diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index 3d6d0b263..2bf2cd89a 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -119,6 +119,20 @@ This is a list with possibly several symbols in it.  Valid symbols are:
 	  (const :tag "SCHEDULED in TODO entries become start date"
 		 todo-start)))
 
+(defcustom org-icalendar-bump-todos nil
+  "Non-nil means that pending TODO VEVENTs are bumped to today.
+In addition, if non-nil, the number of late days is indicated in the summary."
+  :group 'org-export-icalendar
+  :type 'boolean)
+
+(defcustom org-icalendar-warn-deadlines nil
+  "Non-nil means that a new VEVENT is created today to warn for deadlines.
+This only applies to TODOs that are not done.  Relies on
+`org-deadline-warning-days' for the number of days during which the warning
+is created."
+  :group 'org-export-icalendar
+  :type 'boolean)
+
 (defcustom org-icalendar-categories '(local-tags category)
   "Items that should be entered into the \"categories\" field.
 
@@ -481,6 +495,28 @@ or subject for the event."
 	(concat folded-line "\r\n " (substring line chunk-start))
 (org-split-string s "\n") "\r\n")))
 
+(defun org-icalendar-today-timestamp ()
+  "Return a TIMESTAMP object for today, at 00:00."
+  (let ((dt (decode-time)))
+(list 'timestamp
+	  (nconc (list :year-start (nth 5 dt)
+		   :year-end (nth 5 dt)
+		   :month-start (nth 4 dt)
+		   :month-end (nth 4 dt)
+		   :day-start (nth 3 dt)
+		   :day-end (nth 3 dt))
+
+(defun org-icalendar-days-until-timestamp (timestamp)
+  "Return the number of days until TIMESTAMP.
+
+If TIMESTAMP occurs today, return 0.
+If TIMESTAMP occurs yesterday, return -1."
+  (floor
+   (/ (float-time
+   (time-subtract (org-timestamp--to-internal-time timestamp)
+		  (apply 'encode-time
+			 (append '(0 0 0) (nthcdr 3 (decode-time))
+  (* 60 60 24
 
 
 ;;; Filters
@@ -567,19 +603,70 @@ inlinetask within the section."
 	  ;; "VEVENT" component from scheduled, deadline, or any
 	  ;; timestamp in the entry.
 	  (let ((deadline (org-element-property :deadline entry)))
-	(and deadline
+	(when (and deadline
 		   (memq (if todo-type 'event-if-todo 'event-if-not-todo)
-		   org-icalendar-use-deadline)
+			 

Re: [O] org-icalendar: Change dates to today in VEVENT export

2019-02-07 Thread Michaël Cadilhac
Alright, so I guess this is indeed not doable out of the box.  I've
implemented this on my fork of org-mode:
   https://code.orgmode.org/michaelcadilhac/org-mode
(Also two more things that may be of interest: Include tags in summaries,
and give a bit more information about the timezone—ical.js does not
recognize X-WR-TIMEZONE.)

Hopefully this will be useful for someone :-)

Cheers;
M.

On Fri, 1 Feb 2019 at 12:47, Michaël Cadilhac  wrote:

> Hi there yall;
>
> I use org-icalendar to export my TODOs and events to an ics, that is then
> imported in Google Calendar.  As far as I can see, Google Calendar still
> doesn't support VTODOs, so only the VEVENTs are relevant.  *My goal is to
> have my day on Google Calendar looks like my Org Agenda; *in particular
> this means:
>
> 1.   I want my repeats to appear today.
>
> To do this, I have to artificially bump the timestamp of the VEVENTs that
> correspond to a not-DONE TODO to today (and maybe add the "72x" indicating
> that the TODO was scheduled 72 days ago).  How can I do that?
>
> I believe this is not doable out of the box and that I'll have to
> modify org-icalendar-entry; is that correct?
>
> 2.   I want my DEADLINEs to show up `org-deadline-warning-days` days
> before in the export.
>
> Again this means that I have to artificially change the date of the VEVENT
> (and maybe add the "in 6d.").  How can I do that?
>
> Thanks very much!
>
> Cheers;
> M.
>


[O] org-icalendar: Change dates to today in VEVENT export

2019-02-01 Thread Michaël Cadilhac
Hi there yall;

I use org-icalendar to export my TODOs and events to an ics, that is then
imported in Google Calendar.  As far as I can see, Google Calendar still
doesn't support VTODOs, so only the VEVENTs are relevant.  *My goal is to
have my day on Google Calendar looks like my Org Agenda; *in particular
this means:

1.   I want my repeats to appear today.

To do this, I have to artificially bump the timestamp of the VEVENTs that
correspond to a not-DONE TODO to today (and maybe add the "72x" indicating
that the TODO was scheduled 72 days ago).  How can I do that?

I believe this is not doable out of the box and that I'll have to
modify org-icalendar-entry; is that correct?

2.   I want my DEADLINEs to show up `org-deadline-warning-days` days before
in the export.

Again this means that I have to artificially change the date of the VEVENT
(and maybe add the "in 6d.").  How can I do that?

Thanks very much!

Cheers;
M.


[O] [PATCH] org.el: Fix typo

2018-10-09 Thread Michaël Cadilhac
Hi there;

Smallest possible typo. :-)

Cheers;
M.
From 18461bcddf8549f03f5a57128900c3d56b6a7381 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Tue, 9 Oct 2018 17:57:55 +0100
Subject: [PATCH] org.el: Fix typo

* lisp/org.el (org-enforce-todo-checkbox-dependencies): Fix typo.

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

diff --git a/lisp/org.el b/lisp/org.el
index e3866c2..2b7d16c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2822,7 +2822,7 @@ When non-nil, you first need to check off all check boxes before the TODO
 entry can be switched to DONE.
 This variable needs to be set before org.el is loaded, and you need to
 restart Emacs after a change to make the change effective.  The only way
-to change is while Emacs is running is through the customize interface."
+to change it while Emacs is running is through the customize interface."
   :set (lambda (var val)
 	 (set var val)
 	 (if val
-- 
2.19.0



Re: [O] [Patch] Hide the file column in a clock report.

2017-09-02 Thread Michaël Cadilhac
On 2 September 2017 at 03:20, Adam Porter  wrote:
> One suggestion:
>
> +:hidefiles   @r{Should the file column be hidden when multiple files are 
> parsed?}
>
> It would be clearer if it said something like, "Hide file column when
> multiple files are parsed."  The other options mentioned there are
> written like that, not as questions.  :)

While I definitely agree that question form is weird, I copied it from
the ":level" option (arguably without thinking twice) which reads:

:level   @r{Should a level number column be included?}

In any case, let's not repeat that oddity :-)  I've changed the patch
according to your suggestion.

Cheers;
M.
From f251bf0fa764e245eabe88e3959e801af5c8fd37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Thu, 31 Aug 2017 19:37:55 +0100
Subject: [PATCH] Add the option of hiding the file column in a clock report

* contrib/orgmanual.org: Document the change.
* doc/org.texi (The clock table): Ditto.
* lisp/org-clock.el (org-clocktable-defaults): Add default value for
  :hidefiles.
(org-dblock-write:clocktable): Do not make "multiline" true if
hidefiles is.
* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/clocktable):
  Add :hidefiles to completions.

TINYCHANGE
---
 contrib/orgmanual.org | 4 
 doc/org.texi  | 1 +
 lisp/org-clock.el | 5 -
 lisp/org-pcomplete.el | 5 +++--
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/contrib/orgmanual.org b/contrib/orgmanual.org
index 6cc88a86e..e184fb51d 100644
--- a/contrib/orgmanual.org
+++ b/contrib/orgmanual.org
@@ -6253,6 +6253,10 @@ but you can specify your own function using the ~:formatter~ parameter.
 
   Indent each headline field according to its level.
 
+- :hidefiles ::
+
+  Hide the file column when multiple files are used to produced the table.
+
 - :tcolumns ::   
 
   Number of columns to be used for times.  If this is smaller than
diff --git a/doc/org.texi b/doc/org.texi
index a74f967f5..2c2f8d0cc 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6689,6 +6689,7 @@ but you can specify your own function using the @code{:formatter} parameter.
  @r{the org table.  If you write it like @samp{50!}, then the}
  @r{headline will also be shortened in export.}
 :indent  @r{Indent each headline field according to its level.}
+:hidefiles   @r{Hide file column when multiple files are parsed.}
 :tcolumns@r{Number of columns to be used for times.  If this is smaller}
  @r{than @code{:maxlevel}, lower levels will be lumped into one column.}
 :level   @r{Should a level number column be included?}
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 6b967c673..05c46e18c 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -298,6 +298,7 @@ string as argument."
:link nil
:narrow '40!
:indent t
+   :hidefiles nil
:formula nil
:timestamp nil
:level nil
@@ -2391,6 +2392,7 @@ the currently selected interval size."
 	   (ws (plist-get params :wstart))
 	   (ms (plist-get params :mstart))
 	   (step (plist-get params :step))
+	   (hide-files (plist-get params :hidefiles))
 	   (formatter (or (plist-get params :formatter)
 			  org-clock-clocktable-formatter
 			  'org-clocktable-write-default))
@@ -2445,7 +2447,8 @@ the currently selected interval size."
 	 ;; Even though `file-with-archives' can consist of
 	 ;; multiple files, we consider this is one extended file
 	 ;; instead.
-	 (and (consp files) (not (eq scope 'file-with-archives)
+	 (and (not hide-files)
+		  (consp files) (not (eq scope 'file-with-archives)
 
 	(funcall formatter
 		 origin
diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index 61ec5fad4..a92b44cb2 100644
--- a/lisp/org-pcomplete.el
+++ b/lisp/org-pcomplete.el
@@ -374,8 +374,9 @@ Complete a language in the first field, the header arguments and switches."
 			   ":tstart" ":tend" ":block" ":step"
 			   ":stepskip0" ":fileskip0"
 			   ":emphasize" ":link" ":narrow" ":indent"
-			   ":tcolumns" ":level" ":compact" ":timestamp"
-			   ":formula" ":formatter" ":wstart" ":mstart"
+			   ":hidefiles" ":tcolumns" ":level" ":compact"
+			   ":timestamp" ":formula" ":formatter"
+			   ":wstart" ":mstart"
 
 (defun org-pcomplete-case-double (list)
   "Return list with both upcase and downcase version of all strings in LIST."
-- 
2.14.1



[O] [Patch] Hide the file column in a clock report.

2017-08-31 Thread Michaël Cadilhac
Hi there;

Not sure it's for everyone, but I really don't need the file column in
my clock report, even though I use multiple files.  Here's a patch
that allows this, if there's any interest.

M.
From f251bf0fa764e245eabe88e3959e801af5c8fd37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Thu, 31 Aug 2017 19:37:55 +0100
Subject: [PATCH] Add the option of hiding the file column in a clock report

* contrib/orgmanual.org: Document the change.
* doc/org.texi (The clock table): Ditto.
* lisp/org-clock.el (org-clocktable-defaults): Add default value for
  :hidefiles.
(org-dblock-write:clocktable): Do not make "multiline" true if
hidefiles is.
* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/clocktable):
  Add :hidefiles to completions.

TINYCHANGE
---
 contrib/orgmanual.org | 4 
 doc/org.texi  | 1 +
 lisp/org-clock.el | 5 -
 lisp/org-pcomplete.el | 5 +++--
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/contrib/orgmanual.org b/contrib/orgmanual.org
index 6cc88a86e..e184fb51d 100644
--- a/contrib/orgmanual.org
+++ b/contrib/orgmanual.org
@@ -6253,6 +6253,10 @@ but you can specify your own function using the ~:formatter~ parameter.
 
   Indent each headline field according to its level.
 
+- :hidefiles ::
+
+  Hide the file column when multiple files are used to produced the table.
+
 - :tcolumns ::   
 
   Number of columns to be used for times.  If this is smaller than
diff --git a/doc/org.texi b/doc/org.texi
index a74f967f5..2c2f8d0cc 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6689,6 +6689,7 @@ but you can specify your own function using the @code{:formatter} parameter.
  @r{the org table.  If you write it like @samp{50!}, then the}
  @r{headline will also be shortened in export.}
 :indent  @r{Indent each headline field according to its level.}
+:hidefiles   @r{Should the file column be hidden when multiple files are parsed?}
 :tcolumns@r{Number of columns to be used for times.  If this is smaller}
  @r{than @code{:maxlevel}, lower levels will be lumped into one column.}
 :level   @r{Should a level number column be included?}
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 6b967c673..05c46e18c 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -298,6 +298,7 @@ string as argument."
:link nil
:narrow '40!
:indent t
+   :hidefiles nil
:formula nil
:timestamp nil
:level nil
@@ -2391,6 +2392,7 @@ the currently selected interval size."
 	   (ws (plist-get params :wstart))
 	   (ms (plist-get params :mstart))
 	   (step (plist-get params :step))
+	   (hide-files (plist-get params :hidefiles))
 	   (formatter (or (plist-get params :formatter)
 			  org-clock-clocktable-formatter
 			  'org-clocktable-write-default))
@@ -2445,7 +2447,8 @@ the currently selected interval size."
 	 ;; Even though `file-with-archives' can consist of
 	 ;; multiple files, we consider this is one extended file
 	 ;; instead.
-	 (and (consp files) (not (eq scope 'file-with-archives)
+	 (and (not hide-files)
+		  (consp files) (not (eq scope 'file-with-archives)
 
 	(funcall formatter
 		 origin
diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index 61ec5fad4..a92b44cb2 100644
--- a/lisp/org-pcomplete.el
+++ b/lisp/org-pcomplete.el
@@ -374,8 +374,9 @@ Complete a language in the first field, the header arguments and switches."
 			   ":tstart" ":tend" ":block" ":step"
 			   ":stepskip0" ":fileskip0"
 			   ":emphasize" ":link" ":narrow" ":indent"
-			   ":tcolumns" ":level" ":compact" ":timestamp"
-			   ":formula" ":formatter" ":wstart" ":mstart"
+			   ":hidefiles" ":tcolumns" ":level" ":compact"
+			   ":timestamp" ":formula" ":formatter"
+			   ":wstart" ":mstart"
 
 (defun org-pcomplete-case-double (list)
   "Return list with both upcase and downcase version of all strings in LIST."
-- 
2.14.1



Re: [O] org-icalendar--combine-files aggressively releases buffers

2017-08-31 Thread Michaël Cadilhac
Hi there;

On 31 August 2017 at 15:00, Nicolas Goaziou  wrote:

> After a cursory look I think we should:
>
> 1. Remove (org-agenda-prepare-buffers files), which doesn't seem to be
>useful and can lead to errors (it can throw `nextfile') but nothing
>catches it.
>
> 2. let-bind `org-agenda-new-buffers' to nil around the unwind protect.
>
> I pushed it in master branch. Does it solve your issue?

Certainly does, thank you.  Took me some time: it's always a bit of a
nightmare to install git org together with some melpa packages that
depend on org.

Cheers;
M.



[O] org-icalendar--combine-files aggressively releases buffers

2017-08-31 Thread Michaël Cadilhac
Hi there;

I have an idle timer that uses org-icalendar-combine-agenda-files to
publish my agenda.  It may well be that I hadn't saved one of the Org
files used in there, hence when  org-icalendar--combine-files uses :

(org-release-buffers org-agenda-new-buffers)

…I'm prompted to save before closing some buffers.  Worst, I'm even
asked to clock-out if I actually say yes to that question.

Personally, I now expect org to leave quite a lot of .org files open
(namely, my inbox, my todo file, my 3 gmail agendas), so I'd be fine
with simply not having any of these closed for me.  The right thing to
do, however, is probably to check org-agenda-new-buffers before and
after the files are processed, and close the new ones.

Opinions?

M.



[O] iCalendar export and missed deadlines.

2017-08-09 Thread Michaël Cadilhac
Hi there;

When I miss a deadline and scheduled todo, the org-agenda neatly
prints the item until I've turned it to DONE.  In iCalendar export, I
expect/wish that it is also the case when deadlines and scheduled
todos are exported as Events (I use VEVENT's as Google Calendar seems
to not support VTODO's).  By default, this is not the case, and the
todo is simply put in the past by the iCalendar export.

Is there a way to change this behavior so that the item is duplicated
as long as it's not DONE?  If not, where is a good starting point in
ox-icalendar.el to hack this in?

Thanks very much;
Cheers



[O] [PATCH] org-capture.el: Document what the time stamp is in capture templates

2017-08-05 Thread Michaël Cadilhac
On 5 August 2017 at 12:46, Adam Porter  wrote:

> If you could send a TINYCHANGE patch to the docstring, I'm sure Nicolas
> would be grateful!  :)

Sure thing!

M.
From 7c8569f6bf694bb45ac5334c3bcb13e54e0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
Date: Sat, 5 Aug 2017 14:53:29 +0200
Subject: [PATCH] org-capture.el: Document what the time stamp is in capture
 templates

* lisp/org-capture.el (org-capture-templates): Make explicit that the time
stamp aware %-escapes are influenced by `org-capture-use-agenda-date'.

TINYCHANGE
---
 lisp/org-capture.el | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 5675de375..627522a26 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -273,8 +273,10 @@ be replaced with content and expanded:
   happens after expanding non-interactive %-escapes, those can
   be used to fill the expression.
   %<...>  The result of format-time-string on the ... format specification.
-  %t  Time stamp, date only.
-  %T  Time stamp with date and time.
+  %t  Time stamp, date only.  The time stamp is the current time,
+  except when called from agendas with `\\[org-agenda-capture]' or
+  with `org-capture-use-agenda-date' set.
+  %T  Time stamp as above, with date and time.
   %u, %U  Like the above, but inactive time stamps.
   %i  Initial content, copied from the active region.  If %i is
   indented, the entire inserted text will be indented as well.
@@ -292,7 +294,8 @@ be replaced with content and expanded:
   %^g Prompt for tags, with completion on tags in target file.
   %^G Prompt for tags, with completion on all tags in all agenda files.
   %^t Like %t, but prompt for date.  Similarly %^T, %^u, %^U.
-  You may define a prompt like: %^{Please specify birthday}t
+  You may define a prompt like: %^{Please specify birthday}t.
+  The default date is that of %t, see above.
   %^C Interactive selection of which kill or clip to use.
   %^L Like %^C, but insert as link.
   %^{prop}p   Prompt the user for a value for property `prop'.
-- 
2.13.3



Re: [O] Time stamped TODOs with current-time from everywhere.

2017-08-05 Thread Michaël Cadilhac
On 5 August 2017 at 04:27, Adam Porter <a...@alphapapa.net> wrote:
> Michaël Cadilhac <mich...@cadilhac.name> writes:
>
>> However, suppose I'm in Calfw; I jump to some date, hit SPACE and I'm
>> now in Org-Agenda mode, ready to hit k to capture (because Calfw-Org
>> does not offer this directly).  Now I expect %U to still be the
>> current time stamp, and %^t to be prefilled with the date of the
>> Agenda.  It so happens that *both* time stamps are the one of the
>> Agenda.  Is this tweakable so that %U is always (current-time)?
>
> I'm not sure if that's a bug, since it seems like %^t should always
> prompt, or if it's intended that the agenda date fulfill the prompt.
> But either way, you should be able to use a %(sexp) form in the capture
> template to insert the current date.

Thanks for your expertise Adam.  It seems indeed that
org-agenda-capture (or equivalently, setting
org-capture-use-agenda-date) affects the default date at all stages,
i.e., for %u and for the default value of %^t.  This is done through
setting org-overriding-default-time.  I don't think there's any reason
to change this behavior, but it may be worth adding that info in
org-capture-template's docstring.  At the moment, it only says "time
stamp".

Cheers;
M.



[O] Time stamped TODOs with current-time from everywhere.

2017-08-04 Thread Michaël Cadilhac
Hi there people;

I have a few TODO templates of the form:

  ("td" "Todo deadline (with reminders)" entry
   (file "~/org/todos.org")
   "* TODO %^{Todo}\n DEADLINE: %^t\n %U\n%i%?")

The goal is to have two time stamps: an inactivated one (%U),
recording the time the TODO was created, and a queried time (%^t), for
the deadline.  If I'm just out of the blue thinking of a TODO, I can
easily add it this way.

However, suppose I'm in Calfw; I jump to some date, hit SPACE and I'm
now in Org-Agenda mode, ready to hit k to capture (because Calfw-Org
does not offer this directly).  Now I expect %U to still be the
current time stamp, and %^t to be prefilled with the date of the
Agenda.  It so happens that *both* time stamps are the one of the
Agenda.  Is this tweakable so that %U is always (current-time)?

Thanks!

Cheers;
Michaël



[O] Bug: Wrong type argument: integer-or-marker-p, nil on refile

2017-08-02 Thread Michaël Cadilhac
Hi there everyone;

Here's the ECM.

init.el:
(require 'org)
(setq org-refile-use-outline-path (quote file))

Now open an Org file, say foo.org, and type C-u C-c C-w foo.org/ RET
At org.el:11832, pos is nil.

Cheers;
M.