Irreal: Pages in Emacs

Eric James Michael Ritz over at One More Game-Dev and Programming Blog has a nice post on how and why to use pages in Emacs. Pages in Emacs are text separated by form feeds (0xC)1. As Ritz explains, it's easy to move between pages by using 【Ctrl+x [】 (backward-page) and 【Ctrl+x ]】 (forward-page).

Most of us don't use pages but Ritz gives us a good use case. As he points out, you can install a package such as Steve Purcell's page-break-lines package that will make the breaks explicit and others that make navigation easier. Go read his post and see if you can make pages work for you.



Although, like everything else in Emacs, that's configurable. It's controlled by the page-delimiter variable.

-1:-- Pages in Emacs (Post jcs)--L0--C0--September 02, 2015 07:16 PM

Pragmatic Emacs: Org-mode basics II: use simple tables in your notes

In the first post of this series we looked at using org-mode to structure your notes. Today we’ll look at adding simple tables to your notes. Later we’ll see how these tables can be used for advanced features like spreadsheet style calculations, or using them as the input and/or output of code, and also how they export nicely in html or pdf documents. For now we’ll just use them as simple static tables in our notes.

I suggest adding the text below to the org file from last time to build an org-mode notebook on how to keep org-mode notebooks!

* Tables
Hopefully you can see straight away that the simple structure provided
by org-mode gives a nice way to keep an electronic note book.

Often it is nice to include tables in our notes. Org handles this by
using | to separate columns, and a line of --- (inserted with C-c -)
to add horizontal lines.

Exercise: start typing in this table below; type the first line in
 1) when you get to the "s" of comments, press TAB to go to the next
 2) go up to the previous line and use C-c - to add the row of dashes
 3) next enter a few lines of data, using TAB to go through the
    cells - you should notice the columns changing width as needed

| ID | x |  y | comments       |
| A  | 2 |  4 | blah           |
| B  | 3 |  9 | blah           |
| C  | 4 | 16 | blah blah blah |
| D  | 5 | 25 | blah           |

Now, you can move rows and columns around using M-arrow and insert or
delete rows and columns using M-S-arrow. Try this out now.

** Creating and exporting tables
You can create an empty table using C-c | to run the command
org-table-create-or-convert-from-region, which will prompt for table
dimensions if no region is selected.

The same command can easily convert some text to a table; select the
following text and use C-c | to run the command
org-table-create-or-convert-from-region again to convert the text to a

 ID  x   y
 A   2   4
 B   3   9
 C   4  16
 D   5  25

You can also save tables to their own files by putting the cursor in
the table and using M-x org-table-export. You'll be asked for a
file name and a format. For the format, type orgtbl-to and press TAB
to see the available options (e.g. orgtbl-to-csv will convert to csv
in the output file).

** Formulae
You can use formulae to do arithmetic on tables, and use them like a
spreadsheet. This is something I keep meaning to use more often, but
don't generally find I need it. One useful command is C-c + which runs
org-table-sum to sum the numbers in the current column.

For more on this, see e.g. this introduction. Notice that we just
added a link in our org-mode file - this is a teaser for what we will
cover next!
-1:-- Org-mode basics II: use simple tables in your notes (Post Ben Maughan)--L0--C0--September 01, 2015 07:41 PM

Irreal: Org Mode and Pandoc

Bsag over at But She's a Girl has a nice post on using Org mode and Pandoc. She says that she's abandoned Markup in favor of Org mode because, among other things, it provides a rich set facilities for handling the structured text. You can move headers and their associated trees up or down and you can promote or demote them in the hierarchy. And, of course, it has especially rich table editing capabilities. Markup is wonderful and all<img src=—" class="wp-smiley" style="height: 1em; max-height: 1em;" />I mean that<img src=—" class="wp-smiley" style="height: 1em; max-height: 1em;" />but if you're using Emacs as your editor, Org brings you everything Markdown does and much more. You really should be using it.

I've written extensively about my own system of using Org mode for writing. Normally, that means I write in Org and then export to HTML, PDF, or this blog. I use the native Org exporters for that so I don't usually need Pandoc. Bsag, has gone another route and uses ox-pandoc as her export engine. That means that all the conversion is done by Pandoc. I don't know if that's better or worse than my system but if you're just getting started you might want to give bsag's systems a try.

She also mentions using Org and Pandoc to implement a lab notebook. If you're working in the sciences and need to keep a lab notebook, you should definitely give her post a read.

-1:-- Org Mode and Pandoc (Post jcs)--L0--C0--September 01, 2015 01:21 PM

Endless Parentheses: Org-mode subtrees and file-local variables

As you grow accustomed to fine-tuning your Emacs experience, it’s not unusual to start using local variables in your files. These are specified as comment lines at the of the file, and are extremely practical in a number of scenarios. Here’s a very simple org file.

* Some headline
Ramblings no one cares about.
* Another headline
Thoughtfully rescinded.

# Local Variables:
# fill-column: 666
# End:

The only problem is that org-mode thinks that everything after a headline is part of its contents, which is clearly not the case here. One example where this is bad is when you want to shuffle the headlines around with M-↓ or M-↑, and you end up with something like this.

* Another headline
Thoughtfully rescinded.

# Local Variables:
# fill-column: 666
# End:
* Some headline
Ramblings no one cares about.

I asked about that on Emacs.StackExchange and got a very simple solution: just add a “dummy” level-1 headline before the local variable specification.

* Some headline
Ramblings no one cares about.
* Another headline
Thoughtfully rescinded.

* COMMENT Footer 
# Local Variables:
# fill-column: 42
# End:

Now you can move, archive, and refile all your headlines as you wish, without fear of destroying your precious variables. You can even fine-tune the visibility to folded, so that the footer is always folded, and you won’t have to see those variables at all.

But this wouldn’t be our weekly Endless Parentheses if I didn’t give you some code to practice your elisp. The following command is just like end-of-buffer, except it places point before the footer. If invoked again, it will move to the real end of buffer.

