Search code examples
javascriptemacsparedit

Disable paredit insert space between token and parens


I like using paredit for my javascript. I know, it's weird, but its helpful to me. The one thing that really bugs me is when I type foo() it automatically inserts a space to foo ().

Is there an option to disable this behavior?


Solution

  • This seems done by function paredit-insert-pair. Commenting out the line in question as shown at last line below does it here. Writing an own customization in line above might correct value of spacep and keep the space for other modes.

    Also tweaking function paredit-space-for-delimiter-p is an option.

    (defun paredit-insert-pair (n open close forward)
      (let* ((regionp
              (and (paredit-region-active-p)
                   (paredit-region-safe-for-insert-p)))
             (end
              (and regionp
                   (not n)
                   (prog1 (region-end) (goto-char (region-beginning))))))
        (let ((spacep (paredit-space-for-delimiter-p nil open)))
          ;; (if spacep (insert " "))