2016-07-14 4 views
1

이맥스 d-mode 현재 잘못 등들여 쓰기

auto f(T)(T x) 
    if (is(T == struct)) 
    { 
    } 

아무도이 문제를 해결하기 위해 파고 시작하는 위치에 어떤 생각을 가지고 있는가 등

auto f(T)(T x) 
    if (is(T == struct)) 
{ 
} 

같은 템플릿 제한을 들여 쓰기? d-modecc-mode입니다.

답변

0

실행 C-h f d-mode이고 다음과 같이 표시되어야합니다. d-mode is an interactive autoloaded compiled Lisp function in 'd-mode.el'.d-mode.el 링크를 따르십시오.

해당 파일에서 "들여 쓰기"를 검색하면 cc-mode에 정의 된 것을 사용하는 것처럼 보입니다. 당신은 그들이 D 모드 버퍼에서이 프로그램을 실행하여 사용 할 기능을 찾을 수 있습니다 : 그들은 단지 c-indent-line를 사용 했

C-h v indent-line-function 

이 보여줍니다. 아마도이 문제를 해결하는 방법은이 경우를 감지하고 그렇지 않으면 c-indent-line에 대체하는 것입니다. 이와 비슷한 것 (테스트되지 않은 코드, 설명 목적) :

(defun d-indent-line() 
    (let* ((auto-if-curly 
      (save-excursion 
      (back-to-indentation 
      (when (looking-at "{") 
       (forward-line -1) 
       (back-to-indentation 
       (when (looking-at "if") 
        (forward-line -1) 
        (back-to-indentation 
        (looking-at "auto"))))))))) 
    (if auto-if-curly 
     (ident-line-to 0) 
     (c-ident-line)))) 

(add-hook d-mode-hook (lambda() (setq-local indent-line-function 'd-indent-line)))