Benjamin Slade: In praise of DejaVu (Sans Mono)

I do the majority of my work in Emacs - from the composition of linguistics articles and chapters, to lecture slides, to keeping track of grades, to email. Much of what I do requires a monospaced font, and much of what I do requires a good Unicode font. Which narrows the range of potential font candidates significantly. And, since I spend so much time looking at it, I would like the font to be aesthetically-pleasing.
After trying many different fonts, at different sizes and so forth, I’ve found that DejaVu Sans Mono is really the only font which meets all of these criteria. It is really a good-looking font too. Here it is in a few different applications:

Figure 1: DejaVu Sans Mono in mu4e mail
cMMuHWf.png
Figure 2: DejaVu Sans Mono in LaTeX doc
ox7g0FF.jpg
Figure 3: DejaVu Sans Mono displaying some Unicode
And…it appears to be the same font used in the terminal in Tron: Legacy:
TRON_EMACS.JPG
Figure 4: kill -9ing in Tron: Legacy with DejaVu
-1:-- In praise of DejaVu (Sans Mono) (Post be_slayed (noreply@blogger.com))--L0--C0--December 21, 2014 10:57 PM

Benjamin Slade: Emacs and (synchronised) org-mode on Android

Running emacs and org-mode under Android. I’m doing this on my Android tablet - it’s not perhaps as useful on a phone, though it’s not unmanageable.

There used to be an Emacs app for Android in the Google Play store - in fact it’s still there, but the server it used to download its files from is no longer working - and the app was always a bit fiddly to get to work properly.

Here’s a better way of getting it working:
  • Install ZShaolin, a console terminal emulator (zsh shell) for Android with a number of useful commandline tools like rsync, awk, imagmagick etc.
  • Then install the files from the old Emacs app. They’re no longer accessible via the app from the Play store, but I had saved the files from back when it still worked, and have zipped them up and thrown them on mega: https://mega.co.nz/#!B4AThKxI!_ImT57mJNirozxna-1SOcNGAzPRr9QacM34jUoPVMgo
  • Unzip the files from there and place at /sdcard/emacs/ on your device.
  • Then, open up ZShaolin and start a session, and type “emacs”. Voilà.
Now for getting org-mode to work. Org-mode is part of the basic Emacs setup in recent versions of Emacs (including the one above). For some reason, though, at least when I ran it, I had trouble turning on org-mode. Here’s the fix:
  • Create a .emacs file (if you don’t have one already) in ~ under ZShaolin and put the following into:
(defun load-history-filename-element (file-regexp)
"Get the first elt of `load-history' whose car matches FILE-REGEXP.
Return nil if there isn't one."
(let* ((loads load-history)
(load-elt (and loads (car loads))))
(save-match-data
(while (and loads
(or (null (car load-elt))
(not (and (stringp (car load-elt)) ; new condition
(string-match file-regexp (car load-elt))))))
(setq loads (cdr loads)
load-elt (and loads (car loads)))))
load-elt))
That gets org-mode to work as expected.
fh9YvOc.png
Figure 1: Emacing an org file on Android (with ZShaolin)

Now, most likely you will have org-files that you want to keep synchronized. You may already be running MobileOrg, with something like a Dropbox synchronisation. Note that the way that the MobileOrg app works, you can’t edit the org files that it uses directly. MobileOrg utilises some sort of database and the changes that it pushes back are done so through the database, so editing the org files that MobileOrg is synched with (say, in Dropbox) won’t result in any changes being propagated back to your other devices.

So, if you’re running MobileOrg with Dropbox, you’ll need to have a separateDropbox synchronisation in order to be able to edit org-files in Emacs on Android in a way that allows for propagation of changes from Android to other devices/repositories.

Here’s a method which allows for editing of org-mode files on Emacs which allows for back-propagation via Dropbox:
  • Create a separate Dropbox synchronisation directory - that is, separate from the one you use for MobileOrg synchronisation. [The way I did this on my Linux desktop was to create a symlink from my “Org folder” in my Documents directory to the “actual” Org directory in my Dropbox folder. In my setup, this directory also synchs with a git repository, so I ended up excluding the hidden .git directory from synching with Dropbox, since I have only a free, very-limited-space Dropbox account.]
  • Open up the Dropbox app on your Android device. Navigate to your new Org directory (not the one you use for MobileOrg). “Open” any of the org files you want to have access to. It doesn’t matter if they successfully open or not - the act of “opening” them gets the Dropbox app to save a local copy which it will keep synchronised with your Dropbox repository.
  • The location for these local files is a path like this: /sdcard/Android/data/com.dropbox.android/files/u87923223/scratch/YourOrgDirectoryName/the u-number part of the path I assume varies from user to user; and of course the final part of the path will depend on what you named your Org folder and files
  • Files in the above path can be opened in Emacs on Android. Any changes you make will be propagated via Dropbox.
Again, this will be perhaps of limited use on a phone — though ZShaolin does have a built-in software keyboard which works very well for Emacs — on a tablet device with a keyboard (I use an Asus tablet) it works pretty well. (Though I haven’t figured out how to remap CAPSLOCK on my tablet to CTRL yet….)
-1:-- Emacs and (synchronised) org-mode on Android (Post be_slayed (noreply@blogger.com))--L0--C0--December 21, 2014 10:36 PM

Bryan Murdock: Adventure in Building a Home Gym

Last year I started assembling a little garage gym so I could do some weight lifting in the comfort of home. I scoured the online classifieds and found good deals on used power racks, a bench, and some weights. I was doing pretty well finding these deals, I thought. The one oddity was with the weights. The seller wouldn't sell them separate from this monster:



I had no use for this because I had bought into the idea that compound lifts were the best and this enormous and heavy thing served only to isolate your shoulders. I took it anyway because the guy was nice and he was giving me a good deal on the weights whether this was included or not. I was also thinking in the back of my head that I have a friend that likes metalworking that could probably help me turn it into something more useful. Nearly a full year later my hope was finally realized.

I stored it as is in my garage for about 6 months. My basement was being remodeled so there were lots of things in the garage with it (on it, under it, around it) so that wasn't a big deal. Once the basement was finished and we moved everything back in, it was painfully in the way. I moved it to the side of the house where it sat for a couple months, and then finally my next-door neighbor showed me how his acetylene torch worked and this thing was now in a much more compact state:


The flat bench I originally bought was a little rickety and cheap and my idea was to turn this into a nice sturdy one. A couple weeks ago my schedule and my metalworking friends schedules finally synced up and he graciously helped me use his chop saw, MIG welder, and drill press to reform the original beast into this:



It turns out welding is pretty dang fun. Once this metal frame was done I cut out and sanded some 1/2 inch plywood for the actual bench and attached it using bolts and t-nuts. My wife graciously painted the metal with some Rustoleum, found some padding and vinyl and helped me cover the wood. Here are the last few progress pictures:




-1:-- Adventure in Building a Home Gym (Post Bryan (noreply@blogger.com))--L0--C0--December 21, 2014 06:33 PM

Irreal: Ooh, I Must Be a Power User

-1:-- Ooh, I Must Be a Power User (Post jcs)--L0--C0--December 20, 2014 10:40 PM

Irreal: Mastering Emacs, The Book

The estimable Mickey Petersen, proprietor of the Mastering Emacs blog, is working on a book. Mickey says that the book is not an encapsulation of his blog but rather is all new material. His announcement has a general outline of what he's going to cover so read that if you're interested.

Mickey's aiming to release the book in February 2015 so we won't have to wait long. If you sign up to be notified when it's ready, Mickey will give you 20% off. You can sign up on the announcement page so head on over.

-1:-- Mastering Emacs, The Book (Post jcs)--L0--C0--December 19, 2014 11:41 AM

Grant Rettke: Using Units in Calc with Emacs

Calc is an advanced desk calculator and mathematical tool written by Dave Gillespie that runs as part of the GNU Emacs environment.

One special interpretation of algebraic formulas is as numbers with units. For example, the formula 5 m / s^2 can be read “five meters per second squared.”

Of course it can!

-1:-- Using Units in Calc with Emacs (Post Grant)--L0--C0--December 19, 2014 03:19 AM

Mickey Petersen: Announcing my new Mastering Emacs book

After six months (and several years of procrastinating and chiselling away at this) I’m pleased to announce that the Mastering Emacs book will be out Soon(TM).

image

Learn more about the book

It’s fair to say there’s a need for another book on Emacs.

I’ve spent four years writing about Emacs and I’ve realized what Emacs needs more than anything is a book that takes you from knowing something (or nothing) about Emacs to a point where you are comfortable. Those of you reading this who know Emacs well should know what I’m talking about: that moment of clarity when you finally understand how Emacs works.

Unfortunately Emacs’s adoption is marred by this unnecessary complexity; the confusion over the keys, the byzantine terminology, the often paradoxical functionality of common operations. They’re not hard concepts to learn (no really) – but the fragments of knowledge that you need to learn to understand this you won’t find in one single source.

The book will hopefully set out to correct that. I have spent the first 100 (out of what I plan will be a total tally of 200 pages) with the aim of teaching the reader why Emacs is the way it is – a tall order for a text editor older than a lot of its users – and what you need to know, here and now, to overcome these difficulties.

The remainder of the book is hands-on, practical Emacs Stuff: how to move around; how to edit text; how to combine all these commands and tools into what I call “workflow.” For the next-hardest thing (after you’re comfortable with Emacs) is knowing how to use the tools.

Check out the book landing page and sign up to be notified when it’s out!

-1:-- Announcing my new Mastering Emacs book (Post)--L0--C0--December 18, 2014 05:40 PM

sachachua: Emacs Hangout #3: Emacs can read your mind

We’ve been organizing these Emacs Hangouts as an informal way for folks to get together and swap tips/notes/questions. You can find the previous Hangouts at http://sachachua.com/blog/tag/emacs-hangout/ . In this hangout, we shared tips on Emacs configuration, literate programming, remote access, autocompletion, and web development. And then Jonathan Arkell blew our minds with, well, his mind, demonstrating how he got Mindwave working with Emacs and Org Mode. The next one is scheduled for Jan 9, 2015 (Friday) at 7 PM Toronto time (12 AM GMT) – https://plus.google.com/events/cv3ub5ue6k3fluku7e2rfac161o . Want a different time? Feel free to set up an Emacs Hangout, or contact me (sacha@sachachua.com) and we’ll coordinate something.

Approx. time Topic
0:08 describe-variable
0:12 cycle-spacing
0:14 quelpa, better-defaults
0:18 https://github.com/KMahoney/kpm-list
0:19 org-babel
0:24 noweb
0:27 Beamer, org-present
0:30 Emacsclient
0:32 TRAMP, vagrant, X11 forwarding, git
0:40 Evangelism, Emacs defensiveness
0:42 Code organization
0:47 Cask, Quelpa, el-get
0:54 paradox for listing packages
0:58 Helm, helm-git
1:02 Projectile
1:03 More helm, autocomplete
1:06 Autocomplete and company
1:16 Writing packages, flycheck
1:18 Moving to git, working on Emacs
1:22 Gnus, mu4e, notmuch
1:27 Eww, web browsing
1:28 Web dev tools: skewer-mode, slime, swank-js, web-mode
1:32 o-blog static site generator
1:38 orgaggregate
1:41 EEG data. Emacs can read your mind!

Chat, links:

