Doom Emacs の基本的な使い方

<f12> で emacs 起動。

<spc> n r f で、 org の検索ができる。後は vim (cheatsheet) の操作にしたがい編集する。

なんか変な事が起きて、キャンセルしたい場合は、 <C-g>

公開したい記事は、 ファイル上部に、 #+filetags: :public: を記述することで、公開される。 opt-in

<C-w> v で画面の縦分割 <C-w> <C-w> で次の画面に移動

vim

u で undo :q <enter> で閉じる :w <enter> で保存

git push の仕方

  • <spc> g ggit の画面
  • stage したいファイルにカーソルを合わせて、 s で、追加
  • cc でコミット
  • コミットメッセージを記入後、 <C-c> <C-c> で、確定
  • pu で push
  • q で git 画面終了

文字化けした場合

<C-x> <etner> rutf-8 をえらぶ。

TODO org-id link で書き出しを解決する。

<spc> n r i で、 他の org ファイルのリンクが出来るが、書き出しがうまくいかない可能性があるので、使わない。

<C-c> <C-l> でリンクを貼る。

設定

Doom の設定ファイルは init.el, packages.el, config.el, の三つ。このファイルを編集したら、 <C-c> <C-v> t で書き出し。

init.el

それぞれの module のフラグはこちらを参照する。不要なものを全てけずっているので、追加したくなったら、こちらを参照。

init.el
;;; init.el -*- lexical-binding: t; -*-

;; This file controls what Doom modules are enabled and what order they load
;; in. Remember to run 'doom sync' after modifying it!

;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's
;;      documentation. There you'll find a link to Doom's Module Index where all
;;      of our modules are listed, including what flags they support.

;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or
;;      'C-c c k' for non-vim users) to view its documentation. This works on
;;      flags as well (those symbols that start with a plus).
;;
;;      Alternatively, press 'gd' (or 'C-c c d') on a module to browse its
;;      directory (for easy access to its source code).

;; THIS IS AN AUTO GENERATED FILE

(doom! :input
       japanese

       :completion
       company           ; the ultimate code completion backend
       vertico           ; the search engine of the future

       :ui
       doom              ; what makes DOOM look the way it does
       doom-dashboard    ; a nifty splash screen for Emacs
       hl-todo           ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
       modeline          ; snazzy, Atom-inspired modeline, plus API
       ophints           ; highlight the region an operation acts on
       (popup +defaults)   ; tame sudden yet inevitable temporary windows
       vc-gutter         ; vcs diff in the fringe
       vi-tilde-fringe   ; fringe tildes to mark beyond EOB
       workspaces        ; tab emulation, persistence & separate workspaces
       zen

       :editor
       (evil +everywhere); come to the dark side, we have cookies
       file-templates    ; auto-snippets for empty files
       fold              ; (nigh) universal code folding
       snippets          ; my elves. They type so I don't have to

       :emacs
       dired             ; making dired pretty [functional]
       electric          ; smarter, keyword-based electric-indent
       undo              ; persistent, smarter undo for your inevitable mistakes
       vc                ; version-control and Emacs, sitting in a tree

       :term
       vterm             ; the best terminal emulation in Emacs

       :checkers
       syntax              ; tasing you for every semicolon you forget

       :tools
       (eval +overlay)     ; run code, run (also, repls)
       magit             ; a git porcelain for Emacs
       lsp
       biblio

       :os
       (:if IS-MAC macos)  ; improve compatibility with macOS

       :lang
       emacs-lisp        ; drown in parentheses
       markdown          ; writing docs for people to ignore
       (org
        +roam2
        +pretty)              ; organize your plain life in plain text
       (rust +lsp)

       sh                ; she sells {ba,z,fi}sh shells on the C xor
       :email
       :app

       :config
       (default +bindings +smartparens))

config.el

もともとの config.el ファイルはこちらから

config.el (header)
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-

;; THIS IS AN AUTOGENERATED FILE
config.el

general

