Re: [PATCH] Add NO-STATS switch to org-get-heading

2020-03-13 Thread Adam Porter
Please don't add more arguments to org-get-heading.  It used to have 2,
then it had 4, and now you want to add a 5th.  Every time the function's
signature changes, it breaks code in third-party packages and user code
in random places, which requires the addition of messy compatibility
code and intermediate functions that do nothing but wrap org-get-heading
with a certain number of arguments.

It would be much preferable to make a new function that uses keyword
arguments so the addition of more arguments won't affect existing code.
Maybe it could be called org-entry-heading.




Re: [PATCH] Add NO-STATS switch to org-get-heading

2020-03-13 Thread Brice Waegeneire

Hello Nicolas,

On 2020-03-13 17:22, Nicolas Goaziou wrote:

* lisp/org-element.el (org-element-context): Handle headlines only
containing a statistics cookie.
* lisp/org.el (test-org/get-heading): Add regex capture group 6 for
statistics cookie.
(org-get-heading): Add NO-STATS argument, if
non-nil, will not return the statistics cookie.
* testing/lisp/test-org.el (test-org/get-heading): Add 3 tests using 
the

NO-STATS argument.


This assumes statistics cookie is always located at the end of the
title, before the tags. This is not required by the syntax.

Syntax can evolve, but it could introduce many backward
incompatibilities, so it must be discussed first.


I wasn't sure about this. I don't remember ever seeing somebody putting 
the

statistics cookie before the title but org-complex-heading-regexp-format
does support two position for the statistics cookie. Would adding 
support

for the two locations to this patch make the review process faster?

I was just looking for a way to get a heading title without any 
metadata.


Cheers.



Re: [PATCH] Add NO-STATS switch to org-get-heading

2020-03-13 Thread Nicolas Goaziou
Nicolas Goaziou  writes:

> This assumes statistics cookie is always located at the end of the
> title, before the tags. This is not required by the syntax.
>
> Syntax can evolve, but it could introduce many backward
> incompatibilities, so it must be discussed first.

Also, note that statistics cookies are not tied to headlines, unlike
tags or TODO keywords. They can be located almost anywhere in the
document (e.g., in plain lists). So, it seems strange to add it to
`org-get-heading'.



Re: [PATCH] Add NO-STATS switch to org-get-heading

2020-03-13 Thread Nicolas Goaziou
Hello,

Brice Waegeneire  writes:

> * lisp/org-element.el (org-element-context): Handle headlines only
> containing a statistics cookie.
> * lisp/org.el (test-org/get-heading): Add regex capture group 6 for
> statistics cookie.
> (org-get-heading): Add NO-STATS argument, if
> non-nil, will not return the statistics cookie.
> * testing/lisp/test-org.el (test-org/get-heading): Add 3 tests using the
> NO-STATS argument.

This assumes statistics cookie is always located at the end of the
title, before the tags. This is not required by the syntax.

Syntax can evolve, but it could introduce many backward
incompatibilities, so it must be discussed first.

Regards,

-- 
Nicolas Goaziou



[PATCH] Add NO-STATS switch to org-get-heading

2020-03-13 Thread Brice Waegeneire
* lisp/org-element.el (org-element-context): Handle headlines only
containing a statistics cookie.
* lisp/org.el (test-org/get-heading): Add regex capture group 6 for
statistics cookie.
(org-get-heading): Add NO-STATS argument, if
non-nil, will not return the statistics cookie.
* testing/lisp/test-org.el (test-org/get-heading): Add 3 tests using the
NO-STATS argument.
---
 lisp/org-element.el  |  4 ++--
 lisp/org.el  | 13 +
 testing/lisp/test-org.el | 13 +
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 798c540e9..c1798e07a 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -5906,9 +5906,9 @@ Providing it allows for quicker computation."
 (let ((case-fold-search nil))
   (goto-char (org-element-property :begin element))
   (looking-at org-complex-heading-regexp)
-  (let ((end (match-end 4)))
+  (let ((end (or (match-end 6) (match-end 4
 (if (not end) (throw 'objects-forbidden element)
-  (goto-char (match-beginning 4))
+  (goto-char (or (match-beginning 4) (match-beginning 6)))
   (when (looking-at org-comment-string)
 (goto-char (match-end 0)))
   (if (>= (point) end) (throw 'objects-forbidden element)
diff --git a/lisp/org.el b/lisp/org.el
index 31133c554..b6fc6ad26 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4011,6 +4011,7 @@ group 2: The TODO keyword, maybe
 group 3: Priority cookie
 group 4: True headline
 group 5: Tags
+group 6: Statistics cookie
 
 Since TODO keywords are case-sensitive, `case-fold-search' is
 expected to be bound to nil when matching against this regexp.")
