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

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

Re: About abbrevs and spaces at end of line


From: Andreas Röhler
Subject: Re: About abbrevs and spaces at end of line
Date: Tue, 10 Dec 2013 09:07:43 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

Am 09.12.2013 22:46, schrieb Harry Putnam:
Is there some smooth way to avoid having a space at the end of line
when activating an abbrev as the last thing done before newline?

For example:  I have `tru' (in Cperl abbrev table) set like so
tru   "\"TRUE\";"

Which enters "TRUE";<spc> (If I invoked it with the space bar)

I can avoid it by using an <ENTER> using the RET bar and leaving a
newline.

But when editing perl code, I often am working between {} where a
stray newline will leave an unsightly empty line in a clump of code.

Using the space bar to invoke (when in cperl-mode and many other
modes) leaves my code with what appears to be underscores (_) showing
where the spc is.

I'm not real sure where they come from.  They are not really
underscores, but markers left by the editor(?) that do not appear if
you print it (I guess).  Any way, that is another matter for a
different thread.

The short and long is: Invoking with spc leaves unsightly marks like
an underscore if done at the end of a line and invoking with <RET> is
not always desirable if a new line is not needed.

Before I tangle myself up any further.... I'd like to know if there is
a smooth way to create an abbrev that somehow avoids leaving that spc
that was used to invoke it.  Somehow backing the cursor up 1 space
after invocation or the like.

I can do it by creating an elisp 'skeleton' that does the job by using
the proper code to control where the cursor lands, and then associating
that 'skeleton' to my 'tru' abbrev in the cperl-table.  Yes. that
works, but requires a fair bit of typing to create.

I'd need to edit .emacs to type out the 'skeleton' (or some other
sourced file) and then the abbrev table to type out the linked abbrev.

-------        ---------       ---=---       ---------      --------

I have visions of some tricky way of setting up an abbrev with hardly
any more effort than the normal

    M-x edit-abbrevs <RET>

    "tru"       0          "\"TRUE\";"

In the cperl-table, then pressing C-c

Where I only need to edit the cperl abbrev table.





Problem results from binding abbrev-expand to SPACE.
Abbrev is expanded, than SPACE is inserted, as you typed it.

Solution: abbrev-mode off. Use any other key to M-x expand-abbrev RET.
This will expand it, but not insert a space.

Andreas



reply via email to

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