Posts tagged emacs

gnu global

posted on 2017-04-26 20:56

Get the current version from here. Alternatively, use the use the anonymous access to CVS, but no Idea wether the patches would work there.

The steps to version 6.5.6 running on a current gentoo install were, including the patches follow. I hope I don't forget something, this write was done a week later.

needed packages

emerge -atv these:

  • dev-python/pygments
  • dev-util/ctags
  • sys-devel/automake
  • sys-devel/m4

getting and compiling

mkdir asdf
cd asdf
curl -O
tar xzvf global-6.5.6.tar.gz
cd global-6.5.6

applying these two patches:

diff --git a/ b/
index cda52e4..d7d1a73 100644
--- a/
+++ b/
@@ -24,6 +24,7 @@ dnl
 AC_INIT([GNU GLOBAL],[6.5.6])
 AC_DEFINE(COPYRIGHT_YEAR,["1996-2016"],[Copyright Year])
 AM_INIT_AUTOMAKE([1.9.3 gnu subdir-objects])

diff --git a/ b/
index 43585a6..f6ab5c5 100644
--- a/
+++ b/

 EXTRA_DIST = ${gtags_DATA} mainpage.dox

    GTAGSCONF=' --suggest:' doxygen

Then back to the shell:

autoreconf -fvi
./configure --with-universal-ctags=`which ctags`
make check
sudo make install

setup and test

sudo updatedb
sudo locate gtags.conf
cp -va /usr/local/share/gtags/gtags.conf ~/.globalrc
gtags --version
global --version
cd ../..
rm -rf asdf


Now onto actual usage:


gtags -v        # generate tag database (initially, rerun with -i everytime code is changed!)

global FUNC     # finds file where FUNC is defined, regexp's work, too
global -r FUNC      # find files where FUNC is used in
global -x FUNC      # == ctags -x, name+line+path+line_content

Of course you only want to look at source, not generated code. If git is used, doing this from the project root will do the trick:

git ls-files > gtags.files

There's more to it, but it should be sufficiant for now. Usually global should be integrated into your dev environment of choice.

Out of the box, less should work. vim and emacs need plugins to work, they won't be covered at this time here.


export LESSGLOBALTAGS=global  ## this is needed so less knows it can work with global
less -t FUNC        # opens file where FUNC is defined

spacemacs org-mode in very short

posted on 2016-12-14 23:34

Some notes to get up to speed with orgmode AFAP:

  • Header to make emacs recognize org files regardless of file extension: -*- mode: org -*-
  • create bullet point: m-enter
  • bullet-point indenting: tab
  • change indentation of non-bulleted text: tab
  • insert bullet-points without m-enter: start a new line with one or several *'s followed by a space.
  • move bullet point up/down: m-up and m-down
  • change bullet point indentation: m-left and m-right
  • change DONE / TODO for bulletpoint: s-left and s-right
  • show TODO items: spc m T
  • TODO tags can be defined up to in file: #+TODO: TODO IN-PROGRESS WAITING DONE
  • unordered lists (not bulletpointed) start with a - (+ will work, too)
  • exit into normal mode and use o to insert a new list-line
  • descriptions use not just a single colon, but two with leading space: ::
  • change list type with s-left and s-right
  • opening/closing folds of current item: c-tab
  • insert source code block, in insert mode, do: <sTAB (<, s, tab)

There's more, but these are the very basics. A lot of these plus some other stuff can be found here.

On logging time:

  • start timer for current item: spc m I
  • stop timer for current item: spc m O
  • expand LOGBOOK: c-tab
  • insert deadline: spc m d

spacemacs: essentials

posted on 2016-01-16 12:20


Spacemacs is a truly awesome piece of software. It is literally the best of both worlds from vim and emacs.

In the last years I have heavily used (and customized) vim (my .vimrc is about 900 lines). But as soon as you want to do more complex stuff, which involves a lot of plugins, things get ugly and slow. Often you also happen to need a custom compiled vim (so it has python bindings enabled) and bad hackery (vimscript is an absolute traffic accident).

