月別: 7月 2016
Emacsを使い始めました
日々テキストエディタをいろいろ試してますが、久しぶりにEmacsを使ってみようと思い立ち、GNU Emacs 24.5 簡易IME版を入れました。
パッケージが思ったのが出てこなかったり、recentf(ファイル履歴)が使えなかったりとなかなか思うようにいきません。
とりあえずなんとかつかえそうになったので、init.elを貼り付け
ほとんど、以下のサイトから貼り付けただけですが。
http://d.hatena.ne.jp/sandai/20120304/p2
■Emacs用init.el
(setq debug-on-error t) ;;http://d.hatena.ne.jp/sandai/20120304/p2 ;;http://qiita.com/icb54615/items/4c652ad4afccae5fe2ef ;; @ load-path (message "@ load-path") ;;; load-pathを追加する関数を定義 (defun add-to-load-path (&rest paths) (let (path) (dolist (path paths paths) (let ((default-directory (expand-file-name (concat user-emacs-directory path)))) (add-to-list 'load-path default-directory) (if (fboundp 'normal-top-level-add-subdirs-to-load-path) (normal-top-level-add-subdirs-to-load-path)))))) ;;; ディレクトリをサブディレクトリごとload-pathに追加 (add-to-load-path "elisp") ;; ———————————————————————— ;; @ general (message "@ general") ;; common lisp (require 'cl) ;; 文字コード (set-language-environment "Japanese") (let ((ws window-system)) (cond ((eq ws 'w32) (prefer-coding-system 'utf-8-unix) (set-default-coding-systems 'utf-8-unix) (setq file-name-coding-system 'sjis) (setq locale-coding-system 'utf-8)) ((eq ws 'ns) (require 'ucs-normalize) (prefer-coding-system 'utf-8-hfs) (setq file-name-coding-system 'utf-8-hfs) (setq locale-coding-system 'utf-8-hfs)))) ;; Windowsで英数と日本語にMeiryoを指定 @font ;; Macで英数と日本語にRictyを指定 (let ((ws window-system)) (cond ((eq ws 'w32) ;; (set-face-attribute 'default nil ;; :family "Meiryo" ;; 英数 ;; :height 100) ;; (set-fontset-font nil 'japanese-jisx0208 (font-spec :family "Meiryo"))) ;; 日本語 ;; (set-face-attribute 'default nil ;; :family "Myrica M" ;; 英数 ;; :height 120) ;; (set-fontset-font nil 'japanese-jisx0208 (font-spec :family "Myrica M"))) ;; 日本語 ;; (set-face-attribute 'default nil ;; :family "VL Gothic" ;; 英数 ;; :height 120) ;; (set-fontset-font nil 'japanese-jisx0208 (font-spec :family "VL Gothic"))) ;; 日本語 ;; (set-face-attribute 'default nil ;; :family "Consolas" ;; 英数 ;; :height 120) ;; (set-fontset-font nil 'japanese-jisx0208 (font-spec :family "IPA Gothic"))) ;; 日本語 (set-face-attribute 'default nil :family "Ricty Diminished" ;; 英数 :height 120) (set-fontset-font nil 'japanese-jisx0208 (font-spec :family "Ricty Diminished"))) ;; 日本語 ((eq ws 'ns) (set-face-attribute 'default nil :family "Ricty" ;; 英数 :height 140) (set-fontset-font nil 'japanese-jisx0208 (font-spec :family "Ricty"))))) ;; 日本語 ;; スタートアップ非表示 (setq inhibit-startup-screen t) ;; scratchの初期メッセージ消去 (setq initial-scratch-message "") ;; ツールバー非表示 (tool-bar-mode -1) ;; メニューバーを非表示 ;;(menu-bar-mode -1) (message "@ Window setting") ;; スクロールバー非表示 ;;(set-scroll-bar-mode nil) ;; タイトルバーにファイルのフルパス表示 (setq frame-title-format (format "%%f – Emacs@%s" (system-name))) ;; 行番号表示 (global-linum-mode t) (set-face-attribute 'linum nil :foreground "#800" :height 0.9) ;; 行番号フォーマット ;;(setq linum-format "%4d") ;; 括弧の範囲内を強調表示 (show-paren-mode t) (setq show-paren-delay 0) (setq show-paren-style 'expression) ;; 括弧の範囲色 (set-face-background 'show-paren-match-face "#500") ;; 選択領域の色 (set-face-background 'region "#555") ;; 行末の空白を強調表示 (setq-default show-trailing-whitespace t) (set-face-background 'trailing-whitespace "#b14770") ;; タブをスペースで扱う (setq-default indent-tabs-mode nil) ;; タブ幅 (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won’t work right. '(column-number-mode t) '(cua-mode t nil (cua-base)) '(current-language-environment "Japanese") '(show-paren-mode t) '(tab-width 4) '(tool-bar-mode nil)) ;; yes or noをy or n (fset 'yes-or-no-p 'y-or-n-p) ;; 最近使ったファイルをメニューに表示 (recentf-mode t) ;; 最近使ったファイルの表示数 (setq recentf-max-menu-items 10) ;; 最近開いたファイルの保存数を増やす (setq recentf-max-saved-items 3000) ;; ミニバッファの履歴を保存する (savehist-mode 1) ;; ミニバッファの履歴の保存数を増やす (setq history-length 3000) ;; バックアップを残さない (setq make-backup-files nil) ;; 番号付けによる複数保存 (setq version-control t) ;; 実行の有無 (setq kept-new-versions 5) ;; 最新の保持数 (setq kept-old-versions 1) ;; 最古の保持数 (setq delete-old-versions t) ;; 範囲外を削除 ;; 行間 (setq-default line-spacing 0) ;; 1行ずつスクロール (setq scroll-conservatively 35 scroll-margin 0 scroll-step 1) (setq comint-scroll-show-maximum-output t) ;; shell-mode ;; フレームの透明度 (set-frame-parameter (selected-frame) 'alpha '(0.85)) ;; モードラインに行番号表示 (line-number-mode t) ;; モードラインに列番号表示 (column-number-mode t) ;; C-Ret で矩形選択 ;; 詳しいキーバインド操作:http://dev.ariel-networks.com/articles/emacs/part5/ (cua-mode t) (setq cua-enable-cua-keys nil) ;; ———————————————————————— ;; @ modeline (message "@modeline") ;; モードラインの割合表示を総行数表示 (defvar my-lines-page-mode t) (defvar my-mode-line-format) (when my-lines-page-mode (setq my-mode-line-format "%d") (if size-indication-mode (setq my-mode-line-format (concat my-mode-line-format " of %%I"))) (cond ((and (eq line-number-mode t) (eq column-number-mode t)) (setq my-mode-line-format (concat my-mode-line-format " (%%l,%%c)"))) ((eq line-number-mode t) (setq my-mode-line-format (concat my-mode-line-format " L%%l"))) ((eq column-number-mode t) (setq my-mode-line-format (concat my-mode-line-format " C%%c")))) (setq mode-line-position '(:eval (format my-mode-line-format (count-lines (point-max) (point-min)))))) ;; ———————————————————————— ;; @ key bind (message "@ key bind") ;; バックスラッシュ (define-key global-map (kbd "M-|") "\\") ;; globalなC-zを無効化 (global-unset-key "\C-z") ;;カラーテーマ設定 (load-theme 'deeper-blue t) ;;ウィンドウ設定 (message "@Window") ;;ウィンドウサイズ ;; (setq initial-frame-alist ;; '((top . 1) (left . 1) (width . 80) (height . 55))) ;; (setq default-frame-alist ;; (append (list '(foreground-color . "azure3") ;; '(background-color . "black") ;; '(border-color . "black") ;; '(mouse-color . "white") ;; '(cursor-color . "white") ;; '(width . 70) ;; <- ココと ;; '(height . 33) ;; <- ココの数字 ;; '(alpha . (80 60 40 40)) ;; ) ;; default-frame-alist)) ;==================================== ;フレーム位置設定(ウィンドウ) ;==================================== (setq initial-frame-alist (append '((top . 1) ; フレームの Y 位置(ピクセル数) (left . 470) ; フレームの X 位置(ピクセル数) (width . 105) ; フレーム幅(文字数) (height . 41) ; フレーム高(文字数) ) initial-frame-alist)) ;;フォントMyrica M 用 width 105,height 40 ;;フォントVl Gothic 105,33 ;;フォントConsolasとIPA Gothic 94,35 ;;Ricty Diminished 105,41 ;;パッケージ ;; (require 'package) ;; (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/")) ;; (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) ;; (fset 'package-desc-vers 'package–ac-desc-version) ;; (package-initialise) ;; ;;auto-install ;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/auto-install/")) ;; (require 'auto-install) ;; (auto-install-update-emacswiki-package-name t) ;; (auto-install-compatibility-setup) ;; ———————————————————————— ;; @ menu-tree.el (message "@ menu-tree") ;; メニューバー日本語化 ;; http://www11.atwiki.jp/s-irie/pages/13.html ;; (if (and (= emacs-major-version 22) ;; (eq window-system 'x)) ;; (setq menu-tree-coding-system 'utf-8)) ;; (require 'menu-tree nil t) ;; ———————————————————————— ;; @ tabbar.el (message "@ tabbar") ;; タブ化 ;; http://www.emacswiki.org/emacs/tabbar.el ;;(require 'cl) ;; (require 'tabbar nil t) ;; ;; scratch buffer以外をまとめてタブに表示する ;; (setq tabbar-buffer-groups-function ;; (lambda (b) (list "All Buffers"))) ;; (setq tabbar-buffer-list-function ;; (lambda () ;; (remove-if ;; (lambda(buffer) ;; (unless (string-match (buffer-name buffer) ;; "\\(*scratch*\\|*Apropos*\\|*shell*\\|*eshell*\\|*Customize*\\)") ;; (find (aref (buffer-name buffer) 0) " *")) ;; ) ;; (buffer-list)))) ;; ;; tabbarを有効にする ;; (tabbar-mode 1) ;; ;; ボタンをシンプルにする ;; (setq tabbar-home-button-enabled "") ;; (setq tabbar-scroll-right-button-enabled "") ;; (setq tabbar-scroll-left-button-enabled "") ;; (setq tabbar-scroll-right-button-disabled "") ;; (setq tabbar-scroll-left-button-disabled "") ;; ;; Ctrl-Tab, Ctrl-Shift-Tab でタブを切り替える ;; (dolist (func '(tabbar-mode tabbar-forward-tab tabbar-forward-group tabbar-backward-tab tabbar-backward-group)) ;; (autoload func "tabbar" "Tabs at the top of buffers and easy control-tab navigation")) ;; (defmacro defun-prefix-alt (name on-no-prefix on-prefix &optional do-always) ;; `(defun ,name (arg) ;; (interactive "P") ;; ,do-always ;; (if (equal nil arg) ;; ,on-no-prefix ;; ,on-prefix))) ;; (defun-prefix-alt shk-tabbar-next (tabbar-forward-tab) (tabbar-forward-group) (tabbar-mode 1)) ;; (defun-prefix-alt shk-tabbar-prev (tabbar-backward-tab) (tabbar-backward-group) (tabbar-mode 1)) ;; (global-set-key [(control tab)] 'shk-tabbar-next) ;; (global-set-key [(control shift tab)] 'shk-tabbar-prev) ;; ;; GUIで直接ファイルを開いた場合フレームを作成しない ;; (add-hook 'before-make-frame-hook ;; (lambda () ;; (when (eq tabbar-mode t) ;; (switch-to-buffer (buffer-name)) ;; (delete-this-frame)))) ;;バッファ移動で*付をスキップ ;;http://uid0130.blogspot.jp/2014/09/emacsnext-bufferprevious-bufferbuffer.html (defun asterisked? (buf-name) (= 42 (car (string-to-list buf-name)))) (defun move-to-scratch () (interactive) (let ((current-buffer-name (buffer-name))) (next-buffer) (while (and (not (string= "*scratch*" (buffer-name))) (not (string= current-buffer-name (buffer-name)))) (next-buffer)))) (defun next-buffer-with-skip* () (interactive) (let ((current-buffer-name (buffer-name))) (next-buffer) (while (and (asterisked? (buffer-name)) (not (string= current-buffer-name (buffer-name)))) (next-buffer)))) (defun previous-buffer-with-skip* () (interactive) (let ((current-buffer-name (buffer-name))) (previous-buffer) (while (and (asterisked? (buffer-name)) (not (string= current-buffer-name (buffer-name)))) (previous-buffer)))) (global-set-key "\C-z\C-b" 'previous-buffer-with-skip*) (global-set-key "\C-z\C-f" 'next-buffer-with-skip*) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won’t work right. ) ;;スムーズスクロール ;;http://qiita.com/ShingoFukuyama/items/429199542c38625c5554 ;;; smooth-scroll (require 'smooth-scroll) (smooth-scroll-mode t) ;; スクロールした際のカーソルの移動行数 ;; (setq scroll-conservatively 1) ;; ;; スクロール開始のマージンの行数 ;; (setq scroll-margin 5) ;; ;; 1 画面スクロール時に重複させる行数 ;; (setq next-screen-context-lines 3) ;; ;; 1 画面スクロール時にカーソルの画面上の位置をなるべく変えない ;; (setq scroll-preserve-screen-position t) ;;; ホイールマウス (mouse-wheel-mode t) (setq mouse-wheel-follow-mouse t) ;; マウスホイールによるスクロール時の行数 ;; Shift 少なめ、 Ctrl 多めに移動 (setq mouse-wheel-scroll-amount '(5 ; 通常 (デフォルト 5) ((shift) . 1) ; Shift (デフォルト 1) ((control) . 40) ; Ctrl (デフォルト nil = 無効) )) ;;マウススクロール ;;http://n8.hatenablog.com/entry/2012/03/21/012417 ;; (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time ;; (setq mouse-wheel-progressive-speed nil) ;; don’t accelerate scrolling ;; (setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse ;; マウスホイールによるスクロール加速を無効に ;;https://gist.github.com/sonota88/905708/a482512c53c1bd08eb3ed92a8dc4b70d6b021688 (setq mouse-wheel-progressive-speed nil) ;; マウスホイールによるスクロール量を指定 (global-set-key [mouse-4] '(lambda () "" (interactive) (scroll-down 2))) (global-set-key [mouse-5] '(lambda () "" (interactive) (scroll-up 2))) ;; または (kbd "") / (kbd "") ;; カーソルのある行のハイライトを有効にする ;;http://myemacs.readthedocs.io/ja/latest/basic-customize.html (global-hl-line-mode t) ;; ハイライトの色を設定します (custom-set-faces '(hl-line ((t (:background "dark gray"))))) ;; ハイライトのスタイルをアンダーラインにします ;; ただしアンダーバーが見えづらくなる問題があります (setq hl-line-face 'underline) ;;文字コード固定 http://yohshiy.blog.fc2.com/blog-entry-273.html (modify-coding-system-alist 'file "\\.txt\\'" 'shift_jis ) ;; Text
■xyzzyエディタ
ちなみにこちらは、昔使ってたxyzzyを旧HDDからコピーしたもの(使い方忘れてしまいました。)
.xyzzyもとりあえず貼り付け
■.xyzzy
;;********************************************************** ;;自宅用xyzzy定義ファイル ;;********************************************************** ;;◆トレース機能有効 ;;(toggle-trace-on-error) ;;◆diff-buffer (require "diff-buffer") ;;◆IE plug-in (load-library "browser") (load-library "browserex") ;;browserex用キーバインド (global-set-key #\M-F8 'bx:change-browser) (global-set-key #\M-F9 'bx:navigate-current-buffer) (global-set-key #\M-F10 'bx:navigate-current-buffer-directory) (global-set-key #\M-F11 'bx:rotate-browser) (global-set-key #\M-F12 'bx:close-browser) (global-set-key #\RBtnUp 'bx:browserex-mouse-menu-popup) (global-set-key #\Apps 'bx:browserex-apps-popup) (global-set-key #\M-Up 'bx:browserex-scroll-up) (global-set-key #\M-Down 'bx:browserex-scroll-down) (global-set-key #\M-Left 'bx:browserex-scroll-left) (global-set-key #\M-Right 'bx:browserex-scroll-right) (global-set-key #\M-PageUp #'(lambda () (interactive) (bx:browserex-scroll-up :unit :page))) (global-set-key #\M-PageDown #'(lambda () (interactive) (bx:browserex-scroll-down :unit :page))) (global-set-key #\M-Home #'(lambda () (interactive) (bx:browserex-scroll-up :unit :all))) (global-set-key #\M-End #'(lambda () (interactive) (bx:browserex-scroll-down :unit :all))) ;;◆NetInstaller (require "ni/setup") ;; 自動設定を利用する (ni-autoload) ;; PROXYを通す場合 ;;(setq ni::*http-proxy-host* "proxy.******.co.jp") ; PROXY のホスト ;;(setq ni::*http-proxy-port* 8080) ; PROXY のポート ;;Netinstallerのサイトを最新にする(*NetInstaller Site*バッファでN) (defun ni::add-site-from-wiki () (interactive) (let ((s (ni::http-get-url "http://xyzzy.s53.xrea.com/wiki/index.php?cmd=source&page=NetInstaller%2F%C7%DB%C9%DB%A5%D1%A5%C3%A5%B1%A1%BC%A5%B8%B0%EC%CD%F7"))) (ni::load-site-data) (mapcar (lambda (x) (ignore-errors (ni::site-add x))) (set-difference (remove-if 'null (mapcar (lambda (i) (and (string-match "^:[^|]+|\\(http:.*\\)$" i) (apply #'concat (mapcar (lambda (x) (let ((tmp (split-string x #\;))) (if (equal (car tmp) "amp") (apply #'concat "&" (cdr tmp)) (car tmp)))) (split-string (match-string 1) #\&))))) (let (out) (while (handler-case (progn (push (read-line s) out) t) (quit (c) (return-from ni::add-site-from-wiki)) (error (c) nil))) (nreverse out)))) (mapcar (lambda (x) (cdr (assoc "src" x :test 'equal))) ni::*site-data*) :test 'equal))) t) ;;ここがキーバインド (define-key ni::*site-map* #\N 'ni::add-site-from-wiki) ;;◆info (load-library "info") ;;◆info-modoki-mode (require "info-modoki-mode") (define-key ed::*lisp-mode-map* #\F1 'imm-refer-selection) (define-key ed::*lisp-interaction-mode-map* #\F1 'imm-refer-selection) (set-function-bar-label #\F1 "infoモドキ") ;;◆ごみはごみ箱へ (setq *filer-use-recycle-bin* t) ;;◆選択範囲があるときだけWin同様のカットアンドペーストキーマップ ;;(load-library "winkey") ;;◆tterm (load-library "tterm") (use-package "tterm") ;;◆TAB_key(CTRL+Qなしで入力 for c-mode) ;;(define-key ed::*c-mode-map* #\tab 'self-insert-command) ;;◆line-top and line-bottom移動キーマップ ;;(define-key *global-keymap* #\End ;; 'end-of-line ) ;;(define-key *global-keymap* #\Home ;; 'beginning-of-line) ;;(define-key *global-keymap* #\C-Home ;; 'beginning-of-buffer ) ;;(define-key *global-keymap* #\C-End ;; 'end-of-buffer) ;;◆名前をつけて保存のあと、表示ファイル名変更 (define-key ctl-x-map #\C-w 'emacs-write-file) ;;◆window-toggle-division (require "window-toggle-division") ;;◆sql-mode(--で始まる行をコメント文にする) (in-package "editor") (add-hook '*sql-mode-hook* #'(lambda () (set-syntax-start-c++-comment *sql-mode-syntax-table* #\-) (set-syntax-end-c++-comment *sql-mode-syntax-table* #\LFD))) (in-package "user") ;;◆mode選択Popupメニュー(C-x F3) (defun mode-selecter () (interactive) (let ((menu1 (create-popup-menu nil)) (menu2 (create-popup-menu nil)) l ol) (continue-pre-selection) (dolist (m *auto-mode-alist*) (pushnew (cdr m) l :test 'equal)) (dolist (sym (ed::apropos-find-matches "-mode$" #'commandp)) (unless (or (member sym l) (member sym ;[その他(O)...] にも表示しないモード '(latex-mode clickable-url-set-attribute-any-mode life-mode changelogmemo-mode buffer-menu-mode edit-abbrevs-mode tterm-char-mode fortran-auto-fill-mode info-modoki-mode extlib-mode instant-toggle-tab-mode qanda-mode ese-fortune-mode imm-search-mode))) (pushnew sym ol))) (flet ((add-menu (li mn) (dolist (i li) (let ((m i)) (add-menu-item mn nil (format nil "~S" m) #'(lambda () (interactive) (funcall m)) #'(lambda () (when (eq buffer-mode m) :check))))))) (add-menu (sort l #'string-lessp) menu1) (add-menu (sort ol #'string-lessp) menu2)) (add-menu-separator menu1) (add-popup-menu menu1 menu2 "その他(&O)...") (track-popup-menu menu1))) (define-key ctl-x-map #\F3 'mode-selecter) ;;◆IMEのステータスを表示 ;;(setq-default mode-line-format "--%*- %b (%M) [%k:%l] %P %f [%i]") (setq-default mode-line-format "--%*- %b (%M) [%k:%l] %P [%i] %f") ;;◆デフォルトのフォルダを決める ;;(set-default-directory "C:/Data/") (set-default-directory "G:/Data/") ;;◆google search (defun search-google-selection () (interactive) (ed::edict-lookup-selection #'search-google)) (defun search-google (from to) (interactive "r") (if (= from to) (progn (message "単語が選択されてない") (return-from search-google nil))) (long-operation (let ((str (si:www-url-encode (buffer-substring from to))) url) (setq url (concat "http://www.google.co.jp/search?num=50&lr=lang_ja&ie=shift_jis&oe=shift_jis&q=" str)) ;;(setq url (concat "http://www.google.com/search?q=" str)) ;---------------------------------------- ; 1. browser.dll & browserex.l を使う場合 (bx::navigate url :position bx::XPIS_BOTTOM :size 200) ; 2. 標準ブラウザを使う場合 ;(shell-execute url t) ; 3. www-mode を使う場合 ;(www-open-url url) ;---------------------------------------- ))) ;(global-set-key '(#\C-c #\g) 'search-google-selection) ;(global-set-key '(#\C-@) 'search-google-selection) (global-set-key '(#\C-F9) 'search-google-selection) (set-function-bar-label #\C-F9 "Google") ;;◆text-modeではC-aですべて選択する ;;(define-key *text-mode-map* #\C-a 'selection-whole-buffer) ;;◆F1 で info を起動するようにする。 ;;キーバインドを変更する。 ;;(global-set-key #\F1 'ed::info) ;;ラベルを変更する。 ;;(set-function-bar-label #\F1 "info") ;;◆CTRL+Fで検索ダイアログ表示 & SHIFT+F11でgrepダイアログ表示 ;;(global-set-key #\C-f 'ed::search-dialog) (define-key *global-keymap* #\C-f 'search-dialog) (define-key *global-keymap* #\S-F11 'grep-dialog ) ;;ラベルを変更する。 (set-function-bar-label #\S-F11 "Grep") ;;◆layered-window (require "layered-window") ;; Ctrl+F12 で透明化を切り替え (global-set-key #\C-F12 'toggle-layered-window) ;; xyzzy 終了時にフェードアウトする ;(add-hook '*kill-xyzzy-hook* ; #'(lambda () ; (if (layered-window-p) ; (do ((n 100 (- n 10))) ; ((< n 0)) ; (layered-window-set-opacity n) ; (sit-for 0.05)))) ; ) ;; 非アクティブなときは半透明にする (add-hook '*deactivate-hook* #'(lambda () (if (layered-window-p) (layered-window-set-opacity 40))) ) (add-hook '*activate-hook* #'(lambda () ;; opaque だとちらつく (if (layered-window-p) (layered-window-set-opacity 85))) ) ;;ラベルを変更する。 (set-function-bar-label #\C-F12 "Layered") ;; 70% のアルファ値で透明化(0 は完全な透明、100 は完全な不透明) ;;(layered-window-set-opacity 85) ;;◆ *scratch* バッファを自動で保存・復元する。 ;; *scratch* バッファの漢字コード・改行コードの設定 (save-excursion (set-buffer "*scratch*") (change-fileio-encoding *encoding-euc-jp*) ; EUC-JP (change-eol-code *eol-lf*)) ; LF ;; *scratch* を終了時に保存 (add-hook '*kill-xyzzy-hook* #'(lambda () (set-buffer (find-buffer "*scratch*")) (write-file "~/.scratch"))) ;; *scratch* を起動時に復元 (add-hook '*post-startup-hook* #'(lambda () (let ((file "~/.scratch")) (when (file-exist-p file) (set-buffer (find-buffer "*scratch*")) ;(erase-buffer (selected-buffer)) (insert-file-contents file t) (message "*scratch* restored"))))) ;;◆clipselect クリップボード履歴 (require "clipselect") ;;キーバインド (global-set-key '(#\C-F11) 'clipselect) ;;ラベルを変更する。 (set-function-bar-label #\C-F11 "ClipSelect") ;;◆chcolor 色変更 (load-library "chcolor/chcolor") ;;キーバインド (global-set-key #\C-F10 'chcolor) ;;ラベルを変更する。 (set-function-bar-label #\C-F10 "ChColor") ;;◆標準メニューをポップアップ表示 (defun popup-app-menu () (interactive) (let ((menu (copy-menu-items *app-menu* (create-popup-menu)))) (track-popup-menu menu))) (global-set-key #\M-Apps 'popup-app-menu) ;;◆行の二重化 (defun reproduction-line () (interactive) (let (bol eol) (save-excursion (setf bol (progn (goto-bol) (point))) (setf eol (progn (goto-eol) (point))) (newline) (insert-buffer-substring (selected-buffer) bol eol)))) ;;キーバインド (global-set-key #\S-F10 'reproduction-line) ;;ラベルを変更する。 (set-function-bar-label #\S-F10 "Split") ;;◆ .xyzzy を lisp-interaction-mode で編集する (pushnew '(".xyzzy$" . lisp-interaction-mode) *auto-mode-alist*) ;;◆ Bookshelf Basic起動(終了を待つ) (defun bookshelf-call () (interactive) (call-process "C:/Program Files/Microsoft Reference/Bookshelf Basic 2.0/bs98jl.exe" :wait t)) ;;キーバインド (global-set-key #\C-F8 'bookshelf-call) ;;ラベルを変更する。 (set-function-bar-label #\C-F8 "Bookshelf") ;;◆ステータスバー変更 (setq *status-bar-format* "cupT") ;;◆text-modeで起動 ;(setq *initial-buffer-mode* 'text-mode) ;この設定にすると、scratchに対しても確認メッセージが出てしまう。 ;lisp-intaractive-modeになっているとメッセージが出ない。 ;;◆現在時刻挿入 (defun insert-now-string () (interactive "*") (insert (format-date-string "[%Y/%m/%d %H:%M]"))) ;(global-set-key #\C-M-\\ 'insert-now-string) ;;キーバインド (global-set-key #\C-F7 'insert-now-string) ;;ラベルを変更する。 (set-function-bar-label #\C-F7 "日時挿入") ;;◆bufmenu ;;; バッファ選択ポップアップリスト表示 [C-Apps C-Apps] ;; (global-set-key '(#\C-Apps #\C-Apps) 'bufmenu-popup) (global-set-key '(#\S-F2) 'bufmenu-popup) (set-function-bar-label #\S-F2 "buf-pop") ;;; バッファバーコンテクストメニューを表示 [C-Apps Apps] (global-set-key '(#\C-Apps #\Apps) 'bufmenu-popup-buffer-bar-context-menu) ;;◆バッファをさくさく切り替え ;;(ALt + [←/→] でバッファが切り替え) (setq *next-buffer-in-tab-order* t) ; バッファ移動をタブ順に (global-set-key #\M-Right 'next-buffer) ; 前のバッファに移動 (global-set-key #\M-Left 'previous-buffer) ; 後のバッファに移動 ;;◆ウィンドウもさくさく切り替え ;;(ALt + [↑/↓] でウィンドウ(画面内で縦とか横とかに分割単位)を切り替え) ;;(global-set-key #\M-Up 'move-previous-window) ;;(global-set-key #\M-Down 'other-window) ;;(CTL+ALt + [↑/↓] に変えた。変更行への移動とかぶってたので。) (global-set-key #\C-M-Up 'move-previous-window) (global-set-key #\C-M-Down 'other-window) ;;◆www-mode (autoload 'www "www/www" t) ;通常起動 (autoload 'www-open-url "www/www" t) ;URL指定起動 (autoload 'www-open-local-file "www/www" t) ;ローカルのファイル指定起動 (autoload 'www-open-current-buffer "www/www" t) ;現在のファイルで起動 ;;◆re-compile-all-file-necessary(オールバイトコンパイル) ;;キーバインド (global-set-key #\S-C-F5 're-compile-all-file-necessary) ;;ラベルを変更する。 (set-function-bar-label #\S-C-F5 "ByteCompile") ;;◆shell3 ;;;起動は標準と同じでM-x shell ;;;C-p,C-nや上下矢印でコマンド履歴をたどれる。 (require "shell3") ;;◆windows風キー設定 (load-library "winkey2") ;;◆キーボードマクロの開始・終了を同じキーに割り当てる (defun startend-kbd-macro() (interactive) (if (kbd-macro-saving-p) (progn (message "定義終了") (end-kbd-macro)) (progn (message "定義開始") (start-kbd-macro)))) (global-set-key #\S-F1 'startend-kbd-macro) (set-function-bar-label #\S-F1 "KB-Macro") ;;◆書込み禁止のトグル切り替え(標準はC-x C-q) (global-set-key #\S-C-F6 'toggle-read-only) (set-function-bar-label #\S-C-F6 "書込可切替") ;;◆リージョンとセレクション(選択範囲)をトグルで変換。 ;;キー設定 (global-set-key '(#\C-x #\SPC) 'exchange-region-and-selection) (global-set-key #\C-F6 'exchange-region-and-selection) (set-function-bar-label #\C-F6 "選択<->Region") ;;◆変更行の行番号の色変更 (require "chgline_no_chgcolor") ;;◆ファイルを開く時にセッションファイルならば展開する (add-hook '*before-find-file-hook* #'(lambda (x) (when (string-matchp "\\.ssn$" x) (load-session x) (selected-buffer)))) ;;◆filerですべてのファイルを表示 ; 2画面用 (setq *filer-primary-file-mask* '("*")) (setq *filer-secondary-file-mask* '("*")) ; 1画面用 (setq *filer-last-file-mask* '("*")) ;;◆quote-menu(引用符つき貼り付け) (require "quote-menu/quote-menu") (setq ed::*quote-use-customize-menu* t) (setq ed::*quote-string-list* '(">> " "| ")) ;;◆文字列動的補完のキーバインド追加 (require "dabbrev") (global-set-key #\C-t 'dabbrev-popup) (setq *popup-completion-list-default* :always) ;;◆メニューにクローズボックス(メニューの右端にカレントのバッファを閉じる×ボタン追加) (add-hook '*init-app-menus-hook* #'(lambda () (add-menu-item *app-menu* 'close-box :close-box #'kill-selected-buffer))) ;;◆OutlineX (require "outlinex") (global-set-key #\S-F3 'olx) (set-function-bar-label #\S-F3 "アウトライン") ;;◆shift-selectionのキー割付(複数行まとめインデント) ;;インデント (global-set-key #\C-F3 'shift-selection) (set-function-bar-label #\C-F3 "インデント") ;;アンインデント (global-set-key #\C-S-F3 'unshift-selection) (set-function-bar-label #\C-S-F3 "アンインデント") ;;◆Tetris (require "tetris") ;;◆Comment(comment.lと以下のLISP使用) ;;1 行コメントをトグル ;;http://hie.s64.xrea.com/xyzzy/note/edit.html#comment-out-selection-or-one-line (defvar *one-line-comment-alist* '( (awk-mode . ("#")) (css-mode . ("/* " " */")) (html+-mode . ("")) (lisp-mode . (";")) (lisp-interaction-mode . (";")) (perl-mode . ("#")) (php-mode . ("//")) (sql-mode . ("--")) )) (defun toggle-one-line-comment () (interactive) (let ((li (cdr (assoc buffer-mode *one-line-comment-alist*))) bol eol str keyreg) (when li (save-excursion (goto-eol) (setq eol (point)) (back-to-indentation) (setq bol (point)) (setq str (buffer-substring bol eol)) (if (= (length li) 1) (let ((key (car li))) (setq keyreg (format nil "^~A+[ \t]*" (regexp-quote key))) (if (string-match keyreg str) (delete-region (+ bol (match-beginning 0)) (+ bol (match-end 0))) (progn (back-to-indentation) (insert key)))) (let ((key1 (car li)) (key2 (cadr li))) (setq keyreg (format nil "^\\(~A\\)+[ \t]*\\(.*\\)[ \t]*\\(~A\\)+$" (regexp-quote key1) (regexp-quote key2))) (if (string-match keyreg str) (progn (setq str (string-replace-match str "\\2")) (delete-region (+ bol (match-beginning 0)) (+ bol (match-end 0))) (insert str)) (progn (back-to-indentation) (insert key1) (goto-eol) (insert key2))))))))) ;;comment.l と 1 行コメントトグルを合わせて使う ;;結局これに落ち着きそう。 kia さんの comment.l と,toggle-one-line-comment を使って。 ;;セレクションがある状態で C-; すると,セレクションをコメントアウトする。 ;;セレクションがある状態で C-u C-; すると,セレクションをアンコメントする。 ;;セレクションがない状態で C-; すると,カーソル行のコメントアウトまたはアンコメントを行う。 (defun comment-out-selection-or-one-line (&optional count) (interactive "p") (if (pre-selection-p) (progn (require "comment") (let ((fn (cond ((eq *prefix-args* 'universal-argument) (setq count (list count)) 'comment-do-uncomment) ((and (numberp count) (> 0 count)) 'comment-do-uncomment) (t 'comment-do-comment))) beg end) (setq beg (selection-point) end (selection-mark)) (funcall fn beg end count))) (toggle-one-line-comment))) ;;キーバインド(C-;、アンコメントはC-u,C-;) (global-set-key #\C-\; 'comment-out-selection-or-one-line) ;;◆テキストモード時の色設定 ;;http://www.geocities.co.jp/Technopolis-Mars/8229/xyzzy/xyzzy-color.html (add-hook '*text-mode-hook* (function (lambda () (setq abbrev-mode t) (setq highlight-keyword t) (text-parenthses-colorize)))) (defvar *text-paretheses-colorize* nil) (setq *text-paretheses-colorize* (make-hash-table)) (setf (gethash #\「 *text-paretheses-colorize*) #\」) (setf (gethash #\『 *text-paretheses-colorize*) #\』) (setf (gethash #\〈 *text-paretheses-colorize*) #\〉) (setf (gethash #\【 *text-paretheses-colorize*) #\】) (setf (gethash #\≪ *text-paretheses-colorize*) #\≫) (setf (gethash #\〔 *text-paretheses-colorize*) #\〕) (setf (gethash #\[ *text-paretheses-colorize*) #\]) (setf (gethash #\{ *text-paretheses-colorize*) #\}) (setf (gethash #\《 *text-paretheses-colorize*) #\》) (setf (gethash #\< *text-paretheses-colorize*) #\>) (setf (gethash #\[ *text-paretheses-colorize*) #\]) (defun text-parenthses-colorize () (interactive) (setq parentheses-hash-table *text-paretheses-colorize*) (setq highlight-keyword t)) ;;テキストの色を変更する (defvar *text-mode-formats* (compile-regexp-keyword-list '( ;見出し ("^[□■◇◆○●\.\-].*" t (:color 1 0 :bold)) ("^[@].*" t 6) ("[★☆]" t (:color 3 8 :bold)) ("\#[0-9]*" t (:color 14 0 :bold)) ;; ("\'.+\'" t (:color 13 0 :bold)) ("[\'][^\'\n]+[\']" t (:color 13 0 :bold)) ;; ("[\"].+[\"]" t (:color 13 0 :bold)) ("[\"][^\"\n]+[\"]" t (:color 13 0 :bold)) ("※.*" t (:color 5 8 :bold)) ("^>.*" t (:color 14 0 :bold)) ;品番登録用 ("^[ \t]*J[\.].+[ \t\n]" t (:color 9 0 :bold)) ("^[ \t]*S[\.].+[ \t\n]" t (:color 14 0 :bold)) ; ("^[0-9]\{7\}[ \t]J[\.].+[ \t\n]" t (:color 9 0 :bold)) ; ("^[0-9]\{7\}[ \t]S[\.].+[ \t\n]" t (:color 14 0 :bold)) ("(?<=[0-9]\t)J[\.].+[ \t\n]" t (:color 9 0 :bold)) ; ("^[0-9]\{7\}[ \t]S[\.].+[ \t$])" t (:color 14 0 :bold)) ("\tJ\..+(\-|カ|リ| )\/.+[ \t$]" t (:color 13 0 :bold)) ("投入" t (:color 9 0 :bold)) ("出荷" t (:color 14 0 :bold)) ("派生" t (:color 11 0 :bold)) ("([0-9]|,)\{2,\}" t (:color 5 7)) ) ) ) ; ; (setq regexp-keyword-list *text-mode-formats*) (add-hook 'text-mode-hook 'my-color-text-mode) (defun my-color-text-mode () (make-local-variable 'regexp-keyword-list) (setq regexp-keyword-list *text-mode-formats*) ) ;;テキストの色を変更する (add-hook '*lisp-mode-hook* (function (lambda () (setq abbrev-mode t) (setq highlight-keyword t) ))) (defvar *lisp-mode-formats* (compile-regexp-keyword-list '( ("^;;;" t (:color 9 0 :bold)) ) ) ) ; (add-hook 'lisp-mode-hook 'my-color-lisp-mode) (defun my-color-lisp-mode () (make-local-variable 'regexp-keyword-list) (setq regexp-keyword-list *lisp-mode-formats*) ) ;;xyzzyとWindowsのやり取りをシームレスに----開始---- ;;; ------------------------------------------------------------------------ ;;; xyzzyとWindowsのやりとりを少しだけシームレスに ;;; 2005-12-14版 (provide "files+") (in-package "editor") (require "grepd") (export '(files+-grep)) ;;; ------------------------------------------------------------------------ ;;; 機能:フォルダをドラッグ&ドロップするとファイラを起動 ;;; 注意:*drag-and-drop-hook*を置き換えてるのは他の拡張Lispに影響がある ;;; 可能性有り (defun files+-open-directory (filename) (when (and (file-directory-p filename) (not *files+-grep*)) ; 経験的に待ちを入れる (sit-for 0.01) ; とりあえずプライマリだけ設定しなおしてファイラで開く。 (setq *filer-primary-directory* filename) (message "files+-open-directory: ~A" filename) (filer filename t "files+" t) (error "files+-open-directory: done"))) (add-hook '*before-find-file-hook* 'files+-open-directory) (defun files+-drag-and-drop-hook (window files) ; プライマリとセカンダリの設定だけして ; 実際のファイラのオープンはfiles+-open-directoryに任せる。 (when (and (car files) (cadr files) (file-directory-p (car files)) (file-directory-p (cadr files))) (setq *filer-primary-directory* (car files)) (setq *filer-secondary-directory* (cadr files))) (default-drag-and-drop-hook window files)) (setq *drag-and-drop-hook* #'files+-drag-and-drop-hook) ;;; ------------------------------------------------------------------------ ;;; 機能:[送る]で任意のフォルダをgrep ;;; 注意:使用する前に、SendToの中に"xyzzycli.exe -f files+-grep"という ;;; ショートカットを作っておくこと (defvar *files+-grep* nil) (defvar *files+-grep-temp-buffer-name* " *files+-grep*") (defun files+-grep () ; コマンドラインではフラグだけを立てて ; 実際のgrepはfiles+-grep-directoryに任せる。 (setq *files+-grep* t)) (defun files+-grep-directory (filename) (when (and (file-directory-p filename) *files+-grep*) (message "files+-grep-directory: ~A" filename) (setq *files+-grep* nil) (let (*grep-directory-name-hook* text) (setq *grep-directory-name-hook* #'(lambda () filename)) (if (get-selection-type) ; セレクションがあればその内容でgrepする。 (grep-dialog) (progn ; セレクションがなければクリップボードの内容でgrep ; ただし、作業用のバッファにセレクションを作ってgrep-dialogする。 (if (find-buffer *files+-grep-temp-buffer-name*) (delete-buffer *files+-grep-temp-buffer-name*)) (get-buffer-create *files+-grep-temp-buffer-name*) (with-output-to-buffer (*files+-grep-temp-buffer-name*) (setup-temp-buffer *files+-grep-temp-buffer-name*) (set-buffer *files+-grep-temp-buffer-name*) (format t "~A" (get-clipboard-data)) (selection-whole-buffer) (grep-dialog)) (delete-buffer *files+-grep-temp-buffer-name*)))) (error "files+-grep-directory: done"))) (add-hook '*before-find-file-hook* 'files+-grep-directory) ;;; ------------------------------------------------------------------------ ;;; 機能:バッファバーのコンテキストメニューからエクスプローラを表示 ;;; 注意:*buffer-bar-context-menu*を直接書き換えてるのは手抜き (setq *buffer-bar-context-menu* (define-popup-menu (:item 'close "フォルダ(&F)" #'(lambda () (interactive) (let (dir) (if (setq dir (get-short-path-name (map-slash-to-backslash (default-directory)))) (execute-shell-command (concat "start " dir)))))))) ;;xyzzyとWindowsのやり取りをシームレスに----終了---- ;;◆html-popup-menu (add-hook 'ed::*html+-mode-hook* #'(lambda () (require "html-popup-menu"))) ;;デフォルトキーマップ ;; htmlファイルの真ん中あたりで Ctrl + ] または Ctrl + Shift + ] ;;◆行セレクションを上下に移動 ;;http://blue.ribbon.to/~aotororo/prog/200310.html (defun transpose-selection-down (&optional (n 1)) "行セレクションを n 行下に移動" (interactive "*p") (let ((pre-selection-type (get-selection-type)) (column (current-column))) (unless pre-selection-type (goto-bol) (start-selection 1 t) (or (forward-line 1) (progn (goto-eol) (insert #\LFD)))) (selection-start-end (beg end) (when (and (goto-char end) (bolp) (goto-char beg) (bolp)) (insert (prog1 (buffer-substring beg end) (delete-region beg end) (forward-line n) (and (minusp (1- (get-window-line))) (recenter 1)) (when pre-selection-type (start-selection pre-selection-type t)))) (unless pre-selection-type (forward-line -1) (goto-column column)))))) (defun transpose-selection-up (&optional (n 1)) "行セレクションを n 行上に移動" (interactive "*p") (transpose-selection-down (- n))) (global-set-key #\S-M-Down 'transpose-selection-down) (global-set-key #\S-M-Up 'transpose-selection-up) ;;ESC S-Up editor::transpose-selection-up ;;ESC S-Down editor::transpose-selection-down ;;◆カーソル行を画面上の一番上に移動。とりあえず上のを参考に適当に作成。k_suzuki (defun cursor-pos-display-top() (interactive "*p") (recenter 0)) (global-set-key #\C-S-F12 'cursor-pos-display-top) (set-function-bar-label #\C-S-F12 "CursorTop") ;;◆特定のbufferを消す (defun clear-temp-buffers() "*の付いたバッファーを削除" (interactive) (let ((fn)) (dolist (bf (buffer-list)) (setq fn (buffer-name bf)) (when (and fn (equal (schar fn 0) #\*) (not (equal "*scratch*" fn))) ;(msgbox(format nil "<~A>" fn)) (delete-buffer bf);否応なしに ;(erase-buffer bf);尋ねてくる ) )) ) ;;キーバインド (global-set-key #\C-S-F4 'clear-temp-buffers) (set-function-bar-label #\C-S-F4 "*BufKill") ;;インクリメンタルサーチ ;;(require "isearch") ;; サーチ C-s,C-r ;; サーチ中のMigemoトグル C-e ;; (require "migemo") ;; (migemo-toggle t) ;C-c m t で on/off トグル デフォルトで on ;; (define-key *isearch-map* #\C-v 'isearch-paste-from-clipboard) ;isearch でもC-vでペースト (require "migemo") (migemo-toggle t) (define-key *isearch-map* #\C-e 'migemo-toggle)