From: Manuel Uberti <manuel.uberti@inventati.org>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Recent pcase changes
Date: Thu, 4 Mar 2021 11:06:08 +0100 [thread overview]
Message-ID: <7c26cf68-90d6-a36c-59d9-0d737d1ff143@inventati.org> (raw)
Hello,
yesterday I reported a bug on the clojure-mode bug tracker[1] because with a
recent Emacs built from master[2] marking the whole buffer and calling
`indent-region' results in an error.
By looking at clojure-mode code I see it sets `lisp-indent-function' to
`clojure-indent-function', which makes use of `pcase'. More specifically, this
is what it does at line 1497 of clojure-mode.el:
(pcase method
((or (pred integerp) `(,method))
(let ((pos -1))
(condition-case nil
(while (and (<= (point) indent-point)
(not (eobp)))
(clojure-forward-logical-sexp 1)
(cl-incf pos))
;; If indent-point is _after_ the last sexp in the
;; current sexp, we detect that by catching the
;; `scan-error'. In that case, we should return the
;; indentation as if there were an extra sexp at point.
(scan-error (cl-incf pos)))
(cond
;; The first non-special arg. Rigidly reduce indentation.
((= pos (1+ method))
(+ lisp-body-indent containing-form-column))
;; Further non-special args, align with the arg above.
((> pos (1+ method))
(clojure--normal-indent last-sexp 'always-align))
;; Special arg. Rigidly indent with a large indentation.
(t
(+ (* clojure-special-arg-indent-factor lisp-body-indent)
containing-form-column)))))
(`:defn
(+ lisp-body-indent containing-form-column))
((pred functionp)
(funcall method indent-point state))
;; No indent spec, do the default.
(`nil
(let ((function (thing-at-point 'symbol)))
(cond
;; Preserve useful alignment of :require (and friends) in `ns' forms.
((and function (string-match "^:" function))
(clojure--normal-indent last-sexp 'always-align))
;; This should be identical to the :defn above.
((and function
(string-match "\\`\\(?:\\S +/\\)?\\(def[a-z]*\\|with-\\)"
function)
(not (string-match "\\`default" (match-string 1 function))))
(+ lisp-body-indent containing-form-column))
;; Finally, nothing special here, just respect the user's
;; preference.
(t (clojure--normal-indent last-sexp clojure-indent-style))))))
Is there something wrong with this usage of `pcase'? If so, how can it be
adapted to the latest changes on master to work again?
Note that to have clojure-mode working again for now I have reset my Emacs build
to a previous commit[3].
Note also that this is me wild guessing that the problem is related to the
recent `pcase' changes. It could very well be that the problem is elsewhere, and
if so, I'll try debugging more.
All the best
[1] https://github.com/clojure-emacs/clojure-mode/issues/584
[2] Commit: ba33089d50a4f74b88cd7fc9d862d183d096c27d Fix a doc/misc clean rule
[3] Commit: 6bf56a3614ccd23a31e34ae997b2a6bb0d158489 Fix documentation of a
recent change
--
Manuel Uberti
www.manueluberti.eu
next reply other threads:[~2021-03-04 10:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-04 10:06 Manuel Uberti [this message]
2021-03-04 11:30 ` Recent pcase changes Mattias Engdegård
2021-03-04 11:40 ` Omar Polo
2021-03-04 11:44 ` Manuel Uberti
2021-03-04 14:39 ` Stefan Monnier
2021-03-04 14:41 ` Manuel Uberti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7c26cf68-90d6-a36c-59d9-0d737d1ff143@inventati.org \
--to=manuel.uberti@inventati.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.