diff options
Diffstat (limited to 'lisp/emacs-lisp/lisp.el')
-rw-r--r-- | lisp/emacs-lisp/lisp.el | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index 4aeca9c6b00..4b85414943a 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -171,6 +171,8 @@ This command assumes point is not in a string or comment. If INTERACTIVE is non-nil, as it is interactively, report errors as appropriate for this kind of usage." (interactive "^p\nd") + (when (ppss-comment-or-string-start (syntax-ppss)) + (user-error "This command doesn't work in strings or comments")) (if interactive (condition-case _ (down-list arg nil) @@ -855,14 +857,33 @@ The option `delete-pair-blink-delay' can disable blinking." (delete-char -1))) (delete-char 1)))) -(defun raise-sexp (&optional arg) - "Raise ARG sexps higher up the tree." +(defun raise-sexp (&optional n) + "Raise N sexps one level higher up the tree. + +This function removes the sexp enclosing the form which follows +point, and then re-inserts N sexps that originally followe point, +thus raising those N sexps one level up. + +Interactively, N is the numeric prefix argument, and defaults to 1. + +For instance, if you have: + + (let ((foo 2)) + (progn + (setq foo 3) + (zot) + (+ foo 2))) + +and point is before (zot), \\[raise-sexp] will give you + + (let ((foo 2)) + (zot))" (interactive "p") (let ((s (if (and transient-mark-mode mark-active) (buffer-substring (region-beginning) (region-end)) (buffer-substring (point) - (save-excursion (forward-sexp arg) (point)))))) + (save-excursion (forward-sexp n) (point)))))) (backward-up-list 1) (delete-region (point) (save-excursion (forward-sexp 1) (point))) (save-excursion (insert s)))) @@ -922,14 +943,7 @@ character." (defun field-complete (table &optional predicate) (declare (obsolete completion-in-region "24.4")) (let ((minibuffer-completion-table table) - (minibuffer-completion-predicate predicate) - ;; This made sense for lisp-complete-symbol, but for - ;; field-complete, this is out of place. --Stef - ;; (completion-annotate-function - ;; (unless (eq predicate 'fboundp) - ;; (lambda (str) - ;; (if (fboundp (intern-soft str)) " <f>")))) - ) + (minibuffer-completion-predicate predicate)) (call-interactively 'minibuffer-complete))) (defun lisp-complete-symbol (&optional _predicate) |