Skip to content

No comment syntax is defined #2903

Closed
@jimka2001

Description

@jimka2001

This issue reports a problem which was discussed in the clojurians forum.
I often get the following confusing message when debugging clojure macros in cider.

screenshot_2020-09-29_at_15 45 55

The basic problem is that when I'm debugging a clojure macro, the code within defmacro might very well throw an exception. Sometimes emacs ends up in a state where it is asking me for a comment character. I doubt this is information the user should be being asked.

To reproduce this, I've prepared a more-than-minimum working example.
You can download the repo,

git clone https://gitlab.lrde.epita.fr/jnewton/clojure-rte.git
cd clojure-rte
git checkout c2b73731462393540a254c7ed7f1b1cf01a72a1b

You'll find a project.clj file in the top level directory.

Start up cider.
In the REPL paste the following but don't press ENTER>

(destructuring-case
   args
   [[] {}]
   (throw (IllegalArgumentException. 
           "destructuring-fn, empty argument list not supported"))

   [[name & others] {name (not (or (satisfies symbol?)
                                   (= nil))) }]
   `(destructuring-fn nil ~@args)

   [[name] {}]
   (throw (IllegalArgumentException. 
           "destructuring-fn, invalid function body or clauses clauses"))

   [[name lambda-list & others] {lambda-list (satisfies vector?)}]
   `(destructuring-fn-many
     ~@(if name (list name) nil) ;; either name or nothing
     (~lambda-list
      ~@others))
   
   [[name & clauses] {clauses (and (satisfies list?)
                                   (not (= ()))
                                   (rte (:* (:cat (satisfies vector?) (:* :sigma)))))}]
   `(destructuring-fn-many
     ~@(if name (list name) nil) ;; either name or nothing
     ~@clauses)

   [[& others] {}]
   (throw (IllegalArgumentException. 
           (cl-format false
                      "destructuring-fn, invalid argument list: ~A"
                      args))))

With the cursor at the end of the expression, press C-c C-m, to open a new buffer cider-macroexpansion containing the following: (let [...] (rte-case ...))

(let [v15697 args]
  (rte-case
    v15697
    (:cat)
    (let [[] v15697]
      (throw
        (IllegalArgumentException.
          "destructuring-fn, empty argument list not supported")))
    (:cat (not (or (satisfies symbol?) (= nil))) (:* :sigma))
    (let [[name & others] v15697]
      (seq (concat (list 'destructuring-fn) (list 'nil) args)))
    (:cat :sigma)
    (let [[name] v15697]
      (throw
        (IllegalArgumentException.
          "destructuring-fn, invalid function body or clauses clauses")))
    (:cat :sigma (satisfies vector?) (:* :sigma))
    (let [[name lambda-list & others] v15697]
      (seq
        (concat
          (list 'destructuring-fn-many)
          (if name (list name) nil)
          (list (seq (concat (list lambda-list) others))))))
    (:cat
      :sigma
      (:*
        (and
          (satisfies list?)
          (not (= ()))
          (rte (:* (:cat (satisfies vector?) (:* :sigma)))))))
    (let [[name & clauses] v15697]
      (seq
        (concat
          (list 'destructuring-fn-many)
          (if name (list name) nil)
          clauses)))
    (:cat (:* :sigma))
    (let [[& others] v15697]
      (throw
        (IllegalArgumentException.
          (cl-format
            false
            "destructuring-fn, invalid argument list: ~A"
            args))))
    (:* :sigma)
    nil))

Navigate the cursor to the close paren of (rte-case ...), i.e. between the final and penultimate parens as shown here:
Screenshot 2020-10-01 at 09 49 31

Now press m

You should now find yourself in the state where emacs is asking for a comment character
Screenshot 2020-10-01 at 09 51 17

Environment & Version information

CIDER version information

;; CIDER 0.26.1 (Nesebar), nREPL 0.8.0
;; Clojure 1.10.0, Java 11.0.7

Emacs version

Screenshot 2020-10-01 at 09 53 41

Operating system

Screenshot 2020-10-01 at 09 55 36

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issueA simple tasks suitable for first-time contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions