1
Q
들여 쓰기
A
답변
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)))