mirror of
https://codeberg.org/scip/dot-emacs.git
synced 2025-12-17 04:20:57 +01:00
8092 lines
389 KiB
HTML
8092 lines
389 KiB
HTML
<?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-31 Mon 11:28 -->
|
||
<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="Thomas von Dein" />
|
||
<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-2017 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="#orgb77bae2">1. Introduction</a></li>
|
||
<li><a href="#orgf398ee1">2. Config Log, Trivia, Notes, Changes</a>
|
||
<ul>
|
||
<li><a href="#org4fa592a">2.1. Changelog</a></li>
|
||
<li><a href="#org51d48e8">2.2. <span class="todo TODO">TODO</span> </a></li>
|
||
<li><a href="#org119a78e">2.3. Parking Lot / Snippets</a>
|
||
<ul>
|
||
<li><a href="#org99546a6">2.3.1. buffer-local hook</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#org8afe11d">2.4. .emacs config version</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#org1ea8c11">3. System Specifics</a>
|
||
<ul>
|
||
<li><a href="#orgc9b8814">3.1. Global init file+dir vars, portable</a></li>
|
||
<li><a href="#orgab48572">3.2. Fontlock-mode - use syntax highlighting on graphical displays</a></li>
|
||
<li><a href="#org575984f">3.3. line-cursor in console</a></li>
|
||
<li><a href="#orgc80e8bc">3.4. Backup Config</a></li>
|
||
<li><a href="#org28a4abe">3.5. console backspace fix</a></li>
|
||
<li><a href="#org50f2cfa">3.6. hide menu- and tool-bar</a></li>
|
||
<li><a href="#orge8cf187">3.7. stay silent on startup</a></li>
|
||
<li><a href="#orge96e8ed">3.8. y means yes</a></li>
|
||
<li><a href="#orga57394f">3.9. show col in modeline</a></li>
|
||
<li><a href="#orgfb1d55e">3.10. file or buffer in title</a></li>
|
||
<li><a href="#orgf8540e4">3.11. avoid invalid files</a></li>
|
||
<li><a href="#org0e738a6">3.12. prepare load-path</a></li>
|
||
<li><a href="#org9feedab">3.13. byte-compile all of them, if needed</a></li>
|
||
<li><a href="#org0e100da">3.14. increase fontsize with ctrl-+ and ctrl--</a></li>
|
||
<li><a href="#org554270e">3.15. WINDOW management stuff</a>
|
||
<ul>
|
||
<li><a href="#org935f2df">3.15.1. resize windows by keyboard</a></li>
|
||
<li><a href="#org7e93a56">3.15.2. switch windows with MS-WINDOWS key</a></li>
|
||
<li><a href="#org906465d">3.15.3. M-o switch window or buffer</a></li>
|
||
<li><a href="#org66da4c5">3.15.4. Split window to 4 parts</a></li>
|
||
<li><a href="#org6d56a82">3.15.5. Remember and Restore Window Configurations - winner mode</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#org01d67e0">3.16. re-read a modified buffer</a></li>
|
||
<li><a href="#org4648335">3.17. global TAB/Indent config</a></li>
|
||
<li><a href="#org3a88b30">3.18. handy aliases</a></li>
|
||
<li><a href="#org8bc77eb">3.19. various settings</a></li>
|
||
<li><a href="#orga44cd0d">3.20. load imenu</a></li>
|
||
<li><a href="#orgbda9640">3.21. copy/paste Config</a></li>
|
||
<li><a href="#org2474b30">3.22. use more mem</a></li>
|
||
<li><a href="#org6d2284c">3.23. better file name completion</a></li>
|
||
<li><a href="#orgc1abe99">3.24. abbreviations</a></li>
|
||
<li><a href="#orgca0150d">3.25. meaningful names for buffers with the same name</a></li>
|
||
<li><a href="#orgee3fb58">3.26. packages</a></li>
|
||
<li><a href="#orgd79d926">3.27. My own global variables</a></li>
|
||
<li><a href="#org5be14e0">3.28. More scratch space</a>
|
||
<ul>
|
||
<li><a href="#orgab1558c">3.28.1. Text scratch</a></li>
|
||
<li><a href="#orge9b0276">3.28.2. Autoscratch</a></li>
|
||
<li><a href="#orgff5b268">3.28.3. Persistent Scratch</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#org0d57f72">3.29. Recenter config</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#org230c05f">4. Global Key Bindings</a>
|
||
<ul>
|
||
<li><a href="#org48a58c3">4.1. c-h != delete</a></li>
|
||
<li><a href="#org9bc119b">4.2. general keys (re-)mappings</a></li>
|
||
<li><a href="#orgdfb8a0b">4.3. display a list of my own global key bindings and aliases</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#org6077906">5. Productivity Functions</a>
|
||
<ul>
|
||
<li><a href="#org46af389">5.1. goto line with tmp line numbers</a></li>
|
||
<li><a href="#org33c2fcc">5.2. invert fore- and background</a></li>
|
||
<li><a href="#org446659c">5.3. Some useful bindings for Home and End keys Hit the key once to</a></li>
|
||
<li><a href="#org4b0f1f5">5.4. percent function</a></li>
|
||
<li><a href="#orgd7e449d">5.5. Simulate vi's % function</a></li>
|
||
<li><a href="#org7e9782e">5.6. Move region</a></li>
|
||
<li><a href="#orgec73dcb">5.7. comment-uncomment region with one key binding</a></li>
|
||
<li><a href="#org8299554">5.8. search for symbol at point</a></li>
|
||
<li><a href="#org55919f4">5.9. Window Margin</a></li>
|
||
<li><a href="#org221e573">5.10. Fill and justify a paragraph</a></li>
|
||
<li><a href="#org40694bc">5.11. Make a read-only copy of the current buffer</a></li>
|
||
<li><a href="#org4adebb6">5.12. Cleanup, close all windows and kill all buffers</a></li>
|
||
<li><a href="#orgf8ad0ea">5.13. Cleanup current buffer</a></li>
|
||
<li><a href="#orga01c2ff">5.14. Better newline(s)</a></li>
|
||
<li><a href="#org0cd245d">5.15. Mouse Rectangle</a></li>
|
||
<li><a href="#org59840bb">5.16. DOS <=> UNIX conversion helpers</a></li>
|
||
<li><a href="#org4cec669">5.17. helper do add the same thing to multiple mode hooks</a></li>
|
||
<li><a href="#org9c54c41">5.18. helper to catch load errors</a></li>
|
||
<li><a href="#org6afe5c9">5.19. Alignment Wrappers</a></li>
|
||
<li><a href="#orgedcd3ca">5.20. String Helpers</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#org1dfb33e">6. Modes</a>
|
||
<ul>
|
||
<li><a href="#org95b26d6">6.1. Programming Languages</a>
|
||
<ul>
|
||
<li><a href="#org5998720">6.1.1. VALA</a></li>
|
||
<li><a href="#org8eeaed9">6.1.2. python mode</a></li>
|
||
<li><a href="#org58f4124">6.1.3. cperl mode</a></li>
|
||
<li><a href="#orgdf28519">6.1.4. Paredit for lisp only</a></li>
|
||
<li><a href="#org8de0669">6.1.5. ETAGS</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#org31fbc8f">6.2. Text Modes</a>
|
||
<ul>
|
||
<li><a href="#orgc29524b">6.2.1. sgml</a></li>
|
||
<li><a href="#orgd9ccd6e">6.2.2. web-mode (JS, HTML, CSS combined)</a></li>
|
||
<li><a href="#org867c450">6.2.3. Cisco Mode</a></li>
|
||
<li><a href="#org91acd58">6.2.4. Markdown</a></li>
|
||
<li><a href="#org9f8e50c">6.2.5. POD mode</a></li>
|
||
<li><a href="#org9f60fba">6.2.6. conf-mode</a></li>
|
||
<li><a href="#org155a6ed">6.2.7. Config::General mode</a></li>
|
||
<li><a href="#orge4155f1">6.2.8. Xmodmap Mode</a></li>
|
||
<li><a href="#org82aa168">6.2.9. MMM Mode</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#orgae84f93">6.3. Text Manupilation</a>
|
||
<ul>
|
||
<li><a href="#org5689377">6.3.1. expand-region</a></li>
|
||
<li><a href="#org3300d2d">6.3.2. Mark, Copy, Yank Things</a></li>
|
||
<li><a href="#orgebad629">6.3.3. change-inner</a></li>
|
||
<li><a href="#org0b6aa5e">6.3.4. Rotate text</a></li>
|
||
<li><a href="#org2969fa1">6.3.5. Word wrapping</a></li>
|
||
<li><a href="#org6f8cf6d">6.3.6. Viking Mode</a></li>
|
||
<li><a href="#org8d93358">6.3.7. HTMLize</a></li>
|
||
<li><a href="#orga3c41d1">6.3.8. iEdit (inline edit multiple searches)</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#orga33ad97">6.4. Interactives</a>
|
||
<ul>
|
||
<li><a href="#org9595d4e">6.4.1. eShell stuff, or if interactive stuff is needed, use ansi-term</a></li>
|
||
<li><a href="#orga3317e7">6.4.2. Emacs LISP interactive</a></li>
|
||
<li><a href="#org473a586">6.4.3. el2markdown</a></li>
|
||
<li><a href="#org91e51ed">6.4.4. tramp mode</a></li>
|
||
<li><a href="#orgfa1dc0f">6.4.5. org mode</a></li>
|
||
<li><a href="#org0310264">6.4.6. org table mode</a></li>
|
||
<li><a href="#orga33956a">6.4.7. org mode slideshows</a></li>
|
||
<li><a href="#org10e21a1">6.4.8. outshine mode</a></li>
|
||
<li><a href="#org7c877e0">6.4.9. outline mode</a></li>
|
||
<li><a href="#org1e7fef3">6.4.10. narrowing (no mode but fits here)</a></li>
|
||
<li><a href="#orgd35e948">6.4.11. ANSI-TERM (inferior shells/interpreters and REPLs)</a></li>
|
||
<li><a href="#orgaba9496">6.4.12. Puppet</a></li>
|
||
<li><a href="#orgf7daa64">6.4.13. Novel Mode - Screen Reader</a></li>
|
||
<li><a href="#org35abb1d">6.4.14. Macro Math</a></li>
|
||
<li><a href="#orgfb8cd01">6.4.15. Common-Lisp (SLIME)</a></li>
|
||
<li><a href="#orgcfa2941">6.4.16. INFO Mode</a></li>
|
||
<li><a href="#org36a9d5f">6.4.17. calc et al.</a></li>
|
||
<li><a href="#org9300cfe">6.4.18. MACROs</a></li>
|
||
<li><a href="#orga6e3b07">6.4.19. EWW browser stuff</a></li>
|
||
<li><a href="#org03aad87">6.4.20. Firestarter</a></li>
|
||
<li><a href="#orgca3975f">6.4.21. Tabulated List Mode</a></li>
|
||
<li><a href="#orga46b17d">6.4.22. Help Mode</a></li>
|
||
<li><a href="#org980e6a5">6.4.23. Suggest Mode</a></li>
|
||
<li><a href="#org7610483">6.4.24. Followcursor Mode</a></li>
|
||
<li><a href="#org7b092a3">6.4.25. Magit</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#orga8fa542">6.5. Emacs Interface</a>
|
||
<ul>
|
||
<li><a href="#org3e20186">6.5.1. Parens</a></li>
|
||
<li><a href="#orge60ba1a">6.5.2. highlight todo keywords (such as <i>FIXME</i>)</a></li>
|
||
<li><a href="#org54e4f22">6.5.3. UNDO Tree Mode</a></li>
|
||
<li><a href="#orgec0c8fd">6.5.4. Smarter M-x Mode (smex)</a></li>
|
||
<li><a href="#orgcf647f0">6.5.5. Which Func</a></li>
|
||
<li><a href="#org584e613">6.5.6. Show current-line in the Fringe</a></li>
|
||
<li><a href="#orga0ca64a">6.5.7. Recent Files</a></li>
|
||
<li><a href="#orgb8fc2b7">6.5.8. IDO mode</a></li>
|
||
<li><a href="#org6e0b76a">6.5.9. Save cursor position</a></li>
|
||
<li><a href="#orgce37712">6.5.10. DoReMi experimentation</a></li>
|
||
<li><a href="#org6b0a518">6.5.11. Hightligt TABs</a></li>
|
||
<li><a href="#orgd4299b6">6.5.12. Browse kill-ring</a></li>
|
||
<li><a href="#orgf4defa3">6.5.13. goto-last-change</a></li>
|
||
<li><a href="#org471bd24">6.5.14. Bookmarks</a></li>
|
||
<li><a href="#orgc529521">6.5.15. which-key</a></li>
|
||
<li><a href="#org14bf47f">6.5.16. iBuffer mode</a></li>
|
||
<li><a href="#org9c86f40">6.5.17. Printing</a></li>
|
||
<li><a href="#org10a4c82">6.5.18. Beacon mode (pointer blink)</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#org567c4c3">6.6. mode-line setup (must be the last mode)</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#orgb2cfcf2">7. Emacs Autoconfig / Customizegroup stuff</a>
|
||
<ul>
|
||
<li><a href="#org87de9e5">7.1. font faces</a></li>
|
||
<li><a href="#org8a8b4ae">7.2. variables</a></li>
|
||
<li><a href="#orgfc836a8">7.3. done</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<p>
|
||
Toms Emacs Config - portable - version (20170731.01) -*-emacs-lisp-*-
|
||
</p>
|
||
<div id="outline-container-orgb77bae2" class="outline-2">
|
||
<h2 id="orgb77bae2"><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-orgf398ee1" class="outline-2">
|
||
<h2 id="orgf398ee1"><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-org4fa592a" class="outline-3">
|
||
<h3 id="org4fa592a"><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-<up|down> 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 => 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 <C-left> in org mode</li>
|
||
<li><C-up|down> 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…) 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,
|
||
<ret> repeats, a repeats til EOF, q aborts, e enter macro
|
||
(with completion)</li>
|
||
<li>C-x C-s on * elmacro … * 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-<ret> and C-S-<ret></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: <ret> 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 => 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-<down|up> 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>
|
||
<li>fix python loading</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170711.01:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>fixed outshine: only loaded with elisp</li>
|
||
<li>fixed tvd-outshine-jump: use imenu if outside outshine</li>
|
||
<li>fixed kill-all-buffers: restore scratch after killing all buffers</li>
|
||
<li>do not ask to save abbrevs on exit anymore</li>
|
||
<li>reformat changelog</li>
|
||
<li>rm open-line-below</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170711.02:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>fixed POD abbrevs, added way to move point after expansion</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170712.01:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>disabled org mode superscripts</li>
|
||
<li>+ winner mode</li>
|
||
<li>org mode 'code new binding: C-c 0</li>
|
||
<li>fixed emacs-change-log</li>
|
||
<li>added tvd-outshine-end-of-section incl speed command</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170712.02:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>fixed tvd-outshine-end-of-section, it's way faster now and
|
||
works without narrowing.</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170714.01:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>fixed pod-mode abbrev cursor jumping if no jump pos exists</li>
|
||
<li>fix initial-buffer-choice</li>
|
||
<li>added mmm-mode</li>
|
||
<li>added here-doc support to config-general using mmm-mode</li>
|
||
<li>made outline faces a little bigger, added face for level 4</li>
|
||
<li>rm initial buffer, doesnt open commandline files anymore with this</li>
|
||
<li>finally initial buffer works, opens command line file or text scratch</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170715.01:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>no more MMM for C::G, destroys indent</li>
|
||
<li>incorporated my C::G customizations, Steve Purcell removed from
|
||
it because inappropriate,
|
||
<a href="https://github.com/TLINDEN/config-general-mode/commit/d7e8323">see d7e8323</a></li>
|
||
<li>fixed autoscratch hook</li>
|
||
<li>add scratch alias</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170718.01:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>better autoscratch config</li>
|
||
<li>added persistent-scratch mode</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170719.01:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>fixed electric-indent in autoscratch config</li>
|
||
<li>use my own autoscratch triggers</li>
|
||
<li>kill-all-buffers now uses 'autoscratch-buffer</li>
|
||
<li>renamce autoscratch</li>
|
||
<li>tuned recenter-positions</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170722.01:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>added followcursor-mode</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170724.01:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>added ido completion for tramp hostnames</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170725.01:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>autoscratch lambda=>progn</li>
|
||
<li>added sort-table-ip[desc] and fixed auto-alignment so
|
||
that ip's are left aligned</li>
|
||
<li>+req org-table</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170727.01:
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>+magit</li>
|
||
<li>configured magit dirs</li>
|
||
<li>+magit ido</li>
|
||
<li>fix magit info dir</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170730.01
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>+some magit navigation keys</li>
|
||
</ul>
|
||
|
||
<p>
|
||
20170731.01
|
||
</p>
|
||
<ul class="org-ul">
|
||
<li>do not load magit on w32</li>
|
||
<li>Always call `magit-status' with prefix arg</li>
|
||
<li>do bigger jumps in magit with just C-<up|down></li>
|
||
<li>add "ls" to magit-status leading to dired</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org51d48e8" class="outline-3">
|
||
<h3 id="org51d48e8"><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>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>
|
||
<li>check <a href="https://github.com/Malabarba/speed-of-thought-lisp">https://github.com/Malabarba/speed-of-thought-lisp</a></li>
|
||
<li><a href="https://github.com/tkf/emacs-jedi">https://github.com/tkf/emacs-jedi</a></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org119a78e" class="outline-3">
|
||
<h3 id="org119a78e"><span class="section-number-3">2.3</span> Parking Lot / Snippets</h3>
|
||
<div class="outline-text-3" id="text-2-3">
|
||
<p>
|
||
Snippets which maybe of use in the future
|
||
</p>
|
||
</div>
|
||
|
||
<div id="outline-container-org99546a6" class="outline-4">
|
||
<h4 id="org99546a6"><span class="section-number-4">2.3.1</span> buffer-local hook</h4>
|
||
<div class="outline-text-4" id="text-2-3-1">
|
||
<p>
|
||
(with-current-buffer (get-buffer "<b>scratch</b>")
|
||
(add-hook 'kill-buffer-hook
|
||
(lambda () (error "DENIED! don't kill my precious <b>scratch</b>!!"))
|
||
nil t))
|
||
</p>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-org8afe11d" class="outline-3">
|
||
<h3 id="org8afe11d"><span class="section-number-3">2.4</span> .emacs config version</h3>
|
||
<div class="outline-text-3" id="text-2-4">
|
||
<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;">"20170731.01"</span>)
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org1ea8c11" class="outline-2">
|
||
<h2 id="org1ea8c11"><span class="section-number-2">3</span> System Specifics</h2>
|
||
<div class="outline-text-2" id="text-3">
|
||
</div><div id="outline-container-orgc9b8814" class="outline-3">
|
||
<h3 id="orgc9b8814"><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-orgab48572" class="outline-3">
|
||
<h3 id="orgab48572"><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-org575984f" class="outline-3">
|
||
<h3 id="org575984f"><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-orgc80e8bc" class="outline-3">
|
||
<h3 id="orgc80e8bc"><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;">&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-org28a4abe" class="outline-3">
|
||
<h3 id="org28a4abe"><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-org50f2cfa" class="outline-3">
|
||
<h3 id="org50f2cfa"><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-orge8cf187" class="outline-3">
|
||
<h3 id="orge8cf187"><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-orge96e8ed" class="outline-3">
|
||
<h3 id="orge96e8ed"><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-orga57394f" class="outline-3">
|
||
<h3 id="orga57394f"><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-orgfb1d55e" class="outline-3">
|
||
<h3 id="orgfb1d55e"><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-orgf8540e4" class="outline-3">
|
||
<h3 id="orgf8540e4"><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-org0e738a6" class="outline-3">
|
||
<h3 id="org0e738a6"><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-org9feedab" class="outline-3">
|
||
<h3 id="org9feedab"><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>()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(byte-recompile-directory tvd-lisp-dir 0))
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-org0e100da" class="outline-3">
|
||
<h3 id="org0e100da"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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-org554270e" class="outline-3">
|
||
<h3 id="org554270e"><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-org935f2df" class="outline-4">
|
||
<h4 id="org935f2df"><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, <ret> 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-org7e93a56" class="outline-4">
|
||
<h4 id="org7e93a56"><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-org906465d" class="outline-4">
|
||
<h4 id="org906465d"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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->RDP->VNC->X11->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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">cond</span> ((<span style="color: #0000ff;">not</span> (> (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> (< 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 <up> and
|
||
<down> 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-org66da4c5" class="outline-4">
|
||
<h4 id="org66da4c5"><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> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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 id="outline-container-org6d56a82" class="outline-4">
|
||
<h4 id="org6d56a82"><span class="section-number-4">3.15.5</span> Remember and Restore Window Configurations - winner mode</h4>
|
||
<div class="outline-text-4" id="text-3-15-5">
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(winner-mode 1)
|
||
</pre>
|
||
</div>
|
||
|
||
<p>
|
||
keybindings: C-c left - winner-undo
|
||
keybindings: C-c right - winner-redo
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org01d67e0" class="outline-3">
|
||
<h3 id="org01d67e0"><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-<f5>"</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;">&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>
|
||
(<span style="color: #0000ff;">interactive</span> <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-org4648335" class="outline-3">
|
||
<h3 id="org4648335"><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">(<span style="color: #0000ff;">setq-default</span> indent-tabs-mode nil)
|
||
(<span style="color: #0000ff;">setq-default</span> 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 (<span style="color: #0000ff;">quote</span> (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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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> '(lambda() (<span style="color: #0000ff;">setq</span> indent-tabs-mode t)))
|
||
</pre>
|
||
</div>
|
||
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-org3a88b30" class="outline-3">
|
||
<h3 id="org3a88b30"><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 <ret> 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-org8bc77eb" class="outline-3">
|
||
<h3 id="org8bc77eb"><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">(<span style="color: #0000ff;">setq-default</span> 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-orga44cd0d" class="outline-3">
|
||
<h3 id="orga44cd0d"><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-orgbda9640" class="outline-3">
|
||
<h3 id="orgbda9640"><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-<up|down>)</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;">"<up-mouse-2>"</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-org2474b30" class="outline-3">
|
||
<h3 id="org2474b30"><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-org6d2284c" class="outline-3">
|
||
<h3 id="org6d2284c"><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-orgc1abe99" class="outline-3">
|
||
<h3 id="orgc1abe99"><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…
|
||
</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;">"&ouml;"</span> nil 0)
|
||
(<span style="color: #ff0000;">"ue"</span> <span style="color: #ff0000;">"&uuml;"</span> nil 0)
|
||
(<span style="color: #ff0000;">"ae"</span> <span style="color: #ff0000;">"&auml;"</span> nil 0)
|
||
(<span style="color: #ff0000;">"Oe"</span> <span style="color: #ff0000;">"&Ouml;"</span> nil 0)
|
||
(<span style="color: #ff0000;">"Ue"</span> <span style="color: #ff0000;">"&Uuml;"</span> nil 0)
|
||
(<span style="color: #ff0000;">"Ae"</span> <span style="color: #ff0000;">"&Auml;"</span> nil 0)
|
||
(<span style="color: #ff0000;">"<li>"</span> <span style="color: #ff0000;">"<li> </li>"</span> nil 0)
|
||
(<span style="color: #ff0000;">"<ul>"</span> <span style="color: #ff0000;">"<ul> </ul>"</span> nil 0)
|
||
))
|
||
</pre>
|
||
</div>
|
||
|
||
<p>
|
||
do NOT ask to save abbrevs on exit
|
||
</p>
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> save-abbrevs nil)
|
||
</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-orgca0150d" class="outline-3">
|
||
<h3 id="orgca0150d"><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-orgee3fb58" class="outline-3">
|
||
<h3 id="orgee3fb58"><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>()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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> (< 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-orgd79d926" class="outline-3">
|
||
<h3 id="orgd79d926"><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-org5be14e0" class="outline-3">
|
||
<h3 id="org5be14e0"><span class="section-number-3">3.28</span> More scratch space</h3>
|
||
<div class="outline-text-3" id="text-3-28">
|
||
</div><div id="outline-container-orgab1558c" class="outline-4">
|
||
<h4 id="orgab1558c"><span class="section-number-4">3.28.1</span> Text scratch</h4>
|
||
<div class="outline-text-4" id="text-3-28-1">
|
||
<p>
|
||
Sometimes I need a text mode scratch buffer while scratch is
|
||
already in use. So let's prepare one. I also add a buffer hook so that
|
||
this never gets deleted, but cleaned instead.
|
||
</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 id="outline-container-orge9b0276" class="outline-4">
|
||
<h4 id="orge9b0276"><span class="section-number-4">3.28.2</span> Autoscratch</h4>
|
||
<div class="outline-text-4" id="text-3-28-2">
|
||
<p>
|
||
use autoscratch otherwise
|
||
<a href="https://github.com/TLINDEN/autoscratch">autoscratch github</a>
|
||
</p>
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'autoscratch-mode</span>)
|
||
(<span style="color: #0000ff;">setq</span> initial-major-mode <span style="color: #ff00ff;">'autoscratch-mode</span>)
|
||
(add-hook <span style="color: #ff00ff;">'autoscratch-mode-hook</span> '(<span style="color: #0000ff;">lambda</span> ()
|
||
(<span style="color: #0000ff;">setq</span> autoscratch-triggers-alist
|
||
'((<span style="color: #ff0000;">"[(;]"</span> . (<span style="color: #0000ff;">progn</span>
|
||
(emacs-lisp-mode)
|
||
(electric-indent-local-mode t)))
|
||
(<span style="color: #ff0000;">"#"</span> . (<span style="color: #0000ff;">progn</span>
|
||
(config-general-mode)
|
||
(electric-indent-local-mode t)))
|
||
(<span style="color: #ff0000;">"[-a-zA-Z0-9]"</span> . (text-mode))
|
||
(<span style="color: #ff0000;">"/"</span> . (c-mode))
|
||
(<span style="color: #ff0000;">"*"</span> . (<span style="color: #0000ff;">progn</span> (insert <span style="color: #ff0000;">" "</span>) (org-mode)))
|
||
(<span style="color: #ff0000;">"."</span> . (fundamental-mode)))
|
||
autoscratch-trigger-on-first-char t)
|
||
(electric-indent-local-mode nil)
|
||
))
|
||
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'scratch</span> <span style="color: #ff00ff;">'autoscratch-buffer</span>)
|
||
</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-orgff5b268" class="outline-4">
|
||
<h4 id="orgff5b268"><span class="section-number-4">3.28.3</span> Persistent Scratch</h4>
|
||
<div class="outline-text-4" id="text-3-28-3">
|
||
<p>
|
||
I also like to be scratch buffers persistent with
|
||
<a href="https://github.com/Fanael/persistent-scratch">persistent-scratch</a>
|
||
</p>
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'persistent-scratch</span>)
|
||
(<span style="color: #0000ff;">setq</span> persistent-scratch-save-file (expand-file-name <span style="color: #ff0000;">"scratches.el"</span> user-init-dir))
|
||
(persistent-scratch-setup-default)
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-autoscratch-p</span> ()
|
||
<span style="color: #cd6600;">"Return non-nil if the current buffer is a scratch buffer"</span>
|
||
(string-match <span style="color: #ff0000;">"scratch*"</span> (buffer-name)))
|
||
|
||
(<span style="color: #0000ff;">setq</span> persistent-scratch-scratch-buffer-p-function <span style="color: #ff00ff;">'tvd-autoscratch-p</span>)
|
||
</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org0d57f72" class="outline-3">
|
||
<h3 id="org0d57f72"><span class="section-number-3">3.29</span> Recenter config</h3>
|
||
<div class="outline-text-3" id="text-3-29">
|
||
<p>
|
||
<a href="http://oremacs.com/2015/03/28/recenter/">via abo abo</a>
|
||
</p>
|
||
|
||
<p>
|
||
However, I set the first position to 1, which causes the window to
|
||
be recentered on the second line, that is, I can see one line above
|
||
the current one. It works the same with bottom, which I intend, but
|
||
I think this is a recenter calculation bug.
|
||
</p>
|
||
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> recenter-positions '(1 middle bottom))
|
||
</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org230c05f" class="outline-2">
|
||
<h2 id="org230c05f"><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-org48a58c3" class="outline-3">
|
||
<h3 id="org48a58c3"><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-org9bc119b" class="outline-3">
|
||
<h3 id="org9bc119b"><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;">"<backtab>"</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;">"<f9>"</span>) <span style="color: #ff00ff;">'html-mode</span>)
|
||
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"<delete>"</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;">"<backspace>"</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-<delete>"</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-<backspace>"</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-<delete>"</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-<backspace>"</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-orgdfb8a0b" class="outline-3">
|
||
<h3 id="orgdfb8a0b"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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)
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(show-definition <span style="color: #ff0000;">"^(global-set-key"</span>))
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">show-aliases</span>()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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-org6077906" class="outline-2">
|
||
<h2 id="org6077906"><span class="section-number-2">5</span> Productivity Functions</h2>
|
||
<div class="outline-text-2" id="text-5">
|
||
<hr />
|
||
</div>
|
||
<div id="outline-container-org46af389" class="outline-3">
|
||
<h3 id="org46af389"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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;">"<f7>"</span>) <span style="color: #ff00ff;">'goto-line-with-feedback</span>)
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-org33c2fcc" class="outline-3">
|
||
<h3 id="org33c2fcc"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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-org446659c" class="outline-3">
|
||
<h3 id="org446659c"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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;">"<home>"</span>) <span style="color: #ff00ff;">'pc-keys-home</span>)
|
||
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"<end>"</span>) <span style="color: #ff00ff;">'pc-keys-end</span>)
|
||
</pre>
|
||
</div>
|
||
|
||
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-org4b0f1f5" class="outline-3">
|
||
<h3 id="org4b0f1f5"><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>
|
||
(<span style="color: #0000ff;">interactive</span> <span style="color: #ff0000;">"nProzent: "</span>)
|
||
(<span style="color: #0000ff;">if</span> (> (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;">"<f8>"</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-orgd7e449d" class="outline-3">
|
||
<h3 id="orgd7e449d"><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>
|
||
(<span style="color: #0000ff;">interactive</span> <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-org7e9782e" class="outline-3">
|
||
<h3 id="org7e9782e"><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> (< (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>
|
||
(<span style="color: #0000ff;">interactive</span> <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>
|
||
(<span style="color: #0000ff;">interactive</span> <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-<up>"</span>) <span style="color: #ff00ff;">'move-lines-up</span>)
|
||
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"M-<down>"</span>) <span style="color: #ff00ff;">'move-lines-down</span>)
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-orgec73dcb" class="outline-3">
|
||
<h3 id="orgec73dcb"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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-org8299554" class="outline-3">
|
||
<h3 id="org8299554"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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> (< 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-org55919f4" class="outline-3">
|
||
<h3 id="org55919f4"><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>
|
||
(<span style="color: #0000ff;">interactive</span> <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-org221e573" class="outline-3">
|
||
<h3 id="org221e573"><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 <ret> 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>()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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-org40694bc" class="outline-3">
|
||
<h3 id="org40694bc"><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;">"<"</span> (number-to-string copy-counter) <span style="color: #ff0000;">">"</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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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-org4adebb6" class="outline-3">
|
||
<h3 id="org4adebb6"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">when</span> (y-or-n-p <span style="color: #ff0000;">"Close all windows and kill all buffers?"</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))
|
||
(<span style="color: #0000ff;">with-current-buffer</span> (get-buffer-create <span style="color: #ff0000;">"*text*"</span>)
|
||
(text-mode))
|
||
(autoscratch-buffer)))
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-orgf8ad0ea" class="outline-3">
|
||
<h3 id="orgf8ad0ea"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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-orga01c2ff" class="outline-3">
|
||
<h3 id="orga01c2ff"><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> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(end-of-line)
|
||
(newline)
|
||
(indent-for-tab-command))
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">open-line-above</span> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(end-of-line)
|
||
(beginning-of-line)
|
||
(newline)
|
||
(forward-line -1)
|
||
(indent-for-tab-command))
|
||
</pre>
|
||
</div>
|
||
|
||
<p>
|
||
disabled, interferes with modes.
|
||
</p>
|
||
|
||
<p>
|
||
(global-set-key (kbd "<C-return>") 'open-line-below)
|
||
</p>
|
||
|
||
<p>
|
||
(global-set-key (kbd "<C-S-return>") 'open-line-above)
|
||
</p>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-org0cd245d" class="outline-3">
|
||
<h3 id="org0cd245d"><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)
|
||
(<span style="color: #0000ff;">interactive</span> <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-<down-mouse-1>"</span>) <span style="color: #ff00ff;">'mouse-start-rectangle</span>)
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-org59840bb" class="outline-3">
|
||
<h3 id="org59840bb"><span class="section-number-3">5.16</span> DOS <=> 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> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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-org4cec669" class="outline-3">
|
||
<h3 id="org4cec669"><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-org9c54c41" class="outline-3">
|
||
<h3 id="org9c54c41"><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;">&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-org6afe5c9" class="outline-3">
|
||
<h3 id="org6afe5c9"><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;">&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>
|
||
(<span style="color: #0000ff;">interactive</span> <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)
|
||
(<span style="color: #0000ff;">interactive</span> <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)
|
||
(<span style="color: #0000ff;">interactive</span> <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-orgedcd3ca" class="outline-3">
|
||
<h3 id="orgedcd3ca"><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)
|
||
(<span style="color: #0000ff;">push</span> (<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> ((>= (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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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-org1dfb33e" class="outline-2">
|
||
<h2 id="org1dfb33e"><span class="section-number-2">6</span> Modes</h2>
|
||
<div class="outline-text-2" id="text-6">
|
||
</div><div id="outline-container-org95b26d6" class="outline-3">
|
||
<h3 id="org95b26d6"><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-org5998720" class="outline-4">
|
||
<h4 id="org5998720"><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-org8eeaed9" class="outline-4">
|
||
<h4 id="org8eeaed9"><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">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'python</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">function</span>
|
||
(<span style="color: #0000ff;">lambda</span>()
|
||
(local-set-key [delete] <span style="color: #ff00ff;">'py-electric-delete</span>)
|
||
(<span style="color: #0000ff;">setq-default</span> 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-org58f4124" class="outline-4">
|
||
<h4 id="org58f4124"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span> <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;">"&"</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;">"&"</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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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)
|
||
(<span style="color: #0000ff;">interactive</span> <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>
|
||
(<span style="color: #0000ff;">function</span>
|
||
(<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-orgdf28519" class="outline-4">
|
||
<h4 id="orgdf28519"><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;">"<M-up>"</span>) nil)
|
||
(define-key paredit-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"<M-down>"</span>) nil)))
|
||
</pre>
|
||
</div>
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org8de0669" class="outline-4">
|
||
<h4 id="org8de0669"><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 …
|
||
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>
|
||
(<span style="color: #0000ff;">interactive</span> <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;">"€"</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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(tags-completion-table)
|
||
(<span style="color: #0000ff;">let</span> (tag-names)
|
||
(mapatoms (<span style="color: #0000ff;">lambda</span> (x)
|
||
(<span style="color: #0000ff;">push</span> (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-org31fbc8f" class="outline-3">
|
||
<h3 id="org31fbc8f"><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-orgc29524b" class="outline-4">
|
||
<h4 id="orgc29524b"><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-orgd9ccd6e" class="outline-4">
|
||
<h4 id="orgd9ccd6e"><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>()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(web-mode-element-wrap <span style="color: #ff0000;">"p"</span>))
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">html-insert-li</span>()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(web-mode-element-wrap <span style="color: #ff0000;">"li"</span>))
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">html-insert-ul</span>()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(web-mode-element-wrap <span style="color: #ff0000;">"ul"</span>))
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">html-insert-b</span>()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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)
|
||
(<span style="color: #0000ff;">interactive</span> <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;">"<ul>\n"</span>)
|
||
(<span style="color: #0000ff;">while</span> lines
|
||
(insert <span style="color: #ff0000;">" <li>"</span>)
|
||
(insert (<span style="color: #0000ff;">pop</span> lines))
|
||
(insert <span style="color: #ff0000;">"</li>\n"</span>))
|
||
(insert <span style="color: #ff0000;">"</ul>\n"</span>)
|
||
)))
|
||
</pre>
|
||
</div>
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org867c450" class="outline-4">
|
||
<h4 id="org867c450"><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-org91acd58" class="outline-4">
|
||
<h4 id="org91acd58"><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-org9f8e50c" class="outline-4">
|
||
<h4 id="org9f8e50c"><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>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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<"</span> CHAR))
|
||
(goto-char (region-end))
|
||
(insert <span style="color: #ff0000;">">"</span>)))
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">pod-bold</span>()
|
||
<span style="color: #cd6600;">"bold text in outline mode"</span>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(tvd-outline-emphasize ?C))
|
||
</pre>
|
||
</div>
|
||
|
||
<p>
|
||
enhance abbrevs and jump into expanded area to the
|
||
$ character (if it exists), which it also removes
|
||
</p>
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> tvd-abbrev-pos 0)
|
||
(advice-add <span style="color: #ff00ff;">'expand-abbrev</span> <span style="color: #8a2be2;">:before</span>
|
||
'(<span style="color: #0000ff;">lambda</span> () (<span style="color: #0000ff;">setq</span> tvd-abbrev-pos (point))))
|
||
(advice-add <span style="color: #ff00ff;">'expand-abbrev</span> <span style="color: #8a2be2;">:after</span>
|
||
'(<span style="color: #0000ff;">lambda</span> ()
|
||
(<span style="color: #0000ff;">ignore-errors</span>
|
||
(<span style="color: #0000ff;">when</span> (re-search-backward <span style="color: #ff0000;">"\\$"</span> (- tvd-abbrev-pos 0))
|
||
(delete-char 1)))))
|
||
</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;">tune syntax table</span>
|
||
(modify-syntax-entry ?= <span style="color: #ff0000;">"w"</span> pod-mode-syntax-table)
|
||
|
||
<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)
|
||
(<span style="color: #ff0000;">"=over"</span> . 5)
|
||
(<span style="color: #ff0000;">"=item"</span> . 6)
|
||
(<span style="color: #ff0000;">"=begin"</span> . 5)
|
||
(<span style="color: #ff0000;">"=pod"</span> . 5)
|
||
))
|
||
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">outline alone, however, works well</span>
|
||
(outline-minor-mode)
|
||
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">my own abbrevs for POD using mode-specific abbrev table</span>
|
||
(define-abbrev-table <span style="color: #ff00ff;">'pod-mode-abbrev-table</span> '(
|
||
(<span style="color: #ff0000;">"=o"</span> <span style="color: #ff0000;">"=over\n\n=item *$\n\n=back\n\n"</span>)
|
||
(<span style="color: #ff0000;">"=i"</span> <span style="color: #ff0000;">"=item "</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;">"=c"</span> <span style="color: #ff0000;">"=cut"</span>)
|
||
(<span style="color: #ff0000;">"=b"</span> <span style="color: #ff0000;">"=begin"</span>)
|
||
(<span style="color: #ff0000;">"=e"</span> <span style="color: #ff0000;">"=end"</span>)
|
||
(<span style="color: #ff0000;">"b"</span> <span style="color: #ff0000;">"B<$>"</span>)
|
||
(<span style="color: #ff0000;">"c"</span> <span style="color: #ff0000;">"C<$>"</span>)
|
||
(<span style="color: #ff0000;">"l"</span> <span style="color: #ff0000;">"L<$>"</span>)
|
||
(<span style="color: #ff0000;">"i"</span> <span style="color: #ff0000;">"I<$>"</span>)
|
||
(<span style="color: #ff0000;">"e"</span> <span style="color: #ff0000;">"E<$>"</span>)
|
||
(<span style="color: #ff0000;">"f"</span> <span style="color: #ff0000;">"F<$>"</span>))
|
||
<span style="color: #cd6600;">"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 1)
|
||
|
||
<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-org9f60fba" class="outline-4">
|
||
<h4 id="org9f60fba"><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-org155a6ed" class="outline-4">
|
||
<h4 id="org155a6ed"><span class="section-number-4">6.2.7</span> Config::General mode</h4>
|
||
<div class="outline-text-4" id="text-6-2-7">
|
||
</div><ol class="org-ol"><li><a id="org9032199"></a>Config and doc<br /><div class="outline-text-5" id="text-6-2-7-1">
|
||
<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>)
|
||
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'sh-script</span>)
|
||
</pre>
|
||
</div>
|
||
</div></li>
|
||
|
||
<li><a id="org4e9d464"></a>Convenicence Wrappers<br /><div class="outline-text-5" id="text-6-2-7-2">
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">config-general-completion-at-point</span> ()
|
||
<span style="color: #cd6600;">"Complete word at point using hippie-expand, if not on a comment."</span>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">when</span> (looking-back <span style="color: #ff0000;">"[-%$_a-zA-Z0-9]"</span>)
|
||
(<span style="color: #0000ff;">unless</span> (<span style="color: #0000ff;">eq</span> (get-text-property (point) <span style="color: #ff00ff;">'face</span>) <span style="color: #ff00ff;">'font-lock-comment-face</span>)
|
||
(hippie-expand nil))))
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">config-general-do-electric-tab</span> ()
|
||
<span style="color: #cd6600;">"Enter a <TAB> or goto current indentation."</span>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">eq</span> (point) (line-end-position))
|
||
(indent-for-tab-command)
|
||
(back-to-indentation)))
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">config-general-tab-or-expand</span> ()
|
||
<span style="color: #cd6600;">"Do electric TAB or completion depending where point is.</span>
|
||
|
||
<span style="color: #cd6600;">This is just a convenience function, which can be mapped</span>
|
||
<span style="color: #cd6600;">to `</span><span style="color: #cd6600;">tab</span><span style="color: #cd6600;">' by the user. .Not in use by default."</span>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">unless</span> (config-general-completion-at-point)
|
||
(config-general-do-electric-tab)))
|
||
</pre>
|
||
</div>
|
||
|
||
<p>
|
||
<i>FIXME</i>: Use this patched version for older emacsen and the default
|
||
for version which contain the patch (if any, ever).
|
||
</p>
|
||
|
||
<p>
|
||
The original function try-expand-dabbrev-all-buffers doesn't work
|
||
correctly, it ignores a buffer-local configuration of the variables
|
||
hippie-expand-only-buffers and hippie-expand-ignore-buffers. This
|
||
is the patched version of the function.
|
||
</p>
|
||
|
||
<p>
|
||
Bugreport: <a href="http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27501">http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27501</a>
|
||
</p>
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">config-general--try-expand-dabbrev-all-buffers</span> (old)
|
||
<span style="color: #cd6600;">"Try to expand word \"dynamically\", searching all other buffers.</span>
|
||
<span style="color: #cd6600;">The argument OLD has to be nil the first call of this function, and t</span>
|
||
<span style="color: #cd6600;">for subsequent calls (for further possible expansions of the same</span>
|
||
<span style="color: #cd6600;">string). It returns t if a new expansion is found, nil otherwise."</span>
|
||
(<span style="color: #0000ff;">let</span> ((expansion ())
|
||
(buf (current-buffer))
|
||
(orig-case-fold-search case-fold-search)
|
||
(heib hippie-expand-ignore-buffers)
|
||
(heob hippie-expand-only-buffers)
|
||
)
|
||
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> old)
|
||
(<span style="color: #0000ff;">progn</span>
|
||
(he-init-string (he-dabbrev-beg) (point))
|
||
(<span style="color: #0000ff;">setq</span> he-search-bufs (buffer-list))
|
||
(<span style="color: #0000ff;">setq</span> he-searched-n-bufs 0)
|
||
(set-marker he-search-loc 1 (<span style="color: #0000ff;">car</span> he-search-bufs))))
|
||
|
||
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> (equal he-search-string <span style="color: #ff0000;">""</span>))
|
||
(<span style="color: #0000ff;">while</span> (<span style="color: #0000ff;">and</span> he-search-bufs
|
||
(<span style="color: #0000ff;">not</span> expansion)
|
||
(<span style="color: #0000ff;">or</span> (<span style="color: #0000ff;">not</span> hippie-expand-max-buffers)
|
||
(< he-searched-n-bufs hippie-expand-max-buffers)))
|
||
(set-buffer (<span style="color: #0000ff;">car</span> he-search-bufs))
|
||
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">and</span> (<span style="color: #0000ff;">not</span> (<span style="color: #0000ff;">eq</span> (current-buffer) buf))
|
||
(<span style="color: #0000ff;">if</span> heob
|
||
(he-buffer-member heob)
|
||
(<span style="color: #0000ff;">not</span> (he-buffer-member heib))))
|
||
(<span style="color: #0000ff;">save-excursion</span>
|
||
(<span style="color: #0000ff;">save-restriction</span>
|
||
(<span style="color: #0000ff;">if</span> hippie-expand-no-restriction
|
||
(widen))
|
||
(goto-char he-search-loc)
|
||
(<span style="color: #0000ff;">setq</span> expansion
|
||
(<span style="color: #0000ff;">let</span> ((case-fold-search orig-case-fold-search))
|
||
(he-dabbrev-search he-search-string nil)))
|
||
(set-marker he-search-loc (point))
|
||
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> expansion)
|
||
(<span style="color: #0000ff;">progn</span>
|
||
(<span style="color: #0000ff;">setq</span> he-search-bufs (<span style="color: #0000ff;">cdr</span> he-search-bufs))
|
||
(<span style="color: #0000ff;">setq</span> he-searched-n-bufs (1+ he-searched-n-bufs))
|
||
(set-marker he-search-loc 1 (<span style="color: #0000ff;">car</span> he-search-bufs))))))
|
||
(<span style="color: #0000ff;">setq</span> he-search-bufs (<span style="color: #0000ff;">cdr</span> he-search-bufs))
|
||
(set-marker he-search-loc 1 (<span style="color: #0000ff;">car</span> he-search-bufs)))))
|
||
|
||
(set-buffer buf)
|
||
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">not</span> expansion)
|
||
(<span style="color: #0000ff;">progn</span>
|
||
(<span style="color: #0000ff;">if</span> old (he-reset-string))
|
||
())
|
||
(<span style="color: #0000ff;">progn</span>
|
||
(he-substitute-string expansion t)
|
||
t))))
|
||
</pre>
|
||
</div>
|
||
</div></li>
|
||
|
||
<li><a id="org6b08958"></a>Mode Hook<br /><div class="outline-text-5" id="text-6-2-7-3">
|
||
<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;">"<tab>"</span>) <span style="color: #ff00ff;">'config-general-tab-or-expand</span>)
|
||
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">from shell-script-mode, turn << into here-doc</span>
|
||
(sh-electric-here-document-mode 1)
|
||
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">Inserting a brace or quote automatically inserts the matching pair</span>
|
||
(electric-pair-mode t)
|
||
(<span style="color: #0000ff;">setq-local</span> hippie-expand-only-buffers '(config-general-mode))
|
||
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">configure order of expansion functions</span>
|
||
(<span style="color: #0000ff;">if</span> (version< emacs-version <span style="color: #ff0000;">"25.1"</span>)
|
||
(<span style="color: #0000ff;">set</span> (make-local-variable <span style="color: #ff00ff;">'hippie-expand-try-functions-list</span>)
|
||
'(try-expand-dabbrev <span style="color: #006400;">;; </span><span style="color: #006400;">use patched version</span>
|
||
config-general--try-expand-dabbrev-all-buffers
|
||
try-complete-file-name-partially
|
||
try-complete-file-name))
|
||
(<span style="color: #0000ff;">set</span> (make-local-variable <span style="color: #ff00ff;">'hippie-expand-try-functions-list</span>)
|
||
'(try-expand-dabbrev
|
||
try-expand-dabbrev-all-buffers
|
||
try-complete-file-name-partially
|
||
try-complete-file-name)))
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">enable</span>
|
||
(add-hook <span style="color: #ff00ff;">'completion-at-point-functions</span> <span style="color: #ff00ff;">'config-general-completion-at-point</span>)
|
||
)
|
||
)
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div></li></ol>
|
||
</div>
|
||
<div id="outline-container-orge4155f1" class="outline-4">
|
||
<h4 id="orge4155f1"><span class="section-number-4">6.2.8</span> Xmodmap Mode</h4>
|
||
<div class="outline-text-4" id="text-6-2-8">
|
||
<p>
|
||
the shortest mode ever, <a href="https://www.emacswiki.org/emacs/XModMapMode">via emacswiki</a>.
|
||
</p>
|
||
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">define-generic-mode</span> <span style="color: #ff00ff;">'xmodmap-mode</span>
|
||
'(?!)
|
||
'(<span style="color: #ff0000;">"add"</span> <span style="color: #ff0000;">"clear"</span> <span style="color: #ff0000;">"keycode"</span> <span style="color: #ff0000;">"keysym"</span> <span style="color: #ff0000;">"pointer"</span> <span style="color: #ff0000;">"remove"</span>)
|
||
'((<span style="color: #ff0000;">"[0-9]+"</span> . <span style="color: #ff00ff;">'font-lock-variable-name-face</span>))
|
||
'(<span style="color: #ff0000;">"[xX]modmap</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">(</span><span style="color: #ff0000;">rc</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: #cd6600;">"Simple mode for xmodmap files."</span>)
|
||
</pre>
|
||
</div>
|
||
|
||
<p>
|
||
<a href="https://www.emacswiki.org/emacs/GenericMode">see GenericMode for more examples</a>.
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org82aa168" class="outline-4">
|
||
<h4 id="org82aa168"><span class="section-number-4">6.2.9</span> MMM Mode</h4>
|
||
<div class="outline-text-4" id="text-6-2-9">
|
||
</div><ol class="org-ol"><li><a id="orgfe6d83d"></a>MMM configure:<br /><div class="outline-text-5" id="text-6-2-9-1">
|
||
<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;">"/mmm-mode"</span>))
|
||
|
||
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'cl</span>)
|
||
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'mmm-auto</span>)
|
||
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'mmm-vars</span>)
|
||
|
||
(<span style="color: #0000ff;">setq</span> mmm-submode-decoration-level 2)
|
||
</pre>
|
||
</div>
|
||
|
||
|
||
<p>
|
||
<a href="https://github.com/purcell/mmm-mode">mmm-mode github</a>
|
||
see doc for class definition in var 'mmm-classes-alist
|
||
</p>
|
||
</div></li>
|
||
|
||
<li><a id="orgaad8fc5"></a>MMM config for POD mode<br /><div class="outline-text-5" id="text-6-2-9-2">
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(mmm-add-classes
|
||
'((html-pod
|
||
<span style="color: #8a2be2;">:submode</span> html-mode <span style="color: #006400;">;; </span><span style="color: #006400;">web-mode doesnt work this way!</span>
|
||
<span style="color: #8a2be2;">:delimiter-mode</span> nil
|
||
<span style="color: #8a2be2;">:front</span> <span style="color: #ff0000;">"=begin html"</span>
|
||
<span style="color: #8a2be2;">:back</span> <span style="color: #ff0000;">"=end html"</span>)))
|
||
|
||
(mmm-add-mode-ext-class <span style="color: #ff00ff;">'pod-mode</span> nil <span style="color: #ff00ff;">'html-pod</span>)
|
||
|
||
(add-hook <span style="color: #ff00ff;">'pod-mode-hook</span> <span style="color: #ff00ff;">'mmm-mode-on</span>)
|
||
</pre>
|
||
</div>
|
||
</div></li></ol>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-orgae84f93" class="outline-3">
|
||
<h3 id="orgae84f93"><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-org5689377" class="outline-4">
|
||
<h4 id="org5689377"><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-org3300d2d" class="outline-4">
|
||
<h4 id="org3300d2d"><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 <C-c y y> 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;">&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> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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;">&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>
|
||
(<span style="color: #0000ff;">interactive</span> <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-orgebad629" class="outline-4">
|
||
<h4 id="orgebad629"><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;">&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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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 <A-i …>
|
||
</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;">"→"</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;">"→"</span>) <span style="color: #ff00ff;">'change-inner</span>) <span style="color: #006400;">;; </span><span style="color: #006400;"><A-i A-i></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;"><A-i c></span>
|
||
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"¢"</span>) <span style="color: #ff00ff;">'tvd-ci-comment</span>) <span style="color: #006400;">;; </span><span style="color: #006400;"><A-i A-c></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;"><A-i q></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;"><A-i A-q></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;"><A-i w></span>
|
||
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"ł"</span>) <span style="color: #ff00ff;">'tvd-ci-word</span>) <span style="color: #006400;">;; </span><span style="color: #006400;"><A-i A-w></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;"><A-i l></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;"><A-i s></span>
|
||
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"ſ"</span>) <span style="color: #ff00ff;">'tvd-ci-sexp</span>) <span style="color: #006400;">;; </span><span style="color: #006400;"><A-i A-s></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;"><A-i p></span>
|
||
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"þ"</span>) <span style="color: #ff00ff;">'tvd-ci-paragraph</span>) <span style="color: #006400;">;; </span><span style="color: #006400;"><A-i A-p></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;"><A-i a></span>
|
||
(define-key ci-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"æ"</span>) <span style="color: #ff00ff;">'tvd-ci-buffer</span>) <span style="color: #006400;">;; </span><span style="color: #006400;"><A-i A-a></span>
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-org0b6aa5e" class="outline-4">
|
||
<h4 id="org0b6aa5e"><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-org2969fa1" class="outline-4">
|
||
<h4 id="org2969fa1"><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-org6f8cf6d" class="outline-4">
|
||
<h4 id="org6f8cf6d"><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-org8d93358" class="outline-4">
|
||
<h4 id="org8d93358"><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-orga3c41d1" class="outline-4">
|
||
<h4 id="orga3c41d1"><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;">&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;">&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-orga33ad97" class="outline-3">
|
||
<h3 id="orga33ad97"><span class="section-number-3">6.4</span> Interactives</h3>
|
||
<div class="outline-text-3" id="text-6-4">
|
||
</div><div id="outline-container-org9595d4e" class="outline-4">
|
||
<h4 id="org9595d4e"><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;">&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
|
||
(<span style="color: #0000ff;">with-face</span> <span style="color: #ff0000;">"\n"</span>)
|
||
(<span style="color: #0000ff;">with-face</span> (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>)
|
||
(<span style="color: #0000ff;">with-face</span> (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>)
|
||
(<span style="color: #0000ff;">with-face</span> <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>)
|
||
(<span style="color: #0000ff;">with-face</span> (<span style="color: #0000ff;">or</span>
|
||
(<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)
|
||
(<span style="color: #0000ff;">with-face</span> <span style="color: #ff0000;">"\n"</span> <span style="color: #8a2be2;">:background</span> header-bg)
|
||
(<span style="color: #0000ff;">with-face</span> user-login-name <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"blue"</span>)
|
||
<span style="color: #ff0000;">"@"</span>
|
||
(<span style="color: #0000ff;">with-face</span> <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)
|
||
(<span style="color: #0000ff;">with-face</span> <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. > inserts, >> 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;">&rest</span> args)
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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;">&rest</span> args)
|
||
<span style="color: #cd6600;">"Editor commands fired from eshell will be handled by emacs, which already runs anyway."</span>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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;">&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)
|
||
(<span style="color: #0000ff;">interactive</span> <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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span> <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-orga3317e7" class="outline-4">
|
||
<h4 id="orga3317e7"><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> (> (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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span> <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)
|
||
(tvd-outshine-end-of-section)
|
||
(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)
|
||
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">enable outline (with outshine)</span>
|
||
(outline-minor-mode)
|
||
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">enable outshine mode</span>
|
||
(outshine-hook-function)
|
||
|
||
(electric-indent-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>
|
||
… 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_]*\\>"</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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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-org473a586" class="outline-4">
|
||
<h4 id="org473a586"><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-org91e51ed" class="outline-4">
|
||
<h4 id="org91e51ed"><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>
|
||
tramp-default-user nil
|
||
ido-enable-tramp-completion t)
|
||
</pre>
|
||
</div>
|
||
|
||
<p>
|
||
see also backup section
|
||
</p>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-orgfa1dc0f" class="outline-4">
|
||
<h4 id="orgfa1dc0f"><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;">"►"</span> <span style="color: #ff0000;">"✜"</span> <span style="color: #ff0000;">"✸"</span> <span style="color: #ff0000;">"✿"</span> <span style="color: #ff0000;">"♦"</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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(tvd-org-emphasize '95))
|
||
</pre>
|
||
</div>
|
||
|
||
<p>
|
||
my org-mode specific <C-left> and <C-right>
|
||
</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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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> ()
|
||
(<span style="color: #0000ff;">setq</span>
|
||
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 (<span style="color: #0000ff;">quote</span> ((heading . auto) (plain-list-item . auto)))
|
||
org-catch-invisible-edits (<span style="color: #0000ff;">quote</span> 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 (<span style="color: #0000ff;">quote</span> 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-use-sub-superscripts nil
|
||
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
|
||
(<span style="color: #0000ff;">quote</span> (
|
||
(<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;">"<M-return>"</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 0"</span>) <span style="color: #ff00ff;">'code</span>) <span style="color: #006400;">; </span><span style="color: #006400;">aka = without shift</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 <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;">"<C-up>"</span>) <span style="color: #ff00ff;">'tvd-org-heading-up</span>)
|
||
(local-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"<C-down>"</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;">"<C-left>"</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 … 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;">" ⤵"</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> () (<span style="color: #0000ff;">interactive</span>) (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;">&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-org0310264" class="outline-4">
|
||
<h4 id="org0310264"><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>
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'org-table</span>)
|
||
</pre>
|
||
</div>
|
||
|
||
<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>
|
||
(<span style="color: #0000ff;">interactive</span> <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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(org-table-sort-lines nil ?T))
|
||
</pre>
|
||
</div>
|
||
|
||
<p>
|
||
<a href="http://irreal.org/blog/?p=3542">via jcs/irreal.org</a>
|
||
however, I renamed the actual sort wrappers to match my
|
||
naming scheme
|
||
</p>
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">jcs-ip-lessp</span> (ip1 ip2 <span style="color: #483d8b;">&optional</span> op)
|
||
<span style="color: #cd6600;">"Compare two IP addresses.</span>
|
||
<span style="color: #cd6600;">Unless the optional argument OP is provided, this function will return T</span>
|
||
<span style="color: #cd6600;">if IP1 is less than IP2 or NIL otherwise. The optional argument OP is</span>
|
||
<span style="color: #cd6600;">intended to be #'> to support reverse sorting."</span>
|
||
(<span style="color: #0000ff;">setq</span> cmp (<span style="color: #0000ff;">or</span> op #'<))
|
||
(<span style="color: #0000ff;">cl-labels</span> ((compare (l1 l2)
|
||
(<span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">or</span> (null l1) (null l2))
|
||
nil
|
||
(<span style="color: #0000ff;">let</span> ((n1 (string-to-number (<span style="color: #0000ff;">car</span> l1)))
|
||
(n2 (string-to-number (<span style="color: #0000ff;">car</span> l2))))
|
||
(<span style="color: #0000ff;">cond</span>
|
||
((funcall cmp n1 n2) t)
|
||
((= n1 n2) (compare (<span style="color: #0000ff;">cdr</span> l1) (<span style="color: #0000ff;">cdr</span> l2)))
|
||
(t nil))))))
|
||
(compare (split-string ip1 <span style="color: #ff0000;">"\\."</span>) (split-string ip2 <span style="color: #ff0000;">"\\."</span>))))
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">sort-table-ip</span> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(org-table-sort-lines nil ?f #<span style="color: #ff00ff;">'org-sort-remove-invisible</span> #<span style="color: #ff00ff;">'jcs-ip-lessp</span>))
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">sort-table-ip-desc</span> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(org-table-sort-lines nil ?F #<span style="color: #ff00ff;">'org-sort-remove-invisible</span>
|
||
(<span style="color: #0000ff;">lambda</span> (ip1 ip2) (jcs-ip-lessp ip1 ip2 #'>))))
|
||
</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>)
|
||
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'sti</span> <span style="color: #ff00ff;">'sort-table-ip</span>)
|
||
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'stid</span> <span style="color: #ff00ff;">'sort-table-ip-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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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 <tab>"</span>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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;">&optional</span> arg)
|
||
<span style="color: #cd6600;">"move (point) to the beginning of a org mode table cell"</span>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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;">&optional</span> arg)
|
||
<span style="color: #cd6600;">"move (point) to the end of a org mode table cell"</span>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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;">&optional</span> arg)
|
||
<span style="color: #cd6600;">"Copy an org mode table cell to the kill ring using MCYT"</span>
|
||
(<span style="color: #0000ff;">interactive</span> <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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">assert</span> (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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">assert</span> (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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
|
||
<p>
|
||
integers, reals, positives, set via custom
|
||
</p>
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">setq</span> org-table-number-regexp <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;">[0-9]*\\.[0-9]+</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">|</span><span style="color: #ff0000;">[0-9]+\\.?[0-9]*</span><span style="color: #ff0000; font-weight: bold;">\\</span><span style="color: #ff0000; font-weight: bold;">)</span><span style="color: #ff0000;">$"</span>)
|
||
</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-orga33956a" class="outline-4">
|
||
<h4 id="orga33956a"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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;">"•"</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)
|
||
(<span style="color: #0000ff;">interactive</span> <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, <ret> 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-org10e21a1" class="outline-4">
|
||
<h4 id="org10e21a1"><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>
|
||
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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">let</span> ((heading nil))
|
||
(<span style="color: #0000ff;">if</span> (string= <span style="color: #ff0000;">""</span> outshine-normalized-outline-regexp-base)
|
||
(call-interactively <span style="color: #ff00ff;">'imenu</span>) <span style="color: #006400;">;; </span><span style="color: #006400;">use imenu outside outshine</span>
|
||
(<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;">"Could not parse 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))))))
|
||
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-outshine-end-of-section</span> ()
|
||
<span style="color: #cd6600;">"Jump to the end of an outshine section."</span>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">let</span> ((end))
|
||
(outline-show-subtree)
|
||
(<span style="color: #0000ff;">save-excursion</span>
|
||
(outline-next-heading)
|
||
(<span style="color: #0000ff;">when</span> (outline-on-heading-p)
|
||
(backward-paragraph))
|
||
(<span style="color: #0000ff;">setq</span> end (point)))
|
||
(goto-char end)))
|
||
</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
|
||
(<span style="color: #0000ff;">quote</span> (
|
||
(<span style="color: #ff0000;">"v"</span> . outshine-narrow-to-subtree)
|
||
(<span style="color: #ff0000;">"q"</span> . widen)
|
||
(<span style="color: #ff0000;">"e"</span> . tvd-outshine-end-of-section))))))))
|
||
</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;">&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> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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)
|
||
(<span style="color: #0000ff;">interactive</span>
|
||
(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 <pre>'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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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 && git ci +fixes .emacs emacs.html"</span>)
|
||
(shell-command <span style="color: #ff0000;">"cd ~/D/github/dot-emacs && git push"</span>))
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org7c877e0" class="outline-4">
|
||
<h4 id="org7c877e0"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span> <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;">"<C-up>"</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;">"<C-down>"</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;">"<C-left>"</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;">&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-org1e7fef3" class="outline-4">
|
||
<h4 id="org1e7fef3"><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-orgd35e948" class="outline-4">
|
||
<h4 id="orgd35e948"><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;">&optional</span> string)
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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;">&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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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-orgaba9496" class="outline-4">
|
||
<h4 id="orgaba9496"><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-orgf7daa64" class="outline-4">
|
||
<h4 id="orgf7daa64"><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-org35abb1d" class="outline-4">
|
||
<h4 id="org35abb1d"><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-orgfb8cd01" class="outline-4">
|
||
<h4 id="orgfb8cd01"><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-orgcfa2941" class="outline-4">
|
||
<h4 id="orgcfa2941"><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)
|
||
(<span style="color: #0000ff;">interactive</span> <span style="color: #ff0000;">"f"</span>)
|
||
(info-setup file
|
||
(pop-to-buffer-same-window
|
||
(format <span style="color: #ff0000;">"*info*<%s>"</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;">"<C-left>"</span>) <span style="color: #ff00ff;">'Info-history-back</span>)
|
||
(define-key Info-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"<C-right>"</span>) <span style="color: #ff00ff;">'Info-history-forward</span>)))
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org36a9d5f" class="outline-4">
|
||
<h4 id="org36a9d5f"><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 <ret> (+ 1 2) <ret>
|
||
</p>
|
||
|
||
<p>
|
||
or, inferior perl calc: M-x icalc, see above
|
||
</p>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org9300cfe" class="outline-4">
|
||
<h4 id="org9300cfe"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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))
|
||
(<span style="color: #0000ff;">push</span> (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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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 <shift-F6> ..."</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 <C-F6>, save or <C-x C-e> 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;">&optional</span> ARG)
|
||
<span style="color: #cd6600;">"execute last macro (or ARG, if given) repeatedly after every</span>
|
||
<span style="color: #cd6600;"><ret>, 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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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;">"<enter> 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;">"<C-g> 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>… do things …</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;">"<f6>"</span>) <span style="color: #ff00ff;">'tvd-start-or-stop-macro</span>)
|
||
(global-set-key (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"<C-f6>"</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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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;">&rest</span> args)
|
||
(tvd-macro-gen-repeater-and-save)))
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-orga6e3b07" class="outline-4">
|
||
<h4 id="orga6e3b07"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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-org03aad87" class="outline-4">
|
||
<h4 id="org03aad87"><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-orgca3975f" class="outline-4">
|
||
<h4 id="orgca3975f"><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>< shrink column</li>
|
||
<li>> 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- <ret></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> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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-orga46b17d" class="outline-4">
|
||
<h4 id="orga46b17d"><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! … 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-org980e6a5" class="outline-4">
|
||
<h4 id="org980e6a5"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(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;">"<tab>"</span>) <span style="color: #ff00ff;">'tvd-suggest-jump</span>)))))
|
||
</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-org7610483" class="outline-4">
|
||
<h4 id="org7610483"><span class="section-number-4">6.4.24</span> Followcursor Mode</h4>
|
||
<div class="outline-text-4" id="text-6-4-24">
|
||
<p>
|
||
<a href="https://github.com/TLINDEN/followcursor-mode">source on github</a>
|
||
</p>
|
||
|
||
<p>
|
||
From time to time I need to refactor configs and the like based on
|
||
lists. For example in the left window I have a list of bgp peers
|
||
and in the right window a config file for all peers which I have to
|
||
modify based on current settings. With followcursor-mode I can put
|
||
point on an ip address and the line in the config containing this
|
||
ip address will be highlighted. If I move on to the next address
|
||
the next line on the right will be highlighted.
|
||
</p>
|
||
|
||
<p>
|
||
The mode is a work-in-progress…
|
||
</p>
|
||
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'followcursor-mode</span>)
|
||
</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
<div id="outline-container-org7b092a3" class="outline-4">
|
||
<h4 id="org7b092a3"><span class="section-number-4">6.4.25</span> Magit</h4>
|
||
<div class="outline-text-4" id="text-6-4-25">
|
||
<p>
|
||
Not much to say about Magit
|
||
</p>
|
||
<div class="org-src-container">
|
||
<pre class="src src-emacs-lisp">(<span style="color: #0000ff;">unless</span> tvd-win-home
|
||
(<span style="color: #0000ff;">setq</span> tvd-magit-revision <span style="color: #ff0000;">"20170725.1153"</span>)
|
||
|
||
(add-to-list <span style="color: #ff00ff;">'load-path</span> (concat tvd-lisp-dir (concat <span style="color: #ff0000;">"/magit-"</span> tvd-magit-revision)))
|
||
|
||
(<span style="color: #0000ff;">require</span> <span style="color: #ff00ff;">'magit</span>)
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-magit-status</span> ()
|
||
<span style="color: #cd6600;">"Always call `</span><span style="color: #cd6600;">magit-status</span><span style="color: #cd6600;">' with prefix arg."</span>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">let</span> ((current-prefix-arg t))
|
||
(call-interactively <span style="color: #ff00ff;">'magit-status</span>)))
|
||
|
||
(<span style="color: #0000ff;">with-eval-after-load</span> <span style="color: #ff00ff;">'info</span>
|
||
(info-initialize)
|
||
(add-to-list <span style="color: #ff00ff;">'Info-directory-list</span>
|
||
(expand-file-name (concat <span style="color: #ff0000;">"~/.emacs.d/lisp/magit-"</span>
|
||
tvd-magit-revision
|
||
<span style="color: #ff0000;">"/Documentation/"</span>)))
|
||
(<span style="color: #0000ff;">setq</span> magit-view-git-manual-method <span style="color: #ff00ff;">'woman</span>))
|
||
|
||
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'git</span> <span style="color: #ff00ff;">'tvd-magit-status</span>)
|
||
(<span style="color: #0000ff;">defalias</span> <span style="color: #ff00ff;">'gitlog</span> <span style="color: #ff00ff;">'magit-log-buffer-file</span>)
|
||
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">configure magit</span>
|
||
(<span style="color: #0000ff;">with-eval-after-load</span> <span style="color: #ff00ff;">'magit</span>
|
||
(<span style="color: #0000ff;">dolist</span> (dir (list (expand-file-name <span style="color: #ff0000;">"~/D/github"</span>)
|
||
(expand-file-name <span style="color: #ff0000;">"~/dev/git"</span>)))
|
||
(<span style="color: #0000ff;">when</span> (file-exists-p dir)
|
||
(add-to-list <span style="color: #ff00ff;">'magit-repository-directories</span> (cons dir 1))))
|
||
(<span style="color: #0000ff;">setq</span> magit-completing-read-function <span style="color: #ff00ff;">'magit-ido-completing-read</span>)
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">navigate magit buffers as I do everywhere else, I do not automatically</span>
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">cycle/decycle though, the magit defaults are absolutely sufficient.</span>
|
||
(define-key magit-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"<C-down>"</span>) <span style="color: #ff00ff;">'magit-section-forward-sibling</span>)
|
||
(define-key magit-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"<C-up>"</span>) <span style="color: #ff00ff;">'magit-section-backward-sibling</span>)
|
||
(define-key magit-mode-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"<delete>"</span>) <span style="color: #ff00ff;">'magit-delete-thing</span>))
|
||
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">one thing though: on startup it bitches about git version, but it</span>
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">works nevertheless. So I disable this specific warning.</span>
|
||
|
||
(<span style="color: #0000ff;">defun</span> <span style="color: #9932cc;">tvd-ignore-magit-warnings-if-any</span> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<span style="color: #0000ff;">when</span> (get-buffer <span style="color: #ff0000;">"*Warnings*"</span>)
|
||
(<span style="color: #0000ff;">with-current-buffer</span> <span style="color: #ff0000;">"*Warnings*"</span>
|
||
(goto-char (point-min))
|
||
(<span style="color: #0000ff;">when</span> (re-search-forward <span style="color: #ff0000;">"Magit requires Git >="</span>)
|
||
(kill-buffer-and-window)))))
|
||
|
||
(add-hook <span style="color: #ff00ff;">'after-init-hook</span> <span style="color: #ff00ff;">'tvd-ignore-magit-warnings-if-any</span> t)
|
||
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">now, THIS is the pure genius me: hit "ls in magit-status buffer</span>
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">and end up in a dired buffer of current repository. The default</span>
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">binding for this is C-M-i, which is not memorizable, while "ls"</span>
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">is. That is, 'l' is a prefix command leading to magit-log-popup</span>
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">and 's' is undefined, which I define here, which then jumps to</span>
|
||
<span style="color: #006400;">;; </span><span style="color: #006400;">dired.</span>
|
||
(magit-define-popup-action <span style="color: #ff00ff;">'magit-log-popup</span>
|
||
?s <span style="color: #ff0000;">"Dired"</span> <span style="color: #ff00ff;">'magit-dired-jump</span>))
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-orga8fa542" class="outline-3">
|
||
<h3 id="orga8fa542"><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-org3e20186" class="outline-4">
|
||
<h4 id="org3e20186"><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-orge60ba1a" class="outline-4">
|
||
<h4 id="orge60ba1a"><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-org54e4f22" class="outline-4">
|
||
<h4 id="org54e4f22"><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-orgec0c8fd" class="outline-4">
|
||
<h4 id="orgec0c8fd"><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">(<span style="color: #0000ff;">safe-wrap</span>
|
||
(<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-orgcf647f0" class="outline-4">
|
||
<h4 id="orgcf647f0"><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-org584e613" class="outline-4">
|
||
<h4 id="org584e613"><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-orga0ca64a" class="outline-4">
|
||
<h4 id="orga0ca64a"><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>
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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>
|
||
(<span style="color: #0000ff;">interactive</span> <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)))) <span style="color: #ff0000; font-weight: bold;">(buffer-list)))))</span>
|
||
(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-orgb8fc2b7" class="outline-4">
|
||
<h4 id="orgb8fc2b7"><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;">&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;">&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;">&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 (<span style="color: #0000ff;">quote</span> (<span style="color: #ff0000;">"\n-> "</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;">"<down>"</span>) <span style="color: #ff00ff;">'ido-next-match</span>)
|
||
(define-key ido-completion-map (<span style="color: #0000ff;">kbd</span> <span style="color: #ff0000;">"<up>"</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> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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-org6e0b76a" class="outline-4">
|
||
<h4 id="org6e0b76a"><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< 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>)
|
||
(<span style="color: #0000ff;">setq-default</span> save-place t))
|
||
(save-place-mode 1))
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outline-container-orgce37712" class="outline-4">
|
||
<h4 id="orgce37712"><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-org6b0a518" class="outline-4">
|
||
<h4 id="org6b0a518"><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-orgd4299b6" class="outline-4">
|
||
<h4 id="orgd4299b6"><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, <ret> to select, it's the same
|
||
as <M-y> and I never really use it…
|
||
</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-orgf4defa3" class="outline-4">
|
||
<h4 id="orgf4defa3"><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-org471bd24" class="outline-4">
|
||
<h4 id="org471bd24"><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-orgc529521" class="outline-4">
|
||
<h4 id="orgc529521"><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-org14bf47f" class="outline-4">
|
||
<h4 id="org14bf47f"><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 (<TAB>) 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> (<span style="color: #0000ff;">or</span>
|
||
(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> (<span style="color: #0000ff;">or</span>
|
||
(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> ()
|
||
(<span style="color: #0000ff;">interactive</span>)
|
||
(<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">(<span style="color: #0000ff;">define-ibuffer-column</span> 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>
|
||
((> (buffer-size) 1000000) (format <span style="color: #ff0000;">"%7.1fM"</span> (/ (buffer-size) 1000000.0)))
|
||
((> (buffer-size) 100000) (format <span style="color: #ff0000;">"%7.0fk"</span> (/ (buffer-size) 1000.0)))
|
||
((> (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;">&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-org9c86f40" class="outline-4">
|
||
<h4 id="org9c86f40"><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 => 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;">&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>
|
||
(<span style="color: #0000ff;">interactive</span> (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-org10a4c82" class="outline-4">
|
||
<h4 id="org10a4c82"><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> () (<span style="color: #0000ff;">bound-and-true-p</span> novel-mode)))
|
||
|
||
(beacon-mode)
|
||
</pre>
|
||
</div>
|
||
|
||
<hr />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div id="outline-container-org567c4c3" class="outline-3">
|
||
<h3 id="org567c4c3"><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">(<span style="color: #0000ff;">setq-default</span> 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">(<span style="color: #0000ff;">setq-default</span> 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-orgb2cfcf2" class="outline-2">
|
||
<h2 id="orgb2cfcf2"><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-org87de9e5" class="outline-3">
|
||
<h3 id="org87de9e5"><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))))
|
||
'(mmm-default-submode-face ((t nil)))
|
||
'(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;">: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;">: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;">:underline</span> t))))
|
||
'(outline-1 ((t (<span style="color: #8a2be2;">:height</span> 1.2 <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;">:height</span> 1.15 <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;">:height</span> 1.1 <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;">:height</span> 1.05 <span style="color: #8a2be2;">:foreground</span> <span style="color: #ff0000;">"DodgerBlue3"</span> <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-org8a8b4ae" class="outline-3">
|
||
<h3 id="org8a8b4ae"><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-orgfc836a8" class="outline-3">
|
||
<h3 id="orgfc836a8"><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: Thomas von Dein</p>
|
||
<p class="date">Created: 2017-07-31 Mon 11:28</p>
|
||
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
|
||
</div>
|
||
</body>
|
||
</html>
|