unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* (un)expand-region-abbrevs
@ 2014-06-06  9:18 Uwe Brauer
  2014-06-06 11:09 ` (un)expand-region-abbrevs Andreas Röhler
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Uwe Brauer @ 2014-06-06  9:18 UTC (permalink / raw)
  To: emacs-devel

Hello

I find expand-region-abbrevs quite useful, so would it be possible to
have the inverse function? Unexpand-region-abbrev?

Uwe Brauer 




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

* Re: (un)expand-region-abbrevs
  2014-06-06  9:18 (un)expand-region-abbrevs Uwe Brauer
@ 2014-06-06 11:09 ` Andreas Röhler
  2014-06-06 11:15 ` (un)expand-region-abbrevs Stephen J. Turnbull
  2014-06-06 13:16 ` (un)expand-region-abbrevs Stefan Monnier
  2 siblings, 0 replies; 16+ messages in thread
From: Andreas Röhler @ 2014-06-06 11:09 UTC (permalink / raw)
  To: emacs-devel; +Cc: Uwe Brauer

On 06.06.2014 11:18, Uwe Brauer wrote:
> Hello
>
> I find expand-region-abbrevs quite useful, so would it be possible to
> have the inverse function? Unexpand-region-abbrev?
>
> Uwe Brauer
>
>
>

Hi Uwe,

should be not so difficult to match strings ahead against abbrev-table entries.
Do you have a use-case for it?

Andreas



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

* (un)expand-region-abbrevs
  2014-06-06  9:18 (un)expand-region-abbrevs Uwe Brauer
  2014-06-06 11:09 ` (un)expand-region-abbrevs Andreas Röhler
@ 2014-06-06 11:15 ` Stephen J. Turnbull
  2014-06-06 11:54   ` (un)expand-region-abbrevs Andreas Röhler
  2014-06-06 12:37   ` (un)expand-region-abbrevs Uwe Brauer
  2014-06-06 13:16 ` (un)expand-region-abbrevs Stefan Monnier
  2 siblings, 2 replies; 16+ messages in thread
From: Stephen J. Turnbull @ 2014-06-06 11:15 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-devel

Uwe Brauer writes:

 > I find expand-region-abbrevs quite useful, so would it be possible
 > to have the inverse function? Unexpand-region-abbrev?

I don't see why you believe there would be an inverse.  Suppose I have
abbrevs

u -> Uwe
b -> Brauer
ub -> Uwe Brauer

What should (unexpand-region-abbrev "Uwe Brauer") return?




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

* Re: (un)expand-region-abbrevs
  2014-06-06 11:15 ` (un)expand-region-abbrevs Stephen J. Turnbull
@ 2014-06-06 11:54   ` Andreas Röhler
  2014-06-06 12:37   ` (un)expand-region-abbrevs Uwe Brauer
  1 sibling, 0 replies; 16+ messages in thread
From: Andreas Röhler @ 2014-06-06 11:54 UTC (permalink / raw)
  To: emacs-devel; +Cc: Uwe Brauer, Stephen J. Turnbull

On 06.06.2014 13:15, Stephen J. Turnbull wrote:
> Uwe Brauer writes:
>
>   > I find expand-region-abbrevs quite useful, so would it be possible
>   > to have the inverse function? Unexpand-region-abbrev?
>
> I don't see why you believe there would be an inverse.  Suppose I have
> abbrevs
>
> u -> Uwe
> b -> Brauer
> ub -> Uwe Brauer
>
> What should (unexpand-region-abbrev "Uwe Brauer") return?
>
>
>

It would check the word ahead if part of expansions.
Than select the longest match, in this case "ub".






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

* Re: (un)expand-region-abbrevs
  2014-06-06 11:15 ` (un)expand-region-abbrevs Stephen J. Turnbull
  2014-06-06 11:54   ` (un)expand-region-abbrevs Andreas Röhler