me 8:07 PM Thanks!
Zachary Kanfer 8:10 PM A description of Emacs’s “describe variable” is here: Examining.html#Examining
JJ Asghar 8:11 PM zachary: thanks! wait wait wait, org-bable can take over your .emacs.d/*.el files?
me 8:18 PM JJ: Yeah, totally! It’s so useful.
JJ Asghar 8:19 PM i need to dig into that
Jacob MacDonald 8:19 PM https://github.com/KMahoney/kpm-list
jay abber 8:23 PM Org mode has functionality for LaTeX/TeX it appears Am I wrong, any ppl here using Emacs for ReST or LaTeX??
jay abber 8:27 PM it is
Jacob MacDonald 8:27 PM I used the PDF export in Org for notes in a math class, since it exports LaTeX nicely.
jay abber 8:27 PM https://www.cs.tufts.edu/~nr/noweb/
me 8:27 PM I’ve been using Org to export ta LaTeX for Beamer output
jay abber 8:27 PM np
jay abber 8:28 PM yeaaah up yup
Jonathan Arkell 8:29 PM Time for a restart.
jay abber 8:29 PM I think it would nice to know who uses emacs mainly graphically or in a terminal?? me = lurker sorry
jay abber 8:30 PM im trying to use it more in a terminal but always go graphic
Jacob MacDonald 8:31 PM emacs –daemon; emacsclient -c
jay abber 8:31 PM yosmiate yosmite me homebrew
jay abber 8:31 PM 24.4
jay abber 8:32 PM I like that
Christopher Done 8:32 PM audio sounds very trippy
jay abber 8:32 PM w/daft punk poster rockiin
Jonathan Arkell 8:33 PM heh! It’s signed too.
JJ Asghar 8:34 PM Sorry guys I have to go! Thanks so much for this!
me 8:34 PM See you!
jay abber 8:34 PM peace or vnc but thats alot of overhead make sure you lock down you sshdconfig files with sane sec practice Emacs over TMUX?????
Christopher Done 8:38 PM https://github.com/chrisdone/chrisdone-emacs/blob/master/packages/resmacro/resmacro.el unrelated, thought i’d share that =p
me 8:38 PM jay: Good suggestions. Want to speak up?
jay abber 8:38 PM lm lurking tonight
Jacob MacDonald 8:38 PM That audio .
jay abber 8:38 PM next one I promise His voice is awesome
Jacob MacDonald 8:40 PM http://www.emacswiki.org/Rudel
jay abber 8:40 PM Well for me sometimes I hate to confess but I just type vi/vim Noone I know uses any type of editor except word hahahaha
Jonathan Arkell 8:40 PM K, i am going to try audio again. Hopefully it will help Was that better?
jay abber 8:41 PM Can emacs do stuff like mpsyt or youtubedl somehow? yes!!!!
Jacob MacDonald 8:42 PM elisp interface to a shell script should work at a bare minimum.
Jacob MacDonald 8:42 PM I mean, there’s a web browser/mail reader/IRC client built in already…
me 8:42 PM I play MP3s in Emacs using emms and mplayer
jay abber 8:43 PM you know what
Jacob MacDonald 8:43 PM There was a Spotify plugin using dbus a while back, I believe.
jay abber 8:43 PM I think mysyt will be fine
Christopher Done 8:43 PM i was thinking of writing an emacs client to gmail via gmail’s API…
jay abber 8:43 PM its is a just a python script and mpv very suave and minimalist both python
Christopher Done 8:45 PM i stick all my own packages and ones i’m using in my repo https://github.com/chrisdone/chrisdone-emacs/tree/master/packages as submodules
me 8:45 PM Christopher: Gmail client might be nice. I use IMAP occasionally, but I miss the priority inbox.
Christopher Done 8:46 PM yeah. i used offlineimap for a while with notmuch.el, that was pretty good. but i’m tempted by the idea of a “light-weight” approach replacing the browser with emacs, requesting emails/search on demand. might be nice their API looked super trivial to work with
Jonathan Arkell 8:48 PM Sorry Yea Is qwelpa (sp?) native emacs? (elisp) Stupid mic. works great for music.
Jacob MacDonald 8:50 PM lol
Jonathan Arkell 8:50 PM I do all my configuration and packages in Org mode
Christopher Done 8:50 PM i just use git for everything =p
me 8:51 PM Jonathan: Oh, maybe you’re doing some kind of audio processing that removes noise or other odd things? </wild guess>
Jonathan Arkell 8:51 PM Ironically not. I am Launching my DAW now to try and sort it ot.. heh err out … not ot…
jay abber 8:53 PM M=x list-packages now installing org-mode
me 8:53 PM Jay: If you’re installing Org from package, be sure to do it in an Emacs that has not loaded an Org file. because Org 8 (package) and Org 7 (which is built into Emacs) have incompatibilities
jay abber 8:55 PM hmm i installed 24.4 via homebrew
Jonathan Arkell 8:58 PM Okay, I am switching to the built in mic, so hopefully it works. Let me know…
Zachary Kanfer 9:11 PM http://emacsnyc.org/videos.html#2014-05
me 9:12 PM https://github.com/aki2o/emacs-plsense ?
jay abber 9:15 PM Im trying to become a ninja using the shell from w/in Emacs but sometimes I have issues with my ENV and PATH
Jonathan Arkell 9:15 PM OS?
Jacob MacDonald 9:15 PM It’s a thing.
Zachary Kanfer 9:15 PM http://emacs.stackexchange.com/
jay abber 9:15 PM Yosmite like pyenv or rubyenv in HomeBrew yes yes
Jacob MacDonald 9:16 PM Depends on if you use emacs like from brew or Emacs.app.
jay abber 9:16 PM I got cha will find it
Jonathan Hill 9:17 PM great package for handling env variables in and so forth in OSX: exec-path-from-shell
jay abber 9:18 PM jonathan: thanks man
Jonathan Hill 9:18 PM just after (package-initialize), do (exec-path-from-initialize) oops (exec-path-from-shell-initialize)
jay abber 9:18 PM jh: ok
Jonathan Arkell 9:19 PM (setenv “PATH” (concat (getenv “HOME”) “/bin:” “/usr/local/bin:” (getenv “PATH”))) That’s waht i do… (add-to-list ‘exec-path “/usr/local/bin”)
me 9:21 PM http://lars.ingebrigtsen.no/2014/11/13/welcome-new-emacs-developers/
Jonathan Arkell 9:22 PM ERMERGERD +1 +1
Jacob MacDonald 9:32 PM Link please?
Bob Erb 9:33 PM What’s it called?
me 9:33 PM https://github.com/renard/o-blog ?
Jacob MacDonald 9:33 PM Thanks.
me 9:34 PM http://renard.github.io/o-blog/ – docs
jay abber 9:34 PM hey
jay abber 9:34 PM sorry I got side tracks I blog in my posts in REST for pelican static blog generator
jay abber 9:35 PM omg
me 9:35 PM Pretty!
jay abber 9:35 PM elisp for static blog oh know
John Wiegley 9:36 PM Hello
jay abber 9:36 PM https://github.com/renard/o-blog you should never shown that to me
Jacob MacDonald 9:37 PM John, somehow I think I’ve seen you before…
me 9:40 PM https://github.com/tbanel/orgaggregate
Jonathan Arkell 9:44 PM https://github.com/jonnay/mindwave-emacs
jay abber 9:44 PM Hey I have to go now
John Wiegley 9:44 PM Bye Jay
me 9:44 PM See you! Thanks for joining!
jay abber 9:44 PM This was awesome I will be on the next one I have to study precalc
me 9:44 PM Yay!
jay abber 9:45 PM take care
me 9:49 PM Oooh… I wonder how to make coloured graphs like that too. Neat! I should practise using overlays…
Jonathan Arkell 9:53 PM https://github.com/jonnay/mindwave-emacs Here is the Display Code: https://github.com/jonnay/mindwave-emacs/blob/master/mindwave-display.org So wait… C-u C-u C-p takes you… uup?
me 9:59 PM Hah! UUP! Brilliant!
Bob Erb 10:01 PM You’re a treasure, Sacha!

The post Emacs Hangout #3: Emacs can read your mind appeared first on sacha chua :: living an awesome life.

-1:-- Emacs Hangout #3: Emacs can read your mind (Post Sacha Chua)--L0--C0--December 18, 2014 01:00 PM

Phil Hagelberg: in which we take a deep breath before the upcoming plunge

So you might be wondering "what the deuce is technomancy up to these days anyway; he seems to be all over the place". Or you might be not wondering that, but if you were, you'd have a great point. I'm not doing much Clojure these days, there's just a smattering of Racket going on, and I'm not doing all that much Erlang either.

vine pole

Well, this post isn't much about code, but perhaps you'll indulge me a bit all the same. My wife and I always had the idea that we would move overseas at some point. I grew up in Indonesia and Singapore, and her father was raised in Ecuador. We didn't really have a clear idea of what this would look like, but as 2014 began we started to look more seriously.

This past June, my wife and I traveled to Thailand for a few weeks in order to meet up with a few organizations working specifically with Burmese affected by the long-running civil war and rampant human rights abuses. We spent some time in Chiang Mai[1] but then headed down to Mae Sot on the Burmese border. While we were down there we stayed with folks from the Charis project and got to hear stories of their efforts to lift migrant families in the area out of poverty.

So often you see western aid framed in terms of Americans coming in with their money to save the day, (it's less often you hear about ways in which this backfires and contributes to a cycle of dependence) but we could clearly see that wasn't what was happening here. The Charis Project possessed a bold and compelling vision for breaking the cycle of poverty by empowering whole families to be self-sustaining, and they had an impressive track record when it came to pulling it off.

I could tell you some of the stories we heard from them, but they do it so much better.

Yesterday I quit my fantastic job of three years at Heroku, and I'm planning on moving with my family to Thailand next month to partner with them.

It isn't clear yet exactly what our role will be there. If it ends up to be working with technology somehow (likely in the form of education?) then that would be great, but I've gotten over myself and will be content even if not. I've learned a lot about selflessness and helping others through my friends and church the last few years. I almost feel embarassed that it took me to the point where I had everything in my own life put together before I could really take the time to think seriously about what I could do to help those around me. But it feels like the only response I could have as I reflect on how blessed my own life has been and when I read about the situations some of these people are living in.

hut

So the current plan is to fly over in the middle of January. I plan on spending a portion of my time doing consulting[2], but since the cost of living is dramatically lower in Mae Sot than in the United States, my hope is that this will still leave me with a significant amount of time to work with Charis. In addition, I want to continue to run my custom keyboard business selling kits. 10% of proceeds will go directly to poverty-alleviation projects, and the rest will go to supporting my family; if interest remains strong it may allow me to focus more and spend less time consulting.

But you don't need to buy a keyboard to contribute to the work going on there. Again, they've said it better on their blog than I could, but it's remarkable how great an impact you can have with donations that can seem so small from a western lifestyle perspective. Please consider giving to support their life-changing projects.

I'll be posting updates as things progress. We anticipate the first year or so will be focused mostly on learning the language, culture, and just figuring out life. We're all very excited to move into this next phase.


[1] I may have talked to some of you in the past about working in Chiang Mai for another organization. Both organizations are doing fantastic work I greatly respect. It's a long story, but we realized not too long ago that if we really wanted our whole family to be involved, Chiang Mai and the work we had planned there wasn't the way to go about it.

[2] Spending the last five years working remotely has helped prepare me for an arrangement like this, though the time zones will be a new challenge for me.

-1:-- in which we take a deep breath before the upcoming plunge (Post Phil Hagelberg)--L0--C0--December 16, 2014 01:20 PM

Endless Parentheses: New on Elpa and in Emacs 25.1: let-alist

let-alist is the best thing to happen to associative lists since the invention of the cons cell. This little macro lets you easily access the contents of an alist, concisely and efficiently, without having to specify them preemptively. It comes built-in with 25.1, and is also available on GNU Elpa for older Emacsen.

If you've ever had to process the output of a web API, you've certainly had to deal with endless alists returned by json-read. I'll spare you the rant and go straight to the example.

Here's a very simplified version of a function of the SX package, before let-alist.

(defun sx-question-list--print-info (question-data)
  "DOC"
  (let ((tags               (cdr (assq 'tags               question-data)))
        (answer_count       (cdr (assq 'answer_count       question-data)))
        (title              (cdr (assq 'title              question-data)))
        (last_activity_date (cdr (assq 'last_activity_date question-data)))
        (score              (cdr (assq 'score              question-data)))
        (owner-name (cdr (assq 'display_name (cdr (assq 'owner question-data))))))
    (list
     question-data
     (vector
      (int-to-string score)
      (int-to-string answer_count)
      title "     "
      owner-name
      last_activity_date 
      sx-question-list-ago-string
      " " tags))))

And this is what the same function looks like now (again, simplified).

(defun sx-question-list--print-info (question-data)
  "DOC"
  (let-alist question-data
    (list
     question-data
     (vector
      (int-to-string .score)
      (int-to-string .answer_count)
      .title "     "
      .owner.display_name
      .last_activity_date sx-question-list-ago-string
      " " .tags))))

How much nicer is that? let-alist detects all those symbols that start with a ., and wraps the body in a let form essentially identical to the one above. The resulting code is much nicer to write, and the byte-compiled result is exactly as efficient as the manually written version. (If it's not byte-compiled, there will be a performance difference, though it should be small.)

And just to make things nicer, you can use this snippet to highlight those . symbols as if they were keywords.

(font-lock-add-keywords
 'emacs-lisp-mode
 '(("\\_<\\.\\(?:\\sw\\|\\s_\\)+\\_>" 0 
   font-lock-builtin-face)))

Update <2014-12-20 Sat>

Due to popular demand, let-alist now does nested alists. The example above shows how you can use .owner.display_name to access the value of display_name inside the value of owner.

Comment on this.

-1:-- New on Elpa and in Emacs 25.1: let-alist (Post)--L0--C0--December 15, 2014 12:00 AM

Grant Rettke: emacs-refactor: A Generic Refactoring Tool for Emacs

Emacs Refactor (EMR) provides language-specific refactoring support for Emacs. It has a simple declarative interface for easy extension.

-1:-- emacs-refactor: A Generic Refactoring Tool for Emacs (Post Grant)--L0--C0--December 14, 2014 11:34 PM

Definitely a plug: dlist: A Major Mode Tutorial

I recently wrote a small major mode and thought writing some sort of tutorial about it would be a useful resource.

Introduction

I don’t have a lot of free space on the device used for my home directory and I needed to make some room. In order to be efficient I wanted to see what were the biggest files and start by handling these.

So first list the biggest files and for each one check whether I want to keep it (usually by opening them in the right program).

The first step is easy on a Unix system. The following command lists and sorts all the regular files of the current directory along with their human readable size (G, M, K, … suffixes).

$ cd ~/.emacs.d # example dir
$ find -type f -print0 | xargs -0 du -h | sort -rh
2.2M    ./yasnippet/.git/objects/pack/pack-cb5bb802d218e01774bbfb3db456bbc55f247176.pack
2.2M    ./yasnippet/extras/imported/objc-mode/Support/alldefs.txt
624K    ./elpa/ecb-snapshot-20120830/ecb.texi
492K    ./elpa/dired+-20141025.2126/dired+.el
428K    ./elpa/magit-20141115.1601/magit.elc
428K    ./elpa/magit-20141025.429/magit.elc
336K    ./elpa/archives/melpa/archive-contents
320K    ./elpa/dired+-20141025.2126/dired+.elc
...

The second step however is boring. I have to cd in right directory, open the file in the right program and eventually delete it with rm. I thought about using emacs for this (using dired in some way) but dired is made to list directories not to work on existing listings of files that don’t belong in the same directory. I’m sure someone somewhere managed to make it work but I personally decided to write a small major mode for that. A poor man’s dired that I called dlist.

dlist-test.png

Design of dlist

  • As in dired, I need to be able to mark and unmark files (select and deselect in modern parlance).
  • I need to open files to check whether I want to delete them or not.
  • I need a delete operation to delete marked files.

I’ll keep the code simple for the tutorial. The actual code I’m using adds more stuff to make it more practical.

Here’s the basic outline of dlist:

(define-derived-mode dlist-mode
  special-mode "Dlist"
  "Major mode for quick file listing.
\\{dlist-mode-map}"
  (message "dlist: init")) ;; TODO

(define-key dlist-mode-map (kbd "m") 'dlist-mark)
(define-key dlist-mode-map (kbd "u") 'dlist-unmark)
(define-key dlist-mode-map (kbd "o") 'dlist-open)
(define-key dlist-mode-map (kbd "x") 'dlist-marked-delete)

(defun dlist-mark ()
  "Mark file on current line."
  (interactive)
  (message "dlist: mark") ;; TODO

(defun dlist-unmark ()
  "Unmark file on current line."
  (interactive)
  (message "dlist: unmark")) ;; TODO

(defun dlist-open ()
  "Open file on current line."
  (interactive)
  (message "dlist: open")) ;; TODO

(defun dlist-marked-delete ()
  "Delete every marked files."
  (interactive)
  (message "dlist: delete") ;; TODO

(defun dlist-show-biggest ()
  "Show the biggest files of current directory."
  (interactive)
  (let ((b (format "*Dlist %*s" default-directory)))
    (with-current-buffer (get-buffer-create b)
      ;; TODO: fill buffer with command output here
      (dlist-mode)))) ;; set major mode on the buffer

(provide 'dlist)

Major modes can be derived from other major modes. There are 3 basic modes you can use as a base mode: prog-mode, text-mode and special-mode (see Basic Major Modes). Like dired or the buffer list menu, dlist is a special mode, so we use that. We get some keybindings (like q to quit) for free. Also, dlist buffers are read-only by default.

define-derived-mode is a macro that does most of the setup work which includes the definition of:

  • dlist-mode-map keymap variable.
  • dlist-mode init function.
  • dlist-mode-hook hook variable.

Next we add our stub functions and their respective keybindings to the mode keymap.

Finally we define our main entry point dlist-show-biggest: a function that creates a new buffer, fills it with our the listing command output and sets the dlist mode.

Implementation

Marking and Unmarking

Let’s define a variable to hold all the marked files. Since variables are global in elisp and we need each dlist buffer to have their own set of marked files, let’s make that variable buffer-local.

(defvar dlist-marked-files nil
  "List of marked files in the current buffer")
(make-variable-buffer-local 'dlist-marked-files)

Now we have to extract and add the current line file to this variable.

(require 'cl) ;; for `assert'

(defvar dlist-line-rx (rx bol (+ (any num ".")) (+ letter) (+ blank) (group (+ nonl)) eol)
  "Regex used to match and capture the file of a dlist line.")

(defun dlist-file ()
  "Return the file on current line."
  (save-excursion
    (beginning-of-line)
    (save-match-data
      (assert (looking-at dlist-line-rx) nil "Invalid listing line")
      (match-string 1))))

(defun dlist-mark ()
  "Mark file on current line."
  (interactive)
  (let ((file (dlist-file)))
    (add-to-list 'dlist-marked-files file)))

(defun dlist-unmark ()
  "Unmark file on current line."
  (interactive)
  (let ((file (dlist-file)))
    (delete file 'dlist-marked-files)))

Opening a file

We’ll use xdg-open as the generic file opener (google it).

(defun dlist-open ()
  "Open file on current line."
  (interactive)
  (start-process " *dlist open*" nil "xdg-open" (dlist-file)))

Coloring marked lines

How can we change the visual representation of marked lines? Let’s define a new face (Emacs’ font description object) called dlist-marked that we will apply to marked lines.

Since dlist-mode is a special mode, the buffer is read-only by default. To change the content (even just the face) we have to temporarily unset the buffer read-only flag. To do that we have to change the set the buffer-read-only variable to nil.

Here I take advantage of elisp dynamic binding to do that: buffer-read-only reverts back to its previous value once the code in the let body is executed.

(require 'dired) ;; we need dired-marked face

(defface dlist-marked
  '((t (:inherit dired-marked))) ;; we reuse dired marking face
  "Face used for Dlist marks.")

(defun dlist-mark ()
  "Mark file on current line."
  (interactive)
  (let ((file (dlist-file))
        (buffer-read-only nil))
    (add-to-list 'dlist-marked-files file)
    (put-text-property
     (save-excursion
       (beginning-of-line) (point))
     (save-excursion
       (end-of-line) (point))
     'face 'dlist-marked)))

(defun dlist-unmark ()
  "Unmark file on current line."
  (interactive)
  (let ((file (dlist-file))
        (buffer-read-only nil))
    (delete file 'dlist-marked-files)
    (remove-text-properties
     (save-excursion
       (beginning-of-line) (point))
     (save-excursion
       (end-of-line) (point))
     '(face))))

Deleting

We have to delete every marked files (easy) but we also have to remove the corresponding lines from the buffer (harder). Here we’ll loop over each line of the buffer and remove the ones that are in dlist-marked-files.

(defun dlist-marked-delete ()
  "Delete every marked files."
  (interactive)
  (when (y-or-n-p (format "Delete %s ?" (mapconcat 'identity dlist-marked-files ", ")))
    (save-excursion
      (save-match-data
        (let ((buffer-read-only nil)) ;; remove read-only
          (goto-char (point-min))     ;; go to first line

          (while (looking-at dlist-line-rx)
            (let ((f (match-string 1)))

              (if (member f dlist-marked-files) ;; if we have a match, delete
                  (progn
                    (delete-region (save-excursion (beginning-of-line) (point))
                                   (save-excursion (end-of-line) (point)))
                    (delete-char 1) ;; remove newline
                    (message "Deleting %s..." f)
                    (delete-file f))

                (beginning-of-line 2))))))) ;; otherwise, next line
    (setq dlist-marked-files nil))) ;; empty mark list

Generating the file list

We still have to fill the buffer with an actual listing. Since the command can take some time and we don’t want to block the Emacs UI, we’ll do it asynchronously and switch to the buffer when it’s ready.

Async processes are started with start-process. You have to specify an output buffer and you can set a callback function that gets called once the process is terminated (among other things). This callback is called a sentinel in elisp.

We’ll define a new buffer-local variable to store each buffer process object.

(defvar dlist-proc nil
  "Dlist current buffer background process.")
(make-variable-buffer-local 'dlist-proc)

(defvar dlist-cmd "find -type f -print0 | xargs -0 du -h | sort -rh"
  "Command used to generate the file listing.")

(defun dlist-show-biggest ()
  "Show the biggest files of current directory."
  (interactive)
  (let ((buf (format "*Dlist %s*" default-directory)))

    (when (get-buffer buf)
      (kill-buffer buf)) ;; kill buffer if it already exists

    (with-current-buffer (get-buffer-create buf)
      ;; start process (ignore stderr)
      (setq dlist-proc
            (start-process-shell-command
             "dlist" (current-buffer)
             (concat "( " dlist-cmd " ) 2> /dev/null")))

      ;; set callback
      (set-process-sentinel
       dlist-proc
       (lambda (proc event)
         (if (string= event "finished\n")
             (let ((b (process-buffer proc)))
               (switch-to-buffer b)
               (with-current-buffer b (dlist-mode) (goto-char (point-min))))
           (error "Error on dlist cmd: %s" event)))))))

The whole thing

;; ISC license
;; Copyright (C) 2014, Aurélien Aptel <aurelien.aptel@gmail.com>

;; Permission to use, copy, modify, and/or distribute this software for any
;; purpose with or without fee is hereby granted, provided that the above
;; copyright notice and this permission notice appear in all copies.

;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

(require 'cl) ;; for `assert'
(require 'dired) ;; we need `dired-marked' face

(defvar dlist-marked-files nil
  "List of marked files in the current buffer.")
(make-variable-buffer-local 'dlist-marked-files)

(defvar dlist-proc nil
  "Dlist current buffer background process.")
(make-variable-buffer-local 'dlist-proc)

(defvar dlist-cmd "find -type f -print0 | xargs -0 du -h | sort -rh"
  "Command used to generate the file listing.")

(defvar dlist-line-rx (rx bol (+ (any num ".")) (+ letter) (+ blank) (group (+ nonl)) eol)
  "Regex used to match and capture the file of a dlist line.")

(defface dlist-marked
  '((t (:inherit dired-marked))) ;; we reuse dired marking face
  "Face used for Dlist marks.")

(define-derived-mode dlist-mode
  special-mode "Dlist"
  "Major mode for quick file listing.
\\{dlist-mode-map}"
  (message "dlist: init"))

(define-key dlist-mode-map (kbd "m") 'dlist-mark)
(define-key dlist-mode-map (kbd "u") 'dlist-unmark)
(define-key dlist-mode-map (kbd "o") 'dlist-open)
(define-key dlist-mode-map (kbd "x") 'dlist-marked-delete)

(defun dlist-file ()
  "Return the file on current line."
  (save-excursion
    (beginning-of-line)
    (save-match-data
      (assert (looking-at dlist-line-rx) nil "Invalid listing line")
      (match-string 1))))

(defun dlist-open ()
  "Open file on current line."
  (interactive)
  (start-process " *dlist open*" nil "xdg-open" (dlist-file)))

(defun dlist-mark ()
  "Mark file on current line."
  (interactive)
  (let ((file (dlist-file))
        (buffer-read-only nil))
    (add-to-list 'dlist-marked-files file)
    (put-text-property
     (save-excursion
       (beginning-of-line) (point))
     (save-excursion
       (end-of-line) (point))
     'face 'dlist-marked)))

(defun dlist-unmark ()
  "Unmark file on current line."
  (interactive)
  (let ((file (dlist-file))
        (buffer-read-only nil))
    (delete file 'dlist-marked-files)
    (remove-text-properties
     (save-excursion
       (beginning-of-line) (point))
     (save-excursion
       (end-of-line) (point))
     '(face))))

(defun dlist-marked-delete ()
  "Delete every marked files."
  (interactive)
  (when (y-or-n-p (format "Delete %s ?" (mapconcat 'identity dlist-marked-files ", ")))
    (save-excursion
      (save-match-data
        (let ((buffer-read-only nil)) ;; remove read-only
          (goto-char (point-min))     ;; go to first line

          (while (looking-at dlist-line-rx)
            (let ((f (match-string 1)))

              (if (member f dlist-marked-files) ;; if we have a match, delete
                  (progn
                    (delete-region (save-excursion (beginning-of-line) (point))
                                   (save-excursion (end-of-line) (point)))
                    (delete-char 1) ;; remove newline
                    (message "Deleting %s..." f)
                    (delete-file f))

                (beginning-of-line 2))))))) ;; otherwise, next line
    (setq dlist-marked-files nil))) ;; empty mark list

(defun dlist-show-biggest ()
  "Show the biggest files of current directory."
  (interactive)
  (let ((buf (format "*Dlist %s*" default-directory)))

    (when (get-buffer buf)
      (kill-buffer buf)) ;; kill buffer if it already exists

    (with-current-buffer (get-buffer-create buf)
      ;; start process (ignore stderr)
      (setq dlist-proc
            (start-process-shell-command
             "dlist" (current-buffer)
             (concat "( " dlist-cmd " ) 2> /dev/null")))

      ;; set callback
      (set-process-sentinel
       dlist-proc
       (lambda (proc event)
         (if (string= event "finished\n")
             (let ((b (process-buffer proc)))
               (switch-to-buffer b)
               (with-current-buffer b (dlist-mode) (goto-char (point-min))))
           (error "Error on dlist cmd: %s" event)))))))

(provide 'dlist)

Testing

Let’s test this thing. First, create some random files:

$ mkdir /tmp/dlist
$ cd /tmp/dlist
$ for i in $(seq 10); do
    dd if=/dev/urandom of=$RANDOM bs=1 count=$RANDOM
  done

Then, start emacs and load the source. Set the default directory to /tmp/dlist with M-x cd and run M-x dlist-show-biggest.

That’s it!

-1:-- dlist: A Major Mode Tutorial (Post aaptel)--L0--C0--December 13, 2014 06:25 PM

sachachua: Emacs: M-y as helm-show-kill-ring

This entry is part 1 of 1 in the series Emacs Kaizen

After realizing that I barely scratched the surface of Helm’s awesomeness (really, I basically use it as an ido-vertical-mode), I made a concerted effort to explore more of the interesting things in the Helm toolkit. helm-show-kill-ring is one such thing. I’ve bound it to M-y, which I had previously configured to be browse-kill-ring, but helm-show-kill-ring is much cooler because it makes it easy to dynamically filter your kill ring. Also, Kcode>M-y works better for me than C-y does because I know when I want the last thing I killed, but going beyond that is a little annoying.

That said, browse-kill-ring does make it easy to edit a kill ring entry. Maybe I should learn how to modify Helm’s behaviour so that I can add an edit action. There’s already a delete action. Besides, I haven’t used that feature in browse-kill-ring yet, so I can probably get by even without it.

ido fans: you can use helm-show-kill-ring without activating helm-mode, if you want.

On a related note, I like how rebinding M-x (execute-extended-comand) to helm-M-x shows me keybindings as I search for commands. You do have to get used to the quirk of typing C-u and other prefixes after M-x instead of before, but I haven’t had a problem with this yet. This is mostly because I haven’t dug into just how many commands do awesome things when given a prefix argument. I know about using C-u C-c C-w (org-refile) to jump to places instead of refiling notes, but that’s about it. I haven’t gone anywhere close to C-u C-u. Does anyone have a favourite command they use that does really smart things when given that prefix? =)

This Helm intro has animated GIFs and a few other useful commands. Check it out!

The post Emacs: M-y as helm-show-kill-ring appeared first on sacha chua :: living an awesome life.

-1:-- Emacs: M-y as helm-show-kill-ring (Post Sacha Chua)--L0--C0--December 10, 2014 01:00 PM

Endless Parentheses: Introducing Names: practical namespaces for Emacs-Lisp

A little over a month ago, I released a package called Names, designed for mitigating Emacs' namespace issue. Before I even had a chance to announced it, it made a bit of a splash on r/emacs, which I've taken to mean that people are interested. I've been holding off on this post until I had a couple of Names-using packages under my belt, so I could actually speak from experience as opposed to expectation, and that's finally the case.

Names aims to provide an implementation of namespaces in Emacs-Lisp with four guiding principles:

Practical
Actually useful and easy to grasp.
Complete
Support any function, macro, or special-form available in emacs-lisp, even the ones defined by you or a third party.
Robust
No-surprises, well-tested, and with clearly stated limitations.
Debuggable
Support edebug, find-function/ variable/ face, eval-defun, and eval-last-sexp (also known as C-x C-e). Integration with other developing tools are under way.

Why a namespace package?

The lack of actual namespaces in elisp is a recurring topic in the Emacs community. The discussion is long and beyond the scope of this post, so I'll refer those interested to Nic Ferrier's great essay on the subject and to a concise explanation by Jon Snader as well.

In short, Emacs takes the approach of prefixing every symbol name with the name of the package. This successfully avoids name clashes between packages, but it quickly leads to code that's repetitive and annoying to write. The links above mentions many shortcomings of this approach, but this code-cluttering repetition of the package name has always bothered me the most. It makes the code longer and more tiresome to read

See this example from package.el. The word “package” is repeated 7 times in a 10-line function.

;;;###autoload
(defun package-initialize (&optional no-activate)
  "[DOC]"
  (interactive)
  (setq package-alist nil)
  (package-load-all-descriptors)
  (package-read-all-archive-contents)
  (unless no-activate
    (dolist (elt package-alist)
      (package-activate (car elt))))
  (setq package--initialized t))

What does Names do?

It doesn't change this approach, nor does it try to revolutionize Emacs or reinvent packages. Names fully adheres to Emacs conventions and is completely invisible to the end-user, it simply gives you (the developer) a convenient way of writing code that adheres to this standard.

Here's what the code above would look like inside a namespace.

;;;###autoload
(define-namespace package-

:autoload
(defun initialize (&optional no-activate)
  "[DOC]"
  (interactive)
  (setq alist nil)
  (load-all-descriptors)
  (read-all-archive-contents)
  (unless no-activate
    (dolist (elt alist)
      (activate (car elt))))
  (setq -initialized t))
)

define-namespace is a macro. At compilation, it expands to generate the exact same code as the original, thus being completely invisible to the user.

How reliable is it?

I'll forgive you for being sceptical, wrapping your entire package in a macro sounds risky. Rest assured, Names is very smart in what it does, and it strives to avoid surprises.

Furthermore, it features a thorough test suite which leverages off other well-tested packages to the respectable sum of 244 tests. Of course, the number by itself has no objective meaning, but it shows that I'm commited to making it as reliable and robust as possible. To prove I mean business, the last two packages I pushed to Melpa already make use of it. And if that's not enough, I just got news that shell-switcher has joined the party and seems to be passing all tests.

In terms of availability, it's on GNU Elpa, so it's a safe dependency for any Emacs starting with 24.1.

And how do I use it?

If you learn better by example, you can have a quick look at this short dummy package available on the repo or, for real world packages, see camcorder.el or aggressive-indent. In any case, it's important to check the Readme for the most up-to-date instructions but here's the gist of it:

  • List names as a dependency. A typical header will contain
;; Package-Requires: ((names "0.5") (emacs "24"))
  • Write all code inside the define-namespace macro, preceded by an ;;;###autoload cookie. The first argument of the macro is the prefix which will be applied to all definitions. require and provide statements go outside the macro.
;; `require' statements come first.
(require 'whatever)

;;;###autoload
(define-namespace example-
;;; Code goes here
)

(provide 'example)
;;; example.el ends here
  • Inside the macro, instead of using ;;;###autoload cookies, use the :autoload keyword.

And that's pretty much it. Just write your code without prefixing every symbol with the package name, and Names will take care of that for you.

1. Every definition gets namespaced

Any definitions inside will have the prefix prepended to the symbol given. So the code

;;;###autoload
(define-namespace foo-

(defvar bar 1 "docs")

:autoload
(defun free ()
  "DOC"
  (message "hi"))
)

essentially expands to

(defvar foo-bar 1 "docs")

;;;###autoload
(defun foo-free ()
  "DOC"
  (message "hi"))

2. Function calls and variables are namespaced if defined

This is best explained by example. This code:

(define-namespace foo-

(defvar var infinite)
(defun infinite (x)
  (infinite x))

(infinite 2) ;; Local function call
(something-else t) ;; External function call
(::infinite var) ;; External function call
infinite ;; Variable
)

expands to this code:

(defvar foo-myvar infinite)
(defun foo-infinite (x)
  (foo-infinite x))

(foo-infinite 2) ;; Local function call
(something-else t) ;; External function call
(infinite foo-var) ;; External function call.
infinite ;; Variable.

Note how:

  • The infinite symbol gets namespaced only as a function name, not when it's used as a variable. That's because Names knows that foo-infinite is not a defined variable.
  • The symbol ::infinite is not namespaced, because it had been protected with ::.
  • something-else is not namespaced, because it is not a locally defined function, so it must be external.

3. Quoted forms are not namespaced.

Whenever a form is not meant for evaluation, it is left completely untouched. The most significant example of this are lists and symbols quoted with a simple quote (e.g. 'foo). These are regarded as data, not code, so you'll have to write the prefix explicitly inside these quoted forms.

Some examples of the opposite:

  • Symbols quoted with a function quote (e.g. #'foo) are regarded as function names, and are namespaced as explained in item 2. Remember you should use the function quote for functions anyway.
  • Comma forms inside a back-tick form (e.g. `(nothing ,@(function) ,variable)) are meant for evaluation and so will be namespaced.

But is it all worth it?

Absolutely! Like I said, I've already written two packages using Names, and I had a blast! Of course, my opinion is biased. But I can say with all honesty that it's an absolute delight to not need to worry about all those prefixes.

I invite people to try it out. If you do, make sure you (require 'names-dev) in your init file. This will enable integration with edebug, find-function, eval-defun, and eval-last-sexp. I've already got news that shell-switcher has made the conversion, and alchemist seems to be on the way.

Comment on this.

-1:-- Introducing Names: practical namespaces for Emacs-Lisp (Post)--L0--C0--December 10, 2014 12:00 AM

Emacs Redux: Converting between symbols and strings

Sometimes you might need to convert a symbol to string (or vice versa) in Emacs Lisp. You start looking for functions like symbol-to-string and string-to-symbol but, alas, they do not seem exist. Do not despair! Such functions do actually exist, although their names are likely to surprise you:

1
2
3
4
(symbol-name 'some-symbol)
; => "some-symbol"
(intern "some-symbol")
; => some-symbol
-1:-- Converting between symbols and strings (Post)--L0--C0--December 05, 2014 03:28 PM

Chen Bin (redguardtoo): How to validate HTML5 code with Flymake effectively

UPDATED: 2014-12-11

CREATED: 2014-12-05

Here is the solution from EmacsWiki.

I found it not effective because tidy is too strict to HTML5 and produces too much noise.

I only need validation of missing open/closed html tag(s). Nothing more!

So here is my complete solution:

(defun flymake-html-init ()
       (let* ((temp-file (flymake-init-create-temp-buffer-copy
                          'flymake-create-temp-inplace))
              (local-file (file-relative-name
                           temp-file
                           (file-name-directory buffer-file-name))))
         (list "tidy" (list local-file))))

(defun flymake-html-load ()
  (interactive)
  (when (and (not (null buffer-file-name)) (file-writable-p buffer-file-name))
    (set (make-local-variable 'flymake-allowed-file-name-masks)
         '(("\\.html\\|\\.ctp\\|\\.ftl\\|\\.jsp\\|\\.php\\|\\.erb\\|\\.rhtml" flymake-html-init))
         )
    (set (make-local-variable 'flymake-err-line-patterns)
         ;; only validate missing html tags
         '(("line \\([0-9]+\\) column \\([0-9]+\\) - \\(Warning\\|Error\\): \\(missing <\/[a-z0-9A-Z]+>.*\\|discarding unexpected.*\\)" nil 1 2 4))
         )
    (flymake-mode t)))

(add-hook 'web-mode-hook 'flymake-html-load)
(add-hook 'html-mode-hook 'flymake-html-load)
(add-hook 'nxml-mode-hook 'flymake-html-load)
(add-hook 'php-mode-hook 'flymake-html-load)

The only difference from EmacsWiki is only one line:

'(("line \\([0-9]+\\) column \\([0-9]+\\) - \\(Warning\\|Error\\): \\(missing <\/[a-z0-9A-Z]+>.*\\|discarding unexpected.*\\)" nil 1 2 4))
-1:-- How to validate HTML5 code with Flymake effectively (Post Chen Bin)--L0--C0--December 05, 2014 01:00 PM

Bozhidar Batsov: Introducing inf-clojure - a better basic Clojure REPL for Emacs

At Clojure/conj I had the chance to shake Rich Hickey’s hand and exchange a few words with him. When I asked him whether he currently uses CIDER or Cursive for Clojure development he replied that he preferred a simpler solution – clojure-mode & inferior-lisp-mode. I was a bit surprised because clojure-mode’s integration with inferior-lisp-mode sucks (big time). It has always been extremely limited and was never really improved/extended. It has no Clojure specific features and no code completion. I felt that Rich and all the people using inferior-lisp-mode deserved something better, so I quickly put together inf-clojure.

inf-clojure provides some Clojure specific features like showing a var’s doc or source, derives some core functionality from clojure-mode and even features basic code-completion (and company-mode support). That’s not much admittedly, but it’s a good start. Extending inf-clojure is super easy and I expect that we’ll add a bit more features to it along the way (e.g. macroexpansion).

inf-clojure is available in MELPA and will eventually replace completely inferior-lisp-mode when clojure-mode 4.0 is released.

Keep in mind that inf-clojure is nothing like CIDER and will never be. CIDER will always be the powertool for Clojure programming in Emacs. I do understand, however, that some people are overwhelmed by CIDER and some people simply don’t need anything sophisticated. I hope they’ll enjoy inf-clojure!

-1:-- Introducing inf-clojure - a better basic Clojure REPL for Emacs (Post)--L0--C0--December 04, 2014 05:04 PM

Chen Bin (redguardtoo): Advanced tip on using mozrepl to automatically refresh browser

Here is the setup on Emacswiki.

I find it annoying instead of helpful in real world.

The mozrepl trick basically will refresh the current active page in Firefox. It's not smart enough. When developing a web application, I will open many stackoverflow pages to look for technical solution. I don't like my stackoverflow page being refreshed when I'm saving the HTML code for some web application.

So here is my improved solution:

(defun my-moz-refresh-browser-condition (current-file)
  "Should return a boolean javascript expression or nil"
  (let (rlt)
    (cond
     ((string-match "\\(beeta\\|cb_tutorial\\)" current-file)
      (setq rlt "content.document.location.href.indexOf(':8001')!==-1"))
     (t
      (setq rlt nil)))
    rlt))

;; {{ mozrepl auto-refresh browser
(defun moz-reload-browser ()
  (interactive)
  (let (js-cond cmd)
    (if (fboundp 'my-moz-refresh-browser-condition)
        (setq js-cond (funcall 'my-moz-refresh-browser-condition (buffer-file-name))))
    (cond
     (js-cond
      (setq cmd (concat "if(" js-cond "){setTimeout(function(){content.document.location.reload(true);}, '500');}")))
     (t
      (setq cmd "setTimeout(function(){content.document.location.reload(true);}, '500');")))
    (comint-send-string (inferior-moz-process) cmd)
    ))

(defun moz-after-save ()
  (interactive)
  (when (memq major-mode '(web-mode html-mode nxml-mode nxhml-mode php-mode))
    (moz-reload-browser)))

(add-hook 'after-save-hook
              'moz-after-save
              'append 'local)
;; }}
-1:-- Advanced tip on using mozrepl to automatically refresh browser (Post Chen Bin)--L0--C0--December 03, 2014 08:44 AM

Sebastian Wiesner: Generic syntax checkers in Flycheck

In two years of maintaining Flycheck I received many wishes and feature requests. I implemented many, discarded some, but I never came around to add the most requested feature and fix the oldest issue still open: Check a buffer with an arbitrary Emacs Lisp function.

Now, after more than one year of waiting, this feature is finally there: Flycheck now supports “generic syntax checkers”, which call synchronous or asynchronous Emacs Lisp functions instead of invoking external commands. They are “generic” because they are essentially a superset of normal syntax checkers: In fact, regular syntax checkers are now called “command syntax checkers” and implemented on top of this new feature, as a specific kind of generic checkers.

For users of Flycheck nothing has changed other than that you’ll probably see a lot of new syntax checkers emerging in the next weeks and months.

For developers, however, this opens many new interesting possibilities. You have even more power to write syntax checkers for your favourite languages now: Even if there is no linting tool or if it’s not feasible to use an external tool, you can now write syntax checkers using a persistent background process or a running REPL instead. You could even write lints entirely in Emacs Lisp, although that’s not really recommendable due to Emacs synchronous execution1.

For instance, Flycheck never had an OCaml syntax checker. Checking OCaml is not as easy as checking C, because dependency management is more sophisticated and more complicated in OCaml. Luckily, there is a tool called Merlin which does all the dirty work, providing a persistent background process that caches the entire state of an OCaml project. It’s mainly used for completion, but it can also check a buffer for errors.

With generic syntax checkers, we can finally implement a syntax checker that talks to a Merlin process to check a buffer for errors2. This post explains the implementation of this syntax checker (available in the flycheck-ocaml extension) to introduce generic syntax checkers to you.

Note that the Emacs Lisp code in this article is written for lexical scoping, and will not work with dynamical scoping. Please keep that in mind when writing your own syntax checkers.

1 Defining a generic syntax checker

The new function flycheck-define-generic-checker defines a “generic” syntax checker. A generic syntax checker looks almost like a regular syntax checker, except there is a :start function instead of a :command and :error-patterns3:

(flycheck-define-generic-checker 'ocaml-merlin
  "A syntax checker for OCaml using Merlin Mode.

See URL `https://github.com/the-lambda-church/merlin'."
  :start #'flycheck-ocaml-merlin-start
  :modes '(caml-mode tuareg-mode)
  :predicate (lambda () merlin-mode))

Like a regular command syntax checker, a generic checker needs :modes and (optionally) a :predicate. In this case we specify the common OCaml editing modes and an additional predicate that checks whether merlin-mode–which provides the background process we are going to use for syntax checking—is active.

All of this is just the standard boilerplate for syntax checkers, but :start is a new thing. Here the fun begins: The value of :start is a function to start the syntax check.

2 Starting a syntax check

Flycheck calls this :start function whenever it needs to check the buffer, just like it would invoke the :command of a command syntax checker. The :start function takes two arguments:

  1. The syntax checker being run, just in case the :start function is being shared among different syntax checkers.
  2. A callback function, which shall be used to report the results of a syntax check back to Flycheck.

The flycheck-ocaml-merlin-start function of our new syntax checker looks as follows:

(defun flycheck-ocaml-merlin-start (checker callback)
  "Start a Merlin syntax check with CHECKER.

CALLBACK is the status callback passed by Flycheck."
  (merlin-sync-to-point (point-max) t)
  ;; Put the current buffer into the closure environment so that we have access
  ;; to it later.
  (let ((buffer (current-buffer)))
    (merlin-send-command-async
     'errors
     (lambda (data)
       (condition-case err
           (let ((errors (mapcar
                          (lambda (alist)
                            (flycheck-ocaml-merlin-parse-error alist checker
                                                               buffer))
                          data)))
             (funcall callback 'finished (delq nil errors)))
         (error (funcall callback 'errored (error-message-string err)))))
     ;; The error callback
     (lambda (msg) (funcall callback 'errored msg)))))

At the beginning we update Merlin with the current contents of the buffer. This step still happens synchronously, but the subsequent error checking is entirely asynchronous. merlin-send-command-async sends the errors command to the Merlin background process. When finished Merlin calls either of the two callbacks given to this function: The first callback with the results of a successful check, and the second with an error message if the check failed.

We provide two lambdas for these callbacks: The first callback parses the Merlin result and turns it into a proper Flycheck result, whereas the second callback just forwards the error message to Flycheck.

Note that we put the current buffer into a local variable. Since the command is executed asynchronously, we can’t use (current-buffer) in the Merlin callback: The current buffer might have changed meanwhile. By putting it in a local variable we permanently store the buffer being checked in the closure environment.

3 Reporting results

Let use focus on the second callback—the error callback—first, for the sake of simplicity. This callback just calls Flycheck’s own callback with two arguments:

  1. The status symbol
  2. The status metadata

These are the two components of the “status protocol” that Flycheck provides for generic syntax checkers to communicate with Flycheck.

The status symbol errored tells Flycheck that an error occurred in the syntax check. Its metadata is simply the corresponding error message as string.

The other important status symbol is finished, which tells Flycheck that a syntax check as properly finished. It’s metadata is a (potentially empty) list of flycheck-error objects which denote errors in the current buffer.

4 Parsing errors

Before we can report errors, though, we need to parse them. This is what we do in the first merlin-send-command-async callback.

Merlin returns the list of errors as a list of alists in the data argument to the callback. Each alist describes a single error in the buffer. We map over all alists with flycheck-ocaml-merlin-parse-error to turn them into flycheck-error objects. Eventually we pass these parsed errors to Flycheck’s callback, using the finished status. This causes Flycheck to report these errors in the buffer, just like it does for regular command syntax checkers.

flycheck-ocaml-merlin-parse-error extracts the relevant keys from each error list, and creates a new flycheck-error object:

(defun flycheck-ocaml-merlin-parse-error (alist checker buffer)
  "Parse a Merlin error ALIST from CHECKER in BUFFER into a `flycheck-error'.

Return the corresponding `flycheck-error'."
  (let* ((orig-message (cdr (assq 'message alist)))
         (start (cdr (assq 'start alist)))
         (line (or (cdr (assq 'line start)) 1))
         (column (cdr (assq 'col start))))
    (when orig-message
      (pcase-let* ((`(,level . ,message)
                    (flycheck-ocaml-merlin-parse-message orig-message)))
        (if level
            (flycheck-error-new-at line column level message
                                   :checker checker
                                   :buffer buffer
                                   :filename (buffer-file-name))
          (lwarn 'flycheck-ocaml :error
                 "Failed to parse Merlin error message %S from %S"
                 orig-message alist)
          nil)))))

flycheck-ocaml-merlin-parse-message applies a regular expression to the original error messages in order to extract the error level (which Merlin does not report otherwise) and the real error message. It’s rather dumb and not particularly interesting, so I omitted it for the sake of brevity. If you are interested, take a look at the Github page of flycheck-ocaml

flycheck-error-new-at then creates and returns a new flycheck-error object with the information obtained from Merlin. Note that you really need to fill the entire structure, except for those slots which are explicitly marked optional in the documentation. Notably, Flycheck needs the :checker, :buffer and :filename slots to associate the error object with the right buffer.

And that’s it! With just these few lines of code we have defined a syntax checker that talks to a persistent background process to check the current buffer, and parses the results reported by the background process into a format understood by Flycheck.

5 Why did this take so long

If it’s that simple, why did it take so long, I hear you ask. Well, internally things aren’t that simple.

Since Emacs lacks any asynchronous features other than processes, Flycheck grew based on external processes until it had entirely absorbed them. Breaking this close relationship with processes required a lot of refactoring, which is a tedious and error-prone task in a language with as weak a type system as Emacs Lisp.

With the lack of asynchronous functions also comes a notorious lack of modern concurrency primitives in Emacs, which makes it hard to design a reasonable generic API for an asynchronous task. Where I’d just have used a future or channel in a decent programming language, Flycheck does a lot of internal book-keeping of its current state via global variables.

Consequently there are no means to properly debug concurrent code either. A race condition in the new process management code that resulted from the refactoring took me days to debug, until I could finally isolate it with literally dozens of (message "DEBUG") calls all over the place.

6 Final words

Nonetheless, I’m sorry that it took so long, and I hope that what I have come up with compensates for the year that you have all waited. I took quite some time to debug and test the new API and the refactored internals of Flycheck, so there should be little to no bugs left, but if you find any please do not hesitate to report them to the issue tracker.

And if you choose to try the new API and write one or another syntax checker yourself: I’m really keen on your feedback! Please tell me whether you like the API, whether the documentation was sufficient, whether you had any difficulties, and—most importantly—what you think can be improved.


  1. Essentially, an Emacs Lisp linter would freeze Emacs while checking the buffer, which is not particularly convenient.

  2. The same technique can be used for other languages, which Flycheck does not yet sufficiently support. For instance, there’s no support for Java or Clojure in Flycheck because of the long JVM startup times. A generic syntax checker however could send a Clojure buffer of to a running Clojure REPL, which is much faster than starting a new Java process.

  3. Also, unlike flycheck-define-checker the syntax checker name and the property values must be quoted, because flycheck-define-generic-checker is really a function and not a macro.

-1:-- Generic syntax checkers in Flycheck (Post)--L0--C0--December 03, 2014 12:00 AM

Anupam Sengupta: The Other Emacsen

While Emacs remains my primary text editor, there are times when starting a full Emacs session with tons of packages is simply too slow, especially on a terminal window, and when the task at hand is simply to make a few lines of changes in a configuration file.

Yes, I do know about the handy -q command-line option, which prevents the init.el file from being loaded, thereby ensuring a sub-second initialization of Emacs, or the emacsclient route (which I have enabled, and do use), but sometimes it is just more convenient to have a fast editor that has the Emacs feel, without the bloat. And for a text nerd such as myself, it is also a matter of curiosity to try out other editors once in a while.

Emacs actually has had a rich history of variants and alternate implementations, with XEmacs being one of more well known forks. On the Mac OS X, Aquamacs has remained a good option for a number of years. A more comprehensive list is available on the Wikipedia page for Emacs.

Both XEmacs and Aquamacs are forked from, or derivatives of GNU Emacs, which is probably the most used Emacs these days. However, other light-weight Emacs-like editors still exist, and I have been trying out three of these, vile, zile, and jmacs. On the Mac, these are available via Mac Ports, on Fink, and possibly on Homebrew.

vile is an interesting blend of Emacs and vi, and provides the modal commands from vi, but also has many of the window management features of Emacs (including similar Emacs key-bindings). It is really more of a vi variant, but the window management does make it very handy, though it does not support the text objects and other vi extensions as Vim does.

jmacs (the Joe editor’s Emacs emulation) seems to be the most feature rich, and the syntax highlighting seems to be best of the lot.

Then there is zile, yet another Emacs clone that I am beginning to love for being lightweight, and having the most Emacs-like behavior. For simple text entry, zile seems to feel to be the fastest—though in reality—all three editors start up pretty fast.

In the end, while I still end up with using Emacs/emacsclient for most of my editing (after all, I do keep a Emacs session running most of the time like the true faithful), it is still fun to dabble with these editors, if for nothing else than to marvel at the core Emacs editing experience that these micro-editors can provide, in sub-Megabyte packages (vile = 680K, zile = 251K, joe = 440K on my machine).


-1:-- The Other Emacsen (Post evolve75)--L0--C0--November 30, 2014 03:57 PM

Jorgen Schäfer: typo.el 1.0 released: An Emacs library for typographical editing

typo.el provides two modes. typo-global-mode provides a prefix map for a number of useful Unicode glyphs, while typo-mode changes the behavior of a number of keys in the current buffer.

The changed keys will try to smartly guess which Unicode glyph you wanted to enter from context. Most of them let you easily cycle through a selection in case the first one was not what you wanted.

Quotation Marks

“He said, ‘leave me alone,’ and closed the door.”

All quotation marks in this sentence were added by hitting the " key exactly once each. typo.el guessed the correct glyphs to use from context. If it gets it wrong, you can just repeat hitting the " key until you get the quotation mark you wanted.

M-x typo-change-language lets you change which quotation marks to use. This is also configurable, in case you want to add your own.

Dashes and Dots

The hyphen key will insert a default hyphen-minus glyph. On repeated use, though, it will cycle through the en-dash, em-dash, and a number of other dash-like glyphs available in Unicode. This means that typing two dashes inserts an en-dash and typing three dashes inserts an em-dash, as would be expected. The name of the currently inserted dash is shown in the minibuffer.

The full stop key will self-insert as usual. When three dots are inserted in a row, though, they are replaced by a horizontal ellipsis glyph.

Other Keys

Tick and backtick keys insert the appropriate quotation mark as well. The less-than and greater-than signs cycle insert the default glyphs on first use, but cycle through double and single guillemets on repeated use.

Prefix Map

In addition to the above, typo-global-mode also provides a globally-accessible key map under the C-c 8 prefix (akin to Emacs’ default C-x 8 prefix map) to insert various Unicode characters.

In particular, C-c 8 SPC will insert a no-break space. Continued use of SPC after this will cycle through half a dozen different space types available in Unicode.

Check the mode’s documentation for more details.

Download and Installation

Download typo.el and put it somewhere in your load-path.

Add the following to your .emacs:

(typo-global-mode 1)
(add-hook 'text-mode-hook 'typo-mode)
-1:-- typo.el 1.0 released: An Emacs library for typographical editing (Post Jorgen Schäfer (noreply@blogger.com))--L0--C0--November 27, 2014 09:45 AM

Jorgen Schäfer: Emacs: Search for Symbol at Point

One thing I regularly do is to try and look for other occurrences of the symbol at point in my buffer. This can serve as a poor man’s way of finding the definition or callers of a function, or uses of a variable. It’s kind of annoying to do that in Emacs by default, sadly. The following code from my .emacs will enable the key shortcut C-din isearch to yank the symbol at point into the search string. So C-s C-d will then start a search for that symbol, and already highlight it. Keep hitting C-s to move to further occurrences.

(define-key isearch-mode-map (kbd "C-d")
'fc/isearch-yank-symbol)
(defun fc/isearch-yank-symbol ()
"Yank the symbol at point into the isearch minibuffer.

C-w does something similar in isearch, but it only looks for
the rest of the word. I want to look for the whole string. And
symbol, not word, as I need this for programming the most."
(interactive)
(isearch-yank-string
(save-excursion
(when (and (not isearch-forward)
isearch-other-end)
(goto-char isearch-other-end))
(thing-at-point 'symbol))))
-1:-- Emacs: Search for Symbol at Point (Post Jorgen Schäfer (noreply@blogger.com))--L0--C0--November 27, 2014 09:43 AM

Raimon Grau: Temporarily ignore people in IRC

I'm using irc more and more for my communication with others.  And spending more time in IRC means that it makes more sense to optimize it.  And also, erc is a good playground for us, elisp hackers :)

So when someone is bitching or saying nonsensic BS on some IRC channel (or slack, or hipchat, or anything that supports bitlbee), you can ignore him/her, but often you forget to unignore, and after a few hours they tell you something important and you just miss it.  Not good.

So here's a timed ignore command for erc


(
defun erc-cmd-TMPIG (&rest users)
(let ((b (current-buffer)))
(
dolist (user users)
(erc-process-input-line (format
"/ignore %s" user)))
(run-at-time (* 60 10) nil
(
lambda ()
(
dolist (user users)
(
with-current-buffer b
(erc-process-input-line (format
"/unignore %s" user))))))))


Yes, some of you reading this will be the victims of this... :)

EDIT: This code needs to be in a file with lexical scope active. otherwise, use lexical-let instead of let
-1:-- Temporarily ignore people in IRC (Post Raimon Grau (noreply@blogger.com))--L0--C0--November 26, 2014 05:15 PM

emacspeak: Announcing Emacspeak 41.0: NiceDog

Emacspeak 41.0—NiceDog—Unleashed!

1 Emacspeak-41.0 (NiceDog) Unleashed!

** For Immediate Release:

San Jose, Calif., (Nov 26, 2014) Emacspeak: Redefining Accessibility In The Era Of Web Computing –Zero cost of upgrades/downgrades makes priceless software affordable!

Emacspeak Inc (NASDOG: ESPK) --http://emacspeak.sf.net– announces the immediate world-wide availability of Emacspeak 41.0 (NiceDog) –a powerful audio desktop for leveraging today's evolving data, social and service-oriented Web cloud.

1.1 Investors Note:

With several prominent tweeters expanding coverage of #emacspeak, NASDOG: ESPK has now been consistently trading over the social net at levels close to that once attained by DogCom high-fliers—and as of November 2014 is trading at levels close to that achieved by once better known stocks in the tech sector.

1.2 What Is It?

Emacspeak is a fully functional audio desktop that provides complete eyes-free access to all major 32 and 64 bit operating environments. By seamlessly blending live access to all aspects of the Internet such as Web-surfing, blogging, social computing and electronic messaging into the audio desktop, Emacspeak enables speech access to local and remote information with a consistent and well-integrated user interface. A rich suite of task-oriented tools provides efficient speech-enabled access to the evolving service-oriented social Web cloud.

1.3 Major Enhancements:

  • Emacs EWW: Consume Web content efficiently. 📚
  • emacspeak-url-templates: Smart Web access. ♅
  • emacspeak-websearch.el Find things fast. ♁
  • emacspeak-google.el: Improved Google integration. ⁈
  • Calibre integration for searching and viewing epub 📚
  • Complete anything via company integration 🗜
  • Speech-enabled 2048 🂠
  • Emacspeak At Twenty -Historical Overview ⛬
  • gmaps.el: Find places, read reviews, get there. 🌐
  • Feed Browser Consume feeds post Google-Reader. ␌
  • Freebase Search: Explore freebase knowledge base. 🆓
  • Emacs 24.4: Supports all new features in Emacs 24.4. 🌚
  • And a lot more than wil fit this margin. …

1.4 Establishing Liberty, Equality And Freedom:

Never a toy system, Emacspeak is voluntarily bundled with all major Linux distributions. Though designed to be modular, distributors have freely chosen to bundle the fully integrated system without any undue pressure—a documented success for the integrated innovation embodied by Emacspeak. As the system evolves, both upgrades and downgrades continue to be available at the same zero-cost to all users. The integrity of the Emacspeak codebase is ensured by the reliable and secure Linux platform used to develop and distribute the software.

Extensive studies have shown that thanks to these features, users consider Emacspeak to be absolutely priceless. Thanks to this wide-spread user demand, the present version remains priceless as ever—it is being made available at the same zero-cost as previous releases.

At the same time, Emacspeak continues to innovate in the area of eyes-free social interaction and carries forward the well-established Open Source tradition of introducing user interface features that eventually show up in luser environments.

On this theme, when once challenged by a proponent of a crash-prone but well-marketed mousetrap with the assertion "Emacs is a system from the 70's", the creator of Emacspeak evinced surprise at the unusual candor manifest in the assertion that it would take popular idiot-proven interfaces until the year 2070 to catch up to where the Emacspeak audio desktop is today. Industry experts welcomed this refreshing breath of Courage Certainty and Clarity (CCC) at a time when users are reeling from the Fear Uncertainty and Doubt (FUD) unleashed by complex software systems backed by even more convoluted press releases.

1.5 Independent Test Results:

Independent test results have proven that unlike some modern (and not so modern) software, Emacspeak can be safely uninstalled without adversely affecting the continued performance of the computer. These same tests also revealed that once uninstalled, the user stopped functioning altogether. Speaking with Aster Labrador, the creator of Emacspeak once pointed out that these results re-emphasize the user-centric design of Emacspeak; "It is the user –and not the computer– that stops functioning when Emacspeak is uninstalled!".

1.5.1 Note from Aster,Bubbles and Tilden:

UnDoctored Videos Inc. is looking for volunteers to star in a video demonstrating such complete user failure.

1.6 Obtaining Emacspeak:

Emacspeak can be downloaded from Google Code –see http://code.google.com/p/emacspeak/ You can visit Emacspeak on the WWW at http://emacspeak.sf.net. You can subscribe to the emacspeak mailing list emacspeak@cs.vassar.edu by sending mail to the list request address emacspeak-request@cs.vassar.edu. The Emacspeak Blog is a good source for news about recent enhancements and how to use them. The WowDog release is at http://emacspeak.googlecode.com/svn/wiki/downloads/emacspeak-41.0.tar.bz2. The latest development snapshot of Emacspeak is always available via Subversion from Google Code at http://emacspeak.googlecode.com/svn/trunk/

1.7 History:

Emacspeak 41.0 continues to improve upon the desire to provide not just equal, but superior access — technology when correctly implemented can significantly enhance the human ability. Emacspeak 40.0 goes back to Web basics by enabling efficient access to large amounts of readable Web content. Emacspeak 39.0 continues the Emacspeak tradition of increasing the breadth of user tasks that are covered without introducing unnecessary bloatware. Emacspeak 38.0 is the latest in a series of award-winning releases from Emacspeak Inc. Emacspeak 37.0 continues the tradition of delivering robust software as reflected by its code-name. Emacspeak 36.0 enhances the audio desktop with many new tools including full EPub support — hence the name EPubDog. Emacspeak 35.0 is all about teaching a new dog old tricks — and is aptly code-named HeadDog in honor of our new Press/Analyst contact. emacspeak-34.0 (AKA Bubbles) established a new beach-head with respect to rapid task completion in an eyes-free environment. Emacspeak-33.0 AKA StarDog brings unparalleled cloud access to the audio desktop. Emacspeak 32.0 AKA LuckyDog continues to innovate via open technologies for better access. Emacspeak 31.0 AKA TweetDog — adds tweeting to the Emacspeak desktop. Emacspeak 30.0 AKA SocialDog brings the Social Web to the audio desktop—you cant but be social if you speak! Emacspeak 29.0—AKAAbleDog—is a testament to the resilliance and innovation embodied by Open Source software—it would not exist without the thriving Emacs community that continues to ensure that Emacs remains one of the premier user environments despite perhaps also being one of the oldest. Emacspeak 28.0—AKA PuppyDog—exemplifies the rapid pace of development evinced by Open Source software. Emacspeak 27.0—AKA FastDog—is the latest in a sequence of upgrades that make previous releases obsolete and downgrades unnecessary. Emacspeak 26—AKA LeadDog—continues the tradition of introducing innovative access solutions that are unfettered by the constraints inherent in traditional adaptive technologies. Emacspeak 25 —AKA ActiveDog —re-activates open, unfettered access to online information. Emacspeak-Alive —AKA LiveDog —enlivens open, unfettered information access with a series of live updates that once again demonstrate the power and agility of open source software development. Emacspeak 23.0 – AKA Retriever—went the extra mile in fetching full access. Emacspeak 22.0 —AKA GuideDog —helps users navigate the Web more effectively than ever before. Emacspeak 21.0 —AKA PlayDog —continued the Emacspeak tradition of relying on enhanced productivity to liberate users. Emacspeak-20.0 —AKA LeapDog —continues the long established GNU/Emacs tradition of integrated innovation to create a pleasurable computing environment for eyes-free interaction. emacspeak-19.0 –AKA WorkDog– is designed to enhance user productivity at work and leisure. Emacspeak-18.0 –code named GoodDog– continued the Emacspeak tradition of enhancing user productivity and thereby reducing total cost of ownership. Emacspeak-17.0 –code named HappyDog– enhances user productivity by exploiting today's evolving WWW standards. Emacspeak-16.0 –code named CleverDog– the follow-up to SmartDog– continued the tradition of working better, faster, smarter. Emacspeak-15.0 –code named SmartDog–followed up on TopDog as the next in a continuing a series of award-winning audio desktop releases from Emacspeak Inc. Emacspeak-14.0 –code named TopDog–was the first release of this millennium. Emacspeak-13.0 –codenamed YellowLab– was the closing release of the 20th. century. Emacspeak-12.0 –code named GoldenDog– began leveraging the evolving semantic WWW to provide task-oriented speech access to Webformation. Emacspeak-11.0 –code named Aster– went the final step in making Linux a zero-cost Internet access solution for blind and visually impaired users. Emacspeak-10.0 –(AKA Emacspeak-2000) code named WonderDog– continued the tradition of award-winning software releases designed to make eyes-free computing a productive and pleasurable experience. Emacspeak-9.0 –(AKA Emacspeak 99) code named BlackLab– continued to innovate in the areas of speech interaction and interactive accessibility. Emacspeak-8.0 –(AKA Emacspeak-98++) code named BlackDog– was a major upgrade to the speech output extension to Emacs.

Emacspeak-95 (code named Illinois) was released as OpenSource on the Internet in May 1995 as the first complete speech interface to UNIX workstations. The subsequent release, Emacspeak-96 (code named Egypt) made available in May 1996 provided significant enhancements to the interface. Emacspeak-97 (Tennessee) went further in providing a true audio desktop. Emacspeak-98 integrated Internetworking into all aspects of the audio desktop to provide the first fully interactive speech-enabled WebTop.

About Emacspeak:


Originally based at Cornell (NY) http://www.cs.cornell.edu/home/raman –home to Auditory User Interfaces (AUI) on the WWW– Emacspeak is now maintained on GoogleCode --http://code.google.com/p/emacspeak —and Sourceforge —http://emacspeak.sf.net. The system is mirrored world-wide by an international network of software archives and bundled voluntarily with all major Linux distributions. On Monday, April 12, 1999, Emacspeak became part of the Smithsonian's Permanent Research Collection on Information Technology at the Smithsonian's National Museum of American History.

The Emacspeak mailing list is archived at Vassar –the home of the Emacspeak mailing list– thanks to Greg Priest-Dorman, and provides a valuable knowledge base for new users.

1.8 Press/Analyst Contact: Tilden Labrador

Going forward, Tilden acknowledges his exclusive monopoly on setting the direction of the Emacspeak Audio Desktop, and promises to exercise this freedom to innovate and her resulting power responsibly (as before) in the interest of all dogs.

**About This Release:


Windows-Free (WF) is a favorite battle-cry of The League Against Forced Fenestration (LAFF). –see http://www.usdoj.gov/atr/cases/f3800/msjudgex.htm for details on the ill-effects of Forced Fenestration.

CopyWrite )C( Aster and Hubbell Labrador. All Writes Reserved. HeadDog (DM), LiveDog (DM), GoldenDog (DM), BlackDog (DM) etc., are Registered Dogmarks of Aster, Hubbell and Tilden Labrador. All other dogs belong to their respective owners.

-1:-- Announcing Emacspeak 41.0: NiceDog (Post T. V. Raman (noreply@blogger.com))--L0--C0--November 26, 2014 03:09 PM

Timo Geusch: Using ELPA with pinned packages in GNU Emacs 24.4

Yes, I promise I’ll shut up about Emacs package management via ELPA any minute now. Based on the feedback I had on my last post about using a combination of melpa and melpa-stable, I looked into using pinned packages via the package-pinned-packages variable that’s new in Emacs 24.4’s package.el. I couldn’t find any simple examples… Read More »

The post Using ELPA with pinned packages in GNU Emacs 24.4 appeared first on The Lone C++ Coder's Blog.

-1:-- Using ELPA with pinned packages in GNU Emacs 24.4 (Post Timo Geusch)--L0--C0--November 26, 2014 06:50 AM

Phil Hagelberg: in which a shingle is hung out

Atreus production

Earlier this year I designed and built a small ergonomic mechanical keyboard. My original goal was just that of personal use; I wanted to take the joy of mechanical keyboards with me when I go work from coffee shops. I put the design on Github and documented my build process with photos, and once I finished my own keyboard I figured I'd be done with it. But a few of my friends were intrigued and asked me if I'd build them keyboards. I had a lot of fun constructing my first one, so I agreed to build a few more to sell to friends.

Once I got going, one thing led to another, and I started getting queries from friends-of-friends. I put up a web site with an order form, and orders started trickling in. Due to the hand-wiring approach used the construction of these boards took a good four hours of nights and weekends, so a backlog started piling up. At this point I decided I could make myself less of a bottleneck by selling kits and allowing interested customers to do the assembly themselves. This was a big help, and it seemed people really liked the hands-on approach. There's nothing quite like the satisfaction of using hardware you've constructed yourself.

Atreus wiring

The "proper" way to make a keyboard is to build it around a circuit board. But circuit board design is its own skill, and their production benefits greatly from volume discounts, so it really didn't make sense for my own personal project. But once I started to get more orders it became clear that a circuit board would help a lot since the process of hand-wiring is rather intimidating if you've never done any soldering before. I broke out KiCAD and started laying out a circuit board to hold the switches, diodes, and microcontroller after reading through some documentation and tutorials.

One side of Atreus PCB

I carefully laid out one side of the circuit board according to the row spacing and staggering used in the laser-cut case files without too much trouble. Each switch was connected to the others in the row with one pin and to the others in the column with the other, and each row and column was brought back in to the middle with the microcontroller. Then I hit a snag—the two halves of the Atreus keyboard are rotated inward at a 10° angle, but when I went to rotate the design in KiCAD rather than rotating them as a unit, it simply applied the rotation to each component individually.

At that point I was starting to think I'd have to do all this trig by hand and enter the calculated coordinates one by one into KiCAD's edit boxes, which did not sound like fun. I asked on the Freenode channel and found to my delight that the new file format for KiCAD is based on s-expressions! It can all be easily manipulated programmatically. Since the data includes symbols with leading digits in their names, the Clojure reader couldn't handle it, but Racket didn't have a problem with it. So I put together some Racket code to run the trig necessary to calculate the switch and diode positions.

Atreus PCB

Anyway, I just finished assembling my first circuit-board-based keyboard, and it works nicely. It's dramatically easier than the hand-wired variant, even such that my six-year-old son wants to build his own. I had to make one change to give clearance for the micro-USB connector, but I was able to apply this "revision" to my already-produced circuit boards with a hacksaw.

Up to this point I haven't publically promoted it much, but now that the circuit board is here I'm prepared to handle a greater volume of orders. So if you're interested in building your own mechanical travel keyboard or want to hack some hardware designed using Lisp, take a look at http://atreus.technomancy.us.

-1:-- in which a shingle is hung out (Post Phil Hagelberg)--L0--C0--November 24, 2014 08:22 AM

Timo Geusch: Set up Emacs to use both melpa and melpa-stable

I’ve blogged about a little elisp snippet I use to install my preferred base set of Emacs packages before. Thanks for all the feedback, it definitely helped improve the code. One issue that kept annoying me is that there is no simple way to tell ELPA to mainly pull packages from melpa-stable and only fall… Read More »

The post Set up Emacs to use both melpa and melpa-stable appeared first on The Lone C++ Coder's Blog.

-1:-- Set up Emacs to use both melpa and melpa-stable (Post Timo Geusch)--L0--C0--November 22, 2014 05:24 AM

Julien Danjou: Distributed group management and locking in Python with tooz

With OpenStack embracing the Tooz library more and more over the past year, I think it's a good start to write a bit about it.

A bit of history

A little more than year ago, with my colleague Yassine Lamgarchal and others at eNovance, we investigated on how to solve a problem often encountered inside OpenStack: synchronization of multiple distributed workers. And while many people in our ecosystem continue to drive development by adding new bells and whistles, we made a point of solving new problems with a generic solution able to address the technical debt at the same time.

Yassine wrote the first ideas of what should be the group membership service that was needed for OpenStack, identifying several projects that could make use of this. I've presented this concept during the OpenStack Summit in Hong-Kong during an Oslo session. It turned out that the idea was well-received, and the week following the summit we started the tooz project on StackForge.

Goals

Tooz is a Python library that provides a coordination API. Its primary goal is to handle groups and membership of these groups in distributed systems.

Tooz also provides another useful feature which is distributed locking. This allows distributed nodes to acquire and release locks in order to synchronize themselves (for example to access a shared resource).

The architecture

If you are familiar with distributed systems, you might be thinking that there are a lot of solutions already available to solve these issues: ZooKeeper, the Raft consensus algorithm or even Redis for example.

You'll be thrilled to learn that Tooz is not the result of the NIH syndrome, but is an abstraction layer on top of all these solutions. It uses drivers to provide the real functionalities behind, and does not try to do anything fancy.

All the drivers do not have the same amount of functionality of robustness, but depending on your environment, any available driver might be suffice. Like most of OpenStack, we let the deployers/operators/developers chose whichever backend they want to use, informing them of the potential trade-offs they will make.

So far, Tooz provides drivers based on:

All drivers are distributed across processes. Some can be distributed across the network (ZooKeeper, memcached, redis…) and some are only available on the same host (IPC).

Also note that the Tooz API is completely asynchronous, allowing it to be more efficient, and potentially included in an event loop.

Features

Group membership

Tooz provides an API to manage group membership. The basic operations provided are: the creation of a group, the ability to join it, leave it and list its members. It's also possible to be notified as soon as a member joins or leaves a group.

Leader election

Each group can have a leader elected. Each member can decide if it wants to run for the election. If the leader disappears, another one is elected from the list of current candidates. It's possible to be notified of the election result and to retrieve the leader of a group at any moment.

Distributed locking

When trying to synchronize several workers in a distributed environment, you may need a way to lock access to some resources. That's what a distributed lock can help you with.

Adoption in OpenStack

Ceilometer is the first project in OpenStack to use Tooz. It has replaced part of the old alarm distribution system, where RPC was used to detect active alarm evaluator workers. The group membership feature of Tooz was leveraged by Ceilometer to coordinate between alarm evaluator workers.

Another new feature part of the Juno release of Ceilometer is the distribution of polling tasks of the central agent among multiple workers. There's again a group membership issue to know which nodes are online and available to receive polling tasks, so Tooz is also being used here.

The Oslo team has accepted the adoption of Tooz during this release cycle. That means that it will be maintained by more developers, and will be part of the OpenStack release process.

This opens the door to push Tooz further in OpenStack. Our next candidate would be write a service group driver for Nova.

The complete documentation for Tooz is available online and has examples for the various features described here, go read it if you're curious and adventurous!

-1:-- Distributed group management and locking in Python with tooz (Post Julien Danjou)--L0--C0--November 21, 2014 12:10 PM

John DeRosa: GNU Emacs for OS X is a Win

I’ve used Aquamacs for the past four years or so. It has its strong points.

But I’ve always been a little unhappy with its slow performance relative to native Emacs (I use a MacBook Pro), and its unique initialization and behaviors. I’m sure there are good reasons for every difference. But each difference, no matter how small, is a little more cognitive load. E.g., I never got used to M-x Info opening up in a new window somewhere on my screen…

Today, I decided to try Emacs for Mac OS X. Whoa! I love it! It’s Emacs, the whole Emacs, and nothing but the Emacs.  Win!

I even donated $50 to the project. So there!


Tagged: Emacs
-1:-- GNU Emacs for OS X is a Win (Post John)--L0--C0--November 20, 2014 06:23 PM

Wilfred Hughes: Editing Julia code (with Emacs!)

I’m a big admirer of the Julia programming language: it’s a fast general-purpose language with a nice syntax, macros, and a decent package manager.

No respectable up-and-coming language should be without good editor support. I’ve been polishing the Emacs mode, and learnt a lot about the language. If you’re writing Julia code, or integrating an editor, this should be interesting to you.

Syntax highlighting

Syntax highlighting is hard, and it’s rather challenging in Julia. We’ll look at some corner cases of syntax highlighting in Julia, so I’ll show code snippets along with screenshots of how this code is currently highlighted in Emacs.

I’ve written a complete Julia syntax highlighting test file which exercises all the different syntactic features of the language. You can use this to test Julia support in your editor of choice.

Highlighting function calls

Julia supports two ways of declaring functions, which the docs describe as ‘basic’ and ‘terse’.

function f(x,y)
    x + y
end

f(x,y) = x + y

We want to highlight keywords (such as function and end) and to highlight function names (f in this example). This is pretty straightforward: we can write a regular expression that spots either the keyword function or a symbol followed by something roughly like (.*?) =.

We can also define functions in an explicit namespace. This is also straightforward, we just highlight the last symbol after the dot.

function Foo.bar(x, y)
    x + 1
end

A function definition may also include type variables. This isn’t too difficult to handle either, we just need to adjust our terse regular expression to step over the curly brackets.

elsize{T}(::AbstractArray{T}) = sizeof(T)

function elsize{T}(::AbstractArray{T})
    sizeof(T)
end

However, highlighting gets harder with nested brackets.

cell(dims::(Integer...)) = Array(Any, convert((Int...), dims))

At this point, our naive regular expression falls down. We need to count brackets, or write a crude parser. The Emacs editing mode doesn’t yet handle this case.

Macro usage

Highlighting macros is easy. There are some awkward syntactic edge cases but these don’t affect highlighting.

@hello_world! foo

Built-in functions

Julia has a lot of built-in functions. After some discussion, we felt that it wasn’t worth special-casing functions that are keywords in other languages, such as throw and error.

throw(foo)
error("foo", bar, "baz")

Strings and characters

Julia has a lovely syntax here, but it takes a little care to highlight correctly.

For characters, Julia uses single quotes, but it also supports ' as an operator. This gives very readable mathematical formulae.

# Characters
x = 'a'
y = '\u0'

# Not characters
a = b' + c'

Julia’s string syntax allows multi-line strings, triple-quoted strings, regular expression literals, byte array literals and (particularly nifty) version number literals.

x = "foo
bar"
x = """hello world"""
x = "hello $user"
x = r"foo.*"ismx
x = v"0.1"
x = b"DATA\xff\u2200"

We are handling most of this syntax in the Emacs mode, but it’s not perfect yet. I think we should highlight interpolated values in strings. See my test file for a full set of examples.

Comments

Julia’s comment syntax is also very nice. There are single-line and multi-line comments, and they support arbitrary nesting.

# I'm a comment.

#= I'm a 
multi-line comment. =#

#= I'm a #= nested =# comment. =#

Emacs makes it easy for us to support all this different variants, so we’ve supported this for a long time.

Type declarations

You can declare your own types in Julia.

type Foo
    x::Bar
end
immutable Foo
    x::Bar
end

abstract Foo <: Bar

This is mostly a case of knowing all the keywords for type declaration, so it’s straightforward.

The operator <: is particularly tricky. It is used in type declarations to declare subtypes, but it’s also used a boolean operator to see if one value is a subtype of another x <: y. I believe this is impossible to highlight correctly in all cases.

# I can't see how to highlight the first 'T' here.
same_type_numeric{T<:Number}(x::T, y::T) = true

We can cheat by having a full list of built-in types in our highlighting code, so we highlight most subtype declarations correctly.

Type annotations

Julia supports optional type annotations in functions and on variables. These are simple to highlight, but we need to get :: right before dealing with quoted symbols.

f(x::FooBar) = x

function foo()
    local x::Int8 = 5
    x
end

Variable declarations

Julia has a local keyword which lets you introduce local variable bindings. I’d love to highlight this correctly too.

global x = "hello world", y = 3

let x = 1
    x + 1
end

function foo()
    local x = 5
    x + 1
end

This requires parsing to handle correctly, so we don’t handle it yet. We can’t simply look for commas, as there may be arbitrary Julia expressions used.

# 'b' is not declared as a variable here.
global x = foo(a, b), y = 3

Colons and quoting

The hardest part of Julia’s syntax is :. There have also been users confused by this syntax.

# Quoted symbols
x = :foo
y = :function
foo[:baz]
[1 :foo]

# Not quoted symbols
foo[bar:end]
foo[bar:baz]
x = :123
for x=1:foo
    print(x)
end

I’ve opened a pull request that enables Emacs to handle the most common usages correctly, but this is very hard to get right in all cases.

Numbers

Finally, Julia has a really neat numeric syntax. It supports all the literals you could possibly want. It also lets you write 2x as a shorthand for 2 * x, which makes many equations in Julia much more similar to a maths textbook.

x = 0x123abcdef
x = 0o7
x = 0b1011
x = 2.5e-4

# Equivalent to '2 * x'
y = 2x

The Emacs mode currently doesn’t highlight these, but we probably should. Some Emacs modes highlight numbers, some don’t, but for a language with a focus on scientific computing, it would make sense to highlight numbers. It’s particularly helpful to help readers see that 2x is two separate symbols.

Conclusions

Julia’s syntax isn’t completely set in stone, but I doubt much of the syntax will change in ways that affect highlighting. The syntax favours readability over simple parsing (a great tradeoff), so writing a highlighter takes some careful thought.

Once you’ve got syntax highlighting working, it’s much easier to handle indentation. I think Emacs’ ability to indent Julia is pretty good (this blog post is plenty long enough without getting into indentation) and this is because it can fairly robustly identify block delimiters for highlighting.

Finally, it’s also desirable to have as-you-type syntax checking and linting. Flycheck will add support for this using Lint.jl as soon as Lint.jl/Julia performance is good enough to run on demand without a persistent process.

If you do encounter a bug with Emacs and Julia, there’s a ‘julia-mode’ issue label to track any bugs.

Happy hacking!

-1:-- Editing Julia code (with Emacs!) (Post Wilfred Hughes (me@wilfred.me.uk))--L0--C0--November 16, 2014 12:00 AM