Category Archives: emacs

Emacs Conf video tech notes:,, livestreamer, ffmpeg

Last week’s Emacs Conf was fantastic. There were lots of people at the in-person event in San Francisco, and people could also watch the stream through and ask questions through IRC. There were remote speakers and in-person speakers, and that mix even worked for the impromptu lightning talks sprinkled throughout the day.

This is how the tech worked:

  • Before the conference started, the organizers set up a laptop for streaming on This was hooked up to the main display (a large television with speakers). They also configured the account to record and archive videos. In the free account, recorded videos are available for 14 days.
  • Remote speakers were brought in using the Jitsi open source video conferencing system, using the public servers at This was on the same computer that did the streaming, so people watching the stream could see whatever was shared through Jitsi. Organizers read out questions from the in-person audience and from the IRC channel. The audio from Jitsi wasn’t directly available through, though. Instead, the audio came in as a recording from the laptop’s microphone.
  • Local speakers either used the streaming laptop to go to a specific webpage they wanted to talk about, or joined the Jitsi web conference using Google Chrome or Chromium so that they could share their screen. The organizers muted the second Jitsi client to avoid audio feedback loops.

That worked out really well. There were more than a hundred remote viewers. As one of them, I can definitely rate the experience as surprisingly smooth.

All that’s left now is to figure out how to make a more lasting archive of the Emacs Conf videos. As it turns out, or online tools don’t make it easy to download stream recordings that are longer than three hours. Fortunately, livestreamer can handle the job. Here’s what I did to download the timestream data from one of the recordings of EmacsConf:

livestreamer -o emacsconf-1.ts --hls-segment-threads 4 best
ffmpeg -i emacsconf-1.ts -acodec copy -absf aac_adtstoasc -vcodec copy emacsconf-1.mp4

I normally use Camtasia Studio to edit videos, but for some reason, it kept flaking out on me today. After the umpteenth crash, I decided to keep things simple by using ffmpeg to extract the relevant part of the video. To extract a segment, you can use -ss to specify the start time and t to specify the duration. Here’s a sample command:

ffmpeg -i emacsconf-1.mp4 -ss 1:18:06.11 -t 0:03:32.29 -c:v copy -c:a copy emacsconf-engine-mode.mp4

Your version of ffmpeg might have a -to option, which would let you specify the end time instead of using -t to specify duration.

I’m coordinating with the other organizers to see if there’s a better way to process the videos, so that’s why we haven’t released them publicly yet. (Soon!) It would be nice to improve the audio, especially for some of the talks, and maybe it would be good to add overlays or zoom in as well. The on-site organizers captured backup videos and screen recordings, too, so we might want to edit some of those clips into the streamed recording. One of the organizers has access to better video editing tools, so we’ll try that out.

Anyway, those were the commands that helped me get started with command-line conversion and editing of recorded videos. Hope they come in handy for other people too.

For more info about EmacsConf 2015, check out There’ll probably be an announcement there once the videos are up. =)

Hat tip to Reddit and for tips.

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

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!

July 2015 Emacs Hangout

We talked about Python, Org Mode, system administration, keybindings, Hydra, and other neat things. =)

I’ll probably set up another hangout mid-August, or we’ll just do the one on the 29th. We’ll see! You can follow the Emacs Conferences and Hangouts page for more information, or sign up to get e-mails for upcoming hangouts. Past Emacs Hangouts

Text chat (links edited to avoid weird wrapping things):

