Wring case when using org-insert-structure-template

2020-07-08 Thread Guillaume MULLER
Hi,

Thanks for Org-mode. This is really THE software I needed! I LOVE everything 
about it! This is the only piece of software I know of that really designed by 
users for users, with users & efficiency in mind!

I'm using GNU Emacs 26.3, with built-in org 9.1.9.

When I try to automatically insert Structure Templates (e.g. by typing C-c C-, 
s), I get everything inserted in lowercase (e.g. #+begin_src).

In ALL the documentation pages I read, the snippets are written in uppercase 
(i.e. #+BEGIN_SRC, like in the main documentation for this feature: 
https://orgmode.org/org.html#Structure-Templates). I would myself prefer to 
have the templates inserted in uppercase, as it allows to clearly & visually 
differentiate between my main document text and the specific instructions for 
Org.

First question: why isn't the default as in the docs?

Second question: I couldn't find any configuration variable or function to 
change the default behaviour. Is there a way to do so?

Thanks!

-- 
Guillaume MULLER
Data Scientist, PhD
Télécom Saint-Étienne (office i119)
25 rue du Dr Remy Annino
-
Laboratoire Hubert Curien (office e002)
18 rue du Pr Benoît Lauras
-
42000 Saint-Étienne
FRANCE
Mobile : +33 (0)6 51 22 33 49



signature.asc
Description: OpenPGP digital signature


[PATCH] agenda: Fold case when retrieving user-configured effort values

2020-07-08 Thread Kyle Meyer
Nick Dokos writes:

> BTW, I just thought of a possible problem: the manual says that property
> keys are case-insensitive (although all the examples I can find spell
> "_ALL" in upper case, but if I write
>
>   :PROPERTIES:
>   :foo_all: bar baz
>   :END:
>
> I don't think that the code is going to handle it correctly. There
> are other places that also use "_ALL" without a let of case-fold-search
> (at least AFAICT).
>
> Am I paranoid or is this a problem?

case-fold-search is let-bound to t at the beginning of
org-buffer-property-keys, so the added string-match is covered.

When collecting keys, there's no attempt to normalize to upper or lower,
so the delete-dups call won't take care of any keys that are present in
various case styles.  I don't think that's something worth worrying
about (and perhaps it's even preferable, since we can't know which
variant the caller would want to complete).

As for other spots in the code base: looking through grep hits for
"_ALL", it seems like most should be okay because they go through
org-entry-get.  Two places in org-agenda are case-sensitive, though.

-- >8 --
Subject: [PATCH] agenda: Fold case when retrieving user-configured effort
 values

* lisp/org-agenda.el (org-agenda-filter-by-effort):
(org-agenda-filter-completion-function): Ignore case when querying
effort property key in org-global-properties since property keys are
documented as case-insensitive.
---
 lisp/org-agenda.el | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 90129b23e..5c2933b0a 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7611,8 +7611,9 @@ (defun org-agenda-filter-by-effort (strip-or-accumulate)
 consistency with the other filter commands."
   (interactive "P")
   (let* ((efforts (split-string
-  (or (cdr (assoc (concat org-effort-property "_ALL")
-  org-global-properties))
+  (or (cdr (assoc-string (concat org-effort-property "_ALL")
+ org-global-properties
+ t))
   "0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00")))
 ;; XXX: the following handles only up to 10 different
 ;; effort values.
@@ -,8 +7778,9 @@ (defun org-agenda-filter-completion-function (string 
_predicate &optional flag)
  (org-agenda-get-represented-tags
  ((member operator '("<" ">" "="))
   (setq table (split-string
-  (or (cdr (assoc (concat org-effort-property "_ALL")
-  org-global-properties))
+  (or (cdr (assoc-string (concat org-effort-property "_ALL")
+ org-global-properties
+ t))
   "0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00")
   " +")))
  (t (setq table nil)))

base-commit: eac255d911e0793513b2e2f14b06b94194a04daf
-- 
2.26.2




Re: How to mark task as done at specified (past) time?

2020-07-08 Thread Kyle Meyer
Tim Landscheidt writes:

> I have an icky feeling about cl-letfing current-time because
> Murphy might cause a timer to fire in just that time frame
> and I have no idea what current-time is for that timer; so
> if future org-mode releases would provide a cleaner API I
> would very much appreciate that :-).

Murphy would need to do something pretty invasive to get the timer to
execute in that scope, I think.  (Not relevant for this context, but
threads don't play nicely with cl-letf; if you cl-letf bind a function
definition in one thread and then yield execution to another, the second
thread can see the cl-letf binding.)

Anyway, I'd be glad to see API proposals (backward-compatibility
concerns aside).



Re: time-warping - retroactively marking DONE?

2020-07-08 Thread No Wayman



I emailed Adam directly with an experimental package I wrote to 
solve the problem of changing the todo-state of an entry at an 
arbitrary time.

He suggested I posted here as well:

https://github.com/progfolio/epoch/

The package advises current-time to return `epoch-current-time' if 
is set (falling back to the usual current-time if not).
A macro, `epoch-with-time' is provided which allows a body to be 
executed with current-time set to an arbitrary time.
Two commands (which I may separate into their own package), 
`epoch-todo' and `epoch-agenda-todo' call their respective 
org-mode commands.
`org-read-date' is called with the tasks's SCHEDULED or DEADLINE 
time pre-populated so one can easily edit relative to that time.


Still very much a work in progress, but the two commands are 
useful for me so far.


Any ideas, suggestions, criticisms are appreciated.



WIP: Org-plot work

2020-07-08 Thread TEC
>From a7af0ff66917f92c735735d88eeccb5019937273 Mon Sep 17 00:00:00 2001
From: TEC 
Date: Thu, 9 Jul 2020 05:21:44 +0800
Subject: [PATCH 8/8] Org-plot: add radar plot type.

---
 lisp/org-plot.el | 138 ++-
 1 file changed, 137 insertions(+), 1 deletion(-)

diff --git a/lisp/org-plot.el b/lisp/org-plot.el
index 3b486fed2..c435ef733 100644
--- a/lisp/org-plot.el
+++ b/lisp/org-plot.el
@@ -323,7 +323,9 @@ If a function, it is called with the plot type as the argument."
 	(let* ((type (plist-get params :plot-type))
 		   (with (if (eq type 'grid) 'pm3d (plist-get params :with
 	(list (format "'%s' with %s title ''"
-			  data-file with))
+			  data-file with)
+(radar (lambda (data-file num-cols params plot-str)
+	 (list (org--plot/radar table params)
   "List of plot presets with the type name as the car, and a function
 which yeilds plot-lines (a list of strings) as the cdr.
 The parameters of `org-plot/gnuplot-script' and PLOT-STR are passed to
@@ -332,6 +334,140 @@ that function. i.e. it is called with the following arguments:
   :group 'org-plot
   :type '(alist :value-type (symbol group)))
 
+(defvar org--plot/radar-template
+  "### spider plot/chart with gnuplot
+# also known as: radar chart, web chart, star chart, cobweb chart,
+#radar plot,  web plot,  star plot,  cobweb plot,  etc. ...
+set datafile separator ' '
+set size square
+unset tics
+set angles degree
+set key bmargin center horizontal
+unset border
+
+# Load data and settup
+load \"%s\"
+
+# General settings
+DataColCount = words($Data[1])-1
+AxesCount = |$Data|-HeaderLines
+AngleOffset = 90
+Max = 1
+d=0.1*Max
+Direction = -1   # counterclockwise=1, clockwise = -1
+
+# Tic settings
+TicCount = %s
+TicOffset = 0.1
+TicValue(axis,i) = real(i)*(word($Settings[axis],3)-word($Settings[axis],2)) \\
+	  / word($Settings[axis],4)+word($Settings[axis],2)
+TicLabelPosX(axis,i) = PosX(axis,i/TicCount) + PosY(axis, TicOffset)
+TicLabelPosY(axis,i) = PosY(axis,i/TicCount) - PosX(axis, TicOffset)
+TicLen = 0.03
+TicdX(axis,i) = 0.5*TicLen*cos(alpha(axis)-90)
+TicdY(axis,i) = 0.5*TicLen*sin(alpha(axis)-90)
+
+# Label
+LabOffset = 0.10
+LabX(axis) = PosX(axis+1,Max+2*d) + PosY(axis, LabOffset)
+LabY(axis) = PosY($0+1,Max+2*d)
+
+# Functions
+alpha(axis) = (axis-1)*Direction*360.0/AxesCount+AngleOffset
+PosX(axis,R) = R*cos(alpha(axis))
+PosY(axis,R) = R*sin(alpha(axis))
+Scale(axis,value) = real(value-word($Settings[axis],2))/(word($Settings[axis],3)-word($Settings[axis],2))
+
+# Spider settings
+set style arrow 1 dt 1 lw 1.0 @fgal head filled size 0.06,25 # style for axes
+set style arrow 2 dt 2 lw 0.5 @fgal nohead   # style for weblines
+set style arrow 3 dt 1 lw 1 @fgal nohead # style for axis tics
+set samples AxesCount
+set isosamples TicCount
+set urange[1:AxesCount]
+set vrange[1:TicCount]
+set style fill transparent solid 0.2
+
+set xrange[-Max-4*d:Max+4*d]
+set yrange[-Max-4*d:Max+4*d]
+plot \\
+'+' u (0):(0):(PosX($0,Max+d)):(PosY($0,Max+d)) w vec as 1 not, \\
+$Data u (LabX($0)): \\
+	(LabY($0)):1 every ::HeaderLines w labels center enhanced @fgt not, \\
+for [i=1:DataColCount] $Data u (PosX($0+1,Scale($0+1,column(i+1: \\
+	(PosY($0+1,Scale($0+1,column(i+1 every ::HeaderLines w filledcurves lt i title word($Data[1],i+1), \\
+%s
+#'++' u (PosX($1,$2/TicCount)-TicdX($1,$2/TicCount)): \\
+#(PosY($1,$2/TicCount)-TicdY($1,$2/TicCount)): \\
+#(2*TicdX($1,$2/TicCount)):(2*TicdY($1,$2/TicCount)) \\
+#w vec as 3 not, \\
+### end of code
+")
+
+(defvar org--plot/radar-ticks
+  "'++' u (PosX($1,$2/TicCount)):(PosY($1,$2/TicCount)): \\
+	(PosX($1+1,$2/TicCount)-PosX($1,$2/TicCount)):  \\
+	(PosY($1+1,$2/TicCount)-PosY($1,$2/TicCount)) w vec as 2 not, \\
+'++' u (TicLabelPosX(%s,$2)):(TicLabelPosY(%s,$2)): \\
+	(sprintf('%%g',TicValue(%s,$2))) w labels font ',8' @fgat not")
+
+(defvar org--plot/radar-setup-template
+  "# Data
+$Data <

Re: How to mark task as done at specified (past) time?

2020-07-08 Thread Tim Landscheidt
Kyle Meyer  wrote a long time ago:

> […]

>> Do I have to cl-flet org-current-time or something similar?

> Something along those lines would probably be the most straightforward.
> Light testing with the command below suggests overriding current-time is
> sufficient:

> (defun my-org-todo-time-machine ()
>   (interactive)
>   (cl-letf (((symbol-function 'current-time)
>  (lambda ()
>(apply #'encode-time (org-parse-time-string
>  "2019-11-27 Mi 16:44")
> (call-interactively #'org-todo)))

I finally got around to this and ended up with an entry in
gnus-select-article-hook à la:

| (lambda nil
|   (if
|   (and
|(string= gnus-newsgroup-name "mail.only.this.group")
|(string-match "^Regular expression that matches subject$"
|  (gnus-summary-article-subject)))
|   (let
|   ((article-time
| (gnus-date-get-time
|  (mail-header-date
|   (gnus-summary-article-header)
| (cl-letf
| (((symbol-function 'current-time)
|   (lambda nil article-time)))
|   (find-file "/path/to/file.org")
|   (goto-char
|(org-find-entry-with-id "TASK-ID"))
|   (org-todo 'done)

I have an icky feeling about cl-letfing current-time because
Murphy might cause a timer to fire in just that time frame
and I have no idea what current-time is for that timer; so
if future org-mode releases would provide a cleaner API I
would very much appreciate that :-).

Thanks,
Tim



Re: org-sbe and code blocks in a different files

2020-07-08 Thread Douglas Perrin
Hi Michael,
Maybe I am not understanding what you want to do but I use
org-babel-lob-ingest/org-sbe to execute blocks from other files on
start-up like this:
# Local Variables:
# eval: (org-babel-lob-ingest "Template-Loader.org")
# eval: (org-sbe "Init-Template") ;; the name of a block
in Template-Loader.org file
# End:

I assume this means that org-sbe can see the block names from the other
file. But I haven't tested the behavior with #call just executing elisp.
Doug



Date: Wed, 08 Jul 2020 16:59:32 +0200
From: Michael Welle 
To: emacs-orgmode@gnu.org
Subject: Re: org-sbe and code blocks in a different files
Message-ID: <877dve9hnv@luisa.c0t0d0s0.de>
Content-Type: text/plain

Hi Eric,

Eric S Fraga  writes:

> * org-babel-lob-ingest
ah, I learned something new here. Unfortunately, it seems like org-sbe
doesn't look into the list spit out by org-babel-lob-ingest.

Regards
hmw


Re: [PATCH] org: add property names from #+PROPERTY keywords to completion list

2020-07-08 Thread Nick Dokos
Kyle Meyer  writes:

> Nick Dokos writes:
>
>> Here's the amended patch: it includes the fixes from Kyle's review, the 
>> modification
>> he suggested that adds the plain property for each _ALL property to the list
>> and a few test cases to the test/org-buffer-property-keys test.
>
> Thank you for the updates.  Applied (bc4fa8a00).
>
>> -nil)))
>> +;; Get property names from #+PROPERTY keywords as well
>> +(mapcar (lambda (s)
>> +  (nth 0 (split-string s)))
>> +(cdar (org-collect-keywords '("PROPERTY"
>> +nil))
>
> I didn't spot it earlier, but this nil (not added by your patch) is
> unnecessary.  Since the patch is touching the line anyway, I've dropped
> it on apply.
>
>> +bare-props)
>>  (org-with-wide-buffer
>>   (goto-char (point-min))
>>   (while (re-search-forward org-property-start-re nil t)
>> @@ -13132,7 +13137,15 @@ COLUMN formats in the current buffer."
>>   (let ((p (match-string-no-properties 1 value)))
>> (unless (member-ignore-case p org-special-properties)
>>   (push p props))
>> -(sort (delete-dups props) (lambda (a b) (string< (upcase a) (upcase 
>> b))
>> +(sort (delete-dups (append props
>> +   ;; for each xxx_ALL property, make sure
>> +   ;; the bare xxx property is also
>> +   ;; included
>> +   (dolist (x props bare-props)
>> + (if (string-match "_ALL\\b" x)
>> + (setq bare-props (cons (substring x 0 -4)
>> +bare-props))
>
> I did a cosmetic rewrite here to use mapcar, which I hope you won't
> mind.
>

BTW, I just thought of a possible problem: the manual says that property
keys are case-insensitive (although all the examples I can find spell
"_ALL" in upper case, but if I write

  :PROPERTIES:
  :foo_all: bar baz
  :END:

I don't think that the code is going to handle it correctly. There
are other places that also use "_ALL" without a let of case-fold-search
(at least AFAICT).

Am I paranoid or is this a problem?

-- 
Nick




Re: [PATCH] org: add property names from #+PROPERTY keywords to completion list

2020-07-08 Thread Nick Dokos
Kyle Meyer  writes:

> Nick Dokos writes:
>
>> Here's the amended patch: it includes the fixes from Kyle's review, the 
>> modification
>> he suggested that adds the plain property for each _ALL property to the list
>> and a few test cases to the test/org-buffer-property-keys test.
>
> Thank you for the updates.  Applied (bc4fa8a00).
>
>> -nil)))
>> +;; Get property names from #+PROPERTY keywords as well
>> +(mapcar (lambda (s)
>> +  (nth 0 (split-string s)))
>> +(cdar (org-collect-keywords '("PROPERTY"
>> +nil))
>
> I didn't spot it earlier, but this nil (not added by your patch) is
> unnecessary.  Since the patch is touching the line anyway, I've dropped
> it on apply.
>
>> +bare-props)
>>  (org-with-wide-buffer
>>   (goto-char (point-min))
>>   (while (re-search-forward org-property-start-re nil t)
>> @@ -13132,7 +13137,15 @@ COLUMN formats in the current buffer."
>>   (let ((p (match-string-no-properties 1 value)))
>> (unless (member-ignore-case p org-special-properties)
>>   (push p props))
>> -(sort (delete-dups props) (lambda (a b) (string< (upcase a) (upcase 
>> b))
>> +(sort (delete-dups (append props
>> +   ;; for each xxx_ALL property, make sure
>> +   ;; the bare xxx property is also
>> +   ;; included
>> +   (dolist (x props bare-props)
>> + (if (string-match "_ALL\\b" x)
>> + (setq bare-props (cons (substring x 0 -4)
>> +bare-props))
>
> I did a cosmetic rewrite here to use mapcar, which I hope you won't
> mind.

Not at all - thanks!

>
> Thanks again.
>
>

-- 
Nick




Re: org-sbe and code blocks in a different files

2020-07-08 Thread Eric S Fraga
On Wednesday,  8 Jul 2020 at 16:59, Michael Welle wrote:
>> * org-babel-lob-ingest
> ah, I learned something new here. Unfortunately, it seems like org-sbe
> doesn't look into the list spit out by org-babel-lob-ingest.

Pity, and strange in that #+call: works on ingested babel blocks without
having to specify a file name.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-649-gb76ed6



Re: org-sbe and code blocks in a different files

2020-07-08 Thread Michael Welle
Hi Eric,

Eric S Fraga  writes:

> * org-babel-lob-ingest
ah, I learned something new here. Unfortunately, it seems like org-sbe
doesn't look into the list spit out by org-babel-lob-ingest.

Regards
hmw



Re: org-sbe and code blocks in a different files

2020-07-08 Thread Eric S Fraga
On Tuesday,  7 Jul 2020 at 20:43, Michael Welle wrote:
> That is great. Can I call the same function from a table function?
> org-sbe doesn't support the above notation extended with an Org file
> name, I think.

Does org-sbe work if you have invoked org-babel-log-ingest first?
-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-649-gb76ed6



Re: org-sbe and code blocks in a different files

2020-07-08 Thread Eric S Fraga
* org-babel-lob-ingest
-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-649-gb76ed6