Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Help needed: nnmaildir and create-directory parameter.
@ 2022-11-23 14:44 Fernando de Morais
  2022-11-23 18:00 ` Eric Abrahamsen
  0 siblings, 1 reply; 7+ messages in thread
From: Fernando de Morais @ 2022-11-23 14:44 UTC (permalink / raw)
  To: info-gnus-english

Hello everyone,

According to the manual, for a `nnmaildir' server, if my split rules
create new groups, I need to supply a `create-directory' server
parameter[1].  Ok, so considering the following example snippet:

#+begin_src emacs-lisp
  (customize-set-variable 'gnus-select-method '(nnnil ""))
  (customize-set-variable 'gnus-secondary-select-methods
                          '((nntp "news.gwene.org")
                            (nnmaildir ""
                                       (directory "~/Mail/maildirs")
                                       (target-prefix "")
                                       (get-new-mail t)
                                       (create-directory ...)))) ; <-- Here
  (customize-set-variable 'mail-sources '((file :path "~/Mail/emaple_mbox")))
  (customize-set-variable 'nnmail-split-methods '(("inbox" "")))
#+end_src

Following the example snippet above, what is the expected value for the
parameter `create-directory'?  Unfortunately the manual brings no
details about it.

I've been experimenting with some ``logical'' values (basically the same
values accepted in `target-prefix' parameter), but every time I get an
error and a crash box[2].

Can anyone help me with this matter?

Thanks in advance.


Footnotes:
[1]  (info "(gnus) Maildir")
[2]  (info "(gnus) Mail Source Customization")

-- 
Regards,
Fernando de Morais.


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

* Re: Help needed: nnmaildir and create-directory parameter.
  2022-11-23 14:44 Help needed: nnmaildir and create-directory parameter Fernando de Morais
@ 2022-11-23 18:00 ` Eric Abrahamsen
  2022-11-24  5:52   ` Fernando de Morais
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Abrahamsen @ 2022-11-23 18:00 UTC (permalink / raw)
  To: Fernando de Morais; +Cc: info-gnus-english

Fernando de Morais <fernandodemorais.jf@gmail.com> writes:

> Hello everyone,
>
> According to the manual, for a `nnmaildir' server, if my split rules
> create new groups, I need to supply a `create-directory' server
> parameter[1].  Ok, so considering the following example snippet:
>
> #+begin_src emacs-lisp
>   (customize-set-variable 'gnus-select-method '(nnnil ""))
>   (customize-set-variable 'gnus-secondary-select-methods
>                           '((nntp "news.gwene.org")
>                             (nnmaildir ""
>                                        (directory "~/Mail/maildirs")
>                                        (target-prefix "")
>                                        (get-new-mail t)
>                                        (create-directory ...)))) ; <-- Here
>   (customize-set-variable 'mail-sources '((file :path "~/Mail/emaple_mbox")))
>   (customize-set-variable 'nnmail-split-methods '(("inbox" "")))
> #+end_src
>
> Following the example snippet above, what is the expected value for the
> parameter `create-directory'?  Unfortunately the manual brings no
> details about it.

