4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

dired-toggle.elを開きっぱなしにする

Posted at

dired-toggle.elをVisual Studioのソリューションエクスプローラーのように使いたかったので、
ファイルを開いたあとにウィンドウが閉じないように設定した。

設定

dired-toggle.elのdired-toggle-action-find-fileを以下のように編集

dired-toggle.el
(defun dired-toggle-action-find-file ()
  "Custom item action under `dired-toggle-mode'."
  (interactive)
  (let* ((buffer (current-buffer))
         (file (dired-get-file-for-visit))
         (dir-p (file-directory-p file)))
    (if dir-p                           ;open a directory
        (dired-toggle-list-dir buffer (file-name-as-directory file))
      ;; open a file, and delete the referred window firstly
      (if (and (window-live-p dired-toggle-refwin)
               (not (window-minibuffer-p dired-toggle-refwin))
               ;; Some times `dired-toggle-refwin' maybe dired-toggle
               ;; window itself, so just ignore it.
               (not (equal (selected-window) dired-toggle-refwin)))
---		  (delete-window dired-toggle-refwin))
+++	      (select-window dired-toggle-refwin))
---	(dired-find-alternate-file)
+++	(find-file file)
    )))

余談

プラグインを直接書き換えるのはよろしくない感じがするが、
関数の振る舞い変更をinit.elに書き加えるやり方がいまいちわからんかったのでこうした。
うまいやり方あったら教えてください。

4
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?