次のコードを使用してサーバーバッファの動作を自動的に変更します。特にFirefox拡張機能It's All Textで使用します。その拡張子では、バッファにはドメイン名に基づいて名前が付けられているので、ファイルの名前と一致するようにstring-match
を使用して適用するルールを特定することができます。
(defun server-edit-presets()
(cond
;; When editing mail, set the goal-column to 72.
((string-match "mail\\.google\\.com\\.[0-9a-z]+\\.txt" (buffer-name))
(longlines-mode-off)
(auto-fill-mode 1)
(set-fill-column 72)
(save-excursion
;; Don't know if this is necessary, but it seems to help.
(set-buffer (buffer-name))
(goto-char (point-min))
;; Replace non-breaking strange space characters
(while (search-forward (char-to-string 160) nil t)
(replace-match " "))))))
(add-hook 'server-visit-hook 'server-edit-presets)
(add-hook 'server-visit-hook '(lambda() (longlines-mode 1)))
明らかに、このフックは、emacsclientにファイルリストが渡された場合にのみ呼び出されます。ファイルを指定せずに呼び出された場合、フックは実行されません。これは迷惑です。 – FixMaker