2011-12-27 71 views
4

我的配置中有一些東西只能在Xorg中使用,否則會丟失錯誤。如何檢查Xorg是否在emacs lisp中運行?

爲了解決這個問題,我需要知道Xorg是否在運行。我如何檢查它?

(defun nCdy-mode() 
    ;; TOOD: Add Xorg check 
    ;(tool-bar-mode nil) 
    (menu-bar-mode nil) ; TODO: Add hotkey 
    ;(scroll-bar-mode nil) 
    (setq inhibit-splash-screen t) 

    (setq standard-indent 4) 
    ;;(mouse-wheel-mode t) 
    (setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/")))) 

    ;;TODO: Add Xorg check 
    ;(require 'nyan-mode) 
    ;(nyan-mode) 
    ;(nyan-start-animation) 
    ;;nyanyanyanyanyanyanyanyanyanyan 

謝謝

回答

7
(case window-system 
    (x '"X11 running") 
    (otherwise "No X11")) 
4

雖然于爾根是正確的,你可能想測試window-system值,注意,是因爲它的客戶機/服務器機制,單一的Emacs實例可以有幾個幀,其中一些在圖形終端(例如XOrg)上,其中一些在文本終端中。

因此,您應該考慮在哪裏以及何時測試window-system。有關如何處理該問題的更多信息,請參見this answer to a similar question

相關問題