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-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] org-manual: Rewrite opening section in Citation handling

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

> Thanks! I have incorporated all your suggestions into the new version of
> the patch (attached).

Thanks, it looks good to me!

> Yes, it is. Applying diff is easy - easier than manually editing the
> changes according to comments in the email.

Great, good to know.

Best,
Rens



Re: LOGBOOK drawer now being created with blank line afterwards

2024-05-15 Thread Rens Oliemans
Kris Nelson  writes:

> I'm currently reviewing the org source to try and see where the new line is 
> coming from in the process flow, but I'm a bit of a novice in regards to 
> elisp, so I haven't figured that out yet.
>
> I also tried searching the mailing list archive, but didn't see anything 
> related.

Thanks for reporting, it seems that this was changed in
f63ff074417315fcf93c2ca6cfe8f89fcc6d902f, "Fix subtle differences between 
overlays and
invisible text properties", bisected with Emacs 29.3.



Re: [PATCH] org-manual: Rewrite opening section in Citation handling

2024-05-14 Thread Rens Oliemans
Thanks for the patch, it looks good and is an improvement over the
somewhat terse previous version. I do have some thoughts though so will
chime in. Note that I am not a native speaker, it might be best if we get
extra eyes from a(nother?) native speaker.

Ihor Radchenko  writes:

> +While [[*Hyperlinks][links]] are often sufficient to refer to external
> +or internal information from Org, they have their limitations when
> +referring to multiple targets or typesetting printed publications.

In Emacs Info, this renders as

   "While see links. are often sufficient ...".

This seems quite unnatural to me. I would suggest using a different way
of referencing (without "see [link].") if possible, or rewording the
sentence otherwise.

> +In addition to export, users can use completion to search and insert
> +citations from the bibliography (via ~org-cite-insert~).  Citations
> +also act like ordinary links, jumping to the citation metadata when
> +"following" them (~org-open-at-point~).

Alternatively:

   when "following" them using ~org-open-at-point~.

For a more natural sentence?

> +Org mode ships with several built-in citation processors tailored to
> +work with LaTeX export and BibTeX bibliographies (=bibtex=,
> +=biblatex=, and =natbib= processors), or with more generic formats
> +described using [[https://citationstyles.org/][Citation Style
> +Language]] (=csl= processor).
> +
> +The default citation processor is =basic= - it works with arbitrary
> +export formats and recognizes both BibTeX and CSL bibliographies.
> +
> +More citation processors are distributed as Emacs packages.

These very small paragraphs read a bit clunky to me, I think that it's
better to merge them into a single paragraph.

> -  When style is not specified, default style is used
> +  When style is not specified, default style (=nil=) specified by the
> +  citation processor is used

I am only slightly familiar with Org's citation handling, and this part
of the manual is a bit confusing to me. I wrote a small patch on top of
yours with something that is clearer to me, but perhaps this is unique to
me.

>From 70fe33fe0012c124fd011011ee77e544e18d50ad Mon Sep 17 00:00:00 2001
From: Rens Oliemans 
Date: Tue, 14 May 2024 20:45:01 +0200
Subject: [PATCH] org-manual: clarify default style

I don't intend this commit to be merged but instead to be squashed in
the existing patch.
---
 doc/org-manual.org | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 50af99c5b..c2f08be17 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -17609,16 +17609,16 @@ identifying a reference in the bibliography.
 
   : [cite/style:common prefix ;prefix @key suffix; ... ; common suffix]
 
-  When style is not specified, default style (=nil=) specified by the
-  citation processor is used
+  When =style= is not specified, one of the two default styles are
+  used
 
-  + either the default style specified in =CITE_EXPORT= keyword (see
-[[*Citation export processors]])
+  + either the default style specified in the =CITE_EXPORT= keyword
+(see [[*Citation export processors]])
 
 : #+cite_export: basic numeric noauthor/bare
 : [cite:@key] is the same as [cite/noauthor/bare:@key]
 
-  + or using default =nil= style
+  + or, if =CITE_EXPORT= is not set, using the default =nil= style
 
 : [cite:@key] is the same as [cite/nil:@key]
 
-- 
2.44.0


Is this understanding of the 'style' specification correct? This is what
I concluded from reading the manual, if it is incorrect, please forgive
me and let me know how exactly I am incorrect, perhaps that can
illuminate this part ;)


Best,
Rens

PS: is such a way of including a patch (that builds upon a discussed
patch) the best way to communicate changes? 


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-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



