雑多で中途半端なEmacs Lisp集
諸事情によって、というより途中で力尽きて、完成する事のないEmacs Lispをここに集める事にした。
(defun netcat (host port)
"ncを実行する"
(interactive (list (read-from-minibuffer "Host: ")
(read-from-minibuffer "Port: ")))
(make-process
:name "*NETCAT*"
:buffer "*NETCAT*"
:command `("/usr/bin/nc" ,host ,port)
:sentinel (lambda (process event)
(when (not (process-live-p process))
(message event)
(print (process-exit-status process))))))
(defun curl (url method)
"curlを実行する"
(interactive (list (read-from-minibuffer "URL: ")
(completing-read "Method: " '("GET" "POST" "PUT" "PATCH" "DELETE" "OPTIONS"))))
(make-process
:name "*cURL*"
:buffer "*cURL*"
:command `("/usr/bin/curl" ,url "-X" ,method)
:sentinel (lambda (process event)
(when (not (process-live-p process))
(message event)
(print (process-exit-status process))))))
(defun process-send-string-from-minibuffer (process string)
"ミニバッファから入力したデータをプロセスに送信する"
(interactive
(list (if-let ((process-name (completing-read
"Process: " (mapcar #'process-name (process-list)) nil nil
(if-let ((current-process (get-buffer-process (current-buffer))))
(process-name current-process)))))
(get-process process-name))
(read-from-minibuffer "Input from Minibuffer: ")))
(process-send-string process string))
(defun process-send-string-from-kill-ring (process string)
"キルリングから取得したデータをプロセスに送信する"
(interactive
(list (if-let ((process-name (completing-read
"Process: " (mapcar #'process-name (process-list)) nil nil
(if-let ((current-process (get-buffer-process (current-buffer))))
(process-name current-process)))))
(get-process process-name))
(read-from-kill-ring "Input from kill-ring: ")))
(process-send-string process string))
(provide 'symdon)