I have the following emacs script from here
#!/usr/local/bin/emacs --script
;;; rcat --- cat
;;; Commentary:
;;; cat function in elisp
;;; Code:
;;-*- mode: emacs-lisp;-*-
(defun process (string)
"Just reverse the STRING."
(concat (nreverse (string-to-list string))))
(condition-case nil
(let (line)
;;commented out b/c not relevant for `cat`, but potentially useful
(princ "argv is ")
(princ argv)
(princ "\n")
(princ "command-line-args is" )
(princ command-line-args)
(princ "\n")
(while (setq line (read-from-minibuffer ""))
(princ (process line))
(princ "\n")))
(error nil))
(provide 'rcat)
;;; rcat ends here
It works well but I want to use the s package for string manipulation, and convert my script to this:
#!/usr/local/bin/emacs --batch
;;; rcat --- cat
;;; Commentary:
;;; reverse lines cat function in elisp
;;; Code:
;;-*- mode: emacs-lisp;-*-
(require 's)
(condition-case nil
(let (line)
;;commented out b/c not relevant for `cat`, but potentially useful
(princ "argv is ")
(princ argv)
(princ "\n")
(princ "command-line-args is" )
(princ command-line-args)
(princ "\n")
(while (setq line (read-from-minibuffer ""))
(princ (s-reverse line))
(princ "\n")))
(error nil))
(provide 'rcat)
;;; rcat ends here
The first code works well:
./rcat 1 2 3 4 < stuff.txt
argv is (1 2 3 4)
command-line-args is(/usr/local/Cellar/emacs/HEAD-5583e64_1/Emacs.app/Contents/MacOS/Emacs -scriptload ./rcat 1 2 3 4)
dcba
4321
But executing the second, I get:
Cannot open load file: No such file or directory, s
I'm not sure if using cask, batch-mode or something should work.