chromebookにspacemacs環境構築
chromebook (Acer Chromebook Spin 311)を購入したので、spacemacsでorg-modeを使うことを目標に環境構築を行う。
linuxのインストールは設定から行える。
ついでに、検索キーとコントロールを入れ替えておく。
とりあえず最初に以下を実行。
sudo apt update
sudo apt upgrade
新しいバージョンのemacsを入れたいので、下記の方法に従う
mozcのインストール
参照→ https://qiita.com/wakadori_Mk2/items/8d43993ff515c53e830d
sudo apt-get install emacs-mozc emacs-mozc-bin
spacemacsのインストール
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
vim, spacemacsで
.spacemacsのediting-styleをvimからhybridへ
これで、spacemacsを使って、快適な日本語入力までできるようになった。
Google Driveのファイルにアクセスする方法
.spacemacsでフォントをNoto Sans Mono CJK JPに変更
¥を\へ
C-hとjj
evil-escape-key-sequenceは効かない?
flyspellのためのaspell追加
医学用語辞書を追加する。
org-journalのsetup. dotspacemacs-configuration-layersに下記を追記。
(org :variables
;; org-journal
org-enable-org-journal-support t
org-journal-dir "/mnt/chromeos/GoogleDrive/MyDrive/org/"
org-journal-file-format "%Y-%m-%d"
org-journal-date-prefix "#+TITLE: "
org-journal-date-format "%Y-%m-%d"
;; org-journal end
)
1日1ファイルよりも、1年1ファイルの方が好みなので、
org-journal-file-type 'yearly
にする。これはorg-journal-date-prefixと共存できない点に注意。
orgファイルへのリンク貼りを便利にする関数。user-configに定義。
クリップボードの共有
org-journalでorg-captureを使うための設定。
layerに
org-directory "/mnt/chromeos/GoogleDrive/MyDrive/org/"
user-configに
;; org-journal-capture
(defun org-journal-find-location ()
;; Open today's journal, but specify a non-nil prefix argument in order to
;; inhibit inserting the heading; org-capture will insert the heading.
(org-journal-new-entry t)
(unless (eq org-journal-file-type 'daily)
(org-narrow-to-subtree))
(goto-char (point-max)))
(defvar org-journal--date-location-scheduled-time nil)
(defun org-journal-date-location (&optional scheduled-time)
(let ((scheduled-time (or scheduled-time (org-read-date nil nil nil "Date:"))))
(setq org-journal--date-location-scheduled-time scheduled-time)
(org-journal-new-entry t (org-time-string-to-time scheduled-time))
(unless (eq org-journal-file-type 'daily)
(org-narrow-to-subtree))
(goto-char (point-max))))
(setq org-capture-templates '(
("j" "Journal entry" plain (function org-journal-find-location)
"** %(format-time-string org-journal-time-format)%^{Title}\n%i%?"
:jump-to-captured t :immediate-finish t)
("t" "Journal task entry" plain (function org-journal-date-location)
"** TODO %?\n <%(princ org-journal--date-location-scheduled-time)>\n"
:jump-to-captured t)
)
)
org-roamの設定
layerに
org-enable-roam-support t
org-roam-v2-ack t
org-roam-directory "/mnt/chromeos/GoogleDrive/MyDrive/org/"
org-roam-db-autosync-mode t
TODO管理を改造と、agenda, refileの設定
;; org todo keywords
org-todo-keywords '((sequence "TODO(t)" "SOMEDAY(s)" "WAITING(w)" "|" "DONE(d)" "CANCELED(c@)"))
; org todo keywords end
;; org-agenda
org-agenda-files '("/mnt/chromeos/GoogleDrive/MyDrive/org") ;; 末尾のスラッシュは不要
;; org-agenda end
;; org-refile
org-refile-targets '((org-agenda-files :maxlevel . 3))
;; org-refile end
org-use-speed-commands t
org-pomodoroの音がならない?
mozcにDMiMEが反映されてない?
ターミナルでmozcの設定ツールを起動してgoogle日本語入力と同じように設定する
/usr/lib/mozc/mozc_tool --mode=config_dialog
org-roam-complete-everywhere t
org-captureで%aは起動したときに開いていたファイルを表す。これをテンプレートに追加しておく
org-capture-templatesを改造
(setq org-capture-templates '(
("j" "Journal entry" plain (function org-journal-find-location)
"** %(format-time-string org-journal-time-format)%^{Title}\nfrom: %a"
:immediate-finish t)
("t" "Journal task entry" plain (function org-journal-date-location)
"** TODO %?\n<%(princ org-journal--date-location-scheduled-time)>\nadded: %U\nfrom: %a"
:jump-to-captured t)
("r" "reading and watching" plain (file "/mnt/chromeos/GoogleDrive/MyDrive/org/20211012125719-reading_and_watching.org")
"* TODO %^{Title}\nadded: %U\nfrom: %a"
:jump-to-captured t)
)
)
layerのところで
org-startup-truncated nil
org-captureの京大型カード用テンプレート
("c" "card" plain (file "/mnt/chromeos/GoogleDrive/MyDrive/org/20211015223240-cards.org"
"* %^{Title}\nadded: %U\nfrom: %a")
org-captureを起動するキーバインド
(bind-key "C-c c" 'org-capture)
検索で日本語が使えない?
vimの/だけでなく、C-sでも英数入力になってしまっている
org-search-viewでは日本語の検索もできる
気に入ったテーマ。org-modeでの色わけがカラフルで見やすい
sanityinc-tomorrow-blue
org-modeでheadingsのsparseが上手く行かないと思ったら、最上段では機能しないようだ。
上記に対応して、level 2のheadingを挿入するようテンプレートを変更
(setq org-capture-templates '(
("j" "Journal entry" plain (function org-journal-find-location)
"** %(format-time-string org-journal-time-format)%^{Title}\nfrom: %a"
:immediate-finish t)
("t" "Journal task entry" plain (function org-journal-date-location)
"** TODO %?\n<%(princ org-journal--date-location-scheduled-time)>\nadded: %U\nfrom: %a"
:jump-to-captured t)
("c" "card" plain (file "/mnt/chromeos/GoogleDrive/MyDrive/org/20211015223240-cards.org")
"** %^{Title}\nadded: %U\nfrom: %a"
:jump-to-captured t)
("s" "speed card" plain (file "/mnt/chromeos/GoogleDrive/MyDrive/org/20211015223240-cards.org")
"** %^{Title}\nadded: %U\nfrom: %a"
:immediate-finish t)
)
)
ルーチンタスクの管理
org-drillを使うには、dotspacemacs-additional-packagesにorg-drillを追記すればよいようだ。
org-drillの使い方は下記
org-captureの後にIDを自動作成し、org-roamの管理下に置くためのhook
日々の単なる記録が載ると鬱陶しいので、org-drillをorg-roamの管理から外す。
現在のorgまわりの設定をここに記す。
;; List of configuration layers to load.
dotspacemacs-configuration-layers
'(
;; ----------------------------------------------------------------
;; Example of useful layers you may want to use right away.
;; Uncomment some layer names and press `SPC f e R' (Vim style) or
;; `M-m f e R' (Emacs style) to install them.
;; ----------------------------------------------------------------
auto-completion
better-defaults
emacs-lisp
;; git
helm
;; lsp
;; markdown
multiple-cursors
(org :variables
org-use-speed-commands t
org-startup-truncated nil
;; org-capture用に使うdirectory
org-directory "/mnt/chromeos/GoogleDrive/MyDrive/org/"
;; org-capture用に使うdirectory end
;; org todo keywords
org-todo-keywords '((sequence "TODO(t)" "SOMEDAY(s)" "WAITING(w)" "|" "DONE(d)" "CANCELED(c@)"))
;; org todo keywords end
;; org-agenda
org-agenda-files '("/mnt/chromeos/GoogleDrive/MyDrive/org")
;; org-agenda end
;; org-refile
org-refile-targets '((org-agenda-files :maxlevel . 3))
;; org-refile end
;; org-journal
org-enable-org-journal-support t
org-journal-dir "/mnt/chromeos/GoogleDrive/MyDrive/org"
org-journal-file-type 'yearly ;; ファイルは1年1つ
org-journal-file-format "j-%Y.org"
org-journal-date-format "%Y-%m-%d, %A"
org-journal-find-file 'find-file
org-journal-enable-agenda-integration t
;; org-journal end
;; org-roam
org-enable-roam-support t
org-roam-directory "/mnt/chromeos/GoogleDrive/MyDrive/org/roam/"
org-roam-db-autosync-mode t
org-roam-v2-ack t
org-roam-complete-everywhere t
;; org-roam end
;; org-pomodoro
org-pomodoro-finished-sound-p t
;; org-pomodoro end
;; mode line support
spaceline-org-clock-p t
;; mode line support end
)
(shell :variables
shell-default-height 30
shell-default-position 'bottom)
spell-checking
syntax-checking
;; version-control
treemacs)
dotspacemacs-additional-packages '(
mozc
org-drill
)
(defun dotspacemacs/user-config ()
"Configuration for user code:
This function is called at the very end of Spacemacs startup, after layer
configuration.
Put your configuration code here, except for variables that should be set before packages are loaded."
;; Mozc settings
(set-language-environment "Japanese")
(setq default-input-method "japanese-mozc")
(setq mozc-candidate-style 'echo-area)
(defun mozc-start()
(interactive)
(set-cursor-color "blue")
(message "Mozc start")
(mozc-mode 1))
(defun mozc-end()
(interactive)
(set-cursor-color "gray")
(message "Mozc end")
(mozc-mode -1))
(bind-keys*
("<henkan>" . mozc-start)
("<muhenkan>" . mozc-end))
(bind-keys :map mozc-mode-map
("q" . mozc-end)
("C-g" . mozc-end)
("C-x h" . mark-whole-buffer)
("C-x C-s" . save-buffer))
;; Mozc settings end
;; copy and paste
(defun copy-to-clipboard ()
"Copies selection to x-clipboard."
(interactive)
(if (display-graphic-p)
(progn
(message "Yanked region to x-clipboard!")
(call-interactively 'clipboard-kill-ring-save)
)
(if (region-active-p)
(progn
(shell-command-on-region (region-beginning) (region-end) "xsel --clipboard --input")
(message "Yanked region to clipboard!")
(deactivate-mark))
(message "No region active; can't yank to clipboard!")))
)
(defun paste-from-clipboard()
"Pastes from x-clipboard."
(interactive)
(if (display-graphic-p)
(progn
(clipboard-yank)
(message "graphics active")
)
(insert (shell-command-to-string "xsel --clipboard --output"))
)
)
(evil-leader/set-key "o y" 'copy-to-clipboard)
(evil-leader/set-key "o p" 'paste-from-clipboard)
;; copy and paste end
;; C-h
(bind-key* "C-h" #'delete-backward-char)
(with-eval-after-load 'company
(bind-key "C-h" nil company-active-map))
;; C-h end
;; org-link作成用関数
(defun to-clipboard(x)
"与えられた文字列をクリップボードにコピーします"
(when x
(with-temp-buffer
(insert x)
(clipboard-kill-region (point-min) (point-max)))
(message x)))
(defun file-full-path()
"今開いているファイルの絶対パス::行数を返します"
(if (equal major-mode 'dired-mode)
default-directory
(concat (buffer-file-name) "::" (number-to-string (line-number-at-pos)))))
(defun file-full-path-org-link-to-clipboard()
"今開いているファイルのorg linkをクリップボードにコピーします"
(interactive)
(to-clipboard (concat "[[" (file-full-path) "][" (file-name-nondirectory buffer-file-name) "]]")))
;; org-link作成用関数 end
;; org-capture
;; org-capture後にIDもつける
(add-hook 'org-capture-mode-hook #'org-id-get-create)
(bind-key "C-c c" 'org-capture)
(defun org-journal-find-location ()
;; Open today's journal, but specify a non-nil prefix argument in order to
;; inhibit inserting the heading; org-capture will insert the heading.
(org-journal-new-entry t)
(unless (eq org-journal-file-type 'daily)
(org-narrow-to-subtree))
(goto-char (point-max))
)
(defvar org-journal--date-location-scheduled-time nil)
(defun org-journal-date-location (&optional scheduled-time)
(let ((scheduled-time (or scheduled-time (org-read-date nil nil nil "Date:"))))
(setq org-journal--date-location-scheduled-time scheduled-time)
(org-journal-new-entry t (org-time-string-to-time scheduled-time))
(unless (eq org-journal-file-type 'daily)
(org-narrow-to-subtree))
(goto-char (point-max))))
(setq org-capture-templates '(
("j" "Journal entry" plain (function org-journal-find-location)
"** %(format-time-string org-journal-time-format)%^{Title}\nfrom: %a"
:immediate-finish t)
("t" "Journal task entry" plain (function org-journal-date-location)
"** TODO %?\n<%(princ org-journal--date-location-scheduled-time)>\nadded: %U\nfrom: %a"
:jump-to-captured t)
("c" "card" plain (file "/mnt/chromeos/GoogleDrive/MyDrive/org/roam/20211015223240-cards.org")
"** %^{Title}\nadded: %U\nfrom: %a"
:jump-to-captured t)
("s" "speed card" plain (file "/mnt/chromeos/GoogleDrive/MyDrive/org/roam/20211015223240-cards.org")
"** %^{Title}\nadded: %U\nfrom: %a"
:immediate-finish t)
)
)
;; org-capture end
)
org→markdownへの変換のためにmarkdown layerをinstall
ox-zennを入れるにはadditional packagesに書き足すだけでいけるっぽい
org-roamでbacklinkが表示されるが動かない問題の解決
org-roam-serverは入れても反映されない?
YouTubeのvideoIDが不正です
gitの更新
githubの登録
org-roamをスマホでも
chromeで見てるページのリンクを作る
guixを使った入れ方
guix pull
で更新する。時間かかる。
guix pull重すぎてこのPCのスペックだときついかも。一旦断念
libgccjitまわりが上手くいかない。
gccのversionが8なのがよくない?chromebookにgcc-10を入れるには?
libgccjitのコンパイルは通るがsegfaultを返す
native comp emacsは一旦断念