なぜ今?
windmove を使わなければ問題も起きないので、放置してた。
調べるのも面倒だし。
2つのパッケージ
windmode.el
Emacs ビルドインパッケージ
画面分割したバッファを シフトキー+矢印キー
で自由自在に飛び回れる、超すごい、超便利、超凄いぃパッケージ。
org
Emacs ビルドインパッケージ
(最近追加。昔じゃなく最近)
心の中とweb検索では org-mode(オーグ)
と呼んでいる。オーガではないと思う。たぶんオーガナイザー。
色々出来る。
いやホントに、何でも出来るようになって、何が出来ないのかわからなくなっている。
こいつの箇条書きモードは、そんじゅそこらの箇条書きじゃないので無いと仕事を放棄するレベルで困る。
調べたら簡単に解決した
ffap.el
find file (or url) at point
こいつ機能しなくなって調べる事にした。
windmove.el が使えない以上に困る事態に、重い腰も軽くなった。
編集中エディタ画面でファイル名に該当する箇所にカーソルがある時に ファイルを開くコマンド
を使うと、このファイルですか?開いて良いですか?って聞いてくれる。
テニスボールを投げたら取ってきて見上げて尻尾ふるレトリーバのイメージ。ハスキーも好き。芝も良い。
んで、ちょうど直前に、orgファイルで編集中に、久しぶりに有効化していた windmove
機能にイラッとしたのよ。
ちょっと調べてみようかなと。
調査開始
さくっとコードを書いた
コマンドは、 キーバインド
と M-x コマンド
両方だめになってたた。
-
[C-x C-f]
キーバインド -
[M-x]
ffap
コマンド入力
(require 'ffap)
## ~~~~ このffapにカーソルがあればソースが開く
ミニバッファで入力待ちのプロンプトが ffap
のプロンプトだから、途中で何かに消されてるっぽい。
そう判断し、キーバインドそのものを調べる。
-
[C-h]
キーバインド ヘルププレフィックス起動 -
[k]
キーバインドを調べる -
[C-x C-f]
ファイル開くに割り当ててある機能を見たい - じゃ、ジャーン
表示されたヘルプでは、キーバインド機能は正常に割り当てられてますです。
この時点で面倒になって、調査の継続を断念しました!!
C-c C-f runs the command find-file-at-point (found in
leaf-key-override-global-map), which is an autoloaded interactive
native-compiled Lisp function in 'ffap.el'.
It is bound to `C-c` `C-f`, `C-x` `C-f`, <open> and `C-x f`.
It can also be invoked from the menu: File → Visit New File...
(find-file-at-point &optional `FILENAME` )
Find FILENAME, guessing a default from text around point.
If 'ffap-url-regexp' is not nil, the FILENAME may also be an URL.
With a prefix, this command behaves exactly like 'ffap-file-finder'.
If 'ffap-require-prefix' is set, the prefix meaning is reversed.
See also the variables 'ffap-dired-wildcards',
'ffap-url-unwrap-local', 'ffap-url-unwrap-remote',
'ffap-file-name-with-spaces', and the functions 'ffap-file-at-point'
and 'ffap-url-at-point'.
Probably introduced at or before Emacs version 28.1.
[back]
windmove.el
ヘルプからビルドインコマンドのソースを辿ると、圧縮ファイルがそのまま表示される。ちゃんと解凍されたテキストファイルだけど、ソースハイライトしてくれていない。
なので、ちょっと設定ファイルに追加。
auto-mode-alist設定用のorgファイルもあるんだけど、tree-sitterに干渉して頻繁にエラー出すので無効にしてある。
;; https://www.emacswiki.org/emacs/AutoModeAlist
.;; メジャーモードと拡張子の関連付け
;; tree-sitter-langs--init-major-mode-alist list の左側参照
(setq auto-mode-alist
(append '(
("\\.el.gz\\'" . emacs-lips-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode)
("\\.js[mx]?\\'" . javascript-mode)
("\\.pl\\'" . cperl-mode)
("\\.py\\'" . python-mode)
)
auto-mode-alist))
開いていたファイルを開き直すと、色分け表示された
[M-x revert-buffer]
でも行けるはず
% windmove.el.gz 36895 ELisp/l /usr/local/share/emacs/29.4.50/lisp/windmove.el.gz
関係ある箇所だけ抜粋
(defconst windmove--default-keybindings-type
`(choice (const :tag "Don't bind" nil)
(cons :tag "Bind using"
(choice (key-sequence :tag "Prefix")
(const :tag "No Prefix" nil))
(set :tag "Modifier"
:greedy t
;; See `(elisp) Keyboard Events'
(const :tag "Meta" meta)
(const :tag "Control" control)
(const :tag "Shift" shift)
(const :tag "Hyper" hyper)
(const :tag "Super" super)
(const :tag "Alt" alt))))
"Customization type for windmove modifiers.")
(defcustom windmove-default-keybindings nil
"Default keybindings for regular windmove commands.
See `windmove-default-keybindings' for more detail."
:set (lambda (sym val)
(windmove-install-defaults
(car val) (cdr val)
'((windmove-left left)
(windmove-right right)
(windmove-up up)
(windmove-down down))
(null val))
(set-default sym val))
:type windmove--default-keybindings-type
:version "28.1")
中略
;;;###autoload
(defun windmove-default-keybindings (&optional modifiers)
"Set up keybindings for `windmove'.
Keybindings are of the form MODIFIERS-{left,right,up,down},
where MODIFIERS is either a list of modifiers or a single modifier.
If MODIFIERS is `none', the keybindings will be directly bound to
the arrow keys.
Default value of MODIFIERS is `shift'."
(interactive)
(unless modifiers (setq modifiers 'shift))
(when (eq modifiers 'none) (setq modifiers nil))
(unless (listp modifiers) (setq modifiers (list modifiers)))
(windmove-install-defaults nil modifiers
'((windmove-left left)
(windmove-right right)
(windmove-up up)
(windmove-down down))))
(unless (listp modifiers)
で、リストを指定しても良いんだーと、なんとなく思った。
私、emacs-lisp使えないし読めないけど、ふんわり解るから。
やってみたら動いた
ALT
+ SHIFT
+ 矢印キー
コンビネーションに変更して org-mode の箇条書きも快適になった。
うむ
# -*- mode: org; 98-windmove.org --- summary -*- coding: utf-8 ; lexical-binding: t -*-
#+STARTUP: content indent
;; #+STARTUP: showall indent
* auto-insert date [2025-05-30 09:05:09 金曜日]
** Header
#+begin_src emacs-lisp
;;; 98-windmove.el --- summary -*- coding: utf-8 ; lexical-binding: t -*-
;;; Commentary:
;; commentary
;;; Code:
#+end_src
** 98-windmove
#+begin_src emacs-lisp
(straight-use-package 'windmove)
(use-package windmove
:config
;; (const :tag "Meta" meta)
;; (const :tag "Control" control)
;; (const :tag "Shift" shift)
;; (const :tag "Hyper" hyper)
;; (const :tag "Super" super)
;; (const :tag "Alt" alt))))
;; (windmove-default-keybindings) ; shifted arrow keys
;; (windmove-default-keybindings 'ctrl)
;; (windmove-default-keybindings 'hyper)
(windmove-default-keybindings '(meta shift))
(setq windmove-wrap-around t))
;; (add-hook 'org-mode-hook 'turn-off-windmove-mode)
#+end_src
* end of file
#+begin_src emacs-lisp
(provide '98-windmove)
;;; 98-windmove.el end
#+end_src
[2025-05-30 09:05:09 金曜日] >>> auto-insert
# 98-windmove.org end