Skip to content

paredit-mode inserts extra space in clojure-mode #565

Closed
@dgr

Description

@dgr

I'm not sure whether the following is a clojure-mode or paredit-mode bug. Recent updates seem to have introduced this, however, and it doesn't happen when using paredit-mode in other modes (e.g., emacs-lisp-mode).

Expected behavior

If I want to quote a list, I would typically type '( and paredit-mode would insert the closing parenthesis and it would show '() in the buffer.

Actual behavior

In clojure-mode, when I type the opening parenthesis, paredit-mode inserts an extra space between the tick and the opening parenthesis, leaving '<space>() rather than '() in the buffer (where <space> represents the extra space). This does NOT happen when using paredit-mode with emacs-lisp-mode, lisp-mode, or scheme-mode. This suggests that the root cause of the bug is located in clojure-mode.

Steps to reproduce the problem

The following init.el shows a minimal configuration. With this init.el, start emacs and then in the *scratch* buffer, type '( in emacs-lisp mode. Notice that no extra space is entered between the tick and the opening parenthesis.

Next, switch to clojure-mode (e.g., just use M-x clojure-mode in the *scratch* buffer). Type '( again and notice the extra space.

Sample init.el:

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/")
             t)
(package-initialize)

;;; Bootstrap use-package if it isn't already installed
(unless (package-installed-p 'use-package)
  (unless package-archive-contents
    (package-refresh-contents))
  (package-install 'use-package))

(require 'use-package)

(use-package paredit
  :ensure t
  :hook ((emacs-lisp-mode clojure-mode cider-repl-mode lisp-mode scheme-mode) . paredit-mode))

(use-package clojure-mode
  :ensure t
  :mode (("\\.clj\\'" . clojure-mode)
         ("\\.cljs\\'" . clojurescript-mode)
         ("\\.cljc\\'" . clojurec-mode)
         ("\\.cljx\\'" . clojurex-mode)))

Environment & Version information

clojure-mode version

clojure-mode (version 5.2.0-snapshot)

Emacs version

GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Version 10.14.3 (Build 18D109))
 of 2019-09-02

installed via brew cask install emacs.

Operating system

MacOS 10.15.4 (Catalina)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions