Commit graph

650 commits

Author SHA1 Message Date
Po Lu
28f720e7c4 Make dragging stuff to a window above a frame work
* doc/lispref/frames.texi (Mouse Tracking):
* etc/NEWS: Announce new `drag-source' value of `track-mouse'.
* lisp/mouse.el (mouse-drag-and-drop-region): Use new value of
`track-mouse' during interprogram drag and drop.

* src/keyboard.c (make_lispy_position): Handle nil values of f
correctly.
* src/xdisp.c (define_frame_cursor1): Ignore if `drag-source' as
well.
(syms_of_xdisp): New defsym `drag-source'.
* src/xterm.c (XTmouse_position): Implement `drag-source'.
(mouse_or_wdesc_frame): Likewise.
2022-04-03 18:59:12 +08:00
Po Lu
7899e8daff Fix error on mouse move over something not a window while dragging text
* lisp/mouse.el (mouse-drag-and-drop-region): Handle non-window
values of `posn-window' correctly.
2022-04-02 15:59:15 +08:00
Po Lu
c8a49b69ab ; * lisp/mouse.el (mouse-drag-and-drop-region-scroll-margin): Fix type. 2022-04-02 15:48:57 +08:00
Po Lu
e351e9037c Add new option `mouse-drag-and-drop-region-scroll-margin'
* etc/NEWS: Announce new user option.
* lisp/mouse.el (mouse-drag-and-drop-region-scroll-margin): New
user option.
(mouse-drag-and-drop-region): Implement "scroll margin" like
behavior during mouse movement.
2022-04-02 15:45:00 +08:00
Po Lu
0a32037c92 Implement DELETE selection target for cross program drags
* lisp/mouse.el (mouse-drag-and-drop-region): Make sure mark
stays deactivated if a "cut" operation was performed.
* lisp/select.el (xselect-convert-to-delete): Don't clear
selection contents if it's the XdndSelection.
2022-04-02 14:59:08 +08:00
Po Lu
8aff4c0a36 Handle quitting correctly during interprogram drag-and-drop
* lisp/mouse.el (mouse-drag-and-drop-region): Handle quit
correctly by exiting the cross program drag and drop.
2022-03-23 11:30:13 +08:00
Lars Ingebrigtsen
c8bde5b0a3 Fix two no-X compilation warnings
* lisp/mouse.el (x-hide-tip, x-show-tip): Declare to avoid no-X
build compilation warnings (bug#54524).

* lisp/term/pgtk-win.el (window-system-initialization): Avoid no-X
compilation warning.
2022-03-22 21:14:21 +01:00
Po Lu
13762d24b8 Display drag-and-drop messages in echo area on non-graphics displays
* lisp/mouse.el (mouse-drag-and-drop-region-display-tooltip)
(mouse-drag-and-drop-region-hide-tooltip): New functions.
(mouse-drag-and-drop-region): Use them instead of calling
`x-hide-tip' and `x-show-tip' directly.
2022-03-17 15:12:23 +08:00
Po Lu
e8d7139b4e Fix minor bugs with XDND support
* lisp/mouse.el (mouse-drag-and-drop-region): Report more
selection targets for the benefit of Qt and Mozilla.
* lisp/select.el (xselect--encode-string)
(selection-converter-alist): Add new selection targets.

* src/xterm.c (x_dnd_get_window_proxy): New function.
(x_dnd_get_target_window): New argument proto_out, and return
first window with XdndAware instead of bottommost window.
(handle_one_xevent): Use new argument `proto_out'.
2022-03-16 17:03:19 +08:00
Po Lu
47dcf72dec Fix tooltip text properties showing up in dragged text
* lisp/mouse.el (mouse-drag-and-drop-region): Directly call
x-show-tip and x-hide-tip instead of going through tooltip-show.
2022-03-16 15:20:10 +08:00
Po Lu
f62a6acd00 Better handle drag-and-drop from one Emacs frame to another
* doc/lispref/frames.texi (Drag and Drop): Document new
parameter `return-frame' to `x-begin-drag'.
* lisp/mouse.el (mouse-drag-and-drop-region): Utilize new
feature.

* src/xfns.c (Fx_begin_drag): New parameter `return-frame'.
* src/xterm.c (x_dnd_begin_drag_and_drop): New parameter
return_frame_p.
(handle_one_xevent): Set new flags and return frame whenever
appropriate.
* src/xterm.h: Update prototypes.
2022-03-16 12:33:15 +08:00
Po Lu
e53fba3fd4 Add support for dragging text from Emacs to other programs
This still probably needs some more protection from
malfunctioning clients which delete windows at random, but I
don't know if that's a problem in practice.

* doc/emacs/frames.texi (Drag and Drop):
* doc/lispref/frames.texi (Drag and Drop): Document new
features.

* etc/NEWS: Announce new function `x-begin-drag' and new user
option `mouse-drag-and-drop-region-cross-program'.

* lisp/mouse.el (mouse-drag-and-drop-region-cross-program): New
user option.
(x-begin-drag): New variable declaration.
(mouse-drag-and-drop-region): If the mouse moves out of an Emacs
frame, begin a window system drag.
* lisp/x-dnd.el (x-dnd-handle-xdnd): Remove left-over debugging
code.

* src/xfns.c (Fx_set_mouse_absolute_pixel_position): Fix
indentation of opening paren.
(Fx_begin_drag): New function.
(syms_of_xfns): Define new subr.
* src/xselect.c (x_timestamp_for_selection): New function.

* src/xterm.c (X_DND_SUPPORTED_VERSION): New preprocessor
declaration.
(x_dnd_get_window_proto, x_dnd_send_enter, x_dnd_send_position)
(x_dnd_send_leave, x_dnd_send_drop, x_set_dnd_targets)
(x_dnd_begin_drag_and_drop): New functions.
(handle_one_xevent): Handle drag-and-drop motion and button
events when active.
(x_free_frame_resources): If f is the DND source, stop
drag-and-drop.
(x_term_init): Intern new atoms.
(syms_of_xterm): New symbol QXdndSelection.

* src/xterm.h (struct x_display_info): New atoms
Xatom_XdndAware, Xatom_XdndSelection, Xatom_XdndTypeList,
Xatom_XdndActionCopy, Xatom_XdndActionMove,
Xatom_XdndActionLink, Xatom_XdndActionAsk,
Xatom_XdndActionPrivate, Xatom_XdndActionList,
Xatom_XdndActionDescription, Xatom_XdndProxy, Xatom_XdndEnter,
Xatom_XdndPosition, Xatom_XdndStatus, Xatom_XdndLeave,
Xatom_XdndDrop, and Xatom_XdndFinished.
2022-03-16 11:31:29 +08:00
Juri Linkov
17c75146a4 * lisp/mouse.el (context-menu-entry): Remove help-buffer-under-preparation.
(bug#53910)
2022-02-20 20:56:06 +02:00
Juri Linkov
3d0f5bc219 * lisp/mouse.el (context-menu-entry): Don't create menu for Help commands.
Help commands that describe keybindings call context-menu-entry bound to
a key.  This causes too much trouble when trying to build the context menu
in a temporary Help buffer that is not displayed in a window.
OTOH, there is no information in context menus useful for Help commands.
So `help-buffer-under-preparation' is added to filter out such calls.
(bug#53910)
2022-02-17 20:28:43 +02:00
Juri Linkov
437382734a * lisp/mouse.el (context-menu-map): Select only unselected window (bug#53910) 2022-02-10 20:57:42 +02:00
Po Lu
d41a5e7e33 Improve selection of fonts available from `mouse-set-font'
People get confused on a build without font dialogs (such as a
Lucid build) if `menu-set-font' and `mouse-set-font' don't
present them a list of the fonts actually available on their
system.

* lisp/mouse.el (mouse-generate-font-name-for-menu)
(mouse-generate-font-menu): New functions.
(mouse-select-font): Allow the user to select from all fonts
available on the system.
(mouse-set-font): Use `mouse-select-font' to display font menu.
2022-02-09 11:27:15 +08:00
Juri Linkov
791694c5fe * lisp/mouse.el (context-menu-map): Select clicked window (bug#53249). 2022-01-15 20:37:15 +02:00
Juri Linkov
f19b34376a More fixes for recently committed context-menu additions from bug#52973
* lisp/hi-lock.el (highlight-symbol-at-mouse): New defalias.
(hi-lock-face-symbol-at-mouse): Rename from hi-lock-symbol-at-mouse.
(hi-lock-context-menu): Use thing-at-mouse and middle-separator.

* lisp/man.el (Man-context-menu): Fix Man-at-mouse and use middle-separator.

* lisp/mouse.el (context-menu-functions): Remove context-menu-online-search.
Add occur-context-menu and dictionary-context-menu (bug#50552).
2022-01-15 20:33:45 +02:00
Lars Ingebrigtsen
639488b55a Revert "Add command to invoke a search engine"
This reverts commit 3f36d08362.

Similar functionality has been added to webjump, so this commit duplicated that.
2022-01-15 09:06:50 +01:00
Lars Ingebrigtsen
373618d3a8 Add new context menu functions to the context-menu-functions type
* lisp/mouse.el (context-menu-functions): Add new menu functions
to the defcustom type list (bug#52973).
2022-01-14 09:49:44 +01:00
Philip Kaludercic
3f36d08362 Add command to invoke a search engine
* mouse.el (context-menu-online-search): Add new function
(eww-search-prefix): Declare variable from eww.el
(mouse-online-search-at-point): Add new command
2022-01-14 09:47:02 +01:00
Jim Porter
3eaf3aeec8 Prevent further cases of duplicated separators in context menus
In some cases, context menu items are added before the overall prompt
string.  This could cause multiple consecutive separators to appear if
they "surround" the prompt string.  (Bug#52293)

* lisp/mouse.el (context-menu-map): Improve the de-duplication logic
to ignore non-menu-items when checking for consecutive separators.

* test/lisp/mouse-tests.el
(context-menu-map-remove-consecutive-separators)
(context-menu-map-remove-separators-at-beginning-or-end): New tests.
2022-01-04 10:18:15 +02:00
Eli Zaretskii
dcd76bd48d Merge from origin/emacs-28
836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year.
86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year
ebe8772f65 ; Minor fixes related to copyright years
23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye...
8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t.
19dcb237b5 ; Add 2022 to copyright years.

# Conflicts:
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	lib/cdefs.h
#	lisp/erc/erc-dcc.el
#	lisp/erc/erc-imenu.el
#	lisp/erc/erc-replace.el
#	lisp/image-dired.el
#	lisp/progmodes/xref.el
#	m4/alloca.m4
#	m4/byteswap.m4
#	m4/errno_h.m4
#	m4/getopt.m4
#	m4/gnulib-common.m4
#	m4/inttypes.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/sys_socket_h.m4
2022-01-01 07:03:03 -05:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00
Stefan Monnier
aa3434369e lisp/mouse.el: Fix some lambdas quoted with ` or '
Also prefer #' to quote named functions.

* lisp/mouse.el (minor-mode-menu-from-indicator, context-menu-entry)
([C-down-mouse-3]): Don't abuse lambda lists for functions.
(context-menu-mode): Remove redundant `:group`.
(mouse-drag-line): Remove unused var `draggable`.
(mouse-yank-primary): Make it work for non-mouse events.
2021-12-08 16:14:03 -05:00
Juri Linkov
00d107ebea * lisp/mouse.el (context-menu-entry): Bind to make-sparse-keymap, not ignore.
Then where-is-internal does not run context-menu-map from the :filter,
and no context menu functions are called by e.g. describe-mode in wrong buffer
(bug#9923)
2021-12-08 22:31:55 +02:00
Stefan Kangas
abf06a46b4 Merge from origin/emacs-28
da23e607d3 Select the right buffer for event in context-menu function...
2021-12-07 06:47:32 +01:00
Juri Linkov
da23e607d3 Select the right buffer for event in context-menu functions (bug#9923)
* lisp/mouse.el (context-menu-region):
* lisp/progmodes/prog-mode.el (prog-context-menu):
Switch to the buffer displayed by the window of the event
before using syntax-ppss, char-after.
2021-12-06 19:24:09 +02:00
Lars Ingebrigtsen
6980a4fa45 Fix regression introduced by previous context-menu-map change
* lisp/mouse.el (context-menu-map): Make the context mode work
with flyspell again  (bug#52237).
2021-12-05 21:20:03 +01:00
Jim Porter
4a303c4dca Remove separators at the beginning and end of the context menu
* lisp/mouse.el (context-menu-map): Remove beginning/end
seperators (bug#52237).
2021-12-03 17:22:59 +01:00
Jim Porter
5db380abad Ensure there are no duplicate separators when creating a context menu
Previously, if there were three or more consecutive menu separators,
not all of them would be removed.

* lisp/mouse.el (context-menu-map): Ensure no duplicate separators
(bug#52237).
2021-12-02 09:23:06 +01:00
Stefan Kangas
1de6a86553 Merge from origin/emacs-28
0dd3883def Update to Org 9.5-72-gc5d6656
e3d5337970 Fix mouse handling with several TTY frames on MS-Windows
7e437af413 Fix temacs invocation from outside of the 'src' directory
0fbfd4253e ; Avoid byte-compilation warnings in edmacro.el
c22c988b1f Fix mouse events on tab bar or tool bar when 'track-mouse'...
354c834fba Fix `browse-url-interactive-arg' for certain kinds of events

# Conflicts:
#	lisp/mouse.el
2021-11-21 11:18:23 +01:00
martin rudalics
c22c988b1f Fix mouse events on tab bar or tool bar when 'track-mouse' is t
* lisp/mouse.el (mouse-drag-track):
* lisp/mouse-drag.el (mouse-drag-drag): Set 'track-mouse' to some
value neither t nor nil.
* src/keyboard.c (make_lispy_position): If track_mouse is Qt,
report event on tool or tab bar (Bug#51794).
2021-11-20 12:05:36 +02:00
Stefan Kangas
c6d5fccc92 Merge from origin/emacs-28
02853edba7 Fix sorting of menus in `context-menu-local' (bug#50067).
14271d050a Fix flyspell-correct-word selected from context menu opene...
bf824843f4 * lisp/repeat.el (describe-repeat-maps): Print all bound k...
6fc94fb99e * lisp/tab-bar.el: Use 'mouse-1' for history buttons like ...
5eeaf85767 Improve documentation of window hooks
7404f4b4e0 Improve doc string of 'highlight-nonselected-windows'
2021-11-19 07:00:24 +01:00
Juri Linkov
02853edba7 Fix sorting of menus in `context-menu-local' (bug#50067).
* lisp/menu-bar.el (menu-bar-keymap): Don't use `lookup-key'
on the `keymap' arg.

* lisp/mouse.el (context-menu-global): Use `lookup-key global-map'
for the `keymap' arg of `menu-bar-keymap'.
(context-menu-local): Use `menu-bar-keymap' to sort `keymap'.
2021-11-18 20:36:55 +02:00
Juri Linkov
14271d050a Fix flyspell-correct-word selected from context menu opened with the keyboard
* lisp/mouse.el (context-menu-open): Call interactively a command
returned by `context-menu-map' such as `flyspell-correct-word' (bug#50067).

* lisp/textmodes/flyspell.el (flyspell-correct-word): Handle the
case when it's called by a key bound to `context-menu-open'.
Then it should work the same way as `C-c $' typed on misspelled word
where the arg `event' of `flyspell-correct-word-before-point' is nil.
2021-11-18 20:23:58 +02:00
Stefan Kangas
ba0e4f3ad3 Merge from origin/emacs-28
307d164c9c * lisp/mouse.el (mouse-buffer-menu-mode-groups): Tighten "...
818211ed89 * doc/emacs/search.texi (Isearch Yank): Add isearch-forwar...

# Conflicts:
#	etc/NEWS
2021-11-09 06:59:24 +01:00
Juri Linkov
307d164c9c * lisp/mouse.el (mouse-buffer-menu-mode-groups): Tighten "Version Control".
Use word boundaries in the "Version Control" regexp to match mode names
"Log-Edit", "Log-View", "Git-Log-View", "Change Log", "VC dir",
but not "Verilog", "Prolog", "Rlogin" (bug#51337).
2021-11-08 21:23:44 +02:00
Glenn Morris
4cf06bb751 Merge from origin/emacs-28
b0d64be0bc (origin/emacs-28) Improve some NEWS entries
7fde84e881 Improve documentation of syntax-ppss-context slightly
5ecbed01b2 ; * test/lisp/mh-e/mh-utils-tests.el: Update macro declara...
168665da59 Move some xwidget entries
efde024361 time-stamp-tests: improvements to test macros
06c944cff1 Fix rfc6068-parse-mailto-url autoload
9b6b5e37ef Regexp-quote github domains in bug-reference
1f6cdeb12c Ensure valid end/beginning lines in message-mark-inserted-...
9b46150ab0 * etc/NEWS: Improve 'repeat-mode' entry.
9c37b812da ; * lisp/repeat.el (repeat-mode): Fix docstring typo.
caf87d80fa * lisp/repeat.el (repeat-keep-prefix): Expand description.
24083c8d13 * lisp/net/eww.el (eww-retrieve-command): Add :tag.
cf7d8fb1d7 Add description of cards to etc/refcards/README
d2849cc645 Fix 'calculate-lisp-indent' when "[" starts containing sex...
2a0a368ddc Fix typo in doc/emacs/anti.texi
9529e1d2fb Update doc of Edebug specification for macros
5bc522b4f4 ; * lisp/simple.el (kill-region): A better fix for bug#51320.
ee6bdd6eef Fix non-interactive behavior of 'kill-region'
2b7655ca0e ; More accurate doc string for 'tab-bar-format'
2841e26744 * test/lisp/dabbrev-tests.el: Use 'kbd' for readable keys.
1cdb4d2077 * lisp/menu-bar.el (menu-bar-keymap): Add optional arg KEY...

# Conflicts:
#	etc/NEWS
#	lisp/progmodes/bug-reference.el
2021-10-22 09:39:39 -07:00
Juri Linkov
1cdb4d2077 * lisp/menu-bar.el (menu-bar-keymap): Add optional arg KEYMAP (bug#50067).
* lisp/mouse.el (context-menu-global): Use 'menu-bar-keymap' with
its arg KEYMAP set to 'global-map'.
2021-10-21 19:55:24 +03:00
Glenn Morris
a6dea09a15 Merge from origin/emacs-28
9ff6999a06 (origin/emacs-28) Accept process-filter t in Tramp
cf95962092 ; * doc/lispref/processes.texi (Filter Functions): Fix las...
1ad4ad0c11 Document the t value for set-process-filter in the manual
b014efa1e5 * doc/misc/tramp.texi (Frequently Asked Questions): Add re...
b9b78b2631 Fix Help functions for clicks on tool bar and tab bar
74deafe921 ; * etc/DEBUG: Add a section about debugging native-compil...
8153f70b9c In make_lispy_position fix Bug#50993 in rudimentary fashion
0aa52e94f3 Mark vc-switch-backend as obsolete
568e479c59 Add missing parentheses in the Emacs manual
44ce50b0df Improve tooltip of mode-line-position again
9b1adf8b4f Use browse-url-button-regexp for rcirc-url-regexp
9ed53b022d * lisp/help.el (help--analyze-key): Avoid mouse-set-point ...

# Conflicts:
#	etc/NEWS
2021-10-14 07:50:29 -07:00
Eli Zaretskii
b9b78b2631 Fix Help functions for clicks on tool bar and tab bar
* lisp/mouse.el (mouse-minibuffer-check): Don't assume posn-window
returns a window.  (Bug#5199)
2021-10-14 12:29:43 +03:00
Yuri D'Elia
dc5bb72958 Perform cleanup on errors in mouse-drag-track
* lisp/mouse.el (mouse-drag-track): Disable both scroll-margin and
auto-hscroll-mode in mouse-drag-region and do not re-enable them until
dragging is over, making selections work as expected when inside the
margins.
* lisp/mouse.el (mouse-drag-track): Correctly reset original values
changed during execution if errors occur.
2021-10-06 10:43:22 +02:00
Yuri D'Elia
e62d1fa983 Improve interaction between mouse-drag-region and scroll-margin
* lisp/mouse.el (mouse-drag-track): Disable both scroll-margin and
auto-hscroll-mode in mouse-drag-region and do not re-enable them until
dragging is over, making selections work as expected when inside the
margins.
2021-10-06 10:42:56 +02:00
Juri Linkov
121a5abeae Move context-menu selection items Defun/List/Symbol to prog-mode (bug#9054)
* lisp/mouse.el (context-menu-functions):
Add context-menu-middle-separator to choices.
(context-menu-region): Move Defun/List/Symbol selection items
to prog-context-menu.

* lisp/progmodes/prog-mode.el (prog-context-menu):
Move Defun/List/Symbol selection items from context-menu-region.
Include text-mode select menu only in strings and comments.

* lisp/textmodes/text-mode.el (text-mode-menu): New function.
(text-mode): Add text-mode-menu to context-menu-functions.
2021-10-03 20:35:49 +03:00
Juri Linkov
2d1564103e * lisp/mouse.el (context-menu-map): Fix when menu is a command (bug#50851)
* lisp/help.el (help--analyze-key): Get information at the position
of mouse click such as 'C-h k' on a context menu item (bug#50067).
2021-09-28 22:00:41 +03:00
Juri Linkov
28f8ffa58e * lisp/mouse.el (context-menu-region): Check for nil for char-after at eobp. 2021-09-27 18:41:34 +03:00
Juri Linkov
2abf143f81 New thing-at-point target 'string' used in context-menu-region
* lisp/mouse.el (context-menu-region): Use separate "List" and "String".

* lisp/thingatpt.el (string): New target 'string'.
(thing-at-point-bounds-of-string-at-point): New function.
(thing-at-point-bounds-of-list-at-point): Revert previous commit
by removing optional args 'escape-strings' and 'no-syntax-crossing'.
(list-or-string): Remove recently added target 'list-or-string'.
(thing-at-point-bounds-of-list-or-string-at-point): Remove function.
https://lists.gnu.org/archive/html/emacs-devel/2021-09/msg01737.html
2021-09-24 09:29:52 +03:00
Juri Linkov
13d930dedd * lisp/mouse.el (context-menu-region): Use save-excursion for syntax-ppss. 2021-09-23 19:52:49 +03:00
Juri Linkov
5d96fad278 New thing-at-point target 'list-or-string' used in context-menu-region
* lisp/mouse.el (context-menu-region): Rearrange the order to
All>Defun>List>Line>Symbol.  Show title either "List" or "String"
depending on syntax-ppss, then use thing 'list-or-string' (bug#9054).

* lisp/thingatpt.el (thing-at-point-bounds-of-list-at-point): Add optional
args 'escape-strings' and 'no-syntax-crossing' like in 'up-list'.
(list-or-string): New target 'list-or-string'.
(thing-at-point-bounds-of-list-or-string-at-point): New function.
2021-09-23 19:32:36 +03:00