Manuel Uberti: Daily Clojure workflow

It’s already been a month since I started my new job. All is going well and just as expected, and it’s been interesting to see how my carefully tuned Emacs configuration dealt with everyday Clojure programming.

Truth be told, I’ve never used Emacs consistently for work. Before Clojure I mainly did Java and Emacs support for Java is notably not as good as what it offers for other programming languages. Yes, I kept Emacs around for other stuff, but it would be a dull lie to tell I was proudly using Emacs all day in the office.

Anyway, Clojure is the new kid in town now so it’s Emacs all the way. The obvious first choice is CIDER and I genuinely don’t have enough words to say how wonderful it is. I couple it with clj-refactor and Smartparens to get the most out of my coding experience.

I especially love how CIDER enables me to switch easily between Clojure and ClojureScript, with two REPLs ready to go and documentation just under my fingertips. clj-refactor enriches exploratory development with hot reloading of dependencies and handy adjustment of missing requires.

Then there is Projectile. Even on small Clojure projects we are using to test available libraries there are plenty of files around. Mickey Petersen talks about tempo when it comes to using Emacs. Projectile guarantees you don’t lose your tempo while working on projects of different sizes.

What else? I don’t think Magit needs my over enthusiastic words. Ivy is proving to be the right tool at the right time, with Swiper ever so helpful. And now I am only waiting for the day we will need proper documents to bring out the almighty AUCTeX.

In the immortal words of Bozhidar Batsov:

Emacs is power.

Emacs is magic.

Emacs is fun.

Emacs is forever.

-1:-- Daily Clojure workflow (Post)--L0--C0--April 29, 2017 12:00 AM

Irreal: The Value of Source Code in Emacs

Arun Isaac makes a nice point. Most of us support open source and insist on our right to have source code available but we hardly ever look at that source. Except for Emacs. Isaac observes that when the documentation is missing or ambiguous, he simply follows the link to the source to see what’s really going on.

Of course, you have to know some Elisp but the point is that the source is instantly available without leaving Emacs. You can check it and then return to your original buffer with your new knowledge. It’s life changing in a way that even the best of most open source software is not.

As I’ve said before, it’s because Emacs (sort of) recapitulates the Lisp Machines of yore. There are no secrets and everything is available in your chosen environment. This, more than anything, is why I am moving as much as possible into Emacs.

-1:-- The Value of Source Code in Emacs (Post jcs)--L0--C0--April 28, 2017 05:44 PM

Irreal: Installed Emacs 25.2

Emacs 25.2 is mostly a bug-fix release and I haven’t had any problems so I didn’t bother installing it as soon as it was released. Still, Irreal likes to be up-to-date on all things Emacs so I finally got around to compiling and installing it. Really, compiling it from source isn’t much harder than using homebrew or one of its siblings.

Here’s the recipe for compiling and installing it on macOS:

cd path-to-untared-source
configure --with-ns CFLAGS="-g3 -O2 -I /usr/local/include/libxml2"
make
make install
sudo mv nextstep/Emacs.app /Applications

I always mv my current Emacs to a backup version but that’s probably just irrational paranoia. The above recipe builds Emacs with EWW support. If you have additional needs, you may have to adjust the configure.

UPDATE [2017-04-27 Thu]: John Mastro commented that he thought specifying the CFLAGS variable to configure overroad the default value, which turns on some optimization. After some investigation, which you can read about in the comments, I discovered that that was indeed the case. I rebuilt Emacs with the new configure invocation shown above. If you followed the old recipe, you may want to do the same.

-1:-- Installed Emacs 25.2 (Post jcs)--L0--C0--April 27, 2017 02:38 PM

sachachua: 2017-04-24 Emacs news

Links from reddit.com/r/emacs, /r/orgmode, /r/spacemacs, Hacker News, planet.emacsen.org, Youtube, the changes to the Emacs NEWS file, and emacs-devel.

Past Emacs News round-ups

-1:-- 2017-04-24 Emacs news (Post Sacha Chua)--L0--C0--April 25, 2017 03:28 AM

Pragmatic Emacs: Using email address lists in mu4e

To set up lists of multiple email multiple recipients with mu4e, you can make use of mail aliases. To do this, add lists to a file with the following format, with the word “alias” followed by the name you want for the list, followed by a space-separated list of email addresses:

alias jsmiths "John Q. Smith <none@example.com>" "Jane Q. Smith <email@address.com>"

You can either save this file as ~/.mailrc or put it anywhere and tell Emacs where to find it using e.g.

;;mail aliases for lists (address lists)
(setq mail-personal-alias-file (expand-file-name "/homeb/bjm/docs/mail-aliases"))

Now, when composing an email you can type the alias (“jsmiths” in our example) and hit space, and it will expand to the list of email addresses.

If you are using my improved address completion, then you can add those aliases to your bjm/contact-file to have them appear in your completion lists.

-1:-- Using email address lists in mu4e (Post Ben Maughan)--L0--C0--April 24, 2017 08:25 PM

