emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org-agenda-skip fails in batch mode because comment-start-skip is nil
@ 2022-06-15 17:44 Asilata Bapat
  2022-06-19  1:47 ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Asilata Bapat @ 2022-06-15 17:44 UTC (permalink / raw)
  To: emacs-orgmode

When org-scan-tags runs in a batch mode invocation, the value of the variable comment-start-skip is nil even while scanning an org file. The function org-scan-tags calls (org-agenda-skip), which in turn calls (looking-at comment-start-skip). Since the value of comment-start-skip is nil, it triggers the error (wrong-type-argument stringp nil).
To fix this, the function org-agenda-skip should ensure that the variable comment-start-skip is set to the appropriate value.

Two comments:
1. The issue was not present in Org version 9.4.4. The issue comes up when I build my webpage using Emacs 28.1 and Org 9.5.2, but not when I build it using Emacs 27.2 and Org 9.4.4.
2. The issue can indeed be fixed, e.g., by changing the source of org-agenda-skip to invoke (org-mode) immediately before the let statement. Doing this presumably sets the variable comment-start-skip to the expected value, and the invocation succeeds.

Emacs  : GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6)
 of 2022-04-27
Package: Org mode version 9.5.2 (release_9.5.2-25-gaf6f12 @ /usr/share/emacs/28.1/lisp/org/)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-agenda-skip fails in batch mode because comment-start-skip is nil
  2022-06-15 17:44 [BUG] org-agenda-skip fails in batch mode because comment-start-skip is nil Asilata Bapat
@ 2022-06-19  1:47 ` Ihor Radchenko
  2022-06-21  1:42   ` Asilata Bapat
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2022-06-19  1:47 UTC (permalink / raw)
  To: Asilata Bapat; +Cc: emacs-orgmode

Asilata Bapat <asilata@gmail.com> writes:

> When org-scan-tags runs in a batch mode invocation, the value of the variable comment-start-skip is nil even while scanning an org file. The function org-scan-tags calls (org-agenda-skip), which in turn calls (looking-at comment-start-skip). Since the value of comment-start-skip is nil, it triggers the error (wrong-type-argument stringp nil).
> To fix this, the function org-agenda-skip should ensure that the variable comment-start-skip is set to the appropriate value.

Could you please provide a detailed reproducer?

> 2. The issue can indeed be fixed, e.g., by changing the source of org-agenda-skip to invoke (org-mode) immediately before the let statement. Doing this presumably sets the variable comment-start-skip to the expected value, and the invocation succeeds.

org-agenda-skip should be operating after org-agenda-prepare-buffers,
which, in turn, should call org-mode. org-mode calls
org-setup-comments-handling which must set comment-start-skip to
non-nil.

Best,
Ihor


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-agenda-skip fails in batch mode because comment-start-skip is nil
  2022-06-19  1:47 ` Ihor Radchenko
@ 2022-06-21  1:42   ` Asilata Bapat
  2022-06-23 13:13     ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Asilata Bapat @ 2022-06-21  1:42 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1221 bytes --]

Ihor Radchenko <yantar92@gmail.com> writes:
> Could you please provide a detailed reproducer?

Sure. I have attached the files "mwe-data.org" and "mwe-export.org".

To reproduce, save both files in the same directory. Then open mwe-export.org, navigate to the "Export script" heading, and evaluate (Ctrl-C Ctrl-C) the shell source block.

Expected output: a generated html file containing the fruits and vegetables from the mwe-data.org file.
Actual output: Lisp error: (wrong-type-argument stringp nil), details as in my first message.

Compare on the other hand if you navigate to the "Fruits and vegetables" heading and evaluate the emacs-lisp code block, it outputs a list of fruits and vegetables in a results drawer.

> org-agenda-skip should be operating after org-agenda-prepare-buffers,
> which, in turn, should call org-mode. org-mode calls
> org-setup-comments-handling which must set comment-start-skip to
> non-nil.

OK, thanks for the insight. I haven't figured out where things are going wrong. But a possibly related issue is that lately, when I open an org file for the first time, org-mode does not load automatically. If I close the file and reopen, org-mode loads as expected.

Best regards,
Asilata


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: mwe-data.org --]
[-- Type: text/x-org, Size: 94 bytes --]

* Fruits
** Apple
** Banana
** Cantaloupe

* Vegetables
** Asparagus
** Broccoli
** Cabbage



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: mwe-export.org --]
[-- Type: text/x-org, Size: 609 bytes --]

#+title: MWE for testing org-agenda-skip bug
#+author: Asilata Bapat
#+options: toc:nil

