unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Recent pcase changes
@ 2021-03-04 10:06 Manuel Uberti
  2021-03-04 11:30 ` Mattias Engdegård
  0 siblings, 1 reply; 6+ messages in thread
From: Manuel Uberti @ 2021-03-04 10:06 UTC (permalink / raw)
  To: emacs-devel

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



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

end of thread, other threads:[~2021-03-04 14:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04 10:06 Recent pcase changes Manuel Uberti
2021-03-04 11:30 ` 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

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).