emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117904: * lisp/emacs-lisp/lisp.el (lisp-completion-


From: Dmitry Gutov
Subject: [Emacs-diffs] trunk r117904: * lisp/emacs-lisp/lisp.el (lisp-completion-at-point): Only calculate
Date: Fri, 19 Sep 2014 03:28:37 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117904
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Fri 2014-09-19 07:28:31 +0400
message:
  * lisp/emacs-lisp/lisp.el (lisp-completion-at-point): Only calculate
  `table-etc' when `end' is non-nil.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/emacs-lisp/lisp.el        lisp.el-20091113204419-o5vbwnq5f7feedwu-131
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-09-19 03:10:29 +0000
+++ b/lisp/ChangeLog    2014-09-19 03:28:31 +0000
@@ -1,5 +1,10 @@
 2014-09-19  Dmitry Gutov  <address@hidden>
 
+       * emacs-lisp/lisp.el (lisp-completion-at-point): Only calculate
+       `table-etc' when `end' is non-nil.
+
+2014-09-19  Dmitry Gutov  <address@hidden>
+
        * emacs-lisp/lisp.el (lisp--expect-function-p)
        (lisp--form-quoted-p): New functions.
        (lisp-completion-at-point): Use them to see if we're completing a

=== modified file 'lisp/emacs-lisp/lisp.el'
--- a/lisp/emacs-lisp/lisp.el   2014-09-19 03:10:29 +0000
+++ b/lisp/emacs-lisp/lisp.el   2014-09-19 03:28:31 +0000
@@ -960,104 +960,105 @@
                    (when (>= (point) pos)
                      (point)))
                (scan-error pos))))
