Mapping TAB to dabbrev-expand in cperl-mode without loosing indentation functionality

4 views
Skip to first unread message

LanX

unread,
Aug 13, 2009, 8:38:09 AM8/13/09
to emacs-perl-...@googlegroups.com
Hi guys,

Here a typical intersection question 8)

TAB-key in cperl-mode is bound to cperl-indent-command, but IMHO should better be bound intuitevely to 'dabbrev-expand' like expansion on the shell.

Do you have a suggestions how to solve this "conflict"?

E.g. another intuitive  key for indentation or restricting indentation to TAB at first char of line ... or ... ?

Cheers
  rolf

Joe Brenner

unread,
Aug 13, 2009, 9:07:21 AM8/13/09
to LanX, emacs-perl-...@googlegroups.com

LanX <lanx...@googlemail.com> wrote:

> TAB-key in cperl-mode is bound to cperl-indent-command, but IMHO should
> better be bound intuitevely to 'dabbrev-expand' like expansion on the shell.
>
> Do you have a suggestions how to solve this "conflict"?
>
> E.g. another intuitive key for indentation or restricting indentation to
> TAB at first char of line ... or ... ?

Hm... do you ever use "C-M /"? That's bound to dabbrev-completion
by default.

(I've never gotten into using it, myself, but some people swear by it,
and not all of them are java programmers.)

LanX

unread,
Aug 13, 2009, 9:18:24 AM8/13/09
to emacs-perl-intersection
Sorry I'm getting old, there is already a solution in O'Reillys "Perl
Hacks" book in my bookshelf ... ;-|

http://books.google.de/books?id=BOsjDFiJLVsC&lpg=PA14&ots=7EAxM0XLRK&dq=perl%20hacks%20defadvice%20cperl-indent-command&pg=PA14#v=onepage&q=cperl-indent-command&f=false

(defadvice cperl-indent-command
(around cperl-indent-or-complete)

"Changes \\[cperl-indent-command] so it autocompletes when at the
end of a word."
(if (looking-at "\\>")
(dabbrev-expand nil)
ad-do-it))
(eval-after-load "cperl-mode"
'(progn (require 'dabbrev) (ad-activate 'cperl- indent-
command)))

LanX

unread,
Aug 13, 2009, 9:39:28 AM8/13/09
to Joe Brenner, emacs-perl-...@googlegroups.com
Hi Joe

On German keyboard  "Shift-Meta  /" is annoyingly long for dabbrev-expand and expansion while coding with long variable names it's really(!) a bless.

Anyway now it seems to works fine in my init.el! 8)

... but had a little typo in the code posted, here corrected:

---------------------------------------------------------------------------------------------------------

 (defadvice cperl-indent-command
  (around cperl-indent-or-complete)

  "Changes \\[cperl-indent-command] so it autocompletes when at the end of a word."
  (if (looking-at "\\>")
      (dabbrev-expand nil)
    ad-do-it))
(eval-after-load "cperl-mode"
  '(progn (require 'dabbrev) (ad-activate 'cperl-indent-command)))
----------------------------------------------------------------------------------------------------------






2009/8/13 Joe Brenner <do...@kzsu.stanford.edu>
Reply all
Reply to author
Forward
0 new messages