Irreal: Unicode Font Redux

A couple of days ago I wrote about finally solving a long standing Emacs problem involving missing glyphs in my default font. I was really happy to have the problem resolved. So pleased I wrote about it in glowing terms.

That solution involved installing the unicode-fonts package, which scans your fonts for missing glyphs, finds them in other installed fonts, and arranges for them to be used in place of the missing glyphs. It’s a really great package but it does much more than I need. I really just wanted to specify an alternate font for those missing glyphs.

As soon as I published my post, Xah Lee and Artur Malabarba suggested a simpler solution. I was happy with unicode-fonts but couldn’t resist the one line solution that Lee and Malabarba offered. So I disabled unicode-fonts and added the line

(set-fontset-font "fontset-default" nil 
                  (font-spec :size 20 :name "Symbola"))

to my init.el. It worked perfectly, of course, so I uninstalled unicode-fonts and went with the Lee-Malabarba solution.

Malabarba notes that the documentation for set-fontset-font is a bit opaque. That’s an understatement. I had to read it several times before I could figure out why it worked for my problem. No matter. If you’re having the same problem you can just think of it as a magic incantation.

-1:-- Unicode Font Redux (Post jcs)--L0--C0--July 23, 2014 11:52 AM

Emacs Redux: Travel back and forward in git history

I recently discovered an extremely cool package called git-timemachine that allows you to step though the git history of the file you’re currently editing in Emacs.

Using it is pretty simple:

  • visit a git-controlled file and issue M-x git-timemachine (or bind it to a keybinding of your choice)
  • use the following keys to navigate historic version of the file:
    • p visit previous historic version
    • n visit next historic version
    • w copy the hash of the current historic version
    • q exit the time machine buffer

Here you can see git-timemachine in action:

P.S.

This package is bundled with Prelude.

-1:-- Travel back and forward in git history (Post)--L0--C0--July 22, 2014 04:02 PM

Emacs Redux: Become an Emacs Redux patron

Securing funding for OS projects and blogs (outside of displaying annoying ads) is a hard endeavor. While I’d love to raise enough cash to work on CIDER, projectile and Emacs itself for an entire year through some wildly successful crowdfunding campaign, that’s unlikely to ever happen.

That said, I recently discovered an interesting alternative to one-off crowdfunding campaigns called gittip. Self-described as sustainable crowdfunding (meaning people will get microdonations (say half a buck) from their patrons each week) it seems like a reasonable way to raise a modest sum of money so you could work on open-source projects more than your regular schedule might permit.

So, if you like Emacs Redux and the Emacs projects in which I’m involved like:

  • Prelude - An Emacs distribution built on top of GNU Emacs 24
  • Projectile - Project Interaction Library for Emacs, that stays out of your way
  • clojure-mode - A major mode for programming in Clojure
  • cider - A Clojure programming environment for Emacs
  • guru-mode - An annoying companion on your journey to Emacs mastery
  • rubocop-emacs - Emacs integration for RuboCop
  • zenburn-emacs - The Zenburn color theme, ported to Emacs
  • solarized-emacs - The Solarized color theme, ported to Emacs
  • puppet-mode - A mode for editing Puppet 3 manifests
  • swift-mode - A mode for editing Swift code

consider supporting my work via gittip.

Support via Gittip

-1:-- Become an Emacs Redux patron (Post)--L0--C0--July 22, 2014 03:04 PM

Irreal: Fast Toggling Emacs Modes

Over at Endless Parentheses, which I’ve mentioned before, Artur Malabarba has a really good idea. He shows how to define a custom key map that he uses to toggle modes that he uses frequently. He binds the commands to the prefix【Ctrl+x t】, an unused key sequence in stock Emacs. Then he has a third key that mnemonically suggest the mode he wants to toggle. Thus,【Ctrl+x t c】toggles column-number-mode and【Ctrl+x t r】toggles read-only-mode and so on.

Oddly, none of the shortcuts that he proposes are ones I care about but I do have a list of my own

l linum-mode
o org-mode
p paredit-mode
t text-mode
v visual-line-mode

As Malabarba says, these aren’t keys I’ll use everyday but they are mnemonic enough that I’ll be able to remember then.

Doubtless you have your own list of modes you’d like to be able to toggle easily and Malabarba’s method makes it easy to bind them to an easily remembered key.

A very useful post, I think. I’m going to implement the above list in my own init.el as soon as I finish writing this.

-1:-- Fast Toggling Emacs Modes (Post jcs)--L0--C0--July 22, 2014 12:08 PM

Ivan Kanis: Learning Lisp is like learning ancient Greek

Learning Lisp is like learning ancient Greek; although it is alien, it provides insight into modern computer languages.

-1:-- Learning Lisp is like learning ancient Greek (Post Ivan Kanis)--L0--C0--July 21, 2014 12:00 AM

Flickr tag 'emacs': 2014-07-15_223308_1366x768_scrot

Thiago Barroso Perrotta posted a photo:

2014-07-15_223308_1366x768_scrot

A typical emacs session.

-1:-- 2014-07-15_223308_1366x768_scrot (Post Thiago Barroso Perrotta (nobody@flickr.com))--L0--C0--July 16, 2014 01:34 AM

Grant Rettke: Another Emacs configuration in org

Here. It is nice.

My apologies for forgetting how I ended up here.

-1:-- Another Emacs configuration in org (Post Grant)--L0--C0--July 14, 2014 01:24 AM

Grant Rettke: What all of those org-babel functions do

For the lazy org users like myself who want to know what the functions
listed here do, just evaluate the one you want:

