all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* abbreviation ending with "."
@ 2009-11-12  0:30 finotti
  2009-11-12  4:30 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: finotti @ 2009-11-12  0:30 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I want to have an abbreviation that turns "p." into
"para" (Portuguese).  But all my abbreviations that end with "." are
not expanded.  I googled around and could not find anything on this.

Any ideas?

Thanks,

Luis


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

* Re: abbreviation ending with "."
  2009-11-12  0:30 abbreviation ending with "." finotti
@ 2009-11-12  4:30 ` Stefan Monnier
  2009-11-12 16:28   ` finotti
  2009-11-16 10:34   ` harven
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2009-11-12  4:30 UTC (permalink / raw)
  To: help-gnu-emacs

> I want to have an abbreviation that turns "p." into "para"
> (Portuguese).  But all my abbreviations that end with "." are not
> expanded.  I googled around and could not find anything on this.

Abbreviations by default only work if they're exclusively made up of
"word chars" (a.k.a chars of syntax class "word").

So you can either change the char "." to be a word constituent (which
may lead to surprises), or you can change the setting on the
abbrev-table in which you placed that "p." abbreviation.

E.g. if it's added to the abbrev table named `foo-abbrev-table', you
could do

   (abbrev-table-put foo-abbrev-table
                     :regexp "\\<\\(\\w+\\.?\\)\\W*")

See C-h v define-abbrev-table to see the default value used for
the :regexp (to which I just added \\.?).


        Stefan


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

* Re: abbreviation ending with "."
  2009-11-12  4:30 ` Stefan Monnier
@ 2009-11-12 16:28   ` finotti
  2009-11-14  8:11     ` Stefan Monnier
  2009-11-16 10:34   ` harven
  1 sibling, 1 reply; 7+ messages in thread
From: finotti @ 2009-11-12 16:28 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks for the reply!

On Nov 11, 11:30 pm, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> Abbreviations by default only work if they're exclusively made up of
> "word chars" (a.k.a chars of syntax class "word").

I see.  Thanks for clarifying that.


> So you can either change the char "." to be a word constituent (which
> may lead to surprises), or you can change the setting on the
> abbrev-table in which you placed that "p." abbreviation.
>
> E.g. if it's added to the abbrev table named `foo-abbrev-table', you
> could do
>
>    (abbrev-table-put foo-abbrev-table
>                      :regexp "\\<\\(\\w+\\.?\\)\\W*")

Should I put it in my .emacs?  If so, it did not work.  (BTW, I have
it in my global-abbrev-table.)

> See C-h v define-abbrev-table to see the default value used for
> the :regexp (to which I just added \\.?).

That command did not work for me: define-<TAB> gives only "define-key-
rebound-commands"...

Any suggestions?

Thanks again for the quick reply!

Luis


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

* Re: abbreviation ending with "."
  2009-11-12 16:28   ` finotti
@ 2009-11-14  8:11     ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2009-11-14  8:11 UTC (permalink / raw)
  To: help-gnu-emacs

>> See C-h v define-abbrev-table to see the default value used for
>> the :regexp (to which I just added \\.?).
> That command did not work for me: define-<TAB> gives only "define-key-
> rebound-commands"...

I should have said C-h f (help for functions) rather than C-h v (help
for variables).


        Stefan


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

* Re: abbreviation ending with "."
  2009-11-12  4:30 ` Stefan Monnier
  2009-11-12 16:28   ` finotti
@ 2009-11-16 10:34   ` harven
  2009-11-16 11:08     ` Andreas Röhler
       [not found]     ` <mailman.10801.1258369753.2239.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 7+ messages in thread
From: harven @ 2009-11-16 10:34 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I want to have an abbreviation that turns "p." into "para"
>> (Portuguese).  But all my abbreviations that end with "." are not
>> expanded.  I googled around and could not find anything on this.
>
> Abbreviations by default only work if they're exclusively made up of
> "word chars" (a.k.a chars of syntax class "word").
>
> So you can either change the char "." to be a word constituent (which
> may lead to surprises), or you can change the setting on the
> abbrev-table in which you placed that "p." abbreviation.
>
> E.g. if it's added to the abbrev table named `foo-abbrev-table', you
> could do
>
>    (abbrev-table-put foo-abbrev-table
>                      :regexp "\\<\\(\\w+\\.?\\)\\W*")

