unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* DWIM for the TAB key
@ 2005-02-16  1:42 Oliver Scholz
  2005-02-16  2:03 ` Oliver Scholz
  2005-02-16 17:16 ` rbielaws
  0 siblings, 2 replies; 5+ messages in thread
From: Oliver Scholz @ 2005-02-16  1:42 UTC (permalink / raw)


Reading a thread on emacs-devel, I thought that maybe others would
also like what I have been using for quite a while:

(defun egoge-tab-dwim ()
  "Indent or complete depending on the context.
If point is at the beginning of a line or if all characters
between point and the beginning of the line are whitespace
characters, indent that line. Otherwise complete the symbol at
point."
  (interactive)
  (if (or (bolp)
          (save-excursion (backward-char 1)
                          (looking-at "[[:blank:]]")))
      (indent-according-to-mode)
    (if (memq major-mode '(emacs-lisp-mode
                           lisp-interaction-mode
                           inferior-emacs-lisp-mode))
        (lisp-complete-symbol)
      (complete-symbol))))

(define-key global-map [tab] 'egoge-tab-dwim)

    Oliver
-- 
28 Pluviôse an 213 de la Révolution
Liberté, Egalité, Fraternité!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-02-17 14:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-16  1:42 DWIM for the TAB key Oliver Scholz
2005-02-16  2:03 ` Oliver Scholz
2005-02-16 17:16 ` rbielaws
2005-02-17 13:16   ` Oliver Scholz
2005-02-17 14:40     ` Thien-Thi Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).