LoginSignup
5
1

More than 3 years have passed since last update.

[個人メモ] emacsのinit.el

Last updated at Posted at 2019-10-19
  • 自分向けのMac&Emacsでの設定メモ
  • プライベートと仕事のいろんな環境で設定ファイルがずれてきたのでQiitaにUPします。
  • emacs初心者による、先人の方の寄せ集めです。
init.el

;; package管理
(package-initialize)
(setq package-archives
      '(("gnu" . "http://elpa.gnu.org/packages/")
        ("melpa" . "http://melpa.org/packages/")
        ("org" . "http://orgmode.org/elpa/")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; https://dev.classmethod.jp/etc/emacs-setup-and-org-mode/
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(create-fontset-from-ascii-font
 "Menlo-14:weight=normal:slant=normal"
 nil
 "menlokakugo")

(set-fontset-font
 "fontset-menlokakugo"
 'unicode
 (font-spec :family "Hiragino Kaku Gothic ProN")
 nil
 'append)

(add-to-list 'default-frame-alist '(font . "fontset-menlokakugo"))


;; CUAモード(C-RET) 有効
(cua-mode t) 
(setq cua-enable-cua-keys nil) 

;; C-h > バックスペース★バック
(global-set-key (kbd "C-h") 'delete-backward-char) 

;; デフォルトエンコーディングをUTF-8 に
(prefer-coding-system 'utf-8)

;; 自動保存されるバックアップファイルの置き場所を ~/.emacs.d/backup に変更する
(setq backup-directory-alist 
  (cons (cons ".*" (expand-file-name "~/.emacs.d/backup")) 
        backup-directory-alist)) 
(setq auto-save-file-name-transforms 
      `((".*", (expand-file-name "~/.emacs.d/backup/") t))) 

;; ツールバー非表示
(tool-bar-mode -1)

;; 時刻をモードラインに表示
(display-time-mode t)

;; 行番号をモードラインに表示
(column-number-mode t)

;; 左端に行数を表示させる
(global-linum-mode t) 

;; 対応する括弧をハイライト
;(show-paren-mode 1)

;; 起動時の Emacsロゴなどのメッセージを出さない
(setq inhibit-startup-message t) 

;; *scratch* バッファの初期メッセージを消す
(setq initial-scratch-message "")

;;;;;;;;;;;;;;;;;;;;;;;;
;; https://qiita.com/blue0513/items/ff8b5822701aeb2e9aae
;;;;;;;;;;;;;;;;;;;;;;;;

;; 直前のバッファに戻る
(global-set-key (kbd "s-[") 'switch-to-prev-buffer)

;; 次のバッファに進む
(global-set-key (kbd "s-]") 'switch-to-next-buffer)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; https://qiita.com/yn01/items/b8d3dcb5be9078a6e27f
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; 環境を日本語、UTF-8にする
(set-locale-environment nil)
(set-language-environment "Japanese")
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(prefer-coding-system 'utf-8)

;; スタートアップメッセージを表示させない
;(setq inhibit-startup-message t)

;; バックアップファイルを作成させない
; (setq make-backup-files nil)

;; 終了時にオートセーブファイルを削除する
; (setq delete-auto-save-files t)

;; タブにスペースを使用する
(setq-default tab-width 4 indent-tabs-mode nil)

;; 改行コードを表示する
(setq eol-mnemonic-dos "(CRLF)")
(setq eol-mnemonic-mac "(CR)")
(setq eol-mnemonic-unix "(LF)")

;; 複数ウィンドウを禁止する
(setq ns-pop-up-frames nil)

;; ウィンドウを透明にする
;; アクティブウィンドウ/非アクティブウィンドウ(alphaの値で透明度を指定)
(add-to-list 'default-frame-alist '(alpha . (0.85 0.85)))

;; メニューバーを消す
;(menu-bar-mode -1)

;; ツールバーを消す
(tool-bar-mode -1)

;; 列数を表示する
(column-number-mode t)

;; 行数を表示する
(global-linum-mode t)

;; カーソルの点滅をやめる
(blink-cursor-mode 0)

;; カーソル行をハイライトする
(global-hl-line-mode t)

;; 対応する括弧を光らせる
(show-paren-mode 1)

;; ウィンドウ内に収まらないときだけ、カッコ内も光らせる
;(setq show-paren-style 'mixed)
;(set-face-background 'show-paren-match-face "grey")
;(set-face-foreground 'show-paren-match-face "black")

;; スペース、タブなどを可視化する
;(global-whitespace-mode 1)

;; スクロールは1行ごとに
(setq scroll-conservatively 1)

;; シフト+矢印で範囲選択
(setq pc-select-selection-keys-only t)
;(pc-selection-mode 1)

;; C-kで行全体を削除する
;(setq kill-whole-line t)

;;; dired設定
(require 'dired-x)

;; "yes or no" の選択を "y or n" にする
(fset 'yes-or-no-p 'y-or-n-p)

;; beep音を消す
(defun my-bell-function ()
  (unless (memq this-command
        '(isearch-abort abort-recursive-edit exit-minibuffer
              keyboard-quit mwheel-scroll down up next-line previous-line
              backward-char forward-char))
    (ding)))
(setq ring-bell-function 'my-bell-function)

;; Macのキーバインドを使う
;(mac-key-mode 1)

;; Macのoptionをメタキーにする
;(setq mac-option-modifier 'meta)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;https://qiita.com/melito/items/34fa31d2c96d187980e7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; フレームサイズの指定
(set-frame-size (selected-frame) 86 60)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Org mode
;; http://www.mhatta.org/wp/2018/08/16/org-mode-101-1/
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; ファイルの場所
(setq org-directory "~/ownCloud/Org")
;(setq org-directory "~/Dropbox/Org")
(setq org-default-notes-file "notes.org")

; Org-captureの設定

; Org-captureを呼び出すキーシーケンス
(define-key global-map "\C-cc" 'org-capture)
; Org-captureのテンプレート(メニュー)の設定
(setq org-capture-templates
      '(("n" "Note" entry (file+headline "~/ownCloud/Org/notes.org" "Notes")
         "* %?\nEntered on %U\n %i\n %a")
        ))

; メモをC-M-^一発で見るための設定
; https://qiita.com/takaxp/items/0b717ad1d0488b74429d から拝借
(defun show-org-buffer (file)
  "Show an org-file FILE on the current buffer."
  (interactive)
  (if (get-buffer file)
      (let ((buffer (get-buffer file)))
        (switch-to-buffer buffer)
        (message "%s" file))
    (find-file (concat "~/ownCloud/Org/" file))))
(global-set-key (kbd "C-M-^") '(lambda () (interactive)
                                 (show-org-buffer "notes.org")))



(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.
 '(package-selected-packages (quote (org))))
(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.
 )
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1