;;; longlines.el --- automatically wrap long lines
-;; Copyright (C) 2000, 2001, 2004, 2005 by Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc.
;; Authors: Kai Grossjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
;; Alex Schroeder <alex@gnu.org>
(add-to-list 'buffer-file-format 'longlines)
(add-hook 'change-major-mode-hook 'longlines-mode-off nil t)
(make-local-variable 'buffer-substring-filters)
+ (set (make-local-variable 'isearch-search-fun-function)
+ 'longlinges-search-function)
(add-to-list 'buffer-substring-filters 'longlines-encode-string)
(when longlines-wrap-follows-window-size
(set (make-local-variable 'fill-column)
(add-hook 'window-configuration-change-hook
'longlines-window-change-function nil t))
(let ((buffer-undo-list t)
+ (inhibit-read-only t)
(mod (buffer-modified-p)))
;; Turning off undo is OK since (spaces + newlines) is
;; conserved, except for a corner case in
(setq buffer-file-format (delete 'longlines buffer-file-format))
(if longlines-showing
(longlines-unshow-hard-newlines))
- (let ((buffer-undo-list t))
+ (let ((buffer-undo-list t)
+ (inhibit-read-only t))
(longlines-encode-region (point-min) (point-max)))
(remove-hook 'change-major-mode-hook 'longlines-mode-off t)
(remove-hook 'before-kill-functions 'longlines-encode-region t)
(remove-hook 'post-command-hook 'longlines-post-command-function t)
(remove-hook 'window-configuration-change-hook
'longlines-window-change-function t)
- (kill-local-variable 'fill-column)))
+ (when longlines-wrap-follows-window-size
+ (kill-local-variable 'fill-column))
+ (kill-local-variable 'isearch-search-fun-function)
+ (kill-local-variable 'require-final-newline)
+ (kill-local-variable 'buffer-substring-filters)
+ (kill-local-variable 'use-hard-newlines)))
(defun longlines-mode-off ()
"Turn off longlines mode.
(longlines-wrap-region (point-min) (point-max))
(set-buffer-modified-p mod))))
+;; Isearch
+
+(defun longlinges-search-function ()
+ (cond
+ (isearch-word
+ (if isearch-forward 'word-search-forward 'word-search-backward))
+ (isearch-regexp
+ (if isearch-forward 're-search-forward 're-search-backward))
+ (t
+ (if isearch-forward
+ 'longlines-search-forward
+ 'longlines-search-backward))))
+
+(defun longlines-search-forward (string &optional bound noerror count)
+ (let ((search-spaces-regexp "[ \n]+"))
+ (re-search-forward (regexp-quote string) bound noerror count)))
+
+(defun longlines-search-backward (string &optional bound noerror count)
+ (let ((search-spaces-regexp "[ \n]+"))
+ (re-search-backward (regexp-quote string) bound noerror count)))
+
;; Loading and saving
(add-to-list