BtTempleton

I use Emacs.

Alternative list-closing function for ParEdit:

  (defun bpt-paredit-newline-preserving-comment ()
    (let ((comment.point (paredit-find-comment-on-line)))
      (newline)
      (if comment.point
          (save-excursion
            (forward-line -1)
            (end-of-line)
            (indent-to (cdr comment.point))
            (insert (car comment.point))))))
  
  (defun bpt-paredit-first-sexp-on-line-p ()
    (save-excursion
      (forward-sexp -1)
      (let ((beginning-of-sexp (point)))
        (forward-line 0)
        (skip-syntax-forward "-")
        (= beginning-of-sexp (point)))))
  
  (defun bpt-paredit-multi-line-sexp-p ()
    (let ((old-point (point)))
      (save-excursion
        (forward-sexp -1)
        (/= (line-number-at-pos old-point)
            (line-number-at-pos (point))))))
  
  (defun bpt-paredit-close-list-dwim ()
    (interactive)
    (cond ((or (paredit-in-string-p)
               (paredit-in-comment-p))
           (insert ")"))
          ((not (paredit-in-char-p))
           (paredit-move-past-close-and-reindent)
           (cond ((or (paredit-first-sexp-on-line-p)
                      (paredit-multi-line-sexp-p))
                  (paredit-newline-preserving-comment)
                  (lisp-indent-line)
                  (condition-case () (indent-sexp)
                    (scan-error nil))
                  (paredit-blink-paren-match t))
                 (t (paredit-blink-paren-match nil))))))
  
  (define-key paredit-mode-map ")" 'bpt-paredit-close-list-dwim)  

CategoryHomepage