2012-07-30 1 views
2

필자는 Emacs24로 업그레이드했으며, Pymacs를 시작할 때 시간 초과로 인해 중단됩니다.Emacs24 + Pymacs -f pymacs-load-path가 중복 된 스위치?

(defun pymacs-start-services() 
    ;; This function gets called automatically, as needed. 
    (let ((buffer (get-buffer-create "*Pymacs*"))) 
    (with-current-buffer buffer 
     ;; Erase the buffer in case some previous incarnation of the 
     ;; Pymacs helper died. Otherwise, the "(goto-char (point-min))" 
     ;; below might not find the proper synchronising reply and later 
     ;; trigger a spurious "Protocol error" diagnostic. 
     (erase-buffer) 
     (buffer-disable-undo) 
     (pymacs-set-buffer-multibyte nil) 
     (set-buffer-file-coding-system 'raw-text) 
     (save-match-data 
     ;; Launch the Pymacs helper. 
     (let ((process 
       (apply 'start-process "pymacs" buffer 
         (let ((python (getenv "PYMACS_PYTHON"))) 
         (if (or (null python) (equal python "")) 
          "python" 
          python)) 
         "-c" (concat "import sys;" 
            " from Pymacs.pymacs import main;" 
            " main(*sys.argv[1:])") 
         (append 
         (and (>= emacs-major-version 24) '("-f")) 
         (mapcar 'expand-file-name pymacs-load-path))))) 
      (pymacs-kill-without-query process) 
      ;; Receive the synchronising reply. 
      (while (progn 
        (goto-char (point-min)) 
        (not (re-search-forward "<\\([0-9]+\\)\t" nil t))) 
      (unless (accept-process-output process pymacs-timeout-at-start) 
       (pymacs-report-error 
       "Pymacs helper did not start within %d seconds" 
        pymacs-timeout-at-start))) 
      (let ((marker (process-mark process)) 
       (limit-position (+ (match-end 0) 
            (string-to-number (match-string 1))))) 
      (while (< (marker-position marker) limit-position) 
       (unless (accept-process-output process pymacs-timeout-at-start) 
       (pymacs-report-error 
       "Pymacs helper probably was interrupted at start"))))) 
     ;; Check that synchronisation occurred. 
     (goto-char (match-end 0)) 
     (let ((reply (read (current-buffer)))) 
      (if (and (pymacs-proper-list-p reply) 
        (= (length reply) 2) 
        (eq (car reply) 'version)) 
       (unless (string-equal (cadr reply) "0.24-beta2") 
       (pymacs-report-error 
       "Pymacs Lisp version is 0.24-beta2, Python is %s" 
       (cadr reply))) 
      (pymacs-report-error "Pymacs got an invalid initial reply"))))) 
    (if (not pymacs-use-hash-tables) 
     (setq pymacs-weak-hash t) 
     (when pymacs-used-ids 
     ;; A previous Pymacs session occurred in this Emacs session, 
     ;; some IDs hang around which do not correspond to anything on 
     ;; the Python side. Python should not recycle such IDs for 
     ;; new objects. 
     (let ((pymacs-transit-buffer buffer) 
       (pymacs-forget-mutability t) 
       (pymacs-gc-inhibit t)) 
      (pymacs-apply "zombie_python" pymacs-used-ids)) 
     (setq pymacs-used-ids nil)) 
     (setq pymacs-weak-hash (make-hash-table :weakness 'value)) 
     (if (boundp 'post-gc-hook) 
      (add-hook 'post-gc-hook 'pymacs-schedule-gc) 
     (setq pymacs-gc-timer (run-at-time 20 20 'pymacs-schedule-gc)))) 
    ;; If nothing failed, only then declare that Pymacs has started! 
    (setq pymacs-transit-buffer buffer))) 

나는 단순히 콘솔에서 같은 명령을 실행하여 문제점을 재현하기 위해 노력 ;; Launch the Pymacs helper. 아래 부분 :

그때에 보았다

Debugger entered--Lisp error: (error "Pymacs helper did not start within 30 seconds") 
    signal(error ("Pymacs helper did not start within 30 seconds")) 
    pymacs-report-error("Pymacs helper did not start within %d seconds" 30) 
    (if (accept-process-output process pymacs-timeout-at-start) nil (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start)) 
    (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start)) 
    (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\) " nil t))) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) 
    (let ((process (apply (quote start-process) "pymacs" buffer (let ((python (getenv "PYMACS_PYTHON"))) (if (or (null python) (equal python "")) "python" python)) "-c" (concat "import sys;" " from Pymacs.pymacs import main;" " main(*sys.argv[1:])") (append (and (>= emacs-major-version 24) (quote ("-f"))) (mapcar (quote expand-file-name) pymacs-load-path))))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\) " nil t))) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ (match-end 0) (string-to-number (match-string 1))))) (while (< (marker-position marker) limit-position) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) 
    (progn (let ((process (apply (quote start-process) "pymacs" buffer (let ((python ...)) (if (or ... ...) "python" python)) "-c" (concat "import sys;" " from Pymacs.pymacs import main;" " main(*sys.argv[1:])") (append (and (>= emacs-major-version 24) (quote ...)) (mapcar (quote expand-file-name) pymacs-load-path))))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\) " nil t))) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ (match-end 0) (string-to-number (match-string 1))))) (while (< (marker-position marker) limit-position) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) (goto-char (match-end 0)) (let ((reply (read (current-buffer)))) (if (and (pymacs-proper-list-p reply) (= (length reply) 2) (eq (car reply) (quote version))) (unless (string-equal (cadr reply) "0.24-beta2") (pymacs-report-error "Pymacs Lisp version is 0.24-beta2, Python is %s" (cadr reply))) (pymacs-report-error "Pymacs got an invalid initial reply")))) 
    (unwind-protect (progn (let ((process (apply (quote start-process) "pymacs" buffer (let (...) (if ... "python" python)) "-c" (concat "import sys;" " from Pymacs.pymacs import main;" " main(*sys.argv[1:])") (append (and ... ...) (mapcar ... pymacs-load-path))))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\) " nil t))) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ (match-end 0) (string-to-number ...)))) (while (< (marker-position marker) limit-position) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) (goto-char (match-end 0)) (let ((reply (read (current-buffer)))) (if (and (pymacs-proper-list-p reply) (= (length reply) 2) (eq (car reply) (quote version))) (unless (string-equal (cadr reply) "0.24-beta2") (pymacs-report-error "Pymacs Lisp version is 0.24-beta2, Python is %s" (cadr reply))) (pymacs-report-error "Pymacs got an invalid initial reply")))) (set-match-data save-match-data-internal (quote evaporate))) 
    (let ((save-match-data-internal (match-data))) (unwind-protect (progn (let ((process (apply (quote start-process) "pymacs" buffer (let ... ...) "-c" (concat "import sys;" " from Pymacs.pymacs import main;" " main(*sys.argv[1:])") (append ... ...)))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\) " nil t))) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ ... ...))) (while (< (marker-position marker) limit-position) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) (goto-char (match-end 0)) (let ((reply (read (current-buffer)))) (if (and (pymacs-proper-list-p reply) (= (length reply) 2) (eq (car reply) (quote version))) (unless (string-equal (cadr reply) "0.24-beta2") (pymacs-report-error "Pymacs Lisp version is 0.24-beta2, Python is %s" (cadr reply))) (pymacs-report-error "Pymacs got an invalid initial reply")))) (set-match-data save-match-data-internal (quote evaporate)))) 
    (save-match-data (let ((process (apply (quote start-process) "pymacs" buffer (let ((python ...)) (if (or ... ...) "python" python)) "-c" (concat "import sys;" " from Pymacs.pymacs import main;" " main(*sys.argv[1:])") (append (and (>= emacs-major-version 24) (quote ...)) (mapcar (quote expand-file-name) pymacs-load-path))))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\) " nil t))) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ (match-end 0) (string-to-number (match-string 1))))) (while (< (marker-position marker) limit-position) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) (goto-char (match-end 0)) (let ((reply (read (current-buffer)))) (if (and (pymacs-proper-list-p reply) (= (length reply) 2) (eq (car reply) (quote version))) (unless (string-equal (cadr reply) "0.24-beta2") (pymacs-report-error "Pymacs Lisp version is 0.24-beta2, Python is %s" (cadr reply))) (pymacs-report-error "Pymacs got an invalid initial reply")))) 
    (save-current-buffer (set-buffer buffer) (erase-buffer) (buffer-disable-undo) (pymacs-set-buffer-multibyte nil) (set-buffer-file-coding-system (quote raw-text)) (save-match-data (let ((process (apply (quote start-process) "pymacs" buffer (let (...) (if ... "python" python)) "-c" (concat "import sys;" " from Pymacs.pymacs import main;" " main(*sys.argv[1:])") (append (and ... ...) (mapcar ... pymacs-load-path))))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\) " nil t))) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ (match-end 0) (string-to-number ...)))) (while (< (marker-position marker) limit-position) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) (goto-char (match-end 0)) (let ((reply (read (current-buffer)))) (if (and (pymacs-proper-list-p reply) (= (length reply) 2) (eq (car reply) (quote version))) (unless (string-equal (cadr reply) "0.24-beta2") (pymacs-report-error "Pymacs Lisp version is 0.24-beta2, Python is %s" (cadr reply))) (pymacs-report-error "Pymacs got an invalid initial reply"))))) 
    (with-current-buffer buffer (erase-buffer) (buffer-disable-undo) (pymacs-set-buffer-multibyte nil) (set-buffer-file-coding-system (quote raw-text)) (save-match-data (let ((process (apply (quote start-process) "pymacs" buffer (let (...) (if ... "python" python)) "-c" (concat "import sys;" " from Pymacs.pymacs import main;" " main(*sys.argv[1:])") (append (and ... ...) (mapcar ... pymacs-load-path))))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\) " nil t))) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ (match-end 0) (string-to-number ...)))) (while (< (marker-position marker) limit-position) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) (goto-char (match-end 0)) (let ((reply (read (current-buffer)))) (if (and (pymacs-proper-list-p reply) (= (length reply) 2) (eq (car reply) (quote version))) (unless (string-equal (cadr reply) "0.24-beta2") (pymacs-report-error "Pymacs Lisp version is 0.24-beta2, Python is %s" (cadr reply))) (pymacs-report-error "Pymacs got an invalid initial reply"))))) 
    (let ((buffer (get-buffer-create "*Pymacs*"))) (with-current-buffer buffer (erase-buffer) (buffer-disable-undo) (pymacs-set-buffer-multibyte nil) (set-buffer-file-coding-system (quote raw-text)) (save-match-data (let ((process (apply (quote start-process) "pymacs" buffer (let ... ...) "-c" (concat "import sys;" " from Pymacs.pymacs import main;" " main(*sys.argv[1:])") (append ... ...)))) (pymacs-kill-without-query process) (while (progn (goto-char (point-min)) (not (re-search-forward "<\\([0-9]+\\) " nil t))) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper did not start within %d seconds" pymacs-timeout-at-start))) (let ((marker (process-mark process)) (limit-position (+ ... ...))) (while (< (marker-position marker) limit-position) (unless (accept-process-output process pymacs-timeout-at-start) (pymacs-report-error "Pymacs helper probably was interrupted at start"))))) (goto-char (match-end 0)) (let ((reply (read (current-buffer)))) (if (and (pymacs-proper-list-p reply) (= (length reply) 2) (eq (car reply) (quote version))) (unless (string-equal (cadr reply) "0.24-beta2") (pymacs-report-error "Pymacs Lisp version is 0.24-beta2, Python is %s" (cadr reply))) (pymacs-report-error "Pymacs got an invalid initial reply"))))) (if (not pymacs-use-hash-tables) (setq pymacs-weak-hash t) (when pymacs-used-ids (let ((pymacs-transit-buffer buffer) (pymacs-forget-mutability t) (pymacs-gc-inhibit t)) (pymacs-apply "zombie_python" pymacs-used-ids)) (setq pymacs-used-ids nil)) (setq pymacs-weak-hash (make-hash-table :weakness (quote value))) (if (boundp (quote post-gc-hook)) (add-hook (quote post-gc-hook) (quote pymacs-schedule-gc)) (setq pymacs-gc-timer (run-at-time 20 20 (quote pymacs-schedule-gc))))) (setq pymacs-transit-buffer buffer)) 
    pymacs-start-services() 
    (if (and pymacs-transit-buffer (buffer-name pymacs-transit-buffer) (get-buffer-process pymacs-transit-buffer)) nil (when pymacs-weak-hash (unless (or (eq pymacs-auto-restart t) (and (eq pymacs-auto-restart (quote ask)) (yes-or-no-p "The Pymacs helper died. Restart it? "))) (pymacs-report-error "There is no Pymacs helper!"))) (pymacs-start-services)) 
    (unless (and pymacs-transit-buffer (buffer-name pymacs-transit-buffer) (get-buffer-process pymacs-transit-buffer)) (when pymacs-weak-hash (unless (or (eq pymacs-auto-restart t) (and (eq pymacs-auto-restart (quote ask)) (yes-or-no-p "The Pymacs helper died. Restart it? "))) (pymacs-report-error "There is no Pymacs helper!"))) (pymacs-start-services)) 
    pymacs-serve-until-reply("eval" (pymacs-print-for-apply (quote "pymacs_load_helper") (quote ("ropemacs" "rope-")))) 
    pymacs-call("pymacs_load_helper" "ropemacs" "rope-") 
    (let ((lisp-code (pymacs-call "pymacs_load_helper" module prefix))) (cond (lisp-code (let ((result (eval lisp-code))) (message "Pymacs loading %s...done" module) result)) (noerror (message "Pymacs loading %s...failed" module) nil) (t (pymacs-report-error "Pymacs loading %s...failed" module)))) 
    pymacs-load("ropemacs" "rope-") 
    eval-buffer(#<buffer *load*> nil "/home/wvxvw/.emacs" nil t) ; Reading at buffer position 11007 
    load-with-code-conversion("/home/wvxvw/.emacs" "/home/wvxvw/.emacs" t t) 
    load("~/.emacs" t t) 
    #[0 "\205\262 

: 아래

는 역 추적입니다
[email protected]:~$ python -c 'import sys; 
from Pymacs.pymacs import main; 
main(*sys.argv[1:])' -f "/home/wvxvw/programs/pymacs/" "/home/wvxvw/programs/rope-0.9.3/" "/home/wvxvw/programs/ropemacs/" "/home/wvxvw/programs/ropemode/" 
> > Traceback (most recent call last): 
    File "<string>", line 3, in <module> 
    File "/usr/lib/python2.7/dist-packages/Pymacs/pymacs.py", line 57, in main 
    options, arguments = getopt.getopt(arguments, 'd:s:') 
    File "/usr/lib/python2.7/getopt.py", line 90, in getopt 
    opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:]) 
    File "/usr/lib/python2.7/getopt.py", line 190, in do_shorts 
    if short_has_arg(opt, shortopts): 
    File "/usr/lib/python2.7/getopt.py", line 206, in short_has_arg 
    raise GetoptError('option -%s not recognized' % opt, opt) 
getopt.GetoptError: option -f not recognized 

스위치 -f을 제거하면 정상적으로 작동하는 것 같습니다. (예전처럼!). 제 질문은 이렇습니다 : 왜이 ​​스위치가 필요 했습니까? 이 스위치가 필요하다면 다른 어떤 일을 저지른 것일 수도 있지만 저에게는 효과가 없습니다. 나는 다음 -f 스위치를 주석 경우

, 그것은 버전 확인에 실패

이제

Debugger entered--Lisp error: (error "Pymacs Lisp version is 0.24-beta2, Python is 0.23") , 어떻게 Pymacs의 0.24 - 베타 2 버전을받을 수 있나요? 죄송합니다. 이전 epy-setup에 대한 참조를 삭제하는 것을 잊어 버렸지 만, 제거한 후에 Pymacs는 적절한 버전으로 시작됩니다 (그러나 -f 스위치는 필요 없습니다). 내가 도대체 ​​뭘 잘못하고있는 겁니까?

답변

1

대답은 여기에 있습니다 :

sys.argv에와 IMO http://docs.python.org/library/sys.html#module-sys

The list of command line arguments passed to a Python script. argv[0] is the script name (it is operating system dependent whether this is a full pathname or not). If the command was executed using the -c command line option to the interpreter, argv[0] is set to the string '-c'. If no script name was passed to the Python interpreter, argv[0] is the empty string. 

To loop over the standard input, or the list of files given on the command line, see the fileinput module. 

[1] 당신의 모든 나머지 인수를 얻을; "-f"는 일부 쉘 스크립트에서 사용합니다. 여기서는 적합하지 않습니다.