@ 2014-06-06 12:37   ` Uwe Brauer
  2014-06-06 14:21     ` (un)expand-region-abbrevs Eli Zaretskii
                       ` (2 more replies)
  1 sibling, 3 replies; 16+ messages in thread
From: Uwe Brauer @ 2014-06-06 12:37 UTC (permalink / raw)
  To: emacs-devel

>>>>> "Stephen" == Stephen J Turnbull <stephen@xemacs.org> writes:

   > Uwe Brauer writes:
   >> I find expand-region-abbrevs quite useful, so would it be possible
   >> to have the inverse function? Unexpand-region-abbrev?

   > I don't see why you believe there would be an inverse.  Suppose I have
   > abbrevs

   > u -> Uwe
   > b -> Brauer
   > ub -> Uwe Brauer

No, no,  the case I have in mind is very different. I have a huge abbrev list
which expands hebrew words to hebrew words with niqqud, like 

שלום -->     שָלֹם 

So sometimes I want to delete the niqqud. 

One might argue that I would be better off to write a short trans-tab
which replaces the niqqud by "nothing", but I got curious whether I
could use an inverse abbrev function.





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

* Re: (un)expand-region-abbrevs
  2014-06-06  9:18 (un)expand-region-abbrevs Uwe Brauer
  2014-06-06 11:09 ` (un)expand-region-abbrevs Andreas Röhler
  2014-06-06 11:15 ` (un)expand-region-abbrevs Stephen J. Turnbull
@ 2014-06-06 13:16 ` Stefan Monnier
  2014-06-06 13:53   ` (un)expand-region-abbrevs Uwe Brauer
  2 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2014-06-06 13:16 UTC (permalink / raw)
  To: emacs-devel

> I find expand-region-abbrevs quite useful, so would it be possible to
> have the inverse function? Unexpand-region-abbrev?

"expand-region-abbrev" is not naturally invertible, so you'll need to
describe your use case to see if&how it can be done.


        Stefan



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

* Re: (un)expand-region-abbrevs
  2014-06-06 13:16 ` (un)expand-region-abbrevs Stefan Monnier
@ 2014-06-06 13:53   ` Uwe Brauer
  0 siblings, 0 replies; 16+ messages in thread
From: Uwe Brauer @ 2014-06-06 13:53 UTC (permalink / raw)
  To: emacs-devel

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

   >> I find expand-region-abbrevs quite useful, so would it be possible to
   >> have the inverse function? Unexpand-region-abbrev?

   > "expand-region-abbrev" is not naturally invertible, so you'll need to
   > describe your use case to see if&how it can be done.


   >         Stefan


I just did this in my answer to Stephen+Andreas, it is about niqqud for
hebrew. 




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

* Re: (un)expand-region-abbrevs
  2014-06-06 12:37   ` (un)expand-region-abbrevs Uwe Brauer
@ 2014-06-06 14:21     ` Eli Zaretskii
  2014-06-06 14:45       ` (un)expand-region-abbrevs Uwe Brauer
  2014-06-06 14:21     ` (un)expand-region-abbrevs Andreas Röhler
  2014-06-06 15:31     ` (un)expand-region-abbrevs Stefan Monnier
  2 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2014-06-06 14:21 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-devel

> From: Uwe Brauer <oub@mat.ucm.es>
> Date: Fri, 06 Jun 2014 14:37:30 +0200
> 
> No, no,  the case I have in mind is very different. I have a huge abbrev list
> which expands hebrew words to hebrew words with niqqud, like 
> 
> שלום -->     שָלֹם 
> 
> So sometimes I want to delete the niqqud. 

You can delete the niqqud characters by hand, you know.

(I actually wonder why you need the abbrevs at all.  Why not just use
an input method that allows to type the niqqud characters at will.)

> One might argue that I would be better off to write a short trans-tab
> which replaces the niqqud by "nothing", but I got curious whether I
> could use an inverse abbrev function.

You can always _add_ those reverse abbrevs, right?




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

* Re: (un)expand-region-abbrevs
  2014-06-06 12:37   ` (un)expand-region-abbrevs Uwe Brauer
  2014-06-06 14:21     ` (un)expand-region-abbrevs Eli Zaretskii
