[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Replace trivial pcase occurrences in the Emacs sources
From: |
Michael Heerdegen |
Subject: |
Re: Replace trivial pcase occurrences in the Emacs sources |
Date: |
Wed, 24 Oct 2018 17:30:26 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Eli Zaretskii <address@hidden> writes:
> FWIW, my main problem is not even with cl-case, it's with 'cond'. It
> seems like we have some 'pcase' epidemic, whose first symptom is that
> people stop using 'cond' and start using 'pcase' instead. A few
> examples:
>
> todo-mode.el:
>
> (pcase this-param
> ('edit (todo-edit-item--text))
> ('header (todo-edit-item--text 'include-header))
> ('multiline (todo-edit-item--text 'multiline))
> ('add/edit (todo-edit-item--text 'comment-edit))
> ('delete (todo-edit-item--text 'comment-delete))
> ('diary (todo-edit-item--diary-inclusion))
> ('nonmarking (todo-edit-item--diary-inclusion 'nonmarking))
> [...]
>
> auth-source-pass.el:
>
> (pcase (length matching-entries)
> (0 (auth-source-pass--do-debug "no match found")
> nil)
> (1 (auth-source-pass--do-debug "found 1 match: %s" (car
> matching-entries))
> (car matching-entries))
> (_ (auth-source-pass--select-one-entry matching-entries user)))))
>
> bs.el:
>
> (setq bs-buffer-show-mark (pcase bs-buffer-show-mark
> (`nil 'never)
> (`never 'always)
> (_ nil))))))
>
> calculator.el:
>
> (<= inp (pcase calculator-input-radix
> (`nil ?9) (`bin ?1) (`oct ?7) (_ 999))))
>
> lpr.el:
>
> (pcase (count-lines (point-min) (point-max))
> (0 "")
> (1 ": ")
> (_ ":\n"))
FWIW, these are the major cases I wanted to treat, but I wanted to
replace them with equivalent cl-case forms, not with `cond's.
> (Quick: what's the difference between `require and 'require in this
> case?)
There is none any more.
> easy-mmode.el:
>
> (pcase keyw
> (`:group (setq group (nconc group (list :group (pop keys)))))
> (`:global (setq keys (cdr keys)))
> (_ (push keyw extra-keywords) (push (pop keys) extra-keywords))))
>
> (Aren't keywords supposed to be self-quoting? then why they are
> explicitly quoted?)
Yes.
> We have dozens of such fragments in our codebase, which just makes the
> sources harder to read, especially for people who aren't fluent with
> 'pcase' (which seems to be the case with many of us).
These are all cases I would want to fix, but unless the whole pcase form
can be trivially rewritten as cl-case, I want to leave pcase, really.
Michael.
- Re: Replace trivial pcase occurrences in the Emacs sources, (continued)
Re: Replace trivial pcase occurrences in the Emacs sources (was: The poor state of documentation of pcase like things.), Eli Zaretskii, 2018/10/23
- Re: Replace trivial pcase occurrences in the Emacs sources, Stefan Monnier, 2018/10/23
- Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/23
- Re: Replace trivial pcase occurrences in the Emacs sources, Stefan Monnier, 2018/10/23
- pcase vs. case (where it could also be used) [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Garreau\, Alexandre, 2018/10/23
- Re: pcase vs. case (where it could also be used) [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Stefan Monnier, 2018/10/23
- Re: pcase vs. case (where it could also be used) [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Garreau\, Alexandre, 2018/10/23
Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/24
Re: Replace trivial pcase occurrences in the Emacs sources,
Michael Heerdegen <=
Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/24
Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/24
Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/24
Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/24
Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/24
Re: Replace trivial pcase occurrences in the Emacs sources, Garreau\, Alexandre, 2018/10/24
Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/27
Re: Replace trivial pcase occurrences in the Emacs sources, Garreau\, Alexandre, 2018/10/27
Re: Replace trivial pcase occurrences in the Emacs sources, Dmitry Gutov, 2018/10/27
Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/27