-           (funpos (eq (char-before beg) ?\()) ;t if in function position.
-           (table-etc
-            (if (not funpos)
-                ;; FIXME: We could look at the first element of the list and
-                ;; use it to provide a more specific completion table in some
-                ;; cases.  E.g. filter out keywords that are not understood by
-                ;; the macro/function being called.
-                (cond
-                 ((lisp--expect-function-p beg)
-                  (list nil obarray
-                        :predicate #'fboundp
-                        :company-doc-buffer #'lisp--company-doc-buffer
-                        :company-docsig #'lisp--company-doc-string
-                        :company-location #'lisp--company-location))
-                 ((lisp--form-quoted-p beg)
-                  (list nil (completion-table-merge
-                             ;; FIXME: Is this table useful for this case?
-                             lisp--local-variables-completion-table
-                             (apply-partially #'completion-table-with-predicate
-                                              obarray
-                                              ;; Don't include all symbols
-                                              ;; (bug#16646).
-                                              (lambda (sym)
-                                                (or (boundp sym)
-                                                    (fboundp sym)
-                                                    (symbol-plist sym)))
-                                              'strict))
-                      :annotation-function
-                      (lambda (str) (if (fboundp (intern-soft str)) " <f>"))
-                      :company-doc-buffer #'lisp--company-doc-buffer
-                      :company-docsig #'lisp--company-doc-string
-                      :company-location #'lisp--company-location))
-                 (t
-                  (list nil (completion-table-merge
-                             lisp--local-variables-completion-table
-                             (apply-partially #'completion-table-with-predicate
-                                              obarray
-                                              #'boundp
-                                              'strict))
-                        :company-doc-buffer #'lisp--company-doc-buffer
-                        :company-docsig #'lisp--company-doc-string
-                        :company-location #'lisp--company-location)))
-              ;; Looks like a funcall position.  Let's double check.
-              (save-excursion
-                (goto-char (1- beg))
-                (let ((parent
-                       (condition-case nil
-                           (progn (up-list -1) (forward-char 1)
-                                  (let ((c (char-after)))
-                                    (if (eq c ?\() ?\(
-                                      (if (memq (char-syntax c) '(?w ?_))
-                                          (read (current-buffer))))))
-                         (error nil))))
-                  (pcase parent
-                    ;; FIXME: Rather than hardcode special cases here,
-                    ;; we should use something like a symbol-property.
-                    (`declare
-                     (list t (mapcar (lambda (x) (symbol-name (car x)))
-                                     (delete-dups
-                                      ;; FIXME: We should include some
-                                      ;; docstring with each entry.
-                                      (append
-                                       macro-declarations-alist
-                                       defun-declarations-alist)))))
-                    ((and (or `condition-case `condition-case-unless-debug)
-                          (guard (save-excursion
-                                   (ignore-errors
-                                     (forward-sexp 2)
-                                     (< (point) beg)))))
-                     (list t obarray
-                           :predicate (lambda (sym) (get sym 
'error-conditions))))
-                   ((and ?\(
-                         (guard (save-excursion
-                                  (goto-char (1- beg))
-                                  (up-list -1)
-                                  (forward-symbol -1)
-                                  (looking-at "\\_<let\\*?\\_>"))))
-                    (list t obarray
-                          :predicate #'boundp
-                          :company-doc-buffer #'lisp--company-doc-buffer
-                          :company-docsig #'lisp--company-doc-string
-                          :company-location #'lisp--company-location))
-                    (_ (list nil obarray
-                             :predicate #'fboundp
-                             :company-doc-buffer #'lisp--company-doc-buffer
-                             :company-docsig #'lisp--company-doc-string
-                             :company-location #'lisp--company-location
-                             ))))))))
+           ;; t if in function position.
+           (funpos (eq (char-before beg) ?\()))
       (when end
-        (let ((tail (if (null (car table-etc))
-                        (cdr table-etc)
-                      (cons
-                       (if (memq (char-syntax (or (char-after end) ?\s))
-                                 '(?\s ?>))
-                           (cadr table-etc)
-                         (apply-partially 'completion-table-with-terminator
-                                          " " (cadr table-etc)))
-                       (cddr table-etc)))))
-          `(,beg ,end ,@tail))))))
+        (let ((table-etc
+               (if (not funpos)
+                   ;; FIXME: We could look at the first element of the list and
+                   ;; use it to provide a more specific completion table in 
some
+                   ;; cases.  E.g. filter out keywords that are not understood 
by
+                   ;; the macro/function being called.
+                   (cond
+                    ((lisp--expect-function-p beg)
+                     (list nil obarray
+                           :predicate #'fboundp
+                           :company-doc-buffer #'lisp--company-doc-buffer
+                           :company-docsig #'lisp--company-doc-string
+                           :company-location #'lisp--company-location))
+                    ((lisp--form-quoted-p beg)
+                     (list nil (completion-table-merge
+                                ;; FIXME: Is this table useful for this case?
+                                lisp--local-variables-completion-table
+                                (apply-partially 
#'completion-table-with-predicate
+                                                 obarray
+                                                 ;; Don't include all symbols
+                                                 ;; (bug#16646).
+                                                 (lambda (sym)
+                                                   (or (boundp sym)
+                                                       (fboundp sym)
+                                                       (symbol-plist sym)))
+                                                 'strict))
+                           :annotation-function
+                           (lambda (str) (if (fboundp (intern-soft str)) " 
<f>"))
+                           :company-doc-buffer #'lisp--company-doc-buffer
+                           :company-docsig #'lisp--company-doc-string
+                           :company-location #'lisp--company-location))
+                    (t
+                     (list nil (completion-table-merge
+                                lisp--local-variables-completion-table
+                                (apply-partially 
#'completion-table-with-predicate
+                                                 obarray
+                                                 #'boundp
+                                                 'strict))
+                           :company-doc-buffer #'lisp--company-doc-buffer
+                           :company-docsig #'lisp--company-doc-string
+                           :company-location #'lisp--company-location)))
+                 ;; Looks like a funcall position.  Let's double check.
+                 (save-excursion
+                   (goto-char (1- beg))
+                   (let ((parent
+                          (condition-case nil
+                              (progn (up-list -1) (forward-char 1)
+                                     (let ((c (char-after)))
+                                       (if (eq c ?\() ?\(
+                                         (if (memq (char-syntax c) '(?w ?_))
+                                             (read (current-buffer))))))
+                            (error nil))))
+                     (pcase parent
+                       ;; FIXME: Rather than hardcode special cases here,
+                       ;; we should use something like a symbol-property.
+                       (`declare
+                        (list t (mapcar (lambda (x) (symbol-name (car x)))
+                                        (delete-dups
+                                         ;; FIXME: We should include some
+                                         ;; docstring with each entry.
+                                         (append
+                                          macro-declarations-alist
+                                          defun-declarations-alist)))))
+                       ((and (or `condition-case `condition-case-unless-debug)
+                             (guard (save-excursion
+                                      (ignore-errors
+                                        (forward-sexp 2)
+                                        (< (point) beg)))))
+                        (list t obarray
+                              :predicate (lambda (sym) (get sym 
'error-conditions))))
+                       ((and ?\(
+                             (guard (save-excursion
+                                      (goto-char (1- beg))
+                                      (up-list -1)
+                                      (forward-symbol -1)
+                                      (looking-at "\\_<let\\*?\\_>"))))
+                        (list t obarray
+                              :predicate #'boundp
+                              :company-doc-buffer #'lisp--company-doc-buffer
+                              :company-docsig #'lisp--company-doc-string
+                              :company-location #'lisp--company-location))
+                       (_ (list nil obarray
+                                :predicate #'fboundp
+                                :company-doc-buffer #'lisp--company-doc-buffer
+                                :company-docsig #'lisp--company-doc-string
+                                :company-location #'lisp--company-location
+                                ))))))))
+          (nconc (list beg end)
+                 (if (null (car table-etc))
+                     (cdr table-etc)
+                   (cons
+                    (if (memq (char-syntax (or (char-after end) ?\s))
+                              '(?\s ?>))
+                        (cadr table-etc)
+                      (apply-partially 'completion-table-with-terminator
+                                       " " (cadr table-etc)))
+                    (cddr table-etc)))))))))
 
 ;;; lisp.el ends here


reply via email to

[Prev in Thread] Current Thread [Next in Thread]