(describe-function 'org-babel-execute-src-block)
(describe-function 'org-babel-open-src-block-result)
(describe-function 'org-babel-load-in-session)
(describe-function 'org-babel-pop-to-session)
(describe-function 'org-babel-previous-src-block)
(describe-function 'org-babel-next-src-block)
(describe-function 'org-babel-execute-maybe)
(describe-function 'org-babel-open-src-block-result)
(describe-function 'org-babel-expand-src-block)
(describe-function 'org-babel-goto-src-block-head)
(describe-function 'org-babel-goto-named-src-block)
(describe-function 'org-babel-goto-named-result)
(describe-function 'org-babel-execute-buffer)
(describe-function 'org-babel-execute-subtree)
(describe-function 'org-babel-demarcate-block)
(describe-function 'org-babel-tangle)
(describe-function 'org-babel-tangle-file)
(describe-function 'org-babel-check-src-block)
(describe-function 'org-babel-insert-header-arg)
(describe-function 'org-babel-load-in-session)
(describe-function 'org-babel-lob-ingest)
(describe-function 'org-babel-view-src-block-info)
(describe-function 'org-babel-switch-to-session-with-code)
(describe-function 'org-babel-sha1-hash)
(describe-function 'org-babel-describe-bindings)
(describe-function 'org-babel-do-key-sequence-in-edit-buffer)

There are some very special functions in there!

-1:-- What all of those org-babel functions do (Post Grant)--L0--C0--July 14, 2014 12:28 AM

Mickey Petersen: Displaying and Interacting with processes using Proced

If you’re a regular user of the commandline tools top or ps then I have good news for you: there’s an Emacs command that does that and it works on Windows too!

The command is M-x proced and it is modelled on M-x dired (but it is not built on top of dired) and it does shadow most of the common navigational aids: n and p move down and up and g refreshes the buffer, for instance.

It’s also feature rich; by combining the utility of ps with the sortable, columnized and interactive system of top you get the best of both worlds.

What I like about it is that it’s a buffer like any other in Emacs. So if you’re keeping your eye on a handful of processes you can use highlight-phrase to highlight the strings you want to visually separate from the rest. It is also, in true Emacs tradition, very customizable — but I’ll get to that a bit later.

Marking, Sorting, Filtering and Formatting Columns

By default you will be given the short formatting but you can change the number of displayed columns by typing F. You’ll be shown a prompt where you can select from short, medium, long and verbose.

You can also change the filtering — which defaults to all — by pressing f. Like the formatting key above you are given a list of common filter types. Furthermore you can filter by any of the visible columns by moving your point to it and pressing RET. It will incrementally filter so you can repeatedly filter as much as you like — this is a very handy feature. Refreshing the buffer with g does not reset it: you must change your filter with f.

Like dired you can mark processes with both d and m (they do the same thing) and unmark with backspace and u. You can mark and unmark all processes with M and U. And finally you can then filter the marked processes with o.

There are some specialty mark commands as well. The command t will invert your marks and C and P will mark the children or parents of the process point is on.

Finally you can sort by columns as well. All the sort commands are bound to M-x proced-sort-xxx and to the prefix menu s:

Command Description
s c Sort by CPU %
s m Sort by Memory %
s p Sort by PID
s s Sort by Start Time
s t Sort by CPU Time
s u Sort by User
s S Sort by other column

If you want to sort by a column not bound to a key you must use s S where you are then prompted for the name of a column to sort by.

Sending Signals and Interacting with processes

Unsurprisingly sending POSIX signals is fully supported by Emacs. This is done using the Elisp function signal-process. Because of that all signals are sent using the uid of the Emacs process proced is running in. Conceivably proced could be changed to call out to userland command kill (using an external command is supported) and, by combining it with TRAMP for sudo elevation it could kill processes owned by other users. Sadly that functionality does not currently exist but abusing the default-directory variable might work.

To send a signal mark the processes you want to signal, or alternatively put your point on the target process, and press k or x. You will be shown a list of target processes and you can optionally change the default suggestion of TERM to something else.

When the signal(s) have been sent you can review the log by pressing ?.

As of Emacs 24.3 you can also renice a command by pressing r.

Understanding & Customizing Proced’s Internals

Proced is very flexible and it also supports the customize interface. You can access this inferface by typing M-x customize-group proced RET.

Proced will use the Elisp function list-system-processes to retrieve all the known PIDs and then call process-attributes on each one of them to fetch the process details. The good news is that Proced does not parse the output of ps or /proc directly but relies on Emacs’s compatibility layer to make sense of everything: this also means it works rather well on Windows.

Proced can auto update the display and you can enable this for a Proced buffer by running the command proced-toggle-auto-update and it will update every proced-auto-update-interval which is by default 5 seconds.

To make Proced auto update by default you must add a hook:

(defun proced-settings ()
  (proced-toggle-auto-update))

(add-hook 'proced-mode-hook 'proced-settings)

You are free to customize other settings in this mode hook in much the same way you would other mode hook functions.

If you’re really serious about tweaking the way the columns are displayed you can try your hand at editing the alist variable proced-grammar-alist. It controls how sorting, justification and string formatting works for each of the process attributes returned by process-attributes.

You can also alter the default Proced filter by changing proced-filter from user to something else. Creating your own filter is also possible by adding to the proced-filter-alist; in fact this functionality lets you do rather complex things such as calling a custom function for every process attribute.

The default sort and sort order (descending or ascending) is governed by proced-sort and proced-descent respectively.

There are many more customizable options and the author of Proced, Roland Winkler, has done a great job ensuring they’re accessible from Emacs’s customize interface.

It goes without saying that Proced is a both feature rich and customizable. I think it’s a very capable replacement for most ps and top use cases, but like so features in Emacs almost nobody has heard of it.

Share

-1:-- Displaying and Interacting with processes using Proced (Post mickey)--L0--C0--July 08, 2014 10:03 AM

Chris Ball: Serverless WebRTC, continued

Around a year ago, in WebRTC without a signaling server, I presented an simple app that can start a chat session with another browser without using a local web server (i.e. you just browse to file:///), and without using a signaling server (instead of both going to the same web page to share “offers”, you share them manually, perhaps via IM).

It’s been a busy year for WebRTC! When I released serverless-webrtc, Chrome didn’t support datachannels yet, so the code only worked on Firefox. Now it works in stable releases of both browsers, and is interoperable between the two, for both reliable (TCP-like) and unreliable (UDP-like) transfers. And I’ve just added Node to the mix (so you can do Node—Node / Node—Chrome / Node—Firefox) as well, with the first release of the serverless-webrtc NPM package. Here’s how to try it out:

$ git clone git://github.com/cjb/serverless-webrtc
$ cd serverless-webrtc
$ npm install
$ firefox serverless-webrtc.html &
$ node serverless-webrtc.js
<paste firefox's offer into node, hit return>
<paste node's answer into firefox, click ok>
<you're connected!>

And here’s a screenshot of what that looks like:

I’m able to do this thanks to the wrtc NPM module, which binds the WebRTC Native Code Package (written in C++) to Node, and then exposes a JS API on top of it that looks like the browser’s WebRTC JS API. It’s really impressive work, and the maintainers have been super-friendly.

Next I’d like to unwrap the JS from the node client and make a pure C++ version, because the Tor developers would like “to have two C++ programs that are capable of chatting with each other, after being given an offer and answer manually”, to help investigate WebRTC as a method of relaying Tor traffic.

Finally, a link that isn’t related to this project but is too cool not to mention – Feross Aboukhadijeh has a WebTorrent project to port a full BitTorrent client to the browser, also using WebRTC in a serverless way (with trackerless torrents, and peer-to-peer node introductions).

What would it mean if the next Wikipedia or GitHub (see Yurii Rashkovskii’s GitChain project!) didn’t have to spend tens of millions of dollars each year for servers and bandwidth, and could rely on peer-to-peer interaction? I’d love to find out, and I have a feeling WebRTC is going to show us.

-1:-- Serverless WebRTC, continued (Post cjb)--L0--C0--July 01, 2014 01:01 PM

Eric James Michael Ritz: Send Emacs Buffer to jrnl

Lately I’ve been using the program jrnl to keep a journal of personal information. You can write entries completely from the command-line but I dislike that approach because editing text is a pain. Since I am a GNU Emacs junkie I wanted to use that program for all of my writing. Today I want to share an extremely simple function I wrote for that purpose.

You can add a journal entry by feeding it in via standard input, e.g.

$ jrnl < /tmp/entry.txt

It does not take that much effort to write such a file in Emacs and then run the command above. But I am lazy, like most programmers. Instead of taking the minuscule time to save a file and enter one shell command I wrote the following:

(defun ejmr/send-buffer-to-jrnl ()
  "Sends the content of the current buffer to jrnl."
  (interactive)
  (call-process-region (point-min) (point-max) "jrnl")
  (message "Saved buffer contents in journal"))

This illustrates some very basic Emacs Lisp.

First, we have to get the entire contents of the buffer. The functions point-min and point-max give us the buffer’s full length. We could also get the buffer contents by calling buffer-string, but that would not be useful here, the reason being…

Second, we have to give a region to call-process-region. The first two arguments indicate the starting and ending position of the region we want to use. This is why we use the point-* functions instead of buffer-string.

The third and final argument is simply the name of the program which will receive the region via standard input. The result is the same as if we’d executed jrnl < entry.txt where the file entry.txt contains everything in the current buffer. After that all I had to do was bind the command to a key.

As I said, this is rudimentary Emacs Lisp, but I hope it demonstrates how simply you can pass the contents of a buffer onto another program.


-1:-- Send Emacs Buffer to jrnl (Post ericjmritz)--L0--C0--June 30, 2014 09:30 PM

Got Emacs?: Emacs Third Pretest Released

A bit late in posting about it but here is official pretest  release announcement. The Windows binaries take a bit of time to appear if you can't see it already.
-1:-- Emacs Third Pretest Released (Post sivaram (noreply@blogger.com))--L0--C0--June 30, 2014 02:49 AM

sachachua: Read Lisp, Tweak Emacs (Beginner 4/4): “How can I add more features? How do I deal with errors?”

This entry is part 4 of 4 in the series Read Lisp, Tweak Emacs

Previous module: “How can I make things more convenient?”

Some conventions we’ll use:

  • Inline code will be boxed and monospace in the HTML version and generally surrounded by equal signs in plain text.
  • Code samples will be monospace and in boxes in the HTML version, and enclosed in #+begin_src#+end_src in plain text. Example:
    (message "Hello world")
    

After this module, you’ll be able to:

  • load libraries so that you can add new features or set configuration variables
  • install and configure packages in order to add more features to your Emacs
  • understand and fix common errors
  • learn more! =)

Adding more features to Emacs

Most Emacs libraries are not loaded automatically. This saves memory and keeps things simpler. Some of the customizations you may want to make require that other parts of Emacs are loaded first. For example, if you want to define a key for the c-mode-map (used for editing C code) or add a function to org-mode-hook (called when a buffer is set up with Org Mode), those libraries need to be loaded first. You can load libraries by using require, like this:

(require 'org)

This loads the org library. require looks for a file named after the name provided to it, loads it, and double-checks that the library includes (provide 'feature-name-goes-here). It signals a Cannot open load file error if the library is not found. If the library exists but does not provide that symbol, you’ll get a Required feature FEATURE was not provided error instead.

Note that the symbol you give to require might not be the same as the function you call. For example, c-mode is actually defined in the cc-mode library, while org-mode is defined in org. To find out what file a function is defined in, use C-h f (describe-function) followed by the name of the function. The first line will tell you what file the function is defined in, if any. For example, c-mode‘s definition starts with:

c-mode is an interactive autoloaded compiled Lisp function in
`cc-mode.el'.

The first part of the filename (before the .el or .elc) is usually what you would use with require. If you have the source installed (the .el file), you can look for the (provide ...) expression to find the actual symbol to use.

Installing packages

Emacs comes with a lot of code, but there are even more packages out there. When you read other people’s Emacs configurations, you might come across other interesting packages to try out.

Sometimes people don’t indicate which packages they use, so you have to guess the package name based on the function. For example, (global-auto-complete-mode) turns on a completion mode called auto-complete-mode in all buffers. Before you can use this, you will need to install the auto-complete package. In general, you can find package names by looking at functions that include mode in their name, removing global, turn-on, and other prefixes as needed.

The default package repository in Emacs 24 has a limited number of packages. For more choices, you may want to add another repository such as MELPA or Marmalade Here’s the code that you would run in order to add these repositories to your Emacs:

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))

Note that MELPA includes many packages under active development. If you prefer to install only the packages marked as stable, replace the MELPA line with this:

(add-to-list 'package-archives '("melpa-stable" . "http://hiddencameras.milkbox.net/packages/"))

If you’re connected to the Internet, use M-x package-refresh-contents to update the list of packages. Use M-x package-list-packages to list the available packages. RET displays the package’s description. i marks the current package for installation, and x actually performs the operations. If you know the name of the package you want to install, you can skip the list and use M-x package-install instead.

A lightweight list of the key functions defined by packages is loaded after your init.el is run. You can start that initialization earlier by adding (package-initialize), which is useful if you want to call functions that are defined in packages.

Sometimes people want to install some packages on one computer but not on another. Here’s some code that runs some configuration if the miniedit package can be loaded, but silently continues if the package has not been installed.

(when (require 'miniedit nil t)
   (miniedit-install)
   (define-key minibuffer-local-map (kbd "C-c e") 'miniedit))

If you use C-h f (describe-function) on require, you’ll see that it has one required argument (feature) and two optional arguments (filename, noerror). require returns non-nil (or true) if the library was loaded, so if the library exists, then the rest of the code inside the when expression gets called.

Along those lines, you may come across code that looks like this:

(eval-after-load "dash" 
  '(dash-enable-font-lock))

This runs (dash-enable-font-lock) only after dash is loaded. It does not automatically load dash. You’ll see this when people have configuration that they want to run only if something is loaded, which can make sense for performance reasons. When you’re starting out, you may want to use require instead of eval-after-load, since the argument to eval-after-load has to be quoted.

Other Emacs Lisp files

Some files are not yet available as packages. If you search for the function, you’ll probably find a webpage with an .el file. You can save those to your computer and load them with:

(load "/path/to/file")

You can also use this technique to split up your Emacs configuration file into smaller files. For example, you might have an org-config.el file, a programming-config.el file, and so forth. If you would like to load a host-specific file only if it exists, you can take advantage of the optional NOERROR argument for load like this:

(load (concat "~/.emacs.d/" (system-name) ".el") t)

Want to find out what that filename is? Position your cursor after the ​".el") and use C-x C-e (eval-last-sexp) to see the value in the buffer.

Use C-h f (describe-function) to learn more about the load function, including other arguments you can pass to it.

If you would like to use the require syntax to load files only if they haven’t already been loaded, you can do that as long as they include the (provide ...) expression somewhere. First, you’ll need to add your downloaded Emacs Lisp file to the load-path with something like this.

(add-to-list 'load-path "/path/to/dir/with/el/files")

Then you can use require to load the Emacs Lisp code if it exists.

(require 'feature-name)

“Oh no! I have an error!”

Part of learning Emacs is having the confidence to experiment, which you can develop by learning how to recognize and deal with different errors.

If you’ve already added the code to your ~/.emacs.d/init.el, you can start Emacs with emacs --debug-init to display debugging messages, or you can start Emacs with emacs -q to skip your personal configuration. Before reporting a bug with Emacs or with a package, use emacs -q (or emacs -Q, which skips site-wide configuration as well) to see if it works as intended without your personal configuration.

To make it easier to find errors while Emacs is running, use M-x toggle-debug-on-error, then do whatever you did to trigger the error. You will probably see a detailed list of functions called in the *Messages* buffer. If you find this useful, you can enable this by default in your ~/.emacs.d/init.el. Add:

(setq debug-on-error t)

If you have code that takes a while, you might find the debug-on-quit variable or the M-x toggle-debug-on-quit function useful as well. You can quit a long-running operation by using C-g (keyboard-quit).

You can narrow down the source of the problem by progressively commenting out more and more of the code. Make sure you comment out balanced sets of parentheses. To comment a region, select it and use M-x comment-region. You can use M-x uncomment-region to uncomment it. M-x comment-dwim (do what I mean) guesses whether you want to comment or uncomment something, and has the handy keyboard shortcut M-;.

Here are some common error messages and how you can try fixing them. If you don’t see the error you’re struggling with here, ask the relevant mailing list, help-gnu-emacs, the #emacs channel on irc.freenode.net, or StackOverflow for help. Good luck!

Scan error: “Unbalanced parentheses” or “Containing expression ends prematurely”

You may have pasted in something that has a “(” but no matching “)“, which results in unbalanced parentheses. Alternatively, you may have pasted in something that has “)” but no “(“, which results in a premature end. You can use M-x check-parens to quickly check for mismatched parentheses, or try reading the code carefully in order to find the mismatched pair. You can also use C-M-f (forward-sexp) and C-M-b (backward-sexp) to navigate by complete expressions until you find the specific one that causes the error.

Cannot open load file: …

The code is trying to require or load a file that Emacs can’t find.

  • Have you installed the appropriate package? Use M-x list-packages to see if it has been packaged into a form that’s easy to install. You may need to add other sources to your package-archives to see a wider range of packages.
  • Have you downloaded it manually and added it to your load-path? See the notes on load-path for more details.
  • If you’re using load, does the file exist?

Lisp error: (void-function …)

The code calls a function that has not been defined.

  • Have you installed the appropriate package? Look at the function name and try to guess the name of the package. People usually start the function name with the package name in order to make the function names unique. Use M-x list-packages to see the available packages. You may need to add other sources to your package-archives to see a wider range of packages.
  • If you downloaded the library manually, load or require it.
  • If you’re copying some code that isn’t packaged in a library, check if there are any defun (define function) expressions that you forgot to copy. Make sure to include and evaluate those.

Symbol’s value as variable is void: _

The code is trying to get the value of a variable that has not yet been set. See if there’s other code that you need to evaluate first in order to set up those variables. If the expression involves add-to-list or add-hook, you may need to use require to load the library that defines that list or hook first.

You might also get this if you’re using C-x C-e (eval-last-sexp) to evaluate an expression that’s inside let or other things that create variables. When you’re starting out, make sure you use C-x C-e (eval-last-sexp) after the outermost set of parentheses.

I’m using C-x C-e (eval-last-sexp) and I don’t get the results I expected

Make sure you call C-x C-e after the outermost ) for the expression you want to evaluate.

(ido-mode 1)
            ^
            |
            +---- Your cursor should be here

If the code you’re looking at has multiple expressions, you’ll need to call C-x C-e after each of them. It might be easier to select the region and use M-x eval-region, or evaluate the entire buffer with M-x eval-buffer. Alternatively, use M-x ielm to evaluate the code instead.

Again, if you don’t see the error you’re struggling with here, ask the relevant mailing list, help-gnu-emacs, the #emacs channel on irc.freenode.net, or StackOverflow for help. Good luck!

Wrapping up the beginner course

I hope that this course has helped you become more comfortable with reading and tweaking Emacs Lisp configuration code from blog posts, wiki pages, and other resources. There’s much more to learn, of course. With describe-function, describe-variable, and the ability to quickly experiment with Emacs Lisp code without restarting Emacs all the time, I’m sure you’ll get the hang of it! If you’d like to review or refer to this course, you can get it as one page at http://emacslife.com/how-to-read-emacs-lisp.html .

Check out An Introduction to Programming in Emacs Lisp, and delve into the Emacs Lisp Reference Manual for more details. Both are available within Emacs as Info manuals, which you can read with C-h i (info). Look for the Emacs Lisp Intro and Elisp entries, and browse through those manuals for more details. To search the current info manuals, type s (Info-search). To search all info manuals, use M-x info-apropos.

If you liked this or you have other questions, please get in touch – sacha@sachachua.com. I’d love to hear from you, and I’m happy to help with other Emacs questions you may have. Good luck and have fun!

More links:

Series Navigation« Read Lisp Tweak Emacs (Beginner 3/4): How can I make things more convenient?

The post Read Lisp, Tweak Emacs (Beginner 4/4): “How can I add more features? How do I deal with errors?” appeared first on sacha chua :: living an awesome life.

-1:-- Read Lisp, Tweak Emacs (Beginner 4/4): “How can I add more features? How do I deal with errors?” (Post Sacha Chua)--L0--C0--June 26, 2014 12:00 PM

Alex Schroeder: Encrypting Mail using Gnus on OSX

Today I learned…

  1. If you want to use GPG, and you’re on OSX, pinentry will not work. You need a graphical pinentry tool. Your best bet is GPG Tools which is linked from the GnuPG website. You get Mail and Keychain integration for free, which I don’t really care about at the moment, and you get all the command line tools. Thus when I ran gpg in eshell just now, I was asked for my passphrase.
  2. If you want Emacs to know about your gpg-agent, you need to tell it about the PID and the temporary file and all that. My solution is Emacs-only. There’s probably a better way to do this such that you can use GPG from elsewhere as well. See the code snippet below.
  3. If you use Gnus to send mail, you cannot read the encrypted mails unless you set a mysterious variable. See the code snippet below.

First, how to run gpg-agent from your init file:

(setenv "GPG_AGENT_INFO"
	(with-temp-buffer
	  (shell-command "/usr/local/bin/gpg-agent --daemon" (current-buffer))
	  (goto-char (point-min))
	  (when (re-search-forward "GPG_AGENT_INFO=\\([^;\n]+\\)" nil t)
	    (match-string 1))))
;; (getenv "GPG_AGENT_INFO")

How to make sure that mails are always encrypted to you, too:

(setq mml2015-encrypt-to-self t
      mml2015-signers '("353AEFEF"))

There you go.

The alternative to mml2015-signers would be to set mml2015-sign-with-sender to t, I guess.

Tags: RSS RSS

-1:-- Encrypting Mail using Gnus on OSX (Post)--L0--C0--June 26, 2014 10:20 AM

Alex Schroeder: Emacs and Dice

Recently, somebody asked on Google+:

If I roll one of the five standard gaming dice (d4, d6, d8, d10, d12) and you also roll one of those, what are my chances of rolling higher, equal or lower than you, for each possible combination of dice.

I decided to write a little program to simply count it since I was unable to figure it out by thinking it through.

Update: Now that I’ve looked at the data, the formula is obvious. Assume x is the lower die:

x winning `(x(x-1))/2/(xy) = (x-1)/(2y)`
tie `x/(xy) = 1/y`
y winning `((x(x-1))/2 + x(y-x))/(xy) = 1 - ((x+1)/(2y))`
(dolist (die-1 '(4 6 8 10 12))
  (dolist (die-2 '(4 6 8 10 12))
    (unless (< die-2 die-1)
      (let ((a 0) (b 0) (n 0))
	(insert (format "d%d vs. d%d" die-1 die-2))
	(newline)
	(newline)
	(insert "     ")
	(dotimes (roll-1 die-1)
	  (insert (format " %4d" (1+ roll-1))))
	(newline)
	(dotimes (roll-2 die-2)
	  (insert (format " %4d" (1+ roll-2)))
	  (dotimes (roll-1 die-1)
	    (insert "    "
		    (cond ((> roll-1 roll-2)
			   (incf a)
			   "A")
			  ((= roll-1 roll-2)
			   (incf n)
			   "-")
			  (t
			   (incf b)
			   "B"))))
	  (newline))
	(newline)
	(let ((total (+ a b n)))
	  (insert (format "A: %d / %d = %4.3f\n" a total (/ a 1.0 total)))
	  (insert (format "B: %d / %d = %4.3f\n" b total (/ b 1.0 total)))
	  (insert (format "-: %d / %d = %4.3f\n" n total (/ n 1.0 total))))
	(newline)
	(newline)))))

d4 vs. d4

         1    2    3    4
    1    -    A    A    A
    2    B    -    A    A
    3    B    B    -    A
    4    B    B    B    -

A: 6 / 16 = 0.375
B: 6 / 16 = 0.375
-: 4 / 16 = 0.250


d4 vs. d6

         1    2    3    4
    1    -    A    A    A
    2    B    -    A    A
    3    B    B    -    A
    4    B    B    B    -
    5    B    B    B    B
    6    B    B    B    B

A: 6 / 24 = 0.250
B: 14 / 24 = 0.583
-: 4 / 24 = 0.167


d4 vs. d8

         1    2    3    4
    1    -    A    A    A
    2    B    -    A    A
    3    B    B    -    A
    4    B    B    B    -
    5    B    B    B    B
    6    B    B    B    B
    7    B    B    B    B
    8    B    B    B    B

A: 6 / 32 = 0.188
B: 22 / 32 = 0.688
-: 4 / 32 = 0.125


d4 vs. d10

         1    2    3    4
    1    -    A    A    A
    2    B    -    A    A
    3    B    B    -    A
    4    B    B    B    -
    5    B    B    B    B
    6    B    B    B    B
    7    B    B    B    B
    8    B    B    B    B
    9    B    B    B    B
   10    B    B    B    B

A: 6 / 40 = 0.150
B: 30 / 40 = 0.750
-: 4 / 40 = 0.100


d4 vs. d12

         1    2    3    4
    1    -    A    A    A
    2    B    -    A    A
    3    B    B    -    A
    4    B    B    B    -
    5    B    B    B    B
    6    B    B    B    B
    7    B    B    B    B
    8    B    B    B    B
    9    B    B    B    B
   10    B    B    B    B
   11    B    B    B    B
   12    B    B    B    B

A: 6 / 48 = 0.125
B: 38 / 48 = 0.792
-: 4 / 48 = 0.083


d6 vs. d6

         1    2    3    4    5    6
    1    -    A    A    A    A    A
    2    B    -    A    A    A    A
    3    B    B    -    A    A    A
    4    B    B    B    -    A    A
    5    B    B    B    B    -    A
    6    B    B    B    B    B    -

A: 15 / 36 = 0.417
B: 15 / 36 = 0.417
-: 6 / 36 = 0.167


d6 vs. d8

         1    2    3    4    5    6
    1    -    A    A    A    A    A
    2    B    -    A    A    A    A
    3    B    B    -    A    A    A
    4    B    B    B    -    A    A
    5    B    B    B    B    -    A
    6    B    B    B    B    B    -
    7    B    B    B    B    B    B
    8    B    B    B    B    B    B

A: 15 / 48 = 0.312
B: 27 / 48 = 0.562
-: 6 / 48 = 0.125


d6 vs. d10

         1    2    3    4    5    6
    1    -    A    A    A    A    A
    2    B    -    A    A    A    A
    3    B    B    -    A    A    A
    4    B    B    B    -    A    A
    5    B    B    B    B    -    A
    6    B    B    B    B    B    -
    7    B    B    B    B    B    B
    8    B    B    B    B    B    B
    9    B    B    B    B    B    B
   10    B    B    B    B    B    B

A: 15 / 60 = 0.250
B: 39 / 60 = 0.650
-: 6 / 60 = 0.100


d6 vs. d12

         1    2    3    4    5    6
    1    -    A    A    A    A    A
    2    B    -    A    A    A    A
    3    B    B    -    A    A    A
    4    B    B    B    -    A    A
    5    B    B    B    B    -    A
    6    B    B    B    B    B    -
    7    B    B    B    B    B    B
    8    B    B    B    B    B    B
    9    B    B    B    B    B    B
   10    B    B    B    B    B    B
   11    B    B    B    B    B    B
   12    B    B    B    B    B    B

A: 15 / 72 = 0.208
B: 51 / 72 = 0.708
-: 6 / 72 = 0.083


d8 vs. d8

         1    2    3    4    5    6    7    8
    1    -    A    A    A    A    A    A    A
    2    B    -    A    A    A    A    A    A
    3    B    B    -    A    A    A    A    A
    4    B    B    B    -    A    A    A    A
    5    B    B    B    B    -    A    A    A
    6    B    B    B    B    B    -    A    A
    7    B    B    B    B    B    B    -    A
    8    B    B    B    B    B    B    B    -

A: 28 / 64 = 0.438
B: 28 / 64 = 0.438
-: 8 / 64 = 0.125


d8 vs. d10

         1    2    3    4    5    6    7    8
    1    -    A    A    A    A    A    A    A
    2    B    -    A    A    A    A    A    A
    3    B    B    -    A    A    A    A    A
    4    B    B    B    -    A    A    A    A
    5    B    B    B    B    -    A    A    A
    6    B    B    B    B    B    -    A    A
    7    B    B    B    B    B    B    -    A
    8    B    B    B    B    B    B    B    -
    9    B    B    B    B    B    B    B    B
   10    B    B    B    B    B    B    B    B

A: 28 / 80 = 0.350
B: 44 / 80 = 0.550
-: 8 / 80 = 0.100


d8 vs. d12

         1    2    3    4    5    6    7    8
    1    -    A    A    A    A    A    A    A
    2    B    -    A    A    A    A    A    A
    3    B    B    -    A    A    A    A    A
    4    B    B    B    -    A    A    A    A
    5    B    B    B    B    -    A    A    A
    6    B    B    B    B    B    -    A    A
    7    B    B    B    B    B    B    -    A
    8    B    B    B    B    B    B    B    -
    9    B    B    B    B    B    B    B    B
   10    B    B    B    B    B    B    B    B
   11    B    B    B    B    B    B    B    B
   12    B    B    B    B    B    B    B    B

A: 28 / 96 = 0.292
B: 60 / 96 = 0.625
-: 8 / 96 = 0.083


d10 vs. d10

         1    2    3    4    5    6    7    8    9   10
    1    -    A    A    A    A    A    A    A    A    A
    2    B    -    A    A    A    A    A    A    A    A
    3    B    B    -    A    A    A    A    A    A    A
    4    B    B    B    -    A    A    A    A    A    A
    5    B    B    B    B    -    A    A    A    A    A
    6    B    B    B    B    B    -    A    A    A    A
    7    B    B    B    B    B    B    -    A    A    A
    8    B    B    B    B    B    B    B    -    A    A
    9    B    B    B    B    B    B    B    B    -    A
   10    B    B    B    B    B    B    B    B    B    -

A: 45 / 100 = 0.450
B: 45 / 100 = 0.450
-: 10 / 100 = 0.100


d10 vs. d12

         1    2    3    4    5    6    7    8    9   10
    1    -    A    A    A    A    A    A    A    A    A
    2    B    -    A    A    A    A    A    A    A    A
    3    B    B    -    A    A    A    A    A    A    A
    4    B    B    B    -    A    A    A    A    A    A
    5    B    B    B    B    -    A    A    A    A    A
    6    B    B    B    B    B    -    A    A    A    A
    7    B    B    B    B    B    B    -    A    A    A
    8    B    B    B    B    B    B    B    -    A    A
    9    B    B    B    B    B    B    B    B    -    A
   10    B    B    B    B    B    B    B    B    B    -
   11    B    B    B    B    B    B    B    B    B    B
   12    B    B    B    B    B    B    B    B    B    B

A: 45 / 120 = 0.375
B: 65 / 120 = 0.542
-: 10 / 120 = 0.083


d12 vs. d12

         1    2    3    4    5    6    7    8    9   10   11   12
    1    -    A    A    A    A    A    A    A    A    A    A    A
    2    B    -    A    A    A    A    A    A    A    A    A    A
    3    B    B    -    A    A    A    A    A    A    A    A    A
    4    B    B    B    -    A    A    A    A    A    A    A    A
    5    B    B    B    B    -    A    A    A    A    A    A    A
    6    B    B    B    B    B    -    A    A    A    A    A    A
    7    B    B    B    B    B    B    -    A    A    A    A    A
    8    B    B    B    B    B    B    B    -    A    A    A    A
    9    B    B    B    B    B    B    B    B    -    A    A    A
   10    B    B    B    B    B    B    B    B    B    -    A    A
   11    B    B    B    B    B    B    B    B    B    B    -    A
   12    B    B    B    B    B    B    B    B    B    B    B    -

A: 66 / 144 = 0.458
B: 66 / 144 = 0.458
-: 12 / 144 = 0.083

Tags: RSS RSS

-1:-- Emacs and Dice (Post)--L0--C0--June 24, 2014 02:49 PM

sachachua: Read Lisp Tweak Emacs (Beginner 3/4): How can I make things more convenient?

This entry is part 3 of 4 in the series Read Lisp, Tweak Emacs

“How can I customize Emacs to make things more convenient?”

After this module, you’ll be able to:

  • define your own keyboard shortcuts so that you can call functions more easily
  • work with custom functions that other people have defined in their configurations
  • copy and use anonymous functions

Keyboard shortcuts

The default keyboard shortcuts (or “keybindings”) can be difficult to remember, and many useful functions don’t have any keyboard shortcuts at all. People often set up their own keyboard shortcuts to make other commands easier to use. There are different ways to assign keys depending on where you want the keybinding to be available.

Setting keybindings in all buffers

You can assign a key to a function globally, which means that it will be available in buffers of any type if there are no mode maps or local keybindings that override it. (Mode maps are set by major modes like emacs-lisp-mode or minor modes like auto-fill-mode.) Setting a global keybinding is usually done with global-set-key, although sometimes you’ll see it done with define-key and global-map.

You can use global-set-key interactively by calling it with M-x global-set-key. Type the keyboard shortcut you would like to set, then specify the name of the function you would like Emacs to call. Note that the function must be interactive – that is, it must be something you can call with M-x and it should include (interactive ...) in its definition. For example, try M-x global-set-key, then press <f10>, and assign it to save-buffer. After you do that, you should be able to press <f10> to save the current buffer.

If you like a keybinding that you’ve interactively set, use C-x ESC ESC (repeat-complex-command) to see the Emacs Lisp code for it. You can copy and paste that into your configuration. For example, setting the keybinding above will result in:

(global-set-key [f10] (quote save-buffer))

You can also write keybindings from scratch. For example, the code below redefines the Return key (or the Enter key) so that it calls the newline-and-indent function by default.

(global-set-key (kbd "RET") 'newline-and-indent)

Remember, ​'newline-and-indent and (quote newline-and-indent) are the same thing – they both refer to the name of a thing (a function, in this case) instead of its value.

(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)

These set C-+ (Ctrl and <plus>) and C-- (Ctrl and <minus>) to increase and decrease the font size when you’re running Emacs in a graphical environment.

If you want to set a keyboard shortcut only in particular modes or types of files, jump ahead to Setting keybindings in a particular mode.

What does kbd do? How can I figure out which key it sets?

If you’ve gone through the Emacs Tutorial (Help – Emacs Tutorial or C-h t), you’ll be familiar with many of the conventions used for writing keyboard shortcuts. C- stands for the Ctrl key, M- stands for the Meta key (which is probably Alt or Option on your keyboard). There are other prefixes as well. S- is for Shift, H- is for Hyper, and s- is for Super. Some people use operating system tools (such as setxkbmap for Linux) to change keys on their keyboard to Super or Hyper in order to enable even more keyboard shortcuts.

Uppercase or lowercase depends on the character in the shortcut. C-x means Control + x, while C-X is actually Control + Shift + X. You can also specify shift by adding S-, so C-X and C-S-x are the same.

In addition, there are some special characters: RET, SPC, TAB, and ESC must be written in uppercase to mean the special keys they refer to. (There’s also LFD and NUL, but you’re probably not going to encounter those as often.) You can use angle brackets to refer to some other keys, like <return>, <up>, <down>, <left>, <right>. Function keys are written like this: <f1>.

There are different ways to specify the key. Many people use (kbd ...) because it makes bindings easy to read.

(global-set-key (kbd "M-/") 'hippie-expand)

This is the same as

(global-set-key "\M-/" 'hippie-expand)

or

(global-set-key [?\M-/] 'hippie-expand)

You can use ^ to mean Control, so

(global-set-key (kbd "C-s") 'isearch-forward-regexp)

is the same as either of these lines:

(global-set-key "\C-s" 'isearch-forward-regexp)
(global-set-key (kbd "^s") 'isearch-forward-regexp)

but C- is probably easier to read.

When you use kbd, whitespace doesn’t usually matter, but it’s easier to read if you use space to separate the keys to type. For more information about the syntax used by kbd, see C-h f (describe-function) for kbd, then follow the link to the documentation for edmacro-mode.

In general, you can use C-h k (describe-key) followed by a keyboard shortcut to see if it’s already bound, and if so, what function it calls. If you type C-h k and the key you’re interested in, and Emacs is still waiting for another key, then you’re probably looking at a prefix key. For example, C-x is a prefix key that’s used in keyboard shortcuts like C-x C-e (eval-last-sexp).

Multi-key shortcuts

You can set up keybindings that use more than one key combination. This is a popular technique since you can only have so many short keybindings. For example, the following code changes C-x C-b to call ibuffer, which lists your buffers and makes it easy to jump to another buffer.

(global-set-key (kbd "C-x C-b") 'ibuffer)

You don’t have to start with C-c or C-x. Consider using one of your function keys like <f9> as the start of your keyboard shortcuts. Then you can create shortcuts that don’t involve using Ctrl, Alt, or other modifier keys. For example:

(global-set-key (kbd "<f9> b") 'ibuffer)

Read other people’s configurations to get a sense of useful commands and handy keyboard shortcuts. By convention, shortcuts like C-c followed by a lowercase or uppercase letter are reserved for your use, as are the function keys <f5> to <f9>. Other keyboard shortcuts are likely to already be defined by modes. You can override them if you want.

Some people like using a function key followed by letters in order to minimize the need to press Control or Meta. For example, you might use:

(global-set-key (kbd "C-c r") 'query-replace)

or

(global-set-key (kbd "<f9> r") 'query-replace)

to make it easier to replace strings. You can even bind it to both shortcuts.

Binding keys to other keys

In addition to setting keyboard shortcuts for functions, you can also define keys to expand to a longer sequence of keystrokes. You can use this for inserting strings or calling keyboard macros. For example:

(global-set-key (kbd "<f7> e") "you@example.com")
(global-set-key (kbd "<f7> w") "http://example.com")
(global-set-key (kbd "<f7> u") (kbd "C-x C-s"))

These might be handy for quickly inserting your e-mail address or website.

Dealing with errors: “Key sequence __ starts with non-prefix key _

If you want to create a multi-key shortcut, the preceding keys must not already be assigned to functions. For example, if you want M-t l to call transpose-lines, you’ll need to get rid of M-t‘s default binding to transpose-words first. To unset a key, bind it to nil or use global-unset-key. Here’s a group of shortcuts you can try.

(global-set-key (kbd "M-t") nil) ;; Remove the old keybinding
(global-set-key (kbd "M-t c") 'transpose-chars)
(global-set-key (kbd "M-t w") 'transpose-words)
(global-set-key (kbd "M-t t") 'transpose-words)
(global-set-key (kbd "M-t M-t") 'transpose-words)
(global-set-key (kbd "M-t l") 'transpose-lines)
(global-set-key (kbd "M-t e") 'transpose-sexps)
(global-set-key (kbd "M-t s") 'transpose-sentences)
(global-set-key (kbd "M-t p") 'transpose-paragraphs)

The example above has three bindings for transpose-words. M-t w uses the mnemonic of t-ranspose w-ords. M-t t is similar to the original binding for transpose-words, which was M-t. M-t M-t may seem like overkill, but sometimes you’ll find it easier to hold the Meta key down and hit t twice quickly instead of typing M-t, releasing Meta, and then typing t. As you read other people’s keybindings, you’ll get a sense of how people have configured their keyboard shortcuts to speed up typing and minimize thinking.

Setting keybindings in a particular mode

Sometimes you want keys to do different things in different types of files. Modes are how Emacs changes behaviour based on context. For example, Java files use java-mode, Org files use org-mode, and so forth. In addition to the major mode for a buffer, you may have several minor modes that modify the behaviour. Each mode has a keybinding map (or a “keymap”). You can assign a key in a mode map, which means it will override global keybindings in buffers with that mode. You can do this with define-key if you know the name of the keymap you want to change, which is generally the name of the mode + -map. For example:

(define-key emacs-lisp-mode-map (kbd "C-c f") 'find-function)

changes the C-c f keyboard shortcut to find-function (which jumps to the definition of a function), but only in Emacs Lisp buffers.

Note that if you use define-key with a mode map, the mode must already be loaded by the time this code is run. That’s why you’ll often see this after a require (which loads the code) or inside an eval-after-load (which postpones the code until after the mode is loaded). See Adding more features to Emacs for information on loading packages and adding new functions to Emacs.

Other ways people bind keys

The bind-key package provides a function that makes it easier to see your personal keybindings, but bind-key is not part of Emacs by default. I use bind-key a lot in my configuration. The syntax is similar to global-set-key, except it automatically wraps the keyboard shortcut string in kbd. It also keeps track of which keyboard shortcuts you’ve overridden so that you can use M-x describe-personal-keybindings to review them.

(bind-key "C-+" 'text-scale-increase)
(bind-key "C--" 'text-scale-decrease)

You’ll need to install and use the bind-key package before you can use that code.

Because keybinding is something that lots of people do to customize their Emacs, you may find other ways that people have simplified writing keybindings for themselves. When in doubt, use C-h f (describe-function) to explore how something works. If the function can’t be found, see if it’s in a package somewhere, or search the Web for more information.

For more about keybindings, see the Emacs manual and this Mastering Emacs post on keybindings.

Defuns – function definitions

In addition to the functions built into Emacs or available in packages, many people define their own with the defun function.

People often distinguish custom functions by starting them with my/ or their initials. This makes it easier to tell which functions they’ve customized and which ones are part of a package. It also minimizes the risk of accidentally overriding a function defined elsewhere. You can change the name of a function as long as you make sure you change the name wherever it’s called, such as in keyboard shortcuts, hooks, or other functions.

For example, here’s a custom function from Jorgan Schaefer’s config:

(defun fc/kill-to-beginning-of-line ()
  "Kill from the beginning of the line to point."
  (interactive)
  (kill-region (point-at-bol) (point)))

This creates a function called fc/kill-to-beginning-of-line. () is the argument list. Since it doesn’t contain anything, that means this function does not take arguments. ​"Kill from the beginning of the line to point."​ is a documentation string (or docstring) that describes what the function does. Docstrings are optional, but highly recommended. (interactive) means that this can be called with M-x (execute-extended-command) or bound to a keyboard shortcut.

If a function does not have the (interactive) keyword, you won’t be able to call it with M-x or assign it to a keyboard shortcut, but you will still be able to write Emacs Lisp code that calls the function. This means M-x (execute-extended-command) lists only the commands that people will probably find useful while working directly with Emacs, skipping internal functions used by code.

Once you’ve defined a custom function, you can bind it to a keyboard shortcut if you want. The code below binds the fc/kill-to-beginning-of-line function to C-c C-u:

(global-set-key (kbd "C-c C-u") 'fc/kill-to-beginning-of-line)

You will often see custom functions added to hooks. A hook is a list of functions that’s called by some other code. Modes usually define a hook that’s called after the mode is initialized so that you can further customize its behaviours. For example, emacs-lisp-mode has an associated emacs-lisp-mode-hook which is run when a buffer is set up in Emacs Lisp Mode. You can add built-in functions or custom functions to hooks, and they’ll be run when that hook is called.

People sometimes use hook functions to set up keybindings instead of using define-key. For example, this code:

(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(define-key emacs-lisp-mode-map (kbd "C-c f") 'find-function)

can also be written as:

(defun my/set-up-emacs-lisp-shortcuts ()
  "Set up some conveniences for Emacs Lisp."
  (turn-on-eldoc-mode)
  (local-set-key (kbd "C-c f") 'find-function))
(add-hook 'emacs-lisp-mode-hook 'my/set-up-emacs-lisp-shortcuts)

Lambdas – anonymous functions

Sometimes people just want to create a keyboard binding or process some data without defining a new function. lambda creates an anonymous function, which is a function that doesn’t have a name. Here’s an example:

(global-set-key (kbd "C-c e") (lambda () (interactive) (find-file "~/.emacs.d/init.el")))

This binds C-c e to an anonymous function. The () means it doesn’t take any arguments. (interactive) means it can be called through a keyboard shortcut, although since it’s anonymous, it can’t be called with M-x. The function opens the ~/.emacs.d/init.el file, which is a handy way to edit your configuration.

  1. Look for an Emacs configuration file that defines keybindings that you’re curious about. Install any packages or copy any custom functions needed. Experiment with using those keybindings. Do you like them? Do you want to tweak them further?
  2. Think about how you use Emacs. What kinds of keyboard shortcuts would make your work easier? How can you adapt some of the functions you’ve read into things that would make them even more convenient for you?
You can find the draft of the complete course at emacslife.com/how-to-read-emacs-lisp.html. Enjoy!
Series Navigation« Read Lisp Tweak Emacs [Beginner 2/4]: How to understand what Emacs Lisp code doesRead Lisp, Tweak Emacs (Beginner 4/4): “How can I add more features? How do I deal with errors?” »

The post Read Lisp Tweak Emacs (Beginner 3/4): How can I make things more convenient? appeared first on sacha chua :: living an awesome life.

-1:-- Read Lisp Tweak Emacs (Beginner 3/4): How can I make things more convenient? (Post Sacha Chua)--L0--C0--June 20, 2014 12:31 AM

Dev and Such [Emacs Category]: A Possible Paradigm Shift

Lately I've been experiencing a change in the way I look at, think about, and use Emacs.

Emacs was always a one-stop shop for me. If I could do it in Emacs, I did. Email. Web browsing. Twitter. Listening to music. Games. Shells and terminals. Even Google Maps. Of course, I did coding and actual text editing as well.

Well, a while back a gave ol' vim a shot. I like it. Quite a bit, actually. It is my second preferred editor, and I even use evil-mode in Emacs now. I learned a lot during my time with vim, and I have been applying lessons learned to my other work flows. It has created a dichotomy in me that I've been struggling back and forth with for a while now.

Vi(m)'s big motive, so to speak, is to do one thing and do it well. It accomplishes this. It's fast and efficient. Editing in Vim is fast and efficient. This is largely why I have adopted evil-mode. However, I found myself asking "where is X?", where X could be terminals, web browsers, etc. These things simply don't exist in Vim (and, really, rightfully shouldn't). Those things aren't part of the One Thing it does well. That forced me to outsource these things to other programs. Programs I already used, mind you. This was, as crazy as it seems, a revelation. If I'm going to have a terminal, a web browser, etc. open anyway, I may as well make use of them.

So, here I am, years into my Emacs experience, finding myself with, once again, a new look on all things Emacs. Emacs is a hell of a text editor. It does lots of other things as well, some of which it does extremely well. However, not everything needs to be done, or should be done, in Emacs. It hurts me just a little to say that, but I'm increasingly believing that to be true. Heresy, thy name is me.

I'd be remiss if I didn't mention another potential factor in this recent change of mind and heart. I'm slowly (but not that slowly) severing ties with the Google Machine. In doing so, I've become aware of just how tied in I was. It was eye opening and scary. Having all your eggs in one basket, so to speak, has its benefits, but also can basically be a self-imposed lock down.

As I was untangling myself from this web (heh... get it?), I began recognizing other similar situations I was in. Emacs was at the forefront. Being so tied in to Emacs, when it crashed (which, to be fair, is rare), an update went badly, or anything else prevented Emacs from working appropriately, it was detrimental. Spreading tasks to the appropriate separate handlers is important. This is the same reason why micro-frameworks have become a huge deal, especially in the PHP world. It's piecing together your own solutions with several parts that each do one thing and do it well.

The end result of all this is I'm going to use Emacs for what it's good for: development and text editing. This includes things like running terminals for tests or other things, using version control (seriously, magit is the shit [technical term]), and other development and text editing related things. Other tasks will be delegated elsewhere, including 2048.

If you go through the history of Emacs posts on this blog, you'll see that I've flip-flopped on several topics and not kept up with various changes I've made (cough org-mode cough). This may very well fall into that category as well, and I may find myself back to doing as much in Emacs as possible. For now, though, I'll be spreading my work across multiple applications.


Side notes:

You'll notice the title of this article says "possible". That's largely due to what I said in the last paragraph.

Also, as far as getting myself away from the Google Machine, to be fair, I've basically just jumped ship to Apple (for most, but not all, things). This may sound hypocritical, but a.) as I'm basically all Apple hardware these days anyway, it at least makes more sense than being tied into Google, and b.) Apple is now at least on par with Google as far as the EFF is concerned. I'm not a complete hypocrite, though, as I've been looking at what Apple services I can move to other providers, so I'm at least trying to apply this same separation of services thought to my Apple tie-ins as well.

-1:-- A Possible Paradigm Shift (Post)--L0--C0--June 17, 2014 01:57 PM

John Sullivan: No such pipe, or this pipe has been deleted

This data comes from pipes.yahoo.com but the Pipe does not exist or has been deleted.
-1:-- No such pipe, or this pipe has been deleted (Post)--L0--C0--June 14, 2014 03:00 PM

Jorgen Schäfer: The Sorry State of Emacs Lisp Package Archives

GNU Emacs 24 (released in June 2012) introduced official support for packages, that is, a way of installing extensions from a remote repository. This was a huge step forward for Emacs, as it not only allowed users to easily find and install extensions, but it also made it possible for extensions to build upon other extensions without having to tell the user “great you want to install this, just install this extensions and those five other ones, too.” It used to be that many extensions each re-implemented common functionality just to get around this problem. Now, we have a number of general-purpose libraries.

Two years into the age of packages, there are three (four) major package archives available, but they all have some serious problems, making none of them even remotely as useful as, say, Python’s PyPI.

GNU ELPA

Emacs comes with one package archive preconfigured, GNU’s own Emacs Lisp Package Archive (ELPA). This archive is subject to the same copyright assignment policy as Emacs itself, making it nothing more than a way of adding packages to Emacs without shipping them in the default installation. With a high hurdle (requesting copyright assignment not only from yourself but from any possible contributor) and almost no benefits, it’s hardly used.

At the time of this writing, GNU ELPA contains 74 packages.

MELPA

Arguably at the moment the most widely used package archive, MELPA follows a rather idiosyncratic approach to packages. Users do not upload packages, rather MELPA is configured with recipes that specify how to build a package from a remote source, ideally a version control system.

This solves one of the core problems of Emacs packages: Package authors quite regularly do not care about releases. Reducing the workload to get them published, as MELPA does, means there will be more packages available and they won’t become outdated easily just because the author did not feel like releasing their software again. This is a much bigger problem for Emacs Lisp packages than for other languages.

Sadly, MELPA has a few home-made problems.

By far the biggest one is the choice of version numbers. MELPA simply ignores any version numbers specified by the package and uses its own version number scheme based on dates. This makes sense, as it simply downloads the “latest version” from repositories, and for packages with no real releases, this isn’t a problem. But as soon as you have a package with actual releases, this is quite confusing. Worse, though, these version numbers act as a vendor lock-in. If your package evergets on MELPA, you better keep it current there because whenever someone uses MELPA, their version will override whichever one you release because 20140613.420 is simply a higher version number than 5.1.3 or whatever you just released. And MELPA has no problems adding packages even without asking the author if they are ok with it, so authors end up having to deal with this problem no matter what.

And all of this completely without need. They could have just added the date at the end of any existing version string, and all would have been well. 5.1.3.20140613.420 is still higher than 5.1.3.

Even when you decide to support MELPA for a package with actual releases, it’s a pain. When you do a release, you can’t just go and announce it right away, because MELPA can take anything from an hour to a day to figure out that your source change and it re-builds it. You have no control whatsoever over this process.

Another problem is with the intention of MELPA. The maintainers deliberately want it to provide unstable packages, preferring unstable over even slightly outdated. Getting stable releases of packages with those into MELPA requires quite some effort and their authors have to deal with some abuse for it.

MELPA currently contains 1 834 packages.

MELPA Stable

To solve the latter problem, the MELPA maintainers created a spin-off of MELPA for stable packages. It has much stricter requirements than MELPA, and uses github tags to specify stable versions. This is a great idea, but sadly it’s primarily well-intended and does not actually solve any problem. Because it contains only roughly a third of the packages in MELPA unstable, users quite regularly have to use MELPA unstable as well. But MELPA unstable also contains the packages from MELPA stable, with the vendor lock-in version numbers, so they always override the stable ones, making MELPA stable mostly useless.

It is possible to circumvent this in Emacs 24.4 by pinning all packages available from MELPA stable to that repository, but that’s only possible in 24.4, and it’s something users need to do manually. Not really a good prospect for package authors.

MELPA Stable currently contains 591 packages.

Marmalade

Finally, there’s Maramalade. If you come from another programming language, this is what you expect a package archive to look like. Users create accounts, upload their packages with version numbers of their choice, and others can download them. Simple.

Sadly, it suffers from two distinct problems.

The first is the aforementioned mentality of many package authors. Uploading a package to a package archive is effort, and many simply skip it, much like they skip doing releases entirely. This results in a number of outdated packages in Marmalade.

The second problem is workload related. Marmalade used to be written in Node.js and was pretty flaky. The current maintainer had to rewrite it from scratch (it’s now a full web app written in Emacs Lisp, which is kind of cool), and he is already rather busy. With very little help, the rewrite took a while, and for a few months, uploads via the web interface were broken due to bugs in the old software, while currently, creating accounts is not working in the new software yet. Due to these problems, some packages simply moved away from Marmalade.

Between the heavy workload on the maintainer and the problems with package authors who do not do releases, I’m not sure about the future of Marmalade. Though I do hope it stays around; from the options we have, it’s by far the sanest.

Marmalade currently contains 1 043 packages.

Moving Forward

Emacs Lisp Package Archives have some rather unique problems to solve with the general reluctance to do actual releases of packages. Finding a balance between supporting this well and also supporting packages with actual releases is not easy, and all of the current archives have some serious problems because of this.

A good solution for this problem, and adapting or replacing the existing package archives, would be a huge step forward for Emacs.

-1:-- The Sorry State of Emacs Lisp Package Archives (Post Jorgen Schäfer (noreply@blogger.com))--L0--C0--June 13, 2014 06:19 PM

Flickr tag 'emacs': Emacs Text Editor

xmodulo posted a photo:

Emacs Text Editor

What is a good text editor on Linux

If you would like to use this photo, be sure to place a proper attribution linking to xmodulo.com

-1:-- Emacs Text Editor (Post xmodulo (nobody@flickr.com))--L0--C0--June 11, 2014 02:03 AM

Ben Simon: bitgrid -- The Result of a Little Tin Can Hacking

I give you: bitgrid, a webapp without a cause. It's the result of some Tin Can Hacking.

During our last trip overseas I got the idea in my head to give myself a little programming challenge. Given the flight from DC to Paris, what kind of software could I build from scratch? I'd have at my disposal whatever was installed on my laptop, but with no Internet Connection, I was effectively on my own. I couldn't go off and grab 3rd party libraries or get answers from Google. Not to mention, I was programming all this from coach. So not only did I have to get by without StackOverflow, I'd also have to get by without legroom.

It was just me, emacs and xampp, stuck in a tin can flying at 30,000 feet.

After a little brainstorming, I decided I'd focus on building a simple little app for sharing crude images. This ended up refining itself into bitgrid, an app where you can fill in various points of a grid and share that grid with your friends. The state of the application is stored in the URL, so there's actually no database dependency. (In other words: bitgrid may not have much value, but boy does it scale!)

Here's what the webapp looks like:

And here's the URL behind that particular grid: http://bitgrid.benjisimon.com/#1G00S744K5K544S7001G.

What's bitgrid useful for? Well, that's hard to say. It's a pretty generic app, so it's got any number of uses. You could use it to make crude maps or share minimalist art. You could use it to pass secret messages, or as a sort of online ranger beads. With a little effort, you could probably create an online game with it; one that gets played by passing URLs back and forth over Twitter. The sky's the limit.

All I know is, it was a fun little diversion.

Here are some grids to get you started: one, two and three. But really, go make something amazing!

Update: (1) an anonymous user submitted a fix to the bug keeping you from highlighting an entire row of grid points, and I've applied it. And (2), I've put the repo up at github. Feel free to fork this sucker and hack away.

Update: Special thanks to Erwin Koning for finding and fixing a nasty bug in bitgrid.

-1:-- bitgrid -- The Result of a Little Tin Can Hacking (Post Ben Simon)--L0--C0--June 10, 2014 07:11 AM

John Sullivan: GPG keysigning and government identification

Please stop recommending that checking government-issued ID is a good way to verify someone's identity before signing their GPG key.

Have you been a US bartender before? Or held any other position where you've had to verify an ID? It's not an easy thing to do. People in those positions have books of valid IDs from different states. They have lights that show the security marks. They still get it wrong regularly. A very amateur fake ID, or borrowed real ID, will fool just about everyone in any informal context.

What's even worse is that people have a habit of happily looking at passports from other countries than their own, and nodding knowingly. It's fun, but be honest, you have no idea what you're doing.

How about just signing keys with people you would actually say you know well enough to trust? It's not the Web of Amateur ID Checking.

ID checking is at best ineffective against the threats it's supposed to address, and is probably actually damaging to the Web of Trust because of the false sense of security.

No idea what I'm talking about? Learn to encrypt your email by reading the FSF's new Email Self-Defense Guide, published in honor of today's Reset The Net effort.

-1:-- GPG keysigning and government identification (Post)--L0--C0--June 05, 2014 04:02 AM

Julien Danjou: OpenStack Design Summit Juno, from a Ceilometer point of view

Last week was the OpenStack Design Summit in Atlanta, GA where we, developers, discussed and designed the new OpenStack release (Juno) coming up. I've been there mainly to discuss Ceilometer upcoming developments.

The summit has been great. It was my third OpenStack design summit, and the first one not being a PTL, meaning it was a largely more relaxed summit for me!

On Monday, we started by a 2.5 hours meeting with Ceilometer core developers and contributors about the Gnocchi experimental project that I've started a few weeks ago. It was a great and productive afternoon, and allowed me to introduce and cover this topic extensively, something that would not have been possible in the allocated session we had later in the week.

Ceilometer had his design sessions running mainly during Wednesday. We noted a lot of things and commented during the sessions in our Etherpads instances. Here is a short summary of the sessions I've attended.

Scaling the central agent

I was in charge of the first session, and introduced the work that was done so far in the scaling of the central agent. Six months ago, during the Havana summit, I proposed to scale the central agent by distributing the tasks among several node, using a library to handle the group membership aspect of it. That led to the creation of the tooz library that we worked on at eNovance during the last 6 months.

Now that we have this foundation available, Cyril Roelandt started to replace the Ceilometer alarming job repartition code by Taskflow and Tooz. Starting with the central agent is simpler and will be a first proof of concept to be used by the central agent then. We plan to get this merged for Juno.

For the central agent, the same work needs to be done, but since it's a bit more complicated, it will be done after the alarming evaluators are converted.

Test strategy

The next session discussed the test strategy and how we could improve Ceilometer unit and functional testing. There is a lot in this area to be done, and this is going to be one of the main focus of the team in the upcoming weeks. Having Tempest tests run was a goal for Havana, and even if we made a lot of progress, we're still no there yet.

Complex queries and per-user/project data collection

This session, led by Ildikó Váncsa, was about adding finer-grained configuration into the pipeline configuration to allow per-user and per-project data retrieval. This was not really controversial, though how to implement this exactly is still to be discussed, but the idea was well received. The other part of the session was about adding more in the complex queries feature provided by the v2 API.

Rethinking Ceilometer as a Time-Series-as-a-Service

This was my main session, the reason we met on Monday for a few hours, and one of the most promising session – I hope – of the week.

It appears that the way Ceilometer designed its API and storage backends a long time ago is now a problem to scale the data storage. Also, the events API we introduced in the last release partially overlaps some of the functionality provided by the samples API that causes us scaling troubles.

Therefore, I've started to rethink the Ceilometer API by building it as a time series read/write service, letting the audit part of our previous sample API to the event subsystem. After a few researches and experiments, I've designed a new project called Gnocchi, which provides exactly that functionality in a hopefully scalable way.

Gnocchi is split in two parts: a time series API and its driver, and a resource indexing API with its own driver. Having two distinct driver sets allows it to use different technologies to store each data type in the best storage engine possible. The canonical driver for time series handling is based on Pandas and Swift. The canonical resource indexer driver is based on SQLAlchemy.

The idea and project was well received and looked pretty exciting to most people. Our hope is to design a version 3 of the Ceilometer API around Gnocchi at some point during the Juno cycle, and have it ready as some sort of preview for the final release.

Revisiting the Ceilometer data model

This session led by Alexei Kornienko, kind of echoed the previous session, as it clearly also tried to address the Ceilometer scalability issue, but in a different way.

Anyway, the SQL driver limitations have been discussed and Mehdi Abaakouk implemented some of the suggestions during the week, so we should very soon see more performances in Ceilometer with the current default storage driver.

Ceilometer devops session

We organized this session to get feedbacks from the devops community about deploying Ceilometer. It was very interesting, and the list of things we could improve is long, and I think will help us to drive our future efforts.

SNMP inspectors

This session, led by Lianhao Lu, discussed various details of the future of SNMP support in Ceilometer.

Alarm and logs improvements

This mixed session, led by Nejc Saje and Gordon Chung, was about possible improvements on the alarm evaluation system provided by Ceilometer, and making logging in Ceilometer more effective. Both half-sessions were interesting and led to several ideas on how to improve both systems.

Conclusion

Considering the current QA problems with Ceilometer, Eoghan Glynn, the new Project Technical Leader for Ceilometer, clearly indicated that this will be the main focus of the release cycle.

Personally, I will be focused on working on Gnocchi, and will likely be joined by others in the next weeks. Our idea is to develop a complete solution with a high velocity in the next weeks, and then works on its integration with Ceilometer itself.

-1:-- OpenStack Design Summit Juno, from a Ceilometer point of view (Post Julien Danjou)--L0--C0--May 30, 2014 04:49 PM

Raimon Grau: erc makes you faster at jokes!

Hi, today's post is a simple sinppet I wrote to ease the pain of looking for recurrent references on the internet.

At work we use IRC heavily (it's our main channel for comunication). As you know,every platform or channel of comunication has its own processes and joke (slightly related (but interesting nonetheless): The medium is the Massage ) . So IRC is mostly about sending links to gifs and to funny images, and funny images with captions in them.

It's so simple that it doesn't even need explanation. You just have to know that all defuns named "erc-cmd-SOMETHING" will be automatically callable from erc as a /something.



(
defun erc-cmd-MEME (wat)
"Fetch links from the alist of knowledge"
(
let ((h '(("trap" "http://4.bp.blogspot.com/-ae1ZRrrjs8c/Th0rz7ZvogI/AAAAAAAAANU/QM2WW-LNZXY/s1600/original.jpg"))))
(erc-send-message (cadr (assoc wat h)))))

Combined with erc-image.el, it makes a really nice IRC experience :)


-1:-- erc makes you faster at jokes! (Post Raimon Grau (noreply@blogger.com))--L0--C0--May 28, 2014 02:03 PM

emacspeak: Emacspeak And Company: Complete Anything Front-End For emacspeak

Emacspeak And Company: Complete Anything Front-End For Emacspeak

1 Emacspeak And Company: Complete Anything Front-End For Emacspeak

Module emacspeak-company speech-enables package Company — a flexible complete-anything extension for Emacs. Package company gains much of its flexibility by providing an extensible framework for both back-ends and front-ends; back-ends are responsible for language-specific support e.g., C++ vs Emacs Lisp; front-ends can provide different visualizations of the available completions.

I started using package company as I taught myself to program in Go over the last couple of weeks, and package emacspeak-company was one of the bi-products.

1.1 Using Company With Emacspeak

You can turn on company-mode in dividual buffers; you can also turn it on globally. Company comes pre-packaged with backend support for many programming languages; for programming in Go, I use module company-go in conjunction with the GoCode tool.

See customization group company to customize package company; Emacspeak loads package emacspeak-company when package company is loaded, and that automatically sets up the Emacspeak front-end.

Once activated, package company shows available completions where available once you type a prescribed number of characters. Available candidates are displayed visually via an overlay and can be traversed using either the up/down arrows or keys M-n and M-p. You can also search and filter the available completions, see documentation for command company-mode. The available visual front-ends also display relevant metadata for the current candidate in the echo area.

Front-end emacspeak-company performs the following additional actions:

  • Speaks current candidate along with the relevant metadata.
  • The metadata is spoken using voice-annotate.
  • Auditory icon help indicates that completion has started.
  • pressing F1 during completion displays documentation for the current candidate.
  • You can choose the current candidate by pressing RET; this

speaks the selected candidate.

  • Auditory icon close-object indicates that completion has finished.

1.2 Insights From Speech-Enabling Company

Company uses a fluid visual interface to display completions without the user having to switch contexts — it achieves this by using overlays that appear briefly in the form of a conceptual tooltip. These pseudo tooltips are created and destroyed via a timer; keyboard interaction causes these to be updated — including hiding the tooltip where appropriate.

Module emacspeak-company speech-enables this interface by examining the underlying information used to create the visualization to produce an effective audio-formatted representation. The net effect is that you can write code with completion helping you along the way; you do not need to switch tasks to lookup details as to what completions are available.

1.3 Acknowledgements

Thanks again to the authors of package company for a really nice tool — it's a real productivity winner — especially when learning a new language and its built-in packages.

I found these articles really helpful while learning to write package emacspeak-company.

Learning Go was a pleasure (it's still a pleasure — I'm still learning:-)) and the documentation on GoLang is excellent. As an added bonus, that entire site uses clean, well-formed HTML without any unnecessary artifacts that make so much of today's Web a giant mess; I have been able to use Emacs/EWW exclusively while working with golang.org — a real bonus for someone programming heavily in Emacs.

Date: <2014-05-27 Tue>

Author: T.V Raman

Created: 2014-05-27 Tue 08:51

Emacs 24.3.91.1 (Org mode 8.2.6)

Validate

-1:-- Emacspeak And Company: Complete Anything Front-End For emacspeak (Post T. V. Raman (noreply@blogger.com))--L0--C0--May 27, 2014 03:54 PM

Jorgen Schäfer: Race conditions in Emacs' process filter functions

Race conditions are always fun. They are particularly surprising when they happen in a single-threaded program like Emacs. I just ran into this problem for the second time.

When Emacs reads data from a process, it executes a filter functionassociated with that process. The idea is that this filter function handles the data, and after it returns, Emacs continues with other work. Due to some peculiarities of Emacs, it is easily possible for filter functions to run while other filter functions are running, seemingly randomly.

Emacs runs filter functions whenever it reads data from a process, even if this happens while a filter function is already running. And there are many places where Emacs reads data from processes. Even if you knew all the functions that do so, you do not control or know about the code Emacs runs most of the time. For example, if you create a buffer in a particular mode, that mode’s hook is run, which could execute pretty much anything.

I first encountered this problem in Circe, my IRC client for Emacs. In a filter function, it can open a new buffer in a specific mode (a query). That mode can have flyspell active, Emacs spell checker. But flyspell starts a new process for spell checking. Starting a new process can cause Emacs to read from processes, running filter functions. This resulted in a difficult to debug problem that happened only when a user received two messages in very close succession.

You can read my comments on the problem in the Circe source code.

I just ran into the same problem again in Elpy, my Python development environment. To my surprise, Emacs’ process-send-string does not only send data, it also reads data from the process and handles it in the same call. In this particular case, the usual sequence of action is to run an initialization function, and then set a flag that initialization happened, so no need to run it again. But the initialization function sends data to a process. And the filter function for this process might call the original function. Which would notice that no initialization happened, send data, which would read data, which would notice that no initialization happened yet, so send data again … stack overflow.

Solution? A dynamic scope “lock” (not a real lock as it does not block, but close enough).

(defvar my-lock nil)
(when (not my-lock)
(let ((my-lock t))
...))

For a single-threaded application like Emacs, this looks completely useless. But it works.

-1:-- Race conditions in Emacs' process filter functions (Post Jorgen Schäfer (noreply@blogger.com))--L0--C0--May 27, 2014 09:24 AM

Justin Heyes-Jones: Sending notifications from Emacs (Mac OS X)


Sending notifications from emacs is something I find useful. In an earlier blog post I talked about how to use Growl to do so. http://justinsboringpage.blogspot.com/2009/09/making-emacs-growl.html

Well now you don't need Growl any longer. There's a neat github project called terminal notifier https://github.com/alloy/terminal-notifier which let's you send notifications from the terminal.

You can install it simply, via Homebrew or Rubygems as follows:
$ [sudo] gem install terminal-notifier
OR
brew install terminal-notifier
Then you can send notifications using a command like this:

terminal-notifier -message "hello"

Finally in order to send the notification from emacs we need to write a little Emacs lisp.

Check out this gist for the code I use:

https://gist.github.com/justinhj/eb2d354d06631076566f#file-gistfile1-el

This lets you send a notification in the future using M-x timed-notification

You are prompted for a time, and the format of that time can be given in a human readable way such as "2 seconds" or "5 minutes" (If you're curious for the allowed options look at the info page in emacs for the function timer-duration )

Then you are prompted for the message "Go to the store", and the message will be sent.

The code is very simple, it simply uses run-at-time to run the terminal command in the future. A useful command is find-executable, which given a name will find that executable in your path and run it. This makes configuring tools like this less effort.

Troubleshooting

Hey if it doesn't work first time what can you do?


  1. Check if terminal notify is installed correctly by running at terminal
  2. If that succeeds and you don't get a message check if you have enabled do not disturb mode
  3. Otherwise if that succeeds and yet emacs isn't sending messages you likely don't have the executable on the path. M-x customize-variable exec-path








-1:-- Sending notifications from Emacs (Mac OS X) (Post Justin (noreply@blogger.com))--L0--C0--May 26, 2014 05:09 PM

Eric James Michael Ritz: My Favorite Emacs Packages Out of One-Hundred

My Emacs configuration file is getting close to loading one-hundred packages. I download most of them from MELPA, which in my opinion is the best source for libraries or packages you want to mold Emacs for your needs. Once per week I read through MELPA’s Twitter feed and download anything that seems remotely useful—I have so many sub-directories in /home/eric/.emacs/lisp….

Today I want to tell you about my favorite packages from the large number that I am currently using or have used in the past. I hope you find something useful as a result. Now, let the mini-endorsements begin!

use-package

Last year I rewrote my .emacs file and replaced almost all of my require expressions with use-package. I actually blogged about it at the time so I am not going to repeat myself here. Except to say that use-package has proven to be a fantastic way to keep my configuration feeling clean and organized. If your .emacs feels cluttered then you need to check out use-package, or req-package if you have a lot of dependencies between packages.

Expand Region

In the course of all the programming I do, I often want to select regions such as everything in a string, the index of an array, the body of an Emacs Lisp expression, et cetera. Expand Region makes these selections easy. Take a look at the command in action.

The author Magnar Sveen—creator of many great packages—also offers Change Inner, an implementation of the ci (change inner) and co (change outer) commands from Vim, built on top of Expand Region. I often use these in programming. For example, with change-inner bound to M-i, I can kill the contents of a string at point by simply pressing M-i ". If I used M-o instead, which I bind to change-outer, then it would kill the quotes as well. These commands are convenient for any kind of document where you are editing content between delimiters.

Anchored Transpose

Have you ever wanted to swap two regions? One way to do it would be to kill the first region, yank it at the position of the second, then kill the second and jump back to the first position to yank it. Or use the easier Anchored Transpose command. This command is great for swapping the order of parameters in code or exchanging two sentences around a comma or semicolon—things like that. It allows you to select the anchor first, e.g. the comma, and then phrase to transpose; or you can select the two regions independently and then transpose them. The command is aware of any overlap between the two regions and will Do the Right Thing.

Flycheck

GNU Emacs comes with Flymake to perform on-the-fly syntax checking. Flycheck is a replacement with support for more languages, at this time of writing:

  • AsciiDoc
  • C/C++
  • CFEngine
  • Chef
  • Coffeescript
  • CSS
  • D
  • Elixir
  • Emacs Lisp
  • Erlang
  • ERuby
  • Go
  • Haml
  • Handlebars
  • Haskell
  • HTML
  • Javascript
  • JSON
  • LESS
  • Lua
  • Make
  • Perl
  • PHP
  • Puppet
  • Python
  • Racket
  • ReStructuredText
  • Ruby
  • Rust
  • Sass
  • Scala
  • Scss
  • Shell script languages
  • Slim
  • TeX/LaTeX
  • Texinfo
  • Verilog
  • XML
  • YAML

Whew.

If you need support for a language not part of the above then you can use Flycheck’s API to extend it. Flycheck comes with a set of functions to parse the output of lint programs so that you can define a new syntax checker with code as simple as this:

(flycheck-define-checker php-phpcs
  "A PHP syntax checker using PHP_CodeSniffer.

See URL `http://pear.php.net/package/PHP_CodeSniffer/'."
  :command ("phpcs" "--report=checkstyle" source)
  :error-parser flycheck-parse-checkstyle
  :modes php-mode)

(add-to-list 'flycheck-checkers 'php-phpcs)

Flycheck has helped me find countless errors in my work sooner rather than later, and I daresay the package is mandatory for any computer programmer. Flycheck is that useful.

Org Mode

I know more than one person who uses Emacs solely for the purpose of using Org Mode. It’s a comprehensive suite of tools for planning todo lists, tracking your time on tasks, organizing notes—no one demonstrates the usefulness of Org Mode like Sacha Chua. In my opinion her blog is the best place to see every way you can use Org Mode to organize everything you do.

God Mode

Tired of holding Control and/or Alt when executing a series of commands? Then turn God Mode on to get rid of the need for those modifiers. Consider this example of key presses from the project’s GitHub page:

Before: C-p C-k C-n M-^ ) C-j C-y M-r C-x z z M-2 C-g C-g C-x C-s
After:    p   k   n g ^ )   j   y g r     . .   2   g   g   x   s

I know this will sound like heresy to some, but God Mode gives you a level of convenience similar to the command mode of Vim. I realize that is the editor of “The Enemy,” but if we’re being honest then we have to admit that Vim has useful features, like the aforementioned Change Inner/Outer. Personally, I found it easy to adopt the mind-set of no longer holding modifier keys when I need to execute a of key-presses. We all know about “Emacs Pinky.” God Mode is a convenient way to reduce that strain.

Conclusion

Once again, I hope you improve your Emacs workflow by using one or more of the packages described above. If you have any questions about packages for specific purposes, like programming languages, feel free to leave a comment for suggestions. And also please suggest packages that you consider crucial benefits to the way you use Emacs.


-1:-- My Favorite Emacs Packages Out of One-Hundred (Post ericjmritz)--L0--C0--May 16, 2014 11:48 AM

Got Emacs?: Editor wars redux in the mainstream press

From a post on comp.emacs, here's an article on slate comparing Emacs and Vi. Doesn't say anything new to people familiar to Emacs and Vi.  Just that it's there at all in some minor mainstream press.
-1:-- Editor wars redux in the mainstream press (Post sivaram (noreply@blogger.com))--L0--C0--May 14, 2014 04:20 PM

emacspeak: Announcing Emacspeak 40.0 AKA WowDog!

Emacspeak 40.0—WowDog—Unleashed!

1 Emacspeak-40.0 (WowDog) Unleashed!

** For Immediate Release:

San Jose, Calif., (May 13, 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 40.0 (WowDog) –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 2013 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. ♁
  • 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-40.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 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.

Author: T.V Raman

Created: 2014-05-09 Fri 08:44

Emacs 24.4.50.2 (Org mode 8.2.6)

Validate

-1:-- Announcing Emacspeak 40.0 AKA WowDog! (Post T. V. Raman (noreply@blogger.com))--L0--C0--May 12, 2014 02:52 PM