Skip to content

Instantly share code, notes, and snippets.

View twlz0ne's full-sized avatar

twlz0ne

  • Fuzhou, China
View GitHub Profile
@twlz0ne
twlz0ne / git-checkout-pr.sh
Created November 14, 2022 06:59
Checkout Github pull-request locally. #git
#!/usr/bin/env sh
:; # -*- mode: emacs-lisp; lexical-binding: t -*-
:; # Checkout Github pull-request locally.
:; # Last-updated: 2022-11-14 13.42.02 +0800
:; # by: Gong Qijian
:; # Usage:
:; # git-checkout-pr.sh [pull-request-url]
:; # Example:
:; # git-checkout-pr.sh https://github.com/user1/project2/pull/3
:; #
; $Id: helm-ls.el,v 1.4 2018/01/22 21:39:56 thierry Exp $
(defvar helm-source-ls
(helm-build-async-source "ls"
:candidates-process (lambda ()
(let* ((basedir (if (file-directory-p helm-pattern)
helm-pattern
(helm-basedir helm-pattern)))
(proc
(start-file-process "hls" nil "ls"
@twlz0ne
twlz0ne / custom-firefox-search-engine.el
Last active July 23, 2022 15:39
Custom Firefox Search Engine #Emacs
(cl-defun custom-firefox-search-engine (&key
name
description
iconurl
searchurl
&allow-other-keys)
"Custom Firefox Search Engin.
NAME Short name of search engine
DESCRIPTION Description of search engine
@twlz0ne
twlz0ne / advice-remove-button.el
Created July 2, 2022 02:27
Add button to remove advice in help-mode #emacs
(defun function-advices (function)
"Return FUNCTION's advices.
Last-Updated 2022-06-29 00:01:07 +8000"
(let ((flist (indirect-function function)) advices)
(when (and (consp flist)
(or (eq 'macro (car flist))
(and (autoloadp flist) (memq (nth 4 flist) '(macro t)))))
(setq flist (cdr flist)))
(while (advice--p flist)
@twlz0ne
twlz0ne / company-transformer-capf-dabbrev.el
Last active July 4, 2022 03:43
Return different CANDIDATES depending on the point position #emacs #company #lsp
(defun company-transformer//capf-dabbrev (candidates)
"Return different CANDIDATES depending on the point position.
| point at | company-capf | company-dabbrev |
|:---------|:------------:|:---------------:|
| foo.| | ✅ | ❌ |
| \"foo|\" | ❌ | ✅ |
| foo| | ✅ | ✅ |
Inspired by @yyjjl's [company//sort-by-tabnine](https://emacs-china.org/t/tabnine/9988/40)
@twlz0ne
twlz0ne / emacs-pager
Last active May 22, 2022 09:08
Emacs as Pager
#!/usr/bin/env bash
set -e
# Emacs as pager
#
# Author: [email protected]
# Created: 2021-06-06 16.08.51
# Version: 0.1
#
# Installation:
@twlz0ne
twlz0ne / txt2epub.py
Created May 30, 2020 09:06 — forked from scturtle/txt2epub.py
txt to epub
# coding: utf-8
import os
#书籍信息
title='test book'
creator='scturtle'
description='blablablabla'
#章节文件
txtlist=['1.txt','2.txt']
@twlz0ne
twlz0ne / test-lsp-jdtls-installation.el
Created May 11, 2020 03:55
Test jdtls installation #Emacs #LSP
;;; test-lsp-jdtls-installation.el --- Test lsp jdtls installation -*- lexical-binding: t; -*-
;;; Date: 2020-05-11_09.12.50
;;; Usage:
;; ┌────
;; │ $ emacs -nw -Q -l \
;; │ --eval '(setq with-proxy-http-server "127.0.0.1:XXXX")' \
;; │ /path/to/test-lsp-jdtls-installation.el
;; └────
(toggle-debug-on-error)
(setq user-emacs-directory (format "~/.emacs.d/%s/%s/" (file-name-base load-file-name) emacs-version))
@twlz0ne
twlz0ne / test-nested-destructuring-in-dash-let.el
Last active April 15, 2020 07:35
Test nested destructuring in dash let form #Emacs
;;; test-nested-destructuring-in-dash-let.el --- Test nested destructuring in dash let form -*- lexical-binding: t; -*-
;; Author: Gong Qijian <[email protected]>
;; Created: 2020/04/09
;; Version: 1.1
;;; Commentary:
;; Example:
;; ┌────
;; │ (-let [(&alist '(a "b" c) v) '((a . (("b" . ((c . 3))))))] v)
;; │ ;; => (let* ((v (cdr (assoc 'c
;; │ ;; (cdr (assoc "b"
@twlz0ne
twlz0ne / test-magit-stage-minimal.el
Last active January 21, 2022 07:31
Minimal configuration for testing magit stage #Emacs
;;; Usage: /path/to/emacs -nw -Q -l /path/to/test-magit-stage-minimal.el --eval '(load-magit "/path/to/magit/lisp")'
;;; Created: 2020-03-04 03.05.24
;;; Updated: 2020-03-04 21.17.19
;;; Version: 2
(toggle-debug-on-error)
;; ------------------------------------------------------------------
;; elpa