After quite some stints with emacs in the last years (interest in lisp plus the customization which is possible with it, compared to vimscript) and a lot of pulling hair out due to debugging problems (When is a major/minor-mode actually loaded? Packages broken when using the different package universes like melpa/elpa/marmalade together? Evil-mode not working in all buffers even though it was set globally?) I stumbled upon Spacemacs.

common solutions for common problems

helm keybind popup too slow

See ~/.spacemacs:

dotspacemacs-which-key-delay 0.01

syntax highlighting for special files lacking

Put this into ~/.spacemacs in the user-config() section:

(autoload 'markdown-mode "markdown-mode"
  "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.post\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))

font too large

See ~/.spacemacs, same section:

(defun dotspacemacs/user-config ()
       (set-face-attribute 'default nil :height 80)

Here 10 ~= 1pt, so 80 is like 8pt from what I read.

start maximized

See ~/.spacemacs:

dotspacemacs-maximized-at-startup t

custom bindings

Canonical example here shall be using 'jk' simultanously to exit from INSERT mode. For that the key-chord package is needed, plus a little configuration.

See ~/.spacemacs:

(defun dotspacemacs/user-config ()
       (key-chord-define-global "jk" 'evil-normal-state)
       (key-chord-mode t)
(defun dotspacemacs/user-config ()

is the place to go. If you for example need additional packages without grouping them into a layer, put them under dotspacemacs-additional-packages, also in .spacemacs.

dotspacemacs/user-init vs. dotspacemacs/user-config

user-config gets loaded at the end of the parsing of the config file contents, whereas user-init right at the beginning. Usually you want to place code into user-config.

keybinds essentials list (beside original vim stuff)

ESC             abort current menu
C-g             abort current menu
C-h u           go back to previous helm menu

SPC f f         open file
SPC f s         save file

C-x C-c         close spacemacs

# window management
SPC w /         create vertical window split
SPC w -         create horizontal window split
SPC w c         window close

SPC TAB         switch to last buffer
SPC b b         buffer list
SPC b n         next buffer
SPC b p         previous buffer
SPC f d         kill/delete buffer

SPC <number>    jump to window <number>
SPC w arrow     move to window up/left/righ/down
C-w hjkl        move to window up/left/righ/down
SPC w S-arrow   move window up/left/righ/down
SPC w c         close window

# open and reload dotfile
SPC f e d       open
SPC f e R       reload dotfile

# using the help for looking up things, the shortcut is:
SPC h d f       help describe function
SPC h d k       help describe key
SPC h d p       help describe package
SPC h d m       help describe mode
SPC h d v       help describe variable
C-h a           emacs 'apropos'

keybinds additionals list (non-geeks safely forget everything past here...)


SPC t f         toggle show indicator at 80 chars and disable soft-wrapping
SPC t h h       toggle show cursorline
SPC t i         toggle show indent guide
SPC t h a       toggle automatic symbol highlighting
SPC f t         toggle neo-tree (folder browser)


SPC n r         narrow region (just show current selection)
SPC n f         narrow function (just show current function)
SPC n w         widen again

syntax checking

SPC t s         enable flycheck

emacs: remote editing of files

posted on 2015-05-01 01:00:25

emacs comes, just as vim, with the possibility to open remote files within your editor. Usual syntax is this:


From the the emacs manual:

  1. If the host name starts with ‘ftp.’ (with dot), Emacs uses FTP.
  2. If the user name is ‘ftp’ or ‘anonymous’, Emacs uses FTP.
  3. If the variable tramp-default-method is set to ‘ftp’, Emacs uses FTP.
  4. If ssh-agent is running, Emacs uses scp.
  5. Otherwise, Emacs uses ssh.

Usually this is what you want, since it just works:


Installing emacs 25 on debian wheezy

posted on 2015-02-04 13:55:58

To install and not having to care about package dependency hell, here's a walkthrough:

  1. apt-get install -y git-core libxaw7-dev libxpm-dev libpng12-dev libtiff5-dev libgif-dev libjpeg8-dev libgtk2.0-dev libncurses5-dev autoconf automake
  2. apt-get build-dep emacs
  3. git clone --depth 1 -b master git://
  4. cd emacs
  5. ./
  6. ./configure --prefix=/opt/emacs25
  7. make
  8. sudo make install

Step 8 as root, so emacs will be available system-wide.

emacs: change font size

posted on 2015-02-01 22:05:45

There are several possibilities. Aside from using the dropdown menu (heaven forbid!), or using the actual commands via M-x, you have two options:

  1. Shift + Mouse1 - which will open a context menu
  2. c-x c-+ and c-x c--, which is what you will certainly will prefer. =)

bash emacs shell shortcuts

posted on 2014-07-04 13:19:19

Linux comes around usually with the bash shell. By default bash comes with the possibility to enable vi or bash shortcuts. (Google set -o emacs vs. set -o vi for more info.)

Since vi mode is a bit strange to use (No possibility to see which mode you are in, maybe with zsh this could be changed?) I stick to emacs bindings.

Most useful are:

CTRL - P    previous command (previous line)
CTRL - N    next command (next line)

CTRL - R    incremental search in command history

CTRL - A    beginning of line
CTRL - E    end of line
ALT - B     backward one word
ALT - F     forward one word
CTRL - B    backward one character
CTRL - F    forward one character
ALT - A beginning of sentence
ALT - E end of sentence

CTRL - D    next char
CTRL - H    previous char
ALT - D     next word
ALT - BSPC previous word
CTRL - W    previous word (not preferred, as it won't work in emacs with evil-mode enabled :o))
CTRL - K    from cursor to end of line
CTRL - U    from cursor to beginning of line

CTRL - Y    put paste buffer contents back at cursor location

ALT - U     uppercase next word
ALT - L     lowercase next word

CTRL - T    last two characters
ALT - T     last two words

ALT - *     insert all possible completions
ALT - ?     show all possible completions

Emacs tutorial commands

posted on 2014-06-08 16:44:16

Since the emacs tutorial is kind of annoying, here are all commands listed that are introduced there:

page forward                    c-v
page backward                   m-v

clear screen and redisplay text c-l

next line                       c-n
prev line                       c-p
next char                       c-f
prev char                       c-b

next word                       m-f
prev word                       m-b

start of line                   c-a
end of line c-e
start of sentence               m-a
end of sentence                 m-e

prefix-argument for repetition  c-u

cancel on current level         c-g

maximize active window          c-x 1

delete prev char                DEL
delete next char                c-d
kill prev word                  m-DEL
kill next word                  m-d

kill rest of line               c-k
kill rest of sentence           m-k

set start mark                  c-SPACE
set end mark                    c-SPACE

yank/paste                      c-y
change yanked text              m-y

undo                            c-/
undo                            c-x u
undo                            c-_

find file                       c-x c-f
save current file               c-x c-s

list buffers                    c-x c-b
change to buffer                c-x b <buffername>

save all files                  c-x s

character extend                c-x
named command extend            m-x

exit emacs                      c-x c-c
suspend shell emacs             c-z

show major mode documentation   c-h m

alter cursor position (H M L)   c-l

set column size                 c-x f <column number>

forward search                  c-s
reverse search                  c-r

horizontal split                c-x 2
scroll NEXT window              c-m-v
goto next window                c-x o

find file in other window       c-x 4 c-f <file>

create frame                    m-x make-frame
kill frame                      m-x delete-frame

cancel on all levels            ESC

help on command                 c-h c <command>
verbose help on command         c-h k <command>
help on function                c-h f <function>
apropos help                    c-h a <keyword>
read included manual            c-h i

Find files via grep and open in editor

posted on 2014-01-18 23:33:31

Often you have to find a function definition or use or just a unique string or setting, but do not know in which file it is located. Grepping will return the results, but you have to type in the filename again when opening the file in question in an editor. This here is intended to streamline the process.

grepe static void main or
grepv static void main.

No "" needed.

Put this into your .bashrc.

    emacs $(\grep -irl "$*" .)
    vim $(\grep -irl "$*" .)

I wonder why I did not look for this earlier. :o)

grep is used instead of ack so all files are searched, as ack will only search files it 'knows'.

Installing emacs 24.3 on Fedora 19

posted on 2013-12-28 00:56:42

Installing emacs under one of the latest fedora releases is a bit of an act.

First, as of 12/2013 the newest version in yum is 24.1. If you are happy with this, then you are fine. If you need helm... things are different since it needs a recent emacs version, but at least 24.3. Would only be half a funny, if this one wasn't the newest you can possibly get.

Anyway, get the download from the homepage here, and let the games begin!

If you chose one with this funny new .xz ending, unxz emacs-24.3.tar.xz followed by a tar -xf emacs-24.3.tar will do. (bzip will be deprecated for exchanging kernel files beginning 2014, it seems, so xz will stick.)

When trying the magic ./configure, make, make install triplet the configure step will fail with this message:

configure: error: The following required libraries were not found: libXpm libjpeg libgif/libungif libtiff Maybe some development libraries/packages are missing? If you don't want to link with them give --with-xpm=no --with-jpeg=no --with-tiff=no as options to configure

Solution is to install all these lib's -devel files. (At least I did, so I could run the regular ./configure step without disabling anything.) Seems to be fine, if you have either libgif or libungif. I was missing the first one, but that did not pose a problem.

Afterwards, if you try configure right again, it will tell you this:

configure: error: The required function `tputs' was not found in any library. The following libraries were tried (in order): libtinfo, libncurses, libterminfo, libtermcap, libcurses Please try installing whichever of these libraries is most appropriate for your system, together with its header files. For example, a libncurses-dev(el) or similar package.

Install ncurses-devel, make, make install and the newest emacs will be glad to be of service, after about the while it took to write this. :o)

Why to bother with emacs and how to use its help

posted on 2013-11-19 16:33:44

Lately emacs has popped up on my radar. I have been using vim with heavy customization for years, and the benefits are out of question for me. Shell usage, file-related encoding awareness (and understanding), build automatization skills all stem mostly from this editor. That is just because these things are possible. Eclipse and friends will not let you get low-level enough, where you have to understand what you are doing.

Still vim is 'just' an editor, emacs can the environment YOU want, it just lacks a proper editor anecdotically they say. If everything is customizable, why not get vim's editing capabilities into emacs?

Emacs keybinds mostly are strange or are outright crap.

c-n c-p c-f c-b for moving around is nowhere comparable with hjkl in vim. They exist because they could be memoized easily; Next line, Previous line, Forward a char, back a char. But this will fry your hands and pinky finger over time... Also on the keyboards in the time of lisp machines, CTRL and ALT were switched. Once the era of commercial lisp ended, the new keyboards just started to look like what they are now. Compare this to this. Having rebound CTRL to CAPS will lessen this problem, but it will be not as good as it could be.

Emacs is on my task list for its R integration and as it provides an excuse to familiarize myself with elisp (After being forced to learn scheme back in the first semester I was hooked on lisp and programming languages.) ... and down the rabbit hole I go. Emacs' evil-mode helps with the transition a lot, and after one and a half days some comprehension for all the emacs evangelists enthusiasm already shows. If in doubt, watch this.

Only problem is, evil will not work in all the modes (which is good as well as bad). Also most of the time you do not even know what you want to know from the editor, or how to tell him what you want.

For getting help, keep these in mind:

C-h C-h 'open meta-help
and then to scroll:
space 'forward
backspace 'backward
q 'quit

Short for CTRL-h twice, is some kind of 'meta' help.

Also especially helpful are:

C-h f <function> 'describe function
C-h c <key> 'lookup function bound to key
C-h w <function> 'lookup keybind for function

C-h b 'show all key bindings

C-h m 'help on currently active modes
C-h l 'show last several hundred keypresses
C-h C-f 'emacs faq

Especially the first three key sequences are great. To be proficient in emacs, you (more or less) have to rebind keys to work properly. (Claiming otherwise is uneducated guessing. :o))

Basic Emacs movement

posted on 2013-10-23 15:57:51

A list of basic movement command aquivalents in Emacs to those in vim. This might come in handy for buffers where the vim modes of the evil plugin will not work.

Vim    Emacs    Meaning   
j C-n down
k C-p up
h C-b left
l C-f right
0 C-a beginning of line
$ C-e end of line
( M-a beginning of sentence
) M-e end of sentence
w/e M-f next word (not exactly the same)
b M-b previous word
gg M-< beginning of file
G M-> end of file
C-f C-v move one page down
C-b M-v move one page up
Vim    Emacs    Meaning   
:w C-x C-s save file
:q C-x C-c close editor

Emacs with Evil-mode and ESS install howto for using R

posted on 2013-10-22 11:43:20

While reading a R book, I was in need of a R IDE. Emacs with ESS was one of the options along with Eclipse or RStudio. Of course, there was also a vim alternative. After several attempts on using emacs after years with vim, I never passed even the whole introdutionary tutorial, so this was a reason to try emacs for once again. Learning shortcuts in vim seemed way easier in retrospect. Why not use emacs with vim's shortcuts?

There are several plugins available for this (i.e. Viper, Vimpulse, vim-mode...), but people on seem to agree that Evil-mode trumps them all.

General installation

According to the install howto if the Evil wiki, in Emacs24 has Evil prebuilt into it. I could not load it, even though I had v24. I do not yet know if there is a proper plugin manager for emacs (Considering emacs' age, there has to exist a proper solution?), here is how to fix this by hand. Also UndoTree will be installed, for better undo handling.

cd                  # change to home folder
mkdir -p emacs.d    # create folder if it does not exist yet
cd emacs.d
git clone git://
git clone

Once the files are here, open

emacs .emacs

and insert these lines:

(add-to-list 'load-path "~/.emacs.d/evil")
(add-to-list 'load-path "~/.emacs.d/undo-tree")
(require 'evil)
(evil-mode 1)

Base install is now finished.

ESS: Emacs Speaks Statistics

cd emacs.d
git clone
emacs .emacs

and insert

(load "~/.emacs.d/ESS/lisp/ess-site")
(require 'ess-site)

Now head over to here and get going. :-)

A last note with some shortcuts:

M-x R RET "Start R Console"
C-x C-s "save current file"
C-x C-c "close emacs"

C is CTRL, i.e. C-x means Ctrl+x. RET is the Return key.

Next step for deepening Emacs knowledge is probably an elisp-howto...

This blog covers .csv, .htaccess, .pfx, .vmx, /etc/crypttab, /etc/network/interfaces, /etc/sudoers, /proc, 10.04, 14.04, AS, ASA, ControlPanel, DS1054Z, GPT, HWR, Hyper-V, IPSEC, KVM, LSI, LVM, LXC, MBR, MTU, MegaCli, PHP, PKI, R, RAID, S.M.A.R.T., SNMP, SSD, SSL, TLS, TRIM, VEEAM, VMware, VServer, VirtualBox, Virtuozzo, XenServer, acpi, adaptec, algorithm, ansible, apache, apache2.4, apachebench, apple, applet, arcconf, arch, architecture, areca, arping, asa, asdm, autoconf, awk, backup, bandit, bar, bash, benchmarking, binding, bitrate, blackarmor, blockdev, blowfish, bochs, bond, bonding, booknotes, bootable, bsd, btrfs, buffer, c-states, cache, caching, ccl, centos, certificate, certtool, cgdisk, cheatsheet, chrome, chroot, cisco, clamav, cli, clp, clush, cluster, coleslaw, colorscheme, common lisp, configuration management, console, container, containers, controller, cron, cryptsetup, csync2, cu, cups, cygwin, d-states, database, date, db2, dcfldd, dcim, dd, debian, debug, debugger, debugging, decimal, desktop, df, dhclient, dhcp, diff, dig, display manager, dm-crypt, dmesg, dmidecode, dns, docker, dos, drivers, dtrace, dtrace4linux, du, dynamictracing, e2fsck, eBPF, ebook, efi, egrep, emacs, encoding, env, error, ess, esx, esxcli, esxi, ethtool, evil, expect, exportfs, factory reset, factory_reset, factoryreset, fail2ban, fbsd, fdisk, fedora, file, filesystem, find, fio, firewall, firmware, fish, flashrom, forensics, free, freebsd, freedos, fritzbox, fsck, fstrim, ftp, ftps, g-states, gentoo, ghostscript, git, git-filter-branch, github, gitolite, global, gnutls, gradle, grep, grml, grub, grub2, guacamole, hardware, haskell, hdd, hdparm, hellowor, hex, hexdump, history, howto, htop, htpasswd, http, httpd, https, i3, icmp, ifenslave, iftop, iis, imagemagick, imap, imaps, init, innoDB, innodb, inodes, intel, ioncube, ios, iostat, ip, iperf, iphone, ipmi, ipmitool, iproute2, ipsec, iptables, ipv6, irc, irssi, iw, iwconfig, iwlist, iwlwifi, jailbreak, jails, java, javascript, javaws, js, juniper, junit, kali, kde, kemp, kernel, keyremap, kill, kpartx, krypton, lacp, lamp, languages, ldap, ldapsearch, less, leviathan, liero, lightning, links, linux, linuxin3months, lisp, list, livedisk, lmctfy, loadbalancing, locale, log, logrotate, looback, loopback, losetup, lsblk, lsi, lsof, lsusb, lsyncd, luks, lvextend, lvm, lvm2, lvreduce, lxc, lxde, macbook, macro, magento, mailclient, mailing, mailq, manpages, markdown, mbr, mdadm, megacli, micro sd, microsoft, minicom, mkfs, mktemp, mod_pagespeed, mod_proxy, modbus, modprobe, mount, mouse, movement, mpstat, multitasking, myISAM, mysql, mysql 5.7, mysql workbench, mysqlcheck, mysqldump, nagios, nas, nat, nc, netfilter, networking, nfs, nginx, nmap, nocaps, nodejs, numberingsystem, numbers, od, onyx, opcode-cache, openVZ, openlierox, openssl, openvpn, openvswitch, openwrt, oracle linux, org-mode, os, oscilloscope, overview, parallel, parameter expansion, parted, partitioning, passwd, patch, pct, pdf, performance, pfsense, php, php7, phpmyadmin, pi, pidgin, pidstat, pins, pkill, plasma, plesk, plugin, posix, postfix, postfixadmin, postgres, postgresql, poudriere, powershell, preview, profiling, prompt, proxmox, ps, puppet, pv, pveam, pvecm, pvesm, pvresize, python, qemu, qemu-img, qm, qmrestore, quicklisp, quickshare, r, racktables, raid, raspberry pi, raspberrypi, raspbian, rbpi, rdp, redhat, redirect, registry, requirements, resize2fs, rewrite, rewrites, rhel, rigol, roccat, routing, rs0485, rs232, rsync, s-states, s_client, samba, sar, sata, sbcl, scite, scp, screen, scripting, seafile, seagate, security, sed, serial, serial port, setup, sftp, sg300, shell, shopware, shortcuts, showmount, signals, slattach, slip, slow-query-log, smbclient, snmpget, snmpwalk, software RAID, software raid, softwareraid, sophos, spacemacs, spam, specification, speedport, spi, sqlite, squid, ssd, ssh, ssh-add, sshd, ssl, stats, storage, strace, stronswan, su, submodules, subzone, sudo, sudoers, sup, swaks, swap, switch, switching, synaptics, synergy, sysfs, systemd, systemtap, tar, tcpdump, tcsh, tee, telnet, terminal, terminator, testdisk, testing, throughput, tmux, todo, tomcat, top, tput, trafficshaping, ttl, tuning, tunnel, tunneling, typo3, uboot, ubuntu, ubuntu 16.04, udev, uefi, ulimit, uname, unetbootin, unit testing, upstart, uptime, usb, usbstick, utf8, utm, utm 220, ux305, vcs, vgchange, vim, vimdiff, virtualbox, virtualization, visual studio code, vlan, vmstat, vmware, vnc, vncviewer, voltage, vpn, vsphere, vzdump, w, w701, wakeonlan, wargames, web, webdav, weechat, wget, whois, wicd, wifi, windowmanager, windows, wine, wireshark, wpa, wpa_passphrase, wpa_supplicant, x11vnc, x2x, xfce, xfreerdp, xmodem, xterm, xxd, yum, zones, zsh

Unless otherwise credited all material Creative Commons License by sjas