2013-08-14 3 views
1

저는 elisp의 초보자입니다. 그래서 초보자 질문을 변명하십시오. "compile-pkg"함수에 "command"를 전달하려고하는데, 컴파일 함수 make()에서 emacs에 잘못된 인수가 계속 나타납니다.이맥스에서 함수에 인수로 명령을 전달

(defun compile-pkg (&optional command startdir) 
    "Compile a package, moving up to the parent directory 
    containing configure.ac, if it exists. Start in startdir if defined, 
    else start in the current directory." 
    (interactive) 

    (let ((dirname) 
    (dir-buffer nil)) 
    (setq startdir (expand-file-name (if startdir startdir "."))) 
    (setq command (if command command compile-command)) 

    (setq dirname (upward-find-file "Makefile" startdir)) 
    (setq dirname (if dirname dirname (expand-file-name "."))) 
    ; We've now worked out where to start. Now we need to worry about 
    ; calling compile in the right directory 
    (save-excursion 
     (setq dir-buffer (find-file-noselect dirname)) 
     (set-buffer dir-buffer) 
     (compile command) 
     (kill-buffer dir-buffer)))) 

(defun upward-find-file (filename &optional startdir) 
    "Move up directories until we find a certain filename. If we 
    manage to find it, return the containing directory. Else if we 
    get to the toplevel directory and still can't find it, return 
    nil. Start at startdir or . if startdir not given" 

    (let ((dirname (expand-file-name 
      (if startdir startdir "."))) 
    (found nil) ; found is set as a flag to leave loop if we find it 
    (top nil)) ; top is set when we get 
      ; to/so that we only check it once 

    ; While we've neither been at the top last time nor have we found 
    ; the file. 
    (while (not (or found top)) 
     ; If we're at/set top flag. 
     (if (string= (expand-file-name dirname) "/") 
     (setq top t)) 

     ; Check for the file 
     (if (file-exists-p (expand-file-name filename dirname)) 
     (setq found t) 
    ; If not, move up a directory 
    (setq dirname (expand-file-name ".." dirname)))) 
    ; return statement 
    (if found (concat dirname "/") nil))) 

(defun compile-make() 
    (compile-pkg "make")) 

(global-set-key [f1] 'compile-make) 

내가 뭘 잘못하고 있니? ,

(defun compile-make() 
    (interactive) 
    (compile-pkg "make")) 

는 이맥스 LISP 튜토리얼을 살펴보십시오 Making a Function Interactive에 특히 섹션 : 잘못

답변

2

우선 당신이 간단한 변화 할 수있는 명령으로 compile-make을 필요로한다는 것입니다 왜 interactive이 필요한지 이해해야합니다.

참고 : 당신이보고 있던 정확한 오류 메시지를 잘라내거나 붙여 넣는 것이 일반적으로 도움이됩니다. 나는 그것이 상상했다 :

Wrong type argument: commandp, compile-make 
+0

나는 그것이 톱이었다라는 메시지였다. 나는이 작업을 수행하여 오류를 수정 : (defun는 컴파일 메이크업() (SETQ는 "확인"makestring) "처럼 '컴파일'만 사용-PKG를 컴파일" (대화 형) (저장 - 모든 버퍼를) (compile-pkg makestring)) 하지만 setq를 사용하고 인수를 직접 전달하지 않아도되는지 확실하지 않습니다. – SFbay007

+0

@Ammari 수정 사항은'(대화 형)'입니다 - 꺼내면 오류가 다시 발생하는 것을 볼 수 있습니다. –

+0

정말로 틀린 것입니다. 실례지만 내 무지. – SFbay007

관련 문제