Para o autocomplete, uso uma versão modificada do emacs ' dabbrev-expand
. Aqui estão as seções relevantes do meu arquivo .emacs
( source ):
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Make TAB expand words. Source: ;;
;; http://emacsblog.org/2007/03/12/tab-completion-everywhere/ ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun my-tab-fix ()
(local-set-key [tab] 'indent-or-expand))
(add-hook 'c-mode-hook 'my-tab-fix)
(add-hook 'cperl-mode-hook 'my-tab-fix)
(add-hook 'php-mode-hook 'my-tab-fix)
(add-hook 'js-mode-hook 'my-tab-fix)
(add-hook 'python-mode 'my-tab-fix)
(add-hook 'sh-mode-hook 'my-tab-fix)
(add-hook 'emacs-lisp-mode-hook 'my-tab-fix)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Define the indent-or-expand function we ;;
;; just mapped to TAB ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun indent-or-expand (arg)
"Either indent according to mode, or expand the word preceding
point."
(interactive "*P")
(if (and
(or (bobp) (= ?w (char-syntax (char-before))))
(or (eobp) (not (= ?w (char-syntax (char-after))))))
(dabbrev-expand arg)
(indent-according-to-mode)))
Você também pode ter interesse em yasnippet e hippie expandir .
Quanto à localização de declarações de variáveis / funções, eu uso Tags Emacs . É assim que eu configurei no meu ~/.emacs
(não escrito por mim, eu encontrei essas linhas em algum lugar ou outro):
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ETAGS ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun create-tags (dir-name)
"Create tags file."
(interactive "DDirectory: ")
(eshell-command
(format "find %s -type f -name \"*.[ch]\" | etags -L -" dir-name)))
;;; Jonas.Jarnestrom<at>ki.ericsson.se A smarter
;;; find-tag that automagically reruns etags when it cant find a
;;; requested item and then makes a new try to locate it.
;;; Fri Mar 15 09:52:14 2002
(defadvice find-tag (around refresh-etags activate)
"Rerun etags and reload tags if tag not found and redo find-tag.
If buffer is modified, ask about save before running etags."
(let ((extension (file-name-extension (buffer-file-name))))
(condition-case err
ad-do-it
(error (and (buffer-modified-p)
(not (ding))
(y-or-n-p "Buffer is modified, save it? ")
(save-buffer))
(er-refresh-etags extension)
ad-do-it))))
(defun er-refresh-etags (&optional extension)
"Run etags on all peer files in current dir and reload them silently."
(interactive)
(shell-command (format "etags *.%s" (or extension "el")))
(let ((tags-revert-without-query t)) ; don't query, revert silently
(visit-tags-table default-directory nil)))
(global-set-key "\M-s" 'tags-search)
Por fim, também recomendo vivamente o excelente BCE para quem escreve código em emacs
:
ECB stands for "Emacs Code Browser". While Emacs already has good
editing support for many modes, its browsing support is somewhat
lacking. That's where ECB comes in: it displays a number of
informational windows that allow for easy source code navigation and
overview.
The informational windows can contain:
- A directory tree,
- a list of source files in the current directory (with full support and display of the VC-state),
- a list of functions/classes/methods/... in the current file, (ECB uses the CEDET-semantic, or Imenu, or etags, for getting this list so all languages supported by any of these tools are automatically supported by ECB too)
- a history of recently visited files (groupable by several criteria),
- a direct and auto-updated ecb-window for the semantic-analyzer for some intellisense the Speedbar and
- output from compilation (the compilation window) and other modes like help, grep etc. or whatever a user defines to be displayed in this window.