Thank you for the comments. * English I revised English as suggested. * Algorithm in detection of clicking region >> +(defun mouse-on-region-p (position &optional start end) >> + "Return if POSITION is in between START and END in the current buffer. >> +When START and END are nil but there is active region, those of >> +active region is fed." >> + (when (region-active-p) >> + (setq start (or start (region-beginning))) >> + (setq end (or end (region-end)))) >> + (let ((point (posn-point position))) >> + (and >> + (numberp start) >> + (numberp end) >> + (numberp point) >> + (<= start point) >> + (<= point end)))) > > This algorithm will fail with bidirectional text, where buffer > positions don't increase monotonically with screen coordinates. How > about testing the face of the character under mouse instead? I revised the code using following statements. Accordingly, `mouse-on-region-p' is deleted. (equal (mouse-posn-property (event-end event) 'face) 'region) (member 'secondary-selection(mapcar (lambda (xxx) (overlay-get xxx 'face)) (overlays-at (posn-point (event-end event))))) * Name of function >> +(defun mouse-drag-region-pasting (event) > > The function's name is confusing. Why not name it like the defcustom? I changed the name from `mouse-drag-region-pasting' to `mouse-drag-and-drop-region'. As a consequence, variable and function have the same name. I suppose it is OK. * NEWS, ChangeLog, and Info > Please add a NEWS entry and some minimal documentation in the user > manual. I add ChangeLog, NEWS, and Info as shown below. * Copy on Drag and Drop with meta key pressed I found that sometimes I want to copy on drop (instead of cut) even when source buffer and destination buffer are the same. I added a logic to let me do so. When modifier key is pressed on drop, the function does not delete the original region. The modifier key is specified by the variable `mouse-drag-and-drop-region' that is used as flag. I did not create a new variable. # ChangeLog 2017-05-20 Tak Kunihiro Support drag and drop region by the mouse (Bug#26725) * doc/emacs/frames.texi (Drag and Drop): Document support of drag and drop region by the mouse. * lisp/mouse.el (mouse-drag-region): Call mouse-drag-and-drop-region when start-event is against region. (mouse-drag-and-drop-region): Move the region by dragging the mouse. # NEWS ** Support drag and drop text by the mouse. You can start drag-and-drop text by customizing 'mouse-drag-and-drop-region'. # Info diff --git a/site-lisp/frames.252.texi b/site-lisp/frames.texi index 1611bd1..da140a6 100755 --- a/site-lisp/frames.252.texi +++ b/site-lisp/frames.texi @@ -1046,12 +1046,17 @@ Window Dividers, elisp, The Emacs Lisp Reference Manual}. @cindex drag and drop In most graphical desktop environments, Emacs has basic support for -@dfn{drag and drop} operations. For instance, dropping text onto an -Emacs frame inserts the text where it is dropped. Dropping a file -onto an Emacs frame visits that file. As a special case, dropping the -file on a Dired buffer moves or copies the file (according to the -conventions of the application it came from) into the directory -displayed in that buffer. +@dfn{drag and drop} operations. For instance, dragging region can move +the entire region of text to point where mouse is dragged over to. +Dropping text onto an Emacs frame inserts the text where it is dropped. +Dropping a file onto an Emacs frame visits that file. As a special +case, dropping the file on a Dired buffer moves or copies the file +(according to the conventions of the application it came from) into the +directory displayed in that buffer. + +@vindex mouse-drag-and-drop-region + If you prefer to move the entire region of text by mouse, customize +the variable @code{mouse-drag-and-drop-region}. @vindex dnd-open-file-other-window Dropping a file normally visits it in the window you drop it on. If