unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: emacs-devel <emacs-devel@gnu.org>
Subject: longlines-show-hard-newlines sets modified flag
Date: Mon, 26 Nov 2007 18:24:39 +0100	[thread overview]
Message-ID: <474B0157.2000800@gmx.at> (raw)

[-- 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

             reply	other threads:[~2007-11-26 17:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-26 17:24 martin rudalics [this message]
2007-11-26 19:22 ` longlines-show-hard-newlines sets modified flag 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=474B0157.2000800@gmx.at \
    --to=rudalics@gmx.at \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).