Category Archives: emacs

Reading these posts, you can probably tell that I really, really like the Emacs text editor.

View my Emacs configuration.

Check out Planet Emacsen to read other Emacs geeks’ blogs. For all things Emacs, check out the EmacsWiki.

New to Emacs? Start here:

Emacs kaizen: ace-jump-zap lets you use C-u to zap to any character

This entry is part of 2 in the series Emacs Kaizen

I’m perpetually using M-z to zap-to-char and then typing the character back in, because I really should be using zap-up-to-char instead. But if I’m going to get the hang of fiddling with my muscle memory so that I do things the Right Way, I might as well use this opportunity to practise using ace-jump-zap instead. The ace-jump-zap-up-to-char-dwim and ace-jump-zap-to-char-dwim functions behave like their normal equivalents, but if you C-u them, you get ace-jump type behaviour allowing you to quickly zap to any character you see. And since I mentally think of M-z as not including the character, I may as well map it so that M-z behaves that way.

Now I just have to remember that C-u does cool stuff…

(use-package ace-jump-zap
  :ensure ace-jump-zap
  :bind
  (("M-z" . ace-jump-zap-up-to-char-dwim)
   ("C-M-z" . ace-jump-zap-to-char-dwim)))

Emacs Hangout #3: Emacs can read your mind

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

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

Chat, links:

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

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

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

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

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

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

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

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

Emacs configuration and use-package

Watching the second Experimental Emacs Hangout nudged me to improve how I use use-package in my Emacs configuration.

I had been using use-package‘s :init and :config keywords as a more readable and less-error-prone versions of eval-after-load. (Well, technically, :init happens before it’s loaded, and :config is evaluated after it fully loads.) I also used :bind for global keybindings.

I didn’t know about :ensure and :diminish. Adding :ensure let me get rid of my custom sacha/package-install function, and :diminish let me remove a few lines related to my modeline.

One of the benefits of sharing my configuration is that other people pick up ideas, and then I pick up more ideas from their ideas. I get an excuse to revisit packages that may have added features since the last time I checked them out. I learn from other people’s combinations and customizations.

There’s so much to learn about Emacs, even just in terms of the packages that I’ve already configured. Sometimes I start with just the basics and settle into a routine, forgetting that there are even more things I can do. Sometimes people make incompatible changes, and I have to figure out how to adapt. Sometimes packages become unmaintained, and eventually replacements emerge. Always, always, people write more code, add more features, extend Emacs to do more things. It’s never just about what new things I can do. It’s also about this community of people who tickle their brains by building cool stuff, who follow “What if?” to interesting places.

Anyway. :ensure and :diminish, and a few improvements to my config. (Also because I just switched to the 64-bit binary for Emacs 24.4, how exciting…)

Hat-tip to @gozes for nudging me to write about this – back in April!

Emacs Chat: Karl Voit

Org Mode, Memacs, lazyblorg, .emacs, Yasnippet, tags . http://karl-voit.at , http://twitter.com/n0v0id , http://github.com/novoid.

Check out Karl’s notes for more details. (Or at least, you can check them out when his server is up again!)

Thanks, Karl!

Got an interesting Emacs workflow? Please share. =) Happy to bring on more people for Emacs Chats. Also, check out the upcoming Emacs Hangout on Dec 17 (8 PM Toronto)!

Check out TRANSCRIPT here!

How I can improve how I organize notes with Org Mode

Let me think about how I organize my Org Mode files, and how I might improve that. =)

Separate files

You can put different things in different files, of course. I use a few large Org files instead of lots of small ones because I prefer searching within files rather than searching within directories. Separate files make sense when I want to define org-custom-agenda-commands that summarize a subset of my tasks. No sense in going through all my files if I only want the cooking-related ones.

What would help me make better use of lots of files? I can practise on my book notes, which I’ve split up into one file per book. It’s easy enough to open files based on their titles (which I put in my filenames). But I don’t have that overall sense of it yet. Maybe #+INDEX: entries, if I can get them to generate multiple hyperlinks and I have a shortcut to quickly grep across multiple files (maybe with a few lines of context)? Maybe a manual outline, an index like the one I’ve been building for my blog posts? I can work with that as a starter, I think.

