2012-07-01 1 views
1

나는 cc-mode로 emacs24로 작업하고 있는데, 나는 이맥스를 더 "영리하게"만드는 법을 알고 싶다. a를 입력하면 자동으로 새 줄을 삽입하고 들여 쓰기를 예외로 만듭니다. 포인트를 이전 라인으로 전환하는 방법을 알고 싶습니다. 내가 함수를 정의 할 때 예를 들어, 지금 내 이맥스 동작은 다음과 같습니다a를 입력 한 후 포인트를 이전 라인으로 어떻게 변환합니까?

void f() 
{ 
} 
//point 

는 "// 점"커서의 위치 후} 입력했다입니다. 내가 커서의 위치가 자동으로 이전 행 들여 쓰기로 전환 할 수 있기를 바랍니다

void f() 
{ 
    //point 
} 

: 하지만 내가 원하는이있다. 이맥스가이 일을 할 수 있다는 것을 알고 있지만, 어떻게 해야할지 모르겠지만 누가 나를 도와 줄 수 있습니까?

답변

1

나는 C-M-uC-M-d, C-M-fC-M-b

연습 좀 ... 그들은 가지 전역 .. 당신이이 후에 ​​생각하고는 .. 거의 모든 모드에서 문맥 행동

UPDATE를 할 :

ohh .. 커서를 자동으로 배치하려는 것 같습니다. 실제로 좀 더 일반적인 Emacs에서는 }을 입력하지 않아도됩니다. 이맥스는 닫는 파라 탄을 자동으로 삽입 할 수 있습니다.

는 붙박이가 하나 전기 쌍 모드

타사 autopair.el

0

나는 전기 아무것도 믿지 않는, 그래서이 기능을 썼다.

(defconst insert-logical-brackets-logical-bracket-begin "{") 
(defconst insert-logical-brackets-logical-bracket-end "}") 
(defconst insert-logical-brackets-default-style 0) 
(make-variable-buffer-local 'logical-bracket-begin) 
(make-variable-buffer-local 'logical-bracket-end) 
(make-variable-buffer-local 'insert-logical-brackets-default-style) 
(defun insert-logical-brackets(&optional style) 
    "If STYLE = 0(default, according to `insert-logical-brackets-default-style' value), make a newline before opening bracket, if line is not empty. Make a newline after closing bracket, if there is something after this bracket. Make two newlines in the middle. 
If STYLE = 1, don't make newlines before opening a bracket(one of c styles). 
If STYLE = 2, don't make newlines before opening and after closing bracket. 
If STYLE = 3, allways make all newlines. 
If STYLE is not nil, don't make newlines between brackets(still makes before/after lines)." 
    (interactive "P") 
    (when (eq style nil) 
    (setq style insert-logical-brackets-default-style)) 
    (funcall indent-line-function) 
    (unless (or (eq 1 style) (eq 2 style)) 
    (when (or (/= (point) (save-excursion (back-to-indentation) (point))) (eq 3 style)) 
     (newline) 
     (funcall indent-line-function))) 
    (unless (and (integerp style) (= 2 style)) 
    (when (or (not (looking-at "\n")) (eq 3 style)) 
     (newline) 
     (funcall indent-line-function) 
     (forward-line -1) 
     (goto-char (point-at-eol)))) 
    (insert logical-bracket-begin) 
    (funcall indent-line-function) 
    (let ((return-point (point))) 
    (when (or (not style) (or (eq 0 style) (eq 1 style) (eq 2 style) (eq 3 style))) 
     (newline) 
     (funcall indent-line-function) 
     (setq return-point (point)) 
     (newline)) 
    (insert logical-bracket-end) 
    (funcall indent-line-function) 
    (goto-char return-point))) 
관련 문제