lispbuilder-sdl doesn't work on osx due to sdl_delay - macos

my operate system is OS X 10.11.5, code with emacs+slime+sbcl
I loaded lispbuilder-sdl using command:
(asdf:operate 'asdf:load-op :cocoahelper)
(asdf:operate 'asdf:load-op :lispbuilder-sdl)
then copy the example code on here
(sdl:with-init ()
(sdl:window 320 240)
(sdl:update-display)
(sdl:with-events ()
(:quit-event () t)))
but nothing happened,so i type 'C-c C-c' to terminate the process,
it shows some error like this:
Restarts:
0: [CONTINUE] Continue from break.
1: [RETRY] Retry SLIME REPL evaluation request.
2: [*ABORT] Return to SLIME's top level.
3: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1003FC0003}>)
Backtrace:
0: ("bogus stack frame")
1: ("foreign function: SDL_Delay")
2: (LISPBUILDER-SDL-CFFI::SDL-DELAY 27)
3: ((SB-PCL::EMF LISPBUILDER-SDL::PROCESS-TIMESTEP) #<unavailable argument> #<unavailable argument> #<LISPBUILDER-SDL:FPS-FIXED {10059F6E43}> #<FUNCTION (LAMBDA NIL :IN #:DROP-THRU-TAG-1) {10056C6A0B}>)
4: ((:METHOD LISPBUILDER-SDL::PROCESS-TIMESTEP :AROUND (LISPBUILDER-SDL::FPS-MANAGER T)) #<LISPBUILDER-SDL:FPS-FIXED {10059F6E43}> #<FUNCTION (LAMBDA NIL :IN #:DROP-THRU-TAG-1) {10056C6A0B}>) [fast-metho..
5: ((LAMBDA ()))
6: (SB-INT:SIMPLE-EVAL-IN-LEXENV (LISPBUILDER-SDL:WITH-INIT NIL (LISPBUILDER-SDL:WINDOW 320 240) (LISPBUILDER-SDL:UPDATE-DISPLAY) (LISPBUILDER-SDL:WITH-EVENTS NIL (:QUIT-EVENT NIL T))) #<NULL-LEXENV>)
7: (EVAL (LISPBUILDER-SDL:WITH-INIT NIL (LISPBUILDER-SDL:WINDOW 320 240) (LISPBUILDER-SDL:UPDATE-DISPLAY) (LISPBUILDER-SDL:WITH-EVENTS NIL (:QUIT-EVENT NIL T))))
Is there anyone can help me fix this error?

I tried to reproduce your example (Linux/SBCL). First:
(ql:quickload :lispbuilder-sdl)
Then:
(sdl:with-init ()
(sdl:window 320 240)
(sdl:update-display)
(sdl:with-events ()
(:quit-event () t)))
This displays an empty window while the REPL hangs (as expected), until I close the window and can use the REPL again. But if I do C-c C-c while the window is displayed, then I obtain a stack trace similar to yours:
Interrupt from Emacs
[Condition of type SIMPLE-ERROR]
Restarts:
0: [CONTINUE] Continue from break.
1: [RETRY] Retry SLIME REPL evaluation request.
2: [*ABORT] Return to SLIME's top level.
3: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1003498033}>)
Backtrace:
0: ("bogus stack frame")
1: ((SB-PCL::EMF LISPBUILDER-SDL::PROCESS-TIMESTEP) #<unavailable argument> #<unavailable argument> #<LISPBUILDER-SDL:FPS-FIXED {1006F962A3}> #<FUNCTION (LAMBDA NIL :IN #:DROP-THRU-TAG-1) {1006F95F0B}>)
2: ((:METHOD LISPBUILDER-SDL::PROCESS-TIMESTEP :AROUND (LISPBUILDER-SDL::FPS-MANAGER T)) #<LISPBUILDER-SDL:FPS-FIXED {1006F962A3}> #<FUNCTION (LAMBDA NIL :IN #:DROP-THRU-TAG-1) {1006F95F0B}>) [fast-metho..
3: ((LAMBDA ()))
4: (SB-INT:SIMPLE-EVAL-IN-LEXENV (LISPBUILDER-SDL:WITH-INIT NIL (LISPBUILDER-SDL:WINDOW 320 240) (LISPBUILDER-SDL:UPDATE-DISPLAY) (LISPBUILDER-SDL:WITH-EVENTS NIL (:QUIT-EVENT NIL T))) #<NULL-LEXENV>)
5: (EVAL (LISPBUILDER-SDL:WITH-INIT NIL (LISPBUILDER-SDL:WINDOW 320 240) (LISPBUILDER-SDL:UPDATE-DISPLAY) (LISPBUILDER-SDL:WITH-EVENTS NIL (:QUIT-EVENT NIL T))))
--more--
However, everything is working as expected, because I can for example choose to continue the execution, or abort. That's what the interrupt is for.
My guess is that everything works fine but you can't see the window. I don't know why and I have no experience with OS X, unfortunately. Maybe if you try to actually display something (see below), as recommended in SDL window does not show, it could work.
Here is an example which draws something:
(sdl:with-init ()
(sdl:window 320 240)
(sdl:update-display)
(sdl:with-events ()
(:quit-event () t)
(:idle (sdl:fill-surface sdl:*white*)
(sdl:update-display))))

Related

Something Enables scroll-lock-mode in Emacs

I have Emacs running in WSL2
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2021-07-20
About couple of weeks ago open buffers started getting scroll-lock-mode enabled. I have it set to nil by default. Moreover, if I disable scroll-lock-mode after some time it gets enabled. I don't have anything anywhere in the configuration related to scrolling. I have instrumented scroll-lock-mode function, but when it jumps in it, seems to be called from random spots
(let ((last-message (current-message))) (setq scroll-lock-mode (cond ((eq arg 'toggle) (not scroll-lock-mode)) ((and (numberp arg) (< arg 1)) nil) (t t))) (when (boundp 'local-minor-modes) (setq local-minor-modes (delq 'scroll-lock-mode local-minor-modes)) (when scroll-lock-mode (push 'scroll-lock-mode local-minor-modes))) (if scroll-lock-mode (progn (setq scroll-lock-preserve-screen-pos-save scroll-preserve-screen-position) (setq-local scroll-preserve-screen-position 'always)) (setq scroll-preserve-screen-position scroll-lock-preserve-screen-pos-save)) (run-hooks 'scroll-lock-mode-hook (if scroll-lock-mode 'scroll-lock-mode-on-hook 'scroll-lock-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (unless (and (current-message) (not (equal last-message (current-message)))) (let ((local " in current buffer")) (message "Scroll-Lock mode %sabled%s" (if scroll-lock-mode "en" "dis") local))))))
scroll-lock-mode(toggle)
funcall-interactively(scroll-lock-mode toggle)
call-interactively#ido-cr+-record-current-command(#<subr call-interactively> scroll-lock-mode nil nil)
apply(call-interactively#ido-cr+-record-current-command #<subr call-interactively> (scroll-lock-mode nil nil))
call-interactively(scroll-lock-mode nil nil)
command-execute(scroll-lock-mode)
Here's the sample of the Messages buffer
Scroll-Lock mode enabled in current buffer
Scroll-Lock mode disabled in current buffer
GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2021-07-20
Mark set
Scroll-Lock mode enabled in current buffer
How to I make it disabled for good ? I used (setq-default scroll-lock-mode nil) but it is still being enabled by something.
disabling Scroll_lock ends the behavior
(define-key global-map (kbd "<Scroll_Lock>") nil)
linking the key back to scroll-lock-mode will let this problem re-emerge.
I haven't really figured out what's behind such erroneous auto trigger of scroll-lock-mode though.

calling org-content from lisp not working

When I call org-content from the active buffer I get the outline I want. However if I use it in a lisp function like this
(split-window-right (truncate (* W 0.75)))
(if (get-buffer "inbox.org")
(set-window-buffer nil "inbox.org")
(progn
(find-file "~/Documents/GTD/inbox.org")
(text-scale-set -1)))
(org-content)
The windows splits and the right buffer gets loaded but the org-content bit doesn't seem to do anything.
Any ideas of what I do wrong ?
Thanks,
Jouke
Here is a reproducible example, open a new buffer named test.org and define the following function in the *scratch* buffer:
(defun test ()
(let ((buffer (get-buffer "test.org")))
(when buffer
(set-window-buffer nil buffer)
(message "%s" (current-buffer)))))
The message being outputted is *scratch*: only the buffer associated with the window was changed, but what Emacs considers the current buffer did not.
If instead you use switch-to-buffer, as follows, the message displays the selected buffer:
(defun test ()
(let ((buffer (get-buffer "test.org")))
(when buffer
(switch-to-buffer buffer)
(message "%s" (current-buffer)))))
Applying the same change to your code makes (org-content) happy.

Emacs: Symbol's value as variable is void: Removes (init.el)

Sorry if this is a silly question; I am a complete novice when it comes to emacs.
Recently, I began to do research on how to set up emacs and stumbled upon a great video series by Mike Zamansky. However, whilst following this video (creating an org init file), all of the packages I installed onto my emacsclient proceeded to not work. During initialization, there was an error - namely, "Symbol's value as variable is void: Removes." I copied his tutorial verbatim and I don't see any potential syntactical errors - perhaps I overlooked some errors. However, I've been searching throughout the internet, but could not find any answers to this problem.
Here is the contents of the init.el file:
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
(package-initialize)
;; Bootstrap 'use-package'
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(org-babel-load-file (expand-file-name "~/.emacs.d/myinit.org"))
Here is the error:
Warning (initialization): An error occurred while loading
‘/Users/Kyojin/.emacs.d/init.el’:
Symbol's value as variable is void: Removes
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.
Debugger Output (--debug-init):
Debugger entered--Lisp error: (void-variable Removes)
eval-buffer(#<buffer *load*-527594> nil
"/Users/Kyojin/.emacs.d/myinit.el" nil t) ; Reading at buffer position
8
load-with-code-conversion("/Users/Kyojin/.emacs.d/myinit.el"
"/Users/Kyojin/.emacs.d/myinit.el" nil nil)
load("/Users/Kyojin/.emacs.d/myinit.el" nil nil t)
load-file("/Users/Kyojin/.emacs.d/myinit.el")
(progn (load-file exported-file) "Loaded")
(if compile (progn (byte-compile-file exported-file (quote load))
"Compiled and loaded") (progn (load-file exported-file) "Loaded"))
(message "%s %s" (if compile (progn (byte-compile-file exported-file
(quote load)) "Compiled and loaded") (progn (load-file exported-file)
"Loaded")) exported-file)
(let* ((age (function (lambda (file) (float-time (time-subtract
(current-time) (nth 5 ...)))))) (base-name (file-name-sans-extension
file)) (exported-file (concat base-name ".el"))) (if (and (file-exists-
p exported-file) (> (funcall age file) (funcall age exported-file)))
nil (setq exported-file (car (last (org-babel-tangle-file file
exported-file "emacs-lisp"))))) (message "%s %s" (if compile (progn
(byte-compile-file exported-file (quote load)) "Compiled and loaded")
(progn (load-file exported-file) "Loaded")) exported-file))
org-babel-load-file("/Users/Kyojin/.emacs.d/myinit.org")
eval-buffer(#<buffer *load*> nil "/Users/Kyojin/.emacs.d/init.el"
nil t) ; Reading at buffer position 358
load-with-code-conversion("/Users/Kyojin/.emacs.d/init.el"
"/Users/Kyojin/.emacs.d/init.el" t t)
load("/Users/Kyojin/.emacs.d/init" t t)
#[0"\205\266\306=\203\307\310Q\202?\311=\204\307\312Q\202?\313\307
\314\315#\203* \316\202?\313\307\314\317#\203>\320\321\322!D\nB\323
\202?\316\324\325\324\211#\210\324=\203e\326\327\330\307\331Q!\"\325
\324\211#\210\324=\203d\210\203\247\332!\333\232\203\247\334!
\211\335P\336!\203\201\211\202\214\336!\203\213\202\214\314\262\
\203\245\337\"\203\243\340\341#\210\342\343!\210\266\f\205\264\314\325
\344\324\211#)\262\207"[init-file-user system-type
delayed-warnings-list user-init-file inhibit-default-init inhibit-
startup-screen ms-dos "~" "/_emacs" windows-nt "/.emacs" directory-
files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?
$" initialization format-message "`_emacs' init file is deprecated,
please use `.emacs'" "~/_emacs" t load expand-file-name "init" file-
name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-
extension ".el" file-exists-p file-newer-than-file-p message "Warning:
%s is newer than %s" sit-for 1 "default"] 7]()
command-line()
normal-top-level()
Search for the word Removes in your init file, "/Users/Kyojin/.emacs.d/myinit.el" (or possibly in some file that it loads).
If you don't find it immediately then recursively bisect your init file to find the code that is problematic. You can do that by commenting out first 1/2, then 3/4, then 7/8,... of the file until you locate the problem. You can comment a block of text/code by selecting it and then using M-x comment-region. You can uncomment a selection the same way, but with C-u first: C-u M-x comment-region.

sbcl memory-fault-error with zeromq

I am new to Lisp, and am trying to work with ZMQ in it. For a simple function, I get the error below. How do I debug this error? Are there tools to help? It isn't dropping me into the ldb, how do I see what is at the address printed with the error?
Unhandled memory fault at #x10CC8B000.
[Condition of type SB-SYS:MEMORY-FAULT-ERROR]
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "new-repl-thread" RUNNING {1003E0F353}>)
Backtrace:
0: (SB-SYS:MEMORY-FAULT-ERROR)
[No Locals]
1: ("foreign function: call_into_lisp")
[No Locals]
2: ("foreign function: post_signal_tramp")
[No Locals]
3: ("foreign function: _ZN3zmq6pipe_t12get_identityEv")
[No Locals]
4: ("foreign function: _ZN3zmq8router_t5xrecvEPNS_5msg_tE")
[No Locals]
5: ("foreign function: _ZN3zmq5rep_t5xrecvEPNS_5msg_tE")
[No Locals]
6: ("foreign function: _ZN3zmq13socket_base_t4recvEPNS_5msg_tEi")
[No Locals]
7: ("foreign function: _ZL9s_recvmsgPN3zmq13socket_base_tEP9zmq_msg_ti")
[No Locals]
8: (ZEROMQ::%MSG-RECV #.(SB-SYS:INT-SAP #X005002D0) #.(SB-SYS:INT-SAP #X06006000) 0)
Locals:
SB-DEBUG::ARG-0 = #.(SB-SYS:INT-SAP #X005002D0)
SB-DEBUG::ARG-1 = #.(SB-SYS:INT-SAP #X06006000)
SB-DEBUG::ARG-2 = 0
9: ((LAMBDA (&REST SB-DI::ARGS) :IN SB-DI::HANDLE-SINGLE-STEP-AROUND-TRAP) #.(SB-SYS:INT-SAP #X06006000) #S(ZEROMQ:MSG :RAW #.(SB-SYS:INT-SAP #X005002D0)))
Locals:
SB-DI::ARGS = (#.(SB-SYS:INT-SAP #X06006000) #S(ZEROMQ:MSG :RAW #.(SB-SYS:INT-SAP #X005002D0)))
10: (RECV)
Locals:
CONTEXT = #.(SB-SYS:INT-SAP #X00500CC0)
SOCKET = #.(SB-SYS:INT-SAP #X06006000)
11: (SB-INT:SIMPLE-EVAL-IN-LEXENV (RECV) #<NULL-LEXENV>)
Locals:
SB-DEBUG::ARG-0 = (RECV)
SB-DEBUG::ARG-1 = #<NULL-LEXENV>
12: (EVAL (RECV))
Locals:
SB-DEBUG::ARG-0 = (RECV)
--more--
Here is the code I am trying to run. I am running these two functions in two different sbcl processes
sbcl<1>
(defun send ()
(zmq:with-context (context)
(zmq:with-socket (socket context :req)
(break)
(zmq:connect socket "tcp://127.0.0.1:3333")
(break)
(zmq:msg-send socket (zmq:make-msg :size 6 :data "Jello")))))
(send)
sbcl<2>
(defun recv ()
(zmq:with-context (context)
(zmq:with-socket (socket context :rep)
(break)
(zmq:bind socket "tcp://127.0.0.1:3333")
(break)
(zmq:msg-recv
socket (zmq:make-msg :size 6)))))
(recv)
[EDIT]
After a bit of digging around, I found this message in the buffer
* sbcl(49664,0x700000104000) malloc: *** error for object 0x500058: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
CORRUPTION WARNING in SBCL pid 49664(tid 123145303375872):
Received signal 6 in non-lisp thread 123145303375872, resignalling to a lisp thread.
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
I have used the same C library with it's Python & Node bindings and it works without errors in Python and Node. I am only running into these errors with CL
So after a few days of hanging out in the #zeromq IRC, using lldb to debug the memory issues, I finally gave up. The CL bindings for zeromq aren't tested on OS X, and they do not work.
I switched to Ubuntu, and had no such problems.

How do I fix a "Wrong Type Argument: listp," error when trying to access remote file using tramp?

I am unable to access remote files in my usual way:
C-x C-f
[server]:[path][file]
and am thrown this error:
Wrong Type Argument: listp, [[server]:[path][file]
I'm not even sure how to debug this further.
any help is appreciated.
edit:
output when trying to debug:
Debugger entered: nil
(progn (debug) (ido-mode t) (progn (ad-add-advice (quote completing-read) (quote (foo nil
t (advice lambda nil (if (boundp ...) ad-do-it (setq ad-return-value ...))))) (quote
around) (quote nil)) (ad-activate (quote completing-read) nil) (quote completing-read)) (define-key global-map [(meta 120)] (function (lambda nil (interactive) (call-interactively
(intern (ido-completing-read "M-x " (all-completions "" obarray ...))))))))
(if (fboundp (quote ido-mode)) (progn (debug) (ido-mode t) (progn (ad-add-advice (quote
completing-read) (quote (foo nil t (advice lambda nil (if ... ad-do-it ...)))) (quote
around) (quote nil)) (ad-activate (quote completing-read) nil) (quote completing-read))
(define-key global-map [(meta 120)] (function (lambda nil (interactive) (call-
interactively (intern (ido-completing-read "M-x " ...))))))))
eval-buffer() ; Reading at buffer position 16103
call-interactively(eval-buffer)
(lambda nil (interactive) (call-interactively (intern (ido-completing-read "M-x " (all-
completions "" obarray (quote commandp))))))()
call-interactively((lambda nil (interactive) (call-interactively (intern (ido-completing-
read "M-x " (all-completions "" obarray (quote commandp)))))) nil nil)
recursive-edit()
debug(debug)
implement-debug-on-entry()
* ido-find-file()
call-interactively(ido-find-file nil nil)
And this from my init.el:
(require 'ido)
(if (fboundp 'ido-mode)
(progn
(debug)
(ido-mode t)
(defadvice completing-read
(around foo activate)
(if (boundp 'ido-cur-list)
ad-do-it
(setq ad-return-value
(ido-completing-read
prompt
(all-completions "" collection predicate)
nil require-match initial-input hist def))))
(define-key global-map [(meta ?x)]
(lambda ()
(interactive)
(call-interactively
(intern
(ido-completing-read "M-x " (all-completions "" obarray 'commandp))))))))
Check what command C-x C-f is bound to (use C-h k). Is it the standard binding find-file? (It doesn't sound like it.)
If not, check its interactive spec. The command is expecting to receive a list as argument, and it is instead receiving (what looks like) a string.
This is the interactive spec of find-file:
(interactive
(find-file-read-args "Find file: " (confirm-nonexistent-file-or-buffer)))
If the interactive spec of your C-x C-f command, like this one, has a non-string as its argument, then you can either M-x debug-on-entry THE-FUNCTION, where THE-FUNCTION is the function called for the argument (find-file-read-args, in the case of find-file), or wrap that argument so that the debugger is invoked:
(progn (debug) (WHATEVER-WAS-THERE-BEFORE))
Either way, the debugger will open for the interactive part of reading the file name, and you can walk through the debugger to see what goes wrong.
But probably you can figure out the problem just by inspecting the code -- the interactive spec. The argument to your command (whatever it is) is expected to be a list, but it is a string.
I would start by seeing what happens with a local file name. Do you get an error for that too?
Another thing I notice is that the error reports an extra [, in front of what you say you typed as input. That should provide a clue too. What you think it is reading is not what it has read.

Resources