diff options
| author | Stefan Monnier | 2000-09-29 03:30:04 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-09-29 03:30:04 +0000 |
| commit | 11ae6c5d0d40c79483079d3cdfa1e7e85786ff20 (patch) | |
| tree | 16a7990c86d2fd761ac4d93ba09b3e070cdec40c | |
| parent | 5d78d57daf53f6556fd9c5ff9179efe9878cdaff (diff) | |
| download | emacs-11ae6c5d0d40c79483079d3cdfa1e7e85786ff20.tar.gz emacs-11ae6c5d0d40c79483079d3cdfa1e7e85786ff20.zip | |
(lisp-complete-symbol):
Distinguish the let-binding case from the funcall case.
(forward-sexp-function): New variable.
(forward-sexp): Use it.
| -rw-r--r-- | lisp/emacs-lisp/lisp.el | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index 90e02ee2bae..52912146be9 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el | |||
| @@ -44,14 +44,20 @@ See function `beginning-of-defun'." | |||
| 44 | :type 'boolean | 44 | :type 'boolean |
| 45 | :group 'lisp) | 45 | :group 'lisp) |
| 46 | 46 | ||
| 47 | (defvar forward-sexp-function nil | ||
| 48 | "If non-nil, `forward-sexp' delegates to this function. | ||
| 49 | Should take the same arguments and behave similarly to `forward-sexp'.") | ||
| 50 | |||
| 47 | (defun forward-sexp (&optional arg) | 51 | (defun forward-sexp (&optional arg) |
| 48 | "Move forward across one balanced expression (sexp). | 52 | "Move forward across one balanced expression (sexp). |
| 49 | With ARG, do it that many times. Negative arg -N means | 53 | With ARG, do it that many times. Negative arg -N means |
| 50 | move backward across N balanced expressions." | 54 | move backward across N balanced expressions." |
| 51 | (interactive "p") | 55 | (interactive "p") |
| 52 | (or arg (setq arg 1)) | 56 | (or arg (setq arg 1)) |
| 53 | (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) | 57 | (if forward-sexp-function |
| 54 | (if (< arg 0) (backward-prefix-chars))) | 58 | (funcall forward-sexp-function arg) |
| 59 | (goto-char (or (scan-sexps (point) arg) (buffer-end arg))) | ||
| 60 | (if (< arg 0) (backward-prefix-chars)))) | ||
| 55 | 61 | ||
| 56 | (defun backward-sexp (&optional arg) | 62 | (defun backward-sexp (&optional arg) |
| 57 | "Move backward across one balanced expression (sexp). | 63 | "Move backward across one balanced expression (sexp). |
| @@ -354,19 +360,32 @@ considered." | |||
| 354 | (interactive) | 360 | (interactive) |
| 355 | (let* ((end (point)) | 361 | (let* ((end (point)) |
| 356 | (beg (with-syntax-table emacs-lisp-mode-syntax-table | 362 | (beg (with-syntax-table emacs-lisp-mode-syntax-table |
| 357 | (save-excursion | 363 | (save-excursion |
| 358 | (backward-sexp 1) | 364 | (backward-sexp 1) |
| 359 | (while (= (char-syntax (following-char)) ?\') | 365 | (while (= (char-syntax (following-char)) ?\') |
| 360 | (forward-char 1)) | 366 | (forward-char 1)) |
| 361 | (point)))) | 367 | (point)))) |
| 362 | (pattern (buffer-substring-no-properties beg end)) | 368 | (pattern (buffer-substring-no-properties beg end)) |
| 363 | (predicate | 369 | (predicate |
| 364 | (or predicate | 370 | (or predicate |
| 365 | (if (eq (char-after (1- beg)) ?\() | 371 | (save-excursion |
| 366 | 'fboundp | 372 | (goto-char beg) |
| 367 | (function (lambda (sym) | 373 | (if (not (eq (char-before) ?\()) |
| 368 | (or (boundp sym) (fboundp sym) | 374 | (lambda (sym) ;why not just nil ? -sm |
| 369 | (symbol-plist sym))))))) | 375 | (or (boundp sym) (fboundp sym) |
| 376 | (symbol-plist sym))) | ||
| 377 | ;; Looks like a funcall position. Let's double check. | ||
| 378 | (backward-char 1) ;skip paren | ||
| 379 | (if (condition-case nil | ||
| 380 | (progn (up-list -2) (forward-char 1) | ||
| 381 | (eq (char-after) ?\()) | ||
| 382 | (error nil)) | ||
| 383 | ;; If the first element of the parent list is an open | ||
| 384 | ;; parenthesis we are probably not in a funcall position. | ||
| 385 | ;; Maybe a `let' varlist or something. | ||
| 386 | nil | ||
| 387 | ;; Else, we assume that a function name is expected. | ||
| 388 | 'fboundp))))) | ||
| 370 | (completion (try-completion pattern obarray predicate))) | 389 | (completion (try-completion pattern obarray predicate))) |
| 371 | (cond ((eq completion t)) | 390 | (cond ((eq completion t)) |
| 372 | ((null completion) | 391 | ((null completion) |