[fill-paragraph](http://doc.endlessparentheses.com/Fun/fill-paragraph) is probably among the most underappreciated Emacs commands. I use it dozens of times a day, and never stop to think of just how awesome and practical it is. Still, we can make it a little bit better. Every once in a while I need to “unfill” (or “unwrap”) a paragraph that’s broken over many lines.
By being clever enough, we can make this into a free feature. There’s never any reason to hit M-q twice on the same paragraph, so we can use that as our keybind for the “unfill” command.
(defun endless/fill-or-unfill () "Like `fill-paragraph', but unfill if used twice." (interactive) (let ((fill-column (if (eq last-command 'endless/fill-or-unfill) (progn (setq this-command nil) (point-max)) fill-column))) (call-interactively #'fill-paragraph))) (global-set-key [remap fill-paragraph] #'endless/fill-or-unfill)
With this, M-q will act as a toggle. Hitting it once will do its usual thing (even if the paragraph is already filled), but hitting it twice will completely unwrap the current paragraph into a single line.
原文时间: 2016-05-31 08:00
整理时间: 2016-06-05 21:44
本文由 Hick 整理，转载请保留以上信息;
The articles on this site come from Internet, thanks to all the original authors.
If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .