unsealed counsel

Posts tagged "emacs":

Operating on numbers with emacs hydra

05 Jul 2015

Operating on numbers in place in any emacs buffer is one of the cool features that no one thinks they need, but is surprisingly handy, especially for converting bit-masks between decimal and hexadecimal during programming. Akinori Musha's operate-on-number package makes it very easy to set it up with a single keybinding. The only minor issue is that the instructions for setting it up refer to smartrep while my preferred package for setting up such keybindings is hydra. Assuming a recent enough version of hydra (where an escaping bug has been fixed), here is the elisp code needed to set up operate-on-number using hydra:

...
Tags: emacs hydra elisp

Firestarter with project root directories

29 Jun 2015

firestarter is an emacs package used for running arbitrary commands upon saving a file. Out of the box, it comes with support for running shell commands, elisp functions and arbitrary emacs lisp code. The most interesting and likely most common use case is to run shell commands. firestarter provides an interesting format specification for shell commands, e.g., %f is replaced by the name of the file backing the buffer, %p by the path to the file, etc.

...
Tags: emacs firestarter magit

Make company-yasnippet play nice

20 Jun 2015

Company mode is an excellent completion mechanism for emacs, much better than its documentation would lead one to believe. The best keybinding for company mode completion to common prefix is TAB, which, however, is also the best keybinding for yasnippet. The simplest solution would seem to be to use company mode to drive yasnippet. Such a back end for company mode already exists: company-yasnippet bundled with company mode. By default, company-yasnippet is not enabled since it is painful to use with other back ends. My solution has been to bind shift+TAB (called <backtab> in emacs keymap lingo) to company-yasnippet and not enable it by default, but the problem is that the default company mode completion is activated after typing in a snippet prefix, and sets up a transient keymap that simply ignores shift+TAB. We can work around the problem with a little bit of elisp:

...
Tags: emacs company-mode yasnippet

Emacs dummy headers mode without Objective C

14 Jun 2015

Choosing between C mode and C++ mode in emacs for header files can be a bit of a chore if both types of header files have a .h extension. As usual, a package for solving this problem already exists: dummy-h-mode. One of the heuristics that it uses is to search for an implementation file and then to check the extension of that implementation file for a hint on the mode. This heuristic works very well, but with a minor annoyance that it tries to handle Objective C headers as well. In my use case, I sometimes have purely template-based C++ code and a test implementation in Matlab or octave:

...
Tags: emacs dummy-headers C C++

Text-based email setup with mbsync and mu

15 Jul 2014

Composing mail without the assistance of emacs is painful for serious emacs users. KMail (supplemented with emacsclient) had been my email client of choice for more than a decade. While KMail continues to be an excellent mail client, I started looking more into moving my entire email flow into emacs. Sending mail from emacs is pretty easy with smtpmail; so the only issue was finding a way to fetch and display email. After trawling The Interwebz, mu4e seemed to fit in best with my workflow.

...
Tags: emacs mu mbsync gpg
Other posts
Creative Commons License
runes.lexarcana.com by Ravi R Kiran is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License .