summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2011-05-28 20:45:00 -0400
committerChong Yidong <cyd@stupidchicken.com>2011-05-28 20:45:00 -0400
commit1dd3c2d9b2466eb6dc379da6a67074dbd4c13fa5 (patch)
treea812814e376414db37827f4298e375ff868ecdaf
parent8e6ca83dfede41bbc8d060a4aaa72f2a414f59ae (diff)
downloademacs-1dd3c2d9b2466eb6dc379da6a67074dbd4c13fa5.tar.gz
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/NEWS4
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/select.el4
-rw-r--r--src/ChangeLog11
-rw-r--r--src/emacs.c10
-rw-r--r--src/frame.c9
-rw-r--r--src/xselect.c87
-rw-r--r--src/xterm.h1
8 files changed, 82 insertions, 49 deletions
diff --git a/etc/NEWS b/etc/NEWS
index e49b3d34c40..dc1f25ddd3b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -177,6 +177,8 @@ with Xft. To change font, use the X resource font, for example:
Emacs.pane.menubar.font: Courier-12
** On graphical displays, the mode-line no longer ends in dashes.
+Also, the first dash (which does not indicate anything) is just
+displayed as a space.
** On Nextstep/OSX, the menu bar can be hidden by customizing
ns-auto-hide-menu-bar.
@@ -386,6 +388,8 @@ between applications.
*** Support for X cut buffers has been removed.
+*** Support for X clipboard managers has been added.
+
** New command `rectangle-number-lines', bound to `C-x r N', numbers
the lines in the current rectangle. With an prefix argument, this
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 @@
+2011-05-29 Chong Yidong <cyd@stupidchicken.com>
+
+ * select.el: Don't perform clipboard-manager saving in hooks;
+ leave the hooks empty.
+
2011-05-28 Leo Liu <sdl.web@gmail.com>
* 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\"."
(SAVE_TARGETS . xselect-convert-to-save-targets)
(_EMACS_INTERNAL . xselect-convert-to-identity)))
-(when (fboundp 'x-clipboard-manager-save)
- (add-hook 'delete-frame-functions 'x-clipboard-manager-save)
- (add-hook 'kill-emacs-hook 'x-clipboard-manager-save))
-
(provide 'select)
;;; 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 @@
+2011-05-29 Chong Yidong <cyd@stupidchicken.com>
+
+ * xselect.c (x_clipboard_manager_save_frame)
+ (x_clipboard_manager_save_all): New functions.
+ (Fx_clipboard_manager_save): Lisp function deleted.
+
+ * emacs.c (Fkill_emacs): Call x_clipboard_manager_save_all.
+ * frame.c (delete_frame): Call x_clipboard_manager_save_frame.
+
+ * xterm.h: Update prototype.
+
2011-05-28 William Xu <william.xwl@gmail.com>
* 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)
xfree (priority);
}
+#ifdef HAVE_X_WINDOWS
+/* Defined in xselect.c. */
+extern void x_clipboard_manager_save_all (void);
+#endif
+
DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
doc: /* Exit the Emacs job and kill it.
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. */)
UNGCPRO;
+#ifdef HAVE_X_WINDOWS
+ /* Transfer any clipboards we own to the clipboard manager. */
+ x_clipboard_manager_save_all ();
+#endif
+
shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil);
/* 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)
= Fcons (list3 (Qrun_hook_with_args, Qdelete_frame_functions, frame),
pending_funcalls);
else
- safe_call2 (Qrun_hook_with_args, Qdelete_frame_functions, frame);
+ {
+#ifdef HAVE_X_WINDOWS
+ /* Also, save clipboard to the the clipboard manager. */
+ x_clipboard_manager_save_frame (frame);
+#endif
+
+ safe_call2 (Qrun_hook_with_args, Qdelete_frame_functions, frame);
+ }
/* The hook may sometimes (indirectly) cause the frame to be deleted. */
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. */)
return (owner ? Qt : Qnil);
}
+
/* Send the clipboard manager a SAVE_TARGETS request with a
UTF8_STRING property, as described by
http://www.freedesktop.org/wiki/ClipboardManager */
@@ -2126,54 +2127,53 @@ x_clipboard_manager_save (struct x_display_info *dpyinfo,
Qnil, frame);
}
-DEFUN ("x-clipboard-manager-save", Fx_clipboard_manager_save,
- Sx_clipboard_manager_save, 0, 1, 0,
- doc: /* Save the clipboard contents to the clipboard manager.
-This function is intended to run from `delete-frame-functions' and
-`kill-emacs-hook', to transfer clipboard data owned by Emacs to a
-clipboard manager prior to deleting a frame or killing Emacs.
-
-FRAME specifies a frame owning a clipboard; do nothing if FRAME does
-not own the clipboard, or if no clipboard manager is present. If
-FRAME is nil, save all clipboard contents owned by Emacs. */)
- (Lisp_Object frame)
+/* Called from delete_frame: save any clipboard owned by FRAME to the
+ clipboard manager. Do nothing if FRAME does not own the clipboard,
+ or if no clipboard manager is present. */
+
+void
+x_clipboard_manager_save_frame (Lisp_Object frame)
{
- if (FRAMEP (frame))
+ struct frame *f;
+
+ if (FRAMEP (frame)
+ && (f = XFRAME (frame), FRAME_X_P (f))
+ && FRAME_LIVE_P (f))
{
- struct frame *f = XFRAME (frame);
- if (FRAME_LIVE_P (f) && FRAME_X_P (f))
- {
- struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
- Lisp_Object local_selection
- = LOCAL_SELECTION (QCLIPBOARD, dpyinfo);
-
- if (!NILP (local_selection)
- && EQ (frame, XCAR (XCDR (XCDR (XCDR (local_selection)))))
- && XGetSelectionOwner (dpyinfo->display,
- dpyinfo->Xatom_CLIPBOARD_MANAGER))
- x_clipboard_manager_save (dpyinfo, frame);
- }
+ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+ Lisp_Object local_selection
+ = LOCAL_SELECTION (QCLIPBOARD, dpyinfo);
+
+ if (!NILP (local_selection)
+ && EQ (frame, XCAR (XCDR (XCDR (XCDR (local_selection)))))
+ && XGetSelectionOwner (dpyinfo->display,
+ dpyinfo->Xatom_CLIPBOARD_MANAGER))
+ x_clipboard_manager_save (dpyinfo, frame);
}
- else if (NILP (frame))
+}
+
+/* Called from Fkill_emacs: save any clipboard owned by FRAME to the
+ clipboard manager. Do nothing if FRAME does not own the clipboard,
+ or if no clipboard manager is present. */
+
+void
+x_clipboard_manager_save_all (void)
+{
+ /* Loop through all X displays, saving owned clipboards. */
+ struct x_display_info *dpyinfo;
+ Lisp_Object local_selection, local_frame;
+ for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
{
- /* Loop through all X displays, saving owned clipboards. */
- struct x_display_info *dpyinfo;
- Lisp_Object local_selection, local_frame;
- for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
- {
- local_selection = LOCAL_SELECTION (QCLIPBOARD, dpyinfo);
- if (NILP (local_selection)
- || !XGetSelectionOwner (dpyinfo->display,
- dpyinfo->Xatom_CLIPBOARD_MANAGER))
- continue;
-
- local_frame = XCAR (XCDR (XCDR (XCDR (local_selection))));
- if (FRAME_LIVE_P (XFRAME (local_frame)))
- x_clipboard_manager_save (dpyinfo, local_frame);
- }
- }
+ local_selection = LOCAL_SELECTION (QCLIPBOARD, dpyinfo);
+ if (NILP (local_selection)
+ || !XGetSelectionOwner (dpyinfo->display,
+ dpyinfo->Xatom_CLIPBOARD_MANAGER))
+ continue;
- return Qnil;
+ local_frame = XCAR (XCDR (XCDR (XCDR (local_selection))));
+ if (FRAME_LIVE_P (XFRAME (local_frame)))
+ x_clipboard_manager_save (dpyinfo, local_frame);
+ }
}
@@ -2586,7 +2586,6 @@ syms_of_xselect (void)
defsubr (&Sx_disown_selection_internal);
defsubr (&Sx_selection_owner_p);
defsubr (&Sx_selection_exists_p);
- defsubr (&Sx_clipboard_manager_save);
defsubr (&Sx_get_atom_name);
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 *,
Atom,
int,
unsigned long);
+extern void x_clipboard_manager_save_frame (Lisp_Object);
/* Defined in xfns.c */