Skip to content

Instantly share code, notes, and snippets.

View twlz0ne's full-sized avatar

twlz0ne

  • Fuzhou, China
View GitHub Profile
@twlz0ne
twlz0ne / *scratch*.el
Created May 25, 2018 12:14 — forked from jordonbiondo/*scratch*.el
Create an async.el-friendly lambda that uses variables and functions bound in the current emacs instance.
(defmacro value-bound-lambda (args symbols &rest body)
"Returns a lambda expression with ARGS, where each symbol in SYMBOLS is
available for use and is bound to it's value at creation.
Symbols needs to be a list of variables or functions available globally."
(declare (indent defun))
(let ((vars (remove-if-not 'boundp symbols))
(funcs (remove-if-not 'functionp symbols)))
`(lambda ,args
(let ,(mapcar (lambda (sym) (list sym (symbol-value sym))) vars)
@twlz0ne
twlz0ne / Dockerfile
Last active December 9, 2018 09:06
Debian 9 Docker image with Clang 6 installed.
FROM launcher.gcr.io/google/debian9:latest
RUN apt-get update && apt-get install -y gnupg wget software-properties-common
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
RUN apt-add-repository "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-6.0 main"
RUN apt-get update && apt-get install -y clang-6.0
RUN apt-get -y install libclang-common-6.0-dev libclang-6.0-dev libclang1-6.0 libllvm6.0 llvm-6.0-dev
## ISSUE:
# CMake Error at /usr/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
@twlz0ne
twlz0ne / test-fibonacci.el
Created May 8, 2018 03:35
Test fibonacci #emacs-lisp
;;; test-fibonacci.el --- Test fibonacci -*- lexical-binding: t; -*-
;;; Usage: /path/to/emacs --batch -l /path/to/test-fibonacci.el
;;; Date: 2018-05-08_11.32.38
(require 'generator)
;;; utils
(defmacro with-time-elapse (&rest BODY)
@twlz0ne
twlz0ne / test-helm-ff-boring-files-filtering.el
Created April 7, 2018 09:45
Test the filtering of helm ff boring files #emacs
;;; Date: 2017-12-28_23.12.21
;;; Usage:
;; $ /path/to/emacs -nw -Q -l /path/to/test-helm-ff-boring-files-filtering.el
;; or
;; $ /path/to/emacs --batch -l /path/to/test-helm-ff-boring-files-filtering.el
(toggle-debug-on-error)
(global-set-key (kbd "C-h") 'delete-backward-char)
(global-set-key (kbd "M-h") 'backward-kill-word)
(global-set-key (kbd "<f1>") 'help-command)
@twlz0ne
twlz0ne / format-spec+.el
Last active March 21, 2018 12:27
Format a string using named placeholders in #emacs-lisp
(defun format-spec+ (fmt specs)
(with-temp-buffer
(insert fmt)
(goto-char (point-max))
(let ((objs '()))
(while (re-search-backward "%\\([-0-9\\-\\.]*\\){\\([^}]+\\)}\\([a-zA-Z]\\)" nil t)
(let ((num (match-string 1))
(var (match-string 2))
(typ (match-string 3)))
(replace-match (concat "%" num typ))
;;; Reproduce the issue https://github.com/emacs-lsp/lsp-mode/issues/295
;;; Usage: /path/to/emacs -nw -Q -l /path/to/test-lsp-mode-issue295.el
;;; Date: 2018-02-27_23.24.41
(toggle-debug-on-error)
;; ------------------------------------------------------------------
(setq user-emacs-directory (format "~/.emacs.d/%s/%s/" (file-name-base load-file-name) emacs-version))
(setq package-user-dir (concat user-emacs-directory "elpa/"))
@twlz0ne
twlz0ne / image-shadow
Created February 18, 2018 05:01
Add shadow to image
#!/bin/bash
##
# Add shadow to image
# @author gongqijian@gmail.com
# @date 2014-11-22
##
usage() {
app=$(basename $0)
cat <<EOF
@twlz0ne
twlz0ne / test-lsp-flycheck.el
Last active January 21, 2018 08:19
Test lsp-flycheck
;;; Usage: /path/to/emacs -nw -Q -l /path/to/test-lsp-flycheck.el
;;; Date: 2018-01-09_14.09.39
(toggle-debug-on-error)
(global-set-key (kbd "C-h") 'delete-backward-char)
(global-set-key (kbd "M-h") 'backward-kill-word)
(global-set-key (kbd "<f1>") 'help-command)
(define-key isearch-mode-map "\C-h" 'isearch-delete-char)
;; ------------------------------------------------------------------
@twlz0ne
twlz0ne / test-lsp-ui.el
Last active June 10, 2020 07:29
Test lsp-ui
;;; Usage: /path/to/emacs -Q -l /path/to/test-lsp-ui.el
;;; Date: 2018-01-03_09.07.11
(toggle-debug-on-error)
(global-set-key (kbd "C-h") 'delete-backward-char)
(global-set-key (kbd "M-h") 'backward-kill-word)
(global-set-key (kbd "<f1>") 'help-command)
(define-key isearch-mode-map "\C-h" 'isearch-delete-char)
(unless (display-graphic-p)
@twlz0ne
twlz0ne / test-ivy-read.el
Last active December 30, 2017 18:43
Test ivy-read
;;; Usage: /path/to/emacs -nw -Q -l /path/to/test-ivy-read.el
(toggle-debug-on-error)
(global-set-key (kbd "C-h") 'delete-backward-char)
(global-set-key (kbd "M-h") 'backward-kill-word)
(global-set-key (kbd "<f1>") 'help-command)
(define-key isearch-mode-map "\C-h" 'isearch-delete-char)
;; ------------------------------------------------------------------