unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
To: eliz@gnu.org
Cc: tkk@misasa.okayama-u.ac.jp, 27530@debbugs.gnu.org
Subject: bug#27530: patch to cut and copy secondary
Date: Sun, 10 Sep 2017 12:01:43 +0900 (JST)	[thread overview]
Message-ID: <20170910.120143.946950380669459918.tkk@misasa.okayama-u.ac.jp> (raw)
In-Reply-To: <83vakty4ra.fsf@gnu.org>

Thank you for the response.

> In sum, I think these are too general: they talk about OVERLAY in
> general, whereas what you really mean is the special overlay used for
> secondary selection.  So how about these instead:
> 
>   secondary-selection-exist-p
>   secondary-selection-from-region
>   secondary-selection-to-region

OK. How about three functions like below?  I plan to send a patch
relative to lisp/mouse.el.

  (defun secondary-selection-exist-p ()
    "Return if there is the secondary selection in current buffer."
    (memq mouse-secondary-overlay (overlays-in (point-min) (point-max))))
  
  (defun secondary-selection-to-region ()
    "Set beginning and end of the region to those of the secondary selection.
  This works when the secondary selection exists and the region
  does not exist in current buffer.  The secondary selection will
  be deleted afterward."
    (when (and (not (region-active-p))
               (secondary-selection-exist-p))
      (let* ((beg (overlay-start mouse-secondary-overlay))
             (end (overlay-end mouse-secondary-overlay))
             ;; Restore point to whichever closer.
             (is-point-front (< (point) (/ (+ beg end) 2))))
        (push-mark (if is-point-front end beg) t t)
        (goto-char (if is-point-front beg end)))
      ; Delete the secondary selection on current buffer.
      (delete-overlay mouse-secondary-overlay)))
  
  (defun secondary-selection-from-region ()
    "Set beginning and end of the secondary selection to those of the region."
    (when (region-active-p) ; Create the secondary selection from region.
      (delete-overlay mouse-secondary-overlay) ; Delete the secondary selection even on a different buffer.
      (move-overlay mouse-secondary-overlay (region-beginning) (region-end))))


Point-to-point responses are shown below.

>>  -- Function: overlay-exchange-region overlay
>>      This function exchanges the region and OVERLAY.
>>      When the region is active, this sets OVERLAY from the region.
>>      When the region is not active but OVERLAY exists, this sets the
>>      region from OVERLAY.
> 
> Does this do anything but call overlay-to-region and
> overlay-from-region? 

Yes.  I agree to exclude this.

>> -- Function: overlay-exists-p overlay
>>     This function returns if OVERLAY exists in current buffer.
>>     When OVERLAY exists, this returns list of start and end of
>>     OVERLAY.
> 
> This is just
> 
>   (memq OVERLAY (overlays-in (point-min) (point-max)))
> 
> Right?

Yes, you are correct.

>> -- Function: overlay-to-region overlay
>>     This function sets the region to text in OVERLAY.
>>     This works when OVERLAY exists and the region does not exist in
>>     current buffer.  The OVERLAY will be deleted.
> 
> I don't understand this one.  I guess "text in OVERLAY" is confusing;
> did you mean OVERLAY's beginning and end?

Yes, sentence was vague.  It should have said as below.

   -- Function: overlay-to-region overlay
       This function sets beginning and end of the region to those of
       OVERLAY.  This works when OVERLAY exists and the region does not
       exist in current buffer.  The OVERLAY will be deleted afterward.





  reply	other threads:[~2017-09-10  3:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29 12:43 bug#27530: patch to cut and copy secondary Tak Kunihiro
2017-06-29 13:41 ` Drew Adams
2017-07-01  0:45   ` Tak Kunihiro
2017-08-01  1:35     ` Tak Kunihiro
2017-09-05  3:11 ` Tak Kunihiro
2017-09-05  7:51   ` Robert Pluim
2017-09-05  9:25     ` Tak Kunihiro
2017-09-05  9:32       ` Robert Pluim
2017-09-05 12:22         ` Tak Kunihiro
2017-09-05 13:53       ` Drew Adams
2017-09-05 23:17         ` Tak Kunihiro
2017-09-06  0:29           ` Drew Adams
2017-09-05 15:08   ` Eli Zaretskii
2017-09-05 23:06     ` Tak Kunihiro
2017-09-06  2:33       ` Eli Zaretskii
2017-09-06  3:42         ` Tak Kunihiro
2017-09-06 16:04           ` Eli Zaretskii
2017-09-07 12:35             ` Tak Kunihiro
2017-09-07 19:11               ` Eli Zaretskii
2017-09-07 23:02                 ` Tak Kunihiro
2017-09-08  8:27                   ` Eli Zaretskii
2017-09-10  3:01                     ` Tak Kunihiro [this message]
2017-09-11  2:03                       ` Tak Kunihiro
2017-09-20  7:55                         ` Eli Zaretskii
2017-09-20 12:39                           ` Tak Kunihiro
2017-09-21  8:32                             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170910.120143.946950380669459918.tkk@misasa.okayama-u.ac.jp \
    --to=tkk@misasa.okayama-u.ac.jp \
    --cc=27530@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).