unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: About abbrevs and spaces at end of line
Date: Tue, 10 Dec 2013 09:07:43 +0100	[thread overview]
Message-ID: <52A6CBCF.2010506@easy-emacs.de> (raw)
In-Reply-To: <87r49lg0j6.fsf@newsguy.com>

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	other threads:[~2013-12-10  8:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09 21:46 About abbrevs and spaces at end of line Harry Putnam
2013-12-10  8:07 ` Andreas Röhler [this message]
2013-12-10 11:08   ` Harry Putnam
2013-12-10 11:47     ` Andreas Röhler
2013-12-10 11:53       ` Matthias Pfeifer
2013-12-11 12:29       ` Harry Putnam
2013-12-11 13:03         ` Andreas Röhler
     [not found] <mailman.8702.1386625654.10748.help-gnu-emacs@gnu.org>
2013-12-11 20:54 ` duthen.mac.01
2013-12-11 20:55 ` duthen.mac.01

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52A6CBCF.2010506@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).