emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New Package: sticky-shell


From: Stefan Monnier
Subject: Re: New Package: sticky-shell
Date: Tue, 13 Dec 2022 09:22:16 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

>> Any chance we could simply add it to `shell.el`?
> I wouldn't mind adding it to `shell.el`. Let me know what the process would
> be in that case.

Step 1 (same as for GNU ELPA): get the copyright paperwork in order.
       I don't see your name in the FSF's copyright assigners list, so
       either it's still in process or you haven't started yet.
       Let me know if you need help with that.

Step 2: Turn your file into a patch to `shell.el`.
      [ Feel free to also make changes in `shell.el` and/or `eshell.el` to
        make the result cleaner.  ]

> @@ -129,23 +134,25 @@ macro-expands to:
>   (upcase
>    (funcall sticky-shell-get-prompt))
>   \\='face \\='minibuffer-prompt)"
> +  ;; The case distinction appears unnecessary (thread-first (foo)) is
> +  ;; the same as (foo).
>    (if sticky-shell-prompt-modifiers
>        `(thread-first
>           (funcall sticky-shell-get-prompt)
>           ,@sticky-shell-prompt-modifiers)
> +    ;; Perhaps it would be better/cleaner if
> +    ;; `sticky-shell-prompt-modifiers' were a list of function that
> +    ;; all get applied on the result of (funcall
> +    ;; sticky-shell-get-prompt) in order?
>      (funcall sticky-shell-get-prompt)))
> Not sure what you mean by the first comment.
> Regarding the second comment: this is essentially what thread-first does,
> with the added advantage that `sticky-shell-prompt-modifiers' can consist
> not only of functions, but also of forms with multiple arguments, and whose
> first argument will be the result of (funcall sticky-shell-get-prompt) at
> runtime. For example, if users wanted to `propertize' the header with
> particular properties, they wouldn't be able to do it if
> `sticky-shell-prompt-modifiers' was simply a list of functions operating on
> a single argument, because `propertize' requires multiple arguments. The
> solution would have to be to create a new function:
> (defun propertize-my-way (string)
>          (propertize string 'face 'minibuffer))
> And add propertize-my-way to the list of prompt modifiers.
> Using thread-first saves users time by allowing them to simply add
> '(propertize 'face 'minibuffer) to `sticky-shell-prompt-modifiers'.

I can see the upside, yes, but the downside is that the format of
`sticky-shell-prompt-modifiers` is "new" in the sense that it's
different from existing customization variables used for similar
purposes (which are either `<foo>-function` (modified with
`add-function`) or `<foo>-functions` (modified with `add-hook`)).

Another downside of that code is that `sticky-shell-modified-prompt` is
a macro that's expanded every time we refresh the header line, which can
be very frequent in some cases, thus generating excess garbage.

[ Oh, BTW, I suspect your code needs a (require 'subr-x) to be sure
  `thread-first` is actually available.  ]


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]