私のinit.el
連休中、仕事の都合もあって遠出できないので、久しぶりにEmacsまわりをいじりました。
Helmの開発が終わるような話が流れていたのでivyに乗り換えたり、今までリガチャを使いたいがために、仕方なくコンソール上でEmacsを使ってきたのだがJetbrains Monoというフォントを使用するようにしたところ、この問題が解決したのでbrew caskからGUI版のEmacsを入れて(VSCodeから)それに乗り換えたりだとか、そんな事をやっていました。
(加えて、現代的なEmacsの設定を目指してleafを使って環境を整え直しました。)
そんなわけで大体init.el
が固まったので、備忘も兼ねてここに残します。
init.el
を更新した際には、~/.emacs.d
ディレクトリでemacs --batch -f batch-byte-compile init.el
コマンドで設定ファイルをバイトコンパイルして使うようにしています。
;; -*- lexical-binding: t; -*-
;; this enables this running method
;; emacs -q -l ~/.debug.emacs.d/init.el
(eval-and-compile
(when (or load-file-name byte-compile-current-file)
(setq user-emacs-directory
(expand-file-name
(file-name-directory (or load-file-name byte-compile-current-file))))))
(eval-and-compile
(customize-set-variable
'package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
(package-initialize)
(unless (package-installed-p 'leaf)
(package-refresh-contents)
(package-install 'leaf))
(leaf leaf-keywords
:ensure t
:init
;; optional packages if you want to use :hydra, :el-get, :blackout,,,
(leaf hydra :ensure t)
(leaf el-get :ensure t)
(leaf blackout :ensure t)
:config
;; initialize leaf-keywords.el
(leaf-keywords-init)))
(leaf cus-edit
:doc "tools for customizing Emacs and Lisp packages"
:tag "builtin" "faces" "help"
:custom `((custom-file . ,(locate-user-emacs-file "custom.el"))))
(leaf cus-start
:doc "define customization properties of builtins"
:tag "builtin" "internal"
:custom '((user-full-name . "Akira OTA")
(user-mail-address . "dev@10nin.com")
(user-login-name . "10nin")
(create-lockfiles . nil)
(debug-on-error . t)
(init-file-debug . t)
(frame-resize-pixelwise . t)
(enable-recursive-minibuffers . t)
(history-length . 10000)
(history-delete-duplicates . t)
(scroll-preserve-screen-position . t)
(scroll-conservatively . 100)
(mouse-wheel-scroll-amount . '(1 ((control) . 5)))
(ring-bell-function . 'ignore)
(text-quoting-style . 'straight)
(truncate-lines . t)
(use-dialog-box . nil)
(use-file-dialog . nil)
(menu-bar-mode . t)
(tool-bar-mode . nil)
(scroll-bar-mode . nil)
(indent-tabs-mode . nil)
(display-time-mode . t)
(column-number-mode . t)
(global-linum-mode . t)
(inhibit-startup-message . t)
(initial-scratch-message . ""))
:config
(defalias 'yes-or-no-p 'y-or-n-p)
(keyboard-translate ?\C-h ?\C-?))
(eval-and-compile
(leaf bytecomp
:doc "compilation of Lisp code into byte code"
:tag "builtin" "lisp"
:custom (byte-compile-warnings . '(cl-functions))))
(leaf exec-path-from-shell
:ensure t
:defun (exec-path-from-shell-initialize)
:custom
((exec-path-from-shell-check-startup-files . nil)
(exec-path-from-shell-variables . '("SHELL"
"PATH")))
:config
(exec-path-from-shell-initialize))
(leaf autorevert
:doc "revert buffers when files on disk change"
:tag "builtin"
:custom ((auto-revert-interval . 0.3)
(auto-revert-check-vc-info . t))
:global-minor-mode global-auto-revert-mode)
(leaf delsel
:doc "delete selection if you insert"
:tag "builtin"
:global-minor-mode delete-selection-mode)
(leaf paren
:doc "highlight matching paren"
:tag "builtin"
:custom ((show-paren-delay . 0.1))
:global-minor-mode show-paren-mode)
(leaf simple
:doc "basic editing commands for Emacs"
:tag "builtin" "internal"
:custom ((kill-ring-max . 100)
(kill-read-only-ok . t)
(kill-whole-line . t)
(eval-expression-print-length . nil)
(eval-expression-print-level . nil)))
(leaf files
:doc "file input and output commands for Emacs"
:tag "builtin"
:custom `((auto-save-timeout . 15)
(auto-save-interval . 60)
(auto-save-file-name-transforms . '((".*" ,(locate-user-emacs-file "backup/") t)))
(backup-directory-alist . '((".*" . ,(locate-user-emacs-file "backup"))
(,tramp-file-name-regexp . nil)))
(version-control . t)
(delete-old-versions . t)))
(leaf startup
:doc "process Emacs shell arguments"
:tag "builtin" "internal"
:custom `((auto-save-list-file-prefix . ,(locate-user-emacs-file "backup/.saves-"))))
(leaf ivy
:doc "Incremental Vertical completYon"
:req "emacs-24.5"
:tag "matching" "emacs>=24.5"
:url "https://github.com/abo-abo/swiper"
:emacs>= 24.5
:ensure t
:blackout t
:leaf-defer nil
:custom ((ivy-initial-inputs-alist . nil)
(ivy-re-builders-alist . '((t . ivy--regex-fuzzy)
(swiper . ivy--regex-plus)))
(ivy-use-selectable-prompt . t))
:global-minor-mode t
:config
(leaf swiper
:doc "Isearch with an overview. Oh, man!"
:req "emacs-24.5" "ivy-0.13.0"
:tag "matching" "emacs>=24.5"
:url "https://github.com/abo-abo/swiper"
:emacs>= 24.5
:ensure t
:bind (("C-s" . swiper)))
(leaf counsel
:doc "Various completion functions using Ivy"
:req "emacs-24.5" "swiper-0.13.0"
:tag "tools" "matching" "convenience" "emacs>=24.5"
:url "https://github.com/abo-abo/swiper"
:emacs>= 24.5
:ensure t
:blackout t
:bind (("C-S-s" . counsel-imenu)
("C-x C-r" . counsel-recentf))
:custom `((counsel-yank-pop-separator . "\n----------\n")
(counsel-find-file-ignore-regexp . ,(rx-to-string '(or "./" "../") 'no-group)))
:global-minor-mode t))
(leaf ivy-rich
:doc "More friendly display transformer for ivy."
:req "emacs-24.5" "ivy-0.8.0"
:tag "ivy" "emacs>=24.5"
:emacs>= 24.5
:ensure t
:after ivy
:global-minor-mode t)
(leaf prescient
:doc "Better sorting and filtering"
:req "emacs-25.1"
:tag "extensions" "emacs>=25.1"
:url "https://github.com/raxod502/prescient.el"
:emacs>= 25.1
:ensure t
:commands (prescient-persist-mode)
:custom `((prescient-aggressive-file-save . t)
(prescient-save-file . ,(locate-user-emacs-file "prescient")))
:global-minor-mode prescient-persist-mode)
(leaf ivy-prescient
:doc "prescient.el + Ivy"
:req "emacs-25.1" "prescient-4.0" "ivy-0.11.0"
:tag "extensions" "emacs>=25.1"
:url "https://github.com/raxod502/prescient.el"
:emacs>= 25.1
:ensure t
:after prescient ivy
:custom ((ivy-prescient-retain-classic-highlighting . t))
:global-minor-mode t)
(leaf midnight
:custom
((clean-buffer-list-delay-general . 1))
:config
(midnight-mode))
(leaf uniquify
:custom
((uniquify-buffer-name-style . 'post-forward-angle-brackets)
(uniquify-min-dir-content . 1)))
(leaf whitespace
:blackout ((global-whitespace-mode . "")
(whitespace-mode . ""))
:hook (after-init-hook . global-whitespace-mode)
:custom
((whitespace-line-column . 72)
(whitespace-style . '(face ; faceを使う
trailing ; 行末の空白を対象.
tabs ; tab
spaces ; space
))
(whitespace-display-mappings . '((space-mark ?\u3000 [?\□])
(tab-mark ?\t [?\u00BB ?\t] [?\\ ?\t])))
(whitespace-space-regexp . "\\(\u3000+\\)")
(whitespace-global-modes . '(not eww-mode
term-mode
eshell-mode
org-agenda-mode
calendar-mode))))
(leaf all-the-icons
:ensure t
:init (leaf memoize :ensure t)
:custom
((all-the-icons-scale-factor . 0.9)
(all-the-icons-default-adjust . 0.0))
:config
(leaf all-the-icons-ivy
:ensure t
:hook (after-init-hook . all-the-icons-ivy-setup)))
(leaf-keys (("C-h" . backward-delete-char)
("C-;" . comment-region)
("C-S-;" . uncomment-region)
("C-/" . undo)
("<home>" . beginning-of-buffer)
("<end>" . end-of-buffer)))
(leaf cider
:ensure t)
(leaf markdown-mode+
:ensure t)
(leaf solarized-theme
:ensure t
:config (load-theme 'solarized-dark t))
; leafでの設定がよくわからなかったものをマニュアルでセットする
(setq default-directory "~/")
(setq command-line-default-directory "~/")
(with-current-buffer "*scratch*"
(emacs-lock-mode 'kill))
(with-current-buffer "*Messages*"
(emacs-lock-mode 'kill))
; フォント関係
(set-face-font 'default "JetBrains Mono-16")
;; リガチャを有効にする
(let ((alist '((33 . ".\\(?:\\(?:==\\|!!\\)\\|[!=]\\)")
(35 . ".\\(?:###\\|##\\|_(\\|[#(?[_{]\\)")
(36 . ".\\(?:>\\)")
(37 . ".\\(?:\\(?:%%\\)\\|%\\)")
(38 . ".\\(?:\\(?:&&\\)\\|&\\)")
(42 . ".\\(?:\\(?:\\*\\*/\\)\\|\\(?:\\*[*/]\\)\\|[*/>]\\)")
(43 . ".\\(?:\\(?:\\+\\+\\)\\|[+>]\\)")
(45 . ".\\(?:\\(?:-[>-]\\|<<\\|>>\\)\\|[<>}~-]\\)")
(47 . ".\\(?:\\(?:\\*\\*\\|//\\|==\\)\\|[*/=>]\\)")
(48 . ".\\(?:x[a-zA-Z]\\)")
(58 . ".\\(?:::\\|[:=]\\)")
(59 . ".\\(?:;;\\|;\\)")
(60 . ".\\(?:\\(?:!--\\)\\|\\(?:~~\\|->\\|\\$>\\|\\*>\\|\\+>\\|--\\|<[<=-]\\|=[<=>]\\||>\\)\\|[*$+~/<=>|-]\\)")
(61 . ".\\(?:\\(?:/=\\|:=\\|<<\\|=[=>]\\|>>\\)\\|[<=>~]\\)")
(62 . ".\\(?:\\(?:=>\\|>[=>-]\\)\\|[=>-]\\)")
(63 . ".\\(?:\\(\\?\\?\\)\\|[:=?]\\)")
(91 . ".\\(?:]\\)")
(92 . ".\\(?:\\(?:\\\\\\\\\\)\\|\\\\\\)")
(94 . ".\\(?:=\\)")
(119 . ".\\(?:ww\\)")
(123 . ".\\(?:-\\)")
(124 . ".\\(?:\\(?:|[=|]\\)\\|[=>|]\\)")
(126 . ".\\(?:~>\\|~~\\|[>=@~-]\\)"))))
(dolist (char-regexp alist)
(set-char-table-range composition-function-table (car char-regexp)
`([,(cdr char-regexp) 0 font-shape-gstring]))))
(provide 'init)
;; Local Variables:
;; indent-tabs-mode: nil
;; byte-compile-warnings: (not cl-functions obsolete)
;; End:
;;; init.el ends here