SSブログ

Xの起動時に想定外の解像度が使用されることがある [Linux]

1. 発生事象


X の起動時に想定外の解像度が使用されることがある。

【詳細】
/etc/X11/xorg.conf の「Section "Screen"」の Modes で指定した解像度(1440x900) よりも低い解像度で起動されることがある。

【Xorg のバージョン】
・xorg-x11-server-Xorg-1.15.0-25.1.el6.centos.i686 on CentOS 6
・xserver-xorg 1:7.7+3~deb7u1 on Debian GNU/Linux 7

(補足)
・発生頻度は稀である。
・ほとんどの場合は、X を再起動すると改善される。


2. 対処方法


/etc/X11/xorg.conf の「Section "Monitor"」で 明示的に Modeline を指定する。

(例)
Section "Monitor"
  UseModes  "Modes0"
EndSection

Section "Modes"
  Identifier  "Modes0"
  # 1440x900 @ 60.00 Hz (GTF) hsync: 55.92 kHz; pclk: 106.47 MHz
  Modeline  "1440x900"  106.47 1440 1520 1672 1904  900 901 904 932  -HSync +Vsync
EndSection

3. 備考


上記の対応後 2 週間が経過するが、問題の事象は発生していない。



vim-7での文字コードの自動判別 [Linux]

久しぶりに vim を使用して日本語ファイルの編集を行ったところ、文字コード(エンコーディング)の自動判別が上手くできず、非常に使いづらく感じられた。
また、ある程度は設定で改善できるため、設定の変更を行った。
詳細は、以下の通りである。

1. 対象とする環境


(1) vim のバージョン


vim v7.2 および v7.3
・vim v7.2 on CentOS 6
・vim v7.2 on Debian GNU/Linux 6.0
・vim v7.3 on Debian GNU/Linux 7


(2) 文字コード(エンコーディング)の使用状況


・ファイルの新規作成では、基本的には Shift_JIS を使用する。
 (稀に EUC-JP を使用する。)
・EUC-JP で作成されているファイルを参照(稀に編集)することがある。
・UTF-8 および 7bit JIS で作成されているファイルを参照する頻度は低い。


2. 文字コードの自動判別の設定


~/.vimrc に下記の設定を追加する。

"#####################################################################
"# setting of encoding for multi-byte characters
"#####################################################################

"## detect input encoding
"## - if create new file in sjis, set sjis to fileencoding
set encoding=euc-jp
"set fileencoding=euc-jp
set fileencoding=sjis
if has('iconv')
  set fileencodings=iso-2022-jp,utf-8
  if &encoding ==# 'euc-jp'
    set fileencodings+=sjis
  else
    set fileencodings+=euc-jp
  endif
endif

"## specify input encoding
map -E :e ++enc=euc-jp
map -J :e ++enc=iso-2022-jp
map -S :e ++enc=sjis
map -U :e ++enc=utf-8

"## specify output encoding
map =E :set fileencoding=euc-jp
map =J :set fileencoding=iso-2022-jp
map =S :set fileencoding=sjis
map =U :set fileencoding=utf-8

3. 文字コードの自動判別が正しくない場合の対応


上記の設定において、文字コードが正しく判断できないことがある。
例えば、EUC-JP で作成されているファイルが Shift_JIS と判別されることがある。
(ファイルのデータが "テスト" の場合に発生する。)

このような場合には、文字コードを指定して当該ファイルを再読み込みする。
実施手順は、下記の通りである。

(1) 使用されている文字コードの判別


vim において、下記コマンドを実行する。
(nkf -g を実行して、当該ファイルの文字コードを判定する。)

:!nkf -g <file-name>


(2) 指定した文字コードでの再読み込み


vim において、map で設定されている下記のコマンドを実行する。

-E    … EUC-JP を指定の場合
-J    … ISO-2022-JP を指定の場合
-S    … Shift_JIS を指定の場合
-U    … UTF-8 を指定の場合


Mewのログ・ローテーションへの機能追加 [Linux]

Mew のログ・ローテーションへの機能追加を行った。
詳細は、下記の通りである。

1. 追加した機能


・ローテーション後のログ・ファイルの圧縮を可能にする(gzip/bzip2 を使用)。
・保存するログ・ファイルの世代数を指定可能にする。

