[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
longlines-show-hard-newlines sets modified flag
From: |
martin rudalics |
Subject: |
longlines-show-hard-newlines sets modified flag |
Date: |
Mon, 26 Nov 2007 18:24:39 +0100 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
longlines.el has a bug you can reproduce with Emacs -Q as follows:
(1) Visit an arbitrary file, for example, longlines.el
(2) M-x longlines-mode
(3) M-x longlines-show-hard-newlines
The buffer is considered modified. The reason for this bug is bad
handling of `buffer-modified-p' and `inhibit-modification-hooks' in the
associated functions. The attached patch should cure this. If no one
objects I'll install in a couple of days.
*** longlines.el.~1.40.~ Fri Nov 2 09:54:54 2007
--- longlines.el Mon Nov 26 17:55:26 2007
***************
*** 207,239 ****
"Make hard newlines visible by adding a face.
With optional argument ARG, make the hard newlines invisible again."
(interactive "P")
- (let ((buffer-undo-list t)
- (mod (buffer-modified-p)))
(if arg
(longlines-unshow-hard-newlines)
(setq longlines-showing t)
! (longlines-show-region (point-min) (point-max)))
! (set-buffer-modified-p mod)))
(defun longlines-show-region (beg end)
"Make hard newlines between BEG and END visible."
(let* ((pmin (min beg end))
(pmax (max beg end))
(pos (text-property-not-all pmin pmax 'hard nil))
! (inhibit-read-only t))
(while pos
(put-text-property pos (1+ pos) 'display
! (copy-sequence longlines-show-effect))
! (setq pos (text-property-not-all (1+ pos) pmax 'hard nil)))))
(defun longlines-unshow-hard-newlines ()
"Make hard newlines invisible again."
(interactive)
(setq longlines-showing nil)
! (let ((pos (text-property-not-all (point-min) (point-max) 'hard nil)))
(while pos
(remove-text-properties pos (1+ pos) '(display))
! (setq pos (text-property-not-all (1+ pos) (point-max) 'hard nil)))))
;; Wrapping the paragraphs.
--- 207,245 ----
"Make hard newlines visible by adding a face.
With optional argument ARG, make the hard newlines invisible again."
(interactive "P")
(if arg
(longlines-unshow-hard-newlines)
(setq longlines-showing t)
! (longlines-show-region (point-min) (point-max))))
(defun longlines-show-region (beg end)
"Make hard newlines between BEG and END visible."
(let* ((pmin (min beg end))
(pmax (max beg end))
(pos (text-property-not-all pmin pmax 'hard nil))
! (mod (buffer-modified-p))
! (buffer-undo-list t)
! (inhibit-read-only t)
! (inhibit-modification-hooks t))
(while pos
(put-text-property pos (1+ pos) 'display
! (copy-sequence longlines-show-effect))
! (setq pos (text-property-not-all (1+ pos) pmax 'hard nil)))
! (set-buffer-modified-p mod)))
(defun longlines-unshow-hard-newlines ()
"Make hard newlines invisible again."
(interactive)
(setq longlines-showing nil)
! (let ((pos (text-property-not-all (point-min) (point-max) 'hard nil))
! (mod (buffer-modified-p))
! (buffer-undo-list t)
! (inhibit-read-only t)
! (inhibit-modification-hooks t))
(while pos
(remove-text-properties pos (1+ pos) '(display))
! (setq pos (text-property-not-all (1+ pos) (point-max) 'hard nil)))
! (set-buffer-modified-p mod)))
;; Wrapping the paragraphs.
- longlines-show-hard-newlines sets modified flag,
martin rudalics <=