]> code.delx.au - gnu-emacs-elpa/commitdiff
Do minor cleanup
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 18 Oct 2014 19:30:51 +0000 (02:30 +0700)
committerDmitry Gutov <dgutov@yandex.ru>
Sat, 18 Oct 2014 19:30:51 +0000 (02:30 +0700)
* company-xcode.el (company-xcode-fetch): Avoid add-to-list on local var.

* company.el (company--window-height) (company--window-width):
  Move before first use.

company-xcode.el
company.el

index 91ae60b85e17904402d6ffc7d27d0848b2a40330..c7a6f80a2e4f61dac48e661e1b4990f226187011 100644 (file)
@@ -1,6 +1,6 @@
 ;;; company-xcode.el --- company-mode completion back-end for Xcode projects
 
-;; Copyright (C) 2009-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011, 2014  Free Software Foundation, Inc.
 
 ;; Author: Nikolaj Schumacher
 
@@ -80,7 +80,7 @@ valid in most contexts."
                             "\t[^\t\n]*\t[^\t\n]*"))
             candidates)
         (while (re-search-forward regexp nil t)
-          (add-to-list 'candidates (match-string 1)))
+          (cl-pushnew (match-string 1) candidates :test #'equal))
         (message "Retrieving dump from %s...done" project-bundle)
         candidates))))
 
index 36086d025e9331e829f80ed177e007d6d44cdd3e..11a083de8bdb015bcd28d6213da058824ecee905 100644 (file)
@@ -2208,6 +2208,26 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
       limit
     (length lst)))
 
+(defsubst company--window-height ()
+  (if (fboundp 'window-screen-lines)
+      (floor (window-screen-lines))
+    (window-body-height)))
+
+(defsubst company--window-width ()
+  (let ((ww (window-body-width)))
+    ;; Account for the line continuation column.
+    (when (zerop (cadr (window-fringes)))
+      (cl-decf ww))
+    (unless (or (display-graphic-p)
+                (version< "24.3.1" emacs-version))
+      ;; Emacs 24.3 and earlier included margins
+      ;; in window-width when in TTY.
+      (cl-decf ww
+               (let ((margins (window-margins)))
+                 (+ (or (car margins) 0)
+                    (or (cdr margins) 0)))))
+    ww))
+
 (defun company--replacement-string (lines old column nl &optional align-top)
   (cl-decf column company-tooltip-margin)
 
@@ -2232,7 +2252,8 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
     (while old
       (push (company-modify-line (pop old)
                                  (company--offset-line (pop lines) offset)
-                                 column) new))
+                                 column)
+            new))
     ;; Append whole new lines.
     (while lines
       (push (concat (company-space-string column)
@@ -2367,26 +2388,6 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 
 ;; show
 
-(defsubst company--window-height ()
-  (if (fboundp 'window-screen-lines)
-      (floor (window-screen-lines))
-    (window-body-height)))
-
-(defsubst company--window-width ()
-  (let ((ww (window-body-width)))
-    ;; Account for the line continuation column.
-    (when (zerop (cadr (window-fringes)))
-      (cl-decf ww))
-    (unless (or (display-graphic-p)
-                (version< "24.3.1" emacs-version))
-      ;; Emacs 24.3 and earlier included margins
-      ;; in window-width when in TTY.
-      (cl-decf ww
-               (let ((margins (window-margins)))
-                 (+ (or (car margins) 0)
-                    (or (cdr margins) 0)))))
-    ww))
-
 (defun company--pseudo-tooltip-height ()
   "Calculate the appropriate tooltip height.
 Returns a negative number if the tooltip should be displayed above point."