@ 2014-06-06 14:21     ` Andreas Röhler
  2014-06-06 15:31     ` (un)expand-region-abbrevs Stefan Monnier
  2 siblings, 0 replies; 16+ messages in thread
From: Andreas Röhler @ 2014-06-06 14:21 UTC (permalink / raw)
  To: emacs-devel

On 06.06.2014 14:37, Uwe Brauer wrote:
>>>>>> "Stephen" == Stephen J Turnbull <stephen@xemacs.org> writes:
>
>     > Uwe Brauer writes:
>     >> I find expand-region-abbrevs quite useful, so would it be possible
>     >> to have the inverse function? Unexpand-region-abbrev?
>
>     > I don't see why you believe there would be an inverse.  Suppose I have
>     > abbrevs
>
>     > u -> Uwe
>     > b -> Brauer
>     > ub -> Uwe Brauer
>
> No, no,  the case I have in mind is very different. I have a huge abbrev list
> which expands hebrew words to hebrew words with niqqud, like
>
> שלום -->     שָלֹם
>
> So sometimes I want to delete the niqqud.
>
> One might argue that I would be better off to write a short trans-tab
> which replaces the niqqud by "nothing", but I got curious whether I
> could use an inverse abbrev function.
>
>
>
>

Quite easy would be unexpand-abbrev-before-point, resp. after-point.
Which would look up in the abbrev-table and do a simple replace.
With region a multi-word expansion has to be considered.

See code of current edit-abbrevs how to start.








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

* Re: (un)expand-region-abbrevs
  2014-06-06 14:21     ` (un)expand-region-abbrevs Eli Zaretskii
@ 2014-06-06 14:45       ` Uwe Brauer
  2014-06-06 15:10         ` (un)expand-region-abbrevs Eli Zaretskii
  0 siblings, 1 reply; 16+ messages in thread
From: Uwe Brauer @ 2014-06-06 14:45 UTC (permalink / raw)
  To: emacs-devel

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

   >> 
   >> שלום -->     שָלֹם 
   >> 
   >> So sometimes I want to delete the niqqud. 

   > You can delete the niqqud characters by hand, you know.

I am not sure what you mean by hand, deleting individually?

Or something like this.
;; incomplete!

(defun my-anti-niqqud ()
  (interactive)
  (query-replace-regexp "ֿ\\|ֱ\\|ֲ\\|ֳ\\|״\\|ְ\\|ּ\\| ֻ\\|ֹ\\|ֶ\\|ֵ\\|ִ\\|ַ\\|ָ\\|ׂ\\|ׁ\\|ׇ\\|ׄ\\|ׅ" ""))

   > (I actually wonder why you need the abbrevs at all.  Why not just use
   > an input method that allows to type the niqqud characters at will.)

This you can ask for any abbrev: "why don't  you type it at will?"

I think in both cases the answer should be: "Because I am lazy" 

   >> One might argue that I would be better off to write a short trans-tab
   >> which replaces the niqqud by "nothing", but I got curious whether I
   >> could use an inverse abbrev function.

   > You can always _add_ those reverse abbrevs, right?

You mean another table which is the inverse table?

Maybe the query-replace-regexp is the easiest solution, although I am
not sure about performance and we can forget the issue.








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

* Re: (un)expand-region-abbrevs
  2014-06-06 14:45       ` (un)expand-region-abbrevs Uwe Brauer
@ 2014-06-06 15:10         ` Eli Zaretskii
  2014-06-06 16:33           ` (un)expand-region-abbrevs Uwe Brauer
  0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2014-06-06 15:10 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-devel

> From: Uwe Brauer <oub@mat.ucm.es>
> Date: Fri, 06 Jun 2014 16:45:02 +0200
> 
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
> 
>    >> 
>    >> שלום -->     שָלֹם 
>    >> 
>    >> So sometimes I want to delete the niqqud. 
> 
>    > You can delete the niqqud characters by hand, you know.
> 
> I am not sure what you mean by hand, deleting individually?

Yes, with DEL.  They are just characters.

