Files
dot-emacs/emacs.html
Thomas von Dein f50084bebd +fixes
2017-07-09 12:29:27 +02:00

7328 lines
348 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2017-07-09 So 12:29 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Tom" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2013 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org3e95909">1. Introduction</a></li>
<li><a href="#orgace4d38">2. Config Log, Trivia, Notes, Changes</a>
<ul>
<li><a href="#org22656be">2.1. Changelog</a></li>
<li><a href="#org0db84d7">2.2. <span class="todo TODO">TODO</span> </a></li>
<li><a href="#orgaacd3cb">2.3. .emacs config version</a></li>
</ul>
</li>
<li><a href="#org02fd286">3. System Specifics</a>
<ul>
<li><a href="#org612d341">3.1. Global init file+dir vars, portable</a></li>
<li><a href="#org118828d">3.2. Fontlock-mode - use syntax highlighting on graphical displays</a></li>
<li><a href="#orgba83f12">3.3. line-cursor in console</a></li>
<li><a href="#org9ae6dc2">3.4. Backup Config</a></li>
<li><a href="#orgd956bb1">3.5. console backspace fix</a></li>
<li><a href="#orgfe7f135">3.6. hide menu- and tool-bar</a></li>
<li><a href="#org42aabfc">3.7. stay silent on startup</a></li>
<li><a href="#org0209cd0">3.8. y means yes</a></li>
<li><a href="#orga25f218">3.9. show col in modeline</a></li>
<li><a href="#org2e02326">3.10. file or buffer in title</a></li>
<li><a href="#orgd1d9527">3.11. avoid invalid files</a></li>
<li><a href="#org7334313">3.12. prepare load-path</a></li>
<li><a href="#org053f72c">3.13. byte-compile all of them, if needed</a></li>
<li><a href="#org0a13a91">3.14. increase fontsize with ctrl-+ and ctrl--</a></li>
<li><a href="#org887577c">3.15. WINDOW management stuff</a>
<ul>
<li><a href="#orgf1148c0">3.15.1. resize windows by keyboard</a></li>
<li><a href="#org05c7bc5">3.15.2. switch windows with MS-WINDOWS key</a></li>
<li><a href="#org282c3a2">3.15.3. M-o switch window or buffer</a></li>
<li><a href="#orgcd2a705">3.15.4. Split window to 4 parts</a></li>
</ul>
</li>
<li><a href="#orgd9b279b">3.16. re-read a modified buffer</a></li>
<li><a href="#org7170b0a">3.17. global TAB/Indent config</a></li>
<li><a href="#org91aa178">3.18. handy aliases</a></li>
<li><a href="#orgc37a9d7">3.19. various settings</a></li>
<li><a href="#org4d0a51b">3.20. load imenu</a></li>
<li><a href="#org6a4b9e7">3.21. copy/paste Config</a></li>
<li><a href="#orgc4c79f0">3.22. use more mem</a></li>
<li><a href="#org3d34af2">3.23. better file name completion</a></li>
<li><a href="#org3609bd8">3.24. abbreviations</a></li>
<li><a href="#org97f002f">3.25. meaningful names for buffers with the same name</a></li>
<li><a href="#orgc369e59">3.26. packages</a></li>
<li><a href="#orga99b0e3">3.27. My own global variables</a></li>
<li><a href="#orgdc6d06d">3.28. More scratch space</a></li>
</ul>
</li>
<li><a href="#org54c1d15">4. Global Key Bindings</a>
<ul>
<li><a href="#org27d2628">4.1. c-h != delete</a></li>
<li><a href="#orgd531c40">4.2. general keys (re-)mappings</a></li>
<li><a href="#org1c80d66">4.3. display a list of my own global key bindings and aliases</a></li>
</ul>
</li>
<li><a href="#org31da5d6">5. Productivity Functions</a>
<ul>
<li><a href="#orgfa8b60d">5.1. goto line with tmp line numbers</a></li>
<li><a href="#orgd01c0ed">5.2. invert fore- and background</a></li>
<li><a href="#org8f3d06d">5.3. Some useful bindings for Home and End keys Hit the key once to</a></li>
<li><a href="#orgdbc39c6">5.4. percent function</a></li>
<li><a href="#orgaf17dfc">5.5. Simulate vi's % function</a></li>
<li><a href="#org2b9f7f9">5.6. Move region</a></li>
<li><a href="#org1cde696">5.7. comment-uncomment region with one key binding</a></li>
<li><a href="#org08a793d">5.8. search for symbol at point</a></li>
<li><a href="#orgb368809">5.9. Window Margin</a></li>
<li><a href="#org6e8832c">5.10. Fill and justify a paragraph</a></li>
<li><a href="#org6bdfe95">5.11. Make a read-only copy of the current buffer</a></li>
<li><a href="#orgaa566f2">5.12. Cleanup, close all windows and kill all buffers</a></li>
<li><a href="#org690152b">5.13. Cleanup current buffer</a></li>
<li><a href="#orgfa697ab">5.14. Better newline(s)</a></li>
<li><a href="#org4fdd1b6">5.15. Mouse Rectangle</a></li>
<li><a href="#org3c5fdd1">5.16. DOS &lt;=&gt; UNIX conversion helpers</a></li>
<li><a href="#org0fcd0b1">5.17. helper do add the same thing to multiple mode hooks</a></li>
<li><a href="#orgcaa444d">5.18. helper to catch load errors</a></li>
<li><a href="#org6c9e422">5.19. Alignment Wrappers</a></li>
<li><a href="#orge711a42">5.20. String Helpers</a></li>
</ul>
</li>
<li><a href="#org7acd779">6. Modes</a>
<ul>
<li><a href="#orgb77709f">6.1. Programming Languages</a>
<ul>
<li><a href="#org9ed682f">6.1.1. VALA</a></li>
<li><a href="#org870753c">6.1.2. python mode</a></li>
<li><a href="#orgc8cf746">6.1.3. cperl mode</a></li>
<li><a href="#orgf26d44b">6.1.4. Paredit for lisp only</a></li>
<li><a href="#org6fc242d">6.1.5. ETAGS</a></li>
</ul>
</li>
<li><a href="#org1082fee">6.2. Text Modes</a>
<ul>
<li><a href="#orgd430407">6.2.1. sgml</a></li>
<li><a href="#orgcb6def0">6.2.2. web-mode (JS, HTML, CSS combined)</a></li>
<li><a href="#orgdff03c0">6.2.3. Cisco Mode</a></li>
<li><a href="#orgb737379">6.2.4. Markdown</a></li>
<li><a href="#org352873b">6.2.5. POD mode</a></li>
<li><a href="#org5975c00">6.2.6. conf-mode</a></li>
<li><a href="#org08058ca">6.2.7. Config::General mode</a></li>
</ul>
</li>
<li><a href="#org91f94b9">6.3. Text Manupilation</a>
<ul>
<li><a href="#org572f83c">6.3.1. expand-region</a></li>
<li><a href="#org9992dc4">6.3.2. Mark, Copy, Yank Things</a></li>
<li><a href="#org462a3f4">6.3.3. change-inner</a></li>
<li><a href="#org3175c28">6.3.4. Rotate text</a></li>
<li><a href="#org45575d0">6.3.5. Word wrapping</a></li>
<li><a href="#org44c74e2">6.3.6. Viking Mode</a></li>
<li><a href="#orgb540036">6.3.7. HTMLize</a></li>
<li><a href="#org26f2cc6">6.3.8. iEdit (inline edit multiple searches)</a></li>
</ul>
</li>
<li><a href="#org55531a2">6.4. Interactives</a>
<ul>
<li><a href="#orgd7a54af">6.4.1. eShell stuff, or if interactive stuff is needed, use ansi-term</a></li>
<li><a href="#orge10fe7a">6.4.2. Emacs LISP interactive</a></li>
<li><a href="#org9af09e4">6.4.3. el2markdown</a></li>
<li><a href="#orga16c73c">6.4.4. tramp mode</a></li>
<li><a href="#org36e2ef7">6.4.5. org mode</a></li>
<li><a href="#orgfe851c9">6.4.6. org table mode</a></li>
<li><a href="#orgc5b7010">6.4.7. org mode slideshows</a></li>
<li><a href="#org814009d">6.4.8. outshine mode</a></li>
<li><a href="#orgcf462fe">6.4.9. outline mode</a></li>
<li><a href="#orga15337b">6.4.10. narrowing (no mode but fits here)</a></li>
<li><a href="#org75fe805">6.4.11. ANSI-TERM (inferior shells/interpreters and REPLs)</a></li>
<li><a href="#org984408f">6.4.12. Puppet</a></li>
<li><a href="#org741d574">6.4.13. Novel Mode - Screen Reader</a></li>
<li><a href="#orgf60bf97">6.4.14. Macro Math</a></li>
<li><a href="#orgf4c9895">6.4.15. Common-Lisp (SLIME)</a></li>
<li><a href="#org80f2a39">6.4.16. INFO Mode</a></li>
<li><a href="#org7c07808">6.4.17. calc et al.</a></li>
<li><a href="#orgf793545">6.4.18. MACROs</a></li>
<li><a href="#orge706b96">6.4.19. EWW browser stuff</a></li>
<li><a href="#orga813bbb">6.4.20. Firestarter</a></li>
<li><a href="#org3aee3ce">6.4.21. Tabulated List Mode</a></li>
<li><a href="#org1b37644">6.4.22. Help Mode</a></li>
<li><a href="#org7dd3ab4">6.4.23. Suggest Mode</a></li>
</ul>
</li>
<li><a href="#orgbbbb61f">6.5. Emacs Interface</a>
<ul>
<li><a href="#org45d01a9">6.5.1. Parens</a></li>
<li><a href="#org64ac535">6.5.2. highlight todo keywords (such as <i>FIXME</i>)</a></li>
<li><a href="#org93327f8">6.5.3. UNDO Tree Mode</a></li>
<li><a href="#orga571836">6.5.4. Smarter M-x Mode (smex)</a></li>
<li><a href="#org3aecb4e">6.5.5. Which Func</a></li>
<li><a href="#orgab89c04">6.5.6. Show current-line in the Fringe</a></li>
<li><a href="#orga860222">6.5.7. Recent Files</a></li>
<li><a href="#org1607b01">6.5.8. IDO mode</a></li>
<li><a href="#org3615d48">6.5.9. Save cursor position</a></li>
<li><a href="#org65afd36">6.5.10. DoReMi experimentation</a></li>
<li><a href="#org7d42663">6.5.11. Hightligt TABs</a></li>
<li><a href="#orgc31b7a1">6.5.12. Browse kill-ring</a></li>
<li><a href="#org38a233d">6.5.13. goto-last-change</a></li>
<li><a href="#orgf1a8985">6.5.14. Bookmarks</a></li>
<li><a href="#org1c8dda8">6.5.15. which-key</a></li>
<li><a href="#orgeddda89">6.5.16. iBuffer mode</a></li>
<li><a href="#orgc0650d1">6.5.17. Printing</a></li>
<li><a href="#org921ad8b">6.5.18. Beacon mode (pointer blink)</a></li>
</ul>
</li>
<li><a href="#orgbb6fc6c">6.6. mode-line setup (must be the last mode)</a></li>
</ul>
</li>
<li><a href="#orga10fcf5">7. Emacs Autoconfig / Customizegroup stuff</a>
<ul>
<li><a href="#orgcc0e1d4">7.1. font faces</a></li>
<li><a href="#orgd50933d">7.2. variables</a></li>
<li><a href="#orge7a6e26">7.3. done</a></li>
</ul>
</li>
</ul>
</div>
</div>
<p>
Toms Emacs Config - portable - version (20170707.01) -*-emacs-lisp-*-
</p>
<div id="outline-container-org3e95909" class="outline-2">
<h2 id="org3e95909"><span class="section-number-2">1</span> Introduction</h2>
<div class="outline-text-2" id="text-1">
<p>
This is my emacs config, it is more than twenty years old. It
mostly contains stuff implemented by myself, but there are also
snippets I found here and there. The config will probably not be
usefull for anyone else but myself.
</p>
<p>
If you're reading the html exported version: be advised, that I do
NOT maintain my emacs config with "literate programming". Instead I
maintain a plain old .emacs file, which I use at home and work, on
windows, linux and freebsd, console or X11. I use outshine minor
mode to organize my config and I use outorg to export it to org
mode and from there to html.
</p>
<p>
Also I don't use any packaging mechanism, instead I download all
the required elisp files manually and update them only if
required. There's a melpa config toggle though, which I only use to
try out new modes. I distribute my .emacs config along with the
lisp directory to all systems where I need it using a Makefile and
scp. The reason is that I work on a couple of systems without
direct internet access, where packaging or git don't work. So, I
don't use these things nowhere. It's ok for me, I'm used to it.
</p>
<p>
Another thing you might wonder about are my key bindings or
(sometimes) the lack thereof. My problem with key bindings is that
I don't have any useful prefixes left. I am using ONLY commandline
tools, my window manager is Xmonad, I use screen, bash and
mutt. The only applications where I use the mouse is firefox and
gimp. So, it is very hard to avoid conflicts AND memoize new key
bindings. Some key bindings are so deeply wired into muscle memory
that I could use them while drunk or dying.
</p>
<p>
Therefore I use lots of aliases in emacs for not-so-regular used
functions, which turned out to be sometimes easier to type than an
actual key binding.
</p>
<p>
The html export has been created with the function
outshine-to-html, written by myself, see below.
</p>
</div>
</div>
<div id="outline-container-orgace4d38" class="outline-2">
<h2 id="orgace4d38"><span class="section-number-2">2</span> Config Log, Trivia, Notes, Changes</h2>
<div class="outline-text-2" id="text-2">
</div><div id="outline-container-org22656be" class="outline-3">
<h3 id="org22656be"><span class="section-number-3">2.1</span> Changelog</h3>
<div class="outline-text-3" id="text-2-1">
<p>
20160420.03:
</p>
<ul class="org-ul">
<li>started with Changelog and outshine mode</li>
<li>fixed tabs</li>
<li>reorganized keys</li>
<li>added new goto line func</li>
</ul>
<p>
20160421.01:
</p>
<ul class="org-ul">
<li>added smex</li>
<li>added show-keys()</li>
<li>added redo</li>
<li>ssh et. al. interactive in eshell</li>
<li>added recompile()</li>
</ul>
<p>
20160421.02:
</p>
<ul class="org-ul">
<li>added dividers</li>
<li>using org headers</li>
<li>better show-keys()</li>
</ul>
<p>
20160421.03:
</p>
<ul class="org-ul">
<li>added windows support</li>
</ul>
<p>
20160421.04:
</p>
<ul class="org-ul">
<li>added elisp repl support</li>
</ul>
<p>
20160424.01:
</p>
<ul class="org-ul">
<li>added custom modeline</li>
<li>added which-func-mode</li>
<li>shortened some major mode names</li>
<li>added diminish for shorter minor mode names</li>
<li>added better printing menu</li>
</ul>
<p>
20160425.01:
</p>
<ul class="org-ul">
<li>fixed ielm integration</li>
<li>C-x e = eval (buffer|region)</li>
<li>C-x C-e = send (buffer|region) to ielm and eval there</li>
</ul>
<p>
20160425.02:
</p>
<ul class="org-ul">
<li>fix word wrapping</li>
</ul>
<p>
20160426.01:
</p>
<ul class="org-ul">
<li>fixed mode-line config 4 win emacs</li>
<li>added M-&lt;up|down&gt; move-region</li>
</ul>
<p>
20160426.01:
</p>
<ul class="org-ul">
<li>added markdown</li>
</ul>
<p>
20160427.01+02:
</p>
<ul class="org-ul">
<li>cosmetics</li>
</ul>
<p>
20160428.01:
</p>
<ul class="org-ul">
<li>fringe cursor</li>
</ul>
<p>
20160429.01:
</p>
<ul class="org-ul">
<li>file name completion</li>
<li>C-# finally, search for symbol at point</li>
<li>C-c C-c now comments or uncomments regios or line, whatever is current</li>
</ul>
<p>
20160501.01:
</p>
<ul class="org-ul">
<li>no outshine minor in python</li>
<li>added recent files support</li>
</ul>
<p>
20160501.02:
</p>
<ul class="org-ul">
<li>added margin() function, no key binding though</li>
</ul>
<p>
20160503.01:
</p>
<ul class="org-ul">
<li>added C-q fill+justify paragraph macro</li>
<li>added alias 'i' for info manuals</li>
</ul>
<p>
20160503.02:
</p>
<ul class="org-ul">
<li>added 'cp to create read-only buffer copy</li>
</ul>
<p>
20160504.01:
</p>
<ul class="org-ul">
<li>better fringe, now also inversed with C-c i</li>
</ul>
<p>
20160505.01:
</p>
<ul class="org-ul">
<li>added electric-align mode</li>
<li>better outline header colors</li>
<li>no more line numbers in sk occur buffer</li>
</ul>
<p>
20160507.01:
</p>
<ul class="org-ul">
<li>disable electric-align-momde (broken), using M-x align instead</li>
<li>hightlighting TABs with extra font</li>
</ul>
<p>
20160509.01:
</p>
<ul class="org-ul">
<li>fixed margin()</li>
<li>discovered that C-x 0 deletes current window, god did I miss this one!</li>
</ul>
<p>
20160510.01:
</p>
<ul class="org-ul">
<li>added kill-all-buffers()</li>
</ul>
<p>
20160510.02:
</p>
<ul class="org-ul">
<li>no more load-file</li>
<li>added C-c [wlpa]: easy copy things at point
without marking them</li>
</ul>
<p>
20160511.01:
</p>
<ul class="org-ul">
<li>better buffer names with uniquify</li>
</ul>
<p>
20160511.02:
</p>
<ul class="org-ul">
<li>copy-* functions now blink region</li>
<li>added del-* functions, bound to C-d:
press multiple times to delete word, line, paragraph, buffer</li>
</ul>
<p>
20160513.01:
</p>
<ul class="org-ul">
<li>fixed END key func</li>
</ul>
<p>
20160516.01:
</p>
<ul class="org-ul">
<li>removed C-d stuff, replaced with vikiing-mode</li>
</ul>
<p>
20160517.01:
</p>
<ul class="org-ul">
<li>changed highlight face</li>
<li>enabled debug-on-error in lispmode</li>
<li>enabled IDO mode globally, I just tend to love love love it</li>
</ul>
<p>
20160517.02:
</p>
<ul class="org-ul">
<li>added workgroup.el, started experimenting</li>
<li>enabled Super<sub>L</sub> (for workgroups)</li>
</ul>
<p>
20160519.01:
</p>
<ul class="org-ul">
<li>fixed write-file, now ido mode is disabled for this one.</li>
</ul>
<p>
20160520.01:
</p>
<ul class="org-ul">
<li>no x-sel on windows (C-v+C-c =&gt; emacs doesn't work anymore otherwise)</li>
<li>added eldoc mode to elisp hook</li>
</ul>
<p>
20160520.02:
</p>
<ul class="org-ul">
<li>added novel-mode, for better reading</li>
</ul>
<p>
20160522.01:
</p>
<ul class="org-ul">
<li>added vi's % jump paren emulation</li>
<li>enhanced novel-mode</li>
<li>enabled save-place mode which is VERY useful in combination with
novel-mode</li>
</ul>
<p>
20160523.01:
</p>
<ul class="org-ul">
<li>detached novel-mode into its own module, maintain on github
enabled with C-n</li>
</ul>
<p>
20160526.01:
</p>
<ul class="org-ul">
<li>added toggle-melpa</li>
</ul>
<p>
20160527.01:
</p>
<ul class="org-ul">
<li>added htmlize</li>
</ul>
<p>
20160529.01:
</p>
<ul class="org-ul">
<li>added html-listify</li>
</ul>
<p>
20160530.01:
</p>
<ul class="org-ul">
<li>added key chords</li>
<li>added open-line-above+below</li>
</ul>
<p>
20160602.01:
</p>
<ul class="org-ul">
<li>C-q now fills and pressing it again un-fills</li>
</ul>
<p>
20160606.01:
</p>
<ul class="org-ul">
<li>deactivated key-chords, I didn't use them and they were annoying.</li>
</ul>
<p>
20160609.01:
</p>
<ul class="org-ul">
<li>added puppet mode</li>
</ul>
<p>
20160614.01:
</p>
<ul class="org-ul">
<li>added rotate-text (C-t)</li>
<li>added macro math (C-x-0) (0 used as =)</li>
</ul>
<p>
20160713.01:
</p>
<ul class="org-ul">
<li>fixed indent for Makefiles</li>
</ul>
<p>
20160729.01:
</p>
<ul class="org-ul">
<li>rm duplicate abbr defs</li>
</ul>
<p>
20160916.01:
</p>
<ul class="org-ul">
<li>enable mouse mark to copy</li>
</ul>
<p>
20160926.01:
</p>
<ul class="org-ul">
<li>Dont kill-buffer, kill-this-buffer instead</li>
</ul>
<p>
20160928.01:
</p>
<ul class="org-ul">
<li>change macro math C-x 0 to C-x C-0 so that C-0 is
usable again for close window</li>
<li>elisp mode: debug-on-error only on non-cygwin</li>
</ul>
<p>
20161011.01:
</p>
<ul class="org-ul">
<li>added dos2unix and unix2dos</li>
</ul>
<p>
20161014.01:
</p>
<ul class="org-ul">
<li>fix auto-indent in conf-mode</li>
<li>force C-c C-c comment-uncomment in conf-mode</li>
</ul>
<p>
20161018.01:
</p>
<ul class="org-ul">
<li>more effective conf-mode disarming (own defun)</li>
</ul>
<p>
20161022.01:
</p>
<ul class="org-ul">
<li>better paren mode</li>
</ul>
<p>
20161024.01:
</p>
<ul class="org-ul">
<li>fixed org mode hook</li>
</ul>
<p>
20161027.01:
</p>
<ul class="org-ul">
<li>turn off tramp stuff in kill-all-buffers as well,
so that after executing it, no more ssh prompt
appears on C-x f.</li>
</ul>
<p>
20161106.01:
</p>
<ul class="org-ul">
<li>added iedit mode with C-c e</li>
<li>added file-open support to eshell (aliases: vi + emacs)</li>
<li>much better C-l behavior in eshell (eshell/clear)</li>
</ul>
<p>
20161205.01:
</p>
<ul class="org-ul">
<li>added SLIME, sbcl and paredit support, only loaded when exists</li>
</ul>
<p>
20161206.01:
</p>
<ul class="org-ul">
<li>elisp mode: debug-on-error finally completeley disabled</li>
<li>added alias 'table, which enables org-mode table support everywhere</li>
</ul>
<p>
20170205.01:
</p>
<ul class="org-ul">
<li>started with ETAGS support</li>
</ul>
<p>
20170212.01:
</p>
<ul class="org-ul">
<li>added copy-defun (C-c f) to copy whole functions as is</li>
</ul>
<p>
20170212.02:
</p>
<ul class="org-ul">
<li>now using € (alt-r + e) as jump to etag</li>
</ul>
<p>
20170215.02:
</p>
<ul class="org-ul">
<li>added goto-last-change (C-b)</li>
<li>+test section</li>
<li>paredit</li>
</ul>
<p>
20170215.02:
</p>
<ul class="org-ul">
<li>disabled workgoups mode, don't use it, doesn't load correctly</li>
<li>fixed windows switch, no more printing popup on startup</li>
</ul>
<p>
20170220.01:
</p>
<ul class="org-ul">
<li>finally disabled aggressive-indent, it annoys more than it helps</li>
<li>added some bookmark aliases (bm, to, bl, like apparix)</li>
<li>added C-c y [..] copy+yank functions so that I can copy and paste
stuff very fast with one key commbo, like yy in vi.</li>
<li>added copy-parens, copy-quote, copy-help (help message)</li>
</ul>
<p>
20170220.02:
</p>
<ul class="org-ul">
<li>fixed C-c y y: indent correctly</li>
</ul>
<p>
20170220.03:
</p>
<ul class="org-ul">
<li>fixed C-y+mouse-2: both use primary selection</li>
</ul>
<p>
20170221.01:
</p>
<ul class="org-ul">
<li>added which-key</li>
</ul>
<p>
20170223.01:
</p>
<ul class="org-ul">
<li>org-mode enhancements, C-n capture from everywhere</li>
<li>fixed org-mode todo keywords</li>
<li>fixed duplicate yank on win32 on mouse2</li>
</ul>
<p>
20170223.01:
</p>
<ul class="org-ul">
<li>forgot to mv novel-mode to C-c C-n</li>
<li>better org heading faces</li>
</ul>
<p>
20170224.01:
</p>
<ul class="org-ul">
<li>finally fixed C-t, now works everywhere</li>
<li>added more org short commands</li>
</ul>
<p>
20170224.02:
</p>
<ul class="org-ul">
<li>fixed org-mode M-return</li>
<li>added support for windmove (WINDOWS-Key+Arrow: switch window)</li>
</ul>
<p>
20170224.03:
</p>
<ul class="org-ul">
<li>better org colours</li>
</ul>
<p>
20170224.03:
</p>
<ul class="org-ul">
<li>better org capture tpl (DRAFT)</li>
<li>capturing works now globally, even if no org file is open</li>
<li>using org-indent 4</li>
</ul>
<p>
20170224.05:
</p>
<ul class="org-ul">
<li>fixed org tpls</li>
</ul>
<p>
20170227.01:
</p>
<ul class="org-ul">
<li>fix cut/paste org subtress</li>
<li>M-o now switch buffer if 1 window, else switch window</li>
</ul>
<p>
20170227.02:
</p>
<ul class="org-ul">
<li>added alias 'dp which displays everything
there is to know about point (like current face, mode, etc)</li>
</ul>
<p>
20170228.01:
</p>
<ul class="org-ul">
<li>org-refile now works recursivly with completion</li>
<li>org-refile also now uses ido-mode and completes in minibuffer</li>
<li>added alias '2table which converts CSV region to table</li>
<li>added shortcut formatting defuns 'bold, 'italic, 'underline and 'code
which call 'org-emphasize respectively on current region,
including key bindings with org mode keymap (C-c b,/,c,_)</li>
<li>hide emphasized markers in org mode</li>
<li>renamed 'recompile to 'recompile-el and fixed it</li>
<li>added 'info-find-file</li>
</ul>
<p>
20170301.01:
</p>
<ul class="org-ul">
<li>added 'tvd-org-left-or-level-up bound to &lt;C-left&gt; in org mode</li>
<li>&lt;C-up|down&gt; in org mode now jump up on current level and
fold current one and unfolds the target heading</li>
<li>enabled org-bullets</li>
<li>customized height of org-level faces</li>
</ul>
<p>
20170301.02:
</p>
<ul class="org-ul">
<li>org mode emphasize shortcuts (C-c b&#x2026;) expand region if
theres no region active.</li>
</ul>
<p>
20170301.03:
</p>
<ul class="org-ul">
<li>dis line num in org (faster)</li>
</ul>
<p>
20170303.01:
</p>
<ul class="org-ul">
<li>elmacro support added, incl fix for org and outshine,
F6 starts (or stops) a macro and displays the generated
defun. CTRL-F6 executes the last macro interactively,
&lt;ret&gt; repeats, a repeats til EOF, q aborts, e enter macro
(with completion)</li>
<li>C-x C-s on * elmacro &#x2026; * buffer stores it to tvd-macro-file</li>
</ul>
<p>
20170305.01:
</p>
<ul class="org-ul">
<li>added elmacro defadvice, run after done with macro, it will
be evaluated and saved along with a repeater defun.</li>
<li>display red [REC] hint on the mode-line while recording</li>
<li>added ~ shortcut for use inside IDO so I can reach $HOME
very fast from everywhere, no more editing pre-filled
current path and entering <i>home/$user</i>. Yeah!</li>
<li>added flip-window (bound to M-O (ALT-shift-o)</li>
<li>added cleanup-buffer (alias cb)</li>
<li>fixed C-&lt;ret&gt; and C-S-&lt;ret&gt;</li>
</ul>
<p>
20170306.01:
</p>
<ul class="org-ul">
<li>re-enabled linenum mode</li>
<li>fixed custom modeline</li>
</ul>
<p>
20170306.01:
</p>
<ul class="org-ul">
<li>which-func not in elisp anymore</li>
<li>added alias 'ee for 'eval-expression</li>
<li>added 'sa (show-aliases)</li>
<li>some occur enhancements for 'sk and 'sa.</li>
<li>note: inside <b>Occur</b>: q:quit, g:reload, e:edit (buffer must be open)</li>
</ul>
<p>
20170307.01:
</p>
<ul class="org-ul">
<li>fixed 'sk and 'sa</li>
<li>added key bindings to mark things. M-a is the prefix, followed by:
a - all, p - paragraph, f - function, l - line, w - word.</li>
<li>disabled M-O (flip-windows) on console emacs</li>
</ul>
<p>
20170309.01:
</p>
<ul class="org-ul">
<li>added C-c s,u,e and M-a s,u,e</li>
</ul>
<p>
20170309.02:
</p>
<ul class="org-ul">
<li>re-enabled paredit, its better in ielm and slime</li>
<li>added alias 'pe to quickly enable/disable par-edit</li>
<li>added virtual eShell dev /dev/log which stores stuff in <b>LOG</b></li>
</ul>
<p>
20170313.01:
</p>
<ul class="org-ul">
<li>iedit to C-c C-e, so C-c e works again (copy email)</li>
<li>put eshell aliases into .emacs(here) no need for aliases file anymore</li>
<li>added copy-comment (C-c c), copy-and-yank-comment (C-c y c) and
m-mark-comment (M-a c)</li>
</ul>
<p>
20170314.01:
</p>
<ul class="org-ul">
<li>enhanced copy-comment (that is, rewrote it), it now supports
indented multiline comments</li>
</ul>
<p>
20170315.01:
</p>
<ul class="org-ul">
<li>fixed C-c y [cpwf]</li>
<li>fixed copy[+yank+mark] word, it now includes - _ .</li>
<li>added copy-ip (C-c i), yank-ip (C-c y i) and mark-ip (M-a i)</li>
<li>copy-url alternatively copies file-path if it's no url at point</li>
<li>added numerical arg support to yy</li>
</ul>
<p>
20170321.01:
</p>
<ul class="org-ul">
<li>rewrote copy-comment stuff, now supports blocks of comment
after code etc.</li>
</ul>
<p>
20170323.01:
</p>
<ul class="org-ul">
<li>moved the mark,copy,yank stuff into its own mode</li>
</ul>
<p>
20170327.01:
</p>
<ul class="org-ul">
<li>added defadvice for mcyt mode, so that I can use C-v to
always yank the last thing copied.</li>
</ul>
<p>
20170502.01:
</p>
<ul class="org-ul">
<li>added config for ibuffer</li>
</ul>
<p>
20170503.01:
</p>
<ul class="org-ul">
<li>added ibuffer-vc support</li>
</ul>
<p>
20170503.02:
</p>
<ul class="org-ul">
<li>added ibuffer-tramp support</li>
<li>disabled ibuffer tab-collaps stuff</li>
</ul>
<p>
20170505.01:
</p>
<ul class="org-ul">
<li>generalized init-dir+file variables, now more portable, i hope</li>
</ul>
<p>
20170508.01:
</p>
<ul class="org-ul">
<li>backup tramp files remote</li>
<li>do not backup emacs state files</li>
</ul>
<p>
20170509.01:
</p>
<ul class="org-ul">
<li>version fix</li>
</ul>
<p>
20170523.01:
</p>
<ul class="org-ul">
<li>commented ssh backup stuff, not working yet, destroys tramp</li>
<li>added inferior shells for perl, ruby and python (iperl, iruby, ipython)
with ansi-term</li>
</ul>
<p>
20170610.01:
</p>
<ul class="org-ul">
<li>org mode: added C-c C-# to edit src blocks in an extra window</li>
<li>org mode: &lt;ret&gt; opens link in eww</li>
<li>ido-find-file advice: if not writable, try sudo/tramp</li>
<li>+eshell-there remote eshell (Alias: et)</li>
<li>disabled pager in eshell</li>
<li>fixed eshell/x, now uses C-d</li>
<li>org mode: DONE makes heading greyish</li>
<li>re-organized emacs config, now with subsections</li>
<li>removed lisp electric return, destroyed almost all modes</li>
<li>added POD mode with specific abbrevs and including specific outlining</li>
<li>added heading cycle code for outline mode as well</li>
<li>added outline 'n (narrow) + 'w (widen)</li>
<li>added orange fringe for narrowing (org, outline and everywhere else</li>
<li>added alias 'colors</li>
<li>added 'dl (aka describe-library to display the doc string in
COMMENTARY section of .el files</li>
<li>added "C-c t" to copy an org mode cell</li>
<li>ena org pretty entities, list: org-entities-help</li>
<li>2table =&gt; tablify, which is now a function and uses region or whole buffer</li>
<li>added indirect narrowing buffers</li>
<li>renamed all occurences of my- to tvd- so I better know which stuff is mine</li>
<li>added table-to-* org table exporters with aliases</li>
<li>inside org mode: C-c o copy table c[o]lumn, C-c t copy [t]able cell</li>
<li>experimental: added beacon mode (blinking pointer)
(moved 'seq from exp. elpa to lisp/)</li>
<li>added render-html to render current html buffer with eww</li>
<li>added align-regexp-repeat[-left|right] wrappers</li>
<li>fixed org mode C-&lt;down|up&gt; jump paragraphs if not on heading</li>
<li>added 'tvd-outshine-jump (alias 'j) to directly jump to headers
with IDO completion and as sparse-tree, very cool!
mapped to C-c C-j</li>
<li>added <b>text</b> scratch buffer with text mode</li>
<li>added jump-paren-match-or-insert-percent, bound to %, which jumps parens
or inserts a % if not on a paren. Better than C-5, haha.</li>
<li>added 'ffxs</li>
<li>added emacs-change-log</li>
<li>removed GNUS config, not used anymore</li>
<li>restored C-d binding to viking in paredit</li>
<li>added outshine HTML exporter via org: outshine-to-html</li>
<li>fixed outshine config</li>
<li>added (my) config-general-mode</li>
<li>fixed pod format inserters</li>
</ul>
<p>
20170629.01:
</p>
<ul class="org-ul">
<li>added tablist-minor-mode (+config)</li>
<li>added config for tabulated-list-mode</li>
<li>added config for help-mode</li>
<li>added default filename for outshine-to-html</li>
<li>Info mode: C-left+C-right history keys</li>
<li>added loader for el2markdown</li>
<li>removed smart-forward, it annoys me</li>
<li>made tvd-outshine-jump more portable, do not use hardcoded
regexps anymore, use outshine functions</li>
<li>added 'change-inner and ci simulators'</li>
<li>added suggest.el with my own reload function</li>
<li>modified recentf: do not provide files already visited</li>
</ul>
<p>
20170703.01:
</p>
<ul class="org-ul">
<li>fixed recentf-exclude list, now REALLY ignores unreadables</li>
<li>added export for easier export and commit of dot-emacs</li>
<li>added tvd-suggest-jump to jump between input and output</li>
</ul>
<p>
20170707.01:
</p>
<ul class="org-ul">
<li>added C-x 4 to split fram into 4 windows</li>
<li>fixed config-general-mode config</li>
<li>fixed 'emacs-change-log (didn't expand trees before work)</li>
</ul>
</div>
</div>
<div id="outline-container-org0db84d7" class="outline-3">
<h3 id="org0db84d7"><span class="section-number-3">2.2</span> <span class="todo TODO">TODO</span> </h3>
<div class="outline-text-3" id="text-2-2">
<ul class="org-ul">
<li>fix C-c C-j to work in non-elisp buffers too, see /FIXME/s there
and make it recursive like a path or the like</li>
<li>check helpful <a href="https://github.com/wilfred/helpful">https://github.com/wilfred/helpful</a></li>
<li>check no-littering <a href="https://github.com/tarsius/no-littering">https://github.com/tarsius/no-littering</a></li>
<li>submit novel + mark-copy-yank-things-mode to MELPA</li>
<li>put tvd-ci-* stuff into mcyt</li>
<li>check <a href="https://github.com/Wilfred/refine">https://github.com/Wilfred/refine</a>
<a href="https://github.com/Wilfred/emacs-refactor">https://github.com/Wilfred/emacs-refactor</a></li>
</ul>
<hr />
</div>
</div>
<div id="outline-container-orgaacd3cb" class="outline-3">
<h3 id="orgaacd3cb"><span class="section-number-3">2.3</span> .emacs config version</h3>
<div class="outline-text-3" id="text-2-3">
<p>
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.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defvar</span> <span style="color: #a0522d;">tvd-emacs-version</span> <span style="color: #ff0000;">"20170707.01"</span>)
</pre>
</div>
<hr />
</div>
</div>
</div>
<div id="outline-container-org02fd286" class="outline-2">
<h2 id="org02fd286"><span class="section-number-2">3</span> System Specifics</h2>
<div class="outline-text-2" id="text-3">
</div><div id="outline-container-org612d341" class="outline-3">
<h3 id="org612d341"><span class="section-number-3">3.1</span> Global init file+dir vars, portable</h3>
<div class="outline-text-3" id="text-3-1">
<ul class="org-ul">
<li>added dev function which opens a new development frame</li>
</ul>
<p>
since I always use ~/.emacs as my init file, this results in the
correct emacs dir:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> user-init-dir (expand-file-name (concat user-init-file <span style="color: #ff0000;">".d"</span>)))
</pre>
</div>
<p>
<i>FIXME</i>: use (pwd) to determine .emacs.d, make it more portable
use different init dir on cygwin systems
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> tvd-win-home <span style="color: #ff0000;">"C:/Cygwin/home/iz00468"</span>)
(<span style="color: #0000ff;">if</span> (file-exists-p tvd-win-home)
(<span style="color: #0000ff;">setq</span> user-init-dir (expand-file-name <span style="color: #ff0000;">".emacs.d"</span> tvd-win-home))
(<span style="color: #0000ff;">setq</span> tvd-win-home nil))
</pre>
</div>
<p>
all modes and extensions are located here
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> tvd-lisp-dir (expand-file-name <span style="color: #ff0000;">"lisp"</span> user-init-dir))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org118828d" class="outline-3">
<h3 id="org118828d"><span class="section-number-3">3.2</span> Fontlock-mode - use syntax highlighting on graphical displays</h3>
<div class="outline-text-3" id="text-3-2">
<p>
look: <a href="https://www.emacswiki.org/emacs/CustomizingBoth">emacswiki</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">if</span> window-system
(<span style="color: #0000ff;">progn</span>
(global-font-lock-mode 1)
(set-background-color <span style="color: #ff0000;">"white"</span>)
(set-foreground-color <span style="color: #ff0000;">"DarkBlue"</span>)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgba83f12" class="outline-3">
<h3 id="orgba83f12"><span class="section-number-3">3.3</span> line-cursor in console</h3>
<div class="outline-text-3" id="text-3-3">
<p>
better visibility of cursor in console sessions
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">unless</span> (display-graphic-p)
(global-hl-line-mode)
(set-face-background hl-line-face <span style="color: #ff0000;">"DarkGray"</span>)
(set-face-foreground hl-line-face <span style="color: #ff0000;">"Black"</span>))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org9ae6dc2" class="outline-3">
<h3 id="org9ae6dc2"><span class="section-number-3">3.4</span> Backup Config</h3>
<div class="outline-text-3" id="text-3-4">
<p>
I save backup files in a central location below the init dir, that
way they don't clutter productive file systems or repos.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> tvd-backup-directory (expand-file-name <span style="color: #ff0000;">"backups"</span> user-init-dir))
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (file-exists-p tvd-backup-directory))
(make-directory tvd-backup-directory t))
</pre>
</div>
<p>
there's even a trash
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> tvd-trash-directory (expand-file-name <span style="color: #ff0000;">"trash"</span> tvd-backup-directory))
</pre>
</div>
<p>
actual configuration of all things backup related:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> make-backup-files t <span style="color: #006400;">; </span><span style="color: #006400;">backup of a file the first time it is saved.</span>
backup-by-copying t <span style="color: #006400;">; </span><span style="color: #006400;">don't clobber symlinks</span>
version-control t <span style="color: #006400;">; </span><span style="color: #006400;">version numbers for backup files</span>
delete-old-versions t <span style="color: #006400;">; </span><span style="color: #006400;">delete excess backup files silently</span>
delete-by-moving-to-trash t
kept-old-versions 6 <span style="color: #006400;">; </span><span style="color: #006400;">oldest versions to keep when a new numbered backup is made (default: 2)</span>
kept-new-versions 9 <span style="color: #006400;">; </span><span style="color: #006400;">newest versions to keep when a new numbered backup is made (default: 2)</span>
auto-save-default t <span style="color: #006400;">; </span><span style="color: #006400;">auto-save every buffer that visits a file</span>
auto-save-timeout 20 <span style="color: #006400;">; </span><span style="color: #006400;">number of seconds idle time before auto-save (default: 30)</span>
auto-save-interval 200 <span style="color: #006400;">; </span><span style="color: #006400;">number of keystrokes between auto-saves (default: 300)</span>
delete-by-moving-to-trash t
trash-directory tvd-trash-directory
backup-directory-alist `((<span style="color: #ff0000;">"emacs.d/</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">recentf</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">ido.last</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">places</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">"</span> . nil) <span style="color: #006400;">; </span><span style="color: #006400;">do not backup state files</span>
(<span style="color: #ff0000;">"."</span> . ,tvd-backup-directory))) <span style="color: #006400;">; </span><span style="color: #006400;">backup everything else</span>
</pre>
</div>
<p>
However, if the file to be backed up is remote, backup
per remote directory. that way, no root owned files end
up in my home directory, ready to be read by everyone.
This is system specific and only matches special host names.
<i>FIXME</i>: find out programatically hostname und remote user to make this generic
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(advice-add <span style="color: #ff00ff;">'make-backup-file-name-1</span> <span style="color: #8a2be2;">:before</span>
'(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> file)
(<span style="color: #0000ff;">let</span> ((filename (<span style="color: #0000ff;">car</span> file)))
(<span style="color: #0000ff;">if</span> (string-match <span style="color: #ff0000;">"</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">/ssh:.devel[0-9]+</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">:/"</span> filename)
(<span style="color: #0000ff;">setq</span> backup-directory-alist `((<span style="color: #ff0000;">"."</span> . ,(concat (match-string 1 filename) <span style="color: #ff0000;">":/root/.emacs.d/backups"</span>))))
(<span style="color: #0000ff;">setq</span> backup-directory-alist `((<span style="color: #ff0000;">"."</span> . ,tvd-backup-directory)))))))
</pre>
</div>
<p>
<i>FIXME</i>: and/or check <a href="https://www.gnu.org/software/tramp/#Auto_002dsave-and-Backup">gnu.org</a>
</p>
<ul class="org-ul">
<li>tramp-default-proxies-alist</li>
</ul>
<hr />
</div>
</div>
<div id="outline-container-orgd956bb1" class="outline-3">
<h3 id="orgd956bb1"><span class="section-number-3">3.5</span> console backspace fix</h3>
<div class="outline-text-3" id="text-3-5">
<p>
make backspace work in console sessions
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-key key-translation-map [?\C-h] [?\C-?])
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgfe7f135" class="outline-3">
<h3 id="orgfe7f135"><span class="section-number-3">3.6</span> hide menu- and tool-bar</h3>
<div class="outline-text-3" id="text-3-6">
<p>
I prefer a bare bones emacs window without any distractions, so turn them off.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(menu-bar-mode -1)
(tool-bar-mode -1)
(<span style="color: #0000ff;">setq</span> use-dialog-box nil)
(scroll-bar-mode 0)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org42aabfc" class="outline-3">
<h3 id="org42aabfc"><span class="section-number-3">3.7</span> stay silent on startup</h3>
<div class="outline-text-3" id="text-3-7">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> initial-scratch-message <span style="color: #ff0000;">""</span>)
(<span style="color: #0000ff;">setq</span> inhibit-startup-message t)
(<span style="color: #0000ff;">setq</span> inhibit-startup-screen t)
(<span style="color: #0000ff;">setq</span> inhibit-startup-echo-area-message <span style="color: #ff0000;">"scip"</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org0209cd0" class="outline-3">
<h3 id="org0209cd0"><span class="section-number-3">3.8</span> y means yes</h3>
<div class="outline-text-3" id="text-3-8">
<p>
y is shorter than yes and less error prone.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'yes-or-no-p</span> <span style="color: #ff00ff;">'y-or-n-p</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orga25f218" class="outline-3">
<h3 id="orga25f218"><span class="section-number-3">3.9</span> show col in modeline</h3>
<div class="outline-text-3" id="text-3-9">
<p>
very useful to know current column
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(column-number-mode t)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org2e02326" class="outline-3">
<h3 id="org2e02326"><span class="section-number-3">3.10</span> file or buffer in title</h3>
<div class="outline-text-3" id="text-3-10">
<p>
this can be seen in xmobar
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> frame-title-format '(buffer-file-name <span style="color: #ff0000;">"emacs %f"</span> (<span style="color: #ff0000;">"emacs %b"</span>)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgd1d9527" class="outline-3">
<h3 id="orgd1d9527"><span class="section-number-3">3.11</span> avoid invalid files</h3>
<div class="outline-text-3" id="text-3-11">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> require-final-newline t)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org7334313" class="outline-3">
<h3 id="org7334313"><span class="section-number-3">3.12</span> prepare load-path</h3>
<div class="outline-text-3" id="text-3-12">
<p>
where to look for extensions:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-to-list <span style="color: #ff00ff;">'load-path</span> tvd-lisp-dir)
(<span style="color: #0000ff;">if</span> (null tvd-win-home)
(add-to-list <span style="color: #ff00ff;">'load-path</span> (expand-file-name <span style="color: #ff0000;">"compat"</span> tvd-lisp-dir)))
</pre>
</div>
<p>
modules
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-to-list <span style="color: #ff00ff;">'load-path</span> (concat tvd-lisp-dir <span style="color: #ff0000;">"/er"</span>))
(add-to-list <span style="color: #ff00ff;">'load-path</span> (concat tvd-lisp-dir <span style="color: #ff0000;">"/org/lisp"</span>))
(add-to-list <span style="color: #ff00ff;">'load-path</span> (concat tvd-lisp-dir <span style="color: #ff0000;">"/doremi"</span>))
(add-to-list <span style="color: #ff00ff;">'load-path</span> (concat tvd-lisp-dir <span style="color: #ff0000;">"/org/contrib/lisp"</span>))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org053f72c" class="outline-3">
<h3 id="org053f72c"><span class="section-number-3">3.13</span> byte-compile all of them, if needed</h3>
<div class="outline-text-3" id="text-3-13">
<p>
handy function to recompile all lisp files
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">recompile-el</span>()
(interactive)
(byte-recompile-directory tvd-lisp-dir 0))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org0a13a91" class="outline-3">
<h3 id="org0a13a91"><span class="section-number-3">3.14</span> increase fontsize with ctrl-+ and ctrl--</h3>
<div class="outline-text-3" id="text-3-14">
<p>
I use those bindings everywhere (firefox, terminal, etc), and in
emacs as well.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-global-font-size-bigger</span> ()
<span style="color: #cd6600;">"Make font size larger."</span>
(interactive)
(text-scale-increase 0.5))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-global-font-size-smaller</span> ()
<span style="color: #cd6600;">"Change font size back to original."</span>
(interactive)
(text-scale-increase -0.5))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-+"</span>) <span style="color: #ff00ff;">'tvd-global-font-size-bigger</span>) <span style="color: #006400;">; </span><span style="color: #006400;">Schrift groesser</span>
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C--"</span>) <span style="color: #ff00ff;">'tvd-global-font-size-smaller</span>) <span style="color: #006400;">; </span><span style="color: #006400;">kleiner</span>
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org887577c" class="outline-3">
<h3 id="org887577c"><span class="section-number-3">3.15</span> WINDOW management stuff</h3>
<div class="outline-text-3" id="text-3-15">
</div><div id="outline-container-orgf1148c0" class="outline-4">
<h4 id="orgf1148c0"><span class="section-number-4">3.15.1</span> resize windows by keyboard</h4>
<div class="outline-text-4" id="text-3-15-1">
<p>
Very practical: resize windows easily.
</p>
<p>
hit C-c C-r then use cursor keys to resize, &lt;ret&gt; to finish
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'windresize</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-r"</span>) <span style="color: #ff00ff;">'windresize</span>) <span style="color: #006400;">; </span><span style="color: #006400;">Split Buffer Groesse Aendern</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org05c7bc5" class="outline-4">
<h4 id="org05c7bc5"><span class="section-number-4">3.15.2</span> switch windows with MS-WINDOWS key</h4>
<div class="outline-text-4" id="text-3-15-2">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'windmove</span>)
(windmove-default-keybindings <span style="color: #ff00ff;">'super</span>)
(<span style="color: #0000ff;">setq</span> windmove-wrap-around t)
</pre>
</div>
</div>
</div>
<div id="outline-container-org282c3a2" class="outline-4">
<h4 id="org282c3a2"><span class="section-number-4">3.15.3</span> M-o switch window or buffer</h4>
<div class="outline-text-4" id="text-3-15-3">
<p>
via <a href="http://mbork.pl/2017-02-26_other-window-or-switch-buffer">mbork</a>
</p>
<p>
Most of the time I switch back and forth between two buffers, be
they in separate windows or not. With this function I can do
that. Of course this doesn't work if there are more than 2 windows,
and it only works with the 2 most recent visited buffers.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">other-window-or-switch-buffer</span> ()
<span style="color: #cd6600;">"Call `</span><span style="color: #cd6600;">other-window</span><span style="color: #cd6600;">' if more than one window is visible, switch</span>
<span style="color: #cd6600;">to next buffer otherwise."</span>
(interactive)
(<span style="color: #0000ff;">if</span> (one-window-p)
(switch-to-buffer nil)
(other-window 1)))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-o"</span>) <span style="color: #ff00ff;">'other-window-or-switch-buffer</span>)
</pre>
</div>
<p>
M-o doesn't work when using emacs via Win-&gt;RDP-&gt;VNC-&gt;X11-&gt;Xmonad,
so fall back to C-o.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-o"</span>) <span style="color: #ff00ff;">'other-window-or-switch-buffer</span>)
</pre>
</div>
<p>
via
<a href="http://whattheemacsd.com/buffer-defuns.el-02.html">whattheemacs.d</a>:
exchange left with right buffer (or up and down), love it.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">flip-windows</span> ()
<span style="color: #cd6600;">"Rotate your windows"</span>
(interactive)
(<span style="color: #0000ff;">cond</span> ((<span style="color: #0000ff;">not</span> (&gt; (count-windows)1))
(message <span style="color: #ff0000;">"You can't rotate a single window!"</span>))
(t
(<span style="color: #0000ff;">setq</span> i 1)
(<span style="color: #0000ff;">setq</span> numWindows (count-windows))
(<span style="color: #0000ff;">while</span> (&lt; i numWindows)
(<span style="color: #0000ff;">let*</span> (
(w1 (elt (window-list) i))
(w2 (elt (window-list) (+ (% i numWindows) 1)))
(b1 (window-buffer w1))
(b2 (window-buffer w2))
(s1 (window-start w1))
(s2 (window-start w2))
)
(set-window-buffer w1 b2)
(set-window-buffer w2 b1)
(set-window-start w1 s2)
(set-window-start w2 s1)
(<span style="color: #0000ff;">setq</span> i (1+ i)))))))
</pre>
</div>
<p>
Use only in X11 emacs - setting M-O inside console causes &lt;up&gt; and
&lt;down&gt; to stop working properly, for whatever reasons.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">if</span> (display-graphic-p)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-O"</span>) <span style="color: #ff00ff;">'flip-windows</span>))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgcd2a705" class="outline-4">
<h4 id="orgcd2a705"><span class="section-number-4">3.15.4</span> Split window to 4 parts</h4>
<div class="outline-text-4" id="text-3-15-4">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-quarter-windows</span> ()
(interactive)
(split-window-vertically)
(split-window-horizontally)
(windmove-down)
(split-window-horizontally))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-x 4"</span>) <span style="color: #ff00ff;">'tvd-quarter-windows</span>)
</pre>
</div>
<hr />
</div>
</div>
</div>
<div id="outline-container-orgd9b279b" class="outline-3">
<h3 id="orgd9b279b"><span class="section-number-3">3.16</span> re-read a modified buffer</h3>
<div class="outline-text-3" id="text-3-16">
<p>
F5 == reload file if it has been modified by another process, shift
because Xmonad
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"S-&lt;f5&gt;"</span>) <span style="color: #006400;">; </span><span style="color: #006400;">re-read a buffer from disk (revert)</span>
(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;optional</span> force-reverting)
<span style="color: #cd6600;">"Interactive call to revert-buffer. Ignoring the auto-save</span>
<span style="color: #cd6600;"> file and not requesting for confirmation. When the current buffer</span>
<span style="color: #cd6600;"> is modified, the command refuses to revert it, unless you specify</span>
<span style="color: #cd6600;"> the optional argument: force-reverting to true."</span>
(interactive <span style="color: #ff0000;">"P"</span>)
<span style="color: #006400;">;;</span><span style="color: #006400;">(message "force-reverting value is %s" force-reverting)</span>
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">or</span> force-reverting (<span style="color: #0000ff;">not</span> (buffer-modified-p)))
(revert-buffer <span style="color: #8a2be2;">:ignore-auto</span> <span style="color: #8a2be2;">:noconfirm</span>)
(<span style="color: #ff0000; font-weight: bold;">error</span> <span style="color: #ff0000;">"The buffer has been modified"</span>))))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org7170b0a" class="outline-3">
<h3 id="org7170b0a"><span class="section-number-3">3.17</span> global TAB/Indent config</h3>
<div class="outline-text-3" id="text-3-17">
<p>
I use spaces everywhere but Makefiles. If I encounter TABs I
replace them with spaces, if I encounter users entering TABs into
files, I block them.
</p>
<p>
<i>FIXME</i>: also check <a href="https://github.com/glasserc/ethan-wspace">ethan-wspace</a> !
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(<span style="color: #0000ff;">setq</span> indent-line-function <span style="color: #ff00ff;">'insert-tab</span>)
(<span style="color: #0000ff;">setq</span> tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120)))
(<span style="color: #0000ff;">setq</span> tab-always-indent <span style="color: #ff00ff;">'complete</span>) <span style="color: #006400;">; </span><span style="color: #006400;">/</span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">FIXME</span><span style="color: #006400;">/: doesnt work in cperl-mode</span>
(<span style="color: #0000ff;">setq</span> show-trailing-whitespace t)
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">indent-buffer</span> ()
<span style="color: #006400;">;; </span><span style="color: #006400;">Author: Mathias Creutz</span>
<span style="color: #cd6600;">"Re-Indent every line in the current buffer."</span>
(interactive)
(indent-region (point-min) (point-max) nil))
</pre>
</div>
<p>
Use normal tabs in makefiles
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'makefile-mode-hook</span> '(<span style="color: #0000ff;">lambda</span>() (<span style="color: #0000ff;">setq</span> indent-tabs-mode t)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org91aa178" class="outline-3">
<h3 id="org91aa178"><span class="section-number-3">3.18</span> handy aliases</h3>
<div class="outline-text-3" id="text-3-18">
<p>
M-x q r &lt;ret&gt; is short enough for me, no need for key bindings for
those
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'qrr</span> <span style="color: #ff00ff;">'query-replace-regexp</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'qr</span> <span style="color: #ff00ff;">'query-replace</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'cr</span> <span style="color: #ff00ff;">'comment-region</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ur</span> <span style="color: #ff00ff;">'uncomment-region</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ir</span> <span style="color: #ff00ff;">'indent-region</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'dv</span> <span style="color: #ff00ff;">'describe-variable</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'dk</span> <span style="color: #ff00ff;">'describe-key</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'df</span> <span style="color: #ff00ff;">'describe-function</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'dp</span> <span style="color: #ff00ff;">'describe-char</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'dm</span> <span style="color: #ff00ff;">'describe-mode</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'db</span> <span style="color: #ff00ff;">'describe-bindings</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'dl</span> <span style="color: #ff00ff;">'finder-commentary</span>) <span style="color: #006400;">; </span><span style="color: #006400;">aka "describe library"</span>
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'repl</span> <span style="color: #ff00ff;">'ielm</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'i</span> <span style="color: #ff00ff;">'info-display-manual</span>) <span style="color: #006400;">; </span><span style="color: #006400;">with prompt and completion</span>
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ws</span> <span style="color: #ff00ff;">'window-configuration-to-register</span>) <span style="color: #006400;">; </span><span style="color: #006400;">save window config</span>
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'wr</span> <span style="color: #ff00ff;">'jump-to-register</span>) <span style="color: #006400;">; </span><span style="color: #006400;">restore window config</span>
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'rec</span> <span style="color: #ff00ff;">'rectangle-mark-mode</span>)
(<span style="color: #0000ff;">defalias</span> '<span style="color: #9932cc;">|</span> <span style="color: #ff00ff;">'shell-command-on-region</span>) <span style="color: #006400;">; </span><span style="color: #006400;">apply shell command on region</span>
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgc37a9d7" class="outline-3">
<h3 id="orgc37a9d7"><span class="section-number-3">3.19</span> various settings</h3>
<div class="outline-text-3" id="text-3-19">
<p>
point stays while scrolling
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> scroll-preserve-screen-position t)
</pre>
</div>
<p>
no comment margins
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(setq-default comment-column 0)
</pre>
</div>
<p>
do not save until I hit C-x-s
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> auto-save-default nil)
</pre>
</div>
<p>
show all buffers in buffer menu
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> buffers-menu-max-size nil)
</pre>
</div>
<p>
start to wrap at 30 entries
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> mouse-buffer-menu-mode-mult 30)
</pre>
</div>
<p>
I'm grown up!
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> disabled-command-function nil)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org4d0a51b" class="outline-3">
<h3 id="org4d0a51b"><span class="section-number-3">3.20</span> load imenu</h3>
<div class="outline-text-3" id="text-3-20">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-key global-map [C-down-mouse-2] <span style="color: #ff00ff;">'imenu</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org6a4b9e7" class="outline-3">
<h3 id="org6a4b9e7"><span class="section-number-3">3.21</span> copy/paste Config</h3>
<div class="outline-text-3" id="text-3-21">
<p>
Related:
</p>
<ul class="org-ul">
<li>see also mark-copy-yank-things-mode below!</li>
<li>see also: move-region below (for M-&lt;up|down&gt;)</li>
<li>see also: expand-region below (for C-0)</li>
</ul>
<p>
middle mouse button paste at click not where cursor is
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> mouse-yank-at-point t)
</pre>
</div>
<p>
highlight selected stuff (also allows DEL of active region)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> transient-mark-mode t)
</pre>
</div>
<p>
pasting onto selection deletes it
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(delete-selection-mode t)
</pre>
</div>
<p>
delete whole lines
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> kill-whole-line t)
</pre>
</div>
<p>
middle-mouse and C-y use both X-selection and Emacs-clipboard
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">if</span> (null tvd-win-home)
(<span style="color: #0000ff;">progn</span> <span style="color: #006400;">; </span><span style="color: #006400;">unix</span>
(<span style="color: #0000ff;">setq</span> x-select-enable-primary t)
(<span style="color: #0000ff;">setq</span> x-select-enable-clipboard nil))
(<span style="color: #0000ff;">progn</span> <span style="color: #006400;">; </span><span style="color: #006400;">win</span>
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;up-mouse-2&gt;"</span>) <span style="color: #ff00ff;">'yank</span>)))
</pre>
</div>
<p>
marked region automatically copied, also on win
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> mouse-drag-copy-region t)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgc4c79f0" class="outline-3">
<h3 id="orgc4c79f0"><span class="section-number-3">3.22</span> use more mem</h3>
<div class="outline-text-3" id="text-3-22">
<p>
are you from the past?
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> gc-cons-threshold 20000000)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org3d34af2" class="outline-3">
<h3 id="org3d34af2"><span class="section-number-3">3.23</span> better file name completion</h3>
<div class="outline-text-3" id="text-3-23">
<p>
Complete filenames case insensitive and ignore certain files during completion.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> read-file-name-completion-ignore-case t)
(<span style="color: #0000ff;">setq</span> read-buffer-completion-ignore-case t)
</pre>
</div>
<p>
via <a href="http://endlessparentheses.com/improving-emacs-file-name-completion.html">endlessparantheses</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(mapc (<span style="color: #0000ff;">lambda</span> (x)
(add-to-list <span style="color: #ff00ff;">'completion-ignored-extensions</span> x))
'(<span style="color: #ff0000;">".aux"</span> <span style="color: #ff0000;">".bbl"</span> <span style="color: #ff0000;">".blg"</span> <span style="color: #ff0000;">".exe"</span>
<span style="color: #ff0000;">".log"</span> <span style="color: #ff0000;">".meta"</span> <span style="color: #ff0000;">".out"</span> <span style="color: #ff0000;">".pdf"</span>
<span style="color: #ff0000;">".synctex.gz"</span> <span style="color: #ff0000;">".tdo"</span> <span style="color: #ff0000;">".toc"</span>
<span style="color: #ff0000;">"-pkg.el"</span> <span style="color: #ff0000;">"-autoloads.el"</span> <span style="color: #ff0000;">".elc"</span>
<span style="color: #ff0000;">".dump"</span> <span style="color: #ff0000;">".ps"</span> <span style="color: #ff0000;">".png"</span> <span style="color: #ff0000;">".jpg"</span>
<span style="color: #ff0000;">".gz"</span> <span style="color: #ff0000;">".tgz"</span> <span style="color: #ff0000;">".zip"</span>
<span style="color: #ff0000;">"Notes.bib"</span> <span style="color: #ff0000;">"auto/"</span>))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org3609bd8" class="outline-3">
<h3 id="org3609bd8"><span class="section-number-3">3.24</span> abbreviations</h3>
<div class="outline-text-3" id="text-3-24">
<p>
Do I really need those anymore? Added ca 1999&#x2026;
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-abbrev-table <span style="color: #ff00ff;">'global-abbrev-table</span> '(
(<span style="color: #ff0000;">"oe"</span> <span style="color: #ff0000;">"&amp;ouml;"</span> nil 0)
(<span style="color: #ff0000;">"ue"</span> <span style="color: #ff0000;">"&amp;uuml;"</span> nil 0)
(<span style="color: #ff0000;">"ae"</span> <span style="color: #ff0000;">"&amp;auml;"</span> nil 0)
(<span style="color: #ff0000;">"Oe"</span> <span style="color: #ff0000;">"&amp;Ouml;"</span> nil 0)
(<span style="color: #ff0000;">"Ue"</span> <span style="color: #ff0000;">"&amp;Uuml;"</span> nil 0)
(<span style="color: #ff0000;">"Ae"</span> <span style="color: #ff0000;">"&amp;Auml;"</span> nil 0)
(<span style="color: #ff0000;">"&lt;li&gt;"</span> <span style="color: #ff0000;">"&lt;li&gt; &lt;/li&gt;"</span> nil 0)
(<span style="color: #ff0000;">"&lt;ul&gt;"</span> <span style="color: #ff0000;">"&lt;ul&gt; &lt;/ul&gt;"</span> nil 0)
))
</pre>
</div>
</div>
</div>
<div id="outline-container-org97f002f" class="outline-3">
<h3 id="org97f002f"><span class="section-number-3">3.25</span> meaningful names for buffers with the same name</h3>
<div class="outline-text-3" id="text-3-25">
<p>
from (<a href="https://github.com/bbatsov/prelude">prelude</a>)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'uniquify</span>)
(<span style="color: #0000ff;">setq</span> uniquify-buffer-name-style <span style="color: #ff00ff;">'forward</span>)
(<span style="color: #0000ff;">setq</span> uniquify-separator <span style="color: #ff0000;">"/"</span>)
(<span style="color: #0000ff;">setq</span> uniquify-after-kill-buffer-p t) <span style="color: #006400;">; </span><span style="color: #006400;">rename after killing uniquified</span>
(<span style="color: #0000ff;">setq</span> uniquify-ignore-buffers-re <span style="color: #ff0000;">"^\\*"</span>) <span style="color: #006400;">; </span><span style="color: #006400;">don't muck with special buffers</span>
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgc369e59" class="outline-3">
<h3 id="orgc369e59"><span class="section-number-3">3.26</span> packages</h3>
<div class="outline-text-3" id="text-3-26">
<p>
I dont need it all the time and only for experimentation, so lets
only use melpa on demand
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">toggle-melpa</span>()
(interactive)
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'package</span>)
(add-to-list <span style="color: #ff00ff;">'package-archives</span>
'(<span style="color: #ff0000;">"melpa"</span> . <span style="color: #ff0000;">"http://melpa.org/packages/"</span>))
(<span style="color: #0000ff;">when</span> (&lt; emacs-major-version 24)
<span style="color: #006400;">;; </span><span style="color: #006400;">For important compatibility libraries like cl-lib</span>
(add-to-list <span style="color: #ff00ff;">'package-archives</span> '(<span style="color: #ff0000;">"gnu"</span> . <span style="color: #ff0000;">"http://elpa.gnu.org/packages/"</span>)))
(package-initialize)
(list-packages))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orga99b0e3" class="outline-3">
<h3 id="orga99b0e3"><span class="section-number-3">3.27</span> My own global variables</h3>
<div class="outline-text-3" id="text-3-27">
<p>
narrowed fringe background
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defvar</span> <span style="color: #a0522d;">tvd-fringe-narrow-bg</span> <span style="color: #ff0000;">"OrangeRed"</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgdc6d06d" class="outline-3">
<h3 id="orgdc6d06d"><span class="section-number-3">3.28</span> More scratch space</h3>
<div class="outline-text-3" id="text-3-28">
<p>
Sometimes I need a text mode scratch buffer while scratch is
already in use. So let's prepare one
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">with-current-buffer</span> (get-buffer-create <span style="color: #ff0000;">"*text*"</span>)
(text-mode))
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org54c1d15" class="outline-2">
<h2 id="org54c1d15"><span class="section-number-2">4</span> Global Key Bindings</h2>
<div class="outline-text-2" id="text-4">
<hr />
</div>
<div id="outline-container-org27d2628" class="outline-3">
<h3 id="org27d2628"><span class="section-number-3">4.1</span> c-h != delete</h3>
<div class="outline-text-3" id="text-4-1">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(keyboard-translate ?\C-h ?\C-?)
(keyboard-translate ?\C-? ?\C-h)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgd531c40" class="outline-3">
<h3 id="orgd531c40"><span class="section-number-3">4.2</span> general keys (re-)mappings</h3>
<div class="outline-text-3" id="text-4-2">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-s"</span>) <span style="color: #ff00ff;">'isearch-forward-regexp</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-r"</span>) <span style="color: #ff00ff;">'isearch-backward-regexp</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-C-s"</span>) <span style="color: #ff00ff;">'isearch-forward</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-C-r"</span>) <span style="color: #ff00ff;">'isearch-backward</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-%"</span>) <span style="color: #ff00ff;">'query-replace-regexp</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;backtab&gt;"</span>) <span style="color: #ff00ff;">'dabbrev-completion</span>) <span style="color: #006400;">; </span><span style="color: #006400;">shift-tab, inline completion</span>
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;f9&gt;"</span>) <span style="color: #ff00ff;">'html-mode</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;delete&gt;"</span>) <span style="color: #ff00ff;">'delete-char</span>) <span style="color: #006400;">; </span><span style="color: #006400;">Entf Char loeschen</span>
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;backspace&gt;"</span>) <span style="color: #ff00ff;">'backward-delete-char</span>) <span style="color: #006400;">; </span><span style="color: #006400;">Shift+Backspace dito</span>
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"S-&lt;delete&gt;"</span>) <span style="color: #ff00ff;">'kill-word</span>) <span style="color: #006400;">; </span><span style="color: #006400;">Shift+Entf Wort loeschen</span>
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"S-&lt;backspace&gt;"</span>) <span style="color: #ff00ff;">'backward-kill-word</span>) <span style="color: #006400;">; </span><span style="color: #006400;">Shift+Backspace dito</span>
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-&lt;delete&gt;"</span>) <span style="color: #ff00ff;">'kill-word</span>) <span style="color: #006400;">; </span><span style="color: #006400;">Shift+Entf dito</span>
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-&lt;backspace&gt;"</span>) <span style="color: #ff00ff;">'backward-kill-word</span>) <span style="color: #006400;">; </span><span style="color: #006400;">Shift+Backspace dito</span>
(global-unset-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-z"</span>))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-x k"</span>) <span style="color: #ff00ff;">'kill-this-buffer</span>) <span style="color: #006400;">; </span><span style="color: #006400;">C-x k really kill current buffer w/o asking</span>
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-x C-b"</span>) <span style="color: #ff00ff;">'buffer-menu</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org1c80d66" class="outline-3">
<h3 id="org1c80d66"><span class="section-number-3">4.3</span> display a list of my own global key bindings and aliases</h3>
<div class="outline-text-3" id="text-4-3">
<p>
via <a href="https://www.emacswiki.org/emacs/OccurMode#toc9">emacswiki</a>
</p>
<p>
Inside <b>Occur</b>: q - quit, e - edit, g - reload
more help with: describe-function occur-mode
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">occur-mode-clean-buffer</span> ()
<span style="color: #cd6600;">"Removes all commentary from the *Occur* buffer, leaving the</span>
<span style="color: #cd6600;"> unadorned lines."</span>
(interactive)
(<span style="color: #0000ff;">if</span> (get-buffer <span style="color: #ff0000;">"*Occur*"</span>)
(<span style="color: #0000ff;">save-excursion</span>
(set-buffer (get-buffer <span style="color: #ff0000;">"*Occur*"</span>))
(goto-char (point-min))
(toggle-read-only 0)
(<span style="color: #0000ff;">if</span> (looking-at <span style="color: #ff0000;">"^[0-9]+ lines matching \""</span>)
(kill-line 1))
(<span style="color: #0000ff;">while</span> (re-search-forward <span style="color: #ff0000;">"^[ \t]*[0-9]+:"</span>
(point-max)
t)
(replace-match <span style="color: #ff0000;">""</span>)
(forward-line 1)))
(message <span style="color: #ff0000;">"There is no buffer named \"*Occur*\"."</span>)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">show-definition</span>(REGEX)
(interactive)
(<span style="color: #0000ff;">let</span> ((dotemacs-loaded nil)
(occur-b <span style="color: #ff0000;">"*Occur*"</span>)
(occur-c <span style="color: #ff0000;">""</span>))
(<span style="color: #0000ff;">if</span> (get-buffer <span style="color: #ff0000;">".emacs"</span>)
(<span style="color: #0000ff;">progn</span>
(switch-to-buffer <span style="color: #ff0000;">".emacs"</span>)
(<span style="color: #0000ff;">setq</span> dotemacs-loaded t))
(find-file <span style="color: #ff0000;">"~/.emacs"</span>))
(occur REGEX)
(<span style="color: #0000ff;">with-current-buffer</span> occur-b
(occur-mode-clean-buffer)
(<span style="color: #0000ff;">setq</span> occur-c (current-buffer))
(<span style="color: #0000ff;">let</span> ((inhibit-read-only t)) (set-text-properties (point-min) (point-max) ()))
(<span style="color: #0000ff;">while</span> (re-search-forward <span style="color: #ff0000;">"[0-9]*:"</span> nil t)
(replace-match <span style="color: #ff0000;">""</span>))
(beginning-of-buffer)
(kill-line)
(sort-lines nil (point-min) (point-max))
(emacs-lisp-mode)
(beginning-of-buffer)
(insert (format <span style="color: #ff0000;">";; *SHOW*: %s\n"</span> REGEX))
(highlight-regexp REGEX)
(beginning-of-buffer))
(switch-to-buffer occur-b)
(delete-other-windows)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> dotemacs-loaded nil)
(kill-buffer <span style="color: #ff0000;">".emacs"</span>))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">show-keys</span>()
(interactive)
(show-definition <span style="color: #ff0000;">"^(global-set-key"</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">show-aliases</span>()
(interactive)
(show-definition <span style="color: #ff0000;">"^(defalias"</span>))
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'sk</span> <span style="color: #ff00ff;">'show-keys</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'sa</span> <span style="color: #ff00ff;">'show-aliases</span>)
</pre>
</div>
<hr />
</div>
</div>
</div>
<div id="outline-container-org31da5d6" class="outline-2">
<h2 id="org31da5d6"><span class="section-number-2">5</span> Productivity Functions</h2>
<div class="outline-text-2" id="text-5">
<hr />
</div>
<div id="outline-container-orgfa8b60d" class="outline-3">
<h3 id="orgfa8b60d"><span class="section-number-3">5.1</span> goto line with tmp line numbers</h3>
<div class="outline-text-3" id="text-5-1">
<p>
I stole this somewhere, as far as I remember, emacswiki, however, I
always had F7 for goto-line
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">goto-line-with-feedback</span> ()
<span style="color: #cd6600;">"Show line numbers temporarily, while prompting for the line number input"</span>
(interactive)
(<span style="color: #0000ff;">unwind-protect</span>
(<span style="color: #0000ff;">progn</span>
(linum-mode 1)
(call-interactively <span style="color: #ff00ff;">'goto-line</span>))
(linum-mode -1)))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;f7&gt;"</span>) <span style="color: #ff00ff;">'goto-line-with-feedback</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgd01c0ed" class="outline-3">
<h3 id="orgd01c0ed"><span class="section-number-3">5.2</span> invert fore- and background</h3>
<div class="outline-text-3" id="text-5-2">
<p>
Sometimes when sitting in a very dark enviroment, my usual light
emacs frame is a too stark contrast to the environment. With this
function I can just invert my current color settings to dark
background and light foreground.
</p>
<p>
remember last inverse
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defvar</span> <span style="color: #a0522d;">tvd-invert-state</span> t)
</pre>
</div>
<p>
invert everything, reverse it when called again
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-invert</span>()
<span style="color: #cd6600;">"invert fg-bg"</span>
(interactive)
(invert-face <span style="color: #ff00ff;">'default</span>)
(invert-face <span style="color: #ff00ff;">'mode-line</span>)
(set-face-attribute <span style="color: #ff00ff;">'fringe</span> nil <span style="color: #8a2be2;">:inverse-video</span> tvd-invert-state)
(<span style="color: #0000ff;">setq</span> tvd-invert-state (<span style="color: #0000ff;">not</span> tvd-invert-state)) <span style="color: #006400;">;; </span><span style="color: #006400;">cycle variable tvd-invert-state</span>
)
</pre>
</div>
<p>
fast
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-i"</span>) <span style="color: #ff00ff;">'tvd-invert</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org8f3d06d" class="outline-3">
<h3 id="org8f3d06d"><span class="section-number-3">5.3</span> Some useful bindings for Home and End keys Hit the key once to</h3>
<div class="outline-text-3" id="text-5-3">
<p>
Go to the beginning/end of a line, hit it twice in a row to go to
the beginning/end of the window, three times in a row goes to the
beginning/end of the buffer. NB that there is no timeout involved.
</p>
<p>
Uses a function of viking-mode to establish key repeats, see below.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">pc-keys-home</span> ()
<span style="color: #cd6600;">"Go to beginning of line/window/buffer. First hitting key goes</span>
<span style="color: #cd6600;">to beginning of line, second in a row goes to beginning of</span>
<span style="color: #cd6600;">window, third in a row goes to beginning of buffer."</span>
(interactive)
(<span style="color: #0000ff;">let*</span> ((key-times (viking-last-key-repeats)))
(<span style="color: #0000ff;">cond</span>
((<span style="color: #0000ff;">eq</span> key-times 3)
(<span style="color: #0000ff;">if</span> mark-active
(goto-char (point-min))
(beginning-of-buffer)))
((<span style="color: #0000ff;">eq</span> key-times 2)
(<span style="color: #0000ff;">if</span> mark-active () (push-mark))
(move-to-window-line 0))
((<span style="color: #0000ff;">eq</span> key-times 1)
(beginning-of-line)))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">pc-keys-end</span> ()
<span style="color: #cd6600;">"Go to end of line/window/buffer. First hitting key goes</span>
<span style="color: #cd6600;">to end of line, second in a row goes to end of</span>
<span style="color: #cd6600;">window, third in a row goes to end of buffer."</span>
(interactive)
(<span style="color: #0000ff;">let*</span> ((key-times (viking-last-key-repeats)))
(<span style="color: #0000ff;">cond</span>
((<span style="color: #0000ff;">eq</span> key-times 3)
(<span style="color: #0000ff;">if</span> mark-active
(goto-char (point-max))
(end-of-buffer)))
((<span style="color: #0000ff;">eq</span> key-times 2)
(<span style="color: #0000ff;">if</span> mark-active () (push-mark))
(move-to-window-line -1)
(end-of-line))
((<span style="color: #0000ff;">eq</span> key-times 1)
(end-of-line)))))
</pre>
</div>
<p>
This is the most natural use for those keys
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;home&gt;"</span>) <span style="color: #ff00ff;">'pc-keys-home</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;end&gt;"</span>) <span style="color: #ff00ff;">'pc-keys-end</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgdbc39c6" class="outline-3">
<h3 id="orgdbc39c6"><span class="section-number-3">5.4</span> percent function</h3>
<div class="outline-text-3" id="text-5-4">
<p>
by Jens Heunemann: jump to percent position into current buffer
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">goto-percent</span> (p) <span style="color: #006400;">;</span><span style="color: #006400;">goto Prozentwert (0-100): F8</span>
(interactive <span style="color: #ff0000;">"nProzent: "</span>)
(<span style="color: #0000ff;">if</span> (&gt; (point-max) 80000)
(goto-char (* (/ (point-max) 100) p)) <span style="color: #006400;">;</span><span style="color: #006400;">Ueberlauf vermeiden: (max/100)*p</span>
(goto-char (/ (* p (point-max)) 100))) <span style="color: #006400;">;</span><span style="color: #006400;">Rundungsfehler verm.: (max*p)/100</span>
(beginning-of-line))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;f8&gt;"</span>) <span style="color: #ff00ff;">'goto-percent</span>) <span style="color: #006400;">;</span><span style="color: #006400;">F8 goto percent</span>
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgaf17dfc" class="outline-3">
<h3 id="orgaf17dfc"><span class="section-number-3">5.5</span> Simulate vi's % function</h3>
<div class="outline-text-3" id="text-5-5">
<p>
There's not a lot about vi[m] I like, but jumping with % to a
matching paren is one of THOSE features, I also need in emacs.
</p>
<p>
with ideas from <a href="https://www.emacswiki.org/emacs/NavigatingParentheses#toc2">emacswiki</a>
</p>
<p>
If (point) is on a paren, jump to the matching paren, otherwise,
just insert a literal ?%. Only make sense if bound to %.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">jump-paren-match-or-insert-percent</span> (arg)
<span style="color: #cd6600;">"Go to the matching parenthesis if on parenthesis. Otherwise</span>
<span style="color: #cd6600;">insert %. Mimics vi style of % jumping to matching brace."</span>
(interactive <span style="color: #ff0000;">"p"</span>)
(<span style="color: #0000ff;">cond</span> ((looking-at <span style="color: #ff0000;">"\\s\(</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">\{</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">\\["</span>) (forward-list 1) (backward-char 1))
((looking-at <span style="color: #ff0000;">"\\s\)</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">\}</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">\\]"</span>) (forward-char 1) (backward-list 1))
(t (insert <span style="color: #ff0000;">"%"</span>))))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"%"</span>) <span style="color: #ff00ff;">'jump-paren-match-or-insert-percent</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org2b9f7f9" class="outline-3">
<h3 id="org2b9f7f9"><span class="section-number-3">5.6</span> Move region</h3>
<div class="outline-text-3" id="text-5-6">
<p>
Mark a region, then use M-up|down to move it around
via <a href="https://www.emacswiki.org/emacs/MoveRegion">emacswiki</a>
code from <a href="https://github.com/targzeta/move-lines/blob/master/move-lines.el">move-lines</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">move-lines--internal</span> (n)
(<span style="color: #0000ff;">let*</span> ((start (point)) <span style="color: #006400;">;; </span><span style="color: #006400;">The position of beginning of line of the first line</span>
(end start) <span style="color: #006400;">;; </span><span style="color: #006400;">The position of eol+\n of the end line</span>
col-init <span style="color: #006400;">;; </span><span style="color: #006400;">The current column for the first line</span>
(col-end (current-column)) <span style="color: #006400;">;; </span><span style="color: #006400;">The current column for the end line</span>
exchange_pm <span style="color: #006400;">;; </span><span style="color: #006400;">If I had exchanged point and mark</span>
delete-latest-newline) <span style="color: #006400;">;; </span><span style="color: #006400;">If I had inserted a newline at the end</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">STEP 1: Identifying the line(s) to cut.</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">---</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">If region is actives, I ensure that point always is at the end of the</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">region and mark at the beginning.</span>
(<span style="color: #0000ff;">when</span> (region-active-p)
(<span style="color: #0000ff;">when</span> (&lt; (point) (mark))
(<span style="color: #0000ff;">setq</span> exchange_pm t)
(exchange-point-and-mark))
(<span style="color: #0000ff;">setq</span> start (mark)
end (point)
col-end (current-column)))
(goto-char start) (<span style="color: #0000ff;">setq</span> col-init (current-column))
(beginning-of-line) (<span style="color: #0000ff;">setq</span> start (point))
(goto-char end) (end-of-line)
<span style="color: #006400;">;; </span><span style="color: #006400;">If point == point-max, this buffers doesn't have the trailing newline.</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">In this case I have to insert a newline otherwise the following</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">`</span><span style="color: #006400;">forward-char</span><span style="color: #006400;">' (to keep the "\n") will fail.</span>
(<span style="color: #0000ff;">when</span> (= (point) (point-max))
(<span style="color: #0000ff;">setq</span> delete-latest-newline t)
(insert-char ?\n) (forward-char -1))
(forward-char 1) (<span style="color: #0000ff;">setq</span> end (point))
<span style="color: #006400;">;; </span><span style="color: #006400;">STEP 2: Moving the lines.</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">---</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">The region I'm cutting span from the beginning of line of the current</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">line (or current region) to the end of line + 1 (newline) of the current</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">line (or current region).</span>
(<span style="color: #0000ff;">let</span> ((line-text (delete-and-extract-region start end)))
(forward-line n)
<span style="color: #006400;">;; </span><span style="color: #006400;">If the current-column != 0, I have moved the region at the bottom of a</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">buffer doesn't have the trailing newline.</span>
(<span style="color: #0000ff;">when</span> (<span style="color: #0000ff;">not</span> (= (current-column) 0))
(insert-char ?\n)
(<span style="color: #0000ff;">setq</span> delete-latest-newline t))
(<span style="color: #0000ff;">setq</span> start (+ (point) col-init)) <span style="color: #006400;">;; </span><span style="color: #006400;">Now, start is the start of new region</span>
(insert line-text))
<span style="color: #006400;">;; </span><span style="color: #006400;">STEP 3: Restoring</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">---</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">I'm at the end of new region (or line) and start has setted at the</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">beginning of new region (if a region is active).</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">Restoring the end column.</span>
(forward-line -1)
(forward-char col-end)
(<span style="color: #0000ff;">when</span> delete-latest-newline
(<span style="color: #0000ff;">save-excursion</span>
(goto-char (point-max))
(delete-char -1)))
(<span style="color: #0000ff;">when</span> (region-active-p)
(<span style="color: #0000ff;">setq</span> deactivate-mark nil)
(set-mark start)
(<span style="color: #0000ff;">if</span> exchange_pm
(exchange-point-and-mark)))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">move-lines-up</span> (n)
<span style="color: #cd6600;">"Moves the current line or, if region is actives, the lines surrounding</span>
<span style="color: #cd6600;">region, up by N lines, or 1 line if N is nil."</span>
(interactive <span style="color: #ff0000;">"p"</span>)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> n nil)
(<span style="color: #0000ff;">setq</span> n 1))
(move-lines--internal (- n)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">move-lines-down</span> (n)
<span style="color: #cd6600;">"Moves the current line or, if region is actives, the lines surrounding</span>
<span style="color: #cd6600;">region, down by N lines, or 1 line if N is nil."</span>
(interactive <span style="color: #ff0000;">"p"</span>)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> n nil)
(<span style="color: #0000ff;">setq</span> n 1))
(move-lines--internal n))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-&lt;up&gt;"</span>) <span style="color: #ff00ff;">'move-lines-up</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-&lt;down&gt;"</span>) <span style="color: #ff00ff;">'move-lines-down</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org1cde696" class="outline-3">
<h3 id="org1cde696"><span class="section-number-3">5.7</span> comment-uncomment region with one key binding</h3>
<div class="outline-text-3" id="text-5-7">
<p>
via <a href="http://stackoverflow.com/a/9697222/3350881">stackoverflow</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">comment-or-uncomment-region-or-line</span> ()
<span style="color: #cd6600;">"Comments or uncomments the region or the current line if there's no active region."</span>
(interactive)
(<span style="color: #0000ff;">let</span> (beg end)
(<span style="color: #0000ff;">if</span> (region-active-p)
(<span style="color: #0000ff;">setq</span> beg (region-beginning) end (region-end))
(<span style="color: #0000ff;">setq</span> beg (line-beginning-position) end (line-end-position)))
(comment-or-uncomment-region beg end)))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-c"</span>) <span style="color: #ff00ff;">'comment-or-uncomment-region-or-line</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org08a793d" class="outline-3">
<h3 id="org08a793d"><span class="section-number-3">5.8</span> search for symbol at point</h3>
<div class="outline-text-3" id="text-5-8">
<p>
Simulate the # function of vi, marks the symbol at point, C-s then
searches for it. I use this a lot.
</p>
<p>
via <a href="http://ergoemacs.org/emacs/modernization_isearch.html">ergomacs</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">xah-search-current-word</span> ()
<span style="color: #cd6600;">"Call `</span><span style="color: #cd6600;">isearch</span><span style="color: #cd6600;">' on current word or text selection.</span>
<span style="color: #cd6600;"> 'word' here is A to Z, a to z, and hyphen and underline, independent of syntax table.</span>
<span style="color: #cd6600;">URL `[[http://ergoemacs.org/emacs/modernization_isearch.html'][ergomacs]]</span>
<span style="color: #cd6600;">Version 2015-04-09"</span>
(interactive)
(<span style="color: #0000ff;">let</span> ( xahp1 xahp2 )
(<span style="color: #0000ff;">if</span> (use-region-p)
(<span style="color: #0000ff;">progn</span>
(<span style="color: #0000ff;">setq</span> xahp1 (region-beginning))
(<span style="color: #0000ff;">setq</span> xahp2 (region-end)))
(<span style="color: #0000ff;">save-excursion</span>
(skip-chars-backward <span style="color: #ff0000;">"-_A-Za-z0-9"</span>)
(<span style="color: #0000ff;">setq</span> xahp1 (point))
(right-char)
(skip-chars-forward <span style="color: #ff0000;">"-_A-Za-z0-9"</span>)
(<span style="color: #0000ff;">setq</span> xahp2 (point))))
(<span style="color: #0000ff;">setq</span> mark-active nil)
(<span style="color: #0000ff;">when</span> (&lt; xahp1 (point))
(goto-char xahp1))
(isearch-mode t)
(isearch-yank-string (buffer-substring-no-properties xahp1 xahp2))
(message <span style="color: #ff0000;">"Now use C-s to search for it ..."</span>)
))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-#"</span>) <span style="color: #ff00ff;">'xah-search-current-word</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgb368809" class="outline-3">
<h3 id="orgb368809"><span class="section-number-3">5.9</span> Window Margin</h3>
<div class="outline-text-3" id="text-5-9">
<p>
Kinda screen reader for the poor. I use this sometimes with info
or woman mode. I also use a full featured screen reader: nove-mode,
see below.
</p>
<p>
left+right margin on demand (but nothing else)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">margin</span>(m)
<span style="color: #cd6600;">"set left and right margins for better readability"</span>
(interactive <span style="color: #ff0000;">"nEnter Margin (0 to disable) [0-9]+: "</span>)
(set-window-margins (<span style="color: #0000ff;">car</span> (get-buffer-window-list (current-buffer) nil t)) m m) <span style="color: #006400;">;; </span><span style="color: #006400;">set immediately</span>
(<span style="color: #0000ff;">setq</span> left-margin-width m) <span style="color: #006400;">;; </span><span style="color: #006400;">persist until reset</span>
(<span style="color: #0000ff;">setq</span> right-margin-width m)
(message <span style="color: #ff0000;">"To reset, change Buffer or call again with arg 0."</span>)
)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org6e8832c" class="outline-3">
<h3 id="org6e8832c"><span class="section-number-3">5.10</span> Fill and justify a paragraph</h3>
<div class="outline-text-3" id="text-5-10">
<p>
this is just a shortcut for:
C-u 70 &lt;ret&gt; M-x fill-paragraph
but C-q is just easier to remember
</p>
<p>
however, if pressed again it un-fills the paragraph,
idea via: <a href="http://endlessparentheses.com/fill-and-unfill-paragraphs-with-a-single-key.html">endlessparentheses</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-fill-and-justify-or-unfill</span>()
(interactive)
(<span style="color: #0000ff;">let</span> ((fill-column
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> last-command <span style="color: #ff00ff;">'tvd-fill-and-justify-or-unfill</span>)
(<span style="color: #0000ff;">progn</span> (<span style="color: #0000ff;">setq</span> this-command nil)
(point-max))
fill-column)))
(fill-paragraph 70)))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-q"</span>) <span style="color: #ff00ff;">'tvd-fill-and-justify-or-unfill</span>) <span style="color: #006400;">; </span><span style="color: #006400;">like M-q, which is bound to x-window-quit in xmonad: fill+justify</span>
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org6bdfe95" class="outline-3">
<h3 id="org6bdfe95"><span class="section-number-3">5.11</span> Make a read-only copy of the current buffer</h3>
<div class="outline-text-3" id="text-5-11">
<p>
I just create a new read-only buffer and copy the contents of the
current one into it, which can be used as backup. I use this in
cases where I need to re-factor a file and do lots of changes. With
the buffer copy I have a reference to compare without the need to
leave emacs and look at revision control diffs or the like, and if
a file is not maintained via VC anyway.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defvar</span> <span style="color: #a0522d;">copy-counter</span> 0)
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">get-copy-buffer-name</span>()
<span style="color: #cd6600;">"return unique copy buffer name"</span>
(<span style="color: #0000ff;">let</span> ((name (concat <span style="color: #ff0000;">"*COPY "</span> (buffer-name (current-buffer)) <span style="color: #ff0000;">" (RO)"</span>)))
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (get-buffer name))
(<span style="color: #0000ff;">progn</span>
(<span style="color: #0000ff;">setq</span> copy-counter (1+ copy-counter))
(concat name <span style="color: #ff0000;">"&lt;"</span> (number-to-string copy-counter) <span style="color: #ff0000;">"&gt;"</span>))
(concat name))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">copy-buffer-read-only</span>()
<span style="color: #cd6600;">"Create a read-only copy of the current buffer"</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((old-buffer (current-buffer))
(new-buffer-name (get-copy-buffer-name)))
(<span style="color: #0000ff;">progn</span>
(delete-other-windows)
(split-window-horizontally)
(other-window 1)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (<span style="color: #0000ff;">eq</span> (get-buffer new-buffer-name) nil))
(kill-buffer (get-buffer new-buffer-name)))
(set-buffer (get-buffer-create new-buffer-name))
(insert-buffer-substring old-buffer)
(read-only-mode)
(switch-to-buffer new-buffer-name)
(other-window 1))))
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'cp</span> <span style="color: #ff00ff;">'copy-buffer-read-only</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-p"</span>) <span style="color: #ff00ff;">'copy-buffer-read-only</span>) <span style="color: #006400;">; </span><span style="color: #006400;">make read-only buffer copy</span>
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgaa566f2" class="outline-3">
<h3 id="orgaa566f2"><span class="section-number-3">5.12</span> Cleanup, close all windows and kill all buffers</h3>
<div class="outline-text-3" id="text-5-12">
<p>
From time to time I get annoyed by the many dozen buffers
opened. In such cases I like to close them all at once.
</p>
<p>
No key binding though, just in case I stumble upon it and kill my
setup accidentally.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">kill-all-buffers</span> ()
<span style="color: #cd6600;">"Kill all buffers, clean up, close all windows"</span>
(interactive)
(<span style="color: #0000ff;">if</span> (y-or-n-p <span style="color: #ff0000;">"Close all windows and kill all buffers?"</span>)
(<span style="color: #0000ff;">progn</span>
(delete-other-windows)
(clean-buffer-list)
(<span style="color: #0000ff;">dolist</span> (buffer (buffer-list))
(kill-buffer buffer))
(delete-minibuffer-contents)
(<span style="color: #0000ff;">if</span> (fboundp <span style="color: #ff00ff;">'tramp-cleanup-all-connections</span>)
(tramp-cleanup-all-connections)))))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org690152b" class="outline-3">
<h3 id="org690152b"><span class="section-number-3">5.13</span> Cleanup current buffer</h3>
<div class="outline-text-3" id="text-5-13">
<p>
Remove TABs, leading and trailing spaces, re-indent a buffer.
</p>
<p>
via <a href="http://whattheemacsd.com/buffer-defuns.el-01.html">whattheemacs.d</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">cleanup-buffer</span> ()
<span style="color: #cd6600;">"Perform a bunch of safe operations on the whitespace content of a buffer.</span>
<span style="color: #cd6600;">Does not indent buffer, because it is used for a before-save-hook, and that</span>
<span style="color: #cd6600;">might be bad."</span>
(interactive)
(untabify (point-min) (point-max))
(delete-trailing-whitespace)
(<span style="color: #0000ff;">save-excursion</span>
(replace-regexp <span style="color: #ff0000;">"^\n\\{3,\\}"</span> <span style="color: #ff0000;">"\n\n"</span> nil (point-min) (point-max)))
(set-buffer-file-coding-system <span style="color: #ff00ff;">'utf-8</span>)
(indent-region (point-min) (point-max)))
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'cb</span> <span style="color: #ff00ff;">'cleanup-buffer</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgfa697ab" class="outline-3">
<h3 id="orgfa697ab"><span class="section-number-3">5.14</span> Better newline(s)</h3>
<div class="outline-text-3" id="text-5-14">
<p>
Add newline and jump to indent from wherever I am in the current
line, that is it is not required to be on the end of line.
</p>
<p>
via <a href="http://whattheemacsd.com/editing-defuns.el-01.html">whattheemacs.d</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">open-line-below</span> ()
(interactive)
(end-of-line)
(newline)
(indent-for-tab-command))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">open-line-above</span> ()
(interactive)
(end-of-line)
(beginning-of-line)
(newline)
(forward-line -1)
(indent-for-tab-command))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-return&gt;"</span>) <span style="color: #ff00ff;">'open-line-below</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-S-return&gt;"</span>) <span style="color: #ff00ff;">'open-line-above</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org4fdd1b6" class="outline-3">
<h3 id="org4fdd1b6"><span class="section-number-3">5.15</span> Mouse Rectangle</h3>
<div class="outline-text-3" id="text-5-15">
<p>
There's not much use for the mouse in emacs, but this gimick is
funny and works like a charm.
</p>
<p>
via <a href="http://emacs.stackexchange.com/a/7261">stackoverflow</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">mouse-start-rectangle</span> (start-event)
(interactive <span style="color: #ff0000;">"e"</span>)
(deactivate-mark)
(mouse-set-point start-event)
(rectangle-mark-mode +1)
(<span style="color: #0000ff;">let</span> ((drag-event))
(<span style="color: #0000ff;">track-mouse</span>
(<span style="color: #0000ff;">while</span> (<span style="color: #0000ff;">progn</span>
(<span style="color: #0000ff;">setq</span> drag-event (read-event))
(mouse-movement-p drag-event))
(mouse-set-point drag-event)))))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"S-&lt;down-mouse-1&gt;"</span>) <span style="color: #ff00ff;">'mouse-start-rectangle</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org3c5fdd1" class="outline-3">
<h3 id="org3c5fdd1"><span class="section-number-3">5.16</span> DOS &lt;=&gt; UNIX conversion helpers</h3>
<div class="outline-text-3" id="text-5-16">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">dos2unix</span> ()
(interactive)
(set-buffer-file-coding-system <span style="color: #ff00ff;">'utf-8-unix</span>)
(message (format <span style="color: #ff0000;">"converted current buffer to %s"</span> buffer-file-coding-system)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">unix2dos</span> ()
(interactive)
(set-buffer-file-coding-system <span style="color: #ff00ff;">'utf-8-dos</span>)
(message (format <span style="color: #ff0000;">"converted current buffer to %s"</span> buffer-file-coding-system)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org0fcd0b1" class="outline-3">
<h3 id="org0fcd0b1"><span class="section-number-3">5.17</span> helper do add the same thing to multiple mode hooks</h3>
<div class="outline-text-3" id="text-5-17">
<p>
via <a href="http://stackoverflow.com/posts/3900056/revisions">stackoverflow</a>
usage samples below.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">add-something-to-mode-hooks</span> (mode-list something)
<span style="color: #cd6600;">"helper function to add a callback to multiple hooks"</span>
(<span style="color: #0000ff;">dolist</span> (mode mode-list)
(add-hook (intern (concat (symbol-name mode) <span style="color: #ff0000;">"-mode-hook"</span>)) something)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgcaa444d" class="outline-3">
<h3 id="orgcaa444d"><span class="section-number-3">5.18</span> helper to catch load errors</h3>
<div class="outline-text-3" id="text-5-18">
<p>
Try to eval 'fn, catch errors, if any but make it possible for
emacs to continue undisturbed, used with SMEX, see below.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defmacro</span> <span style="color: #9932cc;">safe-wrap</span> (fn <span style="color: #483d8b;">&amp;rest</span> clean-up)
`(<span style="color: #0000ff;">unwind-protect</span>
(<span style="color: #0000ff;">let</span> (retval)
(<span style="color: #0000ff;">condition-case</span> ex
(<span style="color: #0000ff;">setq</span> retval (<span style="color: #0000ff;">progn</span> ,fn))
(<span style="color: #ff00ff;">'error</span>
(message (format <span style="color: #ff0000;">"Caught exception: [%s]"</span> ex))
(<span style="color: #0000ff;">setq</span> retval (cons <span style="color: #ff00ff;">'exception</span> (list ex)))))
retval)
,@clean-up))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org6c9e422" class="outline-3">
<h3 id="org6c9e422"><span class="section-number-3">5.19</span> Alignment Wrappers</h3>
<div class="outline-text-3" id="text-5-19">
<p>
align-regexp is already a very usefull tool, however, sometimes I
want to repeat the alignment and I hate C-u, so here are some
wrappers to make this easier.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">align-repeat</span> (regex <span style="color: #483d8b;">&amp;optional</span> alignment)
<span style="color: #cd6600;">"Aply REGEX to all columns not just the first. Align by</span>
<span style="color: #cd6600;">ALIGNMENT which must be 'left or 'right. The default is 'left.</span>
<span style="color: #cd6600;">Right alignment:</span>
<span style="color: #cd6600;">col1 ,col2</span>
<span style="color: #cd6600;">col1 ,col2</span>
<span style="color: #cd6600;">Left alignment:</span>
<span style="color: #cd6600;">col1, col2</span>
<span style="color: #cd6600;">col1, col2"</span>
(interactive <span style="color: #ff0000;">"MRepeat Align Regex [ ]: "</span>)
(<span style="color: #0000ff;">let</span> ((spc <span style="color: #ff0000;">" "</span>)
(beg (point-min))
(end (point-max))
(areg <span style="color: #ff0000;">"%s</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">\\s-*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">"</span> <span style="color: #006400;">; </span><span style="color: #006400;">default left aligned</span>
))
(<span style="color: #0000ff;">when</span> (string= regex <span style="color: #ff0000;">""</span>)
(<span style="color: #0000ff;">setq</span> regex spc))
(<span style="color: #0000ff;">when</span> (region-active-p)
(<span style="color: #0000ff;">setq</span> beg (region-beginning))
(<span style="color: #0000ff;">setq</span> end (region-end)))
(<span style="color: #0000ff;">when</span> (<span style="color: #0000ff;">eq</span> alignment <span style="color: #ff00ff;">'right</span>)
(<span style="color: #0000ff;">setq</span> areg <span style="color: #ff0000;">"</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">\\s-*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">%s"</span>))
(align-regexp beg end (format areg regex) 1 1 t)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">align-repeat-left</span> (regex)
(interactive <span style="color: #ff0000;">"MRepeat Left Align Regex [ ]: "</span>)
(align-regexp-repeat regex <span style="color: #ff00ff;">'left</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">align-repeat-right</span> (regex)
(interactive <span style="color: #ff0000;">"MRepeat Left Align Regex [ ]: "</span>)
(align-regexp-repeat regex <span style="color: #ff00ff;">'right</span>))
</pre>
</div>
</div>
</div>
<div id="outline-container-orge711a42" class="outline-3">
<h3 id="orge711a42"><span class="section-number-3">5.20</span> String Helpers</h3>
<div class="outline-text-3" id="text-5-20">
<p>
Some helper functions I use here and there.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-alist-keys</span> (A)
<span style="color: #cd6600;">"return a list of keys of alist A"</span>
(<span style="color: #0000ff;">let</span> ((K ()))
(<span style="color: #0000ff;">dolist</span> (e A)
(push (<span style="color: #0000ff;">car</span> e) K)
)
K))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-get-line</span> ()
<span style="color: #cd6600;">"return current line in current buffer"</span>
(buffer-substring-no-properties
(line-beginning-position)
(line-end-position)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-starts-with</span> (s begins)
<span style="color: #cd6600;">"Return non-nil if string S starts with BEGINS."</span>
(<span style="color: #0000ff;">cond</span> ((&gt;= (length s) (length begins))
(string-equal (substring s 0 (length begins)) begins))
(t nil)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-replace-all</span> (regex replace)
<span style="color: #cd6600;">"Replace all matches of REGEX with REPLACE in current buffer."</span>
(interactive)
(goto-char (point-min))
(<span style="color: #0000ff;">while</span> (re-search-forward regex (end-of-line) t)
(replace-match replace)))
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org7acd779" class="outline-2">
<h2 id="org7acd779"><span class="section-number-2">6</span> Modes</h2>
<div class="outline-text-2" id="text-6">
</div><div id="outline-container-orgb77709f" class="outline-3">
<h3 id="orgb77709f"><span class="section-number-3">6.1</span> Programming Languages</h3>
<div class="outline-text-3" id="text-6-1">
</div><div id="outline-container-org9ed682f" class="outline-4">
<h4 id="org9ed682f"><span class="section-number-4">6.1.1</span> VALA</h4>
<div class="outline-text-4" id="text-6-1-1">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(autoload <span style="color: #ff00ff;">'vala-mode</span> <span style="color: #ff0000;">"vala-mode"</span> <span style="color: #cd6600;">"Major mode for editing Vala code."</span> t)
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.vala$"</span> . vala-mode))
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.vapi$"</span> . vala-mode))
(add-to-list <span style="color: #ff00ff;">'file-coding-system-alist</span> '(<span style="color: #ff0000;">"\\.vala$"</span> . utf-8))
(add-to-list <span style="color: #ff00ff;">'file-coding-system-alist</span> '(<span style="color: #ff0000;">"\\.vapi$"</span> . utf-8))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org870753c" class="outline-4">
<h4 id="org870753c"><span class="section-number-4">6.1.2</span> python mode</h4>
<div class="outline-text-4" id="text-6-1-2">
<p>
Not much configured for python, I'm happy with the defaults as it seems :)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(autoload <span style="color: #ff00ff;">'python-mode</span> <span style="color: #ff0000;">"python-mode"</span> <span style="color: #cd6600;">"Major mode for python scripts"</span> t)
(add-hook
<span style="color: #ff00ff;">'python-mode-hook</span>
(function
(<span style="color: #0000ff;">lambda</span>()
(local-set-key [delete] <span style="color: #ff00ff;">'py-electric-delete</span>)
(setq-default indent-tabs-mode nil)
(<span style="color: #0000ff;">setq</span> mode-name <span style="color: #ff0000;">"PY"</span>)
(outline-minor-mode 0) <span style="color: #006400;">;; </span><span style="color: #006400;">turn off outline here. /</span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">FIXME</span><span style="color: #006400;">/: find out where it's turned on!</span>
)))
(<span style="color: #0000ff;">setq</span> auto-mode-alist
(append '((<span style="color: #ff0000;">"\\.</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">py</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">$"</span> . python-mode))
auto-mode-alist))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgc8cf746" class="outline-4">
<h4 id="orgc8cf746"><span class="section-number-4">6.1.3</span> cperl mode</h4>
<div class="outline-text-4" id="text-6-1-3">
<p>
I am a perl addict. I love it, therefore, emacs must be prepared
for my addiction. Most importantly, I prefer cperl instead of the
default perl mode. I do not use the cperl version delivered with
emacs though, but the latest git version.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(autoload <span style="color: #ff00ff;">'cperl-mode</span> <span style="color: #ff0000;">"cperl-mode"</span> <span style="color: #cd6600;">"alternate perl mode"</span> t)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'perl-mode</span> <span style="color: #ff00ff;">'cperl-mode</span>)
</pre>
</div>
<p>
enable the most important cperl features
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> cperl-indent-left-aligned-comments nil)
(<span style="color: #0000ff;">setq</span> cperl-comment-column 32)
(<span style="color: #0000ff;">setq</span> cperl-hairy t)
(<span style="color: #0000ff;">setq</span> cperl-electric-linefeed t)
(<span style="color: #0000ff;">setq</span> cperl-electric-keywords t)
(<span style="color: #0000ff;">setq</span> cperl-electric-parens t)
(<span style="color: #0000ff;">setq</span> cperl-electric-parens-string nil)
</pre>
</div>
<p>
perl special: run, compile, debug
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> perl-run-out-buffer <span style="color: #ff0000;">"*Async Shell Command*"</span>)
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">perl-kill</span> ()
<span style="color: #cd6600;">"get rid of hanging perl compile or run buffers"</span>
(interactive)
(delete-windows-on perl-run-out-buffer)
(kill-buffer perl-run-out-buffer))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">perl-run</span> (switches parameters prefix)
<span style="color: #cd6600;">"execute current perl buffer"</span>
(interactive <span style="color: #ff0000;">"sPerl-switches:\nsParameter:\nP"</span>)
(<span style="color: #0000ff;">let</span> ((file buffer-file-name))
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> prefix nil)
(shell-command (concat <span style="color: #ff0000;">"perl "</span> switches <span style="color: #ff0000;">" "</span> file <span style="color: #ff0000;">" "</span> parameters <span style="color: #ff0000;">"&amp;"</span>))
(shell-command (concat <span style="color: #ff0000;">"perl -wc "</span> switches <span style="color: #ff0000;">" "</span> file <span style="color: #ff0000;">" "</span> parameters <span style="color: #ff0000;">"&amp;"</span>)))
(<span style="color: #0000ff;">save-excursion</span>
(set-buffer perl-run-out-buffer)
(<span style="color: #0000ff;">setq</span> perl-error-fontified nil
perl-error-start nil
perl-error-end nil)
(goto-char (point-min)))
))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">perl-next-error</span> ()
<span style="color: #cd6600;">"jump to next perl run error, if any"</span>
(interactive)
(<span style="color: #0000ff;">let</span> (line
errorfile
(window (get-buffer-window (buffer-name)))
(file buffer-file-name)
(buffer (buffer-name))
)
(select-window (display-buffer perl-run-out-buffer))
(set-buffer perl-run-out-buffer)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> perl-error-fontified t)
(<span style="color: #0000ff;">progn</span>
(set-text-properties perl-error-start perl-error-end ())
(<span style="color: #0000ff;">setq</span> perl-error-fontified nil)
)
)
(<span style="color: #0000ff;">if</span> (re-search-forward (concat <span style="color: #ff0000;">"at </span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">[-a-zA-Z:0-9._~#/\\]*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;"> line </span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">[0-9]*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">[.,]"</span>) (point-max) t)
()
(goto-char (point-min))
(message <span style="color: #ff0000;">"LAST ERROR, jumping to first"</span>)
(re-search-forward (concat <span style="color: #ff0000;">"at </span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">[-a-zA-Z:0-9._~#/\\]*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;"> line </span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">[0-9]*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">[.,]"</span>) (point-max) t)
)
(recenter)
(set-text-properties (match-beginning 1)
(match-end 2)
(list <span style="color: #ff00ff;">'face</span> font-lock-keyword-face))
(<span style="color: #0000ff;">setq</span> perl-error-fontified t
perl-error-start (match-beginning 1)
perl-error-end (match-end 2)
errorfile (buffer-substring
(match-beginning 1)
(match-end 1))
line (string-to-int (buffer-substring
(match-beginning 2)
(match-end 2))))
(select-window window)
(find-file errorfile)
(goto-line line)))
</pre>
</div>
<p>
cperl indent region
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">own-cperl-indent-region-or-paragraph</span> (start end)
(interactive <span style="color: #ff0000;">"r"</span>)
(<span style="color: #0000ff;">if</span> mark-active
(cperl-indent-region start end)
(<span style="color: #0000ff;">save-excursion</span>
(mark-paragraph)
(cperl-indent-region (point) (mark t))
)))
</pre>
</div>
<p>
and hook them into cperl
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook
<span style="color: #ff00ff;">'cperl-mode-hook</span>
(function
(<span style="color: #0000ff;">lambda</span>()
(make-variable-buffer-local <span style="color: #ff00ff;">'perl-error-fontified</span>)
(make-variable-buffer-local <span style="color: #ff00ff;">'perl-error-start</span>)
(make-variable-buffer-local <span style="color: #ff00ff;">'perl-error-end</span>)
(make-variable-buffer-local <span style="color: #ff00ff;">'perl-old-switches</span>)
(make-variable-buffer-local <span style="color: #ff00ff;">'perl-old-parameters</span>)
(local-set-key <span style="color: #ff0000;">"\C-hF"</span> <span style="color: #ff00ff;">'cperl-info-on-current-command</span>)
(local-set-key <span style="color: #ff0000;">"\C-hf"</span> <span style="color: #ff00ff;">'describe-function</span>)
(local-set-key <span style="color: #ff0000;">"\C-hV"</span> <span style="color: #ff00ff;">'cperl-get-help</span>)
(local-set-key <span style="color: #ff0000;">"\C-hv"</span> <span style="color: #ff00ff;">'describe-variable</span>)
(local-set-key <span style="color: #ff0000;">"\C-cr"</span> <span style="color: #ff00ff;">'perl-run</span>)
(local-set-key [f5] <span style="color: #ff00ff;">'perl-run</span>) <span style="color: #006400;">;</span><span style="color: #006400;">F5 perl-run</span>
(local-set-key [f6] <span style="color: #ff00ff;">'perl-kill</span>) <span style="color: #006400;">;</span><span style="color: #006400;">F6 perl-kill</span>
(local-set-key <span style="color: #ff0000;">"\C-ck"</span> <span style="color: #ff00ff;">'perl-kill</span>)
(local-set-key <span style="color: #ff0000;">"\C-c#"</span> <span style="color: #ff00ff;">'perl-next-error</span>)
(local-set-key <span style="color: #ff0000;">"\M-\C-q"</span> <span style="color: #ff00ff;">'own-cperl-indent-region-or-paragraph</span>)
(<span style="color: #0000ff;">setq</span> mode-name <span style="color: #ff0000;">"PL"</span>)
)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgf26d44b" class="outline-4">
<h4 id="orgf26d44b"><span class="section-number-4">6.1.4</span> Paredit for lisp only</h4>
<div class="outline-text-4" id="text-6-1-4">
<p>
I use paredit in lisp a lot, but are mostly happy with the defaults.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(autoload <span style="color: #ff00ff;">'enable-paredit-mode</span> <span style="color: #ff0000;">"paredit"</span> <span style="color: #cd6600;">"Turn on pseudo-structural editing of Lisp code."</span> t)
</pre>
</div>
<p>
However, I use it with lisp dialects only
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'emacs-lisp-mode-hook</span> #<span style="color: #ff00ff;">'enable-paredit-mode</span>)
(add-hook <span style="color: #ff00ff;">'eval-expression-minibuffer-setup-hook</span> #<span style="color: #ff00ff;">'enable-paredit-mode</span>)
(add-hook <span style="color: #ff00ff;">'ielm-mode-hook</span> #<span style="color: #ff00ff;">'enable-paredit-mode</span>)
(add-hook <span style="color: #ff00ff;">'lisp-mode-hook</span> #<span style="color: #ff00ff;">'enable-paredit-mode</span>)
(add-hook <span style="color: #ff00ff;">'lisp-interaction-mode-hook</span> #<span style="color: #ff00ff;">'enable-paredit-mode</span>)
(add-hook <span style="color: #ff00ff;">'scheme-mode-hook</span> #<span style="color: #ff00ff;">'enable-paredit-mode</span>)
(add-hook <span style="color: #ff00ff;">'slime-repl-mode-hook</span> (<span style="color: #0000ff;">lambda</span> () (paredit-mode +1)))
</pre>
</div>
<p>
sometimes I need to be able to turn it off fast:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'pe</span> <span style="color: #ff00ff;">'paredit-mode</span>)
(eval-after-load <span style="color: #ff00ff;">'paredit</span>
'(<span style="color: #0000ff;">progn</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">force my own bindings for those</span>
(define-key paredit-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-d"</span>) nil)
(define-key paredit-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;M-up&gt;"</span>) nil)
(define-key paredit-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;M-down&gt;"</span>) nil)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org6fc242d" class="outline-4">
<h4 id="org6fc242d"><span class="section-number-4">6.1.5</span> ETAGS</h4>
<div class="outline-text-4" id="text-6-1-5">
<p>
I use ETAGS for some projects. With etags I can easily jump to the
definition of a function, struct or whatever across files and
directories.
</p>
<p>
manually generate the tags file:
/usr/bin/ctags-exuberant -e *.c &#x2026;
visit-tags-file ("TAGS" whereever ctags run)
</p>
<p>
then load TAGS with visit-tags-table
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'etags-select</span>)
</pre>
</div>
<p>
generate TAGS and load it
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">etags-create</span> (dir-name)
<span style="color: #cd6600;">"Create tags file."</span>
(interactive <span style="color: #ff0000;">"DDirectory: "</span>)
(<span style="color: #0000ff;">let*</span> ((ctags <span style="color: #ff0000;">"/usr/bin/ctags-exuberant"</span>)
(odir (directory-file-name dir-name))
(ofile (concat odir <span style="color: #ff0000;">"/TAGS"</span>))
(langs <span style="color: #ff0000;">"lisp,python,perl,c,c++,shell"</span>)
(shell-command
(format <span style="color: #ff0000;">"%s -f %s -e -R --languages=%s %s"</span> ctags ofile langs odir))
(visit-tags-table ofile))))
</pre>
</div>
<p>
ALT<sub>R</sub> + e (equals on de keyboard € sign): jump to tag source
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&#8364;"</span>) <span style="color: #ff00ff;">'etags-select-find-tag-at-point</span>) <span style="color: #006400;">; </span><span style="color: #006400;">alt-right + e: jump to tag definition</span>
</pre>
</div>
<p>
Use ido to list tags, but then select via etags-select (best of both worlds!)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">etags-find</span> ()
<span style="color: #cd6600;">"Find a tag using ido"</span>
(interactive)
(tags-completion-table)
(<span style="color: #0000ff;">let</span> (tag-names)
(mapatoms (<span style="color: #0000ff;">lambda</span> (x)
(push (prin1-to-string x t) tag-names))
tags-completion-table)
(etags-select-find (ido-completing-read <span style="color: #ff0000;">"Tag: "</span> tag-names))))
</pre>
</div>
<p>
some handy aliases
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ec</span> <span style="color: #ff00ff;">'etags-create</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ef</span> <span style="color: #ff00ff;">'etags-find</span>)
</pre>
</div>
<hr />
</div>
</div>
</div>
<div id="outline-container-org1082fee" class="outline-3">
<h3 id="org1082fee"><span class="section-number-3">6.2</span> Text Modes</h3>
<div class="outline-text-3" id="text-6-2">
</div><div id="outline-container-orgd430407" class="outline-4">
<h4 id="orgd430407"><span class="section-number-4">6.2.1</span> sgml</h4>
<div class="outline-text-4" id="text-6-2-1">
<p>
Used for XML and the likes.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> sgml-set-face t)
(<span style="color: #0000ff;">setq</span> sgml-balanced-tag-edit t)
(<span style="color: #0000ff;">setq</span> sgml-omittag-transparent nil)
(<span style="color: #0000ff;">setq</span> sgml-auto-insert-required-elements t)
(<span style="color: #0000ff;">setq</span> sgml-markup-faces
'((start-tag . font-lock-function-name-face)
(end-tag . font-lock-function-name-face)
(comment . font-lock-comment-face)
(pi . font-lock-other-type-face)
(sgml . font-lock-variable-name-face)
(doctype . font-lock-type-face)
(entity . font-lock-string-face)
(shortref . font-lock-keyword-face)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgcb6def0" class="outline-4">
<h4 id="orgcb6def0"><span class="section-number-4">6.2.2</span> web-mode (JS, HTML, CSS combined)</h4>
<div class="outline-text-4" id="text-6-2-2">
<p>
Web development is shit. Tech involved is a mess, and in most cases
intermixed. web-mode provides a great fix for this: it handles
HTML, CSS and Javascript in the same buffer very well.
</p>
<p>
See: <a href="http://web-mode.org/">web-mode.org</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'web-mode</span>)
</pre>
</div>
<p>
associate with the usual suspects
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.phtml\\'"</span> . web-mode))
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.tpl\\.php\\'"</span> . web-mode))
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.[agj]sp\\'"</span> . web-mode))
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.as[cp]x\\'"</span> . web-mode))
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.erb\\'"</span> . web-mode))
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.mustache\\'"</span> . web-mode))
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.djhtml\\'"</span> . web-mode))
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.html?\\'"</span> . web-mode))
</pre>
</div>
<p>
configure web mode
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-web-mode-hook</span> ()
<span style="color: #cd6600;">"Hooks for Web mode."</span>
(<span style="color: #0000ff;">setq</span> web-mode-markup-indent-offset 2)
(<span style="color: #0000ff;">setq</span> web-mode-css-indent-offset 2)
(<span style="color: #0000ff;">setq</span> web-mode-code-indent-offset 2)
(<span style="color: #0000ff;">setq</span> web-mode-style-padding 1)
(<span style="color: #0000ff;">setq</span> web-mode-script-padding 1)
(<span style="color: #0000ff;">setq</span> web-mode-block-padding 0)
(<span style="color: #0000ff;">setq</span> web-mode-enable-auto-pairing t)
(<span style="color: #0000ff;">setq</span> web-mode-enable-auto-expanding t))
(add-hook <span style="color: #ff00ff;">'web-mode-hook</span> <span style="color: #ff00ff;">'tvd-web-mode-hook</span>)
</pre>
</div>
<p>
some handy html code inserters
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">html-insert-p</span>()
(interactive)
(web-mode-element-wrap <span style="color: #ff0000;">"p"</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">html-insert-li</span>()
(interactive)
(web-mode-element-wrap <span style="color: #ff0000;">"li"</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">html-insert-ul</span>()
(interactive)
(web-mode-element-wrap <span style="color: #ff0000;">"ul"</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">html-insert-b</span>()
(interactive)
(web-mode-element-wrap <span style="color: #ff0000;">"b"</span>))
</pre>
</div>
<p>
convert a text list into a html list.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">html-listify</span> (beg end)
(interactive <span style="color: #ff0000;">"r"</span>)
(<span style="color: #0000ff;">save-excursion</span>
(<span style="color: #0000ff;">let*</span> ((lines (split-string (buffer-substring beg end) <span style="color: #ff0000;">"\n"</span> t)))
(delete-region beg end)
(insert <span style="color: #ff0000;">"&lt;ul&gt;\n"</span>)
(<span style="color: #0000ff;">while</span> lines
(insert <span style="color: #ff0000;">" &lt;li&gt;"</span>)
(insert (pop lines))
(insert <span style="color: #ff0000;">"&lt;/li&gt;\n"</span>))
(insert <span style="color: #ff0000;">"&lt;/ul&gt;\n"</span>)
)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgdff03c0" class="outline-4">
<h4 id="orgdff03c0"><span class="section-number-4">6.2.3</span> Cisco Mode</h4>
<div class="outline-text-4" id="text-6-2-3">
<p>
Written by myself many years ago, but I'm still using it daily to
view and prepare cisco configs.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(autoload <span style="color: #ff00ff;">'cisco-mode</span> <span style="color: #ff0000;">"cisco-mode"</span> <span style="color: #cd6600;">"Major mode for CISCO configs"</span> t)
(<span style="color: #0000ff;">setq</span> auto-mode-alist
(append '((<span style="color: #ff0000;">"\\.</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">cfg</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">$"</span> . cisco-mode))
auto-mode-alist))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgb737379" class="outline-4">
<h4 id="orgb737379"><span class="section-number-4">6.2.4</span> Markdown</h4>
<div class="outline-text-4" id="text-6-2-4">
<p>
I rarely use markdown, but sometimes I stumble upon such a file and
like to view it with emacs without rendering.
Source: <a href="http://jblevins.org/projects/markdown-mode/">jblevins.org</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(autoload <span style="color: #ff00ff;">'markdown-mode</span> <span style="color: #ff0000;">"markdown-mode"</span>
<span style="color: #cd6600;">"Major mode for editing Markdown files"</span> t)
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.text\\'"</span> . markdown-mode))
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.markdown\\'"</span> . markdown-mode))
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.md\\'"</span> . markdown-mode))
</pre>
</div>
<p>
parens and quotes constraints check on save
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'markdown-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(<span style="color: #0000ff;">when</span> buffer-file-name
(add-hook <span style="color: #ff00ff;">'after-save-hook</span>
<span style="color: #ff00ff;">'check-parens</span>
nil t))
(modify-syntax-entry ?\" <span style="color: #ff0000;">"\""</span> markdown-mode-syntax-table)
))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org352873b" class="outline-4">
<h4 id="org352873b"><span class="section-number-4">6.2.5</span> POD mode</h4>
<div class="outline-text-4" id="text-6-2-5">
<p>
I LOVE POD! POD is the documentation format of perl and there's a
solid toolset available for it. I use it to write documentation and
manual pages. It's much more powerfull than lame markdown and you
can even program great tools yourself around POD (like I did with
PodWiki years ago!)
</p>
<p>
Although cperl mode already has some POD support, pod mode is way
better.
</p>
<p>
Source: <a href="https://github.com/renormalist/emacs-pod-mode">emacs-pod-mode</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'pod-mode</span>)
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'cc-mode</span>)
(add-to-list <span style="color: #ff00ff;">'auto-mode-alist</span> '(<span style="color: #ff0000;">"\\.pod$"</span> . pod-mode))
(add-hook <span style="color: #ff00ff;">'pod-mode-hook</span> <span style="color: #ff00ff;">'font-lock-mode</span>)
</pre>
</div>
<p>
using expand-region: apply pod entity formatting to word at point.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outline-emphasize</span>(CHAR)
<span style="color: #cd6600;">"expand once if no region and apply emphasize CHAR"</span>
(interactive)
(<span style="color: #0000ff;">unless</span> (use-region-p)
(er/expand-region 1))
(<span style="color: #0000ff;">save-excursion</span>
(goto-char (region-beginning))
(insert (format <span style="color: #ff0000;">"%c&lt;"</span> CHAR))
(goto-char (region-end))
(insert <span style="color: #ff0000;">"&gt;"</span>)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">pod-bold</span>()
<span style="color: #cd6600;">"bold text in outline mode"</span>
(interactive)
(tvd-outline-emphasize ?B))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">pod-italic</span>()
<span style="color: #cd6600;">"italic text in outline mode"</span>
(interactive)
(tvd-outline-emphasize ?I))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">pod-code</span>()
<span style="color: #cd6600;">"verbatim text in outline mode"</span>
(interactive)
(tvd-outline-emphasize ?C))
</pre>
</div>
<p>
pod mode config
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'pod-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
<span style="color: #006400;">;; </span><span style="color: #006400;">POD contains headers and I'm used to outlining if there are headers</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">so, enable outlining</span>
(<span style="color: #0000ff;">setq</span> outline-heading-alist '((<span style="color: #ff0000;">"=head1"</span> . 1)
(<span style="color: #ff0000;">"=head2"</span> . 2)
(<span style="color: #ff0000;">"=head3"</span> . 3)
(<span style="color: #ff0000;">"=head4"</span> . 4)))
(outline-minor-mode)
<span style="color: #006400;">;; </span><span style="color: #006400;">my own abbrevs for POD using mode-specific abbrev table</span>
(c-define-abbrev-table <span style="color: #ff00ff;">'pod-mode-abbrev-table</span> '(
(<span style="color: #ff0000;">"ov"</span> <span style="color: #ff0000;">"=over\n\n=item\n\n=back\n"</span>)
(<span style="color: #ff0000;">"h1"</span> <span style="color: #ff0000;">"=head1 "</span>)
(<span style="color: #ff0000;">"h2"</span> <span style="color: #ff0000;">"=head2 "</span>)
(<span style="color: #ff0000;">"h3"</span> <span style="color: #ff0000;">"=head3 "</span>)
(<span style="color: #ff0000;">"h4"</span> <span style="color: #ff0000;">"=head4 "</span>)
(<span style="color: #ff0000;">"b"</span> <span style="color: #ff0000;">"B&lt;&gt;"</span>)
(<span style="color: #ff0000;">"c"</span> <span style="color: #ff0000;">"C&lt;&gt;"</span>)
(<span style="color: #ff0000;">"l"</span> <span style="color: #ff0000;">"L&lt;&gt;"</span>)
(<span style="color: #ff0000;">"i"</span> <span style="color: #ff0000;">"I&lt;&gt;"</span>)
(<span style="color: #ff0000;">"e"</span> <span style="color: #ff0000;">"E&lt;&gt;"</span>)
(<span style="color: #ff0000;">"f"</span> <span style="color: #ff0000;">"F&lt;&gt;"</span>))
<span style="color: #ff0000;">"POD mode abbreviations, see .emacs"</span>
)
(abbrev-table-put pod-mode-abbrev-table <span style="color: #8a2be2;">:case-fixed</span> t)
(abbrev-table-put pod-mode-abbrev-table <span style="color: #8a2be2;">:system</span> t)
<span style="color: #006400;">;; </span><span style="color: #006400;">enable abbreviations</span>
(<span style="color: #0000ff;">setq</span> local-abbrev-table pod-mode-abbrev-table
abbrev-mode t)
<span style="color: #006400;">;; </span><span style="color: #006400;">POD easy formatting</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c b"</span>) <span style="color: #ff00ff;">'pod-bold</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c /"</span>) <span style="color: #ff00ff;">'pod-italic</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c c"</span>) <span style="color: #ff00ff;">'pod-code</span>)
))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org5975c00" class="outline-4">
<h4 id="org5975c00"><span class="section-number-4">6.2.6</span> conf-mode</h4>
<div class="outline-text-4" id="text-6-2-6">
<p>
conf-mode annoyingly overwrites the global keybinding C-c C-c with
some of its internal crab. So, force it to use my own defun. Also,
while we're at it, disable electric indent, it's annoying in
configs. Applies for derivates as well.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-disarm-conf-mode</span>()
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-c"</span>) <span style="color: #ff00ff;">'comment-or-uncomment-region-or-line</span>)
(electric-indent-local-mode 0))
(add-something-to-mode-hooks '(conf cisco fundamental conf-space pod) <span style="color: #ff00ff;">'tvd-disarm-conf-mode</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org08058ca" class="outline-4">
<h4 id="org08058ca"><span class="section-number-4">6.2.7</span> Config::General mode</h4>
<div class="outline-text-4" id="text-6-2-7">
<p>
<a href="https://github.com/TLINDEN/config-general-mode">config-general-mode</a> (also on Melpa).
</p>
<p>
My own mode for <a href="http://search.cpan.org/dist/Config-General/">Config::General</a>
config files. Whenever I write some perl stuff, which needs a config file, I use
this module (and I do this a lot). Previously I used conf-mode or html-mode, but
both did not satisfy me. Now (as of 20170625) I solved this mess once and for all.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'config-general-mode</span>)
</pre>
</div>
<p>
I use TAB for completion AND tab and outshine. Also, the mode
enables electric indent automatically, but I disabled it for
conf-mode (see tvd-disarm-conf-mode), therefore I re-enable it here
for config-general-mode (which inherits from conf-mode).
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'config-general-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(outline-minor-mode)
(electric-indent-mode)
<span style="color: #006400;">;; </span><span style="color: #006400;">de-activate some senseless bindings</span>
(local-unset-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-c"</span>))
(local-unset-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-p"</span>))
(local-unset-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-u"</span>))
(local-unset-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-w"</span>))
(local-unset-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-x"</span>))
(local-unset-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c :"</span>))
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;tab&gt;"</span>) <span style="color: #ff00ff;">'config-general-tab-or-expand</span>)))
</pre>
</div>
<hr />
</div>
</div>
</div>
<div id="outline-container-org91f94b9" class="outline-3">
<h3 id="org91f94b9"><span class="section-number-3">6.3</span> Text Manupilation</h3>
<div class="outline-text-3" id="text-6-3">
</div><div id="outline-container-org572f83c" class="outline-4">
<h4 id="org572f83c"><span class="section-number-4">6.3.1</span> expand-region</h4>
<div class="outline-text-4" id="text-6-3-1">
<p>
One of the best modes I ever discovered. Press C-= multiple times
to create a larger and larger region. I use C-0 (zero) because on a
german keyboard this is the same as C-= without pressing shift.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'expand-region</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-0"</span>) <span style="color: #ff00ff;">'er</span>/expand-region) <span style="color: #006400;">; </span><span style="color: #006400;">C-= without pressing shift on DE keyboard</span>
</pre>
</div>
<p>
related to ER:
</p>
</div>
</div>
<div id="outline-container-org9992dc4" class="outline-4">
<h4 id="org9992dc4"><span class="section-number-4">6.3.2</span> Mark, Copy, Yank Things</h4>
<div class="outline-text-4" id="text-6-3-2">
<p>
For a long time this stuff was located here in my emacs config. As
it grew larger and larger I decided to put it into its own mode:
mark-copy-yank-things-mode, which can be found on github these
days.
</p>
<p>
With this, you can quickly mark or copy or copy+yank things like
words, ip's, url's, lines or defun's with one key binding. I use
this permanently and couldn't live without it anymore.
</p>
<p>
A special feature is the copy+yanking, this is something vi offers:
go to a line, press yy, then p and the current line will be yanked
below. Prefix with a number and copy+yank more lines. This is
really cool and (in vi) often used. So, with this mode, I can use
it with emacs as well. For example, say you edit a configuration
file and added a complicated statement. Next you need to add
another very similar statement. Instead of entering it again, you
just hit &lt;C-c y y&gt; and the current line appears as a copy
below. Change the differences and you're done!
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'mark-copy-yank-things-mode</span>)
(mark-copy-yank-things-global-mode)
</pre>
</div>
<p>
The mode has a rather impractical prefix since it's published on
github and therefore must be written in a way not to disturb other
modes. However, I myself need those simple prefixes:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-key mark-copy-yank-things-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c"</span>) <span style="color: #ff00ff;">'mcyt-copy-map</span>)
(define-key mark-copy-yank-things-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-a"</span>) <span style="color: #ff00ff;">'mcyt-mark-map</span>)
</pre>
</div>
<p>
I use the default yank map
</p>
<p>
With this I put the last thing copied into a register 'c. I can
then later yank this using C-v anytime without browsing the
kill-ring if I kill things between yanking. So, C-v always inserts
the last copied thing, while C-y yanks the last thing killed, which
might be something else.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(advice-add <span style="color: #ff00ff;">'mcyt--copy-thing</span>
<span style="color: #8a2be2;">:after</span>
'(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> args)
(<span style="color: #0000ff;">with-temp-buffer</span>
(yank)
(copy-to-register <span style="color: #ff00ff;">'c</span> (point-min) (point-max)))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-insert-c-register</span> ()
(interactive)
(insert-register <span style="color: #ff00ff;">'c</span>))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-v"</span>) <span style="color: #ff00ff;">'tvd-insert-c-register</span>)
</pre>
</div>
<p>
copy a real number and convert it to german punctuation upon
yanking, so I can do some calculations in 'calculator, copy the
result NNN.NN and paste it into my online banking formular, where
it appears as NNN,NN.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-mcyt-copy-euro</span> (<span style="color: #483d8b;">&amp;optional</span> arg)
<span style="color: #cd6600;">"Copy euro at point into kill-ring and convert to german</span>
<span style="color: #cd6600;">punctuation"</span>
(interactive <span style="color: #ff0000;">"P"</span>)
(mcyt--blink-and-copy-thing <span style="color: #ff00ff;">'mcyt-beginning-of-ip</span> <span style="color: #ff00ff;">'mcyt-end-of-ip</span> arg)
(<span style="color: #0000ff;">with-temp-buffer</span>
(yank)
(beginning-of-buffer)
(<span style="color: #0000ff;">while</span> (re-search-forward <span style="color: #ff0000;">"\\."</span> nil t)
(replace-match <span style="color: #ff0000;">","</span>))
(kill-region (point-min) (point-max))))
(eval-after-load <span style="color: #ff0000;">"mark-copy-yank-things-mode"</span>
'(<span style="color: #0000ff;">progn</span>
(add-hook <span style="color: #ff00ff;">'mark-copy-yank-things-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> () <span style="color: #006400;">;; </span><span style="color: #006400;">g like [G]eld</span>
(define-key mcyt-copy-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"g"</span>) <span style="color: #ff00ff;">'tvd-mcyt-copy-euro</span>)))))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org462a3f4" class="outline-4">
<h4 id="org462a3f4"><span class="section-number-4">6.3.3</span> change-inner</h4>
<div class="outline-text-4" id="text-6-3-3">
<p>
I use change-inner with a prefix key and some wrappers around
mark-copy-yank-things-mode, which is related to change-inner
and expand-region.
</p>
<p>
<a href="https://github.com/magnars/change-inner.el">github source</a>:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'change-inner</span>)
</pre>
</div>
<p>
first some functions:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-ci</span> (beg end <span style="color: #483d8b;">&amp;optional</span> ins)
<span style="color: #cd6600;">"change-inner simulator which works with symbols instead of strings.</span>
<span style="color: #cd6600;">BEG and END must be executable elisp symbols moving (point). Everything</span>
<span style="color: #cd6600;">in between will be killed. If INS is non-nil, it will be inserted then."</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((B nil))
(funcall beg)
(<span style="color: #0000ff;">setq</span> B (point))
(funcall end)
(kill-region B (point))
(<span style="color: #0000ff;">when</span> ins
(insert ins))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-ci-comment</span> ()
<span style="color: #cd6600;">"\"change inner\" a whole comment [block]."</span>
(interactive)
(tvd-ci <span style="color: #ff00ff;">'mcyt-beginning-of-comment-block</span>
<span style="color: #ff00ff;">'mcyt-end-of-comment-block</span>
(format <span style="color: #ff0000;">"%s;# "</span> comment-start)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-ci-quote</span> ()
<span style="color: #cd6600;">"\"change inner\" quoted text."</span>
(interactive)
(tvd-ci <span style="color: #ff00ff;">'mcyt-beginning-of-quote</span>
<span style="color: #ff00ff;">'mcyt-end-of-quote</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-ci-word</span> ()
<span style="color: #cd6600;">"\"change inner\" a word (like cw in vi)."</span>
(interactive)
(tvd-ci <span style="color: #ff00ff;">'mcyt-beginning-of-symbol</span>
<span style="color: #ff00ff;">'mcyt-end-of-symbol</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-ci-line</span> ()
<span style="color: #cd6600;">"\"change inner\" a whole line."</span>
(interactive)
(tvd-ci <span style="color: #ff00ff;">'beginning-of-line</span>
<span style="color: #ff00ff;">'end-of-line</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-ci-paragraph</span> ()
<span style="color: #cd6600;">"\"change inner\" a whole paragraph."</span>
(interactive)
(tvd-ci <span style="color: #ff00ff;">'backward-paragraph</span>
<span style="color: #ff00ff;">'forward-paragraph</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-ci-buffer</span> ()
<span style="color: #cd6600;">"\"change inner\" a whole buffer."</span>
(interactive)
(tvd-ci <span style="color: #ff00ff;">'point-min</span>
<span style="color: #ff00ff;">'point-max</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-ci-sexp</span> ()
<span style="color: #cd6600;">"\"change inner\" a whole sexp."</span>
(interactive)
(er/mark-inside-pairs)
(call-interactively <span style="color: #ff00ff;">'kill-region</span>))
</pre>
</div>
<p>
Define ALT<sub>R</sub> (AltGR) + i as my prefix command for change-inner stuff.
Since I use a german keyboard, this translates to →.
I'll refrence it here now as &lt;A-i &#x2026;&gt;
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-prefix-command <span style="color: #ff00ff;">'ci-map</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&#8594;"</span>) <span style="color: #ff00ff;">'ci-map</span>)
</pre>
</div>
<p>
typing the prefix key twice calls the real change-inner
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&#8594;"</span>) <span style="color: #ff00ff;">'change-inner</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i A-i&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"c"</span>) <span style="color: #ff00ff;">'tvd-ci-comment</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i c&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&#162;"</span>) <span style="color: #ff00ff;">'tvd-ci-comment</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i A-c&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"q"</span>) <span style="color: #ff00ff;">'tvd-ci-quote</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i q&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"@"</span>) <span style="color: #ff00ff;">'tvd-ci-quote</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i A-q&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"w"</span>) <span style="color: #ff00ff;">'tvd-ci-word</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i w&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&#322;"</span>) <span style="color: #ff00ff;">'tvd-ci-word</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i A-w&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"l"</span>) <span style="color: #ff00ff;">'tvd-ci-line</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i l&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"s"</span>) <span style="color: #ff00ff;">'tvd-ci-sexp</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i s&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&#383;"</span>) <span style="color: #ff00ff;">'tvd-ci-sexp</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i A-s&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"p"</span>) <span style="color: #ff00ff;">'tvd-ci-paragraph</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i p&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&#254;"</span>) <span style="color: #ff00ff;">'tvd-ci-paragraph</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i A-p&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"a"</span>) <span style="color: #ff00ff;">'tvd-ci-buffer</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i a&gt;</span>
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&#230;"</span>) <span style="color: #ff00ff;">'tvd-ci-buffer</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">&lt;A-i A-a&gt;</span>
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org3175c28" class="outline-4">
<h4 id="org3175c28"><span class="section-number-4">6.3.4</span> Rotate text</h4>
<div class="outline-text-4" id="text-6-3-4">
<p>
This one is great as well, I use it to toggle flags and such stuff
in configs or code with just one key binding.
</p>
<p>
Source: <a href="http://nschum.de/src/emacs/rotate-text/">nschum.de</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(autoload <span style="color: #ff00ff;">'rotate-text</span> <span style="color: #ff0000;">"rotate-text"</span> nil t)
(autoload <span style="color: #ff00ff;">'rotate-text-backward</span> <span style="color: #ff0000;">"rotate-text"</span> nil t)
</pre>
</div>
<p>
my toggle list
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> rotate-text-words '((<span style="color: #ff0000;">"width"</span> <span style="color: #ff0000;">"height"</span>)
(<span style="color: #ff0000;">"left"</span> <span style="color: #ff0000;">"right"</span> <span style="color: #ff0000;">"top"</span> <span style="color: #ff0000;">"bottom"</span>)
(<span style="color: #ff0000;">"ja"</span> <span style="color: #ff0000;">"nein"</span>)
(<span style="color: #ff0000;">"off"</span> <span style="color: #ff0000;">"on"</span>)
(<span style="color: #ff0000;">"true"</span> <span style="color: #ff0000;">"false"</span>)
(<span style="color: #ff0000;">"nil"</span> <span style="color: #ff0000;">"t"</span>)
(<span style="color: #ff0000;">"yes"</span> <span style="color: #ff0000;">"no"</span>)))
</pre>
</div>
<p>
C-t normally used by transpose-chars, so, unbind it first
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-unset-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-t"</span>))
</pre>
</div>
<p>
however, we cannot re-bind it globally since then it could not be
used in org-mode for org-todo (see below) <i>FIXME</i>: I only use the "t"
short command anymore, so C-t would be free now, wouldn't it?
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-something-to-mode-hooks
'(c c++ cperl vala web emacs-lisp python ruby)
'(<span style="color: #0000ff;">lambda</span> ()
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-t"</span>) <span style="color: #ff00ff;">'rotate-text</span>)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org45575d0" class="outline-4">
<h4 id="org45575d0"><span class="section-number-4">6.3.5</span> Word wrapping</h4>
<div class="outline-text-4" id="text-6-3-5">
<p>
same as word-wrap but without the fringe which I hate the most!
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-something-to-mode-hooks '(tex text eww) <span style="color: #ff00ff;">'visual-line-mode</span>)
</pre>
</div>
<p>
however, it's required when coding, so enable it globally
overwritten by visual-line-mode above for specifics
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> word-wrap t)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org44c74e2" class="outline-4">
<h4 id="org44c74e2"><span class="section-number-4">6.3.6</span> Viking Mode</h4>
<div class="outline-text-4" id="text-6-3-6">
<p>
Delete stuff fast. Press the key multiple times - delete more
things. Inspired by expand-region. Written by myself.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'viking-mode</span>)
(viking-global-mode)
(<span style="color: #0000ff;">setq</span> viking-greedy-kill nil)
(define-key viking-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-d"</span>) <span style="color: #ff00ff;">'viking-repeat-last-kill</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgb540036" class="outline-4">
<h4 id="orgb540036"><span class="section-number-4">6.3.7</span> HTMLize</h4>
<div class="outline-text-4" id="text-6-3-7">
<p>
extracted from debian package emacs-goodies-el-35.2+nmu1, since
there's no other source left. Generates a fontified html version of
the current buffer, however it looks.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'htmlize</span>)
(<span style="color: #0000ff;">setq</span> htmlize-output-type <span style="color: #ff0000;">"inline-css"</span>)
</pre>
</div>
</div>
</div>
<div id="outline-container-org26f2cc6" class="outline-4">
<h4 id="org26f2cc6"><span class="section-number-4">6.3.8</span> iEdit (inline edit multiple searches)</h4>
<div class="outline-text-4" id="text-6-3-8">
<p>
Edit all occurences of something at once. Great for re-factoring.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'iedit</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-e"</span>) <span style="color: #ff00ff;">'iedit-mode</span>)
</pre>
</div>
<p>
Keep buffer-undo-list as is while iedit is active, that is, as long
as I am inside iedit I can undo/redo current occurences. However,
if I leave iedit and issue the undo command, ALL changes made with
iedit are undone, whereas the default behaviour would be to go
through every change made iside iedit, which I hate.
</p>
<p>
iedit doesn't provide a customizable flag to configure it's undo
behavior, so, I modify it myself using defadvice.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> tvd-buffer-undo-list nil)
(advice-add <span style="color: #ff00ff;">'iedit-mode</span> <span style="color: #8a2be2;">:before</span> '(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> args) <span style="color: #006400;">;; </span><span style="color: #006400;">save current</span>
(<span style="color: #0000ff;">setq</span> tvd-buffer-undo-list buffer-undo-list)))
(advice-add <span style="color: #ff00ff;">'iedit-mode</span> <span style="color: #8a2be2;">:after</span> '(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> args) <span style="color: #006400;">;; </span><span style="color: #006400;">restore previously saved</span>
(<span style="color: #0000ff;">setq</span> buffer-undo-list tvd-buffer-undo-list)))
</pre>
</div>
<hr />
</div>
</div>
</div>
<div id="outline-container-org55531a2" class="outline-3">
<h3 id="org55531a2"><span class="section-number-3">6.4</span> Interactives</h3>
<div class="outline-text-3" id="text-6-4">
</div><div id="outline-container-orgd7a54af" class="outline-4">
<h4 id="orgd7a54af"><span class="section-number-4">6.4.1</span> eShell stuff, or if interactive stuff is needed, use ansi-term</h4>
<div class="outline-text-4" id="text-6-4-1">
<p>
I am a hardcore bash user, but from time to time eshell is good
enough. It's great when used remote when only sftp is supported.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'eshell</span>)
</pre>
</div>
<p>
fac'ifier
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defmacro</span> <span style="color: #9932cc;">with-face</span> (str <span style="color: #483d8b;">&amp;rest</span> properties)
`(propertize ,str <span style="color: #ff00ff;">'face</span> (list ,@properties)))
</pre>
</div>
<p>
custom prompt, which resembles my bash prompt
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">shk-eshell-prompt</span> ()
(<span style="color: #0000ff;">let</span> ((header-bg <span style="color: #ff0000;">"Azure"</span>))
(concat
(with-face <span style="color: #ff0000;">"\n"</span>)
(with-face (format-time-string
<span style="color: #ff0000;">"[%Y-%m-%d %H:%M] --- ["</span>
(current-time)) <span style="color: #8a2be2;">:background</span> header-bg <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Black"</span>)
(with-face (concat (eshell/pwd) <span style="color: #ff0000;">""</span>) <span style="color: #8a2be2;">:background</span> header-bg <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Blue"</span>)
(with-face <span style="color: #ff0000;">"] --- "</span> <span style="color: #8a2be2;">:background</span> header-bg <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Black"</span>)
(with-face (or
(<span style="color: #0000ff;">ignore-errors</span> (format <span style="color: #ff0000;">"(%s)"</span> (vc-responsible-backend default-directory)))
<span style="color: #ff0000;">""</span>) <span style="color: #8a2be2;">:background</span> header-bg)
(with-face <span style="color: #ff0000;">"\n"</span> <span style="color: #8a2be2;">:background</span> header-bg)
(with-face user-login-name <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"blue"</span>)
<span style="color: #ff0000;">"@"</span>
(with-face <span style="color: #ff0000;">"localhost"</span> <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"blue"</span>)
(<span style="color: #0000ff;">if</span> (= (user-uid) 0)
(with-face <span style="color: #ff0000;">" #"</span> <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"red"</span>)
<span style="color: #ff0000;">" $"</span>)
<span style="color: #ff0000;">" "</span>)))
(<span style="color: #0000ff;">setq</span> eshell-prompt-function <span style="color: #ff00ff;">'shk-eshell-prompt</span>)
(<span style="color: #0000ff;">setq</span> eshell-highlight-prompt nil)
</pre>
</div>
<p>
I use my own virtual loggin target /dev/log, just redirect
command output to /dev/log and it will be saved to
the <b>LOG</b> buffer. &gt; inserts, &gt;&gt; appends
N.B: /dev/kill puts the stuff into the kill-ring.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">log-comment</span> ()
(<span style="color: #0000ff;">with-current-buffer</span> (get-buffer-create <span style="color: #ff0000;">"*LOG*"</span>)
(insert (format <span style="color: #ff0000;">"# %s\n"</span> (time-stamp-string)))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">log-insert</span> (string)
(<span style="color: #0000ff;">with-current-buffer</span> (get-buffer-create <span style="color: #ff0000;">"*LOG*"</span>)
(delete-region (point-min) (point-max))
(log-comment)
(insert string)
(message <span style="color: #ff0000;">"wrote output to *LOG* buffer"</span>)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">log-append</span> (string)
(<span style="color: #0000ff;">with-current-buffer</span> (get-buffer-create <span style="color: #ff0000;">"*LOG*"</span>)
(end-of-buffer)
(newline)
(log-comment)
(insert string)
(message <span style="color: #ff0000;">"wrote output to *LOG* buffer"</span>)))
</pre>
</div>
<p>
must return a defun which gets the stuff as ARG1
'mode is 'overwrite or 'append
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-to-list <span style="color: #ff00ff;">'eshell-virtual-targets</span> '(<span style="color: #ff0000;">"/dev/log"</span> (<span style="color: #0000ff;">lambda</span> (mode)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> mode <span style="color: #ff00ff;">'overwrite</span>)
<span style="color: #ff00ff;">'log-insert</span>
<span style="color: #ff00ff;">'log-append</span>))
t
))
</pre>
</div>
<p>
eshell config
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(eval-after-load <span style="color: #ff0000;">"eshell"</span>
'(<span style="color: #0000ff;">progn</span>
(add-hook <span style="color: #ff00ff;">'eshell-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(local-unset-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-r"</span>)) <span style="color: #006400;">; </span><span style="color: #006400;">we're already using this for windresize</span>
(add-to-list <span style="color: #ff00ff;">'eshell-visual-commands</span> <span style="color: #ff0000;">"tail"</span>)
(add-to-list <span style="color: #ff00ff;">'eshell-visual-commands</span> <span style="color: #ff0000;">"top"</span>)
(add-to-list <span style="color: #ff00ff;">'eshell-visual-commands</span> <span style="color: #ff0000;">"vi"</span>)
(add-to-list <span style="color: #ff00ff;">'eshell-visual-commands</span> <span style="color: #ff0000;">"ssh"</span>)
(add-to-list <span style="color: #ff00ff;">'eshell-visual-commands</span> <span style="color: #ff0000;">"tail"</span>)
(add-to-list <span style="color: #ff00ff;">'eshell-visual-commands</span> <span style="color: #ff0000;">"mutt"</span>)
(add-to-list <span style="color: #ff00ff;">'eshell-visual-commands</span> <span style="color: #ff0000;">"note"</span>)
(setenv <span style="color: #ff0000;">"TERM"</span> <span style="color: #ff0000;">"xterm"</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-l"</span>) <span style="color: #ff00ff;">'eshell</span>/clear)
(define-key viking-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-d"</span>) nil) <span style="color: #006400;">;; </span><span style="color: #006400;">need to undef C-d first</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-d"</span>) <span style="color: #ff00ff;">'eshell</span>/x)
(<span style="color: #0000ff;">setq</span> mode-name <span style="color: #ff0000;">"ESH"</span>
eshell-hist-ignoredups t
eshell-history-size 5000
eshell-where-to-jump <span style="color: #ff00ff;">'begin</span>
eshell-review-quick-commands nil
eshell-smart-space-goes-to-end t
eshell-scroll-to-bottom-on-input <span style="color: #ff00ff;">'all</span>
eshell-error-if-no-glob t
eshell-save-history-on-exit t
eshell-prefer-lisp-functions t)))))
</pre>
</div>
<p>
exit and restore viking key binding afterwards
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">eshell/x</span> (<span style="color: #483d8b;">&amp;rest</span> args)
(interactive)
(eshell-life-is-too-much)
(define-key viking-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-d"</span>) <span style="color: #ff00ff;">'viking-kill-thing-at-point</span>))
</pre>
</div>
<p>
open files in emacs, split the shell if not already splitted
open empty window if no file argument given.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">eshell/emacs</span> (<span style="color: #483d8b;">&amp;rest</span> args)
<span style="color: #cd6600;">"Editor commands fired from eshell will be handled by emacs, which already runs anyway."</span>
(interactive)
(<span style="color: #0000ff;">let*</span> ((framesize (frame-width))
(winsize (window-body-width)))
(<span style="color: #0000ff;">progn</span>
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> winsize framesize)
(split-window-horizontally))
(other-window 1)
(<span style="color: #0000ff;">if</span> (null args)
(bury-buffer)
(mapc #<span style="color: #ff00ff;">'find-file</span> (mapcar #<span style="color: #ff00ff;">'expand-file-name</span> (eshell-flatten-list (reverse args))))))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">eshell/clear</span> ()
<span style="color: #cd6600;">"Better clear command than (recenter 0) which doesn't work as I</span>
<span style="color: #cd6600;">want. This version really removes the output of previous commands</span>
<span style="color: #cd6600;">and puts the shell to the beginning of a really (then) empty eshell</span>
<span style="color: #cd6600;">buffer. However, just to be sure that I do no accidentally clear</span>
<span style="color: #cd6600;">some shell output that might be useful in the future, it also</span>
<span style="color: #cd6600;">copies the cleared stuff into a backup buffer named</span>
<span style="color: #cd6600;">*eshell-log-buffer*, just in case."</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((beg (point-min))
(end (point-max))
(savebuffer <span style="color: #ff0000;">"*eshell-log-buffer*"</span>)
(log (buffer-substring-no-properties (point-min) (point-max))))
(<span style="color: #0000ff;">progn</span>
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (get-buffer savebuffer))
(get-buffer-create savebuffer))
(<span style="color: #0000ff;">with-current-buffer</span> savebuffer
(goto-char (point-max))
(insert log))
(delete-region beg end)
(eshell-emit-prompt))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">eshell/perldoc</span> (<span style="color: #483d8b;">&amp;rest</span> args)
<span style="color: #cd6600;">"Like `</span><span style="color: #cd6600;">eshell/man</span><span style="color: #cd6600;">', but invoke `</span><span style="color: #cd6600;">perldoc</span><span style="color: #cd6600;">'."</span>
(funcall <span style="color: #ff00ff;">'eshell</span>/perldoc (apply <span style="color: #ff00ff;">'eshell-flatten-and-stringify</span> args)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">eshell/perldoc</span> (man-args)
(interactive <span style="color: #ff0000;">"sPerldoc: "</span>)
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'man</span>)
(<span style="color: #0000ff;">let</span> ((manual-program <span style="color: #ff0000;">"perldoc"</span>))
(man man-args)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">eshell-here</span> ()
<span style="color: #cd6600;">"Opens up a new shell in the directory associated with the</span>
<span style="color: #cd6600;">current buffer's file. The eshell is renamed to match that</span>
<span style="color: #cd6600;">directory to make multiple eshell windows easier."</span>
(interactive)
(<span style="color: #0000ff;">let*</span> ((parent (<span style="color: #0000ff;">if</span> (buffer-file-name)
(file-name-directory (buffer-file-name))
default-directory))
(height (/ (window-total-height) 3))
(name (<span style="color: #0000ff;">car</span> (last (split-string parent <span style="color: #ff0000;">"/"</span> t)))))
(split-window-vertically (- height))
(other-window 1)
(eshell <span style="color: #ff0000;">"new"</span>)
(rename-buffer (concat <span style="color: #ff0000;">"*eshell: "</span> name <span style="color: #ff0000;">"*"</span>))
(insert (concat <span style="color: #ff0000;">"ls"</span>))
(eshell-send-input)))
</pre>
</div>
<p>
via howardism
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">eshell-there</span> (host)
<span style="color: #cd6600;">"Opens a shell on a remote host using tramp."</span>
(interactive <span style="color: #ff0000;">"sHost: "</span>)
(<span style="color: #0000ff;">let</span> ((default-directory (format <span style="color: #ff0000;">"/%s:"</span> host)))
(eshell host)))
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'es</span> <span style="color: #ff00ff;">'eshell-here</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'et</span> <span style="color: #ff00ff;">'eshell-there</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'eshell</span>/vi <span style="color: #ff00ff;">'eshell</span>/emacs)
</pre>
</div>
<p>
plan9 smart command, edit while exec if not silent or successful
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'em-smart</span>)
</pre>
</div>
<p>
eshell shell aliases. I set the global
defvar here so there's no need to transport
~/.emacs.d/eshell/aliases across networks
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> eshell-command-aliases-list ())
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">+alias</span> (al cmd)
<span style="color: #cd6600;">"handy wrapper function to convert alias symbols</span>
<span style="color: #cd6600;">to alias strings to avoid writing 4 quotes per alias.</span>
<span style="color: #cd6600;">AL is a single-word symbol naming the alias, CMD is</span>
<span style="color: #cd6600;">a list symbol describing the command."</span>
(add-to-list <span style="color: #ff00ff;">'eshell-command-aliases-list</span>
(list (symbol-name al)
(mapconcat <span style="color: #ff00ff;">'symbol-name</span> cmd <span style="color: #ff0000;">" "</span>))))
</pre>
</div>
<p>
actual aliases
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(+alias <span style="color: #ff00ff;">'l</span> '(ls -laF $*))
(+alias <span style="color: #ff00ff;">'ll</span> '(ls -l $*))
(+alias <span style="color: #ff00ff;">'la</span> '(ls -a $*))
(+alias <span style="color: #ff00ff;">'lt</span> '(ls -ltr $*))
(+alias '.. '(cd ..))
(+alias '... '(cd ../..))
(+alias '.... '(cd ../../..))
(+alias '..... '(cd ../../../..))
(+alias <span style="color: #ff00ff;">'md</span> '(mkdir -p $*))
(+alias <span style="color: #ff00ff;">'emacs</span> '(find-file $1))
(+alias <span style="color: #ff00ff;">'less</span> '(find-file-read-only $1))
(+alias <span style="color: #ff00ff;">'x</span> '(eshell/exit))
</pre>
</div>
<p>
no need for less or more, this is emacs, isn't it?
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(setenv <span style="color: #ff0000;">"PAGER"</span> <span style="color: #ff0000;">"cat"</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orge10fe7a" class="outline-4">
<h4 id="orge10fe7a"><span class="section-number-4">6.4.2</span> Emacs LISP interactive</h4>
<div class="outline-text-4" id="text-6-4-2">
<p>
General configuration for all things elisp.
</p>
<p>
By using C-x-e I can push region or buffer
of lisp code (i.e. inside <b>scratch</b>) into
REPL where it will be evaluated
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-get-code</span>()
<span style="color: #cd6600;">"helper: returns marked region or the whole buffer contents"</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">/</span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">FIXME</span><span style="color: #006400;">/: mv to string helpers?</span>
(<span style="color: #0000ff;">if</span> mark-active
(<span style="color: #0000ff;">let</span> ( <span style="color: #006400;">;; </span><span style="color: #006400;">save region and buffer</span>
(partb (buffer-substring-no-properties (region-beginning) (region-end)))
(whole (buffer-substring-no-properties (point-min) (point-max)))
)
(<span style="color: #0000ff;">if</span> (&gt; (length partb) 0)
partb
whole
)
)
<span style="color: #006400;">;; </span><span style="color: #006400;">no mark, also return everything</span>
(buffer-substring-no-properties (point-min) (point-max))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-send-region-to-repl</span> ()
<span style="color: #cd6600;">"put region or buffer into elisp repl and eval"</span>
(interactive)
(<span style="color: #0000ff;">let</span> ( <span style="color: #006400;">;; </span><span style="color: #006400;">fetch region or buffer contents</span>
(code (tvd-get-code)))
(<span style="color: #0000ff;">progn</span>
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (get-buffer <span style="color: #ff0000;">"*ielm*"</span>))
<span style="color: #006400;">;; </span><span style="color: #006400;">ielm not yet running, start it in split window but stay here</span>
(<span style="color: #0000ff;">progn</span>
(split-window-horizontally)
(other-window 1)
(ielm)
(other-window 1)))
<span style="color: #006400;">;; </span><span style="color: #006400;">finially, paste content into ielm and evaluate it</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">still we stay where we are</span>
(<span style="color: #0000ff;">with-current-buffer</span> <span style="color: #ff0000;">"*ielm*"</span>
(goto-char (point-max))
(insert code)
(ielm-return)))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-elisp-eval</span>()
<span style="color: #cd6600;">"just eval region or buffer whatever feasible"</span>
(interactive)
(<span style="color: #0000ff;">progn</span>
(<span style="color: #0000ff;">if</span> mark-active
(eval-region)
(eval-buffer))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">ff</span> ()
<span style="color: #cd6600;">"Jump to function definition at point."</span>
(interactive)
(find-function-other-window (symbol-at-point)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-make-defun-links</span> ()
<span style="color: #cd6600;">"experimental: make function calls clickable, on click, jump to definition of it"</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((beg 0)
(end 0)
(fun nil))
(goto-char (point-min))
(<span style="color: #0000ff;">while</span> (re-search-forward <span style="color: #ff0000;">"(tvd[-a-z0-9]*"</span> nil t)
(<span style="color: #0000ff;">setq</span> end (point))
(re-search-backward <span style="color: #ff0000;">"("</span> nil t)
(forward-char 1)
(<span style="color: #0000ff;">setq</span> beg (point))
(<span style="color: #0000ff;">setq</span> fun (buffer-substring-no-properties beg end))
(make-button beg end <span style="color: #ff00ff;">'action</span>
(<span style="color: #0000ff;">lambda</span> (x)
(find-function-other-window (symbol-at-point))))
(goto-char end))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">emacs-change-log</span> (entry)
<span style="color: #cd6600;">"Add a changelog entry to .emacs Changelog"</span>
(interactive <span style="color: #ff0000;">"Menter change log entry: "</span>)
(<span style="color: #0000ff;">save-excursion</span>
(show-all)
(beginning-of-buffer)
(re-search-forward <span style="color: #ff0000;">";; .. Changelog"</span>)
(next-line)
(forward-paragraph)
(insert (format <span style="color: #ff0000;">";; - %s\n"</span> entry))))
</pre>
</div>
<p>
elisp config
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'emacs-lisp-mode-hook</span>
(<span style="color: #0000ff;">lambda</span>()
<span style="color: #006400;">;; </span><span style="color: #006400;">non-separated x-e == eval hidden, aka current buffer</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-x C-e"</span>) <span style="color: #ff00ff;">'tvd-elisp-eval</span>)
<span style="color: #006400;">;; </span><span style="color: #006400;">separate 'e' == separate buffer</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-x e"</span>) <span style="color: #ff00ff;">'tvd-send-region-to-repl</span>)
(<span style="color: #0000ff;">setq</span> mode-name <span style="color: #ff0000;">"EL"</span>
show-trailing-whitespace t)
(eldoc-mode t)
))
</pre>
</div>
<p>
use UP arrow for history in <b>ielm</b> as well, just as C-up
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'comint-mode-hook</span>
(<span style="color: #0000ff;">lambda</span>()
(define-key comint-mode-map [up] <span style="color: #ff00ff;">'comint-previous-input</span>)))
</pre>
</div>
<p>
sometimes I use lisp in minibuffer
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ee</span> <span style="color: #ff00ff;">'eval-expression</span>)
</pre>
</div>
<p>
sometimes I eval regions
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'er</span> <span style="color: #ff00ff;">'eval-region</span>)
</pre>
</div>
<p>
&#x2026; or defuns
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ef</span> <span style="color: #ff00ff;">'eval-defun</span>)
</pre>
</div>
<p>
I like to have some functions fontified differently
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(font-lock-add-keywords
<span style="color: #ff00ff;">'emacs-lisp-mode</span>
'((<span style="color: #ff0000;">"(\\s-*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">eq</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">if</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">cond</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">and</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">set</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">or</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">not</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">when</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">setq</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">let**</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">lambda</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">kbd</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">defun</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">car</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">cdr</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">\\s-+"</span>
1 <span style="color: #ff00ff;">'font-lock-keyword-face</span>)))
</pre>
</div>
<p>
same applies for quoted symbols
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(font-lock-add-keywords
<span style="color: #ff00ff;">'emacs-lisp-mode</span>
'((<span style="color: #ff0000;">"'[-a-zA-Z_][-a-zA-Z0-9_]*\\&gt;"</span> 0 <span style="color: #ff00ff;">'font-lock-constant-face</span>)))
</pre>
</div>
<p>
I hate it when help, debug, ielm and other peripheral buffers
litter my emacs window setup. So, this function fixes this: it
opens a new frame with all those buffers already opened and pinned.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">dev</span> ()
<span style="color: #cd6600;">"Open a new emacs frame with some development peripheral buffers."</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((F (new-frame)))
(<span style="color: #0000ff;">with-selected-frame</span> F
(<span style="color: #0000ff;">with-current-buffer</span> (get-buffer-create <span style="color: #ff0000;">"*Help*"</span>)
(help-mode))
(<span style="color: #0000ff;">with-current-buffer</span> (get-buffer-create <span style="color: #ff0000;">"*ielm*"</span>)
(ielm))
(<span style="color: #0000ff;">with-current-buffer</span> (get-buffer-create <span style="color: #ff0000;">"*suggest*"</span>)
(suggest))
(switch-to-buffer <span style="color: #ff0000;">"*ielm*"</span>)
(split-window-horizontally)
(split-window-vertically)
(windmove-down)
(switch-to-buffer <span style="color: #ff0000;">"*suggest*"</span>)
(tvd-suggest-reload)
(tvd-suggest-reload)
(windmove-right)
(switch-to-buffer <span style="color: #ff0000;">"*Help*"</span>)
(split-window-vertically)
(windmove-down)
(switch-to-buffer <span style="color: #ff0000;">"*scratch*"</span>)
(set-window-dedicated-p (selected-window) t)
(set-background-color <span style="color: #ff0000;">"azure"</span>))))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org9af09e4" class="outline-4">
<h4 id="org9af09e4"><span class="section-number-4">6.4.3</span> el2markdown</h4>
<div class="outline-text-4" id="text-6-4-3">
<p>
<a href="https://github.com/Lindydancer/el2markdown">el2markdown</a> is a module which
can be used to convert Commentary sections into markdown files. I use this to
avoid maintaining the README.md and the Commentary section in parallel.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'el2markdown</span>)
</pre>
</div>
<p>
To use, call el2markdown-view-buffer and put it into the
README.md. Take care though: it doesn't convert the META section.
</p>
<p>
<i>FIXME</i>: write a wrapper to circumvent these restrictions.
</p>
</div>
</div>
<div id="outline-container-orga16c73c" class="outline-4">
<h4 id="orga16c73c"><span class="section-number-4">6.4.4</span> tramp mode</h4>
<div class="outline-text-4" id="text-6-4-4">
<p>
Edit remote files, one of the best things in emacs. I use it every day heavily.
</p>
<p>
Sample: C-x-f /$host:/$file ($host as of .ssh/config or direct, $file including completion)
</p>
<p>
doku: <a href="http://www.gnu.org/software/tramp/">gnu.org</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> tramp-default-method <span style="color: #ff0000;">"ssh"</span>)
(<span style="color: #0000ff;">setq</span> tramp-default-user nil)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org36e2ef7" class="outline-4">
<h4 id="org36e2ef7"><span class="section-number-4">6.4.5</span> org mode</h4>
<div class="outline-text-4" id="text-6-4-5">
<p>
I use org mode to take notes mostly at work. I also track projects
and TODO lists etc. I do not, however, use agenda or any
scheduling whatsoever.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'org</span>)
</pre>
</div>
<p>
I like custom bullets
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'org-bullets</span>)
</pre>
</div>
<p>
enable syntax highlighting for embedded source blocks
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'ob-python</span>)
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'ob-perl</span>)
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'ob-sh</span>)
(<span style="color: #0000ff;">setq</span> org-bullets-bullet-list '(<span style="color: #ff0000;">"&#9658;"</span> <span style="color: #ff0000;">"&#10012;"</span> <span style="color: #ff0000;">"&#10040;"</span> <span style="color: #ff0000;">"&#10047;"</span> <span style="color: #ff0000;">"&#9830;"</span>))
</pre>
</div>
<p>
capture target, os-dependend
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">if</span> (null tvd-win-home)
(<span style="color: #0000ff;">setq</span> tvd-org-file (concat tvd-lisp-dir <span style="color: #ff0000;">"/notizen.org"</span>)
org-attach-directory (concat tvd-lisp-dir <span style="color: #ff0000;">"/attachments"</span>))
(<span style="color: #0000ff;">setq</span> tvd-org-file (concat tvd-win-home <span style="color: #ff0000;">"/notizen.org"</span>)
org-attach-directory (concat tvd-win-home <span style="color: #ff0000;">"/attachments"</span>)))
</pre>
</div>
<p>
text formatting made easy, bound to C-c keys locally
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-org-emphasize</span>(CHAR)
<span style="color: #cd6600;">"expand once if no region and apply emphasize CHAR"</span>
(interactive)
(<span style="color: #0000ff;">unless</span> (region-active-p)
(er/expand-region 1))
(org-emphasize CHAR))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">bold</span>()
<span style="color: #cd6600;">"bold text in org mode"</span>
(interactive)
(tvd-org-emphasize '42))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">italic</span>()
<span style="color: #cd6600;">"italic text in org mode"</span>
(interactive)
(tvd-org-emphasize '47))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">code</span>()
<span style="color: #cd6600;">"verbatim text in org mode"</span>
(interactive)
(tvd-org-emphasize '126))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">underline</span>()
<span style="color: #cd6600;">"underline text in org mode"</span>
(interactive)
(tvd-org-emphasize '95))
</pre>
</div>
<p>
my org-mode specific &lt;C-left&gt; and &lt;C-right&gt;
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-org-left-or-level-up</span>()
<span style="color: #cd6600;">"jump one word to the left if not on a org heading,</span>
<span style="color: #cd6600;">otherwise fold current level and jump one level up."</span>
(interactive)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">and</span> (org-at-heading-p) (looking-at <span style="color: #ff0000;">"*"</span>))
(<span style="color: #0000ff;">progn</span>
(hide-subtree)
(outline-up-heading 1))
(left-word)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-org-heading-up</span>()
<span style="color: #cd6600;">"If on a heading, fold current heading, jump one level</span>
<span style="color: #cd6600;">up and unfold it, otherwise jump paragraph as usual."</span>
(interactive)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">and</span> (org-at-heading-p) (looking-at <span style="color: #ff0000;">"*"</span>))
(<span style="color: #0000ff;">progn</span>
(hide-subtree)
(org-backward-heading-same-level 1)
(org-cycle))
(backward-paragraph)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-org-heading-down</span>()
<span style="color: #cd6600;">"If on a heading, fold current heading, jump one level</span>
<span style="color: #cd6600;">down and unfold it, otherwise jump paragraph as usual."</span>
(interactive)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">and</span> (org-at-heading-p) (looking-at <span style="color: #ff0000;">"*"</span>))
(<span style="color: #0000ff;">progn</span>
(hide-subtree)
(org-forward-heading-same-level 1)
(org-cycle))
(forward-paragraph)))
</pre>
</div>
<p>
org-mode specific config, after load
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(eval-after-load <span style="color: #ff0000;">"org"</span>
'(<span style="color: #0000ff;">progn</span>
(add-hook <span style="color: #ff00ff;">'org-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(setq
org-M-RET-may-split-line nil
org-agenda-files (list tvd-org-file)
org-agenda-restore-windows-after-quit t
org-blank-before-new-entry (quote ((heading . auto) (plain-list-item . auto)))
org-catch-invisible-edits (quote error)
org-columns-default-format <span style="color: #ff0000;">"%80ITEM %22Timestamp %</span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">TODO</span><span style="color: #ff0000;"> %TAGS %0PRIORITY"</span>
org-insert-heading-always-after-current (quote t)
org-mouse-1-follows-link nil
org-remember-store-without-prompt t
org-reverse-note-order t
org-startup-indented t
org-startup-truncated nil
org-return-follows-link t
org-use-speed-commands t
org-yank-adjusted-subtrees t
org-refile-targets '((nil . (<span style="color: #8a2be2;">:maxlevel</span> . 5)))
org-refile-use-outline-path t
org-outline-path-complete-in-steps nil
org-completion-use-ido t
org-support-shift-select t
org-hide-emphasis-markers t
org-fontify-done-headline t
org-pretty-entities t
org-confirm-babel-evaluate nil)
<span style="color: #006400;">; </span><span style="color: #006400;">shortcuts</span>
(<span style="color: #0000ff;">setq</span> org-speed-commands-user
(quote (
(<span style="color: #ff0000;">"0"</span> . ignore)
(<span style="color: #ff0000;">"1"</span> . delete-other-windows)
(<span style="color: #ff0000;">"2"</span> . ignore)
(<span style="color: #ff0000;">"3"</span> . ignore)
(<span style="color: #ff0000;">"d"</span> . org-archive-subtree-default-with-confirmation) <span style="color: #006400;">; </span><span style="color: #006400;">delete, keep track</span>
(<span style="color: #ff0000;">"v"</span> . org-narrow-to-subtree) <span style="color: #006400;">; </span><span style="color: #006400;">only show current heading ("view")</span>
(<span style="color: #ff0000;">"q"</span> . widen) <span style="color: #006400;">; </span><span style="color: #006400;">close current heading and show all ("quit")</span>
(<span style="color: #ff0000;">":"</span> . org-set-tags-command) <span style="color: #006400;">; </span><span style="color: #006400;">add/edit tags</span>
(<span style="color: #ff0000;">"t"</span> . org-todo) <span style="color: #006400;">; </span><span style="color: #006400;">toggle todo type, same as C-t</span>
(<span style="color: #ff0000;">"z"</span> . org-refile) <span style="color: #006400;">; </span><span style="color: #006400;">archive the (sub-)tree</span>
(<span style="color: #ff0000;">"a"</span> . org-attach) <span style="color: #006400;">; </span><span style="color: #006400;">manage attachments</span>
)))
<span style="color: #006400;">; </span><span style="color: #006400;">same as toggle</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-t"</span>) <span style="color: #ff00ff;">'org-todo</span>)
<span style="color: #006400;">; </span><span style="color: #006400;">alt-enter = insert new subheading below current</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;M-return&gt;"</span>) <span style="color: #ff00ff;">'org-insert-subheading</span>)
<span style="color: #006400;">; </span><span style="color: #006400;">search for tags (ends up in agenda view)</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-f"</span>) <span style="color: #ff00ff;">'org-tags-view</span>)
<span style="color: #006400;">; </span><span style="color: #006400;">run presenter, org-present must be installed and loadedwhite</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-p"</span>) <span style="color: #ff00ff;">'org-present</span>)
<span style="color: #006400;">; </span><span style="color: #006400;">todo colors</span>
(<span style="color: #0000ff;">setq</span> org-todo-keyword-faces '(
(<span style="color: #ff0000;">"</span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">TODO</span><span style="color: #ff0000;">"</span> . (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"#b70101"</span> <span style="color: #8a2be2;">:weight</span> bold))
(<span style="color: #ff0000;">"START"</span> . (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"blue"</span> <span style="color: #8a2be2;">:weight</span> bold))
(<span style="color: #ff0000;">"WAIT"</span> . (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"darkorange"</span> <span style="color: #8a2be2;">:weight</span> bold))
(<span style="color: #ff0000;">"DONE"</span> . (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"forestgreen"</span> <span style="color: #8a2be2;">:weight</span> bold))
(<span style="color: #ff0000;">"CANCEL"</span> . (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"red"</span> <span style="color: #8a2be2;">:weight</span> bold))
))
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c b"</span>) <span style="color: #ff00ff;">'bold</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c /"</span>) <span style="color: #ff00ff;">'italic</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c c"</span>) <span style="color: #ff00ff;">'code</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c _"</span>) <span style="color: #ff00ff;">'underline</span>)
<span style="color: #006400;">; </span><span style="color: #006400;">edit babel src block in extra buffer:</span>
<span style="color: #006400;">; </span><span style="color: #006400;">default is C-c ' which is hard to type</span>
<span style="color: #006400;">; </span><span style="color: #006400;">brings me to src code editor buffer</span>
<span style="color: #006400;">; </span><span style="color: #006400;">Also note: enter &lt;s then TAB inserts a code block</span>
<span style="color: #006400;">; </span><span style="color: #006400;">Next, C-c C-c executes the code, adding :results table at the</span>
<span style="color: #006400;">; </span><span style="color: #006400;">end of the begin line, creates a table of the output</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-#"</span>) <span style="color: #ff00ff;">'org-edit-special</span>)
<span style="color: #006400;">; </span><span style="color: #006400;">faster jumping</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-up&gt;"</span>) <span style="color: #ff00ff;">'tvd-org-heading-up</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-down&gt;"</span>) <span style="color: #ff00ff;">'tvd-org-heading-down</span>)
<span style="color: #006400;">; </span><span style="color: #006400;">move word left or heading up, depending where point is</span>
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-left&gt;"</span>) <span style="color: #ff00ff;">'tvd-org-left-or-level-up</span>)
<span style="color: #006400;">; </span><span style="color: #006400;">use nicer bullets</span>
(org-bullets-mode 1))
(org-babel-do-load-languages
<span style="color: #ff00ff;">'org-babel-load-languages</span>
'((python . t)
(emacs-lisp . t)
(shell . t)
(perl . t)
))
)))
</pre>
</div>
<p>
no more &#x2026; at the end of a heading
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> org-ellipsis <span style="color: #ff0000;">" &#10549;"</span>)
</pre>
</div>
<p>
my own keywords, must be set globally, not catched correctly inside hook
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> org-todo-keywords
'((sequence <span style="color: #ff0000;">"</span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">TODO</span><span style="color: #ff0000;">"</span> <span style="color: #ff0000;">"START"</span> <span style="color: #ff0000;">"WAIT"</span> <span style="color: #ff0000;">"|"</span> <span style="color: #ff0000;">"DONE"</span> <span style="color: #ff0000;">"CANCEL"</span>)))
</pre>
</div>
<p>
I always want to be able to capture, even if no ORG is running
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-n"</span>) (<span style="color: #0000ff;">lambda</span> () (interactive) (org-capture)))
</pre>
</div>
<p>
must be global since code edit sub buffers run their own major mode, not org
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-#"</span>) <span style="color: #ff00ff;">'org-edit-src-exit</span>)
</pre>
</div>
<p>
some org mode vars must be set globally
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> org-default-notes-file tvd-org-file
org-startup-indented t
org-indent-indentation-per-level 4)
</pre>
</div>
<p>
my own capture templates
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> org-capture-templates
'((<span style="color: #ff0000;">"n"</span> <span style="color: #ff0000;">"Project"</span> entry (file+headline tvd-org-file <span style="color: #ff0000;">"Unsorted Tasks"</span>)
<span style="color: #ff0000;">"* </span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">TODO</span><span style="color: #ff0000;"> %^{title}\n%u\n** Kostenstelle\n** Contact Peer\n**Contact Customer\n**ARS\n**Daten\n** Notizen\n %i%?\n"</span>)
(<span style="color: #ff0000;">"j"</span> <span style="color: #ff0000;">"Journal"</span> entry (file+headline tvd-org-file <span style="color: #ff0000;">"Kurznotizen"</span>)
<span style="color: #ff0000;">"* </span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">TODO</span><span style="color: #ff0000;"> %^{title}\n%u\n %i%?\n"</span> <span style="color: #8a2be2;">:prepend</span> t)
(<span style="color: #ff0000;">"c"</span> <span style="color: #ff0000;">"Copy/Paste"</span> entry (file+headline tvd-org-file <span style="color: #ff0000;">"Kurznotizen"</span>)
<span style="color: #ff0000;">"* </span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">TODO</span><span style="color: #ff0000;"> %^{title}\n%u\n %x\n"</span> <span style="color: #8a2be2;">:immediate-finish</span> t <span style="color: #8a2be2;">:prepend</span> t)))
</pre>
</div>
<p>
follow links using eww, if present
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">if</span> (fboundp <span style="color: #ff00ff;">'eww-browse-url</span>)
(<span style="color: #0000ff;">setq</span> browse-url-browser-function <span style="color: #ff00ff;">'eww-browse-url</span>))
</pre>
</div>
<p>
mark narrowing with an orange fringe, the advice for 'widen
is in the outline section.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(advice-add <span style="color: #ff00ff;">'org-narrow-to-subtree</span> <span style="color: #8a2be2;">:after</span>
'(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> args)
(set-face-attribute <span style="color: #ff00ff;">'fringe</span> nil <span style="color: #8a2be2;">:background</span> tvd-fringe-narrow-bg)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgfe851c9" class="outline-4">
<h4 id="orgfe851c9"><span class="section-number-4">6.4.6</span> org table mode</h4>
<div class="outline-text-4" id="text-6-4-6">
<p>
I'm so used to lovely org mode tables, I need them everywhere!
</p>
<p>
allow me to insert org tables everywhere on request
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'table</span> <span style="color: #ff00ff;">'orgtbl-mode</span>)
</pre>
</div>
<p>
convert CSV region to table
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tablify</span> (regex)
<span style="color: #cd6600;">"Convert a whitespace separated column list into</span>
<span style="color: #cd6600;">an org mode table and enable orgtbl-mode. You can</span>
<span style="color: #cd6600;">specify another regex for cell splitting."</span>
(interactive <span style="color: #ff0000;">"MConvert [region] to table with regex ([\t\s]+): "</span>)
(<span style="color: #0000ff;">let</span> ((spc <span style="color: #ff0000;">"[\t\s]+"</span>))
(<span style="color: #0000ff;">when</span> (string= regex <span style="color: #ff0000;">""</span>)
(<span style="color: #0000ff;">setq</span> regex spc))
(delete-trailing-whitespace)
(<span style="color: #0000ff;">if</span> (org-region-active-p)
(org-table-convert-region (region-beginning) (region-end) regex)
(org-table-convert-region (point-min) (point-max) regex))
(<span style="color: #0000ff;">when</span> (<span style="color: #0000ff;">not</span> (<span style="color: #0000ff;">eq</span> major-mode <span style="color: #ff00ff;">'org-mode</span>))
(orgtbl-mode))))
</pre>
</div>
<p>
table sorting shortcuts
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">sort-table-numeric</span> ()
<span style="color: #cd6600;">"sort org table numerically by current column"</span>
(interactive)
(org-table-sort-lines nil ?n))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">sort-table-numeric-desc</span> ()
<span style="color: #cd6600;">"reverse sort org table numerically by current column"</span>
(interactive)
(org-table-sort-lines nil ?N))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">sort-table-alphanumeric</span> ()
<span style="color: #cd6600;">"sort org table charwise by current column"</span>
(interactive)
(org-table-sort-lines nil ?a))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">sort-table-alphanumeric-desc</span> ()
<span style="color: #cd6600;">"reverse sort org table charwise by current column"</span>
(interactive)
(org-table-sort-lines nil ?A))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">sort-table-time</span> ()
<span style="color: #cd6600;">"sort org table by times by current column"</span>
(interactive)
(org-table-sort-lines nil ?t))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">sort-table-time-desc</span> ()
<span style="color: #cd6600;">"reverse sort org table by times by current column"</span>
(interactive)
(org-table-sort-lines nil ?T))
</pre>
</div>
<p>
easy access for the shortcuts
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'stn</span> <span style="color: #ff00ff;">'sort-table-numeric</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'stnd</span> <span style="color: #ff00ff;">'sort-table-numeric-desc</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'sta</span> <span style="color: #ff00ff;">'sort-table-alphanumeric</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'stad</span> <span style="color: #ff00ff;">'sort-table-alphanumeric-desc</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'stt</span> <span style="color: #ff00ff;">'sort-table-time</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'sttd</span> <span style="color: #ff00ff;">'sort-table-time-desc</span>)
</pre>
</div>
<p>
generic table exporter
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-export-org-table</span> (fmt)
<span style="color: #cd6600;">"export an org table using format FMT"</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((efile <span style="color: #ff0000;">"/tmp/org-table-export.tmp"</span>)
(ebuf (format <span style="color: #ff0000;">"*table-%s*"</span> fmt)))
(<span style="color: #0000ff;">when</span> (file-exists-p efile)
(delete-file efile))
(org-table-export efile (format <span style="color: #ff0000;">"orgtbl-to-%s"</span> fmt))
(other-window 1)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (<span style="color: #0000ff;">eq</span> (get-buffer ebuf) nil))
(kill-buffer (get-buffer ebuf)))
(set-buffer (get-buffer-create ebuf))
(insert-file-contents efile)
(switch-to-buffer ebuf)
(delete-file efile)))
</pre>
</div>
<p>
format specific exporters
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">table-to-csv</span> ()
<span style="color: #cd6600;">"export current org table to CSV format"</span>
(interactive)
(tvd-export-org-table <span style="color: #ff0000;">"csv"</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">table-to-latex</span> ()
<span style="color: #cd6600;">"export current org table to LaTeX format"</span>
(interactive)
(tvd-export-org-table <span style="color: #ff0000;">"latex"</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">table-to-html</span> ()
<span style="color: #cd6600;">"export current org table to HTML format"</span>
(interactive)
(tvd-export-org-table <span style="color: #ff0000;">"html"</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">table-to-csv-tab</span> ()
<span style="color: #cd6600;">"export current org table to CSV format, separated by &lt;tab&gt;"</span>
(interactive)
(tvd-export-org-table <span style="color: #ff0000;">"tsv"</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">table-to-aligned</span> ()
<span style="color: #cd6600;">"export current org table to space-aligned columns format"</span>
(interactive)
(tvd-export-org-table <span style="color: #ff0000;">"csv"</span>)
(<span style="color: #0000ff;">with-current-buffer</span> <span style="color: #ff0000;">"*table-csv*"</span>
(align-regexp (point-min) (point-max) <span style="color: #ff0000;">"</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">\\s-*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">,"</span> 1 1 t)
(<span style="color: #0000ff;">while</span> (re-search-forward <span style="color: #ff0000;">" ,"</span> nil t)
(replace-match <span style="color: #ff0000;">" "</span>))))
</pre>
</div>
<p>
exporter shortcuts
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ttc</span> <span style="color: #ff00ff;">'table-to-csv</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ttl</span> <span style="color: #ff00ff;">'table-to-latex</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'tth</span> <span style="color: #ff00ff;">'table-to-html</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ttt</span> <span style="color: #ff00ff;">'table-to-csv-tab</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'tta</span> <span style="color: #ff00ff;">'table-to-aligned</span>)
</pre>
</div>
<p>
In org mode I sometimes want to copy the content of a table cell
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-beginning-of-cell</span> (<span style="color: #483d8b;">&amp;optional</span> arg)
<span style="color: #cd6600;">"move (point) to the beginning of a org mode table cell"</span>
(interactive)
(<span style="color: #0000ff;">if</span> (re-search-backward <span style="color: #ff0000;">"|"</span> (line-beginning-position) 3 1)
(forward-char)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-end-of-cell</span> (<span style="color: #483d8b;">&amp;optional</span> arg)
<span style="color: #cd6600;">"move (point) to the end of a org mode table cell"</span>
(interactive)
(<span style="color: #0000ff;">if</span> (re-search-forward <span style="color: #ff0000;">"|"</span> (line-end-position) 3 1)
(backward-char)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-copy-org-table-cell</span>(<span style="color: #483d8b;">&amp;optional</span> arg)
<span style="color: #cd6600;">"Copy an org mode table cell to the kill ring using MCYT"</span>
(interactive <span style="color: #ff0000;">"P"</span>)
(mcyt--blink-and-copy-thing <span style="color: #ff00ff;">'tvd-beginning-of-cell</span> <span style="color: #ff00ff;">'tvd-end-of-cell</span> arg))
</pre>
</div>
<p>
Sometimes I need to copy whole columns too:
via <a href="https://emacs.stackexchange.com/questions/28270/how-to-select-and-copy-a-column-of-an-org-table-without-rectangle-selection">stackoverflow</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">org-table-goto-col-beginning</span> ()
<span style="color: #cd6600;">"Go to beginning of current column and return `</span><span style="color: #cd6600;">point</span><span style="color: #cd6600;">'."</span>
(interactive)
(assert (org-table-p) <span style="color: #ff0000;">"Not in org-table."</span>)
(org-table-align)
(<span style="color: #0000ff;">let</span> ((col (org-table-current-column)))
(goto-char (org-table-begin))
(org-table-goto-column col))
(point))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">org-table-col-beginning</span> ()
<span style="color: #cd6600;">"Return beginning position of current column."</span>
(<span style="color: #0000ff;">save-excursion</span>
(org-table-goto-col-beginning)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">org-table-goto-col-end</span> ()
<span style="color: #cd6600;">"Goto end of current column and return `</span><span style="color: #cd6600;">point</span><span style="color: #cd6600;">'."</span>
(interactive)
(assert (org-table-p) <span style="color: #ff0000;">"Not in org-table."</span>)
(org-table-align)
(<span style="color: #0000ff;">let</span> ((col (org-table-current-column)))
(goto-char (1- (org-table-end)))
(org-table-goto-column col)
(skip-chars-forward <span style="color: #ff0000;">"^|"</span>))
(point))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">org-table-col-end</span> ()
<span style="color: #cd6600;">"Return end position of current column."</span>
(<span style="color: #0000ff;">save-excursion</span>
(org-table-goto-col-end)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">org-table-select-col</span> ()
<span style="color: #cd6600;">"Select current column."</span>
(interactive)
(set-mark (org-table-col-beginning))
(org-table-goto-col-end)
(rectangle-mark-mode))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">org-table-copy-col</span> ()
<span style="color: #cd6600;">"Copy current column."</span>
(interactive)
(org-table-select-col)
(sit-for 0.2 t)
(copy-rectangle-as-kill (org-table-col-beginning) (org-table-col-end)))
</pre>
</div>
<p>
bindings only required with org mode, the'll work in orgtbl mode
tables as well
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(eval-after-load <span style="color: #ff0000;">"org"</span>
'(<span style="color: #0000ff;">progn</span>
(add-hook <span style="color: #ff00ff;">'org-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c o"</span>) <span style="color: #ff00ff;">'org-table-copy-col</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c t"</span>) <span style="color: #ff00ff;">'tvd-copy-org-table-cell</span>)))))
</pre>
</div>
</div>
</div>
<div id="outline-container-orgc5b7010" class="outline-4">
<h4 id="orgc5b7010"><span class="section-number-4">6.4.7</span> org mode slideshows</h4>
<div class="outline-text-4" id="text-6-4-7">
<p>
Making presentations within emacs with org mode is cool as well.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'org-present</span>)
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'darkroom</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">hides distractions</span>
</pre>
</div>
<p>
showtime helpers
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">slide-return-to-present</span> ()
<span style="color: #cd6600;">"wherever we are, go back to slideshow"</span>
(interactive)
(switch-to-buffer-other-window <span style="color: #ff0000;">"*slide*"</span>)
(delete-other-windows))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">slide-split-to-past</span> ()
<span style="color: #cd6600;">"split slide show and show previous buffer next to it"</span>
(interactive)
(split-window-horizontally)
(other-window 1)
(<span style="color: #0000ff;">if</span> (get-buffer <span style="color: #ff0000;">"*eshell*"</span>)
<span style="color: #006400;">;; </span><span style="color: #006400;">if there's no eshell running, start it, otherwise switch to it</span>
(switch-to-buffer <span style="color: #ff0000;">"*eshell*"</span>)
(eshell)))
</pre>
</div>
<p>
org present config
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(eval-after-load <span style="color: #ff0000;">"org-present"</span>
'(<span style="color: #0000ff;">progn</span>
(add-hook <span style="color: #ff00ff;">'org-present-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(org-present-big)
(org-display-inline-images)
(org-present-hide-cursor)
(org-present-read-only)
<span style="color: #006400;">;; </span><span style="color: #006400;">some opticals</span>
(<span style="color: #0000ff;">setq</span> org-hide-emphasis-markers t)
(font-lock-add-keywords <span style="color: #ff00ff;">'org-mode</span>
'((<span style="color: #ff0000;">"^ +</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">[-*]</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;"> "</span>
(0 (<span style="color: #0000ff;">prog1</span> () (compose-region (match-beginning 1) (match-end 1) <span style="color: #ff0000;">"&#8226;"</span>))))))
<span style="color: #006400;">;; </span><span style="color: #006400;">keys</span>
(define-key org-present-mode-keymap [down] <span style="color: #ff00ff;">'org-present-next</span>)
(define-key org-present-mode-keymap [up] <span style="color: #ff00ff;">'org-present-prev</span>)
(define-key org-present-mode-keymap (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"q"</span>) <span style="color: #ff00ff;">'org-present-quit</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c p"</span>) <span style="color: #ff00ff;">'slide-return-to-present</span>) <span style="color: #006400;">; </span><span style="color: #006400;">used inside eshell to return to slide</span>
(define-key org-present-mode-keymap (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"s"</span>) <span style="color: #ff00ff;">'slide-split-to-past</span>)
(<span style="color: #0000ff;">setq</span> current-buffer (buffer-name)) <span style="color: #006400;">; </span><span style="color: #006400;">remember slide buffer name</span>
(rename-buffer <span style="color: #ff0000;">"*slide*"</span>)
<span style="color: #006400;">;;</span><span style="color: #006400;">(darkroom-tentative-mode)</span>
))
(add-hook <span style="color: #ff00ff;">'org-present-mode-quit-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(org-present-small)
(org-remove-inline-images)
(org-present-show-cursor)
(org-present-read-write)
(<span style="color: #0000ff;">setq</span> org-hide-emphasis-markers nil)
(rename-buffer current-buffer)
(global-unset-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c p"</span>))
<span style="color: #006400;">;;</span><span style="color: #006400;">(darkroom-tentative-mode)</span>
))))
</pre>
</div>
<p>
Will be inserted as first help slide in a slide show
(edit table in org-mode!)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">slide-header</span> (prefix)
(interactive <span style="color: #ff0000;">"P"</span>)
(<span style="color: #0000ff;">save-excursion</span>
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> prefix nil)
()
(goto-char (point-min)))
(insert <span style="color: #ff0000;">"\n* ORG-MODE slide show commands</span>
<span style="color: #ff0000;"> | Key | Command |</span>
<span style="color: #ff0000;"> +-------+------------------------------------------------------------+</span>
<span style="color: #ff0000;"> | C-p | start slide show |</span>
<span style="color: #ff0000;"> | q | stop slide show |</span>
<span style="color: #ff0000;"> | s | slit window and switchto or start eshell |</span>
<span style="color: #ff0000;"> | C-c p | while in split mode, return to full screen slide show |</span>
<span style="color: #ff0000;"> | C-c r | enter window resize mode, use cursor keys, &lt;ret&gt; to finish |</span>
<span style="color: #ff0000;"> | C-- | (CTRL and minus) shrink font size |</span>
<span style="color: #ff0000;"> | C-+ | (CTRL and plus) increase font size |</span>
<span style="color: #ff0000;">"</span>)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org814009d" class="outline-4">
<h4 id="org814009d"><span class="section-number-4">6.4.8</span> outshine mode</h4>
<div class="outline-text-4" id="text-6-4-8">
<p>
I maintain my emacs config with outshine mode. It works a lot like
org mode, but I still have a normal emacs lisp buffer, which I can
use directly without any conversion beforehand and which works if
outshine is not installed. Also I thing "literal programming" is
bullshit.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'outshine</span>)
</pre>
</div>
<p>
enable when outline
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'outline-minor-mode-hook</span> <span style="color: #ff00ff;">'outshine-hook-function</span>)
</pre>
</div>
<p>
use it for .emacs:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'emacs-lisp-mode-hook</span> '(<span style="color: #0000ff;">lambda</span> ()
(outline-minor-mode)))
</pre>
</div>
<p>
Generate an alist of all headings with each position in buffer and
use this later to jump to those positions with IDO.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(make-variable-buffer-local <span style="color: #ff00ff;">'tvd-headings</span>)
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outshine-get-level</span> (heading)
<span style="color: #cd6600;">"Return level of HEADING as number, or nil"</span>
(<span style="color: #0000ff;">if</span> (string-match <span style="color: #ff0000;">" </span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">*+</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;"> "</span> heading) <span style="color: #006400;">; </span><span style="color: #006400;">normal outline heading</span>
(length (match-string 1 heading))
(<span style="color: #0000ff;">when</span> (string-match <span style="color: #ff0000;">"^;;</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">;+</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;"> "</span> heading) <span style="color: #006400;">; </span><span style="color: #006400;">else look for elisp heading</span>
(length (match-string 1 heading)))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outshine-cl-heading</span> (heading)
(<span style="color: #0000ff;">let</span> ((regex (cadar outshine-imenu-preliminary-generic-expression)))
(<span style="color: #0000ff;">when</span> (string-match regex heading)
(match-string-no-properties 1 heading))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outshine-parse-headings</span> ()
<span style="color: #cd6600;">"extract outshine headings of current buffer"</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((line nil))
(<span style="color: #0000ff;">save-excursion</span>
(<span style="color: #0000ff;">setq</span> tvd-headings ())
(beginning-of-buffer)
(<span style="color: #0000ff;">while</span> (<span style="color: #0000ff;">not</span> (eobp))
(<span style="color: #0000ff;">setq</span> line (tvd-get-line))
(<span style="color: #0000ff;">when</span> (outline-on-heading-p t)
(add-to-list <span style="color: #ff00ff;">'tvd-headings</span> (cons (tvd-outshine-cl-heading line) (point))))
(forward-line)))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outshine-sparse-tree</span> ()
<span style="color: #cd6600;">"expand outline tree from current position as sparse tree"</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((done nil)
(pos (point))
(tree (list (list (point) 5)))
(l 0))
(<span style="color: #0000ff;">while</span> (<span style="color: #0000ff;">not</span> done)
(outline-up-heading 1)
(<span style="color: #0000ff;">setq</span> l (tvd-outshine-get-level (tvd-get-line)))
(add-to-list <span style="color: #ff00ff;">'tree</span> (list (point) l))
(<span style="color: #0000ff;">when</span> (<span style="color: #0000ff;">eq</span> l 1)
(<span style="color: #0000ff;">setq</span> done t)))
(outline-hide-other)
(<span style="color: #0000ff;">dolist</span> (pos tree)
(goto-char (<span style="color: #0000ff;">car</span> pos))
(outline-cycle))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outshine-jump</span> ()
<span style="color: #cd6600;">"jump to an outshine heading with IDO prompt,</span>
<span style="color: #cd6600;">update heading list if neccessary."</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((heading nil))
(<span style="color: #0000ff;">when</span> (<span style="color: #0000ff;">or</span> (<span style="color: #0000ff;">not</span> tvd-headings)
(buffer-modified-p))
(tvd-outshine-parse-headings))
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> tvd-headings)
(message <span style="color: #ff0000;">"Current buffer doesn't contain any outshine headings!"</span>)
(<span style="color: #0000ff;">setq</span> heading (ido-completing-read <span style="color: #ff0000;">"Jump to heading: "</span> (tvd-alist-keys tvd-headings)))
(<span style="color: #0000ff;">when</span> heading
(show-all)
(goto-char (<span style="color: #0000ff;">cdr</span> (assoc heading tvd-headings)))
(tvd-outshine-sparse-tree)))))
</pre>
</div>
<p>
outshine mode config (inside outline mode)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(eval-after-load <span style="color: #ff0000;">"outline"</span>
'(<span style="color: #0000ff;">progn</span>
(add-hook <span style="color: #ff00ff;">'outline-minor-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'j</span> <span style="color: #ff00ff;">'tvd-outshine-jump</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'jump</span> <span style="color: #ff00ff;">'tvd-outshine-jump</span>)
(define-key outline-minor-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-j"</span>) <span style="color: #ff00ff;">'tvd-outshine-jump</span>)
(<span style="color: #0000ff;">setq</span> outshine-org-style-global-cycling-at-bob-p t
outshine-use-speed-commands t
outshine-speed-commands-user
(quote (
(<span style="color: #ff0000;">"v"</span> . outshine-narrow-to-subtree)
(<span style="color: #ff0000;">"q"</span> . widen)
)))))))
</pre>
</div>
<p>
Narrowing now works within the headline rather than requiring to be on it
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(advice-add <span style="color: #ff00ff;">'outshine-narrow-to-subtree</span> <span style="color: #8a2be2;">:before</span>
(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> args) (<span style="color: #0000ff;">unless</span> (outline-on-heading-p t)
(outline-previous-visible-heading 1))))
</pre>
</div>
<p>
convert outshine buffer to org buffer using outorg, which is part
of outshine.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">outshine-to-org</span> ()
(interactive)
(outorg-convert-to-org)
(org-mode))
</pre>
</div>
<p>
I use this to generate a HTML version of my emacs config for
posting online, which makes it way easier to read.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">outshine-to-html</span> (file)
(interactive
(list
(read-file-name <span style="color: #ff0000;">"HTML output file: "</span>
(expand-file-name <span style="color: #ff0000;">"~/D/github/dot-emacs"</span>)
<span style="color: #ff0000;">"emacs.html"</span>)))
(<span style="color: #0000ff;">let</span> ((B (current-buffer)))
(<span style="color: #0000ff;">with-temp-buffer</span>
(insert-buffer-substring B)
<span style="color: #006400;">;; </span><span style="color: #006400;">remove 'sk spacings for smaller &lt;pre&gt;'s</span>
(tvd-replace-all <span style="color: #ff0000;">")\s*;"</span> <span style="color: #ff0000;">") ;"</span>)
<span style="color: #006400;">;; </span><span style="color: #006400;">highlight at least a little</span>
(tvd-replace-all <span style="color: #ff0000;">"/</span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">FIXME</span><span style="color: #ff0000;">/"</span> <span style="color: #ff0000;">"/</span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">FIXME</span><span style="color: #ff0000;">/"</span>)
(emacs-lisp-mode)
(outshine-to-org)
(org-export-to-file <span style="color: #ff00ff;">'html</span> file))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">export</span> ()
<span style="color: #cd6600;">"Export .emacs to git, do not use."</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">/</span><span style="color: #ff0000; background-color: #ffff00; font-weight: bold; text-decoration: underline;">FIXME</span><span style="color: #006400;">/: generate version number, add last changelog to git</span>
(interactive)
(outshine-to-html <span style="color: #ff0000;">"~/D/github/dot-emacs/emacs.html"</span>)
(shell-command <span style="color: #ff0000;">"cp ~/.emacs ~/D/github/dot-emacs/"</span>)
(shell-command <span style="color: #ff0000;">"cd ~/D/github/dot-emacs &amp;&amp; git ci +fixes .emacs emacs.html"</span>)
(shell-command <span style="color: #ff0000;">"cd ~/D/github/dot-emacs &amp;&amp; git push"</span>))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgcf462fe" class="outline-4">
<h4 id="orgcf462fe"><span class="section-number-4">6.4.9</span> outline mode</h4>
<div class="outline-text-4" id="text-6-4-9">
<p>
I use the very same cycle style as in org mode: when on a heading,
hide it, jump to next heading on the same level and expand that (or
vice versa). however, when NOT on a heading behave as loved: jump
paragraphs.
</p>
<p>
Note, that this also affects outshine mode, since that inherits
from outline.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outline-left-or-level-up</span>()
<span style="color: #cd6600;">"jump one word to the left if not on a heading,</span>
<span style="color: #cd6600;">otherwise fold current level and jump one level up."</span>
(interactive)
(<span style="color: #0000ff;">if</span> (outline-on-heading-p)
(<span style="color: #0000ff;">progn</span>
(hide-subtree)
(outline-up-heading 1))
(left-word)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outline-heading-up</span>()
<span style="color: #cd6600;">"fold current heading, jump one level up and unfold it"</span>
(interactive)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (outline-on-heading-p))
(backward-paragraph)
(hide-subtree)
(outline-backward-same-level 1)
(outline-cycle)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outline-heading-down</span>()
<span style="color: #cd6600;">"fold current heading, jump one level down and unfold it"</span>
(interactive)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (outline-on-heading-p))
(forward-paragraph)
(hide-subtree)
(outline-forward-same-level 1)
(outline-cycle)))
</pre>
</div>
<p>
unused, see tvd-outshine-jump
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outline-jump</span> (part)
<span style="color: #cd6600;">"Jump interactively to next header containing PART using search."</span>
(interactive <span style="color: #ff0000;">"Mjump to: "</span>)
(<span style="color: #0000ff;">let</span> ((done nil)
(pwd (point)))
(beginning-of-buffer)
(outline-show-all)
(<span style="color: #0000ff;">when</span> (re-search-forward (format <span style="color: #ff0000;">"^;; \\*+.*%s"</span> part) (point-max) t)
(<span style="color: #0000ff;">when</span> (outline-on-heading-p)
(beginning-of-line)
(<span style="color: #0000ff;">setq</span> done t)))
(<span style="color: #0000ff;">when</span> (<span style="color: #0000ff;">not</span> done)
(message (format <span style="color: #ff0000;">"no heading with '%s' found"</span> part))
(goto-char pwd))))
</pre>
</div>
<p>
outline mode config
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(eval-after-load <span style="color: #ff0000;">"outline"</span>
'(<span style="color: #0000ff;">progn</span>
(add-hook <span style="color: #ff00ff;">'outline-minor-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
<span style="color: #006400;">;; </span><span style="color: #006400;">narrowing, we use outshine functions, it's loaded anyway</span>
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'n</span> <span style="color: #ff00ff;">'outshine-narrow-to-subtree</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'w</span> <span style="color: #ff00ff;">'widen</span>)
(define-key outline-minor-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-up&gt;"</span>) <span style="color: #ff00ff;">'tvd-outline-heading-up</span>)
(define-key outline-minor-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-down&gt;"</span>) <span style="color: #ff00ff;">'tvd-outline-heading-down</span>)
(define-key outline-minor-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-left&gt;"</span>) <span style="color: #ff00ff;">'tvd-outline-left-or-level-up</span>)))))
</pre>
</div>
<p>
orange fringe when narrowed
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(advice-add <span style="color: #ff00ff;">'outshine-narrow-to-subtree</span> <span style="color: #8a2be2;">:after</span>
'(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> args)
(set-face-attribute <span style="color: #ff00ff;">'fringe</span> nil <span style="color: #8a2be2;">:background</span> tvd-fringe-narrow-bg)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orga15337b" class="outline-4">
<h4 id="orga15337b"><span class="section-number-4">6.4.10</span> narrowing (no mode but fits here)</h4>
<div class="outline-text-4" id="text-6-4-10">
<p>
I use narrowing quite frequently, so here are some enhancements.
</p>
<p>
easier narrowing with Indirect Buffers
Source: <a href="https://www.emacswiki.org/emacs/NarrowIndirect3">emacswiki</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'narrow-indirect</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'nf</span> <span style="color: #ff00ff;">'ni-narrow-to-defun-indirect-other-window</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'nr</span> <span style="color: #ff00ff;">'ni-narrow-to-region-indirect-other-window</span>)
</pre>
</div>
<p>
I like to have an orange fringe background when narrowing is
active, since I forget that it is in effect otherwise sometimes.
</p>
<p>
via <a href="https://emacs.stackexchange.com/questions/33288/how-to-find-out-if-narrow-to-region-has-been-called-within-save-restriction">stackoverflow</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-narrowed-fringe-status</span> ()
<span style="color: #cd6600;">"Make the fringe background reflect the buffer's narrowing status."</span>
(set-face-attribute
<span style="color: #ff00ff;">'fringe</span> nil <span style="color: #8a2be2;">:background</span> (<span style="color: #0000ff;">if</span> (buffer-narrowed-p)
tvd-fringe-narrow-bg
nil)))
(add-hook <span style="color: #ff00ff;">'post-command-hook</span> <span style="color: #ff00ff;">'tvd-narrowed-fringe-status</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org75fe805" class="outline-4">
<h4 id="org75fe805"><span class="section-number-4">6.4.11</span> ANSI-TERM (inferior shells/interpreters and REPLs)</h4>
<div class="outline-text-4" id="text-6-4-11">
<p>
I use ansi term for inferior shells only.
</p>
<p>
via <a href="http://echosa.github.io/blog/2012/06/06/improving-ansi-term/">echosa</a>
</p>
<p>
kill buffer when done
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defadvice</span> <span style="color: #9932cc;">term-sentinel</span> (around tvd-advice-term-sentinel (proc msg))
(<span style="color: #0000ff;">if</span> (memq (process-status proc) '(<span style="color: #ff0000; font-weight: bold;">signal</span> exit))
(<span style="color: #0000ff;">let</span> ((buffer (process-buffer proc)))
ad-do-it
(kill-buffer buffer))
ad-do-it))
(ad-activate <span style="color: #ff00ff;">'term-sentinel</span>)
</pre>
</div>
<p>
force utf8
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-term-use-utf8</span> ()
(set-buffer-process-coding-system <span style="color: #ff00ff;">'utf-8-unix</span> <span style="color: #ff00ff;">'utf-8-unix</span>))
(add-hook <span style="color: #ff00ff;">'term-exec-hook</span> <span style="color: #ff00ff;">'tvd-term-use-utf8</span>)
</pre>
</div>
<p>
make C-y work
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-term-paste</span> (<span style="color: #483d8b;">&amp;optional</span> string)
(interactive)
(process-send-string
(get-buffer-process (current-buffer))
(<span style="color: #0000ff;">if</span> string string (current-kill 0))))
</pre>
</div>
<p>
put all term hooks in here
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-term-hook</span> ()
(goto-address-mode)
(define-key term-raw-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-y"</span>) <span style="color: #ff00ff;">'tvd-term-paste</span>)
(define-key term-raw-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-d"</span>) <span style="color: #ff00ff;">'kill-this-buffer</span>)
(define-key term-raw-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-d"</span>) <span style="color: #ff00ff;">'kill-this-buffer</span>)
(define-key term-raw-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-l"</span>) <span style="color: #ff00ff;">'term-line-mode</span>)
(define-key term-raw-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-k"</span>)
(<span style="color: #0000ff;">lambda</span> ()
(interactive)
(term-send-raw-string <span style="color: #ff0000;">"\C-k"</span>)
(kill-line))))
(add-hook <span style="color: #ff00ff;">'term-mode-hook</span> <span style="color: #ff00ff;">'tvd-term-hook</span>)
</pre>
</div>
<p>
via <a href="https://www.emacswiki.org/emacs/AnsiTermHints#toc4">emacswiki</a>:
Use to supply commandline arguments to ansi-term
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">term-with-args</span> (new-buffer-name cmd <span style="color: #483d8b;">&amp;rest</span> switches)
(<span style="color: #0000ff;">setq</span> term-ansi-buffer-name (concat <span style="color: #ff0000;">"*"</span> new-buffer-name <span style="color: #ff0000;">"*"</span>))
(<span style="color: #0000ff;">setq</span> term-ansi-buffer-name (generate-new-buffer-name term-ansi-buffer-name))
(<span style="color: #0000ff;">setq</span> term-ansi-buffer-name (apply <span style="color: #ff00ff;">'make-term</span> term-ansi-buffer-name cmd nil switches))
(set-buffer term-ansi-buffer-name)
(term-mode)
(term-char-mode)
(message <span style="color: #ff0000;">"Line mode: C-c C-l, Char mode: C-c C-k, Exit: C-c C-d"</span>)
(switch-to-buffer term-ansi-buffer-name))
</pre>
</div>
<p>
finally the inferior REPLs:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">iperl</span> ()
<span style="color: #cd6600;">"interactive perl (via perlbrew if exist or global)"</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((perlbrew (expand-file-name <span style="color: #ff0000;">"~/perl5/perlbrew/bin/perlbrew"</span>)))
(<span style="color: #0000ff;">if</span> (file-exists-p perlbrew)
(term-with-args <span style="color: #ff0000;">"*perlbrew-de0*"</span> perlbrew <span style="color: #ff0000;">"exec"</span> <span style="color: #ff0000;">"--"</span> <span style="color: #ff0000;">"perl"</span> <span style="color: #ff0000;">"-de0"</span>)
(term-with-args <span style="color: #ff0000;">"*perl-de0*"</span> <span style="color: #ff0000;">"perl"</span> <span style="color: #ff0000;">"-de0"</span>))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">iruby</span> ()
<span style="color: #cd6600;">"interactive ruby"</span>
(interactive)
(term-with-args <span style="color: #ff0000;">"*ruby-irb*"</span> <span style="color: #ff0000;">"irb"</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">ipython</span> ()
<span style="color: #cd6600;">"interactive python"</span>
(interactive)
(setenv <span style="color: #ff0000;">"PYTHONSTARTUP"</span> (expand-file-name <span style="color: #ff0000;">"~/.pythonrc"</span>))
(term-with-args <span style="color: #ff0000;">"*python-i*"</span> <span style="color: #ff0000;">"python"</span> <span style="color: #ff0000;">"-i"</span>))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">icalc</span> ()
<span style="color: #cd6600;">"interactive calc"</span>
(interactive)
(term-with-args <span style="color: #ff0000;">"*calc*"</span> (expand-file-name <span style="color: #ff0000;">"~/bin/calc"</span>)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org984408f" class="outline-4">
<h4 id="org984408f"><span class="section-number-4">6.4.12</span> Puppet</h4>
<div class="outline-text-4" id="text-6-4-12">
<p>
adds hook for .pp files
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'puppet-mode</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org741d574" class="outline-4">
<h4 id="org741d574"><span class="section-number-4">6.4.13</span> Novel Mode - Screen Reader</h4>
<div class="outline-text-4" id="text-6-4-13">
<p>
my own emacs screen reader, very handy to read docs on the road.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'novel-mode</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-c C-n"</span>) <span style="color: #ff00ff;">'novel-mode</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgf60bf97" class="outline-4">
<h4 id="orgf60bf97"><span class="section-number-4">6.4.14</span> Macro Math</h4>
<div class="outline-text-4" id="text-6-4-14">
<p>
see <a href="https://github.com/nschum/macro-math.el">macro-math</a>
</p>
<p>
perform elisp evaluation/caluclaton directly in the buffer.
mark something and hit C-x C-0 (which is a reminder to C-x C-= w/o the shift)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(autoload <span style="color: #ff00ff;">'macro-math-eval-and-round-region</span> <span style="color: #ff0000;">"macro-math"</span> t nil)
(autoload <span style="color: #ff00ff;">'macro-math-eval-region</span> <span style="color: #ff0000;">"macro-math"</span> t nil)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-x C-0"</span>) <span style="color: #ff00ff;">'macro-math-eval-region</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgf4c9895" class="outline-4">
<h4 id="orgf4c9895"><span class="section-number-4">6.4.15</span> Common-Lisp (SLIME)</h4>
<div class="outline-text-4" id="text-6-4-15">
<p>
I'm learing CL with slime, start with M-x slime.
</p>
<p>
INSTALL: (see: <a href="http://www.jonathanfischer.net/modern-common-lisp-on-linux/)">jonathanfischer.net</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> slimehelper (expand-file-name <span style="color: #ff0000;">"~/quicklisp/slime-helper.el"</span>))
(<span style="color: #0000ff;">if</span> (file-exists-p slimehelper)
(<span style="color: #0000ff;">progn</span>
(load slimehelper)
<span style="color: #006400;">;; </span><span style="color: #006400;">Replace "sbcl" with the path to your implementation</span>
(<span style="color: #0000ff;">setq</span> inferior-lisp-program <span style="color: #ff0000;">"sbcl"</span>)
<span style="color: #006400;">;; </span><span style="color: #006400;">Stop SLIME's REPL from grabbing DEL,</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">which is annoying when backspacing over a '('</span>
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">override-slime-repl-bindings-with-paredit</span> ()
(define-key slime-repl-mode-map
(read-kbd-macro paredit-backward-delete-key) nil))
(add-hook <span style="color: #ff00ff;">'slime-repl-mode-hook</span> <span style="color: #ff00ff;">'override-slime-repl-bindings-with-paredit</span>)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org80f2a39" class="outline-4">
<h4 id="org80f2a39"><span class="section-number-4">6.4.16</span> INFO Mode</h4>
<div class="outline-text-4" id="text-6-4-16">
<p>
open an info file somewhere outside %infodir% with info-mode
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">info-find-file</span> (file)
(interactive <span style="color: #ff0000;">"f"</span>)
(info-setup file
(pop-to-buffer-same-window
(format <span style="color: #ff0000;">"*info*&lt;%s&gt;"</span>
(file-name-sans-extension
(file-name-nondirectory file))))))
</pre>
</div>
<p>
easier navigation in Info mode, intuitive history back and forth.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(eval-after-load <span style="color: #ff0000;">"Info"</span>
'(<span style="color: #0000ff;">progn</span>
(define-key Info-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-left&gt;"</span>) <span style="color: #ff00ff;">'Info-history-back</span>)
(define-key Info-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-right&gt;"</span>) <span style="color: #ff00ff;">'Info-history-forward</span>)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org7c07808" class="outline-4">
<h4 id="org7c07808"><span class="section-number-4">6.4.17</span> calc et al.</h4>
<div class="outline-text-4" id="text-6-4-17">
<p>
emacs provides 4 ways to calculate:
</p>
<p>
M-x calc:
RPN calc with stack. Enter numbers, when done, operator, enter, etc
heavy duty.
</p>
<p>
provided by calc:
</p>
<pre class="example">
(defun c (expr)
(interactive "Mcalc:")
(message (format "result: %s" (calc-eval expr))))
</pre>
<p>
by calc as well, but with algebraic input, access last result with $
algebraic == 1 +1 / 3. result will stored in kill-ring, use C-y to paste
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'c</span> <span style="color: #ff00ff;">'quick-calc</span>)
</pre>
</div>
<p>
M-x calculator
interactive, simpler than calc, but comprehensive nevertheless, input
is algebraic as well, but last result can be used just as ~/bin/calc
</p>
<p>
lisp can be used to calc as well:
M-x evaluate-expression &lt;ret&gt; (+ 1 2) &lt;ret&gt;
</p>
<p>
or, inferior perl calc: M-x icalc, see above
</p>
<hr />
</div>
</div>
<div id="outline-container-orgf793545" class="outline-4">
<h4 id="orgf793545"><span class="section-number-4">6.4.18</span> MACROs</h4>
<div class="outline-text-4" id="text-6-4-18">
<p>
help: <a href="https://www.emacswiki.org/emacs/KeyboardMacrosTricks">emacswiki macro tricks</a>.
</p>
<p>
Default keybindings:
start-kbd-macro default binding: C-x ( — Starts recording a keyboard macro.
end-kbd-macro default binding: C-x ) — Ends recording of a keyboard macro.
call-last-kbd-macro default binding: C-x e — Executes the last keyboard macro defined.
</p>
<p>
however, I use <a href="https://github.com/Silex/elmacro">elmacro</a>.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'elmacro</span>)
(elmacro-mode)
(<span style="color: #0000ff;">setq</span> tvd-macro-name <span style="color: #ff0000;">"last-macro"</span>)
</pre>
</div>
<p>
ignore stuff
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-to-list <span style="color: #ff00ff;">'elmacro-unwanted-commands-regexps</span> <span style="color: #ff0000;">"^(mouse.*)$"</span>)
(add-to-list <span style="color: #ff00ff;">'elmacro-unwanted-commands-regexps</span> <span style="color: #ff0000;">"^(tvd-start-or-stop-macro)$"</span>)
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-get-macro-name</span>()
<span style="color: #cd6600;">"Ask for a macro name, check for duplicates.</span>
<span style="color: #cd6600;">If the given name is already defined, ask again (and again until unique).</span>
<span style="color: #cd6600;">If a buffer with the given name exists, kill it (that is, the buffer is</span>
<span style="color: #cd6600;">there but has not been saved or evaluated yet). Return the name as string."</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((done nil)
(name nil)
(mbuf nil)
(err <span style="color: #ff0000;">""</span>))
(<span style="color: #0000ff;">while</span> (<span style="color: #0000ff;">not</span> done)
(<span style="color: #0000ff;">setq</span> name (read-string (format <span style="color: #ff0000;">"%s - enter macro name (last-macro): "</span> err) nil nil <span style="color: #ff0000;">"last-macro"</span>))
(<span style="color: #0000ff;">if</span> (fboundp (intern name))
(<span style="color: #0000ff;">setq</span> err (format <span style="color: #ff0000;">"macro '%s is already defined"</span> name))
(<span style="color: #0000ff;">setq</span> mbuf (format <span style="color: #ff0000;">"* elmacro - %s *"</span> name))
(<span style="color: #0000ff;">if</span> (get-buffer mbuf)
(<span style="color: #0000ff;">with-current-buffer</span> mbuf
(kill-buffer mbuf)))
(<span style="color: #0000ff;">setq</span> done t)))
name))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-get-exec-macro-name</span>()
<span style="color: #cd6600;">"Ask for a macro name to be executed"</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((macros ())
(N 1)
(S nil)
(T <span style="color: #ff0000;">""</span>))
(<span style="color: #0000ff;">dolist</span> (entry (<span style="color: #0000ff;">cdr</span> (assoc tvd-macro-file load-history )))
(<span style="color: #0000ff;">setq</span> S (<span style="color: #0000ff;">cdr</span> entry))
(<span style="color: #0000ff;">setq</span> T (symbol-name S))
(push (list T N) macros)
(<span style="color: #0000ff;">setq</span> N (1+ N)))
(completing-read <span style="color: #ff0000;">"enter macro name: "</span> macros nil t nil)))
</pre>
</div>
<p>
the heart of my elmacro stuff
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-start-or-stop-macro</span>()
<span style="color: #cd6600;">"start macro or stop if started"</span>
(interactive)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> defining-kbd-macro nil)
(<span style="color: #0000ff;">progn</span>
(elmacro-clear-command-history)
(start-kbd-macro nil)
(message <span style="color: #ff0000;">"Recording macro. Finish with &lt;shift-F6&gt; ..."</span>))
(<span style="color: #0000ff;">progn</span>
(call-interactively <span style="color: #ff00ff;">'end-kbd-macro</span>)
(<span style="color: #0000ff;">setq</span> tvd-macro-name (tvd-get-macro-name))
(elmacro-show-last-macro tvd-macro-name)
(message <span style="color: #ff0000;">"Recording done. Execute with &lt;C-F6&gt;, save or &lt;C-x C-e&gt; buffer..."</span>))))
</pre>
</div>
<p>
better than the default function
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-exec-last-macro</span>(<span style="color: #483d8b;">&amp;optional</span> ARG)
<span style="color: #cd6600;">"execute last macro (or ARG, if given) repeatedly after every</span>
<span style="color: #cd6600;">&lt;ret&gt;, abort with C-g or q, and repeat until EOF after pressing a.</span>
<span style="color: #cd6600;">If macro defun is known (i.e. because you evaluated the elmacro buffer</span>
<span style="color: #cd6600;">containing the generated defun), it will be executed. Otherwise the</span>
<span style="color: #cd6600;">last kbd-macro will be executed."</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((melm-count 0)
(melm-all nil)
(melm-abort nil)
(melm-beg (eobp))
(melm-code (<span style="color: #0000ff;">or</span> ARG tvd-macro-name)))
(<span style="color: #0000ff;">if</span> (eobp)
(<span style="color: #0000ff;">if</span> (yes-or-no-p <span style="color: #ff0000;">"(point) is at end of buffer. Jump to top?"</span>)
(goto-char (point-min))))
(<span style="color: #0000ff;">while</span> (<span style="color: #0000ff;">and</span> (<span style="color: #0000ff;">not</span> melm-abort)
(<span style="color: #0000ff;">not</span> (eobp)))
(<span style="color: #0000ff;">when</span> (<span style="color: #0000ff;">not</span> melm-all)
(message (concat
(format
<span style="color: #ff0000;">"Executing last macro '%s (%d). Keys:\n"</span> melm-code melm-count)
<span style="color: #ff0000;">"&lt;enter&gt; repeat once\n"</span>
<span style="color: #ff0000;">"a repeat until EOF\n"</span>
<span style="color: #ff0000;">"e enter macro name to execute\n"</span>
<span style="color: #ff0000;">"&lt;C-g&gt; or q abort ..\n "</span>))
(<span style="color: #0000ff;">setq</span> K (read-event))
(<span style="color: #0000ff;">cond</span> ((<span style="color: #0000ff;">or</span> (<span style="color: #0000ff;">eq</span> K <span style="color: #ff00ff;">'return</span>) (<span style="color: #0000ff;">eq</span> K <span style="color: #ff00ff;">'C-f6</span>)) t)
((equal (char-to-string K) <span style="color: #ff0000;">"q"</span>) (<span style="color: #0000ff;">setq</span> melm-abort t))
((equal (char-to-string K) <span style="color: #ff0000;">"a"</span>) (message <span style="color: #ff0000;">"Repeating until EOF"</span>)(<span style="color: #0000ff;">setq</span> melm-all t))
((equal (char-to-string K) <span style="color: #ff0000;">"e"</span>) (<span style="color: #0000ff;">setq</span> tvd-macro-name (tvd-get-exec-macro-name)))
(t (<span style="color: #0000ff;">setq</span> melm-abort t))))
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> melm-abort)
(<span style="color: #0000ff;">progn</span>
(<span style="color: #0000ff;">if</span> (fboundp (intern melm-code))
(call-interactively (intern melm-code))
(call-interactively <span style="color: #ff00ff;">'call-last-kbd-macro</span>))
(<span style="color: #0000ff;">setq</span> melm-count (1+ melm-count)))))
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">and</span> (<span style="color: #0000ff;">eq</span> melm-count 0) (<span style="color: #0000ff;">eq</span> (point) (point-max)))
(message <span style="color: #ff0000;">"(point) is at end of buffer, aborted"</span>)
(message (format <span style="color: #ff0000;">"executed '%s %d times"</span> melm-code melm-count)))))
</pre>
</div>
<p>
My macro recording workflow:
</p>
<ul class="org-ul">
<li>shift-F6</li>
<li>&#x2026; do things &#x2026;</li>
<li>shift-F6 again</li>
<li>enter a name</li>
<li>a new buffer with macro defun appears</li>
<li>C-x C-e evals it</li>
<li>C-F6 (repeatedly) executes it.</li>
</ul>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;f6&gt;"</span>) <span style="color: #ff00ff;">'tvd-start-or-stop-macro</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;C-f6&gt;"</span>) <span style="color: #ff00ff;">'tvd-exec-last-macro</span>)
</pre>
</div>
<p>
I use my own macro file
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> tvd-macro-file (concat tvd-lisp-dir <span style="color: #ff0000;">"/macros.el"</span>))
</pre>
</div>
<p>
but only load if in use
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">if</span> (file-exists-p tvd-macro-file)
(load-file tvd-macro-file))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-macro-store</span>()
<span style="color: #cd6600;">"store current macro to emacs config"</span>
(interactive)
(copy-region-as-kill (point-min) (point-max))
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (get-buffer <span style="color: #ff0000;">"macros.el"</span>))
(find-file tvd-macro-file))
(<span style="color: #0000ff;">with-current-buffer</span> <span style="color: #ff0000;">"macros.el"</span>
(goto-char (point-max))
(newline)
(insert <span style="color: #ff0000;">";;"</span>)
(newline)
(insert (format <span style="color: #ff0000;">";; elmacro added on %s"</span> (current-time-string)))
(newline)
(yank)
(newline)
(save-buffer))
(switch-to-buffer nil)
(delete-window))
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'ms</span> <span style="color: #ff00ff;">'tvd-macro-store</span>)
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-macro-gen-repeater-and-save</span>()
<span style="color: #cd6600;">"generate repeater and save the defun's</span>
<span style="color: #cd6600;">Runs when (point) is at 0,0 of generated</span>
<span style="color: #cd6600;">defun."</span>
(next-line)
(goto-char (point-max))
(newline)
(insert (format <span style="color: #ff0000;">"(defun %s-repeat()\n"</span> tvd-macro-name))
(insert <span style="color: #ff0000;">" (interactive)\n"</span>)
(insert (format <span style="color: #ff0000;">" (tvd-exec-last-macro \"%s\"))\n"</span> tvd-macro-name))
(newline)
(eval-buffer)
(tvd-macro-store))
(advice-add <span style="color: #ff00ff;">'elmacro-show-defun</span> <span style="color: #8a2be2;">:after</span> '(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> args)
(tvd-macro-gen-repeater-and-save)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orge706b96" class="outline-4">
<h4 id="orge706b96"><span class="section-number-4">6.4.19</span> EWW browser stuff</h4>
<div class="outline-text-4" id="text-6-4-19">
<p>
Emacs has a builtin browser, which is not too bad.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'eww</span>)
</pre>
</div>
<p>
see also: shr-render-[buffer|region] !
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">eww-render-current-buffer</span> ()
<span style="color: #cd6600;">"Render HTML in the current buffer with EWW"</span>
(interactive)
(beginning-of-buffer)
(eww-display-html <span style="color: #ff00ff;">'utf8</span> (buffer-name)))
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'render-html</span> <span style="color: #ff00ff;">'eww-render-current-buffer</span>)
</pre>
</div>
<p>
eww config
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'eww-mode-hook</span> #<span style="color: #ff00ff;">'toggle-word-wrap</span>)
(add-hook <span style="color: #ff00ff;">'eww-mode-hook</span> #<span style="color: #ff00ff;">'visual-line-mode</span>)
</pre>
</div>
<p>
custom short commands, see ? for the defaults
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-key eww-mode-map <span style="color: #ff0000;">"o"</span> <span style="color: #ff00ff;">'eww</span>) <span style="color: #006400;">; </span><span style="color: #006400;">aka other page</span>
(define-key eww-mode-map <span style="color: #ff0000;">"f"</span> <span style="color: #ff00ff;">'eww-browse-with-external-browser</span>) <span style="color: #006400;">; </span><span style="color: #006400;">aka firefox</span>
(define-key eww-mode-map <span style="color: #ff0000;">"j"</span> <span style="color: #ff00ff;">'next-line</span>)
(define-key eww-mode-map <span style="color: #ff0000;">"r"</span> <span style="color: #ff00ff;">'eww-reload</span>)
(define-key eww-mode-map <span style="color: #ff0000;">"s"</span> <span style="color: #ff00ff;">'shr-save-contents</span>)
(define-key eww-mode-map <span style="color: #ff0000;">"v"</span> <span style="color: #ff00ff;">'eww-view-source</span>)
(define-key eww-mode-map <span style="color: #ff0000;">"b"</span> <span style="color: #ff00ff;">'eww-add-bookmark</span>)
(define-key eww-mode-map <span style="color: #ff0000;">"p"</span> <span style="color: #ff00ff;">'eww-back-url</span>)
(define-key eww-mode-map <span style="color: #ff0000;">"n"</span> <span style="color: #ff00ff;">'eww-forward-url</span>)
</pre>
</div>
<p>
link short commands
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-key eww-link-keymap <span style="color: #ff0000;">"c"</span> <span style="color: #ff00ff;">'shr-copy-url</span>)
(define-key eww-link-keymap <span style="color: #ff0000;">"s"</span> <span style="color: #ff00ff;">'shr-save-contents</span>)
</pre>
</div>
<p>
<i>FIXME</i>: latest GIT version of eww contains 'eww-readable, which
hides menus and distractions! Update emacs.
</p>
<hr />
</div>
</div>
<div id="outline-container-orga813bbb" class="outline-4">
<h4 id="orga813bbb"><span class="section-number-4">6.4.20</span> Firestarter</h4>
<div class="outline-text-4" id="text-6-4-20">
<p>
experimental: do things on save buffer etc.
Source: <a href="https://github.com/wasamasa/firestarter">firestarter</a>
</p>
</div>
</div>
<div id="outline-container-org3aee3ce" class="outline-4">
<h4 id="org3aee3ce"><span class="section-number-4">6.4.21</span> Tabulated List Mode</h4>
<div class="outline-text-4" id="text-6-4-21">
<p>
built-in, used by many interactive major modes
</p>
<p>
+tablist, which provides many cool features
<a href="https://github.com/politza/tablist">github source</a>
important commands:
</p>
<ul class="org-ul">
<li>&lt; shrink column</li>
<li>&gt; enlarge column</li>
<li>s sort column</li>
<li>/ prefix for filter commands
/ e edit filter, e.g. do not list auto-complete sub-packages in melpa:
/ a ! Package =~ ac- &lt;ret&gt;</li>
</ul>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'tablist</span>)
</pre>
</div>
<p>
we need to kill tablist's binding in order to have ours run (see below)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-key tablist-minor-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"q"</span>) nil)
(define-key tablist-minor-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"q"</span>) <span style="color: #ff00ff;">'tvd-close-window</span>)
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-close-window</span> ()
(interactive)
(kill-this-buffer)
(delete-window))
(eval-after-load <span style="color: #ff0000;">"tabulated-list"</span>
'(<span style="color: #0000ff;">progn</span>
(add-hook <span style="color: #ff00ff;">'tabulated-list-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(tablist-minor-mode)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"Q"</span>) <span style="color: #ff00ff;">'delete-other-windows</span>)
(hl-line-mode)))))
</pre>
</div>
</div>
</div>
<div id="outline-container-org1b37644" class="outline-4">
<h4 id="org1b37644"><span class="section-number-4">6.4.22</span> Help Mode</h4>
<div class="outline-text-4" id="text-6-4-22">
<p>
I even customize help windows! &#x2026; at least a little :)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(eval-after-load <span style="color: #ff0000;">"Help"</span>
'(<span style="color: #0000ff;">progn</span>
(add-hook <span style="color: #ff00ff;">'help-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"q"</span>) <span style="color: #ff00ff;">'tvd-close-window</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"x"</span>) <span style="color: #ff00ff;">'quit-window</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"p"</span>) <span style="color: #ff00ff;">'help-go-back</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"b"</span>) <span style="color: #ff00ff;">'help-go-back</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"n"</span>) <span style="color: #ff00ff;">'help-go-forward</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"f"</span>) <span style="color: #ff00ff;">'help-go-forward</span>)
))))
</pre>
</div>
</div>
</div>
<div id="outline-container-org7dd3ab4" class="outline-4">
<h4 id="org7dd3ab4"><span class="section-number-4">6.4.23</span> Suggest Mode</h4>
<div class="outline-text-4" id="text-6-4-23">
<p>
<a href="https://github.com/Wilfred/suggest.el">suggest mode</a> is a great
elisp development tool. Execute `M-x suggest' and try it.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'suggest</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">depends on dash, s, f, loop</span>
</pre>
</div>
<p>
I use my own clearing function, since suggest doesn't provide this
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-suggest-reload</span> ()
<span style="color: #cd6600;">"Clear suggest buffer and re-paint it."</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((inhibit-read-only t))
(erase-buffer)
(suggest--insert-heading suggest--inputs-heading)
(insert <span style="color: #ff0000;">"\n\n\n"</span>)
(suggest--insert-heading suggest--outputs-heading)
(insert <span style="color: #ff0000;">"\n\n\n"</span>)
(suggest--insert-heading suggest--results-heading)
(insert <span style="color: #ff0000;">"\n"</span>)
(suggest--nth-heading 1)
(forward-line 1)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-suggest-jump</span> ()
<span style="color: #cd6600;">"Jump between input and output suggest buffer."</span>
(interactive)
(forward-line -1)
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> (line-number-at-pos) 1)
(suggest--nth-heading 2)
(suggest--nth-heading 1))
(forward-line 1))
(eval-after-load <span style="color: #ff0000;">"suggest"</span>
'(<span style="color: #0000ff;">progn</span>
(add-hook <span style="color: #ff00ff;">'suggest-mode-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-l"</span>) <span style="color: #ff00ff;">'tvd-suggest-reload</span>)
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;tab&gt;"</span>) <span style="color: #ff00ff;">'tvd-suggest-jump</span>)))))
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgbbbb61f" class="outline-3">
<h3 id="orgbbbb61f"><span class="section-number-3">6.5</span> Emacs Interface</h3>
<div class="outline-text-3" id="text-6-5">
</div><div id="outline-container-org45d01a9" class="outline-4">
<h4 id="org45d01a9"><span class="section-number-4">6.5.1</span> Parens</h4>
<div class="outline-text-4" id="text-6-5-1">
<p>
display matching braces
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(show-paren-mode 1)
</pre>
</div>
<p>
'mixed: highlight all if the other paren is invisible
'expression: highlight the whole sexp
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> show-paren-style <span style="color: #ff00ff;">'mixed</span>)
</pre>
</div>
</div>
</div>
<div id="outline-container-org64ac535" class="outline-4">
<h4 id="org64ac535"><span class="section-number-4">6.5.2</span> highlight todo keywords (such as <i>FIXME</i>)</h4>
<div class="outline-text-4" id="text-6-5-2">
<p>
Absolutely needed!
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'fic-mode</span>)
(add-something-to-mode-hooks '(c c++ cperl vala web emacs-lisp ruby python) <span style="color: #ff00ff;">'turn-on-fic-mode</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org93327f8" class="outline-4">
<h4 id="org93327f8"><span class="section-number-4">6.5.3</span> UNDO Tree Mode</h4>
<div class="outline-text-4" id="text-6-5-3">
<p>
Better undo, with redo support.
</p>
<p>
C-_ (`undo-tree-undo')
Undo changes.
</p>
<p>
C-: (`undo-tree-redo')
Redo changes.
</p>
<p>
more: see undo-tree.el
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'undo-tree</span>)
</pre>
</div>
<p>
use always
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-undo-tree-mode)
</pre>
</div>
<p>
M-_ catched by Xmonad
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-:"</span>) <span style="color: #ff00ff;">'undo-tree-redo</span>) <span style="color: #006400;">; </span><span style="color: #006400;">C-: == REDO C-_ == UNDO</span>
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orga571836" class="outline-4">
<h4 id="orga571836"><span class="section-number-4">6.5.4</span> Smarter M-x Mode (smex)</h4>
<div class="outline-text-4" id="text-6-5-4">
<p>
This is really cool and I don't know how I could ever live without it.
</p>
<p>
fails @win, so wrap it
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(safe-wrap
(<span style="color: #0000ff;">progn</span>
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'smex</span>)
(smex-initialize)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-x"</span>) <span style="color: #ff00ff;">'smex</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-X"</span>) <span style="color: #ff00ff;">'smex-major-mode-commands</span>))
(message <span style="color: #ff0000;">"ignoring unsupported smex"</span>))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org3aecb4e" class="outline-4">
<h4 id="org3aecb4e"><span class="section-number-4">6.5.5</span> Which Func</h4>
<div class="outline-text-4" id="text-6-5-5">
<p>
display current function - if any - in mode line
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-something-to-mode-hooks
'(c c++ cperl vala makefile ruby shell-script python)
<span style="color: #ff00ff;">'which-func-mode</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgab89c04" class="outline-4">
<h4 id="orgab89c04"><span class="section-number-4">6.5.6</span> Show current-line in the Fringe</h4>
<div class="outline-text-4" id="text-6-5-6">
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'fringe-current-line</span>)
(global-fringe-current-line-mode 1)
</pre>
</div>
<p>
also change the color (matching the mode line
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(set-face-attribute <span style="color: #ff00ff;">'fringe</span> nil <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"NavyBlue"</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orga860222" class="outline-4">
<h4 id="orga860222"><span class="section-number-4">6.5.7</span> Recent Files</h4>
<div class="outline-text-4" id="text-6-5-7">
<p>
You know the file you edited yesterday had "kri" in its name, but
where was it? You don't remember. But don't worry, recent files is
your friend. It shows the last N files you edited recently.
I use it permanently.
</p>
<p>
see also: ido-mode and smex
</p>
<p>
setup
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'recentf</span>)
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'cl-lib</span>)
(<span style="color: #0000ff;">setq</span> recentf-auto-cleanup <span style="color: #ff00ff;">'never</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">avoid stat() on tramp buffers</span>
(recentf-mode 1)
</pre>
</div>
<p>
I like to have a longer list reaching deeper into the past
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> recentf-max-menu-items 200
recentf-max-menu-items 30)
</pre>
</div>
<p>
enable IDO completion
via <a href="http://emacsredux.com/blog/2013/04/05/recently-visited-files/">emacsredux</a>
modified to exclude already visited files
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-buffer-exists-p</span> (bufname)
(<span style="color: #0000ff;">not</span> (<span style="color: #0000ff;">eq</span> nil (get-file-buffer bufname))))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">recentf-ido-find-file</span> ()
<span style="color: #cd6600;">"Find a recent file using ido."</span>
(interactive)
(<span style="color: #0000ff;">let</span> ((file (ido-completing-read
<span style="color: #ff0000;">"Choose recent file: "</span>
(cl-remove-if <span style="color: #ff00ff;">'tvd-buffer-exists-p</span> recentf-list) nil t)))
(<span style="color: #0000ff;">when</span> file
(find-file file))))
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-x C-r"</span>) <span style="color: #ff00ff;">'recentf-ido-find-file</span>) <span style="color: #006400;">; </span><span style="color: #006400;">open recent files, same as M-x rf</span>
</pre>
</div>
<p>
now if I incidentally closed a buffer, I can re-open it, thanks to
recent-files
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">undo-kill-buffer</span> (arg)
<span style="color: #cd6600;">"Re-open the last buffer killed. With ARG, re-open the nth buffer."</span>
(interactive <span style="color: #ff0000;">"p"</span>)
(<span style="color: #0000ff;">let</span> ((recently-killed-list (copy-sequence recentf-list))
(buffer-files-list
(delq nil (mapcar (<span style="color: #0000ff;">lambda</span> (buf)
(<span style="color: #0000ff;">when</span> (buffer-file-name buf)
(expand-file-name (buffer-file-name buf)))) (buffer-list)))))
(mapc
(<span style="color: #0000ff;">lambda</span> (buf-file)
(<span style="color: #0000ff;">setq</span> recently-killed-list
(delq buf-file recently-killed-list)))
buffer-files-list)
(find-file
(<span style="color: #0000ff;">if</span> arg (nth arg recently-killed-list)
(<span style="color: #0000ff;">car</span> recently-killed-list)))))
</pre>
</div>
<p>
exclude some auto generated files
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> recentf-exclude (list <span style="color: #ff0000;">"ido.last"</span>
<span style="color: #ff0000;">"/elpa/"</span>
<span style="color: #ff0000;">".el.gz$"</span>
'(<span style="color: #0000ff;">not</span> (file-readable-p))))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org1607b01" class="outline-4">
<h4 id="org1607b01"><span class="section-number-4">6.5.8</span> IDO mode</h4>
<div class="outline-text-4" id="text-6-5-8">
<p>
There are other completion enhancement packages available like ivy
for example, but I love IDO and I am so used to it, it would be
impossible to change. So, I'll stick with IDO until end of (my)
times.
</p>
<p>
Hint: Use C-f during file selection to switch to regular find-file
</p>
<p>
Basic config
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(ido-mode t)
(ido-everywhere nil)
(<span style="color: #0000ff;">setq</span> ido-enable-flex-matching t)
(<span style="color: #0000ff;">setq</span> ido-use-filename-at-point nil)
(<span style="color: #0000ff;">setq</span> ido-use-virtual-buffers t)
(<span style="color: #0000ff;">setq</span> ido-auto-merge-work-directories-length -1)
</pre>
</div>
<p>
One thing annoys me with IDO though: when writing a new file, IDO
wants me to select from a list of existing files. Since it is
nearly impossible to disable ido mode for write-file, which I HATE,
I came up with this:
</p>
<p>
I added a new global variable, 'tvd-ido-disabled, which is nil by
default. Whenever I hit C-x C-w (in order to execute write-file),
it will be set to t, ido mode will be disabled and ido-write-file
will be called. Since ido mode is now disabled, it just calls the
original write-file, which is what I really want.
</p>
<p>
When I'm finished selecting a filename and writing, ido mode will
be turned on again and the variable will be set to nil. However,
sometimes I may abort the process using C-g. In that case ido mode
may end up being disabled because the :after advice will not be
called on C-g.
</p>
<p>
So, I also advice the minibuffer C-g function, which is
'abort-recursive-edit, and re-enable ido mode from here if it is
still disabled. So far I haven't seen any bad side effects of this.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defvar</span> <span style="color: #a0522d;">tvd-ido-disabled</span> nil)
(advice-add <span style="color: #ff00ff;">'ido-write-file</span> <span style="color: #8a2be2;">:before</span> '(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> args) (ido-mode 0) (<span style="color: #0000ff;">setq</span> tvd-ido-disabled t)))
(advice-add <span style="color: #ff00ff;">'ido-write-file</span> <span style="color: #8a2be2;">:after</span> '(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> args) (ido-mode 1) (<span style="color: #0000ff;">setq</span> tvd-ido-disabled nil)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-keyboard-quit-advice</span> (fn <span style="color: #483d8b;">&amp;rest</span> args)
(<span style="color: #0000ff;">when</span> tvd-ido-disabled
(ido-mode 1)
(<span style="color: #0000ff;">setq</span> tvd-ido-disabled nil))
(apply fn args))
(advice-add <span style="color: #ff00ff;">'abort-recursive-edit</span> <span style="color: #8a2be2;">:around</span> #<span style="color: #ff00ff;">'tvd-keyboard-quit-advice</span>)
</pre>
</div>
<p>
from emacs wiki
Display ido results vertically, rather than horizontally
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> ido-decorations (quote (<span style="color: #ff0000;">"\n-&gt; "</span> <span style="color: #ff0000;">""</span> <span style="color: #ff0000;">"\n "</span> <span style="color: #ff0000;">"\n ..."</span> <span style="color: #ff0000;">"["</span> <span style="color: #ff0000;">"]"</span>
<span style="color: #ff0000;">" [No match]"</span> <span style="color: #ff0000;">" [Matched]"</span> <span style="color: #ff0000;">" [Not readable]"</span>
<span style="color: #ff0000;">" [Too big]"</span> <span style="color: #ff0000;">" [Confirm]"</span>)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">ido-disable-line-truncation</span> () (<span style="color: #0000ff;">set</span> (make-local-variable <span style="color: #ff00ff;">'truncate-lines</span>) nil))
(add-hook <span style="color: #ff00ff;">'ido-minibuffer-setup-hook</span> <span style="color: #ff00ff;">'ido-disable-line-truncation</span>)
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">ido-define-keys</span> ()
(define-key ido-completion-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;down&gt;"</span>) <span style="color: #ff00ff;">'ido-next-match</span>)
(define-key ido-completion-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"&lt;up&gt;"</span>) <span style="color: #ff00ff;">'ido-prev-match</span>))
(add-hook <span style="color: #ff00ff;">'ido-setup-hook</span> <span style="color: #ff00ff;">'ido-define-keys</span>)
</pre>
</div>
<p>
quickly go to home via ~ wherever I am
via <a href="http://whattheemacsd.com/setup-ido.el-02.html">whattheemacs.d</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-hook <span style="color: #ff00ff;">'ido-setup-hook</span>
(<span style="color: #0000ff;">lambda</span> ()
<span style="color: #006400;">;; </span><span style="color: #006400;">Go straight home</span>
(define-key ido-file-completion-map
(<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"~"</span>)
(<span style="color: #0000ff;">lambda</span> ()
(interactive)
(<span style="color: #0000ff;">if</span> (looking-back <span style="color: #ff0000;">"/"</span>)
(insert <span style="color: #ff0000;">"~/"</span>)
(call-interactively <span style="color: #ff00ff;">'self-insert-command</span>))))))
</pre>
</div>
<p>
by howardism: [re]open non-writable file with sudo
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defadvice</span> <span style="color: #9932cc;">ido-find-file</span> (after find-file-sudo activate)
<span style="color: #cd6600;">"Find file as root if necessary."</span>
(<span style="color: #0000ff;">unless</span> (<span style="color: #0000ff;">and</span> buffer-file-name
(file-writable-p buffer-file-name))
(<span style="color: #0000ff;">let*</span> ((file-name (buffer-file-name))
(file-root (<span style="color: #0000ff;">if</span> (string-match <span style="color: #ff0000;">"/ssh:</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">[</span><span style="color: #ff0000;">^</span><span style="color: #ff0000;">:]+</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">:</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">.*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">"</span> file-name)
(concat <span style="color: #ff0000;">"/ssh:"</span> (match-string 1 file-name)
<span style="color: #ff0000;">"|sudo:"</span> (match-string 1 file-name)
<span style="color: #ff0000;">":"</span> (match-string 2 file-name))
(concat <span style="color: #ff0000;">"/sudo:localhost:"</span> file-name))))
(find-alternate-file file-root))))
</pre>
</div>
<p>
<i>FIXME</i>: add ido-ignore-files defun.
</p>
<hr />
</div>
</div>
<div id="outline-container-org3615d48" class="outline-4">
<h4 id="org3615d48"><span class="section-number-4">6.5.9</span> Save cursor position</h4>
<div class="outline-text-4" id="text-6-5-9">
<p>
So the next time I start emacs and open a file I were editing
previously, (point) will be in the exact places where it was
before.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">if</span> (version&lt; emacs-version <span style="color: #ff0000;">"25.0"</span>)
(<span style="color: #0000ff;">progn</span>
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'saveplace</span>)
(setq-default save-place t))
(save-place-mode 1))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org65afd36" class="outline-4">
<h4 id="org65afd36"><span class="section-number-4">6.5.10</span> DoReMi experimentation</h4>
<div class="outline-text-4" id="text-6-5-10">
<p>
I'm not using it a lot, sometimes I tune the background color though.
</p>
<p>
via <a href="https://www.emacswiki.org/emacs/DoReMi">emacswiki/DoReMi</a>
cool ones: doremi-buffers, doremi-all-faces-fg+ [s, h]
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'doremi</span>)
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'doremi-frm</span>)
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'doremi-cmd</span>)
</pre>
</div>
<p>
<i>FIXME</i>: find a good key
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'cb</span> <span style="color: #ff00ff;">'doremi-buffers</span>+)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org7d42663" class="outline-4">
<h4 id="org7d42663"><span class="section-number-4">6.5.11</span> Hightligt TABs</h4>
<div class="outline-text-4" id="text-6-5-11">
<p>
not a mode, but however: higlight TABs in certain modes
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defface</span> <span style="color: #a0522d;">extra-whitespace-face</span>
'((t (<span style="color: #8a2be2;">:background</span> <span style="color: #ff0000;">"pale green"</span>)))
<span style="color: #cd6600;">"Used for tabs and such."</span>)
(<span style="color: #0000ff;">defvar</span> <span style="color: #a0522d;">tvd-extra-keywords</span>
'((<span style="color: #ff0000;">"\t"</span> . <span style="color: #ff00ff;">'extra-whitespace-face</span>)))
(add-something-to-mode-hooks '(c c++ vala cperl emacs-lisp python shell-script)
(<span style="color: #0000ff;">lambda</span> () (font-lock-add-keywords nil tvd-extra-keywords)))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgc31b7a1" class="outline-4">
<h4 id="orgc31b7a1"><span class="section-number-4">6.5.12</span> Browse kill-ring</h4>
<div class="outline-text-4" id="text-6-5-12">
<p>
when active use n and p to browse, &lt;ret&gt; to select, it's the same
as &lt;M-y&gt; and I never really use it&#x2026;
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'browse-kill-ring</span>)
(<span style="color: #0000ff;">setq</span> browse-kill-ring-highlight-current-entry t
browse-kill-ring-highlight-inserted-item t)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org38a233d" class="outline-4">
<h4 id="org38a233d"><span class="section-number-4">6.5.13</span> goto-last-change</h4>
<div class="outline-text-4" id="text-6-5-13">
<p>
Very handy, jump to last change[s].
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'goto-last-change</span>)
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-b"</span>) <span style="color: #ff00ff;">'goto-last-change</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgf1a8985" class="outline-4">
<h4 id="orgf1a8985"><span class="section-number-4">6.5.14</span> Bookmarks</h4>
<div class="outline-text-4" id="text-6-5-14">
<p>
I use the builtin bookmark feature quite a lot and am happy with
it. Especially at work, where many files are located in large
path's on remote storage systems, it great to jump quickly to such
places.
</p>
<p>
everytime bookmark is changed, automatically save it
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> bookmark-save-flag 1
bookmark-version-control t)
</pre>
</div>
<p>
I use the same aliases as in apparix for bash (since I'm used to them)
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'to</span> <span style="color: #ff00ff;">'bookmark-jump</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'bm</span> <span style="color: #ff00ff;">'bookmark-set</span>)
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'bl</span> <span style="color: #ff00ff;">'bookmark-bmenu-list</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org1c8dda8" class="outline-4">
<h4 id="org1c8dda8"><span class="section-number-4">6.5.15</span> which-key</h4>
<div class="outline-text-4" id="text-6-5-15">
<p>
One of the best unobstrusive modes for key help ever. Just start
entering a key chord, prefix or whatever, and it pops a small
buffer (on the right side in my case) showing the avialable keys to
press from there along with the associated functions.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'which-key</span>)
(which-key-mode)
(which-key-setup-side-window-right)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgeddda89" class="outline-4">
<h4 id="orgeddda89"><span class="section-number-4">6.5.16</span> iBuffer mode</h4>
<div class="outline-text-4" id="text-6-5-16">
<p>
iBuffer is a great interactive buffer management tool included with
emacs. I use it with a couple of custom groups, my own
collapse-code (&lt;TAB&gt;) and formats.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'ibuffer</span>)
</pre>
</div>
<p>
from github:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'ibuffer-vc</span>)
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'ibuffer-tramp</span>)
</pre>
</div>
<p>
replace default list-buffers with ibuffer
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"C-x C-b"</span>) <span style="color: #ff00ff;">'ibuffer</span>)
</pre>
</div>
<p>
group name
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> tvd-ibuffer-filter-group-name <span style="color: #ff0000;">"tvd-filters"</span>)
</pre>
</div>
<p>
filter group config
with hints from <a href="https://ogbe.net/emacsconfig.html">Ogbe</a> et.al.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> ibuffer-saved-filter-groups
(list (nreverse
`(
(<span style="color: #ff0000;">"Org"</span> (mode . org-mode))
(<span style="color: #ff0000;">"Shell"</span> (<span style="color: #0000ff;">or</span> (mode . term-mode)
(mode . eshell-mode)
(mode . shell-mode)))
(<span style="color: #ff0000;">"Emacs-Config"</span> (filename . <span style="color: #ff0000;">"emacs"</span>))
(<span style="color: #ff0000;">"Cisco-Config"</span> (mode . cisco-mode))
(<span style="color: #ff0000;">"Code"</span> (<span style="color: #0000ff;">or</span> (mode . cperl-mode)
(mode . c-mode)
(mode . python-mode)
(mode . shell-script-mode)
(mode . makefile-mode)
(mode . cc-mode)))
(<span style="color: #ff0000;">"Text"</span> (<span style="color: #0000ff;">or</span> (mode . text-mode)
(filename . <span style="color: #ff0000;">"\\.pod$"</span>)))
(<span style="color: #ff0000;">"LaTeX"</span> (mode . latex-mode))
(<span style="color: #ff0000;">"Interactive"</span> (or
(mode . inferior-python-mode)
(mode . slime-repl-mode)
(mode . inferior-lisp-mode)
(mode . inferior-scheme-mode)
(name . <span style="color: #ff0000;">"*ielm*"</span>)))
(<span style="color: #ff0000;">"Crab"</span> (or
(name . <span style="color: #ff0000;">"^\\*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">Help</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">scratch</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">Messages</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">\\*"</span>)
))
,tvd-ibuffer-filter-group-name))))
</pre>
</div>
<p>
Reverse the order of the filter groups. Kind of confusing: Since
I'm reversing the order of the groups above, this snippet ensures
that the groups are ordered in the way they are written above, with
the "Default" group on top. This advice might need to be ported to
the new advice system soon.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defadvice</span> <span style="color: #9932cc;">ibuffer-generate-filter-groups</span>
(after reverse-ibuffer-groups () activate)
(<span style="color: #0000ff;">setq</span> ad-return-value (nreverse ad-return-value)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">ibuffer-add-dynamic-filter-groups</span> ()
(interactive)
(<span style="color: #0000ff;">dolist</span> (group (ibuffer-vc-generate-filter-groups-by-vc-root))
(add-to-list <span style="color: #ff00ff;">'ibuffer-filter-groups</span> group))
(<span style="color: #0000ff;">dolist</span> (group (ibuffer-tramp-generate-filter-groups-by-tramp-connection))
(add-to-list <span style="color: #ff00ff;">'ibuffer-filter-groups</span> group)))
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-ibuffer-hooks</span> ()
(ibuffer-auto-mode 1)
(ibuffer-switch-to-saved-filter-groups tvd-ibuffer-filter-group-name)
(ibuffer-add-dynamic-filter-groups))
(add-hook <span style="color: #ff00ff;">'ibuffer-mode-hook</span> <span style="color: #ff00ff;">'tvd-ibuffer-hooks</span>)
</pre>
</div>
<p>
Only show groups that have active buffers
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> ibuffer-show-empty-filter-groups nil)
</pre>
</div>
<p>
Don't show the summary or headline
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> ibuffer-display-summary nil)
</pre>
</div>
<p>
do not prompt for every action
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> ibuffer-expert t)
</pre>
</div>
<p>
buffers to always ignore
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-to-list <span style="color: #ff00ff;">'ibuffer-never-show-predicates</span> <span style="color: #ff0000;">"^\\*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">Completions</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">tramp/</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">"</span>)
</pre>
</div>
<p>
Use human readable Size column instead of original one
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-ibuffer-column size-h
(<span style="color: #8a2be2;">:name</span> <span style="color: #ff0000;">"Size"</span> <span style="color: #8a2be2;">:inline</span> t)
(<span style="color: #0000ff;">cond</span>
((&gt; (buffer-size) 1000000) (format <span style="color: #ff0000;">"%7.1fM"</span> (/ (buffer-size) 1000000.0)))
((&gt; (buffer-size) 100000) (format <span style="color: #ff0000;">"%7.0fk"</span> (/ (buffer-size) 1000.0)))
((&gt; (buffer-size) 1000) (format <span style="color: #ff0000;">"%7.1fk"</span> (/ (buffer-size) 1000.0)))
(t (format <span style="color: #ff0000;">"%8d"</span> (buffer-size)))))
</pre>
</div>
<p>
Modify the default ibuffer-formats
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> ibuffer-formats
'((mark modified read-only <span style="color: #ff0000;">" "</span>
(name 20 40 <span style="color: #8a2be2;">:left</span> <span style="color: #8a2be2;">:elide</span>)
<span style="color: #ff0000;">" "</span>
(size-h 9 -1 <span style="color: #8a2be2;">:right</span>)
<span style="color: #ff0000;">" "</span>
(mode 16 16 <span style="color: #8a2be2;">:left</span> <span style="color: #8a2be2;">:elide</span>)
<span style="color: #ff0000;">" "</span>
filename-and-process)))
</pre>
</div>
<p>
hide annoying groups, but keep its buffers available
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defvar</span> <span style="color: #a0522d;">ibuffer-collapsed-groups</span> (list <span style="color: #ff0000;">"Crab"</span>))
(advice-add <span style="color: #ff00ff;">'ibuffer</span> <span style="color: #8a2be2;">:after</span> '(<span style="color: #0000ff;">lambda</span> (<span style="color: #483d8b;">&amp;rest</span> args)
(ignore args)
(<span style="color: #0000ff;">save-excursion</span>
(<span style="color: #0000ff;">dolist</span> (group ibuffer-collapsed-groups)
(<span style="color: #0000ff;">ignore-errors</span>
(ibuffer-jump-to-filter-group group)
(ibuffer-toggle-filter-group))))))
</pre>
</div>
<p>
move point to most recent buffer when entering ibuffer
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defadvice</span> <span style="color: #9932cc;">ibuffer</span> (around ibuffer-point-to-most-recent) ()
<span style="color: #ff0000;">"Open ibuffer with cursor pointed to most recent (non-minibuffer) buffer name"</span>
(<span style="color: #0000ff;">let</span> ((recent-buffer-name
(<span style="color: #0000ff;">if</span> (minibufferp (buffer-name))
(buffer-name
(window-buffer (minibuffer-selected-window)))
(buffer-name (other-buffer)))))
ad-do-it
(ibuffer-jump-to-buffer recent-buffer-name)))
(ad-activate <span style="color: #ff00ff;">'ibuffer</span>)
</pre>
</div>
<p>
override ibuffer M-o binding
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(define-key ibuffer-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-o"</span>) <span style="color: #ff00ff;">'other-window-or-switch-buffer</span>)
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgc0650d1" class="outline-4">
<h4 id="orgc0650d1"><span class="section-number-4">6.5.17</span> Printing</h4>
<div class="outline-text-4" id="text-6-5-17">
<p>
overwrites printing default menu, access via menu File =&gt; Print
or:
</p>
<ul class="org-ul">
<li>M-x ps-spool-buffer-with-faces</li>
<li>go to <b>spool</b> buffer</li>
<li>save to .ps file</li>
<li>print</li>
</ul>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'printing</span>)
(pr-menu-bind)
</pre>
</div>
<p>
via <a href="https://emacs.stackexchange.com/questions/9364/convert-a-text-buffer-to-a-pdf-file">stackoverflow</a>
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">when</span> (executable-find <span style="color: #ff0000;">"ps2pdf"</span>)
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">print-to-pdf</span> (<span style="color: #483d8b;">&amp;optional</span> filename)
<span style="color: #cd6600;">"Print file in the current buffer as pdf, including font, color, and</span>
<span style="color: #cd6600;">underline information. This command works only if you are using a window system,</span>
<span style="color: #cd6600;">so it has a way to determine color values.</span>
<span style="color: #cd6600;">C-u COMMAND prompts user where to save the Postscript file (which is then</span>
<span style="color: #cd6600;">converted to PDF at the same location."</span>
(interactive (list (<span style="color: #0000ff;">if</span> current-prefix-arg
(ps-print-preprint 4)
(concat (file-name-sans-extension (buffer-file-name))
<span style="color: #ff0000;">".ps"</span>))))
(ps-print-with-faces (point-min) (point-max) filename)
(shell-command (concat <span style="color: #ff0000;">"ps2pdf "</span> filename))
(delete-file filename)
(message <span style="color: #ff0000;">"Deleted %s"</span> filename)
(message <span style="color: #ff0000;">"Wrote %s"</span> (concat (file-name-sans-extension filename) <span style="color: #ff0000;">".pdf"</span>))))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-org921ad8b" class="outline-4">
<h4 id="org921ad8b"><span class="section-number-4">6.5.18</span> Beacon mode (pointer blink)</h4>
<div class="outline-text-4" id="text-6-5-18">
<p>
Source: <a href="https://github.com/Malabarba/beacon">beacon mode</a>
</p>
<p>
Blink the cursor shortly when moving across large text sections or
when changing windows. That way it is easier to find the current
editing position.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'beacon</span>)
(<span style="color: #0000ff;">setq</span> beacon-blink-duration 0.1
beacon-blink-when-point-moves-vertically 10
beacon-color 0.3)
(add-hook <span style="color: #ff00ff;">'beacon-dont-blink-predicates</span>
(<span style="color: #0000ff;">lambda</span> () (bound-and-true-p novel-mode)))
(beacon-mode)
</pre>
</div>
<hr />
</div>
</div>
</div>
<div id="outline-container-orgbb6fc6c" class="outline-3">
<h3 id="orgbb6fc6c"><span class="section-number-3">6.6</span> mode-line setup (must be the last mode)</h3>
<div class="outline-text-3" id="text-6-6">
<p>
I just append the current version of my emacs config and leave out
some stuff to keep the modeline short, so that everything can be
seen even if I have multiple windows open.
</p>
<p>
smaller pos
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(setq-default mode-line-position
'((-3 <span style="color: #ff0000;">"%p"</span>) (size-indication-mode (<span style="color: #ff0000;">"/"</span> (-4 <span style="color: #ff0000;">"%I"</span>)))
<span style="color: #ff0000;">" "</span>
(line-number-mode
(<span style="color: #ff0000;">"%l"</span> (column-number-mode <span style="color: #ff0000;">":%c"</span>)))))
</pre>
</div>
<p>
when macro recording is active, signal it with coloring instead of
just a character
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defface</span> <span style="color: #a0522d;">rec-face</span>
'((t (<span style="color: #8a2be2;">:background</span> <span style="color: #ff0000;">"red"</span> <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"white"</span> <span style="color: #8a2be2;">:weight</span> bold)))
<span style="color: #cd6600;">"Flag macro recording in mode-line"</span>
<span style="color: #8a2be2;">:group</span> <span style="color: #ff00ff;">'tvd-mode-line-faces</span>)
</pre>
</div>
<p>
custom modeline
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(setq-default mode-line-format
(list
<span style="color: #ff0000;">"%e"</span>
mode-line-front-space
mode-line-mule-info
mode-line-modified
mode-line-remote
<span style="color: #ff0000;">" "</span>
mode-line-buffer-identification
<span style="color: #ff0000;">" "</span>
mode-line-position
<span style="color: #ff0000;">" (%m) "</span>
<span style="color: #ff0000;">" ["</span> tvd-emacs-version <span style="color: #ff0000;">"] "</span>
'(<span style="color: #8a2be2;">:eval</span> (propertize
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> defining-kbd-macro t)
<span style="color: #ff0000;">"[REC]"</span>
<span style="color: #ff0000;">""</span>)
<span style="color: #ff00ff;">'face</span> <span style="color: #ff00ff;">'rec-face</span>))
mode-line-end-spaces))
</pre>
</div>
<hr />
</div>
</div>
</div>
<div id="outline-container-orga10fcf5" class="outline-2">
<h2 id="orga10fcf5"><span class="section-number-2">7</span> Emacs Autoconfig / Customizegroup stuff</h2>
<div class="outline-text-2" id="text-7">
<hr />
</div>
<div id="outline-container-orgcc0e1d4" class="outline-3">
<h3 id="orgcc0e1d4"><span class="section-number-3">7.1</span> font faces</h3>
<div class="outline-text-3" id="text-7-1">
<p>
Font color config, must always be the last thing so all hook faces are loaded.
</p>
<p>
show available colors:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'colors</span> <span style="color: #ff00ff;">'list-colors-display</span>)
(custom-set-faces
<span style="color: #006400;">;; </span><span style="color: #006400;">custom-set-faces was added by Custom.</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">If you edit it by hand, you could mess it up, so be careful.</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">Your init file should contain only one such instance.</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">If there is more than one, they won't work right.</span>
'(default ((t (<span style="color: #8a2be2;">:family</span> <span style="color: #ff0000;">"DejaVu Sans Mono"</span> <span style="color: #8a2be2;">:foundry</span> <span style="color: #ff0000;">"unknown"</span> <span style="color: #8a2be2;">:slant</span> normal <span style="color: #8a2be2;">:weight</span> normal <span style="color: #8a2be2;">:width</span> normal))))
'(cperl-nonoverridable-face ((((class color) (background light)) (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Magenta"</span>))))
'(custom-documentation-face ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Navy"</span>))) t)
'(custom-group-tag-face-1 ((((class color) (background light)) (<span style="color: #8a2be2;">:underline</span> t <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"VioletRed"</span>))) t)
'(font-lock-builtin-face ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"BlueViolet"</span>))))
'(font-lock-comment-face ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"DarkGreen"</span>))))
'(font-lock-constant-face ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Magenta"</span>))))
'(font-lock-doc-face ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"DarkOrange3"</span>))))
'(font-lock-function-name-face ((t (<span style="color: #8a2be2;">:bold</span> nil <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"DarkOrchid"</span>))))
'(font-lock-keyword-face ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Blue"</span>))))
'(font-lock-string-face ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Red"</span>))))
'(font-lock-type-face ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"DarkSlateBlue"</span>))))
'(font-lock-variable-name-face ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Sienna"</span>))))
'(font-lock-warning-face ((t (<span style="color: #8a2be2;">:bold</span> t <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Red"</span>))))
'(highlight ((t (<span style="color: #8a2be2;">:background</span> <span style="color: #ff0000;">"DodgerBlue2"</span> <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"White"</span>))))
'(ido-only-match ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"dark green"</span> <span style="color: #8a2be2;">:weight</span> bold))))
'(info-title-1 ((t (<span style="color: #8a2be2;">:inherit</span> outline-1))))
'(info-title-2 ((t (<span style="color: #8a2be2;">:inherit</span> outline-2))))
'(info-title-3 ((t (<span style="color: #8a2be2;">:inherit</span> outline-3))))
'(info-title-4 ((t (<span style="color: #8a2be2;">:inherit</span> outline-4))))
'(mode-line ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"White"</span> <span style="color: #8a2be2;">:background</span> <span style="color: #ff0000;">"Blue"</span>))))
'(mode-line-inactive ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"White"</span> <span style="color: #8a2be2;">:background</span> <span style="color: #ff0000;">"DimGray"</span>))))
'(org-date ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"dark gray"</span> <span style="color: #8a2be2;">:underline</span> t))))
'(org-level-1 ((t (<span style="color: #8a2be2;">:height</span> 1.18 <span style="color: #8a2be2;">:inherit</span> outline-1 <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"medium slate blue"</span> <span style="color: #8a2be2;">:underline</span> t))))
'(org-level-2 ((t (<span style="color: #8a2be2;">:height</span> 1.16 <span style="color: #8a2be2;">:inherit</span> outline-2 <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"sea green"</span> <span style="color: #8a2be2;">:underline</span> t <span style="color: #8a2be2;">:weight</span> normal))))
'(org-level-3 ((t (<span style="color: #8a2be2;">:height</span> 1.14 <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"saddle brown"</span> <span style="color: #8a2be2;">:underline</span> t))))
'(org-level-4 ((t (<span style="color: #8a2be2;">:height</span> 1.12 <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"OrangeRed2"</span> <span style="color: #8a2be2;">:underline</span> t))))
'(org-level-5 ((t (<span style="color: #8a2be2;">:height</span> 1.1 <span style="color: #8a2be2;">:inherit</span> outline-5 <span style="color: #8a2be2;">:underline</span> t))))
'(outline-1 ((t (<span style="color: #8a2be2;">:inherit</span> font-lock-function-name-face <span style="color: #8a2be2;">:underline</span> t <span style="color: #8a2be2;">:weight</span> bold))))
'(outline-2 ((t (<span style="color: #8a2be2;">:inherit</span> font-lock-variable-name-face <span style="color: #8a2be2;">:underline</span> t <span style="color: #8a2be2;">:weight</span> bold))))
'(outline-3 ((t (<span style="color: #8a2be2;">:inherit</span> font-lock-keyword-face <span style="color: #8a2be2;">:underline</span> t <span style="color: #8a2be2;">:weight</span> bold))))
'(outline-4 ((t (<span style="color: #8a2be2;">:inherit</span> font-lock-comment-face <span style="color: #8a2be2;">:underline</span> t))))
'(region ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Aquamarine"</span> <span style="color: #8a2be2;">:background</span> <span style="color: #ff0000;">"Darkblue"</span>))))
'(secondary-selection ((t (<span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"Green"</span> <span style="color: #8a2be2;">:background</span> <span style="color: #ff0000;">"darkslateblue"</span>))))
'(wg-command-face ((t nil)))
'(wg-current-workgroup-face ((t nil)))
'(wg-divider-face ((t nil)))
'(wg-filename-face ((t nil)))
'(wg-frame-face ((t nil)))
'(wg-message-face ((t nil)))
'(wg-mode-line-face ((t nil)))
'(wg-other-workgroup-face ((t nil)))
'(wg-previous-workgroup-face ((t nil)))
'(which-func ((t (<span style="color: #8a2be2;">:background</span> <span style="color: #ff0000;">"blue"</span> <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"white"</span>))))
'(which-key-key-face ((t (<span style="color: #8a2be2;">:weight</span> bold)))))
</pre>
</div>
<p>
unless we're on windoze
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (null tvd-win-home))
(set-face-font <span style="color: #ff00ff;">'default</span> <span style="color: #ff0000;">"Courier New"</span>))
</pre>
</div>
<hr />
</div>
</div>
<div id="outline-container-orgd50933d" class="outline-3">
<h3 id="orgd50933d"><span class="section-number-3">7.2</span> variables</h3>
<div class="outline-text-3" id="text-7-2">
<p>
If I ever use custom-group to customize a mode, then I create a
manual config section for it using the values, custom has added
here. So, in normal times this should be empty, but needs to exist.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(custom-set-variables
<span style="color: #006400;">;; </span><span style="color: #006400;">custom-set-variables was added by Custom.</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">If you edit it by hand, you could mess it up, so be careful.</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">Your init file should contain only one such instance.</span>
<span style="color: #006400;">;; </span><span style="color: #006400;">If there is more than one, they won't work right.</span>
)
</pre>
</div>
</div>
</div>
<div id="outline-container-orge7a6e26" class="outline-3">
<h3 id="orge7a6e26"><span class="section-number-3">7.3</span> done</h3>
<div class="outline-text-3" id="text-7-3">
<p>
Finally, this message is being displayed. If this isn't the case I
know easily that something went wrong.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(message <span style="color: #ff0000;">"loading done"</span>)
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Tom</p>
<p class="date">Created: 2017-07-09 So 12:29</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>