From 61a5ea67d86c2bb1f0b6b3ae9d425f48bae65199 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Mon, 7 Aug 2017 21:10:42 +0200 Subject: [PATCH] +fixes --- .emacs | 167 ++++++-- emacs.html | 1122 +++++++++++++++++++++++++++++----------------------- 2 files changed, 744 insertions(+), 545 deletions(-) diff --git a/.emacs b/.emacs index ea6e9e9..05512bb 100644 --- a/.emacs +++ b/.emacs @@ -1,4 +1,4 @@ -;; Toms Emacs Config - portable - version (20170805.01) -*-emacs-lisp-*- +;; Toms Emacs Config - portable - version (20170806.01) -*-emacs-lisp-*- ;; * Introduction ;; This is my emacs config, it is more than twenty years old. It @@ -604,6 +604,9 @@ ;; 20170805.01 ;; - +C-c C-c for rename files in dired +;; 20170807.01 +;; - added dired config and functions + ;; ** TODO ;; - check helpful https://github.com/wilfred/helpful @@ -632,7 +635,7 @@ ;; My emacs config has a version (consisting of a timestamp with a ;; serial), which I display in the mode line. So I can clearly see, if ;; I'm using an outdated config somewhere. -(defvar tvd-emacs-version "20170805.01") +(defvar tvd-emacs-version "20170807.01") ;; -------------------------------------------------------------------------------- @@ -4501,11 +4504,22 @@ defun." ;; -------------------------------------------------------------------------------- ;; *** Dired -;; I do not use dired, but its good to drop into a dired buffer from -;; magit (see "ls" shortcut above). But default dired looks ugly, so I -;; use k. +;; I use dired for two things: from inside magit as a convenient way +;; to add or remove files from a repository. Or if I want to rename a +;; bunch of files using search/replace and other editing commands. + +;; But as with everything else I use, it must fit and so I managed to +;; tune this as well. + +;; More Hints: +;; - http://ergoemacs.org/emacs/emacs_dired_tips.html + +;; **** dired-k + +;; dired-k is k for dired/emacs: it colorizes files and directory by +;; age, that is, the older the greyer they get. And it displays flags +;; about the git status of each file, which is really handy. -;; *** dired-k (require 'dired-k) (add-hook 'dired-initial-position-hook 'dired-k) @@ -4513,26 +4527,11 @@ defun." (setq dired-k-padding 2) -;; [[http://blog.binchen.org/posts/the-most-efficient-way-to-git-add-file-in-dired-mode-emacsendiredgit.html][via bin chen]]: -;; make git commands available from dired buffer, so I can easily add -;; or remove files from git -(defun diredext-exec-git-command-in-shell (command &optional arg file-list) - "Run a shell command git COMMAND ' on the marked files. if no -files marked, always operate on current line in dired-mode" - (interactive - (let ((files (dired-get-marked-files t current-prefix-arg))) - (list - ;; Want to give feedback whether this file or marked files are used: - (dired-read-shell-command "git command on %s: " current-prefix-arg files) - current-prefix-arg - files))) - (unless (string-match "[?][ \t]\'" command) - (setq command (concat command " *"))) - (setq command (concat "git " command)) - (dired-do-shell-command command arg file-list) - (message command)) +;; **** dired sort helpers -;; [[http://ergoemacs.org/emacs/dired_sort.html][via Xah Lee]]: +;; This sort function by [[http://ergoemacs.org/emacs/dired_sort.html][Xah Lee]] +;; is easy to use and does what it should, great!, However, I added some -desc +;; sister sorts for reverse sorting. (defun xah-dired-sort () "Sort dired dir listing in different ways. Prompt for a choice. @@ -4553,7 +4552,31 @@ Version 2015-07-30" (t (error "logic error 09535" ))) (dired-sort-other arg ))) +;; **** dired git helpers + +;; [[http://blog.binchen.org/posts/the-most-efficient-way-to-git-add-file-in-dired-mode-emacsendiredgit.html][via bin chen]]: +;; make git commands available from dired buffer, which can be used in +;; those rare cases, where my wrappers below don't fit. +(defun diredext-exec-git-command-in-shell (command &optional arg file-list) + "Run a shell command git COMMAND ' on the marked files. if no +files marked, always operate on current line in dired-mode" + (interactive + (let ((files (dired-get-marked-files t current-prefix-arg))) + (list + ;; Want to give feedback whether this file or marked files are used: + (dired-read-shell-command "git command on %s: " current-prefix-arg files) + current-prefix-arg + files))) + (unless (string-match "[?][ \t]\'" command) + (setq command (concat command " *"))) + (setq command (concat "git " command)) + (dired-do-shell-command command arg file-list) + (message command)) + +;; some git commandline wrappers which directly work on git files, +;; called with "hydras". (defun tvd-dired-git-add(&optional arg file-list) + "Add marked or current file to current repository (stash)." (interactive (let ((files (dired-get-marked-files t current-prefix-arg))) (list current-prefix-arg files))) @@ -4561,6 +4584,7 @@ Version 2015-07-30" (revert-buffer)) (defun tvd-dired-git-rm(&optional arg file-list) + "Remove marked or current file from current repository and filesystem." (interactive (let ((files (dired-get-marked-files t current-prefix-arg))) (list current-prefix-arg files))) @@ -4568,31 +4592,94 @@ Version 2015-07-30" (revert-buffer)) (defun tvd-dired-git-ungit(&optional arg file-list) + "Like `tvd-dired-git-rm' but keep the files in the filesystem (unstage)." (interactive (let ((files (dired-get-marked-files t current-prefix-arg))) (list current-prefix-arg files))) (dired-do-shell-command "git rm -rf --cached * " arg file-list) (revert-buffer)) +;; **** dired navigation -(eval-after-load 'dired '(progn - ;; stay with 1 dired buffer per instance - (define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file) - (define-key dired-mode-map (kbd "^") (lambda () (interactive) (find-alternate-file ".."))) - (define-key dired-mode-map (kbd "") (lambda () (interactive) (find-alternate-file ".."))) - (define-key dired-mode-map (kbd "s") 'xah-dired-sort) +;; I'm used to jump around with pos1+end +(defun tvd-dired-begin () + "Move point to the first directory in the listing .." + (interactive) + (goto-char (point-min)) + (dired-next-dirline 2)) - (define-prefix-command 'tvd-dired-git-map) - (define-key dired-mode-map (kbd "g") 'tvd-dired-git-map) - (define-key tvd-dired-git-map (kbd "a") 'tvd-dired-git-add) - (define-key tvd-dired-git-map (kbd "d") 'tvd-dired-git-rm) - (define-key tvd-dired-git-map (kbd "u") 'tvd-dired-git-ungit) +(defun tvd-dired-end () + "Move point to the last file or directory in the listing." + (interactive) + (goto-char (point-max)) + (dired-previous-line 1)) - (defalias 'edit-dired 'wdired-change-to-wdired-mode) - (define-key dired-mode-map (kbd "C-c C-c") 'wdired-change-to-wdired-mode))) +;; **** dired buffer names + +;; This took me a long time to figure out, but I finally got it: I +;; really hate it how dired names its buffers, it just uses the +;; basename part of the current working directory as buffer name. So +;; when there are a couple of dozen buffers open and one of them is +;; named "tmp" I just can't see it. So what I do here is to rename +;; each dired buffer right after its creation by advising +;; `dired-internal-noselect'. My dired buffers have such names now: +;; *dired: ~/tmp*. I can find them easily, and I can reach all dired +;; buffers very fast thanks to the *dired prefix. And they are now +;; clearly marked as non-file buffers. In fact I consider this +;; behavior as a bug, but I doubt many people would agree :) + +;; (defun tvd-dired-fix-buffer-name (buffer) +;; "Modify dired buffer names to this pattern: *dired: full-path*" +;; (interactive) +;; (with-current-buffer buffer +;; (rename-buffer (format "*dired: %s*" default-directory))) +;; buffer) +;; (advice-add 'dired-internal-noselect :filter-return 'tvd-dired-fix-buffer-name) + +(advice-add 'dired-internal-noselect + :filter-return + '(lambda (buffer) + "Modify dired buffer names to this pattern: *dired: full-path*" + (interactive) + (with-current-buffer buffer + (rename-buffer (format "*dired: %s*" default-directory))) + buffer)) + +;; **** dired config and key bindings + +;; and finally put everything together. + +(eval-after-load 'dired + '(progn + ;; stay with 1 dired buffer per instance + ;; when changing directories + (define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file) + (define-key dired-mode-map (kbd "^") (lambda () (interactive) (find-alternate-file ".."))) + (define-key dired-mode-map (kbd "") (lambda () (interactive) (find-alternate-file ".."))) + + ;; Xah Lee'S custom sort's + (define-key dired-mode-map (kbd "s") 'xah-dired-sort) + + ;; my git "hydras" + (define-prefix-command 'tvd-dired-git-map) + (define-key dired-mode-map (kbd "g") 'tvd-dired-git-map) + (define-key tvd-dired-git-map (kbd "a") 'tvd-dired-git-add) + (define-key tvd-dired-git-map (kbd "d") 'tvd-dired-git-rm) + (define-key tvd-dired-git-map (kbd "u") 'tvd-dired-git-ungit) + + ;; edit filenames + (defalias 'edit-dired 'wdired-change-to-wdired-mode) + (define-key dired-mode-map (kbd "C-c C-c") 'wdired-change-to-wdired-mode) + + ;; navigation, use TAB and C-TAB to move + ;; point to next or prev dir like in info + ;; mode, and HOME+END to reach the end or + ;; beginning of the listing. + (define-key dired-mode-map (kbd "") 'dired-next-dirline) + (define-key dired-mode-map (kbd "") 'dired-prev-dirline) + (define-key dired-mode-map (kbd "") 'tvd-dired-begin) + (define-key dired-mode-map (kbd "") 'tvd-dired-end))) -;; HINTS: -;; - http://ergoemacs.org/emacs/emacs_dired_tips.html ;; ** Emacs Interface ;; *** Parens diff --git a/emacs.html b/emacs.html index e6b5da6..6fd79ca 100644 --- a/emacs.html +++ b/emacs.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -232,204 +232,203 @@ for the JavaScript code in this tag.

