Lotsa changes
authorJoerg Jaspert <joerg@ganneff.de>
Wed, 24 Apr 2013 12:42:28 +0000 (14:42 +0200)
committerJoerg Jaspert <joerg@ganneff.de>
Wed, 24 Apr 2013 12:42:28 +0000 (14:42 +0200)
.emacs.d/config/emacs.org

index 1a2ac8b..6609c0e 100644 (file)
@@ -325,7 +325,7 @@ for new users. Enable them.
 I've tried various different fonts and while I like the Terminus font
 most for my shells, in Emacs Inconsolata clearly wins.
 #+BEGIN_SRC emacs-lisp
-(set-default-font "Inconsolata-14")
+  (set-default-font "Inconsolata-14")
 #+END_SRC
 
 And I always liked dark backgrounds with colors setup for them. So I
@@ -413,7 +413,7 @@ modeline in red as soon as you are over the defined limit.
   (column-number-mode 1)
   (size-indication-mode 1)
   (setq modelinepos-column-limit 72)
-  
+
   (require 'modeline-posn)
   (set-face-foreground 'mode-line "grey20")
   (set-face-background 'mode-line "grey70")
@@ -449,21 +449,21 @@ character(s).
         (sh-mode . " Σ")
         (nxhtml-mode . "nx"))
       "Alist for `clean-mode-line'.
-     
+
     When you add a new element to the alist, keep in mind that you
     must pass the correct minor/major mode symbol and a string you
     want to use in the modeline *in lieu of* the original.
-  
+
     Want some symbols? Go:
-  
+
     ;ςερτζθιοπασδφγηξκλυχψωβνμ
     :ΣΕΡΤΖΘΙΟΠΑΣΔΦΓΗΞΚΛΥΧΨΩΒΝΜ
     @ł€¶ŧ←↓→øþ¨~æſðđŋħ̣ĸł˝^`|»«¢„“”µ·…
     ☃⌕☥
   ")
-    
+
     (add-hook 'after-change-major-mode-hook 'clean-mode-line)
-  
+
 #+END_SRC
 Unfortunately icicles breaks this with the way it adds/removes itself,
 so take it our for now...
@@ -480,7 +480,7 @@ read in emacs.
 
 *** Shell
 [2013-04-23 Tue 16:43]
-Shell. zsh in my case. 
+Shell. zsh in my case.
 #+BEGIN_SRC emacs-lisp
   (setq shell-file-name "zsh")
   (setq shell-command-switch "-c")
@@ -494,7 +494,7 @@ Shell. zsh in my case.
   (setq comint-completion-autolist t)        ; show completion list when ambiguous
   (setq comint-input-ignoredups t)           ; no duplicates in command history
   (setq comint-completion-addsuffix t)       ; insert space/slash after file completion
+
 #+END_SRC
 
 *** Emacs shell
@@ -526,6 +526,96 @@ Basic settings for emacs integrated shell
 
 #+END_SRC
 
+*** Isearch related
+Incremental search is great, but annoyingly you need to type whatever
+you want. If you want to search for just the next (or previous)
+occurence of what is at your cursor position use the following.
+*C-x* will insert the current word while *M-up* and *M-down* will just
+jump to the next/previous occurence of it.
+#+BEGIN_SRC emacs-lisp
+(define-key isearch-mode-map (kbd "C-x") 'sacha/isearch-yank-current-word)
+(global-set-key '[M-up] 'sacha/search-word-backward)
+(global-set-key '[M-down] 'sacha/search-word-forward)
+#+END_SRC
+
+*** Frame configuration
+I want to see the buffername and its size, not the host I am on in my
+frame title.
+#+BEGIN_SRC emacs-lisp
+(setq frame-title-format "%b (%i)")
+#+END_SRC
+
+*** Protect some buffers
+I don't want some buffers to be killed, **scratch** for example.
+In the past I had a long function that just recreated them, but the
+=keep-buffers= package is easier.
+#+BEGIN_SRC emacs-lisp
+(require 'keep-buffers)
+(keep-buffers-mode 1)
+(push '("\\`*scratch" . erase) keep-buffers-protected-alist)
+(push '("\\`*Org Agenda" . nil) keep-buffers-protected-alist)
+(push '("\\`*Group" . nil) keep-buffers-protected-alist)
+#+END_SRC
+
+*** yes-or-no-p
+Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
+lazy.
+#+BEGIN_SRC emacs-lisp
+(defalias 'yes-or-no-p 'y-or-n-p)
+#+END_SRC
+
+*** Language/i18n stuff
+In this day and age, UTF-8 is the way to go.
+#+BEGIN_SRC emacs-lisp
+(set-language-environment 'utf-8)
+(set-default-coding-systems 'utf-8)
+(set-terminal-coding-system 'utf-8)
+(set-keyboard-coding-system 'utf-8)
+(set-clipboard-coding-system 'utf-8)
+(prefer-coding-system 'utf-8)
+#+END_SRC
+
+*** Hilight matching parentheses
+While I do have the nifty shortcut to jump to the other parentheses,
+hilighting them makes it obvious where they are.
+#+BEGIN_SRC emacs-lisp
+(require 'paren)
+(setq show-paren-style 'parenthesis)
+(show-paren-mode +1)
+#+END_SRC
+*** Kill  other buffers
+While many editors allow you to close "all the other files, not the one
+you are in", emacs doesn't have this... Except, now it will.
+#+BEGIN_SRC emacs-lisp
+(require 'dash)
+(global-set-key (kbd "C-c k") 'prelude-kill-other-buffers)
+
+#+END_SRC
+*** Scrolling
+Default scrolling behaviour in emacs is a bit annoying, who wants to
+jump half-windows?
+#+BEGIN_SRC emacs-lisp
+(setq scroll-margin 0)
+(setq scroll-conservatively 100000)
+(setq scroll-up-aggressively 0.0)
+(setq scroll-down-aggressively 0.0)
+(setq scroll-preserve-screen-position t)
+#+END_SRC
+
+*** Copy/Paste with X
+[2013-04-09 Di 23:31]
+The default how emacs handles cutting/pasting with the primary selection
+changed in emacs24. I am used to the old way, so get it back.
+#+BEGIN_SRC emacs-lisp
+(setq x-select-enable-primary t)
+#+END_SRC
+
+#+BEGIN_SRC emacs-lisp
+(setq x-select-enable-clipboard t        ;; copy-paste should work ...
+  interprogram-paste-function            ;; ...with...
+  'x-cut-buffer-or-selection-value)      ;; ...other X clients
+
+#+END_SRC
 
 *** Global keyboard changes not directly related to a mode
 Disable /suspend_frame/ function, I dislike it.
@@ -652,112 +742,38 @@ disabling that.
 (global-unset-key [kp-insert])
 #+END_SRC
 
-*** Isearch related
-Incremental search is great, but annoyingly you need to type whatever
-you want. If you want to search for just the next (or previous)
-occurence of what is at your cursor position use the following.
-*C-x* will insert the current word while *M-up* and *M-down* will just
-jump to the next/previous occurence of it.
-#+BEGIN_SRC emacs-lisp
-(define-key isearch-mode-map (kbd "C-x") 'sacha/isearch-yank-current-word)
-(global-set-key '[M-up] 'sacha/search-word-backward)
-(global-set-key '[M-down] 'sacha/search-word-forward)
-#+END_SRC
-
-*** Frame configuration
-I want to see the buffername and its size, not the host I am on in my
-frame title.
-
-#+BEGIN_SRC emacs-lisp
-(setq frame-title-format "%b (%i)")
-#+END_SRC
-
-*** Protect some buffers
-I don't want some buffers to be killed, **scratch** for example.
-In the past I had a long function that just recreated them, but the
-=protbuf= package is easier.
-
-#+BEGIN_SRC emacs-lisp
-(require 'protbuf)
-(protect-buffer-from-kill-mode nil (get-buffer "*scratch*"))
-#+END_SRC
-
-*** yes-or-no-p
-Emas usually wants you to type /yes/ or /no/ fully. What a mess, I am
-lazy.
-#+BEGIN_SRC emacs-lisp
-(defalias 'yes-or-no-p 'y-or-n-p)
-#+END_SRC
-
-*** Language/i18n stuff
-In this day and age, UTF-8 is the way to go.
-#+BEGIN_SRC emacs-lisp
-(set-language-environment 'utf-8)
-(set-default-coding-systems 'utf-8)
-(set-terminal-coding-system 'utf-8)
-(set-keyboard-coding-system 'utf-8)
-(set-clipboard-coding-system 'utf-8)
-(prefer-coding-system 'utf-8)
-#+END_SRC
-
-*** Hilight matching parentheses
-While I do have the nifty shortcut to jump to the other parentheses,
-hilighting them makes it obvious where they are.
-#+BEGIN_SRC emacs-lisp
-(require 'paren)
-(setq show-paren-style 'parenthesis)
-(show-paren-mode +1)
-#+END_SRC
-*** Kill  other buffers
-While many editors allow you to close "all the other files, not the one
-you are in", emacs doesn't have this... Except, now it will.
-#+BEGIN_SRC emacs-lisp
-(require 'dash)
-
-(defun prelude-kill-other-buffers ()
-  "Kill all buffers but the current one.
-Doesn't mess with special buffers."
-  (interactive)
-  (-each
-   (->> (buffer-list)
-     (-filter #'buffer-file-name)
-     (--remove (eql (current-buffer) it)))
-   #'kill-buffer))
-(global-set-key (kbd "C-c k") 'kill-other-buffers)
-
-#+END_SRC
-*** Scrolling
-Default scrolling behaviour in emacs is a bit annoying, who wants to
-jump half-windows?
-#+BEGIN_SRC emacs-lisp
-(setq
-  scroll-margin 0                       ;; do smooth scrolling, ...
-  scroll-conservatively 100000          ;; ... the defaults ...
-  scroll-up-aggressively 0.0            ;; ... are very ...
-  scroll-down-aggressively 0.0          ;; ... annoying
-  scroll-preserve-screen-position t)   ;; preserve screen pos with C-v/M-v 
-#+END_SRC
-
-*** Copy/Paste with X
-[2013-04-09 Di 23:31]
-The default how emacs handles cutting/pasting with the primary selection
-changed in emacs24. I am used to the old way, so get it.
-#+BEGIN_SRC emacs-lisp
-(setq x-select-enable-primary t)
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp
-(setq x-select-enable-clipboard t        ;; copy-paste should work ...
-  interprogram-paste-function            ;; ...with...
-  'x-cut-buffer-or-selection-value)      ;; ...other X clients
-
-#+END_SRC
-
 ** Miscellaneous stuff
-#+BEGIN_SRC emacs-lisp
+Emacs should keep backup copies of files I edit, but I do not want them
+to clutter up the filesystem everywhere. So I put them into one defined
+place, backup-directory, which even contains my username (for systems
+where =temporary-file-directory= is not inside my home).
+#+BEGIN_SRC emacs-lisp
+(setq backup-directory
+      (concat temporary-file-directory "/emacs-autosave-" user-login-name))
+(if (not (file-exists-p backup-directory))
+    (make-directory backup-directory))
+(setq backup-directory-alist `(("." . ,backup-directory)))
+(setq auto-save-file-name-transforms `((".*" ,backup-directory t)))
+
+(setq version-control t)     ;; Use version numbers for backups
+(setq kept-new-versions 10)  ;; Number of newest versions to keep
+(setq kept-old-versions 2)   ;; Number of oldest versions to keep
+(setq delete-old-versions t) ;; Ask to delete excess backup versions?
+
+(add-hook 'before-save-hook  'force-backup-of-buffer)
+
+(setq backup-by-copying-when-linked t) ;; Copy linked files, don't rename.
 (setq backup-by-copying t)
-(setq backup-directory-alist (quote (("." . "~/tmp/"))))
 (setq make-backup-files t)
+
+(setq backup-enable-predicate
+      (lambda (name)
+        (and (normal-backup-enable-predicate name)
+             (not
+              (let ((method (file-remote-p name 'method)))
+                (when (stringp method)
+                  (member method '("su" "sudo"))))))))
+
 #+END_SRC
 
 #+BEGIN_SRC emacs-lisp
@@ -842,7 +858,7 @@ See [[http://www.emacswiki.org/emacs/Registers][EmacsWiki: Registers]] and/or [[
 #+END_SRC
 
 
-* Modes and their configuration
+* Extra modes and their configuration
 ** "Preface"
 I use quite a few modes and local added files, which would make emacs
 bootup slow. Especially on some of the slow machines I am forced to work
@@ -898,14 +914,14 @@ configuration.
 Transparent Remote (file) Access, Multiple Protocol, remote file editing.
 #+BEGIN_SRC emacs-lisp
 (require 'tramp)
-(setq 
+(setq
   tramp-default-method        "ssh"
   tramp-persistency-file-name "~/.emacs.d/cache/tramp")
 (setq shell-prompt-pattern "^[^a-zA-Z].*[#$%>] *")
 (add-to-list 'tramp-default-method-alist
                         '("\\`localhost\\'" "\\`root\\'" "su")
                         )
-  
+
 
 #+END_SRC
 
@@ -1795,7 +1811,7 @@ much more like reading and editing of code using its major mode.
 #+BEGIN_SRC emacs-lisp
   (require 'org-latex)
   (setq org-export-latex-listings 'minted)
-  
+
   ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
   ;; but adapted to use latexmk 4.20 or higher.
   (defun my-auto-tex-cmd ()
@@ -1812,9 +1828,9 @@ much more like reading and editing of code using its major mode.
         (setq texcmd "latexmk -pdflatex='xelatex -shell-escape' -pdf -quiet %f"))
     ;; LaTeX compilation command
     (setq org-latex-to-pdf-process (list texcmd)))
-  
+
   (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
-  
+
   ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
   (setq org-export-latex-packages-alist
         '(("" "graphicx" t)
@@ -1822,7 +1838,7 @@ much more like reading and editing of code using its major mode.
           ("" "float" nil)
           ("" "minted" nil)
           ))
-  
+
   (defun my-auto-tex-parameters ()
         "Automatically select the tex packages to include."
         ;; default packages for ordinary latex or pdflatex export
@@ -1838,7 +1854,7 @@ much more like reading and editing of code using its major mode.
                 (""     "latexsym"  t)
                 (""     "amssymb"   t)
                 (""     "hyperref"  nil)))
-  
+
         ;; Packages to include when xelatex is used
         (if (string-match "LATEX_CMD: xelatex" (buffer-string))
             (setq org-export-latex-default-packages-alist
@@ -1851,7 +1867,7 @@ much more like reading and editing of code using its major mode.
                     ("" "soul" t)
                     ("xetex" "hyperref" nil)
                     )))
-  
+
         (if (string-match "#+LATEX_CMD: xelatex" (buffer-string))
             (setq org-export-latex-classes
                   (cons '("scrartcl"
@@ -1862,7 +1878,7 @@ much more like reading and editing of code using its major mode.
                           ("\\paragraph{%s}" . "\\paragraph*{%s}")
                           ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
                         org-export-latex-classes))))
-  
+
   (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
 #+END_SRC
 #+BEGIN_SRC emacs-lisp
@@ -2044,7 +2060,7 @@ according to their depth. Each successive level is highlighted a
 different color. This makes it easy to spot matching delimiters, orient
 yourself in the code, and tell which statements are at the same depth.
 #+BEGIN_SRC emacs-lisp
-(when (require 'rainbow-delimiters nil 'noerror) 
+(when (require 'rainbow-delimiters nil 'noerror)
   (global-rainbow-delimiters-mode))
 #+END_SRC
 ** undo-tree
@@ -2125,16 +2141,16 @@ then I like it nice too...
     (require 'paredit)
     (setq lisp-coding-hook 'lisp-coding-defaults)
       (setq interactive-lisp-coding-hook 'interactive-lisp-coding-defaults)
-    
+
     (eval-after-load "paredit"
       '(diminish 'paredit-mode " π"))
-    
+
   (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
   (add-hook 'emacs-lisp-mode-hook (lambda ()
                                     (run-hooks 'prelude-emacs-lisp-mode-hook)))
-  
+
   (define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
-  
+
   (eval-after-load "elisp-slime-nav"
     '(diminish 'elisp-slime-nav-mode))
   (eval-after-load "rainbow-mode"