From 139862d66ddff37663038c8abe31b4ce7a87599d Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 11 Nov 2017 09:06:41 +0100 Subject: [PATCH] =?UTF-8?q?[Misc]=20Introduce=20variable=20=E2=80=98on-win?= =?UTF-8?q?dows=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to increase readability --- init.el | 13 ++++++++----- site-lisp/db-emms.el | 2 +- site-lisp/db-utils.el | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/init.el b/init.el index 91cd99b..6f89d28 100644 --- a/init.el +++ b/init.el @@ -262,7 +262,7 @@ _h_ _l_ _o_k _y_ank ;; Environment Variables - (unless (memq system-type '(windows-nt cygwin)) + (unless on-windows (ignore-errors (exec-path-from-shell-copy-envs '("SSH_AUTH_SOCK" "SSH_AGENT_PID" @@ -281,7 +281,7 @@ _h_ _l_ _o_k _y_ank ;; Start Server when on Windows - (when (memq system-type '(windows-nt cygwin)) + (when on-windows (server-start)) t) @@ -307,6 +307,9 @@ _h_ _l_ _o_k _y_ank :group 'help :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 @@ -360,7 +363,7 @@ _h_ _l_ _o_k _y_ank x-underline-at-descent-line t 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 doesn’t ;; matter! (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")) (add-to-list 'dired-latex-unclean-extensions extension)) - (if (memq system-type '(windows-nt cygwin)) + (if on-windows (setq dired-guess-shell-alist-user '(("\\.pdf\\'" "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")))) (require 'dired-quick-sort) - (when (eq system-type 'windows-nt) + (when on-windows (setq ls-lisp-use-insert-directory-program t)) (dired-quick-sort-setup) diff --git a/site-lisp/db-emms.el b/site-lisp/db-emms.el index b8a5748..5fa27d9 100644 --- a/site-lisp/db-emms.el +++ b/site-lisp/db-emms.el @@ -105,7 +105,7 @@ that we also follow symbolic links." (point-max)) "\n")))) -(unless (memq system-type '(windows-nt ms-dos)) +(unless on-windows (setq emms-source-file-directory-tree-function #'db/emms-source-file-directory-tree-find)) diff --git a/site-lisp/db-utils.el b/site-lisp/db-utils.el index 69edf50..ef3515e 100644 --- a/site-lisp/db-utils.el +++ b/site-lisp/db-utils.el @@ -329,9 +329,9 @@ path." (defun db/system-open (path) "Open PATH with default program as defined by the underlying system." - (ecase system-type - ((windows-nt cygwin) (w32-shell-execute "open" path)) - ((gnu/linux) (start-process "" nil "xdg-open" path)))) + (if on-windows + (w32-shell-execute "open" path) + (start-process "" nil "xdg-open" path))) (defvar db/helm-source-important-documents '((name . "Important files")