(lisp-complete-symbol):
Distinguish the let-binding case from the funcall case. (forward-sexp-function): New variable. (forward-sexp): Use it.
This commit is contained in:
parent
5d78d57daf
commit
11ae6c5d0d
1 changed files with 31 additions and 12 deletions
|
@ -44,14 +44,20 @@ See function `beginning-of-defun'."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'lisp)
|
:group 'lisp)
|
||||||
|
|
||||||
|
(defvar forward-sexp-function nil
|
||||||
|
"If non-nil, `forward-sexp' delegates to this function.
|
||||||
|
Should take the same arguments and behave similarly to `forward-sexp'.")
|
||||||
|
|
||||||
(defun forward-sexp (&optional arg)
|
(defun forward-sexp (&optional arg)
|
||||||
"Move forward across one balanced expression (sexp).
|
"Move forward across one balanced expression (sexp).
|
||||||
With ARG, do it that many times. Negative arg -N means
|
With ARG, do it that many times. Negative arg -N means
|
||||||
move backward across N balanced expressions."
|
move backward across N balanced expressions."
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(or arg (setq arg 1))
|
(or arg (setq arg 1))
|
||||||
(goto-char (or (scan-sexps (point) arg) (buffer-end arg)))
|
(if forward-sexp-function
|
||||||
(if (< arg 0) (backward-prefix-chars)))
|
(funcall forward-sexp-function arg)
|
||||||
|
(goto-char (or (scan-sexps (point) arg) (buffer-end arg)))
|
||||||
|
(if (< arg 0) (backward-prefix-chars))))
|
||||||
|
|
||||||
(defun backward-sexp (&optional arg)
|
(defun backward-sexp (&optional arg)
|
||||||
"Move backward across one balanced expression (sexp).
|
"Move backward across one balanced expression (sexp).
|
||||||
|
@ -354,19 +360,32 @@ considered."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((end (point))
|
(let* ((end (point))
|
||||||
(beg (with-syntax-table emacs-lisp-mode-syntax-table
|
(beg (with-syntax-table emacs-lisp-mode-syntax-table
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(backward-sexp 1)
|
(backward-sexp 1)
|
||||||
(while (= (char-syntax (following-char)) ?\')
|
(while (= (char-syntax (following-char)) ?\')
|
||||||
(forward-char 1))
|
(forward-char 1))
|
||||||
(point))))
|
(point))))
|
||||||
(pattern (buffer-substring-no-properties beg end))
|
(pattern (buffer-substring-no-properties beg end))
|
||||||
(predicate
|
(predicate
|
||||||
(or predicate
|
(or predicate
|
||||||
(if (eq (char-after (1- beg)) ?\()
|
(save-excursion
|
||||||
'fboundp
|
(goto-char beg)
|
||||||
(function (lambda (sym)
|
(if (not (eq (char-before) ?\())
|
||||||
(or (boundp sym) (fboundp sym)
|
(lambda (sym) ;why not just nil ? -sm
|
||||||
(symbol-plist sym)))))))
|
(or (boundp sym) (fboundp sym)
|
||||||
|
(symbol-plist sym)))
|
||||||
|
;; Looks like a funcall position. Let's double check.
|
||||||
|
(backward-char 1) ;skip paren
|
||||||
|
(if (condition-case nil
|
||||||
|
(progn (up-list -2) (forward-char 1)
|
||||||
|
(eq (char-after) ?\())
|
||||||
|
(error nil))
|
||||||
|
;; If the first element of the parent list is an open
|
||||||
|
;; parenthesis we are probably not in a funcall position.
|
||||||
|
;; Maybe a `let' varlist or something.
|
||||||
|
nil
|
||||||
|
;; Else, we assume that a function name is expected.
|
||||||
|
'fboundp)))))
|
||||||
(completion (try-completion pattern obarray predicate)))
|
(completion (try-completion pattern obarray predicate)))
|
||||||
(cond ((eq completion t))
|
(cond ((eq completion t))
|
||||||
((null completion)
|
((null completion)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue