「Windowsパス と UNCパス を使えるようにするための設定」の編集履歴(バックアップ)一覧はこちら
追加された行は緑色になります。
削除された行は赤色になります。
&bold(){■ Cygwin版 Emacs 特有の設定}
----
&bold(){【お知らせ】}
----
&bold(){<2018/03/12 追記>}
WSL版はこちらを参照してください。
・[[Windowsパス と UNCパス を使えるようにするための設定(WSL 設定編)]]
&bold(){<2018/03/12 追記>}
windows-path-convert-file-name 関数に対するアドバイスを簡素化しました。
&bold(){<2018/03/09 追記>}
UNC パスの貼り付けを既存のパスの後ろに追加しても動作するように改善しました。
&bold(){【本題】}
----
Cygwin版 Emacs(gnupack の場合、12.00 以降)で、Windowsパス と UNCパス を使えるようにするための設定です。
最初に以下をダウンロードし、~/.emacs.d/site-lisp 等の load 対象となるディレクトリ配下にサブディレクトリを作成し格納してください。
・http://emacswiki.org/emacs/windows-path.el
・http://emacswiki.org/emacs/cygwin-mount.el
次に以下の設定を有効にしてください。
1) Windowsパス を使えるようにするは以下の設定を行って下さい。(基本設定)
(require 'cl-lib)
(require 'windows-path)
;; (cygwin-mount-get-cygdrive-prefix) の実行結果が、mount --show-cygdrive-prefix で表示される
;; cygdrive の prefix と異なる場合、cygwin-mount-get-cygdrive-prefix の置き換えをしてから
;; windows-path-activate を実行する。(gnupack の場合は "/" を返すようにする必要がある。)
(cl-letf (((symbol-function 'cygwin-mount-get-cygdrive-prefix)
(lambda () "/"))) ; mount --show-cygdrive-prefix で表示される prefix を / で終わらせて指定する
(windows-path-activate))
2) UNCパス を使えるようにするは以下の設定を行って下さい。(拡張設定(必要な場合))
(defconst windows-path-style3-regexp "\\`\\(.*/\\)?\\(\\\\\\\\.*\\)")
(advice-add 'windows-path-convert-file-name
:after (lambda (&rest args)
(let ((name (nth 0 args)))
(cond ((string-match windows-path-style3-regexp name)
(cygwin-convert-file-name-from-windows (match-string 2 name)))
(t name)))))
(add-to-list 'file-name-handler-alist
(cons windows-path-style3-regexp
'windows-path-map-drive-hook-function))
※ dired での UNCパス の入力は、コピペによる方法をお勧めします。
※ 接続先のサーバが認証を必要とする場合、事前に Windows からの操作で認証を通してください。その際の認証画面で「資格情報を記憶する」にチェックを入れると、次回からの認証を省略する(自動で行う)ことができます。
3) find-file コマンド等で Windows パスや UNC パスを入力し、正しく変換されることを確認してください。コピペでのパス入力をお薦めします。
4) 以下の設定を行うことにより、Windows で作成したショートカットをシンボリックリンクの様に表示し、辿ることができるようになります。お試しください。
・[[Windows ショートカットを dired と連携して使うための設定]]
5) dired で開いているディレクトリの Windowsパス をクリップボードに取り込むには以下のキー設定をご利用ください。
(define-key dired-mode-map (kbd "C-c w")
(lambda ()
(interactive)
(shell-command-to-string
(format "cygpath -w %s | tr -d '\\n' > /dev/clipboard"
(shell-quote-argument (dired-current-directory))))))
----
<変更履歴>
・2015/05/14 このページを作成した。
・2015/05/16 全面的に見直しを行った。
・2015/05/17 windows-path-convert-file-name アドバイスの見直しを行った。
・2015/06/03 dired で開いているディレクトリの Windowsパス をクリップボードに取り込むコマンドを作成した。
・2015/06/27 windows-path-activate 実行時の cygwin-mount-get-cygdrive-prefix の置き換え方法を変更した。
・2015/09/09 advice を Emacs-24.4 以降の書式に見直した。
・2018/03/09 UNC パスの貼り付けを既存のパスの後ろに追加しても動作するように改善した。
・2018/03/12 windows-path-convert-file-name 関数に対するアドバイスを簡素化した。
----
#javascript(){{
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-40267130-1', 'atwiki.jp');
ga('send', 'pageview');
</script>
}}
&bold(){■ Cygwin版 Emacs 特有の設定}
----
&bold(){【お知らせ】}
----
&bold(){<2018/03/12 追記>}
WSL版はこちらを参照してください。
・[[Windowsパス と UNCパス を使えるようにするための設定(WSL 設定編)]]
&bold(){<2018/03/12 追記>}
windows-path-convert-file-name 関数に対するアドバイスを簡素化しました。
&bold(){<2018/03/09 追記>}
UNC パスの貼り付けを既存のパスの後ろに追加しても動作するように改善しました。
&bold(){【本題】}
----
Cygwin版 Emacs(gnupack の場合、12.00 以降)で、Windowsパス と UNCパス を使えるようにするための設定です。
最初に次のファイルをダウンロードし、~/.emacs.d/site-lisp 等の load 対象となるディレクトリ配下にサブディレクトリを作成し格納してください。
・http://emacswiki.org/emacs/windows-path.el
・http://emacswiki.org/emacs/cygwin-mount.el
次に以下の設定を有効にしてください。
1) Windowsパス を使えるようにするは次の設定を行って下さい。(基本設定)
(require 'cl-lib)
(require 'windows-path)
;; (cygwin-mount-get-cygdrive-prefix) の実行結果が、mount --show-cygdrive-prefix で表示される
;; cygdrive の prefix と異なる場合、cygwin-mount-get-cygdrive-prefix の置き換えをしてから
;; windows-path-activate を実行する。(gnupack の場合は "/" を返すようにする必要がある。)
(cl-letf (((symbol-function 'cygwin-mount-get-cygdrive-prefix)
(lambda () "/"))) ; mount --show-cygdrive-prefix で表示される prefix を / で終わらせて指定する
(windows-path-activate))
2) UNCパス を使えるようにするは次の設定を行って下さい。(拡張設定(必要な場合))
(defconst windows-path-style3-regexp "\\`\\(.*/\\)?\\(\\\\\\\\.*\\)")
(advice-add 'windows-path-convert-file-name
:after (lambda (&rest args)
(let ((name (nth 0 args)))
(cond ((string-match windows-path-style3-regexp name)
(cygwin-convert-file-name-from-windows (match-string 2 name)))
(t name)))))
(add-to-list 'file-name-handler-alist
(cons windows-path-style3-regexp
'windows-path-map-drive-hook-function))
※ dired での UNCパス の入力は、コピペによる方法をお勧めします。
※ 接続先のサーバが認証を必要とする場合、事前に Windows からの操作で認証を通してください。その際の認証画面で「資格情報を記憶する」にチェックを入れると、次回からの認証を省略する(自動で行う)ことができます。
3) find-file コマンド等で Windows パスや UNC パスを入力し、正しく変換されることを確認してください。コピペでのパス入力をお薦めします。
4) 次の設定を行うことにより、Windows で作成したショートカットをシンボリックリンクの様に表示し、辿ることができるようになります。お試しください。
・[[Windows ショートカットを dired と連携して使うための設定]]
5) dired で開いているディレクトリの Windowsパス をクリップボードに取り込むには次のキー設定をご利用ください。
(define-key dired-mode-map (kbd "C-c w")
(lambda ()
(interactive)
(shell-command-to-string
(format "cygpath -w %s | tr -d '\\n' > /dev/clipboard"
(shell-quote-argument (dired-current-directory))))))
----
<変更履歴>
・2015/05/14 このページを作成した。
・2015/05/16 全面的に見直しを行った。
・2015/05/17 windows-path-convert-file-name アドバイスの見直しを行った。
・2015/06/03 dired で開いているディレクトリの Windowsパス をクリップボードに取り込むコマンドを作成した。
・2015/06/27 windows-path-activate 実行時の cygwin-mount-get-cygdrive-prefix の置き換え方法を変更した。
・2015/09/09 advice を Emacs-24.4 以降の書式に見直した。
・2018/03/09 UNC パスの貼り付けを既存のパスの後ろに追加しても動作するように改善した。
・2018/03/12 windows-path-convert-file-name 関数に対するアドバイスを簡素化した。
----
#javascript(){{
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-40267130-1', 'atwiki.jp');
ga('send', 'pageview');
</script>
}}