comparison lisp/emacs-lisp/lisp.el @ 110931:2316b868d5be

Merge changes from emacs-23 branch.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 12 Oct 2010 01:57:49 +0200
parents 0e1478bb5f00 81696c97193b
children 417b1e4d63cd
comparison
equal deleted inserted replaced
110918:236342431786 110931:2316b868d5be
644 644
645 645
646 (defun lisp-completion-at-point (&optional predicate) 646 (defun lisp-completion-at-point (&optional predicate)
647 "Function used for `completion-at-point-functions' in `emacs-lisp-mode'." 647 "Function used for `completion-at-point-functions' in `emacs-lisp-mode'."
648 ;; FIXME: the `end' could be after point? 648 ;; FIXME: the `end' could be after point?
649 (let* ((pos (point)) 649 (with-syntax-table emacs-lisp-mode-syntax-table
650 (beg (with-syntax-table emacs-lisp-mode-syntax-table 650 (let* ((pos (point))
651 (condition-case nil 651 (beg (condition-case nil
652 (save-excursion 652 (save-excursion
653 (backward-sexp 1) 653 (backward-sexp 1)
654 (skip-syntax-forward "'") 654 (skip-syntax-forward "'")
655 (point)) 655 (point))
656 (scan-error pos)))) 656 (scan-error pos)))
657 (predicate 657 (predicate
658 (or predicate 658 (or predicate
659 (save-excursion 659 (save-excursion
660 (goto-char beg) 660 (goto-char beg)
661 (if (not (eq (char-before) ?\()) 661 (if (not (eq (char-before) ?\())
662 (lambda (sym) ;why not just nil ? -sm 662 (lambda (sym) ;why not just nil ? -sm
663 (or (boundp sym) (fboundp sym) 663 (or (boundp sym) (fboundp sym)
664 (symbol-plist sym))) 664 (symbol-plist sym)))
665 ;; Looks like a funcall position. Let's double check. 665 ;; Looks like a funcall position. Let's double check.
666 (if (condition-case nil 666 (if (condition-case nil
667 (progn (up-list -2) (forward-char 1) 667 (progn (up-list -2) (forward-char 1)
668 (eq (char-after) ?\()) 668 (eq (char-after) ?\())
669 (error nil)) 669 (error nil))
670 ;; If the first element of the parent list is an open 670 ;; If the first element of the parent list is an open
671 ;; parenthesis we are probably not in a funcall position. 671 ;; paren we are probably not in a funcall position.
672 ;; Maybe a `let' varlist or something. 672 ;; Maybe a `let' varlist or something.
673 nil 673 nil
674 ;; Else, we assume that a function name is expected. 674 ;; Else, we assume that a function name is expected.
675 'fboundp))))) 675 'fboundp)))))
676 (end 676 (end
677 (unless (or (eq beg (point-max)) 677 (unless (or (eq beg (point-max))
678 (member (char-syntax (char-after beg)) '(?\" ?\( ?\)))) 678 (member (char-syntax (char-after beg)) '(?\" ?\( ?\))))
679 (condition-case nil 679 (condition-case nil
680 (save-excursion 680 (save-excursion
681 (goto-char beg) 681 (goto-char beg)
682 (forward-sexp 1) 682 (forward-sexp 1)
683 (when (>= (point) pos) 683 (when (>= (point) pos)
684 (point))) 684 (point)))
685 (scan-error pos))))) 685 (scan-error pos)))))
686 (when end 686 (when end
687 (list beg end obarray 687 (list beg end obarray
688 :predicate predicate 688 :predicate predicate
689 :annotate-function 689 :annotate-function
690 (unless (eq predicate 'fboundp) 690 (unless (eq predicate 'fboundp)
691 (lambda (str) (if (fboundp (intern-soft str)) " <f>"))))))) 691 (lambda (str) (if (fboundp (intern-soft str)) " <f>"))))))))
692 692
693 ;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e 693 ;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e
694 ;;; lisp.el ends here 694 ;;; lisp.el ends here