From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.devel Subject: Re: emacsclient in elisp Date: Thu, 20 May 2021 17:31:55 +0300 Message-ID: References: <00ce8ae3-bb21-c58f-cd32-c196f146842b@daniel-mendler.de> <6fed43bb-d880-bcd5-6f6f-004b6182e539@daniel-mendler.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2926"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.6 (2021-03-06) Cc: Stefan Monnier , "emacs-devel@gnu.org" To: Daniel Mendler Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 20 16:58:42 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ljk8I-0000Wv-Cq for ged-emacs-devel@m.gmane-mx.org; Thu, 20 May 2021 16:58:42 +0200 Original-Received: from localhost ([::1]:40718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljk8G-0006xd-DT for ged-emacs-devel@m.gmane-mx.org; Thu, 20 May 2021 10:58:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljjl6-0007WQ-Kd for emacs-devel@gnu.org; Thu, 20 May 2021 10:34:44 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:60001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljjl2-0003yf-Va for emacs-devel@gnu.org; Thu, 20 May 2021 10:34:44 -0400 Original-Received: from localhost ([::ffff:102.81.93.246]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 00000000000ADF16.0000000060A6737D.00007DAE; Thu, 20 May 2021 07:34:36 -0700 Mail-Followup-To: Daniel Mendler , Stefan Monnier , "emacs-devel@gnu.org" Content-Disposition: inline In-Reply-To: <6fed43bb-d880-bcd5-6f6f-004b6182e539@daniel-mendler.de> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:269499 Archived-At: * Daniel Mendler [2021-05-19 17:14]: > I cannot start the Emacs in the background and communicate with it by > sending/receiving data via stdin/stdout, since Emacs does not offer an > asynchronous facility to read from stdin. Asynchronous reading would be > needed on the daemon. If I am calling `read-from-minibuffer` there it > reads from stdin but blocks the process. Is this correct? It would be useful to have Emacs that can read stdin. To remedy that, I have to make such Common Lisp scripts that read from STDIN, a wrapper that will provide file to Emacs. Can you maybe improve Emacs to read from STDIN? #!/home/data1/protected/bin/lisp (defparameter memdir "/dev/shm/") (defparameter tmp-file "rcd-wrs-XXXXXX") (defparameter tmp-org (format nil "~a~a.org" memdir tmp-file)) (defparameter tmp-md (format nil "~a~a.md" memdir tmp-file)) ;;(delete-file tmp-org) ;;(delete-file tmp-md) (load "/home/data1/protected/Programming/lib/lisp/streamtools.lisp") ;; (require "syscalls") (defparameter org-autoloads.el (concatenate 'string (namestring (car (directory "/home/data1/protected/.emacs.d/elpa/org-20??????/"))) "org-autoloads.el")) (defun main () (let ((input '()) (output '())) (with-open-file (out tmp-org :direction :output :external-format "utf-8" :if-exists :supersede) (loop for line = (read-line *standard-input* nil nil) while line do (write-line line out))) (shell (format nil "emacs -Q -l ~a \"~a\" --batch -f org-mode -f org-md-export-to-markdown --kill" org-autoloads.el tmp-org)) (setf output (with-open-file (stream tmp-md :direction :input :external-format "utf-8") (loop for line = (read-line stream nil nil) while line collect line))) (setf output (format nil "~{~a~^~%~}" output)) (setf output (slurp-stream-io-command "markdown -F 0x4" output)) (princ output)) (exit)) ;; ;; (saveinitmem "org2html" :quiet t :init-function 'main :verbose nil :norc t :documentation "Converts Org standard input into markdown" :executable t) (main) -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns Sign an open letter in support of Richard M. Stallman https://stallmansupport.org/ https://rms-support-letter.github.io/