"I" before "E" except Gleitzman

Posts tagged "Emacs"

6 posts with this tag

Howdoi use howdoi in Emacs?

Howdoi use howdoi in Emacs?

One of my favorite things about howdoi is the portability - meaning that you can get instant coding answers anywhere (not just on the command line). Contributors have created integrations for howdoi on Slack, Telegram, Discord, Visual Studio Code, and Alfred (just to name a few!).

As an Emacs user, you can use the code snippet below to get instant answers inside Emacs.


(defun howdoi (start end command)
  (interactive
   (let ((command "xargs -0 howdoi"))
     (if (use-region-p)
         (list (region-beginning) (region-end) command)
       (list (line-beginning-position) (line-end-position) command))))
  (let ((response (shell-command-on-region-to-string start end command)))
    (kill-new response)
  (save-excursion
    (end-of-visual-line)
    (newline)
    (insert (shell-command-on-region-to-string start end command)))))

(defun shell-command-on-region-to-string (start end command)
  (with-output-to-string
    (shell-command-on-region start end command standard-output)))

Then, when you want to know how to # format a date in bash you can invoke M-x howdoi on that line and voila!

Emacs Initialization, Organization, and Configuration

Emacs Initialization, Organization, and Configuration

A quality developer is constantly on the lookout for a quality tool. With a bit of poetic license on a phrase coined by Sackman, Erikson, and Grant:

There are order-of-magnitude differences among programming tools.

Although there are a number of tools in my belt, Emacs is my primary swiss army knife / operating system. I use Emacs for editing Python, Javascript, Lisp, Scala, Java, HTML, CSS, Markdown, and LaTeX. I use it for managing git repositories. It’s my psychologist and my blog editor.

Open Files on Github from Emacs

Open Files on Github from Emacs

In the course of a project it helps to share pointers to specific files and lines of code with others. I use Github for this task, sharing URLs like: https://github.com/gleitz/howdoi/blob/master/howdoi/howdoi.py#L156

When sharing URLs from a project with deep directories (Scala/Java) it can be a real pain to open github.com, pick a branch, and then click through src/com/blah/blah folders until you find the file. Instead, use this command-line Python script to generate a Github URL directly from a file or directory. Also included is an elisp function to generate URLs from Emacs.

Hunting for Unicode in Emacs

Hunting for Unicode in Emacs

<nerdy>

Emacs has wonderful Unicode support. Copy and paste text from a Word document and Emacs will happily preserve your smart quotes, ellipses, and em dashes. There isn’t a canonical way, however, to strip these “special” characters into their more sane ASCII counterparts.

The unix command tidy does a good job of converting Unicode characters but you are left with ugly HTML equivalents like € instead of the usual quote character. We’ll need an alternative for Emacs, preferably written in Emacs lisp.

Cup a' joe

Cup a’ joe

After celebrating a couple years of not having to deal with the GridBagLayout, I’m dusting off the JVM to give Java another try. However, I’m not quite ready to leave Emacs for Eclipse (don’t mention the doppelgänger keyboard layout – it’s not the same).

Two features I miss from Eclipse are source code navigation and tight server integration. Especially when familiarizing yourself with a new codebase, jumping around within the source can be an excellent tool.

Deterministic Navigation, or, Learning from Vim

Deterministic Navigation, or, Learning from Vim

Recently I had the excellent opportunity to hang out and talk shop with Kyle Wild about the state of Computer Science, CS education, and software development environments. While the former are discussions for later posts, the latter will be part of a series elucidating the good parts of Emacs and Vim.

Parties on both sides of the holy war seem to get more distracted with partisan bickering than figuring out how to best get the code out of your head and into a computer. As an Emacs programmer, I’m interested in how I can incorporate the useful bits of Vim. Kyle, coming from the Vim world, wanted to more clearly understand the pros and cons of using one IDE over another before investing the time required to make the switch. However you currently code, I suggest looking over the shoulder of a friend using a different IDE – you’re bound to learn something.