2010-03-19 7 views
0

나는 emacs로 시작하고 있으며 많은 elisp을 모른다. 거의 아무것도, 정말로.elisp 컴파일, 오류 검출에 regexp를 추가하십시오.

grep 대신 ack를 사용하고 싶습니다.

이 내가 이맥스 내에서 ACK를 사용하는 다음의 지침은 다음과 같습니다 지금이 엘 파일에 사용되는 출력 형식을 좋아하지 않아 http://www.rooijan.za.net/?q=ack_el

가, 나는 ack --group의를로 출력을하고 싶습니다 .

그래서 나는 변경 :

(read-string "Ack arguments: " "-i" nil "-i" nil) 

에 :

(read-string "Ack arguments: " "-i --group" nil "-i --group" nil) 

지금까지 너무 좋아. 하지만이 때문에 출력 버퍼 행에서 click-press_enter를 사용할 수 없게되었습니다. 원래의 동작에서는 컴파일 된 모드를 사용하여 선택한 행으로 이동할 수있었습니다.

나는 내가 ACK 모드에 정규 표현식을 추가해야합니다 생각. 는 ACK 모드는 다음과 같이 정의된다 :

(define-compilation-mode ack-mode "Ack" 
    "Specialization of compilation-mode for use with ack." 
    nil) 

그리고 그것이 출력 놈의 모든 행 (행 번호)가 포함되어 무엇 때문에, 너무 오류로 감지 할 수있는 정규 표현식 [0-9]+:를 추가 할.

위의 define-compilation-mode을 수정하여 정규 표현식을 추가하려고했지만 비참하게 실패했습니다.

ack의 출력 버퍼를 어떻게 만들 수 있습니까? ---

(defvar ack-regexp-alist 
    '(("[0-9]+:" 
    2 3)) 
    "Alist that specifies how to match rows in ack output.") 

(setq compilation-error-regexp-alist 
     (append compilation-error-regexp-alist 
      ack-regexp-alist)) 

내가 그 곳 훔쳐 내 요구에 적응하기 위해 노력 :

--- 편집, 나 또한 노력했다. 불운. 업데이트 ack.el와

--- 편집, 이반의 제안 후 결과 ---

가 포함 :

(defvar ack-regexp-alist 
    '(("^[0-9]+:" ;; match the line number 
    nil  ;; the file is not found on this line, so assume that it's the same as before 
    0   ;; The line is the 0'th subexpression (the whole thing) 
    ) 
    ("^[^: ]+$" ;; match a file -- this could be better 
    0   ;; The file is the 0'th subexpression 
    )) 
    "Alist that specifies how to match rows in ack output.") 

(setq compilation-error-regexp-alist 
     (append compilation-error-regexp-alist 
      ack-regexp-alist)) 


(define-compilation-mode ack-mode "Ack" 
    "Specialization of compilation-mode for use with ack." 
    nil) 

는 그 다음 compilation-error-regext-alist 변수를 확인, 내가 가치를 얻을 :

(absoft ada aix ant bash borland caml comma edg-1 edg-2 epc ftnchek iar ibm irix java jikes-file jikes-line gnu gcc-include lcc makepp mips-1 mips-2 msft oracle perl rxp sparc-pascal-file sparc-pascal-line sparc-pascal-example sun sun-ada 4bsd gcov-file gcov-header gcov-nomark gcov-called-line gcov-never-called 
     ("^[0-9]+:" nil 0) 
     ("^[^: ]+$" 0)) 

나는 그것은 매우 이상한 변수의 형식을하지 않습니다 찾을? 나는 elisp (아직)를 모른다. 그래서 아마 그렇게 될 것이다.

여전히 * ack * 버퍼에 링크 또는 색이 없습니다.

답변

2

내가 전에 사용하고 --group 출력을 처리하는 ELPA에 또 다른 full-ack 패키지가 있습니다.

당신이 그것을 양식이 볼 compilation-error-regexp-alist에 대한 문서를 읽고, 말했다 : 별도로 파일과 줄 일치 할 필요가 --group 출력의 경우

(REGEXP FILE [LINE COLUMN TYPE HYPERLINK HIGHLIGHT...]) 

을, 그래서 당신이 뭔가를 원한다고 생각 (안된)

(defvar ack-regexp-alist 
    '(("^\\S +$" ;; match a file -- this could be better 
    0   ;; The file is the 1st subexpression 
    ) 
    ("^[0-9]+:" ;; match the line number 
    nil  ;; the file is not found on this line, so assume that it's the same as before 
    0   ;; The line is the 0'th subexpression (the whole thing) 
    )) 
    "Alist that specifies how to match rows in ack output.") 

는 - - 업데이트

compilation-error-regext-alist 변수는 0과 같은 심볼 또는 요소의 목록은. 기호는 compilation-error-regexp-alist-alist에서 조회하여 해당 요소를 찾습니다. 그래, 조금 이상하지만,보기 싫은 regexes을 보지 않고 그들이 무엇을하는지 생각하지 않고 켜고 끌 수 있습니다. 만약 당신이 이것을 배포하려고한다면 compilation-error-regexp-alist-alist에 정규 표현식을 추가 한 다음 compilation-error-regext-alist에 넣는 것이 좋겠지 만 올바르게 작동 할 때까지 다소 의의가 있습니다.

ack.el 좀 더 자세히 살펴보면, 나는 그것이 로컬 grep-regexp-alistcompilation-error-regexp-alist 덮어 즉

(let (compile-command 
     (compilation-error-regexp-alist grep-regexp-alist) 
     ...) 
    ... 
) 

를 사용하는 것을 알 수 있으므로 대신에 거기에 정규 표현식에 추가해야합니다. 또는 더 나은 파일 이름 정규식이 제대로 작동하지 않는 것 때문에 난 아직도 full-ack 추천 결국

(let (compile-command 
     (compilation-error-regexp-alist ack-regexp-alist) 
     ...) 
    ... 
) 

로 교체 할 수 있습니다. 그것은 더 복잡해 보이지만 (나는 더 복잡해 보인다) 나는 행복해했다.

+0

알리미 정의에 도움을 주셔서 감사합니다. 그러나, 나는 아직도 그것을 컴파일 명령에 전달하는 방법에 대해 확신하지 못하고있다. 는 출력은 현재 내가 비록'(SETQ 컴파일 오류 - 정규 표현식-alist (컴파일 오류 - 정규 표현식-alist ACK-정규 표현식-alist)를 추가)는 'ACK-정규 표현식 - alist'에 관심을 보인다 ' – Gauthier

+0

'Mx compile '을 사용하여 수동으로 실행하면 저에게 효과적입니다. (regexp 파일은 제대로 작동하지 않지만). 한 가지해야 할 일은 ack-regexp-alist가 업데이트되고 있는지 확인하는 것입니다. 'defvar'를 여러 번 평가하면 일단 설정되면 값이 변경되지 않습니다. 'C-h v ack-regexp-alist RET'는'ack-regexp-alist'의 현재 값을 보여줍니다. 'compilation-error-regexp-alist'와 마찬가지로. –

+0

다시 한번 감사드립니다. 나는 아직도 혼란 스럽다. 나는 내 질문을 편집하여 내가 제안한 후에 ​​내가 갇혀있는 곳을 보여 준다. – Gauthier