(setq user-full-name "Yasushi Sakai"
      user-mail-address "yasushi.accounts@fastmail.com")
  • fonts

    linux 環境でフォントが少し違うので、それをフォローしてやる必要あり

    (if IS-MAC
    (setq doom-font (font-spec :family "Firple" :size 14)
          doom-variable-pitch-font (font-spec :family "IBM Plex Sans JP" :size 16)
          doom-big-font (font-spec :family "Firple" :size 20)))
    
    (if IS-LINUX
    (setq doom-font (font-spec :family "Firple" :size 18)
          doom-unicode-font (font-spec :family "IBM Plex Sans JP" :size 18)
          doom-variable-pitch-font (font-spec :family "IBM Plex Sans JP" :size 20)
          doom-big-font (font-spec :family "Firple" :size 24)))
    
    (setq mixed-pitch-variable-pitch-cursor nil)
    
  • theme

    いつもの

    (setq doom-theme 'doom-nord)
    
  • line numbers
    (setq display-line-numbers-type 'relative)
    

org

本当は、Section ごとに、文字の大きさを変えたいのだが、どうもうまくいかない。

(use-package! org
  :custom
  (org-directory "~/Dropbox/org/notes"))

(add-hook! org-mode :append
           #'visual-line-mode)
           ;;#'variable-pitch-mode)

;; this doesn't work...
(add-hook 'org-mode-hook #'mixed-pitch-mode)
(setq mixed-pitch-set-height t)
  • citation
    (setq! citar-bibliography '("~/Dropbox/org/notes/bib/main.bib"))
    
  • org-roam
    (use-package! org-roam
      :custom
      (org-roam-directory org-directory)
      (org-roam-capture-templates
        '(("d" "default" plain "%?"
          :if-new (file+head "~/Dropbox/org/notes/${slug}.org" "#+title: ${title}\n
    #+date: %U\n
    :DRAWER:\n
    #+options: title:nil\n
    #+LATEX_CLASS: article\n
    #+LATEX_HEADER: \\newcommand{\\headauthor}{Yasushi Sakai}\n
    #+LATEX_HEADER: \\newcommand{\\headtitle}{${title}}\n
    #+LATEX_HEADER: \\newcommand{\\headsubtitle}{${title}}\n
    #+setupfile: ./setup.org\n
    :END:")
         :unarrowed t))))
    
  • org-agenda
    (setq org-agenda-files (list org-directory))
    (defun ys-org-skip-subtree-if-priority (priority)
      "Skip an agenda subtree if it has a priority of PRIORITY.
    PRIORITY may be one of the characters ?A, ?B, or ?C."
      (let ((subtree-end (save-excursion (org-end-of-subtree t)))
            (pri-value (* 1000 (- org-lowest-priority priority)))
            (pri-current (org-get-priority (thing-at-point 'line t))))
        (if (= pri-value pri-current)
            subtree-end
          nil )))
    
    (setq org-agenda-custom-commands
          '(("c" "Simple agenda view" ((tags "PRIORITY=\"A\""
                                             ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
                                              (org-agenda-overriding-header "High-priority undone tasks:")))
                                       (agenda "" ((org-agenda-span 8)
                                                   (org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
                                                   (org-agenda-start-day "-1d")
                                                   (org-deadline-warning-days 0)
                                                   (org-agenda-start-on-weekday nil)
                                                   (org-habit-show-habits-only-for-today t)))
                                       (alltodo ""
                                                ((org-agenda-skip-function
                                                  '(or (ys-org-skip-subtree-if-priority ?A)
                                                       (org-agenda-skip-if nil '(scheduled deadline))))))))))
    
  • publish
    (require 'ox-publish)
    
    (setq org-publish-project-alist
          '(("main"
                 :recursive t
                 :base-directory "~/Dropbox/org/notes"
                 :publishing-directory "~/Dropbox/org/public"
                 :publishing-function org-html-publish-to-html
                 :with-author nil
                 :with-creator nil
                 :with-title nil
                 :with-toc nil
                     :with-timestamps t
                 :with-broken-links 'mark
                 :section-numbers nil
                 :time-stamp-file nil)
            ("images"
                 :base-directory "~/Dropbox/org/notes/images"
                 :base-extension "png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg"
                 :publishing-directory "~/Dropbox/org/public/images"
                 :recursive t
                 :publishing-function org-publish-attachment)
            ("static"
                 :base-directory "~/Dropbox/org/notes/static"
                 :base-extension "js\\|css\\|html"
                 :publishing-directory "~/Dropbox/org/public/static"
                 :recursive t
                 :publishing-function org-publish-attachment)))
    
    (setq org-html-validation-link nil
          org-html-head-include-scripts nil
          org-html-head-include-default-style nil
          org-html-doctype "html5"
          org-html-head "<link rel=\"stylesheet\" href=\"/static/css/ibm-plex-sans-jp.min.css\"><link rel=\"stylesheet\" href=\"/static/style.css\" />")
    
    

packages.el

packages.el
;; -*- no-byte-compile: t; -*-
;;; $DOOMDIR/packages.el

;; THIS IS AN AUTOGENERATED FILE

;; To install a package with Doom you must declare them here and run 'doom sync'
;; on the command line, then restart Emacs for the changes to take effect -- or
;; use 'M-x doom/reload'.


;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;(package! some-package)

;; To install a package directly from a remote git repo, you must specify a
;; `:recipe'. You'll find documentation on what `:recipe' accepts here:
;; https://github.com/raxod502/straight.el#the-recipe-format
;(package! another-package
;  :recipe (:host github :repo "username/repo"))

;; If the package you are trying to install does not contain a PACKAGENAME.el
;; file, or is located in a subdirectory of the repo, you'll need to specify
;; `:files' in the `:recipe':
;(package! this-package
;  :recipe (:host github :repo "username/repo"
;           :files ("some-file.el" "src/lisp/*.el")))

;; If you'd like to disable a package included with Doom, you can do so here
;; with the `:disable' property:
;(package! builtin-package :disable t)

;; You can override the recipe of a built in package without having to specify
;; all the properties for `:recipe'. These will inherit the rest of its recipe
;; from Doom or MELPA/ELPA/Emacsmirror:
;(package! builtin-package :recipe (:nonrecursive t))
;(package! builtin-package-2 :recipe (:repo "myfork/package"))

;; Specify a `:branch' to install a package from a particular branch or tag.
;; This is required for some packages whose default branch isn't 'master' (which
;; our package manager can't deal with; see raxod502/straight.el#279)
;(package! builtin-package :recipe (:branch "develop"))

;; Use `:pin' to specify a particular commit to install.
;(package! builtin-package :pin "1a2b3c4d5e")


;; Doom's packages are pinned to a specific commit and updated from release to
;; release. The `unpin!' macro allows you to unpin single packages...
;(unpin! pinned-package)
;; ...or multiple packages
;(unpin! pinned-package another-pinned-package)
;; ...Or *all* packages (NOT RECOMMENDED; will likely break things)
;(unpin! t)

Date: 2022-03-29 Tue 19:07