It has been more than four months since I wrote my article about leaving Emacs. This article will quickly speak about my journey.
First, I successfully left Emacs. Long story short, I like Emacs and think it’s a great piece of software, but I’m not comfortable being dependent of it for everything I do. I chose to replace all my Emacs usage by other software (agenda, notes taking , todo-list, IRC client, jabber client, editor etc..).
- agenda is not replaced by when (port productivity/when), but I plan to replace it by calendar(1) as it’s in base and that when doesn’t do much.
- todo-list: I now use taskwarrior + a kanban board (using kanboard) for team work
- notes: I wrote a small software named “notes” which is a wrapper for editing files and following edition using git. It’s available at git://bitreich.org/notes
- IRC: weechat (not better or worse than emacs circe)
- jabber: profanity
- editor: vim, ed or emacs, that depend what I do. Emacs is excellent for writing Lisp or Scheme code, while I prefer to use vim for most of edition task. I now use ed for small editions.
- mail: I wrote some kind of a wrapper on top of mblaze. I plan to share it someday.
I’m happy to have moved out from Emacs.
Today I will write about my current process of trying to get rid of emacs. I use it extensively with org-mode for taking notes and making them into a agenda/todo-list, this helped me a lot to remember tasks to do and what people told to me. I also use it for editing of course, any kind of text or source code. This is usually the editor I use for writing the blog articles that you can read here. This one is written using ed. I also read my emails in emacs with mu4e (which last version doesn’t work anymore on powerpc due to a c++14 feature used and no compiler available on powerpc to compile it…).
While I like Emacs, I never liked to use one big tool for everything. My current quest is to look for a portable and efficient way to replace differents emacs parts. I will not stop using Emacs if the replacements are not good enough to do the job.
So, I identified my Emacs uses:
- todo-list / agenda / taking notes
- writing code (perl, C, php, Common LISP)
- writing texts
- playing chess by mail
- jabber client
I will try for each topic to identify alternatives and challenge them to Emacs.
Todo-list / Agenda / Notes taking
This is the most important part of my emacs use and it is the one I would really like to get out of Emacs. What I need is: writing quickly a task, add a deadline to it, add explanations or a description to it, be able to add sub-tasks for a task and be able to display it correctly (like in order of deadline with days / hours before deadline).
I am trying to convert my current todo-list to taskwarrior, the learning curve is not easy but after spending one hour playing with it while reading the man page, I have understood enough to replace org-mode with it. I do not know if it will be as good as org-mode but only time will let us know.
By the way, I found vit, a ncurses front-end for taskwarrior.
Actually Emacs is a good editor. It supports syntax coloring, can evaluates regions of code (depend of the language), the editor is nice etc… I discovered jed which is a emacs-like editor written in C+libslang, it’s stable and light while providing more features than mg editor (available in OpenBSD base installation).
While I am currently playing with ed for some reasons (I will certainly write about it), I am not sure I could use it for writing a software from scratch.
There are lots of differents IRC clients around, I just need to pick up one.
I really enjoy using mu4e, I can find my mails easily with it, the query system is very powerful and interesting. I don’t know what I could use to replace it. I have been using alpine some times ago, and I tried mutt before mu4e and I did not like it. I have heard about some tools to manage a maildir folder using unix commands, maybe I should try this one. I did not any searches on this topic at the moment.
For writing plain text like my articles or for using $EDITOR for differents tasks, I think that ed will do the job perfectly :-) There is ONE feature I really like in Emacs but I think it’s really easy to recreate with a script, the function bind on M-q to wrap a text to the correct column numbers!
Update: meanwhile I wrote a little perl script using Text::Wrap module available in base Perl. It wraps to 70 columns. It could be extended to fill blanks or add a character for the first line of a paragraph.
#!/usr/bin/env perl use strict;use warnings; use Text::Wrap qw(wrap $columns); open IN, '<'.$ARGV; $columns = 70; my @file = <IN>; print wrap("","",@file);
This script does not modify the file itself though.
Some people pointed me that Perl was too much for this task. I have been told about Groff or Par to format my files.
Finally, I found a very BARE way to handle this. As I write my text with ed, I added an new alias named “ruled” with spawn ed with a prompt of 70 characters #, so I have a rule each time ed displays its prompt!!! :D
It looks like this for the last paragraph:
###################################################################### c been told about Groff or Par to format my files. Finally, I found a very **BARE** way to handle this. As I write my text with ed, I added an new alias named "ruled" with spawn ed with a prompt of 70 characters #, so I have a rule each time ed displays its prompt!!! :D . ###################################################################### w
Obviously, this way to proceed only works when writing the content at first. If I need to edit a paragraph, I will need a tool to format correctly my document again.
Using jabber inside Emacs is not a very good experience. I switched to profanity (featured some times ago on this blog).
Well, I stopped playing chess by mails, I am still waiting for my recipient to play his turn since two years now. We were exchanging the notation of the whole play in each mail, by adding our turn each time, I was doing the rendering in Emacs, but I do not remember exactly why but I had problems with this (replaying the string).
In my article about mu4e I said that I would write about sending mails with it. This will be the topic covered in this article.
There are a lot of ways to send mails with a lot of differents use cases. I will only cover a few of them, the documentation of mu4e and emacs are both very good, I will only give hints about some interestings setups.
I would thank Raphael who made me curious about differents ways of sending mails from mu4e and who pointed out some mu4e features I wasn’t aware of.
Send mails through your local server
The easiest way is to send mails through your local mail server (which should be OpenSMTPD by default if you are running OpenBSD). This only requires the following line to works in your ~/.emacs file:
(setq message-send-mail-function 'sendmail-send-it)
Basically, it would be only relayed to the recipient if your local mail is well configured, which is not the case for most servers. This requires a reverse DNS address correctly configured (assuming a static IP address), a SPF record in your DNS and a DKIM signing for outgoing mail. This is the minimum to be accepted to others SMTP servers. Usually people send mails from their personal computer and not from the mail server.
Configure OpenSMTPD to relay to another smtp server
We can bypass this problem by configuring our local SMTP server to relay our mails sent locally to another SMTP server using credentials for authentication.
This is pretty easy to set-up, by using the following /etc/mail/smtpd.conf configuration, just replace remoteserver by your server.
table aliases file:/etc/mail/aliases table secrets file:/etc/mail/secrets listen on lo0 accept for local alias <aliases> deliver to mbox accept for any relay via secure+auth://label@remoteserver:465 auth <secrets>
You will have to create the file /etc/mail/secrets and add your credentials for authentication on the SMTP server.
From smtpd.conf(5) man page, as root:
# touch /etc/mail/secrets # chmod 640 /etc/mail/secrets # chown root:_smtpd /etc/mail/secrets # echo "label username:password" > /etc/mail/secrets
Then, all mail sent from your computer will be relayed through your mail server. With ’sendmail-send-it, emacs will delivered the mail to your local server which will relay it to the outgoing SMTP server.
SMTP through SSH
One setup I like and I use is to relay the mails directly to the outgoing SMTP server, this requires no authentication except a SSH access to the remote server.
It requires the following emacs configuration in ~/.emacs:
(setq message-send-mail-function 'smtpmail-send-it smtpmail-smtp-server "localhost" smtpmail-smtp-service 2525)
The configuration tells emacs to connect to the SMTP server on localhost port 2525 to send the mails. Of course, no mail daemon runs on this port on the local machine, it requires the following ssh command to be able to send mails.
$ ssh -N -L 127.0.0.1:2525:127.0.0.1:25 remoteserver
This will bind the port 127.0.0.1:25 from the remote server point of view on your address 127.0.0.1:2525 from your computer point of view.
Your mail server should accept deliveries from local users of course.
SMTP authentication from emacs
It’s also possible to send mails from emacs using a regular smtp authentication directly from emacs. It is boring to setup, it requires putting credentials into a file named ~/.authinfo that it’s possible to encrypt using GPG but then it requires a wrapper to load it. It also requires to setup correctly the SMTP authentication. There are plenty of examples for this on the Internet, I don’t want to cover it.
Queuing mails for sending it later
Mu4e supports a very nice feature which is mail queueing from smtpmail emacs client. To enable it, it requires two easy steps:
(setq smtpmail-queue-mail t smtpmail-queue-dir "~/Mail/queue/cur")
In your shell:
$ mu mkdir ~/Mail/queue $ touch ~/Mail/queue/.noindex
Then, mu4e will be aware of the queueing, in the home screen of mu4e,
you will be able to switch from queuing to direct sending by pressing
m and flushing the queue by pressing
Note: there is a bug (not sure it’s really a bug). When sending a mail into the queue, if your mail contains special characters, you will be asked to send it raw or to add a header containing the encoding.
Hey ! You use stumpwm, emacs or tmux and your screen (not the GNU screen) split in lot of parts ? There is a solution to improve that. ZOOMING !
Each of them work with a screen divided into panes/windows (the meaning of theses words change between the program), sometime you want want to have the one where your work in fullscreen. An option exists in each of them to get fullscreen temporarly on a window.
Emacs: (not native)
This is not native in emacs, you will need to install
from your favorite repository.
Add the thoses lines in your ~/.emacs:
(require 'zoom-window) (global-set-key (kbd "C-x C-z") 'zoom-window-zoom)
Type C-x C-z to zoom/unzoom your current frame
Toogle zoom (in or out)
Add this to your ~/.stumpwmrc
(define-key *root-map* (kbd "z") "fullscreen")
Using “prefix z” the current window will toggle fullscreen.
In this article we will see how to fetch, read and manage your emails from Emacs using mu4e. The process is the following: mbsync command (while mbsync is the command name, the software name is isync) create a mirror of an imap account into a Maildir format on your filesystem. mu from mu4e will create a database from the Maildir directory using xapian library (full text search database), then mu4e (mu for emacs) is the GUI which queries xapian database to manipulates your mails.
Mu4e handles with dynamic bookmarks, so you can have some predefined filters instead of having classic folders. You can also do a query and reduce the results with successives queries.
You may have heard about using notmuch with emacs to manage mails, mu4e and notmuch doesn’t do the same job. While notmuch is a nice tool to find messages from queries and create filters, it operates as a read-only tool and can’t do anything with your mail. mu4e let you write mail, move, delete, flag etc… AND still allow to make complex queries.
I wrote this article to allow people to try mu4e quickly, you may want to read both isync and mu4e manual to have a better configuration suiting your needs.
On OpenBSD you need to install 2 packages:
# pkg_add mu4 isync
We need to configure isync to connect to the IMAP server:
Edit the file ~/.mbsyncrc, there is a trick to not have the password in clear text in the configuration file, see isync configuration manual for this:
iMAPAccount my_imap Host my_host_domain.info User imap_user Pass my_pass_in_clear_text SSLType IMAPS IMAPStore my_imap-remote Account my_imap MailDirStore my_imap-local Path ~/Maildir/my_imap/ Inbox ~/Maildir/my_imap/Inbox SubFolders Legacy channel my_imap Master :my_imap-remote: Slave :my_imap-local: Patterns * Create Slave Expunge Both
mu4e / emacs configuration
We need to configure mu4e in order to tell where to find the mail folder. Add this to your ~/.emacs file.
(require 'mu4e) (setq mu4e-maildir "~/Maildir/my_imap/" mu4e-sent-folder "/Sent Messages/" mu4e-trash-folder "/Trash" mu4e-drafts-folder "/Drafts")
A few commands are needed in order to make everything works. We need to create the base folder as mbsync command won’t do the job for some reason, and we need mu to index the mails the first time.
mbsync can takes a moment because it will download ALL your mails.
$ mkdir -p ~/Maildir/my_imap $ mbsync -aC $ mu index --maildir=~/Maildir/my_imap
How to use mu4e
start emacs, run M-x mu4e RET and enjoy, the documentation of mu4e is well done. Press “U” at mu4e screen to synchronize with imap server.
A query for mu4e looks like this:
list:misc.openbsd.org flag:unread avahi
This query will search mails having list header “misc.openbsd.org” and which are unread and which contains “avahi” pattern.
This one will looks for mails within date range of 1st january 2014 to 15th february 2015 containing word “urgent”.
The current setup doesn’t handle sending mails, I’ll write another article about this. This requires configuring a smtp authentification and an identify for mu4e.
Also, you may need to tweak mbsync configuration or mu4e configuration, some settings must be changed depending on the imap server, this is particuliarly important for deleted mails.
You want to fold (hide) code between brackets like an if statement, a function, a loop etc.. ? Use the HideShow minor-mode which is part of emacs. All you need is to enable hs-minor-mode. Now you can fold/unfold by cycling with C-c @ C-c.
If you are using emacs under Microsoft Windows and you want to edit remote files through SSH, it’s possible to do it without using Cygwin. Tramp can use the tool “plink” from putty tools to do ssh.
What you need is to get “plink.exe” from the following page and get it into your $PATH, or choose the installer which will install all putty tools.
Then, edit your emacs file to add the following lines to tell it that you want to use plink when using tramp
(require 'tramp) (set-default 'tramp-default-method "plink")
Now, you can edit your remote files, but you will need to type your password. I think that in order to get password-less with ssh keys, you would need to use putty key agent.
Since I upgraded to Emacs 25 it was no longer saving my last cursor position in edited file. This is a feature I really like because I often fire and close emacs rather than keeping it opened.
Before (< emacs 25)
(setq save-place-file "~/.emacs.d/saveplace") (setq-default save-place t) (require 'saveplace)
(save-place-mode t) (setq save-place-file "~/.emacs.d/saveplace") (setq-default save-place t)
That’s all :)
If you have an android Phone, here are two things you may like:
Org-mode <=> Android
First is the MobileOrg app to synchronize your calendar/tasks between your computer org-mode files and your phone. I am using org-mode since a few months, I think I do pretty basics things with it like having a todo list with a deadline for each item. Having it in my phone calendar is a good enhancement. I can also add todo items from my phone to show it on my computer.
The phone and your computer get synced by publishing a special format of org files for the mobile on a remote server. Mobile Org supports ssh, webdav, dropbox or sdcard. I’m using ssh because I own a server and I can reliabily have my things connected together there on a dedicated account. Emacs will then use tramp to publish/retrieve the files.
Read/Write sms from a remote place
Second useful thing I like with my android phone is being able to write and send sms (+ some others things but I was most interested by SMS) from my computer. A few services already exists but they work with “cloud” logic and I don’t want my phone to be connected to one more service. The MAXS app provides me what I need : ability to read/write the sms of my phone from the computer without web browser and relying on my own services. MAXS connects the phone to a XMPP account and you set a whitelist of XMPP mails able to send commands, that’s all. Here are a few examples of use:
To write a SMS I just need to speak to the jabber account of my phone and write
sms send firstname lastname hello how are you ?
Be careful, there are 2 spaces after the lastname ! I think it’s like this so MAXS can make easily the difference between the name and the message.
I can also reply quickly to the last contacted person
reply to Yes I'm answering from my computer
To read the last n sms
sms read n
It’s still not perfect because sometimes it lose connectivity and you can’t speak with it anymore but from the project author it’s not a problem seen on every phone. I did not have the time yet to report exactly the problem (I need to play with Android Debug Bridge for that). If you want to install MAXS, you will need a few app from the store to get it working. First, you will need MAXS main and MAXS transport (a plugin to use XMPP) and then plugins for the differents commands you want, so, maybe, smsread and smswrite. Check their website for more informations.
As presenter earlier on my website, I use profanity as XMPP client. It’s a light and easy to configure/use console client.
I switched to mu4e to manage my mails at work, and also to send mails. But in our corporation we all have a signature that include our logo and some hypertext links, so I couldn’t just insert my signature and be done with that. There is a simple way to deal with this problem, I fetched the html part of my signature (which include an image in base64) and pasted it into my emacs config file this way.
(setq mu4e-compose-signature "<#part type=text/html><html><body><p>Hello ! I am the html signature which can contains anything in html !</p></body></html><#/part>" )
I pasted my signature instead of the hello world text of course, but you only have to use the part tag and you are done ! The rest of your mails will be plain text, except this part.
Here is a dump of my emacs config file. That may be useful for some emacs users who begin.
If you doesn’t want to have your_filename.txt~ files with a tilde at the end (this is a default backup file), add this
; I don't want to have backup files everywhere with filename~ name (setq backup-inhibited t) (setq auto-save-default nil)
To have parenthesis highlighting on match, which is very useful, you will need this
; show match parenthesis (show-paren-mode 1)
I really like this one. It will save the cursor position in every file you edit. When you edit it again, you start exactly where you leaved the last time.
; keep the position of the cursor after editing (setq save-place-file "~/.emacs.d/saveplace") (setq-default save-place t) (require 'saveplace)`
If you write in utf–8 (which is very common now) you should add this.
; utf8 (prefer-coding-system 'utf-8)
Emacs modes are used depending on the extension of a file. Sometime you need to edit files with a custom extension but you want to use a mode for it. So, you just need to add some line like this to get your mode automatically when you load the file.
; associate extension - mode (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.tpl$" . html-mode))
My Org-mode part in the config file
(require 'org) (define-key global-map "\C-ca" 'org-agenda) (setq org-log-done t) (setq org-agenda-files (list "~/Org/work.org" "~/Org/home.org"))
Stop mixing tabs and space when indenting
(setq indent-tabs-mode nil)