aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-08-30 21:45:36 +0000
committerStefan Monnier2009-08-30 21:45:36 +0000
commita1bf889a1493c8f0ca04f6d9527c2ebb582c8827 (patch)
tree08eeeaef253656dc2789276b3867cf6d6c073dcf
parent060c08b5747ab9e4423529ccc011207e83cc2e19 (diff)
downloademacs-a1bf889a1493c8f0ca04f6d9527c2ebb582c8827.tar.gz
emacs-a1bf889a1493c8f0ca04f6d9527c2ebb582c8827.zip
(lisp-complete-symbol): Use minibuffer-complete.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/emacs-lisp/lisp.el115
2 files changed, 40 insertions, 79 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 404f228f9b2..6d658befd51 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12009-08-30 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/lisp.el (lisp-complete-symbol): Use minibuffer-complete.
4
12009-08-30 Juanma Barranquero <lekktu@gmail.com> 52009-08-30 Juanma Barranquero <lekktu@gmail.com>
2 6
3 * subr.el (do-after-load-evaluation): Fix last change: use `mapc' 7 * subr.el (do-after-load-evaluation): Fix last change: use `mapc'
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 107770a3b00..9b48c497eba 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -622,85 +622,42 @@ symbols with function definitions are considered. Otherwise, all
622symbols with function definitions, values or properties are 622symbols with function definitions, values or properties are
623considered." 623considered."
624 (interactive) 624 (interactive)
625 (let ((window (get-buffer-window "*Completions*" 0))) 625 (let* ((end (point))
626 (if (and (eq last-command this-command) 626 (beg (with-syntax-table emacs-lisp-mode-syntax-table
627 window (window-live-p window) (window-buffer window) 627 (save-excursion
628 (buffer-name (window-buffer window))) 628 (backward-sexp 1)
629 ;; If this command was repeated, and 629 (while (= (char-syntax (following-char)) ?\')
630 ;; there's a fresh completion window with a live buffer, 630 (forward-char 1))
631 ;; and this command is repeated, scroll that window. 631 (point))))
632 (with-current-buffer (window-buffer window) 632 (predicate
633 (if (pos-visible-in-window-p (point-max) window) 633 (or predicate
634 (set-window-start window (point-min)) 634 (save-excursion
635 (save-selected-window 635 (goto-char beg)
636 (select-window window) 636 (if (not (eq (char-before) ?\())
637 (scroll-up)))) 637 (lambda (sym) ;why not just nil ? -sm
638 638 (or (boundp sym) (fboundp sym)
639 ;; Do completion. 639 (symbol-plist sym)))
640 (let* ((end (point)) 640 ;; Looks like a funcall position. Let's double check.
641 (beg (with-syntax-table emacs-lisp-mode-syntax-table 641 (if (condition-case nil
642 (save-excursion 642 (progn (up-list -2) (forward-char 1)
643 (backward-sexp 1) 643 (eq (char-after) ?\())
644 (while (= (char-syntax (following-char)) ?\') 644 (error nil))
645 (forward-char 1)) 645 ;; If the first element of the parent list is an open
646 (point)))) 646 ;; parenthesis we are probably not in a funcall position.
647 (pattern (buffer-substring-no-properties beg end)) 647 ;; Maybe a `let' varlist or something.
648 (predicate 648 nil
649 (or predicate 649 ;; Else, we assume that a function name is expected.
650 (save-excursion 650 'fboundp)))))
651 (goto-char beg) 651 (ol (make-overlay beg end nil nil t)))
652 (if (not (eq (char-before) ?\()) 652 (overlay-put ol 'field 'completion)
653 (lambda (sym) ;why not just nil ? -sm 653 (let ((completion-annotate-function
654 (or (boundp sym) (fboundp sym) 654 (unless (eq predicate 'fboundp)
655 (symbol-plist sym))) 655 (lambda (str) (if (fboundp (intern-soft str)) " <f>"))))
656 ;; Looks like a funcall position. Let's double check. 656 (minibuffer-completion-table obarray)
657 (if (condition-case nil 657 (minibuffer-completion-predicate predicate))
658 (progn (up-list -2) (forward-char 1) 658 (unwind-protect
659 (eq (char-after) ?\()) 659 (call-interactively 'minibuffer-complete)
660 (error nil)) 660 (delete-overlay ol)))))
661 ;; If the first element of the parent list is an open
662 ;; parenthesis we are probably not in a funcall position.
663 ;; Maybe a `let' varlist or something.
664 nil
665 ;; Else, we assume that a function name is expected.
666 'fboundp)))))
667 (completion (try-completion pattern obarray predicate)))
668 (cond ((eq completion t))
669 ((null completion)
670 (if (window-minibuffer-p (selected-window))
671 (minibuffer-message (format " [No completions of \"%s\"]" pattern))
672 (message "Can't find completion for \"%s\"" pattern))
673 (ding))
674 ((not (string= pattern completion))
675 (delete-region beg end)
676 (insert completion)
677 ;; Don't leave around a completions buffer that's out of date.
678 (let ((win (get-buffer-window "*Completions*" 0)))
679 (if win (with-selected-window win (bury-buffer)))))
680 (t
681 (let ((minibuf-is-in-use
682 (eq (minibuffer-window) (selected-window))))
683 (unless minibuf-is-in-use
684 (message "Making completion list..."))
685 (let ((list (all-completions pattern obarray predicate)))
686 (setq list (sort list 'string<))
687 (unless (eq predicate 'fboundp)
688 (let (new)
689 (dolist (compl list)
690 (push (if (fboundp (intern compl))
691 (list compl " <f>")
692 compl)
693 new))
694 (setq list (nreverse new))))
695 (if (> (length list) 1)
696 (with-output-to-temp-buffer "*Completions*"
697 (display-completion-list list pattern))
698 ;; Don't leave around a completions buffer that's
699 ;; out of date.
700 (let ((win (get-buffer-window "*Completions*" 0)))
701 (if win (with-selected-window win (bury-buffer))))))
702 (unless minibuf-is-in-use
703 (message "Making completion list...%s" "done")))))))))
704 661
705;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e 662;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e
706;;; lisp.el ends here 663;;; lisp.el ends here