Table of Contents

-Toms Emacs Config - portable - version (20170805.01) -*-emacs-lisp-*- +Toms Emacs Config - portable - version (20170806.01) -*-emacs-lisp-*-

-
-

1 Introduction

+
+

1 Introduction

This is my emacs config, it is more than twenty years old. It @@ -483,11 +482,11 @@ outshine-to-html, written by myself, see below.

-
-

2 Config Log, Trivia, Notes, Changes

+
+

2 Config Log, Trivia, Notes, Changes

-
-

2.1 Changelog

+
+

2.1 Changelog

20160420.03: @@ -1526,11 +1525,18 @@ that ip's are left aligned

  • +C-c C-c for rename files in dired
+ +

+20170807.01 +

+
    +
  • added dired config and functions
  • +
-
-

2.2 TODO

+
+

2.2 TODO

-
-

2.3 Parking Lot / Snippets

+
+

2.3 Parking Lot / Snippets

Snippets which maybe of use in the future

-
-

2.3.1 buffer-local hook

+
+

2.3.1 buffer-local hook

(with-current-buffer (get-buffer "scratch") @@ -1567,8 +1573,8 @@ Snippets which maybe of use in the future

-
-

2.4 .emacs config version

+
+

2.4 .emacs config version

My emacs config has a version (consisting of a timestamp with a @@ -1576,7 +1582,7 @@ serial), which I display in the mode line. So I can clearly see, if I'm using an outdated config somewhere.

-
(defvar tvd-emacs-version "20170805.01")
+
(defvar tvd-emacs-version "20170807.01")
 
@@ -1585,11 +1591,11 @@ I'm using an outdated config somewhere.
-
-

3 System Specifics

+
+

3 System Specifics

-
-

3.1 Global init file+dir vars, portable

+
+

3.1 Global init file+dir vars, portable

  • added dev function which opens a new development frame
  • @@ -1627,8 +1633,8 @@ all modes and extensions are located here
-
-

3.2 Fontlock-mode - use syntax highlighting on graphical displays

+
+

3.2 Fontlock-mode - use syntax highlighting on graphical displays

look: emacswiki @@ -1645,8 +1651,8 @@ look: emacswiki


-
-

3.3 line-cursor in console

+
+

3.3 line-cursor in console

better visibility of cursor in console sessions @@ -1662,8 +1668,8 @@ better visibility of cursor in console sessions


-
-

3.4 Backup Config

+
+

3.4 Backup Config

I save backup files in a central location below the init dir, that @@ -1734,8 +1740,8 @@ This is system specific and only matches special host names.


-
-

3.5 console backspace fix

+
+

3.5 console backspace fix

make backspace work in console sessions @@ -1748,8 +1754,8 @@ make backspace work in console sessions


-
-

3.6 hide menu- and tool-bar

+
+

3.6 hide menu- and tool-bar

I prefer a bare bones emacs window without any distractions, so turn them off. @@ -1765,8 +1771,8 @@ I prefer a bare bones emacs window without any distractions, so turn them off.


-
-

3.7 stay silent on startup

+
+

3.7 stay silent on startup

(setq initial-scratch-message "")
@@ -1779,8 +1785,8 @@ I prefer a bare bones emacs window without any distractions, so turn them off.
 
-
-

3.8 y means yes

+
+

3.8 y means yes

y is shorter than yes and less error prone. @@ -1793,8 +1799,8 @@ y is shorter than yes and less error prone.


-
-

3.9 show col in modeline

+
+

3.9 show col in modeline

very useful to know current column @@ -1807,8 +1813,8 @@ very useful to know current column


-
-

3.10 file or buffer in title

+
+

3.10 file or buffer in title

this can be seen in xmobar @@ -1822,8 +1828,8 @@ this can be seen in xmobar


-
-

3.11 avoid invalid files

+
+

3.11 avoid invalid files

(setq require-final-newline t)
@@ -1833,8 +1839,8 @@ this can be seen in xmobar
 
-
-

3.12 prepare load-path

+
+

3.12 prepare load-path

where to look for extensions: @@ -1861,8 +1867,8 @@ modules


-
-

3.13 byte-compile all of them, if needed

+
+

3.13 byte-compile all of them, if needed

handy function to recompile all lisp files @@ -1877,8 +1883,8 @@ handy function to recompile all lisp files


-
-

3.14 increase fontsize with ctrl-+ and ctrl--

+
+

3.14 increase fontsize with ctrl-+ and ctrl--

I use those bindings everywhere (firefox, terminal, etc), and in @@ -1904,11 +1910,11 @@ emacs as well.


-
-

3.15 WINDOW management stuff

+
+

3.15 WINDOW management stuff

-
-

3.15.1 resize windows by keyboard

+
+

3.15.1 resize windows by keyboard

Very practical: resize windows easily. @@ -1925,8 +1931,8 @@ hit C-c C-r then use cursor keys to resize, <ret> to finish

-
-

3.15.2 switch windows with MS-WINDOWS key

+
+

3.15.2 switch windows with MS-WINDOWS key

(require 'windmove)
@@ -1937,8 +1943,8 @@ hit C-c C-r then use cursor keys to resize, <ret> to finish
 
-
-

3.15.3 M-o switch window or buffer

+
+

3.15.3 M-o switch window or buffer

via mbork @@ -2016,8 +2022,8 @@ Use only in X11 emacs - setting M-O inside console causes <up> and


-
-

3.15.4 Split window to 4 parts

+
+

3.15.4 Split window to 4 parts

(defun tvd-quarter-windows ()
@@ -2035,8 +2041,8 @@ Use only in  X11 emacs - setting M-O inside console  causes <up> and
 
-
-

3.15.5 Remember and Restore Window Configurations - winner mode

+
+

3.15.5 Remember and Restore Window Configurations - winner mode

(winner-mode 1)
@@ -2051,8 +2057,8 @@ keybindings: C-c right   - winner-redo
 
-
-

3.16 re-read a modified buffer

+
+

3.16 re-read a modified buffer

F5 == reload file if it has been modified by another process, shift @@ -2077,8 +2083,8 @@ because Xmonad


-
-

3.17 global TAB/Indent config

+
+

3.17 global TAB/Indent config

I use spaces everywhere but Makefiles. If I encounter TABs I @@ -2118,8 +2124,8 @@ Use normal tabs in makefiles


-
-

3.18 handy aliases

+
+

3.18 handy aliases

M-x q r <ret> is short enough for me, no need for key bindings for @@ -2151,8 +2157,8 @@ those


-
-

3.19 various settings

+
+

3.19 various settings

point stays while scrolling @@ -2205,8 +2211,8 @@ I'm grown up!


-
-

3.20 load imenu

+
+

3.20 load imenu

(define-key global-map [C-down-mouse-2] 'imenu)
@@ -2216,8 +2222,8 @@ I'm grown up!
 
-
-

3.21 copy/paste Config

+
+

3.21 copy/paste Config

Related: @@ -2284,8 +2290,8 @@ marked region automatically copied, also on win


-
-

3.22 use more mem

+
+

3.22 use more mem

are you from the past? @@ -2298,8 +2304,8 @@ are you from the past?


-
-

3.23 better file name completion

+
+

3.23 better file name completion

Complete filenames case insensitive and ignore certain files during completion. @@ -2329,8 +2335,8 @@ via -

3.24 abbreviations

+
+

3.24 abbreviations

Do I really need those anymore? Added ca 1999… @@ -2360,8 +2366,8 @@ do NOT ask to save abbrevs on exit

-
-

3.25 meaningful names for buffers with the same name

+
-
-

3.26 packages

+
+

3.26 packages

I dont need it all the time and only for experimentation, so lets @@ -2403,8 +2409,8 @@ only use melpa on demand


-
-

3.27 My own global variables

+
+

3.27 My own global variables

narrowed fringe background @@ -2417,11 +2423,11 @@ narrowed fringe background


-
-

3.28 More scratch space

+
+

3.28 More scratch space

-
-

3.28.1 Text scratch

+
+

3.28.1 Text scratch

Sometimes I need a text mode scratch buffer while scratch is @@ -2437,8 +2443,8 @@ this never gets deleted, but cleaned instead.

-
-

3.28.2 Autoscratch

+
+

3.28.2 Autoscratch

use autoscratch otherwise @@ -2468,8 +2474,8 @@ use autoscratch otherwise

-
-

3.28.3 Persistent Scratch

+
+

3.28.3 Persistent Scratch

I also like to be scratch buffers persistent with @@ -2491,8 +2497,8 @@ I also like to be scratch buffers persistent with

-
-

3.29 Recenter config

+
+

3.29 Recenter config

via abo abo @@ -2513,13 +2519,13 @@ I think this is a recenter calculation bug.

-
-

4 Global Key Bindings

+
+

4 Global Key Bindings


-
-

4.1 c-h != delete

+
+

4.1 c-h != delete

(keyboard-translate ?\C-h ?\C-?)
@@ -2530,8 +2536,8 @@ I think this is a recenter calculation bug.
 
-
-

4.2 general keys (re-)mappings

+
+

4.2 general keys (re-)mappings

(global-set-key (kbd "C-s")             'isearch-forward-regexp)
@@ -2559,8 +2565,8 @@ I think this is a recenter calculation bug.
 
-
-

4.3 display a list of my own global key bindings and aliases

+
+

4.3 display a list of my own global key bindings and aliases

via emacswiki @@ -2637,13 +2643,13 @@ more help with: describe-function occur-mode

-
-

5 Productivity Functions

+
+

5 Productivity Functions


-
-

5.1 goto line with tmp line numbers

+
+

5.1 goto line with tmp line numbers

I stole this somewhere, as far as I remember, emacswiki, however, I @@ -2667,8 +2673,8 @@ always had F7 for goto-line


-
-

5.2 invert fore- and background

+
+

5.2 invert fore- and background

Sometimes when sitting in a very dark enviroment, my usual light @@ -2711,8 +2717,8 @@ fast


-
-

5.3 Some useful bindings for Home and End keys Hit the key once to

+
+

5.3 Some useful bindings for Home and End keys Hit the key once to

Go to the beginning/end of a line, hit it twice in a row to go to @@ -2776,8 +2782,8 @@ This is the most natural use for those keys


-
-

5.4 percent function

+
+

5.4 percent function

by Jens Heunemann: jump to percent position into current buffer @@ -2798,8 +2804,8 @@ by Jens Heunemann: jump to percent position into current buffer


-
-

5.5 Simulate vi's % function

+
+

5.5 Simulate vi's % function

There's not a lot about vi[m] I like, but jumping with % to a @@ -2831,8 +2837,8 @@ just insert a literal ?%. Only make sense if bound to %.


-
-

5.6 Move region

+
+

5.6 Move region

Mark a region, then use M-up|down to move it around @@ -2931,8 +2937,8 @@ code from -

5.7 comment-uncomment region with one key binding

+ -
-

5.8 search for symbol at point

+
+

5.8 search for symbol at point

Simulate the # function of vi, marks the symbol at point, C-s then @@ -2999,8 +3005,8 @@ via ergomacs


-
-

5.9 Window Margin

+
+

5.9 Window Margin

Kinda screen reader for the poor. I use this sometimes with info @@ -3026,8 +3032,8 @@ left+right margin on demand (but nothing else)


-
-

5.10 Fill and justify a paragraph

+
+

5.10 Fill and justify a paragraph

this is just a shortcut for: @@ -3056,8 +3062,8 @@ idea via: -

5.11 Make a read-only copy of the current buffer

+
+

5.11 Make a read-only copy of the current buffer

I just create a new read-only buffer and copy the contents of the @@ -3106,8 +3112,8 @@ a file is not maintained via VC anyway.


-
-

5.12 Cleanup, close all windows and kill all buffers

+
+

5.12 Cleanup, close all windows and kill all buffers

From time to time I get annoyed by the many dozen buffers @@ -3140,8 +3146,8 @@ setup accidentally.


-
-

5.13 Cleanup current buffer

+
-
-

5.14 Better newline(s)

+
+

5.14 Better newline(s)

Add newline and jump to indent from wherever I am in the current @@ -3215,8 +3221,8 @@ disabled, interferes with modes.


-
-

5.15 Mouse Rectangle

+
-
-

5.16 DOS <=> UNIX conversion helpers

+
+

5.16 DOS <=> UNIX conversion helpers

(defun dos2unix ()
@@ -3265,8 +3271,8 @@ via stackoverflow
 
-
-

5.17 helper do add the same thing to multiple mode hooks

+
+

5.17 helper do add the same thing to multiple mode hooks

via stackoverflow @@ -3284,8 +3290,8 @@ usage samples below.

-
-

5.18 helper to catch load errors

+
+

5.18 helper to catch load errors

Try to eval 'fn, catch errors, if any but make it possible for @@ -3307,8 +3313,8 @@ emacs to continue undisturbed, used with SMEX, see below.


-
-

5.19 Alignment Wrappers

+
+

5.19 Alignment Wrappers

align-regexp is already a very usefull tool, however, sometimes I @@ -3358,8 +3364,8 @@ wrappers to make this easier.

-
-

5.20 String Helpers

+
+

5.20 String Helpers

Some helper functions I use here and there. @@ -3398,14 +3404,14 @@ Some helper functions I use here and there.

-
-

6 Modes

+
+

6 Modes

-
-

6.1 Programming Languages

+
+

6.1 Programming Languages

-
-

6.1.1 VALA

+
+

6.1.1 VALA

(autoload 'vala-mode "vala-mode" "Major mode for editing Vala code." t)
@@ -3420,8 +3426,8 @@ Some helper functions I use here and there.
 
-
-

6.1.2 python mode

+
+

6.1.2 python mode

Not much configured for python, I'm happy with the defaults as it seems :) @@ -3449,8 +3455,8 @@ Not much configured for python, I'm happy with the defaults as it seems :)

-
-

6.1.3 cperl mode

+
+

6.1.3 cperl mode

I am a perl addict. I love it, therefore, emacs must be prepared @@ -3597,8 +3603,8 @@ and hook them into cperl

-
-

6.1.4 Paredit for lisp only

+
+

6.1.4 Paredit for lisp only

I use paredit in lisp a lot, but are mostly happy with the defaults. @@ -3641,8 +3647,8 @@ sometimes I need to be able to turn it off fast:

-
-

6.1.5 ETAGS

+
+

6.1.5 ETAGS

I use ETAGS for some projects. With etags I can easily jump to the @@ -3719,11 +3725,11 @@ some handy aliases

-
-

6.2 Text Modes

+
+

6.2 Text Modes

-
-

6.2.1 sgml

+
+

6.2.1 sgml

Used for XML and the likes. @@ -3750,8 +3756,8 @@ Used for XML and the likes.

-
-

6.2.2 web-mode (JS, HTML, CSS combined)

+
+

6.2.2 web-mode (JS, HTML, CSS combined)

Web development is shit. Tech involved is a mess, and in most cases @@ -3845,8 +3851,8 @@ convert a text list into a html list.

-
-

6.2.3 Cisco Mode

+
+

6.2.3 Cisco Mode

Written by myself many years ago, but I'm still using it daily to @@ -3864,8 +3870,8 @@ view and prepare cisco configs.

-
-

6.2.4 Markdown

+
+

6.2.4 Markdown

I rarely use markdown, but sometimes I stumble upon such a file and @@ -3901,8 +3907,8 @@ parens and quotes constraints check on save

-
-

6.2.5 POD mode

+
+

6.2.5 POD mode

I LOVE POD! POD is the documentation format of perl and there's a @@ -4036,8 +4042,8 @@ pod mode config


-
-

6.2.6 conf-mode

+
+

6.2.6 conf-mode

conf-mode annoyingly overwrites the global keybinding C-c C-c with @@ -4058,10 +4064,10 @@ configs. Applies for derivates as well.

-
-

6.2.7 Config::General mode

+
+

6.2.7 Config::General mode

-
  1. Config and doc
    +
    1. Config and doc

      config-general-mode (also on Melpa).

      @@ -4080,7 +4086,7 @@ both did not satisfy me. Now (as of 20170625) I solved this mess once and for al
-
  • Convenicence Wrappers
    +
  • Convenicence Wrappers
    (defun config-general-completion-at-point ()
       "Complete word at point using hippie-expand, if not on a comment."
    @@ -4180,7 +4186,7 @@ Bugreport: http://d
     
  • -
  • Mode Hook
    +
  • Mode Hook

    I use TAB for completion AND tab and outshine. Also, the mode enables electric indent automatically, but I disabled it for @@ -4230,8 +4236,8 @@ for config-general-mode (which inherits from conf-mode).


  • -
    -

    6.2.8 Xmodmap Mode

    +
    +

    6.2.8 Xmodmap Mode

    the shortest mode ever, via emacswiki. @@ -4254,10 +4260,10 @@ the shortest mode ever, vi

    -
    -

    6.2.9 MMM Mode

    +
    +

    6.2.9 MMM Mode

    -
    1. MMM configure:
      +
      1. MMM configure:
        (add-to-list 'load-path (concat tvd-lisp-dir "/mmm-mode"))
         
        @@ -4276,7 +4282,7 @@ see doc for class definition in var 'mmm-classes-alist
         

      2. -
      3. MMM config for POD mode
        +
      4. MMM config for POD mode
        (mmm-add-classes
          '((html-pod
        @@ -4294,11 +4300,11 @@ see doc for class definition in var 'mmm-classes-alist
         
        -
        -

        6.3 Text Manupilation

        +
        +

        6.3 Text Manupilation

        -
        -

        6.3.1 expand-region

        +
        +

        6.3.1 expand-region

        One of the best modes I ever discovered. Press C-= multiple times @@ -4317,8 +4323,8 @@ related to ER:

        -
        -

        6.3.2 Mark, Copy, Yank Things

        +
        +

        6.3.2 Mark, Copy, Yank Things

        For a long time this stuff was located here in my emacs config. As @@ -4421,8 +4427,8 @@ it appears as NNN,NN.

        -
        -

        6.3.3 change-inner

        +
        +

        6.3.3 change-inner

        I use change-inner with a prefix key and some wrappers around @@ -4544,8 +4550,8 @@ typing the prefix key twice calls the real change-inner


        -
        -

        6.3.4 Rotate text

        +
        +

        6.3.4 Rotate text

        This one is great as well, I use it to toggle flags and such stuff @@ -4601,8 +4607,8 @@ short command anymore, so C-t would be free now, wouldn't it?

        -
        -

        6.3.5 Word wrapping

        +
        +

        6.3.5 Word wrapping

        same as word-wrap but without the fringe which I hate the most! @@ -4624,8 +4630,8 @@ overwritten by visual-line-mode above for specifics

        -
        -

        6.3.6 Viking Mode

        +
        +

        6.3.6 Viking Mode

        Delete stuff fast. Press the key multiple times - delete more @@ -4643,8 +4649,8 @@ things. Inspired by expand-region. Written by myself.

        -
        -

        6.3.7 HTMLize

        +
        +

        6.3.7 HTMLize

        extracted from debian package emacs-goodies-el-35.2+nmu1, since @@ -4661,8 +4667,8 @@ the current buffer, however it looks.

        -
        -

        6.3.8 iEdit (inline edit multiple searches)

        +
        +

        6.3.8 iEdit (inline edit multiple searches)

        Edit all occurences of something at once. Great for re-factoring. @@ -4703,11 +4709,11 @@ behavior, so, I modify it myself using defadvice.

        -
        -

        6.4 Interactives

        +
        +

        6.4 Interactives

        -
        -

        6.4.1 eShell stuff, or if interactive stuff is needed, use ansi-term

        +
        +

        6.4.1 eShell stuff, or if interactive stuff is needed, use ansi-term

        I am a hardcore bash user, but from time to time eshell is good @@ -4987,8 +4993,8 @@ no need for less or more, this is emacs, isn't it?

        -
        -

        6.4.2 Emacs LISP interactive

        +
        +

        6.4.2 Emacs LISP interactive

        General configuration for all things elisp. @@ -5199,8 +5205,8 @@ opens a new frame with all those buffers already opened and pinned.


        -
        -

        6.4.3 el2markdown

        +
        +

        6.4.3 el2markdown

        el2markdown is a module which @@ -5224,8 +5230,8 @@ README.md. Take care though: it doesn't convert the META section.

        -
        -

        6.4.4 tramp mode

        +
        +

        6.4.4 tramp mode

        Edit remote files, one of the best things in emacs. I use it every day heavily. @@ -5253,8 +5259,8 @@ see also backup section

        -
        -

        6.4.5 org mode

        +
        +

        6.4.5 org mode

        I use org mode to take notes mostly at work. I also track projects @@ -5556,8 +5562,8 @@ is in the outline section.


        -
        -

        6.4.6 org table mode

        +
        +

        6.4.6 org table mode

        I'm so used to lovely org mode tables, I need them everywhere! @@ -5871,8 +5877,8 @@ integers, reals, positives, set via custom

        -
        -

        6.4.7 org mode slideshows

        +
        +

        6.4.7 org mode slideshows

        Making presentations within emacs with org mode is cool as well. @@ -5980,8 +5986,8 @@ Will be inserted as first help slide in a slide show


        -
        -

        6.4.8 outshine mode

        +
        +

        6.4.8 outshine mode

        I maintain my emacs config with outshine mode. It works a lot like @@ -6161,8 +6167,8 @@ posting online, which makes it way easier to read.

        -
        -

        6.4.9 outline mode

        +
        +

        6.4.9 outline mode

        I use the very same cycle style as in org mode: when on a heading, @@ -6259,8 +6265,8 @@ orange fringe when narrowed


        -
        -

        6.4.10 narrowing (no mode but fits here)

        +
        +

        6.4.10 narrowing (no mode but fits here)

        I use narrowing quite frequently, so here are some enhancements. @@ -6300,8 +6306,8 @@ via -

        6.4.11 ANSI-TERM (inferior shells/interpreters and REPLs)

        +
        +

        6.4.11 ANSI-TERM (inferior shells/interpreters and REPLs)

        I use ansi term for inferior shells only. @@ -6417,8 +6423,8 @@ finally the inferior REPLs:

        -
        -

        6.4.12 Puppet

        +
        +

        6.4.12 Puppet

        adds hook for .pp files @@ -6432,8 +6438,8 @@ adds hook for .pp files

        -
        -

        6.4.13 Novel Mode - Screen Reader

        +
        +

        6.4.13 Novel Mode - Screen Reader

        my own emacs screen reader, very handy to read docs on the road. @@ -6449,8 +6455,8 @@ my own emacs screen reader, very handy to read docs on the road.

        -
        -

        6.4.14 Macro Math

        +
        +

        6.4.14 Macro Math

        see macro-math @@ -6473,8 +6479,8 @@ mark something and hit C-x C-0 (which is a reminder to C-x C-= w/o the shift)

        -
        -

        6.4.15 Common-Lisp (SLIME)

        +
        +

        6.4.15 Common-Lisp (SLIME)

        I'm learing CL with slime, start with M-x slime. @@ -6507,8 +6513,8 @@ INSTALL: (see: -

        6.4.16 INFO Mode

        +
        +

        6.4.16 INFO Mode

        open an info file somewhere outside %infodir% with info-mode @@ -6540,8 +6546,8 @@ easier navigation in Info mode, intuitive history back and forth.

        -
        -

        6.4.17 calc et al.

        +
        +

        6.4.17 calc et al.

        emacs provides 4 ways to calculate: @@ -6591,8 +6597,8 @@ or, inferior perl calc: M-x icalc, see above

        -
        -

        6.4.18 MACROs

        +
        +

        6.4.18 MACROs

        help: emacswiki macro tricks. @@ -6805,8 +6811,8 @@ but only load if in use


        -
        -

        6.4.19 EWW browser stuff

        +
        +

        6.4.19 EWW browser stuff

        Emacs has a builtin browser, which is not too bad. @@ -6874,8 +6880,8 @@ hides menus and distractions! Update emacs.


        -
        -

        6.4.20 Firestarter

        +
        +

        6.4.20 Firestarter

        experimental: do things on save buffer etc. @@ -6884,8 +6890,8 @@ Source: firestarter

        -
        -

        6.4.21 Tabulated List Mode

        +
        +

        6.4.21 Tabulated List Mode

        built-in, used by many interactive major modes @@ -6933,8 +6939,8 @@ we need to kill tablist's binding in order to have ours run (see below)

        -
        -

        6.4.22 Help Mode

        +
        +

        6.4.22 Help Mode

        I even customize help windows! … at least a little :) @@ -6957,8 +6963,8 @@ I even customize help windows! … at least a little :)

        -
        -

        6.4.23 Suggest Mode

        +
        +

        6.4.23 Suggest Mode

        suggest mode is a great @@ -7008,8 +7014,8 @@ I use my own clearing function, since suggest doesn't provide this

        -
        -

        6.4.24 Followcursor Mode

        +
        +

        6.4.24 Followcursor Mode

        source on github @@ -7038,8 +7044,8 @@ The mode is a work-in-progress… -

        -

        6.4.25 Magit

        +
        +

        6.4.25 Magit

        Not much to say about Magit @@ -7118,20 +7124,35 @@ Not much to say about Magit


        -
        -

        6.4.26 Dired

        +
        +

        6.4.26 Dired

        -I do not use dired, but its good to drop into a dired buffer from -magit (see "ls" shortcut above). But default dired looks ugly, so I -use k. +I use dired for two things: from inside magit as a convenient way +to add or remove files from a repository. Or if I want to rename a +bunch of files using search/replace and other editing commands.

        -
        + +

        +But as with everything else I use, it must fit and so I managed to +tune this as well. +

        + +

        +More Hints: +

        +
        -
        -

        6.4.27 dired-k

        -
        +
        1. dired-k
          +

          +dired-k is k for dired/emacs: it colorizes files and directory by +age, that is, the older the greyer they get. And it displays flags +about the git status of each file, which is really handy. +

          +
          (require 'dired-k)
           
          @@ -7141,33 +7162,13 @@ use k.
           (setq dired-k-padding 2)
           
          +
        2. +
        3. dired sort helpers

          -via bin chen: -make git commands available from dired buffer, so I can easily add -or remove files from git -

          -
          -
          (defun diredext-exec-git-command-in-shell (command &optional arg file-list)
          -  "Run a shell command git COMMAND  ' on the marked files.  if no
          -files marked, always operate on current line in dired-mode"
          -  (interactive
          -   (let ((files (dired-get-marked-files t current-prefix-arg)))
          -     (list
          -      ;; Want to give feedback whether this file or marked files are used:
          -      (dired-read-shell-command "git command on %s: " current-prefix-arg files)
          -      current-prefix-arg
          -      files)))
          -  (unless (string-match "[?][ \t]\'" command)
          -    (setq command (concat command " *")))
          -  (setq command (concat "git " command))
          -  (dired-do-shell-command command arg file-list)
          -  (message command))
          -
          -
          - -

          -via Xah Lee: +This sort function by Xah Lee +is easy to use and does what it should, great!, However, I added some -desc +sister sorts for reverse sorting.

          (defun xah-dired-sort ()
          @@ -7189,8 +7190,42 @@ or remove files from git
                ((equal sort-by "dir-desc") (setq arg "-Al --si --time-style long-iso --group-directories-first -r"))
                (t (error "logic error 09535" )))
               (dired-sort-other arg )))
          +
          +
          +
        4. -(defun tvd-dired-git-add(&optional arg file-list) +
        5. dired git helpers
          +

          +via bin chen: +make git commands available from dired buffer, which can be used in +those rare cases, where my wrappers below don't fit. +

          +
          +
          (defun diredext-exec-git-command-in-shell (command &optional arg file-list)
          +  "Run a shell command git COMMAND  ' on the marked files.  if no
          +files marked, always operate on current line in dired-mode"
          +  (interactive
          +   (let ((files (dired-get-marked-files t current-prefix-arg)))
          +     (list
          +      ;; Want to give feedback whether this file or marked files are used:
          +      (dired-read-shell-command "git command on %s: " current-prefix-arg files)
          +      current-prefix-arg
          +      files)))
          +  (unless (string-match "[?][ \t]\'" command)
          +    (setq command (concat command " *")))
          +  (setq command (concat "git " command))
          +  (dired-do-shell-command command arg file-list)
          +  (message command))
          +
          +
          + +

          +some git commandline wrappers which directly work on git files, +called with "hydras". +

          +
          +
          (defun tvd-dired-git-add(&optional arg file-list)
          +  "Add marked or current file to current repository (stash)."
             (interactive
               (let ((files (dired-get-marked-files t current-prefix-arg)))
                 (list current-prefix-arg files)))
          @@ -7198,6 +7233,7 @@ or remove files from git
             (revert-buffer))
           
           (defun tvd-dired-git-rm(&optional arg file-list)
          +  "Remove marked or current file from current repository and filesystem."
             (interactive
              (let ((files (dired-get-marked-files t current-prefix-arg)))
                (list current-prefix-arg files)))
          @@ -7205,46 +7241,122 @@ or remove files from git
             (revert-buffer))
           
           (defun tvd-dired-git-ungit(&optional arg file-list)
          +  "Like `tvd-dired-git-rm' but keep the files in the filesystem (unstage)."
             (interactive
              (let ((files (dired-get-marked-files t current-prefix-arg)))
                (list current-prefix-arg files)))
             (dired-do-shell-command "git rm -rf --cached * " arg file-list)
             (revert-buffer))
          -
          -
          -(eval-after-load 'dired '(progn
          -                           ;; stay with 1 dired buffer per instance
          -                           (define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file)
          -                           (define-key dired-mode-map (kbd "^") (lambda () (interactive) (find-alternate-file "..")))
          -                           (define-key dired-mode-map (kbd "<C-left>") (lambda () (interactive) (find-alternate-file "..")))
          -                           (define-key dired-mode-map (kbd "s") 'xah-dired-sort)
          -
          -                           (define-prefix-command 'tvd-dired-git-map)
          -                           (define-key dired-mode-map (kbd "g") 'tvd-dired-git-map)
          -                           (define-key tvd-dired-git-map (kbd "a") 'tvd-dired-git-add)
          -                           (define-key tvd-dired-git-map (kbd "d") 'tvd-dired-git-rm)
          -                           (define-key tvd-dired-git-map (kbd "u") 'tvd-dired-git-ungit)
          -
          -                           (defalias 'edit-dired 'wdired-change-to-wdired-mode)
          -                           (define-key dired-mode-map (kbd "C-c C-c") 'wdired-change-to-wdired-mode)))
           
          +
        6. + +
        7. dired navigation
          +

          +I'm used to jump around with pos1+end +

          +
          +
          (defun tvd-dired-begin ()
          +  "Move point to the first directory in the listing .."
          +  (interactive)
          +  (goto-char (point-min))
          +  (dired-next-dirline 2))
          +
          +(defun tvd-dired-end ()
          +  "Move point to the last file or directory in the listing."
          +  (interactive)
          +  (goto-char (point-max))
          +  (dired-previous-line 1))
          +
          +
          +
        8. + +
        9. dired buffer names
          +

          +This took me a long time to figure out, but I finally got it: I +really hate it how dired names its buffers, it just uses the +basename part of the current working directory as buffer name. So +when there are a couple of dozen buffers open and one of them is +named "tmp" I just can't see it. So what I do here is to rename +each dired buffer right after its creation by advising +`dired-internal-noselect'. My dired buffers have such names now: +dired: ~/tmp. I can find them easily, and I can reach all dired +buffers very fast thanks to the *dired prefix. And they are now +clearly marked as non-file buffers. In fact I consider this +behavior as a bug, but I doubt many people would agree :) +

          -HINTS: +(defun tvd-dired-fix-buffer-name (buffer) + "Modify dired buffer names to this pattern: dired: full-path" + (interactive) + (with-current-buffer buffer + (rename-buffer (format "dired: %s" default-directory))) + buffer) +(advice-add 'dired-internal-noselect :filter-return 'tvd-dired-fix-buffer-name)

          - + +
          +
          (advice-add 'dired-internal-noselect
          +            :filter-return
          +            '(lambda (buffer)
          +               "Modify dired buffer names to this pattern: *dired: full-path*"
          +               (interactive)
          +               (with-current-buffer buffer
          +                 (rename-buffer (format "*dired: %s*" default-directory)))
          +               buffer))
          +
          +
        10. + +
        11. dired config and key bindings
          +

          +and finally put everything together. +

          + +
          +
          (eval-after-load 'dired
          +  '(progn
          +     ;; stay  with 1  dired buffer  per instance
          +     ;; when changing directories
          +     (define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file)
          +     (define-key dired-mode-map (kbd "^") (lambda () (interactive) (find-alternate-file "..")))
          +     (define-key dired-mode-map (kbd "<C-left>") (lambda () (interactive) (find-alternate-file "..")))
          +
          +     ;; Xah Lee'S custom sort's
          +     (define-key dired-mode-map (kbd "s") 'xah-dired-sort)
          +
          +     ;; my git "hydras"
          +     (define-prefix-command 'tvd-dired-git-map)
          +     (define-key dired-mode-map (kbd "g") 'tvd-dired-git-map)
          +     (define-key tvd-dired-git-map (kbd "a") 'tvd-dired-git-add)
          +     (define-key tvd-dired-git-map (kbd "d") 'tvd-dired-git-rm)
          +     (define-key tvd-dired-git-map (kbd "u") 'tvd-dired-git-ungit)
          +
          +     ;; edit filenames
          +     (defalias 'edit-dired 'wdired-change-to-wdired-mode)
          +     (define-key dired-mode-map (kbd "C-c C-c") 'wdired-change-to-wdired-mode)
          +
          +     ;; navigation,  use TAB  and C-TAB  to move
          +     ;; point to  next or prev dir  like in info
          +     ;; mode, and  HOME+END to reach the  end or
          +     ;; beginning of the listing.
          +     (define-key dired-mode-map (kbd "<tab>") 'dired-next-dirline)
          +     (define-key dired-mode-map (kbd "<C-tab>") 'dired-prev-dirline)
          +     (define-key dired-mode-map (kbd "<home>") 'tvd-dired-begin)
          +     (define-key dired-mode-map (kbd "<end>") 'tvd-dired-end)))
          +
          +
          +
        -
        -

        6.5 Emacs Interface

        + +
        +

        6.5 Emacs Interface

        -
        -

        6.5.1 Parens

        +
        +

        6.5.1 Parens

        display matching braces @@ -7265,8 +7377,8 @@ display matching braces

        -
        -

        6.5.2 highlight todo keywords (such as FIXME)

        +
        +

        6.5.2 highlight todo keywords (such as FIXME)

        Absolutely needed! @@ -7281,8 +7393,8 @@ Absolutely needed!


        -
        -

        6.5.3 UNDO Tree Mode

        +
        +

        6.5.3 UNDO Tree Mode

        Better undo, with redo support. @@ -7325,8 +7437,8 @@ M-_ catched by Xmonad


        -
        -

        6.5.4 Smarter M-x Mode (smex)

        +
        +

        6.5.4 Smarter M-x Mode (smex)

        This is really cool and I don't know how I could ever live without it. @@ -7349,8 +7461,8 @@ fails @win, so wrap it

        -
        -

        6.5.5 Which Func

        +
        +

        6.5.5 Which Func

        display current function - if any - in mode line @@ -7365,8 +7477,8 @@ display current function - if any - in mode line


        -
        -

        6.5.6 Show current-line in the Fringe

        +
        +

        6.5.6 Show current-line in the Fringe

        (require 'fringe-current-line)
        @@ -7385,8 +7497,8 @@ also change the color (matching the mode line
         
        -
        -

        6.5.7 Recent Files

        +
        +

        6.5.7 Recent Files

        You know the file you edited yesterday had "kri" in its name, but @@ -7480,8 +7592,8 @@ exclude some auto generated files

        -
        -

        6.5.8 IDO mode

        +
        +

        6.5.8 IDO mode

        There are other completion enhancement packages available like ivy @@ -7623,8 +7735,8 @@ by howardism: [re]open non-writable file with sudo

        -
        -

        6.5.9 Save cursor position

        +
        +

        6.5.9 Save cursor position

        So the next time I start emacs and open a file I were editing @@ -7645,8 +7757,8 @@ before.

        -
        -

        6.5.10 DoReMi experimentation

        +
        +

        6.5.10 DoReMi experimentation

        I'm not using it a lot, sometimes I tune the background color though. @@ -7675,8 +7787,8 @@ cool ones: doremi-buffers, doremi-all-faces-fg+ [s, h]


        -
        -

        6.5.11 Hightligt TABs

        +
        +

        6.5.11 Hightligt TABs

        not a mode, but however: higlight TABs in certain modes @@ -7699,8 +7811,8 @@ not a mode, but however: higlight TABs in certain modes

        -
        -

        6.5.12 Browse kill-ring

        +
        +

        6.5.12 Browse kill-ring

        when active use n and p to browse, <ret> to select, it's the same @@ -7718,8 +7830,8 @@ as <M-y> and I never really use it…

        -
        -

        6.5.13 goto-last-change

        +
        +

        6.5.13 goto-last-change

        Very handy, jump to last change[s]. @@ -7736,8 +7848,8 @@ Very handy, jump to last change[s].

        -
        -

        6.5.14 Bookmarks

        +
        +

        6.5.14 Bookmarks

        I use the builtin bookmark feature quite a lot and am happy with @@ -7769,8 +7881,8 @@ I use the same aliases as in apparix for bash (since I'm used to them)

        -
        -

        6.5.15 which-key

        +
        +

        6.5.15 which-key

        One of the best unobstrusive modes for key help ever. Just start @@ -7790,8 +7902,8 @@ press from there along with the associated functions.

        -
        -

        6.5.16 iBuffer mode

        +
        +

        6.5.16 iBuffer mode

        iBuffer is a great interactive buffer management tool included with @@ -8001,8 +8113,8 @@ override ibuffer M-o binding

        -
        -

        6.5.17 Printing

        +
        +

        6.5.17 Printing

        overwrites printing default menu, access via menu File => Print @@ -8047,8 +8159,8 @@ via -

        6.5.18 Beacon mode (pointer blink)

        +
        +

        6.5.18 Beacon mode (pointer blink)

        Source: beacon mode @@ -8078,8 +8190,8 @@ editing position.

        -
        -

        6.6 mode-line setup (must be the last mode)

        +
        +

        6.6 mode-line setup (must be the last mode)

        I just append the current version of my emacs config and leave out @@ -8144,13 +8256,13 @@ custom modeline

        -
        -

        7 Emacs Autoconfig / Customizegroup stuff

        +
        +

        7 Emacs Autoconfig / Customizegroup stuff


        -
        -

        7.1 font faces

        +
        +

        7.1 font faces

        Font color config, must always be the last thing so all hook faces are loaded. @@ -8230,8 +8342,8 @@ unless we're on windoze


        -
        -

        7.2 variables

        +
        +

        7.2 variables

        If I ever use custom-group to customize a mode, then I create a @@ -8251,8 +8363,8 @@ here. So, in normal times this should be empty, but needs to exist.

        -
        -

        7.3 done

        +
        +

        7.3 done

        Finally, this message is being displayed. If this isn't the case I @@ -8269,7 +8381,7 @@ know easily that something went wrong.

        Author: Tom

        -

        Created: 2017-08-05 Sa 20:33

        +

        Created: 2017-08-07 Mo 21:10

        Validate