unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* longlines-show-hard-newlines sets modified flag
@ 2007-11-26 17:24 martin rudalics
  2007-11-26 19:22 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2007-11-26 17:24 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

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.

[-- Attachment #2: longlines.patch --]
[-- Type: text/plain, Size: 2777 bytes --]

*** 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.


[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-11-27 17:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-26 17:24 longlines-show-hard-newlines sets modified flag martin rudalics
2007-11-26 19:22 ` Stefan Monnier
2007-11-26 19:31   ` martin rudalics
2007-11-26 20:25     ` Stefan Monnier
2007-11-27 13:13       ` martin rudalics
2007-11-27 15:45         ` Stefan Monnier
2007-11-27 17:30           ` martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).