Emacs café: Setting up Emacs for JavaScript (part #1)

There’s a lot that can be done to make Emacs a great tool for JavaScript development. So much that I had to split it up into several posts.

In this first article we’ll see how to setup js2-mode and two other packages that rely upon it: js2-refactor and xref-js2.

Emacs comes with a major mode for JavaScript named js-mode. While it is a good major mode, we’ll be using js2-mode instead, an external package that extends js-mode and provides a very interesting feature: instead of using regular expressions, it parses buffers and builds an AST for things like syntax highlighting. While diverging a bit from the traditional “Emacs way of doing things”, this is really interesting, and used as the foundation for other features like refactorings.

Setting up js2-mode

If you haven’t done it already, you should first setup package.el to use MELPA, then install and setup js2-mode like the following:

M-x package-install RET js2-mode RET
(require 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

;; Better imenu
(add-hook 'js2-mode-hook #'js2-imenu-extras-mode)

js2-refactor and xref-js2

Now that we’re using js2-mode for JavaScript buffers, let’s take advantage its capabilities of and install two other packages: js2-refactor and xref-js2.

js2-refactor adds powerful refactorings based on the AST generated by js2-mode, and xref-js2 makes it easy to jump to function references or definitions.

xref-js2 uses ag to perform searches, so you’ll need to install it as well.

M-x package-install RET js2-refactor RET
M-x package-install RET xref-js2 RET
(require 'js2-refactor)
(require 'xref-js2)

(add-hook 'js2-mode-hook #'js2-refactor-mode)
(js2r-add-keybindings-with-prefix "C-c C-r")
(define-key js2-mode-map (kbd "C-k") #'js2r-kill)

;; js-mode (which js2 is based on) binds "M-." which conflicts with xref, so
;; unbind it.
(define-key js-mode-map (kbd "M-.") nil)

(add-hook 'js2-mode-hook (lambda ()
  (add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t)))

Now that everything’s setup, let’s see how to use js2-refactor and xref-js2.

Using js2-refactor

js2-refactor is a JavaScript refactoring library for emacs.

It provides a collection of refactoring functions leveraging the AST provided by js2-mode.

Refactorings go from inlining/extracting variables to converting ternary operators to if statements. The README provides the full list of keybindings.

One minor tweak that I really couldn’t live without is binding js2r-kill to C-k in JS buffers:

(define-key js2-mode-map (kbd "C-k") #'js2r-kill)

This command is very similar to killing in paredit: It kills up to the end of the line, but always keeping the AST valid.

Here’s a usage example of js2-refactor: renaming a function parameter and inlining a variable.

Refactorings

Using xref-js2

xref-js2 adds support for quickly jumping to function definitions or references to JavaScript projects in Emacs (>= 25.1).

Instead of using a tag system, it relies on ag to query the codebase of a project.

  • M-. Jump to definition
  • M-? Jump to references
  • M-, Pop back to where M-. was last invoked.

Here’s a usage example of xref-js2:

Jumping to references

Until next time

You should now have a decent setup for js2-mode and associated tools.

We still have a lot to explore like linting, getting good auto-completion, using snippets, setting up a REPL and debugger, etc. but I promised I would keep posts short, so stay tuned for part #2!

-1:-- Setting up Emacs for JavaScript (part #1) (Post Nicolas Petton)--L0--C0--April 23, 2017 12:50 PM

emacspeak: Mail On The emacspeak Audio Desktop

Email On The Emacspeak Audio Desktop

1 Overview

This question comes up every few months on the emacspeak mailing
list. In general, see
Emacspeak Tools to quickly discover available speech-enabled
applications. This article outlines some of the available email setups
given the wide degree of variance in this space.


2 Background

How one puts together an email environment is a function of the
following:


  1. How email is retrieved.
  2. How email is stored (if storing locally).
  3. How email is sent.

Here is an overview of what is available as viewed from the world of
Linux in general and Emacs in particular:



2.1 Email Retrieval

Email can be retrieved in a number of ways:


  • IMap via Emacs This is implemented well in GNUS, and poorly in
    Emacs/VM. Note that Emacs is single-threaded, and fetching large
    volumes of email via IMap is painful.
  • Batch Retrieval: IMap Tools like fetchmail, offlineimap and friends that live
    outside of Emacs can be used to batch-retrieve email in the
    background. The retrieved mail gets delivered locally as in the past.
  • Mail Filtering: UNIX procmail enables filtering of locally
    delivered email into separate folders for automatically organizing
    incoming email.


2.2 Sending Email

Sending email involves:


  1. Composing email — typically invoked via key-sequence C-x m
    (command: compose-mail). Emacs email packages implement
    specific versions of this command, e.g. vm-mail from package
    emacs/vm, message-mail from the message package etc.
  2. Sending email: This is specific to the email provider being used,
    e.g., GMail. In the past, UNIX machines could talk SMTP to
    the Mail Gateway, but this has mostly disappeared over time. For
    an example of how to configure Emacs to send email via GMail
    using SMTP , see file tvr/gm-smtp.el in the emacspeak repository.



2.3 Local Storage Format

  • UNIX Mail: An email folder is a file of messages. This
    format is used by clients like Emacs/VM, UNIX Mail etc.
  • Maildir: A mail folder is a directory, with
    individual email messages living in files of their
    own. Sample clients include MH-E (UNIX MH), MU4E.
  • RMail This is Emacs' original email format.


3 Putting It All Together

The next sections show my present email setup put together using the
building blocks described above.


  1. I use Linux on all my machines, and Android on my phone.
  2. I mostly limit email usage on my phone to get a quick overview of email that might require immediate attention — toward this end, I have a to-mobile GMail label that collects urgent messages.
  3. Linux is where I handle email in volume.
  4. I use my Inbox as

my ToDo list — which means that I leave little or no email in my
Inbox unless I'm on vacation and disconnected from email.


3.1 Desktop: Batch Retrieval And Emacs/VM

This is the email setup on my workstation. See next section for the
email setup while mobile.


  1. I batch-retrieve email using fetchmail.
  2. This email gets filtered through procmail and auto-filed into
    several folders based on a set of procmail rules. Typical rules
    include separating out various email lists into their respective folders.
  3. Note that this does not preclude using IMap via GNUS to read
    email while online.
  4. Email that is not filtered into separate folders e.g. email that
    is sent directly to me, email regarding projects that need
    immediate attention etc., land up in folder ~/mbox.
  5. So when I launch emacs/vm on my desktop, the above is all I
    need to deal with at any given moment.
  6. I typically read Auto-filed mailing lists using emacs/vm about once a day or
    less — I use package mspools to get a quick overview of the
    state of those mail folders.

3.2 Mobile AccessOn Laptop: GNUS And IMap

See gnus-prepare.el for my gnus configuration for accessing GMail
via imap. That configuration is setup to access multiple GMail accounts.


  1. I see each GMail label as a separate group in GNUS.
  2. I only sync high-priority labels — this works well even
    over slow WIFI connections while on the road. As an example, the
    afore-mentioned to-mobile GMail label is a high-priority group.
  3. Module gm-nnir defines a GNUS/GMail extension that enables
    one to search GMail using GMail's search operators — that is my
    prefered means of quickly finding email messages using
    search. This is very fast since the search happens server-side,
    and only email headers are retrieved when displaying the search
    hits.
  4. Note that this solution is not laptop/mobile specific — I use
    this setup for searching GMail from my desktop as well.

3.3 Composing And Sending EMail

  1. I use compose-mail to compose email.
  2. I optionally activate orgtbl-mode and/or orgstruct-mode if
    editing structured content within the email body.
  3. I send email out using the setup in gm-smtp.el.

4 Conclusion

  1. Email in Linux/Emacs is composed of a set of
    independent building blocks — this gives maximal flexibility.
  2. That flexibility allows one to put together different email
    workflows depending on the connectivity environment in use.
-1:-- Mail On The emacspeak Audio Desktop (Post T. V. Raman (noreply@blogger.com))--L0--C0--April 23, 2017 03:19 AM

Emacs café: M-x hello-world

All blogs should begin with an introductory post, so here we go.

I’ve been willing to make a blog dedicated to Emacs for a long time, but until now I couldn’t find the right topic.

This blog will have a focus on using Emacs as an environment for writing JavaScript. I will talk about Emacs configurations specific to JavaScript and packages that make Emacs the great and powerful IDE that it is for web development.

I’ll try to keep all posts short and to the point, and I’ll most probably post tutorial videos from time to time.

Topics might sometimes slip a bit from the original focus, but as long as it’s about Emacs, I think it’ll be ok.

-1:-- M-x hello-world (Post Nicolas Petton)--L0--C0--April 21, 2017 09:14 PM

Phil Hagelberg: in which actors simulate a protocol

I've been on a bit of a yak shave recently on Bussard, my spaceflight programming adventure game. The game relies pretty heavily on simulating various computer systems, both onboard your craft and in various space stations, portal installations, and other craft you encounter. It naturally needs to simulate communications between all these.

I started with a pretty simple method of having each connection spin up its own coroutine running its own sandboxed session. Space station sessions run smash, a vaguely bash-like shell in a faux-unix, while connecting to a portal triggers a small lisp script to check for clearance and gradually activate the gateway sequence. The main loop would allow each session's coroutine a slice of time for each update tick, but a badly-behaved script could make the frame rate suffer. Also input and output was handled in a pretty ad-hoc method where Lua tables were used as channels to send strings to and from these session coroutines. But most problematic of all was the fact that there wasn't any uniformity or regularity in the implementations of the various sessions.

The next big feature I wanted to add was the ability to deploy rovers from your ship and SSH into them to control their movements or reprogram them. But I really didn't want to add a third half-baked session type; I needed all the different types to conform to a stricter interface. This required some rethinking.

The codebase is written primarily in Lua, but not just any Lua—it uses the LÖVE framework. While Lua's concurrency options are very limited, LÖVE offers true OS threads which run independently of each other. Now of course LÖVE can't magically change the semantics of Lua—these threads are technically in the same process but cannot communicate directly. All communication happens over channels which allow copies of data to be shared, but not actual state.

While these limitations could be annoying in some cases, they turn out to be a perfect fit for simulating communications between separate computer systems. Moving to threads allows for much more complex programs to run on stations, portals, rovers, etc without adversely affecting performance of the game.

Each world has a thread with a pair of input/output channels that gets started when you enter that world's star system. When a login succeeds, a thread is created for that specific session, which also gets its own stdin channel. Each OS can provide its own implementation of what a session thread looks like, but they all exchange stdin and stdout messages over channels. Interactive sessions will typically run a shell like smash or a repl and block on stdin:demand() which will wait until the main thread has some input to send along.

local new_session = function(username, password)
   if(not os.is_authorized(hostname, username, password)) then
      return output:push({op="status", out="Login failed."})
   end
   local session_id = utils.uuid()
   local stdin = love.thread.newChannel()
   sessions[session_id] = os.new_session(stdin, output, username, hostname)
   sessions[session_id].stdin = stdin
   output:push({op="status", ok=true, ["new-session"] = session_id})
   return true
end
-1:-- in which actors simulate a protocol (Post Phil Hagelberg)--L0--C0--April 21, 2017 07:48 PM

Got Emacs?: Emacs 25.2 Released

The bug fix version of Emacs 25.2 is released.  More information can be seen in the official announcement
-1:-- Emacs 25.2 Released (Post sivaram (noreply@blogger.com))--L0--C0--April 21, 2017 04:31 PM

Bryan Murdock: Avoiding Verilog's Non-determinism, Part 1

In my last post we looked at some example code that showed off Verilog's non-determinism. Here it is again (you can actually run it on multiple simulators here on EDA Playground):

module top;
   reg ready;
   integer result;

   initial begin
      #10;
      ready <= 1;
      result <= 5;
   end

   initial begin
      @(posedge ready);
      if(result == 5) begin
       $display("result was ready");
      end
      else begin
       $display("result was not ready");
      end
   end   
endmodule
Just to review from last time, the problem is that sometimes the @(posedge ready) will trigger before result has the value 5 and sometimes it will trigger after result has the value 5. We have called this non-determinism but a more common term for it is, race condition. There is a race between the values of ready and result making it to that second process (the second initial block). If result is updated first (wins the race) then everything runs as the writer of the code intended. If ready is updated first (wins the race) then the result will not actually be ready when the writer of the code intended.
Now the question is, is there a way to write this code so that there is no race condition? Well, first of all I surveyed my body of work on simulation-only code and didn't find very many uses of non-blocking assignments like that. The common advice in the Verilog world is to use non-blocking assignments in clocked always blocks not in "procedural" code like this. If we change the above to use blocking instead of non-blocking assignments, does that fix the problem? Here's what the new first initial block looks like:
   initial begin
      #10;
      ready = 1;
      result = 5;
   end
You can try it on EDA Playground and see that it still behaves the same as it did before except for with GPL Cver. With non-blocking assignments you get "result was not ready" with Cver and now you get "result was ready." That doesn't give me a lot of warm fuzzy feelings though. In fact, looking at that code makes me feel worse. If I'm thinking procedurally it looks totally backwards to set ready to one before assigning the value to result. My instinct would be to write the first initial block like this:
   initial begin
      #10;
      result = 5;
      ready = 1;
   end
Is that better for avoiding race conditions? If I take the explanation for why race-conditions exist in Verilog from Jan Decaluwe's VHDL's Crown Jewel post at face value, I think it actually is. That post explains that right after the first assignment (signal value update, if we use Jan's wording) in the first initial block Verilog could decide to trigger the second process (the second initial block). That case causes problems in the original code because the first assignment is to ready and result doesn't yet have its updated value. With the assignments re-ordered as above even if the second initial block is activated after the first assignment it will not try to read the value of result. It will just block waiting for a posedge ready (which will happen next). Race condition: eliminated. Here is the full fixed code example on EDA Playground.
Strangely enough, I spent the day yesterday debugging and fixing a race condition in our production testbench code here at work. It was very different from this one, so don't get too confident after reading this single blog post. I was able to boil the problem from yesterday down into another small example and so my next post will show off that code and how I eliminated that particular race.
UPDATE: As promised another example of a race condition.
-1:-- Avoiding Verilog's Non-determinism, Part 1 (Post Bryan (noreply@blogger.com))--L0--C0--April 19, 2017 05:51 PM

Bryan Murdock: Quick Thoughts on Creating Coding Standards

Introduction

No team says, "write your code however the heck you want." Unless you are coding alone, it generally helps to have an agreed upon coding standard. Agreeing upon a coding standard, however, can be a painful process full of heated arguments and hurt feelings. This morning I thought it might be useful to first categorize coding standard items before starting the arguments. My hope is that once we categorize coding standard items we can use better decision criteria for each category of items and cut down on arguing. Below are the categories I came up with really quickly with descriptions, examples, and decision criteria for each category. Feedback is welcome in the comments.

Categories of Things in Coding Standards

Language Specific Pitfalls

Characteristics​

  • not subjective, easy to recognize pattern
  • well recognized in the industry as dangerous
  • people have war stories and about these with associated scars to prove it

Examples

  • no multiple declarations on one line in C
  • Cliff Cummings rules for blocking vs. non-blocking assignments in Verilog
  • no willy nilly gotos in C
  • no omitting braces for one liner blocks (or begin-end in Verilog)
  • no compiler warnings allowed

How to resolve disputes on which of these should be in The Coding Standard?

Defer to engineers with best war stories. If nobody has a war story for one, you can probably omit it (or can you?).

General Readability/Maintainability

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." –Martin Fowler

Characteristics

  • things that help humans quickly read, understand, and safely modify code
  • usually not language specific
  • the path from these items to bugs is probably not as clear as with the above items, but a path does exist

Examples

  • no magic numbers
  • no single letter variable names
  • keep functions short
  • indicators in names (_t for typedef's, p for pointers, etc.)

How to resolve disputes on which of these should be in The Coding Standard?

If someone says, "this really helps me" then the team should suck it up and do it. This is essentially the "put the slowest hiker at the front of the group" principle.


Alternatively these can be discussed on a case by case basis during code reviews instead of being codified in The Coding Standard. Be prepared for more "lively" code reviews if you go this route.

Code Formatting

The biggest wars often erupt over these because they are so subjective. This doesn't have to be the case.

Characteristics

  • these probably aren't really preventing any bugs
  • most can easily be automatically corrected
  • are largely a matter of taste
  • only important for consistency (which is important!)

Examples

  • amount of indent
  • brace style
  • camelCase vs. underscore_names
  • 80 column rule
  • dare I even mention it? tabs vs. spaces

How to resolve disputes on which of these should be in The Coding Standard?

Don't spend a long time arguing about these. Because they are so subjective and not likely to cause or reduce bugs one way or the other, nobody should get bent out of shape if their preference is not chosen by the team. Give everyone two minutes to make their case for their favorite, have a vote, majority wins, end of discussion. Use an existing tool (astyle, autopep8, an emacs mode, whatever is available for the language) to help people follow these rules.
-1:-- Quick Thoughts on Creating Coding Standards (Post Bryan (noreply@blogger.com))--L0--C0--April 18, 2017 04:49 PM

sachachua: 2017-04-17 Emacs news

Links from reddit.com/r/emacs, /r/orgmode, /r/spacemacs, Hacker News, planet.emacsen.org, Youtube, the changes to the Emacs NEWS file, and emacs-devel.

Past Emacs News round-ups

-1:-- 2017-04-17 Emacs news (Post Sacha Chua)--L0--C0--April 17, 2017 05:55 AM

Matthias Pfeifer: Emacs symbolism

There are a couple of symbols the emacs‘ lisp interpreter gives special meaning to. Since for some reason these never made it into my long-term memory I collect them here for later reference. Quotes are copied from all over the internet (mostly from GNU Emacs Lisp reference). A reference is given in the last column. […]
-1:-- Emacs symbolism (Post Matthias)--L0--C0--April 12, 2017 12:49 PM

Pragmatic Emacs: Make Emacs a bit quieter

The minibuffer is the area at the bottom of your Emacs frame where you interact with Emacs prompts, or type commands. It also doubles up as the echo area, where Emacs tells you useful things. However sometimes when Emacs is prompting me for an answer in the minibuffer, the prompt is hidden by a message so I can’t see what I’m being asked any more.

When this happens, I found it is almost always a message about a buffer being reverted or a file being auto-saved. These messages can be prevented from appearing in the echo area as follows.

The revert messages are easy to silence with the following setting:

;; turn off auto revert messages
(setq auto-revert-verbose nil)

For the auto-save messages, it is a bit trickier. Some solutions suggest advising do-auto-save which is the function that does the actual job of auto-saving (e.g. this stackexchange question). However, this doesn’t work for Emacs 24.4 and newer since the call to do-auto-save bypasses the advice, for technical reasons I don’t fully understand!

A work around is to switch off the built-in auto-save, and replace it with our own silent version:

;; custom autosave to suppress messages
;;
;; For some reason `do-auto-save' doesn't work if called manually
;; after switching off the default autosave altogether. Instead set
;; to a long timeout so it is not called.
(setq auto-save-timeout 99999)

;; Set up my timer
(defvar bjm/auto-save-timer nil
  "Timer to run `bjm/auto-save-silent'")

;; Auto-save every 5 seconds of idle time
(defvar bjm/auto-save-interval 5
  "How often in seconds of idle time to auto-save with `bjm/auto-save-silent'")

;; Function to auto save files silently
(defun bjm/auto-save-silent ()
  "Auto-save all buffers silently"
  (interactive)
  (do-auto-save t))

;; Start new timer
(setq bjm/auto-save-timer
      (run-with-idle-timer 0 bjm/auto-save-interval 'bjm/auto-save-silent))

Note that I found some strange behaviour that do-auto-save does not work if the built-in auto-save is switched off altogether using (setq auto-save-default nil), so instead I had to set it for a long timeout to prevent it from running.

-1:-- Make Emacs a bit quieter (Post Ben Maughan)--L0--C0--April 10, 2017 06:22 AM

Marcin Borkowski: Quickly loading and finding your elisp files

This is a rather obvious hint – at least with hindsight – but someone might find it useful. If you’re like me, you may have a bunch of short elisp files with various small utilities you have written yourself in the past few years. For some reason, you may not want to load them at startup (maybe you want your Emacs to start as fast as posibble, maybe you don’t want to pollute the namespace with things that are only occasionally useful…).
-1:-- Quickly loading and finding your elisp files (Post)--L0--C0--April 09, 2017 12:58 PM

(or emacs: Ivy 0.9.0 is out

Intro

Ivy is a completion method that's similar to Ido, but with emphasis on simplicity and customizability.

Overview

The current release constitutes of 339 commits and almost a full year of progress since 0.8.0. Many issues ranging from #493 to #946 were fixed. The number of people who contributed code as grown to 63; thanks, everyone!

Details on changes

Changelog.org has been a part of the repository since 0.6.0, you can get the details of the current and past changes:

Highlights

Many improvements are incremental and don't require any extra code to enable. I'll go over a few selected features that require a bit of information to make a good use of them.

A better action choice interface

For all ivy completions, pressing M-o allows to execute one of the custom actions for the current command. Now you have an option to use hydra for selecting an action. Use this code to turn on the feature:

(require 'ivy-hydra)

One big advantage of the new interface is that you can peak at the action list with M-o without dismissing the candidate list. Press M-o again to go back to candidate selection without selecting an action.

Here's some code from my config that ensures that I always have some extra actions to choose from:

(defun ora-insert (x)
  (insert
   (if (stringp x)
       x
     (car x))))

(defun ora-kill-new (x)
  (kill-new
   (if (stringp x)
       x
     (car x))))

(ivy-set-actions
 t
 '(("i" ora-insert "insert")
   ("w" ora-kill-new "copy")))

Grepping

The new counsel-rg joins the group of grepping commands in counsel (counsel-ag, counsel-git-grep, counsel-grep, counsel-pt). It wraps around the newly popular and very fast ripgrep shell tool.

A nice improvement to the grepping commands is the ability to specify extra flags when you press C-u (universal-argument) before the command. See this gif for an example of excluding *.el from the files searched by ag.

counsel-find-file

  • Press M-o b to change the current directory to one of the virtual buffers' directories. You continue to select a file from that directory.

  • Press M-o r to find the current file as root.

counsel-git-log

You can now customize counsel-git-log-cmd. See #652 for using this to make counsel-git-log work on Windows.

counsel-mode

  • counsel-info-lookup-symbol now substitutes the built in info-lookup-symbol.
  • Pressing C-r while in the minibuffer of eval-expression or shell-command now gives you completion of your previous history.

counsel-yank-pop

Use the new counsel-yank-pop-separator variable to make counsel-yank-pop look like this.

ivy

There was breaking change for alist type collections some months ago. Right now the action functions receive an item from the collection, instead of (cdr item) like before. If anything breaks, the easy fix is to add an extra cdr to the action function.

Unique index for alist completion was added. The uniqueness assumption is that the completion system is passed a list of unique strings, of which one (or more) are selected. Unlike plain string completion, alists may require violating the uniqueness assumption: there may be two elements with the same car but different cdr. Example: C function declaration and definition for tag completion. Until now, whenever two equal strings were sent to ivy-read, only the first one could be selected. Now, each alist car gets an integer index assigned to it as a text property 'idx. So it's possible to differentiate two alist items with the same key.

Action functions don't require using with-ivy-window anymore. This allows for a lot of simplification, e.g. use insert instead of (lambda (x) (with-ivy-window (insert x))).

ivy-switch-buffer

You can now customize faces in ivy-switch-buffer by the mode of each buffer. Here's a snippet from my config:

(setq ivy-switch-buffer-faces-alist
      '((emacs-lisp-mode . swiper-match-face-1)
        (dired-mode . ivy-subdir)
        (org-mode . org-level-4)))

Looks neat, I think:

ivy-switch-buffer-faces-alist

swiper

Customize swiper-include-line-number-in-search if you'd like to match line numbers while using swiper.

New Commands

counsel-bookmark

Offers completion for bookmark-jump. Press M-o d to delete a bookmark and M-o e to edit it.

A custom option counsel-bookmark-avoid-dired, which is off by default, allows to continue completion for bookmarked directories. Turn it on with:

(setq counsel-bookmark-avoid-dired t)

and when you choose a bookmarked directory, the choice will be forwarded to counsel-find-file instead of opening a dired-mode buffer.

counsel-colors-emacs and counsel-colors-web

Completion for colors by name:

  • the default action inserts the color name.
  • M-o h inserts the color hex name.
  • M-o N copies the color name to the kill ring.
  • M-o H copies the color hex name to the kill ring.

The colors are displayed in the minibuffer, it looks really cool:

counsel-colors-emacs

You also get 108 shades of grey to choose from, for some reason.

counsel-faces

Completion for faces by name:

counsel-faces

counsel-command-history

Shows the history of the Emacs commands executed and lets you select and eval one again. See #826 for a nice screenshot.

counsel-company

Picks up company's candidates and inserts the result into the buffer.

counsel-dired-jump and counsel-file-jump

Jump to a directory or a file in the current directory.

counsel-dpkg and counsel-rpm

Wrap around the popular system package managers.

counsel-package

Install or uninstall Emacs packages with completion.

counsel-mark-ring

Navigate the current buffer's mark ring.

counsel-semantic

Navigate the current buffer's tags.

counsel-outline

Navigate the current buffer's outlines.

counsel-recentf

Completion for recentf.

counsel-find-library

Completion for find-library.

counsel-hydra-heads

Completion for the last hydra's heads.

counsel-org-agenda-headlines

Completion for headlines of files in your org-agenda-files.

Outro

Again, thanks to all the contributors. Happy hacking!

-1:-- Ivy 0.9.0 is out (Post)--L0--C0--April 08, 2017 10:00 PM

Marcin Borkowski: compilation-in-progress

I use AUCTeX pretty heavily; in fact, it was one of the first things I ever used in Emacs, way before I learned any Elisp or did any serious (or less serious) programming. Some time ago I noticed that sometimes (and I’m not sure what triggers this, though I have some suspicions) the word Compiling will stay in the modeline forever. It bugged me a bit, so I asked about it on the mailing list, and Oleh Krehel (of Ivy and Lispy fame) shared this simple solution: (setq compilation-in-progress nil). It’s not really a clean solution, but it works.
-1:-- compilation-in-progress (Post)--L0--C0--April 01, 2017 06:04 AM

Chris Wellons: My Journey with Touch Typing and Vim

Given the title, the publication date of this article is probably really confusing. This was deliberate.

Three weeks ago I made a conscious decision to improve my typing habits. You see, I had a dirty habit. Despite spending literally decades typing on a daily basis, I’ve been a weak typist. It wasn’t exactly finger pecking, nor did it require looking down at the keyboard as I typed, but rather a six-finger dance I developed organically over the years. My technique was optimized towards Emacs’ frequent use of CTRL and ALT combinations, avoiding most of the hand scrunching. It was fast enough to keep up with my thinking most of the time, but was ultimately limiting due to its poor accuracy. I was hitting the wrong keys far too often.

My prime motivation was to learn Vim — or, more specifically, to learn modal editing. Lots of people swear by it, including people whose opinions I hold in high regard. The modal editing community is without a doubt larger than the Emacs community, especially since, thanks to Viper and Evil, a subset of the Emacs community is also part of the modal editing community. There’s obviously something significantly valuable about it, and I wanted to understand what that was.

But I was a lousy typist who couldn’t hit the right keys often enough to make effective use of modal editing. I would need to learn touch typing first.

Touch typing

How would I learn? Well, the first search result for “online touch typing course” was Typing Club, so that’s what I went with. By the way, here’s my official review: “Good enough not to bother checking out the competition.” For a website it’s pretty much the ultimate compliment, but it’s not exactly the sort of thing you’d want to hear from your long-term partner.

My hard rule was that I would immediately abandon my old habits cold turkey. Poor typing is a bad habit just like smoking, minus the cancer and weakened sense of smell. It was vital that I unlearn all that old muscle memory. That included not just my six-finger dance, but also my NetHack muscle memory. NetHack uses “hjkl” for navigation just like Vim. The problem was that I’d spent a couple hundred hours in NetHack over the past decade with my index finger on “h”, not the proper home row location. It was disorienting to navigate around Vim initally, like riding a bicycle with inverted controls.

Based on reading other people’s accounts, I determined I’d need several days of introductory practice where I’d be utterly unproductive. I took a three-day weekend, starting my touch typing lessons on a Thursday evening. Boy, they weren’t kidding about it being slow going. It was a rough weekend. When checking in on my practice, my wife literally said she pitied me. Ouch.

By Monday I was at a level resembling a very slow touch typist. For the rest of the first week I followed all the lessons up through the number keys, never progressing past an exercise until I had exceeded the target speed with at least 90% accuracy. This was now enough to get me back on my feet for programming at a glacial, frustrating pace. Programming involves a lot more numbers and symbols than other kinds of typing, making that top row so important. For a programmer, it would probably be better for these lessons to be earlier in the series.

For that first week I mostly used Emacs while I was finding my feet (or finding my fingers?). That’s when I experienced first hand what all these non-Emacs people — people who I, until recently, considered to be unenlightened simpletons — had been complaining about all these years: Pressing CTRL and ALT key combinations from the home row is a real pain in in the ass! These complaints were suddenly making sense. I was already seeing the value of modal editing before I even started really learning Vim. It made me look forward to it even more.

During the second week of touch typing I went though Derek Wyatt’s Vim videos and learned my way around the :help system enough to bootstrap my Vim education. I then read through the user manual, practicing along the way. I’ll definitely have to pass through it a few more times to pick up all sorts of things that didn’t stick. This is one way that Emacs and Vim are a lot alike.

Update: Practical Vim: Edit Text at the Speed of Thought was recommended in the comments, and it’s certainly a better place to start than the Vim user manual. Unlike the manual, it’s opinionated and focuses on good habits, which is exactly what a newbie needs.

One of my rules when learning Vim was to resist the urge to remap keys. I’ve done it a lot with Emacs: “Hmm, that’s not very convenient. I’ll change it.” It means my Emacs configuration is fairly non-standard, and using Emacs without my configuration is like using an unfamiliar editor. This is both good and bad. The good is that I’ve truly changed Emacs to be my editor, suited just for me. The bad is that I’m extremely dependent on my configuration. What if there was a text editing emergency?

With Vim as a sort of secondary editor, I want to be able to fire it up unconfigured and continue to be nearly as productive. A pile of remappings would prohibit this. In my mind this is like a form of emergency preparedness. Other people stock up food and supplies. I’m preparing myself to sit at a strange machine without any of my configuration so that I can start the rewrite of the software lost in the disaster, so long as that machine has vi, cc, and make. If I can’t code in C, then what’s the point in surviving anyway?

The other reason is that I’m just learning. A different mapping might seem more appropriate, but what do I know at this point? It’s better to follow the beaten path at first, lest I form a bunch of bad habits again. Trust in the knowledge of the ancients.

Future directions

I am absolutely sticking with modal editing for the long term. I’m really enjoying it so far. At three weeks of touch typing and two weeks of modal editing, I’m around 80% caught back up with my old productivity speed, but this time I’ve got a lot more potential for improvement.

For now, Vim will continue taking over more and more of my text editing work. My last three articles were written in Vim. It’s really important to keep building proficiency. I still rely on Emacs for email and for syndication feeds, and that’s not changing any time soon. I also really like Magit as a Git interface. Plus I don’t want to abandon years of accumulated knowledge and leave the users of my various Emacs packages out to dry. Ultimately I believe will end up using Evil, to get what seems to be the best of both worlds: modal editing and Emacs’ rich extensibility.

-1:-- My Journey with Touch Typing and Vim (Post)--L0--C0--April 01, 2017 04:02 AM

Flickr tag 'emacs': GAMS-mode-Emacs-no1

shiro.takeda posted a photo:

GAMS-mode-Emacs-no1

-1:-- GAMS-mode-Emacs-no1 (Post shiro.takeda (nobody@flickr.com))--L0--C0--March 30, 2017 05:37 PM

Flickr tag 'emacs': GAMS-mode-Emacs-no2

shiro.takeda posted a photo:

GAMS-mode-Emacs-no2

-1:-- GAMS-mode-Emacs-no2 (Post shiro.takeda (nobody@flickr.com))--L0--C0--March 30, 2017 05:37 PM

Chen Bin (redguardtoo): Auto-complete word in Emacs mini-buffer when using Evil

When using Evil I often input %s/old-keyword/new-keyword/g in Minibuffer.

The problem is auto completions of new-keyword using hippie-expand always fail.

It turns out that the character "/" is treated as Word constituent in minibuffer.

The solution is to re-define "/" as Punctuation characters:

(defun minibuffer-inactive-mode-hook-setup ()
  ;; make `try-expand-dabbrev' from `hippie-expand' work in mini-buffer
  ;; @see `he-dabbrev-beg', so we need re-define syntax for '/'
  (set-syntax-table (let* ((table (make-syntax-table)))
                      (modify-syntax-entry ?/ "." table)
                      table)))
(add-hook 'minibuffer-inactive-mode-hook 'minibuffer-inactive-mode-hook-setup)
-1:-- Auto-complete word in Emacs mini-buffer when using Evil (Post Chen Bin)--L0--C0--March 28, 2017 12:16 PM

Chen Bin (redguardtoo): Indent JSX in Emacs

I find rjsx-mode annoying when it indents closed html tag with extra spaces.

It's based on js2-mode which is actually just calling Emacs v25 API js-jsx-indent-line.

So the solution is as simple as advice js-jsx-indent-line:

(defadvice js-jsx-indent-line (after js-jsx-indent-line-after-hack activate)
  "Workaround sgml-mode and follow airbnb component style."
  (let* ((cur-line (buffer-substring-no-properties
                    (line-beginning-position)
                    (line-end-position))))
    (if (string-match "^\\( +\\)\/?> *$" cur-line)
      (let* ((empty-spaces (match-string 1 cur-line)))
        (replace-regexp empty-spaces
                        (make-string (- (length empty-spaces) sgml-basic-offset) 32)
                        nil
                        (line-beginning-position) (line-end-position))))))
-1:-- Indent JSX in Emacs (Post Chen Bin)--L0--C0--March 28, 2017 11:54 AM

(or emacs: Using Emacs as a C++ IDE

Recently, I've had to code some C++ at work. And I saw it as a good opportunity to step up my Emacs' IDE game. I've eschewed clang-based tools until now, but GCC isn't adding AST support any time soon, and CEDET is too slow and too clumsy with macros for the particular project that I had. Here's the line in Eigen that broke the camel's back. Basically it's 30 lines of macros that expand to 30 lines of typedefs. Maybe it's a valid implementation choice, I'd rather avoid the macros altogether, but in any case I couldn't get CEDET to parse that.

Use Rtags for navigation

The first thing I tried was rtags. My project was CMake-based, so I just put this line in my subdirectory Makefile:

cmake:
    cd ../build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..

The -DCMAKE_EXPORT_COMPILE_COMMANDS=1 causes a compile_commands.json file to be emitted during the actual compilation. This file describes the compile flags for every source file. These flags are essential in helping the parser understand what's going on.

Then, in the build directory I start:

rdm & jc -J .

Finally, rtags-find-symbol-at-point should work now. I still like to use CEDET as backup, it's pretty good at tracking variables defined in the current function:

(defun ciao-goto-symbol ()
  (interactive)
  (deactivate-mark)
  (ring-insert find-tag-marker-ring (point-marker))
  (or (and (require 'rtags nil t)
           (rtags-find-symbol-at-point))
      (and (require 'semantic/ia)
           (condition-case nil
               (semantic-ia-fast-jump (point))
             (error nil)))))
(define-key c++-mode-map (kbd "M-.") 'ciao-goto-symbol)
(define-key c++-mode-map (kbd "M-,") 'pop-tag-mark)

For my other C++ projects which aren't CMake-based, I use the excellent bear tool to emit the compile_commands.json file. It's as easy as:

make clean
bear make

Use Irony for completion

It didn't take long to figure out that rtags isn't great at completion. I almost accepted that's just the way it is. But this morning I decided to make some changes and try irony-mode. And it worked beautifully for completion! What's ironic, is that irony-mode doesn't have goto-symbol, so the time spent to figure out rtags was worth it.

Here's my Irony setup; I only changed the C-M-i binding to the newly written counsel-irony, now available in the counsel package on MELPA:

(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)

(defun my-irony-mode-hook ()
  (define-key irony-mode-map
      [remap completion-at-point] 'counsel-irony)
  (define-key irony-mode-map
      [remap complete-symbol] 'counsel-irony))
(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)

And here are some screenshots of counsel-irony:

screenshot-1

First of all, the completion is displayed inline, similarly to modern IDEs. You can use all of Ivy's regex tricks to complete your candidate:

screenshot-2

Note how the power of regex matching allows me to narrow the initial 1622 candidates to only 22 functions that have src1 and src2 as arguments. One of the candidates is cut off for being longer than the window width. You can still match against the invisible text, but you won't see it. It's possible to use C-c C-o (ivy-occur) to store the current candidates into a buffer:

screenshot-3

Clicking the mouse on any of the lines in the new buffer will insert the appropriate symbol into the C++ buffer.

Outro

I'd like to thank the authors of rtags and irony-mode for these nice packages. Hopefully, counsel-irony is a nice addition. Happy hacking!

-1:-- Using Emacs as a C++ IDE (Post)--L0--C0--March 27, 2017 10:00 PM

Rubén Berenguel: The emacs 30 Day Challenge: Using 'gnus' to read mail


The gnus logo,
from gnus homepage
When the time to choose a mail reader for emacs came, as part of my emacs 30 Day Challenge, there were not really a lot of options. A long, long time ago I had tried vm (view mail) with no luck. I don't remember the details (it was something like 3 years ago), but the results where unappealing. The only contenders where gnus and wanderlust.

I managed to configure gnus pretty quickly: in only 30 minutes I had my gmail inbox working and was able to send mails through my main account. As an addition to gnus, I use bbdb to manage my contacts. You can read my post about bbdb and gnus integration.

I decided to give wanderlust a try, after reading a good review and configuration steps from emacs-fu. But had no luck (at least in my netbook), some kind of connectivity problem, probably due to some package which was not the correct version: wanderlust is very picky with what version of what package you have installed. I gave up and stood with gnus.

Installing and configuring gnus with gmail and multiple smtp accounts

If you have a recent emacs version, you'll have already gnus installed and you can start it with M-x gnus. But it is far better to configure it first. And it is far better to start by installing gnutls or starttls, depending on your system. You can do this with your package manager in Linux, or using fink or macports in Mac OS. This allows you to use SSL to connect to your mail servers. This is also a required step to use twittering.el (to be covered in a few days) and I guess it is also required (or should be required!) by jabber.el

I use gmail, together with several accounts from mostlymaths.net, and have configured my main account in gmail to be able to send mails through all my other accounts. Let's configure this. The following configuration is taken from the emacswiki with a few other tweaks from here and there. First C-x C-f ~/.gnus.el, and add the following lines, filling in your details
;; You need this to be able to list all labels in gmail
(setq gnus-ignored-newsgroups "")

;; And this to configure gmail imap
(setq gnus-select-method '(nnimap "gmail"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 993)
(nnimap-stream ssl)))

;; My version of gnus in my Mac does not handle html messages;; correctly (the one in the netbook does, I guess it is a different;; version). The following will chose plaintext every time this is;; possible.
(setq mm-discouraged-alternatives '("text/html" "text/richtext"))

;; Available SMTP accounts. The format is;; type of connection - account in the from field - smtp server -;; port - login name - password. You can leave the password field
;; as NIL and emacs will ask every time

(defvar smtp-accounts
'(
(ssl "mainaccount@gmail.com" "smtp.gmail.com"
587 "mainaccount@gmail.com" "yourpassword")
(ssl "mainaccount@mygoogleapps" "smtp.gmail.com"
587 "mainaccount@mygoogleapps" "otherpassword")
(ssl "workaccount@university" "smtp.gmail.com"
587 "mainaccount@gmail.com" "yourpassword") ))

;; Now lets configure smtpmail.el with your name and functions to send;; mail using your smtp accounts by changing the from field
(require 'smtpmail)
(setq send-mail-function 'smtpmail-send-it
message-send-mail-function 'smtpmail-send-it
mail-from-style nil user-full-name "Your name"
smtpmail-debug-info t smtpmail-debug-verb t)

(defun set-smtp (mech server port user password)
"Set related SMTP variables for supplied parameters."
(setq smtpmail-smtp-server server smtpmail-smtp-service port
smtpmail-auth-credentials (list (list server port user
password)) smtpmail-auth-supported (list mech)
smtpmail-starttls-credentials nil)
(message "Setting SMTP server to `%s:%s' for user `%s'."
server port user))

(defun set-smtp-ssl (server port user password &optional key
cert)
"Set related SMTP and SSL variables for supplied parameters."
(setq starttls-use-gnutls t
starttls-gnutls-program "gnutls-cli"
starttls-extra-arguments nil smtpmail-smtp-server server
smtpmail-smtp-service port
smtpmail-auth-credentials (list (list server port user
password)) smtpmail-starttls-credentials (list (list
server port key cert)))
(message
"Setting SMTP server to `%s:%s' for user `%s'. (SSL
enabled.)"
server port user))

(defun change-smtp ()
"Change the SMTP server according to the current from line."
(save-excursion
(loop with from = (save-restriction
(message-narrow-to-headers)
(message-fetch-field "from"))
for (auth-mech address . auth-spec) in smtp-accounts
when (string-match address from) do (cond
((memq auth-mech '(cram-md5 plain login))
(return (apply 'set-smtp (cons auth-mech auth-spec))))
((eql auth-mech 'ssl)
(return (apply 'set-smtp-ssl auth-spec)))
(t (error "Unrecognized SMTP auth. mechanism:
`
%s'." auth-mech))) finally (error "Cannot infer SMTP
information."
))))

;; The previous function will complain if you fill the from field with;; an account not present in smtp-accounts.
(defvar %smtpmail-via-smtp (symbol-function 'smtpmail-via-smtp))

(defun smtpmail-via-smtp (recipient smtpmail-text-buffer)
(with-current-buffer smtpmail-text-buffer
(change-smtp))
(funcall (symbol-value '%smtpmail-via-smtp) recipient
smtpmail-text-buffer))

;; This wraps send mail via smtp mail, to be able to send multiple;; messages with smtpmail.
Now, we can configure the authentication process. Open ~/.authinfo and fill it with the following data

machine imap.gmail.com login john_doe@gmail.com password notapassword port 993

If you don't like to store your passwords in plain text, you can either leave it blank (gnus will ask every time for your password) or use an encrypted authinfo file. I could not use this solution, as the emacs I have in my Mac has no encryption. But you can check it if you do!

Ready to use gnus! M-x gnus. After a few seconds of data processing, you should have a buffer named *Groups*. In gnus, you subscribe to groups, and the available groups should be your gmail labels. To subscribe to something, issue U followed by a double tab. This will show all the available labels. INBOX is the one you should not miss, of course.


gnus groups -> INBOX -> new mail

Once you have INBOX in your *Groups* buffer, you may need to update it for new mails. Pressing g will fetch new mails (or news) from the server. Pressing enter will open that group and show you your unread mails. If they don't appear in the INBOX buffer, it is somehow usual. If you had already checked and read your mail, fetch again in the *Groups* buffer and press enter, it takes you to the old INBOX buffer, without the new mails. Press M-g in it to fetch new headers and summaries. Pressing enter in your mails of course opens them.

Deleting mails, composing and replying

Now let's say you want to move a message to the Trash folder in your Gmail account, or your Spam folder. Scroll to your mail and press B m (Backend command + move). Now you can choose which folder, and if everything worked smoothly, you could press double tab and show all folders. If not, write [Gmail]/Trash. This is the correct gmail trash folder. Once you are done with operating with your mails in this way, press M-g to really do move them to the trash (and by the way, marking them in Gmail as read).

To quit gnus, in the groups buffer press q (or Q if you don't want to save "your progress"). In case of being lost... Please, use the menus: gnus has a menu for almost anything and they are quite descriptive. And more important, never leave gnus without properly q or Quitting. Also, in my netbook I can't suspend to RAM and then be able to re-start gnus. I have to q first. But in my Mac it works correctly.

We are almost done covering the simplest way to use gnus. Of course, we want to be able to write emails, or reply to mails we got! In the INBOX buffer, that would be r while reading or selecting a mail. To compose an email out in the cold, you can either use m in INBOX or *Groups* buffers. If you are in any buffer, you can compose an email with C-x m.

And if you use bbdb (the big brother database, a contact manager with automatic fetching of gnus data), which I will cover in the next writing, you can compose an email after searching for someone (M-x bbdb query and then m in the resulting search results buffer). You can read about basic use of bbdb in A glimpse of bbdb and gnus.

Searching your mail through imap

And another interesting thing would be to be able to search within your mail. To do so you will need the nnir package and add a line in the imap configuration.
;; To be able to search within your gmail/imap mail
(require 'nnir)

(setq gnus-select-method '(nnimap "gmail"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 993)
(nnimap-stream ssl))
(nnir-search-engine imap))
You should subscribe to [Gmail]/All mail, and then press G G to search within your mail. This is a little slow... But works.

I'm still fiddling with gnus, and learning to use it more effectively, but this can get you going with using it for reading your mail. If I learn something new along the way (or someone more used to gnus posts it here) I'll add it here or in a new gnus post.

If you enjoyed this, please share it with your emacs friends through Reddit, Hackernews or whatever you enjoy.

-1:-- The emacs 30 Day Challenge: Using 'gnus' to read mail (Post Rubén Berenguel (noreply@blogger.com))--L0--C0--March 21, 2017 05:43 PM

Raimon Grau: Browsing allegro lisp docs inside emacs

While programming, I love to read documentation using helm-dash. I've created quite a few docsets for apps/languages that lacked them in the official repos.

Currently I was using python, common lisp, Picolisp, and Redis, but I felt I was going too often to the franz's Allegro Lisp documentation site.  It's nice and loads fast, but it doesn't provide any useful search.

So I created a dash docset for Franz's Allegro Lisp.  As usual, it's in my github.

And here's a little gif I recorded to see how does it look.


-1:-- Browsing allegro lisp docs inside emacs (Post Raimon Grau (noreply@blogger.com))--L0--C0--March 20, 2017 05:05 PM

John Stevenson: Spacemacs - Managing Broken Emacs Packages

There is a great deal of development in Spacemacs and the wider Emacs community, especially around the new features of Emacs 26. So sometimes bugs appear in Emacs packages, but usually for not very long. Here is a simple guide to avoiding broken packages in your Spacemacs environment on the rare occasion that this happens.

One way to track bugs is to watch the Spacemacs Github repository. You can also join the Spacemacs discussions on Gitter.im

Rolling back a package update

I update Emacs packages at least 1 a month using the Update Packages link on the Spacemacs homepage. If one of the new versions of a packages contains a bug, then I perform a rollback using the Rollback Package Updates link.

Spacemacs - Home - Update Packages

Pinning a version for a known buggy package

If you know there is a bug with a specific package before you update all the packages, then you can add the name of that package to dotspacemacs-frozen-packages list.

You need to restart Spacemacs for the change to take effect, but afterwards you can update the rest of your packages without updating any of the frozen packages.

Rollback is not an option

If you can’t rollback, you can tell Spacemacs to install a working version of the broken package by adding it to spacemacs-additional-packages with a recipe.

For example, at the initial time of writing there was a bug in the smartparens package although this was quickly fixed.

To temporarily pin that package to a known good version, we would have added the following to spacemacs-additional-packages:

1
2
3
4
5
(smartparens
:location (recipe
:fetcher github
:repo "Fuco1/smartparens"
:commit "73b9dd0c70f381aee2da8c8b27f79019aa80dcae"))

This temporary fix is no longer need as the Smartparens package was quickly fixed by the author. Smartparens is only used as an example. Thank you.

Summary

We have discussed an easy way to manage broken Emacs packages with Spacemacs, so hopefully you can quickly fix any situation that may occur with packages.

If you do find any bugs in a package then you can also submit an issue or pull request to the relevant package so you wont need to manage frozen or additional packages for long.

My thanks and gratitude goes out to all the Spacemacs and Emacs maintainers and contributors who all make Emacs the best tool out there.

Thank you.
@jr0cket

-1:-- Spacemacs - Managing Broken Emacs Packages (Post)--L0--C0--March 13, 2017 09:05 AM

Manuel Uberti: Clojure it is

Last Friday I finally told my boss that I am going to leave his company for another job.

It’s not the first time in my working life that I want to move to greener pastures. For different reasons I changed jobs quite a lot in the last 10 years. However, this is the first time that I made my decision based on the programming language being used in the office.

As much as I had fun working with Java 8, in the last months there has been little of it. Bouncing back and forth between Java 7 and PHP 5.6 for legacy code maintenance is not exactly my idea of fun.

Both Clojure and functional programming changed the way I think about solving problems with code. I often found myself thinking outside the boundaries of OOP, craving for pure and higher-order functions, all of which are just out of reach in the afore mentioned versions of Java and PHP.

The adoption of Clojure by Italian software houses is still close to none. It’s been a while since I started looking for a job with Clojure, but until now the only opportunities I found required moving to another country. I even tried to convince myself I was willing to pack my bags again, but family comes first and deep in my heart I knew I couldn’t ask my wife to leave everything behind.

Imagine my shock when I heard that 7bridges was hiring. Marco Dalla Stella, CTO and Co–founder of the company, is basically the man who guided me through my first steps with Clojure. It was him, 2 years ago, who pointed me to Programming Clojure and The Joy of Clojure. It was him who joined me for a trip to Bologna where LambdaCon happened. He’s also an Emacs user, which means he must be one of the good guys.

And now I can’t wait to start working with Clojure for real. I celebrated the beginning of this new adventure with a new Dell XPS 13 which will surely be perfect for what I have in mind.

Eventually, Clojure it is.

-1:-- Clojure it is (Post)--L0--C0--March 12, 2017 12:00 AM

John Stevenson: Org-Mode Driven Presentations With Org-Reveal & Spacemacs

Creating web-based presentations has never been easier now that org-revel is just an option in the org layer for Spacemacs. By adding a variable to the org layer in the Spacemacs configuration and setting the location of Reveal.js on your file space you are ready to convert .org files into lovely presentations.

You can see examples of my presentations at http://jr0cket.co.uk/slides

If you have not used org-reveal before, see my previous articles on creating cool slides with Emacs Org-mode and Org-reveal, please note that article has an older configuration. If you have not experienced the amazing Org-mode, then see how to manage your developer life with this amazing tool.

Configure the Org layer

Open the ~/.spacemacs configuration file, SPC f e d (file, emacs, dotfile).

Search for the dotspacemacs-configuration-layers using SPC / (or just scroll down as its near the top of the file)

Now add org-enable-reveal-js-support t as a variable to the org layer, so your org layer entry looks as follows

1
2
(org :variables
org-enable-reveal-js-support t)

If you already have org-mode installed, then simply reload the ~/.spacemacs configuration with SPC f e R.

If this is the first time you are installing org-mode, or org-reveal does’t seem to work, I suggest restarting Spacemacs with SPC q r.

In my ~/.spacemacs configuration file I also have github support to create README files that display on Github repositories.

1
2
3
(org :variables
org-enable-github-support t
org-enable-reveal-js-support t)

Configure the location of Reveal.js

You can specify the location of Reveal.js in each .org file you write by using the variable REVEAL_ROOT. You can use a local directory on your file space or a content delivery network (for which you need to be online to convert your files)

1
#+REVEAL_ROOT: http://cdn.jsdelivr.net/reveal.js/3.0.0/

I prefer to use a local copy of Reveal.js. This does mean I need to download and update Reveal.js manually, however it means that do not need to include the REVEAL_ROOT in each .org file. Instead you need to set the (setq org-reveal-root "") in ``

I place the css, js, plugin and stylesheet directories into a folder that contains all my .org files, so I set an empty org-reveal-root as follows

1
(setq org-reveal-root "")

I deploy my slides on Github pages which does cache some artefacts, so hopefully it also caches org-reveal. I have never experienced any issues with speed browsing the slides.

Creating your slides

Create a new file with the file extension .org, for example my-awesome-presentation.org. You can add meta-data at the top for the title slide and all other slides are defined with a single *. Child slides, appearing underneath a parent slide are created with two * characters, ie. **

I have detailed how to create your first presentation with org-mode and org-reveal in my article entitled Creating Cool Slides With Emacs Org-Mode and Revealjs.

Creating (rendering) the Reveal.js slides

You can use the Org-export dispatcher to convert your .org file into a beautiful Reveal.js presentation:

Use C-c C-e to open the dispatcher menu, select R for the reveal section and R to render the .org file as an .html file of the same name.

Or use C-c C-e R B to render the .html file and open it in a new browser window.

Spacemacs Org-reveal - Org-export Dispatcher

If you prefer using the Spacemacs menu, you can use following commands to convert your .org file:

1
2
3
SPC SPC org-reveal-export-to-html
SPC SPC org-reveal-export-to-html-and-browse

Publishing the slides on Github

Github Pages are a great place for publishing your Reveal.js presentations or any static web content. For existing repositories you simply commit your content to a gh-pages branch or you can create a specific user or organisation repository and commit to the master branch.

I wrote about sharing your Revealjs slides on Github Pages previously, so I wont repeat myself here.

Thank you.
@jr0cket

-1:-- Org-Mode Driven Presentations With Org-Reveal &amp; Spacemacs (Post)--L0--C0--March 08, 2017 09:34 AM

emacsninja: Making Emacs More Presentable

I do occasionally hold talks, mostly about Lisp-related topics. My medium of choice is PDF, as generated by Org’s export with the Beamer backend. When it’s demonstration time, Emacs isn’t nearly as simple to adjust for comfortable viewing as a browser or terminal. My first instinct was to look for a function that allows increasing the font size, similar to C-+. It turns out that C-x C-+ is a thing, however it’s not ideal as it only increases the font size of the current buffer. A quick look at the sources reveals why:

(define-minor-mode text-scale-mode
  "..."
  :lighter (" " text-scale-mode-lighter)
  (when text-scale-mode-remapping
    (face-remap-remove-relative text-scale-mode-remapping))
  (setq text-scale-mode-lighter
        (format (if (>= text-scale-mode-amount 0) "+%d" "%d")
                text-scale-mode-amount))
  (setq text-scale-mode-remapping
        (and text-scale-mode
             (face-remap-add-relative 'default
                                          :height
                                          (expt text-scale-mode-step
                                                text-scale-mode-amount))))
  (force-window-update (current-buffer)))

text-scale-mode is implemented in terms of face-remap-add-relative, a function describing itself as “Add a face remapping entry of FACE to SPECS in the current buffer.”. Funnily enough, both live in face-remap.el, probably because scaling text is merely a demonstration of the buffer-local face remapping capabilities of Emacs. While it’s a cute demo, it’s clearly not what I’d want from a C-+ replacement, so I wrote an alternative solution operating on the frame:

(defun my-alter-frame-font-size (fn)
  (let* ((current-font-name (frame-parameter nil 'font))
         (decomposed-font-name (x-decompose-font-name current-font-name))
         (font-size (string-to-int (aref decomposed-font-name 5))))
    (aset decomposed-font-name 5 (int-to-string (funcall fn font-size)))
    (set-frame-font (x-compose-font-name decomposed-font-name))))

(defun my-inc-frame-font-size ()
  (interactive)
  (my-alter-frame-font-size '1+))

(defun my-dec-frame-font-size ()
  (interactive)
  (my-alter-frame-font-size '1-))

(global-set-key (kbd "C-+") 'my-inc-frame-font-size)
(global-set-key (kbd "C-=") 'my-inc-frame-font-size)
(global-set-key (kbd "C--") 'my-dec-frame-font-size)

This is a bit less hacky, but still disgusting. The code fetches the font name (which curiously comes in the XLFD notation) from the frame, converts it into an array, extracts the font size, manipulates it, puts it back into the array, converts it to a font name and sets the frame’s font to it. You can find this snippet and many more in my init.org, so if you haven’t already, give it a look to find more goodies!

-1:-- Making Emacs More Presentable (Post Vasilij Schneidermann)--L0--C0--March 05, 2017 12:32 PM