* Fruits and vegetables
#+begin_src emacs-lisp :results value drawer :exports results
  (defun show-title ()
    (let ((title (org-entry-get nil "ITEM")))
      (format "- %s" title)))

  (string-join
   (org-map-entries
    'show-title
    "LEVEL=2"
    '("mwe-data.org"))
   "\n")
#+end_src


* Export script :noexport:
#+begin_src shell :results silent
  emacs --batch --visit "mwe-export.org" --eval '(require (quote org))' --eval '(setq org-confirm-babel-evaluate nil)' --eval '(org-html-export-to-html)'
#+end_src

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 219 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-agenda-skip fails in batch mode because comment-start-skip is nil
  2022-06-21  1:42   ` Asilata Bapat
@ 2022-06-23 13:13     ` Ihor Radchenko
  2022-09-28  4:35       ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2022-06-23 13:13 UTC (permalink / raw)
  To: Asilata Bapat; +Cc: emacs-orgmode, Timothy

Asilata Bapat <asilata@gmail.com> writes:

> Ihor Radchenko <yantar92@gmail.com> writes:
>> Could you please provide a detailed reproducer?
>
> Sure. I have attached the files "mwe-data.org" and "mwe-export.org".
>
> To reproduce, save both files in the same directory. Then open mwe-export.org, navigate to the "Export script" heading, and evaluate (Ctrl-C Ctrl-C) the shell source block.

Thanks!

The offending commit is ec6d1df9bc.
The author of the commit claims that we never ever need to activate
major mode inside export:

https://list.orgmode.org/874kfmbc1l.fsf@gmail.com/

>> > I'm still unsure the patch is correct: what if people *need* major
>> > mode initialization before any contents is exported to a file?
>> 
>> I haven't responded to this concern, because I haven't been able to
>> conceive of a single situation where loading the normal-mode for the
>> exported file could be desirable.

So, we do have the situations where initialization of major mode is
required during export.

Timothy, do you have any comments?
I am inclined to revert ec6d1df9bc.

Best,
Ihor



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-agenda-skip fails in batch mode because comment-start-skip is nil
  2022-06-23 13:13     ` Ihor Radchenko
@ 2022-09-28  4:35       ` Ihor Radchenko
  2022-09-28  4:41         ` Asilata Bapat
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2022-09-28  4:35 UTC (permalink / raw)
  To: Asilata Bapat; +Cc: emacs-orgmode, Timothy

Ihor Radchenko <yantar92@gmail.com> writes:

> Asilata Bapat <asilata@gmail.com> writes:
>
>> Ihor Radchenko <yantar92@gmail.com> writes:
>>> Could you please provide a detailed reproducer?
>>
>> Sure. I have attached the files "mwe-data.org" and "mwe-export.org".
>>
>> To reproduce, save both files in the same directory. Then open mwe-export.org, navigate to the "Export script" heading, and evaluate (Ctrl-C Ctrl-C) the shell source block.
>
> Thanks!
>
> The offending commit is ec6d1df9bc.
> The author of the commit claims that we never ever need to activate
> major mode inside export:
>
> https://list.orgmode.org/874kfmbc1l.fsf@gmail.com/

Fixed on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d7a55bbd537314d2776b082bd92a1a08b3edc84e

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-agenda-skip fails in batch mode because comment-start-skip is nil
  2022-09-28  4:35       ` Ihor Radchenko
@ 2022-09-28  4:41         ` Asilata Bapat
  0 siblings, 0 replies; 6+ messages in thread
From: Asilata Bapat @ 2022-09-28  4:41 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode, Timothy

[-- Attachment #1: Type: text/plain, Size: 1170 bytes --]

Wonderful! Thank you so much for your work Ihor.

Asilata

On Wed, 28 Sept 2022 at 14:35, Ihor Radchenko <yantar92@gmail.com> wrote:

> Ihor Radchenko <yantar92@gmail.com> writes:
>
> > Asilata Bapat <asilata@gmail.com> writes:
> >
> >> Ihor Radchenko <yantar92@gmail.com> writes:
> >>> Could you please provide a detailed reproducer?
> >>
> >> Sure. I have attached the files "mwe-data.org" and "mwe-export.org".
> >>
> >> To reproduce, save both files in the same directory. Then open
> mwe-export.org, navigate to the "Export script" heading, and evaluate
> (Ctrl-C Ctrl-C) the shell source block.
> >
> > Thanks!
> >
> > The offending commit is ec6d1df9bc.
> > The author of the commit claims that we never ever need to activate
> > major mode inside export:
> >
> > https://list.orgmode.org/874kfmbc1l.fsf@gmail.com/
>
> Fixed on main.
>
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d7a55bbd537314d2776b082bd92a1a08b3edc84e
>
> --
> Ihor Radchenko,
> Org mode contributor,
> Learn more about Org mode at https://orgmode.org/.
> Support Org development at https://liberapay.com/org-mode,
> or support my work at https://liberapay.com/yantar92
>

[-- Attachment #2: Type: text/html, Size: 2530 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-28  4:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 17:44 [BUG] org-agenda-skip fails in batch mode because comment-start-skip is nil Asilata Bapat
2022-06-19  1:47 ` Ihor Radchenko
2022-06-21  1:42   ` Asilata Bapat
2022-06-23 13:13     ` Ihor Radchenko
2022-09-28  4:35       ` Ihor Radchenko
2022-09-28  4:41         ` Asilata Bapat

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).