[Misc] Introduce variable ‘on-windows’

to increase readability
This commit is contained in:
Daniel Borchmann 2017-11-11 09:06:41 +01:00
parent 1318b74c61
commit 139862d66d
Signed by: exot
GPG Key ID: 4F63DB96D45AA9C6
3 changed files with 12 additions and 9 deletions

13
init.el
View File

@ -262,7 +262,7 @@ _h_ _l_ _o_k _y_ank
;; Environment Variables ;; Environment Variables
(unless (memq system-type '(windows-nt cygwin)) (unless on-windows
(ignore-errors (ignore-errors
(exec-path-from-shell-copy-envs '("SSH_AUTH_SOCK" (exec-path-from-shell-copy-envs '("SSH_AUTH_SOCK"
"SSH_AGENT_PID" "SSH_AGENT_PID"
@ -281,7 +281,7 @@ _h_ _l_ _o_k _y_ank
;; Start Server when on Windows ;; Start Server when on Windows
(when (memq system-type '(windows-nt cygwin)) (when on-windows
(server-start)) (server-start))
t) t)
@ -307,6 +307,9 @@ _h_ _l_ _o_k _y_ank
:group 'help :group 'help
:tag "Personal settings") :tag "Personal settings")
(defconst on-windows (memq system-type '(windows-nt cygwin))
"Non-nil if and only if this instance of Emacs runs on Windows.")
;; * Builtin Variables ;; * Builtin Variables
@ -360,7 +363,7 @@ _h_ _l_ _o_k _y_ank
x-underline-at-descent-line t x-underline-at-descent-line t
search-whitespace-regexp "[ \t\r\n]+") search-whitespace-regexp "[ \t\r\n]+")
(when (memq system-type '(windows-nt cygwin)) (when on-windows
;; treat memory for display time ... but hey, this is Windows, memory doesnt ;; treat memory for display time ... but hey, this is Windows, memory doesnt
;; matter! ;; matter!
(setq inhibit-compacting-font-caches t)) (setq inhibit-compacting-font-caches t))
@ -714,7 +717,7 @@ Certificates are assumed to be of the form *.crt."
(dolist (extension '(".out" ".synctex.gz" ".thm")) (dolist (extension '(".out" ".synctex.gz" ".thm"))
(add-to-list 'dired-latex-unclean-extensions extension)) (add-to-list 'dired-latex-unclean-extensions extension))
(if (memq system-type '(windows-nt cygwin)) (if on-windows
(setq dired-guess-shell-alist-user (setq dired-guess-shell-alist-user
'(("\\.pdf\\'" "cmd /c") '(("\\.pdf\\'" "cmd /c")
("\\.docx\\'" "cmd /c") ("\\.docx\\'" "cmd /c")
@ -766,7 +769,7 @@ Certificates are assumed to be of the form *.crt."
(error "No more than 2 files should be marked")))) (error "No more than 2 files should be marked"))))
(require 'dired-quick-sort) (require 'dired-quick-sort)
(when (eq system-type 'windows-nt) (when on-windows
(setq ls-lisp-use-insert-directory-program t)) (setq ls-lisp-use-insert-directory-program t))
(dired-quick-sort-setup) (dired-quick-sort-setup)

View File

@ -105,7 +105,7 @@ that we also follow symbolic links."
(point-max)) (point-max))
"\n")))) "\n"))))
(unless (memq system-type '(windows-nt ms-dos)) (unless on-windows
(setq emms-source-file-directory-tree-function (setq emms-source-file-directory-tree-function
#'db/emms-source-file-directory-tree-find)) #'db/emms-source-file-directory-tree-find))

View File

@ -329,9 +329,9 @@ path."
(defun db/system-open (path) (defun db/system-open (path)
"Open PATH with default program as defined by the underlying system." "Open PATH with default program as defined by the underlying system."
(ecase system-type (if on-windows
((windows-nt cygwin) (w32-shell-execute "open" path)) (w32-shell-execute "open" path)
((gnu/linux) (start-process "" nil "xdg-open" path)))) (start-process "" nil "xdg-open" path)))
(defvar db/helm-source-important-documents (defvar db/helm-source-important-documents
'((name . "Important files") '((name . "Important files")