all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Autocompletion of Emacs Lisp Symbols in Buffer
@ 2010-05-06 13:30 Dirk80
  0 siblings, 0 replies; 7+ messages in thread
From: Dirk80 @ 2010-05-06 13:30 UTC (permalink / raw)
  To: Help-gnu-emacs


When I'm in lisp-interaction-mode or emacs-lisp mode, i.e. I'm writing
emacs-lisp code in a buffer, then I would like to have the feature of
autocompletion when I'm pressing tab.

Example:
I'm typing insert-buf. Then the possible completions would be:
insert-buf
insert-buffer
insert-buffer-substring-no-properties
insert-buffer-substring-as-yank
insert-buffer-substring

The completion algorithm of the minibuffer can do this. But I would like to
have that feature when I'm programming code in a normal buffer.

My idea is the following:
I know that obarray contains the symbol table. So I wrote a fucntion which
inserts all symbols of obarray into a buffer. 

(defun insert-obarray-entries-into-temp-buffer (symbol)
  (save-excursion
    (set-buffer (get-buffer-create "*temp*"))
    (insert (concat (symbol-name symbol) "\n"))))

(mapatoms 'insert-obarray-entries-into-temp-buffer obarray)

Now I can use (dabbrev-expand nil). I have a smart-tab function in my .emacs
file. This function is bound to "tab" and calls (dabbrev-expand nil) when
point is for example at the end of a word.

Ok, I have more or less a solution. But I think that my solution is just a
workaround. And each time, when a new symbol is inserted into obarray I
would have to update the temporary created buffer.

How would you solve this problem or have you already solved it?

Thank you!

Greetings,
Dirk
-- 
View this message in context: http://old.nabble.com/Autocompletion-of-Emacs-Lisp-Symbols-in-Buffer-tp28473645p28473645.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





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

* Re: Autocompletion of Emacs Lisp Symbols in Buffer
       [not found] <mailman.26.1273152642.10435.help-gnu-emacs@gnu.org>
@ 2010-05-06 17:05 ` Xah Lee
  2010-05-06 19:41   ` Lennart Borgman
                     ` (2 more replies)
  2010-05-07  2:47 ` Stefan Monnier
  1 sibling, 3 replies; 7+ messages in thread
From: Xah Lee @ 2010-05-06 17:05 UTC (permalink / raw)
  To: help-gnu-emacs

On May 6, 6:30 am, Dirk80 <d...@dirkundsari.de> wrote:
> When I'm in lisp-interaction-mode or emacs-lisp mode, i.e. I'm writing
> emacs-lisp code in a buffer, then I would like to have the feature of
> autocompletion when I'm pressing tab.

it is already implemented. The command is lisp-complete-symbol, the
shortcut is Meta+Tab.

Because Meta is often Alt, and Alt+Tab is used by the OS, so you can
do is press Esc Tab.

However, that is very inconvenient, so i created my own key.

(defun call-keyword-completion ()
  "Call the command that has keyboard shortcut M-TAB."
  (interactive)
  (call-interactively (key-binding (kbd "M-TAB")))
)

then give a shortcut to call-keyword-completion, e.g. on Dvorak
keyboard i have
(global-set-key (kbd "M-y") 'call-keyword-completion)

also, you might bind Meta+Shift+y for dabbrev-expand, which does
completion by words already in the buffer. (e.g. from your own
functions, variables)

I think this Meta+Tab conflict with Alt+Tab used by Windows, Mac,
Linux, is a major emacs usability problem. It forces people to make a
choice between a “emacs world” and all others. In the past when i
asked what other heavy emacs users do, seems they either have
completely alterted their keyboard shortcuts on their system so that
emacs's way prevales, or simply doesn't do anything about it, and just
press Esc Tab for completion.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Autocompletion of Emacs Lisp Symbols in Buffer
  2010-05-06 17:05 ` Xah Lee
@ 2010-05-06 19:41   ` Lennart Borgman
  2010-05-07  9:45   ` Dirk80
       [not found]   ` <mailman.9.1273238866.2075.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Lennart Borgman @ 2010-05-06 19:41 UTC (permalink / raw)
  To: Xah Lee; +Cc: help-gnu-emacs

On Thu, May 6, 2010 at 7:05 PM, Xah Lee <xahlee@gmail.com> wrote:
>
> I think this Meta+Tab conflict with Alt+Tab used by Windows, Mac,
> Linux, is a major emacs usability problem. It forces people to make a
> choice between a “emacs world” and all others. In the past when i
> asked what other heavy emacs users do, seems they either have
> completely alterted their keyboard shortcuts on their system so that
> emacs's way prevales, or simply doesn't do anything about it, and just
> press Esc Tab for completion.

In the patched version of Emacs+EmacsW32 the Emacs Meta key can be
moved from Alt to the Windows keys. That is actually what I recommend
and use.

This of course conflicts with the normal use of the Windows keys. The
Windows keys are however possible to override with standard microsoft
api:s while overriding Alt+Tab is not possible that way.

Another reason for moving Emacs Meta from Alt to the Windows keys is
of course that the Alt key is used far more often than the Windows
keys.




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

* Re: Autocompletion of Emacs Lisp Symbols in Buffer
       [not found] <mailman.26.1273152642.10435.help-gnu-emacs@gnu.org>
  2010-05-06 17:05 ` Xah Lee
@ 2010-05-07  2:47 ` Stefan Monnier
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2010-05-07  2:47 UTC (permalink / raw)
  To: help-gnu-emacs

> When I'm in lisp-interaction-mode or emacs-lisp mode, i.e. I'm writing
> emacs-lisp code in a buffer, then I would like to have the feature of
> autocompletion when I'm pressing tab.

Try (setq tab-always-indent 'complete) in Emacs>=23.2.


        Stefan


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

* Re: Autocompletion of Emacs Lisp Symbols in Buffer
  2010-05-06 17:05 ` Xah Lee
  2010-05-06 19:41   ` Lennart Borgman
@ 2010-05-07  9:45   ` Dirk80
       [not found]   ` <mailman.9.1273238866.2075.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Dirk80 @ 2010-05-07  9:45 UTC (permalink / raw)
  To: Help-gnu-emacs


Thank you for your answers. This already helped me alot.


Xah Lee-2 wrote:
> 
> it is already implemented. The command is lisp-complete-symbol, the
> shortcut is Meta+Tab.
> 

The lisp-complete-symbol function is nearly what I want. I don't know why
exactly, but I do not like the completion windows so much. I prefer the way
dabbrev-expand is doing it. Without using a completion window and just
rotating the possible completions when executing the command again.

Is there also existing a function like lisp-expand-symbol? Or do I have to
write it myself?

Thank you.

Greetings,
Dirk
-- 
View this message in context: http://old.nabble.com/Autocompletion-of-Emacs-Lisp-Symbols-in-Buffer-tp28473645p28484102.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





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

* Re: Autocompletion of Emacs Lisp Symbols in Buffer
       [not found]   ` <mailman.9.1273238866.2075.help-gnu-emacs@gnu.org>
@ 2010-05-07 14:21     ` Andreas Politz
  2010-05-08  3:03     ` Xah Lee
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Politz @ 2010-05-07 14:21 UTC (permalink / raw)
  To: help-gnu-emacs

Dirk80 <dirk@dirkundsari.de> writes:

> Thank you for your answers. This already helped me alot.
>
>
> Xah Lee-2 wrote:
>> 
>> it is already implemented. The command is lisp-complete-symbol, the
>> shortcut is Meta+Tab.
>> 
>
> The lisp-complete-symbol function is nearly what I want. I don't know why
> exactly, but I do not like the completion windows so much. I prefer the way
> dabbrev-expand is doing it. Without using a completion window and just
> rotating the possible completions when executing the command again.
>
> Is there also existing a function like lisp-expand-symbol? Or do I have to
> write it myself?
>
> Thank you.
>
> Greetings,
> Dirk

Try `hippie-expand'.

-ap


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

* Re: Autocompletion of Emacs Lisp Symbols in Buffer
       [not found]   ` <mailman.9.1273238866.2075.help-gnu-emacs@gnu.org>
  2010-05-07 14:21     ` Andreas Politz
@ 2010-05-08  3:03     ` Xah Lee
  1 sibling, 0 replies; 7+ messages in thread
From: Xah Lee @ 2010-05-08  3:03 UTC (permalink / raw)
  To: help-gnu-emacs

On May 7, 2:45 am, Dirk80 <d...@dirkundsari.de> wrote:
> Thank you for your answers. This already helped me alot.
>
> Xah Lee-2 wrote:
>
> > it is already implemented. The command is lisp-complete-symbol, the
> > shortcut is Meta+Tab.
>
> The lisp-complete-symbol function is nearly what I want. I don't know why
> exactly, but I do not like the completion windows so much. I prefer the way
> dabbrev-expand is doing it. Without using a completion window and just
> rotating the possible completions when executing the command again.
>
> Is there also existing a function like lisp-expand-symbol? Or do I have to
> write it myself?
>
> Thank you.

Andreas mentioned hippie-expand, i haven't really used. There a few
other packages that do expansion. (see emacswiki.org )

might checkout this tutorial...

• How To Implement Keyword Completion in Emacs
  http://xahlee.org/emacs/elisp_keyword_completion.html

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-05-08  3:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-06 13:30 Autocompletion of Emacs Lisp Symbols in Buffer Dirk80
     [not found] <mailman.26.1273152642.10435.help-gnu-emacs@gnu.org>
2010-05-06 17:05 ` Xah Lee
2010-05-06 19:41   ` Lennart Borgman
2010-05-07  9:45   ` Dirk80
     [not found]   ` <mailman.9.1273238866.2075.help-gnu-emacs@gnu.org>
2010-05-07 14:21     ` Andreas Politz
2010-05-08  3:03     ` Xah Lee
2010-05-07  2:47 ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.