* About abbrevs and spaces at end of line
@ 2013-12-09 21:46 Harry Putnam
2013-12-10 8:07 ` Andreas Röhler
0 siblings, 1 reply; 9+ messages in thread
From: Harry Putnam @ 2013-12-09 21:46 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: About abbrevs and spaces at end of line
2013-12-09 21:46 About abbrevs and spaces at end of line Harry Putnam
@ 2013-12-10 8:07 ` Andreas Röhler
2013-12-10 11:08 ` Harry Putnam
0 siblings, 1 reply; 9+ messages in thread
From: Andreas Röhler @ 2013-12-10 8:07 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: About abbrevs and spaces at end of line
2013-12-10 8:07 ` Andreas Röhler
@ 2013-12-10 11:08 ` Harry Putnam
2013-12-10 11:47 ` Andreas Röhler
0 siblings, 1 reply; 9+ messages in thread
From: Harry Putnam @ 2013-12-10 11:08 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> 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?
[...]
>> 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.
[...]
>>
>> 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.
Thank you.
After looking into this a bit, I'm not seeing a handy way to set
something else permanently.
In fact it appears there are nearly half a dozen ways to invoke
expansion.
space, <RET>, C-x ' (At least two more key combos that I already
forgot)
So there must be a list or regex or something.
I'd like to add some other char to the list somehow.
Any clues how I might do that?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: About abbrevs and spaces at end of line
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
0 siblings, 2 replies; 9+ messages in thread
From: Andreas Röhler @ 2013-12-10 11:47 UTC (permalink / raw)
To: help-gnu-emacs
Am 10.12.2013 12:08, schrieb Harry Putnam:
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>
>> 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?
>
> [...]
>
>>> 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.
>
> [...]
>
>>>
>>> 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.
>
> Thank you.
>
> After looking into this a bit, I'm not seeing a handy way to set
> something else permanently.
>
> In fact it appears there are nearly half a dozen ways to invoke
> expansion.
>
> space, <RET>, C-x ' (At least two more key combos that I already
> forgot)
>
> So there must be a list or regex or something.
>
Do you mean "list of keys"?
> I'd like to add some other char to the list somehow.
>
Are you asking how to bind another key onto expand-abbrev command?
> Any clues how I might do that?
>
>
>
BTW another solution might advice abbrev-expand with (delete-char -1) - which would DTRT with <space> only.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: About abbrevs and spaces at end of line
2013-12-10 11:47 ` Andreas Röhler
@ 2013-12-10 11:53 ` Matthias Pfeifer
2013-12-11 12:29 ` Harry Putnam
1 sibling, 0 replies; 9+ messages in thread
From: Matthias Pfeifer @ 2013-12-10 11:53 UTC (permalink / raw)
To: help-gnu-emacs
Hi Harry,
If you take some time to get comfortable with emacs hippie-expand that
might be an option, too. hippie-expand overloads the tab key with a list of
functions and chooses one that fits to the current position. There is also
a function that expands abbrevs before point.
matthias
2013/12/10 Andreas Röhler <andreas.roehler@easy-emacs.de>
> Am 10.12.2013 12:08, schrieb Harry Putnam:
>
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>>
>> 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?
>>>>
>>>
>> [...]
>>
>> 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.
>>>>
>>>
>> [...]
>>
>>
>>>> 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.
>>>
>>
>> Thank you.
>>
>> After looking into this a bit, I'm not seeing a handy way to set
>> something else permanently.
>>
>> In fact it appears there are nearly half a dozen ways to invoke
>> expansion.
>>
>> space, <RET>, C-x ' (At least two more key combos that I already
>> forgot)
>>
>> So there must be a list or regex or something.
>>
>>
> Do you mean "list of keys"?
>
>
> I'd like to add some other char to the list somehow.
>>
>>
> Are you asking how to bind another key onto expand-abbrev command?
>
>
> Any clues how I might do that?
>>
>>
>>
>>
> BTW another solution might advice abbrev-expand with (delete-char -1) -
> which would DTRT with <space> only.
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: About abbrevs and spaces at end of line
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
1 sibling, 1 reply; 9+ messages in thread
From: Harry Putnam @ 2013-12-11 12:29 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> Am 10.12.2013 12:08, schrieb Harry Putnam:
>> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>>
>>> 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?
>>
>> [...]
>>
>>>> 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.
>>
>> [...]
>>
>>>>
>>>> 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.
>>
>> Thank you.
>>
>> After looking into this a bit, I'm not seeing a handy way to set
>> something else permanently.
>>
>> In fact it appears there are nearly half a dozen ways to invoke
>> expansion.
>>
>> space, <RET>, C-x ' (At least two more key combos that I already
>> forgot)
>>
>> So there must be a list or regex or something.
>>
>
> Do you mean "list of keys"?
I'm suggesting there must already be a list of keys that invoke
expansion.
>> I'd like to add some other char to the list somehow.
>>
>
> Are you asking how to bind another key onto expand-abbrev command?
You seemed to be suggesting that could be done when you said:
>>> Solution: abbrev-mode off. Use any other key to M-x expand-abbrev RET.
>>> This will expand it, but not insert a space.
I was not sure what you mean by 'Use any other key . . . '
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: About abbrevs and spaces at end of line
2013-12-11 12:29 ` Harry Putnam
@ 2013-12-11 13:03 ` Andreas Röhler
0 siblings, 0 replies; 9+ messages in thread
From: Andreas Röhler @ 2013-12-11 13:03 UTC (permalink / raw)
To: help-gnu-emacs
Am 11.12.2013 13:29, schrieb Harry Putnam:
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>
>> Am 10.12.2013 12:08, schrieb Harry Putnam:
>>> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>>>
>>>> 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?
>>>
>>> [...]
>>>
>>>>> 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.
>>>
>>> [...]
>>>
>>>>>
>>>>> 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.
>>>
>>> Thank you.
>>>
>>> After looking into this a bit, I'm not seeing a handy way to set
>>> something else permanently.
>>>
>>> In fact it appears there are nearly half a dozen ways to invoke
>>> expansion.
>>>
>>> space, <RET>, C-x ' (At least two more key combos that I already
>>> forgot)
>>>
>>> So there must be a list or regex or something.
>>>
>>
>> Do you mean "list of keys"?
>
> I'm suggesting there must already be a list of keys that invoke
> expansion.
>
>>> I'd like to add some other char to the list somehow.
>>>
>>
>> Are you asking how to bind another key onto expand-abbrev command?
>
> You seemed to be suggesting that could be done when you said:
>
Yes, there is a plenty of unused combos to employ.
For example that one:
(global-set-key [(super \{)] 'expand-abbrev)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: About abbrevs and spaces at end of line
[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
1 sibling, 0 replies; 9+ messages in thread
From: duthen.mac.01 @ 2013-12-11 20:54 UTC (permalink / raw)
To: help-gnu-emacs
Well, actually, I don't like trailing spaces.
So I always get rid of them with:
(defun jd-replace-alist (start end alist)
"Make all replacements described in alist."
(save-excursion
(save-restriction
(narrow-to-region start end)
(mapc (lambda (modif)
(let ((from (car modif)) (to (cdr modif)))
(goto-char (point-min))
(while (re-search-forward from (null 'bound) 'noerror)
(replace-match to))))
alist))))
(defun jd-zap-trailing-blanks ()
(interactive)
(jd-replace-alist (point-min) (point-max) '(("[ \t]+$" . ""))))
(add-hook 'write-file-functions 'id-zap-trailing-blanks)
This is another way to handle the problem!
HTH
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: About abbrevs and spaces at end of line
[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
1 sibling, 0 replies; 9+ messages in thread
From: duthen.mac.01 @ 2013-12-11 20:55 UTC (permalink / raw)
To: help-gnu-emacs
Well, actually, I don't like trailing spaces.
So I always get rid of them with:
(defun jd-replace-alist (start end alist)
"Make all replacements described in alist."
(save-excursion
(save-restriction
(narrow-to-region start end)
(mapc (lambda (modif)
(let ((from (car modif)) (to (cdr modif)))
(goto-char (point-min))
(while (re-search-forward from (null 'bound) 'noerror)
(replace-match to))))
alist))))
(defun jd-zap-trailing-blanks ()
(interactive)
(jd-replace-alist (point-min) (point-max) '(("[ \t]+$" . ""))))
(add-hook 'write-file-functions 'jd-zap-trailing-blanks)
This is another way to handle the problem!
HTH
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-12-11 20:55 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-09 21:46 About abbrevs and spaces at end of line Harry Putnam
2013-12-10 8:07 ` Andreas Röhler
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
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.