Skip to content

Instantly share code, notes, and snippets.

View tek-nishi's full-sized avatar

Nobuyuki Nishiyama tek-nishi

View GitHub Profile
@tek-nishi
tek-nishi / set-encoding.el
Last active August 29, 2015 14:14
Set encoding new file for some extensions.
(defun my-set-encoding ()
"新規ファイル生成時のみ、エンコードを強制する Thanks for Syohei YOSHIDA"
(let ((bufname (buffer-file-name)))
(when (not (file-exists-p buffer-file-name))
(when (and bufname (string-match-p ".+\\.\\(cpp\\|c\\|hpp\\|h\\|mm\\)$" bufname))
(set-buffer-file-coding-system 'utf-8-with-signature)))))
(add-hook 'find-file-hook 'my-set-encoding)
@tek-nishi
tek-nishi / insert-newline-and-indent.el
Last active November 16, 2018 00:27
insert newline and indent
(defun my-insert-newline-and-indent(arg)
"カーソル行の上や下に一行挿入してインデント(前置引数が4だと下の行に挿入)"
(interactive "p")
(let ((p (if (eq arg 4)
2
1)))
(move-beginning-of-line p)
(open-line 1)
(indent-for-tab-command)))
@tek-nishi
tek-nishi / emacs-24-clang.diff
Created April 18, 2015 02:57
emacs 24.x をMSYS2のclangでビルドするためのパッチ(thank's for rzl24ozi)
--- src/lisp.h.orig 2014-11-19 15:00:20.843528000 +0900
+++ src/lisp.h 2014-11-19 15:07:48.693175100 +0900
@@ -2810,7 +2810,11 @@
/* A platform that uses neither _longjmp nor siglongjmp; assume
longjmp does not affect the sigmask. */
typedef jmp_buf sys_jmp_buf;
+#if defined __MINGW64__ && defined __clang__
+# define sys_setjmp(j) _setjmp (j, NULL)
+#else
# define sys_setjmp(j) setjmp (j)
@tek-nishi
tek-nishi / my-color-hsv-to-rgb.el
Last active August 29, 2015 14:20
Convert from HSV to RGB (Emacs)
(defun my-color-hsv-to-rgb (h s v)
"HSV[0.0, 1.0]からRGB[0.0, 1.0]へ変換する (SOURCE:Wikipedia)"
(let ((r v)
(g v)
(b v))
(if (> s 0)
(progn
(setq h (* h 6))
(let* ((i (truncate h))
(f (- h i)))
@tek-nishi
tek-nishi / my-color-rgb-to-hsv.el
Last active August 29, 2015 14:20
Convert from RGB to HSV (Emacs)
(defun my-color-rgb-to-hsv (r g b)
"RGB[0.0, 1.0]からHSV[0.0, 1.0]へ変換する (SOURCE:Wikipedia)"
(let* ((max (max r g b))
(min (min r g b))
(h (- max min))
(s (- max min))
(v max))
(if (> h 0.0)
(cond ((= max r)
(progn
@tek-nishi
tek-nishi / error_vs2013_initializer-list.cpp
Last active August 29, 2015 14:24
初期化子リストでビルドエラー
#include <map>
#include <functional>
std::map<int, std::function<void ()>> func;
struct Hoge {
void f() {}
};
@tek-nishi
tek-nishi / bs-show-sort-extention.el
Created April 7, 2016 13:07
bs-showで「モード名、拡張子、ファイル名(拡張子除く)」要素でソートする
(defun my-buffer-mode (buffer-or-string)
"Returns the major mode associated with a buffer.
to see http://stackoverflow.com/questions/2238418/emacs-lisp-how-to-get-buffer-major-mode"
(with-current-buffer buffer-or-string
major-mode))
(defun my-dired-directory (buffer-or-string)
"Dired-modeのpathを取得"
(with-current-buffer buffer-or-string
dired-directory))
@tek-nishi
tek-nishi / my-jump-brace.el
Last active August 10, 2017 06:25
対応する括弧へ移動(Vz風)
(defun my-jump-brace()
"対応括弧へジャンプ"
(interactive)
(let ((c (following-char))
(p (preceding-char)))
(if (eq (char-syntax c) 40) (forward-list)
(if (eq (char-syntax p) 41) (backward-list)
(backward-up-list)))))
@tek-nishi
tek-nishi / add-info-path.el
Created September 26, 2016 01:50
Add Info path at Emacs 25.1
;; Add Resouce path(macOS)
(add-to-list 'Info-default-directory-list (expand-file-name "../info" data-directory))
;; Add user local info path
(add-to-list 'Info-default-directory-list (expand-file-name "info" user-emacs-directory))
@tek-nishi
tek-nishi / emacs_build.sh
Last active April 12, 2022 02:02
emacsをビルドするスクリプト
#!/bin/bash
EMACS_VER=28.1
MACPORT_VER=9.0
tar xvfz emacs-${EMACS_VER}.tar.gz
tar xvfz emacs-${EMACS_VER}-mac-${MACPORT_VER}.tar.gz
cd emacs-${EMACS_VER}
patch -p 1 < ../emacs-${EMACS_VER}-mac-${MACPORT_VER}/patch-mac
cp -r ../emacs-${EMACS_VER}-mac-${MACPORT_VER}/mac mac