Skip to content

Instantly share code, notes, and snippets.

View hidsh's full-sized avatar

yakshaver hidsh

View GitHub Profile
@hidsh
hidsh / let-and-lexical-let.el
Last active December 12, 2020 22:06
elisp example: let と lexical-let の違い (emacs 26.3)
;; let の場合
(let (val)
(defun init () (setq val 100))
(defun print () (message "val: %d" val)))
(init) ;; => 100
(let ((val 200))
(print)) ;; => "val: 200" <---!!!
;; lexical-let の場合
@hidsh
hidsh / .vimrc
Created November 10, 2020 21:53
"
" key bindings
"
"------------------------------------------------------
"MODE NO-REMAPPING REMAPPING
"normal nnoremap nmap
"visual vnoremap vmap
"command mode cnoremap cmap
"insert mode inoremap imap
"normal + vilual noremap map
@hidsh
hidsh / git-dig.sh
Last active November 8, 2020 21:01
git でそのファイルのすべての版を落としてくる。どこでおかしくなったか探すときにいちいち git checkout COMMIT_NUM -- hoge.txt とか繰り返すのがめんどいので書いた。リグレッションテストのお供に。
#!/bin/sh
help() {
script=`basename $0`
echo "USAGE: $script FILENAME"
echo "Equivalent to: git checkout ALL-COMMITS -- FILENAME"
}
if [ $# -ne 1 ]; then
help
@hidsh
hidsh / 0-print.sh
Created November 8, 2020 18:07
awk example: print
#!/bin/sh
ls -l
echo ---------------
ls -l |awk '{print $1}'
@hidsh
hidsh / bak.sh
Created November 7, 2020 18:09
backup command by CUI
#!/bin/sh
#
# Filename: bak.sh
# Last modified: Sat Jul 24 2004 19:21:58 LMT
#
# description:
# backup a file to FILE.bak or FILE.orig
# also revert from FILE.bak or FILE.orig
#
# this script also allows to backup directories.
@hidsh
hidsh / emacs-test-advice-add.el
Last active January 29, 2023 02:11
emacs: test for advice-add :before, :around, :after
(defun func-1 () (message "aaa")) ;; target function
(defun my-func-1-adv () ;; advice function
(message "before"))
(advice-add 'func-1 :before #'my-func-1-adv)
;(func-1)
;---> before
;---> aaa
@hidsh
hidsh / emacs-tare-isearch-for-region.el
Created October 31, 2020 01:49
emacs: evilでexpand-regionしたあと"/"したら、選択したリージョンの文字列を検索してくれるようになるタレ(リージョン指定できるならexpand-regionでなくてもevilでなくてもいいはず)
(defun my-isearch-shit-at-point-insert-func ()
(remove-hook 'isearch-mode-hook #'my-isearch-shit-at-point-insert-func)
(when my-isearch-shit-at-point-str
(isearch-yank-string my-isearch-shit-at-point-str)
(setq my-isearch-shit-at-point-str nil)
(setq unread-command-events (listify-key-sequence (kbd "RET")))))
(defvar my-isearch-shit-at-point-str nil)
(defun my-isearch-shit-at-point ()
@hidsh
hidsh / emacs-test-emulate-key-input-and-exec-minibuffer.el
Last active April 5, 2023 20:30
elispでミニバッファに何か入力して実行するテスト
;; M-x ttt すると f2関数がコール
;; -> 自動でミニバッファに文字列を入力
;; -> 自動でEnter入力
;; -> 結果が表示される
(defun f2 ()
"ミニバッファに文字列を入力してEnterする。"
(insert "(1+ 5)")
(setq unread-command-events (listify-key-sequence "\C-j")) ;; Enterキー入力をエミュレート
;;(setq unread-command-events (listify-key-sequence (kbd "RET"))) ;; こっちでないとダメなときがある
# on WSL
ciso="/mnt/c/Program Files (x86)/danny_kay1710/PSP ISO Compressor/files/ciso.exe"
#ciso="/mnt/c/Program\ Files\ \(x86\)/danny_kay1710/PSP\ ISO\ Compressor/files/ciso.exe"
level=1
if [ ! -f "${ciso}" ]; then
echo "ERROR: File not found: $ciso"
exit 1
fi
@hidsh
hidsh / .vimrc
Created September 26, 2020 23:14
my vim setting
"
" key bindings
"
"------------------------------------------------------
"MODE NO-REMAPPING REMAPPING
"normal nnoremap nmap
"visual vnoremap vmap
"command mode cnoremap cmap
"insert mode inoremap imap
"normal + vilual noremap map