* [PATCH] window-system-version function
@ 2011-11-15 16:29 Dmitry Antipov
2011-11-20 19:41 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Antipov @ 2011-11-15 16:29 UTC (permalink / raw
To: emacs-devel
[-- 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;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] window-system-version function
2011-11-15 16:29 [PATCH] window-system-version function Dmitry Antipov
@ 2011-11-20 19:41 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2011-11-20 19:41 UTC (permalink / raw
To: Dmitry Antipov; +Cc: emacs-devel
> 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.
Sounds OK, tho it will have to wait for 24.2.
> P.S. Are there the reasons to have both 'window-system' variable and function
> (except the possible backward compatibility with an old Lisp code)?
Backward compatibility: the window-system variable is used in a lot of
Elisp packages, and many more ~/.emacs files, so we're probably stuck
with it for the foreseeable future.
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-20 19:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-15 16:29 [PATCH] window-system-version function Dmitry Antipov
2011-11-20 19:41 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.