>    > (I actually wonder why you need the abbrevs at all.  Why not just use
>    > an input method that allows to type the niqqud characters at will.)
> 
> This you can ask for any abbrev: "why don't  you type it at will?"
> 
> I think in both cases the answer should be: "Because I am lazy" 

Abbrevs are about less typing.  How does typing "שלום" instead of
"שָלֹם" "abbreviate" anything, when it's more typing?

>    >> One might argue that I would be better off to write a short trans-tab
>    >> which replaces the niqqud by "nothing", but I got curious whether I
>    >> could use an inverse abbrev function.
> 
>    > You can always _add_ those reverse abbrevs, right?
> 
> You mean another table which is the inverse table?

No, I meant have them in the same table.




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

* Re: (un)expand-region-abbrevs
  2014-06-06 12:37   ` (un)expand-region-abbrevs Uwe Brauer
  2014-06-06 14:21     ` (un)expand-region-abbrevs Eli Zaretskii
  2014-06-06 14:21     ` (un)expand-region-abbrevs Andreas Röhler
@ 2014-06-06 15:31     ` Stefan Monnier
  2 siblings, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2014-06-06 15:31 UTC (permalink / raw)
  To: emacs-devel

> No, no,  the case I have in mind is very different. I have a huge abbrev list
> which expands hebrew words to hebrew words with niqqud, like 

> שלום -->     שָלֹם 

> So sometimes I want to delete the niqqud. 

Then, yes, it should be easy to write a `abbrev-inverse-table' which
takes an abbrev-table and inverts it (assuming the abbrevs are all
simple and there are no conflicts), and then passes it to
expand-region-abbrevs.


        Stefan



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

* Re: (un)expand-region-abbrevs
  2014-06-06 15:10         ` (un)expand-region-abbrevs Eli Zaretskii
@ 2014-06-06 16:33           ` Uwe Brauer
  2014-06-06 17:19             ` (un)expand-region-abbrevs Stefan Monnier
  0 siblings, 1 reply; 16+ messages in thread
From: Uwe Brauer @ 2014-06-06 16:33 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1232 bytes --]

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:


   > Abbrevs are about less typing.  How does typing "שלום" instead of
   > "שָלֹם" "abbreviate" anything, when it's more typing?

I presume I have not explained this well enough.
I have a minor mode, say ivrit-niqqud, with a associated abbrev-table.
So typing 

   שלום -->     שָלֹם 

This means typing less gives more.

I save the text, close emacs etc and then visit the file again. Now I decide
I want to delete the niqqud of some text (which I mark). If I had an
inverse-expand-region function I could use it now, but I also could use
the small function I posted in an earlier message. The closest thing I
know of would be good old iso-deaccentuate in of pre mule days.[1]

   >> You mean another table which is the inverse table?

   > No, I meant have them in the same table.
I don't understand

 שלום -->     שָלֹם
and also 
 שָלֹם --> שלום

That looks impossible to me. I thought abbrev should be function, in the
sense that one value is mapped to one but not more values.




Footnotes: 
[1]  which still works and makes sense in Xemacs due to a different
implementation of Mule, I presume.


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5556 bytes --]

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

* Re: (un)expand-region-abbrevs
  2014-06-06 16:33           ` (un)expand-region-abbrevs Uwe Brauer
@ 2014-06-06 17:19             ` Stefan Monnier
  2014-06-09 15:56               ` (un)expand-region-abbrevs Uwe Brauer
  0 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2014-06-06 17:19 UTC (permalink / raw)
  To: emacs-devel

> So typing 

>    שלום -->     שָלֹם 

> This means typing less gives more.

I don't know what the above arrow notation means, nor what it takes to
type either side of the arrow, so I don't know why that explains "typing
less gives more".

> know of would be good old iso-deaccentuate in of pre mule days.[1]
[...]
> [1]  which still works and makes sense in Xemacs due to a different
> implementation of Mule, I presume.

FWIW, iso-deaccentuate is still in obsolete/iso-acc.el and still works,
at least for "é".


        Stefan



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

* Re: (un)expand-region-abbrevs
  2014-06-06 17:19             ` (un)expand-region-abbrevs Stefan Monnier
