diff options
| author | Chong Yidong | 2011-05-28 20:45:00 -0400 |
|---|---|---|
| committer | Chong Yidong | 2011-05-28 20:45:00 -0400 |
| commit | 1dd3c2d9b2466eb6dc379da6a67074dbd4c13fa5 (patch) | |
| tree | a812814e376414db37827f4298e375ff868ecdaf | |
| parent | 8e6ca83dfede41bbc8d060a4aaa72f2a414f59ae (diff) | |
| download | emacs-1dd3c2d9b2466eb6dc379da6a67074dbd4c13fa5.tar.gz emacs-1dd3c2d9b2466eb6dc379da6a67074dbd4c13fa5.zip | |
Move clipboard-manager functionality out of hooks.
* lisp/select.el: Don't perform clipboard-manager saving in hooks;
leave the hooks empty.
* src/emacs.c (Fkill_emacs): Call x_clipboard_manager_save_all.
* src/frame.c (delete_frame): Call x_clipboard_manager_save_frame.
* src/xselect.c (x_clipboard_manager_save_frame)
(x_clipboard_manager_save_all): New functions.
(Fx_clipboard_manager_save): Lisp function deleted.
* src/xterm.h: Update prototype.
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/select.el | 4 | ||||
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/emacs.c | 10 | ||||
| -rw-r--r-- | src/frame.c | 9 | ||||
| -rw-r--r-- | src/xselect.c | 87 | ||||
| -rw-r--r-- | src/xterm.h | 1 |
8 files changed, 82 insertions, 49 deletions
| @@ -177,6 +177,8 @@ with Xft. To change font, use the X resource font, for example: | |||
| 177 | Emacs.pane.menubar.font: Courier-12 | 177 | Emacs.pane.menubar.font: Courier-12 |
| 178 | 178 | ||
| 179 | ** On graphical displays, the mode-line no longer ends in dashes. | 179 | ** On graphical displays, the mode-line no longer ends in dashes. |
| 180 | Also, the first dash (which does not indicate anything) is just | ||
| 181 | displayed as a space. | ||
| 180 | 182 | ||
| 181 | ** On Nextstep/OSX, the menu bar can be hidden by customizing | 183 | ** On Nextstep/OSX, the menu bar can be hidden by customizing |
| 182 | ns-auto-hide-menu-bar. | 184 | ns-auto-hide-menu-bar. |
| @@ -386,6 +388,8 @@ between applications. | |||
| 386 | 388 | ||
| 387 | *** Support for X cut buffers has been removed. | 389 | *** Support for X cut buffers has been removed. |
| 388 | 390 | ||
| 391 | *** Support for X clipboard managers has been added. | ||
| 392 | |||
| 389 | ** New command `rectangle-number-lines', bound to `C-x r N', numbers | 393 | ** New command `rectangle-number-lines', bound to `C-x r N', numbers |
| 390 | the lines in the current rectangle. With an prefix argument, this | 394 | the lines in the current rectangle. With an prefix argument, this |
| 391 | prompts for a number to count from and for a format string. | 395 | prompts for a number to count from and for a format string. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ee03aeccb10..a236441a349 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-05-29 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * select.el: Don't perform clipboard-manager saving in hooks; | ||
| 4 | leave the hooks empty. | ||
| 5 | |||
| 1 | 2011-05-28 Leo Liu <sdl.web@gmail.com> | 6 | 2011-05-28 Leo Liu <sdl.web@gmail.com> |
| 2 | 7 | ||
| 3 | * replace.el (occur-menu-map, occur-edit-mode-map): New vars. | 8 | * replace.el (occur-menu-map, occur-edit-mode-map): New vars. |
diff --git a/lisp/select.el b/lisp/select.el index 5abbf8f795d..10c8f0b1efd 100644 --- a/lisp/select.el +++ b/lisp/select.el | |||
| @@ -395,10 +395,6 @@ This function returns the string \"emacs\"." | |||
| 395 | (SAVE_TARGETS . xselect-convert-to-save-targets) | 395 | (SAVE_TARGETS . xselect-convert-to-save-targets) |
| 396 | (_EMACS_INTERNAL . xselect-convert-to-identity))) | 396 | (_EMACS_INTERNAL . xselect-convert-to-identity))) |
| 397 | 397 | ||
| 398 | (when (fboundp 'x-clipboard-manager-save) | ||
| 399 | (add-hook 'delete-frame-functions 'x-clipboard-manager-save) | ||
| 400 | (add-hook 'kill-emacs-hook 'x-clipboard-manager-save)) | ||
| 401 | |||
| 402 | (provide 'select) | 398 | (provide 'select) |
| 403 | 399 | ||
| 404 | ;;; select.el ends here | 400 | ;;; select.el ends here |
diff --git a/src/ChangeLog b/src/ChangeLog index 1546348bfbf..6c56b878b01 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2011-05-29 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * xselect.c (x_clipboard_manager_save_frame) | ||
| 4 | (x_clipboard_manager_save_all): New functions. | ||
| 5 | (Fx_clipboard_manager_save): Lisp function deleted. | ||
| 6 | |||
| 7 | * emacs.c (Fkill_emacs): Call x_clipboard_manager_save_all. | ||
| 8 | * frame.c (delete_frame): Call x_clipboard_manager_save_frame. | ||
| 9 | |||
| 10 | * xterm.h: Update prototype. | ||
| 11 | |||
| 1 | 2011-05-28 William Xu <william.xwl@gmail.com> | 12 | 2011-05-28 William Xu <william.xwl@gmail.com> |
| 2 | 13 | ||
| 3 | * nsterm.m (ns_term_shutdown): Synchronize user defaults before | 14 | * nsterm.m (ns_term_shutdown): Synchronize user defaults before |
diff --git a/src/emacs.c b/src/emacs.c index 8c4490b0a52..090fddada5c 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1959,6 +1959,11 @@ sort_args (int argc, char **argv) | |||
| 1959 | xfree (priority); | 1959 | xfree (priority); |
| 1960 | } | 1960 | } |
| 1961 | 1961 | ||
| 1962 | #ifdef HAVE_X_WINDOWS | ||
| 1963 | /* Defined in xselect.c. */ | ||
| 1964 | extern void x_clipboard_manager_save_all (void); | ||
| 1965 | #endif | ||
| 1966 | |||
| 1962 | DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P", | 1967 | DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P", |
| 1963 | doc: /* Exit the Emacs job and kill it. | 1968 | doc: /* Exit the Emacs job and kill it. |
| 1964 | If ARG is an integer, return ARG as the exit program code. | 1969 | If ARG is an integer, return ARG as the exit program code. |
| @@ -1985,6 +1990,11 @@ all of which are called before Emacs is actually killed. */) | |||
| 1985 | 1990 | ||
| 1986 | UNGCPRO; | 1991 | UNGCPRO; |
| 1987 | 1992 | ||
| 1993 | #ifdef HAVE_X_WINDOWS | ||
| 1994 | /* Transfer any clipboards we own to the clipboard manager. */ | ||
| 1995 | x_clipboard_manager_save_all (); | ||
| 1996 | #endif | ||
| 1997 | |||
| 1988 | shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil); | 1998 | shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil); |
| 1989 | 1999 | ||
| 1990 | /* If we have an auto-save list file, | 2000 | /* If we have an auto-save list file, |
diff --git a/src/frame.c b/src/frame.c index ce92a83b86c..74e222f85fc 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -1347,7 +1347,14 @@ delete_frame (Lisp_Object frame, Lisp_Object force) | |||
| 1347 | = Fcons (list3 (Qrun_hook_with_args, Qdelete_frame_functions, frame), | 1347 | = Fcons (list3 (Qrun_hook_with_args, Qdelete_frame_functions, frame), |
| 1348 | pending_funcalls); | 1348 | pending_funcalls); |
| 1349 | else | 1349 | else |
| 1350 | safe_call2 (Qrun_hook_with_args, Qdelete_frame_functions, frame); | 1350 | { |
| 1351 | #ifdef HAVE_X_WINDOWS | ||
| 1352 | /* Also, save clipboard to the the clipboard manager. */ | ||
| 1353 | x_clipboard_manager_save_frame (frame); | ||
| 1354 | #endif | ||
| 1355 | |||
| 1356 | safe_call2 (Qrun_hook_with_args, Qdelete_frame_functions, frame); | ||
| 1357 | } | ||
| 1351 | 1358 | ||
| 1352 | /* The hook may sometimes (indirectly) cause the frame to be deleted. */ | 1359 | /* The hook may sometimes (indirectly) cause the frame to be deleted. */ |
| 1353 | if (! FRAME_LIVE_P (f)) | 1360 | if (! FRAME_LIVE_P (f)) |
diff --git a/src/xselect.c b/src/xselect.c index 8741cb89967..0f852a7c382 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -2107,6 +2107,7 @@ frame's display, or the first available X display. */) | |||
| 2107 | return (owner ? Qt : Qnil); | 2107 | return (owner ? Qt : Qnil); |
| 2108 | } | 2108 | } |
| 2109 | 2109 | ||
| 2110 | |||
| 2110 | /* Send the clipboard manager a SAVE_TARGETS request with a | 2111 | /* Send the clipboard manager a SAVE_TARGETS request with a |
| 2111 | UTF8_STRING property, as described by | 2112 | UTF8_STRING property, as described by |
| 2112 | http://www.freedesktop.org/wiki/ClipboardManager */ | 2113 | http://www.freedesktop.org/wiki/ClipboardManager */ |
| @@ -2126,54 +2127,53 @@ x_clipboard_manager_save (struct x_display_info *dpyinfo, | |||
| 2126 | Qnil, frame); | 2127 | Qnil, frame); |
| 2127 | } | 2128 | } |
| 2128 | 2129 | ||
| 2129 | DEFUN ("x-clipboard-manager-save", Fx_clipboard_manager_save, | 2130 | /* Called from delete_frame: save any clipboard owned by FRAME to the |
| 2130 | Sx_clipboard_manager_save, 0, 1, 0, | 2131 | clipboard manager. Do nothing if FRAME does not own the clipboard, |
| 2131 | doc: /* Save the clipboard contents to the clipboard manager. | 2132 | or if no clipboard manager is present. */ |
| 2132 | This function is intended to run from `delete-frame-functions' and | 2133 | |
| 2133 | `kill-emacs-hook', to transfer clipboard data owned by Emacs to a | 2134 | void |
| 2134 | clipboard manager prior to deleting a frame or killing Emacs. | 2135 | x_clipboard_manager_save_frame (Lisp_Object frame) |
| 2135 | |||
| 2136 | FRAME specifies a frame owning a clipboard; do nothing if FRAME does | ||
| 2137 | not own the clipboard, or if no clipboard manager is present. If | ||
| 2138 | FRAME is nil, save all clipboard contents owned by Emacs. */) | ||
| 2139 | (Lisp_Object frame) | ||
| 2140 | { | 2136 | { |
| 2141 | if (FRAMEP (frame)) | 2137 | struct frame *f; |
| 2138 | |||
| 2139 | if (FRAMEP (frame) | ||
| 2140 | && (f = XFRAME (frame), FRAME_X_P (f)) | ||
| 2141 | && FRAME_LIVE_P (f)) | ||
| 2142 | { | 2142 | { |
| 2143 | struct frame *f = XFRAME (frame); | 2143 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 2144 | if (FRAME_LIVE_P (f) && FRAME_X_P (f)) | 2144 | Lisp_Object local_selection |
| 2145 | { | 2145 | = LOCAL_SELECTION (QCLIPBOARD, dpyinfo); |
| 2146 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 2146 | |
| 2147 | Lisp_Object local_selection | 2147 | if (!NILP (local_selection) |
| 2148 | = LOCAL_SELECTION (QCLIPBOARD, dpyinfo); | 2148 | && EQ (frame, XCAR (XCDR (XCDR (XCDR (local_selection))))) |
| 2149 | 2149 | && XGetSelectionOwner (dpyinfo->display, | |
| 2150 | if (!NILP (local_selection) | 2150 | dpyinfo->Xatom_CLIPBOARD_MANAGER)) |
| 2151 | && EQ (frame, XCAR (XCDR (XCDR (XCDR (local_selection))))) | 2151 | x_clipboard_manager_save (dpyinfo, frame); |
| 2152 | && XGetSelectionOwner (dpyinfo->display, | ||
| 2153 | dpyinfo->Xatom_CLIPBOARD_MANAGER)) | ||
| 2154 | x_clipboard_manager_save (dpyinfo, frame); | ||
| 2155 | } | ||
| 2156 | } | 2152 | } |
| 2157 | else if (NILP (frame)) | 2153 | } |
| 2154 | |||
| 2155 | /* Called from Fkill_emacs: save any clipboard owned by FRAME to the | ||
| 2156 | clipboard manager. Do nothing if FRAME does not own the clipboard, | ||
| 2157 | or if no clipboard manager is present. */ | ||
| 2158 | |||
| 2159 | void | ||
| 2160 | x_clipboard_manager_save_all (void) | ||
| 2161 | { | ||
| 2162 | /* Loop through all X displays, saving owned clipboards. */ | ||
| 2163 | struct x_display_info *dpyinfo; | ||
| 2164 | Lisp_Object local_selection, local_frame; | ||
| 2165 | for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) | ||
| 2158 | { | 2166 | { |
| 2159 | /* Loop through all X displays, saving owned clipboards. */ | 2167 | local_selection = LOCAL_SELECTION (QCLIPBOARD, dpyinfo); |
| 2160 | struct x_display_info *dpyinfo; | 2168 | if (NILP (local_selection) |
| 2161 | Lisp_Object local_selection, local_frame; | 2169 | || !XGetSelectionOwner (dpyinfo->display, |
| 2162 | for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) | 2170 | dpyinfo->Xatom_CLIPBOARD_MANAGER)) |
| 2163 | { | 2171 | continue; |
| 2164 | local_selection = LOCAL_SELECTION (QCLIPBOARD, dpyinfo); | ||
| 2165 | if (NILP (local_selection) | ||
| 2166 | || !XGetSelectionOwner (dpyinfo->display, | ||
| 2167 | dpyinfo->Xatom_CLIPBOARD_MANAGER)) | ||
| 2168 | continue; | ||
| 2169 | |||
| 2170 | local_frame = XCAR (XCDR (XCDR (XCDR (local_selection)))); | ||
| 2171 | if (FRAME_LIVE_P (XFRAME (local_frame))) | ||
| 2172 | x_clipboard_manager_save (dpyinfo, local_frame); | ||
| 2173 | } | ||
| 2174 | } | ||
| 2175 | 2172 | ||
| 2176 | return Qnil; | 2173 | local_frame = XCAR (XCDR (XCDR (XCDR (local_selection)))); |
| 2174 | if (FRAME_LIVE_P (XFRAME (local_frame))) | ||
| 2175 | x_clipboard_manager_save (dpyinfo, local_frame); | ||
| 2176 | } | ||
| 2177 | } | 2177 | } |
| 2178 | 2178 | ||
| 2179 | 2179 | ||
| @@ -2586,7 +2586,6 @@ syms_of_xselect (void) | |||
| 2586 | defsubr (&Sx_disown_selection_internal); | 2586 | defsubr (&Sx_disown_selection_internal); |
| 2587 | defsubr (&Sx_selection_owner_p); | 2587 | defsubr (&Sx_selection_owner_p); |
| 2588 | defsubr (&Sx_selection_exists_p); | 2588 | defsubr (&Sx_selection_exists_p); |
| 2589 | defsubr (&Sx_clipboard_manager_save); | ||
| 2590 | 2589 | ||
| 2591 | defsubr (&Sx_get_atom_name); | 2590 | defsubr (&Sx_get_atom_name); |
| 2592 | defsubr (&Sx_send_client_message); | 2591 | defsubr (&Sx_send_client_message); |
diff --git a/src/xterm.h b/src/xterm.h index c44978d5386..2184794af4e 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -1024,6 +1024,7 @@ extern Lisp_Object x_property_data_to_lisp (struct frame *, | |||
| 1024 | Atom, | 1024 | Atom, |
| 1025 | int, | 1025 | int, |
| 1026 | unsigned long); | 1026 | unsigned long); |
| 1027 | extern void x_clipboard_manager_save_frame (Lisp_Object); | ||
| 1027 | 1028 | ||
| 1028 | /* Defined in xfns.c */ | 1029 | /* Defined in xfns.c */ |
| 1029 | 1030 | ||