버전 컨트롤 안하는 init.el 설정은 어떻게 관리하지?

less than 1 minute read

<#gitlab issue 또는 merge request의 링크와 제목 삽입하기> 글에서 짠 함수를 사용하려면 personal access tokens가 필요하다. github에 올려놓은 init.el 파일에 적어놓는 건 아닌 것 같다. id와 password를 공개 장소에 올려놓는 것과 같은 행동이기 때문이다.

<#git 버전 컨트롤 안하는 것들을 어디에 둬야할까?> 글을 참고해 init.local.el 파일을 버전 컨트롤에서 제외했다. 여기에 personal access tokens 같은 설정을 담아두면 된다.

(defconst local-init-el-path "~/.emacs.d/init.local.el")
(when (file-exists-p local-init-el-path)
  (load-file local-init-el-path))

init.el 파일에선 로컬 설정 파일이 있는지 검사 후 로드하면 된다.

;;; init.local.el
(defconst gitlab-private-key "...")
(defconst gitlab-api-base-url "...")
(defconst gitlab-base-url '...")

init.local.el 파일에는 그냥 defconst 특수 형식(special form)으로 심볼(symbol)을 정의하면 된다. 파싱(parsing) 이런 거 필요 없다. load-file 함수로 파일 안의 emacs lisp 코드를 모두 실행한다. 그럼 원하는 심볼에 값이 바인딩 된다.

(when (and (boundp 'gitlab-private-key)
           (boundp 'gitlab-api-base-url)
           (boundp 'gitlab-base-url))

사용하기 전에는 boundp 함수로 심볼에 바인딩 된 값이 있는지 확인하면 된다.

C-x C-s C-x C-c