@ 2014-06-09 15:56               ` Uwe Brauer
  2014-06-09 18:59                 ` (un)expand-region-abbrevs Stefan Monnier
  0 siblings, 1 reply; 16+ messages in thread
From: Uwe Brauer @ 2014-06-09 15:56 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1244 bytes --]

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

   >> So typing 
   >> שלום -->     שָלֹם 


   >> This means typing less gives more.

   > I don't know what the above arrow notation means, nor what it takes to
   > type either side of the arrow, so I don't know why that explains "typing
   > less gives more".

--> means expand.

The issue was that I wrote in Hebrew which is R2L, so maybe that is why
it looks confusing. 

So with latin letters and L2R.

Shlm  --> Shalom

Typing the consonants shlm, expands to the word Shalom, with vowels.

Once I have a text with vowels I might want to delete them (or at least
part of it). For that I could use a replace-regexp or an inverse abbrev
table.


   >> know of would be good old iso-deaccentuate in of pre mule days.[1]
   > [...]
   >> [1]  which still works and makes sense in Xemacs due to a different
   >> implementation of Mule, I presume.

   > FWIW, iso-deaccentuate is still in obsolete/iso-acc.el and still works,
   > at least for ë".

Aha, good to know. Thanks, iso-accents-mode however gives strange
result,
typing 'e gives ĉ even with (iso-accents-customize "spanish")
but anyhow it is obsolete...

Uwe 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5556 bytes --]

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

* Re: (un)expand-region-abbrevs
  2014-06-09 15:56               ` (un)expand-region-abbrevs Uwe Brauer
@ 2014-06-09 18:59                 ` Stefan Monnier
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2014-06-09 18:59 UTC (permalink / raw)
  To: emacs-devel

> The issue was that I wrote in Hebrew which is R2L, so maybe that is why
> it looks confusing.

> So with latin letters and L2R.

> Shlm  --> Shalom

Aha, I did figure the "direction of the arrow" thingy, so the part that
confused me was that "Shalom" ended up displayed shorter than "Shlm".

> Aha, good to know. Thanks, iso-accents-mode however gives strange
> result, typing 'e gives ĉ even with (iso-accents-customize "spanish")
> but anyhow it is obsolete...

Yes, iso-accents-mode is deprecated, but we could move the
iso-deaccentuate out of iso-acc (tho we'd want to bring it up to
Unicode while we do that).

        Stefan



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

end of thread, other threads:[~2014-06-09 18:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-06  9:18 (un)expand-region-abbrevs Uwe Brauer
2014-06-06 11:09 ` (un)expand-region-abbrevs Andreas Röhler
2014-06-06 11:15 ` (un)expand-region-abbrevs Stephen J. Turnbull
2014-06-06 11:54   ` (un)expand-region-abbrevs Andreas Röhler
2014-06-06 12:37   ` (un)expand-region-abbrevs Uwe Brauer
2014-06-06 14:21     ` (un)expand-region-abbrevs Eli Zaretskii
2014-06-06 14:45       ` (un)expand-region-abbrevs Uwe Brauer
2014-06-06 15:10         ` (un)expand-region-abbrevs Eli Zaretskii
2014-06-06 16:33           ` (un)expand-region-abbrevs Uwe Brauer
2014-06-06 17:19             ` (un)expand-region-abbrevs Stefan Monnier
2014-06-09 15:56               ` (un)expand-region-abbrevs Uwe Brauer
2014-06-09 18:59                 ` (un)expand-region-abbrevs Stefan Monnier
2014-06-06 14:21     ` (un)expand-region-abbrevs Andreas Röhler
2014-06-06 15:31     ` (un)expand-region-abbrevs Stefan Monnier
2014-06-06 13:16 ` (un)expand-region-abbrevs Stefan Monnier
2014-06-06 13:53   ` (un)expand-region-abbrevs Uwe Brauer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).