Terminal emulator not spawning process - emacs

C:/Program Files (x86)/emacs-24.2/bin/cmdproxy.exe (the one supplied with the copy of Emacs) isn't firing up in the terminal-emulator, no matter if I try doing it using eval or M-x. Nor is any other CLI such as C:/Program Files (x86)/Git/bin/sh.exe or D:/user_files/Downloads/plink.exe.
It returns:
apply: Spawning child process: invalid argument
when run interactively (M-x)
or
Debugger entered--Lisp error: (file-error "Spawning child process" "invalid argument")
signal(file-error ("Spawning child process" "invalid argument"))
byte-code("\301 \210\302#A\"\207" [err fundamental-mode signal] 3)
terminal-emulator("*PUTTY-RUNNING-TAIL*" "D:/user_files/Downloads/plink.exe" ("10.10.0.145"))
eval((terminal-emulator "*PUTTY-RUNNING-TAIL*" "D:/user_files/Downloads/plink.exe" (cons "192.168.10.8" nil)) nil)
eval-expression((terminal-emulator "*PUTTY-RUNNING-TAIL*" "D:/user_files/Downloads/plink.exe" (cons "192.168.10.8" nil)) nil)
call-interactively(eval-expression nil nil)
when run from eval ((terminal-emulator "*PUTTY-RUNNING-TAIL*" "D:/user_files/Downloads/plink.exe" (cons "192.168.10.8" nil))).
Is this a bug or am I missing something?

