Python Emacs24&x2B;Pymacs-f交换机,Pymacs负载路径冗余?

Python Emacs24&x2B;Pymacs-f交换机,Pymacs负载路径冗余?,python,emacs,pymacs,Python,Emacs,Pymacs,我已经升级到Emacs24,当启动Pymacs时,它会因为超时而中断 以下是回溯: 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 withi

我已经升级到Emacs24,当启动Pymacs时,它会因为超时而中断

以下是回溯:

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
如果我移除
-f
开关,它似乎可以正常工作(就像以前一样!)。因此,我的问题是:为什么需要这种转换?如果需要这个开关的话,我可能会做错别的事情,但它对我不起作用

如果我随后注释掉
-f
开关,则版本检查失败:

调试器已输入--Lisp错误:(错误“Pymacs Lisp版本为0.24-beta2,Python版本为0.23”)
现在,如何获得Pymacs的0.24-beta2版本? 很抱歉,这是我忘记删除对旧epy设置的引用,但是,在删除它之后,Pymacs启动正常,版本正确(但不需要-f开关)。我做错了什么?

答案如下:

IMO与sys.argv[1:]一起,您将获得所有剩余的参数;一些shell脚本中的“-f”,此处不适用

(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)))
wvxvw@wvxvw-desktop:~$ 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
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.