使用 Emacs 进行社交并跟踪你的待办事项列表
Emacs

> 
> 在 2020 年用开源实现更高生产力的二十种方式的第十九篇文章中，访问 Twitter、Reddit、 交谈、电子邮件 、RSS 和你的待办事项列表。
> 
> 
> 


![](/data/attachment/album/202003/04/100911lg2vrv92692b422y.jpg)


去年，我在 19 天里给你介绍了 19 个新（对你而言）的生产力工具。今年，我换了一种方式：使用你在使用或者还没使用的工具，构建一个使你可以在新一年更加高效的环境。


### 使用 Emacs 做（几乎）所有的事情，第 2 部分


[昨天](/article-11932-1.html)，我谈到了如何在 Emacs 中读取电子邮件、访问电子邮件地址和显示日历。Emacs 功能繁多，你还可以将它用于 Twitter、交谈、待办事项列表等等！


![在 Emacs 中处理所有事情](/data/attachment/album/202003/04/100939ces7fy6vk2y7s2sh.png "All the things with Emacs")


要完成所有这些，你需要安装一些 Emacs 包。和昨天一样，用 `Meta+x package-manager` 打开 Emacs 包管理器（Meta 键在大多数键盘上是 `Alt`，在 MacOS 上是 `Option`）。然后通过 `i` 选择以下带有的软件包，然后输入 `x` 进行安装：



```
nnreddit
todotxt
twittering-mode
```

安装之后，按下 `Ctrl+x ctrl+f` 打开 `~/.emacs.d/init.el`，并在 `(custom-set-variables` 行前加上：



```
;; Todo.txt
(require 'todotxt)
(setq todotxt-file (expand-file-name "~/.todo/todo.txt"))

;; Twitter
(require 'twittering-mode)
(setq twittering-use-master-password t)
(setq twittering-icon-mode t)

;; Python3 for nnreddit
(setq elpy-rpc-python-command "python3")
```

按下 `Ctrl+x Ctrl+s` 保存文件，使用 `Ctrl+x Ctrl+c` 退出 Emacs，然后重启 Emacs。


#### 使用 twittering-mode 在 Emacs 中发推


![Emacs 中的 Twitter](/data/attachment/album/202003/04/101001tgajr7z5r5a6truj.png "Twitter in Emacs")


