]> code.delx.au - gnu-emacs-elpa/blobdiff - company.el
Removed unused arg to company-in-string-or-comment.
[gnu-emacs-elpa] / company.el
index c064b3d83595d6add60360d624344f4c3a895674..48f4919429a327bed597fe42fa162e575f8b02ce 100644 (file)
@@ -69,6 +69,9 @@
 ;;
 ;;; Change Log:
 ;;
+;;    Fixed issues with tabbar-mode and line-spacing.
+;;    Performance enhancements.
+;;
 ;; 2009-04-12 (0.3)
 ;;    Added `company-begin-commands' option.
 ;;    Added abbrev, tempo and Xcode back-ends.
@@ -337,7 +340,7 @@ the selected completion.  This can also be a function."
   "Determines which characters trigger an automatic completion.
 See `company-auto-complete'.  If this is a string, each string character causes
 completion.  If it is a list of syntax description characters (see
-`modify-char-syntax'), all characters with that syntax auto-complete.
+`modify-syntax-entry'), all characters with that syntax auto-complete.
 
 This can also be a function, which is called with the new input and should
 return non-nil if company should auto-complete.
@@ -512,13 +515,28 @@ keymap during active completions (`company-active-map'):
 
 ;;; backends ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defun company-grab (regexp &optional expression)
-  (when (looking-back regexp)
+(defun company-grab (regexp &optional expression limit)
+  (when (looking-back regexp limit)
     (or (match-string-no-properties (or expression 0)) "")))
 
-(defun company-in-string-or-comment (&optional point)
-  (let ((pos (syntax-ppss)))
-    (or (nth 3 pos) (nth 4 pos) (nth 7 pos))))
+(defun company-grab-line (regexp &optional expression)
+  (company-grab regexp expression (point-at-bol)))
+
+(defun company-grab-symbol ()
+  (if (looking-at "\\_>")
+      (buffer-substring (point) (save-excursion (skip-syntax-backward "w_")
+                                                (point)))
+    ""))
+
+(defun company-grab-word ()
+  (if (looking-at "\\>")
+      (buffer-substring (point) (save-excursion (skip-syntax-backward "w")
+                                                (point)))
+    ""))
+
+(defun company-in-string-or-comment ()
+  (let ((ppss (syntax-ppss)))
+    (or (nth 3 ppss) (nth 4 ppss) (nth 7 ppss))))
 
 ;;; completion mechanism ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
@@ -553,6 +571,8 @@ keymap during active completions (`company-active-map'):
   "Non-nil, if explicit completion took place.")
 (make-variable-buffer-local 'company--explicit-action)
 
+(defvar company--this-command nil)
+
 (defvar company-point nil)
 (make-variable-buffer-local 'company-point)
 
@@ -577,7 +597,7 @@ keymap during active completions (`company-active-map'):
 (defsubst company-should-complete (prefix)
   (and (eq company-idle-delay t)
        (or (eq t company-begin-commands)
-           (memq this-command company-begin-commands)
+           (memq company--this-command company-begin-commands)
            (and (symbolp this-command) (get this-command 'company-begin)))
        (not (and transient-mark-mode mark-active))
        (>= (length prefix) company-minimum-prefix-length)))
@@ -839,6 +859,7 @@ keymap during active completions (`company-active-map'):
   (unless (company-keep this-command)
     (condition-case err
         (progn
+          (setq company--this-command this-command)
           (unless (equal (point) company-point)
             (company-begin))
           (when company-candidates
@@ -1060,8 +1081,8 @@ followed by `company-search-kill-others' after each input."
   "Select the candidate picked by the mouse."
   (interactive "e")
   (when (nth 4 (event-start event))
-    (company-set-selection (- (cdr (posn-col-row (event-start event)))
-                              (cdr (posn-col-row (posn-at-point)))
+    (company-set-selection (- (cdr (posn-actual-col-row (event-start event)))
+                              (cdr (posn-actual-col-row (posn-at-point)))
                               1))
     t))
 
@@ -1152,7 +1173,7 @@ when the selection has been changed, the selected candidate is completed."
   `(when (company-manual-begin)
      (save-window-excursion
        (let ((height (window-height))
-             (row (cdr (posn-col-row (posn-at-point)))))
+             (row (cdr (posn-actual-col-row (posn-at-point)))))
          ,@body
          (and (< (window-height) height)
               (< (- (window-height) row 2) company-tooltip-limit)
@@ -1316,7 +1337,7 @@ Example:
 
 (defun company-buffer-lines (beg end)
   (goto-char beg)
-  (let ((row (cdr (posn-col-row (posn-at-point))))
+  (let ((row (cdr (posn-actual-col-row (posn-at-point))))
         lines)
     (while (and (equal (move-to-window-line (incf row)) row)
                 (<= (point) end))
@@ -1442,8 +1463,9 @@ Example:
       (overlay-put company-pseudo-tooltip-overlay 'window (selected-window)))))
 
 (defun company-pseudo-tooltip-show-at-point (pos)
-  (let ((col-row (posn-col-row (posn-at-point pos))))
-    (company-pseudo-tooltip-show (1+ (cdr col-row)) (car col-row) company-selection)))
+  (let ((col-row (posn-actual-col-row (posn-at-point pos))))
+    (company-pseudo-tooltip-show (1+ (cdr col-row)) (car col-row)
+                                 company-selection)))
 
 (defun company-pseudo-tooltip-edit (lines selection)
   (let* ((old-string (overlay-get company-pseudo-tooltip-overlay 'company-old))