LoginSignup
1
2

More than 5 years have passed since last update.

空になったファイルを尋ねずに自動削除

Last updated at Posted at 2018-09-25

Emacsで編集作業をしていて、不要になった覚書書メモとかを空にしたら尋ねることなく自動的に削除してくれるという地味で便利な emacs-lispです。下記の記事からの引用です。

設定

;; Automatic deletion for empty files (Valid in all modes)
(defun my:delete-file-if-no-contents ()
  (when (and (buffer-file-name (current-buffer))
             (= (point-min) (point-max)))
    (delete-file
     (buffer-file-name (current-buffer)))))
(if (not (memq 'my:delete-file-if-no-contents after-save-hook))
    (setq after-save-hook
          (cons 'my:delete-file-if-no-contents after-save-hook)))
1
2
0

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
1
2