new comint mod in emacs for plink (putty): Symbol&

2019-02-19 06:31发布

问题:

i want to use a new comint mode for plink(putty), i put the code in init.el, but if M-x run-plink, i got below error:

let*: Symbol's function definition is void: comint-check-proc

;; path    
(defvar plink-file-path "C:/Programme/Putty/plink.exe"     
  "Path to the program used by `run-plink'") 

;; arguments
(defvar plink-arguments '() 
  "Commandline arguments to pass to `plink'") 

;; prompt
(defvar plink-prompt-regexp "^>\s" 
"Prompt for `run-plink'.")

;; Run-plink     
(defun run-plink ()     
  "Run an inferior instance of `plink.js' inside Emacs."     
  (interactive)     
  (setq plink-buffer "*Plink*")     
  (let* ((plink-program plink-file-path) (buffer (comint-check-proc "Plink")))     
    ;; pop to the "*plink*" buffer if the process is dead, the 
    ;; buffer is missing or it's got the wrong mode. 
    (pop-to-buffer-same-window 
     (if (or buffer (not (derived-mode-p 'plink-mode)) 
             (comint-check-proc (current-buffer))) 
         (get-buffer-create (or buffer "*Plink*")) 
       (current-buffer))) 
    ;; create the comint process if there is no buffer. 
    (unless buffer 
      (apply 'make-comint-in-buffer "Plink" buffer plink-program plink-arguments) 
      (plink-mode)))) 

;; plink-mode    
(define-derived-mode plink-mode comint-mode "plink" nil "plink"     
  (setq comint-process-echoes t)     
  (setq comint-use-prompt-regexp t)     
  (setq comint-prompt-regexp plink-prompt-regexp)     
  ; ">" read-only    
  (setq comint-prompt-read-only t)     
  (set (make-local-variable 'paragraph-separate) "..'")     
  (set (make-local-variable 'paragraph-start) plink-prompt-regexp))

回答1:

You have not loaded library comint. You need to do that before Emacs can know about comint-check-proc.

Add a (require 'comint), either in your init file or near the beginning of run-plink - somewhere before it tries to use comint-check-proc.



回答2:

To give this question an answer, which is also meaningful for other questions marked as duplicates of this one, but actually are about other packages not being loaded, I will give a more general answer, which should be applicable to the other questions as well.

Generally an error Symbol's function definition is void often indicates, that a package was not loaded, but then someone/something tried to use it.

So the general answer, that you probably need to (require '<package name>) in your init.el, where the package name is the name of the package which provides what is currently void.