Re: [PATCH 1/2] org-capture: Allow entry template to start without heading

2024-06-05 Thread Rens Oliemans
Ihor Radchenko  writes:

> Applied, onto main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0c8fba93f
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=a62f75c84
>
> I added you to the contributor list:
> https://git.sr.ht/~bzg/worg/commit/05c4acae

Great, thanks!



Re: [PATCH 1/2] org-capture: Allow entry template to start without heading

2024-06-04 Thread Ihor Radchenko
Ihor Radchenko  writes:

> I have improved your patches a little, fixing the regular expression
> used to match headings ("^*" is not accurate, you need
> org-outline-regexp-bol), and adding another test case.
> See the attached.
>
> Before I install the patches, may I know if you have FSF copyright
> assignment? See https://orgmode.org/worg/org-contribute.html#copyright

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0c8fba93f
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=a62f75c84

I added you to the contributor list:
https://git.sr.ht/~bzg/worg/commit/05c4acae

Thanks for your contribution!

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH 1/2] org-capture: Allow entry template to start without heading

2024-05-27 Thread Bastien Guerry
Ihor Radchenko  writes:

> Bastien, may you please check FSF records?

The record for Rens is valid.

Thanks for your contributions!

-- 
 Bastien Guerry



Re: [PATCH 1/2] org-capture: Allow entry template to start without heading

2024-05-27 Thread Rens Oliemans
Ihor Radchenko  writes:

> It has been one month since the last activity in this thread.
> May I know if you got any reply from FSF?

My copyright assignment with the FSF is now complete!



Re: [PATCH 1/2] org-capture: Allow entry template to start without heading

2024-05-27 Thread Ihor Radchenko
Rens Oliemans  writes:

> Ihor Radchenko  writes:
>
>> It has been one month since the last activity in this thread.
>> May I know if you got any reply from FSF?
>
> My copyright assignment with the FSF is now complete!

Bastien, may you please check FSF records?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH 1/2] org-capture: Allow entry template to start without heading

2024-05-14 Thread Rens Oliemans
Ihor Radchenko  writes:

> It has been one month since the last activity in this thread.
> May I know if you got any reply from FSF?

I did, I got and signed the assignment, on Friday the 10th of May. I will get a 
reply of
the FSF once they have signed it, and will post here when that happens.

Best,
Rens



Re: [PATCH 1/2] org-capture: Allow entry template to start without heading

2024-05-14 Thread Ihor Radchenko
Rens Oliemans  writes:

>> Before I install the patches, may I know if you have FSF copyright
>> assignment? See https://orgmode.org/worg/org-contribute.html#copyright
>
> I had not done that yet. I have just sent the form to the FSF. I will let
> you know when the process is complete.

It has been one month since the last activity in this thread.
May I know if you got any reply from FSF?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH 1/2] org-capture: Allow entry template to start without heading

2024-04-14 Thread Rens Oliemans
Ihor Radchenko  writes:

> I have improved your patches a little, fixing the regular expression
> used to match headings ("^*" is not accurate, you need
> org-outline-regexp-bol), and adding another test case.
> See the attached.

Ah I see the difference, good catch. Thank you for the improvements!

> Before I install the patches, may I know if you have FSF copyright
> assignment? See https://orgmode.org/worg/org-contribute.html#copyright

I had not done that yet. I have just sent the form to the FSF. I will let
you know when the process is complete.

Best,
Rens



Re: [PATCH 1/2] org-capture: Allow entry template to start without heading

2024-04-14 Thread Ihor Radchenko
Rens Oliemans  writes:

> * lisp/org-capture.el (org-capture-place-entry): Prepend heading to
> template if the template does not yet start with a heading.
>
> * testing/lisp/test-org-capture.el (test-org-capture/entry): Add two
> tests: no error is raised when org-capture is called with a template
> that does not start with a heading; and org-capture should error with
> a template with a lower heading after a higher heading.
>
> Link: https://list.orgmode.org/877chnc0lr.fsf@localhost/
> ---
> First iteration of these patches, please let me know if anything can be 
> improved, either
> about the code or patches themselves (I am not used to sending patches via 
> email).

Thanks!
I have improved your patches a little, fixing the regular expression
used to match headings ("^*" is not accurate, you need
org-outline-regexp-bol), and adding another test case.
See the attached.

Before I install the patches, may I know if you have FSF copyright
assignment? See https://orgmode.org/worg/org-contribute.html#copyright

>From 36639ac711f099b49900d886ad28d29abc1b29ed Mon Sep 17 00:00:00 2001
Message-ID: <36639ac711f099b49900d886ad28d29abc1b29ed.1713102029.git.yanta...@posteo.net>
From: Rens Oliemans 
Date: Sun, 14 Apr 2024 13:24:49 +0200
Subject: [PATCH v2 1/2] org-capture: Allow entry template to start without
 heading

* lisp/org-capture.el (org-capture-place-entry): Prepend heading to
template if the template does not yet start with a heading.

* testing/lisp/test-org-capture.el (test-org-capture/entry): Add two
tests: no error is raised when org-capture is called with a template
that does not start with a heading; and org-capture should error with
a template with a lower heading after a higher heading.