I won't claim to understand how this is supposed to work, but in
`nnmaildir-open-server' we've got the following chunk of
lisp-as-imperative-code:

(setq x (assq 'target-prefix defs))
(if x
    (progn
      (setq x (cadr x)
	    x (eval x t))	;FIXME: Why `eval'?
      (setf (nnmaildir--srv-target-prefix server) x))
  (setq x (assq 'create-directory defs))
  (if x
      (progn
	(setq x (cadr x)
	      x (eval x t) ;FIXME: Why `eval'?
	      x (file-name-as-directory x))
	(setf (nnmaildir--srv-target-prefix server) x))
    (setf (nnmaildir--srv-target-prefix server) "")))

This makes it look to me like, if you've got a 'target-prefix set (even
if it's the empty string), then 'create-directory never comes into play
at all.

So maybe try taking out the (target-prefix "") server config completely?

I really don't know how this is meant to work. If you figure it out we
should update the manual.

Thanks,
Eric


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

* Re: Help needed: nnmaildir and create-directory parameter.
  2022-11-23 18:00 ` Eric Abrahamsen
@ 2022-11-24  5:52   ` Fernando de Morais
  2022-11-25 19:21     ` Eric Abrahamsen
  0 siblings, 1 reply; 7+ messages in thread
From: Fernando de Morais @ 2022-11-24  5:52 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: info-gnus-english

Hello Eric,

I've managed to figure out.  The TL;DR is: simply, don't use the
`create-directory' server parameter.  Using only `target-prefix' is what
is needed.  😅

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> So maybe try taking out the (target-prefix "") server config completely?

With something like this:

#+begin_src emacs-lisp
...
  (nnmaildir ""
             (directory "~/Dir")
             ;; (target-prefix "")
             (get-new-mail t)
             (create-directory ""))
...
#+end_src

Gnus will create groups (and respective folders) specified in
`nnmail-split-method', however it will raise an error, saying that the
directories already exists (?) and we will get a crash box, again.  With
my testes, any other value besides `""' will result in error.

But, uncommenting the `target-prefix' line and removing the
`create-directory' one, we'll end with the expected behaviour, without
errors.

> I really don't know how this is meant to work. If you figure it out we
> should update the manual.

If its of any use, I'd would like to suggest:

- Inform in the manual that if the user wants to configure something
  like `(target-prefix "maildirs/")', he will need to create the
  `"maildirs"' folder (in my example above, inside the `"~/Dir"'), by
  code or manually; and

- Switch the `create-directory' to `target-prefix' in the last
  paragraph.  But the code will still be there...

I don't know if there would be any practical benefit in making changes
in a way that using `create-directory' works as expected, especially
when `target-prefix' already does the job.  But anyway, I'm just
rambling here, the question has been answered.

Thank you very much for pointing the direction to address this issue,
Eric.

-- 
Regards,
Fernando de Morais.


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

* Re: Help needed: nnmaildir and create-directory parameter.
  2022-11-24  5:52   ` Fernando de Morais
@ 2022-11-25 19:21     ` Eric Abrahamsen
  2022-11-26  0:16       ` Andrew Cohen
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Abrahamsen @ 2022-11-25 19:21 UTC (permalink / raw)
  To: Fernando de Morais; +Cc: info-gnus-english, Andrew Cohen

Fernando de Morais <fernandodemorais.jf@gmail.com> writes:

> Hello Eric,
>
> I've managed to figure out.  The TL;DR is: simply, don't use the
> `create-directory' server parameter.  Using only `target-prefix' is what
> is needed.  😅
>
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> So maybe try taking out the (target-prefix "") server config completely?
>
> With something like this:
>
> #+begin_src emacs-lisp
> ...
>   (nnmaildir ""
>              (directory "~/Dir")
>              ;; (target-prefix "")
>              (get-new-mail t)
>              (create-directory ""))
> ...
> #+end_src
>
> Gnus will create groups (and respective folders) specified in
> `nnmail-split-method', however it will raise an error, saying that the
> directories already exists (?) and we will get a crash box, again.  With
> my testes, any other value besides `""' will result in error.
>
> But, uncommenting the `target-prefix' line and removing the
> `create-directory' one, we'll end with the expected behaviour, without
> errors.

I'm guessing this is because, if you use create-directory instead of
target-prefix, the empty string additionally gets run through
`file-name-as-directory', which converts the "" to "./" and sets that as
the value of target-prefix, and lord knows what that ends up doing.

I just don't understand how any of this is supposed to work -- I don't
even know why you'd use symlinks in your maildirs to begin with. This
part of the manual was written by Andy Cohen and I'm cc'ing him here,
though he doesn't have a lot of time for Emacs these days and we might
not get him.

Andy, you wrote this section of the manual 10+ years ago, do you still
remember how it's supposed to work? What is the intended relationship
between 'remove-prefix and 'create-directory, when the latter simply
gets copied to the former if the former is nil?

(I suspect the end result of all this will be the removal of
'create-directory altogether.)

Thanks,
Eric


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

* Re: Help needed: nnmaildir and create-directory parameter.
  2022-11-25 19:21     ` Eric Abrahamsen
@ 2022-11-26  0:16       ` Andrew Cohen
  2022-11-26 18:02         ` Eric Abrahamsen
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Cohen @ 2022-11-26  0:16 UTC (permalink / raw)
  To: info-gnus-english

>>>>> "EA" == Eric Abrahamsen <eric@ericabrahamsen.net> writes:

    EA> Fernando de Morais <fernandodemorais.jf@gmail.com> writes:
    >> Hello Eric,
    >> 
    >> I've managed to figure out.  The TL;DR is: simply, don't use the
    >> `create-directory' server parameter.  Using only `target-prefix'
    >> is what is needed.  😅
    >> 
    >> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
    >> 

[...]


    EA> I just don't understand how any of this is supposed to work -- I
    EA> don't even know why you'd use symlinks in your maildirs to begin
    EA> with. This part of the manual was written by Andy Cohen and I'm
    EA> cc'ing him here, though he doesn't have a lot of time for Emacs
    EA> these days and we might not get him.

False and true:) I didn't have anything to do with this part of the
manual (or the nnmaildir code), and I have very little time for emacs
these days.

[...]

    EA> (I suspect the end result of all this will be the removal of
    EA> 'create-directory altogether.)

Looking back through git I see that Paul Jarc (the author of nnmaildir)
replaced 'create-directory with 'target-prefix in 2003. It was supposed
to be a /complete/ replacement, but it appears that 'create-directory
was accidentally left in the code and the manual .  Eric's suspicion is
exactly right: don't use 'create-directory, and the variable should be
removed from nnmaildir.el and the manual.

Best,
Andy

-- 
Andrew Cohen
Director, HKUST Jockey Club Institute for Advanced Study
Lam Woo Foundation Professor and Chair Professor of Physics
The Hong Kong University of Science and Technology



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

* Re: Help needed: nnmaildir and create-directory parameter.
  2022-11-26  0:16       ` Andrew Cohen
@ 2022-11-26 18:02         ` Eric Abrahamsen
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2022-11-26 18:02 UTC (permalink / raw)
  To: info-gnus-english

Andrew Cohen <acohen@ust.hk> writes:

>>>>>> "EA" == Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>     EA> Fernando de Morais <fernandodemorais.jf@gmail.com> writes:
>     >> Hello Eric,
>     >> 
>     >> I've managed to figure out.  The TL;DR is: simply, don't use the
>     >> `create-directory' server parameter.  Using only `target-prefix'
>     >> is what is needed.  😅
>     >> 
>     >> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>     >> 
>
> [...]
>
>
>     EA> I just don't understand how any of this is supposed to work -- I
>     EA> don't even know why you'd use symlinks in your maildirs to begin
>     EA> with. This part of the manual was written by Andy Cohen and I'm
>     EA> cc'ing him here, though he doesn't have a lot of time for Emacs
>     EA> these days and we might not get him.
>
> False and true:) I didn't have anything to do with this part of the
> manual (or the nnmaildir code), and I have very little time for emacs
> these days.

Thanks for the quick response! magit-blame in gnus.texi found your
commit 8a1cdce, but you might have been merging docs from different
places. But no matter! So long as the question is resolved.

> [...]
>
>     EA> (I suspect the end result of all this will be the removal of
>     EA> 'create-directory altogether.)
>
> Looking back through git I see that Paul Jarc (the author of nnmaildir)
> replaced 'create-directory with 'target-prefix in 2003. It was supposed
> to be a /complete/ replacement, but it appears that 'create-directory
> was accidentally left in the code and the manual .  Eric's suspicion is
> exactly right: don't use 'create-directory, and the variable should be
> removed from nnmaildir.el and the manual.

Excellent, thanks a lot for this confirmation. I'll yank that stuff out
in a bit.

Eric



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

* Help needed: nnmaildir and create-directory parameter.
@ 2022-11-23 14:25 Fernando de Morais
  0 siblings, 0 replies; 7+ messages in thread
From: Fernando de Morais @ 2022-11-23 14:25 UTC (permalink / raw)
  To: info-gnus-english

Hello everyone,

According to the manual, for a `nnmaildir' server, if my split rules
create new groups, I need to supply a `create-directory' server
parameter[1].  Ok, so considering the following example snippet:

#+begin_src emacs-lisp
  (customize-set-variable 'gnus-select-method '(nnnil ""))
  (customize-set-variable 'gnus-secondary-select-methods
                          '((nntp "news.gwene.org")
                            (nnmaildir ""
                                       (directory "~/Mail/maildirs")
                                       (target-prefix "")
                                       (get-new-mail t)
                                       (create-directory ...)))) ; <-- Here
  (customize-set-variable 'mail-sources '((file :path "~/Mail/emaple_mbox")))
  (customize-set-variable 'nnmail-split-methods '(("inbox" "")))
#+end_src

Following the example snippet above, what is the expected value for the
parameter `create-directory'?  Unfortunately the manual brings no
details about expected values.

I've been experimenting with some ``logical'' values (basically the same
values accepted in `target-prefix' parameter), but every time I get an
error and an crash box[2].

Can anyone help me with this matter?

Thanks in advance.


Footnotes:
[1]  (info "(gnus) Maildir")
[2]  (info "(gnus) Mail Source Customization")

-- 
Regards,
Fernando de Morais.


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

end of thread, other threads:[~2022-11-26 18:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 14:44 Help needed: nnmaildir and create-directory parameter Fernando de Morais
2022-11-23 18:00 ` Eric Abrahamsen
2022-11-24  5:52   ` Fernando de Morais
2022-11-25 19:21     ` Eric Abrahamsen
2022-11-26  0:16       ` Andrew Cohen
2022-11-26 18:02         ` Eric Abrahamsen
  -- strict thread matches above, loose matches on Subject: below --
2022-11-23 14:25 Fernando de Morais

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 NNTP newsgroup(s).