Skip to content

Commit

Permalink
Add unrecognized strings to the completion list in ac-clang-action.
Browse files Browse the repository at this point in the history
ac-clang-action was ignoring strings which it did not recognize. This could make
it impossible to expand a C++ class name in some instances, because the only
expansion options were for the class's constructors.

This commit changes ac-clang-action to add unrecognized strings to the list of
argument completion candidates. In the case reported in
Golevka#44, this means that the empty string is added
to the list of candidates in addition to "()" argument list for the
constructor. This allows the user to complete just the type name, without extra
parentheses.

This commit has two potential side effects. First, candidate argument lists will
now contain an empty string in some cases, which is a waste of space. Second,
there may be other types of strings which are not recognized by ac-clang-action,
these will now also appear in the argument candidate list. My thinking is that
if there are types of completions which are not being handled by
ac-clang-action, we are better off not silently avoiding them. If this turns out
to be annoying a future commit can add explicit handling for the empty string,
and report unhandled strings some other way.
  • Loading branch information
toojays committed Jun 10, 2013
1 parent e32a928 commit 83e58ce
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion auto-complete-clang-async.el
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,15 @@ set new cflags for ac-clang from shell command output"
(push (propertize args 'ac-clang-help ret-f 'raw-args "") candidates)
(when (string-match ", \\.\\.\\." args)
(setq args (replace-regexp-in-string ", \\.\\.\\." "" args))
(push (propertize args 'ac-clang-help ret-f 'raw-args "") candidates)))))
(push (propertize args 'ac-clang-help ret-f 'raw-args "") candidates)))
(t
;; Most likely this is a type with no arguments. We still need to
;; add something to the candidate list. Otherwise, there is no way
;; for the user to complete just a C++ class name, because
;; completion will try to expand to a call to the class's
;; constructor.
(push s candidates))))

(cond (candidates
(setq candidates (delete-dups candidates))
(setq candidates (nreverse candidates))
Expand Down

0 comments on commit 83e58ce

Please sign in to comment.