On this page:

It’s okay to clear the garden and start again

Around this time each year, with the heat of summer sending the lettuce to seed and sending us indoors, I usually fall out of love with gardening. I don’t feel like cooking, so the herbs go unharvested. The lettuce, spinach, and other greens bolt, going bitter and sending up more flowers than I can pinch off.

Having neglected to harvest as much as I could have, I tell myself I’ll just let them go to seed so that I can collect and replant those seeds. But then the garden becomes dry, overgrown, and scraggly, and slugs and other pests decimate the leaves. Only the tomatoes keep me interested throughout the season. If I’m lucky, I remember the rest of the garden in time to plant lettuce and peas for the fall.

This year, I’m trying something different. Seeds are inexpensive and plentiful. Instead of waiting for my lettuce to go to seed, I’ll simply pull them up and start new plants. This keeps the garden feeling more orderly, and gives me more sprouting to enjoy and look forward to. Maybe I’ll even walk to the florist at the corner and buy more seedlings to take advantage of the warmth and sun. Maybe beets or zucchini? I’m clearing a few squares at a time so that I can stagger the planting and keep things manageable. Perhaps the rest of the lettuce and the peas will have fully developed their seeds by the time I get around to pulling them up. I think this will be better than waiting for the whole box to finish. At least I’ll always have something on the go.

Someday, when I’m more of a gardener–perhaps when I have heirloom variants that are hard to find and easy to enjoy–I’ll look into saving seeds again. In the meantime, I’m still working on developing that summer-long habit of gardening, and I enjoy the exciting days of sprouting.

Where else in my life am I letting things go to seed unnecessarily? What else would benefit from pulling things up and starting fresh? Sewing, perhaps. I have a lot of scraps and patterns I haven’t looked at or used. Writing, too – lots of snippets and outlines that I haven’t fleshed out. Sometimes it’s good to clear things out and start again (perhaps with a smaller goal, perhaps with more deliberate attention). That way, the remnants of past decisions don’t weigh down enthusiasm.

How about your garden? How about your life?

Reflections on Aristotle, ends, and leisure

What are the ends I pursue, and how do I pursue them?

I agree with Aristotle in that my ultimate end is happiness. For me, happiness is more along the lines of equanimity or tranquility: being able to appreciate the good parts and being confident that I can weather the tough parts. From stoicism, I understand that things aren’t good or bad in themselves; it’s more about my responses to those things. So for me, a good life is one where I can respond as I want to and as I should.

More specifically, what would that good life look like, and what are the goals I want to strive towards?

One easy goal to plan for is a good financial foundation. It’s easier to act freely when you’re not worried about food or shelter. I also work on keeping frugal, moderate tastes and a detachment from things. “It’s just stuff,” W- and I say as we drop things off for donation or resist buying more things.

I value learning, too. I like feeling concepts click together, learning how to build more complex things. I particularly like it when I can use what I’m learning to save time, especially when I help other people avoid repetitive, mechanical work.

I enjoy learning and working the most when I can create something distinctive that takes advantage of an unusual combination of skills or experiences. For example, I like the social business consulting that I do because it’s uncommon for people to be interested in large organizations, collaboration, workflow, change management, data visualization, programming, and design. I enjoy working on Emacs or on self-tracking because both lend themselves well to idiosyncratic questions and personal curiosities.

I’ve been self-consciously writing about leisure for what feels like too many days now. I’m trying to figure out how I want to spend my time, since that’s a decision I’m going to make repeatedly over decades. My answers will change over the years, too, but if I think about it a little, I might be able to make better decisions.

Most of the time, we think of relaxation and recreation as ways to recharge ourselves so that we can get back to work with more energy. Aristotle prizes the contemplative life, where you use your leisure time not just to amuse yourself, but to improve.

What does that mean to me, though? For example, I could spend some time learning languages, or developing my drawing skills, or picking up a new technology. There’s so much more to learn about all sorts of other subjects. An easy answer to the question “What shall I do with my time?” might be to volunteer, but I would also want to do that with deliberation. What will help me grow, and what’s just a nice-to-have?

Let’s say that I don’t know enough to choose those topics from the beginning. How can I get better at observing myself and learning from how I use my leisure time? What would make a difference when I look back over a long life?

One of the things that has helped me a lot and that I’d like to get very good at is the ability to notice (as the Less Wrong community phrases it) that I am confused, and to explore that confusion. Reading helps me notice the gaps and find words to describe things, and writing helps me start to untangle the knots. If I keep getting better at this, then when I’m much more experienced, I might be able to spot opportunities for growth, catch myself before I make mistakes, and also help friends think through their own lives.

Learning various skills (tech, DIY, cooking) helps improve my self-efficacy. I can make more things myself, and I can imagine more things too. Besides, it’s fun, and occasionally economically useful.

I’m still not as keen on conversation and friendship as I probably should be, at least according to Aristotle. I enjoy conversations with W- most of all. I like the mix of practicality, growth, and whimsical puns. On occasion, I enjoy conversations with other people, especially those I think well of and want to support. Other times, I talk to people for variety and social exercise. I’m comfortable with that because I’m not trying to be popular, entertaining, or entertained. I don’t mind taking my time with the slow collection of interesting people I can learn from and help.

