프로젝트마다 다른 변수를 쓰고 싶을때(특히 빌드시) 이런 기능이 필요해서 dirvars.el 을 가져다 쓰고있었는데 오늘 이맥스위키를 구경하다 보니 유사기능이 정식으로 지원되고 있었네.
info 에서 관련 페이지 따서 적어둔다.
펼쳐두기..
File: emacs, Node: Directory Variables, Prev: File Variables, Up: Variables
*Note (emacs)Top:: > *Note Customization:: > *Note Variables:: > Directory Variables
56.3.5 Per-Directory Local Variables
------------------------------------
Emacs provides a mechanism to specify local variable values
per-directory. This can be done one of two ways.
The first approach is to put a special file, named
`.dir-settings.el', in a directory. When opening a file, Emacs
searches for `.dir-settings.el' starting in the file's directory and
then moving up the directory hierarchy. If `.dir-settings.el' is
found, Emacs applies variable settings from the file to the new buffer.
If the file is remote, Emacs skips this search, because it would be too
slow.
The file should hold a specially-constructed list. This list maps
Emacs mode names (symbols) to alists; each alist maps variable names to
values. The special mode name `nil' means that the alist should be
applied to all buffers. Finally, a string key can be used to specify
an alist which applies to a relative subdirectory in the project.
((nil . ((indent-tabs-mode . t)
(tab-width . 4)
(fill-column . 80)))
(c-mode . ((c-file-style . "BSD")))
(java-mode . ((c-file-style . "BSD")))
("src/imported"
. ((nil . ((change-log-default-name . "ChangeLog.local"))))))
This example shows some settings for a hypothetical project. This
sets `indent-tabs-mode' to `t' for any file in the source tree, and it
sets the indentation style for any C or Java source file to `BSD'.
Finally, it specifies a different `ChangeLog' file name for any file in
the project that appears beneath the directory `src/imported'.
The second approach to directory-local settings is to explicitly
define a project class using `define-project-bindings', and then to
tell Emacs which directory roots correspond to that class, using
`set-directory-project'. You can put calls to these functions in your
`.emacs'; this can be useful when you can't put `.dir-settings.el' in
the directory for some reason. For example, you could apply settings
to an unwriteable directory this way:
(define-project-bindings 'unwriteable-directory
'((nil . ((some-useful-setting . value)))))
(set-directory-project "/usr/include/" 'unwriteable-directory)
Unsafe directory-local variables are handled in the same way as
unsafe file-local variables (*note Safe File Variables::).
대강 테스트 해봤는데 위 제시된 방법중 첫번째는 잘 안먹네.. dirvars.el 하고 충돌인가. 흠...
뭐 어차피 두번째 방법이 더 맘에 드니 별 문제는 없다.
당장 아래 코드 집어넣고 돌려보니 잘 먹는다.
(define-project-bindings 'mao
'((nil . ((yoonkn-build-option . (:wc "/tmp/libbrpc" :cmd "make "))))))
(set-directory-project "~/scratch/libbrpc" 'mao)
음 좀더 써보고 dirvars.el 을 아예 빼버리자..
지금 크게 남은게
yoonkn-build 함수를 좀더 정리하는 거하고 anything-mode 에서 이 프로젝트들을 띄워주는거... 음 또 뭐 있을까?
아
locate-dominating-file 함수도 편해보이던데 솔루션 파일을 찾거나 할때 쓰면 빌드가 좀더 편해지겠구만.