* 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
* Re: longlines-show-hard-newlines sets modified flag
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
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2007-11-26 19:22 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
> ! (set-buffer-modified-p mod)))
[...]
> ! (set-buffer-modified-p mod)))
Please use `restore-buffer-modified-p' here.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: longlines-show-hard-newlines sets modified flag
2007-11-26 19:22 ` Stefan Monnier
@ 2007-11-26 19:31 ` martin rudalics
2007-11-26 20:25 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2007-11-26 19:31 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
> Please use `restore-buffer-modified-p' here.
There are three more occurrences of this in longlines.el.
Replace them too?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: longlines-show-hard-newlines sets modified flag
2007-11-26 19:31 ` martin rudalics
@ 2007-11-26 20:25 ` Stefan Monnier
2007-11-27 13:13 ` martin rudalics
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2007-11-26 20:25 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
>> Please use `restore-buffer-modified-p' here.
> There are three more occurrences of this in longlines.el.
> Replace them too?
I guess so, yes. It avoids the `force-mode-line-update' that's implict
in set-buffer-modified-p.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: longlines-show-hard-newlines sets modified flag
2007-11-26 20:25 ` Stefan Monnier
@ 2007-11-27 13:13 ` martin rudalics
2007-11-27 15:45 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2007-11-27 13:13 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
> I guess so, yes. It avoids the `force-mode-line-update' that's implict
> in set-buffer-modified-p.
Then I'll rather leave them alone. Better see the new
line and coulmn numbers immediately ;-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: longlines-show-hard-newlines sets modified flag
2007-11-27 13:13 ` martin rudalics
@ 2007-11-27 15:45 ` Stefan Monnier
2007-11-27 17:30 ` martin rudalics
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2007-11-27 15:45 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
>> I guess so, yes. It avoids the `force-mode-line-update' that's implict
>> in set-buffer-modified-p.
> Then I'll rather leave them alone. Better see the new
> line and coulmn numbers immediately ;-)
Indeed, if you do want to update the mode-line, then you might as well
use set-buffer-modified-p, but then please add a short comment about it,
like
(set-buffer-modified-p mod) ; and update the mode line.
-- Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: longlines-show-hard-newlines sets modified flag
2007-11-27 15:45 ` Stefan Monnier
@ 2007-11-27 17:30 ` martin rudalics
0 siblings, 0 replies; 7+ messages in thread
From: martin rudalics @ 2007-11-27 17:30 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
> Indeed, if you do want to update the mode-line, then you might as well
> use set-buffer-modified-p, but then please add a short comment about it,
> like
>
> (set-buffer-modified-p mod) ; and update the mode line.
I was talking about the three remaining `set-buffer-modified-p's
in longlines.el. All these may add or remove newlines and thus
change line and/or column numbers. The two you bemoaned
initially will be changed to `restore-buffer-modified-p'.
^ 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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.