Skip to content

Instantly share code, notes, and snippets.

@heikkil
Created August 28, 2018 16:09
Show Gist options
  • Save heikkil/a3edf506046c84f6f508edbaf005810a to your computer and use it in GitHub Desktop.
Save heikkil/a3edf506046c84f6f508edbaf005810a to your computer and use it in GitHub Desktop.
Version of #'endless/fill-or-unfill and key bindings that work in org-mode
(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)))
(if (eq major-mode 'org-mode)
(call-interactively #' org-fill-paragraph)
(call-interactively #'fill-paragraph))))
(define-key org-mode-map (kbd "M-q") #'endless/fill-or-unfill)
(global-set-key [remap fill-paragraph] #'endless/fill-or-unfill)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment