unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#63411: 29.0.90; pcomplete/systemctl cannot complete units for old versions of systemd
@ 2023-05-10  9:47 Liu Hui
  2023-05-17  8:53 ` bug#63411: [PATCH] " Liu Hui
  0 siblings, 1 reply; 7+ messages in thread
From: Liu Hui @ 2023-05-10  9:47 UTC (permalink / raw)
  To: 63411

Hi,

It is very convenient that Emacs 29 supports eshell completion for
systemctl, but I find units cannot be completed on Ubuntu 20.04 LTS:

1. emacs -Q
2. M-x eshell
3. type "systemctl stop ", and press TAB

There is no completion for units.

The reason is that 'pcmpl-linux--systemd-units' uses a new option
'--legend=no' that is introduced since Feb 18, 2021[1], and the option
cannot be recognized by systemd v245 on my system. Since the old
option '--no-legend' is still kept for compatibility[2], I suggest we
can just replace '--legend=no' with '--no-legend' to make systemctl
completion works for old systems.

[1] https://github.com/systemd/systemd/pull/18596
[2] https://github.com/systemd/systemd/blob/main/src/systemctl/systemctl.c#L485

Best,
Liu Hui





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

* bug#63411: [PATCH] pcomplete/systemctl cannot complete units for old versions of systemd
  2023-05-10  9:47 bug#63411: 29.0.90; pcomplete/systemctl cannot complete units for old versions of systemd Liu Hui
@ 2023-05-17  8:53 ` Liu Hui
  2023-05-18 10:40   ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Liu Hui @ 2023-05-17  8:53 UTC (permalink / raw)
  To: 63411

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

Here is the patch that fixes the problem.

