From: Leo Liu Date: Thu, 16 May 2013 03:41:52 +0000 (+0800) Subject: * simple.el (prog-indent-sexp): Indent enclosing defun. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~229^2~69 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9df4ec5e9044e92e792ba9e8cb714603e32c5cc5;p=emacs.git * simple.el (prog-indent-sexp): Indent enclosing defun. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c579642642e..0b233385eb7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2013-05-16 Leo Liu + + * simple.el (prog-indent-sexp): Indent enclosing defun. + 2013-05-15 Glenn Morris * cus-start.el (show-trailing-whitespace): Move to editing basics. diff --git a/lisp/simple.el b/lisp/simple.el index e4bde7c358c..f81b02b0acf 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -380,12 +380,18 @@ Other major modes are defined by comparison with this one." map) "Keymap used for programming modes.") -(defun prog-indent-sexp () - "Indent the expression after point." - (interactive) - (let ((start (point)) - (end (save-excursion (forward-sexp 1) (point)))) - (indent-region start end nil))) +(defun prog-indent-sexp (&optional defun) + "Indent the expression after point. +When interactively called with prefix, indent the enclosing defun +instead." + (interactive "P") + (save-excursion + (when defun + (end-of-line) + (beginning-of-defun)) + (let ((start (point)) + (end (progn (forward-sexp 1) (point)))) + (indent-region start end nil)))) (define-derived-mode prog-mode fundamental-mode "Prog" "Major mode for editing programming language source code."