Delete Org Markup Pairs

The other day I wrote about Bozhidar Batsov’s post on deleting paired delimiters in Emacs and mentioned that he included a bit of Elisp that—sort of—duplicated the behavior of Vim’s surround.vim. The idea is that if you are in a delimited expression and invoke the function, it will ask what delimiter you want to delete and will delete the closest enclosing pair. That obviously has some shortcomings such as not recognizing if one of the delimiters is in, say, a string. Still it’s handy code that does the right thing in most cases.

The code was interesting but I thought I didn’t need it because delete-pair already handled all the cases I was concerned with. As I was writing about Batsov’s post, I had something like =some text= and realized that I didn’t want it displayed in monospace after all. Since delete-pair was on my mind, I tried it but of course it didn’t work because = isn’t a delimiter that delete-pair recognizes so I deleted them by hand.

Later, I realized that I could simply add the Org markup pairs I was interested in to Batsov’s code so I did that and added it to my init.el. It worked perfectly and now I have an easy way of deleting Org markup .

It’s worth noting that Org mode gives you a way to do the opposite too: if you highlight some text and call org-empasize (Ctrl+c Ctrl+x Ctrl+f) it will add the Org markup you choose to the highlighted text.

Note

After I wrote this post, I found out about surround.el. More about that tomorrow.

This entry was posted in General and tagged , . Bookmark the permalink.