changeset 16410:454a13718b1f

(narrow-to-defun): Narrow to the same defun that `mark-defun' would make the region. (insert-parentheses): Let a negative argument enclose preceding sexps.
author Erik Naggum <erik@naggum.no>
date Tue, 08 Oct 1996 23:13:39 +0000
parents 258a28c21b74
children 939831bf2103
files lisp/emacs-lisp/lisp.el
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/lisp.el	Tue Oct 08 23:00:54 1996 +0000
+++ b/lisp/emacs-lisp/lisp.el	Tue Oct 08 23:13:39 1996 +0000
@@ -215,18 +215,22 @@
   (interactive)
   (save-excursion
     (widen)
-    (beginning-of-defun)
-    (narrow-to-region (point) (progn (end-of-defun) (point)))))
+    (end-of-defun)
+    (let ((end (point)))
+      (beginning-of-defun)
+      (narrow-to-region (point) end))))
 
 (defun insert-parentheses (arg)
-  "Put parentheses around next ARG sexps.  Leave point after open-paren.
+  "Enclose following ARG sexps in parentheses.  Leave point after open-paren.
+A negative ARG encloses the preceding ARG sexps instead.
 No argument is equivalent to zero: just insert `()' and leave point between.
 If `parens-require-spaces' is non-nil, this command also inserts a space
 before and after, depending on the surrounding characters."
   (interactive "P")
   (if arg (setq arg (prefix-numeric-value arg))
     (setq arg 0))
-  (or (eq arg 0) (skip-chars-forward " \t"))
+  (cond ((> arg 0) (skip-chars-forward " \t"))
+	((< arg 0) (forward-sexp arg) (setq arg (- arg))))
   (and parens-require-spaces
        (not (bobp))
        (memq (char-syntax (preceding-char)) '(?w ?_ ?\) ))