[Twittering-mode](https://github.com/hayamiz/twittering-mode) 是 Twitter 最好的 Emacs 接口之一。它几乎支持 Twitter 的所有功能，并且键盘快捷键也易于使用。


首先，输入 `Meta+x twit` 来启动 twittering-mode。它会提供一个 URL 并提示你启动浏览器来访问它，你登录该 URL 后就能获得授权令牌。将令牌复制并粘贴到 Emacs 中，你的 Twitter 时间线就会加载了。你可以使用箭头键滚动，使用 `Tab` 从一个项目移动到另一个项目，并按回车访问光标所在的 URL。如果光标在用户名上，按回车将在 web 浏览器中打开时间轴。如果你在一条推文的文本上，按回车将回复该推文。你可以用 `u` 创建一个新的推文，用 `Ctrl+c+Enter` 转发一些内容，然后用 `d` 发送一条即时消息——它打开的对话框中有关于如何发送、取消和缩短 URL 的说明。


按 `V` 会打开一个提示让你跳转到其他时间线。输入 `:mentions` 打开你的提及。输入 `:home` 打开你的主时间线，输入用户名将进入该用户的时间线。最后，按 `q` 会退出 twittering-mode 并关闭窗口。


twitter-mode 还有更多功能，我鼓励你阅读它 GitHub 页面上的[完整功能列表](https://github.com/hayamiz/twittering-mode#features)。


#### 在 Emacs 上使用 Todotxt.el 追踪你的待办事项


![Emacs 中的 todo.txt](/data/attachment/album/202003/04/101003aedzjsujs0k2sje0.png "todo.txt in emacs")


[Todotxt.el](https://github.com/rpdillon/todotxt.el) 是一个很棒的 [todo.txt](http://todotxt.org/) 待办列表管理器接口。它的快捷键几乎无所不包。


输入 `Meta+x todotxt` 启动它将加载 `todotxt-file` 变量中指定的 `todo.txt` 文件（本文的第一部分中设置了该文件）。在 `todo.txt` 的缓冲区（窗口），你可以按 `a` 添加新任务并和按 `c` 标记它已被完成。你还可以使用 `r` 设置优先级，并使用 `t` 添加项目和上下文。完成事项后只需要按下 `A` 即可将任务移如 `done.txt`。你可以使用 `/` 过滤列表，也可以使用 `l` 刷新完整列表。同样，你可以按 `q` 退出。


#### 在 Emacs 中使用 ERC 进行交谈


![使用 ERC 与人交谈 ](/data/attachment/album/202003/04/101022q7bjtzmbrjuj9jce.png "Chatting with erc")


Vim 的缺点之一是很难用它与人交谈。另一方面，Emacs 则将 [ERC](https://www.gnu.org/software/emacs/manual/html_mono/erc.html) 客户端内置到默认发行版中。使用 `Meta+x ERC` 启动 ERC，系统将提示你输入服务器、用户名和密码。你可以使用几天前介绍设置 [BitlBee](/article-11856-1.html) 时使用的相同信息：服务器为 `localhost`，端口为 `6667`，相同用户名，无需密码。


ERC 使用起来与其他 IRC 客户端一样。每个频道单独一个缓冲区（窗口），你可以使用 `Ctrl+x ctrl+b` 进行频道间切换，这也可以在 Emacs 中的其他缓冲区之间进行切换。`/quit` 命令将退出 ERC。


#### 使用 Gnus 阅读电子邮件，Reddit 和 RSS


![Mail，Reddit，and RSS feeds with Gnus](/data/attachment/album/202003/04/101042t8gt1phazatgfoaz.png "Mail, Reddit, and RSS feeds with Gnus")


我相信昨天在我提及在 Emacs 中阅读邮件时，许多 Emacs 的老用户会问，“怎么没有 [Gnus](https://www.gnus.org/) 呢？”


这个疑问很合理。Gnus 是一个内置在 Emacs 中的邮件和新闻阅读器，尽管它这个邮件阅读器不支持以 [Notmuch](/article-11807-1.html) 作为搜索引擎。但是，如果你将其配置来阅读 Reddit 和 RSS feed（稍后你将这样做），那么同时使用它来阅读邮件是个聪明的选择。


Gnus 是为阅读 Usenet 新闻而创建的，并从此发展而来。因此，它的很多外观和感觉（以及术语）看起来很像 Usenet 的新闻阅读器。


Gnus 以 `~/.gnus` 作为自己的配置文件。（该配置也可以包含在 `~/.emacs.d/init.el` 中）。使用 `Ctrl+x Ctrl+f` 打开 `~/.gnus`，并添加以下内容：



```
;; Required packages
(require 'nnir)
(require 'nnrss)

;; Primary Mailbox
(setq gnus-select-method
      '(nnmaildir "Local"
                  (directory "~/Maildir")
                  (nnir-search-engine notmuch)
      ))
(add-to-list 'gnus-secondary-select-methods
             '(nnreddit ""))
```

用 `Ctrl+x Ctrl+s` 保存文件。这分配置告诉 Gnus 从 `~/Maildir` 这个本地邮箱中读取邮件作为主源（参见 `gnus-select-method` 变量），并使用 [nnreddit](https://github.com/dickmao/nnreddit) 插件添加辅源（`gnus-secondary-select-methods` 变量）。你还可以定义多个辅助源，包括 Usenet 新闻（nntp）、IMAP （nnimap）、mbox（nnmbox）和虚拟集合（nnvirtual）。你可以在 [Gnus 手册](https://www.gnus.org/manual/gnus.html) 中了解更多有关所有选项的信息。


保存文件后，使用 `Meta+x Gnus` 启动 Gnus。第一次运行将在 Python 虚拟环境中安装 [Reddit 终端查看器](https://pypi.org/project/rtv/)，Gnus 通过它获取 Reddit 上的文章。然后它会启动浏览器来登录 Reddit。之后，它会扫描并加载你订阅的 Reddit 群组。你会看到一个有新邮件的邮件夹列表和一个有新内容的看板列表。在任一列表上按回车将加载该组中的消息列表。你可以使用箭头键导航并按回车加载和读取消息。在查看消息列表时，按 `q` 将返回到前一个视图，从主窗口按 `q` 将退出 Gnus。在阅读 Reddit 群组时，`a` 会创建一条新消息;在邮件组中，`m` 创建一个新的电子邮件;并且在任何一个视图中按 `r` 回复邮件。


你还可以向 Gnus 接口中添加 RSS 流，并像阅读邮件和新闻组一样阅读它们。要添加 RSS 流，输入 `G+R` 并填写 RSS 流的 URL。会有提示让你输入 RSS 的标题和描述，这些信息可以从流中提取出来并填充进去。现在输入 `g` 来检查新消息（这将检查所有组中的新消息）。阅读 RSS 流 就像阅读 Reddit 群组和邮件一样，它们使用相同的快捷键。


Gnus 中有*很多*功能，还有大量的键组合。[Gnus 参考卡](https://www.gnu.org/software/emacs/refcards/pdf/gnus-refcard.pdf)为每个视图列出了所有这些键组合（以非常小的字体显示在 5 页纸上）。


#### 使用 nyan-mode 查看位置


最后，你可能会一些截屏底部注意到 [Nyan cat](http://www.nyan.cat/)。这是 [nyan-mode](https://github.com/TeMPOraL/nyan-mode)，它指示了你在缓冲区中的位置，因此当你接近文档或缓冲区的底部时，它会变长。你可以使用包管理器安装它，并在 `~/.emacs.d/init.el` 中使用以下代码进行设置：



```
;; Nyan Cat
(setq nyan-wavy-trail t)
(setq nyan-bar-length 20)
(nyan-mode)
```

### Emacs 的基本功能


这只是 Emacs 所有功能的皮毛。Emacs *非常*强大，是我用来提高工作效率的必要工具之一，无论我是在追踪待办事项、阅读和回复邮件、编辑文本，还是与朋友和同事交流我都用它。这需要一点时间来适应，但是一旦你习惯了，它就会成为你桌面上最有用的工具之一。




---


via: <https://opensource.com/article/20/1/emacs-social-track-todo-list>


作者：[Kevin Sonney](https://opensource.com/users/ksonney) 选题：[lujun9972](https://github.com/lujun9972) 译者：[lujun9972](https://github.com/lujun9972) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
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](https://opensource.com/article/20/1/emacs-mail-calendar), 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!

![All the things with Emacs All the things with Emacs](https://opensource.com/sites/default/files/uploads/productivity_19-1.png)

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**:

```
nnreddit
todotxt
twittering-mode
```


Once they are installed, open **~/.emacs.d/init.el** with **Ctrl**+**x Ctrl**+**x**, and add the following before the **(custom-set-variables** line:

```
;; Todo.txt
(require 'todotxt)
(setq todotxt-file (expand-file-name "~/.todo/todo.txt"))
;; Twitter
(require 'twittering-mode)
(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

![Twitter in Emacs Twitter in Emacs](https://opensource.com/sites/default/files/uploads/productivity_19-2.png)

[Twittering-mode](https://github.com/hayamiz/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](https://github.com/hayamiz/twittering-mode#features) on its GitHub page.

### Track your to-do's in Emacs with Todotxt.el

![todo.txt in emacs todo.txt in emacs](https://opensource.com/sites/default/files/uploads/productivity_19-3.png)

[Todotxt.el](https://github.com/rpdillon/todotxt.el) is a nice interface for the [todo.txt](http://todotxt.org/) to-do list manager. It has hotkeys for just about everything.

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

![Chatting with erc Chatting with erc](https://opensource.com/sites/default/files/uploads/productivity_19-4.png)

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](https://www.gnu.org/software/emacs/manual/html_mono/erc.html) 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](https://opensource.com/article/20/1/open-source-chat-tool): 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

![Mail, Reddit, and RSS feeds with Gnus Mail, Reddit, and RSS feeds with Gnus](https://opensource.com/sites/default/files/uploads/productivity_19-5.png)

I'm sure many long-time Emacs users were asking, "but what about [Gnus](https://www.gnus.org/)?" 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](https://opensource.com/article/20/1/organize-email-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
(require 'nnir)
(require 'nnrss)
;; Primary Mailbox
(setq gnus-select-method
'(nnmaildir "Local"
(directory "~/Maildir")
(nnir-search-engine notmuch)
))
(add-to-list 'gnus-secondary-select-methods
'(nnreddit ""))
```


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](https://github.com/dickmao/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](https://www.gnus.org/manual/gnus.html).

Once you save the file, start Gnus with **Meta**+**x gnus**. The first run will install [Reddit Terminal Viewer](https://pypi.org/project/rtv/) 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](https://www.gnu.org/software/emacs/refcards/pdf/gnus-refcard.pdf) 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](http://www.nyan.cat/) at the bottom of some of my screenshots. This is [nyan-mode](https://github.com/TeMPOraL/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)
(nyan-mode)
```


## 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.

## 1 Comment