落書きノート

ふと自分が気になった事を書いてます

現在のEmacsの設定

Linux,macOS,Windowsのこの3つのOSなら全部これ一つで動かせるようにしました。フォントもmacOSのフォントに統一しようかと。GentooではNoto Sansをよく使っているのですが、やっぱりmacOSのフォントの方がいいですよね。Linux,WindowsEmacsでは今のところInconsolataを使っている状態ですが、また追々変えて試してみます。Sierraに同梱されているSF Mono Regularも気に入りました。フルネームはSan Francisco Monoという名前らしいです。Menloと同じように使えます。SF MonoかMenloどちらに統一しよう…。

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.

(when (equal system-type 'darwin)
  
  ;; CUI settings

  (if (not window-system) (progn
                            (global-linum-mode t)
                            ))

  ;; GUI settings

  (if window-system (progn
                      
                      (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))))))

                      (add-to-load-path "original")

                      (require 'package)
                      (add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/"))
                      (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
                      (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
                      (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
                      (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
                      (package-initialize)

                      (require 'color-theme)
                      (color-theme-initialize)
                      (color-theme-midnight)

                      (progn
                        (set-face-foreground 'mode-line "white")
                        (set-face-background 'mode-line "#0000cd")
                        (set-face-background 'region "white")
                        )

                      (require 'tabbar)
                      (tabbar-mode)
                      (setq tabbar-mwheel-mode nil)
                      (setq tabbar-buffer-groups-function nil)
                      (set-face-attribute 'tabbar-default nil :background "#a3ffa3" :foreground "#696969" :family "Menlo")
                      (set-face-attribute 'tabbar-selected nil :background "#00ff00" :foreground "black" :box nil)
                      (set-face-attribute 'tabbar-modified nil :background "#a3ffa3" :foreground "#696969" :box nil)
                      
                      ;; (set-face-attribute 'default nil :family "Menlo" :height 120)

                      ;; (custom-set-faces
                      ;;  '(default ((t (:inherit autoface-default :height 120 :family "Menlo"))) t))

                      (setq x-select-enable-clipboard nil)
                      (setq save-interprogram-paste-before-kill nil)
                      (setq yank-pop-change-selection nil)
                      (setq x-select-enable-clipboard-manager nil)
                      (setq x-select-enable-primary t)
                      (setq mouse-drag-copy-region t)

                      (defun copy-from-osx ()
                        (shell-command-to-string "pbpaste"))

                      (defun paste-to-osx (text &optional push)
                        (let ((process-connection-type nil))
                          (let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
                            (process-send-string proc text)
                            (process-send-eof proc))))

                      (setq interprogram-cut-function 'paste-to-osx)
                      (setq interprogram-paste-function 'copy-from-osx)

                      (define-key global-map (kbd "C-x C-c") 'clipboard-kill-ring-save)
                      (define-key global-map (kbd "C-x C-x") 'clipboard-kill-region)
                      (define-key global-map (kbd "C-x C-k") 'kill-line)
                      (define-key global-map (kbd "C-x C-s") 'save-buffer)
                      (define-key global-map (kbd "C-x C-a") 'mark-whole-buffer)
                      (define-key global-map (kbd "C-x C-v") 'clipboard-yank)
                      (define-key global-map (kbd "C-x C-z") 'undo)
                      (define-key global-map (kbd "C-s") 'isearch-forward)

                      (tool-bar-mode 0)

                      (global-set-key [f1] 'neotree-toggle)
                      (setq neo-show-hidden-files t)
                      (setq neo-create-file-auto-open t)
                      (setq neo-persist-show t)
                      (setq neo-keymap-style 'concise)
                      (setq neo-smart-open t)
                      (setq neo-vc-integration '(face char))
                      (when neo-persist-show
                        (add-hook 'popwin:before-popup-hook
                                  (lambda () (setq neo-persist-show nil)))
                        (add-hook 'popwin:after-popup-hook
                                  (lambda () (setq neo-persist-show t))))

                      (prefer-coding-system 'utf-8)

                      (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)")

                      (add-to-list 'default-frame-alist '(alpha . (0.85 0.85)))

                      (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 'expression)

                      (global-whitespace-mode 1)
                      (setq whitespace-space-regexp "\x3000+")
                      (set-face-foreground 'whitespace-newline "gray40")

                      (require 'cl)
                      (dolist (d '((space-mark ?\ ) (newline-mark ?\n)))
                        (setq whitespace-display-mappings
                              (delete-if
                               '(lambda (e) (and (eq (car d) (car e))
                                                 (eq (cadr d) (cadr e))))
                               whitespace-display-mappings)))

                      (dolist (e '((space-mark   ?\x3000 [?\□])
                                   (newline-mark ?\n     [?\u21B5 ?\n] [?$ ?\n])))
                        (add-to-list 'whitespace-display-mappings e))

                      (dolist (d '(face lines space-before-tab
                                        indentation empty space-after-tab tab-mark))
                        (setq whitespace-style (delq d whitespace-style)))

                      (setq scroll-conservatively 1)

                      (setq kill-whole-line t)

                      (require 'dired-x)

                      (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)

                      (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
                          (go-mode haskell-mode tabbar-ruler tabbar tuareg neotree color-theme))))
                      (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.
                       )

                      (add-to-list 'auto-mode-alist '("\\.ml[iylp]?" . tuareg-mode))
                      (autoload 'tuareg-mode "tuareg" "Major mode for editing OCaml code" t)
                      (autoload 'tuareg-run-ocaml "tuareg" "Run an inferior OCaml process." t)
                      (autoload 'ocamldebug "ocamldebug" "Run the OCaml debugger" t)

                      ;; crystal-mode
                      (autoload 'crystal-mode "crystal-mode" "Major mode for crystal files" t)
                      (add-to-list 'auto-mode-alist '("\\.cr$" . crystal-mode))
                      (add-to-list 'interpreter-mode-alist '("crystal" . crystal-mode))

                      ))
  )

(when (equal system-type 'gnu/linux)
  (package-initialize)
  (setq package-archives
        '(("gnu" . "http://elpa.gnu.org/packages/")
          ("melpa" . "http://melpa.org/packages/")
          ("org" . "http://orgmode.org/elpa/")))

  (add-to-list 'auto-mode-alist '("\\.ml[iylp]?" . tuareg-mode))
  (autoload 'tuareg-mode "tuareg" "Major mode for editing OCaml code" t)
  (autoload 'tuareg-run-ocaml "tuareg" "Run an inferior OCaml process." t)
  (autoload 'ocamldebug "ocamldebug" "Run the OCaml debugger" t)

  (require 'color-theme)
  (color-theme-initialize)
  (color-theme-midnight)

  (setq x-select-enable-clipboard nil)
  (setq save-interprogram-paste-before-kill nil)
  (setq yank-pop-change-selection nil)
  (setq x-select-enable-clipboard-manager nil)
  (setq x-select-enable-clipboard t)
  (setq x-select-enable-primary t)
  (setq mouse-drag-copy-region t)

  (tool-bar-mode 0)

  (global-set-key [f1] 'neotree-toggle)
  (setq neo-show-hidden-files t)
  (setq neo-create-file-auto-open t)
  (setq neo-persist-show t)
  (setq neo-keymap-style 'concise)
  (setq neo-smart-open t)
  (setq neo-vc-integration '(face char))
  (when neo-persist-show
    (add-hook 'popwin:before-popup-hook
              (lambda () (setq neo-persist-show nil)))
    (add-hook 'popwin:after-popup-hook
              (lambda () (setq neo-persist-show t))))

  (progn
    (set-face-foreground 'mode-line "white")
    (set-face-background 'mode-line "blue")
    (set-face-background 'region "white")
    )

  (prefer-coding-system 'utf-8)
  (global-set-key (kbd "C-j") 'toggle-input-method)

  (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)")

  (add-to-list 'default-frame-alist '(alpha . (0.85 0.85)))

  (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 'expression)

  (global-whitespace-mode 1)
  (setq whitespace-space-regexp "\x3000+")
  (set-face-foreground 'whitespace-newline "gray40")

  (dolist (d '((space-mark ?\ ) (newline-mark ?\n)))
    (setq whitespace-display-mappings
          (delete-if
           '(lambda (e) (and (eq (car d) (car e))
                             (eq (cadr d) (cadr e))))
           whitespace-display-mappings)))

  (dolist (e '((space-mark   ?\x3000 [?\□])
               (newline-mark ?\n     [?\u21B5 ?\n] [?$ ?\n])))
    (add-to-list 'whitespace-display-mappings e))

  (dolist (d '(face lines space-before-tab
                    indentation empty space-after-tab tab-mark))
    (setq whitespace-style (delq d whitespace-style)))

  (setq scroll-conservatively 1)

  (setq kill-whole-line t)

  (require 'dired-x)

  (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)

  (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 (:foundry "Inconsolata" :family "Inconsolata" :height 120)))))

  (set-fontset-font t 'japanese-jisx0208 (font-spec :family "Noto Sans Mono CJK JP" :size 14))

  (define-key global-map (kbd "C-x C-c") 'clipboard-kill-ring-save)
  (define-key global-map (kbd "C-x C-x") 'clipboard-kill-region)
  (define-key global-map (kbd "C-x C-k") 'kill-line)
  (define-key global-map (kbd "C-x C-s") 'save-buffer)
  (define-key global-map (kbd "C-x C-a") 'mark-whole-buffer)
  (define-key global-map (kbd "C-x C-v") 'clipboard-yank)
  (define-key global-map (kbd "C-x C-z") 'undo)
  (define-key global-map (kbd "C-s") 'isearch-forward)

  (require 'tabbar)
  (tabbar-mode)
  (setq tabbar-mwheel-mode nil)
  (setq tabbar-buffer-groups-function nil)
  (set-face-attribute 'tabbar-default nil :background "#a3ffa3" :foreground "#696969" :family "Inconsolata")
  (set-face-attribute 'tabbar-selected nil :background "#00ff00" :foreground "black" :box nil)
  (set-face-attribute 'tabbar-modified nil :background "#a3ffa3" :foreground "#696969" :box 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.
   '(package-selected-packages (quote (haskell-mode tuareg tabbar color-theme))))

  )

(when (equal system-type 'windows-nt)
  (require 'package)
  (setq package-archives
        '(("gnu" . "http://elpa.gnu.org/packages/")
          ("melpa" . "http://melpa.org/packages/")
          ("org" . "http://orgmode.org/elpa/")))
  (package-initialize)
  (add-to-list 'auto-mode-alist '("\\.ml[iylp]?" . tuareg-mode))
  (autoload 'tuareg-mode "tuareg" "Major mode for editing OCaml code" t)
  (autoload 'tuareg-run-ocaml "tuareg" "Run an inferior OCaml process." t)
  (autoload 'ocamldebug "ocamldebug" "Run the OCaml debugger" t)

  (require 'color-theme)
  (color-theme-initialize)
  (color-theme-midnight)

  (set-default-coding-systems 'utf-8-dos)

  (global-set-key (kbd "C-j") 'toggle-input-method)

  (setq x-select-enable-clipboard nil)
  (setq save-interprogram-paste-before-kill nil)
  (setq yank-pop-change-selection nil)
  (setq x-select-enable-clipboard-manager nil)
  (setq x-select-enable-primary t)
  (setq mouse-drag-copy-region t)

  (tool-bar-mode 0)

  (global-set-key [f1] 'neotree-toggle)
  (setq neo-show-hidden-files t)
  (setq neo-create-file-auto-open t)
  (setq neo-persist-show t)
  (setq neo-keymap-style 'concise)
  (setq neo-smart-open t)
  (setq neo-vc-integration '(face char))
  (when neo-persist-show
    (add-hook 'popwin:before-popup-hook
              (lambda () (setq neo-persist-show nil)))
    (add-hook 'popwin:after-popup-hook
              (lambda () (setq neo-persist-show t))))

  (progn
    (set-face-foreground 'mode-line "white")
    (set-face-background 'mode-line "blue")
    (set-face-background 'region "white")
    )

  (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)")

  (add-to-list 'default-frame-alist '(alpha . (0.85 0.85)))

  (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 'expression)

  (global-whitespace-mode 1)
  (setq whitespace-space-regexp "\x3000+")
  (set-face-foreground 'whitespace-newline "gray40")

  (dolist (d '((space-mark ?\ ) (newline-mark ?\n)))
    (setq whitespace-display-mappings
          (delete-if
           '(lambda (e) (and (eq (car d) (car e))
                             (eq (cadr d) (cadr e))))
           whitespace-display-mappings)))

  (dolist (e '((space-mark   ?\x3000 [?\□])
               (newline-mark ?\n     [?\u21B5 ?\n] [?$ ?\n])))
    (add-to-list 'whitespace-display-mappings e))

  (dolist (d '(face lines space-before-tab
                    indentation empty space-after-tab tab-mark))
    (setq whitespace-style (delq d whitespace-style)))

  (setq scroll-conservatively 1)

  (setq kill-whole-line t)

  (require 'dired-x)

  (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)

  (set-face-attribute 'default nil :family "inconsolata" :height 120)
  (set-fontset-font nil 'japanese-jisx0208 (font-spec :family "メイリオ"))
  (setq face-font-rescale-alist '(("メイリオ" . 0.9)))

  (define-key global-map (kbd "C-x C-c") 'clipboard-kill-ring-save)
  (define-key global-map (kbd "C-x C-x") 'clipboard-kill-region)
  (define-key global-map (kbd "C-x C-k") 'kill-line)
  (define-key global-map (kbd "C-x C-s") 'save-buffer)
  (define-key global-map (kbd "C-x C-a") 'mark-whole-buffer)
  (define-key global-map (kbd "C-x C-v") 'clipboard-yank)
  (define-key global-map (kbd "C-x C-z") 'undo)
  (define-key global-map (kbd "C-s") 'isearch-forward)

  (require 'tabbar)
  (tabbar-mode)
  (setq tabbar-mwheel-mode nil)
  (setq tabbar-buffer-groups-function nil)
  (set-face-attribute 'tabbar-default nil :background "#a3ffa3" :foreground "#696969" :family "inconsolata")
  (set-face-attribute 'tabbar-selected nil :background "#00ff00" :foreground "black" :box nil)
  (set-face-attribute 'tabbar-modified nil :background "#a3ffa3" :foreground "#696969" :box 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.
   '(package-selected-packages (quote (haskell-mode neotree tuareg tabbar color-theme))))
  (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.
   )
  )