I can use my leisure time to learn how to prefer things that are good for me. For example, I’m working on that exercise habit. I’m sure that once I’ve gotten into the swing of things, I’ll be able to enjoy it – I just have to stick it out until then. I have much to learn about music, art, design, and literature, too.

I think a good life is one where I have the space, awareness, and control to respond to life the way I want to, and that I’ve learned to want what’s good for me. I’d like to be able to say, looking back, that I’ve deliberated on how I wanted to live and that I’ve lived pretty darn close to what I decided. We’ll just have to see how it all works out!

Weekly review: Week ending June 27, 2014

Blog posts

Sketches

I’m getting quite dreadful at this scanning-in thing. It’s probably because it’s so sunny out that I rarely want to go down to the basement these days… Perhaps tomorrow!

Link round-up

Focus areas and time review

  • Business (26.6h – 15%)
    • Earn (16.0h – 60% of Business)
      • E1: Attend meeting
      • Earn: E1: 2.5-3.5 days of consulting
    • Build (6.2h – 23% of Business)
      • Work on a 4clojure problem
      • Work on a 4clojure problem
      • Drawing (3.2h)
      • Delegation (0.0h)
      • Packaging (0.0h)
      • Paperwork (0.0h)
    • Connect (4.3h – 16% of Business)
  • Relationships (11.9h – 7%)
    • Pick up lead testing kit
    • Send claim correction along with note to insurance company
  • Discretionary – Productive (8.5h – 5%)
    • Emacs (0.0h – 0% of all)
      • Take notes on people who are interested in taking course, process course steps
    • Harvest more greens; clear out a square
    • Writing (3.5h)
  • Discretionary – Play (6.6h – 3%)
  • Personal routines (34.1h – 20%)
  • Unpaid work (9.5h – 5%)
  • Sleep (70.9h – 42% – average of 10.1 per day)

A long, long weekend

How do I want to spend my leisure time? I’ve been thinking about that a bit because we have a long weekend, and I have much more discretionary time during the week than most people do.

W- and I are both homebodies. During normal weekends, we typically spend a day focused on cooking, cleaning, washing clothes, and taking care of other little things around the house. That still leaves some time for walks, gardening, reading, writing, and watching the videos that we borrow from the library. During long weekends, we usually take advantage of the extra time and energy by working on household projects or doing a deeper clean. W- tends to work long hours, so when he’s not busy with work or gym classes, I prefer to spend the time with him instead of hanging out with other friends. Life is short, after all.

I also have some time during the week, when most people are busy working. I’ve been using that time to read, learn, exercise, and explore. From time to time, I hang out with friends. Last Friday, two of my friends were hanging out at a park, so I decided to join them. It was a leisurely afternoon of sunshine, idle conversation, and ice cream. In the evening, we watched a movie which turned out to be free because of projector issues.

I’m not always keen on conversation, so I don’t particularly like scheduling things and I can be reluctant to meet up or chat. If I can guiltlessly change plans – to wander in and out as I want – I feel much better about it.

Then there’s discretionary time when I’m alone, too. I usually spend this reading, coding, writing, or drawing. I’ve been feeling a little scattered lately. It’s hard to latch onto a question and follow it. Focusing on building habits around exercise and gardening seems to be helping, and exploring recipes is fun too. Fortunately, there’s a lot to keep making slow progress on while cultivating curiosity…

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 – [email protected]. 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?

This is the year I’m going to build an exercise habit

This year, I am going to become the sort of person who exercises regularly. I’m not particularly concerned about reaching a certain weight, but I’d like to improve my strength and endurance. W- is helping me ease into the learn-to-run program he did at work. I’m also starting from the first rung on the fitness ladder from The Hacker’s Diet. Small activities like these don’t take a lot of time, and the gradual progression will help me build confidence.

I’d also like to turn more exercise activities into ones that W- and I can share. Krav maga isn’t my cup of tea, but I think I’ll like jogging and walking with W-. We can stretch or do some weight-training while watching videos. Biking is fun, too.

What does making fitness part of me mean? I think it means being in tune with how things work, paying attention to the details and the changes. It’s probably like the way daily gardening has changed my experience of the backyard compared to when I dabbled in it. I’m looking forward to trying more things and learning more.

Identity is a big factor when it comes to maintaining good habits. When you make something part of who you are, it’s easier to keep doing it, and it’s harder to neglect it. Here are some of the other identity changes I’ve gone through:

  • I changed from someone who takes transit all the time to someone who bikes whenever she can.
  • I changed from someone who hated writing for school to someone who enjoys writing for this blog.
  • I changed from someone who grew up around household staff (cook, maids) to someone who cooks practically all her meals and takes care of her own chores.

I have the time, space, and support I need, and it’s good for me. I can see the results of good habits and the consequences of poor ones. And I’m going to do it without gym memberships or other things like that. We already have all the tools I need, so I just have to do it. =)