blob: f7617b8e262e62ef5ee84af6cc66a3115f9f8b08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
;;; ravi-init-files.el --- file-handling
;; Copyright (C) 2013
;; Author: <ravi@nero.lan>
;; Keywords:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; File handling
;;; Code:
(setq auto-save-list-file-prefix (ravi/past-file "auto-save-list/.saves-"))
(setq delete-auto-save-files t)
(setq dired-listing-switches "-Flag")
(setq completion-ignored-extensions
(append completion-ignored-extensions
(quote (".bak" ".#*#" ".ps" ".pdf"))))
;; Auto refresh buffers
(global-auto-revert-mode 1)
;; Also auto refresh dired, but be quiet about it
(setq global-auto-revert-non-file-buffers t)
(setq global-auto-revert-ignore-modes '(TeX-output-mode))
(setq auto-revert-verbose nil)
;; Transparently open compressed files
(auto-compression-mode t)
;; UTF-8 please
(setq locale-coding-system 'utf-8) ; pretty
(set-terminal-coding-system 'utf-8) ; pretty
(set-keyboard-coding-system 'utf-8) ; pretty
(set-selection-coding-system 'utf-8) ; please
(prefer-coding-system 'utf-8) ; with sugar on top
(setq history-length 100)
(setq savehist-file (ravi/emacs-file "past/history"))
(savehist-mode 1)
(setq history-delete-duplicates t)
(require 'saveplace)
(setq-default save-place t)
(setq save-place-file (ravi/past-file "places"))
(use-package recentf
:init
(progn
(setq recentf-save-file (ravi/past-file "recentf"))
(setq recentf-max-saved-items 100) ;; just 20 is too recent
)
:config
(progn
(add-to-list 'recentf-exclude "/COMMIT_EDITMSG$")
(add-to-list 'recentf-exclude "/kmail[[:alnum:]]*\\.tmp$")
(add-to-list 'recentf-exclude "/elpa/.*/*-autoloads.el$")
(recentf-mode +1)
))
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward)
(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
(setq minibuffer-completion-confirm t)
(setq find-file-confirm-nonexistent-file t)
(setq find-file-visit-truename t)
;; Automatic loading of file trees
(defun ravi-check-dir-accessible-p (name)
"Check whether NAME is accessible as a directory"
(let* ((topname (file-name-as-directory name))
(name-exists (and (file-exists-p topname)
(file-directory-p topname)
(file-accessible-directory-p topname)
topname)))
name-exists
))
(defun ravi-filecache-add-tree (root recursive simple)
"Add list of directories to filecache for easy opening.
ROOT is the root of the tree to be added. RECURSIVE is a list of
relative paths whose subdirectories are added recursively, while
relative paths in SIMPLE are added non-recursively. If a path does
not exist, it is not added to the filecache."
(let ((topname (ravi-check-dir-accessible-p root))
(dirval nil))
(when topname
(dolist (dir recursive)
(setq dirval (ravi-check-dir-accessible-p
(expand-file-name dir topname)))
(and dirval
(file-cache-add-directory-recursively dirval)))
(dolist (dir simple)
(setq dirval (ravi-check-dir-accessible-p
(expand-file-name dir topname)))
(and dirval
(file-cache-add-directory dirval)))
)))
(use-package tramp
:config
(progn
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(setq tramp-use-ssh-controlmaster-options nil)
(setq tramp-persistency-file-name (ravi/past-file "tramp"))))
;; Write backup files to own directory
(make-directory (ravi/past-file "backups/") t)
(setq backup-by-copying t)
(setq backup-directory-alist
`(("." . ,(ravi/past-file "backups/"))
(,tramp-file-name-regexp nil)))
;; Make backups of files, even when they're in version control
(setq vc-make-backup-files t)
;; Git/svn/etc. projects
(use-package projectile
:init
(progn
(use-package pkg-info)
(setq projectile-known-projects-file
(ravi/past-file "projectile-bookmarks.eld"))
)
:bind-keymap ("C-c p" . projectile-command-map)
:bind(("C-<f2>" . projectile-find-file-dwim))
:config
(progn
(projectile-global-mode)
(bind-key "C-<f2>" 'projectile-find-file-dwim)
(if (and (boundp 'ravi/use-selection-system)
(equal ravi/use-selection-system 'helm))
(progn
(setq projectile-completion-system 'helm)
(use-package helm-projectile
:config
(progn
(helm-projectile-on)
(bind-key "M-s M-g" 'helm-projectile-ag))))
(bind-key "M-s M-g" 'projectile-ag)))
:diminish projectile-mode)
;; Use emacsclient as external editor for kmail
(add-to-list 'auto-mode-alist
(cons (concat temporary-file-directory ".*/kmail[[:alnum:]]*.tmp\\'") 'message-mode))
(setq gnus-message-highlight-citation t)
(provide 'ravi-init-files)
;;; ravi-init-files.el ends here
|