aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuhiro Ito2025-02-23 22:47:00 +0900
committerEli Zaretskii2025-03-06 16:04:51 +0200
commit64b3ad5c763ed3d2a9978fce06c0ccbdd085fe35 (patch)
tree60d07b2c75d335c05ed46b44aeaadebd93ffd36b
parente856e031b77f25957f09d42dc0fa9214c751a54d (diff)
downloademacs-64b3ad5c763ed3d2a9978fce06c0ccbdd085fe35.tar.gz
emacs-64b3ad5c763ed3d2a9978fce06c0ccbdd085fe35.zip
Avoid defining unneeded variables on Cygw32
lisp/term/w32-win.el contained definitions of variables which were not used on Cygw32. It is now to split into two files, common part and Windows native build specific part. The latter is a new file, lisp/term/w32-nt.el. * src/image.c (Qlibpng_version, Qlibgif_version) (Qlibjpeg_version): Don't define on Cygw32 build. * src/treesit.c (Qtree_sitter__library_abi): Ditto. * lisp/term/w32-win.el (dynamic-library-alist, libpng-version) (libgif-version, libjpeg-version, libgnutls-version) (tree-sitter--library-abi, gui-backend-set-selection) (gui-backend-get-selection, gui-backend-selection-owner-p) (gui-selection-exists-p): Moved to lisp/term/w32-nt.el. * lisp/term/w32-nt.el: New file, separated Windows native build specific part from lisp/term/w32-win.el. * lisp/loadup.el: Load term/w32-nt.el on Windows native build. (Bug#75926)
-rw-r--r--lisp/loadup.el1
-rw-r--r--lisp/term/w32-nt.el153
-rw-r--r--lisp/term/w32-win.el108
-rw-r--r--src/image.c2
-rw-r--r--src/treesit.c2
5 files changed, 156 insertions, 110 deletions
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 9089da9a988..3e87f4811df 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -332,6 +332,7 @@
332 (load "term/w32-win") 332 (load "term/w32-win")
333 (load "disp-table") 333 (load "disp-table")
334 (when (eq system-type 'windows-nt) 334 (when (eq system-type 'windows-nt)
335 (load "term/w32-nt")
335 (load "w32-fns") 336 (load "w32-fns")
336 (load "ls-lisp") 337 (load "ls-lisp")
337 (load "dos-w32")) 338 (load "dos-w32"))
diff --git a/lisp/term/w32-nt.el b/lisp/term/w32-nt.el
new file mode 100644
index 00000000000..7ff9472839d
--- /dev/null
+++ b/lisp/term/w32-nt.el
@@ -0,0 +1,153 @@
1;;; w32-nt.el --- MS-Windows native build specific definitions -*- lexical-binding: t -*-
2
3;; Copyright (C) 1993-1994, 2001-2025 Free Software Foundation, Inc.
4
5;; Author: FSF
6;; Keywords: terminals
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
22
23;;; Commentary:
24
25;; w32-nt.el: this file contains MS-Windows native build specific
26;; definitions formerly included in w32-win.el.
27
28;;; Code:
29
30
31(eval-when-compile (require 'cl-lib))
32
33
34(defvar dynamic-library-alist)
35(defvar libpng-version) ; image.c #ifdef HAVE_NTGUI
36(defvar libgif-version)
37(defvar libjpeg-version)
38
39(defvar libgnutls-version) ; gnutls.c
40
41(defvar tree-sitter--library-abi) ; treesit.c
42
43;;; Set default known names for external libraries
44(setq dynamic-library-alist
45 (list
46 '(gdiplus "gdiplus.dll")
47 '(shlwapi "shlwapi.dll")
48 '(xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll")
49 ;; Versions of libpng 1.4.x and later are incompatible with
50 ;; earlier versions. Set up the list of libraries according to
51 ;; the version we were compiled against. (If we were compiled
52 ;; without PNG support, libpng-version's value is -1.)
53 (if (>= libpng-version 10400)
54 (let ((major (/ libpng-version 10000))
55 (minor (mod (/ libpng-version 100) 10)))
56 (list 'png
57 ;; libpngXY.dll is the default name when building
58 ;; with CMake or from a lpngXYY tarball on w32,
59 ;; libpngXY-XY.dll is the DLL name when building
60 ;; with libtool / autotools
61 (format "libpng%d%d.dll" major minor)
62 (format "libpng%d%d-%d%d.dll" major minor major minor)))
63 '(png "libpng12d.dll" "libpng12.dll" "libpng3.dll" "libpng.dll"
64 ;; these are libpng 1.2.8 from GTK+
65 "libpng13d.dll" "libpng13.dll"))
66 '(tiff "libtiff-5.dll" "libtiff3.dll" "libtiff.dll")
67 (if (> libjpeg-version 62)
68 ;; Versions of libjpeg after 6b are incompatible with
69 ;; earlier versions, and each of versions 7, 8, and 9 is
70 ;; also incompatible with the preceding ones (the core data
71 ;; structures used for communications with the library
72 ;; gained additional members with each new version). So we
73 ;; must use only the version of the library which Emacs was
74 ;; compiled against.
75 (list 'jpeg (format "libjpeg-%d.dll" (/ libjpeg-version 10)))
76 '(jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll"))
77 ;; Versions of giflib 5.0.0 and later changed signatures of
78 ;; several functions used by Emacs, which makes those versions
79 ;; incompatible with previous ones. We select the correct
80 ;; libraries according to the version of giflib we were
81 ;; compiled against. (If we were compiled without GIF support,
82 ;; libgif-version's value is -1.)
83 (if (>= libgif-version 50100)
84 ;; Yes, giflib 5.0 uses 6 as the major version of the API,
85 ;; and giflib 5.1 uses 7, thus "libgif-7.dll" and
86 ;; "libgif-6.dll" below (giflib 4.x used 5 as the major API
87 ;; version). giflib5.dll is from the lua-files project,
88 ;; and gif.dll is from luapower.
89 '(gif "libgif-7.dll")
90 (if (>= libgif-version 50000)
91 '(gif "libgif-6.dll" "giflib5.dll" "gif.dll")
92 '(gif "libgif-5.dll" "giflib4.dll" "libungif4.dll" "libungif.dll")))
93 '(svg "librsvg-2-2.dll")
94 '(webp "libwebp-7.dll" "libwebp.dll")
95 '(webpdemux "libwebpdemux-2.dll" "libwebpdemux.dll")
96 '(sqlite3 "libsqlite3-0.dll")
97 '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
98 '(glib "libglib-2.0-0.dll")
99 '(gio "libgio-2.0-0.dll")
100 '(gobject "libgobject-2.0-0.dll")
101 (if (>= libgnutls-version 30400)
102 '(gnutls "libgnutls-30.dll")
103 '(gnutls "libgnutls-28.dll" "libgnutls-26.dll"))
104 '(libxml2 "libxml2-2.dll" "libxml2.dll")
105 '(zlib "zlib1.dll" "libz-1.dll")
106 '(lcms2 "liblcms2-2.dll")
107 '(gccjit "libgccjit-0.dll")
108 ;; MSYS2 distributes libtree-sitter.dll, without API version
109 ;; number, upto and including version 0.24.3-2; later versions
110 ;; come with libtree-sitter-major.minor.dll (as in
111 ;; libtree-sitter-0.24.dll). Sadly, the header files don't have
112 ;; any symbols for library version, so we can only use the
113 ;; library-language ABI version; according to
114 ;; https://github.com/tree-sitter/tree-sitter/issues/3925, the
115 ;; language ABI must change when the library's ABI is modified.
116 (if (<= tree-sitter--library-abi 14)
117 '(tree-sitter "libtree-sitter-0.24.dll"
118 "libtree-sitter.dll"
119 "libtree-sitter-0.dll")
120 '(tree-sitter "libtree-sitter-0.25.dll"))))
121
122
123;;;; Selections
124
125(declare-function w32--set-selection "w32-win.el")
126
127(declare-function w32--get-selection "w32-win.el")
128
129(declare-function w32--selection-owner-p "w32-win.el")
130
131(declare-function w32-selection-exists-p "w32select.c"
132 (&optional selection terminal))
133
134;; Make copy&pasting in w32's console interact with the system's clipboard!
135(cl-defmethod gui-backend-set-selection (type value
136 &context (window-system nil))
137 (w32--set-selection type value))
138
139(cl-defmethod gui-backend-get-selection (type data-type
140 &context (window-system nil))
141 (w32--get-selection type data-type))
142
143(cl-defmethod gui-backend-selection-owner-p (selection
144 &context (window-system nil))
145 (w32--selection-owner-p selection))
146
147(cl-defmethod gui-selection-exists-p (selection
148 &context (window-system nil))
149 (w32-selection-exists-p selection))
150
151(provide 'term/w32-nt)
152
153;;; w32-nt.el ends here
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index af53345a377..fa7862d9bff 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -240,94 +240,6 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
240 "Report an error when a suspend is attempted." 240 "Report an error when a suspend is attempted."
241 (error "Suspending an Emacs running under W32 makes no sense")) 241 (error "Suspending an Emacs running under W32 makes no sense"))
242 242
243(defvar dynamic-library-alist)
244(defvar libpng-version) ; image.c #ifdef HAVE_NTGUI
245(defvar libgif-version)
246(defvar libjpeg-version)
247
248(defvar libgnutls-version) ; gnutls.c
249
250(defvar tree-sitter--library-abi) ; treesit.c
251
252;;; Set default known names for external libraries
253(setq dynamic-library-alist
254 (list
255 '(gdiplus "gdiplus.dll")
256 '(shlwapi "shlwapi.dll")
257 '(xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll")
258 ;; Versions of libpng 1.4.x and later are incompatible with
259 ;; earlier versions. Set up the list of libraries according to
260 ;; the version we were compiled against. (If we were compiled
261 ;; without PNG support, libpng-version's value is -1.)
262 (if (>= libpng-version 10400)
263 (let ((major (/ libpng-version 10000))
264 (minor (mod (/ libpng-version 100) 10)))
265 (list 'png
266 ;; libpngXY.dll is the default name when building
267 ;; with CMake or from a lpngXYY tarball on w32,
268 ;; libpngXY-XY.dll is the DLL name when building
269 ;; with libtool / autotools
270 (format "libpng%d%d.dll" major minor)
271 (format "libpng%d%d-%d%d.dll" major minor major minor)))
272 '(png "libpng12d.dll" "libpng12.dll" "libpng3.dll" "libpng.dll"
273 ;; these are libpng 1.2.8 from GTK+
274 "libpng13d.dll" "libpng13.dll"))
275 '(tiff "libtiff-5.dll" "libtiff3.dll" "libtiff.dll")
276 (if (> libjpeg-version 62)
277 ;; Versions of libjpeg after 6b are incompatible with
278 ;; earlier versions, and each of versions 7, 8, and 9 is
279 ;; also incompatible with the preceding ones (the core data
280 ;; structures used for communications with the library
281 ;; gained additional members with each new version). So we
282 ;; must use only the version of the library which Emacs was
283 ;; compiled against.
284 (list 'jpeg (format "libjpeg-%d.dll" (/ libjpeg-version 10)))
285 '(jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll"))
286 ;; Versions of giflib 5.0.0 and later changed signatures of
287 ;; several functions used by Emacs, which makes those versions
288 ;; incompatible with previous ones. We select the correct
289 ;; libraries according to the version of giflib we were
290 ;; compiled against. (If we were compiled without GIF support,
291 ;; libgif-version's value is -1.)
292 (if (>= libgif-version 50100)
293 ;; Yes, giflib 5.0 uses 6 as the major version of the API,
294 ;; and giflib 5.1 uses 7, thus "libgif-7.dll" and
295 ;; "libgif-6.dll" below (giflib 4.x used 5 as the major API
296 ;; version). giflib5.dll is from the lua-files project,
297 ;; and gif.dll is from luapower.
298 '(gif "libgif-7.dll")
299 (if (>= libgif-version 50000)
300 '(gif "libgif-6.dll" "giflib5.dll" "gif.dll")
301 '(gif "libgif-5.dll" "giflib4.dll" "libungif4.dll" "libungif.dll")))
302 '(svg "librsvg-2-2.dll")
303 '(webp "libwebp-7.dll" "libwebp.dll")
304 '(webpdemux "libwebpdemux-2.dll" "libwebpdemux.dll")
305 '(sqlite3 "libsqlite3-0.dll")
306 '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
307 '(glib "libglib-2.0-0.dll")
308 '(gio "libgio-2.0-0.dll")
309 '(gobject "libgobject-2.0-0.dll")
310 (if (>= libgnutls-version 30400)
311 '(gnutls "libgnutls-30.dll")
312 '(gnutls "libgnutls-28.dll" "libgnutls-26.dll"))
313 '(libxml2 "libxml2-2.dll" "libxml2.dll")
314 '(zlib "zlib1.dll" "libz-1.dll")
315 '(lcms2 "liblcms2-2.dll")
316 '(gccjit "libgccjit-0.dll")
317 ;; MSYS2 distributes libtree-sitter.dll, without API version
318 ;; number, upto and including version 0.24.3-2; later versions
319 ;; come with libtree-sitter-major.minor.dll (as in
320 ;; libtree-sitter-0.24.dll). Sadly, the header files don't have
321 ;; any symbols for library version, so we can only use the
322 ;; library-language ABI version; according to
323 ;; https://github.com/tree-sitter/tree-sitter/issues/3925, the
324 ;; language ABI must change when the library's ABI is modified.
325 (if (<= tree-sitter--library-abi 14)
326 '(tree-sitter "libtree-sitter-0.24.dll"
327 "libtree-sitter.dll"
328 "libtree-sitter-0.dll")
329 '(tree-sitter "libtree-sitter-0.25.dll"))))
330
331;;; multi-tty support 243;;; multi-tty support
332(defvar w32-initialized nil 244(defvar w32-initialized nil
333 "Non-nil if the w32 window system has been initialized.") 245 "Non-nil if the w32 window system has been initialized.")
@@ -554,26 +466,6 @@ also be textual."
554 &context (window-system w32)) 466 &context (window-system w32))
555 (w32-selection-exists-p selection)) 467 (w32-selection-exists-p selection))
556 468
557(when (eq system-type 'windows-nt)
558 ;; Make copy&pasting in w32's console interact with the system's clipboard!
559 ;; We could move those cl-defmethods outside of the `when' and use
560 ;; "&context (system-type (eql windows-nt))" instead!
561 (cl-defmethod gui-backend-set-selection (type value
562 &context (window-system nil))
563 (w32--set-selection type value))
564
565 (cl-defmethod gui-backend-get-selection (type data-type
566 &context (window-system nil))
567 (w32--get-selection type data-type))
568
569 (cl-defmethod gui-backend-selection-owner-p (selection
570 &context (window-system nil))
571 (w32--selection-owner-p selection))
572
573 (cl-defmethod gui-selection-exists-p (selection
574 &context (window-system nil))
575 (w32-selection-exists-p selection)))
576
577;; The "Windows" keys on newer keyboards bring up the Start menu 469;; The "Windows" keys on newer keyboards bring up the Start menu
578;; whether you want it or not - make Emacs ignore these keystrokes 470;; whether you want it or not - make Emacs ignore these keystrokes
579;; rather than beep. 471;; rather than beep.
diff --git a/src/image.c b/src/image.c
index b051e4ca796..65d8db24adc 100644
--- a/src/image.c
+++ b/src/image.c
@@ -13003,7 +13003,7 @@ non-numeric, there is no explicit limit on the size of images. */);
13003 DEFSYM (Qgs_load_image, "gs-load-image"); 13003 DEFSYM (Qgs_load_image, "gs-load-image");
13004#endif /* HAVE_GHOSTSCRIPT */ 13004#endif /* HAVE_GHOSTSCRIPT */
13005 13005
13006#ifdef HAVE_NTGUI 13006#ifdef WINDOWSNT
13007 /* Versions of libpng, libgif, and libjpeg that we were compiled with, 13007 /* Versions of libpng, libgif, and libjpeg that we were compiled with,
13008 or -1 if no PNG/GIF support was compiled in. This is tested by 13008 or -1 if no PNG/GIF support was compiled in. This is tested by
13009 w32-win.el to correctly set up the alist used to search for the 13009 w32-win.el to correctly set up the alist used to search for the
diff --git a/src/treesit.c b/src/treesit.c
index 585be9efe29..9622addd09b 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -4683,7 +4683,7 @@ applies to LANGUAGE-A will be redirected to LANGUAGE-B instead. */);
4683 defsubr (&Streesit_subtree_stat); 4683 defsubr (&Streesit_subtree_stat);
4684#endif /* HAVE_TREE_SITTER */ 4684#endif /* HAVE_TREE_SITTER */
4685 defsubr (&Streesit_available_p); 4685 defsubr (&Streesit_available_p);
4686#ifdef HAVE_NTGUI 4686#ifdef WINDOWSNT
4687 DEFSYM (Qtree_sitter__library_abi, "tree-sitter--library-abi"); 4687 DEFSYM (Qtree_sitter__library_abi, "tree-sitter--library-abi");
4688 Fset (Qtree_sitter__library_abi, 4688 Fset (Qtree_sitter__library_abi,
4689#if HAVE_TREE_SITTER 4689#if HAVE_TREE_SITTER