all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Running just-one-space after expand-abbrev
@ 2008-11-12 17:49 Ian Eure
  2008-11-13 19:33 ` Nikolaj Schumacher
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Eure @ 2008-11-12 17:49 UTC (permalink / raw)
  To: help-gnu-emacs

I have abbrevs for public/protected/private: pub/prot/pri.

I often find that I'm editing something like:

public function foo();

And I want to change it from public to protected. My first thought is:  
C-a M-d prot SPC

The problem is that the M-d leaves the whitespace to the left of  
"function," and the SPC to expand the   abbrev gives another, so now I  
have two spaces.

Is it possible to run (just-one-space) after an abbrev is expanded? I  
tried advising (expand-abbrev), but that didn't work. I don't see any  
hooks for that function, either.

Ideas?




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

* Re: Running just-one-space after expand-abbrev
       [not found] <mailman.175.1226512203.26697.help-gnu-emacs@gnu.org>
@ 2008-11-12 22:28 ` aartist
  2008-11-12 23:59   ` Ian Eure
  0 siblings, 1 reply; 6+ messages in thread
From: aartist @ 2008-11-12 22:28 UTC (permalink / raw)
  To: help-gnu-emacs

On Nov 12, 12:49 pm, Ian Eure <i...@digg.com> wrote:
> I have abbrevs for public/protected/private: pub/prot/pri.
>
> I often find that I'm editing something like:
>
> public function foo();
>
> And I want to change it from public to protected. My first thought is:  
> C-a M-d prot SPC
>
> The problem is that the M-d leaves the whitespace to the left of  
> "function," and the SPC to expand the   abbrev gives another, so now I  
> have two spaces.
>
> Is it possible to run (just-one-space) after an abbrev is expanded? I  
> tried advising (expand-abbrev), but that didn't work. I don't see any  
> hooks for that function, either.
>
> Ideas?
Are you sure?
I couldn't repeat it..


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

* Re: Running just-one-space after expand-abbrev
  2008-11-12 22:28 ` aartist
@ 2008-11-12 23:59   ` Ian Eure
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Eure @ 2008-11-12 23:59 UTC (permalink / raw)
  To: aartist; +Cc: help-gnu-emacs

On Nov 12, 2008, at 2:28 PM, aartist wrote:

> On Nov 12, 12:49 pm, Ian Eure <i...@digg.com> wrote:
>> I have abbrevs for public/protected/private: pub/prot/pri.
>>
>> I often find that I'm editing something like:
>>
>> public function foo();
>>
>> And I want to change it from public to protected. My first thought  
>> is:
>> C-a M-d prot SPC
>>
>> The problem is that the M-d leaves the whitespace to the left of
>> "function," and the SPC to expand the   abbrev gives another, so  
>> now I
>> have two spaces.
>>
>> Is it possible to run (just-one-space) after an abbrev is expanded? I
>> tried advising (expand-abbrev), but that didn't work. I don't see any
>> hooks for that function, either.
>>
>> Ideas?
> Are you sure?
> I couldn't repeat it..
Can you explain what you did to make it work?

This is what I tried, and I just confirmed it does not work:

(defadvice abbrev-expand (after one-space activate)
   "Run just-one-space after expanding an abbrev"
   (just-one-space))

To be clear: This works if I hit C-x '. It does not work if I'm using  
the abbrev minor mode and something is automatically expanded when I  
hit SPC.

  - Ian





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

* Re: Running just-one-space after expand-abbrev
  2008-11-12 17:49 Running just-one-space after expand-abbrev Ian Eure
@ 2008-11-13 19:33 ` Nikolaj Schumacher
  2008-11-13 19:52   ` Ian Eure
  0 siblings, 1 reply; 6+ messages in thread
From: Nikolaj Schumacher @ 2008-11-13 19:33 UTC (permalink / raw)
  To: Ian Eure; +Cc: help-gnu-emacs

Ian Eure <ian@digg.com> wrote:

> The problem is that the M-d leaves the whitespace to the left of
> "function," and the SPC to expand the abbrev gives another, so now I
> have two spaces.

This has annoyed me as well in the past.  I took a different route in
the solution.  just-one-space would collide with my finger memory when
inserting something in the middle.  Instead I chose to give the tab key
an additional function

(defun tab-command ()
  "Do the right thing for the tab key."
  (interactive)
  (or (expand-abbrev)
      (indent-according-to-mode)))

My tab-command does in fact do many more things depending on context.
This is the abridged version. :)


regards,
Nikolaj Schumacher




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

* Re: Running just-one-space after expand-abbrev
  2008-11-13 19:33 ` Nikolaj Schumacher
