Function: longlines-mode

longlines-mode is an interactive and byte-compiled function defined in longlines.el.gz.

Signature

(longlines-mode &optional ARG)

Documentation

Toggle Long Lines mode in this buffer.

This is a minor mode. If called interactively, toggle the Longlines mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate longlines-mode(var)/longlines-mode(fun).

The mode's hook is called both when the mode is enabled and when it is disabled.

When Long Lines mode is enabled, long lines are wrapped if they extend beyond fill-column. The soft newlines used for line wrapping will not show up when the text is yanked or saved to disk.

If the variable longlines-auto-wrap(var)/longlines-auto-wrap(fun) is non-nil, lines are automatically wrapped whenever the buffer is changed. You can always call fill-paragraph to fill individual paragraphs.

If the variable longlines-show-hard-newlines(var)/longlines-show-hard-newlines(fun) is non-nil, hard newlines are indicated with a symbol.

Probably introduced at or before Emacs version 23.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/longlines.el.gz
;;;###autoload
(define-minor-mode longlines-mode
  "Toggle Long Lines mode in this buffer.

When Long Lines mode is enabled, long lines are wrapped if they
extend beyond `fill-column'.  The soft newlines used for line
wrapping will not show up when the text is yanked or saved to
disk.

If the variable `longlines-auto-wrap' is non-nil, lines are
automatically wrapped whenever the buffer is changed.  You can
always call `fill-paragraph' to fill individual paragraphs.

If the variable `longlines-show-hard-newlines' is non-nil, hard
newlines are indicated with a symbol."
  :lighter " ll"
  (if longlines-mode
      ;; Turn on longlines mode
      (progn
        (use-hard-newlines 1 'never)
        (set (make-local-variable 'require-final-newline) nil)
        (add-to-list 'buffer-file-format 'longlines)
        (add-hook 'change-major-mode-hook #'longlines-mode-off nil t)
	(add-hook 'before-revert-hook #'longlines-before-revert-hook nil t)
        (make-local-variable 'buffer-substring-filters)
        (make-local-variable 'longlines-auto-wrap)
	(set (make-local-variable 'isearch-search-fun-function)
	     #'longlines-search-function)
	(set (make-local-variable 'replace-search-function)
	     #'longlines-search-forward)
	(set (make-local-variable 'replace-re-search-function)
	     #'longlines-re-search-forward)
        (add-to-list 'buffer-substring-filters 'longlines-encode-string)
        (when longlines-wrap-follows-window-size
	  (let ((dw (if (and (integerp longlines-wrap-follows-window-size)
			     (>= longlines-wrap-follows-window-size 0)
			     (< longlines-wrap-follows-window-size
				(window-width)))
			longlines-wrap-follows-window-size
		      2)))
	    (set (make-local-variable 'fill-column)
		 (- (window-width) dw)))
          (add-hook 'window-configuration-change-hook
                    #'longlines-window-change-function nil t))
        (let ((buffer-undo-list t)
              (inhibit-read-only t)
	      (inhibit-modification-hooks t)
              (mod (buffer-modified-p))
	      buffer-file-name buffer-file-truename)
          ;; Turning off undo is OK since (spaces + newlines) is
          ;; conserved, except for a corner case in
          ;; longlines-wrap-lines that we'll never encounter from here
	  (save-restriction
	    (widen)
	    (unless longlines-decoded
	      (longlines-decode-buffer)
	      (setq longlines-decoded t))
	    (longlines-wrap-region (point-min) (point-max)))
          (set-buffer-modified-p mod))
        (when (and longlines-show-hard-newlines
                   (not longlines-showing))
          (longlines-show-hard-newlines))

	;; Hacks to make longlines play nice with various modes.
	(cond ((eq major-mode 'mail-mode)
	       (declare-function mail-indent-citation "sendmail" ())
	       (add-hook 'mail-setup-hook #'longlines-decode-buffer nil t)
	       (or mail-citation-hook
		   (add-hook 'mail-citation-hook #'mail-indent-citation nil t))
	       (add-hook 'mail-citation-hook #'longlines-decode-region nil t))
	      ((eq major-mode 'message-mode)
	       (add-hook 'message-setup-hook #'longlines-decode-buffer nil t)
	       (make-local-variable 'message-indent-citation-function)
	       (if (not (listp message-indent-citation-function))
		   (setq message-indent-citation-function
			 (list message-indent-citation-function)))
	       (add-hook 'message-indent-citation-function
			 #'longlines-decode-region t t)))

	(add-hook 'after-change-functions #'longlines-after-change-function nil t)
	(add-hook 'post-command-hook #'longlines-post-command-function nil t)
        (when longlines-auto-wrap
          (auto-fill-mode 0)))
    ;; Turn off longlines mode
    (setq buffer-file-format (delete 'longlines buffer-file-format))
    (if longlines-showing
        (longlines-unshow-hard-newlines))
    (let ((buffer-undo-list t)
	  (inhibit-modification-hooks t)
          (inhibit-read-only t)
	  buffer-file-name buffer-file-truename)
      (if longlines-decoded
	  (save-restriction
	    (widen)
	    (longlines-encode-region (point-min) (point-max))
	    (setq longlines-decoded nil))))
    (remove-hook 'change-major-mode-hook #'longlines-mode-off t)
    (remove-hook 'after-change-functions #'longlines-after-change-function t)
    (remove-hook 'post-command-hook #'longlines-post-command-function t)
    (remove-hook 'before-revert-hook #'longlines-before-revert-hook t)
    (remove-hook 'window-configuration-change-hook
                 #'longlines-window-change-function t)
    (when longlines-wrap-follows-window-size
      (kill-local-variable 'fill-column))
    (kill-local-variable 'isearch-search-fun-function)
    (kill-local-variable 'replace-search-function)
    (kill-local-variable 'replace-re-search-function)
    (kill-local-variable 'require-final-newline)
    (kill-local-variable 'buffer-substring-filters)
    (kill-local-variable 'use-hard-newlines)))