@@ -4328,7 +4329,8 @@ related expressions."
  "\\(?: +" org-todo-regexp "\\)?"
  "\\(?: +\\(\\[#.\\]\\)\\)?"
  "\\(?: +\\(.*?\\)\\)??"
- "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?"
+ "\\(?: +\\(?6:\\[[0-9%%/]+\\]\\)\\)?"
+ "\\(?:[ \t]+\\(?5::[[:alnum:]_@#%:]+:\\)\\)?"
  "[ \t]*$")
  org-complex-heading-regexp-format
  (concat "^\\(\\*+\\)"
@@ -6897,12 +6899,14 @@ So this will delete or add empty lines."
 (insert (make-string n ?\n))
 (move-to-column column)))
 
-(defun org-get-heading ( no-tags no-todo no-priority no-comment)
+(defun org-get-heading ( no-tags no-todo no-priority
+  no-comment no-stats)
   "Return the heading of the current entry, without the stars.
 When NO-TAGS is non-nil, don't include tags.
 When NO-TODO is non-nil, don't include TODO keywords.
 When NO-PRIORITY is non-nil, don't include priority cookie.
 When NO-COMMENT is non-nil, don't include COMMENT string.
+When NO-STATS is non-nil, don't include statistics cookie.
 Return nil before first heading."
   (unless (org-before-first-heading-p)
 (save-excursion
@@ -6919,9 +6923,10 @@ Return nil before first heading."
  (format "\\`%s[ \t]+" org-comment-string))
"" h))
  (h h)))