Okay. So, coming at it from several directions here:

  • A manual map based on an outline with lots of links, with some links between topics as well – similar to my blog outline or to my evil plans document
  • Quick way to grep? helm-do-grep works, but my long filenames are hard to read.
  • Links between notes and to blog posts
  • TODOs, agenda views

Outlines

Within each file, outlines work really well. You can create any number of headings by using *, and you can use TAB to collapse or expand headings. You can promote or demote subtrees, move them around, or even sort them.

I generally have a few high-level headings, like this:

* Projects
** One heading per current project
*** TODO Project task
* Reference
Information I need to keep track of
* Other notes
* Tasks
** TODO Lots of miscellaneous tasks go here
** TODO Lots of miscellaneous tasks go here
** TODO Lots of miscellaneous tasks go here

Every so often, I do some clean-up on my Org files, refiling or archiving headings as needed. This makes it easier to review my current list of projects. I keep this list separate from the grab-bag of miscellaneous tasks and notes that might not yet be related to particular projects.

I use org-refile with the C-u argument (so, C-u C-c C-w) to quickly jump to headings by typing in part of them. To make it easy to jump to the main headings in any of my agenda files, I set my org-refile-targets like this:

(setq org-refile-targets '((org-agenda-files . (:maxlevel . 6))))

How can I get better at organizing things with outlines? My writing workflow is a natural place to practise. I’ve accumulated lots of small ideas in my writing file, so if I work on fleshing those out even when I don’t have a lot of energy–breaking things down into points, and organizing several notes into larger chunks–that should help me become more used to outlines.

Tags

In addition to organizing notes in outlines, you can also use tags. Tags go on the ends of headings, like this:

** Heading title     :tag:another-tag:

You can filter headings by tags using M-x org-match-sparse-tree (C-c \) or M-x org-tags-view (C-c a m).

Tags are interesting as a way to search for or filter out combinations. I used tags a lot more before, when I was using them for GTD contexts. I don’t use them as much now, although I’ve started tagging recipes by main ingredient and cooking method. (Hmm, maybe I should try visualizing things as a table…) I also use tags to post entries under WordPress blog categories.

How can I get better at using tags? I can look for things that don’t lend themselves well to outlines, but have several dimensions that I may want to browse or search by. That’s probably going to be recipe management for now. If I figure out a neat way to add tags to my datetree journal notes and then visualize them, that might be cool too.

Links

Org Mode links allow me to refer not only to web pages, files, headings, and text searches, but to things like documentation or even executable code. When I find myself jumping between places a lot, I tend to build links so that I don’t have to remember what to jump to. My evil plans Org Mode file uses links to create and visualize structure, so that’s pretty cool, too. But there’s still a lot more that I could probably do with this.

How can I use links more effectively? I can link to more types of things, such as Lisp code. I can go back over my book notes and fill in the citation graph out of curiosity. Come to think of it, I could do that with my writing as well. My writing ideas rarely fit in neat outlines. I often feel like I’m combining multiple threads, and links could help me see those connections.

In addition to explicit links, I can also define “radio targets” that turn any instance of that text into a hyperlink back to that location. Only seems to work within a single file, though, and I’ve never actually used this feature for something yet.

Properties

You can set various properties for your Org Mode subtrees and then display those properties in columns or filter your subtrees by those properties. I’ve used Effort to keep track of effort estimates and I have some agenda commands that use that. I also use a custom Quantified property to make it easier to clock into tasks using my Quantified Awesome system.

I could track energy level as either tags or properties. Properties allow for easier sorting, I think. Can I define a custom sort order, or do I have to stick with numeric codes? Yeah, I can sort by a custom function, so I can come up with my own thing. Okay. That suggests a way I can learn to use properties more effectively.

There are even more ways to organize Org Mode notes in Emacs (agenda views, exports, etc.), but the ones above look like good things to focus on. So much to try and learn!