[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 01/05: Do minor cleanup
From: |
Dmitry Gutov |
Subject: |
[elpa] 01/05: Do minor cleanup |
Date: |
Tue, 28 Oct 2014 01:38:55 +0000 |
dgutov pushed a commit to branch master
in repository elpa.
commit 42012730da15ffaef7c61722475040babed15332
Author: Stefan Monnier <address@hidden>
Date: Sun Oct 19 02:30:51 2014 +0700
Do minor cleanup
* 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 | 4 ++--
company.el | 43 ++++++++++++++++++++++---------------------
2 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/company-xcode.el b/company-xcode.el
index 91ae60b..c7a6f80 100644
--- a/company-xcode.el
+++ b/company-xcode.el
@@ -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))))
diff --git a/company.el b/company.el
index 36086d0..11a083d 100644
--- a/company.el
+++ b/company.el
@@ -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."