Emacs / Meadow の基本機能の拡張などに関する情報を、この page では掲載しています。
ekb-isearch.el を導入する方法 (Meadow のみ?) と
isearch-edit-string を使う方法を紹介します。
ekb-isearch.el
をもらってきて、それを (byte-compile して) load-path の通ったところに置き、
以下を ~/.emacs に書きましょう。
(require 'ekb-isearch nil t)
これで i-search の際に通常の方法で日本語入力が出来るようになります。
以下を ~/.emacs に書き加えましょう。
(define-key isearch-mode-map "\C-k" 'isearch-edit-string)
これで i-search に入ったとき、C-k すれば日本語が通るはずです。
font-lock-mode (の lazy-lock-mode か jit-lock-mode) を利用しましょう。
僕は以下を ~/.emacs に書いています。
(when (or window-system (eq emacs-major-version '21)) (setq font-lock-support-mode (if (fboundp 'jit-lock-mode) 'jit-lock-mode 'lazy-lock-mode)) (global-font-lock-mode 1))
emacs (Meadow.exe) を起動するとき、-rv という option を付けてあげると良いです。
redo.el をもらってきて、
それを (byte-compile して) load-path の通ったところに置き、以下を ~/.emacs に書き加えましょう。
(when (require 'redo nil t) (define-key ctl-x-map (if window-system "U" "r") 'redo))
これで C-x U (terminal 上では C-x r) で redo 出来るようになります。
ちなみに僕は以下のように設定しています。
これだと C-. でも redo 出来ます。
(when (require 'redo nil t) (define-key ctl-x-map (if window-system "U" "r") 'redo) (define-key global-map [?\C-.] 'redo))
menu-tree.el をもらってきて、
それを (byte-compile して) load-path の通ったところに置き、以下を ~/.emacs に書き加えましょう。
(require 'menu-tree nil t)
frame-title-format をいじれば良いです。
僕は以下を ~/.emacs に書いています。
(setq frame-title-format "%b (%f)")
アイコン化した時のタイトルにも、icon-title-format で同様なことが出来ます。
(setq icon-title-format "%b")
C-h に delete-backward-char を割り当てる方法と、
keyboard-translate を使う方法の 2 通りの方法を紹介します。
(global-set-key "\C-h" 'delete-backward-char)
以上を ~/.emacs に書き加えるのが前者、以下を ~/.emacs に書き加えるのが後者。
(keyboard-translate ?\C-h ?\C-?)
(global-set-key "\C-h" nil)
僕は以下のようにしています。
(keyboard-translate ?\C-h ?\C-?)
;(global-set-key "\C-h" nil)
session.el をもらってきて、
それを (byte-compile して) load-path の通ったところに置き、以下を ~/.emacs に書き加えましょう。
これだけで mini buffer の M-p, M-n が豊かな内容に。 :-)
(when (require 'session nil t) (add-hook 'after-init-hook 'session-initialize))
僕は以下のようにしています。
(when (require 'session nil t) (setq session-initialize '(de-saveplace session keys menus) session-globals-include '((kill-ring 50) (session-file-alist 100 t) (file-name-history 100))) (add-hook 'after-init-hook 'session-initialize))
browse-kill-ring.el を利用する方法を 別の page にまとめました。
以下を ~/.emacs に書き加えましょう。
(setq truncate-partial-width-windows nil)
以下を ~/.emacs に書き加えましょう。
(setq inhibit-startup-message t)
*scratch* で最初に書かれる message を消すだけなら、以下のみで十分です。
(setq initial-scratch-message "")
以下を ~/.emacs に書き加えましょう。
(defadvice query-replace (around ys:qr-region) (if (and transient-mark-mode mark-active) (save-restriction (narrow-to-region (region-beginning) (region-end)) ad-do-return) ad-do-return)) (defadvice query-replace-regexp (around ys:qrr-region) (if (and transient-mark-mode mark-active) (save-restriction (narrow-to-region (region-beginning) (region-end)) ad-do-return) ad-do-return)) (ad-enable-advice 'query-replace 'around 'ys:qr-region) (ad-enable-advice 'query-replace-regexp 'around 'ys:qrr-region)
小松さんのコードをもらったものです。
以下 (~/.autosave の部分は適当に) を ~/.emacs に書き加えましょう。
(setq auto-save-list-file-prefix (expand-file-name "~/.autosave"))
普通に割り当てれば良いだけです。 以下を ~/.emacs に書き加えましょう。
(global-set-key "\C-z" 'scroll-down)
僕は更に以下を追加して、もともと C-z に割り当ててあった機能を C-x C-z に割り当ててます。
(define-key ctl-x-map "\C-z" (if window-system 'iconify-or-deiconify-frame 'suspend-emacs))
山岡サンの fj.editor.emacs への投稿から、 以下を ~/.emacs に書き加えれば良いことがわかります。
(eval-after-load "ispell" '(add-to-list 'ispell-skip-region-alist '("[^\000-\377]+")))
ファイル名等の補完で大文字と小文字を区別させないようにするには、以下を ~/.emacs に書き加えると良いです。
(setq completion-ignore-case t)
一部の Emacsen では初めから t になっていると思います。
other-window + 負の引数で実現可能です。
(define-key ctl-x-map "p" #'(lambda (arg) (interactive "p") (other-window (- arg))))
C-x 5 o の逆の動作も同じ要領で。
(define-key ctl-x-5-map "p" #'(lambda (arg) (interactive "p") (other-frame (- arg))))
font-lock-info.el をもらってきて、
それを (byte-compile して) load-path の通ったところに置き、以下を ~/.emacs に書きましょう。
(and window-system
(eq emacs-major-version '20)
(require 'font-lock-info nil t))
Emacs 21 では必要ないみたいですね。
mic-paren.el を使うと、 (色々な形で) 対応する括弧を強調表示できるようになります。
(and (or window-system (eq emacs-major-version '21))
(locate-library "mic-paren")
(autoload 'paren-activate "mic-paren" nil t)
(setq paren-match-face 'bold
paren-sexp-mode t))
僕は上記のように設定しています。
以下を ~/.emacs に書くと、buffer の選択が i-search のような動作になります。
(iswitchb-default-keybindings)
また、以下を書いておくと、同一名の buffer があったとき、 (開いているファイルのパスの一部が表示され) ちょっと見易くなります。 :-)
(require 'uniquify) (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
以下を ~/.emacs に書いておくと、*HELP* などの window が適当な大きさで開くようになります。
(temp-buffer-resize-mode 1)
以下を ~/.emacs に書いておくと、mini buffer が必要に応じて適当な大きさになります。
(resize-minibuffer-mode 1)
以下を ~/.emacs に書いておくと良いです。
(setq backward-delete-char-untabify-method 'hungry)
以下を ~/.emacs に書いておくと良いです。
(setq require-final-newline t)
以下を ~/.emacs に書いておき、M-x ys:trim-whitespaces すると良いです。 これにより、buffer 末尾の余分な whitespace や改行も削除されます。 また、必要に応じて whitespace を tab に変換することも出来ます。
(defun ys:trim-whitespaces () "Trim excess whitespaces." (interactive "*") (let ((key (read-char "Convert spaces?: (t)abify (u)ntabify (n)o")) (reg (and transient-mark-mode mark-active))) (save-excursion (save-restriction (if reg (narrow-to-region (region-beginning) (region-end))) (goto-char (point-min)) (while (re-search-forward "[ \t]+$" nil t) (replace-match "" nil nil)) (if reg nil (goto-char (point-max)) (delete-blank-lines)) (cond ((= key ?t) (tabify (point-min) (point-max))) ((= key ?u) (untabify (point-min) (point-max))))))) (deactivate-mark))
これは region 指定しての利用も可能です。
以下を ~/.emacs に書いておくと良いです。
(when (or window-system (eq emacs-major-version '21)) (defadvice yank (after ys:highlight-string activate) (let ((ol (make-overlay (mark t) (point)))) (overlay-put ol 'face 'highlight) (sit-for 0.5) (delete-overlay ol))) (defadvice yank-pop (after ys:highlight-string activate) (when (eq last-command 'yank) (let ((ol (make-overlay (mark t) (point)))) (overlay-put ol 'face 'highlight) (sit-for 0.5) (delete-overlay ol)))))
以下を ~/.emacs に書いておくと良いです。
(defadvice backward-delete-char-untabify (around ys:backward-delete-region activate) (if (and transient-mark-mode mark-active) (delete-region (region-beginning) (region-end)) ad-do-it))
Daredevil SKK な人は以下も書いておくと良いかも…。 :-)
(add-hook 'skk-load-hook
#'(lambda ()
(defadvice skk-delete-backward-char
(around ys:skk-delete-backward-region activate)
(if (and transient-mark-mode mark-active)
(delete-region (region-beginning) (region-end))
ad-do-it))))
以下を ~/.emacs に書いて C-x M-s すれば、該当する buffer を確認しながら保存できます。 また、C-u C-x M-s では確認せずに保存します。
(defun ys:save-all-buf (&optional arg) "Save buffers in visited file if modified." (interactive "P") (let ((blist (buffer-list)) (wconf (current-window-configuration)) (numa 0) (numb 0) mess file) (delete-other-windows) (while blist (switch-to-buffer (car blist)) (and (setq file (buffer-file-name)) (buffer-modified-p) (setq numa (1+ numa)) (or arg (y-or-n-p (concat "Wrote \"" file "\"? "))) (setq numb (1+ numb) mess (concat (buffer-name) (if mess ", ") mess)) (basic-save-buffer)) (setq blist (cdr blist))) (set-window-configuration wconf) (message (if (= numa 0) "(No changes need to be saved)" (format "Wrote %d file(s): %s" numb mess))))) (define-key ctl-x-map "\M-s" 'ys:save-all-buf)
以下を ~/.emacs に書いておけば良いでしょう。
(add-hook 'find-file-hooks
#'(lambda ()
(let ((sl buffer-file-name) file)
(when (setq file (ys:file-symlink-p sl))
(while file
(find-alternate-file file)
(setq file (ys:file-symlink-p buffer-file-name)))
(setq buffer-read-only t)
(ding)
(message (format "Opened file: %s (<- %s)"
buffer-file-name sl))))))
(defun ys:file-symlink-p (path &optional arg)
(let ((top (expand-file-name path)) bot)
(while (not (or (file-symlink-p top)
(string-match "^[^/]*$" top)))
(string-match "/[^/]*$" top)
(setq bot (concat (substring top (match-beginning 0)) bot))
(setq top (replace-match "" nil t top)))
(if (setq top (file-symlink-p top))
(expand-file-name (concat top (if bot ".") bot))
(when arg (expand-file-name path)))))
これが表示されていなくても、特に問題はないと思います。 以下を ~/.emacs に書いておけば良いでしょう。
(let ((elem (assq 'encoded-kbd-mode minor-mode-alist))) (when elem (setcar (cdr elem) "")))
ishl.el を導入しましょう。 これは Emacs 21 では標準で (同等のものが) 入っているので、以下の様な対策込みの設定をしておくと良いでしょう。
(and window-system
(not (boundp 'isearch-lazy-highlight-search))
(locate-library "ishl")
(autoload 'ishl-mode "ishl" nil t)
(setq ishl-initial-delay 0.25
ishl-delay 0.05)
(add-hook 'isearch-mode-hook
#'(lambda () (ishl-mode 1))))
elscreen.el を導入しましょう。
(when (locate-library "elscreen") (setq elscreen-prefix-key (if window-system [?\C-\;] "\C-\\")) (require 'elscreen))
この場合、C-; (terminal 上では C-\) で ElScreen の呼び出しとなります。
更に僕は elscreen-plus.el というものを入れています。 この場合は以下の様に設定します。
(when (locate-library "elscreen") (setq elscreen-prefix-key (if window-system [?\C-\;] "\C-\\")) (require 'elscreen) (require 'elscreen-plus nil t))
これを導入すると、elscreen の呼び出し時に screen の一覧がエコー領域に表示されるようになります。 また、その一覧が消えてしまっても、スペースを押せば再表示されます。 その他の基本的なキー操作自体は変わりません。
dabbrev-highlight.el を導入しましょう。
(when (or window-system (eq emacs-major-version '21)) (require 'dabbrev-highlight nil t))
dabbrev-expand で日本語を扱う場合、dabbrev-highlight.el とともに配布されている dabbrev-ja.el も導入した方が良いでしょう。
(load "dabbrev-ja" t t)
minibuf-isearch.el を導入しましょう。
(require 'minibuf-isearch nil t)
mini-buffer での文字列入力時に C-r すると、i-search が始まります。
Emacs 21 の場合、\M-x hl-line-mode すると良いでしょう。 もしそれが出来ない場合は、 highline.el を導入しましょう。
(and window-system
(locate-library "highline")
(autoload 'highline-on "highline" nil t)
(autoload 'highline-mode-on "highline" nil t)
(setq highline-face 'highlight))
上記の内容を ~/.emacs に追加して、 M-x highline-on や M-x highline-mode-on すれば良いです。
以下を ~/.emacs に追加すれば、
kill-ring-save 等した時にその内容が既に kill-ring にある場合、その文字列が kill-ring の先頭に 1 つにまとめられます。
(defadvice kill-new (before ys:no-kill-new-duplicates activate) (setq kill-ring (delete (ad-get-arg 0) kill-ring)))
gc-cons-threshold の値 (初期設定では 400,000) を大きくすると、
ガベッジコレクションの頻度が下がり、結果として Emacs の動作が速くなります。
僕は以下のようにしています。
(setq gc-cons-threshold 5242880)
Meadow-1.1X では defface で underline: は nil, t しか受け付けないので、 それ以外の値を利用とする semantic や emacs wiki ではエラーが出てしまいます。 以下を ~/.emacs に書くことにより、それを回避できます。
(when (and (featurep 'meadow) (eq emacs-major-version 20)) (defadvice internal-set-face-property (before face-underline activate) (when (and (eq property 'underline) value (stringp value)) (setq value t))))
このコードは 白井サンが meadow-users-jp に投稿された ものです。
以下の例の様に ~/.emacs に書けば良いです。 もちろん、色の指定の部分は適当に書き換えて下さい。
(set-face-foreground 'default "white") (set-face-background 'default "black") (setq frame-background-mode 'dark) (frame-update-face-colors (selected-frame))
ちなみに上記の例は reverse video と同じ効果を得るものです。