Subject: bug in add-text-properties

From: Werner LEMBERG <[email-masked]>
Date: Wed, 27 May 2009 07:26:38 +0200 (CEST)

[emacs CVS build 2009-05-13]

Steps to repeat the bug:

  0. Start `emacs -Q'.

  1. Load attached file `emacs-bug.txt' with `C-x C-f'.

  2. Load attached file `emacs-bug.el' with `load-file'.

  3. Say `M-x make-first-line-invisible'.

The first line properly disappears, however, the first character in
the now visible part of the buffer (the letter `a') makes problems: It
incorrectly refers to the character at buffer position 1 (the digit
`1').  In particular, `C-u C-x =' for letter `a' shows

---

        character: 1 (49, #o61, #x31)
preferred charset: ascii (ASCII (ISO646 IRV))
       code point: 0x31
           syntax: w 	which means: word
         category: .:Base, a:ASCII, l:Latin, r:Roman
      buffer code: #x31
        file code: #x31 (encoded by coding system undecided-unix)
          display: by this font (glyph code)
    xft:-unknown-DejaVu Sans Mono-normal-normal-normal-*-21-*-*-*-m-0-iso10646-1 (#x14)

Character code properties: customize what to show
  name: DIGIT ONE
  general-category: Nd (Number, Decimal Digit)

There are text properties here:
  intangible           t
  invisible            t

---

A side effect is that `C-a' no longer moves to the beginning of the
line.

    Werner
12345
abcde
(defun make-first-line-invisible ()
  (interactive)
  (goto-char (point-min))
  (setq start (line-beginning-position))
  (setq end (1+ (line-end-position))) ; handle \n
  (add-text-properties start
		       end
		       '(invisible t
			 intangible t)))