help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding Key bindings


From: Kevin Rodgers
Subject: Re: Adding Key bindings
Date: Thu, 27 Jul 2006 10:03:02 -0600
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

Paulo J. Matos wrote:
On 21/07/06, Kevin Rodgers <ihs_4664@yahoo.com> wrote:
(defun c++-complete-or-indent ()
   (interactive)
   "Try to complete the current symbol at point, otherwise indent."
   ;; Kludge this because semantic-ia-complete-symbol really doesn't
   ;; return anything useful:
   (when (equal (semantic-ia-complete-symbol (point))
               "No smart completions found.")
     (c-indent-command current-prefix-arg)))

(add-hook 'c++-mode-hook
          (lambda ()
            (local-set-key "\t" c++-complete-or-indent)))


Hi all,

There's a problem with this code which I'm not being able to solve.
When you are on an empty line, there's no autocompletion but the
cursor is not indented to the correct position either. Any way to
solve this?

Assuming that "on an empty line" means "at the beginning of a line
with no characters (not even whitespace)":

(when (or (looking-at "^$")
          (equal (semantic-ia-complete-symbol (point))
                 "No smart completions found."))
  (c-indent-command current-prefix-arg))

--
Kevin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]