반응형
elisp에서 운영을 확인하는 방법은 무엇입니까?
ELisp에서 실행중인 OS Emacs를 프로그래밍 방식으로 어떻게 확인합니까?
.emacs
OS 에 따라 다른 코드를 실행하고 싶습니다 .
system-type
변수 :
system-type is a variable defined in `C source code'.
Its value is darwin
Documentation:
Value is symbol indicating type of operating system you are using.
Special values:
`gnu' compiled for a GNU Hurd system.
`gnu/linux' compiled for a GNU/Linux system.
`darwin' compiled for Darwin (GNU-Darwin, Mac OS X, ...).
`ms-dos' compiled as an MS-DOS application.
`windows-nt' compiled as a native W32 application.
`cygwin' compiled using the Cygwin library.
Anything else indicates some sort of Unix system.
elisp를 처음 사용하는 사람들을 위해 샘플 사용법 :
(if (eq system-type 'darwin)
; something for OS X if true
; optional something if not
)
시스템 유형에 따라 코드를 쉽게 만들 수 있습니다.
(defmacro with-system (type &rest body)
"Evaluate BODY if `system-type' equals TYPE."
(declare (indent defun))
`(when (eq system-type ',type)
,@body))
(with-system gnu/linux
(message "Free as in Beer")
(message "Free as in Freedom!"))
.emacs에는 system-type
뿐만 아니라 window-system
변수도 있습니다. x 전용 옵션, 터미널 또는 macOS 설정 선택하려는 경우 유용합니다.
이제 Windows 용 Linux 하위 시스템 (Windows 10의 bash) system-type
도 gnu/linux
있습니다. 이 시스템 유형을 선택하신 다음 사용하십시오.
(if
(string-match "Microsoft"
(with-temp-buffer (shell-command "uname -r" t)
(goto-char (point-max))
(delete-char -1)
(buffer-string)))
(message "Running under Linux subsystem for Windows")
(message "Not running under Linux subsystem for Windows")
)
FreeBSD에서 "berkeley-unix"라는 값은 "berkeley-unix"입니다.
system-configuration
빌드 시스템의 차이를 조정하려는 경우 ( 적어도 24/25에) 있습니다.
참고 URL : https://stackoverflow.com/questions/1817257/how-to-determine-operating-system-in-elisp
반응형
'ProgramingTip' 카테고리의 다른 글
Gradle로 라이브러리 프로젝트를 빌드 할 때 BuildConfig.DEBUG는 항상 false입니다. (0) | 2020.10.04 |
---|---|
redux에서 특정 배열 항목 내부의 단일 값을 업데이트하는 방법 (0) | 2020.10.04 |
Jquery는 요소가 뷰포트에 보이는지 확인합니다 (0) | 2020.10.04 |
mongodb 그룹 값을 여러 필드로 (0) | 2020.10.04 |
프록시 뒤에서 sbt를 사용하는 방법은 무엇입니까? (0) | 2020.10.04 |