me 9:18 PM literate devops link
Daniel Gopar 9:34 PM config link
me 9:37 PM jwiegley/dot-emacs jwiegley – haskell
Howard Melman 9:48 PM cocoa-text-system
Mr Swathepocalypse 9:55 PM I have to go attend to some work stuff, I look forward to watching the rest of the hangout later on.
me 9:55 PM Orgstruct
Mr Swathepocalypse 9:55 PM Thanks guys!
me 9:55 PM Bye Dylan! my config erc erc-pass
Howard Abrams 9:59 PM Did I mention how I’ve been using emacs mail to mime encode an org-mode buffer into HTML for the most awesome mail messages.
Daniel Gopar 10:05 PM Have you guys used “helm-M-x”? It’s part of the helm package I believe
Kaushal Modi 10:07 PM ready to share which-key package
Daniel Gopar 10:10 PM Got to go. Nice talking to everyone.
Kaushal Modi 10:14 PM config link
Kaushal Modi 10:37 PM (setq debug-on-message “Making tags”)
me 10:39 PM org-map-entries
Correl Roush 10:47 PM git graphs
me 10:54 PM imagex-global-sticky-mode imagex-auto-adjust-mode
Kaushal Modi 10:54 PM Emacs-imagex config link example of setting ditaa and plantuml
Correl Roush 10:58 PM writing specs link that has some setup steps listed out as well

Emacs Hangout June 2015

Times may be off by a little bit, sorry!

Boo, I accidentally browsed in the Hangouts window before copying the text chat, so no copy of the text chat this time… =|

Using your own Emacs Lisp functions in Org Mode table calculations: easier dosage totals

UPDATE 2015-06-17: In the comments below, Will points out that if you use proper dates ([yyyy-mm-dd] instead of yyyy-mm-dd), Org will do the date arithmetic for you. Neato! Here’s what Will said:

Hi Sacha. Did you know you can do date arithmetic directly on org’s inactive or active timestamps? It can even give you an answer in fractional days if the time of day is different in the two timestamps:

| Start                  | End                    | Interval |
| [2015-06-16 Tue]       | [2015-06-23 Tue]       |        7 |
| <2015-06-13 Sat>       | <2015-06-15 Mon>       |        2 |
| [2015-06-10 Wed 20:00] | [2015-06-17 Wed 08:00] |      6.5 |
#+TBLFM: $3=$2 - $1 

Here’s my previous convoluted way of doing things… =)

I recently wrote about calculating how many doses you need to buy using an Org Mode table. On reflection, it’s easier and more flexible to do that calculation using an Emacs Lisp function instead of writing a function that processes and outputs entire tables.

First, we define a function that calculates the number of days between two dates, including the dates given. I put this in my Emacs config.

(defun my/org-days-between (start end)
  "Number of days between START and END.
This includes START and END."
  (1+ (- (calendar-absolute-from-gregorian (org-date-to-gregorian end))
         (calendar-absolute-from-gregorian (org-date-to-gregorian start)))))

Here’s the revised table. I moved the “Needed” column to the left of the medication type because this makes it much easier to read and confirm.

| Needed | Type         | Per day |      Start |        End | Stock |
|     30 | Medication A |       2 | 2015-06-16 | 2015-06-30 |     0 |
|      2 | Medication B |     0.1 | 2015-06-16 | 2015-06-30 |   0.2 |
#+TBLFM: @2$1..@>$1='(ceiling (- (* (my/org-days-between $4 $5) (string-to-number $3)) (string-to-number $6)))

C-c C-c on the #+TBLFM: line updates the values in column 1.

@2$1..@>$1 means the cells from the second row (@2) to the last row (@>) in the first column ($1).  '  tells Org to evaluate the following expression as Emacs Lisp, substituting the values as specified ($4 is the fourth column’s value, etc.).

The table formula calculates the value of the first column (Needed) based on how many you need per day, the dates given (inclusive), and how much you already have in stock. It rounds numbers up by using the ceiling function.

Because this equation uses the values from each row, the start and end date must be filled in for all rows. To quickly duplicate values downwards, set org-table-copy-increment to nil, then use S-return (shift-return) in the table cell you want to copy. Keep typing S-return to copy more.

This treats the calculation inputs as strings, so I used string-to-number to convert some of them to numbers for multiplication and subtraction. If you were only dealing with numbers, you can convert them automatically by using the ;N flag, like this:

| Needed | Type         | Per day | Days | Stock |
|      6 | Medication A |       2 |    3 |     0 |
|      1 | Medication B |     0.1 |    3 |   0.2 |
#+TBLFM: @2$1..@>$1='(ceiling (- (* $3 $4) $5)));N