emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] master b88e7c8: Make transpose-regions interactive (Bu


From: Juri Linkov
Subject: Re: [Emacs-diffs] master b88e7c8: Make transpose-regions interactive (Bug#30343)
Date: Wed, 28 Mar 2018 23:19:04 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>> > Instead of defining transpose-regions (and its interactive spec) in
>> > Lisp (as the reverted patch did), we could take the current
>> > interactive spec of transpose-regions and use that to make a preloaded
>> > function named "read-two-regions" in simple.el.  That would allow its
>> > reuse by other commands, too.
>>
>> Where would such a function be useful?
>
> Nothing specific comes to mind.  There is one pair of commands that
> already reads multiple regions: ediff-regions-linewise and -wordwise,
> so it's not unlikely that there could be other applications.

Why not use a compromise and move only the interactive spec to simple.el:

(put 'transpose-regions
     'interactive-form
     '(if (< (length mark-ring) 2)
          (error "Other region must be marked before transposing two regions")
        (let* ((num (if current-prefix-arg
                        (prefix-numeric-value current-prefix-arg)
                      0))
               (ring-length (length mark-ring))
               (eltnum (mod num ring-length))
               (eltnum2 (mod (1+ num) ring-length)))
          (list (point) (mark) (elt mark-ring eltnum) (elt mark-ring 
eltnum2)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]