[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



[PATCH 2/2] org-capture: Allow table-line entry to start without |

2024-04-14 Thread Rens Oliemans
* 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 750778f8b..a56e75fda 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1355,13 +1355,14 @@ may have been stored before."
 (defun org-capture-place-table-line ()
   "Place the template as a table line."
   (require 'org-table)
-  (let ((text
-(pcase (org-trim (org-capture-get :template))
-  ((pred (string-match-p org-table-border-regexp))
-   "| %?Bad template |")
-  (text (concat text "\n"
-   (table-line-pos (org-capture-get :table-line-pos))
-   beg end)
+  (let* ((template (org-trim (org-capture-get :template)))
+ (text
+ (pcase template
+   ((pred (string-match-p org-table-border-regexp))
+(concat "| " template))
+   (text (concat text "\n"
+(table-line-pos (org-capture-get :table-line-pos))
+beg end)
 (cond
  ((org-capture-get :exact-position)
   (org-with-point-at (org-capture-get :exact-position)
diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el
index 9ab078193..6c13e8283 100644
--- a/testing/lisp/test-org-capture.el
+++ b/testing/lisp/test-org-capture.el
@@ -606,6 +606,16 @@
   "| 2 |" :immediate-finish t
  (org-capture nil "t"))
(buffer-string
+  ;; Prepend | when the template does not start with it
+  (should
+   (equal "| 1 |\n| 2 |\n"
+  (org-test-with-temp-text-in-file "| 1 |\n"
+(let* ((file (buffer-file-name))
+   (org-capture-templates
+`(("t" "Table" table-line (file ,file)
+   "2 |" :immediate-finish t
+  (org-capture nil "t")
+  (buffer-string)
   ;; When `:prepend' is nil, add the row at the end of the table.
   (should
(equal "| a |\n| x |\n"
-- 
2.44.0




"Bad template" when creating org-capture for table-line without '|'

2024-03-27 Thread Rens Oliemans
Hi,

I was trying to create an org-capture for a table-line type, and I noticed that
org-capture inserts the string "| Bad template |" when the template does not 
start with
'|'. This could make sense, since a line is (only) considered part of a table 
when it
starts with '|'.

However, I did not know that the _template_ also has to start with '|', and 
org-capture
still inserts the string "| Bad template |", which does not suggest in any way 
that the
lacking '|' would be the problem (after all, it is smart enough to prepend a 
'|').

Use this template to reproduce the behaviour, present on 9.7-pre
(release_9.6.23-1318-g990b89):

(setq org-capture-templates '(("t" "Test" table-line (file "test.org")
   "%^t")))

I did not see this documented anywhere: this was quite confusing, and the only 
way I got a
hint at what I did wrong was to see the default template for table-line: "| %? 
|". It
seems that this behaviour is intended, looking at org-capture.el:1358 @ 
990b89d3:

...
 (pcase (org-trim (org-capture-get :template))
   ((pred (string-match-p org-table-border-regexp))
"| %?Bad template |")
   (text (concat text "\n"
...

however, is this also what's ideal? I would suggest one of the following 
alternatives:

- An error is signalled to the user with the root cause of the error: no '|' at 
start of
  template. In addition, the org-capture-templates variable documentation 
string and the
  manual would be updated. I am happy to create a patch for this.

- org-capture could pre- and suffix a '|' if the user did not supply it in 
their template.
  I am also happy to create a patch for this, however that would be my first so 
such a
  patch would perhaps have a few iterations ;)

What are your thoughts on this?

Best



Re: Possible bug in org-agenda not showing habits properly

2024-03-20 Thread Rens Oliemans
Ihor Radchenko  writes:

> You should set `org-modules' _before_ loading Org. Or you can load
> org-habit in more traditional way, via (require 'org-habit) or
> (use-package org-habit).

Thanks, this works! I misunderstood the way the different use-package blocks 
got executed.



Possible bug in org-agenda not showing habits properly

2024-03-18 Thread Rens Oliemans
When I open an org file before opening the agenda, my habits show up as regular 
tasks,
rather than with the consistency graph. Additionally, many CANCELed tasks still 
show up in
the agenda. When I open the agenda first however, everything goes fine.

Interestingly, this only happens when I bind 'org-agenda' to a key. To show 
this, I have
attached bad.el and good.el which reproduce the issue on current main (Org mode 
version
9.7-pre (release_9.6.21-1295-g46909a @ /opt/org-mode/lisp/)).

Note that they set

(setq org-directory "/tmp/tmp.emacs/notes")

and they expect '/tmp/tmp.emacs/notes/file.org' to exist, see attachment.

Reproduce with:

  emacs -Q -l bad.el /tmp/tmp.emacs/notes/file.org

so that it definitely opens an org-file before the org-agenda. After opening 
the agenda,
my habits do not show up as habits. My habits do show up with:

  emacs -Q -l bad.el --eval="(org-agenda-list)"

and with they also show up:

  emacs -Q -l good.el /tmp/tmp.emacs/notes/file.org

I am running Emacs 29.2. Am I doing something wrong here?

(use-package org
  :load-path "/opt/org-mode/lisp"
  :init
  (setq org-directory "/tmp/tmp.emacs/notes"))

(use-package org-agenda
  :ensure nil
  :load-path "/opt/org-mode/lisp"
  :config
  (add-to-list 'org-modules 'org-habit t)
  (setq org-agenda-files '("file.org"))

  :bind (("C-c a" . org-agenda)))
(use-package org
  :load-path "/opt/org-mode/lisp"
  :init
  (setq org-directory "/tmp/tmp.emacs/notes"))

(use-package org-agenda
  :ensure nil
  :load-path "/opt/org-mode/lisp"
  :config
  (add-to-list 'org-modules 'org-habit t)
  (setq org-agenda-files '("file.org")))


file.org
Description: Lotus Organizer


Re: [BUG] org-refile doesn't work when target is immediately above

2023-10-02 Thread Rens Oliemans
Ihor Radchenko  writes:

> I cannot reproduce on the latest main.

Me neither, it seems that commit 0d5951a9b02d9ce71af154612d0fa3a3381856ec fixed 
the issue.

--
Rens



Tips on reproducing and bisecting bugs

2023-09-06 Thread Rens Oliemans
Hi all,

Thanks for creating and maintaining Org mode, it's great. I tried helping out 
recently by
confirming and bisecting a reported bug
(https://list.orgmode.org/camjkazz6srdoxv6rhmdm97enhysntodtctcznn1zbquk3gh...@mail.gmail.com/),
but am not sure if what I did was actually useful, and if so, how to do this 
more
efficiently.

I have the orgmode repo cloned, and build orgmode with `make && make vanilla`. 
When
bisecting, I manually navigate to and load the required init.el and reproduce 
the bug per
commit. It seems that parameters passed to `make vanilla` are not passed to 
emacs. Is this
how you would do it, or do you have tips to improve this workflow? 
Additionally, how could
I do this for different emacs versions?

If it wasn't all that useful, what can I do to improve this? I have a little 
bit of lisp
knowledge, but no experience with the orgmode source code (yet).

--
Thanks and best,
Rens



Re: [BUG] unexpected octave output from code blocks [9.7-pre (release_9.6.7-581-gd38ca5)]

2023-09-06 Thread Rens Oliemans
Confirmed on my machine, thanks for the bug report and reproduction files.

I could reproduce the bug on GNU Emacs 28.2, git bisect told me that commit
866ed1a3c5c37cad243085f9a8fa904970e4d614 was the first bad commit.

--
Rens Oliemans



[BUG] Header-args :results output of code block don't take precedence above headline header-args [9.6 (release_9.6-32-gc59d6d @ /tmp/org/org-mode/lisp/)]

2022-12-09 Thread Rens Oliemans
Hi all,

A code block with ":results output" as header argument still has its
output silenced if it's inside a headline with ":results none". MWE:

1. Create an .org file with the following content:

* Sub-tree with =:results none=
:PROPERTIES:
:header-args: :results none
:END:

#+BEGIN_SRC bash :results output
  echo "is silent"
#+END_SRC

2. Use a minimal config, attached is the one I used. Bug is present on
at least Org 9.6 and 9.5

3. Evaluate the code block(s) and see that their output is silenced.

Attached is a file much like this, but with an additional code block
with a #+HEADER style argument. Also included is the minimal-org.el I
used to reproduce this.

I tried bisecting this, but I can't find a good commit that's recent
enough to compile on my machine without changing Emacs versions. This
might be a clue that this is not a bug but a configuration issue on my
side, but I did my best to rule that out. This is the first time posting
in a (and by extension, this) mailing list, please highlight any errors
I made/things I can do better.

All the best,
Rens Oliemans

Emacs : GNU Emacs 28.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version
 3.24.34, cairo version 1.17.6) of 2022-07-21
Package: Org mode version 9.6 (release_9.6-32-gc59d6d @
 /tmp/org/org-mode/lisp/)

* Sub-tree with =:results none=
:PROPERTIES:
:header-args: :results none
:END:

#+BEGIN_SRC bash :results output
  echo "is silent"
#+END_SRC

#+HEADER: :results output
#+BEGIN_SRC bash
  echo "is also silent"
#+END_SRC
;; Add latest Org mode to load path.
(add-to-list 'load-path (expand-file-name "/tmp/org/org-mode/lisp"))

;; Relevant settings for bug repro
(org-babel-do-load-languages
 'org-babel-load-languages
 '((shell . t)))