Skip to content

Fix paredit breakage #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@
"\\>")
1 font-lock-type-face)
;; Constant values (keywords), including as metadata e.g. ^:static
("\\<^?:\\(\\sw\\)+\\>" 0 font-lock-constant-face)
("\\<^?:\\(\\sw\\|\\s_\\)+\\(\\>\\|\\_>\\)" 0 font-lock-constant-face)
;; Meta type annotation #^Type or ^Type
("#?^\\sw+" 0 font-lock-preprocessor-face)
("#?^\\(\\sw\\|\\s_\\)+" 0 font-lock-preprocessor-face)
("\\<io\\!\\>" 0 font-lock-warning-face)

;;Java interop highlighting
Expand Down Expand Up @@ -367,7 +367,7 @@ Clojure to load that file."
(modify-syntax-entry ?\] ")[" table)
(modify-syntax-entry ?^ "'" table)
;; Make hash a usual word character
(modify-syntax-entry ?# "w" table)
(modify-syntax-entry ?# "_ p" table)
table))

(defvar clojure-mode-abbrev-table nil
Expand Down Expand Up @@ -401,6 +401,22 @@ numbers count from the end:
(defalias 'clojure-parent-mode
(if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))

(defun clojure-space-for-delimiter-p (endp delim)
(if (eq major-mode 'clojure-mode)
(save-excursion
(backward-char)
(if (and (or (char-equal delim ?\()
(char-equal delim ?\")
(char-equal delim ?{))
(not endp))
(if (char-equal (char-after) ?#)
(and (not (bobp))
(or (char-equal ?w (char-syntax (char-before)))
(char-equal ?_ (char-syntax (char-before)))))
t)
t))
t))

;;;###autoload
(define-derived-mode clojure-mode clojure-parent-mode "Clojure"
"Major mode for editing Clojure code - similar to Lisp mode.
Expand Down Expand Up @@ -435,7 +451,9 @@ if that value is non-nil."
(lambda ()
(when (>= paredit-version 21)
(define-key clojure-mode-map "{" 'paredit-open-curly)
(define-key clojure-mode-map "}" 'paredit-close-curly)))))
(define-key clojure-mode-map "}" 'paredit-close-curly)
(add-to-list 'paredit-space-for-delimiter-predicates
'clojure-space-for-delimiter-p)))))

(defun clojure-display-inferior-lisp-buffer ()
"Display a buffer bound to `inferior-lisp-buffer'."
Expand Down