emacsorphanage / helm-gtags

GNU GLOBAL helm interface
204 stars 31 forks source link

how about add completion at point feature using globle -c #128

Closed jixiuf closed 8 years ago

jixiuf commented 8 years ago
(defun helm-gtags--source-complete-init ()
  (with-current-buffer (helm-candidate-buffer 'global)
    (if (not helm-gtags-cache-select-result)
        (process-file "global" nil t nil "-c" helm-gtags--query)
      (helm-gtags--select-cache-init-common '("-c" helm-gtags--query) "GTAGS"))))

(defvar helm-source-gtags-complete
  (helm-build-in-buffer-source "Completion at point"
    :init 'helm-gtags--source-complete-init
    :candidate-number-limit helm-gtags-maximum-candidates
    :fuzzy-match helm-gtags-fuzzy-match
    :action 'helm-gtags-complete-insert-action))

;;;###autoload
(defun helm-gtags-complete-at-point()
  (interactive)
  (setq helm-gtags--query (or (thing-at-point 'symbol) ""))
  (helm-gtags--common '(helm-source-gtags-complete) nil))

(defun helm-gtags-complete-insert-action(cand)
  "insert candidate at point"
  (let ((bound (bounds-of-thing-at-point 'symbol)))
    (when bound (delete-region (car bound) (cdr bound))))
  (insert cand))
syohex commented 8 years ago

I suppose company-mode or auto-complete are better for completion. Both supports GNU Global base completion by default.