emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacsclient in elisp


From: Jean Louis
Subject: Re: emacsclient in elisp
Date: Thu, 20 May 2021 17:31:55 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Daniel Mendler <mail@daniel-mendler.de> [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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]