aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2018-09-07 17:41:21 +0300
committerEli Zaretskii2018-09-07 17:41:21 +0300
commit752a05b17dfb1bfb27867f1cf3a7548dbb570d26 (patch)
treef487433532dac5062cd7834aa21582d02428605f
parent2c8520e19c0fe72d046033e39953b7a0a87be24e (diff)
downloademacs-752a05b17dfb1bfb27867f1cf3a7548dbb570d26.tar.gz
emacs-752a05b17dfb1bfb27867f1cf3a7548dbb570d26.zip
Read Windows OS info for report-emacs-bug from Registry
* lisp/w32-fns.el (w32--os-description): New function. * lisp/mail/emacsbug.el (report-emacs-bug--os-description): Use 'w32--os-description' instead of launching the 'systeminfo' program, which can be very slow, and is also missing on versions of Windows before XP Professional.
-rw-r--r--lisp/mail/emacsbug.el17
-rw-r--r--lisp/w32-fns.el99
2 files changed, 75 insertions, 41 deletions
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index 92b005d47d2..8cacad8726d 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -134,22 +134,7 @@ This requires either the macOS \"open\" command, or the freedesktop
134 os)) 134 os))
135 ((eq system-type 'windows-nt) 135 ((eq system-type 'windows-nt)
136 (or report-emacs-bug--os-description 136 (or report-emacs-bug--os-description
137 (setq 137 (setq report-emacs-bug--os-description (w32--os-description))))
138 report-emacs-bug--os-description
139 (let (os)
140 (with-temp-buffer
141 ;; Seems like this command can be slow, because it
142 ;; unconditionally queries a bunch of other stuff
143 ;; we don't care about.
144 (when (eq 0 (ignore-errors
145 (call-process "systeminfo" nil '(t nil) nil)))
146 (dolist (s '("OS Name" "OS Version"))
147 (goto-char (point-min))
148 (if (re-search-forward
149 (format "^%s\\s-*:\\s-+\\(.*\\)$" s)
150 nil t)
151 (setq os (concat os " " (match-string 1)))))))
152 os))))
153 ((eq system-type 'berkeley-unix) 138 ((eq system-type 'berkeley-unix)
154 (with-temp-buffer 139 (with-temp-buffer
155 (when 140 (when
diff --git a/lisp/w32-fns.el b/lisp/w32-fns.el
index a8a41c453a0..91fe5186bc9 100644
--- a/lisp/w32-fns.el
+++ b/lisp/w32-fns.el
@@ -39,6 +39,8 @@
39 ;; same buffer. 39 ;; same buffer.
40 (setq find-file-visit-truename t)) 40 (setq find-file-visit-truename t))
41 41
42;;;; Shells
43
42(defun w32-shell-name () 44(defun w32-shell-name ()
43 "Return the name of the shell being used." 45 "Return the name of the shell being used."
44 (or (bound-and-true-p shell-file-name) 46 (or (bound-and-true-p shell-file-name)
@@ -120,6 +122,8 @@ You should set this to t when using a non-system shell.\n\n"))))
120 122
121(add-hook 'after-init-hook 'w32-check-shell-configuration) 123(add-hook 'after-init-hook 'w32-check-shell-configuration)
122 124
125;;;; Coding-systems, locales, etc.
126
123;; Override setting chosen at startup. 127;; Override setting chosen at startup.
124(defun w32-set-default-process-coding-system () 128(defun w32-set-default-process-coding-system ()
125 ;; Most programs on Windows will accept Unix line endings on input 129 ;; Most programs on Windows will accept Unix line endings on input
@@ -187,31 +191,6 @@ You should set this to t when using a non-system shell.\n\n"))))
187;; (setq source-directory (file-name-as-directory 191;; (setq source-directory (file-name-as-directory
188;; (expand-file-name ".." exec-directory))))) 192;; (expand-file-name ".." exec-directory)))))
189 193
190(defun w32-convert-standard-filename (filename)
191 "Convert a standard file's name to something suitable for MS-Windows.
192This means to guarantee valid names and perhaps to canonicalize
193certain patterns.
194
195This function is called by `convert-standard-filename'.
196
197Replace invalid characters and turn Cygwin names into native
198names."
199 (save-match-data
200 (let ((name
201 (if (string-match "\\`/cygdrive/\\([a-zA-Z]\\)/" filename)
202 (replace-match "\\1:/" t nil filename)
203 (copy-sequence filename)))
204 (start 0))
205 ;; leave ':' if part of drive specifier
206 (if (and (> (length name) 1)
207 (eq (aref name 1) ?:))
208 (setq start 2))
209 ;; destructively replace invalid filename characters with !
210 (while (string-match "[?*:<>|\"\000-\037]" name start)
211 (aset name (match-beginning 0) ?!)
212 (setq start (match-end 0)))
213 name)))
214
215(defun w32-set-system-coding-system (coding-system) 194(defun w32-set-system-coding-system (coding-system)
216 "Set the coding system used by the Windows system to CODING-SYSTEM. 195 "Set the coding system used by the Windows system to CODING-SYSTEM.
217This is used for things like passing font names with non-ASCII 196This is used for things like passing font names with non-ASCII
@@ -297,6 +276,76 @@ bit output with no translation."
297 (w32-add-charset-info "tis620-0" 'w32-charset-thai 874) 276 (w32-add-charset-info "tis620-0" 'w32-charset-thai 874)
298 (w32-add-charset-info "iso8859-1" 'w32-charset-ansi 1252)) 277 (w32-add-charset-info "iso8859-1" 'w32-charset-ansi 1252))
299 278
279;;;; Standard filenames
280
281(defun w32-convert-standard-filename (filename)
282 "Convert a standard file's name to something suitable for MS-Windows.
283This means to guarantee valid names and perhaps to canonicalize
284certain patterns.
285
286This function is called by `convert-standard-filename'.
287
288Replace invalid characters and turn Cygwin names into native
289names."
290 (save-match-data
291 (let ((name
292 (if (string-match "\\`/cygdrive/\\([a-zA-Z]\\)/" filename)
293 (replace-match "\\1:/" t nil filename)
294 (copy-sequence filename)))
295 (start 0))
296 ;; leave ':' if part of drive specifier
297 (if (and (> (length name) 1)
298 (eq (aref name 1) ?:))
299 (setq start 2))
300 ;; destructively replace invalid filename characters with !
301 (while (string-match "[?*:<>|\"\000-\037]" name start)
302 (aset name (match-beginning 0) ?!)
303 (setq start (match-end 0)))
304 name)))
305
306;;;; System name and version for emacsbug.el
307
308(defun w32--os-description ()
309 "Return a string describing the underlying OS and its version."
310 (let* ((w32ver (car (w32-version)))
311 (w9x-p (< w32ver 5))
312 (key (if w9x-p
313 "SOFTWARE/Microsoft/Windows/CurrentVersion"
314 "SOFTWARE/Microsoft/Windows NT/CurrentVersion"))
315 (os-name (w32-read-registry 'HKLM key "ProductName"))
316 (os-version (if w9x-p
317 (w32-read-registry 'HKLM key "VersionNumber")
318 (let ((vmajor
319 (w32-read-registry 'HKLM key
320 "CurrentMajorVersionNumber"))
321 (vminor
322 (w32-read-registry 'HKLM key
323 "CurrentMinorVersionNumber")))
324 (if (and vmajor vmajor)
325 (format "%d.%d" vmajor vminor)
326 (w32-read-registry 'HKLM key "CurrentVersion")))))
327 (os-csd (w32-read-registry 'HKLM key "CSDVersion"))
328 (os-rel (or (w32-read-registry 'HKLM key "ReleaseID")
329 (w32-read-registry 'HKLM key "CSDBuildNumber")
330 "0")) ; No Release ID before Windows Vista
331 (os-build (w32-read-registry 'HKLM key "CurrentBuildNumber"))
332 (os-rev (w32-read-registry 'HKLM key "UBR"))
333 (os-rev (if os-rev (format "%d" os-rev))))
334 (if w9x-p
335 (concat
336 (if (not (string-match "\\`Microsoft " os-name)) "Microsoft ")
337 os-name
338 " (v" os-version ")")
339 (concat
340 (if (not (string-match "\\`Microsoft " os-name)) "Microsoft ")
341 os-name ; Windows 7 Enterprise
342 " "
343 os-csd ; Service Pack 1
344 (if (and os-csd (> (length os-csd) 0)) " " "")
345 "(v"
346 os-version "." os-rel "." os-build (if os-rev (concat "." os-rev))
347 ")"))))
348
300 349
301;;;; Support for build process 350;;;; Support for build process
302 351