- (tags (and (not no-tags) (match-string 5
+ (tags (and (not no-tags) (match-string 5)))
+(stats (and (not no-stats) (match-string 6
  (mapconcat #'identity
-(delq nil (list todo priority headline tags))
+(delq nil (list todo priority headline stats tags))
 " "))
 
 (defun org-heading-components ()
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index dc4a6a59f..f98918dae 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1887,6 +1887,19 @@
(equal "TODO [#A] H"
  (org-test-with-temp-text "* TODO [#A] COMMENT H"
(org-get-heading nil nil nil t
+  ;; With NO-STATS, ignore statistics cookie.
+  (should
+   (equal "H"
+ (org-test-with-temp-text "* H [1/3]"
+   (org-get-heading nil nil nil nil t
+  (should
+   (equal "H"
+ (org-test-with-temp-text "* H"
+   (org-get-heading nil nil nil nil t
+  (should
+   (equal "TODO [#A] H"
+ (org-test-with-temp-text "* TODO [#A] H [33%]"
+   (org-get-heading nil nil nil nil t
   ;; On an empty headline, return value is consistent.
   (should (equal "" (org-test-with-temp-text "* " (org-get-heading
   (should (equal "" (org-test-with-temp-text "* " (org-get-heading t
-- 
2.25.0




Re: Can Org Mode tag support dash character "-"?

2020-03-13 Thread Carsten Dominik
On Fri, Mar 13, 2020 at 3:08 PM stardiviner  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> I found Org Mode tags does not support tag like "COVID-9", The dash
> character "-" is not supported.


> Can Org Mode support the dash char because it is very often used.
>

This is not a good idea, because searches can be built with +tag and -tag .

Use COVID9 or COVID_9 instead.

Carsten


>
> - --
> [ stardiviner ]
>I try to make every word tell the meaning what I want to express.
>
>Blog: https://stardiviner.github.io/
>IRC(freenode): stardiviner, Matrix: stardiviner
>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>
> -BEGIN PGP SIGNATURE-
>
> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5rkPsUHG51bWJjaGls
> ZEBnbWFpbC5jb20ACgkQG13xyVromsNJpggAkpjsjbLKi/qF+MroVNyQRxRjC51v
> SEgU45CWgrNnusgO6m53btRKemcAwsvQEWiqecAXxDpozReRXECyUQSTRGlqwmG/
> cHSArejGF8zr3kvC/Md7Ay+azFA9/h7Tc7PDW/BVerouXLIJ2dfMQjut406oWq43
> vuxAqzzHgiZ1PQCuYDvBq6Z4YqcPecER0cVHOFvbRgG9ZxM1VwN3AmMr/4T4U39v
> FACnWfpo77nVYydhWUc8Cgi6+oUHSe6lUYAPgVTDuppXqi9rFfMQ8OgEP9Cw014/
> PHGPgHsV7fOV7zHmMpY9bci/bPEL14PJ8ZjTQ31NCELOXWddtGg9PdlD9g==
> =Mrnk
> -END PGP SIGNATURE-
>
>


Can Org Mode tag support dash character "-"?

2020-03-13 Thread stardiviner
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256


I found Org Mode tags does not support tag like "COVID-9", The dash character 
"-" is not supported.

Can Org Mode support the dash char because it is very often used.

- -- 
[ stardiviner ]
   I try to make every word tell the meaning what I want to express.

   Blog: https://stardiviner.github.io/
   IRC(freenode): stardiviner, Matrix: stardiviner
   GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
  
-BEGIN PGP SIGNATURE-

iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5rkPsUHG51bWJjaGls
ZEBnbWFpbC5jb20ACgkQG13xyVromsNJpggAkpjsjbLKi/qF+MroVNyQRxRjC51v
SEgU45CWgrNnusgO6m53btRKemcAwsvQEWiqecAXxDpozReRXECyUQSTRGlqwmG/
cHSArejGF8zr3kvC/Md7Ay+azFA9/h7Tc7PDW/BVerouXLIJ2dfMQjut406oWq43
vuxAqzzHgiZ1PQCuYDvBq6Z4YqcPecER0cVHOFvbRgG9ZxM1VwN3AmMr/4T4U39v
FACnWfpo77nVYydhWUc8Cgi6+oUHSe6lUYAPgVTDuppXqi9rFfMQ8OgEP9Cw014/
PHGPgHsV7fOV7zHmMpY9bci/bPEL14PJ8ZjTQ31NCELOXWddtGg9PdlD9g==
=Mrnk
-END PGP SIGNATURE-



Automatic Capture of Heading Creation Time In Certain Files?

2020-03-13 Thread Tim Visher
Ohai,

I would like to automatically have the results of a double prefixed call to
`org-time-stamp-inactive` inserted as the body of new TODO entries. I
suspect I can do this with Capture templates but every time I read that
manual section it seems to have a lot more than I want. I'm also reasonably
sure I could write a simple function and override bindings such that all of
the default behaviors of TODO insertion happened _plus_ newline-and-indent,
newline-and-indent, double prefix org-time-stamp-inactive, previous-line,
previous-line.

Am I missing something here or barking up the wrong tree in either
direction?

Thanks in advance!

--

In Christ,

Timmy V.

https://blog.twonegatives.com
https://five.sentenc.es


Bug: ob-python mangles multiline :var values [9.3.6 (release_9.3.6-397-ga089600)]

2020-03-13 Thread Štěpán Němec


Recipe:
---

emacs -Q
M-x load-library RET ob-python RET
M-x org-mode RET

#+begin_src python :var text="a\nb\nc"
return text
#+end_src

#+RESULTS:
: a
:   b
:   c


Commentary:
---

ob-python seems to prepend a TAB character to every line except for the
first one.

Emacs  : GNU Emacs 28.0.50 (build 11, x86_64-pc-linux-gnu, GTK+ Version 
3.24.14, cairo version 1.17.3)
 of 2020-03-11
Package: Org mode version 9.3.6 (release_9.3.6-397-ga08960 @ 
/home/stepnem/.emacs.d/lib/org/lisp/)



Re: bi-monthly steps.

2020-03-13 Thread Peter Neilson

On Fri, 13 Mar 2020 04:01:43 -0400, Michal Politowski  wrote:


Fortnightly :)
Such a useful word.


There are 24 semi-months in a year. There are roughly 26 fortnights.

American English seem to allow the adverb semimonthly but generally avoids  
the

British term fortnightly.

There ought to be an unnecessary book English Made Difficult as a  
companion piece to Carl E. Linderholm's book Mathematics Made Difficult.




On Thu, 12 Mar 2020 18:55:16 -0400, Christian Hopps wrote:

could use semimonth then :)

> On Mar 12, 2020, at 2:15 PM, Nick Dokos  wrote:
>
> "Bi-monthly" is ambiguous: it can mean twice a month or it can mean
> once every two months and there is no convincing anybody that their
> use of it is wrong :-)
>
> --
> Nick
>
> "There are only two hard problems in computer science: cache
> invalidation, naming things, and off-by-one errors." -Martin Fowler




semimonthly steps [Re: bi-monthly steps.]

2020-03-13 Thread Christian Hopps


FWIW the code was actually unambiguous. :)

I meant "semimonthly" or twice a month (i.e., like some people get paid: 
1-15th, 16th-endofmonth).

Thanks,
Chris.

Loris Bennett  writes:


Eric S Fraga  writes:


On Friday, 13 Mar 2020 at 00:47, Peter Neilson wrote:

I think the original question from Christian Hopps presumes the
meaning, "Every two months."


Oh, I took it to mean bi-weekly. ;-)


Exactly.  So "bi-monthly" just means "twice a week".  I'm sure we can all
agree on that :-)




signature.asc
Description: PGP signature


Re: bi-monthly steps.

2020-03-13 Thread Michal Politowski
Fortnightly :)
Such a useful word.

On Thu, 12 Mar 2020 18:55:16 -0400, Christian Hopps wrote:
> could use semimonth then :)
> 
> > On Mar 12, 2020, at 2:15 PM, Nick Dokos  wrote:
> > 
> > "Bi-monthly" is ambiguous: it can mean twice a month or it can mean
> > once every two months and there is no convincing anybody that their
> > use of it is wrong :-)
> > 
> > -- 
> > Nick
> > 
> > "There are only two hard problems in computer science: cache
> > invalidation, naming things, and off-by-one errors." -Martin Fowler

-- 
Michał Politowski
Talking has been known to lead to communication if practiced carelessly.



Re: bi-monthly steps.

2020-03-13 Thread Loris Bennett
Eric S Fraga  writes:

> On Friday, 13 Mar 2020 at 00:47, Peter Neilson wrote:
>> I think the original question from Christian Hopps presumes the
>> meaning, "Every two months."
>
> Oh, I took it to mean bi-weekly. ;-)

Exactly.  So "bi-monthly" just means "twice a week".  I'm sure we can all
agree on that :-)

-- 
This signature is currently under construction.



Re: bi-monthly steps.

2020-03-13 Thread Eric S Fraga
On Friday, 13 Mar 2020 at 00:47, Peter Neilson wrote:
> I think the original question from Christian Hopps presumes the
> meaning, "Every two months."

Oh, I took it to mean bi-weekly. ;-)

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.6-412-ge18415