I missed being able to do M-q to reindent the current defun, like in ILISP. Here's the version I'm using. The patch is against a month-old cvs snapshot, sorry.
--- slime.el.~1.258.~ Thu Apr 8 16:41:04 2004 +++ slime.el Sun May 2 17:02:35 2004 @@ -449,6 +449,7 @@ ("\M-." slime-edit-definition :inferior t :sldb t) ("\M-," slime-pop-find-definition-stack :inferior t :sldb t) ("\C-q" slime-close-parens-at-point :prefixed t :inferior t) + ("\M-q" slime-reindent-defun :inferior t) ;; Evaluating ("\C-x\C-e" slime-eval-last-expression :inferior t) ("\C-x\M-e" slime-eval-last-expression-display-output :inferior t) @@ -5523,6 +5524,29 @@ (get symbol 'slime-indent)) (put symbol 'slime-indent indent) (put symbol 'common-lisp-indent-function indent))))) + +(defun slime-reindent-defun (&optional force-text-fill) + "Reindent the current defun, or refill the current paragraph. +If point is inside a comment block, the text around point will be +treated as a paragraph and will be filled with `fill-paragraph'. +Otherwise, it will be treated as Lisp code, and the current defun +will be reindented. If the current defun has unbalanced parens, +an attempt will be made to fix it before reindenting. + +When given a prefix argument, the text around point will always +be treated as a paragraph. This is useful for filling docstrings." + (interactive "P") + (save-excursion + (if (or force-text-fill (slime-beginning-of-comment)) + (fill-paragraph nil) + (let ((start (progn (beginning-of-defun) (point))) + (end (ignore-errors (end-of-defun) (point)))) + (unless end + (forward-paragraph) + (slime-close-all-sexp) + (end-of-defun) + (setf end (point))) + (indent-region start end)))))
;;; Test suite
"Thomas F. Burdick" tfb@OCF.Berkeley.EDU writes:
I missed being able to do M-q to reindent the current defun, like in ILISP. Here's the version I'm using.
Thanks, applied.
I changed the binding to C-M-q (usually `indent-sexp') though. Otherwise you need to use different key sequences for indenting docstrings in Common Lisp buffers vs. Emacs Lisp ones.
Cheers, Luke
Luke Gorrie luke@bluetail.com writes:
"Thomas F. Burdick" tfb@OCF.Berkeley.EDU writes:
I missed being able to do M-q to reindent the current defun, like in ILISP. Here's the version I'm using.
Thanks, applied.
I changed the binding to C-M-q (usually `indent-sexp') though. Otherwise you need to use different key sequences for indenting docstrings in Common Lisp buffers vs. Emacs Lisp ones.
I just moved this again, now to `C-c M-q'. This is to save myself from the angry mob protesting that C-M-q is supposed to be indent-sexp, as bound by lisp-mode.
But I'm guessing you've already bound this command to M-q in your local config anyway :-)
Luke Gorrie writes:
Luke Gorrie luke@bluetail.com writes:
"Thomas F. Burdick" tfb@OCF.Berkeley.EDU writes:
I missed being able to do M-q to reindent the current defun, like in ILISP. Here's the version I'm using.
Thanks, applied.
I changed the binding to C-M-q (usually `indent-sexp') though. Otherwise you need to use different key sequences for indenting docstrings in Common Lisp buffers vs. Emacs Lisp ones.
I just moved this again, now to `C-c M-q'. This is to save myself from the angry mob protesting that C-M-q is supposed to be indent-sexp, as bound by lisp-mode.
But I'm guessing you've already bound this command to M-q in your local config anyway :-)
Yup, you guessed right. Now all I need to do is get around to writing some code that indents loop in a non-crazy manner (altho I'm guessing this is on a lot of people's to-do list).