【動作確認を行ったバージョン】
・Mew 5.2/6.3/6.4 (~/Mail/{Refilelog,Smtplog} で確認)


2. 使用方法


(1) mew-log-util.el の導入


load-path に設定されているディレクトリに、mew-log-util.el として保存する。

;;; -*- tab-width: 4 -*-
;;; mew-log-util.el --- utilities to rotate log file of Mew

;; This is for Mew-3.1 or later.

(require 'mew)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; variables
;;

(defvar mew-log-max-rotation 4
  "*A value for the max number of times of log rotation.
If the value is not more than 0, log files are not rotated.
If the value is less than 0, it is changed to 0 when used.

Rotated log file is the following.
- file name: file.<number>.<compress_suffix> or file.<number>
- number: 0 origin")

(defvar mew-log-compression t
  "*If non-nil, compress rotated log files.")

(defvar mew-log-compress-cmd "gzip"
  "*Command to use compress rotated log files.
Only 'gzip' and 'bzip2' are supported.")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; functions
;;

(defun mew-rotate-log-files-enhanced (file-name)
  "Rotate log files.
This is enhancement of mew-rotate-log-files.

The following features are supported.
- compression of rotated log files (use gzip or bzip2)
- ability to change the maximum number of rotated log file"
  (when (< mew-log-max-rotation 0)
    (setq mew-log-max-rotation 0))
  (let ((i (- mew-log-max-rotation 2))
        (file (expand-file-name file-name mew-conf-path))
        src dst (suffix ""))
    (when mew-log-compression
      ;; set suffix
      (if (equal mew-log-compress-cmd "bzip2")
          (setq suffix ".bz2")
        (setq suffix ".gz")))
    (when (and (file-exists-p file)
               (>= (mew-file-get-size file) mew-log-max-size))
      ;; rotate files
      (while (>= i 0)
        (setq src (format "%s.%d%s" file i suffix))
        (setq dst (format "%s.%d%s" file (1+ i) suffix))
        (when (file-exists-p src)
          (rename-file src dst t))
        (setq i (1- i)))
      (when (> mew-log-max-rotation 0)
        (setq dst (format "%s.0" file))
        (rename-file file dst)
        (when mew-log-compression
          (call-process mew-log-compress-cmd nil nil nil "-f" dst))))
    ;; delete old log files
    (mew-delete-old-log-files file-name)))

(defun mew-delete-old-log-files (file-name)
  "Delete old log files."
  (let (flist fname index offset offset2 (suffix ""))
    ;; get file list
    (setq flist
          (append
           (directory-files
            mew-conf-path nil
            (format "%s\\.[0-9]\\(\\|\\.gz\\|\\.bz2\\)$" file-name))
           (directory-files
            mew-conf-path nil
            (format "%s\\.[1-9][0-9]\\(\\|\\.gz\\|\\.bz2\\)$" file-name))))
    ;; delete old log file
    (while flist
      (setq fname (car (last flist)))
      (setq flist (butlast flist))
      ;; check whether old log file
      (setq offset2 (string-match "\\.\\(gz\\|bz2\\)$" fname))
      (when (null offset2)
        (setq offset2 (length fname)))
      (setq offset (string-match "\\." fname))
      (setq index (string-to-number (substring fname (1+ offset) offset2)))
      (if (>= index mew-log-max-rotation)
          (delete-file (expand-file-name fname mew-conf-path))
        (setq flist nil)))
    ;; get file list of old format log
    (cond
     (mew-log-compression
      (if (equal mew-log-compress-cmd "bzip2")
          (setq suffix ".gz")
        (setq suffix ".bz2"))
      (setq flist
            (append
             (directory-files
              mew-conf-path nil
              (format "%s\\.[0-9]+%s$" file-name suffix))
             (directory-files
              mew-conf-path nil
              (format "%s\\.[0-9]+$" file-name)))))
     (t
      (setq flist
            (directory-files
             mew-conf-path nil
             (format "%s\\.[0-9]+\\.\\(gz\\|bz2\\)$" file-name)))))
    ;; delete old format log file
    (while flist
      (setq fname (pop flist))
      (delete-file (expand-file-name fname mew-conf-path)))))

;; enable to enhance mew-rotate-log-files
(defalias 'mew-rotate-log-files 'mew-rotate-log-files-enhanced)

(provide 'mew-log-util)

;;; mew-log-util.el ends here


(2) ~/.mew.el への設定(例)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; setting to rotate log file of Mew
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; enable to enhance mew-rotate-log-files
(require 'mew-log-util)

;; set the max number of rotated log files (default: 4)
(setq mew-log-max-rotation 3)

;; set max size of log file in bytes (default: 512000)
(setq mew-log-max-size 100000)


・ローテーション後のログ・ファイルの圧縮を行わない場合
 (setq mew-log-compression nil)

・ローテーション後のログ・ファイルの圧縮に bzip2 を使用する場合
 (setq mew-log-compress-cmd "bzip2")



Firefox 32.0でのTab Mix Plus 0.4.1.4のタブバー表示の問題点 [Linux]

1. 発生事象


(1) タブバーの [スクロール可能にし、右にボタンを表示] が機能しない。


・設定直後は問題ないが、Firefox を再起動すると機能しない。
 ([表示] -> [タブバー] で設定。)

・Firefox 31.0 では発生しない。


2. 対処方法


下記のいずれかの方法で対応可能である。

(1) [スクロール可能にし、左右にボタンを表示] を代用する。


ハイライト表示のタイミングにやや問題はあるが、動作的には問題はない。


(2) 開発版 0.4.1.5pre.140913a2 に更新する。


下記の手順により、ダウンロード可能である。

https://addons.mozilla.org/ja/firefox/addon/tab-mix-plus/ にアクセスする。
・左下にある [開発チャンネル] をクリックする。
・[Add to Firefox] を右クリックし、[名前を付けてリンク先を保存] を選択する。



Mewのシングルパートでの転送 [Linux]

Mew のメール転送は、マルチパートでの転送となる(mew-summary-forward)。
このため、シングルパートで転送を行う関数を追加した。

【動作確認を行ったバージョン】
Mew 5.2/6.3/6.4

詳細は、下記の通りである。

1. ~/.mew.el への設定の追加
(defun mew-summary-forward-single (&optional no-prefix)
  "Forward this message to a third person. A new draft is prepared in
Draft mode and this message is automatically inserted.
If NO-PREFIX is nil, insert citation prefix and label."
  (interactive)
  ;; create multipart message (original message is attached)
  (mew-summary-forward)
  ;; delete entire attachments (same as main part of mew-attach-delete)
  (when (mew-attach-p)
    (goto-char (point-min))
    (goto-line (+ (mew-attach-line) 2))
    (mew-delete-directory-recursively (mew-attachdir))
    (setq mew-encode-syntax nil)
    (mew-attach-clear))
  ;; insert original message
  (if no-prefix
      (mew-draft-yank)
    (mew-draft-cite)))

(defalias 'mew-summary-forward-single-no-prefix
  '(lambda ()
     (interactive)
     (mew-summary-forward-single t))
  "This is an alias for (mew-summary-forward-single t).")

(define-key mew-summary-mode-map "\ef" 'mew-summary-forward-single)
(define-key mew-summary-mode-map "\eF" 'mew-summary-forward-single-no-prefix)

2. 使用方法


(1) Summary モードにおいて、メッセージを選択し、M-f または M-F を押下する。


・M-f: 引用符の挿入あり (mew-summary-forward-single の実行)
・M-F: 引用符の挿入なし (mew-summary-forward-single-no-prefix の実行)


(2) 宛先アドレスを指定し、送信する。



.fetchmailrcファイルの所在 [Linux]

fetchmail の設定ファイルである .fetchmailrc の所在についてまとめたものである。

【対象とする fetchmail のバージョン】
fetchmail-6.3.17-1.el6.i686 (on CentOS 6.5)
fetchmail 6.3.18-2 (on Debian 6.0)
fetchmail 6.3.21-4 (on Debian 7)

1. 標準のパス (デフォルト値)


~/.fetchmailrc


2. -f オプションで指定したパス


任意のパスを設定できる。


3. $FETCHMAILHOME/fetchmailrc


環境変数 FETCHMAILHOME にディレクトリを設定すると、$FETCHMAILHOME/fetchmailrc が使用される。

(注意)
ファイル名は、.fetchmailrc ではなく、fetchmailrc である。


4. $HOME_ETC/.fetchmailrc


環境変数 HOME_ETC にディレクトリを設定すると、$HOME_ETC/.fetchmailrc が使用される。

(注意)
環境変数 FETCHMAILHOME の設定の方が優先される。


5. シンボリック・リンクの使用


以前はシンボリック・リンクに未対応であったという記憶があるが、現在は対応している。
例えば、下記の設定を行うと、/x/y/.fetchmailrc を使用することができる。

% cd
% ln -s /x/y/.fetchmailrc


Emacsのmode-line-formatの設定 [Linux]

Emacs のモードラインで不要な情報を表示しないために、下記のような設定を行っていた。
(cond
 ((>= emacs-major-version 22)
  (setq-default mode-line-format
              '("-"
                mode-line-mule-info
                mode-line-modified
                mode-line-frame-identification
                mode-line-buffer-identification
                " "
                mode-line-position
                (vc-mode vc-mode)
                " "
                mode-line-modes
                (which-func-mode ("" which-func-format "-"))
                (global-mode-string ("-" global-mode-string))
                "-%-"))))

動作上の問題はないが、バッファのリサイズに関するヘルプ(上下矢印のアイコンの時に表示するヘルプ)が表示されないという事象が発生していた。また、当該機能の使用頻度が低いことから、特に気にしないでいた。

今回、デフォルト値と比較し直したところ、上記のヘルプを表示する部分が抜けていることがわかった。また、下記のように変更を行うことで、上記のヘルプが表示されるようになった。
(cond
 ((>= emacs-major-version 22)
  (defvar mode-line-resizing-help
    (concat
     "mouse-1: Select (drag to resize)\n"
     "mouse-2: Make current window occupy the whole frame\n"
     "mouse-3: Remove current window from display")
    "Help message that is displayed when mouse is pointing mode line.
This message is about resizing buffer.")
  (setq-default mode-line-format
                '(#("-" 0 1 (help-echo mode-line-resizing-help))
                  mode-line-mule-info
                  mode-line-modified
                  mode-line-frame-identification
                  mode-line-buffer-identification
                  #(" " 0 1 (help-echo mode-line-resizing-help))
                  mode-line-position
                  (vc-mode vc-mode)
                  #(" " 0 1 (help-echo mode-line-resizing-help))
                  mode-line-modes
                  (which-func-mode
                   ("" which-func-format
                    #("-" 0 1 (help-echo mode-line-resizing-help))))
                  (global-mode-string
                   (#("-" 0 1 (help-echo mode-line-resizing-help))
                    global-mode-string))
                  #("-%-" 0 3 (help-echo mode-line-resizing-help)))))


PostfixのSMTP リレーのSSL/TLS化 [Linux]

Postfix の SMTP リレーの SSL/TLS 化を行った。
また、リレー時の認証の設定については、既に完了しているものとし、説明を割愛する。

動作確認を行った環境は、下記の通りである。
【CentOS 6.5】
 ・postfix-2.6.6-6.el6_5.i686
 ・ca-certificates-2014.1.98-65.0.el6_5.noarch
 ・stunnel-4.29-3.el6_4.i686
【Debian 6.0】
 ・postfix 2.7.1-1+squeeze1
 ・ca-certificates 20090814+nmu3squeeze1
 ・stunnel4 3:4.29-1+squeeze1
【Debian 7】
 ・postfix 2.9.6-2
 ・ca-certificates 20130119
 ・stunnel4 3:4.53-1.1

実施手順は、下記の通りである。

1. STARTTLS を使用する場合


(1) TLS の有効化


main.cf に下記の設定を追加する。

smtp_tls_security_level = may    … Postfix 2.3 以降 (推奨される設定)
smtp_use_tls = yes               … Postfix 2.2 まで


Postfix 2.3 以降でも、smtp_use_tls はサポートされている。


(2) TLS のログ出力


main.cf に下記の設定を追加する。

smtp_tls_loglevel = 1


さらに詳細なログを出力したい場合には、2 を設定する(最大で 4 まで設定可能)。
また、ログが不要の場合には、0 を設定する。


(3) サーバー証明書の検証


main.cf に下記の設定を追加する。

smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt    … CentOS 6.5 の場合
smtp_tls_CApath = /etc/ssl/certs            … Debian 6.0、Debian 7 の場合


(4) リレー先の設定


main.cf の relayhost、または transport_maps にリレー先を設定する。
また、transport_maps を使用する場合には、postmap コマンドを実行し、lookup table を更新する。


(5) リレー先の認証用パスワードの設定 (ユーザー認証が必要な場合のみ実施)


/etc/postfix/sasl_passwd にリレー先のユーザーとパスワードを設定する。
その後、postmap コマンドを実行し、lookup table を更新する。


(6) Postfix の再起動


2. SSL/TLS (ただし、STARTTLS を除く) を使用する場合


(1) stunnel (Secure Tunnel) のインストール


・CentOS 6.5 の場合: stunnel-4.29-3.el6_4.i686
・Debian 6.0 の場合: stunnel4 3:4.29-1+squeeze1
・Debian 7 の場合: stunnel4 3:4.53-1.1


(2) stunnel の設定


下記の内容の /etc/stunnel/smtps.conf を作成する。

CAfile = /etc/pki/tls/certs/ca-bundle.crt    … (注1)
verify = 2                                   … サーバー証明書の検証の有無
debug = 6                                    … ログの出力レベル

[smtps]                                      … 識別可能な値を設定
accept = <local-port>                  … stunnel との接続用ポート (注2)
client = yes                                 … client mode での実行
connect = <relay-server>:465           … 実際のリレー先 (注3)


(注1) サーバー証明書の検証に使用する情報の所在を指定する。
   (Debian の場合には、CApath = /etc/ssl/certs とする。)
(注2) stunnel との接続に使用するポートを指定する。
   (例) accept = 10465
(注3) SMTP リレーのリレー先(サーバーとポート)を指定する。


(3) Postfix の設定


(a) リレー先の設定


リレー先として、[127.0.0.1]:<local-port> を設定する。
(例) 100465 番ポートの場合には、[127.0.0.1]:10465 と設定する。

main.cf の relayhost、または transport_maps に設定する。
また、transport_maps を使用する場合には、postmap コマンドを実行し、lookup table を更新する。


(b) リレー先の認証用パスワードの設定 (ユーザー認証が必要な場合のみ実施)


sasl_passwd に [127.0.0.1]:<local-port> のユーザーとパスワードを設定する。
その後、postmap コマンドを実行し、lookup table を更新する。

上記の設定値として、<relay-server>:465 のユーザーとパスワードを使用する。
([127.0.0.1]:<local-port> のユーザー/パスワードとして設定する。)


(4) Postfix の再起動

(5) 使用方法


(a) stunnel の起動

# /usr/bin/stunnel /etc/stunnel/smtps.conf     … CentOS 6.5 の場合
# /usr/bin/stunnel4 /etc/stunnel/smtps.conf    … Debian 7、Debian 6.0 の場合


(b) メールの送信


送信されたメールは、下記のようにリレーされる。

Postfix → 127.0.0.1:<local-port> → <relay-server>:465


(c) stunnel の停止


stunnel を停止する場合には、下記のコマンドを実行する。
(通常の使用では、停止する必要はない。)

# killall stunnel     … CentOS 6.5 の場合
# killall stunnel4    … Debian 7、Debian 6.0 の場合


Emacsでのman pageの参照 [Linux]

Emacs 上での man page の参照のため、環境の整備を行った。
(Interactive Shell 上での man コマンドの実行を除く。)

動作確認を行った環境は、下記の通りである。

・Emacs 23.4.1 on Debian/GNU Linux 7
・Emacs 23.2.1 on Debian/GNU Linux 6.0
・Emacs 23.1.1 on CentOS 6

1. man.el


使用するロケールにより、参照する man page を選択できる。
(ロケールは、環境変数 LC_ALL、LANG 等で指定。)
よって、下記のような設定を行った。

(1) ロケールを指定して関数 man を実行する関数の追加


・関数 man-en および man-ja の追加
 (ローカル変数 process-environment にロケール設定を追加し、関数 man を実行)
・変数 Man-cooked-hook への処理の追加
 (バッファ名に言語の種類(en/jp)を追加)

man-setup.el を作成し、(require 'man-setup) で使用できるように設定。
詳細は、備考に記載。


(2) ~/.emacs への設定

;;
;; man.el (browse UNIX manual pages)
;;
(require 'man-setup)                                                  … (a)
;; enable to display Japanese man page with UTF-8 locale
;; - patch for man.el in Emacs 23.2.1
(when (and                                                            … (b)
       (string< emacs-version "23.3")
       (not (string< emacs-version "23.2")))
  (when (and locale-coding-system
             (string= (coding-system-category locale-coding-system)
                      "coding-category-utf-8"))
    (setq Man-switches "-Tutf8")))


(a) Emacs プロセスのロケールが ja_JP.eucJP 以外の日本語ロケールの場合


変数 Man-x-locale-ja に該当するロケールを設定する必要がある。
例えば、ja_JP.UTF-8 の場合には、下記の設定を追加する。

(setq Man-x-locale-ja "ja_JP.UTF-8")


(b) Emacs 23.2.1 と ja_JP.UTF-8 ロケールとの組み合わせの場合


man page が見つけられない状態となってしまうため、変数 Man-switches で utf8 を指定している。


(3) その他


Emacs 23.2 の man.el では、-k 等のオプションの指定ができない。

オプションを使用する場合には、Emacs 23.4 の man.el に置き換える。
(/usr/share/emacs/23.2/lisp/man.elc より先にロードされるパスに置く。)
下記 URL から Emacs のソースファイルのダウンロードが可能である。

・http://ftp.jaist.ac.jp/pub/GNU/emacs/

% diff man.el-23.4 man.el-23.2
4c4
< ;;   2006, 2007, 2008, 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
---
> ;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
312c312
< ;; references to manpages.
---
> ;; refernces to manpages.
757,759d756
<    ((equal string "-k")
<     ;; Let SPC (minibuffer-complete-word) insert the space.
<     (complete-with-action action '("-k ") string pred))

2. woman.el


変数 woman-locale に日本語のロケールを設定することにより、英語と日本語の man page を選択表示できる。
よって、下記のような設定を行った。

(1) ~/.emacs への設定

;;
;; woman.el (browse UN*X manual pages `wo (without) man')
;;
(setq woman-locale "ja_JP.eucJP")                            … (a)
(setq woman-use-own-frame nil)                               … (b)
(add-hook 'woman-pre-format-hook 'woman-monochrome-faces)    … (c)


(a) ja_JP.UTF-8 を指定することも可能
(b) 専用のフレームを作成しないための設定
(c) モノクロ表示(色をつけない)ための設定


3. man page 用のバッファの一覧


list-buffers (C-x C-b) の実行結果がバッファ名でソートされるように設定する。
・man(man-en、man-ja) の実行結果 … Man モードのバッファ
・woman の実行結果 … WoMan モードのバッファ

(1) ~/.emacs への追加

(setq Buffer-menu-sort-column 2) ;; sort by buffer names

[備考]


Emacs 23のバッファ一覧のソート [Linux]

Emacs において、list-buffers (C-x C-b) を実行するとバッファの一覧が取得できる。
しかし、バッファ名でソートされていないため、少々不便を感じていた。

(例) M-x man で複数の manual page を参照する時のバッファ(manual page) の選択時

ソースを参照したところ、指定したカラムの値でソートできることがわかった。
(Emacs 22 でも同様。また、Emacs 21 では該当する機能が存在しない。)
詳細は、下記の通りである。

1. 自動実行


~/.emacs に下記のような設定を追加することで、自動的にソートされるようになる。

(例) バッファ名でのソート

;; enable to sort by buffer names in Buffer-menu-mode
(setq Buffer-menu-sort-column 2)

2. 手動実行


"*Buffer List*" バッファにおいて、下記のいずれかの手順を実施する。

(1) タイトル行の当該カラムをマウスの左ボタン(または中ボタン)でクリック


Buffer-menu-sort-by-column が実行される。

(例) "Buffer" をクリックすると、バッファ名でソートされる。


(2) Buffer-menu-sort の実行


(例) バッファ名でのソート

(Buffer-menu-sort 2) ;; sort by buffer names

3. 補足


(1) バッファ名の表示幅の変更


(例) 表示幅の拡張

(setq Buffer-menu-buffer+size-width 34) ;; default is 26


(2) バッファ一覧の更新


list-buffers の再実行により一覧が更新される。
~/.emacs に下記の設定を追加すれば、U の押下により更新可能となる。

(add-hook 'Buffer-menu-mode-hook
          '(lambda ()
             (define-key Buffer-menu-mode-map "U" 'list-buffers)))


この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。