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 / join-multi-lines-to-one.el
Last active January 5, 2023 09:33
Emacs(Elisp): Join multi lines to one. 選択範囲を1行にまとめます。
;;; ------------------------------------------------------------
;;; 選択範囲を1行にする。最初のインデントは残す。
;; gist-description: Emacs(Elisp): Join multi lines to one. 選択範囲を1行にまとめます。
;; gist-id: ee6b2f8ef659ed58605d
;; gist-name: join-multi-lines-to-one.el
;; gist-private: nil
(defun join-multi-lines-to-one ()
"Join multi lines."
(interactive)
@jidaikobo-shibata
jidaikobo-shibata / normalize-chars.el
Last active May 16, 2022 23:23
Emacs(Elisp): 全角英数字を半角英数字に、半角カナを全角に、UTF-8の濁点分離を直す。
;;; ------------------------------------------------------------
;;; 全角英数字を半角英数字に、半角カナを全角に、UTF-8の濁点分離を直す
;; http://d.hatena.ne.jp/nakamura001/20120529/1338305696
;; http://www.sakito.com/2010/05/mac-os-x-normalization.html
;; gist-description: Emacs(Elisp): 全角英数字を半角英数字に、半角カナを全角に、UTF-8の濁点分離を直す。
;; gist-id: 08a752b04107dbc50ef5
;; gist-name: normalize-chars.el
;; gist-private: nil
(require 'ucs-normalize)
@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 / 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 / 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.
@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 / 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 / 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 / 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 / yagist-region-create-or-update.el
Last active July 19, 2016 09:30
Emacs(Elisp): create or update gist by using yagist. yagistでregionのgistをupdateする。
;;; ------------------------------------------------------------
;; gist-description: Emacs(Elisp): create or update gist by using yagist. yagistでregionのgistをupdateする。
;; gist-id: a20cd2d106edba225115
;; gist-name: yagist-region-create-or-update.el
;; gist-private: nil
(require 'yagist)
(defun yagist-region-create-or-update (beg end)
"Post the current region as a create or update at gist.github.com.