Editor/emacs
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#topicpath
/////////////////////////////////////////////////////////...
* 目次 [#xdc7c37e]
#contents();
#ls2(Editor/emacs/);
/////////////////////////////////////////////////////////...
* 編集関連 [#d174f0d4]
//=======================================================...
** 編集コマンド [#cmd-edit]
|~Key |~command name |~Operation ...
|C-SPC |set-mark-command |選択の開始 ...
|M-P |set-mark-command |選択の開始 ...
|C-w |kill-region |選択した箇所をカット ...
|C-k |kill-line |現在のカーソル位置から行...
|C-y |yank |選択した箇所をヤンク(貼...
//=======================================================...
** 矩形編集コマンド [#cm-edit-rectangle]
- rectangle-mark-mode を使う。
|~Key |~command name |~Operation ...
|C-x SPC |rectangle-mark-mode |矩形選択の開始 ...
|C-w |kill-region |選択した箇所をカ...
|M-w |kill-ring-save |選択した箇所をコ...
|C-y |yank |選択した箇所をヤ...
|C-o |open-line |矩形選択した箇所...
|C-t <CHAR> |transpose-chars |矩形選択した箇所...
|C-x r t <CHAR> |transpose-chars |矩形選択した箇所...
|C-SPC → (region選択) → C-x SPC | |選択したリージョン...
|C-x r k |kill-rectangle |矩形の切り取り |
|C-x r y |yank-rectngle |矩形の貼り付け |
|C-x r N |rectangle-number-lines |上から1で始まる...
-- 矩形編集は emacs24 あたりから使うことが出来るが、使う...
//-------------------------------------------------------...
*** 使い方 [#d2cde02a]
+ 矩形編集モードに入る
C-x SPC
+ 編集対象とする矩形をカーソルキーで選択する
+ 編集したいコマンドを実行する
-- 例:矩形選択した箇所を <CHAR> で置換
C-x r t <CHAR>
//-------------------------------------------------------...
*** 参考リンク [#k8b26146]
- [[GNU Emacs Manual(Japanese Translation): Rectangles>ht...
- [[Emacs における矩形領域のコピペ系編集機能 | プログラマ...
//=======================================================...
** 置換 [#edit-replace]
//-------------------------------------------------------...
*** 対話置換 [#f82d1655]
- 検索と置換の開始
|~binding |~command name |~Operation |
|M-% |query-replace |検索して置換を開始 |
- 検索で見つかった文字列の置換
|~binding |~Operation |
|y |ハイライト中の文字列を、指定した文字列で置換し...
|n |ハイライト中の文字列を置換しないで次を検索 |
|! |全てのマッチした文字列を置換する |
|q |置換を終了する |
|? |ヘルプを表示する |
//-------------------------------------------------------...
*** 一括置換(対話なし) [#da3ba60e]
|~binding |~command |~description |
| |replace-string |一括置換 |
| |replace-regexp |一括置換(正規表現版) |
//=======================================================...
** 一括検索&一括置換 [#ff58ba80]
- moccur-edit を使う。
- 一括検索&一括置換の手順
++ 検索する
+++ 検索開始
M-x: moccur-grep-find
++ 検索対象ディレクトリを指定
Directory: <firectory>
++ 検索キーワードとファイル名キーワードの入力
Input Regexp and FileMask: <keyword-for-grep> <file-name...
--- 正規表現が使用可
--- 但し、ファイル名キーワードに於いて拡張子指定する場合...
--- 例
Input Regexp and FileMask: hoge .html$
++ 検索結果を元に一括置換する為、編集モードに入る
r
++ 置換する
M-%
++ 置換した結果を保存する
C-x C-s
- 編集のキャンセル
C-x k
//=======================================================...
** 一括インデント [#y159cc3a]
+ まず、バッファ全体を選択する
C-x h (mark-whole-buffer)
+ 選択領域に対してインデントを実行する
C-M-\ (indent-region)
//=======================================================...
** キーワードによる一括アライン(align-regex)[#align-reg...
- 代入式などが複数行にわたって並んでいるときに "=" などの...
+ 範囲を選択
C-@
+ コマンド実行する
M-x: align-regex
+ アラインするキーワードを指定する
- 例
-- 実行前
int aaa = 120;
double ad = 23.55;
std::string buff = format("test data = %d, ad = %f\n...
-- 実行後(アラインキーワードに "=" を指定した)
int aaa = 120;
double ad = 23.55;
std::string buff = format("test data = %d, ad = %f\n...
//=======================================================...
** コメントアウト/コメントアウト取り消し toggle [#c91abb...
- 下記にて、使用言語に合わせたコメントアウト/コメントア...
++ コメントアウトする領域を選択
C-@
++ コメント/コメントアウト取り消し実行
M-;
- 各言語毎の挙動
|~言語 |~コメントアウト文字 |~備考 |
|C | /* */ で各行毎に括る・削除 | |
|C++ | // を行頭に追加・削除 | |
|Objective-C | // を行頭に追加・削除 | |
|Java | // を行頭に追加・削除 | |
|Pike | // を行頭に追加・削除 | |
|python | # を行頭に追加・削除 | |
|perl | # を行頭に追加・削除 | |
|Tcl | # を行頭に追加・削除 | |
|expect | # を行頭に追加・削除 | |
|bash | # を行頭に追加・削除 | |
|HTML | <!-- --> で各行毎に括る・削除 | |
|PHP | <!-- --> で各行毎に括る・削除 | |
|C# | 未対応 | |
|Pascal | { } で各行毎に括る・削除 | |
|elisp | ;; を行頭に追加・削除 | |
- この他、非言語の設定ファイルでも対応しているものがある:
|~項目 |~コメントアウト文字 |~備考 |
|.gitconfig | # を行頭に追加・削除 | |
/////////////////////////////////////////////////////////...
* 編集以外の機能 [#q1c8a63a]
//=======================================================...
** シェルコマンドの実行 [#s3e9c369]
- 下記にてシェルコマンドを実行出来る:
M-!
//=======================================================...
** 文字数を数える [#t87cae47]
- 対象領域を選択し、
M-x: count-lines-region
または
M-=
とする。
- 行数と文字数が表示される。文字数は、全角も半角もそれぞ...
//=======================================================...
** 行をウインドウ幅で折り返す・折り返さない [#rde48c86]
- 下記のコマンドで toggle 出来る
M-x toggle-truncate-lines
C-x x t
//=======================================================...
** ファイルを read-only で開く [#sd5faa53]
C-x C-r
//=======================================================...
** HTML文書編集での自動補完 [#d02f9e86]
- yahtmlを使う(yahtmlは、YaTeXに付属しているもの)。
- [[参考リンク>http://www.namazu.org/~tsuchiya/elisp/yaht...
//=======================================================...
** 現在の文字サイズの変更 [#na2363e5]
|~binding |~command |~description |
|C-x C-- |text-scale-adjust |文字サイズを小さくする |
|C-x C-+ |text-scale-adjust |文字サイズを大きくする |
|C-x C-0 |text-scale-adjust |文字サイズを初期値に戻す |
//=======================================================...
** 起動済みのemacs にファイルを渡す (emacsclient) [#ob79c...
- emacs起動時に、emacs-serverが起動するようにしておく必要...
-- .emacs に以下の行がなければ追記する:
(server-start)
- 起動済みのemacsに、コマンドラインからファイルを渡す方法
$ emacsclient <file-name> &
-- ファイルを送っただけのようで、実際には送り先のemacsと...
-- 上記コマンドを打った端末を終了すると、送り先のemacsか...
-- どうしてもemacsclientを起動した端末が死んでも構わない...
$ nohup emacslient <file-name> &
→[[System/Process#never-kill]]
/////////////////////////////////////////////////////////...
* キーバインド [#b4420c29]
//=======================================================...
** prefix の指針 [#z4320821]
|~prefix-key |~description |
|C-x |システムコマンドが使用する |
|C-c |ユーザが定義する。(拡張機能の実装ではこれ...
|M-g |行移動に関するキーバインドが定義される |
/////////////////////////////////////////////////////////...
* モードライン [#q8d089ae]
- モードラインの表示例
--------------------------------------------------------...
-UU-:----F1 color-moccur.el 16% (665,0) Git-master ...
--------------------------------------------------------...
- 文字コード
|~表記 |~文字コード |~emacs での呼称 |
|U |Unicode |utf-8, utf-16, utf-7, etc., |
|S |Shift_JIS |sjis (shift_jis) |
|J |JIS |iso-2022-jp, etc., |
|E |EUC (JP) |euc-jp, euc-jis-2004, etc., |
|1 |Latin-1 |latin-1 (iso-8859-1) |
- 改行コード
|~表記 |~改行コード |~emacs での呼称 |
|: |LF |unix |
|(DOS) |CR+LF |dos |
|(MAC) |CR |mac |
//=======================================================...
** モードラインの書式設定 [#o351158a]
|~format |~description |~remark |
|%b |カレントバッファ名 |(buffer-name) の値 |
|%f |ファイルのフルパス |(buffer-file-name) の値 |
|%F |選択中のフレーム | |
|%* |バッファが readonly であれば "%", 変更されてい...
|%+ |バッファが readonly であっても変更されていれば ...
|%& |バッファが readonly であっても変更されていれば ...
|%s |サブプロセスのステータス |(process-status) の値 |
|%l |カーソルの行番号 | |
|%c |カーソル一のカラム番号 | |
|%i |バッファのファイルサイズ |1byte 単位 |
|%I |~|kB/MB/GB |
|%p |ウインドウの上端より上にあるバッファ量の割合 |...
|%P |ウインドウの下端より下にあるバッファ量の割合 |~|
|%n |ナローイング中であれば "Narrow" を表示する | |
|%t |ファイルがテキストであれば "T", バイナリであれ...
|%z |キーボード、端末、ファイルの文字コードを表示 |...
|%Z |文字コードと改行コードを表示する | |
|%e |エラーメッセージを表示する | |
|%@ |ファイルがローカルホストであれば "-", リモート...
|%[ |再帰編集のレベルを "[" の数で表示する。 "%]" も...
|%% |"%" を表示 | |
|%- |無限に "-" を表示する | |
/////////////////////////////////////////////////////////...
* 設定関連 [#l0e4033f]
//=======================================================...
** OS による処理分岐 [#h759b01c]
(when (eq system-type 'gnu/linux)
; Linux の場合
)
(when (eq system-type 'darwin)
; Mac の場合
)
(when (eq system-type 'windows-nt)
; Windows の場合
)
(when (eq system-type 'cygwin)
; Cygwin の場合
)
//=======================================================...
** GUI / CUI による処理分岐 [#uc1c5e73]
- 変数 window-system を参照して分岐する。
-- 変数 window-system には、 X Window-System の場合は値に...
- 分岐処理の例
-- 例1
(when window-system (progn
;; GUI用設定
))
(when (not window-system) (progn
;; CUI用設定
))
-- 例2
(if window-system (progn
;; GUI用設定
)
(progn
;; CUI用設定
))
-- 実使用例
--- Menu を開くコマンドは、emacs-28.2 時点では GUI と CUI...
(if window-system
(global-set-key "\M-m" 'accelerate-menu); メニュ...
(global-set-key "\M-m" 'menu-bar-open); メニュー...
)
//=======================================================...
** フォント設定 [#ld049214]
+ Menu → "Options" → "Set Default Font..." でフォントを選...
+ Menu → "Options" → "Save Options" で設定を保存する。(...
- フォントを "Noto Sans Mono" に設定する(${HOME}/.emacs/...
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be ...
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Noto Sans Mono" :foundry "GOOG"...
//=======================================================...
** which-function-mode [#which-function-mode]
- ソースコードを開いているとき、カーソル位置が何らかの関...
- 設定するには、この機能を使いたいモード(C/C++/perl/java...
-- 設定例:C/C++ (一旦 hook 用関数を定義してその中で呼...
; c系言語共通設定
(defun c-c++-mode-common-conf ()
"common settings for C/C++"
(if (which-function-mode nil) (which-function-mode)) ;...
)
(add-hook 'c-mode-common-hook 'c-c++-mode-common-conf)
-- 設定例:Perl (hook 用関数の代わりにλ関数を使用し、そ...
(setq perl-mode-hook
#'(lambda ()
(if (which-function-mode nil) (which-function-...
))
- 設定時の注意点
-- 各モードの hook 以外のところ(例えばそれより前の段階で...
//=======================================================...
** lisp の場所を設定する [#sa55267e]
- load-path : 指定したディレクトリを lisp を走査する場所...
-- 書式:
(load-path <path-to-lisp-dir>)
-- 書式例:
(load-path (expand-file-name "~/.emacs.d/lisp")) ; ${HOM...
- normal-top-level-add-subdirs-to-load-path : load-path ...
-- 書式:
(normal-top-level-add-subdirs-to-load-path)
-- 環境によってはアクセス権の問題等でエラーになる場合があ...
//=======================================================...
** タイトルバーの表示書式にファイル名を入れる [#h8aae4c1]
(setq frame-title-format (format "emacs@%s : %%f" (syste...
//=======================================================...
** 文字色の変更 [#j1818f18]
- emacs 上で指定された文字色を変更する方法について。
- magit, xcscope などのパッケージで、文字色の制御を行って...
//-------------------------------------------------------...
*** terminal 上で動作させる場合 [#q0925a19]
- 方法1
$ cat ${HOME}/.bashrc
alias emacsd='env TERM=xterm emacs --daemon'
alias emacs='emacsclient -t'
- 方法2
$ TERM=xterm-256color emacs -nw
- 方法3 init.elに以下を追加する
(defun terminal-init-gnome ()
"Terminal initialization function for gnome-terminal."
;; This is a dirty hack that I accidentally stumbled a...
;; initializing "rxvt" first and _then_ "xterm" seems
;; to make the colors work... although I have no idea...
(tty-run-terminal-initialization (selected-frame) "rxv...
(tty-run-terminal-initialization (selected-frame) "xte...
- 方法4 init.elに以下を追加する
(add-hook 'tty-setup-hook
'(lambda ()
(set-terminal-parameter nil 'background-mod...
//-------------------------------------------------------...
*** どの変数で色定義されているかを調べる [#eefe35f4]
+ 対象となる文字列にカーソルを合わせた上で、以下を実行す...
M-x: describe-face
すると、ミニバッファに以下のように表示される:
Describe face (default `cscope-file-face'):
+ ここで決定(return キーを押す)と、以下のように表示され...
Face: cscope-file-face (sample) (customize this face)
Documentation:
Face used to highlight file name in the *cscope* buffer.
Defined in `xcscope.el'.
Family: unspecified
Foundry: unspecified
Width: unspecified
Height: unspecified
Weight: unspecified
Slant: unspecified
Foreground: yellow
DistantForeground: unspecified
Background: unspecified
Underline: unspecified
Overline: unspecified
Strike-through: unspecified
Box: unspecified
Inverse: unspecified
Stipple: unspecified
Font: unspecified
Fontset: unspecified
Inherit: unspecified
//-------------------------------------------------------...
*** 色変更の定義 [#v3047709]
+ 上記を元に、以下のように設定してやれば、色を変えること...
(set-face-foreground 'cscope-file-face "#d54e53") ; yel...
//=======================================================...
** 色設定 [#uf6d738d]
- ${HOME}/.bashrc での、emacs/XEmacs の色設定
alias emacsk='emacs -bg "#303030" -fg white'
alias emacsb='emacs -bg azure'
alias emacsy='emacs -bg lightyellow'
alias emacsg='emacs -bg "#e0ffe0"'
alias emacsr='emacs -bg "#fff5f5"'
alias xemacs='/usr/bin/xemacs21'
alias xemacsb='xemacs -bg azure'
alias xemacsy='xemacs -bg lightyellow'
alias xemacsg='xemacs -bg "#e0ffe0"'
alias xemacsr='xemacs -bg "#fff5f5"'
//=======================================================...
** wahel-theme [#wahel-theme]
- 暗色形テーマの一つ。
- 概ね良いのだが、以下の問題がある:
-- which-function-mode でモード行に表示する関数名が暗い灰...
--- 以下のようにすると見やすくなる:
(custom-set-faces
;; which-function-mode の関数名表示の色を変更する
'(which-func ((t (:foreground "yellow"))))
)
-- C/C++ ソースコードの ediff で、コメント行同士の比較が...
//-------------------------------------------------------...
*** 参考リンク [#g0d03289]
- [[waher-theme.el : ダークなカラーテーマ>http://emacs.ru...
- [[Waher Theme | Emacs Themes>https://emacsthemes.com/th...
- [[GitHub>https://github.com/emacsfodder/emacs-waher-the...
//=======================================================...
** {menu|tool}-barを消す [#y7f4f9fe]
(tool-bar-mode 0) ; tool bar を表示しない
(menu-bar-mode 0) ; menu bar を表示しない
(which-function-mode 1) ; 現在の関数名をモードラインに表示
//=======================================================...
** 行頭に行番号を表示する(モード行ではなく) [#hd23498b]
- linum-mode を使用する(Emacs23以降で有効)
M-x: linum-mode
- Toggle する関数
; 行番号表示をトグル
; http://qiita.com/yyamamot/items/df430d4e725ea38ffc9f
(defun toggle-linum-mode ()
"toggle display line number"
(interactive)
(setq linum-format "%4d ")
(linum-mode
(if linum-mode -1 1)))
(global-set-key [f5] 'toggle-linum-mode) ; linum-mode
- 参考:[[Emacsで行番号表示をトグルする>http://qiita.com/...
//=======================================================...
** モードラインに現在カーソルが位置している関数の関数名を...
- モードラインに、現在カーソルがある位置の関数名を動的に...
M-x: which-function-mode
- .emacs に設定するには、
(setq which-function-mode t)
//=======================================================...
** モードラインの現在時刻の表示 [#l41ac910]
- 現在時刻を表示する
(display-time)
- 24時間表示にする
(setq display-time-24hr-format t)
- 24時間制・秒も表示する
(setq display-time-interval 1)
(setq display-time-string-forms
; '((format "%s:%s:%s" 24-hours minutes seconds))
'((format "%s.%s.%s(%s) %s:%s:%s" day month year d...
; '((format "%s/%s/%s(%s) %s:%s:%s" year month day...
)
-- 秒の表示は、フォーマットで秒まで指定しただけでは駄目で...
//=======================================================...
** use-package [#use-package]
- 設定を、統一的な分かり易い記述で書けるようにするライブ...
- use-package マクロを利用することで、ライブラリのロード...
- 取得元: https://github.com/jwiegley/use-package.git
//-------------------------------------------------------...
*** use-package 参考リンク [#use-package-link]
- [[use-packageで可読性の高いinit.elを書く - Qiita>https:...
- [[use-packageの使い方 [QumaWiki]>https://www-he.scphys....
//=======================================================...
** Time-stamp [#m59e6eee]
; Time-stamp
; http://homepage.mac.com/zenitani/elisp-j.html#time-stamp
(require 'time-stamp)
(setq time-stamp-start "Last updated: <") ; 開始文字列の...
;; 日本語で日付を入れたくないのでlocaleをCにする
(defun time-stamp-with-locale-c ()
(let ((system-time-locale "C"))
(time-stamp)
nil))
(if (not (memq 'time-stamp-with-locale-c write-file-hook...
(add-hook 'write-file-hooks 'time-stamp-with-locale-...
; (setq time-stamp-format "%3a %3b %02d %02H:%02M:%02S %...
(setq time-stamp-format "%04y/%02m/%02d %02H:%02M:%02S %...
//=======================================================...
** isearch で、カーソルの位置にある単語を検索対象にする [...
- isearch時に、 C-w と打てばOK
//=======================================================...
** shell-mode で制御文字を処理する [#s805f2e5]
; shell-mode で制御文字を処理する。
(autoload 'ansi-color-for-comint-mode-on "ansi-color"
"Set `ansi-color-for-comint-mode' to t." t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
//=======================================================...
** バックアップファイルを作らないようにする [#d7ff8fd4]
(setq make-backup-files nil) ; *.~ とかのバックアップフ...
(setq auto-save-default nil) ; .#* とかのバックアップフ...
//=======================================================...
** 選択領域を [DEL] で一気に消せるようにする [#y95ca8b8]
; (setq delete-selection-mode t)
(delete-selection-mode)
//=======================================================...
** scroll を1行単位にする [#l150a348]
(setq scroll-step 1)
//=======================================================...
** 分割した window のサイズを変える [#y029a37e]
|~command |~description |~remark |
|M-x: enlarge-window |縦方向にサイズを大きくする | |
|M-x: shrink-window |縦方向にサイズを小さくする | |
|M-x: enlarge-window-horizontally |横方向にサイズを大きく...
|M-x: shrink-window-horizontally |横方向にサイズを小さく...
- 参考: emacs25.1.1 では以下のように設定することで、キー...
(global-set-key (kbd "M-<up>") 'enlarge-window)
(global-set-key (kbd "M-<down>") 'shrink-window)
(global-set-key (kbd "M-<right>") 'enlarge-window-horizo...
(global-set-key (kbd "M-<left>") 'shrink-window-horizon...
- 参考: emacs23 では以下のように設定することで、キー割り...
(global-set-key "M-<up>" 'enlarge-window)
(global-set-key "M-<down>" 'shrink-window)
(global-set-key "M-<right>" 'enlarge-window-horizontally)
(global-set-key "M-<left>" 'shrink-window-horizontally)
//=======================================================...
** ウインドウ自動分割時の制御 [#k8d8ac5a]
- ウインドウが自動分割される際の、垂直分割・水平分割の制御
- 垂直分割を防ぐには、下記を設定する:
(setq split-width-threshold nil)
- 挙動としては、
++ split-height-threshold の値が選択したウィンドウより小...
++ そうでない場合、 split-width-threshold がウィンドウの...
++ どちらも満たさず、既にウィンドウが分割されてない場合は...
//=======================================================...
** beep 音を消す [#oe941343]
- 以下を設定することで、beep が一切無効になる
(setq ring-bell-function 'ignore) ; beep を一切無効にする
- 嘗ては、以下の設定でカスタマイズすることが出来たが、ema...
-- Visible bell にする
(setq visible-bell t);; Visual Bell有効(エラー時画面反...
;(setq visible-bell nil);; Visual Bell無効(エラー時ブザ...
-- beep を鳴らさないようにする
; (setq message-beep 'silent)
//=======================================================...
** 今日の日付を挿入する [#af85099b]
(defun today()
(interactive)
(insert (format-time-string "%Y/%m/%d" (current-time))))
//=======================================================...
** 前のウインドウに戻る [#ia6f365e]
; XEmacsにはあるが、emacsにはない(!)
; http://matome.replore.com/index.php?title=Emacs_Lisp%E...
; xemacsに合わせて、関数名を backward-other-window に変...
; (defun other-window-backward (&optional n)
(defun backward-other-window (&optional n)
"Select nth previous window."
(interactive "P")
(other-window (- (prefix-numeric-value n))))
//=======================================================...
** 検索時に大文字・小文字を区別するかしないかの設定 [#cas...
(setq default-case-fold-search nil) ; 大文字・小文字を...
(setq case-fold-search nil) ; 大文字・小文字を...
- emacs23.2 以降では default-case-fold-search ではなく ca...
//=======================================================...
** ediff の control window を別ウインドウにしないようにす...
- X11 環境では、デフォルトではコントロールウインドウが別...
- 方法1
++ M-x: customize-group
++ [Ediff Window Setup Function] 行頭の三角をクリックし、...
++ [Value Menu] をクリックし、プルダウンから [Single Fram...
++ バッファ先頭付近の [Apply and Save] をクリックして設定...
- 方法2:以下を設定する:
;; コントロール用のバッファを同一フレーム内に表示
(setq ediff-window-setup-function 'ediff-setup-windows-p...
;; diffのバッファを上下ではなく左右に並べる
(setq ediff-split-window-function 'split-window-horizont...
//-------------------------------------------------------...
*** 参考リンク [#qd6e9c5e]
- [[同一フレーム内にediffのコントロールバッファを表示>htt...
- [[Emacs Lisp TIPS>https://sci.nao.ac.jp/MEMBER/zenitani...
//=======================================================...
** カレンダーで日本の祝日を表示する [#u4db1263]
- M-x: calendar で表示するカレンダーで日本の祝日を表示す...
- japanese-holidays.el を入手する
-- 入手先: https://github.com/emacs-jp/japanese-holidays...
- 設定
-- 参考: http://blog.livedoor.jp/tek_nishi/archives/3027...
- enmacs 起動時に cl-lib が見つからないと怒られた場合
-- cl-lib.el を入手し、load-path の通っているところに配置...
-- 入手先: http://elpa.gnu.org/packages/cl-lib.html
/////////////////////////////////////////////////////////...
* 自動インデントにおけるインデント量のカスタマイズ [#r8a...
//=======================================================...
** C++ [#ja3a6f5a]
//-------------------------------------------------------...
*** namespace の後のインデント [#m5fa651a]
- namespace 内でのインデント量を 0 に設定したい場合
+ 下記のようにカーソルをおく
namespace hogehoge {
| ← ここにカーソルをおく
}
+ C-c C-s をタイプする。するとミニバッファにこのときのイ...
Syntactic analysis: ((innamespace 353) (topmost-intro 35...
-- ここでは、''innamespace'' がインデント量を司る変数
+ インデント量を変更する
-- 直接反映する場合
+++ C-c C-o をタイプする
+++ 変更対象を指定する
innamespace [Enter]
+++ インデント量を指定する
0 [Enter]
+++ 以上で namespace 内のインデント量が 0 に変更される
-- 設定ファイルに記述する場合
;; c++ 設定
(defun c++-mode-common-conf ()
"common settings for C/C++"
; (c-set-style "bsd")
; (c-set-style "cc-mode")
(c-set-style "stroustrup")
; (c-set-style "ellementel")
;; 注: c-set-offset は、 c-set-style よりも後に記述す...
(c-set-offset 'innamespace 0) ;; name...
)
(add-hook 'c-mode-common-hook 'c++-mode-common-conf)
/////////////////////////////////////////////////////////...
* helm [#helm]
** 入手先 [#s31bbdeb]
- [[GitHub: emacs-helm/helm>https://github.com/emacs-helm...
** 参考リンク [#g7fffd17]
- [[初心者〜初級者のためのEmacs-Helm事始め : 前編>https:/...
- [[【Emacs】helmを使う>https://www.yokoweb.net/2017/01/2...
/////////////////////////////////////////////////////////...
* 参考リンク [#links]
- [[るびきち「日刊Emacs」>http://rubikitch.com/]]
- [[Programming in Emacs Lisp [ja]>http://www.math.s.chib...
- [[Meadow/Emacs memo>http://www.bookshelf.jp/soft/meadow...
- [[Emacs 活用法>http://www.math.s.chiba-u.ac.jp/~matsu/e...
- [[navi.el(関数の一覧表示とジャンプ)>http://www.ne.jp/...
-- fume-mode.el は XEmacsでしか使えないが、これはemacsで...
- [[Emacs Lispまとめ>http://matome.replore.com/index.php?...
- [[CEDET>http://sourceforge.jp/projects/sfnet_cedet/]]
- [[Undo-tree.el>http://www.emacswiki.org/emacs/UndoTree]]
終了行:
#topicpath
/////////////////////////////////////////////////////////...
* 目次 [#xdc7c37e]
#contents();
#ls2(Editor/emacs/);
/////////////////////////////////////////////////////////...
* 編集関連 [#d174f0d4]
//=======================================================...
** 編集コマンド [#cmd-edit]
|~Key |~command name |~Operation ...
|C-SPC |set-mark-command |選択の開始 ...
|M-P |set-mark-command |選択の開始 ...
|C-w |kill-region |選択した箇所をカット ...
|C-k |kill-line |現在のカーソル位置から行...
|C-y |yank |選択した箇所をヤンク(貼...
//=======================================================...
** 矩形編集コマンド [#cm-edit-rectangle]
- rectangle-mark-mode を使う。
|~Key |~command name |~Operation ...
|C-x SPC |rectangle-mark-mode |矩形選択の開始 ...
|C-w |kill-region |選択した箇所をカ...
|M-w |kill-ring-save |選択した箇所をコ...
|C-y |yank |選択した箇所をヤ...
|C-o |open-line |矩形選択した箇所...
|C-t <CHAR> |transpose-chars |矩形選択した箇所...
|C-x r t <CHAR> |transpose-chars |矩形選択した箇所...
|C-SPC → (region選択) → C-x SPC | |選択したリージョン...
|C-x r k |kill-rectangle |矩形の切り取り |
|C-x r y |yank-rectngle |矩形の貼り付け |
|C-x r N |rectangle-number-lines |上から1で始まる...
-- 矩形編集は emacs24 あたりから使うことが出来るが、使う...
//-------------------------------------------------------...
*** 使い方 [#d2cde02a]
+ 矩形編集モードに入る
C-x SPC
+ 編集対象とする矩形をカーソルキーで選択する
+ 編集したいコマンドを実行する
-- 例:矩形選択した箇所を <CHAR> で置換
C-x r t <CHAR>
//-------------------------------------------------------...
*** 参考リンク [#k8b26146]
- [[GNU Emacs Manual(Japanese Translation): Rectangles>ht...
- [[Emacs における矩形領域のコピペ系編集機能 | プログラマ...
//=======================================================...
** 置換 [#edit-replace]
//-------------------------------------------------------...
*** 対話置換 [#f82d1655]
- 検索と置換の開始
|~binding |~command name |~Operation |
|M-% |query-replace |検索して置換を開始 |
- 検索で見つかった文字列の置換
|~binding |~Operation |
|y |ハイライト中の文字列を、指定した文字列で置換し...
|n |ハイライト中の文字列を置換しないで次を検索 |
|! |全てのマッチした文字列を置換する |
|q |置換を終了する |
|? |ヘルプを表示する |
//-------------------------------------------------------...
*** 一括置換(対話なし) [#da3ba60e]
|~binding |~command |~description |
| |replace-string |一括置換 |
| |replace-regexp |一括置換(正規表現版) |
//=======================================================...
** 一括検索&一括置換 [#ff58ba80]
- moccur-edit を使う。
- 一括検索&一括置換の手順
++ 検索する
+++ 検索開始
M-x: moccur-grep-find
++ 検索対象ディレクトリを指定
Directory: <firectory>
++ 検索キーワードとファイル名キーワードの入力
Input Regexp and FileMask: <keyword-for-grep> <file-name...
--- 正規表現が使用可
--- 但し、ファイル名キーワードに於いて拡張子指定する場合...
--- 例
Input Regexp and FileMask: hoge .html$
++ 検索結果を元に一括置換する為、編集モードに入る
r
++ 置換する
M-%
++ 置換した結果を保存する
C-x C-s
- 編集のキャンセル
C-x k
//=======================================================...
** 一括インデント [#y159cc3a]
+ まず、バッファ全体を選択する
C-x h (mark-whole-buffer)
+ 選択領域に対してインデントを実行する
C-M-\ (indent-region)
//=======================================================...
** キーワードによる一括アライン(align-regex)[#align-reg...
- 代入式などが複数行にわたって並んでいるときに "=" などの...
+ 範囲を選択
C-@
+ コマンド実行する
M-x: align-regex
+ アラインするキーワードを指定する
- 例
-- 実行前
int aaa = 120;
double ad = 23.55;
std::string buff = format("test data = %d, ad = %f\n...
-- 実行後(アラインキーワードに "=" を指定した)
int aaa = 120;
double ad = 23.55;
std::string buff = format("test data = %d, ad = %f\n...
//=======================================================...
** コメントアウト/コメントアウト取り消し toggle [#c91abb...
- 下記にて、使用言語に合わせたコメントアウト/コメントア...
++ コメントアウトする領域を選択
C-@
++ コメント/コメントアウト取り消し実行
M-;
- 各言語毎の挙動
|~言語 |~コメントアウト文字 |~備考 |
|C | /* */ で各行毎に括る・削除 | |
|C++ | // を行頭に追加・削除 | |
|Objective-C | // を行頭に追加・削除 | |
|Java | // を行頭に追加・削除 | |
|Pike | // を行頭に追加・削除 | |
|python | # を行頭に追加・削除 | |
|perl | # を行頭に追加・削除 | |
|Tcl | # を行頭に追加・削除 | |
|expect | # を行頭に追加・削除 | |
|bash | # を行頭に追加・削除 | |
|HTML | <!-- --> で各行毎に括る・削除 | |
|PHP | <!-- --> で各行毎に括る・削除 | |
|C# | 未対応 | |
|Pascal | { } で各行毎に括る・削除 | |
|elisp | ;; を行頭に追加・削除 | |
- この他、非言語の設定ファイルでも対応しているものがある:
|~項目 |~コメントアウト文字 |~備考 |
|.gitconfig | # を行頭に追加・削除 | |
/////////////////////////////////////////////////////////...
* 編集以外の機能 [#q1c8a63a]
//=======================================================...
** シェルコマンドの実行 [#s3e9c369]
- 下記にてシェルコマンドを実行出来る:
M-!
//=======================================================...
** 文字数を数える [#t87cae47]
- 対象領域を選択し、
M-x: count-lines-region
または
M-=
とする。
- 行数と文字数が表示される。文字数は、全角も半角もそれぞ...
//=======================================================...
** 行をウインドウ幅で折り返す・折り返さない [#rde48c86]
- 下記のコマンドで toggle 出来る
M-x toggle-truncate-lines
C-x x t
//=======================================================...
** ファイルを read-only で開く [#sd5faa53]
C-x C-r
//=======================================================...
** HTML文書編集での自動補完 [#d02f9e86]
- yahtmlを使う(yahtmlは、YaTeXに付属しているもの)。
- [[参考リンク>http://www.namazu.org/~tsuchiya/elisp/yaht...
//=======================================================...
** 現在の文字サイズの変更 [#na2363e5]
|~binding |~command |~description |
|C-x C-- |text-scale-adjust |文字サイズを小さくする |
|C-x C-+ |text-scale-adjust |文字サイズを大きくする |
|C-x C-0 |text-scale-adjust |文字サイズを初期値に戻す |
//=======================================================...
** 起動済みのemacs にファイルを渡す (emacsclient) [#ob79c...
- emacs起動時に、emacs-serverが起動するようにしておく必要...
-- .emacs に以下の行がなければ追記する:
(server-start)
- 起動済みのemacsに、コマンドラインからファイルを渡す方法
$ emacsclient <file-name> &
-- ファイルを送っただけのようで、実際には送り先のemacsと...
-- 上記コマンドを打った端末を終了すると、送り先のemacsか...
-- どうしてもemacsclientを起動した端末が死んでも構わない...
$ nohup emacslient <file-name> &
→[[System/Process#never-kill]]
/////////////////////////////////////////////////////////...
* キーバインド [#b4420c29]
//=======================================================...
** prefix の指針 [#z4320821]
|~prefix-key |~description |
|C-x |システムコマンドが使用する |
|C-c |ユーザが定義する。(拡張機能の実装ではこれ...
|M-g |行移動に関するキーバインドが定義される |
/////////////////////////////////////////////////////////...
* モードライン [#q8d089ae]
- モードラインの表示例
--------------------------------------------------------...
-UU-:----F1 color-moccur.el 16% (665,0) Git-master ...
--------------------------------------------------------...
- 文字コード
|~表記 |~文字コード |~emacs での呼称 |
|U |Unicode |utf-8, utf-16, utf-7, etc., |
|S |Shift_JIS |sjis (shift_jis) |
|J |JIS |iso-2022-jp, etc., |
|E |EUC (JP) |euc-jp, euc-jis-2004, etc., |
|1 |Latin-1 |latin-1 (iso-8859-1) |
- 改行コード
|~表記 |~改行コード |~emacs での呼称 |
|: |LF |unix |
|(DOS) |CR+LF |dos |
|(MAC) |CR |mac |
//=======================================================...
** モードラインの書式設定 [#o351158a]
|~format |~description |~remark |
|%b |カレントバッファ名 |(buffer-name) の値 |
|%f |ファイルのフルパス |(buffer-file-name) の値 |
|%F |選択中のフレーム | |
|%* |バッファが readonly であれば "%", 変更されてい...
|%+ |バッファが readonly であっても変更されていれば ...
|%& |バッファが readonly であっても変更されていれば ...
|%s |サブプロセスのステータス |(process-status) の値 |
|%l |カーソルの行番号 | |
|%c |カーソル一のカラム番号 | |
|%i |バッファのファイルサイズ |1byte 単位 |
|%I |~|kB/MB/GB |
|%p |ウインドウの上端より上にあるバッファ量の割合 |...
|%P |ウインドウの下端より下にあるバッファ量の割合 |~|
|%n |ナローイング中であれば "Narrow" を表示する | |
|%t |ファイルがテキストであれば "T", バイナリであれ...
|%z |キーボード、端末、ファイルの文字コードを表示 |...
|%Z |文字コードと改行コードを表示する | |
|%e |エラーメッセージを表示する | |
|%@ |ファイルがローカルホストであれば "-", リモート...
|%[ |再帰編集のレベルを "[" の数で表示する。 "%]" も...
|%% |"%" を表示 | |
|%- |無限に "-" を表示する | |
/////////////////////////////////////////////////////////...
* 設定関連 [#l0e4033f]
//=======================================================...
** OS による処理分岐 [#h759b01c]
(when (eq system-type 'gnu/linux)
; Linux の場合
)
(when (eq system-type 'darwin)
; Mac の場合
)
(when (eq system-type 'windows-nt)
; Windows の場合
)
(when (eq system-type 'cygwin)
; Cygwin の場合
)
//=======================================================...
** GUI / CUI による処理分岐 [#uc1c5e73]
- 変数 window-system を参照して分岐する。
-- 変数 window-system には、 X Window-System の場合は値に...
- 分岐処理の例
-- 例1
(when window-system (progn
;; GUI用設定
))
(when (not window-system) (progn
;; CUI用設定
))
-- 例2
(if window-system (progn
;; GUI用設定
)
(progn
;; CUI用設定
))
-- 実使用例
--- Menu を開くコマンドは、emacs-28.2 時点では GUI と CUI...
(if window-system
(global-set-key "\M-m" 'accelerate-menu); メニュ...
(global-set-key "\M-m" 'menu-bar-open); メニュー...
)
//=======================================================...
** フォント設定 [#ld049214]
+ Menu → "Options" → "Set Default Font..." でフォントを選...
+ Menu → "Options" → "Save Options" で設定を保存する。(...
- フォントを "Noto Sans Mono" に設定する(${HOME}/.emacs/...
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be ...
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Noto Sans Mono" :foundry "GOOG"...
//=======================================================...
** which-function-mode [#which-function-mode]
- ソースコードを開いているとき、カーソル位置が何らかの関...
- 設定するには、この機能を使いたいモード(C/C++/perl/java...
-- 設定例:C/C++ (一旦 hook 用関数を定義してその中で呼...
; c系言語共通設定
(defun c-c++-mode-common-conf ()
"common settings for C/C++"
(if (which-function-mode nil) (which-function-mode)) ;...
)
(add-hook 'c-mode-common-hook 'c-c++-mode-common-conf)
-- 設定例:Perl (hook 用関数の代わりにλ関数を使用し、そ...
(setq perl-mode-hook
#'(lambda ()
(if (which-function-mode nil) (which-function-...
))
- 設定時の注意点
-- 各モードの hook 以外のところ(例えばそれより前の段階で...
//=======================================================...
** lisp の場所を設定する [#sa55267e]
- load-path : 指定したディレクトリを lisp を走査する場所...
-- 書式:
(load-path <path-to-lisp-dir>)
-- 書式例:
(load-path (expand-file-name "~/.emacs.d/lisp")) ; ${HOM...
- normal-top-level-add-subdirs-to-load-path : load-path ...
-- 書式:
(normal-top-level-add-subdirs-to-load-path)
-- 環境によってはアクセス権の問題等でエラーになる場合があ...
//=======================================================...
** タイトルバーの表示書式にファイル名を入れる [#h8aae4c1]
(setq frame-title-format (format "emacs@%s : %%f" (syste...
//=======================================================...
** 文字色の変更 [#j1818f18]
- emacs 上で指定された文字色を変更する方法について。
- magit, xcscope などのパッケージで、文字色の制御を行って...
//-------------------------------------------------------...
*** terminal 上で動作させる場合 [#q0925a19]
- 方法1
$ cat ${HOME}/.bashrc
alias emacsd='env TERM=xterm emacs --daemon'
alias emacs='emacsclient -t'
- 方法2
$ TERM=xterm-256color emacs -nw
- 方法3 init.elに以下を追加する
(defun terminal-init-gnome ()
"Terminal initialization function for gnome-terminal."
;; This is a dirty hack that I accidentally stumbled a...
;; initializing "rxvt" first and _then_ "xterm" seems
;; to make the colors work... although I have no idea...
(tty-run-terminal-initialization (selected-frame) "rxv...
(tty-run-terminal-initialization (selected-frame) "xte...
- 方法4 init.elに以下を追加する
(add-hook 'tty-setup-hook
'(lambda ()
(set-terminal-parameter nil 'background-mod...
//-------------------------------------------------------...
*** どの変数で色定義されているかを調べる [#eefe35f4]
+ 対象となる文字列にカーソルを合わせた上で、以下を実行す...
M-x: describe-face
すると、ミニバッファに以下のように表示される:
Describe face (default `cscope-file-face'):
+ ここで決定(return キーを押す)と、以下のように表示され...
Face: cscope-file-face (sample) (customize this face)
Documentation:
Face used to highlight file name in the *cscope* buffer.
Defined in `xcscope.el'.
Family: unspecified
Foundry: unspecified
Width: unspecified
Height: unspecified
Weight: unspecified
Slant: unspecified
Foreground: yellow
DistantForeground: unspecified
Background: unspecified
Underline: unspecified
Overline: unspecified
Strike-through: unspecified
Box: unspecified
Inverse: unspecified
Stipple: unspecified
Font: unspecified
Fontset: unspecified
Inherit: unspecified
//-------------------------------------------------------...
*** 色変更の定義 [#v3047709]
+ 上記を元に、以下のように設定してやれば、色を変えること...
(set-face-foreground 'cscope-file-face "#d54e53") ; yel...
//=======================================================...
** 色設定 [#uf6d738d]
- ${HOME}/.bashrc での、emacs/XEmacs の色設定
alias emacsk='emacs -bg "#303030" -fg white'
alias emacsb='emacs -bg azure'
alias emacsy='emacs -bg lightyellow'
alias emacsg='emacs -bg "#e0ffe0"'
alias emacsr='emacs -bg "#fff5f5"'
alias xemacs='/usr/bin/xemacs21'
alias xemacsb='xemacs -bg azure'
alias xemacsy='xemacs -bg lightyellow'
alias xemacsg='xemacs -bg "#e0ffe0"'
alias xemacsr='xemacs -bg "#fff5f5"'
//=======================================================...
** wahel-theme [#wahel-theme]
- 暗色形テーマの一つ。
- 概ね良いのだが、以下の問題がある:
-- which-function-mode でモード行に表示する関数名が暗い灰...
--- 以下のようにすると見やすくなる:
(custom-set-faces
;; which-function-mode の関数名表示の色を変更する
'(which-func ((t (:foreground "yellow"))))
)
-- C/C++ ソースコードの ediff で、コメント行同士の比較が...
//-------------------------------------------------------...
*** 参考リンク [#g0d03289]
- [[waher-theme.el : ダークなカラーテーマ>http://emacs.ru...
- [[Waher Theme | Emacs Themes>https://emacsthemes.com/th...
- [[GitHub>https://github.com/emacsfodder/emacs-waher-the...
//=======================================================...
** {menu|tool}-barを消す [#y7f4f9fe]
(tool-bar-mode 0) ; tool bar を表示しない
(menu-bar-mode 0) ; menu bar を表示しない
(which-function-mode 1) ; 現在の関数名をモードラインに表示
//=======================================================...
** 行頭に行番号を表示する(モード行ではなく) [#hd23498b]
- linum-mode を使用する(Emacs23以降で有効)
M-x: linum-mode
- Toggle する関数
; 行番号表示をトグル
; http://qiita.com/yyamamot/items/df430d4e725ea38ffc9f
(defun toggle-linum-mode ()
"toggle display line number"
(interactive)
(setq linum-format "%4d ")
(linum-mode
(if linum-mode -1 1)))
(global-set-key [f5] 'toggle-linum-mode) ; linum-mode
- 参考:[[Emacsで行番号表示をトグルする>http://qiita.com/...
//=======================================================...
** モードラインに現在カーソルが位置している関数の関数名を...
- モードラインに、現在カーソルがある位置の関数名を動的に...
M-x: which-function-mode
- .emacs に設定するには、
(setq which-function-mode t)
//=======================================================...
** モードラインの現在時刻の表示 [#l41ac910]
- 現在時刻を表示する
(display-time)
- 24時間表示にする
(setq display-time-24hr-format t)
- 24時間制・秒も表示する
(setq display-time-interval 1)
(setq display-time-string-forms
; '((format "%s:%s:%s" 24-hours minutes seconds))
'((format "%s.%s.%s(%s) %s:%s:%s" day month year d...
; '((format "%s/%s/%s(%s) %s:%s:%s" year month day...
)
-- 秒の表示は、フォーマットで秒まで指定しただけでは駄目で...
//=======================================================...
** use-package [#use-package]
- 設定を、統一的な分かり易い記述で書けるようにするライブ...
- use-package マクロを利用することで、ライブラリのロード...
- 取得元: https://github.com/jwiegley/use-package.git
//-------------------------------------------------------...
*** use-package 参考リンク [#use-package-link]
- [[use-packageで可読性の高いinit.elを書く - Qiita>https:...
- [[use-packageの使い方 [QumaWiki]>https://www-he.scphys....
//=======================================================...
** Time-stamp [#m59e6eee]
; Time-stamp
; http://homepage.mac.com/zenitani/elisp-j.html#time-stamp
(require 'time-stamp)
(setq time-stamp-start "Last updated: <") ; 開始文字列の...
;; 日本語で日付を入れたくないのでlocaleをCにする
(defun time-stamp-with-locale-c ()
(let ((system-time-locale "C"))
(time-stamp)
nil))
(if (not (memq 'time-stamp-with-locale-c write-file-hook...
(add-hook 'write-file-hooks 'time-stamp-with-locale-...
; (setq time-stamp-format "%3a %3b %02d %02H:%02M:%02S %...
(setq time-stamp-format "%04y/%02m/%02d %02H:%02M:%02S %...
//=======================================================...
** isearch で、カーソルの位置にある単語を検索対象にする [...
- isearch時に、 C-w と打てばOK
//=======================================================...
** shell-mode で制御文字を処理する [#s805f2e5]
; shell-mode で制御文字を処理する。
(autoload 'ansi-color-for-comint-mode-on "ansi-color"
"Set `ansi-color-for-comint-mode' to t." t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
//=======================================================...
** バックアップファイルを作らないようにする [#d7ff8fd4]
(setq make-backup-files nil) ; *.~ とかのバックアップフ...
(setq auto-save-default nil) ; .#* とかのバックアップフ...
//=======================================================...
** 選択領域を [DEL] で一気に消せるようにする [#y95ca8b8]
; (setq delete-selection-mode t)
(delete-selection-mode)
//=======================================================...
** scroll を1行単位にする [#l150a348]
(setq scroll-step 1)
//=======================================================...
** 分割した window のサイズを変える [#y029a37e]
|~command |~description |~remark |
|M-x: enlarge-window |縦方向にサイズを大きくする | |
|M-x: shrink-window |縦方向にサイズを小さくする | |
|M-x: enlarge-window-horizontally |横方向にサイズを大きく...
|M-x: shrink-window-horizontally |横方向にサイズを小さく...
- 参考: emacs25.1.1 では以下のように設定することで、キー...
(global-set-key (kbd "M-<up>") 'enlarge-window)
(global-set-key (kbd "M-<down>") 'shrink-window)
(global-set-key (kbd "M-<right>") 'enlarge-window-horizo...
(global-set-key (kbd "M-<left>") 'shrink-window-horizon...
- 参考: emacs23 では以下のように設定することで、キー割り...
(global-set-key "M-<up>" 'enlarge-window)
(global-set-key "M-<down>" 'shrink-window)
(global-set-key "M-<right>" 'enlarge-window-horizontally)
(global-set-key "M-<left>" 'shrink-window-horizontally)
//=======================================================...
** ウインドウ自動分割時の制御 [#k8d8ac5a]
- ウインドウが自動分割される際の、垂直分割・水平分割の制御
- 垂直分割を防ぐには、下記を設定する:
(setq split-width-threshold nil)
- 挙動としては、
++ split-height-threshold の値が選択したウィンドウより小...
++ そうでない場合、 split-width-threshold がウィンドウの...
++ どちらも満たさず、既にウィンドウが分割されてない場合は...
//=======================================================...
** beep 音を消す [#oe941343]
- 以下を設定することで、beep が一切無効になる
(setq ring-bell-function 'ignore) ; beep を一切無効にする
- 嘗ては、以下の設定でカスタマイズすることが出来たが、ema...
-- Visible bell にする
(setq visible-bell t);; Visual Bell有効(エラー時画面反...
;(setq visible-bell nil);; Visual Bell無効(エラー時ブザ...
-- beep を鳴らさないようにする
; (setq message-beep 'silent)
//=======================================================...
** 今日の日付を挿入する [#af85099b]
(defun today()
(interactive)
(insert (format-time-string "%Y/%m/%d" (current-time))))
//=======================================================...
** 前のウインドウに戻る [#ia6f365e]
; XEmacsにはあるが、emacsにはない(!)
; http://matome.replore.com/index.php?title=Emacs_Lisp%E...
; xemacsに合わせて、関数名を backward-other-window に変...
; (defun other-window-backward (&optional n)
(defun backward-other-window (&optional n)
"Select nth previous window."
(interactive "P")
(other-window (- (prefix-numeric-value n))))
//=======================================================...
** 検索時に大文字・小文字を区別するかしないかの設定 [#cas...
(setq default-case-fold-search nil) ; 大文字・小文字を...
(setq case-fold-search nil) ; 大文字・小文字を...
- emacs23.2 以降では default-case-fold-search ではなく ca...
//=======================================================...
** ediff の control window を別ウインドウにしないようにす...
- X11 環境では、デフォルトではコントロールウインドウが別...
- 方法1
++ M-x: customize-group
++ [Ediff Window Setup Function] 行頭の三角をクリックし、...
++ [Value Menu] をクリックし、プルダウンから [Single Fram...
++ バッファ先頭付近の [Apply and Save] をクリックして設定...
- 方法2:以下を設定する:
;; コントロール用のバッファを同一フレーム内に表示
(setq ediff-window-setup-function 'ediff-setup-windows-p...
;; diffのバッファを上下ではなく左右に並べる
(setq ediff-split-window-function 'split-window-horizont...
//-------------------------------------------------------...
*** 参考リンク [#qd6e9c5e]
- [[同一フレーム内にediffのコントロールバッファを表示>htt...
- [[Emacs Lisp TIPS>https://sci.nao.ac.jp/MEMBER/zenitani...
//=======================================================...
** カレンダーで日本の祝日を表示する [#u4db1263]
- M-x: calendar で表示するカレンダーで日本の祝日を表示す...
- japanese-holidays.el を入手する
-- 入手先: https://github.com/emacs-jp/japanese-holidays...
- 設定
-- 参考: http://blog.livedoor.jp/tek_nishi/archives/3027...
- enmacs 起動時に cl-lib が見つからないと怒られた場合
-- cl-lib.el を入手し、load-path の通っているところに配置...
-- 入手先: http://elpa.gnu.org/packages/cl-lib.html
/////////////////////////////////////////////////////////...
* 自動インデントにおけるインデント量のカスタマイズ [#r8a...
//=======================================================...
** C++ [#ja3a6f5a]
//-------------------------------------------------------...
*** namespace の後のインデント [#m5fa651a]
- namespace 内でのインデント量を 0 に設定したい場合
+ 下記のようにカーソルをおく
namespace hogehoge {
| ← ここにカーソルをおく
}
+ C-c C-s をタイプする。するとミニバッファにこのときのイ...
Syntactic analysis: ((innamespace 353) (topmost-intro 35...
-- ここでは、''innamespace'' がインデント量を司る変数
+ インデント量を変更する
-- 直接反映する場合
+++ C-c C-o をタイプする
+++ 変更対象を指定する
innamespace [Enter]
+++ インデント量を指定する
0 [Enter]
+++ 以上で namespace 内のインデント量が 0 に変更される
-- 設定ファイルに記述する場合
;; c++ 設定
(defun c++-mode-common-conf ()
"common settings for C/C++"
; (c-set-style "bsd")
; (c-set-style "cc-mode")
(c-set-style "stroustrup")
; (c-set-style "ellementel")
;; 注: c-set-offset は、 c-set-style よりも後に記述す...
(c-set-offset 'innamespace 0) ;; name...
)
(add-hook 'c-mode-common-hook 'c++-mode-common-conf)
/////////////////////////////////////////////////////////...
* helm [#helm]
** 入手先 [#s31bbdeb]
- [[GitHub: emacs-helm/helm>https://github.com/emacs-helm...
** 参考リンク [#g7fffd17]
- [[初心者〜初級者のためのEmacs-Helm事始め : 前編>https:/...
- [[【Emacs】helmを使う>https://www.yokoweb.net/2017/01/2...
/////////////////////////////////////////////////////////...
* 参考リンク [#links]
- [[るびきち「日刊Emacs」>http://rubikitch.com/]]
- [[Programming in Emacs Lisp [ja]>http://www.math.s.chib...
- [[Meadow/Emacs memo>http://www.bookshelf.jp/soft/meadow...
- [[Emacs 活用法>http://www.math.s.chiba-u.ac.jp/~matsu/e...
- [[navi.el(関数の一覧表示とジャンプ)>http://www.ne.jp/...
-- fume-mode.el は XEmacsでしか使えないが、これはemacsで...
- [[Emacs Lispまとめ>http://matome.replore.com/index.php?...
- [[CEDET>http://sourceforge.jp/projects/sfnet_cedet/]]
- [[Undo-tree.el>http://www.emacswiki.org/emacs/UndoTree]]
ページ名: