Get the highlights in your inbox every week.
Use Emacs to get social and track your todo list | Opensource.com
Use Emacs to get social and track your todo list
Access Twitter, Reddit, chat, email, RSS, and your todo list in the nineteenth in our series on 20 ways to be more productive with open source in 2020.
Last year, I brought you 19 days of new (to you) productivity tools for 2019. This year, I'm taking a different approach: building an environment that will allow you to be more productive in the new year, using tools you may or may not already be using.
Doing (almost) all the things with Emacs, part 2
Yesterday, I talked about how to read email, access your addresses, and show calendars in Emacs. Emacs has tons and tons of functionality, and you can also use it for Twitter, chatting, to-do lists, and more!
To do all of this, you need to install some Emacs packages. As you did yesterday, open the Emacs package manager with Meta+x package-manager (Meta is Alt on most keyboards or Option on MacOS). Now select the following packages with i, then install them by typing x:
Once they are installed, open ~/.emacs.d/init.el with Ctrl+x Ctrl+x, and add the following before the (custom-set-variables line:
(setq todotxt-file (expand-file-name "~/.todo/todo.txt"))
(setq twittering-use-master-password t)
(setq twittering-icon-mode t)
;; Python3 for nnreddit
(setq elpy-rpc-python-command "python3")
Save the file with Ctrl+x Ctrl+a, exit Emacs with Ctrl+x Ctrl+c, then restart Emacs.
Tweet from Emacs with twittering-mode
Twittering-mode is one of the best Emacs interfaces for Twitter. It supports almost all the features of Twitter and has some easy-to-use keyboard shortcuts.To get started, type Meta+x twit to launch twittering-mode. It will give a URL to open—and prompt you to launch a browser with it if you want—so you can log in and get an authorization token. Copy and paste the token into Emacs, and your Twitter timeline should load. You can scroll with the Arrow keys, use Tab to move from item to item, and press Enter to view the URL the cursor is on. If the cursor is on a username, pressing Enter will open that timeline in a web browser. If you are on a tweet's text, pressing Enter will reply to that tweet. You can create a new tweet with u, retweet something with Ctrl+c+Enter, and send a direct message with d—the dialog it opens has instructions on how to send, cancel, and shorten URLs.
Pressing V will open a prompt to get to other timelines. To open your mentions, type :mentions. The home timeline is :home, and typing a username will take you to that user's timeline. Finally, pressing q will quit twittering-mode and close the window.
There is a lot more functionality available in twittering-mode, and I encourage you to read the full list on its GitHub page.
Track your to-do's in Emacs with Todotxt.el
To start it up, type Meta+x todotxt, and it will load the todo.txt file you specified in the todotxt-file variable (which you set in the first part of this article). Inside the buffer (window) for todo.txt, you can press a to add a new task and c to mark it complete. You can set priorities with r, and add projects and context to an item with t. When you are ready to move everything to done.txt, just press A. And you can filter the list with / or refresh back to the full list with l. And again, you can press q to exit.
Chat in Emacs with ERC
One of Vim's shortcomings is that trying to use chat with it is difficult (at best). Emacs, on the other hand, has the ERC client built into the default distribution. Start ERC with Meta+x erc, and you will be prompted for a server name, username, and password. You can use the same information you used a few days ago when you set up BitlBee: server localhost, port 6667, and the same username with no password. It should be the same as using almost any other IRC client. Each channel will be split into a new buffer (window), and you can switch between them with Ctrl+x Ctrl+b, which also switches between other buffers in Emacs. The /quit command will exit ERC.
Read email, Reddit, and RSS feeds with Gnus
I'm sure many long-time Emacs users were asking, "but what about Gnus?" yesterday when I was talking about reading mail in Emacs. And it's a valid question. Gnus is a mail and newsreader built into Emacs, although it doesn't support Notmuch as a mail reader, just as a search engine. However, if you are configuring it for Reddit and RSS feeds (as you'll do in a moment), it's smart to add in mail functionality as well.
Gnus was created for reading Usenet News and grew from there. So, a lot of its look and feel (and terminology) seem a lot like a Usenet newsreader.
Gnus has its own configuration file in ~/.gnus (the configuration can also be included in the main ~/.emacs.d/init.el). Open ~/.gnus with Ctrl+x Ctrl+f and add the following:
;; Required packages
;; Primary Mailbox
Save the file with Ctrl+x Ctrl+s. This tells Gnus to read mail from the local mailbox in ~/Maildir as the primary source (gnus-select-method) and add a second source (gnus-secondary-select-methods) using the nnreddit plugin. You can also define multiple secondary sources, including Usenet News (nntp), IMAP (nnimap), mbox (nnmbox), and virtual collections (nnvirtual). You can learn more about all the options in the Gnus manual.
Once you save the file, start Gnus with Meta+x gnus. The first run will install Reddit Terminal Viewer in a Python virtual environment, which is how it gets Reddit articles. It will then launch your browser to log into Reddit. After that, it will scan and load your subscribed Reddit groups. You will see a list of email folders with new mail and the list of subreddits with new content. Pressing Enter on any of them will load the list of messages for the group. You can navigate with the Arrow keys and press Enter to load and read a message. Pressing q will go back to the prior view when viewing message lists, and pressing q from the main window will exit Gnus. When reading a Reddit group, a creates a new message; in a mail group, m creates a new email; and r replies to messages in either view.
You can also add RSS feeds to the Gnus interface and read them like mail and newsgroups. To add an RSS feed, type G+R and fill in the RSS feed's URL. You will be prompted for the title and description of the feed, which should be auto-filled from the feed. Now type g to check for new messages (this checks for new messages in all groups). Reading a feed is like reading Reddit groups and mail, so it uses the same keys.
There is a lot of functionality in Gnus, and there are a whole lot more key combinations. The Gnus Reference Card lists all of them for each view (on five pages in very small type).
See your position with nyan-mode
As a final note, you might notice Nyan cat at the bottom of some of my screenshots. This is nyan-mode, which indicates where you are in a buffer, so it gets longer as you get closer to the bottom of a document or buffer. You can install it with the package manager and set it up with the following code in ~/.emacs.d/init.el:
;; Nyan Cat
(setq nyan-wavy-trail t)
(setq nyan-bar-length 20)
Scratching Emacs' surface
This is just scratching the surface of all the things you can do with Emacs. It is very powerful, and it is one of my go-to tools for being productive whether I'm tracking to-dos, reading and responding to mail, editing text, or chatting with my friends and co-workers. It takes a bit of getting used to, but once you do, it can become one of the most useful tools on your desktop.