unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#342: kill-line sometimes unexpectedly kills invisible text
@ 2008-05-31 20:57 Felix -
  2008-06-01  8:26 ` martin rudalics
  0 siblings, 1 reply; 2+ messages in thread
From: Felix - @ 2008-05-31 20:57 UTC (permalink / raw)
  To: bug-gnu-emacs

emacs-version "22.2.1"

current line is visible,
next line is invisible,
I move to end of visible line,
then type ctrl-k.
I expect it to kill just the visible newline,
and sometimes it does that,
but sometimes it kills the invisible line too.

what's annoying is, it's inconsistent in an unobvious way.
the behavior depends on what's in the invisible text.

the underlying problem:
kill-line in that case uses forward-visible-line
to find the end of the kill region.

this code demonstrates the forward-visible-line problem:

(with-current-buffer (get-buffer-create "*test*")
  (add-to-invisibility-spec '(foo . t))

  (goto-char (point-max))
  (insert "\n t1: invis ends with newline: abc\n"
          (propertize "def\n ghi\n" 'invisible 'foo)
          "\n jkl\n")
  (search-backward "abc")
  (insert "[")
  (forward-visible-line 1)
  (insert "]")

  (goto-char (point-max))
  (insert "\n t2: invis doesn't end with newline: abc\n"
          (propertize "def\n ghi" 'invisible 'foo)
          "\n jkl\n")
  (search-backward "abc")
  (insert "[")
  (forward-visible-line 1)
  (insert "]")

  (pop-to-buffer (current-buffer))
  )

when I run that, my *test* buffer ends up looking like this:

 t1: invis ends with newline: [abc
...]
 jkl

 t2: invis doesn't end with newline: [abc
]...
 jkl

I don't really care whether it does t1 or t2,
I just want it to be consistently t1 or t2.







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

* bug#342: kill-line sometimes unexpectedly kills invisible text
  2008-05-31 20:57 bug#342: kill-line sometimes unexpectedly kills invisible text Felix -
@ 2008-06-01  8:26 ` martin rudalics
  0 siblings, 0 replies; 2+ messages in thread
From: martin rudalics @ 2008-06-01  8:26 UTC (permalink / raw)
  To: Felix -, 342; +Cc: bug-gnu-emacs

 > current line is visible,
 > next line is invisible,
 > I move to end of visible line,
 > then type ctrl-k.
 > I expect it to kill just the visible newline,
 > and sometimes it does that,
 > but sometimes it kills the invisible line too.
 >
 > what's annoying is, it's inconsistent in an unobvious way.
 > the behavior depends on what's in the invisible text.
 >
 > the underlying problem:
 > kill-line in that case uses forward-visible-line
 > to find the end of the kill region.

FWIW, your problem is caused by the

	      (unless (bolp)
		(goto-char opoint))))

checks in `forward-visible-line' which get you back to the position
before the invisible text if that text does not end in a newline as with
the t2 part of your code.  Hence the invisible text won't be killed for
t2.  In the t1 part the invisible region ends in a newline and kill-line
will kill it along with the visible text.

I think the behavior of Emacs is consistent here but maybe not very
intuitive.  On the other hand I'm quite confident that changing that
behavior will break something else :-(







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

end of thread, other threads:[~2008-06-01  8:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-31 20:57 bug#342: kill-line sometimes unexpectedly kills invisible text Felix -
2008-06-01  8:26 ` 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).