Link: https://list.orgmode.org/877chnc0lr.fsf@localhost/
---
 lisp/org-capture.el  |  2 ++
 testing/lisp/test-org-capture.el | 24 
 2 files changed, 26 insertions(+)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index da14f45c0..a95a38162 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1198,6 +1198,8 @@ (defun org-capture-place-entry ()
 	(exact-position (org-capture-get :exact-position))
 	(insert-here? (org-capture-get :insert-here))
 	(level 1))
+(unless (string-match org-outline-regexp-bol template)
+  (setq template (concat "* " template)))
 (org-capture-verify-tree template)
 (when exact-position (goto-char exact-position))
 (cond
diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el
index 0ed44c6af..4e9139c40 100644
--- a/testing/lisp/test-org-capture.el
+++ b/testing/lisp/test-org-capture.el
@@ -244,6 +244,30 @@ (ert-deftest test-org-capture/entry ()
 		:immediate-finish t
(org-capture nil "t")
(buffer-string
+  ;; Do not raise an error on templates that do not start with a heading.
+  (should
+   (org-test-with-temp-text-in-file ""
+ (let* ((file (buffer-file-name))
+(org-capture-templates
+ `(("t" "Test" entry (file ,file) "Foo"
+:immediate-finish t
+   (org-capture nil "t"
+  (should
+   (org-test-with-temp-text-in-file ""
+ (let* ((file (buffer-file-name))
+(org-capture-templates
+ `(("t" "Test" entry (file ,file) "*bold*"
+:immediate-finish t
+   (org-capture nil "t"
+  ;; Raise an error on templates with a lower level heading after a
+  ;; higher level one.
+  (should-error
+   (org-test-with-temp-text-in-file ""
+ (let* ((file (buffer-file-name))
+(org-capture-templates
+ `(("t" "Test" entry (file ,file) "** X\n* Y"
+	:immediate-finish t
+   (org-capture nil "t"
   ;; With a 0 prefix argument, ignore surrounding lists.
   (should
(equal "Foo\n* X\nBar\n"
-- 
2.44.0

>From af0b56f3338b8700bd6096e4963c95436b1a14b0 Mon Sep 17 00:00:00 2001
Message-ID: 
In-Reply-To: <36639ac711f099b49900d886ad28d29abc1b29ed.1713102029.git.yanta...@posteo.net>
References: <36639ac711f099b49900d886ad28d29abc1b29ed.1713102029.git.yanta...@posteo.net>
From: Rens Oliemans 
Date: Sun, 14 Apr 2024 13:24:51 +0200
Subject: [PATCH v2 2/2] org-capture: Allow table-line entry to start without |

* lisp/org-capture.el (org-capture-place-table-line): Prepend
table-line begin ('|') if the template does not start with it.

* testing/lisp/test-org-capture.el (test-org-capture/table-line):
Verify that a template gets prepended with a '|' if it does not start
with it.
---
 lisp/org-capture.el  | 15 ---
 testing/lisp/test-org-capture.el | 10 ++
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index a95a38162.

[PATCH 1/2] org-capture: Allow entry template to start without heading

2024-04-14 Thread Rens Oliemans
* lisp/org-capture.el (org-capture-place-entry): Prepend heading to
template if the template does not yet start with a heading.

* testing/lisp/test-org-capture.el (test-org-capture/entry): Add two
tests: no error is raised when org-capture is called with a template
that does not start with a heading; and org-capture should error with
a template with a lower heading after a higher heading.

Link: https://list.orgmode.org/877chnc0lr.fsf@localhost/
---
First iteration of these patches, please let me know if anything can be 
improved, either
about the code or patches themselves (I am not used to sending patches via 
email).

 lisp/org-capture.el  |  1 +
 testing/lisp/test-org-capture.el | 17 +
 2 files changed, 18 insertions(+)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index da14f45c0..750778f8b 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1198,6 +1198,7 @@ may have been stored before."
(exact-position (org-capture-get :exact-position))
(insert-here? (org-capture-get :insert-here))
(level 1))
+(unless (string-match "^*" template) (setq template (concat "* " 
template)))
 (org-capture-verify-tree template)
 (when exact-position (goto-char exact-position))
 (cond
diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el
index 0ed44c6af..9ab078193 100644
--- a/testing/lisp/test-org-capture.el
+++ b/testing/lisp/test-org-capture.el
@@ -244,6 +244,23 @@
:immediate-finish t
(org-capture nil "t")
(buffer-string
+  ;; Do not raise an error on templates that do not start with a heading.
+  (should
+   (org-test-with-temp-text-in-file ""
+ (let* ((file (buffer-file-name))
+(org-capture-templates
+ `(("t" "Test" entry (file ,file) "Foo"
+:immediate-finish t
+   (org-capture nil "t"
+  ;; Raise an error on templates with a lower level heading after a
+  ;; higher level one.
+  (should-error
+   (org-test-with-temp-text-in-file ""
+ (let* ((file (buffer-file-name))
+(org-capture-templates
+ `(("t" "Test" entry (file ,file) "** X\n* Y"
+   :immediate-finish t
+   (org-capture nil "t"
   ;; With a 0 prefix argument, ignore surrounding lists.
   (should
(equal "Foo\n* X\nBar\n"
-- 
2.44.0