aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorDaniel Colascione2012-09-17 03:55:04 -0800
committerDaniel Colascione2012-09-17 03:55:04 -0800
commit6b59694eac33d4733bfd5f1e656ff8a23d7808ec (patch)
tree1b152f359c1598a166e5dc385710b7f72679cc57 /lib-src
parent5e0944c6f072cc1b9304b7369bf61091ffd23ea7 (diff)
downloademacs-6b59694eac33d4733bfd5f1e656ff8a23d7808ec.tar.gz
emacs-6b59694eac33d4733bfd5f1e656ff8a23d7808ec.zip
Add alt_display to emacsclient for w32, ns
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/emacsclient.c127
1 files changed, 78 insertions, 49 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 103473abdb1..9c222b6be66 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -144,6 +144,9 @@ int current_frame = 1;
144/* The display on which Emacs should work. --display. */ 144/* The display on which Emacs should work. --display. */
145const char *display = NULL; 145const char *display = NULL;
146 146
147/* The alternate display we should try if Emacs does not support display. */
148const char *alt_display = NULL;
149
147/* The parent window ID, if we are opening a frame via XEmbed. */ 150/* The parent window ID, if we are opening a frame via XEmbed. */
148char *parent_id = NULL; 151char *parent_id = NULL;
149 152
@@ -581,16 +584,29 @@ decode_options (int argc, char **argv)
581 Without the -c option, we used to set `display' to $DISPLAY by 584 Without the -c option, we used to set `display' to $DISPLAY by
582 default, but this changed the default behavior and is sometimes 585 default, but this changed the default behavior and is sometimes
583 inconvenient. So we force users to use "--display $DISPLAY" if 586 inconvenient. So we force users to use "--display $DISPLAY" if
584 they want Emacs to connect to their current display. */ 587 they want Emacs to connect to their current display.
588
589 Some window systems have a notion of default display not
590 reflected in the DISPLAY variable. If the user didn't give us an
591 explicit display, try this platform-specific after trying the
592 display in DISPLAY (if any). */
585 if (!current_frame && !tty && !display) 593 if (!current_frame && !tty && !display)
586 { 594 {
587 display = egetenv ("DISPLAY"); 595 /* Set these here so we use a default_display only when the user
588#ifdef NS_IMPL_COCOA 596 didn't give us an explicit display. */
589 /* Under Cocoa, we don't really use displays the same way as in X, 597#if defined (NS_IMPL_COCOA)
590 so provide a dummy. */ 598 alt_display = "ns";
591 if (!display || strlen (display) == 0) 599#elif defined (HAVE_NTGUI)
592 display = "ns"; 600 alt_display = "windows";
593#endif 601#endif
602
603 display = egetenv ("DISPLAY");
604 }
605
606 if (!display)
607 {
608 display = alt_display;
609 alt_display = NULL;
594 } 610 }
595 611
596 /* A null-string display is invalid. */ 612 /* A null-string display is invalid. */
@@ -1541,8 +1557,10 @@ main (int argc, char **argv)
1541 progname = argv[0]; 1557 progname = argv[0];
1542 1558
1543#ifdef HAVE_NTGUI 1559#ifdef HAVE_NTGUI
1544 /* On Windows 7 and later, we need to explicitly associate emacsclient 1560 /* On Windows 7 and later, we need to explicitly associate
1545 with emacs so the UI behaves sensibly. */ 1561 emacsclient with emacs so the UI behaves sensibly. This
1562 association does no harm if we're not actually connecting to an
1563 Emacs using a window display. */
1546 w32_set_user_model_id (); 1564 w32_set_user_model_id ();
1547#endif /* HAVE_NTGUI */ 1565#endif /* HAVE_NTGUI */
1548 1566
@@ -1581,6 +1599,7 @@ main (int argc, char **argv)
1581 } 1599 }
1582 1600
1583#ifdef HAVE_NTGUI 1601#ifdef HAVE_NTGUI
1602 if (display && !strcmp (display, "windows"))
1584 w32_give_focus (); 1603 w32_give_focus ();
1585#endif /* HAVE_NTGUI */ 1604#endif /* HAVE_NTGUI */
1586 1605
@@ -1751,46 +1770,56 @@ main (int argc, char **argv)
1751 if (end_p != NULL) 1770 if (end_p != NULL)
1752 *end_p++ = '\0'; 1771 *end_p++ = '\0';
1753 1772
1754 if (strprefix ("-emacs-pid ", p)) 1773 if (strprefix ("-emacs-pid ", p))
1755 { 1774 {
1756 /* -emacs-pid PID: The process id of the Emacs process. */ 1775 /* -emacs-pid PID: The process id of the Emacs process. */
1757 emacs_pid = strtol (p + strlen ("-emacs-pid"), NULL, 10); 1776 emacs_pid = strtol (p + strlen ("-emacs-pid"), NULL, 10);
1758 } 1777 }
1759 else if (strprefix ("-window-system-unsupported ", p)) 1778 else if (strprefix ("-window-system-unsupported ", p))
1760 { 1779 {
1761 /* -window-system-unsupported: Emacs was compiled without X 1780 /* -window-system-unsupported: Emacs was compiled without support
1762 support. Try again on the terminal. */ 1781 for whatever window system we tried. Try the alternate
1763 nowait = 0; 1782 display, or, failing that, try the terminal. */
1764 tty = 1; 1783 if (alt_display)
1765 goto retry; 1784 {
1766 } 1785 display = alt_display;
1767 else if (strprefix ("-print ", p)) 1786 alt_display = NULL;
1768 { 1787 }
1769 /* -print STRING: Print STRING on the terminal. */ 1788 else
1770 str = unquote_argument (p + strlen ("-print ")); 1789 {
1771 if (needlf) 1790 nowait = 0;
1772 printf ("\n"); 1791 tty = 1;
1773 printf ("%s", str); 1792 }
1774 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1793
1775 } 1794 goto retry;
1776 else if (strprefix ("-print-nonl ", p)) 1795 }
1777 { 1796 else if (strprefix ("-print ", p))
1778 /* -print-nonl STRING: Print STRING on the terminal. 1797 {
1779 Used to continue a preceding -print command. */ 1798 /* -print STRING: Print STRING on the terminal. */
1780 str = unquote_argument (p + strlen ("-print-nonl ")); 1799 str = unquote_argument (p + strlen ("-print "));
1781 printf ("%s", str); 1800 if (needlf)
1782 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1801 printf ("\n");
1783 } 1802 printf ("%s", str);
1784 else if (strprefix ("-error ", p)) 1803 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1785 { 1804 }
1786 /* -error DESCRIPTION: Signal an error on the terminal. */ 1805 else if (strprefix ("-print-nonl ", p))
1787 str = unquote_argument (p + strlen ("-error ")); 1806 {
1788 if (needlf) 1807 /* -print-nonl STRING: Print STRING on the terminal.
1789 printf ("\n"); 1808 Used to continue a preceding -print command. */
1790 fprintf (stderr, "*ERROR*: %s", str); 1809 str = unquote_argument (p + strlen ("-print-nonl "));
1791 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1810 printf ("%s", str);
1792 exit_status = EXIT_FAILURE; 1811 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1793 } 1812 }
1813 else if (strprefix ("-error ", p))
1814 {
1815 /* -error DESCRIPTION: Signal an error on the terminal. */
1816 str = unquote_argument (p + strlen ("-error "));
1817 if (needlf)
1818 printf ("\n");
1819 fprintf (stderr, "*ERROR*: %s", str);
1820 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1821 exit_status = EXIT_FAILURE;
1822 }
1794#ifdef SIGSTOP 1823#ifdef SIGSTOP
1795 else if (strprefix ("-suspend ", p)) 1824 else if (strprefix ("-suspend ", p))
1796 { 1825 {