conf-dired.el 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. (provide 'conf-dired)
  2. (require 'dired+)
  3. ;; dired-x load and setup
  4. (require 'dired-x)
  5. (setq-default dired-omit-files-p t)
  6. (setq dired-omit-files "^\\.?#\\|^\\.[^\\.]+")
  7. ;(setq dired-omit-files "^\\.?#\\|^\\.")
  8. ;; Dired mode init
  9. (require 'dired-details+)
  10. (defun dired-narrow-window ()
  11. "make the current dired mode window 30 chars wide"
  12. (interactive)
  13. (adjust-window-trailing-edge (selected-window) (- 30 (window-width)) t))
  14. (add-hook 'dired-mode-hook
  15. '(lambda()
  16. (visual-line-mode 0) ;; unwrap lines.
  17. (linum-mode 0) ;; turn off line numbers.
  18. (auto-revert-mode) ;; auto-refresh dired
  19. (define-key dired-mode-map [mouse-3] 'dired-maybe-insert-subdir)
  20. (define-key dired-mode-map (kbd "C-{") 'dired-narrow-window)
  21. )
  22. )
  23. ;; shorter dired output
  24. (require 'dired-details)
  25. (setq-default dired-details-hidden-string "--- ")
  26. (dired-details-install)
  27. ;; Move files between split panes
  28. (setq dired-dwim-target t)
  29. ;; Reload dired after making changes
  30. (--each '(dired-do-rename
  31. dired-do-copy
  32. dired-create-directory
  33. wdired-abort-changes)
  34. (eval `(defadvice ,it (after revert-buffer activate)
  35. (revert-buffer))))
  36. ;; make end-of-buffer and beginning-of-buffer behave properly
  37. (defun dired-back-to-top ()
  38. (interactive)
  39. (beginning-of-buffer)
  40. (next-line 2))
  41. (defun dired-jump-to-bottom ()
  42. (interactive)
  43. (end-of-buffer)
  44. (next-line -1))
  45. (add-hook 'dired-mode-hook
  46. (lambda ()
  47. (define-key dired-mode-map
  48. (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)
  49. (define-key dired-mode-map
  50. (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)))
  51. (eval-after-load 'dired '(progn (require 'single-dired)))
  52. ;;; Load packages
  53. (require 'dired-details+)
  54. (add-hook 'dired-load-hook
  55. (lambda () (require 'dired-sort-menu)))
  56. ;;; fsdired: sort files to go to different places in dired
  57. (require 'fsdired)
  58. ;; -----------------------------------------------------------------------------
  59. ;;; Set the ls options
  60. ;; Set the ls options to put directories first
  61. ;; ideally by adding --group-directories-first
  62. ;; but long options are not currently supported so ...
  63. (setq dired-listing-switches "-al")
  64. ;; ... and hack the dired-insert-directory function to add the
  65. ;; --group-directories-first option:
  66. (defadvice dired-insert-directory
  67. (before my-dired-insert-directory
  68. (dir switches &optional file-list wildcard hdr))
  69. (setq switches (concat switches " --group-directories-first")))
  70. (ad-activate 'dired-insert-directory)
  71. ;; Set the face for executable files
  72. (defface diredp-executable-file-name
  73. '((t (:foreground "Red" :weight bold)))
  74. "*Face used for names of executable files in dired buffers."
  75. :group 'Dired-Plus :group 'font-lock-highlighting-faces)
  76. (defvar diredp-executable-file-name 'diredp-executable-file-name)
  77. (setq diredp-font-lock-keywords-1
  78. (append
  79. diredp-font-lock-keywords-1
  80. (list
  81. (list dired-re-exe
  82. `(".+"
  83. (dired-move-to-filename)
  84. nil
  85. (0 diredp-executable-file-name t))))))
  86. ;; -----------------------------------------------------------------------------
  87. ;;; Better cursor movement functions
  88. (defun dired-next-file-line ()
  89. "Move to the next dired line that have a file or directory name on it."
  90. (interactive)
  91. (call-interactively 'dired-next-line)
  92. (if (eobp)
  93. (dired-previous-line 1)))
  94. (defun dired-previous-file-line ()
  95. "Move to the previous dired line that have a file or directory name on it."
  96. (interactive)
  97. (call-interactively 'dired-previous-line)
  98. (if (not (dired-move-to-filename))
  99. (dired-next-line 1)))
  100. ;; Set buffer-local variables
  101. (defun my-dired-mode-hook ()
  102. ;; hl-line - highlight current-line
  103. (hl-line-mode)
  104. ;; Use the same buffer for visited directories
  105. (toggle-diredp-find-file-reuse-dir 1)
  106. ;; Set omit-mode by default
  107. (dired-omit-mode 1)
  108. ;; Ensure that the byte-compiled version picks-up the dired+ fonts
  109. (set (make-local-variable 'font-lock-defaults)
  110. (cons '(dired-font-lock-keywords diredp-font-lock-keywords-1)
  111. (cdr font-lock-defaults)))
  112. ;; Switch-on font-lock
  113. (font-lock-mode 1)
  114. )
  115. (add-hook 'dired-mode-hook 'my-dired-mode-hook)
  116. ;; -----------------------------------------------------------------------------
  117. ;;; Image-dired
  118. ;; Set the directory for the thumbnail images generated by image-dired
  119. (setq image-dired-dir (expand-file-name "~/.thumbnails/emacs"))
  120. ;;Direx
  121. (require 'direx-project)
  122. (setq direx:leaf-icon " " direx:open-icon "▾ " direx:closed-icon "▸ ")