3

I am trying to use Emacs, because it seems a little bit nicer than Notepad++.

I am trying to use the code completion feature (a.k.a intellisense), but don't know how to do it.

First, I type in M-x, then eval-expression, then in the minibuffer, I want to type in

(print (font-family-list))

So I type in (print (font-f and then press TAB, I get a window with the content:

Click <mouse-2> on a completion to select it.
In this buffer, type RET to select the completion near point.

Possible completions are:
font-face-attributes
font-family-list

I can use my mouse to click on the second option (font-family-list). But how do I select the option using only my keyboard? What are the shortcut keys?

Tahir Hassan
  • 5,715
  • 6
  • 45
  • 65

3 Answers3

2

In these situations, completion is done via TAB. Completion will add any unique characters until there is a collision (in your case, it added the letter "a"). At this point you need to type the next character that differentiates it. If you type mTAB Emacs will select font-family-list.

phils
  • 71,335
  • 11
  • 153
  • 198
dmg
  • 4,231
  • 1
  • 18
  • 24
2

You can have a better completion system, but not in the mini-buffer that you call with eval-expression or M-:.

I suggest you call the interactive inferior elisp shell with M-x ielm. Now you can enable the completion of company-mode which brings something like this:

company-mode completion in shell-mode

Install company, which is in melpa:

package-install RET company RET

and call it when you want:

M-x company-mode

You'll notice it works in a shell and in other languages :)

Ehvince
  • 17,274
  • 7
  • 58
  • 79
  • Hello thanks for the suggestion. But a minibuffer drop down list would be good for org-mode. Still searching for a solution. Will change my answer if I find something. – Tahir Hassan Feb 11 '16 at 16:25
0

I was really asking the same question as:

In Emacs, how do I select the completion list with the keyboard?

From the Completion Commands doc and the above answer, I realised that I need to be executing switch-to-completions function. Because M-v wasn't working for me, I ended up binding Shift-Tab to switch to the completions window while in the minibuffer:

(define-key minibuffer-local-map  (kbd "<S-tab>") 'switch-to-completions)

EDIT: M-v (or Alt-v) is working for me on a fresh install - however since using cua-mode, it stopped working.

I was about to install minibuffer-complete-cycle but then when I was reading the description, it says that if completion-cycle-threshold variable is set to a an integer, say 3, then if there are 3 or fewer completion options, then TAB will cycle through them. We can still use M-v with it.

Though reading its description, minibuffer-complete-cycle seems a bit more polished.

Community
  • 1
  • 1
Tahir Hassan
  • 5,715
  • 6
  • 45
  • 65