(defun endless/org-eob ()
  "Move to end of content, then end of buffer."
  (unless (use-region-p)
  (if (looking-at-p "\n\\* COMMENT Footer")
      (goto-char (point-max))
    (goto-char (point-min))
    (if (search-forward "\n* COMMENT Footer"
                        nil 'noerror)
        (goto-char (match-beginning 0))
      (goto-char (point-max)))))
(define-key org-mode-map [remap end-of-buffer]

Comment on this.

-1:-- Org-mode subtrees and file-local variables (Post)--L0--C0--September 01, 2015 12:00 AM

Jorgen Schäfer: Elpy 1.9.0 released

I just released version 1.9.0 of Elpy, the Emacs Python Development Environment. This is a feature release.

Elpy is an Emacs package to bring powerful Python editing to Emacs. It combines a number of other packages, both written in Emacs Lisp as well as Python.

Quick Installation

Evaluate this:

(require 'package)
(add-to-list 'package-archives
'("elpy" .

Then run M-x package-install RET elpy RET.

Finally, run the following (and add them to your .emacs):


Changes in 1.9.0

  • Elpy now supports the autopep8 library for automatically formatting Python code. All refactoring-related code is now grouped under C-c C-r. Use C-c C-r i to fix up imports using importmagic, C-c C-r p to fix up Python code with autopep8, and C-c C-r r to bring up the old Rope refactoring menu.
  • C-c C-b will now select a region containing surrounding lines of the current indentation or more.
  • C-c C-z in a Python shell will now switch back to the last Python buffer, allowing to use the key to cycle back and forth between the Python buffer and shell.
  • The pattern used for C-c C-s is now customizeable in elpy-rgrep-file-pattern.
  • <C-return> now can be used to send the current statement to the Python shell. Be careful, this can break with nested statements.
  • The Elpy minor mode now also works in modes derived from python-mode, not just in the mode itself.

Thanks to ChillarAnand, raylu and Chedi for their contributions!

-1:-- Elpy 1.9.0 released (Post Jorgen Schäfer ( 30, 2015 12:18 PM

Grant Rettke: Org2Blog DITAA Test


The test succeeded by turning off thumbnail images.

-1:-- Org2Blog DITAA Test (Post Grant)--L0--C0--August 30, 2015 02:39 AM

Grant Rettke: Migrating to Org2Blog

WordPress is a powerful and satisfying writing and publishing platform. After learning Org-Mode, I wanted to use Org-Mode for writing and WordPress for publishing. Org2Blog makes that easy.

WordPress easily exports your posts to XML. Org2Blog-Importers converts them to Org-Mode via Pandoc. Tonight I converted them here. Any future modifications belong in these documents with publishing to WordPress.

I tested both publishing new posts and modifying and re-publishing old posts and both worked correctly.

-1:-- Migrating to Org2Blog (Post Grant)--L0--C0--August 30, 2015 02:19 AM

Eric James Michael Ritz: Using Page-Breaks in GNU Emacs

Today I want to talk about the concept of pages in GNU Emacs, how I use them, and why I use them. In my experience pages are often overlooked by Emacs users, most likely because they look ugly, but I will show you a package to deal with that. And along the way I will show you a package that I use to make it easier to navigate between pages.

A Crash Course Introduction to Pages

‘Pages’ in Emacs refers to text separated by the form-feed character, i.e. the ^L character, meaning Ctrl+L. We can type this character by pressing C-q C-l. Using C-q tells Emacs to directly insert whatever key you press next. Normally C-l runs the recenter-top-bottom command. And so we cannot simply type C-l to get the form-feed character. But C-q C-l tells Emacs to ignore any command bound to C-l and thus inserts a literal ^L, the character we need to separate text into pages.

We use C-x [ and C-x ] to move backward and forward through pages, respectively. Those keys, by default, invoke the backward-page and forward-page commands. By pressing C-x C-p we can mark whatever page we are on.

And that’s pretty much it. Later I will come back to talk about some packages to help us navigate pages. But this is all we need to know in order to get started with pages.

Why Use Pages?

I like to use pages, particularly in programming, as a means to divide content into sections. For our game, my studio has recently created the Chance library. The source code has page-breaks dividing each section, although you won’t seem them on GitHub; they will appear as blank lines, e.g. line 228. But in Emacs that page-break line looks like this.

What turns those ugly ^L characters into those pretty horizontal lines? Steve Purcell’s terrific page-break-lines package.

The Chance library uses LDoc for generating its documentation—a form of Javadoc for Lua. In LDoc one can use the @section markup to group the code into related chunks. I have a page-break directly above each comment block that creates a new @section. Doing so divides the source code itself into the same sections by treating each section as a page in Emacs.

The result is that I can easily navigate through the source code per-section by using pages. I could use the aforementioned C-x [ and C-x ] commands for this navigation, but instead….

A Nicer Way to Navigate Pages

I like to use helm-pages to move between pages in a file. When I invoke helm-pages in the Chance source code this is what I see. Since it shows the first line on each page this results in an easy, and in my opinion pretty, way to quickly move between sections of the code base. The test suite for Chance uses page-breaks in the same way, and again helm-pages works well since the first line on each page is a call to describe() which indicates what part of the library that section tests—I use Busted for the unit tests.


A short article, I know, but honestly there’s nothing else to really say. Hopefully this demonstrates how using pages in Emacs can be a useful way to divide-up source code (or any kind of file) and easily navigate to those divisions as needed. If you have never used pages in Emacs then give it a try sometime because, like me, you may find it to be a useful tool for organizing a single file into nice, logical chunks which you can jump between quickly and easily.

-1:-- Using Page-Breaks in GNU Emacs (Post ericjmritz)--L0--C0--August 29, 2015 10:19 PM

Pragmatic Emacs: Fix touch-typing semicolon typo

I’ve started learning to touch type (for the nth time) and I find I make a lot of typos. Most are easily fixed with flyspell’s C-;, but I quite often hit ; instead of l, which flyspell can’t fix as it looks like the end of a word. I wrote a quick bit of code to replace the most recent ; with l…

;;fix ; typos
(defun bjm-semicolon-to-l ()
  "Change the most recent semicolon behind the point to an l character. Useful for fixing a common touch-typing error"
  (let ((bjm-start-pos (point)))
    (search-backward ";")
    (delete-char 1)
    (insert "l")
    (goto-char bjm-start-pos)))

(global-set-key (kbd "C-:") 'bjm-semicolon-to-l)

This is pretty simplistic, but it shows how easy it is to add a very personalised bit of extra functionality to emacs with minimal lisp skills!

-1:-- Fix touch-typing semicolon typo (Post Ben Maughan)--L0--C0--August 28, 2015 08:56 AM

(or emacs: Complete Python symbols using Ivy

I had a fascination with Python at one point, until I got too annoyed with the indentation rules. I still have a few scripts left over, so I'm sympathetic to Python support in Emacs. The reason for today's post comes from this question on Emacs StackExchange. Essentially, the user wants to insert parens automatically when a function name is completed.

The completion candidates come from jedi plugin. To quickly see where the list of strings is coming from, I've examined ac-sources variable and saw that it contains ac-source-jedi-direct, which evaluates to:

((candidates . jedi:ac-direct-matches)
 (prefix . jedi:ac-direct-prefix)
 (init . jedi:complete-request)
 (requires . -1))

This means that jedi:complete-request has to be called at point, followed by jedi:ac-direct-matches to obtain the list of strings. So basically, this code:


Note the call to deferred:sync!. I had to add that one to make sure that jedi:complete-request completes before jedi:ac-direct-matches is called.

Testing with some Python code, where | is the point:

params = {"foo":"bar"}

The Elisp code above will return:

   0 5 (summary
        "function: __builtin__.dict.items"

D.items() -> list of D's (key, value) pairs, as 2-tuples"))
    0 9 (summary
         "function: __builtin__.dict.iteritems"

D.iteritems() -> an iterator over the (key, value) items of D"))
    0 8 (summary
         "function: __builtin__.dict.iterkeys"

D.iterkeys() -> an iterator over the keys of D"))
    0 10 (summary
          "function: __builtin__.dict.itervalues"

D.itervalues() -> an iterator over the values of D")))

So these strings come with the symbol documentation and symbol type encoded as string properties. After this, the rest of the Elisp code follows very easily, you can find it as part of counsel package on MELPA:

(defun counsel-jedi ()
  "Python completion at point."
  (let ((bnd (bounds-of-thing-at-point 'symbol)))
    (if bnd
          (setq counsel-completion-beg (car bnd))
          (setq counsel-completion-end (cdr bnd)))
      (setq counsel-completion-beg nil)
      (setq counsel-completion-end nil)))
  (ivy-read "Symbol name: " (jedi:ac-direct-matches)
            :action #'counsel--py-action))

(defun counsel--py-action (symbol)
  "Insert SYMBOL, erasing the previous one."
  (when (stringp symbol)
      (when counsel-completion-beg
      (setq counsel-completion-beg
            (move-marker (make-marker) (point)))
      (insert symbol)
      (setq counsel-completion-end
            (move-marker (make-marker) (point)))
      (when (equal (get-text-property 0 'symbol symbol) "f")
        (insert "()")
        (setq counsel-completion-end
              (move-marker (make-marker) (point)))
        (backward-char 1)))))

Essentially, the last interesting part is (equal (get-text-property 0 'symbol symbol) "f") which test if the string corresponds to a function or not. The rest of the code just fiddles with symbol markers with ensure that the previous symbol is erased before the new symbol is inserted if you press C-M-n (ivy-next-line-and-call), or use ivy-resume. Just to describe how this would be useful for the Python code above: I call counsel-jedi, followed by C-M-n to get:

params = {"foo":"bar"}

Pressing C-M-n again will result in:

params = {"foo":"bar"}

Once I'm satisfied with my selected candidate, I can press either C-m or C-j or C-g. Most of the above code can be used almost verbatim if you're a Helm fan and want to implement helm-jedi. Basically, the approach I described (going through ac-sources) can be used to implement alternative completion in a lot of cases where auto-complete-mode completion is already available.

Finally, if you like the idea of auto-inserting parens with completion and are using C/C++, have a look at function-args - this package does that too, with Ivy, Ido and Helm as available back ends.

-1:-- Complete Python symbols using Ivy (Post)--L0--C0--August 25, 2015 10:00 PM

Timo Geusch: Embedding YouTube vidoes via org-mode

Artur Malabarba over on Endless Parentheses has a short post about embedding a YouTube video directly from org-mode. I haven’t tried using it in org2blog yet, but I’m hoping/expecting that it’ll work there, too. It’s a very timely post as I’ve got a couple of Emacs related short video tutorials planned that would really benefit… Read More »

The post Embedding YouTube vidoes via org-mode appeared first on The Lone C++ Coder's Blog.

-1:-- Embedding YouTube vidoes via org-mode (Post Timo Geusch)--L0--C0--August 24, 2015 07:07 PM

Endless Parentheses: Making Ispell work with org-mode

If you’ve every tried to do some spell-checking in org-mode you know how finicky that can be. Ispell is happy to check absolutely anything, even code blocks and property drawers! When you’re blogging about code-snippets from an org file this annoyance quickly turns into irritation. Here’s how you fix it.

(defun endless/org-ispell ()
  "Configure `ispell-skip-region-alist' for `org-mode'."
  (make-local-variable 'ispell-skip-region-alist)
  (add-to-list 'ispell-skip-region-alist '(org-property-drawer-re))
  (add-to-list 'ispell-skip-region-alist '("~" "~"))
  (add-to-list 'ispell-skip-region-alist '("=" "="))
  (add-to-list 'ispell-skip-region-alist '("^#\\+BEGIN_SRC" . "^#\\+END_SRC")))
(add-hook 'org-mode-hook #'endless/org-ispell)

Comment on this.

-1:-- Making Ispell work with org-mode (Post)--L0--C0--August 24, 2015 12:00 AM

Mathias Dahl: Something I should have done a long time ago...

This is something I should have done a long time ago, to make window creation and manipulation easier in Emacs:

(global-set-key (kbd "C-1") 'delete-other-windows)
(global-set-key (kbd "C-2") 'split-window-below)
(global-set-key (kbd "C-3") 'split-window-right)
(global-set-key (kbd "C-0") 'delete-window)

It gives the window manipulating commands I use the most nicer key bindings; just by keeping the Ctrl key pressed and typing away (crazily) on the keys 2 and 3 you can create master pieces of window configurations :)

I could do this since I realized I seldom or never use these shortcuts to enter a numeric argument. If I need to, I can use a slightly longer key sequence like C-u 1 or M-1 which I have kept (for now...).

Perhaps this post will inspire someone else to do the same.

-1:-- Something I should have done a long time ago... (Post Mathias Dahl ( 21, 2015 11:47 AM

Flickr tag 'emacs': Purpel Flags

timonoko posted a photo:

Purpel Flags

My - mapserver had no bookmarking ability. First time I ever needed those to mark good berry spots. I can execute major software projects on phone+emacs alone. Slowly yes, but then it is also bug-free code. Flag-icon made with Gimp on UbuntuOnAndroid, of course.

-1:-- Purpel Flags (Post timonoko ( 18, 2015 10:07 AM

Timo Geusch: Building Emacs on OS X using homebrew

I’ve recently switched to using homebrew as my source for Emacs on OS X  after seeing this blog post by Philip Ingram. It’s a simple way to install a current Emacs once or twice a year. I don’t use beta versions or other pre-release versions, only released versions. My editor is too important a tool… Read More »

The post Building Emacs on OS X using homebrew appeared first on The Lone C++ Coder's Blog.

-1:-- Building Emacs on OS X using homebrew (Post Timo Geusch)--L0--C0--August 18, 2015 01:51 AM

Flickr tag 'emacs': sql-mode

zatsu posted a photo:


-1:-- sql-mode (Post zatsu ( 17, 2015 10:56 PM

Ryan Rix: Automatic Workflows in Org-Mode

I recently implemented a system for automatically moving among a list of Org-mode tasks, which I call *TaskFlows*. The idea is simple: tag a project as a taskflow, and when you complete a task, it automatically clocks in to the next task. It's incredibly simple, being only about 20 lines of code on top of Bernt Hansen's org-mode system, but the implications are quite nice for me.
-1:-- Automatic Workflows in Org-Mode (Post)--L0--C0--August 16, 2015 12:00 AM

Sebastian Wiesner: Emojis in Emacs

I’ve recently found the best Emacs package ever: company-emoji. It’s a Company source for Emoji input 😍.

Emoji input with CompanyEmoji input with Company

Just install from MELPA, enable it with (add-to-list 'company-backends 'company-emoji) and enjoy 😍 👍

-1:-- Emojis in Emacs (Post)--L0--C0--August 16, 2015 12:00 AM

sachachua: August 2015 Emacs Hangout

Thanks to Philip Stark for hosting this one!

Text chat:

Paul Harper 2:08 PM Evan’s Links: Dart Throwing Chimp:
Philip Stark 2:15 PM
Paul Harper 2:19 PM mu4e: Zawinski’s Law “Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.” Law of Software Envelopment, Jamie Zawinski. Mutt with Org-Mode:
me 2:23 PM Maybe ?
Magnus Henoch 2:24 PM I mashed some of those together into this monster: link (
Mond Beton 2:25 PM org mode is new
Rogelio Zarate 2:26 PM Just started with emacs
Paul Harper 2:27 PM Emacs and Vim started in 1976 link (
me 2:28 PM Was it this Err, link ( ?
Paul Harper 2:41 PM Not sure if this might help. Setting up Emacs key mappings on Windows Outlook link (
me 2:42 PM suggests XKeymacs, but I don’t know if it will work with recent versions of Windows.
Mond Beton 2:44 PM thank you
Rogelio Zarate 2:48 PM Too many opinions on how to do things, example keybing on emacs/os x
me 2:50 PM link ( may be helpful if you want it to reuse an existing Emacs if possible
Daniel Gopar 2:58 PM
Paul Harper 2:59 PM Something for beginners like me. A course in research tools which includes some clear videos on using Emacs. Kurt Schwehr put the course on YouTube (linked in note) and the course is in org mode. The Course itself is GIS focused. You can download the whole thing with Mercurial. Instructions on the page. I found it very helpful when I started.
Philip Stark 3:02 PM What’s GIS?
me 3:03 PM Phil: Hmm, something like using tags?
Philip Stark 3:05 PM
Philip Stark 3:07 PM
Daniel Gopar 3:09 PM so im learning elisp. Does elisp have any ways of creating private/public variables? or is everything exposed once you run the require command on the file?
Philip Stark 3:09 PM
Rogelio Zarate 3:14 PM How do you handle projects, like in Sublime, do you use Projectile or Perspective?
Philip Stark 3:14 PM
me 3:16 PM and
Philip Stark 3:18 PM
Rogelio Zarate 3:19 PM Keeping just one list sounds like the correct approach. Great tip.
me 3:19 PM link (
Paul Harper 3:21 PM Notmuch
me 3:29 PM Want to get notified about upcoming hangouts? You can sign up for notifications at

The post August 2015 Emacs Hangout appeared first on sacha chua :: living an awesome life.

-1:-- August 2015 Emacs Hangout (Post Sacha Chua)--L0--C0--August 14, 2015 04:41 PM

(or emacs: Store all current ivy candidates into the kill ring

I'd like to highlight a new command added to ivy-mode today: ivy-kill-ring-save. It allows to store all current candidates to the kill ring. This could have a number of uses.

Scenario 1

Suppose you want to learn some Elisp, specifically all functions that start with forward-. Then call counsel-describe-function with "forward-" as input and press M-w. Then just yank this into some buffer, org-mode for instance, and go through the functions one-by-one takings notes on the way:


Scenario 2

Suppose you want to store a subset of projectile-find-file names that match a pattern. Just press M-w and those file names will be on the top of the kill ring. Of course, you need to have this setting on:

(setq projectile-completion-system 'ivy)

This scenario should apply to basically any place where you're completing file names, like counsel-locate or counsel-find-file. Also find-file-in-project, which uses ivy for completion if it's installed.


Note also that the command comes for free, since normally nothing is done by M-w when the region isn't active. When the region is active, this command will store the selected text instead of matched candidates.

Thanks to @drorbemet for giving me the idea in #197.

-1:-- Store all current ivy candidates into the kill ring (Post)--L0--C0--August 13, 2015 10:00 PM

Julien Danjou: Reading with Pocket

I've started to use Pocket a few months ago to store my backlog of things to read. It's especially useful as I can use it to read content offline since we still don't have any Internet access in places such as airplanes or the Paris metro. It's only 2015 after all.

I am also a subscriber for years now, and I really like their articles from the weekly edition. Unfortunately, as the access is restricted to subscribers, you need to login: it makes it impossible to add these articles to Pocket directly. Sad.

Yesterday, I thought about that and decided to start hacking on it. LWN provides a feature called "Subscriber Link" that allows you to share an article with a friend. I managed to use that feature to share the articles with my friend… Pocket!

As doing that every week is tedious, I wrote a small Python program called lwn2pocket that I published on GitHub. Feel free to use it, hack it and send pull requests.

-1:-- Reading with Pocket (Post Julien Danjou)--L0--C0--August 13, 2015 04:39 PM

Aidan McQuay: emacsclientw.exe Opens New Frames on Windows 7

There is an issue specific to Windows 7 that will cause emacs open new frames even if you have the server running. I believe for me there are actually two issues:

1) The emacs server file cannot be stored anywhere except within %appdata% so if you run your home from Dropbox or somesuch thing you will have to add this to force the server file back to the appdata directory:

(if (string= system-name "MATH-PC")
  (setq server-auth-dir (concat (getenv "APPDATA") "/.emacs.d/server")))

2) The server directory had to be owned by the same user as is running emacs. Typically you will run emacs from a normal user and the directory will below to Administrator. To fix this you need to browse to “%appdata%/.emacs.d/server” in explorer and change the ownership of the directory to your windows username:

-1:-- emacsclientw.exe Opens New Frames on Windows 7 (Post Aidan McQuay)--L0--C0--August 10, 2015 09:21 PM

Jorgen Schäfer: Circe 2.0 released – Circe turns 10

We just released version 2.0 of Circe, the Client for IRC in Emacs.

Circe is a Client for IRC in Emacs. It tries to have sane defaults, and integrates well with the rest of the editor, using standard Emacs key bindings and indicating activity in channels in the status bar so it stays out of your way unless you want to use it.

This is an anniversary release – today 10 years ago, Circe has had its first commit! Since then, the code base expanded quite a bit and Circe has gained a lot of good features, contributed by over a dozen people over time. And the client now has a number of users.

It's a weird feeling when you realize that this piece of software you wrote because you were unhappy with the existing solutions not only has been with you for a decade, but has other people using and contributing to it.

Major thanks to all the awesome people I know through this software. On to the next 10 years!

Quick Installation

Evaluate this:

(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "") t)

Then run M-x package-install RET circe RET.

After this, M-x circe should work.

Changes in 2.0

  • Circe has had its IRC backend completely rewritten. It is now a separate library, irc.el, and much more powerful. Alas, this means a lot of existing configuration code will break.
  • Because of this, Circe now fully supports SASL authentication, extended joins, and a few other modern IRC capabilities.
  • XKCD references, CVE numbers and github issues are now buttonized.
  • All IRC buffers change to the home directory by default.
  • Circe now uses buttercup for tests and Travis-CI for continuous integration tests.
  • A number of options were removed to focus on sensible defaults. Re-check your configuration.
  • Nick colors are now pre-computed to make them more appropriate for the current display and more distinct from each other.
  • A lot of format strings have been added. Check the circe-format customization group.

Thanks to Vasilij Schneidermann, Taylan Ulrich Bayırlı/Kammer, Steve Purcell and Alex Dunn for their contributions!

-1:-- Circe 2.0 released – Circe turns 10 (Post Jorgen Schäfer ( 10, 2015 11:30 AM

Chen Bin (redguardtoo): Evil text object to select nearby file path

CREATED: <2015-08-08 Sat>

UPDATED: <2015-08-24 Mon>

Insert below code into ~/.emacs:

;; {{ nearby file path as text object,
;;      - "vif" to select only basename
;;      - "vaf" to select the full path
;;  example: "/hello/world" "/test/back.exe"
;;               "C:hello\\hello\\world\\test.exe" "D:blah\\hello\\world\\base.exe"
;; tweak evil-filepath-is-nonname to re-define a path
(defun evil-filepath-is-separator-char (ch)
  "Check ascii table"
  (let (rlt)
    (if (or (= ch 47)
            (= ch 92))
        (setq rlt t))

(defun evil-filepath-not-path-char (ch)
  "Check ascii table for charctater "
  (let (rlt)
    (if (or (and (<= 0 ch) (<= ch 32))
            (= ch 34) ; double quotes
            (= ch 39) ; single quote
            (= ch 40) ; (
            (= ch 41) ; )
            (= ch 60) ; <
            (= ch 62) ; >
            (= ch 91) ; [
            (= ch 93) ; ]
            (= ch 96) ; `
            (= ch 123) ; {
            (= ch 125) ; }
            (= 127 ch))
        (setq rlt t))

(defun evil-filepath-char-not-placed-at-end-of-path (ch)
  (or (= 44 ch) ; ,
      (= 46 ch) ; .

(defun evil-filepath-calculate-path (b e)
  (let (rlt f)
    (when (and b e)
      (setq b (+ 1 b))
      (when (save-excursion
                (goto-char e)
                (setq f (evil-filepath-search-forward-char 'evil-filepath-is-separator-char t))
                (and f (>= f b)))
        (setq rlt (list b (+ 1 f) (- e 1)))))

(defun evil-filepath-get-path-already-inside ()
  (let (b e)
      (setq b (evil-filepath-search-forward-char 'evil-filepath-not-path-char t)))
      (setq e (evil-filepath-search-forward-char 'evil-filepath-not-path-char))
      (when e
        (goto-char (- e 1))
        ;; example: hello/world,
        (if (evil-filepath-char-not-placed-at-end-of-path (following-char))
            (setq e (- e 1)))
    (evil-filepath-calculate-path b e)))

(defun evil-filepath-search-forward-char (fn &optional backward)
  (let (found rlt (limit (if backward (point-min) (point-max))) out)
      (while (not out)
        ;; for the char, exit
        (if (setq found (apply fn (list (following-char))))
            (setq out t)
          ;; reach the limit, exit
          (if (= (point) limit)
              (setq out t)
            ;; keep moving
            (if backward (backward-char) (forward-char)))))
      (if found (setq rlt (point))))

(defun evil-filepath-extract-region ()
  "Find the closest file path"
  (let (rlt

    (if (and (not (evil-filepath-not-path-char (following-char)))
             (setq rlt (evil-filepath-get-path-already-inside)))
        ;; maybe (point) is in the middle of the path
      ;; need search forward AND backward to find the right path
        ;; path in backward direction
        (when (setq b (evil-filepath-search-forward-char 'evil-filepath-is-separator-char t))
          (goto-char b)
          (setq f1 (evil-filepath-get-path-already-inside))))
        ;; path in forward direction
        (when (setq b (evil-filepath-search-forward-char 'evil-filepath-is-separator-char))
          (goto-char b)
          (setq f2 (evil-filepath-get-path-already-inside))))
      ;; pick one path as the final result
       ((and f1 f2)
        (if (> (- (point) (nth 2 f1)) (- (nth 0 f2) (point)))
            (setq rlt f2)
          (setq rlt f1)))
        (setq rlt f1))
        (setq rlt f2))))


(evil-define-text-object evil-filepath-inner-text-object (&optional count begin end type)
  "File name of nearby path"
  (let ((selected-region (evil-filepath-extract-region)))
    (if selected-region
        (evil-range (nth 1 selected-region) (nth 2 selected-region) :expanded t))))

(evil-define-text-object evil-filepath-outer-text-object (&optional NUM begin end type)
  "Nearby path"
  (let ((selected-region (evil-filepath-extract-region)))
    (if selected-region
        (evil-range (car selected-region) (+ 1 (nth 2 selected-region)) type :expanded t))))

(define-key evil-inner-text-objects-map "f" 'evil-filepath-inner-text-object)
(define-key evil-outer-text-objects-map "f" 'evil-filepath-outer-text-object)
;; }}
-1:-- Evil text object to select nearby file path (Post Chen Bin)--L0--C0--August 08, 2015 01:16 PM

sachachua: Org Mode date arithmetic

Whenever I need to get Emacs to prompt me for a date or time (even for non-Org things), I use org-read-date. I love its flexibility. It’s great to be able to say things like +3 for three days from now, fri for next Friday, +2tue for two Tuesdays from now, +1w for next week, and +1m for next month. It’s easy to use org-read-date in Emacs Lisp. Calling it with (org-read-date) (usually as an interactive argument, like so: (interactive (list (org-read-date)))) gives me a date like 2015-08-06 depending on what I type in.

I use org-read-date for non-interactive date calculations, too. For example, if I want to quickly get the Org-style date for tomorrow, I can use org-read-date‘s third parameter (from-string) like this:

(org-read-date nil nil "+1")

Here’s how to calculate relative dates based on a specified date. You can hard-code the base date or use another org-read-date to get it. In this example, I’m getting the Monday after 2015-08-31. Note the use of two + signs instead of just one.

(org-read-date nil nil "++mon" nil (org-time-string-to-time "2015-08-31"))

org-time-string-to-time converts a date or time string into the internal representation for time. You can then extract individual components (ex: month) with decode-time, or convert it to the number of seconds since the epoch with time-to-seconds. Alternatively, you can convert Org time strings directly to seconds with org-time-to-seconds.

If you’re working with days, you can convert time strings with org-time-string-to-absolute. For example, you can use this to calculate the number of days between two dates (including the first day but excluding the last day), like this:

(let ((start-date (org-read-date))
      (end-date (org-read-date)))
  (- (org-time-string-to-absolute end-date)
     (org-time-string-to-absolute start-date)))

To get the month, day, and year, you can use org-time-string-to-time and decode-time, or you can use org-time-string-to-seconds and calendar-gregorian-from-absolute.

To convert internal time representations into Org-style dates, I tend to use (format-time-string "%Y-%m-%d" ...). encode-time is useful for converting something to the internal time representation. If you’re working with absolute days, you can convert them to Gregorian, and then format the string.

So, to loop over all the days between the start and end date, you could use a pattern like this:

(let* ((start-date (org-read-date))
       (end-date (org-read-date))
       (current (org-time-string-to-absolute start-date))
       (end (org-time-string-to-absolute end-date))
  (while (< current end)
    (setq gregorian-date (calendar-gregorian-from-absolute current))
    (setq formatted-date
          (format "%04d-%02d-%02d"
                  (elt gregorian-date 2) ; month
                  (elt gregorian-date 0) ; day
                  (elt gregorian-date 1))) ; year
    ;; Do something here; ex:
    (message "%s" formatted-date)
    ;; Move to the next date
    (setq current (1+ current))))

Alternatively, you could use org-read-date with a default date, like this:

(let* ((start-date (org-read-date))
       (end-date (org-read-date))
       (current start-date))
  (while (string< current end-date)
    ;; Do something here; ex:
    (message "%s" current)
    ;; Move to the next date
    (setq current (org-read-date nil nil "++1" nil (org-time-string-to-time current)))))

There are probably more elegant ways to write this code, so if you can think of improvements, please feel free to share.

Anyway, hope that helps!

The post Org Mode date arithmetic appeared first on sacha chua :: living an awesome life.

-1:-- Org Mode date arithmetic (Post Sacha Chua)--L0--C0--August 06, 2015 12:00 PM

Julien Danjou: Ceilometer, Gnocchi & Aodh: Liberty progress

It's been a while since I talked about Ceilometer and its companions, so I thought I'd go ahead and write a bit about what's going on this side of OpenStack. I'm not going to cover new features and fancy stuff today, but rather a shallow overview of the new project processes we initiated.

Ceilometer growing

Ceilometer has grown a lot since that time when we started it 3 years ago. It has evolved from a system designed to fetch and store measurements, to a more complex system, with agents, alarms, events, databases, APIs, etc.

All those features were needed and asked for by users and operators, but let's be honest, some of them should never have ended up in the Ceilometer code repository, especially not all at the same time.

The reality is we picked a pragmatic approach due to the rigidity of the OpenStack Technical Committee in regards to new projects to become OpenStack integrated – and, therefore, blessed – projects. Ceilometer was actually the first project to be incubated and then integrated. We had to go through the very first issues of that process.

Fortunately, now that time has passed, and all those constraints have been relaxed. To me, the OpenStack Foundation is turning into something that looks like the Apache Foundation, and there's, therefore, no need to tie technical solutions to political issues.

Indeed, the Big Tent now allows much more flexibility to all of that. Back a year ago, we were afraid to bring Gnocchi into Ceilometer. Was the Technical Committee going to review the project? Was the project going to be in the scope of Ceilometer for the Technical Committee? Now we don't have to ask ourselves those questions, now that we have that freedom, it empowers us to actually do what we think is good in term of technical design without worrying too much about political issues.

Ceilometer development activity

Acknowledging Gnocchi

The first step in this new process was to continue working on Gnocchi (a timeserie database and resource indexer designed to overcome historical Ceilometer storage issue) and to decide that it was not the right call to merge it into Ceilometer as some REST API v3, but that it was better to keep it standalone.

We managed to get traction to Gnocchi, getting a few contributors and users. We're even seeing talks proposed to the next Tokyo Summit where people leverage Gnocchi, such as "Service of predictive analytics on cost and performance in OpenStack", "Suveil" and "Cutting Edge NFV On OpenStack: Healing and Scaling Distributed Applications".

We are also doing some progress on pushing Gnocchi outside of the OpenStack community, as it can be a self-sufficient timeserie and resource database that can be used without any OpenStack interaction.

Branching Aodh

Rather than continuing to grow Ceilometer, during the last summit we all decided that it was time to reorganize and split Ceilometer into the different components it is made of, leveraging a more service-oriented architecture. The alarm subsystem of Ceilometer being mostly untied to the rest of Ceilometer, we decided it was the first and perfect candidate to do that. I personally engaged into doing the work and created a new repository with only the alarm code from Ceilometer, named Aodh.

Aodh is an Irish word meaning fire. A word picked so it also had some relation to Heat, and because we have some Irish influence around the project 😁.

This made sense for a lot of reason. First because Aodh can now work completely standalone, using either Ceilometer or Gnocchi as a backend – or any new plugin you'd write. I love the idea that OpenStack projects can work standalone – like Swift does for example – without implying any other OpenStack component. I think it's a proof of good design. Secondly, because it allows us to resonate on a smaller chunk of software – a reason really under-estimated today in OpenStack. I believe that the size of your software should match a certain ratio to the size of your team.

Aodh is, therefore, a new project under the OpenStack Telemetry program (or what remains of OpenStack programs now), alongside Ceilometer and Gnocchi, forked from the original Ceilometer alarm feature. We'll deprecate the latter with the Liberty release, and we'll remove it in the Mitaka release.

Lessons learned

Actually, moving that code out of Ceilometer (in the case of Aodh), or not merging it in (in the case of Gnocchi) had a few side effects that I admit I think we probably under-estimated back then.

Indeed, the code size of Gnocchi or Aodh ended up being much smaller than the entire Ceilometer project – Gnocchi is 7× smaller and Aodh 5x smaller than Ceilometer – and therefore much more easy to manipulate and to hack on. That allowed us to merge dozens of patches in a few weeks, cleaning-up and enhancing a lot of small things in the code. Those tasks are very much harder in Ceilometer, due to the bigger size of the code base and the small size of our team. By having our small team working on smaller chunks of changes – even when it meant actually doing more reviews – greatly improved our general velocity and the number of bugs fixed and features implemented.

On the more sociological side, I think it gave the team the sensation of finally owning the project. Ceilometer was huge, and it was impossible for people to know every side of it. Now, it's getting possible for people inside a team to cover a much larger portion of those smaller project, which gives them a greater sense of ownership and caring. Which ends up being good for the project quality overall.

That also means that we technically decided to have different core teams by project (Ceilometer, Gnocchi, and Aodh) as they all serve different purposes and can all be used standalone or with each others. Meaning we could have contributors completely ignoring other projects.

All of that reminds me some discussion I heard about projects such as Glance, trying to fit new features in - some that are really orthogonal to the original purpose. It's now clear to me that having different small components interacting together that can be completely owned and taken care of by a (small) team of contributors is the way to go. People that can therefore trust each others and easily bring new people in, makes a project really incredibly more powerful. Having a project covering a too wide set of features make things more difficult if you don't have enough manpower. This is clearly an issue that big projects inside OpenStack are facing now, such as Neutron or Nova.

-1:-- Ceilometer, Gnocchi &amp; Aodh: Liberty progress (Post Julien Danjou)--L0--C0--August 04, 2015 08:48 AM

Chen Bin (redguardtoo): Use which-func-mode with js2-mode

Two years ago in my article "Why Emacs is better editor - a case study for javascript developer" I proved that Emacs is a better javascript editor because its js2-mode can parse the tags ) in opened file more intelligently.

Since then, the js2-mode keeps improving and becomes better every day. I'm absolutely satisfied with it except one minor issue.

For performance reason, js2-mode place the imenu results into a cache which is updated by a timer.

`(which-function)` from which-func-mode takes advantage of the imenu results. So the result of `(which-function)` may be incorrect if the cache is not updated by timer.

The solution is to re-define a `my-which-function`:

(defun my-which-function ()
  ;; clean the imenu cache
  ;; @see
  (setq imenu--index-alist nil)

The new API is very useful when I use yasnippet to insert logging code in javascript file.

Here is a sample (log-which-func.yasnippet):

# -*- coding: utf-8; mode: snippet -*-
# name: console.log which function called
# key: lwf
# --
console.log('${1:`(my-which-function)`} called');
-1:-- Use which-func-mode with js2-mode (Post Chen Bin)--L0--C0--August 03, 2015 12:08 PM

Alex Schroeder: Gmail, Gnus and GPG

I wrote some instructions for setting up Gmail, Gnus and GPG. I used Emacs 24.5 and GPG 2.0 for this tutorial.

If you’re on a Mac

I tried this using my Mac and a Guest account. A Guest account has all its files deleted when you log out. It’s as “clean” as I could get.

You can install Emacs in various ways. You could use Emacs For Mac OS X. “Pure Emacs! No Extras! No Nonsense!” This is what I used to run. I’ve also built Emacs from source many times. Just remember to ./configure --with-ns before you start. You can install it from Homebrew: You could brew install emacs or you could install Yamamoto Mitsuharu’s Emacs Mac Port. This last variant is what I’m using right now.

brew tap railwaycat/emacsmacport
brew install emacs-mac --with-gnutls --with-imagemagick --with-official-icon --with-xml2
brew linkapps emacs-mac

As for GPG, you have two options. You can install GPG via GPG Suite. This is what I used at first. gpg --version said gpg (GnuPG/MacGPG2) 2.0.27 (the current, stable version is 2.0.28). But I wanted to install GPG via Homebrew. If you want to try it as well, make sure you uninstall the GPG Suite if you had it installed.

If you just install gpg2, you won’t be able to enter your passphrase from within Emacs with a GUI. You’ll see a simple, cut off message saying epa-file--find-file-not-found-function: Opening input file: Decryption failed,. If you only use Emacs within terminal windows, no problem. No need to do anything. But if you like to use Emacs with fonts and colors, menus and scrollbars, then you need to install a special variant of pinentry in order to get a separate Pinentry window:

brew install gpg2
brew install pinentry-mac

Once you have done that, change your ~/.gnupg/gpg-agent.conf file so that it has only this one line:

pinentry-program /usr/local/bin/pinentry-mac

When you install gpg2, it tells you to put use-standard-socket in your ~/.gnupg/gpg-agent.conf file. Don’t do that unless you only want to use Emacs from a terminal. Here’s a sample session in a terminal, showing you what you’ll get, if you don’t use pinentry-mac:

alex@Megabombus:~$ echo "This is a test." > test
alex@Megabombus:~$ gpg --recipient kensanata --encrypt test
alex@Megabombus:~$ ls test*
test     test.gpg
alex@Megabombus:~$ gpg --output test2 test.gpg 

You need a passphrase to unlock the secret key for
user: "Alex Schroeder <>"
8192-bit RSA key, ID 4529A45C, created 2015-03-01 (main key ID ACECFEAE)

gpg: encrypted with 8192-bit RSA key, ID 4529A45C, created 2015-03-01
      "Alex Schroeder <>"
alex@Megabombus:~$ ls test*
test     test.gpg test2
alex@Megabombus:~$ diff test test2

When asked for your passphrase, you’ll see something like the following:

               │ Please enter the passphrase to unlock the secret key for the OpenPGP certificate:  │
               │ "Alex Schroeder <>"                                            │
               │ 8192-bit RSA key, ID 4529A45C,                                                     │
               │ created 2015-03-01 (main key ID ACECFEAE).                                         │
               │                                                                                    │
               │                                                                                    │
               │ Passphrase *****************************************************************______ │
               │                                                                                    │
               │            <OK>                                                  <Cancel>          │

This pinentry works in a terminal, but it won’t show up when GPG is called by GUI Emacs! Install pinentry-mac and you’ll be able to provide your passphrase when using Emacs.

If you already tinkered with gpg before changing ~/.gnupg/gpg-agent.conf, you’ll have to reload gpg-agent.

alex@Megabombus:~$ echo RELOADAGENT | gpg-connect-agent


-1:-- Gmail, Gnus and GPG (Post)--L0--C0--July 24, 2015 06:09 PM

Emacs Redux: ace-jump-mode is Dead, Long Live Avy

People often ask how am I navigating efficiently Emacs windows and buffers. I have the feeling they expect me to share with them some secrets that would turbo-charge common commands like C-s, M-f, C-x o, etc. I don’t, however, use those commands that much. Ever since I saw that vim’s EasyMotion has been ported to Emacs, I’ve been using that port - namely ace-jump-mode.

Basically, it allows you to navigate to every visible portion of your Emacs (buffers & windows) with only a handful of keystrokes (usually one two activate it and one or two to get where you want to go). You can see it in action in this excellent video. ace-jump served me well for years, but I’ve had a few gripes with it that were never addressed (multi-char targets, CamelCase support, etc). I would have implemented those myself, if the project was maintained at all, but alas - that’s not the case. Seems I wasn’t the only one who was frustrated with ace-jump, as the prolific Oleh Krehel reimplemented it pretty much from scratch for the purposes of his excellent ace-window library. Once I got wind of this, I managed to persuade Oleh to start distributing his rewrite as a standalone project, which he dubbed avy.

Avy features everything ace-jump does and more. Apart from the many extra features, its codebase is way cleaner and readable and Oleh is a fantastic and very responsive maintainer. So, as far as I’m concerned ace-jump is now a dead project and pretty much everyone who’s using it should try out avy instead. Their usage and interface are pretty similar, so the learning curve is non-existing. By the way, here’s avy in action:

And what about my usage of avy? Nothing fancy here - I just bind the commands I consider most important to handy keystrokes.

(global-set-key (kbd "C-c j") 'avy-goto-word-or-subword-1)
(global-set-key (kbd "s-.") 'avy-goto-word-or-subword-1)
(global-set-key (kbd "s-w") 'ace-window)

avy-goto-word-or-subword-1 is aware of CamelCase words and I do a lot of programming in languages that use those extensively.

avy has one more thing going for it - it’s part of the default Emacs package repo GNU ELPA, which means that you can install it right away without having to setup any third-party repositories (which you’ll probably need sooner or later).

avy and ace-window are naturally part of Prelude.

P.S. Oleh, one of those days you should rename ace-window to avy-window. :-)

-1:-- ace-jump-mode is Dead, Long Live Avy (Post)--L0--C0--July 19, 2015 08:48 AM

Emacs Redux: JDEE Reborn

JDEE (Java Development Environment for Emacs) used to be best way to develop Java apps in Emacs a while back. It offered a ton of cool features, like smart auto-completion and a debugger. Unfortunately at some point the development slowed down significantly and the project went in a catatonic state. There was pretty much no activity for years in the official SourceForge repo and there was also no support for features introduced in Java 5+.

Recently, however, the project migrated to GitHub and it’s now way easier to get involved. Seems that some people have already started work on updating JDEE to support modern JDKs and modern Emacs functionality.

That’s a really exciting project, as Java support has traditionally been a weakness of Emacs and I’m writing this post with the hope that more people will help make JDEE great again.

So what are you waiting for? If you’re into Java and friends (Scala, Clojure, Groovy, etc), check out the new official repo and let’s get this party started!

-1:-- JDEE Reborn (Post)--L0--C0--July 19, 2015 08:37 AM