@ 2008-11-13 19:52   ` Ian Eure
  2008-11-17 15:52     ` Nikolaj Schumacher
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Eure @ 2008-11-13 19:52 UTC (permalink / raw)
  To: Nikolaj Schumacher; +Cc: help-gnu-emacs

On Nov 13, 2008, at 11:33 AM, Nikolaj Schumacher wrote:

> Ian Eure <ian@digg.com> wrote:
>
>> The problem is that the M-d leaves the whitespace to the left of
>> "function," and the SPC to expand the abbrev gives another, so now I
>> have two spaces.
>
> This has annoyed me as well in the past.  I took a different route in
> the solution.  just-one-space would collide with my finger memory when
> inserting something in the middle.  Instead I chose to give the tab  
> key
> an additional function
>
> (defun tab-command ()
>  "Do the right thing for the tab key."
>  (interactive)
>  (or (expand-abbrev)
>      (indent-according-to-mode)))
>
> My tab-command does in fact do many more things depending on context.
> This is the abridged version. :)
>
Alas, this doesn't solve the case I illustrated, since I want to  
eliminate extra whitespace from the middle of the line, rather than  
fix whitespace at the beginning.

I think I may need to disable the global abbrev mode and rebind SPC to  
(self-insert-command) (and (expand-abbrev) (just-one-space)).

Thanks for the suggestion, though.

  - Ian




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

* Re: Running just-one-space after expand-abbrev
  2008-11-13 19:52   ` Ian Eure
@ 2008-11-17 15:52     ` Nikolaj Schumacher
  0 siblings, 0 replies; 6+ messages in thread
From: Nikolaj Schumacher @ 2008-11-17 15:52 UTC (permalink / raw)
  To: Ian Eure; +Cc: help-gnu-emacs

Ian Eure <ian@digg.com> wrote:

> On Nov 13, 2008, at 11:33 AM, Nikolaj Schumacher wrote:
>
>> (defun tab-command ()
>>  "Do the right thing for the tab key."
>>  (interactive)
>>  (or (expand-abbrev)
>>      (indent-according-to-mode)))
>>
>> My tab-command does in fact do many more things depending on context.
>> This is the abridged version. :)
>>
> Alas, this doesn't solve the case I illustrated, since I want to
> eliminate extra whitespace from the middle of the line, rather than
> fix whitespace at the beginning.

I think you misunderstood.  The `indent-according-to-mode' part is just
for compatibility for the old meaning of tab.  The solution I use is:

void prot function
         ^

With cursor at ^ I just use my command instead of space.  So the second
space is never added.

regards,
Nikolaj Schumacher




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

end of thread, other threads:[~2008-11-17 15:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-12 17:49 Running just-one-space after expand-abbrev Ian Eure
2008-11-13 19:33 ` Nikolaj Schumacher
2008-11-13 19:52   ` Ian Eure
2008-11-17 15:52     ` Nikolaj Schumacher
     [not found] <mailman.175.1226512203.26697.help-gnu-emacs@gnu.org>
2008-11-12 22:28 ` aartist
2008-11-12 23:59   ` Ian Eure

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.