unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Antipov <dmantipov@yandex.ru>
To: emacs-devel@gnu.org
Subject: [PATCH] window-system-version function
Date: Tue, 15 Nov 2011 20:29:00 +0400	[thread overview]
Message-ID: <4EC2934C.1030206@yandex.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 400 bytes --]

This patch replaces global variable 'window-system-version' with the function
which returns the window system version for the specified frame. I believe
this is more reasonable, at least for the configuration which allows both
TTY and X frames.

Dmitry

P.S. Are there the reasons to have both 'window-system' variable and function
(except the possible backward compatibility with an old Lisp code)?

[-- Attachment #2: window_system_version.patch --]
[-- Type: text/plain, Size: 6142 bytes --]

=== modified file 'lisp/international/mule-diag.el'
--- lisp/international/mule-diag.el	2011-11-14 06:27:12 +0000
+++ lisp/international/mule-diag.el	2011-11-15 14:45:06 +0000
@@ -1105,7 +1105,7 @@
       (insert-section 2 "Display")
       (if window-system
 	  (insert (format "Window-system: %s, version %s"
-			  window-system window-system-version))
+			  window-system (window-system-version)))
 	(insert "Terminal: " (getenv "TERM")))
       (insert "\n\n")
 

=== modified file 'lisp/textmodes/artist.el'
--- lisp/textmodes/artist.el	2011-11-14 23:59:56 +0000
+++ lisp/textmodes/artist.el	2011-11-15 15:40:31 +0000
@@ -5384,20 +5384,22 @@
   (interactive)
   (require 'reporter)
   (if (y-or-n-p "Do you want to submit a bug report on Artist? ")
-      (let ((to   artist-maintainer-address)
-	    (vars '(window-system
-		    window-system-version
-		    ;;
-		    artist-rubber-banding
-		    artist-interface-with-rect
-		    artist-aspect-ratio
-		    ;; Now the internal ones
-		    artist-curr-go
-		    artist-key-poly-point-list
-		    artist-key-shape
-		    artist-key-draw-how
-		    artist-arrow-point-1
-		    artist-arrow-point-2)))
+      (let* ((to artist-maintainer-address)
+	     ;; backward compatibility hack
+	     (window-system-version (window-system-version))
+	     (vars '(window-system
+		     window-system-version
+		     ;;
+		     artist-rubber-banding
+		     artist-interface-with-rect
+		     artist-aspect-ratio
+		     ;; Now the internal ones
+		     artist-curr-go
+		     artist-key-poly-point-list
+		     artist-key-shape
+		     artist-key-draw-how
+		     artist-arrow-point-1
+		     artist-arrow-point-2)))
 	;; Remove those variables from vars that are not bound
 	(mapc
 	 (function

=== modified file 'src/dispnew.c'
--- src/dispnew.c	2011-11-12 11:56:57 +0000
+++ src/dispnew.c	2011-11-15 14:37:14 +0000
@@ -6223,9 +6223,6 @@
   if (!inhibit_window_system && display_arg)
     {
       Vinitial_window_system = Qx;
-#ifdef HAVE_X11
-      Vwindow_system_version = make_number (11);
-#endif
 #if defined (GNU_LINUX) && defined (HAVE_LIBNCURSES)
       /* In some versions of ncurses,
 	 tputs crashes if we have not called tgetent.
@@ -6241,7 +6238,6 @@
   if (!inhibit_window_system)
     {
       Vinitial_window_system = Qw32;
-      Vwindow_system_version = make_number (1);
       adjust_frame_glyphs_initially ();
       return;
     }
@@ -6255,7 +6251,6 @@
       )
     {
       Vinitial_window_system = Qns;
-      Vwindow_system_version = make_number (10);
       adjust_frame_glyphs_initially ();
       return;
     }
@@ -6497,10 +6492,6 @@
 use `display-graphic-p' or any of the other `display-*-p'
 predicates which report frame's specific UI-related capabilities.  */);
 
-  DEFVAR_LISP ("window-system-version", Vwindow_system_version,
-	       doc: /* The version number of the window system in use.
-For X windows, this is 11.  */);
-
   DEFVAR_BOOL ("cursor-in-echo-area", cursor_in_echo_area,
 	       doc: /* Non-nil means put cursor in minibuffer, at end of any message there.  */);
 
@@ -6535,8 +6526,5 @@
 #ifdef CANNOT_DUMP
   if (noninteractive)
 #endif
-    {
-      Vinitial_window_system = Qnil;
-      Vwindow_system_version = Qnil;
-    }
+    Vinitial_window_system = Qnil;
 }

=== modified file 'src/frame.c'
--- src/frame.c	2011-11-07 09:51:08 +0000
+++ src/frame.c	2011-11-15 16:14:31 +0000
@@ -256,6 +256,52 @@
     return type;
 }
 
+DEFUN ("window-system-version", Fwindow_system_version, Swindow_system_version, 0, 1, 0,
+       doc: /* The version of the window system that FRAME is displaying through.
+It's value is a number:
+ - 0 for a termcap frame,
+ - Major X protocol version for the frame on X display,
+ - Major OS version for the frame on MS-Windows display,
+ - 24 for the frame on direct-write MS-DOS display,
+ - 10 for the frame on a GNUstep or Macintosh Cocoa display.
+
+FRAME defaults to the currently selected frame.  */)
+     (Lisp_Object frame)
+{
+  struct frame *f;
+
+  if (NILP (frame))
+    frame = selected_frame;
+  CHECK_LIVE_FRAME (frame);
+  f = XFRAME (frame);
+
+  switch (f->output_method)
+    {
+    case output_initial:
+    case output_termcap:
+      return make_number (0);
+#ifdef HAVE_X_WINDOWS
+    case output_x_window:
+      return make_number (ProtocolVersion (FRAME_X_DISPLAY (f)));
+#endif
+#ifdef WINDOWSNT
+    case output_w32:
+      return make_number (w32_major_version);
+#endif
+#ifdef MSDOS
+    case output_msdos_raw:
+      return make_number (24);
+#endif
+#ifdef HAVE_NS
+    case output_mac:
+    case output_ns:
+      return make_number (10);
+#endif
+    default:
+      abort ();
+    }
+}
+
 struct frame *
 make_frame (int mini_p)
 {
@@ -4457,6 +4503,7 @@
   defsubr (&Sframep);
   defsubr (&Sframe_live_p);
   defsubr (&Swindow_system);
+  defsubr (&Swindow_system_version);
   defsubr (&Smake_terminal_frame);
   defsubr (&Shandle_switch_frame);
   defsubr (&Sselect_frame);

=== modified file 'src/msdos.c'
--- src/msdos.c	2011-09-09 01:06:52 +0000
+++ src/msdos.c	2011-11-15 14:37:27 +0000
@@ -1813,7 +1813,6 @@
 	}
 
       Vinitial_window_system = Qpc;
-      Vwindow_system_version = make_number (23); /* RE Emacs version */
       tty->terminal->type = output_msdos_raw;
 
       /* If Emacs was dumped on DOS/V machine, forget the stale VRAM

=== modified file 'src/w32fns.c'
--- src/w32fns.c	2011-11-14 23:59:56 +0000
+++ src/w32fns.c	2011-11-15 14:37:35 +0000
@@ -4724,7 +4724,6 @@
     error ("Cannot connect to server %s", SDATA (name));
 
   w32_in_use = 1;
-  XSETFASTINT (Vwindow_system_version, w32_major_version);
 
   return dpyinfo;
 }
@@ -4815,7 +4814,6 @@
 
   w32_in_use = 1;
 
-  XSETFASTINT (Vwindow_system_version, w32_major_version);
   return Qnil;
 }
 

=== modified file 'src/xfns.c'
--- src/xfns.c	2011-11-14 06:27:12 +0000
+++ src/xfns.c	2011-11-15 14:37:45 +0000
@@ -4035,7 +4035,6 @@
     error ("Cannot connect to X server %s", SDATA (name));
 
   x_in_use = 1;
-  XSETFASTINT (Vwindow_system_version, 11);
 
   return dpyinfo;
 }
@@ -4090,7 +4089,6 @@
 
   x_in_use = 1;
 
-  XSETFASTINT (Vwindow_system_version, 11);
   return Qnil;
 }
 


             reply	other threads:[~2011-11-15 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15 16:29 Dmitry Antipov [this message]
2011-11-20 19:41 ` [PATCH] window-system-version function Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EC2934C.1030206@yandex.ru \
    --to=dmantipov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).