Skip to content

Instantly share code, notes, and snippets.

View lagagain's full-sized avatar

lagagain lagagain

View GitHub Profile
@lagagain
lagagain / example_x-popup-menu.el
Last active April 11, 2019 02:24
[Emacs Lisp]Example of x-popup-menu
(easy-menu-define testmenu nil "Test Menu" '(("Hello") ("abc") ("def")))
(windowp
(get-buffer-window "*Messages*"))
(x-popup-menu `((0 0) ,(get-buffer-window "*Messages*")) testmenu)
(x-popup-menu `((0 0) ,(get-buffer-window)) testmenu)
@lagagain
lagagain / hello.cpp
Created August 26, 2018 08:07
[pratice] Python3.5 call C++ function with extern "C"
#include "hello.h"
#include<Python.h>
using namespace std;
extern "C"{
static PyObject *_hello(PyObject *self, PyObject *args){
hello();
return self;
}
@lagagain
lagagain / main.c
Last active August 15, 2022 06:43
[practice] Lua interact with C
#include "lua.h"
#include "lauxlib.h"
#include<stdio.h>
#include<stdlib.h>
int l_bar0(lua_State *L){
printf("----------- in the bar0 ---------------\n");
printf("----------- out the bar0 ---------------\n\n");
return 0;
@lagagain
lagagain / send-regrion-to-term.el
Created November 19, 2018 16:33
[practice] emacs elisp send-regrion-to-term
(defun send-region-to-term nil
(interactive)
(send-string "*terminal*" (buffer-substring-no-properties (region-beginning) (region-end)))
(send-string "*terminal*" "\n"))
(local-set-key (kbd "C-c C-r")
'send-region-to-term)
@lagagain
lagagain / README.md
Last active February 14, 2023 11:56
[practice] [Common Lisp] hello CFFI (Common Lisp + C)

This is a practice project to test Common Lisp + C with CFFI.

CFFI is a protocal for common lisp, and most popular impl like sbcl,ccl,cmucl,ecl and abcl have to this. So We can eazy to access C code from Common Lisp.

Env need

just only write for Linux(Unix) and need a lisp impl with cffi package. I pratice it with sbcl. You can install it with Roswell, or you can also ues more friendly env - cl-repl which also can install by roswell.

  • OS: Linux(Unix)
  • A Common lisp impl with cffi
@lagagain
lagagain / try-fiveam.lisp
Created November 28, 2018 03:18
Try use FiveAM which is a test framework for Common Lisp.
;;(ql:quickload :fiveam)
(require :fiveam)
(defpackage try-fiveam
(:use :cl)
(:import-from :fiveam test run run! def-suite is))
(in-package try-fiveam)
(test test+
@lagagain
lagagain / case vs bind.lisp
Last active September 3, 2019 04:53
Common lisp 錯誤處理練習
(define-condition div-by-zero ()
((message :initarg :message
:accessor message
:initform ""
:type 'string))
(:report (lambda (c s) (format s "Can not div by zero: ~A~&" (message c)))))
(defun prompt (message)
(format t message)
(read))
@lagagain
lagagain / LICENCE
Last active December 4, 2018 02:56
Try Common Lisp GTK(cl-cffi-gtk)
Copyright (c) 2018, lagagain
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
@lagagain
lagagain / LICENCE
Last active December 4, 2018 07:35
my local setting. base on purcell
These files flow BSD-3
- init-local.el
Copyright (c) 2018, lagagain
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
@lagagain
lagagain / obj call.lisp
Created December 8, 2018 23:06
example for read macro
(set-dispatch-macro-character #\# #\o
(lambda (s c1 c2)
(declare (ignore c1 c2))
(let* ((form (read s))
(obj (car form))
(method (cadr form))
(args (cddr form)))
`(,method ,obj ,@args))))
(defmethod run ((name string))