This does not seem to work. I tried the following with emacs -Q 

(progn
   (setq abbrev-mode t)
   (define-abbrev-table 'my-abbrev-table '(
      ("success"         "success again")
      ("try."            "try again")))
   (abbrev-table-put my-abbrev-table
                        :regexp "\\<\\(\\w+\\.?\\)\\W*")
   (setq local-abbrev-table my-abbrev-table))

success expands as success again.
try. does not expand.

Strange enough, If I try to make a new expansion for "try." with C-x a i l, 
it says that I am trying to overwrite the "try. -> try again" expansion, but 
there is still no expansion. What am I doing wrong ?

I am running "GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.16.5) of 2009-09-14 on raven, modified by Debian"


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

* Re: abbreviation ending with "."
  2009-11-16 10:34   ` harven
@ 2009-11-16 11:08     ` Andreas Röhler
       [not found]     ` <mailman.10801.1258369753.2239.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2009-11-16 11:08 UTC (permalink / raw)
  To: help-gnu-emacs

harven wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
> 
>>> I want to have an abbreviation that turns "p." into "para"
>>> (Portuguese).  But all my abbreviations that end with "." are not
>>> expanded.  I googled around and could not find anything on this.
>> Abbreviations by default only work if they're exclusively made up of
>> "word chars" (a.k.a chars of syntax class "word").
>>
>> So you can either change the char "." to be a word constituent (which
>> may lead to surprises), or you can change the setting on the
>> abbrev-table in which you placed that "p." abbreviation.
>>
>> E.g. if it's added to the abbrev table named `foo-abbrev-table', you
>> could do
>>
>>    (abbrev-table-put foo-abbrev-table
>>                      :regexp "\\<\\(\\w+\\.?\\)\\W*")
> 
> This does not seem to work. I tried the following with emacs -Q 
> 
> (progn
>    (setq abbrev-mode t)
>    (define-abbrev-table 'my-abbrev-table '(
>       ("success"         "success again")
>       ("try."            "try again")))
>    (abbrev-table-put my-abbrev-table
>                         :regexp "\\<\\(\\w+\\.?\\)\\W*")
>    (setq local-abbrev-table my-abbrev-table))
> 
> success expands as success again.
> try. does not expand.
> 

Here an explizit 'M-x expand-abbrev' does it, but <space> not.
Seems a bug somewhere.


Andreas

--
https://code.launchpad.net/s-x-emacs-werkstatt/
http://bazaar.launchpad.net/~a-roehler/python-mode/python-mode.el/





> Strange enough, If I try to make a new expansion for "try." with C-x a i l, 
> it says that I am trying to overwrite the "try. -> try again" expansion, but 
> there is still no expansion. What am I doing wrong ?
> 
> I am running "GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.16.5) of 2009-09-14 on raven, modified by Debian"
> 





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

* Re: abbreviation ending with "."
       [not found]     ` <mailman.10801.1258369753.2239.help-gnu-emacs@gnu.org>
@ 2009-11-16 14:54       ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2009-11-16 14:54 UTC (permalink / raw)
  To: help-gnu-emacs

> Here an explizit 'M-x expand-abbrev' does it, but <space> not.
> Seems a bug somewhere.

Good catch.  `self-insert-command' only calls `expand-abbrev' on word
ends (i.e. when inserting a non-word char after a word char).
Hmm...


        Stefan


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

end of thread, other threads:[~2009-11-16 14:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-12  0:30 abbreviation ending with "." finotti
2009-11-12  4:30 ` Stefan Monnier
2009-11-12 16:28   ` finotti
2009-11-14  8:11     ` Stefan Monnier
2009-11-16 10:34   ` harven
2009-11-16 11:08     ` Andreas Röhler
     [not found]     ` <mailman.10801.1258369753.2239.help-gnu-emacs@gnu.org>
2009-11-16 14:54       ` Stefan Monnier

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.