28. 情報共有 Emacsをサクラエディタ代わりに
━━━━━━━━━━━━━━
/home/user/.emacs.d/init.el
━━━━━━━━━━━━━━
(set-fontset-font "fontset-standard"
'ascii
(font-spec :family "VL Gothic" :size 20) nil 'prepend) ;; ここでサイズを指定
(set-fontset-font "fontset-standard"
'japanese-jisx0213.2004-1
(font-spec :family "VL Gothic") nil 'prepend)
(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.
'(global-display-line-numbers-mode t)
'(inhibit-startup-screen t)
'(tool-bar-mode nil))
(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.
'(default ((t (:family "VL ゴシック" :foundry "VL " :slant normal :weight regular :height 181 :width normal)))))
;====================================
; Initial フレームサイズ,位置,色,フォントなど
;====================================
(setq initial-frame-alist
(append (list
'(width . 155) ;; ウィンドウ幅
'(height . 40) ;; ウィンドウ高さ
'(top . 0) ;; 表示位置
'(left . 1100) ;; 表示位置
)
initial-frame-alist))
(setq default-frame-alist initial-frame-alist)
;EmacsのキーバインドをWindows風にしてみる
;設定 変更不可能なものはコメントアウト
;キーバインド一覧を表示するには、
;M-x describe-bindings
(global-unset-key "\E")
(global-unset-key "\C-a")
(global-unset-key "\C-b")
(global-unset-key "\C-c")
(global-unset-key "\C-d")
(global-unset-key "\C-e")
(global-unset-key "\C-f")
;(global-unset-key "\C-g")
(global-unset-key "\C-h")
;(global-unset-key "\C-i")
;(global-unset-key "\C-j")
(global-unset-key "\C-k")
(global-unset-key "\C-l")
;(global-unset-key "\C-m")
(global-unset-key "\C-n")
(global-unset-key "\C-o")
(global-unset-key "\C-p")
(global-unset-key "\C-q")
(global-unset-key "\C-r")
(global-unset-key "\C-s")
(global-unset-key "\C-t")
(global-unset-key "\C-u")
(global-unset-key "\C-v")
(global-unset-key "\C-w")
(global-unset-key "\C-x")
(global-unset-key "\C-y")
(global-unset-key "\C-z")
;設定
(global-unset-key [(escape)])
;redo は無いが、Undoの直後にカーソル入力すると、Undoの方向が変わる(Redoが可能)
(defun date (arg)
(interactive "P")
(insert (if arg
(format-time-string "%d.%m.%Y")
(format-time-string "%Y年%m月%d日"))))
(defun timestamp ()
(interactive)
(insert (format-time-string "%H:%M:%S")))
(defun do-lines (&optional start end)
(interactive)
(setq start (region-beginning)
end (region-end)
)
;;(message "%s" start)
;;(message "%s" end)
(save-excursion
(goto-char start)
(beginning-of-line)
(while (<= (point) end)
(setq end (+ end 4))
(tab-to-tab-stop)
(forward-line 1)))
)
(defun tab-tcs ()
(interactive)
(if (use-region-p)
(progn
;; (message "Test000")
(do-lines)
;; (message "Test001")
;; ;;(indent-for-tab-command)
;; ;;(indent-relative)
;; ;;(indent-rigidly)
)
(tab-to-tab-stop)
)
)
(defun backtab-tcs ()
(interactive)
;; (if (use-region-p)
(progn
;; (message "Test000")
;; (do-lines)
;; (message "Test001")
(indent-for-tab-command)
;; (indent-relative)
;; (indent-rigidly -4)
)
;; (tab-to-tab-stop)
)
(defun ctrlk-tcs ()
(interactive)
(beginning-of-line)
(kill-line)
)
(setq window_tcs t)
(defun split-tcs ()
(interactive)
(if window_tcs
(progn
(split-window-below)
(setq window_tcs nil)
)
(progn
(delete-other-windows)
(setq window_tcs t)
)
)
)
;Shell Script modeで、横取りされないように
(define-minor-mode overriding-minor-mode
"強制的にキーバインドを割り当てる" ;説明文字列
t ;デフォルトで有効にする
"" ;モードラインに表示しない
`(
(,(kbd "C-a") . mark-whole-buffer)
(,(kbd "C-c") . copy-region-as-kill)
(,(kbd "C-z") . undo)
(,(kbd "C-x") . kill-region)
(,(kbd "C-v") . yank)
;(,(kbd "C-b") . bookmark-set)
;(,(kbd "C-j") . bookmark-jump)
(,(kbd "C-r") . query-replace-regexp)
(,(kbd "C-s") . save-buffer)
(,(kbd "C-f") . isearch-forward)
(,(kbd "<f3>") . isearch-repeat-forward)
(,(kbd "<f2>") . isearch-repeat-backward)
(,(kbd "C-S-f") . isearch-backward)
(,(kbd "<ESC>") . keyboard-quit)
(,(kbd "C-d") . date)
(,(kbd "C-t") . timestamp)
(,(kbd "<tab>") . tab-tcs)
(,(kbd "<backtab>") . backtab-tcs)
(,(kbd "C-k") . ctrlk-tcs)
(,(kbd "<f4>") . split-tcs)
(,(kbd "C-l") . whitespace-cleanup)
)
)
;謎のバグ対応(Shift-Eが小文字になる)
(global-set-key "\S-e" 'self-insert-command)
;; goto-addr
(progn
(add-hook 'prog-mode-hook 'goto-address-prog-mode)
(add-hook 'text-mode-hook 'goto-address-mode))
(setq-default tab-width 4)
(setq default-tab-width 4)
(setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60
64 68 72 76 80 84 88 92 96 100 104 108 112 116 120))
(setq-default indent-tabs-mode nil)
(defun search-selection (start end)
"search for selected text"
(interactive "r")
(setq regionp (buffer-substring start end))
(if (use-region-p)
(progn
(deactivate-mark)
(backward-word 1)
(isearch-mode t nil nil nil)
(isearch-yank-string regionp)
)
)
)
(global-set-key [mouse-3] 'search-selection)
(tool-bar-mode 0)
;;(require 'keisen nil t)
(load "/home/user/.emacs.d/lisp/keisen.el")
;; Control+矢印キーで罫線を引く場合
(global-set-key [C-right] 'keisen-right-move)
(global-set-key [C-left] 'keisen-left-move)
(global-set-key [C-up] 'keisen-up-move)
(global-set-key [C-down] 'keisen-down-move)
(global-whitespace-mode 1)
(setq load-path (cons
"~/.emacs.d/lisp" ; elファイルのパス
load-path))
;日本語印刷
;(setq ps-multibyte-buffer 'non-latin-printer)
;(require 'ps-mule)
;(defalias 'ps-mule-header-string-charsets 'ignore)
;;;印刷設定(postscript用)
;(setq ps-multibyte-buffer 'non-latin-printer)
;(setq ps-lpr-command "/usr/bin/lpr")
;(setq ps-printer-name "ps")
;(setq ps-paper-type 'a4)
;印刷時文字化け対策
;http://tanaka-cs.co.jp/download/mojibake.el
(require 'mojibake)
;pdfプレビュー
(defun print-tcs (start end)
(interactive "r")
(mojibake-replace)
(setq regionp (buffer-substring start end))
(if (use-region-p)
(pdf-preview-region start end)
(pdf-preview-buffer)
)
)
;http://en.sourceforge.jp/projects/macemacsjp/scm/svn/blobs/head/pdf-preview/trunk/pdf-preview.el
(require 'pdf-preview)
;(setq pdf-preview-ps2pdf-command "perl ~/bin/cjkps2pdf.pl --keepmetrics")
;(setq pdf-preview-ps2pdf-paper-size-option "--papersize ")
(setq pdf-preview-preview-command
"atril") ;ここに、PDFファイルを開くコマンドを記述
;ショートカット
(global-set-key "\C-p" 'print-tcs)
;;; *.~ とかのバックアップファイルを作らない
(setq make-backup-files nil)
;;; .#* とかのバックアップファイルを作らない
(setq auto-save-default nil)
(defun jump-to-matching-paren ()
"カーソルの位置の対応する括弧にジャンプします。"
(interactive)
(let ((forward-point (save-excursion (forward-sexp) (point)))
(backward-point (save-excursion (backward-sexp) (point))))
(cond ((and (looking-at "[{([(【「[]") forward-point)
(goto-char forward-point))
((and (looking-back "[]}))】」]]") (goto-char backward-point)))
(t (message "対応する括弧が見つかりません"))
)
)
)
(global-set-key (kbd "C-]") 'jump-to-matching-paren)
(global-set-key (kbd "C-=") 'jump-to-matching-paren)
(global-set-key (kbd "C-[") 'jump-to-matching-paren)
━━━━━━━━━━━━━━━
/home/user/.emacs.d/keisen.el
━━━━━━━━━━━━━━━
;; keisen.el -- provide facility for drawing ruled-line
;;
;; Copyright (C) 1990-2004 増井俊之 masui@pitecan.com
;;
;; This is a Public Domain Software.
;; Everyone is granted permission to copy, modify and redistribute
;; this program freely.
;; .emacsに以下のような記述を入れると矢印キーで罫線が引ける
;;
;; 文字端末の矢印キーで罫線を引く場合
;; (global-set-key "\eOA" 'keisen-up-move)
;; (global-set-key "\eOB" 'keisen-down-move)
;; (global-set-key "\eOD" 'keisen-left-move)
;; (global-set-key "\eOC" 'keisen-right-move)
;;
;; 文字端末のMeta-Pなどで罫線を引く場合
;; (global-set-key "\M-p" 'keisen-up-move)
;; (global-set-key "\M-n" 'keisen-down-move)
;; (global-set-key "\M-b" 'keisen-left-move)
;; (global-set-key "\M-f" 'keisen-right-move)
;;
;; Control+矢印キーで罫線を引く場合
;; (global-set-key [C-right] 'keisen-right-move)
;; (global-set-key [C-left] 'keisen-left-move)
;; (global-set-key [C-up] 'keisen-up-move)
;; (global-set-key [C-down] 'keisen-down-move)
;;
;; (autoload 'keisen-up-move "keisen" nil t)
;; (autoload 'keisen-down-move "keisen" nil t)
;; (autoload 'keisen-left-move "keisen" nil t)
;; (autoload 'keisen-right-move "keisen" nil t)
;;; 92.7.6 modified for Mule Ver.0.9.5 by T.Shingu <shingu@cpr.canon.co.jp>
;;; 92.7.13 modified for Mule Ver.0.9.5 by K.Handa <handa@etl.go.jp>
;;; 93.8.5 modified for dmacro.el by T.Masui <masui@shpcsl.sharp.co.jp>
;;; 93.8.5 modified for Mule Ver.1.1 by K.Handa <handa@etl.go.jp>
;;; To be used also with Nemacs.
;;; 2004.5.6 modified for Emacs21 by T.Masui <masui@pitecan.com>
(provide 'keisen)
(require 'picture)
(defconst keisen-right 1)
(defconst keisen-up 2)
(defconst keisen-left 4)
(defconst keisen-down 8)
(defconst keisen-table "\
***└*─┘┴*┌│├┐┬┤┼\
**********┝*****\
*****┸**********\
┗***************\
**********┥*****\
━*┷*****┯*┿*****\
┛***************\
┻***************\
*****┰**********\
┏***************\
┃┠**┨╂**********\
┣***************\
┓***************\
┳***************\
┫***************\
╋***************"
"罫線キャラクタの各方向の枝の有無を8ビットで表現する。
インデックスの上位4ビットは太い線の有無を示し、下位4ビットが
細い線の有無を示す。")
(defvar keisen-width 2
"罫線の太さ。1のとき細く、2以上のとき太い。")
(defun keisen-toggle-width ()
"罫線の太さを切り換える"
(interactive)
(cond
((> keisen-width 1) (message "細い罫線を使用します") (setq keisen-width 1))
(t (message "太い罫線を使用します") (setq keisen-width 2))
))
(defun keisen-opposite-direction (dir)
(cond
((= dir keisen-right) keisen-left)
((= dir keisen-left) keisen-right)
((= dir keisen-up) keisen-down)
((= dir keisen-down) keisen-up)
(t 0)
))
(defun keisen-direction (command)
(cond
((eq command 'keisen-right-move) keisen-right)
((eq command 'keisen-left-move) keisen-left)
((eq command 'keisen-up-move) keisen-up)
((eq command 'keisen-down-move) keisen-down)
((eq command t) keisen-last-direction) ; 93.8.5 by T.Masui
(t 0)))
(defun keisen-new-string () ; 92.7.13 by K.Handa -- Big change
(let (pos factor str old-direction new-direction)
(setq old-direction (keisen-direction last-command))
(setq new-direction (keisen-direction this-command))
(setq keisen-last-direction new-direction) ; 93.8.5 by T.Masui
(setq factor (if (> keisen-width 1) 16 1))
(setq str (if (eobp) " "
(buffer-substring (point) (+ (point) 1))))
(setq pos (string-match str keisen-table))
(if (null pos)
(progn
(setq pos 0)
(if (= old-direction (keisen-opposite-direction new-direction))
(setq old-direction new-direction))
(if (= old-direction 0) (setq old-direction new-direction))
))
(setq pos (logior pos
(* (keisen-opposite-direction old-direction) factor)
(* new-direction factor)))
(substring keisen-table pos (+ pos 1))
))
(defun keisen-move (v h)
(setq picture-vertical-step v)
(setq picture-horizontal-step h)
(setq picture-desired-column (current-column))
(picture-insert (string-to-char (keisen-new-string)) 1)
)
(defun keisen-right-move ()
"罫線を引きながら右方向に移動する"
(interactive)
(keisen-move 0 1))
(defun keisen-left-move ()
"罫線を引きながら左方向に移動する"
(interactive)
(keisen-move 0 -1))
(defun keisen-up-move ()
"罫線を引きながら上方向に移動する"
(interactive)
(keisen-move -1 0))
(defun keisen-down-move ()
"罫線を引きながら下方向に移動する"
(interactive)
(keisen-move 1 0))
前へ / 次へ