[-- Attachment #2: 0001-Fix-systemd-unit-completion-for-old-versions-of-syst.patch --]
[-- Type: text/x-patch, Size: 988 bytes --]

From aaba4753ada1c003171d9a5342c87a945992e62f Mon Sep 17 00:00:00 2001
From: Liu Hui <liuhui1610@gmail.com>
Date: Wed, 17 May 2023 16:39:18 +0800
Subject: [PATCH] Fix systemd unit completion for old versions of systemd

* lisp/pcmpl-linux.el (pcmpl-linux--systemd-units): Use '--no-legend'
for compatibility.
---
 lisp/pcmpl-linux.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/pcmpl-linux.el b/lisp/pcmpl-linux.el
index 082072d87d2..589b4799c8d 100644
--- a/lisp/pcmpl-linux.el
+++ b/lisp/pcmpl-linux.el
@@ -119,7 +119,8 @@ pcmpl-linux--systemd-units
   (with-temp-buffer
     (apply #'call-process
            "systemctl" nil '(t nil) nil
-           "list-units" "--full" "--legend=no" "--plain" args)
+           ;; "--legend=no" doesn't exist before systemd v248
+           "list-units" "--full" "--no-legend" "--plain" args)
     (goto-char (point-min))
     (let (result)
       (while (re-search-forward (rx bol (group (+ (not space)))
-- 
2.25.1


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

* bug#63411: [PATCH] pcomplete/systemctl cannot complete units for old versions of systemd
  2023-05-17  8:53 ` bug#63411: [PATCH] " Liu Hui
@ 2023-05-18 10:40   ` Eli Zaretskii
  2023-05-18 13:29     ` Liu Hui
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-05-18 10:40 UTC (permalink / raw)
  To: Liu Hui; +Cc: 63411

> From: Liu Hui <liuhui1610@gmail.com>
> Date: Wed, 17 May 2023 16:53:13 +0800
> 
> Here is the patch that fixes the problem.
> 
> From aaba4753ada1c003171d9a5342c87a945992e62f Mon Sep 17 00:00:00 2001
> From: Liu Hui <liuhui1610@gmail.com>
> Date: Wed, 17 May 2023 16:39:18 +0800
> Subject: [PATCH] Fix systemd unit completion for old versions of systemd
> 
> * lisp/pcmpl-linux.el (pcmpl-linux--systemd-units): Use '--no-legend'
> for compatibility.
> ---
>  lisp/pcmpl-linux.el | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lisp/pcmpl-linux.el b/lisp/pcmpl-linux.el
> index 082072d87d2..589b4799c8d 100644
> --- a/lisp/pcmpl-linux.el
> +++ b/lisp/pcmpl-linux.el
> @@ -119,7 +119,8 @@ pcmpl-linux--systemd-units
>    (with-temp-buffer
>      (apply #'call-process
>             "systemctl" nil '(t nil) nil
> -           "list-units" "--full" "--legend=no" "--plain" args)
> +           ;; "--legend=no" doesn't exist before systemd v248
> +           "list-units" "--full" "--no-legend" "--plain" args)
>      (goto-char (point-min))
>      (let (result)
>        (while (re-search-forward (rx bol (group (+ (not space)))
> -- 
> 2.25.1

Thanks.

I'm not an expert on systemctl; would someone who uses that please
tell if this could have any downsides?  E.g., is --no-legend expected
to be deprecated, perhaps resulting in a warning message or something?
If not, why did the systemd developers add another option with the
same semantics?





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

* bug#63411: [PATCH] pcomplete/systemctl cannot complete units for old versions of systemd
  2023-05-18 10:40   ` Eli Zaretskii
@ 2023-05-18 13:29     ` Liu Hui
  2023-05-18 14:16       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Liu Hui @ 2023-05-18 13:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 63411

> I'm not an expert on systemctl; would someone who uses that please
> tell if this could have any downsides?  E.g., is --no-legend expected
> to be deprecated, perhaps resulting in a warning message or something?
> If not, why did the systemd developers add another option with the
> same semantics?

--no-legend is indeed superseded by --legend=yes/no in systemd v248+,
but it is not deprecated. It is kept for compatibility and is totally
equivalent to --legend=no, and doesn't produce any warning message. I
have tested with systemctl v249 on Ubuntu 22.04 and the outputs are
same. In fact, the point of the new option is it allows to display
legends by --legend=yes in spite of other options such as --quiet,
which is explained in https://github.com/systemd/systemd/pull/18596.

Another simple solution is adding a variable, e.g.
pcmpl-linux-systemd-list-unit-arguments, to allow users to change
options passing to systemctl. WDYT?





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

* bug#63411: [PATCH] pcomplete/systemctl cannot complete units for old versions of systemd
  2023-05-18 13:29     ` Liu Hui
@ 2023-05-18 14:16       ` Eli Zaretskii
  2023-05-18 18:57         ` Jim Porter
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-05-18 14:16 UTC (permalink / raw)
  To: Liu Hui; +Cc: 63411

> From: Liu Hui <liuhui1610@gmail.com>
> Date: Thu, 18 May 2023 21:29:46 +0800
> Cc: 63411@debbugs.gnu.org
> 
> > I'm not an expert on systemctl; would someone who uses that please
> > tell if this could have any downsides?  E.g., is --no-legend expected
> > to be deprecated, perhaps resulting in a warning message or something?
> > If not, why did the systemd developers add another option with the
> > same semantics?
> 
> --no-legend is indeed superseded by --legend=yes/no in systemd v248+,
> but it is not deprecated. It is kept for compatibility and is totally
> equivalent to --legend=no, and doesn't produce any warning message. I
> have tested with systemctl v249 on Ubuntu 22.04 and the outputs are
> same. In fact, the point of the new option is it allows to display
> legends by --legend=yes in spite of other options such as --quiet,
> which is explained in https://github.com/systemd/systemd/pull/18596.

Thanks, I think I will wait for a few days to let others chime in.

> Another simple solution is adding a variable, e.g.
> pcmpl-linux-systemd-list-unit-arguments, to allow users to change
> options passing to systemctl. WDYT?

If --no-legend will continue to be supported for the observable
future, asking users to control that would be an annoyance, I think.





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

* bug#63411: [PATCH] pcomplete/systemctl cannot complete units for old versions of systemd
  2023-05-18 14:16       ` Eli Zaretskii
@ 2023-05-18 18:57         ` Jim Porter
  2023-05-20 15:02           ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Jim Porter @ 2023-05-18 18:57 UTC (permalink / raw)
  To: Eli Zaretskii, Liu Hui; +Cc: 63411

On 5/18/2023 7:16 AM, Eli Zaretskii wrote:
>> From: Liu Hui <liuhui1610@gmail.com>
>> Date: Thu, 18 May 2023 21:29:46 +0800
>> Cc: 63411@debbugs.gnu.org
>>
>> --no-legend is indeed superseded by --legend=yes/no in systemd v248+,
>> but it is not deprecated. It is kept for compatibility and is totally
>> equivalent to --legend=no, and doesn't produce any warning message. I
>> have tested with systemctl v249 on Ubuntu 22.04 and the outputs are
>> same. In fact, the point of the new option is it allows to display
>> legends by --legend=yes in spite of other options such as --quiet,
>> which is explained in https://github.com/systemd/systemd/pull/18596.
> 
> Thanks, I think I will wait for a few days to let others chime in.

I stumbled on this too, and was about to post a patch before I noticed 
this bug, so I support this change.





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

* bug#63411: [PATCH] pcomplete/systemctl cannot complete units for old versions of systemd
  2023-05-18 18:57         ` Jim Porter
@ 2023-05-20 15:02           ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-05-20 15:02 UTC (permalink / raw)
  To: Jim Porter; +Cc: liuhui1610, 63411-done

> Date: Thu, 18 May 2023 11:57:46 -0700
> Cc: 63411@debbugs.gnu.org
> From: Jim Porter <jporterbugs@gmail.com>
> 
> On 5/18/2023 7:16 AM, Eli Zaretskii wrote:
> >> From: Liu Hui <liuhui1610@gmail.com>
> >> Date: Thu, 18 May 2023 21:29:46 +0800
> >> Cc: 63411@debbugs.gnu.org
> >>
> >> --no-legend is indeed superseded by --legend=yes/no in systemd v248+,
> >> but it is not deprecated. It is kept for compatibility and is totally
> >> equivalent to --legend=no, and doesn't produce any warning message. I
> >> have tested with systemctl v249 on Ubuntu 22.04 and the outputs are
> >> same. In fact, the point of the new option is it allows to display
> >> legends by --legend=yes in spite of other options such as --quiet,
> >> which is explained in https://github.com/systemd/systemd/pull/18596.
> > 
> > Thanks, I think I will wait for a few days to let others chime in.
> 
> I stumbled on this too, and was about to post a patch before I noticed 
> this bug, so I support this change.

Thanks, installed on the emacs-29 branch, and closing the bug.





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

end of thread, other threads:[~2023-05-20 15:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-10  9:47 bug#63411: 29.0.90; pcomplete/systemctl cannot complete units for old versions of systemd Liu Hui
2023-05-17  8:53 ` bug#63411: [PATCH] " Liu Hui
2023-05-18 10:40   ` Eli Zaretskii
2023-05-18 13:29     ` Liu Hui
2023-05-18 14:16       ` Eli Zaretskii
2023-05-18 18:57         ` Jim Porter
2023-05-20 15:02           ` Eli Zaretskii

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

	https://git.savannah.gnu.org/cgit/emacs.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).