Skip to content

Instantly share code, notes, and snippets.

View jidaikobo-shibata's full-sized avatar

jidaikobo-shibata jidaikobo-shibata

View GitHub Profile
@jidaikobo-shibata
jidaikobo-shibata / open-large-file-quickly.el
Last active August 2, 2020 07:32
Emacs(Elisp): Open large file quickly. 大きいファイルを早く開きたい
;;; ------------------------------------------------------------
;;; 大きいファイルを早く開きたい
;; gist-description: Emacs(Elisp): Open large file quickly. 大きいファイルを早く開きたい
;; gist-id: 96e00bd843c838f45ab8183e286150ec
;; gist-name: open-large-file-quickly.el
;; gist-private: nil
(defun open-large-file-quickly()
"To read large file."
(interactive)
(progn
@jidaikobo-shibata
jidaikobo-shibata / preserve-region-when-kill.el
Created June 7, 2017 09:02
Emacs(Elisp): Preserve region when kill. 他のエディタだと選択範囲を作った後コピーしても選択範囲が解除されないが、Emacsは解除されちゃう。1年以上使っていてもどうしてもこれには慣れることができなかったので、選択範囲をキープするように変更。
;;; ------------------------------------------------------------
;;; やっぱりキル時にリージョンを残したい……。
;; gist-description: Emacs(Elisp): Preserve region when kill. 他のエディタだと選択範囲を作った後コピーしても選択範囲が解除されないが、Emacsは解除されちゃう。1年以上使っていてもどうしてもこれには慣れることができなかったので、選択範囲をキープするように変更。
;; gist-id:
;; gist-name: preserve-region-when-kill.el
;; gist-private: nil
(defun f--around--cua-copy-region (cua-copy-region arg)
"Keep Region at kill. CUA-COPY-REGION, ARG."
(let ((beg (region-beginning))
(end (region-end)))
@jidaikobo-shibata
jidaikobo-shibata / preserve-last-buffers-and-point.el
Last active July 22, 2016 13:37
Emacs(Elisp): Preserve last buffers and its each point to reopen. 終了時のバッファとポイントを記憶して、起動時に同じ状態で開くelispです。
;;; ------------------------------------------------------------
;;; 起動時には最後に作業していたファイルを開く
;; gist-description: Emacs(Elisp): Preserve last buffers and its each point to reopen. 終了時のバッファとポイントを記憶して、起動時に同じ状態で開くelispです。
;; gist-id: 35b4d739a149f70e86298f71e5b1f9e7
;; gist-name: preserve-last-buffers-and-point.el
;; gist-private: nil
(defvar my-hist-dir (expand-file-name "~/.emacs.d/histories/"))
(defvar my-hist-last-files (concat my-hist-dir "last-files"))
@jidaikobo-shibata
jidaikobo-shibata / move-to-next(previous)-word-break.el
Last active October 12, 2020 07:10
Emacs(Elisp): forward/backward-wordだと、移動距離が微妙に大きい。単語境界も微妙だった。ので、ちょっと変質的にカーソル移動をカスタマイズ。
;;; ------------------------------------------------------------
;;; 次/前のwordbreakへ
;; gist-description: Emacs(Elisp): forward/backward-wordだと、移動距離が微妙に大きいので、単語境界でひっかかるように。
;; gist-id: 467f4302c002049bfb95511bd21cdbe7
;; gist-name: move-to-next(previous)-word-break.el
;; gist-private: nil
;; thx http://d.hatena.ne.jp/h1mesuke/20070803/p1
(defun move-to-next-word-break (&optional arg)
"Move point forward ARG word breaks (backward if ARG is negative)."
@jidaikobo-shibata
jidaikobo-shibata / defadvice-indent-for-tab-command.el
Last active July 11, 2016 13:34
Emacs(Elisp): To integrate indent style, delete existing whitespaces before indent-for-tab-command. indent-for-tab-commandの前に存在する行頭ホワイトスペースを削除することでインデントスタイルを統一する
;; defadvice-indent-for-tab-command
;; gist-description: Emacs(Elisp): To integrate indent style, delete existing whitespaces before indent-for-tab-command. indent-for-tab-commandの前に存在する行頭ホワイトスペースを削除することでインデントスタイルを統一する
;; gist-id: 604173d11ff376036635fd4811df6abb
;; gist-name: defadvice-indent-for-tab-command.el
;; gist-private: nil
(defadvice indent-for-tab-command (around advise-indent-for-tab-command activate)
"To integrate indent style, delete existing whitespaces before indentation."
(let (beg
end
@jidaikobo-shibata
jidaikobo-shibata / move(region)-to-next(previous)-blank-line.el
Last active July 7, 2016 05:29 — forked from jewel12/gist:2873112
Emacs(Elisp): forward/backward-paragraphだとparagraph判定がおそらくシンタックステーブル依存になり、字義通りの「次の空行」にならないので、別途用意。
;;; ------------------------------------------------------------
;;; 次/前の空行
;; gist-description: Emacs(Elisp): forward/backward-paragraphだとparagraph判定がおそらくシンタックステーブル依存になり、字義通りの「次の空行」にならないので、別途用意。
;; gist-id: ad27b19dd3779ccc1ff2
;; gist-name: move(region)-to-next(previous)-blank-line.el
;; gist-private: nil
(defun move-to-previous-blank-line ()
"Go to previous empty lines."
(interactive "^")
@jidaikobo-shibata
jidaikobo-shibata / my-indext-region.el
Last active July 6, 2016 04:12
Emacs(Elisp): indent.elにそのままの機能があったので、そちらに置き換え。
;;; ------------------------------------------------------------
;;; インデント整形
;; gist-description: Emacs(Elisp): indent.elにそのままの機能があったので、そちらに置き換え。
;; gist-id: f941e7f365872920c7f8
;; gist-name: my-indext-region.el
;; gist-private: nil
(global-set-key (kbd "s-}") 'indent-rigidly-right-to-tab-stop)
(global-set-key (kbd "s-]") 'indent-rigidly-right-to-tab-stop)
(global-set-key (kbd "s-{") 'indent-rigidly-left-to-tab-stop)
@jidaikobo-shibata
jidaikobo-shibata / move-current-tab-to-top.el
Last active April 14, 2018 23:31
Emacs(Elisp): move current tab (buffer) to top at tabbar-mode. tabbarで選択中のタブ(バッファ)を左端に移動します。
;; move-current-tab-to-top
;; gist-description: Emacs(Elisp): move current tab (buffer) to top at tabbar-mode. tabbarで選択中のタブ(バッファ)を左端に移動します。
;; gist-id: 54dab2fc5f2e278833f5
;; gist-name: move-current-tab-to-top.el
;; gist-private: nil
(defun move-current-tab-to-top ()
"Move current tab to top."
(interactive)
(let* ((bufset (tabbar-current-tabset t))
@jidaikobo-shibata
jidaikobo-shibata / duplicate-region-or-line.el
Last active August 3, 2016 13:01
Emacs(Elisp): duplicate region or line. if same command repeated, then duplicate sate strings. 選択範囲がある場合は選択範囲を、選択範囲がない場合は、行を複製します。繰り返した場合、同じ文字列を複製し続けます。
;;; 行/選択範囲の複製 (cmd+d)
;; gist-description: Emacs(Elisp): duplicate region or line. if same command repeated, then duplicate sate strings. 選択範囲がある場合は選択範囲を、選択範囲がない場合は、行を複製します。繰り返した場合、同じ文字列を複製し続けます。
;; gist-id: 297fe973cde66b384fa1
;; gist-name: duplicate-region-or-line.el
;; gist-private: nil
(defvar previous-duplicate-region-or-line nil)
(defvar previous-duplicate-region-or-line-was-line nil)
(defun duplicate-region-or-line ()
"Duplicate region or line."
@jidaikobo-shibata
jidaikobo-shibata / calculate-region-and-insert.el
Last active June 27, 2019 06:47
Emacs(Elisp): calculate region and insert. 選択範囲の数式を計算して、次の行にinsertします。数字が羅列されている場合は、加算します。数字や式と自然な文章が混在している場合は、数式のみを計算します。
;;; ------------------------------------------------------------
;;; 選択範囲を計算してバッファに出力
;; gist-description: Emacs(Elisp): calculate region and insert. 選択範囲の数式を計算して、次の行にinsertします。数字が羅列されている場合は、加算します。数字や式と自然な文章が混在している場合は、数式のみを計算します。
;; gist-id: b967d6a7441f85aa541d
;; gist-name: calculate-region-and-insert.el
;; gist-private: nil
(defun add-number-grouping (number &optional separator)
"Add commas to NUMBER and return it as a string.
Optional SEPARATOR is the string to use to separate groups.