I am afraid that the root cause of your problem is a hardcoded /bin/sh in terminal-emulator code ((start-process "terminal-emulator" (current-buffer) "/bin/sh" "-c" ...). You could try changing that to a shell that is valid for you, but I am not optimistic about the outcome.
See this question about a similar problem for a different kind of terminal emulation under Emacs in a Windows based platform.

Related

Emacs markdown mode live preview doesn' work - wrong-type-argument stringp nil

I get error "wrong-type-argument stringp nil" when execute one of markdown-mode plugin's live preview command (mode, export, re-export ...).
markdown-live-preview-mode only passes once, when I start fresh emacs and immediately execute command. But still it doesn't update when I change anything in markdown source.
I use pandoc to generate mardown html:
(custom-set-variables
'(markdown-command "/usr/bin/pandoc"))
Here are debug logs:
(1) for markdown-live-preview-export
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
expand-file-name(nil)
eww-open-file(nil)
markdown-live-preview-window-eww(nil)
markdown-live-preview-export()
call-interactively(markdown-live-preview-export record nil)
command-execute(markdown-live-preview-export record)
helm-M-x(nil #("markdown-live-preview-export" 0 28 (match-part "markdown-live-preview-export")))
call-interactively(helm-M-x nil nil)
command-execute(helm-M-x)
(2) for markdown-live-preview-mode
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
expand-file-name(nil)
eww-open-file(nil)
markdown-live-preview-window-eww(nil)
markdown-live-preview-export()
markdown-live-preview-mode(toggle)
call-interactively(markdown-live-preview-mode record nil)
command-execute(markdown-live-preview-mode record)
helm-M-x(nil #("markdown-live-preview-mode" 0 26 (match-part "markdown-live-preview-mode")))
call-interactively(helm-M-x nil nil)
command-execute(helm-M-x)
It seems like it doesn't pass proper path of generated html file to eww. Instead it is nil.
Thanks!
I'm using pandoc and it turned out, that I had missing packages for LaTeX (which is used in my markdown files). After installing texlive-base, texlive-fonts-recommended and texlive-latex-recommended everything works just fine!

failed to download melpa archive

I am using emacs 24.5 and i am trying to add the melpa archive to emacs to my package-archives . when i try M-x list-packages i get failed to download melpa archive and the list of packages of melpa repo doesn't appear. here is what i got when i try M-x toggle-debug-on-error
Debugger entered--Lisp error: (error "Could not create connection to melpa.org:443")
signal(error ("Could not create connection to melpa.org:443"))
error("Could not create connection to %s:%d" "melpa.org" 443)
url-http([cl-struct-url "https" nil nil "melpa.org" nil "/packages/archive- contents" nil nil t nil t] #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] (nil))
url-https([cl-struct-url "https" nil nil "melpa.org" nil "/packages/archive- contents" nil nil t nil t] #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] (nil))
url-retrieve-internal("https://melpa.org/packages/archive-contents" #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] (nil) nil nil)
url-retrieve("https://melpa.org/packages/archive-contents" #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] nil nil nil)
url-retrieve-synchronously("https://melpa.org/packages/archive-contents")
url-insert-file-contents("https://melpa.org/packages/archive-contents")
package--download-one-archive(("melpa" . "https://melpa.org/packages/") "archive-contents")
#[0 "\301\300\302\"\207" [("melpa" . "https://melpa.org/packages/")
package--download-one-archive "archive-contents"] 3 "\n\n(fn)"]()
funcall(#[0 "\301\300\302\"\207" [("melpa" . "https://melpa.org/packages/") package--download-one-archive "archive-contents"] 3 "\n\n(fn)"])
package-refresh-contents()
list-packages(nil)
call-interactively(list-packages record nil)
command-execute(list-packages record)
execute-extended-command(nil "list-packages")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
and my .emacs file
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-archives
(quote
(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
i have found exactly where the problem is...to download the melpa list in emacs (emacs must access the internet) so you must include the library files to do that...download gnutls-3.3.11-w32-bin from here https://sourceforge.net/projects/ezwinports/files/ ... extract the downloaded file... and put the .dll files in bin file in emacs folder...
hope you are happy with my little help :)
I had a similar issue on Win7 and this answer from StackExchange helped me.
In short, you have to download compiled Windows GnuTLS libraries and dependencies from here and unzip it to the emacs folder. Get emacs-25-i686-deps.zip if you use 32-bit Windows and get emacs-25-x86_64-deps.zip if you use 64-bit.
I had this problem. It could be a $PATH issue.
For me, since I was using Emacs 25.2 64-bit, I had to download the emacs-25-x86_64-deps.zip files from here:
https://ftp.gnu.org/gnu/emacs/windows/emacs-25/

closure-common: sbcl borks because standard readtable modified

I updated quicklisp to the latest February version and went to re-run a few of my unit tests for the xlmanip workbook/worksheet reader I'm developing. SBCL borks on the unit test because it recompiles the closure-common package and closure-common modifies the standard readtable (in a nice way, actually.)
My one option is to fork the closure-common code base, hope that the maintainer actually responds to the patch, and pray that the patch is accepted, follow clozure-common dependencies in quicklisp where SET-DISPATCH-MACRO-CHARACTER is also called for the same reason.
Does anyone know of a workaround for this problem? closure-common isn't the only package that has this issue, I'm fairly certain.
EDIT: If I have to clone and hack clozure-common, what is the recommended/preferred way for localizing readtable modifications or switching to a custom readtable?
EDIT #2: Here's the output transcript using a freshly installed quicklisp (specifically, look at the last line of closure-common-20101107-git/syntax.lisp where the call to SET-DISPATCH-MACRO-CHARACTER occurs):
To load "xlmanip/tests":
Load 1 ASDF system:
xlmanip/tests
; Loading "xlmanip/tests"
.
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
yes, using code points.
..
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
yes, using code points.
;;; Building Closure with CHARACTER RUNES
........While evaluating the form starting at line 4, column 0
of #P"/tmp/xlmanip17497a.lisp":
Fatal condition:
SET-DISPATCH-MACRO-CHARACTER would modify the standard readtable.
See also:
The ANSI Standard, Section 2.1.1.2
The ANSI Standard, Glossary entry for "standard readtable"
Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1002A7D263}>
0: ((LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX))
1: (SB-IMPL::CALL-WITH-SANE-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX) {1006B1F8BB}>)
2: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX) {1006B1F88B}>)
3: (SB-DEBUG:PRINT-BACKTRACE :STREAM #<SB-SYS:FD-STREAM for "standard error" {1003135713}> :START 0 :FROM :DEBUGGER-FRAME :COUNT 4611686018427387903 :PRINT-THREAD T :PRINT-FRAME-SOURCE NIL :METHOD-FRAME-STYLE NIL :EMERGENCY-BEST-EFFORT NIL)
4: ((LAMBDA NIL :IN UIOP/IMAGE:PRINT-BACKTRACE))
5: ((LAMBDA NIL :IN UIOP/STREAM:CALL-WITH-SAFE-IO-SYNTAX))
6: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN UIOP/STREAM:CALL-WITH-SAFE-IO-SYNTAX) {1006B1F86B}>)
7: (UIOP/IMAGE:PRINT-CONDITION-BACKTRACE #<SB-INT:STANDARD-READTABLE-MODIFIED-ERROR {1006B1D643}> :STREAM #<SB-SYS:FD-STREAM for "standard error" {1003135713}> :COUNT NIL)
8: (UIOP/IMAGE:HANDLE-FATAL-CONDITION #<SB-INT:STANDARD-READTABLE-MODIFIED-ERROR {1006B1D643}>)
9: (SIGNAL #<SB-INT:STANDARD-READTABLE-MODIFIED-ERROR {1006B1D643}>)
10: (CERROR "Frob it anyway!" SB-INT:STANDARD-READTABLE-MODIFIED-ERROR :OPERATION SET-DISPATCH-MACRO-CHARACTER)
11: (SET-DISPATCH-MACRO-CHARACTER #\# #\/ RUNES::RUNE-READER #<READTABLE {100041EA83}>)
12: (SB-FASL::LOAD-FASL-GROUP #S(SB-FASL::FASL-INPUT :STREAM #<SB-SYS:FD-STREAM for "file <homedir>/.cache/common-lisp/sbcl-1.3.1.243-55a6786-macosx-x64/<homedir>/quicklisp/dists/quicklisp/software/closure-common-20101107-git/syntax.fasl" {1006B0F693}> :TABLE #(282 SET *PACKAGE* "RUNES" #<PACKAGE "SB-IMPL"> SB-IMPL::%DEFUN #<PACKAGE "RUNES"> RUNES::RT-WHITE-SPACE-P STRING MAKE-STRING-INPUT-STREAM :EOF PEEK-CHAR ...) :STACK #(0 SET-DISPATCH-MACRO-CHARACTER #\# #\/ RUNES::RUNE-READER 0 50 "<homedir>/quicklisp/dists/quicklisp/software/closure-common-20101107-git/syntax.lisp" #<SB-KERNEL:LAYOUT for SB-C:DEFINITION-SOURCE-LOCATION {10000415B3}> NIL NIL NIL ...) :DEPRECATED-STUFF NIL :SKIP-UNTIL NIL) NIL)
<...truncated... error occurs in syntax.lisp>
The script that generates this output:
#!/bin/sh
tmpf=/tmp/xlmanip$$a.lisp
cat >${tmpf} <<__EOF__
(proclaim '(optimize speed space))
;;; SBCL:Muffle compiler-notes
#+sbcl (declaim (sb-ext:muffle-conditions sb-ext:compiler-note))
(ql:quickload :xlmanip/tests)
(time (asdf:oos 'asdf:test-op :xlmanip))
(quit)
__EOF__
trap "rm -f ${tmpf}" 0 1 2 3 15
if test "x${CL_LISPS}" = x; then
CL_LISPS="sbcl ccl clisp ecl"
fi
for l in $CL_LISPS; do
echo "\n======== $l ========\n"
cl-launch --lisp $l --execute --quicklisp --init '(load "'"${tmpf}"'")'
done
Diagnosing the problem: Somewhere in the code stream that loads closure-common, there seems to be a call similar to:
(with-standard-io-syntax
(load "closure-common"))
That's the only way that I've found to trip the standard *readtable* modification. In all other cases, e.g., from the sbcl prompt, set-dispatch-macro-character doesn't modify the standard *readtable*. I haven't traced the problem into ASDF, UIOP or Quicklisp itself, although those are likely candidates as well.
I've bitten the bullet, cloned the closure-common repo and decided to go with named-readtables. Very likely that if I publish these changes to quicklisp, implicitly taking maintainership, there will be ripple changes into other dependent packages that use #" and #/ reader macros provided by closure-common.

in Emacs, how to open file in external program without errors?

I use the following code to direct Emacs to open PDF files using an external application:
(require 'openwith)
'(openwith-associations (quote (("\\.skim\\'" "open" (file)) ("\\.pdf\\'" "open" (file)))))
(openwith-mode t)
When I visit a PDF file, it successfully opens the file in my external program, but it also gives me errors and a backtrace:
Debugger entered--Lisp error: (error "Opened Foundation - Isaac Asimov.pdf in external program")
signal(error ("Opened Foundation - Isaac Asimov.pdf in external program"))
error("Opened %s in external program" "Foundation - Isaac Asimov.pdf")
openwith-file-handler(insert-file-contents "/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf" t nil nil nil)
insert-file-contents("~/iBooks/Books/Foundation - Isaac Asimov.pdf" t)
byte-code("\302\303 \302\"\210)\302\207" [inhibit-read-only filename t insert-file-contents] 3)
find-file-noselect-1(#<killed buffer> "~/iBooks/Books/Foundation - Isaac Asimov.pdf" nil nil "~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books/Foundation - Isaac Asimov.pdf" (21490564 16777218))
find-file-noselect("/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf" nil nil nil)
find-file("/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf")
mapc(find-file ("/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf"))
helm-find-many-files("/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf")
apply(helm-find-many-files "/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf")
How do I open files in external applications without throwing errors?
My recommendation would be to use start-process in conjunction with dired-mode to open files in external applications.
Xah Lee has written short, yet effective, function to handle opening files in the external default application set up on the OS: http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html
(defun xah-open-in-external-app (&optional file)
"Open the current file or dired marked files in external app.
The app is chosen from your OS's preference."
(interactive)
(let ( doIt
(myFileList
(cond
((string-equal major-mode "dired-mode") (dired-get-marked-files))
((not file) (list (buffer-file-name)))
(file (list file)))))
(setq doIt (if (<= (length myFileList) 5)
t
(y-or-n-p "Open more than 5 files? ") ) )
(when doIt
(cond
((string-equal system-type "windows-nt")
(mapc (lambda (fPath) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\" fPath t t)) ) myFileList))
((string-equal system-type "darwin")
(mapc (lambda (fPath) (shell-command (format "open \"%s\"" fPath)) ) myFileList) )
((string-equal system-type "gnu/linux")
(mapc (lambda (fPath) (let ((process-connection-type nil)) (start-process "" nil "xdg-open" fPath)) ) myFileList) ) ) ) ) )
I use something similar (which can be viewed at the following Github link), but it is not as straight forward as the function written by Xah Lee: https://github.com/lawlist/dired-read-file-name/blob/master/dired-read-file-name.el
If the path to the file is in the buffer, I save it with M-w then invoke shell-command and call xdg-open C-y. This will yank the path to the file previously saved and opens it with the associated program. xdg-open takes care of finding the right program to open that file (screenshots).
In a dired buffer, browse-url-of-dired-file ("ask a WWW browser to display the file named on this line" - bound to W by default for me) opened a .csv file in Excel & a .md file in MacDown (both the OS default for those filetypes).
This is good enough for me, I might try to work out how to do it for the current buffer file some time.
(macOS Monterey 12.6.2, Emacs 28.2)

cl-pdf output error

I'm trying to use cl-pdf for some fairly basic PDF generation, but I'm getting tripped up at the examples (which is embarassing to say the least).
When I run the first example included in the package
(defun example1 (&optional (file #P"/tmp/ex1.pdf"))
(pdf:with-document ()
(pdf:with-page ()
(pdf:with-outline-level ("Example" (pdf:register-page-reference))
(let ((helvetica (pdf:get-font "Helvetica")))
(pdf:in-text-mode
(pdf:set-font helvetica 36.0)
(pdf:move-text 100 800)
(pdf:draw-text "cl-pdf: Example 1"))
(pdf:translate 230 500)
(loop repeat 150
for i = 0.67 then (* i 1.045)
do (pdf:in-text-mode
(pdf:set-font helvetica i)
(pdf:set-rgb-fill (/ (random 255) 255.0)
(/ (random 255) 255.0)
(/ (random 255) 255.0))
(pdf:move-text (* i 3) 0)
(pdf:show-text "cl-typesetting"))
(pdf:rotate 13)))))
(pdf:write-document file)))
by running (example1 #P"/home/inaimathi/Desktop/ex1.pdf") it gives me this error
#<SB-SYS:FD-STREAM for "file /home/inaimathi/Desktop/test.pdf"
{CF9D931}> is not a binary output stream.
[Condition of type SIMPLE-TYPE-ERROR]
Restarts:
0: [ABORT] Exit debugger, returning to top level.
The same thing happens when I call (example1), or when I do
(with-open-file
(test-file #P"/home/inaimathi/Desktop/ex1.pdf"
:direction :output :if-does-not-exist :create)
(example1 test-file))
Finally, if I try
(with-open-file
(test-file #P"/home/inaimathi/Desktop/ex1.pdf"
:direction :output :if-does-not-exist :create
:element-type '(unsigned-byte 8))
(example1 test-file))
I get the error
#<SB-SYS:FD-STREAM for "file /home/inaimathi/Desktop/test.pdf"
{D197C99}> is not a character output stream.
[Condition of type SIMPLE-TYPE-ERROR]
Restarts:
0: [ABORT] Exit debugger, returning to top level.
Is there a way to declare a binary character stream? How do I get simple output out of cl-pdf? I'm using SBCL straight out of the debian repos (which is 1.0.29, I think), in case it matters.
(setf pdf:*compress-streams* nil) should help. It's trying to write binary data to a character stream, and while that works on LispWorks and some other systems, it doesn't work everywhere and particularly not on SBCL.
EDIT 2: asdf-install is unmaintained and deprecated. It is best to use Quicklisp. To install Quicklisp, you'll need to download it:
$ curl -O https://beta.quicklisp.org/quicklisp.lisp
Then add cl-pdf to your lisp installation:
$ sbcl --load quicklisp.lisp
* (quicklisp-quickstart:install)
* (ql:quickload "vecto")
* (ql:add-to-init-file)
* (exit)
Now all you need to do is add
(load "~/quicklisp/setup.lisp") ; if it installed in the default location
to your .lisp file, and you can then add
(ql:quickload "cl-pdf")
EDIT: This is what I ended up doing. The solution by xach above would also work.
In the end I had to wget http://www.fractalconcept.com/download/cl-pdf-current.tgz and install that.
For the newbs (since I remember how frustrating it is for someone new to Common Lisp to hear "just do a checkout and install it"):
1.Do the checkout as above (I assume you've done this in your home directory from now on)
2.Type in tar xvzf cl-pdf-current.tgz (the point is to get a tarball of the folder. You can do this through the GUI too, it makes no difference)
3.Hop into your SBCL prompt and enter
(require 'asdf)
(require 'asdf-install)
4.If you already installed cl-pdf using (asdf-install:install 'cl-pdf), then you'll need to enter (asdf-install:uninstall 'cl-pdf)
5.Type (asdf-install:install "/home/[your home folder name]/cl-pdf-current.tgz")
I got one compilation error throughout this process, which I just selected [Accept] for. It still seems to work fine.
Hopefully the upcoming release of quicklisp will reduce the need for this sort of package hunting.