├── flowed.png ├── non-flowed.png ├── hard-newline-in-buffer.png ├── README.org └── messages-are-flowing.el /flowed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/legoscia/messages-are-flowing/HEAD/flowed.png -------------------------------------------------------------------------------- /non-flowed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/legoscia/messages-are-flowing/HEAD/non-flowed.png -------------------------------------------------------------------------------- /hard-newline-in-buffer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/legoscia/messages-are-flowing/HEAD/hard-newline-in-buffer.png -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * =messages-are-flowing= 2 | 3 | If you're writing an email in Emacs, and the recipient reads it on 4 | their phone, chances are it's going to look like this: 5 | 6 | [[./non-flowed.png]] 7 | 8 | If you use =messages-are-flowing=, it will hopefully look like this instead: 9 | 10 | [[./flowed.png]] 11 | 12 | This works by distinguishing "hard" and "soft" newlines while writing 13 | the message. As shown in this screenshot, hard newlines are 14 | designated with "⏎": 15 | 16 | [[./hard-newline-in-buffer.png]] 17 | 18 | The "flowed" text format is described in [[https://tools.ietf.org/html/rfc2646][RFC 2646]]. 19 | 20 | ** How to use it 21 | 22 | Install =messages-are-flowing.el= with =M-x package-install-file=, and 23 | then add the following to your =.emacs= file: 24 | 25 | #+BEGIN_SRC emacs-lisp 26 | (add-hook 'message-mode-hook 'messages-are-flowing-use-and-mark-hard-newlines) 27 | #+END_SRC 28 | 29 | 30 | #+STARTUP: showall 31 | -------------------------------------------------------------------------------- /messages-are-flowing.el: -------------------------------------------------------------------------------- 1 | ;;; messages-are-flowing.el --- visible indication when composing "flowed" emails -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2017 Magnus Henoch 4 | 5 | ;; Author: Magnus Henoch 6 | ;; Keywords: mail 7 | ;; Version: 0.1 8 | 9 | ;; This program is free software; you can redistribute it and/or modify 10 | ;; it under the terms of the GNU General Public License as published by 11 | ;; the Free Software Foundation, either version 3 of the License, or 12 | ;; (at your option) any later version. 13 | 14 | ;; This program is distributed in the hope that it will be useful, 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ;; GNU General Public License for more details. 18 | 19 | ;; You should have received a copy of the GNU General Public License 20 | ;; along with this program. If not, see . 21 | 22 | ;;; Commentary: 23 | 24 | ;; If you're writing emails to people who might not view them on a 25 | ;; display with the same width as yours, you probably want to send the 26 | ;; messages as "flowed" (as per RFC 2646) in order to let the 27 | ;; recipient's device disregard the line breaks in your message and 28 | ;; rewrap the text for readability. In `message-mode', you can do 29 | ;; that by turning on the `use-hard-newlines' minor mode. 30 | ;; 31 | ;; However, you probably want some of your newlines to stay put, for 32 | ;; paragraph breaks, and for content where you really do want to break 33 | ;; the lines yourself. You can do that with `use-hard-newlines', but 34 | ;; it doesn't show you where it's going to put "hard" newlines and 35 | ;; where it's going to put "soft" ones. 36 | ;; 37 | ;; That's where `messages-are-flowing' comes in. It marks all "hard" 38 | ;; newlines with a `⏎' symbol, so that you can have an idea about what 39 | ;; parts of your message might be reflowed when the recipient reads it. 40 | ;; 41 | ;; To activate `messages-are-flowing', add the following to your .emacs: 42 | ;; 43 | ;; (with-eval-after-load "message" 44 | ;; (add-hook 'message-mode-hook 'messages-are-flowing-use-and-mark-hard-newlines)) 45 | 46 | ;;; Code: 47 | 48 | (defcustom messages-are-flowing-newline-marker "⏎" 49 | "String used to visualise hard newlines." 50 | :type 'string 51 | :group 'message-interface) 52 | 53 | ;;;###autoload 54 | (defun messages-are-flowing-use-and-mark-hard-newlines () 55 | "Turn on `use-hard-newlines', and make hard newlines visible. 56 | The main use of this is to send \"flowed\" email messages, where 57 | line breaks within paragraphs are adjusted by the recipient's 58 | device, such that messages remain readable on narrow displays." 59 | (interactive) 60 | (use-hard-newlines) 61 | (add-hook 'after-change-functions 'messages-are-flowing--mark-hard-newlines nil t)) 62 | 63 | (defun messages-are-flowing--mark-hard-newlines (beg end &rest _ignore) 64 | "Visibly mark hard newlines between BEG and END. 65 | For each hard newline, add a display property that makes it visible. 66 | For each soft newline, remove any display property." 67 | ;; Uncomment for debugging: 68 | ;;(interactive (list (point-min) (point-max))) 69 | (save-excursion 70 | (goto-char beg) 71 | (while (search-forward "\n" end t) 72 | (let ((pos (1- (point)))) 73 | (if (get-text-property pos 'hard) 74 | ;; Use `copy-sequence', because display property values must not be `eq'! 75 | (add-text-properties 76 | pos (1+ pos) 77 | (list 'display (copy-sequence 78 | (concat messages-are-flowing-newline-marker "\n")))) 79 | (remove-text-properties pos (1+ pos) '(display nil))))))) 80 | 81 | (provide 'messages-are-flowing) 82 | ;;; messages-are-flowing.el ends here 83 | --------------------------------------------------------------------------------