package: Add fzf.
misc: Add GNU Build System package section.
package: Add m4.
個人用端末 (Taix) の構成.
OS は GNU Guix を使用し, 可能な限り宣言的に構成を記述している.
以下の手順を実行して, Guix を設定する.
このファイルから各種設定ファイルを生成する.
emacs -Q --batch --eval "(progn (require 'ob-tangle) (with-current-buffer (find-file-noselect \"taix.org\") (org-babel-tangle)))"
チャンネル情報を更新する.
guix pull
sudo guix system reconfigure guix-config/system-config.scm
# guix home reconfigure guix-config/home-config.scm
guix package --manifest=guix-config/package-config.scm
GNU Stow を使用し, 生成された各設定ファイルを規定のパスにリンクする.
cd dotfiles
stow -vt $HOME emacs.d guix nyxt sbcl fontconfig
チャンネルの設定ファイルは, 下記の構成で記述されている.
<<ヘッダ行>>
(cons*
<<custom-channels>>
%default-channels)
出力されたファイル: dotfiles/guix/.config/guix/channels.scm
NonGuix をチャンネルに加える.
(channel
(name 'nonguix)
(url "https://gitlab.com/nonguix/nonguix")
(introduction
(make-channel-introduction
"897c1a470da759236cc11798f4e0a5f7d4d59fbc"
(openpgp-fingerprint
"2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5"))))
emacs-edge
などを提供している WhereIsEveryone の guixrus
をチャンネルに加える.
(channel
(name 'guixrus)
(url "https://git.sr.ht/~whereiseveryone/guixrus")
(introduction
(make-channel-introduction
"7c67c3a9f299517bfc4ce8235628657898dd26b2"
(openpgp-fingerprint
"CD2D 5EAA A98C CB37 DA91 D6B0 5F58 1664 7F8B E551"))))
既存のチャンネルに存在しないパッケージを管理するために, 独自チャンネルを追加する.
(channel
(name 'taix)
(url "https://git.sr.ht/~taiju/taix"))
システムの設定ファイルは, 下記の構成で記述されている.
<<ヘッダ行>>
(use-modules (gnu)
(nongnu packages linux)
(nongnu system linux-initrd))
(use-service-modules desktop
networking
ssh
xorg
docker
virtualization)
(operating-system
(kernel linux)
(initrd microcode-initrd)
(firmware (list linux-firmware))
(locale "ja_JP.utf8")
(timezone "Asia/Tokyo")
(keyboard-layout
(keyboard-layout
"jp"
#:options
'("ctrl:nocaps")))
(host-name "Taix")
(users (cons* (user-account
(name "taiju")
(comment "Taiju HIGASHI")
(group "users")
(home-directory "/home/taiju")
(supplementary-groups
'("wheel" "netdev" "audio" "video" "docker" "kvm" "libvirt")))
%base-user-accounts))
(packages
(append
(list (specification->package "nss-certs")
(specification->package "font-google-noto"))
%base-packages))
(services
(append
(list (service gnome-desktop-service-type)
(set-xorg-configuration
(xorg-configuration
(keyboard-layout keyboard-layout)
(extra-config (list
<<libinput-config>>))))
(service docker-service-type)
(service libvirt-service-type
(libvirt-configuration
(unix-sock-group "libvirt")))
(service virtlog-service-type)
(extra-special-file "/var/lib/gdm/.config/fontconfig/fonts.conf"
(plain-file "gdm-fonts.conf"
"<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>/run/current-system/profile/share/fonts/</dir>
</fontconfig>
")))
%desktop-services))
(bootloader
(bootloader-configuration
(bootloader grub-efi-bootloader)
(targets '("/boot/efi"))
(keyboard-layout keyboard-layout)))
(mapped-devices
(list (mapped-device
(source
(uuid "6563ab41-2324-469f-9664-683cf4ba0065"))
(target "cryptroot")
(type luks-device-mapping))
(mapped-device
(source
(uuid "738e914a-a68a-4c4b-b7e1-62dda98cd2f8"))
(target "crypthome")
(type luks-device-mapping))))
(file-systems
(cons* (file-system
(mount-point "/boot/efi")
(device (uuid "A0B0-3FC0" 'fat32))
(type "vfat"))
(file-system
(mount-point "/")
(device "/dev/mapper/cryptroot")
(type "ext4")
(dependencies mapped-devices))
(file-system
(mount-point "/home")
(device "/dev/mapper/crypthome")
(type "ext4")
(dependencies mapped-devices))
%base-file-systems)))
出力されたファイル: system-config.scm
タッチパッドをタップした時にクリックとして扱われるようにする.
"Section \"InputClass\"
Identifier \"TouchPad\"
MatchIsTouchpad \"on\"
Driver \"libinput\"
Option \"Tapping\" \"on\"
EndSection"
TBD
パッケージのマニフェストは, 下記の構成で記述されている.
<<ヘッダ行>>
(use-modules (guix packages)
(gnu packages pdf)
(taix packages pdf))
<<パッケージマニフェスト用のユーティリティ定義>>
(packages->manifest
(list
<<Guix Packages>>))
出力されたファイル: package-config.scm
デスクトップ関連のパッケージとして下記をインストールする.
(with-poppler-data (specification->package "evince"))
(specification->package "gnome-shell")
(specification->package "gnome-shell-extension-dash-to-dock")
(specification->package "gnome-shell-extensions")
(specification->package "gnome-tweaks")
(specification->package "ibus")
(specification->package "ibus-anthy")
(specification->package "xdg-desktop-portal")
(specification->package "xdg-desktop-portal-gtk")
(specification->package "xdg-utils")
パッケージマネージャ関連のパッケージとして下記をインストールする.
Guix のパッケージになっていないソフトウェアのインストールや管理に Flatpak を使用する.
(specification->package "flatpak")
Emacs 関連のパッケージとして下記をインストールする.
(specification->package "emacs")
(specification->package "emacs-ace-window")
(specification->package "emacs-bash-completion")
(specification->package "emacs-company")
(specification->package "emacs-ddskk-nicola")
(specification->package "emacs-docker")
(specification->package "emacs-docker-tramp")
(specification->package "emacs-editorconfig")
(specification->package "emacs-flycheck")
(specification->package "emacs-geiser")
(specification->package "emacs-geiser-guile")
(specification->package "emacs-guix")
(specification->package "emacs-go-mode")
(specification->package "emacs-hide-mode-line")
(specification->package "emacs-haskell-mode")
(specification->package "emacs-htmlize")
(specification->package "emacs-lsp-mode")
(specification->package "emacs-lsp-ui")
(specification->package "emacs-magit")
(specification->package "emacs-markdown-mode")
(specification->package "emacs-ob-async")
(specification->package "emacs-org-contrib")
(specification->package "emacs-org-present")
(specification->package "emacs-org-roam")
(specification->package "emacs-ox-gfm")
(specification->package "emacs-paredit")
(specification->package "emacs-projectile")
(specification->package "emacs-slime")
(specification->package "emacs-slime-company")
(specification->package "emacs-vterm")
(specification->package "emacs-which-key")
(specification->package "emacs-yaml-mode")
(specification->package "emacs-yasnippet")
(specification->package "emacs-yasnippet-snippets")
シェル関連のパッケージとして下記をインストールする.
(specification->package "bash")
(specification->package "bash-completion")
(specification->package "fzf")
(specification->package "openssh")
(specification->package "rlwrap")
(specification->package "stow")
(specification->package "tree")
アプリケーションとして下記をインストールする.
(specification->package "anki")
(with-poppler-data (specification->package "calibre"))
(specification->package "cawbird")
(specification->package "gimp")
(specification->package "icecat")
(specification->package "inkscape")
(specification->package "libreoffice")
(specification->package "nyxt")
(specification->package "mpv")
(specification->package "pelican")
(specification->package "tootle")
(specification->package "youtube-dl")
フォント関連のパッケージとして下記をインストールする.
(specification->package "font-google-noto")
(specification->package "font-plemoljp")
開発関連のパッケージとして下記をインストールする.
(specification->package "git")
(list (specification->package "git") "send-email")
(specification->package "guile")
(specification->package "guile-hall")
(specification->package "nss-certs")
(specification->package "sbcl")
(specification->package "ghq")
GNU Build System のパッケージとして下記をインストールする.
(specification->package "autoconf")
(specification->package "automake")
(specification->package "m4")
(specification->package "make")
(specification->package "texinfo")
ユーティリティ関連のパッケージとして下記をインストールする.
(specification->package "curl")
(specification->package "jq")
(specification->package "perl")
(specification->package "pinentry")
(specification->package "python")
(specification->package "recutils")
(specification->package "unzip")
(specification->package "zip")
poppler を依存関係に持つパッケージに poppler-data を追加するためのラッパ関数.
(define with-poppler-data
(package-input-rewriting `((,poppler . ,poppler-with-data))))
このラッパ関数でパッケージを包むと, PDF ファイル中の日本語を描画したり, 日本語のテキストの抽出できるようになる.
Guix の公式チャンネルなどに未登録で, 独自にパッケージ定義しているものは, 独自チャンネルを作成して管理する.
<<ヘッダ行>>
(define-module (taix packages ibus)
#:use-module (guix licenses)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix build-system gnu)
#:use-module (gnu packages anthy)
#:use-module (gnu packages gettext)
#:use-module (gnu packages glib)
#:use-module (gnu packages gtk)
#:use-module (gnu packages ibus)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python))
(define-public ibus-anthy
(package
(name "ibus-anthy")
(version "1.5.14")
(source (origin
(method url-fetch)
(uri (string-append
"https://github.com/ibus/ibus-anthy/releases/download/"
version "/ibus-anthy-" version ".tar.gz"))
(sha256
(base32
"16vd0k8wm13s38869jqs3dnwmjvywgn0snnpyi41m28binhlssf8"))))
(build-system gnu-build-system)
(arguments
'(#:configure-flags
;; Use absolute exec path in the anthy.xml.
(list (string-append "--libexecdir=" %output "/libexec"))
#:tests? #f ; The tests in this package include test cases with user input, so skip them.
#:phases
(modify-phases %standard-phases
(add-after 'install 'wrap-programs
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(for-each
(lambda (prog)
(wrap-program (string-append out "/libexec/" prog)
`("GUIX_PYTHONPATH" ":" prefix
(,(getenv "GUIX_PYTHONPATH")))
`("GI_TYPELIB_PATH" ":" prefix
(,(getenv "GI_TYPELIB_PATH")
,(string-append out "/lib/girepository-1.0")))))
'("ibus-engine-anthy" "ibus-setup-anthy"))
#t))))))
(native-inputs
`(("gettext" ,gettext-minimal)
("glib:bin" ,glib "bin")
("intltool" ,intltool)
("pkg-config" ,pkg-config)
("python" ,python)))
(inputs
(list anthy gtk+ ibus gobject-introspection python-pygobject))
(synopsis "Anthy Japanese language input method for IBus")
(description "IBus-Anthy is an engine for the input bus \"IBus\"). It
adds the Anthy Japanese language input method to IBus. Because most graphical
applications allow text input via IBus, installing this package will enable
Japanese language input in most graphical applications.")
(home-page "https://github.com/fujiwarat/ibus-anthy")
(license gpl2+)))
<<ヘッダ行>>
(define-module (taix packages pdf)
#:use-module (guix packages)
#:use-module (gnu packages pdf))
(define-public poppler-with-data
(package/inherit poppler
(name "poppler-with-data")
(inputs `(("poppler-data" ,poppler-data)
,@(package-inputs poppler)))
(synopsis "Poppler with poppler-data.")
(description
"Poppler is a PDF rendering library based on the xpdf-3.0 code base.
This package includes Poppler encoding files for rendering of CJK and Cyrillic text")))
Org Mode を使用して Literature Programming 方式で Emacs を設定する.
Emacs の設定ファイルは, 下記の構成で記述されている.
<<ヘッダ行>>
<<変数定義>>
<<関数定義>>
<<プリミティブ実装部分のカスタマイズ>>
<<パッケージのカスタマイズ>>
出力されたファイル: dotfiles/emacs.d/.emacs.d/init.el
プリミティブ実装部分のカスタマイズ内容を定義する.
Updating of data structures for redisplay.
ベル音を抑制して, 画面が光る表現で代替する.
(customize-set-variable 'visible-bell t)
Fontset handler.
JIS X 0208 の文字セットでデフォルトの sans-serif フォントを使用する.
(set-fontset-font t 'japanese-jisx0208 (font-spec :family *my-sans-serif-font*))
絵文字の範囲は Noto Color Emoji を使用する.
(set-fontset-font t 'symbol (font-spec :family "Noto Color Emoji"))
Generic frame functions.
メニューバーを非表示にする.
(customize-set-variable 'menu-bar-mode nil)
ツールバーを非表示にする.
(customize-set-variable 'tool-bar-mode nil)
Display generation from window structure and buffer text.
ポイントが画面枠外に出た際の自動スクロールでウィンドウのセンタリングを抑制し, 1 行ずつスクロールされるようにする.
(customize-set-variable 'scroll-conservatively 100)
Lisp functions pertaining to editing.
ユーザーフルネームを設定する.
(customize-set-variable 'user-full-name "Taiju HIGASHI")
各種パッケージのカスタマイズ内容を定義する.
Quickly switch windows.
ace-window のキーをモードラインに表示する.
(customize-set-variable 'ace-window-display-mode t)
ace-window にグローバルなキーをバインドする.
(global-set-key (kbd "M-o") 'ace-window)
file input and output commands for Emacs
使用中のファイルを自動保存する.
(customize-set-variable 'auto-save-visited-mode t)
バックアップファイルを作らない.
(customize-set-variable 'make-backup-files nil)
ファイルの保存時とファイル使用時に最終行に空行を追加する.
(customize-set-variable 'require-final-newline 'visit-save)
read-only でファイルを開いた場合は view-mode を有効にする.
(customize-set-variable 'view-read-only t)
ファイル保存時に不要な空白を削除するようにする.
(add-hook 'before-save-hook #'delete-trailing-whitespace)
pass a URL to a WWW browser
Emacs で使用するデフォルトのブラウザを EWW に設定する.
(customize-set-variable 'browse-url-browser-function 'eww-browse-url)
Modular text completion framework
company-mode をグローバルに有効にする.
(customize-set-variable 'global-company-mode t)
company による補完を 1 文字目で開始する.
(customize-set-variable 'company-minimum-prefix-length 1)
Minibuffer completion functions
ミニバッファの補完スタイルは initials
, flex
を使用する.
(customize-set-variable 'completion-styles '(initials flex))
initials
M-x lch
-> list-command-history
flex
M-x foo
-> fbarbazoo
tools for declaring and initializing options
テーマに leuven
を使用する.
(customize-set-variable 'custom-enabled-themes '(leuven))
display battery status information
モードラインにバッテリの状態を表示する.
(customize-set-variable 'display-battery-mode t)
display time, load and mail indicator in mode line of Emacs
モードラインに現在時刻を表示する.
(customize-set-variable 'display-time-mode t)
フォーマットは %m-%d %H:%M
にする.
(customize-set-variable 'display-time-format "%m-%d %H:%M")
Automatic parenthesis pairing
開き括弧を入力した時に, 閉じ括弧を自動入力するようにする.
(customize-set-variable 'electric-pair-mode t)
Show function arglist or variable docstring in echo area
emacs-lisp-mode
, lisp-mode
, scheme-mode
で eldoc-mode を有効にする.
(my-add-hooks
'(emacs-lisp-mode-hook lisp-mode-hook scheme-mode-hook)
#'eldoc-mode)
minor mode for editing parentheses
Lisp 系の各種モードで paredit-mode を有効にする.
(my-add-hooks
'(emacs-lisp-mode-hook
lisp-mode-hook
scheme-mode-hook
eval-expression-minibuffer-setup-hook
ielm-mode-hook
slime-repl-mode-hook)
#'enable-paredit-mode)
default, simple IRC client
ニックネームやサーバなどの初期設定をする.
(customize-set-variable 'rcirc-server-alist
'(("irc.libera.chat" :channels ("#emacs #guix #guix-jp #nyxt #commonlisp #guile #fsf")
:port 6697 :encryption tls :user-name "taiju" :full-name "Taiju HIGASHI")))
(customize-set-variable 'rcirc-default-nick "taiju")
(add-hook 'rcirc-mode-hook #'rcirc-track-minor-mode)
(add-hook 'rcirc-mode-hook #'rcirc-omit-mode)
completion using the TAB key
EShell のコマンド補完候補に Emacs Lisp 関数も表示するようにする.
(customize-set-variable 'eshell-show-lisp-completions t)
minibuffer completion incremental feedback
ミニバッファで使用する icomplete-mode を ido-mode のような挙動にする.
(customize-set-variable 'fido-mode t)
process Emacs shell arguments
Emacs の初期表示画面を抑制する.
(customize-set-variable 'inhibit-startup-screen t)
メールアドレスを設定する.
(customize-set-variable 'user-mail-address "higashi@taiju.info")
Outline-based notes management and organizer
アウトラインレベルに合わせてインデントされるようにする.
(customize-set-variable 'org-adapt-indentation t)
~/org
以下のファイルを Org Agenda で使用する.
(customize-set-variable 'org-agenda-files (list (expand-file-name "~/org")))
タスクを完了にする際に, タイムスタンプを追加する.
(customize-set-variable 'org-log-done 'time)
org-babel で使用する言語を指定する.
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(sql . t)
(shell . t)))
Dynamic task and appointment lists for Org
C-c a
で Org Agenda を起動する.
(global-set-key (kbd "C-c a") 'org-agenda)
Fast note taking in Org
C-c c
で Org Capture を起動する.
(global-set-key (kbd "C-c c") 'org-capture)
タスクと時系列のメモは org-capture で記録する.
(customize-set-variable 'org-capture-templates
`(("t" "TODO" entry (file ,(expand-file-name "~/org/inbox.org"))
"* TODO %?")
("n" "Notes" entry (file+olp+datetree ,(expand-file-name "~/org/notes.org"))
"* %?%<%H:%M>")))
A database abstraction layer for Org-mode
Migration utilities from v1 to v2
(setq org-roam-v2-ack t)
Major mode for special Org-roam buffers
(global-set-key (kbd "C-c n l") 'org-roam-buffer-toggle)
(global-set-key (kbd "C-c n f") 'org-roam-node-find)
(global-set-key (kbd "C-c n i") 'org-roam-node-insert)
(global-set-key (kbd "C-c n g") 'org-roam-graph)
(global-set-key (kbd "C-c n c") 'org-roam-capture)
(customize-set-variable 'org-roam-db-autosync-mode t)
Minimalist presentation minor-mode for Emacs org-mode.
org-present-mode に切り替えた際に, プレゼン用に設定を変更し, プレゼン終了時に後始末する.
(eval-after-load "org-present"
'(progn
(add-hook 'org-present-mode-hook
(lambda ()
(org-present-big)
(org-display-inline-images nil t)
(org-present-hide-cursor)
(org-present-read-only)
(toggle-frame-fullscreen)
(hide-mode-line-mode)))
(add-hook 'org-present-mode-quit-hook
(lambda ()
(org-present-small)
(org-remove-inline-images)
(org-present-show-cursor)
(org-present-read-write)
(toggle-frame-fullscreen)
(hide-mode-line-mode)))))
Asynchronous org-babel src block execution
Org Babel を非同期に実行できるようにする.
(require 'ob-async)
Github Flavored Markdown Back-End for Org Export Engine
Github Flavored Markdown でエクスポートできるようにデフォルトで有効化する.
(eval-after-load "org"
'(require 'ox-gfm nil t))
(customize-set-variable 'projectile-mode t)
(customize-set-variable 'scroll-bar-mode nil)
(customize-set-variable 'send-mail-function 'smtpmail-send-it)
(customize-set-variable 'skk-kanagaki-keyboard-type '106-jis)
(global-unset-key "\C-xt")
(define-key ctl-x-map "t" tab-prefix-map)
(customize-set-variable 'skk-large-jisyo (expand-file-name "skk-get-jisyo/SKK-JISYO.L" user-emacs-directory))
(customize-set-variable 'skk-use-kana-keyboard t)
(customize-set-variable 'smtpmail-smtp-server "smtp.gmail.com")
(customize-set-variable 'smtpmail-smtp-service 587)
(customize-set-variable 'which-key-mode t)
(mapc (lambda (face) (set-face-attribute face nil :family *my-sans-serif-font*))
'(default fixed-pitch variable-pitch))
(set-face-attribute 'bold nil :family *my-sans-serif-font*)
(set-face-attribute 'fixed-pitch-serif nil :slant 'italic :family *my-serif-font*)
(set-face-attribute 'tab-bar-tab nil :inherit 'tab-bar :background "white")
(global-set-key (kbd "C-x C-b") 'ibuffer)
(require 'bash-completion)
(bash-completion-setup)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(require 'server)
(unless server-process
(server-start))
tools for customizing Emacs and Lisp packages
カスタムファイルを init.el
と別にする.
(customize-set-variable 'custom-file (expand-file-name "~/.emacs.d/custom.el"))
EditorConfig Emacs Plugin
EditorConfig を有効にする.
(customize-set-variable 'editorconfig-mode 1)
an inferior-lisp mode
Inferior Lisp mode で SBCL を使用する.
(customize-set-variable 'inferior-lisp-program "sbcl")
SLIME などでこの値が参照される.
Superior Lisp Interaction Mode for Emacs
SLIME で使用する Contrib Package をロードする.
(setq slime-setup-contribs '(slime-fancy slime-quicklisp slime-asdf slime-company slime-fuzzy))
LSP mode
LSP モードのキーバインディングを設定する.
(customize-set-variable 'lsp-keymap-prefix "C-c l")
Yet another snippet extension for Emacs
Guix のスニペットを登録する.
(customize-set-variable 'yas-snippet-dirs (list "~/.emacs.d/snippets"
(concat *guix-source-path* "/etc/snippets")))
参考: The Perfect Setup (GNU Guix Reference Manual)
Yasnippet をグローバルに有効化する.
(yas-global-mode 1)
update the copyright notice in current buffer
Copyright の検索範囲を広げる.
(customize-set-variable 'copyright-limit 20000)
copyright-update
等で使用するユーザー名の正規表現を設定する.
(customize-set-variable 'copyright-names-regexp
(format "%s <%s>" user-full-name user-mail-address))
Guix のコントリビュート時に著作権表示を簡単に更新できるようにする.
(load-file (concat *guix-source-path* "/etc/copyright.el"))
参考: The Perfect Setup (GNU Guix Reference Manual)
Guile's implementation of the geiser protocols
Guix のソースコードを Geiser のロードパスに追加する.
(with-eval-after-load 'geiser-guile
(add-to-list 'geiser-guile-load-path *guix-source-path*))
参考: The Perfect Setup (GNU Guix Reference Manual)
Geiser's REPL
Project 関数を projectile にする.
(customize-set-variable 'geiser-repl-current-project-function 'projectile-project-root)
basic editing commands for Emacs
インデントはスペースをデフォルトにする.
(customize-set-variable 'indent-tabs-mode nil)
Emacs のコンフィグで使用する変数を定義する.
sans-serif
には PlemolJP Console
を使用する.
(defvar *my-sans-serif-font* "PlemolJP Console")
serif
には Noto Sans Serif CJK JP
を使用する.
(defvar *my-serif-font* "Noto Sans Serif CJK JP")
Guix のソースコードのパスを定義する.
(defvar *guix-source-path* "~/repos/savannah/guix")
Emacs のコンフィグで使用する関数を定義する.
コマンドまたは関数を複数のフックにまとめて登録するためのユーティリティ関数.
(defun my-add-hooks (hooks func)
(mapc (lambda (hook) (add-hook hook func)) hooks))
ファイル保存時に不要なスペースを削除するかどうかを切り替えられるようにする関数.
(defun my-toggle-delete-trailing-whitespace-on-save ()
(interactive)
(cond ((member 'delete-trailing-whitespace before-save-hook)
(remove-hook 'before-save-hook 'delete-trailing-whitespace)
(message "delete-trailing-whitespace: OFF"))
(t
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(message "delete-trailing-whitespace: ON"))))
メインブラウザとして使用している Nyxt を設定する.
Nyxt の設定ファイルは, 下記の構成で記述されている.
<<ヘッダ行>>
<<Nyxt のバッファ設定>>
<<Nyxt の関数定義>>
<<Nyxt のコマンド定義>>
出力されたファイル: dotfiles/nyxt/.config/nyxt/init.lisp
Nyxt は Emacs のキーバインドで操作する.
(define-configuration buffer
((default-modes (append '(nyxt::emacs-mode nyxt::blocker-mode) %slot-default%))))
Nyxt で使用する独自コマンドを定義する.
某動画配信サービスの動画を mpv で再生するための URL を取得するコマンド.
(define-command-global copy-tver-streaming-url ()
"Copy TVer streaming URL from a buffer."
(let ((url (make-tver-streaming-url (document-model (current-buffer)))))
(if url
(progn (copy-to-clipboard url)
(echo "~a copied to clipboard." url))
(echo "Not found streaming url."))))
某動画配信サービスの動画を mpv で再生するコマンド.
(define-command-global play-movie-of-tver-on-mpv ()
"Make TVer streaming URL from a buffer and play the movie on mpv"
(let ((url (make-tver-streaming-url (document-model (current-buffer)))))
(if url
(progn
(echo "run command: ~a" (make-mpv-command url))
(uiop:run-program (make-mpv-command url)))
(echo "Not found streaming url."))))
某動画配信サービスの動画を 2 倍速で mpv で再生するコマンド.
(define-command-global play-movie-of-tver-on-mpv-x2 ()
"Make streaming URL from a buffer and play the movie on mpv (speed=2.0)"
(let ((url (make-tver-streaming-url (document-model (current-buffer)))))
(if url
(let ((command (format nil "~a --speed=2.0" (make-mpv-command url))))
(echo "run command: ~a" command)
(uiop:run-program command))
(echo "Not found streaming url."))))
定義したコマンド等で使用する関数を定義する.
バッファから URL を生成するユーティリティ関数.
(defun make-tver-streaming-url (dom)
"Make streaming URL from a buffer."
(let ((els (clss:select "[data-video-id]" dom)))
(when (> (length els) 0)
(let* ((el (aref els 0))
(account (plump:attribute el "data-account"))
(video-id (plump:attribute el "data-video-id")))
(format nil "http://players.brightcove.net/~a/default_default/index.html?videoId=~a" account video-id)))))
URL から mpv コマンドを生成するユーティリティ関数.
(defun make-mpv-command (url)
"Make mpv command from url."
(format nil "mpv ~a" url))
Nyxt のデバッグや拡張の開発のために, Common Lisp のまま使用できるようにする.
その際, 下記のパッケージが依存関係にないと、Common Lisp の Nyxt パッケージがロードできないため, Guix でインストールする.
(specification->package "gcc-toolchain")
(specification->package "gobject-introspection")
(specification->package "sbcl-iolib")
(specification->package "webkitgtk")
(specification->package "openssl")
SBCL を設定する.
<<ASDF の設定>>
<<QuickLisp の設定>>
<<CFFI の設定>>
出力されたファイル: dotfiles/.sbclrc
いつでも ASDF が使用できるようにする.
(require "asdf")
いつでも QuickLisp が使用できるようにする.
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
CFFI が Guix 上で C ライブラリを参照できるようにする.
(let ((guix-profile (format nil "~a/.guix-profile/lib/" (uiop:getenv "HOME"))))
(when (and (probe-file guix-profile)
(ignore-errors (asdf:load-system "cffi")))
(push guix-profile
(symbol-value (find-symbol (string '*foreign-library-directories*)
(find-package 'cffi))))))
フォントを設定する.
等幅フォントには PlemolJP Console を指定し、その他は Noto フォントを指定する.
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match>
<edit mode="prepend" name="family">
<string>Noto Sans CJK JP</string>
</edit>
</match>
<match>
<test compare="contains" name="lang">
<string>ja</string>
</test>
<edit mode="prepend" name="family">
<string>Noto Sans CJK JP</string>
</edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>sans-serif</string></test>
<!--<test qual="any" name="lang"><string>ja</string></test>-->
<edit name="family" mode="prepend" binding="strong"><string>Noto Sans CJK JP</string></edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>serif</string></test>
<edit name="family" mode="prepend" binding="strong"><string>Noto Serif CJK JP</string></edit>
</match>
<match target="pattern">
<test qual="any" name="family"><string>monospace</string></test>
<edit name="family" mode="prepend" binding="strong"><string>PlemolJP Console</string></edit>
</match>
<alias>
<family>serif</family>
<prefer>
<family>Noto Serif CJK JP</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans CJK JP</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>PlemolJP Console</family>
</prefer>
</alias>
</fontconfig>