conf-file-management.el 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. (provide 'conf-file-management)
  2. ; autosave settings
  3. (setq auto-save-list-file-prefix nil)
  4. (setq make-backup-files nil)
  5. ; recentf - save history of recently visited files
  6. (require 'recentf)
  7. (run-with-idle-timer (* 5 60) t 'recentf-save-list)
  8. (setq recentf-auto-cleanup 'never)
  9. (setq recentf-max-saved-items 1000)
  10. ; saveplace - save position in files (http://whattheemacsd.com/init.el-03.html)
  11. (require 'saveplace)
  12. (setq-default save-place t)
  13. (setq save-place-file (in-emacs-d ".places"))
  14. ; rename buffer and file
  15. (defun my/rename-current-buffer-file ()
  16. "Renames current buffer and file it is visiting."
  17. (interactive)
  18. (let ((name (buffer-name))
  19. (filename (buffer-file-name)))
  20. (if (not (and filename (file-exists-p filename)))
  21. (error "Buffer '%s' is not visiting a file!" name)
  22. (let ((new-name (read-file-name "New name: " filename)))
  23. (if (get-buffer new-name)
  24. (error "A buffer named '%s' already exists!" new-name)
  25. (rename-file filename new-name 1)
  26. (rename-buffer new-name)
  27. (set-visited-file-name new-name)
  28. (set-buffer-modified-p nil)
  29. (message "File '%s' successfully renamed to '%s'"
  30. name (file-name-nondirectory new-name)))))))
  31. (global-set-key (kbd "C-x C-r") 'my/rename-current-buffer-file)
  32. ; find-files-in-project
  33. (require 'find-file-in-project)
  34. ; Recognize zsh files
  35. (add-to-list 'auto-mode-alist '("\\.sh\\'" . shell-script-mode))